Skip to contents

Package

tensory-package tensory
tensory: Tensory - Modern Tensor Operations for R

Tensor classes and constructors

The dense Tensor object, its matricized and decomposed relatives, and the constructors that build them.

tensor()
R6 Tensor Class
tenrand()
Random Dense Tensor
ones()
Create a tensor of ones
zeros()
Create a tensor of zeros
tendiag()
Diagonal Tensor
teneye()
Identity Tensor
tenfun()
Apply Elementwise Function to Tensor Arguments
tenmat()
R6 Tenmat Class
as.tenmat()
Convert object to Tenmat
ktensor()
R6 Class for Kruskal Tensors (KTensor)
ttensor()
R6 Class for Tucker Tensors (TTensor)
sptensor()
R6 Class for Sparse Tensors (Sptensor)
sptenmat()
R6 Class for Sparse Matricized Tensors (Sptenmat)
sptenrand()
Random Sparse Tensor
symtensor()
R6 Class for Symmetric Tensors (SymTensor)
symktensor()
R6 Class for Symmetric Kruskal Tensors (SymKTensor)
sumtensor()
R6 Class for Implicit Sums of Tensors (SumTensor)
as.tensor()
Convert object to Tensor
as.tensor(<KTensor>)
S3 function to convert KTensor to full Tensor
as.tensor(<TTensor>)
S3 function to convert TTensor to full Tensor
as.tensor(<Tenmat>)
Convert Tenmat to Tensor

Shape, indexing, and predicates

Reshaping, unfolding, conversion, and structural queries.

permute()
Permute Tensor Dimensions
reshape()
Reshape Tensor
squeeze()
Squeeze Tensor
unfold()
Unfold Tensor
vec()
Vectorize Tensor
find()
Find Nonzero Entries
nnz()
Number of Nonzeros
full()
Dense Array Representation
isequal()
Equality Test for Tensors
isscalar()
Scalar Tensor Predicate
issymmetric()
Check Tensor Symmetry
symmetrize()
Symmetrize Tensor
transpose()
Transpose Tensor
double.Tensor()
MATLAB-Style Double Conversion
double.Tenmat()
Convert Tenmat to standard R double array (alias for matrix)
as.double(<Tenmat>)
Convert Tenmat to standard R Matrix using generic type conversion
as.matrix(<Tenmat>)
Convert Tenmat to standard R Matrix
as.vector(<Tenmat>)
Convert Tenmat to standard R vector
head(<Tensor>)
S3 head method for Tensor
tail(<Tensor>)
S3 tail method for Tensor
show.Tensor()
S3 show method for Tensor
print(<Tensor>)
S3 print method for Tensor
print(<KTensor>)
S3 print method for KTensor
print(<TTensor>)
S3 print method for TTensor
Math(<Tensor>)
S3 Math group generic for Tensor
Summary(<Tensor>)
S3 Summary group generic for Tensor

Products, contractions, and reductions

The computational core: tensor-times-matrix/vector/tensor products, matricized products, norms, and reductions.

ttm()
Tensor Times Matrix/Vector (ttm) Operation
ttv()
Tensor Times Vector
ttt()
Tensor Times Tensor (ttt) Operation
ttsv()
Tensor Times Same Vector
mtimes()
Matrix Multiplication Alias
`%*%`
S3 Matrix Multiplication Generic
innerprod()
Inner Product
contract()
Contract Tensor Dimensions
khatri_rao()
Khatri-Rao Product
kronecker()
Kronecker Product
hadamard()
Hadamard Product
mttkrp()
Matricized Tensor Times Khatri-Rao Product
mttkrps()
Sequence of MTTKRP Calculations
fibers()
Extract Tensor Fibers
mask()
Mask Tensor Values
collapse()
Collapse Tensor
scale()
Tensor Scaling
t_scale()
Scale Tensor
fnorm()
Frobenius Norm
nvecs()
Leading Mode-n Vectors

Decompositions

CP, Tucker, generalized CP, and tensor eigenpairs.

cp_als()
CP Alternating Least Squares Decomposition
cp_nmu()
Nonnegative CP Decomposition via Multiplicative Updates
cp_apr()
Poisson CP Decomposition (CP-APR) via Multiplicative Updates
cp_opt()
CP Decomposition via Direct Optimization
cp_wopt()
Weighted CP Decomposition via Direct Optimization
cp_arls()
CP Decomposition via Randomized (Sampled) ALS
cp_sym()
Symmetric CP Decomposition via Direct Optimization
gcp_opt()
Generalized CP Decomposition
tucker_als()
Tucker Alternating Least Squares (HOOI)
tucker_sym()
Symmetric Tucker Decomposition
hosvd()
Higher-Order Singular Value Decomposition
eig_sshopm()
Shifted Symmetric Higher-Order Power Method (SS-HOPM)
eig_geap()
Generalized Eigenproblem Adaptive Power Method (GEAP)

Regression with tensor predictors

Supervised models where each subject’s predictor is a whole array: sparse partial generalized tensor regression, tensor envelope PLS, and partial quantile tensor regression.

spgtr() coef(<spgtr>) print(<spgtr>)
Sparse Partial Generalized Tensor Regression (SPGTR)
spgtr_cv()
Choose the Sparsity of a Tensor Regression by Cross-Validation
predict(<spgtr>)
Predict from a Tensor Regression Fit
summary(<spgtr>)
Summarize a Tensor Regression Fit
tepls()
Tensor Envelope Partial Least Squares Regression (TEPLS)
predict(<tepls>)
Predict from a TEPLS Fit
pqtr() coef(<pqtr>) print(<pqtr>)
Partial Quantile Tensor Regression (PQTR)
pqtr_cv()
Choose the Reduced Dimension of a Quantile Tensor Regression
predict(<pqtr>)
Predict from a Partial Quantile Tensor Regression Fit

Working with CP factors

Post-processing, comparison, and visualization of KTensor fits.

arrange()
Arrange the Components of a Kruskal Tensor
normalize()
Normalize a Kruskal Tensor
fixsigns()
Fix Sign Ambiguity of a Kruskal Tensor
score()
Score the Similarity of Two Kruskal Tensors
ncomponents()
Number of Components of a Kruskal Tensor
extract()
Extract Components of a Kruskal Tensor
redistribute()
Redistribute Kruskal Weights into a Mode
tovec()
Kruskal Tensor to Vector
viz()
Visualize a Kruskal Tensor

Import and export

import_data()
Import Tensor Data from a Text File
export_data()
Export Tensor Data to a Text File