From: Patrik J. <co...@fa...> - 2014-08-20 22:05:07
|
A clarification: blitz never creates temporary arrays (even if it would be advantageous to do so). But in this case it will *evaluate* the rhs for every value of i,j,k, even if not all of them appear in the expression. On Wed, Aug 20, 2014 at 11:36 AM, Patrik Jonsson <co...@fa...> wrote: > Yes, the tensor expressions must necessarily evaluate the rhs for > every element of the lhs. I'm not aware of a way to take yscale and > copy it into an arbitrary subset of A without a loop. I'm not even > sure what the syntax for that would look like. > > > On Wed, Aug 20, 2014 at 7:45 AM, Stuart Levy <sa...@il...> wrote: >> Hmm, thanks, Patrik. >> >> That doesn't quite work - BZ_DEBUG reports that it's assigning a rank-2 >> expression to a rank-3 array. >> >> It does seem to work if I write all the tensor terms, like >> >> A *= ( 0*tensor::i + yscale( tensor::j ) + 0*tensor::k ); >> >> That does seem to create a 3-D expression with the required shape. But >> is it creating a whole 3D chunk of data to do it? I suspect it does >> and wish it wouldn't... It'd be very wasteful of cache, and I'm trying >> to do this efficiently on pretty large arrays. >> >> >> On 8/20/14 12:21 PM, Patrik Jonsson wrote: >>> Hi Stuart, >>> >>> I'm a bit rusty, but it seems like >>> >>> A = yscale(tensor::j); >>> >>> would work? >>> >>> Cheers, >>> >>> /Patrik >>> >>> >>> On Wed, Aug 20, 2014 at 7:02 AM, Stuart Levy <sa...@il...> wrote: >>>> Is there any concise Blitz way to do the equivalent of >>>> >>>> Array<float,3> A( Nz,Ny,Nx ); >>>> Array<float,1> yscale( Ny ); >>>> >>>> for i ... >>>> for j ... >>>> for k ... >>>> A(i,j,k) *= yscale(j) >>>> >>>> ? >>>> >>>> Do I just need to write it as an explicit loop over the 1-D axis? >>>> >>>> Or make a goofy (Nz,Ny,Nx) array with a hand-constructed stride vector >>>> that has the Z- and X-strides equal to zero? >>>> >>>> One reason I'd like this: trying to implement curl() over a grid with >>>> nonuniform spacing on each axis. >>>> >>>> If I can write this as an array expression, maybe it can fit in a >>>> stencil. Otherwise I'm making a mess of loops which looks a lot like >>>> the C style I was hoping to avoid... >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Slashdot TV. >>>> Video for Nerds. Stuff that matters. >>>> http://tv.slashdot.org/ >>>> _______________________________________________ >>>> Blitz-support mailing list >>>> Bli...@li... >>>> https://lists.sourceforge.net/lists/listinfo/blitz-support >>> ------------------------------------------------------------------------------ >>> Slashdot TV. >>> Video for Nerds. Stuff that matters. >>> http://tv.slashdot.org/ >>> _______________________________________________ >>> Blitz-support mailing list >>> Bli...@li... >>> https://lists.sourceforge.net/lists/listinfo/blitz-support >>> >> >> >> ------------------------------------------------------------------------------ >> Slashdot TV. >> Video for Nerds. Stuff that matters. >> http://tv.slashdot.org/ >> _______________________________________________ >> Blitz-support mailing list >> Bli...@li... >> https://lists.sourceforge.net/lists/listinfo/blitz-support |