working on comples64
This commit is contained in:
@ -19,9 +19,9 @@
|
||||
class cuvect2;
|
||||
class cuvect3;
|
||||
class cuvect4;
|
||||
class cuvect2f;
|
||||
class cuvect3f;
|
||||
class cuvect4f;
|
||||
class cuvec2f;
|
||||
class cuvec3f;
|
||||
class cuvec4f;
|
||||
|
||||
//Need a way to define the same symbols using both host and device code
|
||||
//A solution was found here: https://stackoverflow.com/questions/9457572/cuda-host-and-device-using-same-constant-memory
|
||||
@ -51,9 +51,9 @@ namespace amscuda
|
||||
#include <amsculib2/cuvect2.hpp>
|
||||
#include <amsculib2/cuvect3.hpp>
|
||||
#include <amsculib2/cuvect4.hpp>
|
||||
#include <amsculib2/cuvect2f.hpp>
|
||||
#include <amsculib2/cuvect3f.hpp>
|
||||
#include <amsculib2/cuvect4f.hpp>
|
||||
#include <amsculib2/cuvec2f.hpp>
|
||||
#include <amsculib2/cuvec3f.hpp>
|
||||
#include <amsculib2/cuvec4f.hpp>
|
||||
#include <amsculib2/amscugeom.hpp>
|
||||
#include <amsculib2/amscuarray.hpp>
|
||||
#include <amsculib2/amscuda_binarrrw.hpp>
|
||||
|
||||
@ -1,28 +1,28 @@
|
||||
#ifndef __CUVECT2F_HPP__
|
||||
#define __CUVECT2F_HPP__
|
||||
#ifndef __cuvec2f_HPP__
|
||||
#define __cuvec2f_HPP__
|
||||
|
||||
namespace amscuda
|
||||
{
|
||||
|
||||
class cuvect2f
|
||||
class cuvec2f
|
||||
{
|
||||
public:
|
||||
float x;
|
||||
float y;
|
||||
|
||||
|
||||
__host__ __device__ cuvect2f();
|
||||
__host__ __device__ ~cuvect2f();
|
||||
__host__ __device__ cuvect2f(const float &_x, const 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__ cuvect2f operator+(const cuvect2f &lhs);
|
||||
__host__ __device__ cuvect2f operator-(const cuvect2f &lhs);
|
||||
__host__ __device__ cuvect2f operator*(const float &lhs);
|
||||
__host__ __device__ cuvect2f operator/(const float &lhs);
|
||||
__host__ __device__ friend cuvect2f operator-(const cuvect2f &rhs);
|
||||
__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
|
||||
@ -40,7 +40,7 @@ namespace amscuda
|
||||
__host__ __device__ cumat2f operator-(cumat2f lhs);
|
||||
__host__ __device__ cumat2f operator*(float lhs);
|
||||
__host__ __device__ cumat2f operator/(float lhs);
|
||||
__host__ __device__ cuvect2f operator*(cuvect2f lhs);
|
||||
__host__ __device__ cuvec2f operator*(cuvec2f lhs);
|
||||
__host__ __device__ cumat2f operator*(cumat2f lhs);
|
||||
__host__ __device__ friend cumat2f operator-(cumat2f rhs);
|
||||
|
||||
@ -49,11 +49,11 @@ namespace amscuda
|
||||
__host__ __device__ cumat2f inverse();
|
||||
};
|
||||
|
||||
__host__ __device__ float cuvect2f_dot(const cuvect2f &a, const cuvect2f &b);
|
||||
__host__ __device__ float cuvect2f_cross(const cuvect2f &a, const cuvect2f &b);
|
||||
__host__ __device__ float cuvect2f_norm(const cuvect2f &a);
|
||||
__host__ __device__ cuvect2f cuvect2f_normalize(const cuvect2f &a);
|
||||
__host__ __device__ cuvect2f cuvect2f_proj(const cuvect2f &a, const cuvect2f &b);
|
||||
__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]
|
||||
@ -74,10 +74,10 @@ namespace amscuda
|
||||
__host__ __device__ void mat2f_mult(float *mat2a, float *mat2b, float *mat2c);
|
||||
|
||||
// ret = a*b
|
||||
__host__ __device__ cuvect2f mat2f_mult(float *mat2a, const cuvect2f &b);
|
||||
__host__ __device__ cuvec2f mat2f_mult(float *mat2a, const cuvec2f &b);
|
||||
|
||||
|
||||
void test_cuvect2f_1();
|
||||
void test_cuvec2f_1();
|
||||
|
||||
|
||||
};
|
||||
|
||||
@ -1,34 +1,34 @@
|
||||
#ifndef __CUVECT3F_HPP__
|
||||
#define __CUVECT3F_HPP__
|
||||
#ifndef __cuvec3f_HPP__
|
||||
#define __cuvec3f_HPP__
|
||||
|
||||
namespace amscuda
|
||||
{
|
||||
|
||||
class cuvect3f
|
||||
class cuvec3f
|
||||
{
|
||||
public:
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
|
||||
__host__ __device__ cuvect3f();
|
||||
__host__ __device__ ~cuvect3f();
|
||||
__host__ __device__ cuvect3f(const float &_x, const float &_y, const float &_z);
|
||||
__host__ __device__ cuvec3f();
|
||||
__host__ __device__ ~cuvec3f();
|
||||
__host__ __device__ cuvec3f(const float &_x, const float &_y, const float &_z);
|
||||
|
||||
|
||||
__host__ __device__ float& operator[](const int &I);
|
||||
__host__ __device__ const float& operator[](const int &I) const;
|
||||
|
||||
__host__ __device__ cuvect3f operator+(const cuvect3f &rhs);
|
||||
__host__ __device__ cuvect3f operator-(const cuvect3f &rhs);
|
||||
__host__ __device__ cuvect3f operator*(const float &rhs);
|
||||
__host__ __device__ cuvect3f operator/(const float &rhs);
|
||||
__host__ __device__ friend cuvect3f operator-(const cuvect3f &rhs);
|
||||
__host__ __device__ cuvec3f operator+(const cuvec3f &rhs);
|
||||
__host__ __device__ cuvec3f operator-(const cuvec3f &rhs);
|
||||
__host__ __device__ cuvec3f operator*(const float &rhs);
|
||||
__host__ __device__ cuvec3f operator/(const float &rhs);
|
||||
__host__ __device__ friend cuvec3f operator-(const cuvec3f &rhs);
|
||||
|
||||
__host__ __device__ cuvect3f& operator+=(const cuvect3f &rhs);
|
||||
__host__ __device__ cuvect3f& operator-=(const cuvect3f &rhs);
|
||||
__host__ __device__ cuvect3f& operator/=(const float &rhs);
|
||||
__host__ __device__ cuvect3f& operator*=(const float &rhs);
|
||||
__host__ __device__ cuvec3f& operator+=(const cuvec3f &rhs);
|
||||
__host__ __device__ cuvec3f& operator-=(const cuvec3f &rhs);
|
||||
__host__ __device__ cuvec3f& operator/=(const float &rhs);
|
||||
__host__ __device__ cuvec3f& operator*=(const float &rhs);
|
||||
|
||||
};
|
||||
|
||||
@ -59,7 +59,7 @@ namespace amscuda
|
||||
__host__ __device__ cumat3f operator-(const cumat3f &rhs);
|
||||
__host__ __device__ cumat3f operator*(const float &rhs);
|
||||
__host__ __device__ cumat3f operator/(const float &rhs);
|
||||
__host__ __device__ cuvect3f operator*(const cuvect3f &rhs);
|
||||
__host__ __device__ cuvec3f operator*(const cuvec3f &rhs);
|
||||
__host__ __device__ cumat3f operator*(const cumat3f &rhs);
|
||||
__host__ __device__ friend cumat3f operator-(const cumat3f &rhs);
|
||||
|
||||
@ -79,15 +79,15 @@ namespace amscuda
|
||||
|
||||
};
|
||||
|
||||
__host__ __device__ float cuvect3f_dot(const cuvect3f &a,const cuvect3f &b);
|
||||
__host__ __device__ cuvect3f cuvect3f_cross(const cuvect3f &a, const cuvect3f &b);
|
||||
__host__ __device__ float cuvect3f_norm(const cuvect3f &a);
|
||||
__host__ __device__ cuvect3f cuvect3f_normalize(const cuvect3f &a);
|
||||
__host__ __device__ cuvect3f cuvect3f_proj(const cuvect3f &a, const cuvect3f &b);
|
||||
__host__ __device__ float cuvec3f_dot(const cuvec3f &a,const cuvec3f &b);
|
||||
__host__ __device__ cuvec3f cuvec3f_cross(const cuvec3f &a, const cuvec3f &b);
|
||||
__host__ __device__ float cuvec3f_norm(const cuvec3f &a);
|
||||
__host__ __device__ cuvec3f cuvec3f_normalize(const cuvec3f &a);
|
||||
__host__ __device__ cuvec3f cuvec3f_proj(const cuvec3f &a, const cuvec3f &b);
|
||||
|
||||
__host__ __device__ cumat3f hodge_dual(const cuvect3f &vin);
|
||||
__host__ __device__ cuvect3f hodge_dual(const cumat3f &min);
|
||||
__host__ __device__ cumat3f rotmat_from_axisangle(const cuvect3f &axis, const float &angle);
|
||||
__host__ __device__ cumat3f hodge_dual(const cuvec3f &vin);
|
||||
__host__ __device__ cuvec3f hodge_dual(const cumat3f &min);
|
||||
__host__ __device__ cumat3f rotmat_from_axisangle(const cuvec3f &axis, const float &angle);
|
||||
|
||||
|
||||
//3x3 matrix operations
|
||||
@ -105,14 +105,14 @@ namespace amscuda
|
||||
//inverts a 3x3 (9 element) matrix
|
||||
__host__ __device__ void mat3f_inverse(float *mat3inout);
|
||||
|
||||
__host__ __device__ cuvect3f mat3f_mult(float *mat3in, const cuvect3f &cvin);
|
||||
__host__ __device__ cuvec3f mat3f_mult(float *mat3in, const cuvec3f &cvin);
|
||||
__host__ __device__ void mat3f_mult(float *matina, float *matinb, float *matout);
|
||||
|
||||
__host__ __device__ void mat3f_hodgedual(const cuvect3f &vecin, float *matout);
|
||||
__host__ __device__ void mat3f_hodgedual(float *matin, cuvect3f &vecout);
|
||||
__host__ __device__ void mat3f_hodgedual(const cuvec3f &vecin, float *matout);
|
||||
__host__ __device__ void mat3f_hodgedual(float *matin, cuvec3f &vecout);
|
||||
|
||||
//returns direction cosine rotation matrix from axis and angle
|
||||
__host__ __device__ void mat3f_rot_from_axisangle(cuvect3f axis, float angle, float *matout);
|
||||
__host__ __device__ void mat3f_rot_from_axisangle(cuvec3f axis, float angle, float *matout);
|
||||
|
||||
__host__ void test_cudavectf_logic1();
|
||||
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
#ifndef __CUVECT4F_HPP__
|
||||
#define __CUVECT4F_HPP__
|
||||
#ifndef __cuvec4f_HPP__
|
||||
#define __cuvec4f_HPP__
|
||||
|
||||
namespace amscuda
|
||||
{
|
||||
|
||||
class cuvect4f
|
||||
class cuvec4f
|
||||
{
|
||||
public:
|
||||
float x;
|
||||
@ -12,18 +12,18 @@ namespace amscuda
|
||||
float z;
|
||||
float w;
|
||||
|
||||
__host__ __device__ cuvect4f();
|
||||
__host__ __device__ ~cuvect4f();
|
||||
__host__ __device__ cuvect4f(float _x, float _y, float _z, float _w);
|
||||
__host__ __device__ cuvec4f();
|
||||
__host__ __device__ ~cuvec4f();
|
||||
__host__ __device__ cuvec4f(float _x, float _y, float _z, float _w);
|
||||
|
||||
__host__ __device__ float& operator[](const int I);
|
||||
__host__ __device__ const float& operator[](const int I) const;
|
||||
|
||||
__host__ __device__ cuvect4f operator+(cuvect4f lhs);
|
||||
__host__ __device__ cuvect4f operator-(cuvect4f lhs);
|
||||
__host__ __device__ cuvect4f operator*(float lhs);
|
||||
__host__ __device__ cuvect4f operator/(float lhs);
|
||||
__host__ __device__ friend cuvect4f operator-(cuvect4f rhs);
|
||||
__host__ __device__ cuvec4f operator+(cuvec4f lhs);
|
||||
__host__ __device__ cuvec4f operator-(cuvec4f lhs);
|
||||
__host__ __device__ cuvec4f operator*(float lhs);
|
||||
__host__ __device__ cuvec4f operator/(float lhs);
|
||||
__host__ __device__ friend cuvec4f operator-(cuvec4f rhs);
|
||||
};
|
||||
|
||||
class cumat4f
|
||||
@ -41,7 +41,7 @@ namespace amscuda
|
||||
__host__ __device__ cumat4f operator-(cumat4f lhs);
|
||||
__host__ __device__ cumat4f operator*(float lhs);
|
||||
__host__ __device__ cumat4f operator/(float lhs);
|
||||
__host__ __device__ cuvect4f operator*(cuvect4f lhs);
|
||||
__host__ __device__ cuvec4f operator*(cuvec4f lhs);
|
||||
__host__ __device__ cumat4f operator*(cumat4f lhs);
|
||||
__host__ __device__ friend cumat4f operator-(cumat4f rhs);
|
||||
|
||||
@ -50,10 +50,10 @@ namespace amscuda
|
||||
__host__ __device__ cumat4f inverse();
|
||||
};
|
||||
|
||||
__host__ __device__ float cuvect4f_dot(cuvect4f a, cuvect4f b);
|
||||
__host__ __device__ float cuvect4f_norm(cuvect4f a);
|
||||
__host__ __device__ cuvect4f cuvect4f_normalize(cuvect4f a);
|
||||
__host__ __device__ cuvect4f cuvect4f_proj(cuvect4f a, cuvect4f b);
|
||||
__host__ __device__ float cuvec4f_dot(cuvec4f a, cuvec4f b);
|
||||
__host__ __device__ float cuvec4f_norm(cuvec4f a);
|
||||
__host__ __device__ cuvec4f cuvec4f_normalize(cuvec4f a);
|
||||
__host__ __device__ cuvec4f cuvec4f_proj(cuvec4f a, cuvec4f b);
|
||||
|
||||
|
||||
};
|
||||
|
||||
@ -3,91 +3,91 @@
|
||||
namespace amscuda
|
||||
{
|
||||
|
||||
__host__ __device__ cuvect2f::cuvect2f()
|
||||
__host__ __device__ cuvec2f::cuvec2f()
|
||||
{
|
||||
x = 0.0; y = 0.0;
|
||||
return;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect2f::~cuvect2f()
|
||||
__host__ __device__ cuvec2f::~cuvec2f()
|
||||
{
|
||||
x = 0.0; y = 0.0;
|
||||
return;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect2f::cuvect2f(const float &_x, const float &_y)
|
||||
__host__ __device__ cuvec2f::cuvec2f(const float &_x, const float &_y)
|
||||
{
|
||||
x = _x; y = _y;
|
||||
return;
|
||||
}
|
||||
|
||||
__host__ __device__ float& cuvect2f::operator[](const int &I)
|
||||
__host__ __device__ float& cuvec2f::operator[](const int &I)
|
||||
{
|
||||
if(I==0) return x;
|
||||
if(I==1) return y;
|
||||
return x;
|
||||
}
|
||||
|
||||
__host__ __device__ const float& cuvect2f::operator[](const int &I) const
|
||||
__host__ __device__ const float& cuvec2f::operator[](const int &I) const
|
||||
{
|
||||
if(I==0) return x;
|
||||
if(I==1) return y;
|
||||
return x;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect2f cuvect2f::operator+(const cuvect2f &lhs)
|
||||
__host__ __device__ cuvec2f cuvec2f::operator+(const cuvec2f &lhs)
|
||||
{
|
||||
cuvect2f ret;
|
||||
cuvec2f ret;
|
||||
ret.x = x + lhs.x;
|
||||
ret.y = y + lhs.y;
|
||||
return ret;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect2f cuvect2f::operator-(const cuvect2f &lhs)
|
||||
__host__ __device__ cuvec2f cuvec2f::operator-(const cuvec2f &lhs)
|
||||
{
|
||||
cuvect2f ret;
|
||||
cuvec2f ret;
|
||||
ret.x = x - lhs.x;
|
||||
ret.y = y - lhs.y;
|
||||
return ret;
|
||||
}
|
||||
__host__ __device__ cuvect2f cuvect2f::operator*(const float &lhs)
|
||||
__host__ __device__ cuvec2f cuvec2f::operator*(const float &lhs)
|
||||
{
|
||||
cuvect2f ret;
|
||||
cuvec2f ret;
|
||||
ret.x = x*lhs;
|
||||
ret.y = y*lhs;
|
||||
return ret;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect2f cuvect2f::operator/(const float &lhs)
|
||||
__host__ __device__ cuvec2f cuvec2f::operator/(const float &lhs)
|
||||
{
|
||||
cuvect2f ret;
|
||||
cuvec2f ret;
|
||||
ret.x = x/lhs;
|
||||
ret.y = y/lhs;
|
||||
return ret;
|
||||
}
|
||||
|
||||
__host__ __device__ float cuvect2f_dot(const cuvect2f &a, const cuvect2f &b)
|
||||
__host__ __device__ float cuvec2f_dot(const cuvec2f &a, const cuvec2f &b)
|
||||
{
|
||||
float ret = a.x*b.x+a.y*b.y;
|
||||
return ret;
|
||||
}
|
||||
|
||||
__host__ __device__ float cuvect2f_cross(const cuvect2f &a, const cuvect2f &b)
|
||||
__host__ __device__ float cuvec2f_cross(const cuvec2f &a, const cuvec2f &b)
|
||||
{
|
||||
float ret = a.x*b.y-a.y*b.x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
__host__ __device__ float cuvect2f_norm(const cuvect2f &a)
|
||||
__host__ __device__ float cuvec2f_norm(const cuvec2f &a)
|
||||
{
|
||||
float ret = ::sqrtf(a.x*a.x+a.y*a.y);
|
||||
return ret;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect2f cuvect2f_normalize(const cuvect2f &a)
|
||||
__host__ __device__ cuvec2f cuvec2f_normalize(const cuvec2f &a)
|
||||
{
|
||||
cuvect2f ret;
|
||||
float m = cuvect2f_norm(a);
|
||||
cuvec2f ret;
|
||||
float m = cuvec2f_norm(a);
|
||||
if(m>0.0)
|
||||
{
|
||||
ret.x = a.x/m; ret.y = a.y/m;
|
||||
@ -99,11 +99,11 @@ namespace amscuda
|
||||
return ret;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect2f cuvect2f_proj(const cuvect2f &a, const cuvect2f &b)
|
||||
__host__ __device__ cuvec2f cuvec2f_proj(const cuvec2f &a, const cuvec2f &b)
|
||||
{
|
||||
cuvect2f ret;
|
||||
cuvect2f bn = cuvect2f_normalize(b);
|
||||
float m = cuvect2f_dot(a,bn);
|
||||
cuvec2f ret;
|
||||
cuvec2f bn = cuvec2f_normalize(b);
|
||||
float m = cuvec2f_dot(a,bn);
|
||||
ret = bn*m;
|
||||
return ret;
|
||||
}
|
||||
@ -189,9 +189,9 @@ __host__ __device__ float& cumat2f::at(const int I, const int J)
|
||||
}
|
||||
|
||||
|
||||
__host__ __device__ cuvect2f cumat2f::operator*(cuvect2f lhs)
|
||||
__host__ __device__ cuvec2f cumat2f::operator*(cuvec2f lhs)
|
||||
{
|
||||
cuvect2f ret = cuvect2f(0.0,0.0);
|
||||
cuvec2f ret = cuvec2f(0.0,0.0);
|
||||
int I,J;
|
||||
for(I=0;I<2;I++)
|
||||
{
|
||||
@ -343,17 +343,17 @@ __host__ __device__ void mat2f_mult(float *mat2a, float *mat2b, float *mat2c)
|
||||
}
|
||||
|
||||
// ret = a*b
|
||||
__host__ __device__ cuvect2f mat2f_mult(float *mat2a, const cuvect2f &b)
|
||||
__host__ __device__ cuvec2f mat2f_mult(float *mat2a, const cuvec2f &b)
|
||||
{
|
||||
cuvect2f ret;
|
||||
cuvec2f ret;
|
||||
ret.x = b.x*mat2a[0+0*2] + b.y*mat2a[1+0*2];
|
||||
ret.y = b.x*mat2a[0+1*2] + b.y*mat2a[1+1*2];
|
||||
return ret;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect2f operator-(cuvect2f rhs)
|
||||
__host__ __device__ cuvec2f operator-(cuvec2f rhs)
|
||||
{
|
||||
cuvect2f ret;
|
||||
cuvec2f ret;
|
||||
ret[0] = -rhs[0];
|
||||
ret[1] = -rhs[1];
|
||||
return ret;
|
||||
@ -367,7 +367,7 @@ __host__ __device__ cumat2f operator-(cumat2f rhs)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void test_cuvect2f_1()
|
||||
void test_cuvec2f_1()
|
||||
{
|
||||
|
||||
|
||||
|
||||
@ -3,19 +3,19 @@
|
||||
namespace amscuda
|
||||
{
|
||||
|
||||
__host__ __device__ cuvect3f::cuvect3f()
|
||||
__host__ __device__ cuvec3f::cuvec3f()
|
||||
{
|
||||
x = 0.0; y = 0.0; z = 0.0;
|
||||
return;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect3f::~cuvect3f()
|
||||
__host__ __device__ cuvec3f::~cuvec3f()
|
||||
{
|
||||
x = 0.0; y = 0.0; z = 0.0;
|
||||
return;
|
||||
}
|
||||
|
||||
__host__ __device__ float& cuvect3f::operator[](const int &I)
|
||||
__host__ __device__ float& cuvec3f::operator[](const int &I)
|
||||
{
|
||||
if(I==0) return x;
|
||||
if(I==1) return y;
|
||||
@ -23,7 +23,7 @@ namespace amscuda
|
||||
return x;
|
||||
}
|
||||
|
||||
__host__ __device__ const float& cuvect3f::operator[](const int &I) const
|
||||
__host__ __device__ const float& cuvec3f::operator[](const int &I) const
|
||||
{
|
||||
if(I==0) return x;
|
||||
if(I==1) return y;
|
||||
@ -31,9 +31,9 @@ namespace amscuda
|
||||
return x;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect3f cuvect3f::operator+(const cuvect3f &rhs)
|
||||
__host__ __device__ cuvec3f cuvec3f::operator+(const cuvec3f &rhs)
|
||||
{
|
||||
cuvect3f ret;
|
||||
cuvec3f ret;
|
||||
ret.x = x+rhs.x;
|
||||
ret.y = y+rhs.y;
|
||||
ret.z = z+rhs.z;
|
||||
@ -41,9 +41,9 @@ namespace amscuda
|
||||
return ret;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect3f cuvect3f::operator-(const cuvect3f &rhs)
|
||||
__host__ __device__ cuvec3f cuvec3f::operator-(const cuvec3f &rhs)
|
||||
{
|
||||
cuvect3f ret;
|
||||
cuvec3f ret;
|
||||
ret.x = x-rhs.x;
|
||||
ret.y = y-rhs.y;
|
||||
ret.z = z-rhs.z;
|
||||
@ -51,25 +51,25 @@ namespace amscuda
|
||||
return ret;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect3f cuvect3f::operator*(const float &rhs)
|
||||
__host__ __device__ cuvec3f cuvec3f::operator*(const float &rhs)
|
||||
{
|
||||
cuvect3f ret;
|
||||
cuvec3f ret;
|
||||
ret.x = x*rhs;
|
||||
ret.y = y*rhs;
|
||||
ret.z = z*rhs;
|
||||
return ret;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect3f cuvect3f::operator/(const float &rhs)
|
||||
__host__ __device__ cuvec3f cuvec3f::operator/(const float &rhs)
|
||||
{
|
||||
cuvect3f ret;
|
||||
cuvec3f ret;
|
||||
ret.x = x/rhs;
|
||||
ret.y = y/rhs;
|
||||
ret.z = z/rhs;
|
||||
return ret;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect3f& cuvect3f::operator+=(const cuvect3f &rhs)
|
||||
__host__ __device__ cuvec3f& cuvec3f::operator+=(const cuvec3f &rhs)
|
||||
{
|
||||
x = x + rhs.x;
|
||||
y = y + rhs.y;
|
||||
@ -77,7 +77,7 @@ namespace amscuda
|
||||
return *this;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect3f& cuvect3f::operator-=(const cuvect3f &rhs)
|
||||
__host__ __device__ cuvec3f& cuvec3f::operator-=(const cuvec3f &rhs)
|
||||
{
|
||||
x = x - rhs.x;
|
||||
y = y - rhs.y;
|
||||
@ -85,7 +85,7 @@ namespace amscuda
|
||||
return *this;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect3f& cuvect3f::operator*=(const float &rhs)
|
||||
__host__ __device__ cuvec3f& cuvec3f::operator*=(const float &rhs)
|
||||
{
|
||||
x = x * rhs;
|
||||
y = y * rhs;
|
||||
@ -93,7 +93,7 @@ namespace amscuda
|
||||
return *this;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect3f& cuvect3f::operator/=(const float &rhs)
|
||||
__host__ __device__ cuvec3f& cuvec3f::operator/=(const float &rhs)
|
||||
{
|
||||
x = x / rhs;
|
||||
y = y / rhs;
|
||||
@ -102,23 +102,23 @@ namespace amscuda
|
||||
}
|
||||
|
||||
|
||||
__host__ __device__ cuvect3f::cuvect3f(const float &_x, const float &_y, const float &_z)
|
||||
__host__ __device__ cuvec3f::cuvec3f(const float &_x, const float &_y, const float &_z)
|
||||
{
|
||||
x = _x; y = _y; z = _z;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
__host__ __device__ float cuvect3f_dot(const cuvect3f &a, const cuvect3f &b)
|
||||
__host__ __device__ float cuvec3f_dot(const cuvec3f &a, const cuvec3f &b)
|
||||
{
|
||||
float ret = a.x*b.x+a.y*b.y+a.z*b.z;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect3f cuvect3f_cross(const cuvect3f &a, const cuvect3f &b)
|
||||
__host__ __device__ cuvec3f cuvec3f_cross(const cuvec3f &a, const cuvec3f &b)
|
||||
{
|
||||
cuvect3f ret;
|
||||
cuvec3f ret;
|
||||
ret[0] = a[1]*b[2]-a[2]*b[1];
|
||||
ret[1] = a[2]*b[0]-a[0]*b[2];
|
||||
ret[2] = a[0]*b[1]-a[1]*b[0];
|
||||
@ -126,16 +126,16 @@ namespace amscuda
|
||||
return ret;
|
||||
}
|
||||
|
||||
__host__ __device__ float cuvect3f_norm(const cuvect3f &a)
|
||||
__host__ __device__ float cuvec3f_norm(const cuvec3f &a)
|
||||
{
|
||||
float ret;
|
||||
ret = ::sqrtf(a.x*a.x+a.y*a.y+a.z*a.z);
|
||||
return ret;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect3f cuvect3f_normalize(const cuvect3f &a)
|
||||
__host__ __device__ cuvec3f cuvec3f_normalize(const cuvec3f &a)
|
||||
{
|
||||
cuvect3f ret;
|
||||
cuvec3f ret;
|
||||
float m;
|
||||
m = ::sqrtf(a.x*a.x+a.y*a.y+a.z*a.z);
|
||||
if(m>0.0)
|
||||
@ -150,11 +150,11 @@ namespace amscuda
|
||||
return ret;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect3f cuvect3f_proj(const cuvect3f &a, const cuvect3f &b)
|
||||
__host__ __device__ cuvec3f cuvec3f_proj(const cuvec3f &a, const cuvec3f &b)
|
||||
{
|
||||
cuvect3f ret;
|
||||
cuvect3f bn = cuvect3f_normalize(b);
|
||||
float m = cuvect3f_dot(a,bn);
|
||||
cuvec3f ret;
|
||||
cuvec3f bn = cuvec3f_normalize(b);
|
||||
float m = cuvec3f_dot(a,bn);
|
||||
ret = bn*m;
|
||||
return ret;
|
||||
}
|
||||
@ -346,9 +346,9 @@ __host__ __device__ cumat3f cumat3f::operator/(const float &rhs)
|
||||
return ret;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect3f cumat3f::operator*(const cuvect3f &rhs)
|
||||
__host__ __device__ cuvec3f cumat3f::operator*(const cuvec3f &rhs)
|
||||
{
|
||||
cuvect3f ret;
|
||||
cuvec3f ret;
|
||||
|
||||
ret.x = m00*rhs.x + m01*rhs.y + m02*rhs.z;
|
||||
ret.y = m10*rhs.x + m11*rhs.y + m12*rhs.z;
|
||||
@ -649,10 +649,10 @@ __host__ __device__ void mat3f_inverse(float *mat3inout)
|
||||
return;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect3f mat3f_mult(float *mat3in, const cuvect3f &cvin)
|
||||
__host__ __device__ cuvec3f mat3f_mult(float *mat3in, const cuvec3f &cvin)
|
||||
{
|
||||
int I,J;
|
||||
cuvect3f ret;
|
||||
cuvec3f ret;
|
||||
for(I=0;I<3;I++)
|
||||
{
|
||||
ret[I] = 0.0;
|
||||
@ -700,7 +700,7 @@ __host__ __device__ void mat3f_mult(float *matina, float *matinb, float *matout)
|
||||
return;
|
||||
}
|
||||
|
||||
__host__ __device__ void mat3f_hodgedual(const cuvect3f &vecin, float *matout)
|
||||
__host__ __device__ void mat3f_hodgedual(const cuvec3f &vecin, float *matout)
|
||||
{
|
||||
matout[0 + 0*3] = 0.0f;
|
||||
matout[1 + 0*3] = -vecin[2];
|
||||
@ -716,7 +716,7 @@ __host__ __device__ void mat3f_hodgedual(const cuvect3f &vecin, float *matout)
|
||||
return;
|
||||
}
|
||||
|
||||
__host__ __device__ void mat3f_hodgedual(float *matin, cuvect3f &vecout)
|
||||
__host__ __device__ void mat3f_hodgedual(float *matin, cuvec3f &vecout)
|
||||
{
|
||||
vecout[0] = 0.5*(matin[1 + 2*3] - matin[2 + 1*3]);
|
||||
vecout[1] = 0.5*(matin[2 + 0*3] - matin[0 + 2*3]);
|
||||
@ -726,7 +726,7 @@ __host__ __device__ void mat3f_hodgedual(float *matin, cuvect3f &vecout)
|
||||
}
|
||||
|
||||
//returns direction cosine rotation matrix from axis and angle
|
||||
__host__ __device__ void mat3f_rot_from_axisangle(cuvect3f axis, float angle, float *matout)
|
||||
__host__ __device__ void mat3f_rot_from_axisangle(cuvec3f axis, float angle, float *matout)
|
||||
{
|
||||
int I;
|
||||
float H[9];
|
||||
@ -738,7 +738,7 @@ __host__ __device__ void mat3f_rot_from_axisangle(cuvect3f axis, float angle, fl
|
||||
II[1+1*3] = 1.0;
|
||||
II[2+2*3] = 1.0;
|
||||
|
||||
axis = cuvect3f_normalize(axis);
|
||||
axis = cuvec3f_normalize(axis);
|
||||
|
||||
mat3f_hodgedual(axis,H);
|
||||
mat3f_mult(H,H,Hsq);
|
||||
@ -759,7 +759,7 @@ __host__ void test_cudavectf_logic1()
|
||||
|
||||
printf("3 dim vector and matrix functional tests on host side\n");
|
||||
|
||||
cuvect3f a,b,c;
|
||||
cuvec3f a,b,c;
|
||||
float ma[9],mb[9],mc[9];
|
||||
|
||||
int I,J;
|
||||
@ -798,7 +798,7 @@ __host__ void test_cudavectf_logic1()
|
||||
}
|
||||
}
|
||||
|
||||
a = cuvect3f(1,1,1);
|
||||
a = cuvec3f(1,1,1);
|
||||
b = mat3f_mult(ma,a);
|
||||
b = mat3f_mult(mb,b);
|
||||
|
||||
@ -807,8 +807,8 @@ __host__ void test_cudavectf_logic1()
|
||||
printf("a[%d] = %1.3f, b[%d] = %1.3f\n",I,a[I],I,b[I]);
|
||||
}
|
||||
|
||||
a = cuvect3f(1,0,1);
|
||||
b = cuvect3f(0,1,-1);
|
||||
a = cuvec3f(1,0,1);
|
||||
b = cuvec3f(0,1,-1);
|
||||
c = a+b;
|
||||
|
||||
for(I=0;I<3;I++)
|
||||
@ -823,31 +823,31 @@ __host__ void test_cudavectf_logic1()
|
||||
printf("a[%d] = %1.3f, b[%d] = %1.3f, c[%d] = %1.3f\n",I,a[I],I,b[I],I,c[I]);
|
||||
}
|
||||
|
||||
c = cuvect3f_cross(a,b);
|
||||
c = cuvec3f_cross(a,b);
|
||||
|
||||
for(I=0;I<3;I++)
|
||||
{
|
||||
printf("a[%d] = %1.3f, b[%d] = %1.3f, c[%d] = %1.3f\n",I,a[I],I,b[I],I,c[I]);
|
||||
}
|
||||
|
||||
printf("c dot a = %1.3f, c dot b = %1.3f\n",cuvect3f_dot(c,a),cuvect3f_dot(c,b));
|
||||
printf("c dot a = %1.3f, c dot b = %1.3f\n",cuvec3f_dot(c,a),cuvec3f_dot(c,b));
|
||||
|
||||
printf("norm(a)=%1.3f, norm(b)=%1.3f, norm(c)=%1.3f\n",cuvect3f_norm(a),cuvect3f_norm(b),cuvect3f_norm(c));
|
||||
a = cuvect3f_normalize(a);
|
||||
b = cuvect3f_normalize(b);
|
||||
c = cuvect3f_normalize(c);
|
||||
printf("norm(a)=%1.3f, norm(b)=%1.3f, norm(c)=%1.3f\n",cuvec3f_norm(a),cuvec3f_norm(b),cuvec3f_norm(c));
|
||||
a = cuvec3f_normalize(a);
|
||||
b = cuvec3f_normalize(b);
|
||||
c = cuvec3f_normalize(c);
|
||||
|
||||
for(I=0;I<3;I++)
|
||||
{
|
||||
printf("a[%d] = %1.3f, b[%d] = %1.3f, c[%d] = %1.3f\n",I,a[I],I,b[I],I,c[I]);
|
||||
}
|
||||
printf("c dot a = %1.3f, c dot b = %1.3f\n",cuvect3f_dot(c,a),cuvect3f_dot(c,b));
|
||||
printf("norm(a)=%1.3f, norm(b)=%1.3f, norm(c)=%1.3f\n",cuvect3f_norm(a),cuvect3f_norm(b),cuvect3f_norm(c));
|
||||
printf("c dot a = %1.3f, c dot b = %1.3f\n",cuvec3f_dot(c,a),cuvec3f_dot(c,b));
|
||||
printf("norm(a)=%1.3f, norm(b)=%1.3f, norm(c)=%1.3f\n",cuvec3f_norm(a),cuvec3f_norm(b),cuvec3f_norm(c));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
__host__ __device__ cumat3f hodge_dual(const cuvect3f &vin)
|
||||
__host__ __device__ cumat3f hodge_dual(const cuvec3f &vin)
|
||||
{
|
||||
cumat3f ret;
|
||||
|
||||
@ -866,9 +866,9 @@ __host__ __device__ cumat3f hodge_dual(const cuvect3f &vin)
|
||||
return ret;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect3f hodge_dual(const cumat3f &min)
|
||||
__host__ __device__ cuvec3f hodge_dual(const cumat3f &min)
|
||||
{
|
||||
cuvect3f ret;
|
||||
cuvec3f ret;
|
||||
|
||||
ret.x = 0.5f*(min.m12 - min.m21);
|
||||
ret.y = 0.5f*(min.m20 - min.m02);
|
||||
@ -893,13 +893,13 @@ __host__ __device__ const cumat3f cumat3f_zeros()
|
||||
return ret;
|
||||
}
|
||||
|
||||
__host__ __device__ cumat3f rotmat_from_axisangle(const cuvect3f &axis, const float &angle)
|
||||
__host__ __device__ cumat3f rotmat_from_axisangle(const cuvec3f &axis, const float &angle)
|
||||
{
|
||||
cumat3f ret = cumat3f_zeros();
|
||||
cumat3f H;
|
||||
cuvect3f _naxis;
|
||||
cuvec3f _naxis;
|
||||
|
||||
_naxis = cuvect3f_normalize(axis);
|
||||
_naxis = cuvec3f_normalize(axis);
|
||||
H = hodge_dual(_naxis);
|
||||
|
||||
ret += H*sinf(angle);
|
||||
|
||||
@ -4,28 +4,28 @@ namespace amscuda
|
||||
{
|
||||
|
||||
////////////
|
||||
//cuvect4ff//
|
||||
//cuvec4ff//
|
||||
////////////
|
||||
|
||||
__host__ __device__ cuvect4f::cuvect4f()
|
||||
__host__ __device__ cuvec4f::cuvec4f()
|
||||
{
|
||||
x = 0.0; y = 0.0; z = 0.0; w = 0.0;
|
||||
return;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect4f::~cuvect4f()
|
||||
__host__ __device__ cuvec4f::~cuvec4f()
|
||||
{
|
||||
x = 0.0; y = 0.0; z = 0.0; w = 0.0;
|
||||
return;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect4f::cuvect4f(float _x, float _y, float _z, float _w)
|
||||
__host__ __device__ cuvec4f::cuvec4f(float _x, float _y, float _z, float _w)
|
||||
{
|
||||
x = _x; y = _y; z = _z; w = _w;
|
||||
return;
|
||||
}
|
||||
|
||||
__host__ __device__ float& cuvect4f::operator[](const int I)
|
||||
__host__ __device__ float& cuvec4f::operator[](const int I)
|
||||
{
|
||||
if(I==0) return x;
|
||||
else if(I==1) return y;
|
||||
@ -34,7 +34,7 @@ __host__ __device__ float& cuvect4f::operator[](const int I)
|
||||
return x;
|
||||
}
|
||||
|
||||
__host__ __device__ const float& cuvect4f::operator[](const int I) const
|
||||
__host__ __device__ const float& cuvec4f::operator[](const int I) const
|
||||
{
|
||||
if(I==0) return x;
|
||||
else if(I==1) return y;
|
||||
@ -43,9 +43,9 @@ __host__ __device__ const float& cuvect4f::operator[](const int I) const
|
||||
return x;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect4f cuvect4f::operator+(cuvect4f lhs)
|
||||
__host__ __device__ cuvec4f cuvec4f::operator+(cuvec4f lhs)
|
||||
{
|
||||
cuvect4f ret;
|
||||
cuvec4f ret;
|
||||
ret.x = this->x + lhs.x;
|
||||
ret.y = this->y + lhs.y;
|
||||
ret.z = this->z + lhs.z;
|
||||
@ -53,9 +53,9 @@ __host__ __device__ cuvect4f cuvect4f::operator+(cuvect4f lhs)
|
||||
return ret;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect4f cuvect4f::operator-(cuvect4f lhs)
|
||||
__host__ __device__ cuvec4f cuvec4f::operator-(cuvec4f lhs)
|
||||
{
|
||||
cuvect4f ret;
|
||||
cuvec4f ret;
|
||||
ret.x = this->x - lhs.x;
|
||||
ret.y = this->y - lhs.y;
|
||||
ret.z = this->z - lhs.z;
|
||||
@ -63,9 +63,9 @@ __host__ __device__ cuvect4f cuvect4f::operator-(cuvect4f lhs)
|
||||
return ret;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect4f cuvect4f::operator*(float lhs)
|
||||
__host__ __device__ cuvec4f cuvec4f::operator*(float lhs)
|
||||
{
|
||||
cuvect4f ret;
|
||||
cuvec4f ret;
|
||||
ret.x = this->x*lhs;
|
||||
ret.y = this->y*lhs;
|
||||
ret.z = this->z*lhs;
|
||||
@ -73,9 +73,9 @@ __host__ __device__ cuvect4f cuvect4f::operator*(float lhs)
|
||||
return ret;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect4f cuvect4f::operator/(float lhs)
|
||||
__host__ __device__ cuvec4f cuvec4f::operator/(float lhs)
|
||||
{
|
||||
cuvect4f ret;
|
||||
cuvec4f ret;
|
||||
ret.x = this->x/lhs;
|
||||
ret.y = this->y/lhs;
|
||||
ret.z = this->z/lhs;
|
||||
@ -162,9 +162,9 @@ __host__ __device__ cumat4f cumat4f::operator/(float lhs)
|
||||
return ret;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect4f cumat4f::operator*(cuvect4f lhs)
|
||||
__host__ __device__ cuvec4f cumat4f::operator*(cuvec4f lhs)
|
||||
{
|
||||
cuvect4f ret = cuvect4f(0.0,0.0,0.0,0.0);
|
||||
cuvec4f ret = cuvec4f(0.0,0.0,0.0,0.0);
|
||||
int I,J;
|
||||
|
||||
for(I=0;I<4;I++)
|
||||
@ -382,41 +382,41 @@ __host__ __device__ cumat4f cumat4f::inverse()
|
||||
}
|
||||
|
||||
|
||||
__host__ __device__ float cuvect4f_dot(cuvect4f a, cuvect4f b)
|
||||
__host__ __device__ float cuvec4f_dot(cuvec4f a, cuvec4f b)
|
||||
{
|
||||
float ret = 0.0;
|
||||
ret = a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w;
|
||||
return ret;
|
||||
}
|
||||
|
||||
__host__ __device__ float cuvect4f_norm(cuvect4f a)
|
||||
__host__ __device__ float cuvec4f_norm(cuvec4f a)
|
||||
{
|
||||
float ret = 0.0;
|
||||
ret = ::sqrtf(cuvect4f_dot(a,a));
|
||||
ret = ::sqrtf(cuvec4f_dot(a,a));
|
||||
return ret;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect4f cuvect4f_normalize(cuvect4f a)
|
||||
__host__ __device__ cuvec4f cuvec4f_normalize(cuvec4f a)
|
||||
{
|
||||
cuvect4f ret = cuvect4f(0.0f,0.0f,0.0f,0.0f);
|
||||
float nrm = cuvect4f_norm(a);
|
||||
cuvec4f ret = cuvec4f(0.0f,0.0f,0.0f,0.0f);
|
||||
float nrm = cuvec4f_norm(a);
|
||||
if(nrm>0.0)
|
||||
ret = a/nrm;
|
||||
return ret;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect4f cuvect4f_proj(cuvect4f a, cuvect4f b)
|
||||
__host__ __device__ cuvec4f cuvec4f_proj(cuvec4f a, cuvec4f b)
|
||||
{
|
||||
cuvect4f ret;
|
||||
cuvect4f bn = cuvect4f_normalize(b);
|
||||
float d = cuvect4f_dot(a,bn);
|
||||
cuvec4f ret;
|
||||
cuvec4f bn = cuvec4f_normalize(b);
|
||||
float d = cuvec4f_dot(a,bn);
|
||||
ret = bn*d;
|
||||
return ret;
|
||||
}
|
||||
|
||||
__host__ __device__ cuvect4f operator-(cuvect4f rhs)
|
||||
__host__ __device__ cuvec4f operator-(cuvec4f rhs)
|
||||
{
|
||||
cuvect4f ret;
|
||||
cuvec4f ret;
|
||||
ret[0] = -rhs[0];
|
||||
ret[1] = -rhs[1];
|
||||
ret[2] = -rhs[2];
|
||||
|
||||
Reference in New Issue
Block a user