Hello,
I am facing the following performance issues due to internals of quaternion.
abs(q) function is quite slow, and most of the time (according to callgrind) is taken to create valarray which is easily unnecessarily here. valarray requires doing malloc and free, because it is dynamic container, at the same time the size of quaternion is 4 and it is fixed.
So, was was the purpose to use std::valarray internally? As the person who has probably inherited maintenance of quaternion (but who's also been ignoring it!) I feel I should comment - and confess I don't know the answer. But I guess the idea was to take advantage of valarray's vector operations to simplify the implementation. Unfortunately as you rightly point out, this is a dis-optimization in
On 29/07/2015 11:52, Matwey V. Kornilov wrote: this case, particularly as valarray has no allocator parameter, so a scoped storage allocator is out of the question :( To be honest, quaternion and octonion should probably be rewritten to bring them into the post C++ 11 age. There's a lot of cunningly crafted code in there though so it's not necessarily a trivial job. Can you please file a bug report though so this doesn't get lost/forgotten? Thanks, John.