1 #ifndef GENESIS_UTILS_CONTAINERS_MATRIX_ROW_H_ 2 #define GENESIS_UTILS_CONTAINERS_MATRIX_ROW_H_ 39 #include <type_traits> 59 template <
typename MT,
typename T>
144 return (*mat_)( row_, col_ + n );
149 return (*mat_)( row_, col_ );
154 return &((*mat_)( row_, col_ ));
197 return self_type( it.mat_, it.row_, it.col_ + n );
202 return self_type( it.mat_, it.row_, it.col_ + n );
207 return self_type( it.mat_, it.row_, it.col_ - n );
212 return col_ - other.col_;
217 return other.mat_ == mat_ && other.row_ == row_ && other.col_ == col_;
222 return !(other == *
this);
227 return col_ < other.col_;
232 return col_ <= other.col_;
237 return col_ > other.col_;
242 return col_ >= other.col_;
248 swap( mat_, other.mat_ );
249 swap( row_, other.row_ );
250 swap( col_, other.col_ );
287 return Iterator( mat_, row_, mat_->cols() );
295 return mat_->at( row_, column );
303 return (*mat_)( row_, column );
337 operator std::vector<non_const_value_type>()
const 347 auto result = std::vector<non_const_value_type>( mat_->cols() );
348 for(
size_t i = 0; i < mat_->cols(); ++i ) {
349 result[i] = (*mat_)( row_, i );
361 if( vec.size() != mat_->cols() ) {
362 throw std::runtime_error(
"Cannot assign vector with different size to Matrix row." );
365 for(
size_t i = 0; i < vec.size(); ++i ) {
366 (*mat_)( row_, i ) = vec[i];
380 if( other.
size() != mat_->cols() ) {
381 throw std::runtime_error(
"Cannot assign row with different size to Matrix row." );
384 for(
size_t i = 0; i < other.
size(); ++i ) {
385 (*mat_)( row_, i ) = other[i];
402 if( mat_->cols() != other.mat_->cols() ) {
407 for(
size_t i = 0; i < mat_->cols(); ++i ) {
408 if( !( (*mat_)( row_, i ) == other[ i ] )) {
421 return !(*
this == other);
438 #endif // include guard friend self_type operator+(difference_type n, self_type const &it)
bool operator>=(self_type const &other) const
friend void swap(self_type &lhs, self_type &rhs)
value_type & at(size_t column) const
Return the element at a given column of the Matrix row.
Iterator end() const
Return an iterator to past-the-end of the row.
void swap(SequenceSet &lhs, SequenceSet &rhs)
MatrixRow< MT, T >::Iterator self_type
friend self_type operator-(self_type const &it, difference_type n)
typename std::remove_const< T >::type non_const_value_type
Container namespace for all symbols of genesis in order to keep them separate when used as a library...
bool operator==(self_type const &other) const
MatrixRow & operator=(MatrixRow const &)=default
MatrixRow(matrix_type &mat, size_t row)
self_type & assign(self_type const &other)
Overwrite a row by the elements of another row.
self_type operator-=(difference_type n)
bool operator!=(self_type const &other) const
Iterator begin() const
Return an iterator to the beginning of the row.
value_type & operator[](difference_type n) const
size_t row() const
Get the row index that this object represents.
size_t size() const
Get the size of the row, that is, the number of columns of the Matrix.
Iterator & operator=(Iterator const &)=default
value_type & operator*() const
bool operator<=(self_type const &other) const
std::vector< non_const_value_type > to_vector() const
Explicit conversion to vector.
value_type * operator->() const
std::random_access_iterator_tag iterator_category
void swap(self_type &other)
ptrdiff_t difference_type
self_type operator+=(difference_type n)
matrix_type & matrix() const
Get the underlying Matrix.
bool operator<(self_type const &other) const
Random access iterator into a Matrix row.
value_type & operator[](size_t column) const
Return the element at a given column of the Matrix row.
bool operator>(self_type const &other) const