working on comples64

This commit is contained in:
2026-04-10 16:28:25 -04:00
parent a8ed51a904
commit f315dfb6f6
48 changed files with 551 additions and 2523 deletions

View File

@ -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
@ -46,8 +46,8 @@ namespace amscuda
//Components
#include <amsculib3/amscu_cudafunctions.hpp>
#include <amsculib3/math/amscumath.hpp>
#include <amsculib3/geom/amscugeom.hpp>
#include <amsculib3/amscugeom.hpp>
#include <amsculib3/amscuarray.hpp>
#include <amsculib3/amscuda_binarrrw.hpp>
#include <amsculib3/amscu_random.hpp>

View File

@ -15,7 +15,8 @@ namespace cmp
__host__ __device__ cucomp128();
__host__ __device__ ~cucomp128();
__host__ __device__ cucomp128(const cucomp128 &other);
__host__ __device__ cucomp128(const double &other);
__host__ __device__ explicit cucomp128(const double &other);
__host__ __device__ explicit cucomp128(const double &_real, const double &_imag);
__host__ __device__ cucomp128& operator=(cucomp128& other);
__host__ __device__ const cucomp128& operator=(const cucomp128& other);
@ -58,7 +59,6 @@ namespace cmp
__host__ __device__ double arg(cucomp128 z);
__host__ __device__ cucomp128 dtocomp(double _r, double _i);
__host__ __device__ double real(cucomp128 z);
__host__ __device__ double imag(cucomp128 z);
__host__ __device__ cucomp128 sin(cucomp128 z);

View File

@ -15,7 +15,8 @@ namespace cmp
__host__ __device__ cucomp64();
__host__ __device__ ~cucomp64();
__host__ __device__ cucomp64(const cucomp64 &other);
__host__ __device__ cucomp64(const float &other);
__host__ __device__ explicit cucomp64(const float &other);
__host__ __device__ explicit cucomp64(const float &_real, const float &_imag);
__host__ __device__ cucomp64& operator=(cucomp64& other);
__host__ __device__ const cucomp64& operator=(const cucomp64& other);
@ -53,31 +54,42 @@ namespace cmp
__host__ __device__ bool iszero() const;
__host__ __device__ float arg() const;
__host__ __device__ float mag() const;
__host__ __device__ float abs() const;
__host__ __device__ cucomp64 conj() const;
//accumulation operators
__host__ __device__ cucomp64& operator+=(const cucomp64& z);
__host__ __device__ cucomp64& operator-=(const cucomp64& z);
__host__ __device__ cucomp64& operator*=(const cucomp64& z);
__host__ __device__ cucomp64& operator/=(const cucomp64& z);
__host__ __device__ cucomp64& operator+=(const float& z);
__host__ __device__ cucomp64& operator-=(const float& z);
__host__ __device__ cucomp64& operator*=(const float& z);
__host__ __device__ cucomp64& operator/=(const float& z);
};
__host__ __device__ float arg(cucomp64 z);
__host__ __device__ cucomp64 dtocomp64(float _r, float _i);
__host__ __device__ float real(cucomp64 z);
__host__ __device__ float imag(cucomp64 z);
__host__ __device__ cucomp64 sin(cucomp64 z);
__host__ __device__ cucomp64 cos(cucomp64 z);
__host__ __device__ cucomp64 tan(cucomp64 z);
__host__ __device__ cucomp64 exp(cucomp64 z);
__host__ __device__ cucomp64 log(cucomp64 z);
__host__ __device__ float abs(cucomp64 z);
__host__ __device__ cucomp64 conj(cucomp64 z);
__host__ __device__ float arg(const cucomp64 &z);
__host__ __device__ float real(const cucomp64 &z);
__host__ __device__ float imag(const cucomp64 &z);
__host__ __device__ cucomp64 sin(const cucomp64 &z);
__host__ __device__ cucomp64 cos(const cucomp64 &z);
__host__ __device__ cucomp64 tan(const cucomp64 &z);
__host__ __device__ cucomp64 exp(const cucomp64 &z);
__host__ __device__ cucomp64 log(const cucomp64 &z);
__host__ __device__ float abs(const cucomp64 &z);
__host__ __device__ cucomp64 conj(const cucomp64 &z);
// //need hyperbolic trig Functions
__host__ __device__ cucomp64 cosh(cucomp64 z);
__host__ __device__ cucomp64 sinh(cucomp64 z);
__host__ __device__ cucomp64 tanh(cucomp64 z);
__host__ __device__ cucomp64 cosh(const cucomp64 &z);
__host__ __device__ cucomp64 sinh(const cucomp64 &z);
__host__ __device__ cucomp64 tanh(const cucomp64 &z);
__host__ __device__ cucomp64 pow(cucomp64 z1, cucomp64 z2);
__host__ __device__ cucomp64 pow(const cucomp64 &z1, const cucomp64 &z2);
// //returns "complex sign" of complex number - 0, or a unit number with same argument
__host__ __device__ cucomp64 csgn(cucomp64 z);
__host__ __device__ cucomp64 csgn(const cucomp64 &z);
void test_cucomp64_1();

