Contributing to RcppML
Source:CONTRIBUTING.md
Thank you for your interest in contributing to RcppML! This document provides guidelines and instructions for contributing to the project.
Getting Started
-
Fork and clone the repository:
-
Install dependencies:
install.packages(c("Rcpp", "RcppEigen", "Matrix", "testthat", "devtools", "roxygen2", "knitr", "rmarkdown")) -
Build and test:
Project Structure
| Directory | Contents |
|---|---|
R/ |
R source files (roxygen documented) |
src/ |
C++ Rcpp bridge files (RcppFunctions*.cpp, sparsepress_bridge.cpp) |
inst/include/RcppML/ |
Header-only C++ library (core NNLS, clustering) |
inst/include/FactorNet/ |
NMF/SVD engine, GPU kernels, factor graph fitting |
inst/include/streampress/ |
StreamPress I/O (rANS coding) |
inst/include/sparsepress/ |
SparsePress compression |
tests/testthat/ |
Unit tests (testthat) |
vignettes/ |
Package vignettes |
man/ |
Auto-generated — do NOT edit |
NAMESPACE |
Auto-generated — do NOT edit |
Development Workflow
Editing C++ Code
All C++ algorithm code lives in inst/include/ as a header-only library (subdivided into RcppML/, FactorNet/, streampress/, and sparsepress/). The src/ directory contains Rcpp bridge files (RcppFunctions*.cpp) that provide // [[Rcpp::export]] wrappers, plus sparsepress_bridge.cpp for StreamPress I/O.
After changing // [[Rcpp::export]] annotations, run:
devtools::document() # Also runs Rcpp::compileAttributes()Then:
Auto-Generated Files (NEVER Edit Manually)
| File(s) | Generator |
|---|---|
NAMESPACE |
roxygen2 via devtools::document()
|
man/*.Rd |
roxygen2 via devtools::document()
|
src/RcppExports.cpp |
Rcpp::compileAttributes() via devtools::document()
|
R/RcppExports.R |
Rcpp::compileAttributes() via devtools::document()
|
Code Style
R Code
- Follow standard R style (snake_case for functions, PascalCase for S4 classes)
- All exported functions must have complete roxygen documentation including
@returnand@examples - Use
stop()for user-facing errors with clear messages
C++ Code
- Namespace:
RcppML(PascalCase) for all new code - Templates: use
Scalaras the floating-point type parameter - Headers must be Rcpp-free — use
RCPPML_LOG_INFO()instead ofRcpp::Rcout - Sparse matrices: expect
Eigen::SparseMatrix<Scalar>in CSC format - Internal W is stored transposed (k × m) for cache efficiency
Testing
Submitting Changes
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes with tests
- Ensure
devtools::check()passes with no errors - Push and open a Pull Request against
main
Reporting Issues
Open an issue at https://github.com/zdebruine/RcppML/issues with: - A minimal reproducible example - R session info (sessionInfo()) - Expected vs actual behavior