queso-0.53.0
Protected Attributes | List of all members
QUESO::LagrangeBasis1D1DFunction Class Reference

Class for Lagrange polynomial basis. More...

#include <1D1DFunction.h>

Inheritance diagram for QUESO::LagrangeBasis1D1DFunction:
Inheritance graph
[legend]
Collaboration diagram for QUESO::LagrangeBasis1D1DFunction:
Collaboration graph
[legend]

Public Member Functions

Constructor/Destructor methods
 LagrangeBasis1D1DFunction (const std::vector< double > &positionValues, unsigned int basisIndex)
 Default constructor. More...
 
 ~LagrangeBasis1D1DFunction ()
 Destructor. More...
 
Mathematical methods
double value (double domainValue) const
 Returns the value of the Lagrange basis at point domainValue. More...
 
double deriv (double domainValue) const
 TODO: Returns the value of the derivative of the Lagrange basis 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

std::vector< double > m_positionValues
 
unsigned int m_basisIndex
 
- Protected Attributes inherited from QUESO::Base1D1DFunction
double m_minDomainValue
 
double m_maxDomainValue
 

Detailed Description

Class for Lagrange polynomial basis.

Given a set of $ k+1 $ data points $(x_0, y_0),\ldots,(x_j, y_j),\ldots,(x_k, y_k)$ where no two $ x_j $ are the same, the interpolation polynomial in the Lagrange form is a linear combination

\[ L(x) = \sum_{j=0}^{k} y_j \ell_j(x) \]

of Lagrange basis polynomials

\[ \ell_j(x) = \prod_{0\le m\le k;\, m\neq j} \frac{x-x_m}{x_j-x_m} = \frac{(x-x_0)}{(x_j-x_0)} \cdots \frac{(x-x_{j-1})}{(x_j-x_{j-1})} \frac{(x-x_{j+1})}{(x_j-x_{j+1})} \cdots \frac{(x-x_k)}{(x_j-x_k)},\]

where $ 0\le j\le k $.
This class implements the one-dimensional function (Lagrange basis) $ \ell_j(x) $. In this class, the array std::vector<double>& positionValues stores the points $ x_1, x_2, ... x_n $ and the index $ j $ is stored in basisIndex.

Definition at line 609 of file 1D1DFunction.h.

Constructor & Destructor Documentation

QUESO::LagrangeBasis1D1DFunction::LagrangeBasis1D1DFunction ( const std::vector< double > &  positionValues,
unsigned int  basisIndex 
)

Default constructor.

Definition at line 820 of file 1D1DFunction.C.

References m_basisIndex, m_positionValues, and queso_require_less_msg.

823  :
824  Base1D1DFunction(-INFINITY,INFINITY),
825  m_positionValues(positionValues),
826  m_basisIndex (basisIndex)
827 {
828  queso_require_less_msg(m_basisIndex, m_positionValues.size(), "invalid input");
829 }
#define queso_require_less_msg(expr1, expr2, msg)
Definition: asserts.h:87
Base1D1DFunction(double minDomainValue, double maxDomainValue)
Default constructor.
Definition: 1D1DFunction.C:33
std::vector< double > m_positionValues
Definition: 1D1DFunction.h:635
QUESO::LagrangeBasis1D1DFunction::~LagrangeBasis1D1DFunction ( )

Destructor.

Definition at line 831 of file 1D1DFunction.C.

832 {
833 }

Member Function Documentation

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

TODO: Returns the value of the derivative of the Lagrange basis at point domainValue.

Todo:
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 853 of file 1D1DFunction.C.

References QUESO::Base1D1DFunction::m_maxDomainValue, QUESO::Base1D1DFunction::m_minDomainValue, queso_not_implemented, queso_require_msg, and value().

854 {
855  double value = 0.;
856 
857  if ((domainValue < m_minDomainValue) || (domainValue > m_maxDomainValue)) {
858  std::cerr << "In LagrangeBasis1D1DFunction::deriv()"
859  << ": requested x (" << domainValue
860  << ") is out of the interval (" << m_minDomainValue
861  << ", " << m_maxDomainValue
862  << ")"
863  << std::endl;
864  }
865 
866  queso_require_msg(!((domainValue < m_minDomainValue) || (domainValue > m_maxDomainValue)), "x out of range");
867 
869 
870  return value;
871 }
double value(double domainValue) const
Returns the value of the Lagrange basis at point domainValue.
Definition: 1D1DFunction.C:836
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
#define queso_not_implemented()
Definition: asserts.h:56
double QUESO::LagrangeBasis1D1DFunction::value ( double  domainValue) const
virtual

Returns the value of the Lagrange basis at point domainValue.

Implements QUESO::Base1D1DFunction.

Definition at line 836 of file 1D1DFunction.C.

References k, m_basisIndex, and m_positionValues.

Referenced by deriv().

837 {
838  double scaleFactor = 1.;
839 
840  unsigned int k = m_basisIndex;
841  double posK = m_positionValues[k];
842  for (unsigned int j = 0; j < m_positionValues.size(); ++j) {
843  if (j != k) {
844  double posJ = m_positionValues[j];
845  scaleFactor *= (domainValue-posJ)/(posK-posJ);
846  }
847  }
848 
849  return scaleFactor;
850 }
std::vector< double > m_positionValues
Definition: 1D1DFunction.h:635
int k
Definition: ann_sample.cpp:53

Member Data Documentation

unsigned int QUESO::LagrangeBasis1D1DFunction::m_basisIndex
protected

Definition at line 636 of file 1D1DFunction.h.

Referenced by LagrangeBasis1D1DFunction(), and value().

std::vector<double> QUESO::LagrangeBasis1D1DFunction::m_positionValues
protected

Definition at line 635 of file 1D1DFunction.h.

Referenced by LagrangeBasis1D1DFunction(), and value().


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

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