Introduce N-ary map
Hi Klaus,
Would be possible to extend the map functionality to accept N
arguments? e.g.
blaze::DynamicMatrix<double> A, B, C, D;
D = map( A, B, C, []( double a, double b, double c ) {
return custom_Op(a,b,c);
} );
Thanks,
Max
Comments (6)
-
-
reporter - marked as minor
-
reporter Hi,
I'm downgrading the priority to minor. I found a work around that iterates over dynamic matrices (the only use case I'm worried about) using
loada
andstore
member functions.Perhaps one use-case to consider is that I have multiple outputs as well, i.e. I have an API at the moment that looks like this:
template <typename Datapar> BLAZE_STRONG_INLINE void LLF_flux(const Datapar& gravity, const Datapar& ze_in, const Datapar& qx_in, const Datapar& qy_in, const Datapar& ze_ex, const Datapar& qx_ex, const Datapar& qy_ex, const Datapar& bath, const Datapar& sp, const Datapar& nx, const Datapar& ny, double* flux_ze_addr, double* flux_qx_addr, double* flux_qy_addr)
Where I need to compute temporaries that get used in multiple outputs. I'm not sure if this fits cleanly into an Expression template idiom, but maybe you could do something with
std::tie
or expose a subroutine like interface. -
-
assigned issue to
-
assigned issue to
-
- changed status to open
-
- changed status to resolved
Summary
The feature has been implemented, tested, optimized, and documented as required. It is immediately available via cloning the Blaze repository and will be officially released in Blaze 3.7.
N-ary map() Operation
Via the
map()
functions it is possible to execute componentwise custom operations on vectors. The N-arymap()
functions can be used to apply an operation componentwise to the elements of N dense vectors or N dense matrices (whereN <= 6
). The following example demonstrates a the definition of the ternary multiply-accumulate (MAC) operation for three dense vectors with identical transpose flag:template< typename VT1 , typename VT2 , typename VT3 , bool TF > decltype(auto) mac( const DenseVector<VT1,TF>& dv1, const DenseVector<VT2,TF>& dv2, const DenseVector<VT3,TF>& dv3 ) { return map( ~dv1, ~dv2, ~dv3, []( auto a, auto b, auto c ){ return a*b + c; } ); }
- Log in to comment
Hi Max!
Thanks a lot for creating this proposal. This is of course a very reasonable and natural extension that we have also considered. The task is already on our list, but currently doesn't have the highest priority. Still we will try to implement the N-ary map operation as soon as possible. Thanks again,
Best regards,
Klaus!