Changelog
Source:NEWS.md
tensory 0.0.1
First development version. Everything below is new.
Tensor classes
-
Tensor, an R6 class for dense multidimensional arrays, usable either method-style (x$clone_tensor()$add(y)) or through S3 generics and operators (x + y,ttm(x, A, mode = 2)). - Structured companions, each with an
as.tensor()method that materializes a denseTensor:Tenmat(matricization),KTensor(CP/Kruskal),TTensor(Tucker),SptensorandSptenmat(sparse),SymTensorandSymKTensor(compact symmetric storage), andSumTensor(lazy sum of parts). - Constructors
tensor(),tenrand(),ones(),zeros(),tendiag(),teneye(),tenfun(), andsptenrand().
Operations
- Products and contractions:
ttm(),ttv(),ttt(),ttsv(),mtimes(),%*%,innerprod(),contract(),khatri_rao(),kronecker(),hadamard(),mttkrp(), andmttkrps(). - Shape and structure:
permute(),reshape(),squeeze(),unfold(),vec(),collapse(),t_scale(),mask(),fibers(),find(),symmetrize(),issymmetric(),fnorm(), andnvecs(). - Naming and argument semantics follow the MATLAB Tensor Toolbox where that reads naturally in R; divergences are documented per function (most notably, a full contraction returns a scalar
Tensorwithdims = integer(0)). - Compiled
xtensor+ BLAS kernels backttm,mttkrp,mttkrps,fibers,contract,mask, andissymmetric. Every kernel is optional: each method keeps a complete R implementation and delegates only when the compiled symbol is present.
Decompositions
- CP:
cp_als(), plus the variantscp_nmu()(nonnegative multiplicative updates),cp_apr()(Poisson),cp_opt()andcp_wopt()(L-BFGS-B on the exact gradient, the latter handling missing data),cp_arls()(randomized ALS), andcp_sym()(symmetric CP). - Tucker:
tucker_als(),tucker_sym(), andhosvd(). - Generalized CP with a loss catalog:
gcp_opt(). - Tensor eigenpairs:
eig_sshopm()andeig_geap(), following Kolda & Mayo (2014). -
KTensorpost-processing:arrange(),normalize(),fixsigns(),score(),ncomponents(),extract(),redistribute(),tovec(), andviz(). -
cp_als()accepts anSptensornatively and never densifies it.
Regression with tensor predictors
-
spgtr()andspgtr_cv()fit the sparse partial generalized tensor regression of Sun, Peng, Qiu, Stevens, Manatunga and Guo (submitted): a generalized linear model whose predictor is a whole array per observation. Each mode is reduced to an envelope basis, the GLM is fit on the latent scores, and the coefficient array is returned in the original shape as aTTensor. An adaptively weighted row-wise L2,1 penalty selects whole slices of the array;spgtr_cv()chooses its strength by cross-validated deviance. Any GLM family is supported, with optional unpenalized nuisance covariates. Seevignette("spgtr"). -
tepls()fits the tensor envelope partial least-squares regression of Zhang and Li (2017) for continuous responses, one or several at a time. The per-mode envelope dimensions are chosen automatically whenuis not given. Seevignette("tepls"). -
pqtr()andpqtr_cv()fit the partial quantile tensor regression of Sun, Qiu, Peng, Guo and Manatunga (2024): a chosen quantile of the outcome, rather than its mean, is regressed on the array through per-mode partial-least-squares directions. Optional unreduced covariates are supported, the reduced dimension is chosen by an eigenvalue-ratio rule or by cross-validated check loss, and the inner quantile regressions use the MM algorithm of Hunter and Lange (2000), so no linear-programming dependency is needed. Seevignette("pqtr"). - All three accept the predictor either as a list of equally shaped observations or as a single array whose last mode indexes observations.
Data exchange
-
export_data()andimport_data()read and write the MATLAB Tensor Toolbox text format.
Fixes
-
scale()on an ordinary matrix no longer recurses until the C stack overflows. The default method calledbase::scale(), which is itself a generic and dispatched straight back to it.