Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Backofen, Rainer
amdis
Commits
4e3b2026
Commit
4e3b2026
authored
Mar 24, 2015
by
Praetorius, Simon
Browse files
small workaround for mtl dense_vector 'bug' when using const value_type
parent
e8a3e3b6
Changes
4
Hide whitespace changes
Inline
Side-by-side
AMDiS/src/MatrixVectorOperations.h
View file @
4e3b2026
...
...
@@ -159,7 +159,8 @@ namespace AMDiS {
/// vector *= scalar (elementwise)
template
<
typename
T
,
typename
S
>
Vector
<
T
>&
operator
*=
(
Vector
<
T
>&
v
,
S
scal
)
typename
enable_if
<
traits
::
is_multiplicable
<
S
,
T
>
,
Vector
<
T
>
>::
type
&
operator
*=
(
Vector
<
T
>&
v
,
S
scal
)
{
T
*
vIt
;
for
(
vIt
=
v
.
begin
();
vIt
!=
v
.
end
();
++
vIt
)
...
...
@@ -169,17 +170,17 @@ namespace AMDiS {
/// vector := vector * scalar (elementwise)
template
<
typename
T
,
typename
S
>
Vector
<
typename
traits
::
mult
_type
<
T
,
S
>::
type
>
operator
*
(
Vector
<
T
>
const
&
v
,
S
scal
)
typename
enable_if
<
traits
::
is_
mult
iplicable
<
S
,
T
>
,
Vector
<
T
>
>::
type
operator
*
(
Vector
<
T
>
result
,
S
scal
)
{
Vector
<
typename
traits
::
mult_type
<
T
,
S
>::
type
>
result
=
v
;
result
*=
scal
;
return
result
;
}
/// vector /= scalar (elementwise)
template
<
typename
T
,
typename
S
>
Vector
<
T
>&
operator
/=
(
Vector
<
T
>&
v
,
S
scal
)
typename
enable_if
<
traits
::
is_multiplicable
<
S
,
T
>
,
Vector
<
T
>
>::
type
&
operator
/=
(
Vector
<
T
>&
v
,
S
scal
)
{
T
*
vIt
;
for
(
vIt
=
v
.
begin
();
vIt
!=
v
.
end
();
++
vIt
)
...
...
@@ -189,10 +190,9 @@ namespace AMDiS {
/// vector := vector / scalar (elementwise)
template
<
typename
T
,
typename
S
>
Vector
<
typename
traits
::
mult
_type
<
T
,
S
>::
type
>
operator
/
(
Vector
<
T
>
const
&
v
,
S
scal
)
typename
enable_if
<
traits
::
is_
mult
iplicable
<
S
,
T
>
,
Vector
<
T
>
>::
type
operator
/
(
Vector
<
T
>
result
,
S
scal
)
{
Vector
<
typename
traits
::
mult_type
<
T
,
S
>::
type
>
result
=
v
;
result
/=
scal
;
return
result
;
}
...
...
@@ -319,7 +319,7 @@ namespace AMDiS {
/// vector := vector * scalar (elementwise)
template
<
typename
T
,
typename
S
>
WorldVector
<
T
>
typename
enable_if
<
traits
::
is_multiplicable
<
S
,
T
>
,
WorldVector
<
T
>
>::
type
operator
*
(
WorldVector
<
T
>
const
&
v
,
S
scal
)
{
WorldVector
<
T
>
result
=
v
;
...
...
@@ -329,7 +329,7 @@ namespace AMDiS {
/// vector := scalar * vector (elementwise)
template
<
typename
T
,
typename
S
>
WorldVector
<
T
>
typename
enable_if
<
traits
::
is_multiplicable
<
S
,
T
>
,
WorldVector
<
T
>
>::
type
operator
*
(
S
scal
,
WorldVector
<
T
>
const
&
v
)
{
WorldVector
<
T
>
result
=
v
;
...
...
@@ -339,7 +339,7 @@ namespace AMDiS {
/// vector := vector / scalar (elementwise)
template
<
typename
T
,
typename
S
>
WorldVector
<
T
>
typename
enable_if
<
traits
::
is_multiplicable
<
S
,
T
>
,
WorldVector
<
T
>
>::
type
operator
/
(
WorldVector
<
T
>
const
&
v
,
S
scal
)
{
WorldVector
<
T
>
result
=
v
;
...
...
@@ -359,7 +359,7 @@ namespace AMDiS {
/// matrix := matrix * scalar (elementwise)
template
<
typename
T
,
typename
S
>
WorldMatrix
<
T
>
typename
enable_if
<
traits
::
is_multiplicable
<
S
,
T
>
,
WorldMatrix
<
T
>
>::
type
operator
*
(
WorldMatrix
<
T
>
const
&
m
,
S
scal
)
{
WorldMatrix
<
T
>
result
=
m
;
...
...
@@ -369,7 +369,7 @@ namespace AMDiS {
/// matrix := scalar * matrix (elementwise)
template
<
typename
T
,
typename
S
>
WorldMatrix
<
T
>
typename
enable_if
<
traits
::
is_multiplicable
<
S
,
T
>
,
WorldMatrix
<
T
>
>::
type
operator
*
(
S
scal
,
WorldMatrix
<
T
>
const
&
m
)
{
WorldMatrix
<
T
>
result
=
m
;
...
...
@@ -379,7 +379,7 @@ namespace AMDiS {
/// matrix := matrix / scalar (elementwise)
template
<
typename
T
,
typename
S
>
WorldMatrix
<
T
>
typename
enable_if
<
traits
::
is_multiplicable
<
S
,
T
>
,
WorldMatrix
<
T
>
>::
type
operator
/
(
WorldMatrix
<
T
>
const
&
m
,
S
scal
)
{
WorldMatrix
<
T
>
result
=
m
;
...
...
AMDiS/src/operations/norm.hpp
View file @
4e3b2026
...
...
@@ -59,7 +59,7 @@ namespace AMDiS
using
namespace
mtl
::
vector
;
typedef
parameters
<
mtl
::
col_major
,
non_fixed
::
dimension
,
false
,
size_type
>
param
;
mtl
::
dense_vector
<
const
value_type
,
param
>
tmp
(
AMDiS
::
size
(
v
),
v
.
begin
());
mtl
::
dense_vector
<
value_type
,
param
>
tmp
(
AMDiS
::
size
(
v
),
const_cast
<
value_type
*>
(
v
.
begin
())
)
;
return
mtl
::
two_norm
(
tmp
);
}
...
...
@@ -110,7 +110,7 @@ namespace AMDiS
using
namespace
mtl
::
vector
;
typedef
parameters
<
mtl
::
col_major
,
non_fixed
::
dimension
,
false
,
size_type
>
param
;
mtl
::
dense_vector
<
const
value_type
,
param
>
tmp
(
AMDiS
::
size
(
v
),
v
.
begin
());
mtl
::
dense_vector
<
value_type
,
param
>
tmp
(
AMDiS
::
size
(
v
),
const_cast
<
value_type
*>
(
v
.
begin
())
)
;
return
mtl
::
vector
::
one_norm
(
tmp
);
}
...
...
AMDiS/src/operations/product.hpp
View file @
4e3b2026
...
...
@@ -64,8 +64,8 @@ namespace AMDiS
using
namespace
mtl
::
vector
;
typedef
parameters
<
mtl
::
col_major
,
non_fixed
::
dimension
,
false
,
size_type1
>
param1
;
typedef
parameters
<
mtl
::
col_major
,
non_fixed
::
dimension
,
false
,
size_type2
>
param2
;
mtl
::
dense_vector
<
const
value_type1
,
param1
>
tmp1
(
AMDiS
::
size
(
v1
),
v1
.
begin
());
mtl
::
dense_vector
<
const
value_type2
,
param2
>
tmp2
(
AMDiS
::
size
(
v2
),
v2
.
begin
());
mtl
::
dense_vector
<
value_type1
,
param1
>
tmp1
(
AMDiS
::
size
(
v1
),
const_cast
<
value_type1
*>
(
v1
.
begin
())
)
;
mtl
::
dense_vector
<
value_type2
,
param2
>
tmp2
(
AMDiS
::
size
(
v2
),
const_cast
<
value_type2
*>
(
v2
.
begin
())
)
;
return
mtl
::
dot
(
tmp1
,
tmp2
);
}
...
...
AMDiS/src/traits/basic.hpp
View file @
4e3b2026
...
...
@@ -61,6 +61,15 @@ namespace AMDiS
// dummy type
typedef
boost
::
numeric
::
ublas
::
error_cant_deduce_type
no_valid_type
;
template
<
class
A
,
class
B
>
struct
is_multiplicable
:
boost
::
mpl
::
not_
<
boost
::
is_same
<
typename
mtl
::
Multiplicable
<
A
,
B
>::
result_type
,
no_valid_type
>
>
{};
template
<
class
A
,
class
B
>
struct
is_addable
:
boost
::
mpl
::
not_
<
boost
::
is_same
<
typename
mtl
::
Addable
<
A
,
B
>::
result_type
,
no_valid_type
>
>
{};
#ifdef HAS_CPP11
template
<
typename
T
>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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