MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Fw: FORTRAN style, not OK?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg26890] Re: [mg26806] Fw: FORTRAN style, not OK?
  • From: BobHanlon at aol.com
  • Date: Fri, 26 Jan 2001 01:27:33 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

There is only a problem if v is not assigned a value prior to using it in a 
recursive looking assignment. It is the lack of an initial assignment that 
causes it to go looking forever.

v=5;

v = v - c

5 - c

v = a;

v = v - c

a - c

SubtractFrom

(v = 0; Table[v -= c, {5}])

{-c, -2*c, -3*c, -4*c, -5*c}

AddTo

(v = 0; Table[v += c, {5}])

{c, 2*c, 3*c, 4*c, 5*c}

TimesBy

(v = 1; Table[v *= c, {5}])

{c, c^2, c^3, c^4, c^5}

DivideBy

(v = 1; Table[v /= c, {5}])

{c^(-1), c^(-2), c^(-3), c^(-4), c^(-5)}

Clear[v];

Table[v[i,j,k] = 0, {i, 2}, {j,2},{k,2}];

Table[v[i,j,k] = v[i,j,k] - va[j], {i, 2}, {j,2},{k,2}]

{{{-va[1], -va[1]}, {-va[2], -va[2]}}, 
 {{-va[1], -va[1]}, {-va[2], -va[2]}}}


Bob Hanlon

In a message dated 2001/1/24 5:24:18 AM, meshii at mech.fukui-u.ac.jp writes:

>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?
>Please let me know.
>___________________________________
>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}];
>


  • Prev by Date: Re: Rewriting of Trigonometric Functions
  • Next by Date: Re: triangles in circles
  • Previous by thread: Re: FORTRAN style, not OK?
  • Next by thread: Re: Fw: FORTRAN style, not OK?