comparison src/DLD-FUNCTIONS/chol.cc @ 14854:5ae9f0f77635

maint: Use Octave coding conventions for coddling parenthis is DLD-FUNCTIONS directory * __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc, __magick_read__.cc, besselj.cc, bsxfun.cc, ccolamd.cc, cellfun.cc, chol.cc, colamd.cc, daspk.cc, dasrt.cc, dassl.cc, dmperm.cc, fft.cc, filter.cc, find.cc, gcd.cc, kron.cc, lsode.cc, lu.cc, luinc.cc, quad.cc, quadcc.cc, rand.cc, regexp.cc, schur.cc, str2double.cc, symbfact.cc, symrcm.cc, tril.cc, urlwrite.cc: Use Octave coding conventions for coddling parenthis is DLD-FUNCTIONS directory.
author Rik <octave@nomad.inbox5.com>
date Mon, 09 Jul 2012 13:01:49 -0700
parents 460a3c6d8bf1
children
comparison
equal deleted inserted replaced
14853:72b8b39e12be 14854:5ae9f0f77635
370 return retval; 370 return retval;
371 } 371 }
372 372
373 /* 373 /*
374 %!assert (chol ([2, 1; 1, 1]), [sqrt(2), 1/sqrt(2); 0, 1/sqrt(2)], sqrt (eps)) 374 %!assert (chol ([2, 1; 1, 1]), [sqrt(2), 1/sqrt(2); 0, 1/sqrt(2)], sqrt (eps))
375 %!assert (chol (single([2, 1; 1, 1])), single([sqrt(2), 1/sqrt(2); 0, 1/sqrt(2)]), sqrt (eps ("single"))) 375 %!assert (chol (single ([2, 1; 1, 1])), single ([sqrt(2), 1/sqrt(2); 0, 1/sqrt(2)]), sqrt (eps ("single")))
376 376
377 %!error chol ()
377 %!error <matrix must be positive definite> chol ([1, 2; 3, 4]) 378 %!error <matrix must be positive definite> chol ([1, 2; 3, 4])
378 %!error <requires square matrix> chol ([1, 2; 3, 4; 5, 6]) 379 %!error <requires square matrix> chol ([1, 2; 3, 4; 5, 6])
379 %!error chol ()
380 %!error <unexpected second or third input> chol (1, 2) 380 %!error <unexpected second or third input> chol (1, 2)
381 */ 381 */
382 382
383 DEFUN_DLD (cholinv, args, , 383 DEFUN_DLD (cholinv, args, ,
384 "-*- texinfo -*-\n\ 384 "-*- texinfo -*-\n\
987 %! 0.63930 ; 987 %! 0.63930 ;
988 %! 3.31057 ; 988 %! 3.31057 ;
989 %! -0.13825 ; 989 %! -0.13825 ;
990 %! 0.45266 ]); 990 %! 0.45266 ]);
991 %! 991 %!
992 %! R = chol(single(A)); 992 %! R = chol (single (A));
993 %! 993 %!
994 %! j = 3; p = [1:j-1, j+1:5]; 994 %! j = 3; p = [1:j-1, j+1:5];
995 %! R1 = cholinsert (R, j, u2); 995 %! R1 = cholinsert (R, j, u2);
996 %! A1 = R1'*R1; 996 %! A1 = R1'*R1;
997 %! 997 %!
1181 return retval; 1181 return retval;
1182 } 1182 }
1183 1183
1184 /* 1184 /*
1185 %!test 1185 %!test
1186 %! R = chol(A); 1186 %! R = chol (A);
1187 %! 1187 %!
1188 %! j = 3; p = [1:j-1,j+1:4]; 1188 %! j = 3; p = [1:j-1,j+1:4];
1189 %! R1 = choldelete (R, j); 1189 %! R1 = choldelete (R, j);
1190 %! 1190 %!
1191 %! assert (norm (triu (R1)-R1, Inf), 0); 1191 %! assert (norm (triu (R1)-R1, Inf), 0);
1208 %! 1208 %!
1209 %! assert (norm (triu (R1)-R1, Inf), single (0)); 1209 %! assert (norm (triu (R1)-R1, Inf), single (0));
1210 %! assert (norm (R1'*R1 - single (A(p,p)), Inf) < 1e1*eps ("single")); 1210 %! assert (norm (R1'*R1 - single (A(p,p)), Inf) < 1e1*eps ("single"));
1211 1211
1212 %!test 1212 %!test
1213 %! R = chol(single(Ac)); 1213 %! R = chol (single (Ac));
1214 %! 1214 %!
1215 %! j = 3; p = [1:j-1,j+1:4]; 1215 %! j = 3; p = [1:j-1,j+1:4];
1216 %! R1 = choldelete(R,j); 1216 %! R1 = choldelete (R,j);
1217 %! 1217 %!
1218 %! assert (norm (triu (R1)-R1, Inf), single (0)); 1218 %! assert (norm (triu (R1)-R1, Inf), single (0));
1219 %! assert (norm (R1'*R1 - single (Ac(p,p)), Inf) < 1e1*eps ("single")); 1219 %! assert (norm (R1'*R1 - single (Ac(p,p)), Inf) < 1e1*eps ("single"));
1220 */ 1220 */
1221 1221
1333 %! assert (norm (R1'*R1 - A(p,p), Inf) < 1e1*eps); 1333 %! assert (norm (R1'*R1 - A(p,p), Inf) < 1e1*eps);
1334 %! 1334 %!
1335 %! j = 1; i = 3; p = [1:j-1, shift(j:i,+1), i+1:4]; 1335 %! j = 1; i = 3; p = [1:j-1, shift(j:i,+1), i+1:4];
1336 %! R1 = cholshift (R, i, j); 1336 %! R1 = cholshift (R, i, j);
1337 %! 1337 %!
1338 %! assert (norm(triu(R1)-R1, Inf), 0); 1338 %! assert (norm (triu (R1) - R1, Inf), 0);
1339 %! assert (norm(R1'*R1 - A(p,p), Inf) < 1e1*eps); 1339 %! assert (norm (R1'*R1 - A(p,p), Inf) < 1e1*eps);
1340 1340
1341 %!test 1341 %!test
1342 %! R = chol (Ac); 1342 %! R = chol (Ac);
1343 %! 1343 %!
1344 %! i = 1; j = 3; p = [1:i-1, shift(i:j,-1), j+1:4]; 1344 %! i = 1; j = 3; p = [1:i-1, shift(i:j,-1), j+1:4];