queso-0.53.0
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 voidm_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 = GslVector, class M = GslMatrix>
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 46 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 queso_not_implemented, and queso_require_msg.

64 {
65  queso_require_msg(m_valueRoutinePtr, "m_valueRoutinePtr = NULL");
66 
67  double value = m_valueRoutinePtr(domainVector, domainDirection, m_routinesDataPtr, gradVector, hessianMatrix, hessianEffect);
68  if (m_routineIsForLn) {
69  value = std::exp(value);
70 
71  if ((domainDirection != NULL) ||
72  (gradVector != NULL) ||
73  (hessianMatrix != NULL) ||
74  (hessianEffect != NULL))
76  }
77  return value;
78 }
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
#define queso_not_implemented()
Definition: asserts.h:56
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 >
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 82 of file GenericScalarFunction.C.

References queso_not_implemented, and queso_require_msg.

87 {
88  queso_require_msg(m_valueRoutinePtr, "m_valueRoutinePtr = NULL");
89 
90  double value = m_valueRoutinePtr(domainVector, domainDirection, m_routinesDataPtr, gradVector, hessianMatrix, hessianEffect);
91  if (m_routineIsForLn == false) {
92  value = log(value);
93 
94  if ((domainDirection != NULL) ||
95  (gradVector != NULL) ||
96  (hessianMatrix != NULL) ||
97  (hessianEffect != NULL))
99  }
100  return value;
101 }
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
#define queso_not_implemented()
Definition: asserts.h:56
double(* m_valueRoutinePtr)(const V &domainVector, const V *domainDirection, const void *routinesDataPtr, V *gradVector, M *hessianMatrix, V *hessianEffect)
Routine defining a scalar function.

Member Data Documentation

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

Definition at line 83 of file GenericScalarFunction.h.

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

Definition at line 82 of file GenericScalarFunction.h.

template<class V = GslVector, class M = GslMatrix>
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 81 of file GenericScalarFunction.h.


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

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