Skip to content

Commit 4a9c6a8

Browse files
committed
minor simplification to #622, tested locally
1 parent 8e5a3e8 commit 4a9c6a8

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2016-12-31 Dirk Eddelbuettel <[email protected]>
2+
3+
* inst/include/Rcpp/vector/Matrix.h: Minor simplification
4+
15
2016-12-31 James J Balamuta <[email protected]>
26

37
* inst/include/Rcpp/vector/Matrix.h: Fixed non-symmetric case of matrix

inst/include/Rcpp/vector/Matrix.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,7 @@ class Matrix : public Vector<RTYPE, StoragePolicy>, public MatrixBase<RTYPE, tru
177177
void fill_diag__dispatch( traits::false_type, const U& u) {
178178
Shield<SEXP> elem( converter_type::get( u ) );
179179

180-
R_xlen_t bounds = ( Matrix::nrow() < Matrix::ncol() ) ?
181-
Matrix::nrow() : Matrix::ncol();
182-
180+
R_xlen_t bounds = std::min(Matrix::nrow(), Matrix::ncol());
183181
for (R_xlen_t i = 0; i < bounds; ++i) {
184182
(*this)(i, i) = elem;
185183
}
@@ -188,12 +186,11 @@ class Matrix : public Vector<RTYPE, StoragePolicy>, public MatrixBase<RTYPE, tru
188186
template <typename U>
189187
void fill_diag__dispatch( traits::true_type, const U& u) {
190188
stored_type elem = converter_type::get( u );
191-
192-
R_xlen_t bounds = ( Matrix::nrow() < Matrix::ncol() ) ?
193-
Matrix::nrow() : Matrix::ncol();
189+
190+
R_xlen_t bounds = std::min(Matrix::nrow(), Matrix::ncol());
194191

195192
for (R_xlen_t i = 0; i < bounds; ++i) {
196-
(*this)(i, i) = elem;
193+
(*this)(i, i) = elem;
197194
}
198195
}
199196

0 commit comments

Comments
 (0)