cyclops-community / ctf

Cyclops Tensor Framework: parallel arithmetic on multidimensional arrays
Other
199 stars 53 forks source link

Scale with Endomorphism #160

Open bonfus opened 9 months ago

bonfus commented 9 months ago

Hi, thanks for this fantastic library!

In order to make this work:

   Tensor<dtype> N(n_spin, len_N);
    N.fill_random(0.0,1.0);
    dtype scal(0,2.*M_PI);
    auto f = Endomorphism<dtype>([](dtype a){ return exp(a);});
    N.scale(scal, idxi, f);

I had to apply this patch:

--- a/src/interface/tensor.cxx
+++ b/src/interface/tensor.cxx
@@ -1770,7 +1770,7 @@ NORM_INFTY_INST(double)
   void Tensor<dtype>::scale(dtype               alpha,
                             const char *        idx_A,
                             Endomorphism<dtype> fseq){
-    CTF_int::scaling scl = CTF_int::scaling(this, idx_A, &fseq, (char const *)&alpha);
+    CTF_int::scaling scl = CTF_int::scaling(this, idx_A, (char const *)&alpha, &fseq);
     scl.execute();
   }

Is this a bug or I'm using it wrong?