Commit dab2dde8 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Small improvements to external functions code.

parent 3d11273a
/*
* Copyright (C) 2003-2012 Dynare Team
* Copyright (C) 2003-2014 Dynare Team
*
* This file is part of Dynare.
*
......@@ -68,10 +68,16 @@ protected:
binary_op_node_map_t binary_op_node_map;
typedef map<pair<pair<pair<expr_t, expr_t>, expr_t>, TrinaryOpcode>, TrinaryOpNode *> trinary_op_node_map_t;
trinary_op_node_map_t trinary_op_node_map;
// (arguments, symb_id) -> ExternalFunctionNode
typedef map<pair<vector<expr_t>, int>, ExternalFunctionNode *> external_function_node_map_t;
external_function_node_map_t external_function_node_map;
// ((arguments, deriv_idx), symb_id) -> FirstDerivExternalFunctionNode
typedef map<pair<pair<vector<expr_t>, int>, int>, FirstDerivExternalFunctionNode *> first_deriv_external_function_node_map_t;
first_deriv_external_function_node_map_t first_deriv_external_function_node_map;
// ((arguments, (deriv_idx1, deriv_idx2)), symb_id) -> SecondDerivExternalFunctionNode
typedef map<pair<pair<vector<expr_t>, pair<int, int> >, int>, SecondDerivExternalFunctionNode *> second_deriv_external_function_node_map_t;
second_deriv_external_function_node_map_t second_deriv_external_function_node_map;
......
/*
* Copyright (C) 2007-2013 Dynare Team
* Copyright (C) 2007-2014 Dynare Team
*
* This file is part of Dynare.
*
......@@ -4935,12 +4935,10 @@ FirstDerivExternalFunctionNode::writeOutput(ostream &output, ExprNodeOutputType
return;
}
int first_deriv_symb_id = datatree.external_functions_table.getFirstDerivSymbID(symb_id);
const int first_deriv_symb_id = datatree.external_functions_table.getFirstDerivSymbID(symb_id);
assert(first_deriv_symb_id != eExtFunSetButNoNameProvided);
int tmpIndx = inputIndex;
if (IS_C(output_type))
tmpIndx = tmpIndx - 1;
const int tmpIndx = inputIndex - ARRAY_SUBSCRIPT_OFFSET(output_type);
if (first_deriv_symb_id == symb_id)
output << "TEFD_" << getIndxInTefTerms(symb_id, tef_terms)
......@@ -4982,15 +4980,14 @@ FirstDerivExternalFunctionNode::compile(ostream &CompileCode, unsigned int &inst
int first_deriv_symb_id = datatree.external_functions_table.getFirstDerivSymbID(symb_id);
assert(first_deriv_symb_id != eExtFunSetButNoNameProvided);
int tmpIndx = inputIndex;
if (!lhs_rhs)
{
FLDTEFD_ fldtefd(getIndxInTefTerms(symb_id, tef_terms), tmpIndx);
FLDTEFD_ fldtefd(getIndxInTefTerms(symb_id, tef_terms), inputIndex);
fldtefd.write(CompileCode, instruction_number);
}
else
{
FSTPTEFD_ fstptefd(getIndxInTefTerms(symb_id, tef_terms), tmpIndx);
FSTPTEFD_ fstptefd(getIndxInTefTerms(symb_id, tef_terms), inputIndex);
fstptefd.write(CompileCode, instruction_number);
}
}
......@@ -5193,16 +5190,11 @@ SecondDerivExternalFunctionNode::writeOutput(ostream &output, ExprNodeOutputType
return;
}
int second_deriv_symb_id = datatree.external_functions_table.getSecondDerivSymbID(symb_id);
const int second_deriv_symb_id = datatree.external_functions_table.getSecondDerivSymbID(symb_id);
assert(second_deriv_symb_id != eExtFunSetButNoNameProvided);
int tmpIndex1 = inputIndex1;
int tmpIndex2 = inputIndex2;
if (IS_C(output_type))
{
tmpIndex1 = tmpIndex1 - 1;
tmpIndex2 = tmpIndex2 - 1;
}
const int tmpIndex1 = inputIndex1 - ARRAY_SUBSCRIPT_OFFSET(output_type);
const int tmpIndex2 = inputIndex2 - ARRAY_SUBSCRIPT_OFFSET(output_type);
int indx = getIndxInTefTerms(symb_id, tef_terms);
if (second_deriv_symb_id == symb_id)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment