half done with cuvect4f

This commit is contained in:
2026-04-09 15:37:50 -04:00
parent b40bdce4c0
commit 43e130e57d
20 changed files with 120 additions and 70 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -14,16 +14,22 @@ namespace amscuda
__host__ __device__ cuvect4f();
__host__ __device__ ~cuvect4f();
__host__ __device__ cuvect4f(float _x, float _y, float _z, float _w);
__host__ __device__ cuvect4f(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+(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__ 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__ 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);
};
class cumat4f
@ -31,6 +37,11 @@ namespace amscuda
public:
float dat[16];
// float m00,m10,m20,m30; //named references to force register use?
// float m01,m11,m21,m31; //switched to column-major-order to match GLSL/lapack
// float m02,m12,m22,m32;
// float m03,m13,m23,m33;
__host__ __device__ cumat4f();
__host__ __device__ ~cumat4f();
__host__ __device__ float& operator[](const int I);

View File

@ -9,80 +9,119 @@ namespace amscuda
__host__ __device__ cuvect4f::cuvect4f()
{
x = 0.0; y = 0.0; z = 0.0; w = 0.0;
x = 0.0f; y = 0.0f; z = 0.0f; w = 0.0f;
return;
}
__host__ __device__ cuvect4f::~cuvect4f()
{
x = 0.0; y = 0.0; z = 0.0; w = 0.0;
x = 0.0f; y = 0.0f; z = 0.0f; w = 0.0f;
return;
}
__host__ __device__ cuvect4f::cuvect4f(float _x, float _y, float _z, float _w)
__host__ __device__ float& cuvect4f::operator[](const int &I)
{
if(I==0) return x;
if(I==1) return y;
if(I==2) return z;
if(I==3) return w;
return x;
}
__host__ __device__ const float& cuvect4f::operator[](const int &I) const
{
if(I==0) return x;
if(I==1) return y;
if(I==2) return z;
if(I==3) return w;
return x;
}
__host__ __device__ cuvect4f cuvect4f::operator+(const cuvect4f &rhs)
{
cuvect4f ret;
ret.x = x+rhs.x;
ret.y = y+rhs.y;
ret.z = z+rhs.z;
ret.w = w+rhs.w;
return ret;
}
__host__ __device__ cuvect4f cuvect4f::operator-(const cuvect4f &rhs)
{
cuvect4f ret;
ret.x = x-rhs.x;
ret.y = y-rhs.y;
ret.z = z-rhs.z;
ret.w = w-rhs.w;
return ret;
}
__host__ __device__ cuvect4f cuvect4f::operator*(const float &rhs)
{
cuvect4f ret;
ret.x = x*rhs;
ret.y = y*rhs;
ret.z = z*rhs;
ret.w = w*rhs;
return ret;
}
__host__ __device__ cuvect4f cuvect4f::operator/(const float &rhs)
{
cuvect4f ret;
ret.x = x/rhs;
ret.y = y/rhs;
ret.z = z/rhs;
ret.w = w/rhs;
return ret;
}
__host__ __device__ cuvect4f& cuvect4f::operator+=(const cuvect4f &rhs)
{
x = x + rhs.x;
y = y + rhs.y;
z = z + rhs.z;
w = w + rhs.w;
return *this;
}
__host__ __device__ cuvect4f& cuvect4f::operator-=(const cuvect4f &rhs)
{
x = x - rhs.x;
y = y - rhs.y;
z = z - rhs.z;
w = w - rhs.w;
return *this;
}
__host__ __device__ cuvect4f& cuvect4f::operator*=(const float &rhs)
{
x = x * rhs;
y = y * rhs;
z = z * rhs;
w = w * rhs;
return *this;
}
__host__ __device__ cuvect4f& cuvect4f::operator/=(const float &rhs)
{
x = x / rhs;
y = y / rhs;
z = z / rhs;
w = w / rhs;
return *this;
}
__host__ __device__ cuvect4f::cuvect4f(const float &_x, const float &_y, const float &_z, const float &_w)
{
x = _x; y = _y; z = _z; w = _w;
return;
}
__host__ __device__ float& cuvect4f::operator[](const int I)
{
if(I==0) return x;
else if(I==1) return y;
else if(I==2) return z;
else if(I==3) return w;
return x;
}
__host__ __device__ const float& cuvect4f::operator[](const int I) const
{
if(I==0) return x;
else if(I==1) return y;
else if(I==2) return z;
else if(I==3) return w;
return x;
}
__host__ __device__ cuvect4f cuvect4f::operator+(cuvect4f lhs)
{
cuvect4f ret;
ret.x = this->x + lhs.x;
ret.y = this->y + lhs.y;
ret.z = this->z + lhs.z;
ret.w = this->w + lhs.w;
return ret;
}
__host__ __device__ cuvect4f cuvect4f::operator-(cuvect4f lhs)
{
cuvect4f ret;
ret.x = this->x - lhs.x;
ret.y = this->y - lhs.y;
ret.z = this->z - lhs.z;
ret.w = this->w - lhs.w;
return ret;
}
__host__ __device__ cuvect4f cuvect4f::operator*(float lhs)
{
cuvect4f ret;
ret.x = this->x*lhs;
ret.y = this->y*lhs;
ret.z = this->z*lhs;
ret.w = this->w*lhs;
return ret;
}
__host__ __device__ cuvect4f cuvect4f::operator/(float lhs)
{
cuvect4f ret;
ret.x = this->x/lhs;
ret.y = this->y/lhs;
ret.z = this->z/lhs;
ret.w = this->w/lhs;
return ret;
}
__host__ __device__ cumat4f::cumat4f()
{
int I;