23#include <cusp/detail/config.h>
24#include <cusp/detail/format.h>
27#include <cusp/memory.h>
29#include <cusp/detail/array2d_format_utils.h>
30#include <cusp/detail/matrix_base.h>
32#include <thrust/functional.h>
92template<
typename ValueType,
typename MemorySpace,
typename Orientation = cusp::row_major>
93class array2d :
public cusp::detail::matrix_base<int,ValueType,MemorySpace,cusp::array2d_format>
97 typedef 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,::cuda::std::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,::cuda::std::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,::cuda::std::is_same<Orientation,cusp::row_major>::value
128 > const_row_view_type;
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,::cuda::std::is_same<Orientation,cusp::column_major>::value
134 > const_column_view_type;
136 typedef typename const_column_view_type::ArrayType const_column_view;
138 typedef typename cusp::detail::transpose_orientation<Orientation>::type transpose_orientation;
161 : Parent(num_rows, num_cols, num_rows * num_cols),
162 pitch(cusp::detail::minor_dimension(num_rows, num_cols, orientation())),
163 values(num_rows * num_cols) {}
171 array2d(
size_t num_rows,
size_t num_cols,
const ValueType& value)
172 : Parent(num_rows, num_cols, num_rows * num_cols),
173 pitch(cusp::detail::minor_dimension(num_rows, num_cols, orientation())),
174 values(num_rows * num_cols, value) {}
183 array2d(
const size_t num_rows,
const size_t num_cols,
const ValueType& value,
const size_t pitch);
189 template <
typename MatrixType>
197 typename values_array_type::reference
operator()(
const size_t i,
const size_t j);
204 typename values_array_type::const_reference
operator()(
const size_t i,
const size_t j)
const;
214 void resize(
const size_t num_rows,
const size_t num_cols);
226 void resize(
const size_t num_rows,
const size_t num_cols,
const size_t pitch);
237 row_view
row(
const size_t i);
249 const_row_view
row(
const size_t i)
const;
255 const_column_view
column(
const size_t i)
const;
268 template <
typename MatrixType>
275 transpose_const_view_type
T(
void)
const;
327template<
typename ArrayView,
class Orientation = cusp::row_major>
329 :
public cusp::detail::matrix_base<int,
330 typename ArrayView::value_type,
331 typename ArrayView::memory_space,
332 cusp::array2d_format>
336 typedef cusp::detail::matrix_base<int,
337 typename ArrayView::value_type,
338 typename ArrayView::memory_space,
339 cusp::array2d_format> Parent;
344 typedef Orientation orientation;
346 typedef ArrayView values_array_type;
352 typedef cusp::detail::row_or_column_view<
353 typename values_array_type::iterator,::cuda::std::is_same<Orientation,cusp::row_major>::value
355 typedef typename row_view_type::ArrayType row_view;
357 typedef cusp::detail::row_or_column_view<
358 typename values_array_type::iterator,::cuda::std::is_same<Orientation,cusp::column_major>::value
360 typedef typename column_view_type::ArrayType column_view;
362 typedef typename cusp::detail::transpose_orientation<Orientation>::type transpose_orientation;
403 template <
typename Array2>
412 typename values_array_type::reference
operator()(
const size_t i,
const size_t j)
const;
422 void resize(
const size_t num_rows,
const size_t num_cols);
434 void resize(
const size_t num_rows,
const size_t num_cols,
const size_t pitch);
452 row_view
row(
size_t i)
const;
464 transpose_const_view_type
T(
void)
const;
477template <
typename Iterator,
typename Orientation>
492template <
typename Array,
typename Orientation>
493array2d_view<Array,Orientation>
508template<
typename T,
class MemorySpace,
class Orientation>
509array2d_view<typename cusp::array1d_view<typename cusp::array1d<T,MemorySpace>::iterator>, Orientation>
524template<
typename T,
class MemorySpace,
class Orientation>
525array2d_view<typename cusp::array1d_view<typename cusp::array1d<T,MemorySpace>::const_iterator>, Orientation>
535#include <cusp/detail/array2d.inl>
1D array of elements that may reside in "host" or "device" memory space
The array1d_view class is a 1D vector container that wraps data from various iterators in a array1d d...
The array1d class is a 1D vector container that may contain elements stored in "host" or "device" mem...
The array2d_view is a view of a array2d container.
void resize(const size_t num_rows, const size_t num_cols)
values_array_type::reference operator()(const size_t i, const size_t j) const
column_view column(size_t i) const
row_view row(size_t i) const
array2d_view(size_t num_rows, size_t num_cols, size_t pitch, const Array2 &values)
void resize(const size_t num_rows, const size_t num_cols, const size_t pitch)
array2d_view(const array2d_view &a)
transpose_const_view_type T(void) const
array2d_view(array2d< typename Parent::value_type, typename Parent::memory_space, orientation > &a)
column_view column(size_t i)
The array2d class is a 2D vector container that may contain elements stored in "host" or "device" mem...
values_array_type::const_reference operator()(const size_t i, const size_t j) const
values_array_type::reference operator()(const size_t i, const size_t j)
const_column_view column(const size_t i) const
array2d(const size_t num_rows, const size_t num_cols, const ValueType &value, const size_t pitch)
transpose_const_view_type T(void) const
column_view column(const size_t i)
array2d & operator=(const MatrixType &matrix)
array2d(const MatrixType &matrix)
void resize(const size_t num_rows, const size_t num_cols)
array2d(size_t num_rows, size_t num_cols, const ValueType &value)
row_view row(const size_t i)
void resize(const size_t num_rows, const size_t num_cols, const size_t pitch)
const_row_view row(const size_t i) const
array2d & operator=(const array2d &matrix)
void swap(array2d &matrix)
array2d(size_t num_rows, size_t num_cols)
array1d_view< Iterator > make_array1d_view(Iterator first, Iterator last)
array2d_view< typename cusp::array1d_view< Iterator >, Orientation > make_array2d_view(size_t num_rows, size_t num_cols, size_t pitch, const cusp::array1d_view< Iterator > &values, Orientation)