queso-0.57.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
QUESO::PiecewiseLinear1D1DFunction Class Reference

Class for piecewise-linear one-dimensional functions. More...

#include <1D1DFunction.h>

Inheritance diagram for QUESO::PiecewiseLinear1D1DFunction:
QUESO::Base1D1DFunction

Public Member Functions

Constructor/Destructor methods
 PiecewiseLinear1D1DFunction (double minDomainValue, double maxDomainValue, const std::vector< double > &referenceDomainValues, double referenceImageValue0, const std::vector< double > &rateValues)
 Default constructor. More...
 
 ~PiecewiseLinear1D1DFunction ()
 Destructor. More...
 
Mathematical methods
double value (double domainValue) const
 Returns the value of the piecewise-linear function at point domainValue. More...
 
double deriv (double domainValue) const
 Returns the value of the derivative of the piecewise-linear function at point domainValue. More...
 
- Public Member Functions inherited from QUESO::Base1D1DFunction
 Base1D1DFunction (double minDomainValue, double maxDomainValue)
 Default constructor. More...
 
virtual ~Base1D1DFunction ()
 Destructor. More...
 
double minDomainValue () const
 Returns the minimum value of the domain of the (one-dimensional) function. More...
 
double maxDomainValue () const
 Returns the maximum value of the domain of the (one-dimensional) function. More...
 
virtual double multiplyAndIntegrate (const Base1D1DFunction &func, unsigned int quadratureOrder, double *resultWithMultiplicationByTAsWell) const
 TODO: Multiplies this function with function, and integrates it numerically. See template specialization. More...
 

Protected Attributes

unsigned int m_numRefValues
 Number of points which will be evaluated. More...
 
std::vector< double > m_referenceDomainValues
 Reference values in the piecewise-linear function domain; \( x_1i \) in \( f_i(x) = y_{1i} + m_i (x - x_{1i})\), for each \( i \)=1 .. m_numRefValues. More...
 
std::vector< double > m_referenceImageValues
 Reference values in the piecewise-linear function image; \( y_{1i} \) in \( f_i(x) = y_{1i} + m_i (x - x_{1i})\), for each \( i \)=1 .. m_numRefValues. More...
 
std::vector< double > m_rateValues
 Rate value; \( m_i \) in \( f_i(x) = y_{1i} + m_i (x - x_{1i})\), for each \( i \)=1 .. m_numRefValues. More...
 
- Protected Attributes inherited from QUESO::Base1D1DFunction
double m_minDomainValue
 
double m_maxDomainValue
 

Detailed Description

Class for piecewise-linear one-dimensional functions.

This class implements piecewise-linear one-dimensional functions.

Definition at line 237 of file 1D1DFunction.h.

Constructor & Destructor Documentation

QUESO::PiecewiseLinear1D1DFunction::PiecewiseLinear1D1DFunction ( double  minDomainValue,
double  maxDomainValue,
const std::vector< double > &  referenceDomainValues,
double  referenceImageValue0,
const std::vector< double > &  rateValues 
)

Default constructor.

Definition at line 239 of file 1D1DFunction.C.

References m_numRefValues, m_rateValues, m_referenceDomainValues, m_referenceImageValues, QUESO::queso_require_equal_to_msg, and QUESO::queso_require_not_equal_to_msg.

