Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dynare
preprocessor
Commits
dab2dde8
Commit
dab2dde8
authored
Feb 24, 2014
by
Sébastien Villemot
Browse files
Small improvements to external functions code.
parent
3d11273a
Changes
2
Hide whitespace changes
Inline
Side-by-side
DataTree.hh
View file @
dab2dde8
/*
* Copyright (C) 2003-201
2
Dynare Team
* Copyright (C) 2003-201
4
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
;
...
...
ExprNode.cc
View file @
dab2dde8
/*
* Copyright (C) 2007-201
3
Dynare Team
* Copyright (C) 2007-201
4
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
),
tmp
Indx
);
FLDTEFD_
fldtefd
(
getIndxInTefTerms
(
symb_id
,
tef_terms
),
input
Ind
e
x
);
fldtefd
.
write
(
CompileCode
,
instruction_number
);
}
else
{
FSTPTEFD_
fstptefd
(
getIndxInTefTerms
(
symb_id
,
tef_terms
),
tmp
Indx
);
FSTPTEFD_
fstptefd
(
getIndxInTefTerms
(
symb_id
,
tef_terms
),
input
Ind
e
x
);
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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment