mitsuba-renderer / enoki

Enoki: structured vectorization and differentiation on modern processor architectures
Other
1.26k stars 94 forks source link

error: lvalue required as left operand of assignment #84

Closed andyyankai closed 4 years ago

andyyankai commented 4 years ago

Trying to do this:

FloatD arr = {1.f,3.f,2.f,5.f,6.f,2.f,6.f}; FloatD t = 0.0f; set_requires_gradient(t);

arr[2] = arr[2] + t (error: lvalue required as left operand of assignment)

Speierers commented 4 years ago

You will need to use mask-assignement for this. Something like this:

mask_t<FloatD> mask = {0, 1, 0, 0, ...};
arr[mask] += t;

You could also use arange to craft some fancier masks based on indexing.

Speierers commented 4 years ago

Please note that you will often find answers to such questions by reading the documentation carefully. We would like to keep github issues for actual issues/bugs with the library 😉