Mercurial > hg > octave-lyh
diff src/xdiv.cc @ 3480:45742a3b1f7c
[project @ 2000-01-26 06:16:41 by jwe]
author | jwe |
---|---|
date | Wed, 26 Jan 2000 06:16:44 +0000 |
parents | 7a5a5da64756 |
children | 744755872311 |
line wrap: on
line diff
--- a/src/xdiv.cc +++ b/src/xdiv.cc @@ -33,22 +33,18 @@ #include "error.h" #include "xdiv.h" -static inline int -result_ok (int info, double rcond, int warn = 1) +static inline bool +result_ok (int info) { assert (info != -1); - if (info == -2) - { - if (warn) - warning ("matrix singular to machine precision, rcond = %g", rcond); - else - error ("matrix singular to machine precision, rcond = %g", rcond); + return (info != -2); +} - return 0; - } - else - return 1; +static void +solve_singularity_warning (double rcond) +{ + warning ("matrix singular to machine precision, rcond = %g", rcond); } template <class T1, class T2> @@ -128,8 +124,11 @@ if (btmp.rows () == btmp.columns ()) { double rcond = 0.0; - Matrix result = btmp.solve (atmp, info, rcond); - if (result_ok (info, rcond)) + + Matrix result + = btmp.solve (atmp, info, rcond, solve_singularity_warning); + + if (result_ok (info)) return Matrix (result.transpose ()); } @@ -153,8 +152,11 @@ if (btmp.rows () == btmp.columns ()) { double rcond = 0.0; - ComplexMatrix result = btmp.solve (atmp, info, rcond); - if (result_ok (info, rcond)) + + ComplexMatrix result + = btmp.solve (atmp, info, rcond, solve_singularity_warning); + + if (result_ok (info)) return result.hermitian (); } @@ -178,8 +180,11 @@ if (btmp.rows () == btmp.columns ()) { double rcond = 0.0; - ComplexMatrix result = btmp.solve (atmp, info, rcond); - if (result_ok (info, rcond)) + + ComplexMatrix result + = btmp.solve (atmp, info, rcond, solve_singularity_warning); + + if (result_ok (info)) return result.hermitian (); } @@ -203,8 +208,11 @@ if (btmp.rows () == btmp.columns ()) { double rcond = 0.0; - ComplexMatrix result = btmp.solve (atmp, info, rcond); - if (result_ok (info, rcond)) + + ComplexMatrix result + = btmp.solve (atmp, info, rcond, solve_singularity_warning); + + if (result_ok (info)) return result.hermitian (); } @@ -303,8 +311,11 @@ if (a.rows () == a.columns ()) { double rcond = 0.0; - Matrix result = a.solve (b, info, rcond); - if (result_ok (info, rcond)) + + Matrix result + = a.solve (b, info, rcond, solve_singularity_warning); + + if (result_ok (info)) return result; } @@ -323,8 +334,11 @@ if (a.rows () == a.columns ()) { double rcond = 0.0; - ComplexMatrix result = a.solve (b, info, rcond); - if (result_ok (info, rcond)) + + ComplexMatrix result + = a.solve (b, info, rcond, solve_singularity_warning); + + if (result_ok (info)) return result; } @@ -343,8 +357,11 @@ if (a.rows () == a.columns ()) { double rcond = 0.0; - ComplexMatrix result = a.solve (b, info, rcond); - if (result_ok (info, rcond)) + + ComplexMatrix result + = a.solve (b, info, rcond, solve_singularity_warning); + + if (result_ok (info)) return result; } @@ -363,8 +380,11 @@ if (a.rows () == a.columns ()) { double rcond = 0.0; - ComplexMatrix result = a.solve (b, info, rcond); - if (result_ok (info, rcond)) + + ComplexMatrix result + = a.solve (b, info, rcond, solve_singularity_warning); + + if (result_ok (info)) return result; }