27 #ifndef MPBLOCKS_CUDA_POLYNOMIAL_STURMSEQUENCE_H_
28 #define MPBLOCKS_CUDA_POLYNOMIAL_STURMSEQUENCE_H_
38 namespace polynomial {
40 template <
typename Scalar,
int max>
43 namespace sturm_detail
51 return (T(0) < val) - (val < T(0));
56 template <
typename Scalar,
int size>
63 template <
typename Scalar>
67 template <
class Scalar,
int i,
int max>
70 template <
class Scalar,
int i,
int max>
73 template <
class Scalar,
int max>
77 template <
class Scalar,
int max>
87 template <
int i,
typename Scalar,
int max >
97 template <
typename Scalar,
int max>
106 template <
class Exp,
class Spec >
113 template <
class Exp,
class Spec>
119 Poly1 p1 = d_ds<1>( rhs );
140 Scalar y0 =
polyval( get<0>(*
this),s );
146 template <
int i,
typename Scalar,
int max >
148 Polynomial<Scalar,
typename intlist::range<0,max-i>::result>&
155 namespace sturm_detail
158 template <
class Scalar,
int i,
int size>
166 typedef typename intlist::range<0,
max-(i-1)>::result Spec2;
171 Quotient_t q( get<i-2>(sturm) / get<i-1>(sturm) );
172 get<i>(sturm) = -q.r;
187 template <
class Scalar,
int size>
200 Quotient_t q( get<max-2>(sturm) / get<max-1>(sturm) );
201 get<max>(sturm) = -q.r;
213 template <
class Scalar,
int i,
int size>
214 struct SignChangeHelper
220 Scalar next =
polyval( get<i>(sturm), s );
223 return (
sgn(next) ==
sgn(prev) ? 0 : 1 )
231 template <
class Scalar,
int size>
242 template <
class Scalar,
int max>
249 template <
class Scalar,
int max>
286 #endif // STURMSEQUENCE_H_
A sparse, statically sized polynomial.
__host__ __device__ static __forceinline__ int count(SturmSequence< Scalar, size-1 > &sturm, Scalar s, Scalar prev)
Polynomial< Scalar, typename intlist::range< 0, size >::result > poly
__host__ __device__ __forceinline__ SturmSequence()
__host__ __device__ __forceinline__ void rebuild(SturmSequence< Scalar, max > &sturm)
__host__ __device__ __forceinline__ int signChanges(SturmSequence< Scalar, max > &sturm, Scalar s, Scalar prev)
expression template for polynomial long division
expression template for rvalues
__host__ __device__ static __forceinline__ int count(SturmSequence< Scalar, max > &sturm, Scalar s, Scalar prev)
stores a squence of polynomials which satisfy the properties of sturms theorem and provides methods f...
__host__ __device__ static __forceinline__ void rebuild(SturmSequence< Scalar, max > &sturm)
__host__ __device__ __forceinline__ void rebuild(const RValue< Scalar, Exp, Spec > &rhs)
__host__ __device__ static __forceinline__ void rebuild(SturmSequence< Scalar, size-1 > &sturm)
Storage class, stores one polynomial in teh sequence.
__host__ __device__ __forceinline__ int signChanges(Scalar s)
return the number of sign changes at the specified point
__host__ __device__ __forceinline__ int sgn(T val)
signum
__host__ __device__ Normalized< Scalar, Exp, Spec > normalized(const RValue< Scalar, Exp, Spec > &exp)
__host__ __device__ Scalar polyval(const RValue< Scalar, Exp, Spec > &exp, Scalar2 x)
evaluate a polynomial
creates an integer list from i to j (including both i and j)
__host__ __device__ __forceinline__ SturmSequence(const RValue< Scalar, Exp, Spec > &rhs)
builds a sturm sequence from a polynomial