245  :
247  m_numRefValues (referenceDomainValues.size()),
248  m_referenceDomainValues(referenceDomainValues),
249  m_rateValues (rateValues)
250 {
251  queso_require_not_equal_to_msg(m_numRefValues, 0, "num ref values = 0");
252 
253  queso_require_equal_to_msg(m_numRefValues, rateValues.size(), "num rate values is inconsistent");
254 
255  for (unsigned int i = 1; i < m_numRefValues; ++i) { // Yes, from '1'
256  queso_require_greater_msg(m_referenceDomainValues[i], m_referenceDomainValues[i-1], "reference domain values are inconsistent");
257  }
258 
259  m_referenceImageValues.clear();
260  m_referenceImageValues.resize(m_numRefValues,0.);
261  m_referenceImageValues[0] = referenceImageValue0;
262  for (unsigned int i = 1; i < m_numRefValues; ++i) { // Yes, from '1'
264  }
265 
266  if (false) { // For debug only
267  std::cout << "In PiecewiseLinear1D1DFunction::constructor():"
268  << std::endl;
269  for (unsigned int i = 0; i < m_numRefValues; ++i) {
270  std::cout << "i = " << i
271  << ", m_referenceDomainValues[i] = " << m_referenceDomainValues[i]
272  << ", m_referenceImageValues[i] = " << m_referenceImageValues[i]
273  << ", m_rateValues[i] = " << m_rateValues[i]
274  << std::endl;
275  }
276  }
277 }
std::vector< double > m_rateValues
Rate value; in , for each =1 .. m_numRefValues.
Definition: 1D1DFunction.h:277
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix queso_require_not_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the absence of an options input file"))
unsigned int m_numRefValues
Number of points which will be evaluated.
Definition: 1D1DFunction.h:268
double maxDomainValue() const
Returns the maximum value of the domain of the (one-dimensional) function.
Definition: 1D1DFunction.C:54
double minDomainValue() const
Returns the minimum value of the domain of the (one-dimensional) function.
Definition: 1D1DFunction.C:48
Base1D1DFunction(double minDomainValue, double maxDomainValue)
Default constructor.
Definition: 1D1DFunction.C:33
std::vector< double > m_referenceDomainValues
Reference values in the piecewise-linear function domain; in , for each =1 .. m_numRefValues.
Definition: 1D1DFunction.h:271
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
std::vector< double > m_referenceImageValues
Reference values in the piecewise-linear function image; in , for each =1 .. m_numRefValues.
Definition: 1D1DFunction.h:274
QUESO::PiecewiseLinear1D1DFunction::~PiecewiseLinear1D1DFunction ( )

Destructor.

Definition at line 279 of file 1D1DFunction.C.

References m_rateValues, m_referenceDomainValues, and m_referenceImageValues.

280 {
281  m_rateValues.clear();
282  m_referenceImageValues.clear();
283  m_referenceDomainValues.clear();
284 }
std::vector< double > m_rateValues
Rate value; in , for each =1 .. m_numRefValues.
Definition: 1D1DFunction.h:277
std::vector< double > m_referenceDomainValues
Reference values in the piecewise-linear function domain; in , for each =1 .. m_numRefValues.
Definition: 1D1DFunction.h:271
std::vector< double > m_referenceImageValues
Reference values in the piecewise-linear function image; in , for each =1 .. m_numRefValues.
Definition: 1D1DFunction.h:274

Member Function Documentation

double QUESO::PiecewiseLinear1D1DFunction::deriv ( double  domainValue) const
virtual

Returns the value of the derivative of the piecewise-linear function at point domainValue.

This function checks if point domainValue belongs to the domain of this function, and in affirmative case, it returns the value of the derivative at such point.

Implements QUESO::Base1D1DFunction.

Definition at line 334 of file 1D1DFunction.C.

References QUESO::Base1D1DFunction::m_maxDomainValue, QUESO::Base1D1DFunction::m_minDomainValue, m_numRefValues, m_rateValues, and m_referenceDomainValues.

335 {
336  if ((domainValue < m_minDomainValue) || (domainValue > m_maxDomainValue)) {
337  std::cerr << "In PiecewiseLinear1D1DFunction::deriv()"
338  << ": requested x (" << domainValue
339  << ") is out of the interval (" << m_minDomainValue
340  << ", " << m_maxDomainValue
341  << ")"
342  << std::endl;
343  }
344 
345  queso_require_msg(!((domainValue < m_minDomainValue) || (domainValue > m_maxDomainValue)), "x out of range");
346 
347  unsigned int i = 0;
348  if (m_numRefValues == 1) {
349  // Nothing else to do
350  }
351  else {
352  bool referenceDomainValueFound = false;
353  while (referenceDomainValueFound == false) {
354  if (domainValue < m_referenceDomainValues[i+1]) {
355  referenceDomainValueFound = true;
356  }
357  else {
358  ++i;
359  queso_require_less_equal_msg(i, m_numRefValues, "too big 'i'");
360  }
361  }
362  }
363 
364  return m_rateValues[i];
365 }
std::vector< double > m_rateValues
Rate value; in , for each =1 .. m_numRefValues.
Definition: 1D1DFunction.h:277
unsigned int m_numRefValues
Number of points which will be evaluated.
Definition: 1D1DFunction.h:268
std::vector< double > m_referenceDomainValues
Reference values in the piecewise-linear function domain; in , for each =1 .. m_numRefValues.
Definition: 1D1DFunction.h:271
double QUESO::PiecewiseLinear1D1DFunction::value ( double  domainValue) const
virtual

Returns the value of the piecewise-linear function at point domainValue.

This function checks if point domainValue belongs to the domain of this function, and in affirmative case, it evaluates the function at such point.

