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.