Skip to content

Commit fc1dd88

Browse files
committed
update matrix API to allow both rows and columns
1 parent d527c44 commit fc1dd88

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

inst/include/cpp11/matrix.hpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,17 @@ class matrix {
140140

141141
r_vector<r_string> names() const { return SEXP(vector_.names()); }
142142

143-
row operator[](const int pos) { return {*this, pos}; }
143+
row row_at(const int pos) { return {*this, pos}; }
144+
column column_at(const int pos) { return {*this, pos}; }
144145

145-
T operator()(int row, int col) { return vector_[row + (col * nrow_)]; }
146+
T at(int row, int col) { return vector_[row + (col * nrow_)]; }
147+
T operator()(int row, int col) { return at(row, col); }
146148

147-
row begin() { return {*this, 0}; }
148-
row end() { return {*this, nrow_}; }
149+
row rows_begin() { return {*this, 0}; }
150+
row rows_end() { return {*this, nrow()}; }
151+
152+
column columns_begin() { return {*this, 0}; }
153+
column columns_end() { return {*this, ncol()}; }
149154
};
150155

151156
using doubles_matrix = matrix<r_vector<double>, double>;

0 commit comments

Comments
 (0)