View File

@ -59,12 +59,12 @@ namespace amscuda
//component headers
#include <amsculib3/math/amscu_comp64.hpp>
#include <amsculib3/math/amscu_comp128.hpp>
#include <amsculib3/math/cuvect2.hpp>
#include <amsculib3/math/cuvect3.hpp>
#include <amsculib3/math/cuvect4.hpp>
#include <amsculib3/math/cuvect2f.hpp>
#include <amsculib3/math/cuvect3f.hpp>
#include <amsculib3/math/cuvect4f.hpp>
//#include <amsculib3/math/cuvect2.hpp>
//#include <amsculib3/math/cuvect3.hpp>
//#include <amsculib3/math/cuvect4.hpp>
#include <amsculib3/math/cuvec2f.hpp>
#include <amsculib3/math/cuvec3f.hpp>
#include <amsculib3/math/cuvec4f.hpp>
#endif

View File

@ -1,33 +1,33 @@
#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 &rhs);
__host__ __device__ cuvect2f operator-(const cuvect2f &rhs);
__host__ __device__ cuvect2f operator*(const float &rhs);
__host__ __device__ cuvect2f operator/(const float &rhs);
__host__ __device__ friend cuvect2f operator-(const cuvect2f &rhs);
__host__ __device__ cuvec2f operator+(const cuvec2f &rhs);
__host__ __device__ cuvec2f operator-(const cuvec2f &rhs);
__host__ __device__ cuvec2f operator*(const float &rhs);
__host__ __device__ cuvec2f operator/(const float &rhs);
__host__ __device__ friend cuvec2f operator-(const cuvec2f &rhs);
__host__ __device__ cuvect2f& operator+=(const cuvect2f &rhs);
__host__ __device__ cuvect2f& operator-=(const cuvect2f &rhs);
__host__ __device__ cuvect2f& operator/=(const float &rhs);
__host__ __device__ cuvect2f& operator*=(const float &rhs);
__host__ __device__ cuvec2f& operator+=(const cuvec2f &rhs);
__host__ __device__ cuvec2f& operator-=(const cuvec2f &rhs);
__host__ __device__ cuvec2f& operator/=(const float &rhs);
__host__ __device__ cuvec2f& operator*=(const float &rhs);
};
@ -59,7 +59,7 @@ namespace amscuda
__host__ __device__ cumat2f operator-(const cumat2f &rhs);
__host__ __device__ cumat2f operator*(const float &rhs);
__host__ __device__ cumat2f operator/(const float &rhs);
__host__ __device__ cuvect2f operator*(const cuvect2f &rhs);
__host__ __device__ cuvec2f operator*(const cuvec2f &rhs);
__host__ __device__ cumat2f operator*(const cumat2f &rhs);
__host__ __device__ friend cumat2f operator-(const cumat2f &rhs);
@ -78,45 +78,18 @@ namespace amscuda
__host__ __device__ cumat2f& operator*=(const cumat2f &rhs);
};
__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);
__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+2*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__ cuvect2f mat2f_mult(float *mat2a, const cuvect2f &b);
void test_cuvec2f_1();

View File

@ -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);
};
@ -62,7 +62,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);
@ -82,21 +82,19 @@ 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);
__host__ void test_cudavectf_logic1();
};
#include <amsculib2/cuvect3f_legacy.hpp>
#endif

