18template <
typename T>
struct Linear2;
109 constexpr T PI_T =
static_cast<T
>(M_PI);
110 const T theta_div = std::floor((coordSph.
Y() + .5f * PI_T) / PI_T);
111 const bool theta_flip =
static_cast<bool>(std::abs(
static_cast<long>(theta_div)) % 2);
112 const T phi_div = std::floor((coordSph.
Z() + .5f * PI_T) / PI_T);
113 const bool phi_flip =
static_cast<bool>(std::abs(
static_cast<long>(phi_div)) % 2);
115 T r_ret = coordSph.
X();
116 T theta_ret = coordSph.
Y() - PI_T * theta_div;
117 T phi_ret = coordSph.
Z() - PI_T * phi_div;
119 if (phi_flip && !theta_flip) theta_ret *= -1;
120 if (phi_flip != theta_flip) r_ret *= -1;
122 return {r_ret, theta_ret, phi_ret};
128__host__ cudaError_t CudaMemcpyToObjectSymbol(
const T &symbol, T &src, cudaMemcpyKind kind = cudaMemcpyHostToDevice) {
129 return cudaMemcpyToSymbol(symbol, &src,
sizeof(T), 0, kind);
#define __host__
Definition Global.h:17
#define __device__
Definition Global.h:22
A simple vector class derived from std::array<T, N>, providing overrides for all useful operators.
Definition Vec.h:21
__host__ __device__ constexpr const T & X() const
Get a constant reference to the first element.
Definition Vec.h:417
__host__ __device__ constexpr const T & Z() const
Get a constant reference to the third element.
Definition Vec.h:443
__host__ __device__ constexpr const T & Y() const
Get a constant reference to the second element.
Definition Vec.h:427
__host__ __device__ Vec< T, 3 > UnflipSphericalCoordinate(const Vec< T, 3 > &coordSph)
'Unflips' the given spherical coordinates so that theta and phi both lie between -pi/2 and pi/2
Definition Common.h:108
__host__ __device__ Linear2< T > operator()(const Linear2< T > &other) const
Definition Common.h:96
Definition GridSample3DCPU.cpp:6
A functor class that represents a linear transformation of two variables: intercept + gradient1 * x +...
Definition Common.h:59
__host__ __device__ Linear2 operator()(const Linear< T > &other) const
Definition Common.h:78
__host__ __device__ T operator()(const T &x, const T &y) const
Definition Common.h:69
__host__ __device__ Linear2 operator()(const Linear2 &other) const
Definition Common.h:88
T intercept
Definition Common.h:60
T gradient2
Definition Common.h:62
T gradient1
Definition Common.h:61
A functor class that represents a linear transformation: intercept + gradient * x.
Definition Common.h:27
T gradient
Definition Common.h:29
__host__ __device__ Linear operator()(const Linear &other) const
Definition Common.h:42
__host__ __device__ T operator()(const T &x) const
Definition Common.h:35
T intercept
Definition Common.h:28