Mercurial > hg > octave-max
changeset 7509:e41d6aff83ea
fsolve: detect nonsquare systems
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 21 Feb 2008 03:04:27 -0500 |
parents | f501b22c0394 |
children | f3e6ada67d9e |
files | src/ChangeLog src/DLD-FUNCTIONS/fsolve.cc |
diffstat | 2 files changed, 11 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2008-02-21 John W. Eaton <jwe@octave.org> + + * DLD-FUNCTIONS/fsolve.cc (fsolve_user_jacobian): + Check dimensions of user-supplied Jacobian matrix. + (fsolve_user_function): Check for non-square systems. + 2008-02-20 John W. Eaton <jwe@octave.org> * data.cc (map_d_m, map_m_d, map_m_m, Fatan2, Ffmod):
--- a/src/DLD-FUNCTIONS/fsolve.cc +++ b/src/DLD-FUNCTIONS/fsolve.cc @@ -139,6 +139,8 @@ if (error_state || retval.length () <= 0) gripe_user_supplied_eval ("fsolve"); + else if (retval.length () != x.length ()) + error ("fsolve: unable to solve non-square systems"); } else gripe_user_supplied_eval ("fsolve"); @@ -188,6 +190,9 @@ if (error_state || retval.length () <= 0) gripe_user_supplied_eval ("fsolve"); + else if (! (retval.rows () == x.length () + && retval.columns () == x.length ())) + error ("fsolve: invalid Jacobian matrix dimensions"); } else gripe_user_supplied_eval ("fsolve");