Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2026-09-22 Iñaki Ucar <iucar@fedoraproject.org>

* inst/include/Rcpp/sugar/matrix/col.h: Fix Col constructor using ncol()
instead of nrow() to set the number of rows
* inst/tinytest/test_sugar.R: Add a non-square matrix test case for the
row()/col() sugar functions

2026-09-05 Iñaki Ucar <iucar@fedoraproject.org>

* .github/workflows/werror.yaml: Add -Wconversion
Expand Down
2 changes: 1 addition & 1 deletion inst/include/Rcpp/sugar/matrix/col.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Col : public MatrixBase<
public:
typedef Rcpp::MatrixBase<RTYPE,LHS_NA,LHS_T> LHS_TYPE ;

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

inline int operator()( int /*i*/, int j ) const {
return j + 1 ;
Expand Down
8 changes: 8 additions & 0 deletions inst/tinytest/test_sugar.R
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,14 @@ target <- list( row = row(m), col = col(m) )
expect_equal( res, target )


# test.sugar.matrix.row.nonsquare <- function( ){
fx <- runit_row
m <- matrix(1:24, nrow = 6, ncol = 4)
res <- fx(m)
target <- list(row = row(m), col = col(m))
expect_equal(res, target)


# test.sugar.diag <- function( ){
fx <- runit_diag

Expand Down
Loading