View File

@ -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,24 +12,24 @@ namespace amscuda
float z;
float w;
__host__ __device__ cuvect4f();
__host__ __device__ ~cuvect4f();
__host__ __device__ cuvect4f(const float &_x, const float &_y, const float &_z, const float &_w);
__host__ __device__ cuvec4f();
__host__ __device__ ~cuvec4f();
__host__ __device__ cuvec4f(const float &_x, const float &_y, const float &_z, const float &_w);
__host__ __device__ float& operator[](const int &I);
__host__ __device__ const float& operator[](const int &I) const;
__host__ __device__ cuvect4f operator+(const cuvect4f &rhs);
__host__ __device__ cuvect4f operator-(const cuvect4f &rhs);
__host__ __device__ cuvect4f operator*(const float &rhs);
__host__ __device__ cuvect4f operator/(const float &rhs);
__host__ __device__ friend cuvect4f operator-(const cuvect4f &rhs);
__host__ __device__ cuvec4f operator+(const cuvec4f &rhs);
__host__ __device__ cuvec4f operator-(const cuvec4f &rhs);
__host__ __device__ cuvec4f operator*(const float &rhs);
__host__ __device__ cuvec4f operator/(const float &rhs);
__host__ __device__ friend cuvec4f operator-(const cuvec4f &rhs);
__host__ __device__ cuvect4f& operator+=(const cuvect4f &rhs);
__host__ __device__ cuvect4f& operator-=(const cuvect4f &rhs);
__host__ __device__ cuvect4f& operator/=(const float &rhs);
__host__ __device__ cuvect4f& operator*=(const float &rhs);
__host__ __device__ cuvec4f& operator+=(const cuvec4f &rhs);
__host__ __device__ cuvec4f& operator-=(const cuvec4f &rhs);
__host__ __device__ cuvec4f& operator/=(const float &rhs);
__host__ __device__ cuvec4f& operator*=(const float &rhs);
};
class cumat4f
@ -66,7 +66,7 @@ namespace amscuda
__host__ __device__ cumat4f operator-(const cumat4f &rhs);
__host__ __device__ cumat4f operator*(const float &rhs);
__host__ __device__ cumat4f operator/(const float &rhs);
__host__ __device__ cuvect4f operator*(const cuvect4f &rhs);
__host__ __device__ cuvec4f operator*(const cuvec4f &rhs);
__host__ __device__ cumat4f operator*(const cumat4f &rhs);
__host__ __device__ friend cumat4f operator-(const cumat4f &rhs);
@ -85,10 +85,10 @@ namespace amscuda
__host__ __device__ cumat4f& operator*=(const cumat4f &rhs);
};
__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);
};

View File

