From: Tama Ma <pin...@it...> - 2010-07-20 15:07:46
|
Hi, If what you want is matrix product, then the following is the solution: typedef double valuetype; blitz::Array<valuetype, 2> A; blitz::Array<valuetype, 1> B; blitz::Array<valuetype, 1> C; A.resize(2,2); B.resize(2); C.resize(2); C = blitz::sum(A(blitz::tensor::i, blitz::tensor::j) * B(blitz::tensor::j)) , blitz::tensor::j); A.free(); B.free(); C.free(); Hope this works! Best regards, Tama Ma On Jul 18, 2010, at 10:19 PM, W.P. McNeill wrote: > I want to do outer multiplication on two Arrays, a 2x2 called A and a 2x1 called B. If I want to multiply over the first index of A, I can say this: > > firstIndex i; > secondIndex j; > C = A(i,j) * B(i); > > If I want to multiply over the second index, I can say this: > > ... > C = A(i,j) * B(j); > > This requires me to decide which index I'm multiplying over when I write the source code. Is there a way to make a decision about which index to multiply over at runtime? Is there a way to do this for arbitrary dimensions in a matrix? > > I don't see how to do this from looking at the header files. I tried calling A(...) and B(...) with TinyVectors of IndexPlaceholder objects, but that doesn't work. > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first_______________________________________________ > Blitz-support mailing list > Bli...@li... > https://lists.sourceforge.net/lists/listinfo/blitz-support -- ETH Zurich Tama Ma Institute for Theoretical Physics HIT K31.3 Wolfgang-Pauli-Str. 27 8093 Zurich Switzerland pin...@it... www.phys.ethz.ch/~pingnang +41 44 633 76 55 Phone +41 44 633 11 15 Fax |