[genius] Tue Dec 20 15:11:04 2016 Jiri (George) Lebl <jirka 5z com>
- From: George Lebl <jirka src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [genius] Tue Dec 20 15:11:04 2016 Jiri (George) Lebl <jirka 5z com>
- Date: Tue, 20 Dec 2016 21:11:02 +0000 (UTC)
commit b84743d64170f524e08e7d70cdc9f58a76f45fe7
Author: Jiri (George) Lebl <jiri lebl gmail com>
Date: Tue Dec 20 15:11:26 2016 -0600
Tue Dec 20 15:11:04 2016 Jiri (George) Lebl <jirka 5z com>
* examples/explicit-heat-fdm.gel, examples/explicit-heat-fdm-line.gel:
Improve the FDM example: make it easy to do other boundary
conditions, and add some more sample initial functions. Also
add a version that plots the 2d line plot as an animation
* src/matrixw.c: Fix setting matrices that have been transposed.
* src/geniustests.pl: Add a bunch of tests
ChangeLog | 11 +++
examples/Makefile.am | 1 +
examples/explicit-fdm-heat-line.gel | 105 +++++++++++++++++++++++++++
examples/explicit-fdm-heat.gel | 52 +++++++++++---
src/geniustests.txt | 63 ++++++++++++++++-
src/matrixw.c | 132 ++++++++++++++++++++---------------
6 files changed, 296 insertions(+), 68 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 6a39341..8191d1b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Tue Dec 20 15:11:04 2016 Jiri (George) Lebl <jirka 5z com>
+
+ * examples/explicit-heat-fdm.gel, examples/explicit-heat-fdm-line.gel:
+ Improve the FDM example: make it easy to do other boundary
+ conditions, and add some more sample initial functions. Also
+ add a version that plots the 2d line plot as an animation
+
+ * src/matrixw.c: Fix setting matrices that have been transposed.
+
+ * src/geniustests.pl: Add a bunch of tests
+
Mon Dec 19 20:07:44 2016 Jiri (George) Lebl <jirka 5z com>
* po/eo.po: Add some translations.
diff --git a/examples/Makefile.am b/examples/Makefile.am
index df2f16f..58bbcc6 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -6,6 +6,7 @@ example_DATA = \
eulers-method-exp-run.gel \
eulers-method-graphs-exp.gel \
explicit-fdm-heat.gel \
+ explicit-fdm-heat-line.gel \
laplace-fdm.gel \
linapprox.gel \
lorenz.gel \
diff --git a/examples/explicit-fdm-heat-line.gel b/examples/explicit-fdm-heat-line.gel
new file mode 100644
index 0000000..23206b5
--- /dev/null
+++ b/examples/explicit-fdm-heat-line.gel
@@ -0,0 +1,105 @@
+# Category: Differential Equations
+# Name: Heat equation solved using Explicit Finite Difference Method (line plot)
+#
+# Solve heat equation using explicit FDM. We try to animate as different
+# times are solved for, though of course we must skip graphing some times when
+# there are too many steps. The plot is an animated line plot.
+#
+# The equation is u_t = u_{xx} where 0 < x < 1
+# Boundary conditions by default are
+# The boundary conditions are insulated on x=0, u_x(0,t) = 0
+# and Dirichlet condition on x=1, u(1,t) = 0
+# But this can be changed below.
+
+# Initial value, u(x,0) = ?
+function initialf(x) = sin(2*pi*x);
+#function initialf(x) = 1.0;
+#function initialf(x) = 0.0;
+#function initialf(x) = x;
+#function initialf(x) = 1-x;
+#function initialf(x) = if x < 0.5 then 2*x else 2-2*x;
+#function initialf(x) = if x < 0.5 then 4*x^2 else 4*(x-1)^2;
+#function initialf(x) = if x < 0.5 then -1 else 1;
+
+
+# Left hand (x=0) endpoint insulated by default
+leftendinsulated := true;
+leftenddirichlet := 0.0;
+
+# Right hand (x=1) endpoint Dirichlet condition set at 0
+# by default
+rightendinsulated := false;
+rightenddirichlet := 0.0;
+
+# How long to wait after each animation step. Lowering the number will
+# make things go faster, increasing it will make things go slower.
+waitinterval := 0.05;
+
+# Plot every so many steps. Setting it to a higher value makes the
+# animation faster.
+plotevery := 1;
+
+# plot range is x between 0 and 1, and y between -1.1 and 1.1
+LinePlotWindow = [0,1,-1.1,1.1];
+
+# The number of intervals on the x axis
+n := 60;
+h := float(1/n);
+
+# The value of k/h^2 must be less than or equal 0.5 for the method to be
+# stable. We use 0.4 to ensure even the step function is stable.
+# Try using 0.55 instead of 0.4, or even try 0.5 with the step function.
+# Or set it to less. See what it does to accuracy.
+k := 0.4*h^2;
+
+# Maximum t to go up to. maxt=1 will go for a quite a while
+maxt := 1.0;
+
+m := round(maxt/k);
+
+#Set up initial value
+u := null;
+x := null;
+for j=1 to n+1 do (
+ xx := (j-1)*h;
+ u@(j) := initialf(xx);
+ x@(j) := xx;
+);
+
+# Make sure u and x are column vectors not row vectors;
+u := u.';
+x := x.';
+
+LinePlotDrawLegends := true;
+PlotWindowPresent(); # Make sure the window is raised
+
+toplot := 0;
+
+for i=1 to m do (
+ v := u;
+ for j=2 to n do (
+ u@(j) := v@(j) + (k/(h^2))*(v@(j+1)+v@(j-1)-2*v@(j))
+ );
+ if leftendinsulated then (
+ u@(1) := u@(2)
+ ) else (
+ u@(1) := leftenddirichlet
+ );
+ if rightendinsulated then (
+ u@(n+1) := u@(n)
+ ) else (
+ u@(n+1) := rightenddirichlet
+ );
+
+ increment toplot;
+ if toplot == plotevery then (
+ toplot := 0;
+
+ PlotCanvasFreeze();
+ LinePlotClear();
+ LinePlotDrawLine([x,u],"legend","u","color","blue");
+ PlotCanvasThaw();
+
+ wait(waitinterval)
+ )
+);
diff --git a/examples/explicit-fdm-heat.gel b/examples/explicit-fdm-heat.gel
index 0d88575..b2666f7 100644
--- a/examples/explicit-fdm-heat.gel
+++ b/examples/explicit-fdm-heat.gel
@@ -1,5 +1,5 @@
# Category: Differential Equations
-# Name: Heat equation solved using Explicit Finite Difference Method
+# Name: Heat equation solved using Explicit Finite Difference Method (surface plot)
#
# Solve heat equation using explicit FDM. We try to animate as different
# times are solved for, though of course we must skip graphing some times when
@@ -9,28 +9,50 @@
# To set them back to default do SurfacePlotVariableNames = ["x","y","z"];
#
# The equation is u_t = u_{xx} where 0 < x < 1
+# Boundary conditions by default are
# The boundary conditions are insulated on x=0, u_x(0,t) = 0
# and Dirichlet condition on x=1, u(1,t) = 0
+# But this can be changed below.
+
+# Initial value, u(x,0) = ?
+function initialf(x) = sin(2*pi*x);
+#function initialf(x) = 1.0;
+#function initialf(x) = 0.0;
+#function initialf(x) = x;
+#function initialf(x) = 1-x;
+#function initialf(x) = if x < 0.5 then 2*x else 2-2*x
+#function initialf(x) = if x < 0.5 then 4*x^2 else 4*(x-1)^2;
+#function initialf(x) = if x < 0.5 then -1 else 1;
+
+
+# Left hand (x=0) endpoint insulated by default
+leftendinsulated := true;
+leftenddirichlet := 0.0;
+
+# Right hand (x=1) endpoint Dirichlet condition set at 0
+# by default
+rightendinsulated := false;
+rightenddirichlet := 0.0;
# The number of intervals on the x axis
n := 20;
h := float(1/n);
-function initialf(x) = sin(2*pi*x);
-
# The value of k/h^2 must be less than or equal 0.5 for the method to be
-# stable. try putting 0.55 in the line below instead of 0.5. Try setting it
-# to less than 0.5 to what it does to accuracy
-k := 0.5*h^2;
+# stable. We use 0.4 to ensure even the step function is stable.
+# Try using 0.55 instead of 0.4, or even try 0.5 with the step function.
+# Or set it to less. See what it does to accuracy.
+k := 0.4*h^2;
+
# Maximum t to go up to
-maxt := 0.06;
+maxt := 0.05;
m := round(maxt/k);
# Never plot more than 4*n steps in the t (that is y) direction
-# rather skip rows. If you do not want to skip rows, comment out
-# the next line.
+# rather skip rows. If you do not want to skip rows, set plotevery
+# to 1
plotevery := max(1,floor(m/(2*n)));
#Set up initial value
@@ -56,8 +78,16 @@ for i=1 to m do (
for j=2 to n do (
u@(j) := v@(j) + (k/(h^2))*(v@(j+1)+v@(j-1)-2*v@(j))
);
- u@(1) := u@(2);
- u@(n+1) := 0;
+ if leftendinsulated then (
+ u@(1) := u@(2)
+ ) else (
+ u@(1) := leftenddirichlet
+ );
+ if rightendinsulated then (
+ u@(n+1) := u@(n)
+ ) else (
+ u@(n+1) := rightenddirichlet
+ );
increment toplot;
if toplot == plotevery then (
diff --git a/src/geniustests.txt b/src/geniustests.txt
index b65fdbc..865b8c3 100644
--- a/src/geniustests.txt
+++ b/src/geniustests.txt
@@ -230,14 +230,60 @@ MaxDigits=12;exp(3*ln(2)) 8.0
if(0)then 1;0 0
24/2 12
a@(1,2)=3;a [0,3]
+a@(1,2)=3;a@(3)=9;a [0,3,9]
+a@(2,1)=3;a=a.';a@(3)=9;a [0,3,9]
+a@(2,1)=3;a@(3)=9;a [0;3;9]
+a@(1,2)=3;a=a.';a@(3)=9;a [0;3;9]
a@(2,2)=3;a [0,0;0,3]
a@(,2)=[1;2;3];a [0,1;0,2;0,3]
[1,2;3,4]@(,2) [2;4]
+m=[1,2;3,4];m=m.';m@(,2) [3;4]
+m=[1,2;3,4];m=m.';m@(,2)=[9;10];m [1,9;2,10]
[1,2;3,4]@(1,) [1,2]
+m=[1,2;3,4];m=m.';m@(1,) [1,3]
[1,2;3,4]@(2,) [3,4]
+m=[1,2;3,4];m=m.';m@(2,) [2,4]
a=[1,2;3,4];a@(2,)=[5,6];a [1,2;5,6]
a=[1,2;3,4];a@(2,)=5;a [1,2;5,5]
a@(1,1)=&d;a [(&d)]
+c=[1,2,3];c@([1,2])=9;c [9,9,3]
+c=[1,2,3];c@([1,3])=9;c [9,2,9]
+c=[1,2,3];c@([2,6])=9;c [1,9,3,0,0,9]
+c=[1,2,3];c=c.';c@([1,2])=9;c [9;9;3]
+c=[1,2,3];c=c.';c@([1,3])=9;c [9;2;9]
+c=[1,2,3];c=c.';c@([2,6])=9;c [1;9;3;0;0;9]
+c=[1;2;3];c@([1,2])=9;c [9;9;3]
+c=[1;2;3];c@([1,3])=9;c [9;2;9]
+c=[1;2;3];c@([2,6])=9;c [1;9;3;0;0;9]
+c=[1;2;3];c=c.';c@([1,2])=9;c [9,9,3]
+c=[1;2;3];c=c.';c@([1,3])=9;c [9,2,9]
+c=[1;2;3];c=c.';c@([2,6])=9;c [1,9,3,0,0,9]
+c=[1,2,3];c@([1,2])=[7,8];c [7,8,3]
+c=[1,2,3];c@([1;2])=[7,8];c [7,8,3]
+c=[1,2,3];c@([1,2])=[7;8];c [7,8,3]
+c=[1,2,3];c@([1;2])=[7;8];c [7,8,3]
+c=[1,2,3];c@([1,3])=[7,8];c [7,2,8]
+c=[1,2,3];c@([2,6])=[7,8];c [1,7,3,0,0,8]
+c=[1,2,3];c=c.';c@([1,2])=[7,8];c [7;8;3]
+c=[1,2,3];c=c.';c@([1;2])=[7,8];c [7;8;3]
+c=[1,2,3];c=c.';c@([1,2])=[7;8];c [7;8;3]
+c=[1,2,3];c=c.';c@([1;2])=[7;8];c [7;8;3]
+c=[1,2,3];c=c.';c@([1,3])=[7,8];c [7;2;8]
+c=[1,2,3];c=c.';c@([2,6])=[7,8];c [1;7;3;0;0;8]
+c=[1;2;3];c@([1,2])=[7,8];c [7;8;3]
+c=[1;2;3];c@([1,2,3])=[7,8];c [7;8;0]
+c=[1;2;3];c@([1,3])=[7,8];c [7;2;8]
+c=[1;2;3];c@([2,6])=[7,8];c [1;7;3;0;0;8]
+c=[1;2;3];c=c.';c@([1,2])=[7,8];c [7,8,3]
+c=[1;2;3];c=c.';c@([1,2,3])=[7,8];c [7,8,0]
+c=[1;2;3];c=c.';c@([1,3])=[7,8];c [7,2,8]
+c=[1;2;3];c=c.';c@([2,6])=[7,8];c [1,7,3,0,0,8]
+c=[1,2,3,4;5,6,7,8];c@(6)=99;c [1,2,3,4;5,99,7,8]
+c=[1,5;2,6;3,7;4,8];c=c.';c@(6)=99;c [1,2,3,4;5,99,7,8]
+c=[1,2,3,4;5,6,7,8];c@(4)=99;c [1,2,3,99;5,6,7,8]
+c=[1,5;2,6;3,7;4,8];c=c.';c@(4)=99;c [1,2,3,99;5,6,7,8]
+c=[1,2,3,4;5,6,7,8];c@(11)=99;c [1,2,3,4;5,6,7,8;0,0,99,0]
+c=[1,5;2,6;3,7;4,8];c=c.';c@(11)=99;c [1,2,3,4;5,6,7,8;0,0,99,0]
if(1 and 1) then 1 else 0 1
if(0 and 1) then 1 else 0 0
if("blah" and 1) then 1 else 0 1
@@ -307,8 +353,11 @@ rref([1,2,3;2,4,6]) [1,2,3;0,0,0]
[[2;3;4],I(2)] [2,1,0;3,0,1;4,1,0]
a@(1,&f)=1 ((a@(1,(&f)))=1)
a=[1,2;3,4];a@(,2)=[1,2] ((a@(,2))=[1,2])
+a=[1,3;2,4];a=a.';a@(,2)=[1,2] ((a@(,2))=[1,2])
a=[1,2;3,4];a@(,2)=[7,8]';a [1,7;3,8]
+a=[1,3;2,4];a=a.';a@(,2)=[7,8]';a [1,7;3,8]
a=[1,2;3,4];a@(2,)=[7;8]';a [1,2;7,8]
+a=[1,3;2,4];a=a.';a@(2,)=[7;8]';a [1,2;7,8]
a=[1,2;3,4];a@(3:1,1:2) ([1,2;3,4]@(`[3,2,1],`[1,2]))
I(3)@(2:3,) [0,1,0;0,0,1]
a@(2:3,2:3)=[1,2;3,4];a [0,0,0;0,1,2;0,3,4]
@@ -318,8 +367,11 @@ a=[1,2,3;4,5,6;7,8,9];[a@(1:1,1:1),a@(1,3);a@(3,1),a@(3,3)] [1,3;7,9]
a=[1,2,3;4,5,6;7,8,9];a@(1:2,2:3) [2,3;5,6]
a=[1,2,3;4,5,6;7,8,9];a@(1,1:3) [1,2,3]
a=[1,2,3;4,5,6;7,8,9];a@(1:3,2)' [2,5,8]
+a=[1,2,3;4,5,6;7,8,9];a@(1:3,2).' [2,5,8]
a=[1,2;3,4];a@(2:3,2)=[5,6]';a [1,2;3,5;0,6]
+a=[1,3;2,4];a=a.';a@(2:3,2)=[5,6]';a [1,2;3,5;0,6]
a=[1,2;3,4];a@(2:3,2:3)=[5,6;7,8];a [1,2,0;3,5,6;0,7,8]
+a=[1,3;2,4];a=a.';a@(2:3,2:3)=[5,6;7,8];a [1,2,0;3,5,6;0,7,8]
b@(4:8,3)=[1,2,3,4]' ((b@(`[4,5,6,7,8],3))=[1;2;3;4])
b@(2:3,2)=[1,2]';b [0,0;0,1;0,2]
(k=0;while(k<3) do (k=k+1;))+1 ((null)+1)
@@ -1070,6 +1122,15 @@ v=[0,1,2];increment v;v [1,2,3]
v=[0,1,2];increment v by 2;v [2,3,4]
v=[0,1,2];increment v@([2,3]);v [0,2,3]
v=[0,1,2];increment v@(2);v [0,2,2]
+v=[0,1,2];increment v@(5);v [0,1,2,0,1]
+v=[0;1;2];v=v.';increment v@(2);v [0,2,2]
+v=[0;1;2];v=v.';increment v@(5);v [0,1,2,0,1]
+v=[0,1,2;3,4,5];increment v@(2);v [0,2,2;3,4,5]
+v=[0,1,2;3,4,5];increment v@(5);v [0,1,2;3,5,5]
+v=[0,1,2;3,4,5];increment v@(8);v [0,1,2;3,4,5;0,1,0]
+v=[0,3;1,4;2,5];v=v.';increment v@(2);v [0,2,2;3,4,5]
+v=[0,3;1,4;2,5];v=v.';increment v@(5);v [0,1,2;3,5,5]
+v=[0,3;1,4;2,5];v=v.';increment v@(8);v [0,1,2;3,4,5;0,1,0]
v=[0,1;2,3];increment v;v [1,2;3,4]
v=[0,1;2,3];increment v@(1,2);v [0,2;2,3]
v=[0,1;2,3];increment v@(1,:);v [1,2;2,3]
@@ -1089,7 +1150,7 @@ m=[1,2;3,4];m@(1,1) swapwith m@(1,2);m [2,1;3,4]
m=[1,2;3,4];m@(3,1) swapwith m@(1,2);m [1,0;3,4;2,0]
k=99;m=[1,2;3,4];k swapwith m@(1,2);m [1,99;3,4]
k=99;m=[1,2;3,4];m@(1,2) swapwith k;m [1,99;3,4]
-A=2;A swapwith e;A 2
+A=2;A swapwith e;A 2
ReverseVector([1:5]) `[5,4,3,2,1]
ReverseVector(null)+1 ((null)+1)
ShuffleVector([1]) [1]
diff --git a/src/matrixw.c b/src/matrixw.c
index e0a85ec..0e2f640 100644
--- a/src/matrixw.c
+++ b/src/matrixw.c
@@ -1,5 +1,5 @@
/* GENIUS Calculator
- * Copyright (C) 1997-2014 Jiri (George) Lebl
+ * Copyright (C) 1997-2016 Jiri (George) Lebl
*
* Author: Jiri (George) Lebl
*
@@ -601,7 +601,7 @@ gel_matrixw_incr_element (GelMatrixW *m, int x, int y, mpw_ptr by)
#endif
if (m->tr)
- internal_make_private (m, MAX(m->regh, y+1), MAX(m->regw, x+1),
+ internal_make_private (m, MAX(m->regw, y+1), MAX(m->regh, x+1),
TRUE /* kill_type_caches */);
else
internal_make_private (m, MAX(m->regw, x+1), MAX(m->regh, y+1),
@@ -628,29 +628,25 @@ void
gel_matrixw_set_velement (GelMatrixW *m, int i, gpointer data)
{
GelETree *t;
- int x, y;
+ int x, y, w, h;
g_return_if_fail (m != NULL);
g_return_if_fail (i >= 0);
+ w = gel_matrixw_width (m);
+ h = gel_matrixw_height (m);
+
+ if (h == 1) {
+ x = i;
+ y = 0;
+ } else {
+ x = i % w;
+ y = i / w;
+ }
if (m->tr) {
- if (m->regw == 1) {
- x = 0;
- y = i;
- } else {
- x = i % m->regh;
- y = i / m->regh;
- }
- internal_make_private (m, MAX(m->regh, y+1), MAX(m->regw, x+1),
+ internal_make_private (m, MAX(m->regw, y+1), MAX(m->regh, x+1),
TRUE /* kill_type_caches */);
} else {
- if (m->regh == 1) {
- x = i;
- y = 0;
- } else {
- x = i % m->regw;
- y = i / m->regw;
- }
internal_make_private (m, MAX(m->regw, x+1), MAX(m->regh, y+1),
TRUE /* kill_type_caches */);
}
@@ -666,30 +662,26 @@ void
gel_matrixw_incr_velement (GelMatrixW *m, int i, mpw_ptr by)
{
GelETree *t;
- int x, y;
+ int x, y, w, h;
g_return_if_fail (m != NULL);
g_return_if_fail (i >= 0);
+ w = gel_matrixw_width (m);
+ h = gel_matrixw_height (m);
+
+ if (h == 1) {
+ x = i;
+ y = 0;
+ } else {
+ x = i % w;
+ y = i / w;
+ }
if (m->tr) {
- if (m->regw == 1) {
- x = 0;
- y = i;
- } else {
- x = i % m->regh;
- y = i / m->regh;
- }
- internal_make_private (m, MAX(m->regh, y+1), MAX(m->regw, x+1),
+ internal_make_private (m, MAX(m->regw, x+1), MAX(m->regh, y+1),
TRUE /* kill_type_caches */);
} else {
- if (m->regh == 1) {
- x = i;
- y = 0;
- } else {
- x = i % m->regw;
- y = i / m->regw;
- }
- internal_make_private (m, MAX(m->regw, x+1), MAX(m->regh, y+1),
+ internal_make_private (m, MAX(m->regw, y+1), MAX(m->regh, x+1),
TRUE /* kill_type_caches */);
}
gel_matrixw_set_at_least_size (m, x+1, y+1);
@@ -1279,8 +1271,8 @@ gel_matrixw_set_vregion (GelMatrixW *m, GelMatrixW *src, int *desti, int len)
x = desti[i];
y = 0;
} else {
- x = desti[i] / m->regw;
- y = desti[i] % m->regw;
+ x = desti[i] % m->regw;
+ y = desti[i] / m->regw;
}
t = gel_matrix_index (m->m, x, y);
@@ -1302,49 +1294,77 @@ gel_matrixw_set_vregion (GelMatrixW *m, GelMatrixW *src, int *desti, int len)
void
gel_matrixw_set_vregion_etree (GelMatrixW *m, GelETree *src, int *desti, int len)
{
+ int srcelts;
+ int max;
+
g_return_if_fail (m != NULL);
g_return_if_fail (src != NULL);
g_return_if_fail (desti != NULL);
g_return_if_fail (len > 0);
-
#ifdef MATRIX_DEBUG
/*debug*/printf ("%s\n", G_GNUC_PRETTY_FUNCTION);
#endif
+ max = getmax (desti, len);
+
if (m->tr) {
- int max = getmax (desti, len);
- int minw = (max / m->regh) + 1;
int i;
-
- internal_make_private (m, MAX (minw, m->regw), m->regh,
- TRUE /* kill_type_caches */);
- ensure_at_least_size (m, minw, m->regh);
+ if (m->regw == 1) {
+ internal_make_private (m, m->regw, MAX (max+1, m->regh),
+ TRUE /* kill_type_caches */);
+ ensure_at_least_size (m, m->regw, max+1);
+ } else {
+ int minw = (max / m->regh) + 1;
+ internal_make_private (m, MAX (minw, m->regw), m->regh,
+ TRUE /* kill_type_caches */);
+ ensure_at_least_size (m, minw, m->regh);
+ }
/* assume that's what ensure/make_us_a_copy does */
g_assert (m->regx == NULL && m->regy == NULL);
for (i = 0; i < len; i++) {
- int x = desti[i] / m->regw;
- int y = desti[i] % m->regw;
- GelETree *t = gel_matrix_index (m->m, x, y);
+ int x, y;
+ GelETree *t;
+ if (m->regw == 1) {
+ x = 0;
+ y = desti[i];
+ } else {
+ x = desti[i] / m->regh;
+ y = desti[i] % m->regh;
+ }
+ t = gel_matrix_index (m->m, x, y);
+
gel_matrix_index (m->m, x, y) = gel_copynode (src);
+
if (t != NULL)
gel_freetree (t);
}
} else {
- int max = getmax (desti, len);
- int minh = (max / m->regw) + 1;
int i;
-
- internal_make_private (m, m->regw, MAX (minh, m->regh),
- TRUE /* kill_type_caches */);
- ensure_at_least_size (m, m->regw, minh);
+ if (m->regh == 1) {
+ internal_make_private (m, MAX (max+1, m->regw), m->regh,
+ TRUE /* kill_type_caches */);
+ ensure_at_least_size (m, max+1, m->regh);
+ } else {
+ int minh = (max / m->regw) + 1;
+ internal_make_private (m, m->regw, MAX (minh, m->regh),
+ TRUE /* kill_type_caches */);
+ ensure_at_least_size (m, m->regw, minh);
+ }
/* assume that's what ensure/make_us_a_copy does */
g_assert (m->regx == NULL && m->regy == NULL);
for (i = 0; i < len; i++) {
- int x = desti[i] % m->regw;
- int y = desti[i] / m->regw;
- GelETree *t = gel_matrix_index (m->m, x, y);
+ int x, y;
+ GelETree *t;
+ if (m->regh == 1) {
+ x = desti[i];
+ y = 0;
+ } else {
+ x = desti[i] % m->regw;
+ y = desti[i] / m->regw;
+ }
+ t = gel_matrix_index (m->m, x, y);
gel_matrix_index (m->m, x, y) = gel_copynode (src);
if (t != NULL)
gel_freetree (t);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]