# [Maxima] Difference between array and matrix and usage of "~"

=?EUC-CN?B?zO8gvL27wA==?= tianjh04 at mails.tsinghua.edu.cn
Tue Nov 13 06:27:32 CST 2007

```Hello everyone:

I'm a maxima beginner and not very familiar with common lisp. I have
some questions about the difference between array and matrix while I'm
dealing with cross product calculation "~" in package "vect":

1. It seems like cross product "~" operator only works with array, not
matrix, for when I input the following, error occurs:

(C1) load(vect)\$
(C2) A : matrix([1,2,3], [4,5,6])\$
(C3) row(A,1) ~ row(A,2);
(D3)                       [ 1  2  3 ] ~ [ 4  5  6 ]
(C4) express(row(A,1) ~ row(A,2));
~ USED WITH IMPROPER ARGUMENTS: [ 1  2  3 ] [ 4  5  6 ]
#0: EXPRESS1(expn=MATRIX([1,2,3]) ~ MATRIX([4,5,6]))(vect.mac line 165)
-- an error.  Quitting.  To debug this try DEBUGMODE(TRUE);)

In vect.mac, the procedure related to "~" is:

IF PIECE="~" THEN (
ANS: INPART(EXPN,1),  EXPN:INPART(EXPN,2),
IF LISTP(ANS) AND LISTP(EXPN) AND LENGTH(ANS)=LENGTH(EXPN)
----------> line 165
THEN (IF LENGTH(ANS)=2 THEN RETURN(ANS[1]*EXPN[2]
-ANS[2]*EXPN[1]),
IF LENGTH(ANS)=3 THEN RETURN([ANS[2]*EXPN[3]-
ANS[3]*EXPN[2], ANS[3]*EXPN[1]-ANS[1]*EXPN[3],
ANS[1]*EXPN[2]-ANS[2]*EXPN[1]])),
ERROR("~ USED WITH IMPROPER ARGUMENTS:",ANS,EXPN))

We can see that "~" only accepts type list as its arguments. Then we
will know array is implemented as list, but what about matrix, I may
wonder.

2. zero vector returned from "~" simply "shrinks" to scalar zero:

(C1) [1,1,1] ~ [1,1,1];
(D1)                                               0

Why isn't it [0,0,0]?

Thank you very much for your help!
```

More information about the Maxima mailing list