Sounds like [std::valarray](http://www.cplusplus.com/reference/valarray/) already have all the expression templates needed to optmize the operations...