7 #include "GeoGenericFunctions/FunctionComposition.h" 11 FUNCTION_OBJECT_IMP(FunctionComposition)
13 FunctionComposition::FunctionComposition(const AbsFunction *arg1, const AbsFunction *arg2):_arg1(arg1->clone()),_arg2(arg2->clone())
15 if (arg1->dimensionality()!=1) {
16 throw std::runtime_error(
"Dimension mismatch in function composition");
20 FunctionComposition::FunctionComposition(
const FunctionComposition & right):
22 _arg1(right._arg1->clone()),
23 _arg2(right._arg2->clone())
26 FunctionComposition::~FunctionComposition()
32 unsigned int FunctionComposition::dimensionality()
const {
33 return _arg2->dimensionality();
36 double FunctionComposition::operator ()(
double argument)
const {
37 if (dimensionality()!=1) {
38 throw std::runtime_error(
"FunctionComposition: dimension mismatch");
42 return (*_arg1)((*_arg2)(argument));
46 double FunctionComposition::operator() (
const Argument & v)
const {
47 if (v.dimension()!=_arg2->dimensionality()) {
48 throw std::runtime_error(
"FunctionComposition: dimension mismatch");
52 return (*_arg1)((*_arg2)(v));
57 Derivative FunctionComposition::partial(
unsigned int index)
const {
58 const Derivative & d1=_arg1->partial(0);
59 const Derivative & d2=_arg2->partial(index);
60 const AbsFunction & fPrime = d1(*_arg2)*d2;
61 return Derivative(&fPrime);