In comparison, the performance they're getting out of Haskell is coming from comparatively mundane, easy to understand code. That's pretty impressive.
Or another way of putting it: It looks like naive Haskell outperforms naive C++, and naive Haskell is not that much slower than carefully-tuned C++.
template < typename Derived >
typename Derived::Scalar norm2( const MatrixBase <Derived >& v ) {
return v.dot(v);
}
Why is it a template function? Why does it return Derived::Scalar instead of double? Dear god, Eigen is magic.