@ -1,87 +0,0 @@
#ifndef __CUVECT2_HPP__
#define __CUVECT2_HPP__
namespace amscuda
{
class cuvect2
{
public:
double x;
double y;
__host__ __device__ cuvect2();
__host__ __device__ ~cuvect2();
__host__ __device__ cuvect2(double _x, double _y);
__host__ __device__ double& operator[](const int I);
__host__ __device__ const double& operator[](const int I) const;
__host__ __device__ cuvect2 operator+(cuvect2 lhs);
__host__ __device__ cuvect2 operator-(cuvect2 lhs);
__host__ __device__ cuvect2 operator*(double lhs);
__host__ __device__ cuvect2 operator/(double lhs);
__host__ __device__ friend cuvect2 operator-(cuvect2 rhs);
};
class cumat2
{
public:
double dat[4];
__host__ __device__ cumat2();
__host__ __device__ ~cumat2();
__host__ __device__ double& operator[](const int I);
__host__ __device__ double& operator()(const int I, const int J);
__host__ __device__ double& at(const int I, const int J);
__host__ __device__ cumat2 operator+(cumat2 lhs);
__host__ __device__ cumat2 operator-(cumat2 lhs);
__host__ __device__ cumat2 operator*(double lhs);
__host__ __device__ cumat2 operator/(double lhs);
__host__ __device__ cuvect2 operator*(cuvect2 lhs);
__host__ __device__ cumat2 operator*(cumat2 lhs);
__host__ __device__ friend cumat2 operator-(cumat2 rhs);
__host__ __device__ double det();
__host__ __device__ cumat2 transpose();
__host__ __device__ cumat2 inverse();
};
__host__ __device__ double cuvect2_dot(cuvect2 a, cuvect2 b);
__host__ __device__ double cuvect2_cross(cuvect2 a, cuvect2 b);
__host__ __device__ double cuvect2_norm(cuvect2 a);
__host__ __device__ cuvect2 cuvect2_normalize(cuvect2 a);
__host__ __device__ cuvect2 cuvect2_proj(cuvect2 a, cuvect2 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 mat2_transpose(double *mat2inout);
//copies src to dest
__host__ __device__ void mat2_copy(double *mat2_dest, const double *mat2_src);
//inverts mat?inout[4]
__host__ __device__ void mat2_inverse(double *mat2inout);
//rotatin matrix from angle
__host__ __device__ void mat2_rot_from_angle(double angle, double *mat2);
//multiplies c = a*b
__host__ __device__ void mat2_mult(double *mat2a, double *mat2b, double *mat2c);
// ret = a*b
__host__ __device__ cuvect2 mat2_mult(double *mat2a, cuvect2 b);
void test_cuvect2_1();
}; //end namespace amscuda
#endif

View File

@ -1,122 +0,0 @@
#ifndef __CUVECT3_HPP__
#define __CUVECT3_HPP__
namespace amscuda
{
class cuvect3
{
public:
double x;
double y;
double z;
__host__ __device__ cuvect3();
__host__ __device__ ~cuvect3();
__host__ __device__ cuvect3(const double &_x, const double &_y, const double &_z);
__host__ __device__ double& operator[](const int &I);
__host__ __device__ const double& operator[](const int &I) const;
__host__ __device__ cuvect3 operator+(const cuvect3 &rhs);
__host__ __device__ cuvect3 operator-(const cuvect3 &rhs);
__host__ __device__ cuvect3 operator*(const double &rhs);
__host__ __device__ cuvect3 operator/(const double &rhs);
__host__ __device__ friend cuvect3 operator-(const cuvect3 &rhs);
__host__ __device__ cuvect3& operator+=(const cuvect3 &rhs);
__host__ __device__ cuvect3& operator-=(const cuvect3 &rhs);
__host__ __device__ cuvect3& operator/=(const double &rhs);
__host__ __device__ cuvect3& operator*=(const double &rhs);
};
class cumat3
{
public:
double m00,m10,m20; //named references to force register use?
double m01,m11,m21; //switched to column-major-order to match GLSL/lapack
double m02,m12,m22;
__host__ __device__ cumat3();
__host__ __device__ ~cumat3();
__host__ __device__ cumat3(
const double & _m00, const double & _m01, const double & _m02,
const double & _m10, const double & _m11, const double & _m12,
const double & _m20, const double & _m21, const double & _m22
);
__host__ __device__ double& operator[](const int &I);
__host__ __device__ double& operator()(const int &I, const int &J);
__host__ __device__ double& at(const int &I, const int &J);
__host__ __device__ const double& operator[](const int &I) const;
__host__ __device__ const double& operator()(const int &I, const int &J) const;
__host__ __device__ const double& at(const int &I, const int &J) const;
__host__ __device__ cumat3 operator+(const cumat3 &rhs);
__host__ __device__ cumat3 operator-(const cumat3 &rhs);
__host__ __device__ cumat3 operator*(const double &rhs);
__host__ __device__ cumat3 operator/(const double &rhs);
__host__ __device__ cuvect3 operator*(const cuvect3 &rhs);
__host__ __device__ cumat3 operator*(const cumat3 &rhs);
__host__ __device__ friend cumat3 operator-(const cumat3 &rhs);
__host__ __device__ double det();
__host__ __device__ cumat3 transpose();
__host__ __device__ cumat3 inverse();
__host__ __device__ double* data(); //pointer to double[9] representation of matrix
__host__ __device__ const double* data() const; //pointer to double[9] representation of matrix
//In place operations (to save GPU register use)
__host__ __device__ cumat3& operator+=(const cumat3 &rhs);
__host__ __device__ cumat3& operator-=(const cumat3 &rhs);
__host__ __device__ cumat3& operator/=(const double &rhs);
__host__ __device__ cumat3& operator*=(const double &rhs);
__host__ __device__ cumat3& operator*=(const cumat3 &rhs);
};
__host__ __device__ double cuvect3_dot(const cuvect3 &a,const cuvect3 &b);
__host__ __device__ cuvect3 cuvect3_cross(const cuvect3 &a, const cuvect3 &b);
__host__ __device__ double cuvect3_norm(const cuvect3 &a);
__host__ __device__ cuvect3 cuvect3_normalize(const cuvect3 &a);
__host__ __device__ cuvect3 cuvect3_proj(const cuvect3 &a, const cuvect3 &b);
__host__ __device__ cumat3 hodge_dual(const cuvect3 &vin);
__host__ __device__ cuvect3 hodge_dual(const cumat3 &min);
__host__ __device__ cumat3 rotmat_from_axisangle(const cuvect3 &axis, const double &angle);
//3x3 matrix operations
//matrix order is assumed to be mat[I,J] = mat[I+3*J]
//transposes a 3x3 (9 element) matrix
__host__ __device__ void mat3f_transpose(double *mat3inout);
//copies src to dest
__host__ __device__ void mat3f_copy(double *mat3f_dest, const double *mat3f_src);
//returns determinant of 3x3 matrix
__host__ __device__ double mat3f_det(double *mat3in);
//inverts a 3x3 (9 element) matrix
__host__ __device__ void mat3f_inverse(double *mat3inout);
__host__ __device__ cuvect3 mat3f_mult(double *mat3in, const cuvect3 &cvin);
__host__ __device__ void mat3f_mult(double *matina, double *matinb, double *matout);
__host__ __device__ void mat3f_hodgedual(const cuvect3 &vecin, double *matout);
__host__ __device__ void mat3f_hodgedual(double *matin, cuvect3 &vecout);
//returns direction cosine rotation matrix from axis and angle
__host__ __device__ void mat3f_rot_from_axisangle(cuvect3 axis, double angle, double *matout);
__host__ void test_cudavect_logic1();
}; //end namespace amscuda
#endif

View File

@ -1,61 +0,0 @@
#ifndef __CUVECT4_HPP__
#define __CUVECT4_HPP__
namespace amscuda
{
class cuvect4
{
public:
double x;
double y;
double z;
double w;
__host__ __device__ cuvect4();
__host__ __device__ ~cuvect4();
__host__ __device__ cuvect4(double _x, double _y, double _z, double _w);
__host__ __device__ double& operator[](const int I);
__host__ __device__ const double& operator[](const int I) const;
__host__ __device__ cuvect4 operator+(cuvect4 lhs);
__host__ __device__ cuvect4 operator-(cuvect4 lhs);
__host__ __device__ cuvect4 operator*(double lhs);
__host__ __device__ cuvect4 operator/(double lhs);
__host__ __device__ friend cuvect4 operator-(cuvect4 rhs);
};
class cumat4
{
public:
double dat[16];
__host__ __device__ cumat4();
__host__ __device__ ~cumat4();
__host__ __device__ double& operator[](const int I);
__host__ __device__ double& operator()(const int I, const int J);
__host__ __device__ double& at(const int I, const int J);
__host__ __device__ cumat4 operator+(cumat4 lhs);
__host__ __device__ cumat4 operator-(cumat4 lhs);
__host__ __device__ cumat4 operator*(double lhs);
__host__ __device__ cumat4 operator/(double lhs);
__host__ __device__ cuvect4 operator*(cuvect4 lhs);
__host__ __device__ cumat4 operator*(cumat4 lhs);
__host__ __device__ friend cumat4 operator-(cumat4 rhs);
__host__ __device__ double det();
__host__ __device__ cumat4 transpose();
__host__ __device__ cumat4 inverse();
};
__host__ __device__ double cuvect4_dot(cuvect4 a, cuvect4 b);
__host__ __device__ double cuvect4_norm(cuvect4 a);
__host__ __device__ cuvect4 cuvect4_normalize(cuvect4 a);
__host__ __device__ cuvect4 cuvect4_proj(cuvect4 a, cuvect4 b);
}; //end namespace amscuda
#endif