Matrix Profile for R

This is the core functions needed by the 'tsmp' package. The low level and carefully checked mathematical functions are here. These are implementations of the Matrix Profile concept that was created by CS-UCR < http://www.cs.ucr.edu/~eamonn/MatrixProfile.html>.


README

Francisco Bischoff

14 Oct 2026

matrixprofiler logo

Matrix Profile for R

License lifecycle

Lint

codecov CodeQL

CRANversion CRANDownloads

What’s New β€” v0.1.12 (October 2026)

matrixprofiler is the high-performance C++ engine of the Matrix Profile ecosystem. This release focuses on native parallelism, new algorithms, and safer NA handling.

Key highlights:

  • ⚑ RcppThread replaces RcppParallel/Intel TBB β€” zero-dependency, fork-safe multithreading on all platforms.
  • πŸ†• contrast() β€” native Contrast Profile computation with multi-threading, Pearson and Euclidean distance metrics.
  • πŸ†• rfcp() & rfcp_top_k() β€” Relative Frequency Contrast Profile with Top-K morphology discovery, frequency adaptation, checkpoints, and CUDA acceleration.
  • πŸ†• mstomp() β€” native C++ Multivariate STOMP with n_workers support.
  • πŸ†• mpdist() β€” native C++ MPdist (scalar and vector variants), multi-thread.
  • πŸ”’ NA_integer_ β€” invalid profile indices now follow R’s canonical missing-value convention (was -1L).
  • πŸ›‘οΈ na_strategy for all mov_* window functions β€” predictable, non-cascading NA handling.

πŸ“„ Full API changes, breaking changes, and migration guide: MIGRATION.md

Overview

R package implementing the UCR Matrix Profile Algorithm (http://www.cs.ucr.edu/~eamonn/MatrixProfile.html) as an optimised C++17 engine.

This package provides the core computational primitives for building and querying Matrix Profiles. Higher-level analytics (motif search, segmentation, snippets, plotting) live in the tsmp package, which uses matrixprofiler as its backend.

Installation

# Install the released version from CRAN
install.packages("matrixprofiler")
# Or the development version from GitHub:
# install.packages("devtools")
devtools::install_github("matrix-profile-foundation/matrixprofiler")

Optional: NVIDIA CUDA GPU Acceleration

By default, matrixprofiler installs as a portable, high-performance CPU engine with multi-threading via RcppThread (zero external dependencies, 100% CRAN compliant).

If you have an NVIDIA GPU and the CUDA Toolkit installed, you can compile matrixprofiler with native CUDA acceleration for supported algorithms (such as rfcp() and mpx()):

# Clone the repository
git clone https://github.com/matrix-profile-foundation/matrixprofiler.git
cd matrixprofiler

# Compile CUDA kernels and install directly into your R library
./inst/cuda/build_cuda_rcpp.sh R CMD INSTALL .
# or with devtools:
./inst/cuda/build_cuda_rcpp.sh Rscript -e 'devtools::install()'

Once installed, check if CUDA is enabled in your R session:

library(matrixprofiler)
has_cuda()
#> [1] TRUE

Currently available Features

  • STAMP (single and multi-thread)
  • STOMP (single and multi-thread)
  • SCRIMP (single and multi-thread, not for AB-joins yet)
  • MPX (single and multi-thread)
  • Contrast Profile (contrast) β€” Contrast profile between positive and negative classes (Euclidean/Pearson, multi-thread)
  • RFCP (rfcp) β€” Relative Frequency Contrast Profile for discriminative pattern discovery (CPU multi-threaded & CUDA GPU)
  • Top-K Morphology Discovery (rfcp_top_k) β€” Iterative discovery of top-K distinct morphologies with frequency adaptation and checkpointing
  • mSTOMP β€” Multivariate STOMP, native C++ with n_workers
  • MPdist β€” Matrix Profile Distance, scalar and vector variants, multi-thread
  • Misc:
    • MASS v2.0 / v3.0 (multi-variant)
    • MASS extensions: WQ (Weighted Query), ABS (Absolute), UN (Unnormalized)
    • Sliding-window functions (mov_mean, mov_std, mov_var, mov_min, mov_max, muinvn, zero_crossing) with na_strategy = c("window_na", "remove", "error") and na.rm control

Roadmap

  • [x] Replace Intel TBB / RcppParallel with RcppThread (fork-safe, zero external dep)
  • [x] Native Multivariate STOMP (mstomp()) in C++
  • [x] Native MPdist (mpdist()) in C++
  • [x] Contrast Profile (contrast()) in native C++
  • [x] Relative Frequency Contrast Profile (rfcp()) and Top-K Morphology Discovery (rfcp_top_k())
  • [x] Standardise invalid indices to NA_integer_
  • [x] na_strategy for all sliding-window functions
  • [ ] STOMPi (On-line / streaming version)
  • [ ] SiMPle-Fast (Music Analysis)
  • [ ] VALMOD (Variable Length Motifs) β€” candidate for matrixprofiler core
  • [ ] MASS extensions: ADP (Approximate Distance Profile, with PAA), QwG (Query with Gap)

Other projects with Matrix Profile

Matrix Profile Foundation

Our next step unifying the Matrix Profile implementation in several programming languages.

Visit: Matrix Profile Foundation

Benchmarks

Available at RPubs.

Package dependencies

Matrixprofiler package dependencies network graph

Code of Conduct

Please note that the matrixprofiler project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("matrixprofiler")

0.1.12 by Francisco Bischoff, 4 days ago


https://matrix-profile-foundation.github.io/matrixprofiler/, https://github.com/matrix-profile-foundation/matrixprofiler


Report a bug at https://github.com/matrix-profile-foundation/matrixprofiler/issues


Browse source code at https://github.com/cran/matrixprofiler


Authors: Francisco Bischoff [aut, cre] (ORCID: , Michael Yeh [res, ccp, ctb] (ORCID: , Diego Silva [res, ccp, ctb] (ORCID: , Yan Zhu [res, ccp, ctb] (ORCID: , Hoang Dau [res, ccp, ctb] (ORCID: , Michele Linardi [res, ccp, ctb] (ORCID:


Documentation:   PDF Manual  


GPL-3 license


Imports checkmate, Rcpp

Suggests debugme, spelling, testthat

Linking to Rcpp, RcppThread

System requirements: GNU make


Imported by tsmp.


See at CRAN