Canonical Polyadic (CP) decomposition of a tensor, aka CANDECOMP/PARAFRAC.
Approximate a K-Tensor using a sum of
num_components rank-1 K-Tensors.
A rank-1 K-Tensor can be written as an outer product of K vectors.
There are a total of
num_compoents *darr@num_modes vectors in the output,
This is an iterative algorithm, with two possible stopping conditions:
either relative error in Frobenius norm has gotten below
max_iter number of iterations has been reached.
For more details on CP decomposition, consult Kolda and Bader (2009).
cp(darr, num_components=NULL, max_iter=25, tol=1e-05) ## S4 method for signature 'DelayedArray' cp(darr, num_components, max_iter, tol)
Tensor with K modes
the number of rank-1 K-Tensors to use in approximation
maximum number of iterations if error stays above
relative Frobenius norm error tolerance
This function is an extension of the
Uses the Alternating Least Squares (ALS) estimation procedure. A progress bar is included to help monitor operations on large tensors.
a list containing the following
a vector of normalizing constants, one for each component
a list of matrices - one for each mode -
each matrix with
whether or not
by the last iteration
the percent of Frobenius norm explained by the approximation
darr after compression
the Frobenius norm of the error
vector containing the Frobenius norm of error for all the iterations
T. Kolda, B. Bader, "Tensor decomposition and applications". SIAM Applied Mathematics and Applications 2009.
library("DelayedRandomArray") darr <- RandomUnifArray(c(3,4,5)) cp(darr, num_components=2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.