23 #include <cusp/detail/config.h>
25 #include <cusp/memory.h>
26 #include <cusp/detail/format.h>
29 #include <cusp/detail/array2d_format_utils.h>
30 #include <cusp/detail/matrix_base.h>
32 #include <thrust/functional.h>
92 template<
typename ValueType,
typename MemorySpace,
typename Orientation = cusp::row_major>
93 class array2d :
public cusp::detail::matrix_base<int,ValueType,MemorySpace,cusp::array2d_format>
97 typedef typename cusp::detail::matrix_base<int,ValueType,MemorySpace,cusp::array2d_format> Parent;
101 typedef Orientation orientation;
103 template<
typename MemorySpace2>
114 typedef cusp::detail::row_or_column_view<
115 typename values_array_type::iterator,thrust::detail::is_same<Orientation,cusp::row_major>::value>
118 typedef typename row_view_type::ArrayType row_view;
120 typedef cusp::detail::row_or_column_view
121 <
typename values_array_type::iterator,thrust::detail::is_same<Orientation,cusp::column_major>::value>
124 typedef typename column_view_type::ArrayType column_view;
126 typedef cusp::detail::row_or_column_view
127 <
typename values_array_type::const_iterator,thrust::detail::is_same<Orientation,cusp::row_major>::value>
130 typedef typename const_row_view_type::ArrayType const_row_view;
132 typedef cusp::detail::row_or_column_view
133 <
typename values_array_type::const_iterator,thrust::detail::is_same<Orientation,cusp::column_major>::value>
134 const_column_view_type;
136 typedef typename const_column_view_type::ArrayType const_column_view;
158 : Parent(num_rows, num_cols, num_rows * num_cols),
159 pitch(cusp::detail::minor_dimension(num_rows, num_cols, orientation())),
160 values(num_rows * num_cols) {}
168 array2d(
size_t num_rows,
size_t num_cols,
const ValueType& value)
169 : Parent(num_rows, num_cols, num_rows * num_cols),
170 pitch(cusp::detail::minor_dimension(num_rows, num_cols, orientation())),
171 values(num_rows * num_cols, value) {}
180 array2d(
const size_t num_rows,
const size_t num_cols,
const ValueType& value,
const size_t pitch);
186 template <
typename MatrixType>
187 array2d(
const MatrixType& matrix);
194 typename values_array_type::reference
operator()(
const size_t i,
const size_t j);
201 typename values_array_type::const_reference
operator()(
const size_t i,
const size_t j)
const;
211 void resize(
const size_t num_rows,
const size_t num_cols);
223 void resize(
const size_t num_rows,
const size_t num_cols,
const size_t pitch);
234 row_view
row(
const size_t i);
240 column_view
column(
const size_t i);
246 const_row_view
row(
const size_t i)
const;
252 const_column_view
column(
const size_t i)
const;
265 template <
typename MatrixType>
318 template<
typename ArrayView,
class Orientation = cusp::row_major>
320 :
public cusp::detail::matrix_base<int,
321 typename ArrayView::value_type,
322 typename ArrayView::memory_space,
323 cusp::array2d_format>
327 typedef cusp::detail::matrix_base<int,
328 typename ArrayView::value_type,
329 typename ArrayView::memory_space,
330 cusp::array2d_format> Parent;
335 typedef Orientation orientation;
337 typedef ArrayView values_array_type;
343 typedef cusp::detail::row_or_column_view<
344 typename values_array_type::iterator,thrust::detail::is_same<Orientation,cusp::row_major>::value> row_view_type;
345 typedef typename row_view_type::ArrayType row_view;
347 typedef cusp::detail::row_or_column_view<
348 typename values_array_type::iterator,thrust::detail::is_same<Orientation,cusp::column_major>::value> column_view_type;
349 typedef typename column_view_type::ArrayType column_view;
389 template <
typename Array2>
391 : Parent(num_rows, num_cols, num_rows * num_cols), pitch(pitch), values(values) {}
398 typename values_array_type::reference
operator()(
const size_t i,
const size_t j)
const;
408 void resize(
const size_t num_rows,
const size_t num_cols);
420 void resize(
const size_t num_rows,
const size_t num_cols,
const size_t pitch);
426 row_view
row(
size_t i);
432 column_view
column(
size_t i);
438 row_view
row(
size_t i)
const;
444 column_view
column(
size_t i)
const;
457 template <
typename Iterator,
typename Orientation>
472 template <
typename Array,
typename Orientation>
488 template<
typename T,
class MemorySpace,
class Orientation>
504 template<
typename T,
class MemorySpace,
class Orientation>
515 #include <cusp/detail/array2d.inl>
void swap(array2d &matrix)
values_array_type::reference operator()(const size_t i, const size_t j)
The array1d_view class is a 1D vector container that wraps data from various iterators in a array1d d...
row_view row(const size_t i)
void resize(const size_t num_rows, const size_t num_cols)
array2d(size_t num_rows, size_t num_cols)
array2d(size_t num_rows, size_t num_cols, const ValueType &value)
The array2d_view is a view of a array2d container.
array1d_view< Iterator > make_array1d_view(Iterator first, Iterator last)
column_view column(const size_t i)
values_array_type::reference operator()(const size_t i, const size_t j) const
array2d_view< typename cusp::array1d_view< typename cusp::array1d< T, MemorySpace >::const_iterator >, Orientation > make_array2d_view(const cusp::array2d< T, MemorySpace, Orientation > &v)
The array2d class is a 2D vector container that may contain elements stored in "host" or "device" mem...
void resize(const size_t num_rows, const size_t num_cols)
array2d & operator=(const array2d &matrix)
1D array of elements that may reside in "host" or "device" memory space
column_view column(size_t i)