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