36 #include <cereal/access.hpp>
37 #include <cereal/types/polymorphic.hpp>
38 #include <cereal/types/string.hpp>
39 #endif // SERIALIZATION
49 string const & polynomial_name,
58 polynomial_name_(polynomial_name),
59 xmin_(xmin), xmax_(xmax), min_val_(min_val), max_val_(max_val), root1_(root1), root2_(root2),
61 coefficients_(coefficients)
67 utility::pointer::ReferenceCount( src ),
68 polynomial_name_(src.polynomial_name_),
69 xmin_(src.xmin_), xmax_(src.xmax_), root1_(src.root1_), root2_(src.root2_),
71 coefficients_(src.coefficients_)
82 std::stringstream msg;
83 msg <<
"Polnomial_1d is badly formed because (xmin: '" <<
xmin_ <<
"') > (xmax: '" <<
xmax_ <<
"')";
88 std::stringstream msg;
89 msg <<
"Polnomial_1d is badly formed because no coefficients were provided";
94 std::stringstream msg;
95 msg <<
"Polnomial_1d is badly formed because the degree was given to be '" <<
degree_ <<
"' while '" <<
coefficients_.size() <<
"' coefficients were provided, while they should be equal.";
190 double const variable,
192 double & deriv)
const
194 if ( variable <=
xmin_ ) {
199 if ( variable >=
xmax_ ) {
208 (deriv *= variable) += value;
216 if ( variable <=
xmin_ ) {
219 if ( variable >=
xmax_ ) {
239 <<
"domain:(" <<
xmin_ <<
"," <<
xmax_ <<
") "
255 if ( degree_-i >1 ) {
256 out <<
"x^" << degree_-i;
257 }
else if ( degree_-i == 1 ) {
271 template<
class Archive >
273 numeric::Polynomial_1d::save( Archive & arc )
const {
274 arc( CEREAL_NVP( polynomial_name_ ) );
275 arc( CEREAL_NVP( xmin_ ) );
276 arc( CEREAL_NVP( xmax_ ) );
277 arc( CEREAL_NVP( min_val_ ) );
278 arc( CEREAL_NVP( max_val_ ) );
279 arc( CEREAL_NVP( root1_ ) );
280 arc( CEREAL_NVP( root2_ ) );
281 arc( CEREAL_NVP( degree_ ) );
282 arc( CEREAL_NVP( coefficients_ ) );
286 template<
class Archive >
289 arc( polynomial_name_ );
297 arc( coefficients_ );
303 CEREAL_REGISTER_DYNAMIC_INIT( numeric_polynomial )
304 #endif // SERIALIZATION
Polynomial_1d(std::string const &polynomial_name, Real const xmin, Real const xmax, Real const min_val, Real const max_val, Real const root1, Real const root2, Size degree, utility::vector1< Real > const &coefficients)
ctor
common derived classes for thrown exceptions
std::string polynomial_name_
Commons serlialization routines.
double eval(double const variable)
just evaluate the polynomial, w/o derivatives
T abs(T const &x)
std::abs( x ) == | x |
std::vector with 1-based indexing
rosetta project type declarations. Should be kept updated with core/types.hh. This exists because num...
utility::vector1< Real > const & coefficients() const
Polynomial evaluation class.
void operator()(double const variable, double &value, double &deriv) const
Evaluate the polynomial and its derivative.
utility::vector1< Real > coefficients_
vector1: std::vector with 1-based indexing
struct numeric::kinematic_closure::p poly
std::ostream & operator<<(std::ostream &stream, BodyPosition< T > const &p)
stream << BodyPosition output operator
Serlialization routines for vector1s.
void check_invariants() const
void show(std::ostream &out) const