Disable buffer security checks.
Remove duplicated call to std::cos
Add vmax/vmin function that return by value.

For details see: http://randomascii.wordpress.com/2013/11/24/stdmin-causing-three-times-slowdown-on-vc/