Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dynare
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
121
Issues
121
List
Boards
Labels
Service Desk
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dynare
dynare
Commits
129d404e
Commit
129d404e
authored
Dec 17, 2010
by
Ferhat Mihoubi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- The binary operator oDerivPower is implemented in bytecode
parent
d8dbc68e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
2 deletions
+72
-2
mex/sources/bytecode/ErrorHandling.hh
mex/sources/bytecode/ErrorHandling.hh
+31
-0
mex/sources/bytecode/Interpreter.cc
mex/sources/bytecode/Interpreter.cc
+34
-1
preprocessor/CodeInterpreter.hh
preprocessor/CodeInterpreter.hh
+2
-0
preprocessor/ExprNode.cc
preprocessor/ExprNode.cc
+5
-0
preprocessor/ExprNode.hh
preprocessor/ExprNode.hh
+0
-1
No files found.
mex/sources/bytecode/ErrorHandling.hh
View file @
129d404e
...
...
@@ -24,6 +24,10 @@
#include <iostream>
#include <sstream>
#include "CodeInterpreter.hh"
#ifdef DEBUG_EX
# include <math>
# include "mex_interface.hh"
#endif
using
namespace
std
;
...
...
@@ -1078,6 +1082,33 @@ print_expression(it_code_type it_code, bool evaluate, int size, int block_num, b
Stack
.
push
(
tmp_out
.
str
());
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
oPowerDeriv
:
{
int
derivOrder
=
nearbyint
(
Stackf
.
top
());
Stackf
.
pop
();
if
(
fabs
(
v1f
)
<
NEAR_ZERO
&&
v2f
>
0
&&
derivOrder
>=
v2f
&&
fabs
(
v2f
-
nearbyint
(
v2f
))
<
NEAR_ZERO
)
Stackf
.
push
(
0.0
);
else
{
double
dxp
=
pow
(
v1f
,
v2f
-
derivOrder
);
for
(
int
i
=
0
;
i
<
derivOrder
;
i
++
)
dxp
*=
v2f
--
;
Stackf
.
push
(
dxp
);
}
tmp_out
.
str
(
""
);
if
(
isnan
(
r
))
tmp_out
<<
"$ PowerDeriv "
;
else
tmp_out
<<
"PowerDeriv"
;
tmp_out
<<
"("
<<
v1
<<
", "
<<
v2
<<
", "
<<
derivOrder
<<
")"
;
Stack
.
push
(
tmp_out
.
str
());
}
#ifdef DEBUG
tmp_out
<<
" |PowerDeriv("
<<
v1
<<
", "
<<
v2
<<
")|"
;
#endif
break
;
case
oMax
:
...
...
mex/sources/bytecode/Interpreter.cc
View file @
129d404e
...
...
@@ -874,6 +874,35 @@ Interpreter::compute_block_time(int Per_u_, bool evaluate, int block_num, int si
tmp_out
<<
" |"
<<
v1
<<
"^"
<<
v2
<<
"|"
;
#endif
break
;
case
oPowerDeriv
:
{
int
derivOrder
=
nearbyint
(
Stack
.
top
());
Stack
.
pop
();
try
{
if
(
fabs
(
v1
)
<
NEAR_ZERO
&&
v2
>
0
&&
derivOrder
>=
v2
&&
fabs
(
v2
-
nearbyint
(
v2
))
<
NEAR_ZERO
)
Stack
.
push
(
0.0
);
else
{
double
dxp
=
pow1
(
v1
,
v2
-
derivOrder
);
for
(
int
i
=
0
;
i
<
derivOrder
;
i
++
)
dxp
*=
v2
--
;
Stack
.
push
(
dxp
);
}
}
catch
(
FloatingPointExceptionHandling
&
fpeh
)
{
mexPrintf
(
"%s %s
\n
"
,
fpeh
.
GetErrorMsg
().
c_str
(),
error_location
(
evaluate
,
steady_state
,
size
,
block_num
,
it_
,
Per_u_
).
c_str
());
go_on
=
false
;
}
}
#ifdef DEBUG
tmp_out
<<
" |PowerDeriv("
<<
v1
<<
", "
<<
v2
<<
")|"
;
#endif
break
;
case
oMax
:
Stack
.
push
(
max
(
v1
,
v2
));
#ifdef DEBUG
...
...
@@ -2429,7 +2458,11 @@ Interpreter::compute_blocks(string file_name, string bin_basename, bool steady_s
delete
fb
;
}
if
(
block
>=
0
)
go_on
=
false
;
{
go_on
=
false
;
}
break
;
case
FEND
:
#ifdef DEBUG
...
...
preprocessor/CodeInterpreter.hh
View file @
129d404e
...
...
@@ -38,6 +38,8 @@
#include <stdint.h>
#define NEAR_ZERO (1e-12)
using
namespace
std
;
/**
...
...
preprocessor/ExprNode.cc
View file @
129d404e
...
...
@@ -2525,6 +2525,11 @@ BinaryOpNode::compile(ostream &CompileCode, unsigned int &instruction_number,
}
return
;
}
if
(
op_code
==
oPowerDeriv
)
{
FLDC_
fldc
(
powerDerivOrder
);
fldc
.
write
(
CompileCode
,
instruction_number
);
}
arg1
->
compile
(
CompileCode
,
instruction_number
,
lhs_rhs
,
temporary_terms
,
map_idx
,
dynamic
,
steady_dynamic
,
tef_terms
);
arg2
->
compile
(
CompileCode
,
instruction_number
,
lhs_rhs
,
temporary_terms
,
map_idx
,
dynamic
,
steady_dynamic
,
tef_terms
);
FBINARY_
fbinary
(
op_code
);
...
...
preprocessor/ExprNode.hh
View file @
129d404e
...
...
@@ -107,7 +107,6 @@ enum ExprNodeOutputType
#define MIN_COST_C (40*4)
#define MIN_COST(is_matlab) ((is_matlab) ? MIN_COST_MATLAB : MIN_COST_C)
#define NEAR_ZERO (1e-12)
//! Base class for expression nodes
class
ExprNode
...
...
Write
Preview
Markdown
is supported
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