1 /*! 2 * \file src/Math/Negation.cxx 3 * \brief 4 * 5 * \author Thomas Helfer 6 * \date 04 oct 2007 7 * \copyright Copyright (C) 2006-2018 CEA/DEN, EDF R&D. All rights 8 * reserved. 9 * This project is publicly released under either the GNU GPL Licence 10 * or the CECILL-A licence. A copy of thoses licences are delivered 11 * with the sources of TFEL. CEA or EDF may also distribute this 12 * project under specific licensing conditions. 13 */ 14 15 #include"TFEL/Math/Parser/Negation.hxx" 16 17 namespace tfel 18 { 19 namespace math 20 { 21 22 namespace parser 23 { 24 Negation(const std::shared_ptr<Expr> e)25 Negation::Negation(const std::shared_ptr<Expr> e) 26 : expr(e) 27 {} // end of Negation::Negation 28 getCxxFormula(const std::vector<std::string> & m) const29 std::string Negation::getCxxFormula(const std::vector<std::string>& m) const{ 30 return "-("+this->expr->getCxxFormula(m)+')'; 31 } // end of Negation::getCxxFormula 32 getValue() const33 double Negation::getValue() const 34 { 35 return -(this->expr->getValue()); 36 } // end of Negation::getValue() 37 38 void checkCyclicDependency(std::vector<std::string> & names) const39 Negation::checkCyclicDependency(std::vector<std::string>& names) const 40 { 41 this->expr->checkCyclicDependency(names); 42 } // end of Negation::checkCyclicDependency 43 44 std::shared_ptr<Expr> differentiate(const std::vector<double>::size_type pos,const std::vector<double> & variable) const45 Negation::differentiate(const std::vector<double>::size_type pos, 46 const std::vector<double>& variable) const 47 { 48 using std::shared_ptr; 49 shared_ptr<Expr> e = this->expr->differentiate(pos,variable); 50 return shared_ptr<Expr>(new Negation(e)); 51 } // end of Negation::differentiate 52 53 std::shared_ptr<Expr> clone(const std::vector<double> & v) const54 Negation::clone(const std::vector<double>& v) const 55 { 56 return std::shared_ptr<Expr>(new Negation(this->expr->clone(v))); 57 } 58 59 std::shared_ptr<Expr> createFunctionByChangingParametersIntoVariables(const std::vector<double> & v,const std::vector<std::string> & params,const std::map<std::string,std::vector<double>::size_type> & pos) const60 Negation::createFunctionByChangingParametersIntoVariables(const std::vector<double>& v, 61 const std::vector<std::string>& params, 62 const std::map<std::string, 63 std::vector<double>::size_type>& pos) const 64 { 65 using std::shared_ptr; 66 shared_ptr<Expr> nexpr = this->expr->createFunctionByChangingParametersIntoVariables(v,params,pos); 67 return shared_ptr<Expr>(new Negation(nexpr)); 68 } // end of Negation::createFunctionByChangingParametersIntoVariables 69 70 std::shared_ptr<Expr> resolveDependencies(const std::vector<double> & v) const71 Negation::resolveDependencies(const std::vector<double>& v) const 72 { 73 using std::shared_ptr; 74 return shared_ptr<Expr>(new Negation(this->expr->resolveDependencies(v))); 75 } // end of Negation::resolveDependencies 76 77 void getParametersNames(std::set<std::string> & p) const78 Negation::getParametersNames(std::set<std::string>& p) const 79 { 80 this->expr->getParametersNames(p); 81 } // end of Negation::getParametersNames 82 83 Negation::~Negation() = default; 84 85 } // end of namespace parser 86 87 } // end of namespace math 88 89 } // end of namespace tfel 90 91