rebuilding vecs

This commit is contained in:
2026-04-13 11:52:21 -04:00
parent 17a1c3f84a
commit e3be5a8a2c
16 changed files with 2497 additions and 3 deletions

View File

@ -57,14 +57,19 @@ namespace amscuda
#include <amsculib3/math/amscumath_impl.hpp>
//component headers
#include <amsculib3/math/amscumath_predecl.hpp>
#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/cuvec2.hpp>
#include <amsculib3/math/cuvec3.hpp>
#include <amsculib3/math/cuvec4.hpp>
#include <amsculib3/math/cuvec2f.hpp>
#include <amsculib3/math/cuvec3f.hpp>
#include <amsculib3/math/cuvec4f.hpp>
#include <amsculib3/math/cuvec2i.hpp>
#include <amsculib3/math/cuvec3i.hpp>
#include <amsculib3/math/cuvec4i.hpp>
#endif

View File

@ -0,0 +1,11 @@
#ifndef __AMSCUMATH_PREDECL_HPP__
#define __AMSCUMATH_PREDECL_HPP__
namespace amscuda
{
}; //end namespace amscuda
#endif

View File

@ -0,0 +1,104 @@
#ifndef __CUVEC2_HPP__
#define __CUVEC2_HPP__
namespace amscuda
{
class cuvec2
{
public:
double x;
double y;
__host__ __device__ cuvec2();
__host__ __device__ ~cuvec2();
__host__ __device__ cuvec2(const double &_x, const double &_y);
__host__ __device__ double& operator[](const int &I);
__host__ __device__ const double& operator[](const int &I) const;
__host__ __device__ cuvec2 operator+(const cuvec2& rhs) const;
__host__ __device__ cuvec2 operator-(const cuvec2& rhs) const;
__host__ __device__ cuvec2 operator*(const cuvec2& rhs) const; //elementwise product
__host__ __device__ cuvec2 operator/(const cuvec2& rhs) const; //elementwise division
__host__ __device__ friend cuvec2 operator*(const cuvec2& lhs, const double& rhs);
__host__ __device__ friend cuvec2 operator*(const double& lhs, const cuvec2& rhs);
__host__ __device__ friend cuvec2 operator/(const cuvec2& lhs, const double& rhs);
__host__ __device__ friend cuvec2 operator/(const double& lhs, const cuvec2& rhs);
__host__ __device__ friend cuvec2 operator-(const cuvec2& other);
__host__ __device__ cuvec2& operator+=(const cuvec2& rhs);
__host__ __device__ cuvec2& operator-=(const cuvec2& rhs);
__host__ __device__ cuvec2& operator*=(const double& rhs);
__host__ __device__ cuvec2& operator/=(const double& rhs);
};
class cumat2
{
public:
double m00,m10;
double m01,m11;
__host__ __device__ cumat2();
__host__ __device__ ~cumat2();
__host__ __device__ cumat2(
const double& _m00, const double& _m01,
const double& _m10, const double& _m11
);
__host__ __device__ cumat2(const double* data4);
__host__ __device__ double& operator[](const int &I);
__host__ __device__ const double& operator[](const int &I) const;
__host__ __device__ double& operator()(const int &I, const int &J);
__host__ __device__ const double& operator()(const int &I, const int &J) const;
__host__ __device__ double& at(const int &I, const int &J);
__host__ __device__ const double& at(const int &I, const int &J) const;
__host__ __device__ double* data(); //pointer to double4 representation of matrix
__host__ __device__ const double* data() const; //pointer to double4 representation of matrix
//operators
__host__ __device__ cumat2 operator+(const cumat2& rhs) const;
__host__ __device__ cumat2 operator-(const cumat2& rhs) const;
__host__ __device__ cumat2 operator*(const cumat2& rhs) const;
__host__ __device__ friend cumat2 operator*(const cumat2& lhs, const double& rhs);
__host__ __device__ friend cumat2 operator/(const cumat2& lhs, const double& rhs);
__host__ __device__ friend cumat2 operator*(const double& lhs, const cumat2& rhs);
__host__ __device__ friend cuvec2 operator*(const cumat2& lhs, const cuvec2& rhs);
__host__ __device__ friend cuvec2 operator*(const cuvec2& lhs, const cumat2& rhs);
__host__ __device__ friend cumat2 operator-(const cumat2& rhs);
//in place operators to save register use
__host__ __device__ cumat2& operator+=(const cumat2& rhs);
__host__ __device__ cumat2& operator-=(const cumat2& rhs);
__host__ __device__ cumat2& operator*=(const double& rhs);
__host__ __device__ cumat2& operator/=(const double& rhs);
__host__ __device__ cumat2& operator*=(const cumat2& rhs);
__host__ __device__ cumat2 transpose() const;
__host__ __device__ double det();
__host__ __device__ cumat2 inverse();
};
__host__ __device__ double cuvec2_dot(const cuvec2 &a, const cuvec2 &b);
__host__ __device__ double cuvec2_cross(const cuvec2 &a, const cuvec2 &b);
__host__ __device__ double cuvec2_norm(const cuvec2 &a);
__host__ __device__ cuvec2 cuvec2_normalize(const cuvec2 &a);
__host__ __device__ cuvec2 cuvec2_proj(const cuvec2 &a, const cuvec2 &b);
__host__ __device__ cumat2 cumat2_rot_from_angle(const double &angle);
///////////
// Tests //
///////////
void test_cuvec2_1();
}; //end namespace amscuda
#endif

