[Bug report] `dr::scatter` for Quaternion seems to be incorrect
Chaphlagical opened this issue · 3 comments
Chaphlagical commented
Hi, I try following code for setting quaternion data:
using Float = dr::LLVMArray<float>;
int main()
{
jit_init(JitBackend::LLVM);
dr::Array<Float, 3> x = dr::zeros<dr::Array<Float, 3>>(3);
dr::scatter(x, dr::Array<Float, 3>(1, 2, 3), 0);
dr::scatter(x, dr::Array<Float, 3>(11, 12, 13), 1);
dr::scatter(x, dr::Array<Float, 3>(21, 22, 23), 2);
dr::Quaternion<Float> y = dr::zeros<dr::Quaternion<Float>>(3);
dr::scatter(y, dr::Quaternion<Float>(1, 2, 3, 4), 0);
dr::scatter(y, dr::Quaternion<Float>(11, 12, 13, 14), 1);
dr::scatter(y, dr::Quaternion<Float>(21, 22, 23, 24), 2);
std::cout << x << std::endl;
std::cout << y << std::endl;
return 0;
}
Output:
[[1, 2, 3],
[11, 12, 13],
[21, 22, 23]]
[4 + 21i + 22j + 23k,
14 + 0i + 0j + 0k,
24 + 0i + 0j + 0k]
However,
[4 + 1i + 2j + 3k,
14 + 11i + 12j + 13k,
24 + 21i + 22j + 23k]
is what I expected.
Is it a Dr.JIT bug or just I didn't do it right?
njroussel commented
This sounds like a Dr.Jit bug, and I can only reproduce it in C++. In Python it works fine, it produces the result that you expected. I'll look into this.
Chaphlagical commented
Thanks!