#ifndef __AMSCU_COMP128_HPP__
#define __AMSCU_COMP128_HPP__

namespace amscuda
{
namespace cmp
{

    class cucomp128
    {
        public:
        double real;
        double imag;

        __host__ __device__ cucomp128();
        __host__ __device__ ~cucomp128();
        __host__ __device__ cucomp128(const cucomp128 &other);
        __host__ __device__ explicit cucomp128(const double &other);
        __host__ __device__ explicit cucomp128(const double &_real, const double &_imag);

        __host__ __device__ cucomp128& operator=(const cucomp128& other);
        __host__ __device__ cucomp128& operator=(const double& other);
        
        __host__ __device__ double& operator[](int& ind);
        __host__ __device__ const double& operator[](const int& ind) const;

        __host__ __device__ cucomp128 operator+(const cucomp128& z) const;
        __host__ __device__ cucomp128 operator-(const cucomp128& z) const;
        __host__ __device__ cucomp128 operator*(const cucomp128& z) const;
        __host__ __device__ cucomp128 operator/(const cucomp128& z) const;

        __host__ __device__ friend cucomp128 operator+(const cucomp128& z1, const double& z2);
        __host__ __device__ friend cucomp128 operator-(const cucomp128& z1, const double& z2);
        __host__ __device__ friend cucomp128 operator*(const cucomp128& z1, const double& z2);
        __host__ __device__ friend cucomp128 operator/(const cucomp128& z1, const double& z2);

        __host__ __device__ friend cucomp128 operator+(const double& z1, const cucomp128& z2);
        __host__ __device__ friend cucomp128 operator-(const double& z1, const cucomp128& z2);
        __host__ __device__ friend cucomp128 operator*(const double& z1, const cucomp128& z2);
        __host__ __device__ friend cucomp128 operator/(const double& z1, const cucomp128& z2);

        __host__ __device__ friend cucomp128 operator-(const cucomp128& z); //negation sign

        //comparison operators
        __host__ __device__ bool operator==(const cucomp128& z) const;
        __host__ __device__ bool operator!=(const cucomp128& z) const;
        __host__ __device__ bool operator>(const cucomp128& z) const;
        __host__ __device__ bool operator<(const cucomp128& z) const;
        __host__ __device__ bool operator>=(const cucomp128& z) const;
        __host__ __device__ bool operator<=(const cucomp128& z) const;

        __host__ __device__ bool isnan() const;
        __host__ __device__ bool isinf() const;

        __host__ __device__ bool isreal() const;
        __host__ __device__ bool isimag() const;
        __host__ __device__ bool iszero() const;
        __host__ __device__ double arg() const;
        __host__ __device__ double mag() const;
        __host__ __device__ double abs() const;
        __host__ __device__ cucomp128 conj() const;

        //accumulation operators
        __host__ __device__ cucomp128& operator+=(const cucomp128& z);
        __host__ __device__ cucomp128& operator-=(const cucomp128& z);
        __host__ __device__ cucomp128& operator*=(const cucomp128& z);
        __host__ __device__ cucomp128& operator/=(const cucomp128& z);

        __host__ __device__ cucomp128& operator+=(const double& z);
        __host__ __device__ cucomp128& operator-=(const double& z);
        __host__ __device__ cucomp128& operator*=(const double& z);
        __host__ __device__ cucomp128& operator/=(const double& z);
        
    };

    __host__ __device__ double arg(const cucomp128 &z);
    __host__ __device__ double real(const cucomp128 &z);
    __host__ __device__ double imag(const cucomp128 &z);
    __host__ __device__ cucomp128 sin(const cucomp128 &z);
    __host__ __device__ cucomp128 cos(const cucomp128 &z);
    __host__ __device__ cucomp128 tan(const cucomp128 &z);
    __host__ __device__ cucomp128 exp(const cucomp128 &z);
    __host__ __device__ cucomp128 log(const cucomp128 &z);
    __host__ __device__ double abs(const cucomp128 &z);
    __host__ __device__ cucomp128 conj(const cucomp128 &z);

    // //need hyperbolic trig Functions
    __host__ __device__ cucomp128 cosh(const cucomp128 &z);
    __host__ __device__ cucomp128 sinh(const cucomp128 &z);
    __host__ __device__ cucomp128 tanh(const cucomp128 &z);

    __host__ __device__ cucomp128 pow(const cucomp128 &z1, const cucomp128 &z2);

    // //returns "complex sign" of complex number - 0, or a unit number with same argument
    __host__ __device__ cucomp128 csgn(const cucomp128 &z);

void test_cucomp128_1();


}; //end namespace cmp
}; //end namespace amscuda

#endif

