25 #ifndef LSST_AFW_MATH_FUNCTION_H 26 #define LSST_AFW_MATH_FUNCTION_H 34 #include "boost/format.hpp" 35 #include "boost/serialization/nvp.hpp" 36 #include "boost/serialization/vector.hpp" 37 #include "boost/serialization/void_cast.hpp" 38 #include "boost/serialization/export.hpp" 49 using boost::serialization::make_nvp;
80 template <
typename ReturnT>
159 (boost::format(
"params has %d entries instead of %d") % params.
size() %
_params.
size())
173 os <<
"parameters: [ ";
192 friend class boost::serialization::access;
193 template <
class Archive>
194 void serialize(Archive& ar,
unsigned int const version) {
195 ar& make_nvp(
"params", _params);
206 template <
typename ReturnT>
238 virtual ReturnT operator()(
double x)
const = 0;
251 friend class boost::serialization::access;
252 template <
class Archive>
253 void serialize(Archive& ar,
unsigned const int version) {
265 template <
typename ReturnT>
299 virtual ReturnT operator()(
double x,
double y)
const = 0;
309 "getDFuncDParameters is not implemented for this class");
317 friend class boost::serialization::access;
318 template <
class Archive>
319 void serialize(Archive& ar,
unsigned const int version) {
334 template <
typename ReturnT>
377 os <<
"order=" << order <<
" invalid: must be >= 0";
380 return (order + 1) * (order + 2) / 2;
398 int order =
static_cast<int>(
399 0.5 + ((-3.0 + (
std::sqrt(1.0 + (8.0 * static_cast<double>(nParameters))))) / 2.0));
402 os <<
"nParameters=" << nParameters <<
" invalid: order is not an integer";
422 for (
unsigned int i = 0; i < numParams; ++i) {
423 dummy->setParameter(i, 0.0);
426 for (
unsigned int i = 0; i < numParams; ++i) {
427 dummy->setParameter(i, 1.0);
428 deriv[i] = (*dummy)(
x, y);
429 dummy->setParameter(i, 0.0);
442 friend class boost::serialization::access;
443 template <
class Archive>
444 void serialize(Archive& ar,
unsigned const int version) {
446 ar& make_nvp(
"order", _order);
453 template <
typename ReturnT>
462 ReturnT operator()(
double)
const {
return static_cast<ReturnT
>(0); }
465 friend class boost::serialization::access;
466 template <
class Archive>
467 void serialize(Archive& ar,
unsigned int const version) {
475 template <
typename ReturnT>
484 ReturnT operator()(
double,
double)
const {
return static_cast<ReturnT
>(0); }
487 friend class boost::serialization::access;
488 template <
class Archive>
489 void serialize(Archive& ar,
unsigned int const version) {
497 #endif // #ifndef LSST_AFW_MATH_FUNCTION_H
int _order
order of polynomial
virtual bool isLinearCombination() const
Is the function a linear combination of its parameters?
virtual bool isLinearCombination() const
Is the function a linear combination of its parameters?
std::shared_ptr< Function2< ReturnT > > clone() const
Return a pointer to a deep copy of this function.
Function2(unsigned int nParams)
Construct a Function2 given the number of function parameters.
std::shared_ptr< Function1< ReturnT > > clone() const
Return a pointer to a deep copy of this function.
BasePolynomialFunction2(std::vector< double > params)
Construct a polynomial function with specified parameters.
Function1(unsigned int nParams)
Construct a Function1 given the number of function parameters.
A Function taking two arguments.
Base class for 2-dimensional polynomials of the form:
A base class for objects that can be persisted via afw::table::io Archive classes.
BasePolynomialFunction2(unsigned int order)
Construct a polynomial function of specified order.
static int nParametersFromOrder(int order)
Compute number of parameters from polynomial order.
a class used in function calls to indicate that no Function2 is being provided
std::vector< double > _params
A base class for image defects.
virtual double getParameter(unsigned int ind) const
Get one function parameter without range checking.
std::vector< double > const & getParameters() const
Return all function parameters.
virtual std::vector< double > getDFuncDParameters(double, double) const
Return the derivative of the Function with respect to its parameters.
Function(unsigned int nParams)
Construct a Function given the number of function parameters.
A Function taking one argument.
a class used in function calls to indicate that no Function1 is being provided
virtual std::string getPythonModule() const
Return the fully-qualified Python module that should be imported to guarantee that its factory is reg...
Function(std::vector< double > const ¶ms)
Construct a Function given the function parameters.
#define LSST_EXCEPT(type,...)
Function2(std::vector< double > const ¶ms)
Construct a Function2 given the function parameters.
virtual ~BasePolynomialFunction2()
virtual std::vector< double > getDFuncDParameters(double x, double y) const
Return the derivative of the Function with respect to its parameters.
void setParameters(std::vector< double > const ¶ms)
Set all function parameters.
Citizen(const std::type_info &)
virtual std::string toString(std::string const &prefix="") const
Return a string representation of the function.
int getOrder() const
Get the polynomial order.
void setParameter(unsigned int ind, double newValue)
Set one function parameter without range checking.
Function1(std::vector< double > const ¶ms)
Construct a Function1 given the function parameters.
virtual void computeCache(int const n)
virtual std::string toString(std::string const &) const
Return a string representation of the function.
A CRTP facade class for subclasses of Persistable.
static int orderFromNParameters(int nParameters)
Compute polynomial order from the number of parameters.
unsigned int getNParameters() const
Return the number of function parameters.
BasePolynomialFunction2()
virtual std::string toString(std::string const &prefix="") const
Return a string representation of the function.