MathGroup Archive 2011

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

Search the Archive

Re: Array from for-loop iterations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg116865] Re: Array from for-loop iterations
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Thu, 3 Mar 2011 05:55:15 -0500 (EST)

vec = Array[a, {8, 3}];

f0 = 0.5;

sol1 = (#[[3]] - f0)^2 + (#[[1]] - f0) (#[[2]] - #[[1]]) -
    (#[[2]] - f0) (#[[3]] - f0) & /@ vec

sol1 == Table[(vec[[k, 3]] - f0)^2 + (vec[[k, 1]] - f0) (vec[[k, 2]] -
       vec[[k, 1]]) - (vec[[k, 2]] - f0) (vec[[k, 3]] - f0), {k,
   Length[vec]}]

True


Bob Hanlon

---- Lengyel Tamas <lt648 at hszk.bme.hu> wrote:

==========================
Dear Mathworld Community,

I am tackling a simple problem,

I have written a simple for-loop using elements from an array of
3-dimensional vectors:

f0=0.5;
For[k = 1, k < 9, k++,

 (vec[[k, 3]] - f0)^2 + (vec[[k, 1]] - f0) (vec[[k, 2]] - vec[[k, 1]]) -
vec[[k, 2]] - f0) (vec[[k, 3]] - f0)
    ]

I don't know how to make an array out of the computed results.

Please help my silly soul.

Thank you.

Tam=C3=A1s



  • Prev by Date: player pro and notebooks
  • Next by Date: Any recommendations for new hardware (quadcore/GPUs)?
  • Previous by thread: Array from for-loop iterations
  • Next by thread: Re: Array from for-loop iterations