Two things here: I personally prefer implementing binary operators where there is no main or principal object involved as unbound function instead of member function. That's a matter of taste though.
Well, I'll try that and see if it helps the optimizer.
for( unsigned i=0; i < dim; i++ )Ideomatic (but I don't think it's faster here) would be to use 'i!=dim' and '++i'. Should be in any beginners introduction to iterators and for loops.
The beginner's book was probably different 15 years ago when I learned the loop. ;)
Finally, one things you could try is to apply (partial) specialisation for this, unrolling the loop for some cases. Maybe the boost metaprogramming library might help you in that task, but I'm no expert in that field.
I had tried many variations on that already, and strangely everything I did by hand (unrolling, specialization, etc.) ended up making it slower.
A last thing I noticed is that sometimes float is faster than double. This strongly depends on the processor though, so never hard-wire either choice into your program.
The "rtype" is either a double or long double in my program, and although I know the float is faster in our program (from testing), it doesn't have the precision we need (we're borderline needing long double).
-- edA-qa mort-ora-y Idea Architect http://disemia.com/ _______________________________________________ Help-gplusplus mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-gplusplus
