|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file. 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
std::vector< non_const_value_type > to_vector() const
Explicit conversion to vector.
void swap(Sample &lhs, Sample &rhs)
friend self_type operator+(difference_type n, self_type const &it)
value_type & operator*() const
self_type & assign(self_type const &other)
Overwrite a row by the elements of another row.
bool operator!=(self_type const &other) const
bool operator<=(self_type const &other) const
void swap(self_type &other)
typename std::remove_const< T >::type non_const_value_type
Random access iterator into a Matrix row.
MatrixRow(matrix_type &mat, size_t row)
bool operator<(self_type const &other) const
MatrixRow & operator=(MatrixRow const &)=default
bool operator!=(self_type const &other) const
Return whether the elements of two rows are identical, using == for comparing elements.
friend void swap(self_type &lhs, self_type &rhs)
Iterator begin() const
Return an iterator to the beginning of the row.
size_t size() const
Get the size of the row, that is, the number of columns of the Matrix.
Iterator end() const
Return an iterator to past-the-end of the row.
ptrdiff_t difference_type
bool operator>=(self_type const &other) const
self_type operator+=(difference_type n)
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
size_t row() const
Get the row index that this object represents.
bool operator==(self_type const &other) const
std::random_access_iterator_tag iterator_category
Iterator & operator=(Iterator const &)=default
friend self_type operator-(self_type const &it, difference_type n)
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
Return whether the elements of two rows are identical, using == for comparing elements.
bool operator>(self_type const &other) const
self_type operator-=(difference_type n)
value_type & at(size_t column) const
Return the element at a given column of the Matrix row.
value_type & operator[](difference_type n) const
matrix_type & matrix() const
Get the underlying Matrix.
MatrixRow< MT, T >::Iterator self_type
value_type * operator->() const