[96] in mathematical software users group

home help back first fref pref prev next nref lref last post

maple questions(compare matrices;packages;parameters)

daemon@ATHENA.MIT.EDU (siman@BOURBAKI.MIT.EDU)
Wed Jun 23 18:17:23 1993

Date: Wed, 23 Jun 93 18:16:42 EDT
From: siman@BOURBAKI.MIT.EDU
To: msug@Athena.MIT.EDU

Dear MSUGers,

It seems that Maple V would not allow me to compare two matrices directly! e.g.

> e := matrix(2,2,[1,2,3,4]);   f := matrix(2,2,[1,2,3,4]);
> if e = f
>   then print(`good`);
> else
>   print(`bad`);
> fi;
                                      bad
>
(blank lines omitted) The same problem occur when comparing vectors.

Is this because matrices & vectors obey those "last name evaluation" rules? (I
only have very vague ideas about what that means, but it seems to be my
constant source of problem). In any case, what should I do to compare two
vectors or matrices (component-wise) ?

One more peculiarity: when I extract one row of a matrix using the "row"
function, Maple tells me that the vector so obtained is of type "table" !!
>
>  m := matrix(4,4,[[1,2,3,4],[0,0,0,0],[1,2,3,4],[1,2,3,4]]);
>  whattype(row(m,2));
                                     table
>
whereas
>   v := vector(4,[0,0,0,0]);
>  whattype(v);
                                     string
>
What's happening?

I posed two maple questions to sci.math.symbolic and got no response, so I
repose them here. Any help are really appreciated!

Thanks!
Siman Wong

**** questions originally posted in sci.math.symbolic ****

Hi Everybody, I have a few simple questions re. Maple (release 5.0). Any
suggestions are welcome!

(1) when I read the linear algebra package via  with(linalg) it automatically
    replace the debugging tool *trace* with the *trace* function for matrices.
    Is there anyway I can keep both, say by renaming one of them?

    Now, one can read part of a library; is it possible to do the opposite
    thing, e.g. read all the linalg package *except* the trace function?

(2) I've come up with a cute trick to do a "call by name" parameter passing
    (cf. Pascal), and I wonder if it is valid Maple: say I have a procedure
    with two parameters,
           gcdlat(x,y)
    In addition to the procedure's function, I'd to change the value of the
    parameter y. I do so by the following:

          gcdlat(x,y,z)
            [ same as before ]
            z := new value of y
          end:

    Then I call this procedure by
          gcdlat(lattice, factor, 'factor');

    ie. first pass the value of "factor" to the procedure, then assign a new
    value to the variable whose name is "factor". The procedure works fine.

    Is this valid Maple? Is there any subtly I should be aware of?

    One more thing: matrices seem to be passed by name -- maple does not
    complain when I modify the entries (it does for ordinary variables), and
    the modified values stay there after the procedure is over. Is it related
    to that "last name" evaluation business?
    Where can I find more info about parameter passing?

Thanks a lot!
Siman

home help back first fref pref prev next nref lref last post