Skip to content
Snippets Groups Projects
Select Git revision
  • d0bc8128c7a614bda2eb356cb95c92aa17523cbc
  • master default
  • julia
  • created_preprocessor_repo
4 results

ComputingTasks.cc

Blame
  • Forked from Dynare / preprocessor
    Source project has a limited visibility.
    ExprNode.hh 94.15 KiB
    /*
     * Copyright © 2007-2021 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 <https://www.gnu.org/licenses/>.
     */
    
    #ifndef _EXPR_NODE_HH
    #define _EXPR_NODE_HH
    
    #include <set>
    #include <map>
    #include <vector>
    #include <ostream>
    #include <functional>
    
    using namespace std;
    
    #include "CodeInterpreter.hh"
    #include "ExternalFunctionsTable.hh"
    
    class DataTree;
    class NumConstNode;
    class VariableNode;
    class UnaryOpNode;
    class BinaryOpNode;
    class PacExpectationNode;
    
    using expr_t = class ExprNode *;
    
    struct ExprNodeLess;
    
    //! Type for set of temporary terms
    /*! The ExprNodeLess ordering is important for the temporary terms algorithm,
      see the definition of ExprNodeLess */
    using temporary_terms_t = set<expr_t, ExprNodeLess>;
    /*! Keeps track of array indices of temporary_terms for writing */
    using temporary_terms_idxs_t = map<expr_t, int>;
    
    //! Type for evaluation contexts
    /*! The key is a symbol id. Lags are assumed to be null */
    using eval_context_t = map<int, double>;
    
    //! Type for tracking first/second derivative functions that have already been written as temporary terms
    using deriv_node_temp_terms_t = map<pair<int, vector<expr_t>>, int>;
    
    //! Type for the substitution map used for creating aux. vars for diff and unary_ops
    /*! Let ≅ be the equivalence relationship such that two expressions e₁ and e₂
        are equivalent iff e₁ can be obtained from e₂ by shifting all leads/lags by
        the same number of periods (e.g. x₋₁+y₂≅x₁+y₄).
    
        For each equivalence class, we select a representative element, which is
        the class member which has no lead and a variable appearing at current
        period (in the previous example, it would be x₋₃+y). (Obviously, if there
        is no variable in the expression, then there is only one element in the
        class, and that one is the representative)
    
        Each member of an equivalence class is represented by an integer,