Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Variable substitution within n matrices

18 views
Skip to first unread message

Nicola Bressanin

unread,
Jan 11, 2012, 7:58:36 AM1/11/12
to
I needed a program to read a few 3x3 matrices containing
variables,like N and T.
N and T are stored in the same directory; when invoking the program
(SOST) the newer N and T are present on stack levels 1 and 2.I solved
it with ->NUM in this program,but was there another(better) way to do
it?is SUBST helpful?

SOST
<<
'T' STO
'N' STO
Rr1 Rr2 Rr3 Rr4
->NUM 'Rr4S' STO
->NUM 'Rr3S' STO
->NUM 'Rr2S' STO
->NUM 'Rr1S' STO
Rr1S Rr2S Rr3S Rr4S
>>

Han

unread,
Jan 11, 2012, 12:21:03 PM1/11/12
to
On Jan 11, 7:58 am, Nicola Bressanin <nicola.bressa...@gmail.com>
wrote:
From the listing you posted, it appears that Rr1, Rr2, Rr3, and Rr4
are static. Suppose that Rr1 looks like:

[ [ 1 2 N ] [ 4 5 T ] [ 7 8 9 ] ]

You could use:

<<
-> T N
<<
[ [ 1 2 N ] [ 4 5 T ] [ 7 8 9 ] ]
... insert the other 3 matrices here ...

>>
>>

This treats T and N as local variables. It takes T and N from the
stack, and then leaves four matrices with the T and N values
substituted into the matrices themselves for you to do whatever you
wish with them. This reduces the number of variables you have to keep
around in your directory.

Nemo

unread,
Jan 11, 2012, 2:10:27 PM1/11/12
to
Hi, something like :

SOST : « -> T N L « L 1 « ->NUM ->NUM » DOLIST » »

Example :

1 2 { Rr1 Rr2 Rr3 Rr4 } SOST

Eventually Followed by { Rr1S Rr2S Rr3S Rr4S } STO

Of course you can put the list in the SOST prog if it is always the
same matrices

Gilles

Nemo

unread,
Jan 11, 2012, 2:54:39 PM1/11/12
to
Another way is to use the | function. You can try this to
understand :


Rr1 « {'N' 3 'T' 5 } | » MAP

| do substitutions in an algebraic object and MAP apply a program on
each element of a matrice.In this case, N become 3 and T become 5

| is very interessing, for example you can do such things : Rr1 « {'N'
'N+1' 'T' '2*T' } | » MAP

Nicola Bressanin

unread,
Jan 13, 2012, 5:43:23 AM1/13/12
to
Thanks i'll try it
0 new messages