90 onvec = zeros(size(vec));
95 for i=1:(size(vec,2)-1)
96 for j=(i+1):size(vec,2)
97 if isequal(vec(:,i),vec(:,j))
104 onvec = this.ortho_gs(vec);
106 onvec = this.ortho_qr(vec);
108 onvec = this.ortho_ch(vec);
122 #if 0 //mtoc++: 'set.G'
124 if ~isa(value,
" double ")
125 error("
G should be a
double matirx ");
134 #if 0 //mtoc++: 'set.Epsilon'
137 error(" value must be a positive real scalar. ");
146 #if 0 //mtoc++: 'set.Algorithm'
148 if ~any(strcmp(value,[
" gs " " qr " " ch "]))
149 error(" Invalid method: %s ",value);
159 function onvec = ortho_gs(vec) {
162 for i = 1:size(vec,2)
165 n = sqrt(onvec(:,i)^
t * this.
G * onvec(:,i));
169 onvec(:,i) = onvec(:,i)/n;
173 A_mult_onvec_i = this.
G*onvec(:,i);
176 coeffs= A_mult_onvec_i^
t * onvec(:,i+1:end);
179 coeffmat = onvec(:,i) * coeffs;
182 onvec(:,i+1:end) = onvec(:,i+1:end) - coeffmat;
186 nsqr = sum(onvec.^2);
187 onvec = onvec(:,nsqr > 0.1);
198 function onvec = ortho_qr(vec) {
200 error(
" Algorithm 'qr' not working. Need to check. ");
205 R_M = ichol(sparse(this.
G),
" inf ");
208 [Q, R, E]= qr(R_M * onvec, 0);
214 ind = find(abs(diag(R)) > this.
Epsilon);
215 onvec = onvec(:,ind);
217 onvec = onvec(:,ind) / Rind;
221 function onvec = ortho_ch(vec) {
223 error(
" Algorithm 'ch' not working. Need to check. ");
228 Gr = onvec^
t * this.
G * onvec;
229 Gr = 0.5* (Gr + Gr^
t);
241 R = full(ichol(sparse(Gr),options));
243 ind = find(diag(R) > this.
Epsilon);
244 onvec = onvec(:,ind);
249 norms = onvec^
t * this.
G * onvec;
250 onvec = onvec(:,abs(diag(norms)-1)<0.5);
260 d1 = d2 +
k*randi(10);
264 o = general.Orthonormalizer;
266 ov1 = o.orthonormalize(A);
273 res = res & isequal(round(ov1^
t*ov1),eye(d2));
274 res = res & abs(norm(ov1^
t*ov1)-1) < 1000*eps;
Epsilon
Tolerance for zero columns at orthogonalization.
static function res = test_Orthogonalization()
function onvec = orthonormalize(vec)
Performs orthogonalization using the given column vectors vec and the scalar product induced by the m...
Base class for any KerMor class.
G
The scalar product matrix .
Class that supports orthonormalization of vectors.
function res = isposrealscalar(value)
isposintscalar: Backwards-compatibility function for matlab versions greater than 2012a ...
Algorithm
The orthogonalization algorithm used.