queso-0.51.1
Protected Attributes | List of all members
QUESO::GenericScalarFunction< V, M > Class Template Reference

A class for handling generic scalar functions. More...

#include <GenericScalarFunction.h>

Inheritance diagram for QUESO::GenericScalarFunction< V, M >:
Inheritance graph
[legend]
Collaboration diagram for QUESO::GenericScalarFunction< V, M >:
Collaboration graph
[legend]

Public Member Functions

Constructor/Destructor methods
 GenericScalarFunction (const char *prefix, const VectorSet< V, M > &domainSet, double(*valueRoutinePtr)(const V &domainVector, const V *domainDirection, const void *routinesDataPtr, V *gradVector, M *hessianMatrix, V *hessianEffect), const void *routinesDataPtr, bool routineIsForLn)
 Default constructor. More...
 
virtual ~GenericScalarFunction ()
 Virtual destructor. More...
 
Mathematical method
double actualValue (const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
 Calculates the actual value of this scalar function. More...
 
double lnValue (const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
 Calculates the logarithm of value of this scalar function. More...
 
- Public Member Functions inherited from QUESO::BaseScalarFunction< V, M >
 BaseScalarFunction (const char *prefix, const VectorSet< V, M > &domainSet)
 Default constructor. More...
 
virtual ~BaseScalarFunction ()
 Destructor. More...
 
const VectorSet< V, M > & domainSet () const
 Access to the protected attribute m_domainSet: domain set of the scalar function. More...
 

Protected Attributes

double(* m_valueRoutinePtr )(const V &domainVector, const V *domainDirection, const void *routinesDataPtr, V *gradVector, M *hessianMatrix, V *hessianEffect)
 Routine defining a scalar function. More...
 
const void * m_routinesDataPtr
 
bool m_routineIsForLn
 
- Protected Attributes inherited from QUESO::BaseScalarFunction< V, M >
const BaseEnvironmentm_env
 
std::string m_prefix
 
const VectorSet< V, M > & m_domainSet
 Domain set of the scalar function. More...
 

Detailed Description

template<class V, class M>
class QUESO::GenericScalarFunction< V, M >

A class for handling generic scalar functions.

This class allows the mathematical definition of a scalar function such as: $ f: B \subset R \rightarrow R $. It is derived from BaseScalarFunction.

Definition at line 43 of file GenericScalarFunction.h.

Constructor & Destructor Documentation

template<class V , class M >
QUESO::GenericScalarFunction< V, M >::GenericScalarFunction ( const char *  prefix,
const VectorSet< V, M > &  domainSet,
double(*)(const V &domainVector, const V *domainDirection, const void *routinesDataPtr, V *gradVector, M *hessianMatrix, V *hessianEffect)  valueRoutinePtr,
const void *  routinesDataPtr,
bool  routineIsForLn 
)

Default constructor.

Instantiates an object of this class given its prefix, domain set and a pointer to a routine. This routine plays the role of a scalar math function, and it is useful, for instance, to calculate the likelihood (and its image set).

Definition at line 39 of file GenericScalarFunction.C.

44  : BaseScalarFunction<V,M>(((std::string)(prefix)+"gen").c_str(), domainSet),
45  m_valueRoutinePtr (valueRoutinePtr),
46  m_routinesDataPtr (routinesDataPtr),
47  m_routineIsForLn (routineIsForLn)
48 {
49 }
const VectorSet< V, M > & domainSet() const
Access to the protected attribute m_domainSet: domain set of the scalar function. ...
double(* m_valueRoutinePtr)(const V &domainVector, const V *domainDirection, const void *routinesDataPtr, V *gradVector, M *hessianMatrix, V *hessianEffect)
Routine defining a scalar function.
template<class V , class M >
QUESO::GenericScalarFunction< V, M >::~GenericScalarFunction ( )
virtual

Virtual destructor.

Definition at line 53 of file GenericScalarFunction.C.

54 {
55 }

Member Function Documentation

template<class V , class M >
double QUESO::GenericScalarFunction< V, M >::actualValue ( const V &  domainVector,
const V *  domainDirection,
V *  gradVector,
M *  hessianMatrix,
V *  hessianEffect 
) const
virtual

Calculates the actual value of this scalar function.

Implements QUESO::BaseScalarFunction< V, M >.

Definition at line 59 of file GenericScalarFunction.C.

References UQ_FATAL_TEST_MACRO.

64 {
66  m_env.worldRank(),
67  "GenericScalarFunction<V,M>::actualValue()",
68  "m_valueRoutinePtr = NULL");
69 
70  double value = m_valueRoutinePtr(domainVector, domainDirection, m_routinesDataPtr, gradVector, hessianMatrix, hessianEffect);
71  if (m_routineIsForLn) {
72  value = std::exp(value);
73  UQ_FATAL_TEST_MACRO((domainDirection != NULL) ||
74  (gradVector != NULL) ||
75  (hessianMatrix != NULL) ||
76  (hessianEffect != NULL),
77  m_env.worldRank(),
78  "GenericScalarFunction<V,M>::gradOfActual()",
79  "INCOMPLETE CODE");
80  }
81  return value;
82 }
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
const BaseEnvironment & m_env
double(* m_valueRoutinePtr)(const V &domainVector, const V *domainDirection, const void *routinesDataPtr, V *gradVector, M *hessianMatrix, V *hessianEffect)
Routine defining a scalar function.
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
template<class V , class M >
double QUESO::GenericScalarFunction< V, M >::lnValue ( const V &  domainVector,
const V *  domainDirection,
V *  gradVector,
M *  hessianMatrix,
V *  hessianEffect 
) const
virtual

Calculates the logarithm of value of this scalar function.

It is used in routines that calculate the likelihood and expect the logarithm of value.

Implements QUESO::BaseScalarFunction< V, M >.

Definition at line 86 of file GenericScalarFunction.C.

References UQ_FATAL_TEST_MACRO.

91 {
93  m_env.worldRank(),
94  "GenericScalarFunction<V,M>::lnValue()",
95  "m_valueRoutinePtr = NULL");
96 
97  double value = m_valueRoutinePtr(domainVector, domainDirection, m_routinesDataPtr, gradVector, hessianMatrix, hessianEffect);
98  if (m_routineIsForLn == false) {
99  value = log(value);
100  UQ_FATAL_TEST_MACRO((domainDirection != NULL) ||
101  (gradVector != NULL) ||
102  (hessianMatrix != NULL) ||
103  (hessianEffect != NULL),
104  m_env.worldRank(),
105  "GenericScalarFunction<V,M>::gradOfLn()",
106  "INCOMPLETE CODE");
107  }
108  return value;
109 }
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
const BaseEnvironment & m_env
double(* m_valueRoutinePtr)(const V &domainVector, const V *domainDirection, const void *routinesDataPtr, V *gradVector, M *hessianMatrix, V *hessianEffect)
Routine defining a scalar function.
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223

Member Data Documentation

template<class V , class M >
bool QUESO::GenericScalarFunction< V, M >::m_routineIsForLn
protected

Definition at line 80 of file GenericScalarFunction.h.

template<class V , class M >
const void* QUESO::GenericScalarFunction< V, M >::m_routinesDataPtr
protected

Definition at line 79 of file GenericScalarFunction.h.

template<class V , class M >
double(* QUESO::GenericScalarFunction< V, M >::m_valueRoutinePtr)(const V &domainVector, const V *domainDirection, const void *routinesDataPtr, V *gradVector, M *hessianMatrix, V *hessianEffect)
protected

Routine defining a scalar function.

The presence of the parameters gradVectors, hessianMatrices and hessianEffects allows the user to calculate gradient vectors, Hessian matrices and Hessian effects; which can hold important information about her/his statistical application. Used, for instance to define the likelihood.

Definition at line 78 of file GenericScalarFunction.h.


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