Polynomial.h
1//-*-C++-*-
2/***************************************************************************
3 *
4 * Copyright (C) 2004 by Willem van Straten
5 * Licensed under the Academic Free License version 2.1
6 *
7 ***************************************************************************/
8
9// psrchive/More/MEAL/MEAL/Polynomial.h
10
11#ifndef __Polynomial_H
12#define __Polynomial_H
13
14#include "MEAL/Univariate.h"
15#include "MEAL/Scalar.h"
16#include "MEAL/Parameters.h"
17
18namespace MEAL {
19
21 class Polynomial : public Univariate<Scalar> {
22
23 public:
24
26 Polynomial (unsigned ncoef = 0);
27
29 Polynomial (const Polynomial&);
30
33
35 Polynomial* clone () const;
36
38 void resize (unsigned ncoef);
39
40 unsigned get_ncoef () const { return get_nparam(); }
41 void set_ncoef (unsigned nc) { resize (nc); }
42
44 template<class T>
45 Polynomial (const std::vector<T>& coefs) : parameters (this, coefs.size())
46 {
47 init ();
48 for (unsigned ic=0; ic < coefs.size(); ic++)
49 set_param (ic, coefs[ic]);
50 }
51
53 void set_abscissa_offset(double x0)
54 { x_0 = x0; }
55
56 // ///////////////////////////////////////////////////////////////////
57 //
58 // Function implementation
59 //
60 // ///////////////////////////////////////////////////////////////////
61
63 std::string get_name () const;
64
66 void set_param_name (unsigned icoeff, const std::string& name);
67
69 void parse (const std::string& text);
70
72 class Interface;
73
76
77 protected:
78
80 void calculate (double& x, std::vector<double>* grad=0);
81
83 void print_parameters (std::string& text, const std::string& sep) const;
84
85 private:
86
88 double x_0;
89
91 Parameters parameters;
92
94 void init ();
95
96 };
97
98}
99
100#endif
void set_param(unsigned index, double value)
Set the value of the specified parameter.
Definition Function.h:131
unsigned get_nparam() const
Return the number of parameters.
Definition Function.h:115
Abstract base class implements parameter storage and access.
Definition Parameters.h:23
Polynomial(unsigned ncoef=0)
Default constructor.
Definition Polynomial.C:24
std::string get_name() const
Return the name of the class.
Definition Polynomial.C:64
void parse(const std::string &text)
Parses the values of model parameters and fit flags from a string.
Definition Polynomial.C:74
Polynomial & operator=(const Polynomial &)
Assignment operator.
Definition Polynomial.C:38
Polynomial(const std::vector< T > &coefs)
Construct from array of polynomial coefficients.
Definition Polynomial.h:45
void print_parameters(std::string &text, const std::string &sep) const
Print the values of model parameters and fit flags to a string.
Definition Polynomial.C:115
TextInterface::Parser * get_interface()
Return a text interface that can be used to access this instance.
Definition Polynomial.C:172
void calculate(double &x, std::vector< double > *grad=0)
Return the value (and gradient, if requested) of the function.
Definition Polynomial.C:123
void set_abscissa_offset(double x0)
Setter.
Definition Polynomial.h:53
void set_param_name(unsigned icoeff, const std::string &name)
Set the parameter name of the specified coefficient.
Definition Polynomial.C:69
void resize(unsigned ncoef)
Resize.
Definition Polynomial.C:55
Polynomial * clone() const
Clone operator.
Definition Polynomial.C:50
Univariate()
Definition Univariate.h:28
Namespace in which all modeling and calibration related code is declared.
Definition ExampleComplex2.h:16

Generated using doxygen 1.14.0