/* Example programs from the book Scientific and Engineering Programming in C++: An Introduction with Advanced Techniques and Examples, Addison-Wesley, 1994. (c) COPYRIGHT INTERNATIONAL BUSINESS MACHINES CORPORATION 1994. ALL RIGHTS RESERVED. See README file for further details. */ #ifndef UnaryFunctionalH #define UnaryFunctionalH #include "Function/Functional.h" #include "SciEng/Ptrs.h" #include "Algebra/BuiltinInverse.h" template class UnaryFunctional { public: UnaryFunctional(const CloneableObjPtr< IsoFunctional >& lhs): the_lhs(lhs){ } const IsoFunctional& lhs() const { return *the_lhs;} private: CloneableObjPtr< IsoFunctional > the_lhs; }; template class AdditiveInverseFunctional : public virtual IsoFunctional, private UnaryFunctional { public: AdditiveInverseFunctional(const CloneableObjPtr >& lhs): UnaryFunctional(lhs){ } virtual Domain operator()(const Domain& v) const { return -lhs()(v); } virtual AdditiveInverseFunctional* clone() const { return new AdditiveInverseFunctional(*this); } }; template class MultiplicativeInverseFunctional : public virtual IsoFunctional, private UnaryFunctional { public: MultiplicativeInverseFunctional(const CloneableObjPtr >& lhs): UnaryFunctional(lhs){ } virtual Domain operator()(const Domain& v) const { return inverse( lhs()(v) ); } virtual MultiplicativeInverseFunctional* clone() const { return new MultiplicativeInverseFunctional(*this); } }; #endif