Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1999
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1999

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

Search the Archive

Re: Iterators, again

  • To: mathgroup at smc.vnet.net
  • Subject: [mg20468] Re: Iterators, again
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Wed, 27 Oct 1999 02:04:40 -0400
  • Organization: Universitaet Leipzig
  • References: <7v3b55$5ss@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Eric,

stop to use nested Part[] calls !
If you say

m[[i,j]] you will get allmost the same as with m[[i]][[j]] but
internal it is different
m[[i,j]] is Part[m,i,j] (one call) and

m[[i]][[j]] is Part[Part[m,i],j] when the outer Part[] call is evaluated
the i-th row of m is copyed to a vector and than the outer Part[] gives
just one element.

You don't need any loops because

> Sum[(something[[m]][[i]])(something[[n]][[i]]),
>         {i, 1, itop}]

is Dot[m,Transpose[something]]

Regards
  Jens

Eric Spahr wrote:
> 
> I am trying to build a matrix:
>         Array[MyArray, {jtop,jtop}] // Array[f, {m,n}]
> where   jtop = some number;
>         m = 1...jtop;
>         n = 1...jtop;
>         itop = some number;
>   and I want to
> Sum[(something[[m]][[i]])(something[[n]][[i]]),
>         {i, 1, itop}]for it, thus:
>         Array[MyArray =
> Sum[(something[[m]][[i]])(somethingElse[[n]][[i]]),
>         {i, 1, itop}],{jtop,jtop}].
> 
> In other words, I want to iterate through inner n with m
> = 1, then through outer m with n iterating again. (and,
> of course, i iterating 1 -> itop each time.
>         This doesn't seem to be able to pick up the part
> specifications.
> though it does build the appropriately sized matrix.
> Nested For[]'s don't seem to work either.
> Thanks in advance.


  • Prev by Date: Re: A simple question? Please help
  • Next by Date: Re: Non standard evaluation troubles.
  • Previous by thread: Iterators, again
  • Next by thread: entering stuff using escape