27 #include <queso/Defines.h>
28 #include <queso/VectorSet.h>
29 #include <queso/VectorSubset.h>
30 #include <queso/Environment.h>
31 #include <queso/GenericScalarFunction.h>
32 #include <queso/GslVector.h>
33 #include <queso/GslMatrix.h>
38 template<
class V,
class M>
41 double (*valueRoutinePtr)(
const V& domainVector,
const V* domainDirection,
const void* routinesDataPtr, V* gradVector, M* hessianMatrix, V* hessianEffect),
42 const void* routinesDataPtr,
45 m_valueRoutinePtr (valueRoutinePtr),
46 m_routinesDataPtr (routinesDataPtr),
47 m_routineIsForLn (routineIsForLn)
52 template<
class V,
class M>
58 template<
class V,
class M>
60 const V* domainDirection,
63 V* hessianEffect)
const
67 double value = m_valueRoutinePtr(domainVector, domainDirection, m_routinesDataPtr, gradVector, hessianMatrix, hessianEffect);
68 if (m_routineIsForLn) {
69 value = std::exp(value);
71 if ((domainDirection != NULL) ||
72 (gradVector != NULL) ||
73 (hessianMatrix != NULL) ||
74 (hessianEffect != NULL))
81 template<
class V,
class M>
83 const V* domainDirection,
86 V* hessianEffect)
const
90 double value = m_valueRoutinePtr(domainVector, domainDirection, m_routinesDataPtr, gradVector, hessianMatrix, hessianEffect);
91 if (m_routineIsForLn ==
false) {
94 if ((domainDirection != NULL) ||
95 (gradVector != NULL) ||
96 (hessianMatrix != NULL) ||
97 (hessianEffect != NULL))
A templated class for handling sets.
A class for handling generic scalar functions.
double actualValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
Calculates the actual value of this scalar function.
A templated (base) class for handling scalar functions.
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.
#define queso_require_msg(asserted, msg)
#define queso_not_implemented()
virtual ~GenericScalarFunction()
Virtual destructor.
double lnValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
Calculates the logarithm of value of this scalar function.