diff --git a/build/__pycache__/amsbuildlib4.cpython-310.pyc b/build/__pycache__/amsbuildlib4.cpython-310.pyc index 521d819..590285b 100644 Binary files a/build/__pycache__/amsbuildlib4.cpython-310.pyc and b/build/__pycache__/amsbuildlib4.cpython-310.pyc differ diff --git a/build/__pycache__/amsbuildlib4.cpython-311.pyc b/build/__pycache__/amsbuildlib4.cpython-311.pyc index a3642e0..df8efce 100644 Binary files a/build/__pycache__/amsbuildlib4.cpython-311.pyc and b/build/__pycache__/amsbuildlib4.cpython-311.pyc differ diff --git a/build_linux64/libamsculib3.linux64.a b/build_linux64/libamsculib3.linux64.a index 1c8e36b..e06ae52 100644 Binary files a/build_linux64/libamsculib3.linux64.a and b/build_linux64/libamsculib3.linux64.a differ diff --git a/build_linux64/objstore/amscu_comp128.o b/build_linux64/objstore/amscu_comp128.o index 2a47d18..2c90406 100644 Binary files a/build_linux64/objstore/amscu_comp128.o and b/build_linux64/objstore/amscu_comp128.o differ diff --git a/build_linux64/objstore/amscu_comp64.o b/build_linux64/objstore/amscu_comp64.o index a217bae..ba9bed6 100644 Binary files a/build_linux64/objstore/amscu_comp64.o and b/build_linux64/objstore/amscu_comp64.o differ diff --git a/build_linux64/objstore/amscu_cudafunctions.o b/build_linux64/objstore/amscu_cudafunctions.o index db83c5b..1481357 100644 Binary files a/build_linux64/objstore/amscu_cudafunctions.o and b/build_linux64/objstore/amscu_cudafunctions.o differ diff --git a/build_linux64/objstore/amscu_random.o b/build_linux64/objstore/amscu_random.o index 0e407a7..17da646 100644 Binary files a/build_linux64/objstore/amscu_random.o and b/build_linux64/objstore/amscu_random.o differ diff --git a/build_linux64/objstore/amscuarray.o b/build_linux64/objstore/amscuarray.o index 365e905..5ab9e32 100644 Binary files a/build_linux64/objstore/amscuarray.o and b/build_linux64/objstore/amscuarray.o differ diff --git a/build_linux64/objstore/amscuarray_dops.o b/build_linux64/objstore/amscuarray_dops.o index 6e79477..77ceb4b 100644 Binary files a/build_linux64/objstore/amscuarray_dops.o and b/build_linux64/objstore/amscuarray_dops.o differ diff --git a/build_linux64/objstore/amscugeom.o b/build_linux64/objstore/amscugeom.o index 8896ad7..dfe3b7a 100644 Binary files a/build_linux64/objstore/amscugeom.o and b/build_linux64/objstore/amscugeom.o differ diff --git a/build_linux64/objstore/amsculib3.o b/build_linux64/objstore/amsculib3.o index a0141c8..4820382 100644 Binary files a/build_linux64/objstore/amsculib3.o and b/build_linux64/objstore/amsculib3.o differ diff --git a/build_linux64/objstore/amscumath.o b/build_linux64/objstore/amscumath.o index 8dc15b4..4087a4b 100644 Binary files a/build_linux64/objstore/amscumath.o and b/build_linux64/objstore/amscumath.o differ diff --git a/build_linux64/objstore/amscurarray.o b/build_linux64/objstore/amscurarray.o index 519248e..8f08c5f 100644 Binary files a/build_linux64/objstore/amscurarray.o and b/build_linux64/objstore/amscurarray.o differ diff --git a/build_linux64/objstore/cuvec2f.o b/build_linux64/objstore/cuvec2f.o index 17771d0..e54b9f3 100644 Binary files a/build_linux64/objstore/cuvec2f.o and b/build_linux64/objstore/cuvec2f.o differ diff --git a/build_linux64/objstore/cuvec3f.o b/build_linux64/objstore/cuvec3f.o index b3cdf72..0f10658 100644 Binary files a/build_linux64/objstore/cuvec3f.o and b/build_linux64/objstore/cuvec3f.o differ diff --git a/build_linux64/objstore/cuvec4f.o b/build_linux64/objstore/cuvec4f.o index 5bde412..8f97486 100644 Binary files a/build_linux64/objstore/cuvec4f.o and b/build_linux64/objstore/cuvec4f.o differ diff --git a/build_linux64/test b/build_linux64/test index a3941b7..a01602f 100644 Binary files a/build_linux64/test and b/build_linux64/test differ diff --git a/include/amsculib3/math/amscu_comp64.hpp b/include/amsculib3/math/amscu_comp64.hpp index 7b8cf29..531233d 100644 --- a/include/amsculib3/math/amscu_comp64.hpp +++ b/include/amsculib3/math/amscu_comp64.hpp @@ -18,23 +18,26 @@ namespace cmp __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); - __host__ __device__ cucomp64& operator=(float& other); - __host__ __device__ const cucomp64& operator=(const float& other); + __host__ __device__ cucomp64& operator=(const cucomp64& other); + __host__ __device__ cucomp64& operator=(const float& other); __host__ __device__ float& operator[](int& ind); __host__ __device__ const float& operator[](const int& ind) const; - __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 cucomp64& z) const; + __host__ __device__ cucomp64 operator-(const cucomp64& z) const; + __host__ __device__ cucomp64 operator*(const cucomp64& z) const; + __host__ __device__ cucomp64 operator/(const cucomp64& z) const; - __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__ friend cucomp64 operator+(const cucomp64& z1, const float& z2); + __host__ __device__ friend cucomp64 operator-(const cucomp64& z1, const float& z2); + __host__ __device__ friend cucomp64 operator*(const cucomp64& z1, const float& z2); + __host__ __device__ friend cucomp64 operator/(const cucomp64& z1, const float& z2); + + __host__ __device__ friend cucomp64 operator+(const float& z1, const cucomp64& z2); + __host__ __device__ friend cucomp64 operator-(const float& z1, const cucomp64& z2); + __host__ __device__ friend cucomp64 operator*(const float& z1, const cucomp64& z2); + __host__ __device__ friend cucomp64 operator/(const float& z1, const cucomp64& z2); __host__ __device__ friend cucomp64 operator-(const cucomp64& z); //negation sign diff --git a/src/amsculib3/math/amscu_comp64.cu b/src/amsculib3/math/amscu_comp64.cu index e5789f5..ff848f9 100644 --- a/src/amsculib3/math/amscu_comp64.cu +++ b/src/amsculib3/math/amscu_comp64.cu @@ -41,34 +41,21 @@ __host__ __device__ cucomp64::cucomp64(const float &_real, const float &_imag) return; } -__host__ __device__ cucomp64& cucomp64::operator=(cucomp64& other) +__host__ __device__ cucomp64& cucomp64::operator=(const cucomp64& other) { real = other.real; imag = other.imag; return *this; } -__host__ __device__ const cucomp64& cucomp64::operator=(const cucomp64& other) -{ - this->real = other.real; - this->imag = other.imag; - return *this; -} -__host__ __device__ cucomp64& cucomp64::operator=(float& other) +__host__ __device__ cucomp64& cucomp64::operator=(const float& other) { real = other; imag = 0.0f; return *this; } -__host__ __device__ const cucomp64& cucomp64::operator=(const float& other) -{ - this->real = other; - this->imag = 0.0f; - return *this; -} - __host__ __device__ float& cucomp64::operator[](int& ind) { if(ind==0) @@ -93,7 +80,7 @@ __host__ __device__ const float& cucomp64::operator[](const int& ind) const } } -__host__ __device__ cucomp64 cucomp64::operator+(const cucomp64& z) +__host__ __device__ cucomp64 cucomp64::operator+(const cucomp64& z) const { cucomp64 ret; ret.real = real + z.real; @@ -101,7 +88,7 @@ __host__ __device__ cucomp64 cucomp64::operator+(const cucomp64& z) return ret; } -__host__ __device__ cucomp64 cucomp64::operator-(const cucomp64& z) +__host__ __device__ cucomp64 cucomp64::operator-(const cucomp64& z) const { cucomp64 ret; ret.real = real - z.real; @@ -109,68 +96,95 @@ __host__ __device__ cucomp64 cucomp64::operator-(const cucomp64& z) return ret; } -__host__ __device__ cucomp64 cucomp64::operator*(const cucomp64& z) +__host__ __device__ cucomp64 cucomp64::operator*(const cucomp64& z) const { cucomp64 ret; - ret.real = (real*z.real - imag*z.imag); - ret.imag = (imag*z.real + real*z.imag); + ret.real = real*z.real - imag*z.imag; + ret.imag = imag*z.real + real*z.imag; return ret; } -__host__ __device__ cucomp64 cucomp64::operator/(const cucomp64& z) +__host__ __device__ cucomp64 cucomp64::operator/(const cucomp64& z) const { cucomp64 ret; float zm2 = z.real*z.real+z.imag*z.imag; - if(zm2>0.0) - { - ret.real = (this->real*z.real+this->imag*z.imag)/zm2; - ret.imag = (this->imag*z.real-this->real*z.imag)/zm2; - } - else - { - ret.real = (float) finf; - ret.imag = (float) finf; - } +// if(zm2>0.0) +// { + ret.real = (real*z.real+imag*z.imag)/zm2; + ret.imag = (imag*z.real-real*z.imag)/zm2; +// } +// else +// { +// ret.real = (float) finf; +// ret.imag = (float) finf; +// } return ret; } -__host__ __device__ cucomp64 cucomp64::operator+(const float& z) +__host__ __device__ cucomp64 operator+(const cucomp64& z1, const float& z2) { cucomp64 ret; - ret.real = this->real + z; - ret.imag = this->imag; + ret.real = z1.real+z2; + ret.imag = z1.imag; return ret; } -__host__ __device__ cucomp64 cucomp64::operator-(const float& z) -{ - cucomp64 ret; - ret.real = real-z; - ret.imag = imag; - return ret; -} -__host__ __device__ cucomp64 cucomp64::operator*(const float& z) -{ - cucomp64 ret; - ret.real = real*z; - ret.imag = imag*z; - return ret; -} -__host__ __device__ cucomp64 cucomp64::operator/(const float& z) -{ - cucomp64 ret; - if(z!=0.0f) - { - ret.real = real/z; - ret.imag = imag/z; - } - else - { - ret.real = finf; - ret.imag = finf; - } +__host__ __device__ cucomp64 operator-(const cucomp64& z1, const float& z2) +{ + cucomp64 ret; + ret.real = z1.real-z2; + ret.imag = z1.imag; + return ret; +} + +__host__ __device__ cucomp64 operator*(const cucomp64& z1, const float& z2) +{ + cucomp64 ret; + ret.real = z1.real*z2; + ret.imag = z1.imag*z2; + return ret; +} + +__host__ __device__ cucomp64 operator/(const cucomp64& z1, const float& z2) +{ + cucomp64 ret; + ret.real = z1.real/z2; + ret.imag = z1.imag/z2; + return ret; +} + +__host__ __device__ cucomp64 operator+(const float& z1, const cucomp64& z2) +{ + cucomp64 ret; + ret.real = z1 + z2.real; + ret.imag = z2.imag; + return ret; +} + +__host__ __device__ cucomp64 operator-(const float& z1, const cucomp64& z2) +{ + cucomp64 ret; + ret.real = z1 - z2.real; + ret.imag = -z2.imag; + return ret; +} + +__host__ __device__ cucomp64 operator*(const float& z1, const cucomp64& z2) +{ + cucomp64 ret; + ret.real = z1*z2.real; + ret.imag = z1*z2.imag; + return ret; +} + +__host__ __device__ cucomp64 operator/(const float& z1, const cucomp64& z2) +{ + cucomp64 ret; + float zmg = z2.real*z2.real + z2.imag*z2.imag; + ret.real = z1*(z2.real)/zmg; + ret.imag = -z1*(z2.imag)/zmg; return ret; } @@ -463,42 +477,56 @@ __host__ __device__ cucomp64 csgn(const cucomp64 &z) __host__ __device__ cucomp64& cucomp64::operator+=(const cucomp64& z) { - + real += z.real; + imag += z.imag; return (*this); } __host__ __device__ cucomp64& cucomp64::operator-=(const cucomp64& z) { + real -= z.real; + imag -= z.imag; return (*this); } __host__ __device__ cucomp64& cucomp64::operator*=(const cucomp64& z) { + cucomp64 t = (*this); + real = t.real*z.real - t.imag*z.imag; + imag = t.real*z.imag + t.imag*z.real; return (*this); } __host__ __device__ cucomp64& cucomp64::operator/=(const cucomp64& z) { + amscuda::cmp::cucomp64 t = *this; + *this = t/z; return (*this); } __host__ __device__ cucomp64& cucomp64::operator+=(const float& z) { + real += z; return (*this); } __host__ __device__ cucomp64& cucomp64::operator-=(const float& z) { + real -= z; return (*this); } __host__ __device__ cucomp64& cucomp64::operator*=(const float& z) { + real *= z; + imag *= z; return (*this); } __host__ __device__ cucomp64& cucomp64::operator/=(const float& z) { + real /= z; + imag /= z; return (*this); }