user questions



Hello,

thnaks for answering.

Am Donnerstag, den 06. Dezember schrieb Stavros Macrakis:
> a) It's not clear what you mean by "declaring" a vector.  Very few things
> need to be declared in Maxima.

Telling maxima that a variable is a vector with 3 values, p.e.

  a : [ a[1], a[2], a[3] ];

I did not find an othe way to do so.

> 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.

Yes.

> 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.

How to code a function/macro that allows to define a variable with the
same name as the parameter. I also failed to declare something with
expanding the first parameter p.e. ?declare(concat(i, _1), real)?.

> Since I'm not sure what problem you're trying to solve, I'm not sure
> what a better solution is.

I'm trying to tell maxima that a variable is a vector from R?.

> 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).

O.K.

> 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

Hmm, I tried this, but it does not seem to work.

  a : makelist(a[i],i,1,3);
        [a?, a?, a?]

  declare(a, complex);
          done

  featurep(a, complex);
          false

  featurep(a[1], complex);
          false

so featurep says: not 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
> >
> >


	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