Commit 0704c342 authored by Jiri (George) Lebl's avatar Jiri (George) Lebl

Wed Oct 24 20:33:24 2018 Jiri (George) Lebl <jirka@5z.com>

	* lib/linear_algebra/misc.gel: optimize the Make(Row)Vector functions
	  in case of vector input.

	* src/geniustests.txt: Add a bunch of tests
parent 7bd9728b
Wed Oct 24 20:33:24 2018 Jiri (George) Lebl <jirka@5z.com>
* 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 <jirka@5z.com>
* src/funclib.c, src/funclibhelper.cP: Add AppendVector, plus a few
......
......@@ -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,)]
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment