Skip to content

Conversation

@david20011999
Copy link
Contributor

This pull request refactors several components of the ssemQr package to improve numerical precision, modernize the Rcpp interface, and enhance code maintainability and compilability.
The main updates replace single-precision (float) Eigen matrices with double-precision (double) equivalents, remove outdated .Call() wrappers, and rely on // [[Rcpp::export]] for cleaner R-C++ integration.

Details

1. R/solver.R

  • Replaced the .Call("L2Regression", ...) interface with a direct call to the exported L2Regression() function.
  • Simplified function call to ensure compatibility with the updated Rcpp interface.

2. R/utils.R

  • Replaced .Call("ObjL2Regression", ...) and .Call("L2lamax", ...) by direct Rcpp exports.
  • Ensured all L2 routines are now called via the modern Rcpp mechanism.

3. src/ssemQr.cpp

  • Major refactor from MatrixXf (float) to MatrixXd (double) for better numerical precision.
  • Replaced manual SEXP parsing with idiomatic Rcpp + Eigen type conversions.
  • Added //[[Rcpp::export]] to L2Regression, ObjL2Regression, and L2lamax.
  • Rewrote handling of list-type inputs using std::vector<ArrayXi> instead of std::vector<ArrayXd> for integer indexing.

src/LR.h

  • Replaced all MatrixXf/VectorXf types with template-consistent MatType.
  • Ensured consistent use of MatType in L2lr and L2lamax.
  • Fixed identity matrix generation (MatType::Identity).

src/MatOp.h

  • Unified index access using ix[i] instead of ix(i), improving compatibility with std::vector and ArrayXi.
  • Changed iteration variable types (size_t) for safety.
  • Updated centering function to use double and std::bind with std::minus<float> instead of deprecated bind2nd.

Testing

  • Successfully compiled on both Linux (Ubuntu 22.04.5 LTS) and Windows 11 environments without errors or warnings.
  • Confirmed that the Rmarkdown example included in the package documentation (model with simulated data) runs to completion without issues and reproduces expected results.

@Ivis4ml Ivis4ml merged commit 4638ca2 into Ivis4ml:master Oct 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants