25 #include <queso/1D1DFunction.h> 
   26 #include <queso/1DQuadrature.h> 
   34   double minDomainValue,
 
   35   double maxDomainValue)
 
   37   m_minDomainValue(minDomainValue),
 
   38   m_maxDomainValue(maxDomainValue)
 
   66   if (resultWithMultiplicationByTAsWell) { 
 
   67     func.
value((
double) quadratureOrder);
 
   77   double minDomainValue,
 
   78   double maxDomainValue,
 
   79   double (*valueRoutinePtr)(
double domainValue, 
const void* routinesDataPtr),
 
   80   double (*derivRoutinePtr)(
double domainValue, 
const void* routinesDataPtr),
 
   81   const void* routinesDataPtr)
 
   84   m_valueRoutinePtr      (valueRoutinePtr),
 
   85   m_derivRoutinePtr      (derivRoutinePtr),
 
   86   m_routinesDataPtr      (routinesDataPtr)
 
   98     std::cerr << 
"In Generic1D1DFunction::value()" 
   99               << 
": requested x ("            << domainValue
 
  115     std::cerr << 
"In Generic1D1DFunction::deriv()" 
  116               << 
": requested x ("            << domainValue
 
  132   double minDomainValue,
 
  133   double maxDomainValue,
 
  134   double constantValue)
 
  137   m_constantValue        (constantValue)
 
  149     std::cerr << 
"In Constant1D1DFunction::value()" 
  150               << 
": requested x ("            << domainValue
 
  166     std::cerr << 
"In Constant1D1DFunction::deriv()" 
  167               << 
": requested x ("            << domainValue
 
  183   double minDomainValue,
 
  184   double maxDomainValue,
 
  185   double referenceDomainValue,
 
  186   double referenceImageValue,
 
  190   m_referenceDomainValue (referenceDomainValue),
 
  191   m_referenceImageValue  (referenceImageValue),
 
  192   m_rateValue            (rateValue)
 
  204     std::cerr << 
"In Linear1D1DFunction::value()" 
  205               << 
": requested x ("            << domainValue
 
  223     std::cerr << 
"In Linear1D1DFunction::deriv()" 
  224               << 
": requested x ("            << domainValue
 
  240   double                     minDomainValue,
 
  241   double                     maxDomainValue,
 
  242   const std::vector<double>& referenceDomainValues,
 
  243   double                     referenceImageValue0,
 
  244   const std::vector<double>& rateValues)
 
  247   m_numRefValues         (referenceDomainValues.size()),
 
  248   m_referenceDomainValues(referenceDomainValues),
 
  249   m_rateValues           (rateValues)
 
  267     std::cout << 
"In PiecewiseLinear1D1DFunction::constructor():" 
  270       std::cout << 
"i = " << i
 
  290     std::cerr << 
"In PiecewiseLinear1D1DFunction::value()" 
  291               << 
": requested x ("            << domainValue
 
  305     bool referenceDomainValueFound = 
