Program Listing for File SumDerivatives.h

Return to documentation for file (/home/kpenev/projects/git/poet/poet_src/StellarEvolution/SumDerivatives.h)

#ifndef __SUM_DERIVATIVES_H
#define __SUM_DERIVATIVES_H

#include "../Core/SharedLibraryExportMacros.h"
#include "../Core/Functions.h"

namespace StellarEvolution {

    class LIB_LOCAL SumDerivatives : public FunctionDerivatives {
    private:
        const FunctionDerivatives *q1_deriv,

              *q2_deriv;

        bool destroy_derivs;
    public:
        SumDerivatives(
            const FunctionDerivatives *derivative1,

            const FunctionDerivatives *derivative2,

            bool delete_inputs=true)
            : q1_deriv(derivative1), q2_deriv(derivative2),
            destroy_derivs(delete_inputs) {}

        double order(unsigned deriv_order=1) const
        {return q1_deriv->order(deriv_order)+q2_deriv->order(deriv_order);}

        ~SumDerivatives()
        {if(destroy_derivs) {delete q1_deriv; delete q2_deriv;}}
    }; //End SumDerivatives class declaration.

} //End StellarEvolution namespace.

#endif