diff --git a/build_linux64/libamsculib2.linux64.a b/build_linux64/libamsculib2.linux64.a index 80d41b0..abba8e2 100644 Binary files a/build_linux64/libamsculib2.linux64.a and b/build_linux64/libamsculib2.linux64.a differ diff --git a/build_linux64/objstore/cuvect2f.o b/build_linux64/objstore/cuvect2f.o index 65df8f0..2e88046 100644 Binary files a/build_linux64/objstore/cuvect2f.o and b/build_linux64/objstore/cuvect2f.o differ diff --git a/build_linux64/objstore/cuvect3f.o b/build_linux64/objstore/cuvect3f.o index ef6f84a..b619a80 100644 Binary files a/build_linux64/objstore/cuvect3f.o and b/build_linux64/objstore/cuvect3f.o differ diff --git a/build_linux64/test b/build_linux64/test index c815a3d..4cc4378 100644 Binary files a/build_linux64/test and b/build_linux64/test differ diff --git a/include/amsculib2/cuvect2f.hpp b/include/amsculib2/cuvect2f.hpp index dcab448..ed6f58c 100644 --- a/include/amsculib2/cuvect2f.hpp +++ b/include/amsculib2/cuvect2f.hpp @@ -45,6 +45,8 @@ namespace amscuda const float & _m10, const float & _m11 ); + __host__ __device__ explicit cumat2f(const float* data2x2); + __host__ __device__ float& operator[](const int &I); __host__ __device__ float& operator()(const int &I, const int &J); __host__ __device__ float& at(const int &I, const int &J); @@ -65,8 +67,8 @@ namespace amscuda __host__ __device__ cumat2f transpose(); __host__ __device__ cumat2f inverse(); - __host__ __device__ float* data(); //pointer to float[9] representation of matrix - __host__ __device__ const float* data() const; //pointer to float[9] representation of matrix + __host__ __device__ float* data(); //pointer to float[4] representation of matrix + __host__ __device__ const float* data() const; //pointer to float[4] representation of matrix //In place operations (to save GPU register use) __host__ __device__ cumat2f& operator+=(const cumat2f &rhs); @@ -82,10 +84,21 @@ namespace amscuda __host__ __device__ cuvect2f cuvect2f_normalize(const cuvect2f &a); __host__ __device__ cuvect2f cuvect2f_proj(const cuvect2f &a, const cuvect2f &b); - __host__ __device__ cumat2f mat2f_rot_from_angle(const cuvect3f &axis, const float &angle); + __host__ __device__ cumat2f cumat2f_rot_from_angle(const float &angle); + + + /////////// + // Tests // + /////////// + void test_cuvect2f_1(); + + + /////////////////////////// + //legacy array operations// + /////////////////////////// //2x2 matrix operations - //matrix order is assumed to be mat[I,J] = mat[I+3*J] + //matrix order is assumed to be mat[I,J] = mat[I+2*J] //transpose a 2x2 matrix in place __host__ __device__ void mat2f_transpose(float *mat2inout); @@ -106,7 +119,7 @@ namespace amscuda __host__ __device__ cuvect2f mat2f_mult(float *mat2a, const cuvect2f &b); - void test_cuvect2f_1(); + }; diff --git a/include/amsculib2/cuvect3f.hpp b/include/amsculib2/cuvect3f.hpp index 0e06f45..7d6b22b 100644 --- a/include/amsculib2/cuvect3f.hpp +++ b/include/amsculib2/cuvect3f.hpp @@ -47,6 +47,9 @@ namespace amscuda const float & _m20, const float & _m21, const float & _m22 ); + __host__ __device__ explicit cumat3f(const float *data9); + + __host__ __device__ float& operator[](const int &I); __host__ __device__ float& operator()(const int &I, const int &J); __host__ __device__ float& at(const int &I, const int &J); diff --git a/src/amsculib2/cuvect2f.cu b/src/amsculib2/cuvect2f.cu index 8b76b49..a6230c4 100644 --- a/src/amsculib2/cuvect2f.cu +++ b/src/amsculib2/cuvect2f.cu @@ -421,7 +421,24 @@ namespace amscuda return (const float*) this; } + __host__ __device__ cumat2f::cumat2f(const float* data2x2) + { + m00 = data2x2[0]; + m10 = data2x2[1]; + m01 = data2x2[2]; + m11 = data2x2[3]; + return; + } + __host__ __device__ cumat2f cumat2f_rot_from_angle(const float &angle) + { + cumat2f R; + R(0,0) = ::cosf(angle); + R(1,0) = ::sinf(angle); + R(0,1) = -::sinf(angle); + R(1,1) = ::cosf(angle); + return R; + } /////////////////////////// //legacy array operations// diff --git a/src/amsculib2/cuvect3f.cu b/src/amsculib2/cuvect3f.cu index 309d6bb..6f8a397 100644 --- a/src/amsculib2/cuvect3f.cu +++ b/src/amsculib2/cuvect3f.cu @@ -191,6 +191,20 @@ __host__ __device__ cumat3f::~cumat3f() return; } +__host__ __device__ cumat3f::cumat3f(const float *data9) +{ + m00 = data9[0]; + m10 = data9[1]; + m20 = data9[2]; + m01 = data9[3]; + m11 = data9[4]; + m21 = data9[5]; + m02 = data9[6]; + m12 = data9[7]; + m22 = data9[8]; + return; +} + __host__ __device__ float& cumat3f::operator[](const int &I) { if(I==0) return m00;