27 #ifndef MPBLOCKS_CUDA_POLYNOMIAL_DIVIDE_H_
28 #define MPBLOCKS_CUDA_POLYNOMIAL_DIVIDE_H_
32 namespace polynomial {
34 template<
class NumSpec,
class DenSpec >
47 template <
class NumSpec,
class DenSpec >
59 template <
class NumSpec,
class DenSpec >
74 template<
bool Enabled,
int i,
typename Scalar,
75 class NumExp,
class NumSpec,
76 class DenExp,
class DenSpec >
80 static void step(
const NumExp& n,
const DenExp& d,
86 template<
int i,
typename Scalar,
87 class NumExp,
class NumSpec,
88 class DenExp,
class DenSpec >
89 struct Divide< true, i, Scalar, NumExp, NumSpec, DenExp, DenSpec>
95 max_coeff_Q = max_coeff_N - max_coeff_D,
96 max_coeff_R = max_coeff_D - 1,
97 coeff_N = max_coeff_N - i,
98 coeff_Q = max_coeff_Q - i,
102 static void step(
const NumExp& n,
const DenExp& d,
106 set<coeff_Q>(q) = get<coeff_N>(r) / get<max_coeff_D>(d);
112 template<
typename Scalar,
113 class NumExp,
class NumSpec,
114 class DenExp,
class DenSpec >
115 struct Divide< true, 0, Scalar, NumExp,NumSpec,DenExp,DenSpec >
122 max_coeff_Q = max_coeff_N - max_coeff_D,
123 max_coeff_R = max_coeff_D - 1,
124 coeff_N = max_coeff_N - i,
125 coeff_Q = max_coeff_Q - i,
129 static void step(
const NumExp& n,
const DenExp& d,
133 set<coeff_Q>(q) = get<coeff_N>(n) / get<max_coeff_D>(d);
141 template<
typename Scalar,
142 class NumExp,
class NumSpec,
143 class DenExp,
class DenSpec >
145 void divide(
const NumExp& n,
const DenExp& d,
153 max_coeff_Q = max_coeff_N - max_coeff_D,
154 max_coeff_R = max_coeff_D - 1,
155 end_step = max_coeff_Q + 1
173 template<
typename Scalar,
class NumSpec,
class DenSpec >
184 max_coeff_Q = max_coeff_N - max_coeff_D,
185 max_coeff_R = max_coeff_D - 1,
186 end_step = max_coeff_Q + 1
A sparse, statically sized polynomial.
intlist::range< 0, max_coeff_Q >::result result
__host__ __device__ static __forceinline__ void step(const NumExp &n, const DenExp &d, Polynomial< Scalar, typename QuotientSpec< NumSpec, DenSpec >::result > &q, Polynomial< Scalar, typename ScratchSpec< NumSpec, DenSpec >::result > &r)
intlist::range< 0, max_coeff_R >::result result
__host__ __device__ __forceinline__ void mod(const Polynomial< Scalar, NumSpec > &n, const Polynomial< Scalar, DenSpec > &d, Polynomial< Scalar, typename RemainderSpec< NumSpec, DenSpec >::result > &r)
specialization for the first step uses actual numerator, not remainder
__host__ __device__ static __forceinline__ void step(const NumExp &n, const DenExp &d, Polynomial< Scalar, typename QuotientSpec< NumSpec, DenSpec >::result > &q, Polynomial< Scalar, typename ScratchSpec< NumSpec, DenSpec >::result > &r)
intlist::range< 0, max_coeff_S >::result result
__host__ __device__ __forceinline__ void divide(const NumExp &n, const DenExp &d, Polynomial< Scalar, typename QuotientSpec< NumSpec, DenSpec >::result > &q, Polynomial< Scalar, typename RemainderSpec< NumSpec, DenSpec >::result > &r)
retrieve the max element of the list (linear without short circut so it works with non-sorted arrays ...
__host__ __device__ static __forceinline__ void step(const NumExp &n, const DenExp &d, Polynomial< Scalar, typename QuotientSpec< NumSpec, DenSpec >::result > &q, Polynomial< Scalar, typename ScratchSpec< NumSpec, DenSpec >::result > &r)