25 #ifndef LSST_AFW_MATH_FUNCTION_H 26 #define LSST_AFW_MATH_FUNCTION_H 35 #include "boost/format.hpp" 83 template <
typename ReturnT>
177 os <<
"parameters: [ ";
203 template <
typename ReturnT>
225 ~
Function1() noexcept
override =
default;
240 virtual ReturnT operator()(
double x)
const = 0;
260 template <
typename ReturnT>
284 ~
Function2() noexcept
override =
default;
299 virtual ReturnT operator()(
double x,
double y)
const = 0;
309 "getDFuncDParameters is not implemented for this class");
327 template <
typename ReturnT>
374 os <<
"order=" << order <<
" invalid: must be >= 0";
377 return (order + 1) * (order + 2) / 2;
395 int order =
static_cast<int>(
396 0.5 + ((-3.0 + (
std::sqrt(1.0 + (8.0 * static_cast<double>(nParameters))))) / 2.0));
399 os <<
"nParameters=" << nParameters <<
" invalid: order is not an integer";
419 for (
unsigned int i = 0; i < numParams; ++i) {
420 dummy->setParameter(i, 0.0);
423 for (
unsigned int i = 0; i < numParams; ++i) {
424 dummy->setParameter(i, 1.0);
425 deriv[i] = (*dummy)(
x,
y);
426 dummy->setParameter(i, 0.0);
442 template <
typename ReturnT>
451 ReturnT operator()(
double)
const noexcept(IS_NOTHROW_INIT<ReturnT>)
override {
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);
474 #endif // #ifndef LSST_AFW_MATH_FUNCTION_H
unsigned int getNParameters() const noexcept
Return the number of function parameters.
std::vector< double > getDFuncDParameters(double x, double y) const override
Return the derivative of the Function with respect to its parameters.
int _order
order of polynomial
bool isLinearCombination() const noexcept override
Is the function a linear combination of its parameters?
bool constexpr IS_NOTHROW_INIT
Test that a Function's return value is nothrow-castable to T.
std::shared_ptr< Function1< ReturnT > > clone() const override
Return a pointer to a deep copy of this function.
~Function() noexcept override=default
Function2(unsigned int nParams)
Construct a Function2 given the number of function parameters.
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
Reports attempts to access elements using an invalid key.
std::vector< double > _params
std::string toString(std::string const &prefix="") const override
Return a string representation of the function.
A base class for image defects.
virtual double getParameter(unsigned int ind) const
Get one function parameter without range checking.
virtual std::vector< double > getDFuncDParameters(double, double) const
Return the derivative of the Function with respect to its parameters.
std::vector< double > const & getParameters() const noexcept
Return all function parameters.
Function(unsigned int nParams)
Construct a Function given the number of function parameters.
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
virtual bool isLinearCombination() const noexcept
Is the function a linear combination of its parameters?
A Function taking one argument.
Function & operator=(Function const &)=default
std::string getPythonModule() const override
Return the fully-qualified Python module that should be imported to guarantee that its factory is reg...
a class used in function calls to indicate that no Function1 is being provided
Function(std::vector< double > const ¶ms)
Construct a Function given the function parameters.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Function2(std::vector< double > const ¶ms)
Construct a Function2 given the function parameters.
void setParameters(std::vector< double > const ¶ms)
Set all function parameters.
Citizen(const std::type_info &)
void setParameter(unsigned int ind, double newValue)
Set one function parameter without range checking.
std::string toString(std::string const &prefix="") const override
Return a string representation of the function.
Reports invalid arguments.
Function1(std::vector< double > const ¶ms)
Construct a Function1 given the function parameters.
int getOrder() const noexcept
Get the polynomial order.
virtual void computeCache(int const n)
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
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.
std::shared_ptr< Function2< ReturnT > > clone() const override
Return a pointer to a deep copy of this function.
BasePolynomialFunction2()