Re: FORTRAN style, not OK?

• To: mathgroup at smc.vnet.net
• Subject: [mg26848] Re: FORTRAN style, not OK?
• From: "Allan Hayes" <hay at haystack.demon.co.uk>
• Date: Thu, 25 Jan 2001 01:13:25 -0500 (EST)
• References: <94m96g\$3nd@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Toshi,
I'm not famiar with Fortran, but here is what is happening with Mathematica:

1) When v has no value the evaluation steps are

v = v - c
the rule v = v - c is stored
v - c   is output
the rule is then used on this output to give output (v-c)-c
the rule is then used on *this* output to give output ((v-c)-c)-c
and so on, until the recursion limit is reached.

2) When v has a value, say p (it in initialized) the evaluation steps are

v = v - c
the right side is evaluated to give v = p - c
the rule v = p - c is stored
p -c is output.

So in this case we can use v = v -c repeatedly:

Clear[v]

v = p;
Do[v = v - c, {7}]
v

-7 c + p

Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

"Toshiyuki (Toshi) Meshii" <meshii at mech.fukui-u.ac.jp> wrote in message
news:94m96g\$3nd at smc.vnet.net...
> Hello,
>
> I found out a case in which I cannot directly use FORTRAN statement in
> Mathematica programming.
> Here is the case good in FORTRAN.
>
> v=v-c
>
> However in Mathematica, it seems that I have to use a trick like this.
>
> temp=v;
> v=temp-c
>
> Is there more smart way for doing the above?
> ___________________________________
> The final goal for me is to do the following.
>
> Do[
>  Do[
>       v[i][j][k] = v[i][j][k] - va[j]
>       ,{j, 3}]
>     ,{k, 100}];
>
> -Toshi
>
>
>

```

• Prev by Date: Re: Who can help me?
• Next by Date: Re: Book
• Previous by thread: Re: Fw: FORTRAN style, not OK?
• Next by thread: Re: FORTRAN style, not OK?