Am Montag, 16. Mai 2022, finden Wartungsarbeiten am Gitlab-Server (Update auf neue Version statt). Der Dienst wird daher am Montag für einige Zeit nicht verfügbar sein.
On Monday, May 16th 2022, the Gitlab server will be updated. The service will therefore not be accessible for some time on Monday.

Commit 4e3b2026 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

small workaround for mtl dense_vector 'bug' when using const value_type

parent e8a3e3b6
......@@ -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_multiplicable<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_multiplicable<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;
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment