25 #ifndef LSST_AFW_MATH_FUNCTION_H
26 #define LSST_AFW_MATH_FUNCTION_H
35 #include "boost/format.hpp"
82 template <
typename ReturnT>
175 os <<
"parameters: [ ";
201 template <
typename ReturnT>
238 virtual ReturnT operator()(
double x) const = 0;
258 template <
typename ReturnT>
297 virtual ReturnT operator()(
double x,
double y) const = 0;
307 "getDFuncDParameters is not implemented for this class");
325 template <
typename ReturnT>
372 os <<
"order=" <<
order <<
" invalid: must be >= 0";
393 int order =
static_cast<int>(
394 0.5 + ((-3.0 + (
std::sqrt(1.0 + (8.0 *
static_cast<double>(nParameters))))) / 2.0));
397 os <<
"nParameters=" << nParameters <<
" invalid: order is not an integer";
417 for (
unsigned int i = 0; i < numParams; ++i) {
418 dummy->setParameter(i, 0.0);
421 for (
unsigned int i = 0; i < numParams; ++i) {
422 dummy->setParameter(i, 1.0);
423 deriv[i] = (*dummy)(
x,
y);
424 dummy->setParameter(i, 0.0);
440 template <
typename ReturnT>
449 ReturnT operator()(
double)
const noexcept(IS_NOTHROW_INIT<ReturnT>)
override {
450 return static_cast<ReturnT
>(0);
457 template <
typename ReturnT>
466 ReturnT operator()(
double,
double)
const noexcept(IS_NOTHROW_INIT<ReturnT>)
override {
467 return static_cast<ReturnT
>(0);
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Base class for 2-dimensional polynomials of the form:
int _order
order of polynomial
static int nParametersFromOrder(int order)
Compute number of parameters from polynomial order.
bool isLinearCombination() const noexcept override
Is the function a linear combination of its parameters?
BasePolynomialFunction2(BasePolynomialFunction2 &&)=default
BasePolynomialFunction2(unsigned int order)
Construct a polynomial function of specified order.
std::vector< double > getDFuncDParameters(double x, double y) const override
Return the derivative of the Function with respect to its parameters.
int getOrder() const noexcept
Get the polynomial order.
BasePolynomialFunction2(BasePolynomialFunction2 const &)=default
BasePolynomialFunction2(std::vector< double > params)
Construct a polynomial function with specified parameters.
BasePolynomialFunction2()
static int orderFromNParameters(int nParameters)
Compute polynomial order from the number of parameters.
~BasePolynomialFunction2() noexcept override=default
BasePolynomialFunction2 & operator=(BasePolynomialFunction2 &&)=default
BasePolynomialFunction2 & operator=(BasePolynomialFunction2 const &)=default
A Function taking one argument.
~Function1() noexcept override=default
Function1(Function1 const &)=default
Function1(std::vector< double > const ¶ms)
Construct a Function1 given the function parameters.
Function1 & operator=(Function1 &&)=default
std::string toString(std::string const &prefix="") const override
Return a string representation of the function.
Function1(unsigned int nParams)
Construct a Function1 given the number of function parameters.
virtual void computeCache(int const n)
virtual std::shared_ptr< Function1< ReturnT > > clone() const =0
Return a pointer to a deep copy of this function.
Function1(Function1 &&)=default
Function1 & operator=(Function1 const &)=default
A Function taking two arguments.
virtual std::shared_ptr< Function2< ReturnT > > clone() const =0
Return a pointer to a deep copy of this function.
Function2(unsigned int nParams)
Construct a Function2 given the number of function parameters.
~Function2() noexcept override=default
Function2(Function2 const &)=default
Function2 & operator=(Function2 const &)=default
virtual std::vector< double > getDFuncDParameters(double, double) const
Return the derivative of the Function with respect to its parameters.
std::string toString(std::string const &prefix="") const override
Return a string representation of the function.
Function2(Function2 &&)=default
Function2 & operator=(Function2 &&)=default
Function2(std::vector< double > const ¶ms)
Construct a Function2 given the function parameters.
std::vector< double > const & getParameters() const noexcept
Return all function parameters.
virtual std::string toString(std::string const &) const
Return a string representation of the function.
void setParameter(unsigned int ind, double newValue)
Set one function parameter without range checking.
Function(Function &&)=default
std::vector< double > _params
std::string getPythonModule() const override
Return the fully-qualified Python module that should be imported to guarantee that its factory is reg...
virtual bool isLinearCombination() const noexcept
Is the function a linear combination of its parameters?
Function(Function const &)=default
void setParameters(std::vector< double > const ¶ms)
Set all function parameters.
Function & operator=(Function &&)=default
Function & operator=(Function const &)=default
~Function() noexcept override=default
virtual double getParameter(unsigned int ind) const
Get one function parameter without range checking.
Function(unsigned int nParams)
Construct a Function given the number of function parameters.
unsigned int getNParameters() const noexcept
Return the number of function parameters.
Function(std::vector< double > const ¶ms)
Construct a Function given the function parameters.
a class used in function calls to indicate that no Function1 is being provided
std::shared_ptr< Function1< ReturnT > > clone() const override
Return a pointer to a deep copy of this function.
a class used in function calls to indicate that no Function2 is being provided
std::shared_ptr< Function2< ReturnT > > clone() const override
Return a pointer to a deep copy of this function.
A CRTP facade class for subclasses of Persistable.
A base class for objects that can be persisted via afw::table::io Archive classes.
Reports invalid arguments.
Reports attempts to access elements using an invalid key.
constexpr bool IS_NOTHROW_INIT
Test that a Function's return value is nothrow-castable to T.
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
A base class for image defects.