27 #ifndef MPBLOCKS_CUDA_POLYNOMIAL_POLYNOMIAL_H_
28 #define MPBLOCKS_CUDA_POLYNOMIAL_POLYNOMIAL_H_
41 namespace polynomial {
47 template <
typename Scalar,
int Idx>
55 template <
typename Scalar,
class IntList>
58 template <
typename Scalar,
int SpecHead,
class SpecTail>
78 void assign(
const Scalar& v0,
const Scalar& v1 )
85 void assign(
const Scalar& v0,
const Scalar& v1,
const Scalar& v2 )
92 void assign(
const Scalar& v0,
const Scalar& v1,
const Scalar& v2,
const Scalar& v3 )
99 void assign(
const Scalar& v0,
const Scalar& v1,
const Scalar& v2,
const Scalar& v3,
const Scalar& v4 )
106 void assign(
const Scalar& v0,
const Scalar& v1,
const Scalar& v2,
const Scalar& v3,
const Scalar& v4,
const Scalar& v5 )
113 template <
class Exp,
class Spec2 >
123 get<SpecHead>(
static_cast<const Exp&
>(exp) );
128 template <
typename T>
139 Scalar
eval(
const Scalar&
s, Scalar sn = Scalar(1.0) )
142 return eval<idx+1>(
s, sn*
s );
172 template <
typename Scalar,
int SpecTail>
186 template <
class Exp,
class Spec2 >
192 static_cast<const Exp&
>(exp) );
196 template <
typename T>
205 Scalar
eval(
const Scalar&
s, Scalar sn = Scalar(1.0) )
208 return eval<idx+1>(
s, sn*
s );
232 namespace coefficient_key
246 namespace device_coefficient_key
265 template <
typename Scalar,
class Spec>
268 RValue< Scalar, Polynomial<Scalar,Spec>, Spec >,
269 LValue< Scalar, Polynomial<Scalar,Spec> >
276 template <
typename Exp,
class Spec2>
285 template <
typename Exp,
class Spec2>
294 template <
int n,
class Exp2,
class Spec2>
298 differentiate<n>( surrogate.
exp, *this );
301 template <
int n,
class Exp2,
class Spec2>
317 Polynomial(
const Scalar& v0,
const Scalar& v1,
const Scalar& v2 )
321 Polynomial(
const Scalar& v0,
const Scalar& v1,
const Scalar& v2,
const Scalar& v3 )
325 Polynomial(
const Scalar& v0,
const Scalar& v1,
const Scalar& v2,
const Scalar& v3,
const Scalar& v4 )
329 Polynomial(
const Scalar& v0,
const Scalar& v1,
const Scalar& v2,
const Scalar& v3,
const Scalar& v4,
const Scalar& v5 )
344 template<
bool HasCoefficient,
int idx,
typename Scalar,
class Spec >
354 template<
int idx,
typename Scalar,
class Spec >
360 return poly.Coefficient<Scalar,idx>::value;
368 template <
int idx,
typename Scalar,
class Spec>
376 template <
int idx,
typename Scalar,
class Spec>
383 template <
int idx,
typename Scalar,
class Spec>
394 template<
class Scalar,
class Spec >
408 #endif // POLYNOMIAL_H_
A sparse, statically sized polynomial.
__host__ __device__ __forceinline__ Polynomial(const Scalar &v0, const Scalar &v1)
__host__ __device__ __forceinline__ void fill(T value)
__host__ __device__ __forceinline__ Scalar eval(const Scalar &s, Scalar sn=Scalar(1.0))
evaluate the polynomial
const CoefficientKey< 4 > _4
__host__ __device__ __forceinline__ void assign(const Scalar &v0)
const CoefficientKey< 7 > _7
__device__ const CoefficientKey< 5 > _5
const CoefficientKey< 1 > _1
__host__ __device__ __forceinline__ void assign(const Scalar &v0, const Scalar &v1, const Scalar &v2, const Scalar &v3, const Scalar &v4, const Scalar &v5)
__device__ const CoefficientKey< 8 > _8
__host__ __device__ __forceinline__ void assign(const Scalar &v0, const Scalar &v1, const Scalar &v2, const Scalar &v3, const Scalar &v4)
__host__ __device__ __forceinline__ Polynomial(const Scalar &v0, const Scalar &v1, const Scalar &v2)
__host__ __device__ __forceinline__ void operator=(const DerivativeSurrogate< n, Scalar, Exp2, Spec2 > &surrogate)
__device__ const CoefficientKey< 4 > _4
__host__ __device__ void differentiate(const RValue< Scalar, Exp1, InSpec > &in, LValue< Scalar, Exp2 > &out)
evaluate a polynomial
__host__ __device__ __forceinline__ void assign(const Scalar &v0, const Scalar &v1, const Scalar &v2)
__host__ __device__ Scalar & set(Exp1 &)
const CoefficientKey< 3 > _3
__host__ __device__ __forceinline__ Polynomial()
Default constructor.
__host__ __device__ __forceinline__ void operator=(const RValue< Scalar, Exp, Spec2 > &exp)
__host__ __device__ __forceinline__ void assign(const Scalar &v0, const Scalar &v1)
__host__ __device__ __forceinline__ Polynomial(const RValue< Scalar, Exp, Spec2 > &exp)
Construct from any PolynomialExpression:
expression template for rvalues
__host__ __device__ __forceinline__ void assign(const RValue< Scalar, Exp, Spec2 > &exp)
assignment by rvalue
__host__ __device__ __forceinline__ Polynomial(const Scalar &v0, const Scalar &v1, const Scalar &v2, const Scalar &v3)
__host__ __device__ __forceinline__ Polynomial(const DerivativeSurrogate< n, Scalar, Exp2, Spec2 > &surrogate)
__host__ __device__ __forceinline__ Scalar eval(const Scalar &s, Scalar sn=Scalar(1.0))
expression template for lvalues
__host__ void dyn_set(int i, const Scalar &value)
__device__ const CoefficientKey< 1 > _1
const CoefficientKey< 5 > _5
__device__ const CoefficientKey< 9 > _9
const CoefficientKey< 8 > _8
__device__ const CoefficientKey< 7 > _7
__host__ __device__ __forceinline__ void assign(const Scalar &v0, const Scalar &v1, const Scalar &v2, const Scalar &v3)
__host__ __device__ __forceinline__ void assign(const Scalar &v0)
variadic initializer, recursively sets all coefficients with a function call
const CoefficientKey< 9 > _9
__host__ __device__ __forceinline__ Polynomial(const Scalar &v0, const Scalar &v1, const Scalar &v2, const Scalar &v3, const Scalar &v4)
const CoefficientKey< 2 > _2
__device__ const CoefficientKey< 0 > _0
__device__ const CoefficientKey< 6 > _6
__host__ __device__ __forceinline__ void assign(const RValue< Scalar, Exp, Spec2 > &exp)
assignment by rvalue
intermediate object which allows LValue assignment operator to call differntiate expression template ...
__device__ const CoefficientKey< 2 > _2
__host__ __device__ __forceinline__ Polynomial(const Scalar &v0)
class actually providing storage for a coefficient
__host__ Scalar dyn_get(int i)
__host__ __device__ __forceinline__ Polynomial(const Scalar &v0, const Scalar &v1, const Scalar &v2, const Scalar &v3, const Scalar &v4, const Scalar &v5)
__host__ __device__ __forceinline__ Scalar dyn_get(int i)
runtime indexing of coefficients, i is the array offset (i.e. the i'th nonzero coefficient, not the coefficient of the i'th power of the polynomial parameter )
__device__ const CoefficientKey< 3 > _3
__host__ __device__ Scalar get(const Derivative< Scalar, Exp, Spec > &exp)
__host__ __device__ __forceinline__ Scalar eval(Scalar x)
evaluate the polynomial at a particular value
__host__ __device__ __forceinline__ void dyn_set(int i, const Scalar &value)
runtime indexing of coefficients, i is the array offset (i.e. the i'th nonzero coefficient, not the coefficient of the i'th power of the polynomial parameter )
__host__ __device__ __forceinline__ Scalar & set_storage(Polynomial< Scalar, Spec > &poly)
__host__ __device__ __forceinline__ void fill(T value)
assignment of all coefficients
compile time integer list (because cuda doesn't understand variadic templates )
const CoefficientKey< 0 > _0
recursive inheritance tree which provides storage for each of the required coefficients ...
__host__ __device__ __forceinline__ void assign(Polynomial< Scalar, Spec > &p, const Exp &exp)
const CoefficientKey< 6 > _6