Re:Haskell Beats C Using Generalized Stream Fusion [pdf]
by pbsd on Sunday April 07, 2013 @12:59PM
(#5507790)
While 'Derived::Scalar' could very well be replaced by 'double' in that case, you need the templated function to catch the temporary type (expression template) that represents the u-v computation. This lets Eigen compute u[i]-v[i] and the dot product inside the same inner loop.
Without the templated function, the compiler would first generate the subtraction into a temporary vector, and then compute the dot product on that vector.
Without the templated function, the compiler would first generate the subtraction into a temporary vector, and then compute the dot product on that vector.