39 #ifndef ECUDA_MODEL_DEVICE_MATRIX_HPP
40 #define ECUDA_MODEL_DEVICE_MATRIX_HPP
42 #include "../global.hpp"
43 #include "../memory.hpp"
44 #include "../iterator.hpp"
59 template<
typename T,
class P>
60 class device_matrix :
public device_sequence<T,P>
63 typedef device_sequence<T,P> base_type;
66 typedef typename base_type::value_type value_type;
67 typedef typename base_type::pointer pointer;
68 typedef typename base_type::reference reference;
69 typedef typename base_type::const_reference const_reference;
70 typedef typename base_type::size_type size_type;
71 typedef typename base_type::difference_type difference_type;
73 typedef typename base_type::iterator iterator;
74 typedef typename base_type::const_iterator const_iterator;
75 typedef typename base_type::reverse_iterator reverse_iterator;
76 typedef typename base_type::const_reverse_iterator const_reverse_iterator;
78 typedef device_sequence< value_type, typename make_unmanaged<pointer>::type > row_type;
79 typedef device_sequence< const value_type, typename make_unmanaged_const<pointer>::type > const_row_type;
80 typedef device_sequence< value_type, striding_ptr<value_type,typename make_unmanaged<pointer>::type> > column_type;
81 typedef device_sequence< const value_type, striding_ptr<const value_type,typename make_unmanaged_const<pointer>::type> > const_column_type;
87 __HOST__ __DEVICE__ device_matrix( pointer ptr = pointer(), size_type rows = 0, size_type columns = 0 ) : base_type(ptr,rows*columns), rows(rows) {}
88 __HOST__ __DEVICE__ device_matrix(
const device_matrix& src ) : base_type(src), rows(src.rows) {}
89 __HOST__ device_matrix& operator=(
const device_matrix& src ) {
90 base_type::operator=(src);
94 #ifdef ECUDA_CPP11_AVAILABLE
95 __HOST__ device_matrix( device_matrix&& src ) : base_type(src), rows(std::move(src.rows)) {}
96 __HOST__ device_matrix& operator=( device_matrix&& src )
98 base_type::operator=( src );
99 rows = std::move(src.rows);
110 unmanaged_cast(base_type::get_pointer())+(row*number_columns()),
117 return const_row_type(
118 unmanaged_cast(base_type::get_pointer())+(row*number_columns()),
126 striding_ptr<value_type,
typename make_unmanaged<pointer>::type>(
127 unmanaged_cast(base_type::get_pointer())+column,
134 __HOST__ __DEVICE__ inline const_column_type get_column(
const size_type column )
const {
135 return const_column_type(
136 striding_ptr<
const value_type,
typename make_unmanaged_const<pointer>::type>(
137 unmanaged_cast(base_type::get_pointer())+column,
144 __HOST__ __DEVICE__ inline row_type operator[](
const size_type row ) {
return get_row(row); }
145 __HOST__ __DEVICE__ inline const_row_type operator[](
const size_type row )
const {
return get_row(row); }
__HOST__ __DEVICE__ void swap(T &a, T &b) __NOEXCEPT__