Commit cbb505d7 authored by Morten Welinder's avatar Morten Welinder

Non-linar solver: fix crash.

parent fb3475d9
......@@ -14,6 +14,7 @@ Morten:
* Fix xls read crash. [#679992]
* Reduce code duplication for dependents.
* Make cells regular dependents.
* Fix non-linear solver crash. [#680719]
--------------------------------------------------------------------------
Gnumeric 1.11.5
......
2012-07-27 Morten Welinder <terra@gnome.org>
* gnm-nlsolve.c (rosenbrock_iter): Fix crash and marginally
improve precision.
2012-07-15 Morten Welinder <terra@gnome.org>
* Release 1.11.5
......
......@@ -536,10 +536,16 @@ rosenbrock_iter (GnmNlsolve *nl)
}
}
div = sqrt (t[0]);
for (i = 0; i < n; i++) {
nl->xi[0][i] = A[0][i] / div;
g_assert (gnm_finite (nl->xi[0][i]));
gnm_range_hypot (dx, n, &div);
if (div != 0) {
for (i = 0; i < n; i++) {
nl->xi[0][i] = A[0][i] / div;
if (!gnm_finite (nl->xi[0][i])) {
g_printerr ("%g %g %g\n",
div, A[0][i], nl->xi[0][i]);
g_assert (gnm_finite (nl->xi[0][i]));
}
}
}
/* ---------------------------------------- */
......
......@@ -26,6 +26,12 @@ gnm_range_count (G_GNUC_UNUSED gnm_float const *xs, int n, gnm_float *res)
int
gnm_range_hypot (gnm_float const *xs, int n, gnm_float *res)
{
/* Drop outside zeros because the n<=2 cases are more accurate. */
while (n > 0 && xs[0] == 0)
xs++, n--;
while (n > 0 && xs[n - 1] == 0)
n--;
switch (n) {
case 0: *res = 0; return 0;
case 1: *res = gnm_abs (xs[0]); return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment