A clean, fast, and fully documented C++20 implementation of the NIPALS PLS1 algorithm applied to functional data, developed as part of the course Statistics and Data Analysis — M. Sc. in Data Science and Information Retrieval.
Includes realistic synthetic data *amplitude-modulated sine waves) and linear response generation, and a complete simulation study framework.
Perfect for teaching, research, benchmarking, or extending to real functional datasets (spectroscopy, chemometrics, FDA, etc.).
We generate functional predictors
with latent amplitude
This creates a strong linear relationship which PLSR recovers with just 1–2 components.
- Modern C++20 + Eigen3 (header-only dependency)
- Classic NIPALS PLS1 implementation (Wold et al., 1984)
- Reproducible synthetic functional data (B-spline/Fourier-ready structure)
- Linear response
- Full Doxygen documentation with LaTeX formulas
- Cross-platform: Linux • macOS • Windows (MSVC, Clang, GCC)
- Extremely simple build system (just a smart Makefile wrapper around CMake)
plsr-cpp/
├── CMakeLists.txt
├── Makefile ← one-command magic
├── include/
│ ├── DataGenerator.hpp
│ ├── ResponseGenerator.hpp
│ ├── fourier.hpp
│ ├── bspline.hpp
│ └── PLSR.hpp
├── src/ ← implementations
├── tests/ ← unit tests
├── main.cpp ← full simulation demo
├── results/ ← generated data & comparison
├── LICENSE ← GPL-3.0
└── README.md
- A modern C++ compiler (GCC ≥ 10, Clang ≥ 10, MSVC ≥ 2019)
- CMake ≥ 3.16
- Eigen3 (header-only)
Installation of Eigen3
# Ubuntu/Debian
sudo apt install libeigen3-dev
# Arch Linux
sudo pacman -S eigen
# macOS (Homebrew)
brew install eigen
# Windows: use vcpkg
vcpkg install eigen3
# or Conan, or just drop the headers somewherecd plsr-cpp
make go # builds + runs the full demo
make tests # runs all unit testsOther useful targets:
make setup # first-time configuration
make build # fast incremental rebuild
make run # run the demo (same as `make make go`)
make clean # remove build artifactsOpen a terminal (PowerShell, CMD, or Git Bash) and run exactly the same make commands above if you have GNU Make installed.
Alternative: pure CMake (works everywhere)
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release # Linux/macOS
# or
cmake .. -G "Visual Studio 17 2022" -A x64 # Windows MSVC
cmake --build . --config Release --parallel
./main # Linux/macOS
./Release/main.exe # WindowsAfter running make go or ./build/main you will get:
results/
├── response.txt
└── coef_functions.txt
Dhiaa Eddine Bahri
dhya.bahri@proton.me
Main contributions: PLSR algorithm, project architecture, main integration and build system
Malek Rihani
malek.rihani090@gmail.com
Main contributions: Functional data and linear response generators
Academic year 2025-2026
M. Sc. in Data Science and Information Retrieval
University of Manouba — Higher Institute of Multimedia Arts
If you use this code in your research or teaching, please cite:
@software{plsr_cpp_2025,
author = {Bahri, Dhiaa Eddine and Rihani, Malek},
title = {PLSR-CPP: A C++20 implementation of NIPALS PLS1 for functional data},
year = 2025,
publisher = {GitHub},
url = {https://github.com/Disciple0fMarx/plsr-cpp}
}Enjoy the power of supervised dimension reduction on functional data!