Commit 2fd03136 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

tests and examples adopted, small errors corrected

parent b23e2c59
......@@ -28,7 +28,6 @@
#include <boost/numeric/mtl/operation/conj.hpp>
#include <boost/numeric/mtl/operation/resource.hpp>
#include <boost/numeric/mtl/operation/lazy.hpp>
#include <boost/numeric/mtl/utility/static_assert.hpp>
#include <boost/numeric/mtl/interface/vpt.hpp>
namespace itl {
......@@ -130,7 +129,7 @@ class cg_solver
/// Construct solver from a linear operator; generate (left) preconditioner from it
explicit cg_solver(const LinearOperator& A) : base(A), L(A)
{
// MTL_STATIC_ASSERT((!pc::static_is_identity<RightPreconditioner>::value),
// static_assert((!pc::static_is_identity<RightPreconditioner>::value),
// "Right preconditioner must be identity!");
if (!pc::static_is_identity<RightPreconditioner>::value)
std::cerr << "Right Preconditioner ignored!" << std::endl;
......
// Software License for MTL
//
// Copyright (c) 2007 The Trustees of Indiana University.
//
// Copyright (c) 2007 The Trustees of Indiana University.
// 2008 Dresden University of Technology and the Trustees of Indiana University.
// 2010 SimuNova UG, www.simunova.com.
// 2010 SimuNova UG, www.simunova.com.
// All rights reserved.
// Authors: Peter Gottschling and Andrew Lumsdaine
//
//
// This file is part of the Matrix Template Library
//
//
// See also tools/license/license.mtl.txt in the distribution.
#ifndef ITL_PC_SOLVER_INCLUDE
......@@ -15,14 +15,10 @@
namespace itl {
#ifdef MTL_WITH_TEMPLATE_ALIAS
template <typename Matrix, template <typename, typename, typename> class Solver,
template <typename> class Left, template <typename> class Right>
using pc_solver= Solver<Matrix, Left<Matrix>, Right<Matrix> >;
#endif // MTL_WITH_TEMPLATE_ALIAS
} // namespace itl
#endif // ITL_PC_SOLVER_INCLUDE
......@@ -302,12 +302,10 @@ struct contiguous_memory_block
copy_construction(other);
}
#ifdef MTL_WITH_MOVE
contiguous_memory_block(self&& other) // : data(other.data), category(other.category) {}
{
move_construction(other);
}
#endif
// Force copy construction
contiguous_memory_block(const self& other, clone_ctor)
......@@ -324,7 +322,6 @@ struct contiguous_memory_block
copy_construction(other);
}
#ifdef MTL_WITH_MOVE
self& operator=(self&& other)
{
move_assignment(other);
......@@ -336,20 +333,6 @@ struct contiguous_memory_block
copy_assignment(other);
return *this;
}
#elif defined(MTL_MEMORY_BLOCK_MOVE_EMULATION)
// Operator takes parameter by value and consumes it
self& operator=(self other)
{
move_assignment(other);
return *this;
}
#else
self& operator=(self other)
{
copy_assignment(other);
return *this;
}
#endif
// Same behavior as consuming assignment, to be used by derived classes
protected:
......
......@@ -294,7 +294,7 @@ namespace mtl { namespace traits { namespace detail {
template <typename Range1, typename Range2>
struct min
: public std::conditional<
(Range1::complexity::value < Range2::complexity::value)>
(Range1::complexity::value < Range2::complexity::value)
, Range1
, Range2
>
......
// Software License for MTL
//
//
// Copyright (c) 2007 The Trustees of Indiana University.
// 2008 Dresden University of Technology and the Trustees of Indiana University.
// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com.
// All rights reserved.
// Authors: Peter Gottschling and Andrew Lumsdaine
//
//
// This file is part of the Matrix Template Library
//
//
// See also license.mtl.txt in the distribution.
#ifndef MTL_BASE_SUB_MATRIX_INCLUDE
......@@ -16,7 +16,6 @@
#include <algorithm>
#include <boost/numeric/mtl/matrix/dimension.hpp>
#include <boost/numeric/mtl/detail/index.hpp>
#include <boost/numeric/mtl/utility/static_assert.hpp>
#include <boost/numeric/mtl/utility/assert.hpp>
namespace mtl { namespace mat {
......@@ -25,7 +24,7 @@ namespace mtl { namespace mat {
// Contains only very simple functionality that is used in all sub-matrices
// But also used in some complete matrices
template <class Elt, class Parameters>
struct base_sub_matrix
struct base_sub_matrix
{
typedef Elt value_type;
typedef typename Parameters::orientation orientation;
......@@ -51,15 +50,15 @@ struct base_sub_matrix
public:
// base_sub_matrix() : my_nnz(0), my_begin_row(0), my_end_row(0), my_begin_col(0), my_end_col(0) {}
base_sub_matrix()
base_sub_matrix()
{
// With no static dimension information, it is by default 0
constructor_helper(dim_type());
}
explicit base_sub_matrix(const dim_type& d)
//explicit base_sub_matrix(mtl::non_fixed::dimensions d)
explicit base_sub_matrix(const dim_type& d)
//explicit base_sub_matrix(mtl::non_fixed::dimensions d)
{
constructor_helper(d);
}
......@@ -82,13 +81,13 @@ struct base_sub_matrix
}
protected:
void change_dim(non_fixed::dimensions d) { constructor_helper(d); }
void change_dim(non_fixed::dimensions d) { constructor_helper(d); }
template <std::size_t Rows, std::size_t Cols>
void change_dim(fixed::dimensions<Rows, Cols> d) { check_dim(d.num_rows(), d.num_cols()); }
void change_dim(fixed::dimensions<Rows, Cols> d) { check_dim(d.num_rows(), d.num_cols()); }
void change_dim(size_type r, size_type c) { change_dim(dim_type(r, c)); }
void change_dim(size_type r, size_type c) { change_dim(dim_type(r, c)); }
void set_ranges(size_type br, size_type er, size_type bc, size_type ec)
{
......@@ -98,13 +97,13 @@ protected:
}
public:
void check_ranges(size_type MTL_DEBUG_ARG(begin_r), size_type MTL_DEBUG_ARG(end_r),
void check_ranges(size_type MTL_DEBUG_ARG(begin_r), size_type MTL_DEBUG_ARG(end_r),
size_type MTL_DEBUG_ARG(begin_c), size_type MTL_DEBUG_ARG(end_c) ) const
{
MTL_CRASH_IF(begin_r < begin_row(), "begin_row out of range");
// if (end_r > end_row()) std::cout << "end_row out of range\n";
MTL_CRASH_IF(end_r > end_row(), "end_row out of range");
MTL_CRASH_IF(begin_c < begin_col(), "begin_col out of range");
MTL_CRASH_IF(end_c > end_col(), "end_col out of range");
}
......@@ -113,39 +112,39 @@ public:
{
set_ranges(br, er, bc, ec);
}
// Number of rows
size_type num_rows() const
size_type num_rows() const
{
return my_end_row - my_begin_row;
}
// First row taking indexing into account (already stored as such)
size_type begin_row() const
size_type begin_row() const
{
return my_begin_row;
}
// Past-end row taking indexing into account (already stored as such)
size_type end_row() const
size_type end_row() const
{
return my_end_row;
}
// Number of columns
size_type num_cols() const
size_type num_cols() const
{
return my_end_col - my_begin_col;
}
// First column taking indexing into account (already stored as such)
size_type begin_col() const
size_type begin_col() const
{
return my_begin_col;
}
// Past-end column taking indexing into account (already stored as such)
size_type end_col() const
size_type end_col() const
{
return my_end_col;
}
......@@ -158,48 +157,48 @@ public:
protected:
// dispatched functions for major dimension
size_type dim1(row_major) const
size_type dim1(row_major) const
{
return num_rows();
}
size_type dim1(col_major) const
size_type dim1(col_major) const
{
return num_cols();
}
// dispatched functions for minor dimension
size_type dim2(row_major) const
size_type dim2(row_major) const
{
return num_cols();
}
size_type dim2(col_major) const
size_type dim2(col_major) const
{
return num_rows();
}
// Dispatched functions for major
// Trailing _ due to conflicts with macro major
size_type major_(size_type r, size_type, row_major) const
{
return r;
return r;
}
size_type major_(size_type, size_type c, col_major) const
{
return c;
}
return c;
}
public:
// return major dimension
size_type dim1() const
size_type dim1() const
{
return dim1(orientation());
}
// return minor dimension
size_type dim2() const
size_type dim2() const
{
return dim2(orientation());
}
......@@ -218,10 +217,10 @@ public:
return major_(c, r, orientation());
}
dim_type get_dimensions() const
dim_type get_dimensions() const
{
return dim_type(num_rows(), num_cols());
}
return dim_type(num_rows(), num_cols());
}
};
......@@ -231,7 +230,7 @@ public:
#endif // MTL_BASE_SUB_MATRIX_INCLUDE
/*
/*
Question:
- Shall we keep the position in the original matrix?
*/
......@@ -19,6 +19,7 @@
#include <cmath>
#include <tuple>
#include <type_traits>
#include <initializer_list>
#include <boost/numeric/linear_algebra/identity.hpp>
......@@ -46,10 +47,6 @@
#include <boost/numeric/mtl/operation/size.hpp>
#include <boost/numeric/mtl/interface/vpt.hpp>
#ifdef MTL_WITH_INITLIST
# include <initializer_list>
#endif
#undef major // fight namespace pollution
namespace mtl { namespace mat {
......@@ -363,17 +360,7 @@ class compressed2D
}
// Default is faster !!! Only used with move constructor and without defaults
#if (!defined(MTL_WITH_DEFAULTIMPL) && defined(MTL_WITH_MOVE))
/// Copy constructor (just in case that is not generated by all compilers (generic matrix copy slower))
compressed2D(const self& src)
: super(src), data(src.data),
starts(src.starts), indices(src.indices), inserting(false)
{}
#endif
#if defined(MTL_WITH_DEFAULTIMPL)
compressed2D(const compressed2D&) = default;
#endif
/// Copy from other types
template <typename MatrixSrc>
......@@ -383,7 +370,6 @@ class compressed2D
*this= src;
}
#ifdef MTL_WITH_MOVE
// compressed2D(self&& src)
//: super(std::move(src)),
//data(std::move(src.data)), starts(std::move(src.starts)),
......@@ -391,9 +377,7 @@ class compressed2D
// {}
compressed2D(self&& src) : inserting(false)
{ swap(*this, src); }
#endif
#if defined(MTL_WITH_INITLIST) && defined(MTL_WITH_AUTO) && defined(MTL_WITH_RANGEDFOR)
/// Constructor for initializer list \p values
template <typename Value2>
compressed2D(std::initializer_list<std::initializer_list<Value2> > values)
......@@ -404,9 +388,7 @@ class compressed2D
allocate(super::dim1() * super::dim2());
*this= values;
}
#endif
#if defined(MTL_WITH_MOVE)
self& operator=(self&& src)
{
//std::cout << "I am move-assigning !!!\n";
......@@ -432,19 +414,6 @@ class compressed2D
inserting = src.inserting;
return *this;
}
#else
/// Consuming assignment operator (poor men's move semantics)
self& operator=(self src)
{
assert(this != &src); // Self-copy would be an indication of an error
check();
// TODO Check the following line
this->checked_change_dim(src.num_rows(), src.num_cols());
swap(*this, src);
return *this;
}
#endif
using assign_base::operator=;
......
......@@ -14,7 +14,6 @@
#include <boost/numeric/mtl/matrix/parameter.hpp>
#include <boost/numeric/mtl/vector/dense_vector.hpp>
#include <boost/numeric/mtl/utility/is_row_major.hpp>
#include <boost/numeric/mtl/utility/static_assert.hpp>
namespace mtl { namespace mat {
......@@ -238,7 +237,7 @@ struct coordinate2D_inserter
typedef operations::update_proxy<self, size_type> proxy_type;
// We only support storing so far !!!
// STATIC_ASSERT((std::is_same<Updater, mtl::operations::update_store<value_type> >::value), "We only support storing so far");
// static_assert((std::is_same<Updater, mtl::operations::update_store<value_type> >::value), "We only support storing so far");
coordinate2D_inserter(matrix_type& matrix, size_type slot_size= 1)
: matrix(matrix)
......
......@@ -35,7 +35,6 @@
#include <boost/numeric/mtl/utility/is_static.hpp>
#include <boost/numeric/mtl/utility/irange.hpp>
#include <boost/numeric/mtl/utility/dense_el_cursor.hpp>
#include <boost/numeric/mtl/utility/static_assert.hpp>
#include <boost/numeric/mtl/utility/strided_dense_el_cursor.hpp>
#include <boost/numeric/mtl/utility/strided_dense_el_iterator.hpp>
#include <boost/numeric/mtl/utility/transposed_orientation.hpp>
......@@ -139,7 +138,7 @@ namespace detail
struct dense2D_array_size<Parameters, true>
{
typedef typename Parameters::dimensions dimensions;
MTL_STATIC_ASSERT((dimensions::is_static), "Size must be known at compile time.");
static_assert((dimensions::is_static), "Size must be known at compile time.");
static std::size_t const value= dimensions::Num_Rows * dimensions::Num_Cols;
};
......@@ -247,7 +246,7 @@ public:
explicit dense2D(value_type* a)
: super(), memory_base(a, dim_type().num_rows() * dim_type().num_cols())
{
MTL_STATIC_ASSERT((dim_type::is_static), "Size must be known at compile time.");
static_assert((dim_type::is_static), "Size must be known at compile time.");
init();
}
......@@ -329,7 +328,6 @@ public:
public:
#ifdef MTL_WITH_MOVE
/// Move assignment for data on heap
self& operator=(self&& src)
{ return self_assign(src, std::integral_constant<bool, memory_base::on_stack>()); }
......@@ -338,14 +336,6 @@ public:
self& operator=(const self& src)
{ return self_assign(src, std::true_type()); }
#else
/// (Copy) Assignment
self& operator=(typename detail::ref_on_stack<self, memory_base::on_stack>::type src)
{
return self_assign(src, std::integral_constant<bool, memory_base::on_stack>());
}
#endif
private:
// Already copied for lvalues -> data can be stolen (need non-const ref)
self& self_assign(self& src, std::false_type)
......
......@@ -73,9 +73,9 @@ struct map_view
map_view (const Functor& functor, const other& ref) : functor(functor), ref(ref) {}
map_view (const Functor& functor, std::shared_ptr<Matrix> p)
: functor(functor), my_copy(p), ref(*p) {}
: my_copy(p), functor(functor), ref(*p) {}
map_view (self&& that) : functor(that.functor), my_copy(std::move(that.my_copy)), ref(that.ref) {}
map_view (self&& that) : my_copy(std::move(that.my_copy)), functor(that.functor), ref(that.ref) {}
map_view (const self& that) : functor(that.functor), ref(that.ref) { assert(that.my_copy.use_count() == 0); }
......@@ -345,12 +345,10 @@ struct imag_view
typedef imag_view self;
imag_view(const Matrix& matrix) : base(functor_type(), matrix) {}
imag_view(boost::shared_ptr<Matrix> p) : base(functor_type(), p) {}
imag_view(std::shared_ptr<Matrix> p) : base(functor_type(), p) {}
#ifdef MTL_WITH_CPP11_MOVE
imag_view (self&& that) : base(that) {}
imag_view (const self& that) : base(that) {}
#endif
};
template <typename Matrix>
......
......@@ -510,7 +510,6 @@ class morton_dense
}
#ifdef MTL_WITH_MOVE
/// Move Assignment
self& operator=(self&& src)
{
......@@ -531,21 +530,6 @@ class morton_dense
matrix_copy(src, *this);
return *this;
}
#else
/// Copy assignment (with move emulation)
self& operator=(self src)
{
// Self-copy would be an indication of an error
assert(this != &src);
this->check_dim(src.num_rows(), src.num_cols());
if (this->category == memory_base::view || src.category == memory_base::view)
matrix_copy(src, *this);
else
memory_base::move_assignment(src);
return *this;
}
#endif
using assign_base::operator=;
......
......@@ -27,7 +27,6 @@
#include <boost/numeric/mtl/utility/is_composable_vector.hpp>
#include <boost/numeric/mtl/utility/is_multi_vector_expr.hpp>
#include <boost/numeric/mtl/utility/fast_multi_vector_expr.hpp>
#include <boost/numeric/mtl/utility/static_assert.hpp>
#include <boost/numeric/mtl/vector/parameter.hpp>
......@@ -48,7 +47,7 @@ class multi_vector
typedef base_matrix<typename Collection<Vector>::value_type, parameters<> > super;
// Vector must by column vector
MTL_STATIC_ASSERT((std::is_same<typename OrientedCollection<Vector>::orientation,
static_assert((std::is_same<typename OrientedCollection<Vector>::orientation,
tag::col_major>::value),
"Vector must be a column vector.");
public:
......
......@@ -17,7 +17,6 @@
#include <boost/numeric/mtl/utility/ashape.hpp>
#include <boost/numeric/mtl/utility/is_multi_vector_expr.hpp>
#include <boost/numeric/mtl/utility/static_assert.hpp>
#include <boost/numeric/mtl/matrix/all_mat_expr.hpp>
#include <boost/numeric/mtl/mtl_fwd.hpp>
......@@ -29,7 +28,7 @@ inline mat_mat_plus_expr<E1, E2>
operator+ (const mat_expr<E1>& e1, const mat_expr<E2>& e2)
{
// do not add matrices with inconsistent value types
MTL_STATIC_ASSERT((std::is_same<typename ashape::ashape<E1>::type,
static_assert((std::is_same<typename ashape::ashape<E1>::type,
typename ashape::ashape<E2>::type>::value), "Matrices have not consistent algebraic shape (i.e. nested types).");
return mat_mat_plus_expr<E1, E2>(static_cast<const E1&>(e1), static_cast<const E2&>(e2));
}
......@@ -57,7 +56,7 @@ inline dmat_dmat_plus_expr<E1, E2>
operator+ (const dmat_expr<E1>& e1, const dmat_expr<E2>& e2)
{
// do not add matrices with inconsistent value types
MTL_STATIC_ASSERT((std::is_same<typename ashape::ashape<E1>::type,
static_assert((std::is_same<typename ashape::ashape<E1>::type,
typename ashape::ashape<E2>::type>::value), "Matrices have not consistent algebraic shape (i.e. nested types).");
return dmat_dmat_plus_expr<E1, E2>(static_cast<const E1&>(e1), static_cast<const E2&>(e2));
}
......@@ -69,7 +68,7 @@ inline mat_mat_minus_expr<E1, E2>
operator- (const mat_expr<E1>& e1, const mat_expr<E2>& e2)
{
// do not add matrices with inconsistent value types
MTL_STATIC_ASSERT((std::is_same<typename ashape::ashape<E1>::type,
static_assert((std::is_same<typename ashape::ashape<E1>::type,
typename ashape::ashape<E2>::type>::value), "Matrices have not consistent algebraic shape (i.e. nested types).");
return mat_mat_minus_expr<E1, E2>(static_cast<const E1&>(e1), static_cast<const E2&>(e2));
}
......@@ -87,7 +86,7 @@ inline mat_mat_ele_times_expr<E1, E2>
ele_prod(const mat_expr<E1>& e1, const mat_expr<E2>& e2)
{
// do not multiply matrices element-wise with inconsistent value types
MTL_STATIC_ASSERT((std::is_same<typename ashape::ashape<E1>::type,
static_assert((std::is_same<typename ashape::ashape<E1>::type,
typename ashape::ashape<E2>::type>::value), "Matrices do not have consistent algebraic shape (i.e. nested types).");
return mat_mat_ele_times_expr<E1, E2>(static_cast<const E1&>(e1), static_cast<const E2&>(e2));
}
......
// Software License for MTL
//
//
// Copyright (c) 2007 The Trustees of Indiana University.
// 2008 Dresden University of Technology and the Trustees of Indiana University.
// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com.
// All rights reserved.
// Authors: Peter Gottschling and Andrew Lumsdaine
//
//
// This file is part of the Matrix Template Library
//
//
// See also license.mtl.txt in the distribution.
#ifndef MTL_MATRIX_PARAMETERS_INCLUDE
#define MTL_MATRIX_PARAMETERS_INCLUDE
#include <boost/numeric/mtl/utility/static_assert.hpp>
#include <boost/numeric/mtl/utility/tag.hpp>
#include <boost/numeric/mtl/detail/index.hpp>
#include <boost/numeric/mtl/matrix/dimension.hpp>
......@@ -26,12 +25,12 @@ namespace mtl { namespace mat {
\sa \ref matrix_parameters
\sa \ref tuning_fsize
\sa \ref tuning_sizetype **/
template <typename Orientation= row_major,
template <typename Orientation= row_major,
typename Index= index::c_index,
typename Dimensions= mtl::non_fixed::dimensions,
bool OnStack= mtl::traits::is_static<Dimensions>::value,
typename SizeType= std::size_t>