Skip to content

Commit 1224acc

Browse files
committed
small fix in Col constructor
1 parent f33b2eb commit 1224acc

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

‎ChangeLog‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2026-09-22 Iñaki Ucar <iucar@fedoraproject.org>
2+
3+
* inst/include/Rcpp/sugar/matrix/col.h: Fix Col constructor using ncol()
4+
instead of nrow() to set the number of rows
5+
* inst/tinytest/test_sugar.R: Add a non-square matrix test case for the
6+
row()/col() sugar functions
7+
18
2026-09-05 Iñaki Ucar <iucar@fedoraproject.org>
29

310
* .github/workflows/werror.yaml: Add -Wconversion

‎inst/include/Rcpp/sugar/matrix/col.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Col : public MatrixBase<
3535
public:
3636
typedef Rcpp::MatrixBase<RTYPE,LHS_NA,LHS_T> LHS_TYPE ;
3737

38-
Col( const LHS_TYPE& lhs) : nr( static_cast<int>(lhs.ncol()) ), nc( static_cast<int>(lhs.ncol()) ) {}
38+
Col( const LHS_TYPE& lhs) : nr( static_cast<int>(lhs.nrow()) ), nc( static_cast<int>(lhs.ncol()) ) {}
3939

4040
inline int operator()( int /*i*/, int j ) const {
4141
return j + 1 ;

‎inst/tinytest/test_sugar.R‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,14 @@ target <- list( row = row(m), col = col(m) )
592592
expect_equal( res, target )
593593

594594

595+
# test.sugar.matrix.row.nonsquare <- function( ){
596+
fx <- runit_row
597+
m <- matrix(1:24, nrow = 6, ncol = 4)
598+
res <- fx(m)
599+
target <- list(row = row(m), col = col(m))
600+
expect_equal(res, target)
601+
602+
595603
# test.sugar.diag <- function( ){
596604
fx <- runit_diag
597605

0 commit comments

Comments
 (0)