cyclops-community / ctf

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

[question] setting all nonzeros to a value #142

Closed rohany closed 2 years ago

rohany commented 2 years ago

Is it possible to read a tensor from disk and then set all nonzero entries of that tensor to a particular value? I don't see anything like this in the API, so double checking here.

raghavendrak commented 2 years ago

You can use Transform // add 1 to all nonzeros in v Transform<float>([](float & a){ a+=1; })(v["i"]); Look at codes in ./examples

rohany commented 2 years ago

Thanks, this worked!