bppnnls: Block Principal Pivoted Non-Negative Least Squares

View source: R/RcppExports.R

bppnnlsR Documentation

Block Principal Pivoted Non-Negative Least Squares

Description

Use the BPP algorithm to get the nonnegative least squares solution. Regular NNLS problem is described as optimizing \min_{x\ge0}||CX - B||_F^2 where C and B are given and X is to be solved. bppnnls takes C and B as input. bppnnls_prod takes C^\mathsf{T}C and C^\mathsf{T}B as input to directly go for the intermediate step of BPP algorithm. This can be useful when the dimensionality of C and B is large while pre-calculating C^\mathsf{T}C and C^\mathsf{T}B is cheap.

Usage

bppnnls(C, B, nCores = 2L)

bppnnls_prod(CtC, CtB, nCores = 2L)

Arguments

C

Input dense C matrix

B

Input B matrix of either dense or sparse form

nCores

The number of parallel tasks that will be spawned. Default 2

CtC

The C^\mathsf{T}C matrix, see description.

CtB

The C^\mathsf{T}B matrix, see description.

Value

The calculated solution matrix in dense form.

Examples

set.seed(1)
C <- matrix(rnorm(250), nrow = 25)
B <- matrix(rnorm(375), nrow = 25)
res1 <- bppnnls(C, B)
dim(res1)
res2 <- bppnnls_prod(t(C) %*% C, t(C) %*% B)
all.equal(res1, res2)

RcppPlanc documentation built on April 15, 2025, 1:11 a.m.