[genius] Fri Jul 24 17:23:04 2009 Jiri (George) Lebl <jirka 5z com>
- From: George Lebl <jirka src gnome org>
- To: svn-commits-list gnome org
- Subject: [genius] Fri Jul 24 17:23:04 2009 Jiri (George) Lebl <jirka 5z com>
- Date: Fri, 24 Jul 2009 22:23:28 +0000 (UTC)
commit 8502c3fdff0ae0344cf86afab1db01c2ae9b4614
Author: Jiri (George) Lebl <jirka 5z com>
Date: Fri Jul 24 17:23:07 2009 -0500
Fri Jul 24 17:23:04 2009 Jiri (George) Lebl <jirka 5z com>
* lib/calculus/fourier.gel: fix cosine series and fix argument
checking on the fourier function creation
* src/geniustests.txt, src/testfourier.gel: add tests for the
fourier functions
* src/graphing.c: the create plot and plot dialogs are stupid as
dialogs because of the way metacity handles dialogs (annoyingly
as "keep above parent") so set the hint to normal.
ChangeLog | 12 ++++++++
lib/calculus/fourier.gel | 6 ++--
src/geniustests.txt | 1 +
src/graphing.c | 5 +++
src/testfourier.gel | 63 ++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 84 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9390398..461c219 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Fri Jul 24 17:23:04 2009 Jiri (George) Lebl <jirka 5z com>
+
+ * lib/calculus/fourier.gel: fix cosine series and fix argument
+ checking on the fourier function creation
+
+ * src/geniustests.txt, src/testfourier.gel: add tests for the
+ fourier functions
+
+ * src/graphing.c: the create plot and plot dialogs are stupid as
+ dialogs because of the way metacity handles dialogs (annoyingly
+ as "keep above parent") so set the hint to normal.
+
Fri Jul 24 16:32:32 2009 Jiri (George) Lebl <jirka 5z com>
* lib/calculus/fourier.gel: add NumericalFourierCosineSeriesFunction
diff --git a/lib/calculus/fourier.gel b/lib/calculus/fourier.gel
index bde51c1..4c689a4 100644
--- a/lib/calculus/fourier.gel
+++ b/lib/calculus/fourier.gel
@@ -54,7 +54,7 @@ SetHelp("NumericalFourierCosineSeriesFunction","calculus","Return a function whi
function FourierSeriesFunction(a,b,L) =
(
# check arguments
- if not (IsVector(a) and IsVector(b)) then
+ if not ((IsVector(a) or IsNull(a)) and (IsVector(b) or IsNull(b))) then
(error("FourierSeriesFunction: arguments a and b must be vectors");bailout)
else if not (IsReal(L) and L > 0) then
(error("FourierSeriesFunction: argument L must be a positive real value");bailout);
@@ -133,9 +133,9 @@ function NumericalFourierCosineSeriesCoefficients(f,L,N) =
a = .;
- a@(1) = (1/L)*NumericalIntegral(f,-L,L);
+ a@(1) = (2/L)*NumericalIntegral(f,0,L);
for n = 1 to N do (
- a@(n+1) = (1/L)*NumericalIntegral(`(x)[f,L,n]=(local *;(f call (x))*cos(x*n*pi/L)),-L,L)
+ a@(n+1) = (2/L)*NumericalIntegral(`(x)[f,L,n]=(local *;(f call (x))*cos(x*n*pi/L)),0,L)
);
a
)
diff --git a/src/geniustests.txt b/src/geniustests.txt
index 167838b..fed41e7 100644
--- a/src/geniustests.txt
+++ b/src/geniustests.txt
@@ -973,3 +973,4 @@ load "nullspacetest.gel" true
load "longtest.gel" true
load "testprec.gel" true
load "testscope.gel" true
+load "testfourier.gel" true
diff --git a/src/graphing.c b/src/graphing.c
index 8bc3318..3290d59 100644
--- a/src/graphing.c
+++ b/src/graphing.c
@@ -1714,6 +1714,9 @@ ensure_window (gboolean do_window_present)
GTK_STOCK_CLOSE,
GTK_RESPONSE_CLOSE,
NULL);
+ gtk_window_set_type_hint (GTK_WINDOW (graph_window),
+ GDK_WINDOW_TYPE_HINT_NORMAL);
+
gtk_window_add_accel_group (GTK_WINDOW (graph_window),
accel_group);
@@ -5056,6 +5059,8 @@ genius_plot_dialog (void)
_("_Plot"),
RESPONSE_PLOT,
NULL);
+ gtk_window_set_type_hint (GTK_WINDOW (plot_dialog),
+ GDK_WINDOW_TYPE_HINT_NORMAL);
gtk_dialog_set_default_response (GTK_DIALOG (plot_dialog),
RESPONSE_PLOT);
diff --git a/src/testfourier.gel b/src/testfourier.gel
new file mode 100644
index 0000000..2dc567b
--- /dev/null
+++ b/src/testfourier.gel
@@ -0,0 +1,63 @@
+f = NumericalFourierSeriesFunction(`(x)=x^2,1,10);
+if |f(0)| >= 0.01 then (error("Fourier test 1 fail");exit());
+if |f(1)-1| >= 0.05 then (error("Fourier test 2 fail");exit());
+if |f(-1)-1| >= 0.05 then (error("Fourier test 3 fail");exit());
+if |f(2)| >= 0.01 then (error("Fourier test 4 fail");exit());
+if |f(-2)| >= 0.01 then (error("Fourier test 5 fail");exit());
+
+function ff(x) = x^3+x^2;
+f = NumericalFourierSeriesFunction(ff,1,30);
+for x=-0.7 to 0.7 by 0.1 do (
+ if |f(x)-ff(x)| >= 0.025 then (error("Fourier test 6 fail at x=" + x);exit());
+);
+
+function ff(x) = x^3+x^2;
+f = NumericalFourierSineSeriesFunction(ff,1,30);
+for x=0.3 to 0.7 by 0.1 do (
+ if |f(x)-ff(x)| >= 0.03 then (error("Fourier test 7 fail at x=" + x);exit());
+);
+for x=0.3 to 0.7 by 0.1 do (
+ if |-f(-x)-ff(x)| >= 0.03 then (error("Fourier test 8 fail at x=" + x);exit());
+);
+
+function ff(x) = x^3+x^2;
+f = NumericalFourierCosineSeriesFunction(ff,1,20);
+for x=0.3 to 0.7 by 0.1 do (
+ if |f(x)-ff(x)| >= 0.01 then (error("Fourier test 9 fail at x=" + x);exit());
+);
+for x=0.3 to 0.7 by 0.1 do (
+ if |f(-x)-ff(x)| >= 0.01 then (error("Fourier test 10 fail at x=" + x);exit());
+);
+
+function ff(x) = x^3+x^2;
+f1=OddPeriodicExtension (ff,1);
+for x=0.1 to 0.9 by 0.1 do (
+ if f1(x) != ff(x) then (error("Odd ext test 1 fail at x=" + x);exit());
+);
+for x=0.1 to 0.9 by 0.1 do (
+ if |-f1(-x) - ff(x)| >= 0.000001 then (error("Odd ext test 2 fail at x=" + x);exit());
+);
+for x=0.1 to 0.9 by 0.1 do (
+ if |-f1(-x+2) - ff(x)| >= 0.000001 then (error("Odd ext test 3 fail at x=" + x);exit());
+);
+for x=0.1 to 0.9 by 0.1 do (
+ if |-f1(-x-2) - ff(x)| >= 0.000001 then (error("Odd ext test 4 fail at x=" + x);exit());
+);
+
+function ff(x) = x^3+x^2;
+f1=EvenPeriodicExtension (ff,1);
+for x=0.1 to 0.9 by 0.1 do (
+ if f1(x) != ff(x) then (error("Odd ext test 1 fail at x=" + x);exit());
+);
+for x=0.1 to 0.9 by 0.1 do (
+ if |f1(-x) - ff(x)| >= 0.000001 then (error("Odd ext test 2 fail at x=" + x);exit());
+);
+for x=0.1 to 0.9 by 0.1 do (
+ if |f1(-x+2) - ff(x)| >= 0.000001 then (error("Odd ext test 3 fail at x=" + x);exit());
+);
+for x=0.1 to 0.9 by 0.1 do (
+ if |f1(-x-2) - ff(x)| >= 0.000001 then (error("Odd ext test 4 fail at x=" + x);exit());
+);
+
+
+print("true");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]