Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
iwr
amdis
Commits
a6df9bdc
Commit
a6df9bdc
authored
Jan 22, 2019
by
Praetorius, Simon
Browse files
small updates in simplify and functor expressions
parent
8aa43b17
Changes
2
Show whitespace changes
Inline
Side-by-side
AMDiS/src/expressions/functorN_expr.hpp
View file @
a6df9bdc
...
...
@@ -109,7 +109,7 @@ namespace AMDiS
template
<
class
R
,
class
C
,
class
...
As
>
struct
Function
<
R
(
C
::*
)(
As
...)
>
{
typedef
R
result_
type
;
typedef
R
type
;
};
template
<
class
R
,
class
C
,
class
...
As
>
...
...
@@ -128,11 +128,6 @@ namespace AMDiS
typedef
decltype
(
function_helper
(
&
F
::
operator
()))
type
;
};
template
<
class
R
,
class
...
As
>
struct
Functor
<
std
::
function
<
R
(
As
...)
>
>
{
typedef
R
type
;
};
template
<
class
F
>
struct
Functor
<
F
,
typename
void_
<
typename
F
::
value_type
>::
type
>
...
...
AMDiS/src/expressions/simplify_expr.hpp
View file @
a6df9bdc
...
...
@@ -74,6 +74,16 @@ namespace AMDiS
static
type
eval
(
RValue
<
T
>
const
&
t
)
{
return
t
;
}
};
/// -(n) -> (-n)
template
<
class
T
>
struct
Simplify
<
Negative
<
RValue
<
T
>
>
>
{
typedef
RValue
<
T
>
type
;
static
type
eval
(
Negative
<
RValue
<
T
>
>
const
&
t
)
{
return
RValue
<
T
>
(
-
t
.
term
.
value
);
}
};
/// -(N) -> (-N)
template
<
int
N
>
struct
Simplify
<
Negative
<
CValue
<
N
>
>
>
...
...
@@ -82,7 +92,6 @@ namespace AMDiS
static
type
eval
(
Negative
<
CValue
<
N
>
>
const
&
t
)
{
return
CValue
<-
N
>
();
}
};
/// -0 -> 0
...
...
@@ -439,14 +448,23 @@ namespace AMDiS
/// (X + (-Y)) -> X - Y
template
<
typename
X
,
typename
Y
>
struct
Simplify
<
Negative
<
Add
<
X
,
Negative
<
Y
>
>
>
>
struct
Simplify
<
Add
<
X
,
Negative
<
Y
>
>
>
{
typedef
Subtract
<
X
,
Y
>
type
;
static
type
eval
(
Negative
<
Add
<
X
,
Negative
<
Y
>
>
>
const
&
t
)
static
type
eval
(
Add
<
X
,
Negative
<
Y
>
>
const
&
t
)
{
return
t
.
term1
-
t
.
term2
.
term
;
}
};
template
<
typename
Y
>
struct
Simplify
<
Add
<
CValue
<
0
>
,
Negative
<
Y
>
>
>
{
typedef
Negative
<
Y
>
type
;
static
type
eval
(
Add
<
CValue
<
0
>
,
Negative
<
Y
>
>
const
&
t
)
{
return
t
.
term2
;
}
};
/// -(X - Y) -> Y - X
template
<
typename
X
,
typename
Y
>
struct
Simplify
<
Negative
<
Subtract
<
X
,
Y
>
>
>
...
...
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