42 #ifndef _TEUCHOS_SCALARTRAITS_CUDA_HPP_
43 #define _TEUCHOS_SCALARTRAITS_CUDA_HPP_
54 struct ScalarTraits<int>
64 static inline __device__ __host__
int zero() {
return 0; }
65 static inline __device__ __host__
int one() {
return 1; }
66 static inline __device__ __host__
int conjugate(
int x) {
return x; }
67 static inline __device__ __host__
int real(
int x) {
return x; }
68 static inline __device__ __host__
int imag(
int) {
return 0; }
69 static inline __device__ __host__
bool isnaninf(
int) {
return false; }
70 static inline __device__ __host__
int squareroot(
int x) {
return (
int)sqrtf((
float)x); }
71 static inline __device__ __host__
int pow(
int x,
int y) {
return (
int)powf((
float)x,(
float)y); }
75 struct ScalarTraits<long int>
85 static inline __device__ __host__
magnitudeType magnitude(
long int a) {
return (
long int)fabsf((
float)a); }
86 static inline __device__ __host__
long int zero() {
return 0; }
87 static inline __device__ __host__
long int one() {
return 1; }
88 static inline __device__ __host__
long int conjugate(
long int x) {
return x; }
89 static inline __device__ __host__
long int real(
long int x) {
return x; }
90 static inline __device__ __host__
long int imag(
long int) {
return 0; }
91 static inline __device__ __host__
bool isnaninf(
int) {
return false; }
92 static inline __device__ __host__
long int squareroot(
long int x) {
return (
long int)sqrtf((
float)x); }
93 static inline __device__ __host__
long int pow(
long int x,
long int y) {
return (
long int)powf((
float)x,(
float)y); }
96 #ifdef HAVE_KOKKOSCLASSIC_CUDA_FLOAT
98 struct ScalarTraits<float>
102 #ifdef HAVE_KOKKOSCLASSIC_CUDA_DOUBLE
112 static inline __device__ __host__
float zero() {
return(0.0f); }
113 static inline __device__ __host__
float one() {
return(1.0f); }
114 static inline __device__ __host__
float conjugate(
float x) {
return(x); }
115 static inline __device__ __host__
float real(
float x) {
return x; }
116 static inline __device__ __host__
float imag(
float) {
return zero(); }
117 static inline __device__ __host__
bool isnaninf(
float x) {
return isnan(x) || isinf(x); }
118 static inline __device__ __host__
float squareroot(
float x) {
return sqrtf(x); }
119 static inline __device__ __host__
float pow(
float x,
float y) {
return powf(x,y); }
121 #endif // HAVE_KOKKOSCLASSIC_CUDA_FLOAT
123 #ifdef HAVE_KOKKOSCLASSIC_CUDA_DOUBLE
125 struct ScalarTraits<double>
128 #ifdef HAVE_KOKKOSCLASSIC_CUDA_FLOAT
139 static inline __device__ __host__
double zero() {
return(0.0); }
140 static inline __device__ __host__
double one() {
return(1.0); }
141 static inline __device__ __host__
double conjugate(
double x) {
return(x); }
142 static inline __device__ __host__
double real(
double x) {
return x; }
143 static inline __device__ __host__
double imag(
double) {
return zero(); }
144 static inline __device__ __host__
bool isnaninf(
double x) {
return isnan(x) || isinf(x); }
145 static inline __device__ __host__
double squareroot(
double x) {
return sqrt(x); }
146 static inline __device__ __host__
double pow(
double x,
double y) {
return pow(x,y); }
148 #endif // HAVE_KOKKOSCLASSIC_CUDA_DOUBLE
152 #endif // _TEUCHOS_SCALARTRAITS_CUDA_HPP_
T magnitudeType
Mandatory typedef for result of magnitude.
static T squareroot(T x)
Returns a number of magnitudeType that is the square root of this scalar type x.
static const bool isComparable
Determines if scalar type supports relational operators such as <, >, <=, >=.
static magnitudeType real(T a)
Returns the real part of the scalar type a.
Declaration and default implementation for basic traits for the scalar field type.
static T pow(T x, T y)
Returns the result of raising one scalar x to the power y.
static const bool hasMachineParameters
Determines if scalar type have machine-specific parameters (i.e. eps(), sfmin(), base(), prec(), t(), rnd(), emin(), rmin(), emax(), rmax() are supported).
static T conjugate(T a)
Returns the conjugate of the scalar type a.
static const bool isOrdinal
Determines if scalar type is an ordinal type.
T doublePrecision
Typedef for double precision.
static magnitudeType imag(T a)
Returns the imaginary part of the scalar type a.
static bool isnaninf(const T &x)
Returns true if x is NaN or Inf.
static magnitudeType magnitude(T a)
Returns the magnitudeType of the scalar type a.
static T zero()
Returns representation of zero for this scalar type.
T halfPrecision
Typedef for half precision.
static const bool isComplex
Determines if scalar type is std::complex.
static T one()
Returns representation of one for this scalar type.