[gnumeric] Solver: line search fix if we start from 0.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Solver: line search fix if we start from 0.
- Date: Wed, 6 May 2015 01:46:44 +0000 (UTC)
commit ee9550b07fea46ab629cceb120f93b3c805bb277
Author: Morten Welinder <terra gnome org>
Date: Tue May 5 21:45:56 2015 -0400
Solver: line search fix if we start from 0.
src/tools/gnm-solver.c | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/src/tools/gnm-solver.c b/src/tools/gnm-solver.c
index e6c0f25..846aa00 100644
--- a/src/tools/gnm-solver.c
+++ b/src/tools/gnm-solver.c
@@ -2656,17 +2656,22 @@ cb_polish_iter (GnmSolverIterator *iter, GnmIterSolver *isol)
dir = g_new0 (gnm_float, n);
for (c = 0; c < n; c++) {
- gnm_float s, y, s0, xc = isol->xk[c];
- int e;
+ gnm_float s, y, s0, sm, xc = isol->xk[c];
- (void)gnm_frexp (xc, &e);
- s0 = gnm_ldexp (1, e - 10);
- if (s0 == 0) s0 = GNM_MIN;
+ if (xc == 0) {
+ s0 = 0.5;
+ sm = 1;
+ } else {
+ int e;
+ (void)gnm_frexp (xc, &e);
+ s0 = gnm_ldexp (1, e - 10);
+ if (s0 == 0) s0 = GNM_MIN;
+ sm = gnm_abs (xc);
+ }
dir[c] = 1;
s = gnm_solver_line_search (sol, isol->xk, dir, TRUE,
- s0, gnm_abs (xc), 0.0,
- &y);
+ s0, sm, 0.0, &y);
dir[c] = 0;
if (gnm_finite (s)) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]