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
0269a0c9
Commit
0269a0c9
authored
Jan 22, 2019
by
Praetorius, Simon
Browse files
Merge branch 'issue/expressions' into 'dev'
small updates in simplify and functor expressions See merge request
!26
parents
383830fc
a6df9bdc
Changes
2
Hide whitespace changes
Inline
Side-by-side
AMDiS/src/expressions/functorN_expr.hpp
View file @
0269a0c9
...
@@ -109,13 +109,13 @@ namespace AMDiS
...
@@ -109,13 +109,13 @@ namespace AMDiS
template
<
class
R
,
class
C
,
class
...
As
>
template
<
class
R
,
class
C
,
class
...
As
>
struct
Function
<
R
(
C
::*
)(
As
...)
>
struct
Function
<
R
(
C
::*
)(
As
...)
>
{
{
typedef
R
result_
type
;
typedef
R
type
;
};
};
template
<
class
R
,
class
C
,
class
...
As
>
template
<
class
R
,
class
C
,
class
...
As
>
struct
Function
<
R
(
C
::*
)(
As
...)
const
>
struct
Function
<
R
(
C
::*
)(
As
...)
const
>
{
{
typedef
R
type
;
typedef
R
type
;
};
};
template
<
class
T
>
template
<
class
T
>
...
@@ -128,11 +128,6 @@ namespace AMDiS
...
@@ -128,11 +128,6 @@ namespace AMDiS
typedef
decltype
(
function_helper
(
&
F
::
operator
()))
type
;
typedef
decltype
(
function_helper
(
&
F
::
operator
()))
type
;
};
};
template
<
class
R
,
class
...
As
>
struct
Functor
<
std
::
function
<
R
(
As
...)
>
>
{
typedef
R
type
;
};
template
<
class
F
>
template
<
class
F
>
struct
Functor
<
F
,
typename
void_
<
typename
F
::
value_type
>::
type
>
struct
Functor
<
F
,
typename
void_
<
typename
F
::
value_type
>::
type
>
...
...
AMDiS/src/expressions/simplify_expr.hpp
View file @
0269a0c9
...
@@ -74,6 +74,16 @@ namespace AMDiS
...
@@ -74,6 +74,16 @@ namespace AMDiS
static
type
eval
(
RValue
<
T
>
const
&
t
)
{
return
t
;
}
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)
/// -(N) -> (-N)
template
<
int
N
>
template
<
int
N
>
struct
Simplify
<
Negative
<
CValue
<
N
>
>
>
struct
Simplify
<
Negative
<
CValue
<
N
>
>
>
...
@@ -82,7 +92,6 @@ namespace AMDiS
...
@@ -82,7 +92,6 @@ namespace AMDiS
static
type
eval
(
Negative
<
CValue
<
N
>
>
const
&
t
)
static
type
eval
(
Negative
<
CValue
<
N
>
>
const
&
t
)
{
return
CValue
<-
N
>
();
}
{
return
CValue
<-
N
>
();
}
};
};
/// -0 -> 0
/// -0 -> 0
...
@@ -439,14 +448,23 @@ namespace AMDiS
...
@@ -439,14 +448,23 @@ namespace AMDiS
/// (X + (-Y)) -> X - Y
/// (X + (-Y)) -> X - Y
template
<
typename
X
,
typename
Y
>
template
<
typename
X
,
typename
Y
>
struct
Simplify
<
Negative
<
Add
<
X
,
Negative
<
Y
>
>
>
>
struct
Simplify
<
Add
<
X
,
Negative
<
Y
>
>
>
{
{
typedef
Subtract
<
X
,
Y
>
type
;
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
;
}
{
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
/// -(X - Y) -> Y - X
template
<
typename
X
,
typename
Y
>
template
<
typename
X
,
typename
Y
>
struct
Simplify
<
Negative
<
Subtract
<
X
,
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