queso-0.51.1
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 913 of file 1D1DFunction.C.

References m_basisIndex, m_positionValues, UQ_FATAL_TEST_MACRO, and QUESO::UQ_UNAVAILABLE_RANK.

916  :
917  Base1D1DFunction(-INFINITY,INFINITY),
918  m_positionValues(positionValues),
919  m_basisIndex (basisIndex)
920 {
923  "LagrangeBasis1D1DFunction::constructor()",
924  "invalid input");
925 }
Base1D1DFunction(double minDomainValue, double maxDomainValue)
Default constructor.
Definition: 1D1DFunction.C:33
const int UQ_UNAVAILABLE_RANK
Definition: Defines.h:74
std::vector< double > m_positionValues
Definition: 1D1DFunction.h:635
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
QUESO::LagrangeBasis1D1DFunction::~LagrangeBasis1D1DFunction ( )

Destructor.

Definition at line 927 of file 1D1DFunction.C.

928 {
929 }

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 949 of file 1D1DFunction.C.

References QUESO::Base1D1DFunction::m_maxDomainValue, QUESO::Base1D1DFunction::m_minDomainValue, UQ_FATAL_TEST_MACRO, QUESO::UQ_UNAVAILABLE_RANK, and value().

950 {
951  double value = 0.;
952 
953  if ((domainValue < m_minDomainValue) || (domainValue > m_maxDomainValue)) {
954  std::cerr << "In LagrangeBasis1D1DFunction::deriv()"
955  << ": requested x (" << domainValue
956  << ") is out of the interval (" << m_minDomainValue
957  << ", " << m_maxDomainValue
958  << ")"
959  << std::endl;
960  }
961 
962  UQ_FATAL_TEST_MACRO(((domainValue < m_minDomainValue) || (domainValue > m_maxDomainValue)),
964  "LagrangeBasis1D1DFunction::deriv()",
965  "x out of range");
966 
967  UQ_FATAL_TEST_MACRO(true,
969  "LagrangeBasis1D1DFunction::deriv()",
970  "not implemented yet");
971 
972  return value;
973 }
double value(double domainValue) const
Returns the value of the Lagrange basis at point domainValue.
Definition: 1D1DFunction.C:932
const int UQ_UNAVAILABLE_RANK
Definition: Defines.h:74
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
double QUESO::LagrangeBasis1D1DFunction::value ( double  domainValue) const
virtual

Returns the value of the Lagrange basis at point domainValue.

Implements QUESO::Base1D1DFunction.

Definition at line 932 of file 1D1DFunction.C.

References m_basisIndex, and m_positionValues.

Referenced by deriv().

933 {
934  double scaleFactor = 1.;
935 
936  unsigned int k = m_basisIndex;
937  double posK = m_positionValues[k];
938  for (unsigned int j = 0; j < m_positionValues.size(); ++j) {
939  if (j != k) {
940  double posJ = m_positionValues[j];
941  scaleFactor *= (domainValue-posJ)/(posK-posJ);
942  }
943  }
944 
945  return scaleFactor;
946 }
std::vector< double > m_positionValues
Definition: 1D1DFunction.h:635

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 Apr 23 2015 19:26:17 for queso-0.51.1 by  doxygen 1.8.5