Implements QUESO::Base1D1DFunction.

Definition at line 287 of file 1D1DFunction.C.

References QUESO::Base1D1DFunction::m_maxDomainValue, QUESO::Base1D1DFunction::m_minDomainValue, m_numRefValues, m_rateValues, m_referenceDomainValues, and m_referenceImageValues.

288 {
289  if ((domainValue < m_minDomainValue) || (domainValue > m_maxDomainValue)) {
290  std::cerr << "In PiecewiseLinear1D1DFunction::value()"
291  << ": requested x (" << domainValue
292  << ") is out of the interval (" << m_minDomainValue
293  << ", " << m_maxDomainValue
294  << ")"
295  << std::endl;
296  }
297 
298  queso_require_msg(!((domainValue < m_minDomainValue) || (domainValue > m_maxDomainValue)), "x out of range");
299 
300  unsigned int i = 0;
301  if (m_numRefValues == 1) {
302  // Nothing else to do
303  }
304  else {
305  bool referenceDomainValueFound = false;
306  while (referenceDomainValueFound == false) {
307  if (domainValue < m_referenceDomainValues[i+1]) {
308  referenceDomainValueFound = true;
309  }
310  else {
311  ++i;
312  if (i == (m_numRefValues-1)) {
313  referenceDomainValueFound = true;
314  }
315  }
316  }
317  }
318  double imageValue = m_referenceImageValues[i] + m_rateValues[i]*(domainValue - m_referenceDomainValues[i]);
319  if (false) { // For debug only
320  std::cout << "In PiecewiseLinear1D1DFunction::value()"
321  << ": domainValue = " << domainValue
322  << ", i = " << i
323  << ", m_referenceDomainValues[i] = " << m_referenceDomainValues[i]
324  << ", m_referenceImageValues[i] = " << m_referenceImageValues[i]
325  << ", m_rateValues[i] = " << m_rateValues[i]
326  << ", imageValue = " << imageValue
327  << std::endl;
328  }
329 
330  return imageValue;
331 }
std::vector< double > m_rateValues
Rate value; in , for each =1 .. m_numRefValues.
Definition: 1D1DFunction.h:277
unsigned int m_numRefValues
Number of points which will be evaluated.
Definition: 1D1DFunction.h:268
std::vector< double > m_referenceDomainValues
Reference values in the piecewise-linear function domain; in , for each =1 .. m_numRefValues.
Definition: 1D1DFunction.h:271
std::vector< double > m_referenceImageValues
Reference values in the piecewise-linear function image; in , for each =1 .. m_numRefValues.
Definition: 1D1DFunction.h:274

Member Data Documentation

unsigned int QUESO::PiecewiseLinear1D1DFunction::m_numRefValues
protected

Number of points which will be evaluated.

Definition at line 268 of file 1D1DFunction.h.

Referenced by deriv(), PiecewiseLinear1D1DFunction(), and value().

std::vector<double> QUESO::PiecewiseLinear1D1DFunction::m_rateValues
protected

Rate value; \( m_i \) in \( f_i(x) = y_{1i} + m_i (x - x_{1i})\), for each \( i \)=1 .. m_numRefValues.

Definition at line 277 of file 1D1DFunction.h.

Referenced by deriv(), PiecewiseLinear1D1DFunction(), value(), and ~PiecewiseLinear1D1DFunction().

std::vector<double> QUESO::PiecewiseLinear1D1DFunction::m_referenceDomainValues
protected

Reference values in the piecewise-linear function domain; \( x_1i \) in \( f_i(x) = y_{1i} + m_i (x - x_{1i})\), for each \( i \)=1 .. m_numRefValues.

Definition at line 271 of file 1D1DFunction.h.

Referenced by deriv(), PiecewiseLinear1D1DFunction(), value(), and ~PiecewiseLinear1D1DFunction().

std::vector<double> QUESO::PiecewiseLinear1D1DFunction::m_referenceImageValues
protected

Reference values in the piecewise-linear function image; \( y_{1i} \) in \( f_i(x) = y_{1i} + m_i (x - x_{1i})\), for each \( i \)=1 .. m_numRefValues.

Definition at line 274 of file 1D1DFunction.h.

Referenced by PiecewiseLinear1D1DFunction(), value(), and ~PiecewiseLinear1D1DFunction().


The documentation for this class was generated from the following files:

Generated on Tue Jun 5 2018 19:49:16 for queso-0.57.1 by  doxygen 1.8.5