29 #ifndef SCIMATH_GENERICL2FIT_H
30 #define SCIMATH_GENERICL2FIT_H
46 template <
class T>
class Array;
47 template <
class T,
class U>
class Function;
214 template<
class T>
class GenericL2Fit :
public LSQaips {
259 ptr_derive_p->nparameters() !=
function.nparameters() ||
260 function.ndim() != x.nelements())
return False;
572 #ifndef CASACORE_NO_AUTO_TEMPLATES
573 #include <casacore/scimath/Fitting/GenericL2Fit.tcc>
574 #endif //# CASACORE_NO_AUTO_TEMPLATES
void setMaskedParameterValues(const Vector< typename FunctionTraits< T >::BaseType > &parms)
GenericL2Fit & operator=(const GenericL2Fit &other)
Assignment (deep copy)
FunctionTraits< T >::DiffType valder_p
Local value and derivatives.
A 1-D Specialization of the Array class.
void buildNormalMatrix(const Vector< typename FunctionTraits< T >::BaseType > &x, const Vector< typename FunctionTraits< T >::BaseType > &y, const Vector< typename FunctionTraits< T >::BaseType > &sigma, const Vector< Bool > *const mask=0)
Generate the normal equations by one or more calls to the buildNormalMatrix(), before calling a fit()...
void fillSVDConstraints()
Get the SVD constraints.
Vector< typename FunctionTraits< T >::BaseType > err_p
Local error area.
void setParameterValues(const Vector< typename FunctionTraits< T >::BaseType > &parms)
Set the parameter values.
virtual ~GenericL2Fit()
Destructor.
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
GenericL2Fit()
Create a fitter: the normal way to generate a fitter object.
Vector< typename FunctionTraits< T >::BaseType > fit(const Vector< typename FunctionTraits< T >::BaseType > &x, const Vector< typename FunctionTraits< T >::BaseType > &y, const Vector< typename FunctionTraits< T >::BaseType > &sigma, const Vector< Bool > *const mask=0)
Fit the function to the data.
uInt aCount_ai
Adjustable.
Bool residual(Vector< typename FunctionTraits< T >::BaseType > &y, const Array< typename FunctionTraits< T >::BaseType > &x, const Vector< typename FunctionTraits< T >::BaseType > &sol, const Bool model=False)
Return the residual after a fit in y.
Vector< typename FunctionTraits< T >::BaseType > fsol_p
Bool asweight_p
Interpret as weights rather than as sigma the given values.
PtrBlock< Vector< typename FunctionTraits< T >::BaseType > * > constrArg_p
List of vectors describing the constraint equations' arguments.
T BaseType
Template base type.
Vector< typename FunctionTraits< T >::BaseType > ferr_p
uInt NConstraints()
Return the number of constraints, and pointers to constraint functions.
uInt nUnknowns() const
Get the number of unknowns.
uInt pCount_p
Number of available parameters.
FunctionTraits< T >::BaseType getVal_p(const Array< typename FunctionTraits< T >::BaseType > &x, uInt j, uInt i) const
Function to get evaluated functional value.
uInt testInput_p(const Array< typename FunctionTraits< T >::BaseType > &x, const Vector< typename FunctionTraits< T >::BaseType > &y, const Vector< typename FunctionTraits< T >::BaseType > *const sigma)
Return number of condition equations and check sizes x, y, sigma.
A 2-D Specialization of the Array class.
void resetFunction()
Reset all the input.
Vector< typename FunctionTraits< T >::BaseType > sol_p
Local solution area.
PtrBlock< typename FunctionTraits< T >::BaseType * > constrVal_p
List of values describing the constraint equations' value.
void buildMatrix(const Array< typename FunctionTraits< T >::BaseType > &x, const Vector< typename FunctionTraits< T >::BaseType > &y, const Vector< typename FunctionTraits< T >::BaseType > *const sigma, const Vector< Bool > *const mask=0)
Build the normal matrix.
Bool solved_p
Have solution.
Matrix< Double > compuCovariance()
Get covariance matrix.
Double chiSquare() const
Obtain the chi squared.
Vector< typename FunctionTraits< T >::BaseType > fullEq_p
Equation for all available parameters.
Function< typename FunctionTraits< T >::DiffType, typename FunctionTraits< T >::DiffType > * ptr_derive_p
Function to use in evaluating condition equation.
Vector< typename FunctionTraits< T >::ArgType > carg_p
void setCollinearity(const Double cln)
Set the collinearity factor as the square of the sine of the minimum angle allowed between input vect...
void setFunctionEx()
Set function properties.
Numerical functional interface class.
const Double COLLINEARITY
Default collinearity test for SVD.
uInt ndim_p
Number of dimensions of input data.
Vector< typename FunctionTraits< T >::BaseType > condEq_p
Condition equation parameters (for number of adjustable parameters)
uInt fittedNumber() const
Return the number of fitted parameters.
virtual Bool fitIt(Vector< typename FunctionTraits< T >::BaseType > &sol, const Array< typename FunctionTraits< T >::BaseType > &x, const Vector< typename FunctionTraits< T >::BaseType > &y, const Vector< typename FunctionTraits< T >::BaseType > *const sigma, const Vector< Bool > *const mask=0)=0
Generalised fitter.
Generic base class for least-squares fit.
Bool needInit_p
No normal equations yet.
Vector< typename LSQTraits< typename FunctionTraits< T >::BaseType >::base > getSVDConstraint(uInt n)
Return the nth constraint equation derived from SVD Note that the number present will be given by get...
bool Bool
Define the standard types used by Casacore.
Class that computes partial derivatives by automatic differentiation.
Function< typename FunctionTraits< T >::DiffType, typename FunctionTraits< T >::DiffType > * fittedFunction()
Return a pointer to the function being fitted.
PtrBlock< Function< typename FunctionTraits< T >::DiffType, typename FunctionTraits< T >::DiffType > * > constrFun_p
List of functions describing the possible constraint equations e.g.
A drop-in replacement for Block<T*>.
template <class T, class U> class vector;
Bool errors_p
Have errors.
void asWeight(const Bool aswgt)
Set sigma values to be interpreted as weight (i.e.
const Function< typename FunctionTraits< T >::DiffType, typename FunctionTraits< T >::DiffType > * fittedFunction() const
uInt getRank() const
Get the rank of the solution (or zero of no fit() done yet).
Bool addConstraint(const Function< typename FunctionTraits< T >::DiffType, typename FunctionTraits< T >::DiffType > &function, const Vector< typename FunctionTraits< T >::BaseType > &x, const typename FunctionTraits< T >::BaseType y=typename FunctionTraits< T >::BaseType(0))
Vector< typename FunctionTraits< T >::ArgType > arg_p
Contiguous argument areas.
Double getChi() const
Get chi^2 (both are identical); the standard deviation (per observation) and the standard deviation p...
void initfit_p(uInt parcnt)
Initialise the fitter with number of solvable parameters.
const Vector< typename FunctionTraits< T >::BaseType > & errors() const
Get the errors on the solved values.
uInt getDeficiency() const
Get the rank deficiency Warning: Note that the number is returned assuming real values; For complex ...
void setFunction(const Function< U, U > &function)
Sets the function to be fitted.
void asSVD(const Bool svd)
Set the use of SVD or not (default).
uInt nr_p
The rank of the solution.
void buildConstraint()
Build the constraint equations.
Bool setConstraintEx(const uInt n, const Vector< typename FunctionTraits< T >::BaseType > &x, const typename FunctionTraits< T >::BaseType y)
Set Constraint properties.
Bool buildResidual(Vector< typename FunctionTraits< T >::BaseType > &y, const Array< typename FunctionTraits< T >::BaseType > &x, const Vector< typename FunctionTraits< T >::BaseType > *const sol, const Bool model=False)
Calculate residuals.
Function< typename FunctionTraits< T >::DiffType, typename FunctionTraits< T >::DiffType > * getConstraint(const uInt n)
Bool setConstraint(const uInt n, const Function< U, U > &function, const Vector< typename FunctionTraits< T >::BaseType > &x, const typename FunctionTraits< T >::BaseType y=typename FunctionTraits< T >::BaseType(0))
Set the possible constraint functions.
#define casacore
<X11/Intrinsic.h> #defines true, false, casacore::Bool, and String.
Vector< Vector< typename LSQTraits< typename FunctionTraits< T >::BaseType >::base > > consvd_p
Local SVD constraints.