Skip to content

Commit 2c0f75a

Browse files
committed
Adjust tests and example to deprecations
1 parent 771df90 commit 2c0f75a

File tree

8 files changed

+72
-62
lines changed

8 files changed

+72
-62
lines changed

ChangeLog

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
* inst/include/Eigen/: Sync with upstream Eigen 5.0.0 (aka 3.5.0)
44
* inst/include/unsupported/Eigen/: Idem
55

6+
* patches/eigen-5.0.0.diff: Summary of changes applied
7+
8+
* inst/include/RcppEigenForward.h: No longer use deprecated type
9+
* inst/include/RcppEigenWrap.h: Idem
10+
* inst/tinytest/cpp/rcppeigen.cpp: Adjust test to non-deprecated map
11+
* inst/tinytest/cpp/sparse.cpp: Skip test of deprecated type
12+
* inst/tinytest/test_sparse.R: Idem
13+
14+
* src/fastLm.cpp (SVD::SVD): Update to current form of option setting
15+
616
2025-08-26 Dirk Eddelbuettel <edd@debian.org>
717

818
* inst/tinytest/test_misc.R: Add minimal test for EigenNbThreads()

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: RcppEigen
22
Type: Package
33
Title: 'Rcpp' Integration for the 'Eigen' Templated Linear Algebra Library
4-
Version: 0.3.4.0.2.1
5-
Date: 2025-08-26
4+
Version: 0.4.9.9-0
5+
Date: 2025-12-25
66
Authors@R: c(person("Doug", "Bates", role = "aut",
77
comment = c(ORCID = "0000-0001-8316-9503")),
88
person("Dirk", "Eddelbuettel", role = c("aut", "cre"), email = "edd@debian.org",

inst/include/RcppEigenForward.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ namespace Rcpp {
5454
template<typename T> class Exporter< Eigen::Array<T, Eigen::Dynamic, 1> >;
5555
template<typename T> class Exporter< Eigen::Array<T, 1, Eigen::Dynamic> >;
5656
template<typename T> class Exporter< Eigen::Map<Eigen::SparseMatrix<T> > >;
57-
template<typename T> class Exporter< Eigen::MappedSparseMatrix<T> >; // Deprecated
57+
//template<typename T> class Exporter< Eigen::MappedSparseMatrix<T> >; // Deprecated
5858
template<typename T> class Exporter< Eigen::SparseMatrix<T> >;
5959
template<typename T> class Exporter< Eigen::Map<Eigen::SparseMatrix<T, Eigen::RowMajor> > >;
60-
template<typename T> class Exporter< Eigen::MappedSparseMatrix<T, Eigen::RowMajor> >; // Deprecated
60+
//template<typename T> class Exporter< Eigen::MappedSparseMatrix<T, Eigen::RowMajor> >; // Deprecated
6161
template<typename T> class Exporter< Eigen::SparseMatrix<T, Eigen::RowMajor> >;
6262

6363
} // namespace traits

inst/include/RcppEigenWrap.h

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -310,24 +310,24 @@ namespace Rcpp{
310310
IntegerVector d_dims, d_i, d_p;
311311
Vector<RTYPE> xx ;
312312
};
313-
// Deprecated
314-
template<typename T>
315-
class Exporter<Eigen::MappedSparseMatrix<T> > {
316-
public:
317-
const static int RTYPE = ::Rcpp::traits::r_sexptype_traits<T>::rtype ;
318-
Exporter(SEXP x) : d_x(x), d_dims(d_x.slot("Dim")), d_i(d_x.slot("i")), d_p(d_x.slot("p")), xx( d_x.slot("x") ) {
319-
if (!d_x.is("dgCMatrix"))
320-
throw std::invalid_argument("Need S4 class dgCMatrix for a mapped sparse matrix");
321-
}
322-
Eigen::MappedSparseMatrix<T> get() {
323-
return Eigen::MappedSparseMatrix<T>(d_dims[0], d_dims[1], d_p[d_dims[1]],
324-
d_p.begin(), d_i.begin(), xx.begin() );
325-
}
326-
protected:
327-
S4 d_x;
328-
IntegerVector d_dims, d_i, d_p;
329-
Vector<RTYPE> xx ;
330-
};
313+
// // Deprecated
314+
// template<typename T>
315+
// class Exporter<Eigen::MappedSparseMatrix<T> > {
316+
// public:
317+
// const static int RTYPE = ::Rcpp::traits::r_sexptype_traits<T>::rtype ;
318+
// Exporter(SEXP x) : d_x(x), d_dims(d_x.slot("Dim")), d_i(d_x.slot("i")), d_p(d_x.slot("p")), xx( d_x.slot("x") ) {
319+
// if (!d_x.is("dgCMatrix"))
320+
// throw std::invalid_argument("Need S4 class dgCMatrix for a mapped sparse matrix");
321+
// }
322+
// Eigen::MappedSparseMatrix<T> get() {
323+
// return Eigen::MappedSparseMatrix<T>(d_dims[0], d_dims[1], d_p[d_dims[1]],
324+
// d_p.begin(), d_i.begin(), xx.begin() );
325+
// }
326+
// protected:
327+
// S4 d_x;
328+
// IntegerVector d_dims, d_i, d_p;
329+
// Vector<RTYPE> xx ;
330+
// };
331331

332332
// Starting from Eigen 3.3 MappedSparseMatrix was deprecated.
333333
// The new type is Map<SparseMatrix>.
@@ -348,24 +348,24 @@ namespace Rcpp{
348348
IntegerVector d_dims, d_j, d_p;
349349
Vector<RTYPE> xx ;
350350
};
351-
// Deprecated
352-
template<typename T>
353-
class Exporter<Eigen::MappedSparseMatrix<T, Eigen::RowMajor> > {
354-
public:
355-
const static int RTYPE = ::Rcpp::traits::r_sexptype_traits<T>::rtype ;
356-
Exporter(SEXP x) : d_x(x), d_dims(d_x.slot("Dim")), d_j(d_x.slot("j")), d_p(d_x.slot("p")), xx( d_x.slot("x") ) {
357-
if (!d_x.is("dgRMatrix"))
358-
throw std::invalid_argument("Need S4 class dgRMatrix for a mapped sparse matrix");
359-
}
360-
Eigen::MappedSparseMatrix<T, Eigen::RowMajor> get() {
361-
return Eigen::MappedSparseMatrix<T, Eigen::RowMajor>(d_dims[0], d_dims[1], d_p[d_dims[1]],
362-
d_p.begin(), d_j.begin(), xx.begin() );
363-
}
364-
protected:
365-
S4 d_x;
366-
IntegerVector d_dims, d_j, d_p;
367-
Vector<RTYPE> xx ;
368-
};
351+
// // Deprecated
352+
// template<typename T>
353+
// class Exporter<Eigen::MappedSparseMatrix<T, Eigen::RowMajor> > {
354+
// public:
355+
// const static int RTYPE = ::Rcpp::traits::r_sexptype_traits<T>::rtype ;
356+
// Exporter(SEXP x) : d_x(x), d_dims(d_x.slot("Dim")), d_j(d_x.slot("j")), d_p(d_x.slot("p")), xx( d_x.slot("x") ) {
357+
// if (!d_x.is("dgRMatrix"))
358+
// throw std::invalid_argument("Need S4 class dgRMatrix for a mapped sparse matrix");
359+
// }
360+
// Eigen::MappedSparseMatrix<T, Eigen::RowMajor> get() {
361+
// return Eigen::MappedSparseMatrix<T, Eigen::RowMajor>(d_dims[0], d_dims[1], d_p[d_dims[1]],
362+
// d_p.begin(), d_j.begin(), xx.begin() );
363+
// }
364+
// protected:
365+
// S4 d_x;
366+
// IntegerVector d_dims, d_j, d_p;
367+
// Vector<RTYPE> xx ;
368+
// };
369369

370370
template<typename T>
371371
class Exporter<Eigen::SparseMatrix<T> > {

inst/tinytest/cpp/rcppeigen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ Rcpp::List fx5(Rcpp::List input) {
131131

132132
// [[Rcpp::export]]
133133
Rcpp::List fx6(Rcpp::List input) {
134-
const Eigen::MappedSparseMatrix<double> m1 = input[0]; // maps share storage and do not allow conversion
134+
const Eigen::Map<Eigen::SparseMatrix<double>> m1 = input[0]; // maps share storage and do not allow conversion
135135

136136
Rcpp::List res = Rcpp::List::create(Rcpp::_["nnz"] = double(m1.nonZeros()),
137137
Rcpp::_["nr"] = double(m1.rows()),

inst/tinytest/cpp/sparse.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ double asMappedSparseDoubleColMajor(Eigen::Map<Eigen::SparseMatrix<double, Eigen
5252
return s;
5353
}
5454

55-
// [[Rcpp::export]]
56-
double asMappedSparseDeprecatedDoubleColMajor(Eigen::MappedSparseMatrix<double, Eigen::ColMajor> mm) {
57-
// Deprecated
58-
double s = mm.sum(); // access instantiated sparse matrix
59-
return s;
60-
}
55+
// // [ [ Rcpp::export]]
56+
// double asMappedSparseDeprecatedDoubleColMajor(Eigen::MappedSparseMatrix<double, Eigen::ColMajor> mm) {
57+
// // Deprecated
58+
// double s = mm.sum(); // access instantiated sparse matrix
59+
// return s;
60+
// }
6161

6262
// [[Rcpp::export]]
6363
double asSparseDoubleRowMajor(Eigen::SparseMatrix<double, Eigen::RowMajor> mm) {
@@ -71,11 +71,11 @@ double asMappedSparseDoubleRowMajor(Eigen::Map<Eigen::SparseMatrix<double, Eigen
7171
return s;
7272
}
7373

74-
// [[Rcpp::export]]
75-
double asMappedSparseDeprecatedDoubleRowMajor(Eigen::MappedSparseMatrix<double, Eigen::RowMajor> mm) {
76-
double s = mm.sum(); // access instantiated sparse matrix
77-
return s;
78-
}
74+
// // [ [ Rcpp::export ] ]
75+
// double asMappedSparseDeprecatedDoubleRowMajor(Eigen::MappedSparseMatrix<double, Eigen::RowMajor> mm) {
76+
// double s = mm.sum(); // access instantiated sparse matrix
77+
// return s;
78+
// }
7979

8080
// [[Rcpp::export]]
8181
Rcpp::List sparseCholesky(Rcpp::List input) {

inst/tinytest/test_sparse.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ expect_equal( res, sum(rr), info = "as<Map<SparseMatrix<double, Eigen::ColMajor>
9999

100100

101101
#test.asMappedSparse.deprecated.double.ColMajor.R <- function(){
102-
fx <- asMappedSparseDeprecatedDoubleColMajor
103-
rr <- Matrix::t(as(gl(3,3), "sparseMatrix"))
104-
colnames(rr) <- NULL
105-
res <- fx( rr )
106-
expect_equal( res, sum(rr), info = "as<MappedSparseMatrix<double, Eigen::ColMajor> >")
102+
#fx <- asMappedSparseDeprecatedDoubleColMajor
103+
#rr <- Matrix::t(as(gl(3,3), "sparseMatrix"))
104+
#colnames(rr) <- NULL
105+
#res <- fx( rr )
106+
#expect_equal( res, sum(rr), info = "as<MappedSparseMatrix<double, Eigen::ColMajor> >")
107107

108108

109109
#test.asSparse.double.RowMajor.R <- function(){
@@ -121,10 +121,10 @@ expect_equal( res, sum(rr), info = "as<Map<SparseMatrix<double, Eigen::RowMajor>
121121

122122

123123
#test.asMappedSparse.deprecated.double.RowMajor.R <- function(){
124-
rr <- new( "dgRMatrix", j=rep(0L:2L, each=3), p=0L:9L, x=as.numeric(9:1), Dim=c(9L,3L) )
125-
colnames(rr) <- NULL
126-
res <- asMappedSparseDeprecatedDoubleRowMajor( rr )
127-
expect_equal( res, sum(rr), info = "as<MappedSparseMatrix<double, Eigen::RowMajor> >")
124+
#rr <- new( "dgRMatrix", j=rep(0L:2L, each=3), p=0L:9L, x=as.numeric(9:1), Dim=c(9L,3L) )
125+
#colnames(rr) <- NULL
126+
#res <- asMappedSparseDeprecatedDoubleRowMajor( rr )
127+
#expect_equal( res, sum(rr), info = "as<MappedSparseMatrix<double, Eigen::RowMajor> >")
128128

129129

130130
# test.sparseCholesky.R <- function() {

src/fastLm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ namespace lmsol {
167167
}
168168

169169
SVD::SVD(const Map<MatrixXd> &X, const Map<VectorXd> &y) : lm(X, y) {
170-
JacobiSVD<MatrixXd> UDV(X.jacobiSvd(ComputeThinU|ComputeThinV));
170+
JacobiSVD<MatrixXd> UDV(X, ComputeThinU | ComputeThinV);
171171
MatrixXd VDi(UDV.matrixV() *
172172
Dplus(UDV.singularValues().array()).matrix().asDiagonal());
173173
m_coef = VDi * UDV.matrixU().adjoint() * y;

0 commit comments

Comments
 (0)