|
Go to the documentation of this file. 1 #ifndef NPSTAT_SCALABLECLASSICALORTHOPOLY1D_HH_
2 #define NPSTAT_SCALABLECLASSICALORTHOPOLY1D_HH_
18 class ScalableOrthoPoly1DDeg;
19 class ScalableOrthoPoly1DWeight;
28 long double location, long double scale);
31 double location, double scale);
41 inline long double location() const { return location_;}
42 inline long double scale() const { return scale_;}
49 inline void setLocation( const long double v) {location_ = v;}
50 inline void setScale( const long double v)
52 if (v <= 0.0) throw std::invalid_argument(
53 "In npstat::ScalableClassicalOrthoPoly1D::setScale: "
54 "scale parameter must be positive");
58 inline long double weight( const long double x) const
59 { return poly_-> weight((x - location_)/scale_)/scale_;}
61 inline double xmin() const { return scale_*poly_-> xmin() + location_;}
63 inline double xmax() const { return scale_*poly_->xmax() + location_;}
65 inline unsigned maxDegree() const { return poly_-> maxDegree();}
67 inline long double poly( const unsigned deg, const long double x) const
68 { return poly_-> poly(deg, (x - location_)/scale_);}
70 inline long double monic( const unsigned deg, const long double x) const
71 { return poly_-> monic(deg, (x - location_)/scale_);}
77 inline std::pair<long double,long double> twopoly(
78 const unsigned deg1, const unsigned deg2, const long double x) const
79 { return poly_-> twopoly(deg1, deg2, (x - location_)/scale_);}
87 long double* values, const unsigned maxdeg) const
88 {poly_-> allpoly((x - location_)/scale_, values, maxdeg);}
90 inline void allmonic( const long double x,
91 long double* values, const unsigned maxdeg) const
92 {poly_-> allmonic((x - location_)/scale_, values, maxdeg);}
94 inline double series( const double* coeffs, const unsigned maxdeg,
96 { return poly_-> series(coeffs, maxdeg, (x - location_)/scale_);}
98 inline double integrateSeries( const double* coeffs, const unsigned maxdeg) const
108 template < class Functor, class Quadrature>
110 double* coeffs, unsigned maxdeg) const;
119 template < class Numeric>
120 inline void sampleCoeffs( const Numeric* coords, const unsigned long lenCoords,
121 double* coeffs, const unsigned maxdeg) const
123 const Numeric mu = static_cast<Numeric >(location_);
124 const Numeric s = static_cast<Numeric >(scale_);
125 poly_-> sampleCoeffs(coords, lenCoords, mu, s, coeffs, maxdeg);
128 template < class Numeric>
129 inline void sampleCoeffVars( const Numeric* coords, const unsigned long lenCoords,
130 const double* coeffs, const unsigned maxdeg,
131 double* variances) const
133 const Numeric mu = static_cast<Numeric >(location_);
134 const Numeric s = static_cast<Numeric >(scale_);
135 poly_-> sampleCoeffVars(coords, lenCoords, mu, s, coeffs, maxdeg, variances);
138 template < class Numeric>
140 sampleCoeffCovariance( const Numeric* coords, const unsigned long lenCoords,
141 const double* coeffs, const unsigned maxdeg) const
143 const Numeric mu = static_cast<Numeric >(location_);
144 const Numeric s = static_cast<Numeric >(scale_);
158 template < class Pair>
160 double* coeffs, const unsigned maxdeg) const
162 typedef typename Pair::first_type Numeric;
163 const Numeric mu = static_cast<Numeric >(location_);
164 const Numeric s = static_cast<Numeric >(scale_);
168 template < class Pair>
169 inline void weightedSampleCoeffVars( const Pair* points, const unsigned long nPoints,
170 const double* coeffs, const unsigned maxdeg,
171 double* variances) const
173 typedef typename Pair::first_type Numeric;
174 const Numeric mu = static_cast<Numeric >(location_);
175 const Numeric s = static_cast<Numeric >(scale_);
179 template < class Pair>
181 weightedSampleCoeffCovariance( const Pair* points, const unsigned long nPoints,
182 const double* coeffs, const unsigned maxdeg) const
184 typedef typename Pair::first_type Numeric;
185 const Numeric mu = static_cast<Numeric >(location_);
186 const Numeric s = static_cast<Numeric >(scale_);
194 template < class Numeric, typename Real>
196 Real* averages, unsigned maxdeg) const;
206 template < class Pair, typename Real>
208 Real* averages, unsigned maxdeg) const;
215 template < class Functor, typename Real>
218 Real* averages, unsigned maxdeg) const;
225 template < class Functor>
231 long double location_;
236 inline void setLocation2( const double v)
239 inline void setScale2( const double v)
242 inline double location2() const
245 inline double scale2() const
248 inline double weight2( const double x) const
251 inline double poly2( const unsigned deg, const double x) const
252 { return poly(deg, x);}
254 inline double monic2( const unsigned deg, const double x) const
255 { return monic(deg, x);}
257 inline std::pair<double,double> twopoly2( const unsigned deg1,
259 const double x) const
261 const std::pair<long double,long double>& p = twopoly(deg1, deg2, x);
262 return std::pair<double,double>(p.first, p.second);
265 inline std::vector<double> allpoly2( const unsigned maxdeg, const double x) const
267 std::vector<long double> p(maxdeg+1);
269 return std::vector<double>(p.begin(), p.end());
272 inline std::vector<double> allmonic2( const unsigned maxdeg, const double x) const
274 std::vector<long double> p(maxdeg+1);
275 allmonic(x, &p[0], p.size());
276 return std::vector<double>(p.begin(), p.end());
292 const long double normfactor)
293 : fcn_(fcn), norm_(normfactor) {}
299 : fcn_(fcn), norm_(1.0L) {}
303 inline virtual long double operator()( const long double& a) const
304 { return norm_*fcn_.weight(a);}
323 const unsigned degree,
324 const long double normfactor=1.0L)
325 : fcn_(fcn), norm_(normfactor), deg_(degree)
327 if (deg_ > fcn_.maxDegree()) throw std::invalid_argument(
328 "In npstat::ScalableOrthoPoly1DDeg::constructor: "
329 "degree argument is out of range");
334 inline virtual long double operator()( const long double& a) const
335 { return norm_*fcn_.poly(deg_, a);}
346 #include "npstat/nm/ScalableClassicalOrthoPoly1D.icc"
Base class for classical continuous orthonormal polynomials.
Definition: AbsClassicalOrthoPoly1D.hh:32
Matrix< long double > jacobiMatrix(unsigned n) const
virtual double xmin() const =0
void allmonic(long double x, long double *values, unsigned maxdeg) const
void sampleCoeffs(const Numeric *coords, unsigned long lenCoords, double *coeffs, unsigned maxdeg) const
void weightedSampleCoeffs(const Pair *points, unsigned long numPoints, double *coeffs, unsigned maxdeg) const
Matrix< double > sampleCoeffCovariance(const Numeric *coords, unsigned long lenCoords, const double *coeffs, unsigned maxdeg) const
double integrateSeries(const double *coeffs, unsigned maxdeg) const
long double monic(unsigned deg, long double x) const
Matrix< double > weightedSampleCoeffCovariance(const Pair *points, unsigned long nPoints, const double *coeffs, unsigned maxdeg) const
void weightedSampleCoeffVars(const Pair *points, unsigned long nPoints, const double *coeffs, unsigned maxdeg, double *variances) const
void allpoly(long double x, long double *values, unsigned maxdeg) const
virtual long double weight(long double x) const =0
std::pair< long double, long double > twopoly(unsigned deg1, unsigned deg2, long double x) const
double series(const double *coeffs, unsigned maxdeg, double x) const
virtual unsigned maxDegree() const Definition: AbsClassicalOrthoPoly1D.hh:52
long double poly(unsigned deg, long double x) const
void sampleCoeffVars(const Numeric *coords, unsigned long lenCoords, const double *coeffs, unsigned maxdeg, double *variances) const
Definition: AbsIntervalQuadrature1D.hh:19
Definition: ScalableClassicalOrthoPoly1D.hh:22
void sampleCoeffs(const Numeric *coords, const unsigned long lenCoords, double *coeffs, const unsigned maxdeg) const Definition: ScalableClassicalOrthoPoly1D.hh:120
void sampleAverages(const Numeric *coords, unsigned long lenCoords, Real *averages, unsigned maxdeg) const
void calculateCoeffs(const Functor &fcn, const Quadrature &quad, double *coeffs, unsigned maxdeg) const
void weightedPointsAverages(const Pair *points, unsigned long numPoints, Real *averages, unsigned maxdeg) const
void allpoly(const long double x, long double *values, const unsigned maxdeg) const Definition: ScalableClassicalOrthoPoly1D.hh:86
void extWeightAverages(const Functor &extWeight, const AbsIntervalQuadrature1D &quad, Real *averages, unsigned maxdeg) const
Matrix< double > extWeightProductAverages(const Functor &extWeight, const AbsIntervalQuadrature1D &quad, unsigned maxdeg) const
std::pair< long double, long double > twopoly(const unsigned deg1, const unsigned deg2, const long double x) const Definition: ScalableClassicalOrthoPoly1D.hh:77
void weightedSampleCoeffs(const Pair *points, const unsigned long numPoints, double *coeffs, const unsigned maxdeg) const Definition: ScalableClassicalOrthoPoly1D.hh:159
Definition: ScalableClassicalOrthoPoly1D.hh:320
Definition: ScalableClassicalOrthoPoly1D.hh:288
Definition: AbsArrayProjector.hh:14
Definition: SimpleFunctors.hh:58
|