Improved the vector math library by adding optional user supplied temp memory to
avoid extra mallocs for repeated calls.