// This file is part of Bertini 2. // // differential.hpp is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or //(at your option) any later version. // // differential.hpp is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with differential.hpp. If not, see . // // Copyright(C) 2015 - 2021 by Bertini2 Development Team // // See for a copy of the license, // as well as COPYING. Bertini2 is provided with permitted // additional terms in the b2/licenses/ directory. // individual authors of this file include: // James Collins // West Texas A&M University // Spring, Summer 2015 // // silviana amethyst, university of wisconsin-eau claire // // Created by Collins, James B. on 4/30/15. // // // differential.hpp: Declares the class SpecialNumber. /** \file differential.hpp \brief Provides the differential Node class. */ #ifndef BERTINI_NODE_DIFFERENTIAL_HPP #define BERTINI_NODE_DIFFERENTIAL_HPP #include #include "function_tree/node.hpp" #include "function_tree/symbols/number.hpp" #include "function_tree/symbols/symbol.hpp" namespace bertini { namespace node { class Variable; /** \brief Provides the differential type for differentiation of expression trees. This class represents differentials. These are produced in the course of differentiation of a non-constant expression tree. */ class Differential : public virtual NamedSymbol, public virtual EnableSharedFromThisVirtual { public: BERTINI_DEFAULT_VISITABLE() template static std::shared_ptr Make(Ts&&... ts) { return std::shared_ptr(new Differential(ts...)); } private: /** Input shared_ptr to a Variable. */ Differential(std::shared_ptr diff_variable, std::string var_name); public: void Reset() const override; const std::shared_ptr& GetVariable() const; void print(std::ostream& target) const override; /** Differentiates a number. */ std::shared_ptr Differentiate( std::shared_ptr const& v = nullptr) const override; virtual ~Differential() = default; /** Compute the degree with respect to a single variable. For differentials, the degree is 0. */ int Degree(std::shared_ptr const& v = nullptr) const override; int Degree(VariableGroup const& vars) const override; std::vector MultiDegree(VariableGroup const& vars) const override; void Homogenize(VariableGroup const& vars, std::shared_ptr const& homvar) override; bool IsHomogeneous( std::shared_ptr const& v = nullptr) const override; /** Check for homogeneity, with respect to a variable group. */ bool IsHomogeneous(VariableGroup const& vars) const override; /** Change the precision of this variable-precision tree node. \param prec the number of digits to change precision to. */ void precision(unsigned int prec) const override; protected: // This should never be called for a Differential. Only for Jacobians. dbl FreshEval_d( std::shared_ptr const& diff_variable) const override; void FreshEval_d( dbl& evaluation_value, std::shared_ptr const& diff_variable) const override; mpfr_complex FreshEval_mp( std::shared_ptr const& diff_variable) const override; void FreshEval_mp( mpfr_complex& evaluation_value, std::shared_ptr const& diff_variable) const override; private: Differential() = default; std::shared_ptr differential_variable_; friend class boost::serialization::access; template void save(Archive& ar, const unsigned int version) const { ar& boost::serialization::base_object(*this); ar & differential_variable_; // ar & const_cast // >(differential_variable_); } template void load(Archive& ar, const unsigned int version) { ar& boost::serialization::base_object(*this); ar& std::const_pointer_cast(differential_variable_); } // BOOST_SERIALIZATION_SPLIT_MEMBER() }; } // namespace node } // namespace bertini #endif