mitsuba-renderer / enoki

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

Cast std::array to enoki::array #83

Closed andyyankai closed 4 years ago

andyyankai commented 4 years ago

I tried

float arr[4] = { 10.f, 20.f, 30.f, 40.f };
float* ptr;
ptr = arr;
FloatC arr_enoki = load<float>(ptr);
std::cout << "see if this is working" << std::endl;
std::cout << arr_enoki << std::endl; // [10]
andyyankai commented 4 years ago

Also, it seem scatter_add is working, but I hope to know if there is any way to avoid the loop, just for the performance reason

Speierers commented 4 years ago

load<float>(ptr) will return a simple float as this is the type you specified as template parameter. (here the first one of the list, so 10.f).

You can construct the FloatC passing the list-initializion I believe:

FloatC arr_enoki = { 1.f, 2.f, 3.f, 4.f };

You should also give a try to functions like linspace<FloatC> and arange<FloatC>, those are really useful.