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
4624a310
Commit
4624a310
authored
Sep 04, 2018
by
Sébastien Villemot
Browse files
Macroprocessor: implement power operator for integers
For consistency with the power operator for sets (see
#5
).
parent
a35c1785
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/macro/MacroValue.cc
View file @
4624a310
...
...
@@ -18,6 +18,7 @@
*/
#include
<utility>
#include
<cmath>
#include
"MacroDriver.hh"
...
...
@@ -198,6 +199,15 @@ IntMV::divide(const MacroValuePtr &mv) noexcept(false)
return
make_shared
<
IntMV
>
(
value
/
mv2
->
value
);
}
MacroValuePtr
IntMV
::
power
(
const
MacroValuePtr
&
mv
)
noexcept
(
false
)
{
auto
mv2
=
dynamic_pointer_cast
<
IntMV
>
(
mv
);
if
(
!
mv2
)
throw
TypeError
(
"Type mismatch for operands of ^ operator"
);
return
make_shared
<
IntMV
>
(
pow
(
value
,
mv2
->
value
));
}
shared_ptr
<
IntMV
>
IntMV
::
is_less
(
const
MacroValuePtr
&
mv
)
noexcept
(
false
)
{
...
...
src/macro/MacroValue.hh
View file @
4624a310
...
...
@@ -135,6 +135,7 @@ public:
MacroValuePtr
times
(
const
MacroValuePtr
&
mv
)
noexcept
(
false
)
override
;
//! Computes arithmetic division
MacroValuePtr
divide
(
const
MacroValuePtr
&
mv
)
noexcept
(
false
)
override
;
MacroValuePtr
power
(
const
MacroValuePtr
&
mv
)
noexcept
(
false
)
override
;
shared_ptr
<
IntMV
>
is_less
(
const
MacroValuePtr
&
mv
)
noexcept
(
false
)
override
;
shared_ptr
<
IntMV
>
is_greater
(
const
MacroValuePtr
&
mv
)
noexcept
(
false
)
override
;
shared_ptr
<
IntMV
>
is_less_equal
(
const
MacroValuePtr
&
mv
)
noexcept
(
false
)
override
;
...
...
Sébastien Villemot
@sebastien
mentioned in issue
#5 (closed)
·
Sep 24, 2018
mentioned in issue
#5 (closed)
mentioned in issue #5
Toggle commit list
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