View File

@ -0,0 +1,12 @@
#ifndef __CUVEC2I_HPP__
#define __CUVEC2I_HPP__
namespace amscuda
{
}; //end namespace amscuda
#endif

View File

@ -0,0 +1,103 @@
#ifndef __CUVEC3_HPP__
#define __CUVEC3_HPP__
namespace amscuda
{
class cuvec3
{
public:
double x;
double y;
double z;
__host__ __device__ cuvec3();
__host__ __device__ ~cuvec3();
__host__ __device__ cuvec3(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__ cuvec3 operator+(const cuvec3& rhs) const;
__host__ __device__ cuvec3 operator-(const cuvec3& rhs) const;
__host__ __device__ cuvec3 operator*(const cuvec3& rhs) const; //elementwise product
__host__ __device__ cuvec3 operator/(const cuvec3& rhs) const; //elementwise division
__host__ __device__ friend cuvec3 operator*(const cuvec3& lhs, const double& rhs);
__host__ __device__ friend cuvec3 operator*(const double& lhs, const cuvec3& rhs);
__host__ __device__ friend cuvec3 operator/(const cuvec3& lhs, const double& rhs);
__host__ __device__ friend cuvec3 operator/(const double& lhs, const cuvec3& rhs);
__host__ __device__ friend cuvec3 operator-(const cuvec3& other);
__host__ __device__ cuvec3& operator+=(const cuvec3& rhs);
__host__ __device__ cuvec3& operator-=(const cuvec3& rhs);
__host__ __device__ cuvec3& operator*=(const double& rhs);
__host__ __device__ cuvec3& operator/=(const double& rhs);
};
class cumat3
{
public:
double m00,m10,m20;
double m01,m11,m21;
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__ cumat3(const double* data9);
__host__ __device__ double& operator[](const int &I);
__host__ __device__ const double& operator[](const int &I) const;
__host__ __device__ double& operator()(const int &I, const int &J);
__host__ __device__ const double& operator()(const int &I, const int &J) const;
__host__ __device__ double& at(const int &I, const int &J);
__host__ __device__ const double& at(const int &I, const int &J) const;
__host__ __device__ double* data(); //pointer to double9 representation of matrix
__host__ __device__ const double* data() const; //pointer to double9 representation of matrix
__host__ __device__ cumat3 operator+(const cumat3& rhs) const;
__host__ __device__ cumat3 operator-(const cumat3& rhs) const;
__host__ __device__ cumat3 operator*(const cumat3& rhs) const;
__host__ __device__ friend cumat3 operator*(const cumat3& lhs, const double& rhs);
__host__ __device__ friend cumat3 operator/(const cumat3& lhs, const double& rhs);
__host__ __device__ friend cumat3 operator*(const double& lhs, const cumat3& rhs);
__host__ __device__ friend cuvec3 operator*(const cumat3& lhs, const cuvec3& rhs);
__host__ __device__ friend cuvec3 operator*(const cuvec3& lhs, const cumat3& rhs);
__host__ __device__ friend cumat3 operator-(const cumat3& rhs);
__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__ cumat3 transpose() const;
__host__ __device__ double det();
__host__ __device__ cumat3 inverse();
};
__host__ __device__ double cuvec3_dot(const cuvec3 &a,const cuvec3 &b);
__host__ __device__ cuvec3 cuvec3_cross(const cuvec3 &a, const cuvec3 &b);
__host__ __device__ double cuvec3_norm(const cuvec3 &a);
__host__ __device__ cuvec3 cuvec3_normalize(const cuvec3 &a);
__host__ __device__ cuvec3 cuvec3_proj(const cuvec3 &a, const cuvec3 &b);
__host__ __device__ cumat3 hodge_dual(const cuvec3 &vin);
__host__ __device__ cuvec3 hodge_dual(const cumat3 &min);
__host__ __device__ cumat3 rotmat_from_axisangle(const cuvec3 &axis, const double &angle);
__host__ void test_cudavectf_logic1();
}; //end namespace amscuda
#endif

View File

@ -0,0 +1,12 @@
#ifndef __CUVEC3I_HPP__
#define __CUVEC3I_HPP__
namespace amscuda
{
}; //end namespace amscuda
#endif

View File

@ -0,0 +1,103 @@
#ifndef __CUVEC4_HPP__
#define __CUVEC4_HPP__
namespace amscuda
{
class cuvec4
{
public:
double x;
double y;
double z;
double w;
__host__ __device__ cuvec4();
__host__ __device__ ~cuvec4();
__host__ __device__ cuvec4(const double &_x, const double &_y, const double &_z, const double &_w);
__host__ __device__ double& operator[](const int &I);
__host__ __device__ const double& operator[](const int &I) const;
__host__ __device__ cuvec4 operator+(const cuvec4& rhs) const;
__host__ __device__ cuvec4 operator-(const cuvec4& rhs) const;
__host__ __device__ cuvec4 operator*(const cuvec4& rhs) const; //elementwise product
__host__ __device__ cuvec4 operator/(const cuvec4& rhs) const; //elementwise division
__host__ __device__ friend cuvec4 operator*(const cuvec4& lhs, const double& rhs);
__host__ __device__ friend cuvec4 operator*(const double& lhs, const cuvec4& rhs);
__host__ __device__ friend cuvec4 operator/(const cuvec4& lhs, const double& rhs);
__host__ __device__ friend cuvec4 operator/(const double& lhs, const cuvec4& rhs);
__host__ __device__ friend cuvec4 operator-(const cuvec4& other);
__host__ __device__ cuvec4& operator+=(const cuvec4& rhs);
__host__ __device__ cuvec4& operator-=(const cuvec4& rhs);
__host__ __device__ cuvec4& operator*=(const double& rhs);
__host__ __device__ cuvec4& operator/=(const double& rhs);
};
class cumat4
{
public:
//double dat[16];
//__forceinline__
double m00,m10,m20,m30;
double m01,m11,m21,m31;
double m02,m12,m22,m32;
double m03,m13,m23,m33;
__host__ __device__ cumat4();
__host__ __device__ ~cumat4();
__host__ __device__ cumat4(
const double& _m00, const double& _m01, const double& _m02, const double& _m03,
const double& _m10, const double& _m11, const double& _m12, const double& _m13,
const double& _m20, const double& _m21, const double& _m22, const double& _m23,
const double& _m30, const double& _m31, const double& _m32, const double& _m33
);
__host__ __device__ cumat4(const double* data16);
__host__ __device__ double& operator[](const int &I);
__host__ __device__ const double& operator[](const int &I) const;
__host__ __device__ double& operator()(const int &I, const int &J);
__host__ __device__ const double& operator()(const int &I, const int &J) const;
__host__ __device__ double& at(const int &I, const int &J);
__host__ __device__ const double& at(const int &I, const int &J) const;
__host__ __device__ double* data(); //pointer to double16 representation of matrix
__host__ __device__ const double* data() const; //pointer to double16 representation of matrix
__host__ __device__ cumat4 operator+(const cumat4& rhs) const;
__host__ __device__ cumat4 operator-(const cumat4& rhs) const;
__host__ __device__ cumat4 operator*(const cumat4& rhs) const;
__host__ __device__ friend cumat4 operator*(const cumat4& lhs, const double& rhs);
__host__ __device__ friend cumat4 operator/(const cumat4& lhs, const double& rhs);
__host__ __device__ friend cumat4 operator*(const double& lhs, const cumat4& rhs);
__host__ __device__ friend cuvec4 operator*(const cumat4& lhs, const cuvec4& rhs);
__host__ __device__ friend cuvec4 operator*(const cuvec4& lhs, const cumat4& rhs);
__host__ __device__ friend cumat4 operator-(const cumat4& rhs);
__host__ __device__ cumat4& operator+=(const cumat4& rhs);
__host__ __device__ cumat4& operator-=(const cumat4& rhs);
__host__ __device__ cumat4& operator*=(const double& rhs);
__host__ __device__ cumat4& operator/=(const double& rhs);
__host__ __device__ cumat4& operator*=(const cumat4& rhs);
__host__ __device__ cumat4 transpose() const;
__host__ __device__ double det();
__host__ __device__ cumat4 inverse();
};
__host__ __device__ double cuvec4_dot(cuvec4 &a, cuvec4 &b);
__host__ __device__ double cuvec4_norm(cuvec4 &a);
__host__ __device__ cuvec4 cuvec4_normalize(cuvec4 &a);
__host__ __device__ cuvec4 cuvec4_proj(cuvec4 &a, cuvec4 &b);
}; //end namespace amscuda
#endif

View File

@ -0,0 +1,11 @@
#ifndef __CUVEC4I_HPP__
#define __CUVEC4I_HPP__
namespace amscuda
{
}; //end namespace amscuda
#endif