false;
 
  306     while (referenceDomainValueFound == 
false) {
 
  308         referenceDomainValueFound = 
true;
 
  313           referenceDomainValueFound = 
true;
 
  320     std::cout << 
"In PiecewiseLinear1D1DFunction::value()" 
  321               << 
": domainValue = "                << domainValue
 
  326               << 
", imageValue = "                 << imageValue
 
  337     std::cerr << 
"In PiecewiseLinear1D1DFunction::deriv()" 
  338               << 
": requested x ("            << domainValue
 
  352     bool referenceDomainValueFound = 
false;
 
  353     while (referenceDomainValueFound == 
false) {
 
  355         referenceDomainValueFound = 
true;
 
  371   double minDomainValue,
 
  372   double maxDomainValue,
 
  392     std::cerr << 
"In Quadratic1D1DFunction::value()" 
  393               << 
": requested x ("            << domainValue
 
  402   double imageValue = m_a*domainValue*domainValue + m_b*domainValue + m_c;
 
  411     std::cerr << 
"In Quadratic1D1DFunction::deriv()" 
  412               << 
": requested x ("            << domainValue
 
  421   return 2.*m_a*domainValue + m_b;
 
  438   const std::vector<double>& domainValues,
 
  439   const std::vector<double>& imageValues)
 
  442   m_domainValues    (domainValues.size(),0.),
 
  443   m_imageValues     (imageValues.size(), 0.)
 
  446   for (
unsigned int i = 0; i < tmpSize; ++i) {
 
  460     std::cerr << 
"In Sampled1D1DFunction::value()" 
  461               << 
": requested x ("            << domainValue
 
  470   double returnValue = 0.;
 
  487   for (i = 0; i < tmpSize; ++i) {
 
  508     std::cerr << 
"In Sampled1D1DFunction::deriv()" 
  509               << 
": requested x ("            << domainValue
 
  522 const std::vector<double>&
 
  528 const std::vector<double>&
 
  540   for (
unsigned int i = 0; i < tmpSize; ++i) {
 
  552   const std::vector<double>& domainValues,
 
  553   const std::vector<double>& imageValues)
 
  558   unsigned int tmpSize = domainValues.size();
 
  564   for (
unsigned int i = 0; i < tmpSize; ++i) {
 
  575   std::ofstream&                ofsvar,
 
  576   const std::string&            prefixName)
 const 
  581     ofsvar << 
"\n" << prefixName << 
"Time_sub" << env.
subIdString() << 
" = zeros("  << tmpSize << 
",1);" 
  582            << 
"\n" << prefixName << 
"Value_sub" << env.
subIdString() << 
" = zeros(" << tmpSize << 
",1);";
 
  585     ofsvar << 
"\n" << prefixName << 
"Time_sub" << env.
subIdString() << 
" = zeros("  << tmpSize << 
",1);" 
  586            << 
"\n" << prefixName << 
"Value_sub" << env.
subIdString() << 
" = zeros(" << tmpSize << 
",1);";
 
  587     for (
unsigned int i = 0; i < tmpSize; ++i) {
 
  629     std::cerr << 
"In ScalarTimes1D1DFunction::deriv()" 
  630               << 
": requested x ("            << domainValue
 
  651   Base1D1DFunction(std::max(func1.minDomainValue(),func2.minDomainValue()),std::min(func1.maxDomainValue(),func2.maxDomainValue())),
 
  677     std::cerr << 
"In FuncTimes1D1DFunction::deriv()" 
  678               << 
": requested x ("            << domainValue
 
  699   Base1D1DFunction(std::max(func1.minDomainValue(),func2.minDomainValue()),std::min(func1.maxDomainValue(),func2.maxDomainValue())),
 
  725     std::cerr << 
"In FuncPlus1D1DFunction::deriv()" 
  726               << 
": requested x ("            << domainValue
 
  744   const std::vector<double>& positionValues,
 
  745   const std::vector<double>* functionValues)
 
  748   m_positionValues(positionValues),
 
  749   m_functionValues(positionValues.size(),1.)
 
  751   if (functionValues) {
 
  767     double scaleFactor = 1.;
 
  772         scaleFactor *= (domainValue-posJ)/(posK-posJ);
 
  802     std::cerr << 
"In LagrangePolynomial1D1DFunction::deriv()" 
  803               << 
": requested x ("            << domainValue
 
  821   const std::vector<double>& positionValues,
 
  822   unsigned int               basisIndex)
 
  825   m_positionValues(positionValues),
 
  826   m_basisIndex    (basisIndex)
 
  838   double scaleFactor = 1.;
 
  845       scaleFactor *= (domainValue-posJ)/(posK-posJ);
 
  858     std::cerr << 
"In LagrangeBasis1D1DFunction::deriv()" 
  859               << 
": requested x ("            << domainValue
 
  877                                unsigned int                    initialPos,
 
  882                                unsigned int                    quadratureOrder)
 
  884   double resultValue = 0.;
 
  890   const std::vector<double>& quadPositions = quadObj.positions();
 
  891   const std::vector<double>& quadWeights   = quadObj.weights  ();
 
  894   unsigned int numQuadraturePositions = quadPositions.size();
 
  896   for (
unsigned int k = 0; 
k < dataSize; ++
k) {
 
  899     double x1k = scalarSeq1[
k];
 
  900     double x2k = scalarSeq2[
k];
 
  901     for (
unsigned int j = 0; j < numQuadraturePositions; ++j) {
 
  902       value1 += func1.
value(scaleValue1*quadPositions[j]+x1k)*quadWeights[j];
 
  903       value2 += func2.
value(scaleValue2*quadPositions[j]+x2k)*quadWeights[j];
 
  905     resultValue += value1*value2;
 
  907   resultValue *= 1./(2.*M_PI)/((
double) dataSize);
 
~LagrangeBasis1D1DFunction()
Destructor. 
 
double minDomainValue() const 
Returns the minimum value of the domain of the (one-dimensional) function. 
 
Quadratic1D1DFunction(double minDomainValue, double maxDomainValue, double a, double b, double c)
Default constructor. 
 
LagrangeBasis1D1DFunction(const std::vector< double > &positionValues, unsigned int basisIndex)
Default constructor. 
 
~ScalarTimesFunc1D1DFunction()
Destructor. 
 
Sampled1D1DFunction()
Default constructor. It should not be called by the user. 
 
double value(double domainValue) const 
Returns the value of the (one-dimensional) function at point domainValue, already multiplied by the s...
 
Constant1D1DFunction(double minDomainValue, double maxDomainValue, double constantValue)
Default constructor. 
 
PiecewiseLinear1D1DFunction(double minDomainValue, double maxDomainValue, const std::vector< double > &referenceDomainValues, double referenceImageValue0, const std::vector< double > &rateValues)
Default constructor. 
 
Base1D1DFunction(double minDomainValue, double maxDomainValue)
Default constructor. 
 
double deriv(double domainValue) const 
TODO: Returns the value of the derivative of the function multiplied by the given scalar at point dom...
 
double deriv(double domainValue) const 
TODO: Returns the value of the derivative of the addition of two functions. 
 
const void * m_routinesDataPtr
 
#define queso_require_greater_equal_msg(expr1, expr2, msg)
 
std::vector< double > m_referenceImageValues
Reference values in the piecewise-linear function image;  in , for each =1 .. m_numRefValues. 
 
~Linear1D1DFunction()
Destructor. 
 
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
 
std::vector< double > m_rateValues
Rate value;  in , for each =1 .. m_numRefValues. 
 
double deriv(double domainValue) const 
Bogus: Derivative of the function. 
 
~FuncPlusFunc1D1DFunction()
Destructor. 
 
~FuncTimesFunc1D1DFunction()
Destructor. 
 
virtual double value(double domainValue) const 
Returns the value of the sampled function at point domainValue. 
 
double deriv(double domainValue) const 
TODO: Returns the value of the derivative of the Lagrange basis at point domainValue. 
 
double deriv(double domainValue) const 
TODO: Returns the value of the derivative of the Lagrange polynomial at point domainValue. 
 
double value(double domainValue) const 
Returns the value of the (one-dimensional) function at point domainValue. 
 
ScalarTimesFunc1D1DFunction(double scalar, const Base1D1DFunction &func)
Default constructor. 
 
~PiecewiseLinear1D1DFunction()
Destructor. 
 
std::vector< double > m_positionValues
 
const Base1D1DFunction & m_func1
 
#define queso_require_equal_to_msg(expr1, expr2, msg)
 
#define queso_require_less_msg(expr1, expr2, msg)
 
const Base1D1DFunction & m_func2
 
Class for handling scalar samples. 
 
const Base1D1DFunction & m_func1
 
const Base1D1DFunction & m_func
 
~Generic1D1DFunction()
Destructor. 
 
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. 
 
double deriv(double domainValue) const 
Returns the value of the derivative of the piecewise-linear function at point domainValue. 
 
FuncPlusFunc1D1DFunction(const Base1D1DFunction &func1, const Base1D1DFunction &func2)
Default constructor. 
 
double(* m_valueRoutinePtr)(double domainValue, const void *routinesDataPtr)
 
double deriv(double domainValue) const 
TODO: Returns the value of the derivative of the function func1 by another function func2 at the poin...
 
Linear1D1DFunction(double minDomainValue, double maxDomainValue, double referenceDomainValue, double referenceImageValue, double rateValue)
Default constructor. 
 
double m_referenceDomainValue
Reference value in the function domain;  in . 
 
std::vector< double > m_positionValues
 
~Constant1D1DFunction()
Destructor. 
 
~Quadratic1D1DFunction()
Destructor. 
 
FuncTimesFunc1D1DFunction(const Base1D1DFunction &func1, const Base1D1DFunction &func2)
Default constructor. 
 
double value(double domainValue) const 
Returns the value of the constant function at point domainValue. 
 
double value(double domainValue) const 
Returns the value of the Lagrange basis at point domainValue. 
 
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...
 
const std::string & subIdString() const 
Access to the attribute m_subIdString; which stores the string for the sub-environment, and it will be used, for instance, to create the output files for each sub-environment. 
 
Generic1D1DFunction(double minDomainValue, double maxDomainValue, double(*valueRoutinePtr)(double domainValue, const void *routinesDataPtr), double(*derivRoutinePtr)(double domainValue, const void *routinesDataPtr), const void *routinesDataPtr)
Default constructor. 
 
double deriv(double domainValue) const 
Returns the value of the derivative of the constant function at point domainValue. 
 
std::vector< double > m_domainValues
Array of the values in the domain of the function (values of the independent variable). 
 
#define queso_require_greater_msg(expr1, expr2, msg)
 
#define queso_not_implemented()
 
virtual double value(double domainValue) const =0
Returns the value of the (one-dimensional) function. See template specialization. ...
 
unsigned int m_basisIndex
 
virtual ~Sampled1D1DFunction()
Destructor. 
 
double(* m_derivRoutinePtr)(double domainValue, const void *routinesDataPtr)
 
#define queso_require_not_equal_to_msg(expr1, expr2, msg)
 
double value(double domainValue) const 
Returns the value of the piecewise-linear function at point domainValue. 
 
double value(double domainValue) const 
Returns the value of the multiplication of a function func1 by another function func2 at the point do...
 
bool domainValueMatchesExactly(double domainValue) const 
Checks whether the domain value domainValue matches exactly one of the values in the function domain ...
 
#define queso_require_less_equal_msg(expr1, expr2, msg)
 
LagrangePolynomial1D1DFunction(const std::vector< double > &positionValues, const std::vector< double > *functionValues)
Default constructor. 
 
double value(double domainValue) const 
Returns the value of the Lagrange polynomial at point domainValue. 
 
double deriv(double domainValue) const 
Returns the value of the derivative of the function at point domainValue. 
 
const std::vector< double > & domainValues() const 
Array of the domain values (values of the independent variable). 
 
#define queso_require_msg(asserted, msg)
 
std::vector< double > m_functionValues
 
double m_rateValue
Rate value;  in . 
 
std::vector< double > m_imageValues
Array of the values in the image of the function (values of the dependent variable). 
 
Class for one-dimensional functions. 
 
virtual ~Base1D1DFunction()
Destructor. 
 
const std::vector< double > & imageValues() const 
Array of the image values (values of the dependent variable). 
 
virtual double deriv(double domainValue) const =0
Returns the value of the derivative of the function. See template specialization. ...
 
double value(double domainValue) const 
Returns the value of the linear function at point domainValue. 
 
double value(double domainValue) const 
Returns the value of the addition of function func1 and func2 evaluated at the point domainValue...
 
#define queso_error_msg(msg)
 
virtual void printForMatlab(const BaseEnvironment &env, std::ofstream &ofsvar, const std::string &prefixName) const 
Prints the values of the function in Matlab/Octave format. 
 
std::vector< double > m_referenceDomainValues
Reference values in the piecewise-linear function domain;  in , for each =1 .. m_numRefValues. 
 
unsigned int subSequenceSize() const 
Size of the sub-sequence of scalars. 
 
~LagrangePolynomial1D1DFunction()
Destructor. 
 
double maxDomainValue() const 
Returns the maximum value of the domain of the (one-dimensional) function. 
 
Class for Hermite-Gauss quadrature rule for one-dimensional functions. 
 
const Base1D1DFunction & m_func2
 
virtual double multiplyAndIntegrate(const Base1D1DFunction &func, unsigned int quadratureOrder, double *resultWithMultiplicationByTAsWell) const 
TODO: Multiplies this function with function, and integrates it numerically. See template specializat...
 
double deriv(double domainValue) const 
Returns the value of the derivative of the linear function at point domainValue. 
 
double m_referenceImageValue
Reference value in the function image;  in . 
 
unsigned int m_numRefValues
Number of points which will be evaluated.