queso-0.53.0
1D1DFunction.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // QUESO - a library to support the Quantification of Uncertainty
5 // for Estimation, Simulation and Optimization
6 //
7 // Copyright (C) 2008-2015 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 #ifndef UQ_1D_1D_FUNCTION_H
26 #define UQ_1D_1D_FUNCTION_H
27 
28 #include <queso/ScalarSequence.h>
29 #include <queso/1DQuadrature.h>
30 #include <queso/Environment.h>
31 #include <queso/Defines.h>
32 #include <vector>
33 #include <math.h>
34 #include <fstream>
35 
36 namespace QUESO {
37 
44 //*****************************************************
45 // Base 1D->1D class
46 //*****************************************************
47 
53 class
55 public:
57 
58  Base1D1DFunction(double minDomainValue,
60  double maxDomainValue);
61 
63  virtual ~Base1D1DFunction();
65 
67 
68  double minDomainValue() const;
70 
72  double maxDomainValue() const;
73 
75  virtual double value (double domainValue) const = 0;
76 
78  virtual double deriv (double domainValue) const = 0;
79 
81 
82  virtual double multiplyAndIntegrate(const Base1D1DFunction& func, unsigned int quadratureOrder, double* resultWithMultiplicationByTAsWell) const;
84 protected:
87 };
88 
89 //*****************************************************
90 // Generic 1D->1D class
91 //*****************************************************
98 public:
100 
103  double maxDomainValue,
104  double (*valueRoutinePtr)(double domainValue, const void* routinesDataPtr),
105  double (*derivRoutinePtr)(double domainValue, const void* routinesDataPtr),
106  const void* routinesDataPtr);
110 
112 
113 
116  double value(double domainValue) const;
117 
119 
121  double deriv(double domainValue) const;
123 protected:
126 
127  double (*m_valueRoutinePtr)(double domainValue, const void* routinesDataPtr);
128  double (*m_derivRoutinePtr)(double domainValue, const void* routinesDataPtr);
129  const void* m_routinesDataPtr;
130 };
131 
132 //*****************************************************
133 // Constant 1D->1D class
134 //*****************************************************
141 public:
143 
146  double maxDomainValue,
147  double constantValue);
151 
153 
154 
158  double value(double domainValue) const;
159 
161 
163  double deriv(double domainValue) const;
165 protected:
168 
170 };
171 
172 //*****************************************************
173 // Linear 1D->1D class
174 //*****************************************************
187 public:
189 
190 
194  double maxDomainValue,
195  double referenceDomainValue,
196  double referenceImageValue,
197  double rateValue);
201 
203 
204 
207  double value(double domainValue) const;
208 
210 
213  double deriv(double domainValue) const;
215 protected:
218 
221 
224 
226  double m_rateValue;
227 };
228 
229 //*****************************************************
230 // PiecewiseLinear 1D->1D class
231 //*****************************************************
238 public:
240 
243  double maxDomainValue,
244  const std::vector<double>& referenceDomainValues,
245  double referenceImageValue0,
246  const std::vector<double>& rateValues);
250 
252 
253 
256  double value(double domainValue) const;
257 
259 
261  double deriv(double domainValue) const;
263 protected:
266 
268  unsigned int m_numRefValues;
269 
271  std::vector<double> m_referenceDomainValues;
272 
274  std::vector<double> m_referenceImageValues;
275 
277  std::vector<double> m_rateValues;
278 };
279 
280 //*****************************************************
281 // Quadratic 1D->1D class
282 //*****************************************************
293 public:
295 
296 
300  double maxDomainValue,
301  double a,
302  double b,
303  double c);
306 
308 
309 
313  double value(double domainValue) const;
314 
316 
319  double deriv(double domainValue) const;
321 protected:
324 
326  double m_a;
327 
329  double m_b;
330 
332  double m_c;
333 };
334 
335 //*****************************************************
336 // Sampled 1D->1D class
337 //*****************************************************
348 public:
350 
353 
355 
358  Sampled1D1DFunction(const std::vector<double>& domainValues,
359  const std::vector<double>& imageValues);
360 
362  virtual ~Sampled1D1DFunction();
364 
366 
367 
372  virtual double value(double domainValue) const;
373 
375 
378  double deriv(double domainValue) const;
379 
381  const std::vector<double>& domainValues() const;
382 
384  const std::vector<double>& imageValues () const;
385 
387  bool domainValueMatchesExactly(double domainValue) const;
388 
390  void set(const std::vector<double>& domainValues,
391  const std::vector<double>& imageValues);
393 
395 
396  virtual void printForMatlab(const BaseEnvironment& env, std::ofstream& ofsvar, const std::string& prefixName) const;
399 protected:
402 
404  std::vector<double> m_domainValues;
405 
407  std::vector<double> m_imageValues;
408 };
409 
410 //*****************************************************
411 // 'ScalarTimesFunc' 1D->1D class
412 //*****************************************************
422 public:
424 
425  ScalarTimesFunc1D1DFunction(double scalar,
427  const Base1D1DFunction& func);
428 
432 
434 
435 
438  double value(double domainValue) const;
439 
441 
442  double deriv(double domainValue) const;
444 protected:
447 
448  double m_scalar;
450 };
451 
452 //*****************************************************
453 // 'FuncTimesFunc' 1D->1D class
454 //*****************************************************
463 public:
465 
468  const Base1D1DFunction& func2);
469 
473 
475 
476 
479  double value(double domainValue) const;
480 
482 
484  double deriv(double domainValue) const;
486 
487 protected:
490 
493 };
494 
495 //*****************************************************
496 // 'FuncPlusFunc' 1D->1D class
497 //*****************************************************
505 public:
507 
510  const Base1D1DFunction& func2);
511 
515 
517 
518 
521  double value(double domainValue) const;
522 
524 
525  double deriv(double domainValue) const;
527 protected:
530 
533 };
534 //*****************************************************
535 // Lagrange Polynomial 1D->1D class
536 //*****************************************************
559 public:
561 
562  LagrangePolynomial1D1DFunction(const std::vector<double>& positionValues,
564  const std::vector<double>* functionValues);
565 
569 
571 
572  double value(double domainValue) const;
574 
576 
578  double deriv(double domainValue) const;
580 protected:
583 
584  std::vector<double> m_positionValues;
585  std::vector<double> m_functionValues;
586 };
587 
588 //*****************************************************
589 // Lagrange Basis 1D->1D class
590 //*****************************************************
610 public:
612 
613  LagrangeBasis1D1DFunction(const std::vector<double>& positionValues,
615  unsigned int basisIndex);
616 
620 
622 
623  double value(double domainValue) const;
625 
627 
629  double deriv(double domainValue) const;
631 protected:
634 
635  std::vector<double> m_positionValues;
636  unsigned int m_basisIndex;
637 };
638 
639 //----------------------------------------------------------------------
641 
646 template <class T>
647 double SubF1F2Gaussian2dKdeIntegral(const ScalarSequence<T>& scalarSeq1,
648  const ScalarSequence<T>& scalarSeq2, unsigned int initialPos,
649  double scaleValue1, double scaleValue2, const Base1D1DFunction& func1,
650  const Base1D1DFunction& func2, unsigned int quadratureOrder);
651 
652 } // End namespace QUESO
653 
654 #endif // UQ_1D_1D_FUNCTION_H
std::vector< double > m_rateValues
Rate value; in , for each =1 .. m_numRefValues.
Definition: 1D1DFunction.h:277
Class for generic one-dimensional functions.
Definition: 1D1DFunction.h:97
LagrangeBasis1D1DFunction(const std::vector< double > &positionValues, unsigned int basisIndex)
Default constructor.
Definition: 1D1DFunction.C:820
Sampled1D1DFunction()
Default constructor. It should not be called by the user.
Definition: 1D1DFunction.C:427
~Constant1D1DFunction()
Destructor.
Definition: 1D1DFunction.C:141
Linear1D1DFunction(double minDomainValue, double maxDomainValue, double referenceDomainValue, double referenceImageValue, double rateValue)
Default constructor.
Definition: 1D1DFunction.C:182
~Generic1D1DFunction()
Destructor.
Definition: 1D1DFunction.C:90
double m_referenceImageValue
Reference value in the function image; in .
Definition: 1D1DFunction.h:223
double value(double domainValue) const
Returns the value of the linear function at point domainValue.
Definition: 1D1DFunction.C:201
double deriv(double domainValue) const
TODO: Returns the value of the derivative of the Lagrange polynomial at point domainValue.
Definition: 1D1DFunction.C:797
Class for one-dimensional functions.
Definition: 1D1DFunction.h:53
double value(double domainValue) const
Returns the value of the multiplication of a function func1 by another function func2 at the point do...
Definition: 1D1DFunction.C:662
Class for one-dimensional sampled functions.
Definition: 1D1DFunction.h:347
double deriv(double domainValue) const
Returns the value of the derivative of the constant function at point domainValue.
Definition: 1D1DFunction.C:163
std::vector< double > m_domainValues
Array of the values in the domain of the function (values of the independent variable).
Definition: 1D1DFunction.h:404
std::vector< double > m_imageValues
Array of the values in the image of the function (values of the dependent variable).
Definition: 1D1DFunction.h:407
FuncTimesFunc1D1DFunction(const Base1D1DFunction &func1, const Base1D1DFunction &func2)
Default constructor.
Definition: 1D1DFunction.C:647
Class for constant one-dimensional functions.
Definition: 1D1DFunction.h:140
double deriv(double domainValue) const
TODO: Returns the value of the derivative of the Lagrange basis at point domainValue.
Definition: 1D1DFunction.C:853
~Linear1D1DFunction()
Destructor.
Definition: 1D1DFunction.C:196
Generic1D1DFunction(double minDomainValue, double maxDomainValue, double(*valueRoutinePtr)(double domainValue, const void *routinesDataPtr), double(*derivRoutinePtr)(double domainValue, const void *routinesDataPtr), const void *routinesDataPtr)
Default constructor.
Definition: 1D1DFunction.C:76
double value(double domainValue) const
Returns the value of the Lagrange basis at point domainValue.
Definition: 1D1DFunction.C:836
Class for piecewise-linear one-dimensional functions.
Definition: 1D1DFunction.h:237
PiecewiseLinear1D1DFunction(double minDomainValue, double maxDomainValue, const std::vector< double > &referenceDomainValues, double referenceImageValue0, const std::vector< double > &rateValues)
Default constructor.
Definition: 1D1DFunction.C:239
void set(const std::vector< double > &domainValues, const std::vector< double > &imageValues)
Sets the values of the independent (domainValues) and dependent (imageValues) variables of this sampl...
Definition: 1D1DFunction.C:551
const std::vector< double > & domainValues() const
Array of the domain values (values of the independent variable).
Definition: 1D1DFunction.C:523
Class for addition of a one-dimensional function with another.
Definition: 1D1DFunction.h:504
double minDomainValue() const
Returns the minimum value of the domain of the (one-dimensional) function.
Definition: 1D1DFunction.C:48
Class for one-dimensional quadratic functions.
Definition: 1D1DFunction.h:292
double deriv(double domainValue) const
TODO: Returns the value of the derivative of the function multiplied by the given scalar at point dom...
Definition: 1D1DFunction.C:624
~FuncTimesFunc1D1DFunction()
Destructor.
Definition: 1D1DFunction.C:657
double(* m_derivRoutinePtr)(double domainValue, const void *routinesDataPtr)
Definition: 1D1DFunction.h:128
unsigned int m_numRefValues
Number of points which will be evaluated.
Definition: 1D1DFunction.h:268
const Base1D1DFunction & m_func2
Definition: 1D1DFunction.h:492
double value(double domainValue) const
Returns the value of the constant function at point domainValue.
Definition: 1D1DFunction.C:146
double value(double domainValue) const
Returns the value of the addition of function func1 and func2 evaluated at the point domainValue...
Definition: 1D1DFunction.C:710
const void * m_routinesDataPtr
Definition: 1D1DFunction.h:129
double maxDomainValue() const
Returns the maximum value of the domain of the (one-dimensional) function.
Definition: 1D1DFunction.C:54
virtual double value(double domainValue) const
Returns the value of the sampled function at point domainValue.
Definition: 1D1DFunction.C:457
double deriv(double domainValue) const
Returns the value of the derivative of the function at point domainValue.
Definition: 1D1DFunction.C:112
double m_rateValue
Rate value; in .
Definition: 1D1DFunction.h:226
virtual void printForMatlab(const BaseEnvironment &env, std::ofstream &ofsvar, const std::string &prefixName) const
Prints the values of the function in Matlab/Octave format.
Definition: 1D1DFunction.C:573
const std::vector< double > & imageValues() const
Array of the image values (values of the dependent variable).
Definition: 1D1DFunction.C:529
FuncPlusFunc1D1DFunction(const Base1D1DFunction &func1, const Base1D1DFunction &func2)
Default constructor.
Definition: 1D1DFunction.C:695
LagrangePolynomial1D1DFunction(const std::vector< double > &positionValues, const std::vector< double > *functionValues)
Default constructor.
Definition: 1D1DFunction.C:743
virtual double deriv(double domainValue) const =0
Returns the value of the derivative of the function. See template specialization. ...
Class for multiplication of a one-dimensional function by a scalar.
Definition: 1D1DFunction.h:421
Class for multiplication of a one-dimensional function by another.
Definition: 1D1DFunction.h:462
const Base1D1DFunction & m_func2
Definition: 1D1DFunction.h:532
bool domainValueMatchesExactly(double domainValue) const
Checks whether the domain value domainValue matches exactly one of the values in the function domain ...
Definition: 1D1DFunction.C:535
double value(double domainValue) const
Returns the value of the (one-dimensional) function at point domainValue.
Definition: 1D1DFunction.C:95
double deriv(double domainValue) const
Returns the value of the derivative of the piecewise-linear function at point domainValue.
Definition: 1D1DFunction.C:334
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
Definition: Environment.h:193
double SubF1F2Gaussian2dKdeIntegral(const ScalarSequence< T > &scalarSeq1, const ScalarSequence< T > &scalarSeq2, unsigned int initialPos, double scaleValue1, double scaleValue2, const Base1D1DFunction &func1, const Base1D1DFunction &func2, unsigned int quadratureOrder)
Calculates the integral of a 2D Gaussian KDE.
Definition: 1D1DFunction.C:875
ScalarTimesFunc1D1DFunction(double scalar, const Base1D1DFunction &func)
Default constructor.
Definition: 1D1DFunction.C:599
double deriv(double domainValue) const
Returns the value of the derivative of the linear function at point domainValue.
Definition: 1D1DFunction.C:220
Class for linear one-dimensional functions.
Definition: 1D1DFunction.h:186
~FuncPlusFunc1D1DFunction()
Destructor.
Definition: 1D1DFunction.C:705
double value(double domainValue) const
Returns the value of the Lagrange polynomial at point domainValue.
Definition: 1D1DFunction.C:762
std::vector< double > m_referenceDomainValues
Reference values in the piecewise-linear function domain; in , for each =1 .. m_numRefValues.
Definition: 1D1DFunction.h:271
Class for Lagrange polynomial basis.
Definition: 1D1DFunction.h:609
double(* m_valueRoutinePtr)(double domainValue, const void *routinesDataPtr)
Definition: 1D1DFunction.h:127
virtual double value(double domainValue) const =0
Returns the value of the (one-dimensional) function. See template specialization. ...
virtual ~Sampled1D1DFunction()
Destructor.
Definition: 1D1DFunction.C:452
double value(double domainValue) const
Returns the value of the (one-dimensional) function at point domainValue, already multiplied by the s...
Definition: 1D1DFunction.C:614
const Base1D1DFunction & m_func1
Definition: 1D1DFunction.h:531
std::vector< double > m_referenceImageValues
Reference values in the piecewise-linear function image; in , for each =1 .. m_numRefValues.
Definition: 1D1DFunction.h:274
const Base1D1DFunction & m_func1
Definition: 1D1DFunction.h:491
double value(double domainValue) const
Returns the value of the piecewise-linear function at point domainValue.
Definition: 1D1DFunction.C:287
std::vector< double > m_positionValues
Definition: 1D1DFunction.h:584
double m_referenceDomainValue
Reference value in the function domain; in .
Definition: 1D1DFunction.h:220
Class for handling scalar samples.
~LagrangeBasis1D1DFunction()
Destructor.
Definition: 1D1DFunction.C:831
Class for one-dimensional Lagrange polynomials.
Definition: 1D1DFunction.h:558
std::vector< double > m_positionValues
Definition: 1D1DFunction.h:635
std::vector< double > m_functionValues
Definition: 1D1DFunction.h:585
double deriv(double domainValue) const
Bogus: Derivative of the function.
Definition: 1D1DFunction.C:505
Quadratic1D1DFunction(double minDomainValue, double maxDomainValue, double a, double b, double c)
Default constructor.
Definition: 1D1DFunction.C:370
double deriv(double domainValue) const
TODO: Returns the value of the derivative of the addition of two functions.
Definition: 1D1DFunction.C:720
double deriv(double domainValue) const
TODO: Returns the value of the derivative of the function func1 by another function func2 at the poin...
Definition: 1D1DFunction.C:672
const Base1D1DFunction & m_func
Definition: 1D1DFunction.h:449
Constant1D1DFunction(double minDomainValue, double maxDomainValue, double constantValue)
Default constructor.
Definition: 1D1DFunction.C:131
~Quadratic1D1DFunction()
Destructor.
Definition: 1D1DFunction.C:384

Generated on Thu Jun 11 2015 13:52:32 for queso-0.53.0 by  doxygen 1.8.5