11-12-2015, 03:05 PM
I am having great difficulty doing cas matrix operations in a program.
The test case below shows one of the problems
EXPORT hsbat2(M)
BEGIN
LOCAL I,P,Q;
DEBUG;
I := inv(M); <- the inverse seems ok. Both M and I are lists
P := I*M; <- a problem here since '*' does silly list multiply
Q := simplify(P); <- since P is wrong this doesnt do much.
{M,I,P,Q}
END;
From the cas console by hand the matrices are sugar coated with
[[..]] and the parser knows that they are matrices (hidden type) so
it does the right thing.
Not so in a program where '*' sees things as lists so it multiplies element
by element, the wrong answer for matrices and vectors.
If there is a multiplyMat(M1,M2) like function, i cant find it.
Apparenty most of the cas functions expecting vectors or matrices treat
lists appropriatly. Not so for lexical operators, i guess.
Another problem i have is determing the return type when matrices or vectors
are involve since everything is a list.
Do i need to write my own matrix /vector multiply routines for program use[/u]?
The test case below shows one of the problems
EXPORT hsbat2(M)
BEGIN
LOCAL I,P,Q;
DEBUG;
I := inv(M); <- the inverse seems ok. Both M and I are lists
P := I*M; <- a problem here since '*' does silly list multiply
Q := simplify(P); <- since P is wrong this doesnt do much.
{M,I,P,Q}
END;
From the cas console by hand the matrices are sugar coated with
[[..]] and the parser knows that they are matrices (hidden type) so
it does the right thing.
Not so in a program where '*' sees things as lists so it multiplies element
by element, the wrong answer for matrices and vectors.
If there is a multiplyMat(M1,M2) like function, i cant find it.
Apparenty most of the cas functions expecting vectors or matrices treat
lists appropriatly. Not so for lexical operators, i guess.
Another problem i have is determing the return type when matrices or vectors
are involve since everything is a list.
Do i need to write my own matrix /vector multiply routines for program use[/u]?