gnumeric r17246 - in trunk: . plugins/fn-financial
- From: mortenw svn gnome org
- To: svn-commits-list gnome org
- Subject: gnumeric r17246 - in trunk: . plugins/fn-financial
- Date: Sat, 28 Mar 2009 16:38:16 +0000 (UTC)
Author: mortenw
Date: Sat Mar 28 16:38:15 2009
New Revision: 17246
URL: http://svn.gnome.org/viewvc/gnumeric?rev=17246&view=rev
Log:
2009-03-28 Morten Welinder <terra gnome org>
* functions.c (gnm_range_xirr): Try insanely close to -1 if all
else fails.
Modified:
trunk/NEWS
trunk/plugins/fn-financial/ChangeLog
trunk/plugins/fn-financial/functions.c
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Sat Mar 28 16:38:15 2009
@@ -3,6 +3,7 @@
Morten:
* Handle elapsed time formats better on text export.
* Plug leak.
+ * Improve XIRR a bit.
--------------------------------------------------------------------------
Gnumeric 1.9.5
Modified: trunk/plugins/fn-financial/functions.c
==============================================================================
--- trunk/plugins/fn-financial/functions.c (original)
+++ trunk/plugins/fn-financial/functions.c Sat Mar 28 16:38:15 2009
@@ -1978,7 +1978,9 @@
status = goal_seek_newton (&xirr_npv, NULL, &data, &p, rate0);
if (status != GOAL_SEEK_OK) {
+ double r;
int i;
+
for (i = 1; i <= 1024; i += i) {
(void)goal_seek_point (&xirr_npv, &data, &p, -1 + 10.0 / (i + 9));
(void)goal_seek_point (&xirr_npv, &data, &p, i);
@@ -1986,6 +1988,14 @@
if (status == GOAL_SEEK_OK)
break;
}
+
+ /* Try insanely close to -1. */
+ for (r = GNM_EPSILON; r < 0.02; r *= 2) {
+ (void)goal_seek_point (&xirr_npv, &data, &p, -1 + r);
+ status = goal_seek_bisection (&xirr_npv, &data, &p);
+ if (status == GOAL_SEEK_OK)
+ break;
+ }
}
if (status == GOAL_SEEK_OK) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]