user questions



a) It's not clear what you mean by "declaring" a vector.  Very few things
need to be declared in Maxima.

b) Your function r3vect is trying to do something very odd.  "::" is the
assignment function that *evaluates* the left-hand side.  So presumably x
needs to be a list of variable names, e.g. [a,b,c].  It then assigns a:
[a[1],a[2],a[3]] -- is that really what you want.  It does not work for
[x], because it is trying to find the second and third elements of the *list
* [x], which of course do not exist.  Note that x[i] can mean two different
things: if x is a list, it is the *i*'th element; if it is a symbolic
variable, it is just the symbolic subscripted variable x-sub-i.

Since I'm not sure what problem you're trying to solve, I'm not sure what a
better solution is.  Do you want to generate the 3-vector [a[1],a[2],a[3]]?
 Then something like makelist(a[i],i,1,3) will do. Do you want to do this
for an arbitrary variable name; then how about r3vect(var) :=
makelist(var[i],i,1,3).

c) Maxima cannot declare individual subscripted elements real or complex;
declaring a variable real or complex declares all its subscripted forms to
be the same.  Variables are assumed real by default.  Thus:

       carg([q,q[1]]) => [atan2(0,q),atan2(0,q[1])]
                default is real

       declare(r,real)$ carg([r,r[1]]) => [atan2(0,r),atan2(0,r[1])]
                 explicit declaration as real changes nothing

       declare(c,complex)$ carg([c,c[1]])
=> ['carg(c),atan2('imagpart(c[1]),'realpart(c[1]))]
                 explicit declaration as complex

          -s

On Thu, Dec 6, 2012 at 8:30 AM, M G Berberich <berberic at fmi.uni-passau.de>wrote:

> Hello,
>
> I'm declaring vectors from R? by a macro:
>
>   r3vect(x) := for i in x do i :: [ i[1], i[2], i[3] ];
>
> This works mostly. It does not work for r3vect([x]):
>
>   part: invalid index of list or matrix.
>
> A vector named ?x? can not be declared this way. Why is this?
>
> After ?r3vect([a]);? a is a vector: [a?, a?, a?], but the elements can
> not be declared real:
>
>   (%i5) declare(a[1], real);
>
>   declare: improper argument: a?
>
> Is there another (better) way to declare vectors from R??
>
>         MfG
>         bmg
>
> --
> ?Des is v?llig wurscht, was heut beschlos- | M G Berberich
>  sen wird: I bin sowieso dagegn!?          | berberic at fmi.uni-passau.de
> (SPD-Stadtrat Kurt Schindler; Regensburg)  |
> www.fmi.uni-passau.de/~berberic
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>