#ifndef __AMSCUMATH_HPP__
#define __AMSCUMATH_HPP__

namespace amscuda
{



    //Problem: These are not in the namespace
    //#define nan NAN
    //#define fnan (float) NAN
    //#define inf INFINITY
    //#define finf (float) INFINITY
    //#define pi 3.1415926535897936

    //These need to be the same symbol for both host and device code
    AMSCU_CONST static const double nan = NAN;
    AMSCU_CONST static const float fnan = (float) NAN;
    AMSCU_CONST static const double inf = INFINITY;
    AMSCU_CONST static const float finf = (float) INFINITY;
    AMSCU_CONST static const double pi = 3.1415926535897936;
    AMSCU_CONST static const float pif = 3.1415926535897936;

    __host__ __device__ double dabs(const double &x);
    __host__ __device__ float fabs(const float &x);
    
    template<typename T> __host__ __device__ T abs(const T in)
    {
        T ret = in;
        if(in<0) ret = -in;
        return ret;
    }

    __host__ __device__ double mod(const double &a, const double &md);
    __host__ __device__ float mod(const float &a, const float &md);
    __host__ __device__ int mod(const int &x, const int &n);
    __host__ __device__ long mod(const long &x, const long &n);

    __host__ __device__ int truediv(const int &x, const int &y);
    __host__ __device__ long truediv(const long &x, const long &y);

    template<typename T> __host__ __device__ T min(const T &a, const T &b);
    template<typename T> __host__ __device__ T max(const T &a, const T &b);

    __device__ __host__ double arg(const double &x, const double &y);
    __device__ __host__ void get_azel(const double &x, const double &y, const double &z, double *az, double *el);
    __device__ __host__ void get_azel(const double &x, const double &y, const double &z, double &az_out, double &el_out);

    __device__ __host__ double argf(const float &x, const float &y);
    __device__ __host__ void get_azelf(const float &x, const float &y, const float &z, float &az_out, float &el_out);

    void test_amscumath1();


}; //end namespace amscuda

#include <amsculib2/amscumath_impl.hpp>

#endif

