Skip to content
Snippets Groups Projects
Select Git revision
21 results Searching

CodeInterpreter.hh

Blame
  • Forked from Dynare / dynare
    Source project has a limited visibility.
    ModelTree.cc 191.54 KiB
    /*
     * Copyright (C) 2003-2008 Dynare Team
     *
     * This file is part of Dynare.
     *
     * Dynare 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.
     *
     * Dynare 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 Dynare.  If not, see <http://www.gnu.org/licenses/>.
     */
    
    #include <iostream>
    #include <fstream>
    #include <sstream>
    
    #include <cmath>
    
    #include "ModelTree.hh"
    #include "Interface.hh"
    
    #include "Model_Graph.hh"
    
    ModelTree::ModelTree(SymbolTable &symbol_table_arg,
                         NumericalConstants &num_constants_arg) :
      DataTree(symbol_table_arg, num_constants_arg),
      mode(eStandardMode),
      compiler(NO_COMPILE),
      cutoff(1e-12),
      markowitz(0.7),
      new_SGE(true),
      computeJacobian(false),
      computeJacobianExo(false),
      computeHessian(false),
      computeStaticHessian(false),
      computeThirdDerivatives(false),
      block_triangular(symbol_table_arg)
    {
    }
    
    int
    ModelTree::equation_number() const
    {
      return(equations.size());
    }
    
    void
    ModelTree::writeDerivative(ostream &output, int eq, int symb_id, int lag,
                               ExprNodeOutputType output_type,
                               const temporary_terms_type &temporary_terms) const
    {
      first_derivatives_type::const_iterator it = first_derivatives.find(make_pair(eq, variable_table.getID(eEndogenous, symb_id, lag)));
      if (it != first_derivatives.end())
        (it->second)->writeOutput(output, output_type, temporary_terms);
      else
        output << 0;
    }
    
    void
    ModelTree::compileDerivative(ofstream &code_file, int eq, int symb_id, int lag, ExprNodeOutputType output_type, map_idx_type map_idx) const
    {
      first_derivatives_type::const_iterator it = first_derivatives.find(make_pair(eq, variable_table.getID(eEndogenous, symb_id, lag)));
      if (it != first_derivatives.end())