From: Charles D. <cde...@gm...> - 2016-11-28 16:04:48
|
That works perfectly, thanks Karl. Regards, Charles On Wed, Nov 23, 2016 at 2:53 PM, Karl Rupp <ru...@iu...> wrote: > Hi Charles, > > Right now, if I want to take the negative of every element in a matrix I >> end up doing the following: >> >> // previously assigned >> viennacl::matrix<T> vcl_A; >> >> // matrix of zeros to subtract from >> viennacl::matrix<T> vcl_Z = >> viennacl::zero_matrix<T>(vcl_A.size1(),vcl_A.size2()); >> >> // subtract in-place >> vcl_Z -= vcl_A; >> vcl_A = vcl_Z; >> >> Is there a more efficient way to approach this? Allocating an >> additional entire matrix is proving quite wasteful in some of my >> benchmarks. >> > > What about just > > vcl_A = T(-1) * vcl_A; > > ? This is 'inplace' as requested :-) > > Best regards, > Karli > > > |