A rough cut...using templates to support multiple types.  Had to create a separate set of template functions to handle float2,double2,int2 types.  Only testing a single type in the example application and matlab script.