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
65 queso_require_msg(m_valueRoutinePtr,
"m_valueRoutinePtr = NULL");
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))
75 queso_not_implemented();
81 template<
class V,
class M>
83 const V* domainDirection,
86 V* hessianEffect)
const
88 queso_require_msg(m_valueRoutinePtr,
"m_valueRoutinePtr = NULL");
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))
98 queso_not_implemented();
virtual ~GenericScalarFunction()
Virtual destructor.
A templated (base) class for handling scalar functions.
double lnValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
Calculates the logarithm of value of this scalar function.
A templated class for handling sets.
double actualValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
Calculates the actual value of this scalar function.
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.
A class for handling generic scalar functions.