# HG changeset patch # User John W. Eaton # Date 1203581067 18000 # Node ID e41d6aff83ea636e51a41e059e6af969e5a1e5e6 # Parent f501b22c0394431eb83076f578d780be0d21770d fsolve: detect nonsquare systems diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2008-02-21 John W. Eaton + + * 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 * data.cc (map_d_m, map_m_d, map_m_m, Fatan2, Ffmod): diff --git a/src/DLD-FUNCTIONS/fsolve.cc b/src/DLD-FUNCTIONS/fsolve.cc --- 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");