1#ifndef TATAMI_MAKE_DELAYED_SUBSET_HPP
2#define TATAMI_MAKE_DELAYED_SUBSET_HPP
38template<
typename Value_,
typename Index_,
class SubsetStorage_>
40 bool is_unsorted =
false;
41 for (Index_ i = 0, end = subset.size(); i < end; ++i) {
43 if (subset[i] < subset[i-1]) {
51 bool has_duplicates =
false;
52 for (Index_ i = 0, end = subset.size(); i < end; ++i) {
54 if (subset[i] == subset[i-1]) {
55 has_duplicates =
true;
61 if (!has_duplicates) {
62 bool consecutive =
true;
63 for (Index_ i = 0, end = subset.size(); i < end; ++i) {
65 if (subset[i] > subset[i-1] + 1) {
73 auto start = (subset.size() ? subset[0] : 0);
74 return std::shared_ptr<Matrix<Value_, Index_> >(
78 return std::shared_ptr<Matrix<Value_, Index_> >(
83 return std::shared_ptr<Matrix<Value_, Index_> >(
89 bool has_duplicates =
false;
90 std::vector<unsigned char> accumulated(by_row ? matrix->nrow() : matrix->ncol());
91 for (Index_ i = 0, end = subset.size(); i < end; ++i) {
92 auto& found = accumulated[subset[i]];
94 has_duplicates =
true;
101 if (!has_duplicates) {
102 return std::shared_ptr<Matrix<Value_, Index_> >(
106 return std::shared_ptr<Matrix<Value_, Index_> >(
115template<
typename Value_,
typename Index_,
class SubsetStorage_>
116std::shared_ptr<Matrix<Value_, Index_> >
make_DelayedSubset(std::shared_ptr<Matrix<Value_, Index_> > matrix, SubsetStorage_ subset,
bool by_row) {
127template<
int margin_,
typename Value_,
typename Index_,
class SubsetStorage_>
128std::shared_ptr<Matrix<Value_, Index_> >
make_DelayedSubset(std::shared_ptr<
const Matrix<Value_, Index_> > matrix, SubsetStorage_ subset) {
132template<
int margin_,
typename Value_,
typename Index_,
class SubsetStorage_>
133std::shared_ptr<Matrix<Value_, Index_> >
make_DelayedSubset(std::shared_ptr<Matrix<Value_, Index_> > matrix, SubsetStorage_ subset) {
Defines a tatami-compatible array view.
Delayed subsetting to a single contiguous block.
Delayed subsetting with sorted and unique row/column indices.
Delayed subsetting with sorted row/column indices.
Delayed subsetting by unique row/column indices.
Delayed subsetting by rows or columns.
Delayed subsetting to a contiguous block.
Definition DelayedSubsetBlock.hpp:167
Delayed subsetting of a matrix with sorted, unique indices.
Definition DelayedSubsetSortedUnique.hpp:162
Delayed subsetting of a matrix with sorted indices.
Definition DelayedSubsetSorted.hpp:334
Delayed subsetting of a matrix with unique indices.
Definition DelayedSubsetUnique.hpp:270
Delayed subsetting of a matrix with general indices.
Definition DelayedSubset.hpp:382
Virtual class for a matrix.
Definition Matrix.hpp:59
Flexible representations for matrix data.
Definition Extractor.hpp:15
std::shared_ptr< Matrix< Value_, Index_ > > make_DelayedSubset(std::shared_ptr< const Matrix< Value_, Index_ > > matrix, SubsetStorage_ subset, bool by_row)
Definition make_DelayedSubset.hpp:39