87 lines
2.8 KiB
C++
87 lines
2.8 KiB
C++
#ifndef __cuvec2f_HPP__
|
|
#define __cuvec2f_HPP__
|
|
|
|
namespace amscuda
|
|
{
|
|
|
|
class cuvec2f
|
|
{
|
|
public:
|
|
float x;
|
|
float y;
|
|
|
|
|
|
__host__ __device__ cuvec2f();
|
|
__host__ __device__ ~cuvec2f();
|
|
__host__ __device__ cuvec2f(const float &_x, const float &_y);
|
|
|
|
__host__ __device__ float& operator[](const int &I);
|
|
__host__ __device__ const float& operator[](const int &I) const;
|
|
|
|
__host__ __device__ cuvec2f operator+(const cuvec2f &lhs);
|
|
__host__ __device__ cuvec2f operator-(const cuvec2f &lhs);
|
|
__host__ __device__ cuvec2f operator*(const float &lhs);
|
|
__host__ __device__ cuvec2f operator/(const float &lhs);
|
|
__host__ __device__ friend cuvec2f operator-(const cuvec2f &rhs);
|
|
};
|
|
|
|
class cumat2f
|
|
{
|
|
public:
|
|
float dat[4];
|
|
|
|
__host__ __device__ cumat2f();
|
|
__host__ __device__ ~cumat2f();
|
|
__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);
|
|
|
|
__host__ __device__ cumat2f operator+(cumat2f lhs);
|
|
__host__ __device__ cumat2f operator-(cumat2f lhs);
|
|
__host__ __device__ cumat2f operator*(float lhs);
|
|
__host__ __device__ cumat2f operator/(float lhs);
|
|
__host__ __device__ cuvec2f operator*(cuvec2f lhs);
|
|
__host__ __device__ cumat2f operator*(cumat2f lhs);
|
|
__host__ __device__ friend cumat2f operator-(cumat2f rhs);
|
|
|
|
__host__ __device__ float det();
|
|
__host__ __device__ cumat2f transpose();
|
|
__host__ __device__ cumat2f inverse();
|
|
};
|
|
|
|
__host__ __device__ float cuvec2f_dot(const cuvec2f &a, const cuvec2f &b);
|
|
__host__ __device__ float cuvec2f_cross(const cuvec2f &a, const cuvec2f &b);
|
|
__host__ __device__ float cuvec2f_norm(const cuvec2f &a);
|
|
__host__ __device__ cuvec2f cuvec2f_normalize(const cuvec2f &a);
|
|
__host__ __device__ cuvec2f cuvec2f_proj(const cuvec2f &a, const cuvec2f &b);
|
|
|
|
//2x2 matrix operations
|
|
//matrix order is assumed to be mat[I,J] = mat[I+3*J]
|
|
|
|
//transpose a 2x2 matrix in place
|
|
__host__ __device__ void mat2f_transpose(float *mat2inout);
|
|
|
|
//copies src to dest
|
|
__host__ __device__ void mat2f_copy(float *mat2f_dest, const float *mat2f_src);
|
|
|
|
//inverts mat?inout[4]
|
|
__host__ __device__ void mat2f_inverse(float *mat2inout);
|
|
|
|
//rotatin matrix from angle
|
|
__host__ __device__ void mat2f_rot_from_angle(float angle, float *mat2);
|
|
|
|
//multiplies c = a*b
|
|
__host__ __device__ void mat2f_mult(float *mat2a, float *mat2b, float *mat2c);
|
|
|
|
// ret = a*b
|
|
__host__ __device__ cuvec2f mat2f_mult(float *mat2a, const cuvec2f &b);
|
|
|
|
|
|
void test_cuvec2f_1();
|
|
|
|
|
|
};
|
|
|
|
#endif
|
|
|