genius r711 - in trunk: . help/C lib/equation_solving src
- From: jirka svn gnome org
- To: svn-commits-list gnome org
- Subject: genius r711 - in trunk: . help/C lib/equation_solving src
- Date: Tue, 10 Feb 2009 22:59:42 +0000 (UTC)
Author: jirka
Date: Tue Feb 10 22:59:42 2009
New Revision: 711
URL: http://svn.gnome.org/viewvc/genius?rev=711&view=rev
Log:
Tue Feb 10 16:43:08 2009 Jiri (George) Lebl <jirka 5z com>
* configure.in, NEWS: raise version update NEWS
* src/mpwrap.c: fix leak in multiply
* src/mpwrap.c: fix a leak and fix a buffer overrun (Thanks to
Simon Munton simon-genius at munton.demon.co.uk)
* lib/equation_solving/diffeqs.gel: Fix EulersMethod (it was
overshooting by one increment) Also EulersMethod and RungeKutta
now solve system by just accepting vectors for y
* src/geniustests.txt: add new tests for EulersMethod
* help/C/genius.xml, help/C/gel-function-list.xml: Update
documentation, fix EulersMethod doc by using the right id string.
Modified:
trunk/ChangeLog
trunk/NEWS
trunk/configure.in
trunk/help/C/gel-function-list.xml
trunk/help/C/genius.txt
trunk/help/C/genius.xml
trunk/lib/equation_solving/diffeqs.gel
trunk/src/geniustests.txt
trunk/src/mpwrap.c
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Tue Feb 10 22:59:42 2009
@@ -1,3 +1,10 @@
+Changes to 1.0.5
+
+* Fix buffer overrun in print (Simon Munton)
+* Fix EulersMethod (and also fix it's documentation)
+* EulersMethod and RungeKutta now solve systems by accepting vectors
+* Fix several memory leaks
+
Changes to 1.0.4
* Add slope and vector field plotting, with a graphical solver for the
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Tue Feb 10 22:59:42 2009
@@ -1,7 +1,7 @@
AC_INIT(src/calc.c)
AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(genius,1.0.4)
+AM_INIT_AUTOMAKE(genius,1.0.5)
dnl make sure we keep ACLOCAL_FLAGS around for maintainer builds to work
AC_SUBST(ACLOCAL_AMFLAGS, "$ACLOCAL_FLAGS")
Modified: trunk/help/C/gel-function-list.xml
==============================================================================
--- trunk/help/C/gel-function-list.xml (original)
+++ trunk/help/C/gel-function-list.xml Tue Feb 10 22:59:42 2009
@@ -4243,19 +4243,27 @@
</listitem>
</varlistentry>
- <varlistentry id="gel-function-EulerMethod">
- <term>EulerMethod</term>
+ <varlistentry id="gel-function-EulersMethod">
+ <term>EulersMethod</term>
<listitem>
- <synopsis>EulerMethod (f,x0,y0,x1,n)</synopsis>
+ <synopsis>EulersMethod (f,x0,y0,x1,n)</synopsis>
<para>
Use classical Euler's method to numerically solve y'=f(x,y) for
initial <varname>x0</varname>, <varname>y0</varname> going to
<varname>x1</varname> with <varname>n</varname> increments,
returns <varname>y</varname> at <varname>x1</varname>.
</para>
+ <para>
+ Systems can be solved by just having <varname>y</varname> be a
+ (column) vector everywhere. That is, <varname>y0</varname> can
+ be a vector in which case <varname>f</varname> should take a number
+ <varname>x</varname> and a vector of the same size for the second
+ argument and should return a vector of the same size.
+ </para>
<para>
See
- <ulink url="http://mathworld.wolfram.com/EulerForwardMethod.html">Mathworld</ulink> for more information.
+ <ulink url="http://mathworld.wolfram.com/EulerForwardMethod.html">Mathworld</ulink>, or
+ <ulink url="http://en.wikipedia.org/wiki/Eulers_method">Wikipedia</ulink> for more information.
</para>
</listitem>
</varlistentry>
@@ -4360,14 +4368,23 @@
<listitem>
<synopsis>RungeKutta (f,x0,y0,x1,n)</synopsis>
<para>
- Use classical non-adaptive Runge-Kutta method to numerically solve
+ Use classical non-adaptive fourth order Runge-Kutta method to
+ numerically solve
y'=f(x,y) for initial <varname>x0</varname>, <varname>y0</varname>
going to <varname>x1</varname> with <varname>n</varname>
increments, returns <varname>y</varname> at <varname>x1</varname>.
</para>
+ <para>
+ Systems can be solved by just having <varname>y</varname> be a
+ (column) vector everywhere. That is, <varname>y0</varname> can
+ be a vector in which case <varname>f</varname> should take a number
+ <varname>x</varname> and a vector of the same size for the second
+ argument and should return a vector of the same size.
+ </para>
<para>
See
- <ulink url="http://mathworld.wolfram.com/Runge-KuttaMethod.html">Mathworld</ulink> for more information.
+ <ulink url="http://mathworld.wolfram.com/Runge-KuttaMethod.html">Mathworld</ulink>, or
+ <ulink url="http://en.wikipedia.org/wiki/Runge-Kutta_methods">Wikipedia</ulink> for more information.
</para>
</listitem>
</varlistentry>
Modified: trunk/help/C/genius.txt
==============================================================================
--- trunk/help/C/genius.txt (original)
+++ trunk/help/C/genius.txt Tue Feb 10 22:59:42 2009
@@ -5037,14 +5037,19 @@
See Planetmath, Mathworld, or Wikipedia for more information.
- EulerMethod
+ EulersMethod
- EulerMethod (f,x0,y0,x1,n)
+ EulersMethod (f,x0,y0,x1,n)
Use classical Euler's method to numerically solve y'=f(x,y) for
initial x0, y0 going to x1 with n increments, returns y at x1.
- See Mathworld for more information.
+ Systems can be solved by just having y be a (column) vector
+ everywhere. That is, y0 can be a vector in which case f should
+ take a number x and a vector of the same size for the second
+ argument and should return a vector of the same size.
+
+ See Mathworld, or Wikipedia for more information.
FindRootBisection
@@ -5108,11 +5113,16 @@
RungeKutta (f,x0,y0,x1,n)
- Use classical non-adaptive Runge-Kutta method to numerically solve
- y'=f(x,y) for initial x0, y0 going to x1 with n increments,
- returns y at x1.
+ Use classical non-adaptive fourth order Runge-Kutta method to
+ numerically solve y'=f(x,y) for initial x0, y0 going to x1 with n
+ increments, returns y at x1.
+
+ Systems can be solved by just having y be a (column) vector
+ everywhere. That is, y0 can be a vector in which case f should
+ take a number x and a vector of the same size for the second
+ argument and should return a vector of the same size.
- See Mathworld for more information.
+ See Mathworld, or Wikipedia for more information.
----------------------------------------------------------------------
Modified: trunk/help/C/genius.xml
==============================================================================
--- trunk/help/C/genius.xml (original)
+++ trunk/help/C/genius.xml Tue Feb 10 22:59:42 2009
@@ -3,9 +3,9 @@
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
<!ENTITY app "<application>Genius Mathematics Tool</application>">
<!ENTITY appname "Genius">
- <!ENTITY appversion "1.0.4">
+ <!ENTITY appversion "1.0.5">
<!ENTITY manrevision "0.2.3">
- <!ENTITY date "January 2009">
+ <!ENTITY date "February 2009">
<!ENTITY legal SYSTEM "legal.xml">
Modified: trunk/lib/equation_solving/diffeqs.gel
==============================================================================
--- trunk/lib/equation_solving/diffeqs.gel (original)
+++ trunk/lib/equation_solving/diffeqs.gel Tue Feb 10 22:59:42 2009
@@ -8,14 +8,14 @@
# Note we can't check the 2 arguments, FIXME
if not IsFunction(f) then
(error("EulersMethod: f must be a function of two arguments");bailout)
- else if not IsValue(x0) or not IsValue(y0) or not IsValue(x1) then
- (error("EulersMethod: x0, y0 and x1 must be numbers");bailout)
+ else if not IsValue(x0) or (not IsValue(y0) and not IsVector(y0)) or not IsValue(x1) then
+ (error("EulersMethod: x0, y0 and x1 must be numbers (y0 can be a vector)");bailout)
else if not IsPositiveInteger(n) then
(error("EulersMethod: n must be a positive integer");bailout);
h := float(x1-x0) / n;
x := x0;
y := y0;
- for k = 0 to n do (
+ for k = 1 to n do (
y := y + h*f(x,y);
x := x + h
);
@@ -31,8 +31,8 @@
# Note we can't check the 2 arguments, FIXME
if not IsFunction(f) then
(error("RungeKutta: f must be a function of two arguments");bailout)
- else if not IsValue(x0) or not IsValue(y0) or not IsValue(x1) then
- (error("RungeKutta: x0, y0 and x1 must be numbers");bailout)
+ else if not IsValue(x0) or (not IsValue(y0) and not IsVector(y0)) or not IsValue(x1) then
+ (error("RungeKutta: x0, y0 and x1 must be numbers (y0 can be a vector)");bailout)
else if not IsPositiveInteger(n) then
(error("RungeKutta: n must be a positive integer");bailout);
h := float(x1-x0) / n;
Modified: trunk/src/geniustests.txt
==============================================================================
--- trunk/src/geniustests.txt (original)
+++ trunk/src/geniustests.txt Tue Feb 10 22:59:42 2009
@@ -724,7 +724,7 @@
MoebiusMu(4) 0
MoebiusMu(2*3) 1
RungeKutta (`(x,y) = 2*x+3,0,0,8,10) 88.0
-EulersMethod (`(x,y) = 2*x+3,0,0,8,100) 88.88
+EulersMethod (`(x,y) = 2*x+3,0,0,8,100) 87.36
SymbolicDerivative(sin) (`(x)=cos(x))
SymbolicDerivative(cos) (`(x)=(-sin(x)))
SymbolicDerivative(`(x)=10*x^3+x^2+88*x+100) (`(x)=(88+((30*(x^2))+(2*x))))
@@ -923,5 +923,9 @@
for n=-10 to 10 do .;n 10
for n=-10 to 10 by 3 do .;n 8
for n=-11 to 10 by 3 do .;n 10
+EulersMethod (`(x,y)=(x-y),0,0,3,3) 2.0
+EulersMethod (`(x,y)=[(x-y@(1));0],0,[0;0],3,3) [2.0;0.0]
+EulersMethod (`(x,y)=[0;(x-y@(2))],0,[0;0],3,3) [0.0;2.0]
+EulersMethod (`(x,y)=[(x-y@(1));(x-y@(2))],0,[0;0],3,3) [2.0;2.0]
load "nullspacetest.gel" true
load "longtest.gel" true
Modified: trunk/src/mpwrap.c
==============================================================================
--- trunk/src/mpwrap.c (original)
+++ trunk/src/mpwrap.c Tue Feb 10 22:59:42 2009
@@ -118,8 +118,8 @@
#define MAKE_CPLX_OPS(THE_op,THE_r,THE_i) { \
if(rop==THE_op) { \
- THE_r = g_new0(MpwRealNum,1); \
- THE_i = g_new0(MpwRealNum,1); \
+ THE_r = g_alloca (sizeof (MpwRealNum)); \
+ THE_i = g_alloca (sizeof (MpwRealNum)); \
mpwl_init_type(THE_r,THE_op->r->type); \
mpwl_init_type(THE_i,THE_op->i->type); \
mpwl_set(THE_r,THE_op->r); \
@@ -2765,6 +2765,8 @@
for(i=0;i<e-len;i++)
strcat(p,"0");
} else if(e<len) {
+ /* FIXME: is this correct? */
+ p = g_realloc (p, strlen(p) + 2);
if(p[0]=='-') {
shiftstr(p+1+e,1);
p[e+1]='.';
@@ -2776,6 +2778,7 @@
str_trim_trailing_zeros (p, TRUE /* leave_first_zero */);
} else { /*e<=0*/
if(len == 0) {
+ g_free (p);
p = g_strdup ("0.0");
} else {
p = g_realloc (p, strlen(p)+2+(-e)+2);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]