diff --git a/ChangeLog b/ChangeLog index fba4351bf562492df58b15d3eb2b6e5ba9dfddda..508c293e2b9247f31f0aac7367c6cb95ecd1b834 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Oct 24 20:33:24 2018 Jiri (George) Lebl + + * lib/linear_algebra/misc.gel: optimize the Make(Row)Vector functions + in case of vector input. + + * src/geniustests.txt: Add a bunch of tests + Wed Oct 24 13:38:31 2018 Jiri (George) Lebl * src/funclib.c, src/funclibhelper.cP: Add AppendVector, plus a few diff --git a/lib/linear_algebra/misc.gel b/lib/linear_algebra/misc.gel index 1aea93ff57a9954afa9d90fb47e82f0e7f0d5553..cd7ec6a0c51a1c4cd0b36135cee28b95605f3ac6 100644 --- a/lib/linear_algebra/misc.gel +++ b/lib/linear_algebra/misc.gel @@ -345,7 +345,9 @@ function MakeVector(A) = ( else if not IsMatrix(A) then (error("MakeVector: argument not a matrix");bailout) else if columns(A) == 1 then - return A; + return A + else if rows(A) == 1 then + return A.'; r = null; for k=1 to columns(A) do ( r = [r;A@(,k)] @@ -361,7 +363,9 @@ function MakeRowVector(A) = ( else if not IsMatrix(A) then (error("MakeRowVector: argument not a matrix");bailout) else if rows(A) == 1 then - return A; + return A + else if columns(A) == 1 then + return A.'; r = null; for k=1 to rows(A) do ( r = [r,A@(k,)] diff --git a/src/geniustests.txt b/src/geniustests.txt index d898a8d66556fd15838e90e33a3fee3c5b806ae5..06244f5868684457241c1d0690eb97b2fa9c821d 100644 --- a/src/geniustests.txt +++ b/src/geniustests.txt @@ -19,6 +19,7 @@ if 66 then 4 else 5 4 if 0 then 4 else 5 5 a=1 1 a=1;a 1 +a=1;b=a;a=2;b 1 a=2;a=a+1;a 3 a=1;b=&a;b (&a) a=1;b=&a;c=b;c (&a) @@ -229,6 +230,10 @@ prime(10) 29 MaxDigits=12;exp(3*ln(2)) 8.0 if(0)then 1;0 0 24/2 12 +a@(3)=3;a [0,0,3] +a=null;a@(3)=3;a [0,0,3] +a=[1;2;5];a@(3)=3;a [1;2;3] +a=[1;2;5];a@(5)=3;a [1;2;5;0;3] 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] @@ -1287,17 +1292,36 @@ Im(4) 0 0.00000000000000000000000000000000000001+1.1i 0.0+1.1i -0.00000000000000000000000000000000000001+1.1i -0.0+1.1i Subfactorial([1,2,3,4,5,6]) [0,1,2,9,44,265] +Subfactorial([1;2;3]) [0;1;2] Subfactorial(0) 1 Subfactorial(-1) Subfactorial(-1) Factorial([0,1,2,3,4,5,6]) [1,1,2,6,24,120,720] DoubleFactorial([0,1,2,3,4,5,6]) [1,1,2,3,8,15,48] +DoubleFactorial(-1) DoubleFactorial(-1) StripZeroColumns(zeros(4,4))+0 ((null)+0) Image(zeros(4,4))+0 ((null)+0) +rows(null) 0 +rows(1) rows(1) +rows([1,2]) 1 +rows(`[1,[1;2]]) 1 +rows(`[1;[1;2]]) 2 +rows([1;2]) 2 +rows([1,3,1;2,8,2]) 2 +columns(null) 0 +columns(1) columns(1) +columns([1,2]) 2 +columns(`[1,[1,2]]) 2 +columns(`[1;[1,2]]) 1 +columns([1;2]) 1 +columns([1,3,1;2,8,2]) 3 elements(null) 0 +elements(1) elements(1) elements([1,2]) 2 elements(`[1,[1,2]]) 2 +elements([1;[1,2]]) 4 elements([1;2]) 2 elements([1,3;2,8]) 4 +elements([1,3,1;2,8]) 6 v=[1,2,3];w=AppendElement(v,5) [1,2,3,5] v=[1;2;3];w=AppendElement(v,5) [1;2;3;5] v=[1];w=AppendElement(v,5) [1,5] @@ -1305,6 +1329,9 @@ v=null;w=AppendElement(v,5) [5] v=[1,2,3];w=AppendElement(v,5);v [1,2,3] v=[1,2,3];w=AppendElement(v,v) [1,2,3,[1,2,3]] v=[1,2,3];w=AppendElement(v,v);v [1,2,3] +AppendElement(null,null) [(null)] +AppendElement([1,2,3],null) [1,2,3,(null)] +AppendElement(1,1) AppendElement(1,1) load "nullspacetest.gel" true load "longtest.gel" true load "testprec.gel" true