tatami
C++ API for different matrix representations
Loading...
Searching...
No Matches
DelayedTranspose.hpp
Go to the documentation of this file.
1#ifndef TATAMI_DELAYED_TRANSPOSE
2#define TATAMI_DELAYED_TRANSPOSE
3
4#include "../base/Matrix.hpp"
5#include <memory>
6
15namespace tatami {
16
26template<typename Value_, typename Index_>
27class DelayedTranspose : public Matrix<Value_, Index_> {
28public:
32 DelayedTranspose(std::shared_ptr<const Matrix<Value_, Index_> > matrix) : my_matrix(std::move(matrix)) {}
33
34private:
35 std::shared_ptr<const Matrix<Value_, Index_> > my_matrix;
36
37public:
38 Index_ nrow() const {
39 return my_matrix->ncol();
40 }
41
42 Index_ ncol() const {
43 return my_matrix->nrow();
44 }
45
46 bool is_sparse() const {
47 return my_matrix->is_sparse();
48 }
49
50 double is_sparse_proportion() const {
51 return my_matrix->is_sparse_proportion();
52 }
53
54 bool prefer_rows() const {
55 return !my_matrix->prefer_rows();
56 }
57
58 double prefer_rows_proportion() const {
59 return 1 - my_matrix->prefer_rows_proportion();
60 }
61
62 bool uses_oracle(bool row) const {
63 return my_matrix->uses_oracle(!row);
64 }
65
67
69
70 /********************
71 *** Myopic dense ***
72 ********************/
73public:
74 std::unique_ptr<MyopicDenseExtractor<Value_, Index_> > dense(bool row, const Options& opt) const {
75 return my_matrix->dense(!row, opt);
76 }
77
78 std::unique_ptr<MyopicDenseExtractor<Value_, Index_> > dense(bool row, Index_ block_start, Index_ block_length, const Options& opt) const {
79 return my_matrix->dense(!row, block_start, block_length, opt);
80 }
81
82 std::unique_ptr<MyopicDenseExtractor<Value_, Index_> > dense(bool row, VectorPtr<Index_> indices_ptr, const Options& opt) const {
83 return my_matrix->dense(!row, std::move(indices_ptr), opt);
84 }
85
86 /*********************
87 *** Myopic sparse ***
88 *********************/
89public:
90 std::unique_ptr<MyopicSparseExtractor<Value_, Index_> > sparse(bool row, const Options& opt) const {
91 return my_matrix->sparse(!row, opt);
92 }
93
94 std::unique_ptr<MyopicSparseExtractor<Value_, Index_> > sparse(bool row, Index_ block_start, Index_ block_length, const Options& opt) const {
95 return my_matrix->sparse(!row, block_start, block_length, opt);
96 }
97
98 std::unique_ptr<MyopicSparseExtractor<Value_, Index_> > sparse(bool row, VectorPtr<Index_> indices_ptr, const Options& opt) const {
99 return my_matrix->sparse(!row, std::move(indices_ptr), opt);
100 }
101
102 /**********************
103 *** Oracular dense ***
104 **********************/
105public:
106 std::unique_ptr<OracularDenseExtractor<Value_, Index_> > dense(bool row, std::shared_ptr<const Oracle<Index_> > oracle, const Options& opt) const {
107 return my_matrix->dense(!row, std::move(oracle), opt);
108 }
109
110 std::unique_ptr<OracularDenseExtractor<Value_, Index_> > dense(bool row, std::shared_ptr<const Oracle<Index_> > oracle, Index_ block_start, Index_ block_length, const Options& opt) const {
111 return my_matrix->dense(!row, std::move(oracle), block_start, block_length, opt);
112 }
113
114 std::unique_ptr<OracularDenseExtractor<Value_, Index_> > dense(bool row, std::shared_ptr<const Oracle<Index_> > oracle, VectorPtr<Index_> indices_ptr, const Options& opt) const {
115 return my_matrix->dense(!row, std::move(oracle), std::move(indices_ptr), opt);
116 }
117
118 /***********************
119 *** Oracular sparse ***
120 ***********************/
121public:
122 std::unique_ptr<OracularSparseExtractor<Value_, Index_> > sparse(bool row, std::shared_ptr<const Oracle<Index_> > oracle, const Options& opt) const {
123 return my_matrix->sparse(!row, std::move(oracle), opt);
124 }
125
126 std::unique_ptr<OracularSparseExtractor<Value_, Index_> > sparse(bool row, std::shared_ptr<const Oracle<Index_> > oracle, Index_ block_start, Index_ block_length, const Options& opt) const {
127 return my_matrix->sparse(!row, std::move(oracle), block_start, block_length, opt);
128 }
129
130 std::unique_ptr<OracularSparseExtractor<Value_, Index_> > sparse(bool row, std::shared_ptr<const Oracle<Index_> > oracle, VectorPtr<Index_> indices, const Options& opt) const {
131 return my_matrix->sparse(!row, std::move(oracle), std::move(indices), opt);
132 }
133};
134
145template<typename Value_, typename Index_>
146std::shared_ptr<Matrix<Value_, Index_> > make_DelayedTranspose(std::shared_ptr<const Matrix<Value_, Index_> > matrix) {
147 return std::shared_ptr<Matrix<Value_, Index_> >(new DelayedTranspose<Value_, Index_>(std::move(matrix)));
148}
149
153template<typename Value_, typename Index_>
154std::shared_ptr<Matrix<Value_, Index_> > make_DelayedTranspose(std::shared_ptr<Matrix<Value_, Index_> > matrix) {
155 return std::shared_ptr<Matrix<Value_, Index_> >(new DelayedTranspose<Value_, Index_>(std::move(matrix)));
156}
161}
162
163#endif
Delayed transposition of a matrix.
Definition DelayedTranspose.hpp:27
DelayedTranspose(std::shared_ptr< const Matrix< Value_, Index_ > > matrix)
Definition DelayedTranspose.hpp:32
std::unique_ptr< MyopicSparseExtractor< Value_, Index_ > > sparse(bool row, Index_ block_start, Index_ block_length, const Options &opt) const
Definition DelayedTranspose.hpp:94
std::unique_ptr< MyopicDenseExtractor< Value_, Index_ > > dense(bool row, VectorPtr< Index_ > indices_ptr, const Options &opt) const
Definition DelayedTranspose.hpp:82
std::unique_ptr< MyopicDenseExtractor< Value_, Index_ > > dense(bool row, Index_ block_start, Index_ block_length, const Options &opt) const
Definition DelayedTranspose.hpp:78
std::unique_ptr< MyopicDenseExtractor< Value_, Index_ > > dense(bool row, const Options &opt) const
Definition DelayedTranspose.hpp:74
Index_ ncol() const
Definition DelayedTranspose.hpp:42
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > sparse(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, Index_ block_start, Index_ block_length, const Options &opt) const
Definition DelayedTranspose.hpp:126
std::unique_ptr< MyopicSparseExtractor< Value_, Index_ > > sparse(bool row, VectorPtr< Index_ > indices_ptr, const Options &opt) const
Definition DelayedTranspose.hpp:98
bool is_sparse() const
Definition DelayedTranspose.hpp:46
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > dense(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, Index_ block_start, Index_ block_length, const Options &opt) const
Definition DelayedTranspose.hpp:110
bool uses_oracle(bool row) const
Definition DelayedTranspose.hpp:62
std::unique_ptr< MyopicSparseExtractor< Value_, Index_ > > sparse(bool row, const Options &opt) const
Definition DelayedTranspose.hpp:90
bool prefer_rows() const
Definition DelayedTranspose.hpp:54
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > sparse(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const
Definition DelayedTranspose.hpp:122
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > sparse(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, VectorPtr< Index_ > indices, const Options &opt) const
Definition DelayedTranspose.hpp:130
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > dense(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const
Definition DelayedTranspose.hpp:106
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > dense(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, VectorPtr< Index_ > indices_ptr, const Options &opt) const
Definition DelayedTranspose.hpp:114
Index_ nrow() const
Definition DelayedTranspose.hpp:38
double is_sparse_proportion() const
Definition DelayedTranspose.hpp:50
double prefer_rows_proportion() const
Definition DelayedTranspose.hpp:58
Virtual class for a matrix.
Definition Matrix.hpp:59
Predict future access requests on the target dimension.
Definition Oracle.hpp:21
Flexible representations for matrix data.
Definition Extractor.hpp:15
std::shared_ptr< const std::vector< Index_ > > VectorPtr
Definition Matrix.hpp:26
std::shared_ptr< Matrix< Value_, Index_ > > make_DelayedTranspose(std::shared_ptr< const Matrix< Value_, Index_ > > matrix)
Definition DelayedTranspose.hpp:146
auto consecutive_extractor(const Matrix< Value_, Index_ > *mat, bool row, Index_ iter_start, Index_ iter_length, Args_ &&... args)
Definition consecutive_extractor.hpp:35
Options for accessing data from a Matrix instance.
Definition Options.hpp:30