├── README.md ├── Synthetic ├── 2-Mode │ ├── NORT │ │ ├── MakePart.m │ │ ├── NORT.m │ │ ├── TencompPred.m │ │ ├── copyToSpa.m │ │ ├── den-multi │ │ │ ├── fastMulti1u.m │ │ │ ├── fastMulti1v.m │ │ │ ├── fastMulti2u.m │ │ │ └── fastMulti2v.m │ │ ├── makepart │ │ │ ├── makepart1.m │ │ │ └── makepart2.m │ │ ├── powermethod │ │ │ ├── PowerMethod1.m │ │ │ ├── PowerMethod2.m │ │ │ ├── subMulti1u.m │ │ │ ├── subMulti1v.m │ │ │ ├── subMulti2u.m │ │ │ └── subMulti2v.m │ │ ├── sNORT.m │ │ ├── spa-multi │ │ │ ├── subSpa1u.m │ │ │ ├── subSpa1v.m │ │ │ ├── subSpa2u.m │ │ │ └── subSpa2v.m │ │ ├── subMulti1u.m │ │ ├── subMulti1v.m │ │ ├── subMulti2u.m │ │ ├── subMulti2v.m │ │ └── warmStart.m │ ├── ProxAvg │ │ ├── GDPAN.m │ │ └── ProxAvg.m │ ├── TestSyn.m │ └── setup.m └── 3-Mode │ ├── 200-1.mat │ ├── NORT │ ├── NORT.m │ ├── TencompPred.m │ ├── filterBase.m │ ├── makepart │ │ ├── MakepartM1.m │ │ ├── MakepartM1_c.cpp │ │ ├── MakepartM1_c.mexw64 │ │ ├── MakepartM1_cblas.cpp │ │ ├── MakepartM2.m │ │ ├── MakepartM2_c.cpp │ │ ├── MakepartM2_c.mexw64 │ │ ├── MakepartM3.m │ │ ├── MakepartM3_c.cpp │ │ ├── MakepartM3_c.mexw64 │ │ └── compile.m │ ├── powermethod │ │ ├── PowerMethod1.m │ │ ├── PowerMethod2.m │ │ ├── PowerMethod3.m │ │ ├── den-multi │ │ │ ├── subMulti1M2u.m │ │ │ ├── subMulti1M2v.m │ │ │ ├── subMulti1M3u.m │ │ │ ├── subMulti1M3v.m │ │ │ ├── subMulti2M1u.m │ │ │ ├── subMulti2M1v.m │ │ │ ├── subMulti2M3u.m │ │ │ ├── subMulti2M3v.m │ │ │ ├── subMulti3M1u.m │ │ │ ├── subMulti3M1v.m │ │ │ ├── subMulti3M2u.m │ │ │ └── subMulti3M2v.m │ │ └── spa-multi │ │ │ ├── compile.m │ │ │ ├── subSpa1Mu.m │ │ │ ├── subSpa1Mu_c.cpp │ │ │ ├── subSpa1Mu_c.mexw64 │ │ │ ├── subSpa1Mu_cblas.cpp │ │ │ ├── subSpa1Mv.m │ │ │ ├── subSpa1Mv_c.cpp │ │ │ ├── subSpa1Mv_c.mexw64 │ │ │ ├── subSpa2Mu.m │ │ │ ├── subSpa2Mu_c.cpp │ │ │ ├── subSpa2Mu_c.mexw64 │ │ │ ├── subSpa2Mv.m │ │ │ ├── subSpa2Mv_c.cpp │ │ │ ├── subSpa2Mv_c.mexw64 │ │ │ ├── subSpa3Mu.m │ │ │ ├── subSpa3Mu_c.cpp │ │ │ ├── subSpa3Mu_c.mexw64 │ │ │ ├── subSpa3Mv.m │ │ │ ├── subSpa3Mv_c.cpp │ │ │ └── subSpa3Mv_c.mexw64 │ ├── sNORT.m │ └── subMakrPrat.m │ ├── ProxAvg │ ├── GDPAN.m │ ├── ProxAvg.m │ ├── getX.m │ └── proxAvgObj.m │ ├── Test.m │ └── setup.m └── common-tools ├── Auxiliary_files ├── Fold.m ├── Unfold.m ├── calcFunction_mex.c ├── calcFunction_mex.mexa64 ├── calcFunction_mex.mexmaci64 ├── calcFunction_mex.mexw64 ├── calcGradient_mex.c ├── calcGradient_mex.mexa64 ├── calcGradient_mex.mexmaci64 ├── calcGradient_mex.mexw64 ├── calcInitial_mex.c ├── calcInitial_mex.mexa64 ├── calcInitial_mex.mexmaci64 ├── calcInitial_mex.mexw64 ├── calcProjection_mex.c ├── calcProjection_mex.mexa64 ├── calcProjection_mex.mexmaci64 ├── calcProjection_mex.mexw64 ├── getValsAtIndex_mex.c ├── getValsAtIndex_mex.mexa64 ├── getValsAtIndex_mex.mexmaci64 ├── getValsAtIndex_mex.mexw64 ├── makeOmegaSet.m └── makeRandTensor.m ├── GIST_package ├── GIST │ ├── funRegC.cpp │ ├── funRegC.mexw64 │ ├── gistL2SVM.m │ ├── gistLeast.m │ ├── gistLogistic.m │ ├── proximalRegC.cpp │ ├── proximalRegC.mexw64 │ └── proximalRegC_warpper.m ├── GISTMatComp.m ├── GISTRPCA.m ├── install.m └── readme.txt ├── PROPACK ├── Afunc.m ├── AtAfunc.m ├── Atransfunc.m ├── Cfunc.m ├── bdsqr-csz363.m ├── bdsqr-csz920.m ├── bdsqr.m ├── bdsqr.mexglx ├── bdsqr.mexsg ├── bdsqr.mexsg64 ├── bdsqr.mexsol ├── bdsqr.mexw32 ├── bdsqr_mex.c ├── bdsqr_mex.mexw64.manifest ├── bdsqr_mex.mexw64.map ├── compute_int.m ├── dbdqr.f ├── helio.mat ├── lanbpro-csz363.m ├── lanbpro-csz920.m ├── lanbpro.doc ├── lanbpro.m ├── lanbpro.txt ├── laneig.doc ├── laneig.m ├── laneig.txt ├── lanpro.doc ├── lanpro.m ├── lanpro.txt ├── lansvd-csz363.m ├── lansvd-csz920.m ├── lansvd.doc ├── lansvd.m ├── lansvd.txt ├── mminfo.m ├── mmread.m ├── mmwrite.m ├── pythag.m ├── refinebounds.m ├── reorth-csz363.m ├── reorth-csz920.m ├── reorth.f ├── reorth.m ├── reorth.mexglx ├── reorth.mexsg ├── reorth.mexsg64 ├── reorth.mexsol ├── reorth_mex.c ├── reorth_mex.mexw64.manifest ├── reorth_mex.mexw64.map ├── test-csz363.m ├── test-csz920.m ├── test.m ├── testtqlb.m ├── tqlb.f ├── tqlb.m ├── tqlb.mexglx ├── tqlb.mexsg ├── tqlb.mexsg64 ├── tqlb.mexsol ├── tqlb_mex.c └── update_gbound.m ├── poblano_toolbox_1.1 ├── COPYRIGHT.txt ├── Contents.m ├── INSTALL.txt ├── LICENSE.txt ├── RELEASE_NOTES.txt ├── cstep.m ├── cvsrch.m ├── doc │ ├── A1_POBLANO_overview_docs.html │ ├── A1_POBLANO_overview_docs_eq45126.png │ ├── A1_POBLANO_overview_docs_eq52638.png │ ├── A1_POBLANO_overview_docs_eq56797.png │ ├── A1_POBLANO_overview_docs_eq57797.png │ ├── A1_POBLANO_overview_docs_eq92049.png │ ├── A1_POBLANO_overview_docs_eq93418.png │ ├── A2_poblano_params_docs.html │ ├── A3_poblano_out_docs.html │ ├── A4_poblano_examples_docs.html │ ├── A4_poblano_examples_docs_eq05153.png │ ├── A4_poblano_examples_docs_eq06715.png │ ├── A4_poblano_examples_docs_eq15166.png │ ├── A4_poblano_examples_docs_eq15843.png │ ├── A4_poblano_examples_docs_eq18009.png │ ├── A4_poblano_examples_docs_eq19084.png │ ├── A4_poblano_examples_docs_eq20021.png │ ├── A4_poblano_examples_docs_eq21144.png │ ├── A4_poblano_examples_docs_eq21265.png │ ├── A4_poblano_examples_docs_eq24693.png │ ├── A4_poblano_examples_docs_eq31302.png │ ├── A4_poblano_examples_docs_eq31461.png │ ├── A4_poblano_examples_docs_eq34276.png │ ├── A4_poblano_examples_docs_eq35707.png │ ├── A4_poblano_examples_docs_eq37179.png │ ├── A4_poblano_examples_docs_eq47284.png │ ├── A4_poblano_examples_docs_eq49857.png │ ├── A4_poblano_examples_docs_eq72809.png │ ├── A4_poblano_examples_docs_eq86607.png │ ├── A4_poblano_examples_docs_eq88356.png │ ├── B_ncg_docs.html │ ├── B_ncg_docs_eq12896.png │ ├── B_ncg_docs_eq12912.png │ ├── B_ncg_docs_eq21114.png │ ├── B_ncg_docs_eq26687.png │ ├── B_ncg_docs_eq37777.png │ ├── B_ncg_docs_eq38027.png │ ├── B_ncg_docs_eq43170.png │ ├── B_ncg_docs_eq47697.png │ ├── B_ncg_docs_eq48204.png │ ├── B_ncg_docs_eq50028.png │ ├── B_ncg_docs_eq64465.png │ ├── B_ncg_docs_eq69196.png │ ├── B_ncg_docs_eq94234.png │ ├── C_lmbfgs_docs.html │ ├── C_lmbfgs_docs_eq12912.png │ ├── C_lmbfgs_docs_eq26618.png │ ├── C_lmbfgs_docs_eq28128.png │ ├── C_lmbfgs_docs_eq37777.png │ ├── C_lmbfgs_docs_eq49162.png │ ├── C_lmbfgs_docs_eq94234.png │ ├── D_tn_docs.html │ ├── D_tn_docs_eq12912.png │ ├── D_tn_docs_eq14236.png │ ├── D_tn_docs_eq17182.png │ ├── D_tn_docs_eq24873.png │ ├── D_tn_docs_eq37600.png │ ├── D_tn_docs_eq37777.png │ ├── D_tn_docs_eq77996.png │ ├── D_tn_docs_eq81624.png │ ├── D_tn_docs_eq89032.png │ ├── D_tn_docs_eq94234.png │ ├── D_tn_docs_eq95956.png │ ├── E_gradientcheck_docs.html │ ├── E_gradientcheck_docs_eq28128.png │ ├── E_gradientcheck_docs_eq43551.png │ ├── E_gradientcheck_docs_eq57210.png │ ├── E_gradientcheck_docs_eq60012.png │ ├── E_gradientcheck_docs_eq73316.png │ ├── E_gradientcheck_docs_eq81966.png │ ├── E_gradientcheck_docs_eq94104.png │ ├── helptoc.xml │ ├── images │ │ ├── banner-background.jpg │ │ └── logo.gif │ └── poblano_toolbox_product_page.html ├── example1.m ├── example2.m ├── example2_extract.m ├── example2_init.m ├── gradientcheck.m ├── hessvec_fd.m ├── info.xml ├── install_poblano.m ├── lbfgs.m ├── ncg.m ├── poblano_linesearch.m ├── poblano_out.m ├── poblano_params.m ├── setup.m └── tn.m ├── tensor_toolbox_2.6 ├── @ktensor │ ├── arrange.m │ ├── datadisp.m │ ├── disp.m │ ├── display.m │ ├── double.m │ ├── end.m │ ├── extract.m │ ├── fixsigns.m │ ├── full.m │ ├── innerprod.m │ ├── isequal.m │ ├── issymmetric.m │ ├── ktensor.m │ ├── minus.m │ ├── mtimes.m │ ├── mttkrp.m │ ├── ncomponents.m │ ├── ndims.m │ ├── norm.m │ ├── normalize.m │ ├── nvecs.m │ ├── permute.m │ ├── plus.m │ ├── redistribute.m │ ├── score.m │ ├── size.m │ ├── subsasgn.m │ ├── subsref.m │ ├── symmetrize.m │ ├── times.m │ ├── tocell.m │ ├── ttm.m │ ├── ttv.m │ ├── uminus.m │ └── uplus.m ├── @sptenmat │ ├── aatx.m │ ├── disp.m │ ├── display.m │ ├── double.m │ ├── end.m │ ├── full.m │ ├── nnz.m │ ├── norm.m │ ├── size.m │ ├── sptenmat.m │ ├── subsasgn.m │ ├── subsref.m │ ├── tsize.m │ ├── uminus.m │ └── uplus.m ├── @sptensor │ ├── and.m │ ├── collapse.m │ ├── contract.m │ ├── ctranspose.m │ ├── disp.m │ ├── display.m │ ├── divide.m │ ├── double.m │ ├── elemfun.m │ ├── end.m │ ├── eq.m │ ├── find.m │ ├── full.m │ ├── ge.m │ ├── gt.m │ ├── innerprod.m │ ├── isequal.m │ ├── ldivide.m │ ├── le.m │ ├── lt.m │ ├── minus.m │ ├── mldivide.m │ ├── mrdivide.m │ ├── mtimes.m │ ├── mttkrp.m │ ├── ndims.m │ ├── ne.m │ ├── nnz.m │ ├── norm.m │ ├── not.m │ ├── nvecs.m │ ├── ones.m │ ├── or.m │ ├── permute.m │ ├── plus.m │ ├── private │ │ ├── allsubs.m │ │ ├── extract.m │ │ ├── irenumber.m │ │ ├── renumber.m │ │ └── subdims.m │ ├── rdivide.m │ ├── reshape.m │ ├── scale.m │ ├── size.m │ ├── spmatrix.m │ ├── sptensor.m │ ├── squeeze.m │ ├── subsasgn.m │ ├── subsref.m │ ├── times.m │ ├── transpose.m │ ├── ttm.m │ ├── ttt.m │ ├── ttv.m │ ├── uminus.m │ ├── uplus.m │ └── xor.m ├── @tenmat │ ├── ctranspose.m │ ├── disp.m │ ├── display.m │ ├── double.m │ ├── end.m │ ├── minus.m │ ├── mtimes.m │ ├── norm.m │ ├── plus.m │ ├── size.m │ ├── subsasgn.m │ ├── subsref.m │ ├── tenmat.m │ ├── tsize.m │ ├── uminus.m │ └── uplus.m ├── @tensor │ ├── and.m │ ├── collapse.m │ ├── contract.m │ ├── ctranspose.m │ ├── disp.m │ ├── display.m │ ├── double.m │ ├── end.m │ ├── eq.m │ ├── find.m │ ├── full.m │ ├── ge.m │ ├── gt.m │ ├── innerprod.m │ ├── isequal.m │ ├── issymmetric.m │ ├── ldivide.m │ ├── le.m │ ├── lt.m │ ├── minus.m │ ├── mldivide.m │ ├── mrdivide.m │ ├── mtimes.m │ ├── mttkrp.m │ ├── ndims.m │ ├── ne.m │ ├── nnz.m │ ├── norm.m │ ├── not.m │ ├── nvecs.m │ ├── or.m │ ├── permute.m │ ├── plus.m │ ├── power.m │ ├── rdivide.m │ ├── reshape.m │ ├── scale.m │ ├── size.m │ ├── squeeze.m │ ├── subsasgn.m │ ├── subsref.m │ ├── symmetrize.m │ ├── tenfun.m │ ├── tensor.m │ ├── times.m │ ├── transpose.m │ ├── ttm.m │ ├── ttsv.m │ ├── ttt.m │ ├── ttv.m │ ├── uminus.m │ ├── uplus.m │ └── xor.m ├── @ttensor │ ├── disp.m │ ├── display.m │ ├── double.m │ ├── end.m │ ├── full.m │ ├── innerprod.m │ ├── isequal.m │ ├── mtimes.m │ ├── mttkrp.m │ ├── ndims.m │ ├── norm.m │ ├── nvecs.m │ ├── permute.m │ ├── size.m │ ├── subsasgn.m │ ├── subsref.m │ ├── ttensor.m │ ├── ttm.m │ ├── ttv.m │ ├── uminus.m │ └── uplus.m ├── COPYRIGHT.txt ├── Contents.m ├── INSTALL.txt ├── LICENSE.txt ├── RELEASE_NOTES.txt ├── cp_als.m ├── cp_apr.m ├── cp_nmu.m ├── cp_opt.m ├── cp_wopt.m ├── create_guess.m ├── create_problem.m ├── doc │ ├── A1_tensor_doc.m │ ├── A2_sptensor_doc.m │ ├── B1_tenmat_doc.m │ ├── B2_sptenmat_doc.m │ ├── C_ttensor_doc.m │ ├── D_ktensor_doc.m │ ├── M1_multiply_doc.m │ ├── M2_identities_doc_future.m │ ├── N_nvecs_doc.m │ ├── Q_collapse_scale_doc.m │ ├── S_test_problems_doc.m │ ├── T1_algorithms_doc.m │ ├── T2_opt_algorithms_doc.m │ ├── T3_wopt_algorithms_doc.m │ ├── T4_cpapr_doc.m │ ├── V_SSHOPM_doc.m │ ├── html │ │ ├── A1_tensor_doc.html │ │ ├── A2_sptensor_doc.html │ │ ├── B1_tenmat_doc.html │ │ ├── B2_sptenmat_doc.html │ │ ├── C_ttensor_doc.html │ │ ├── C_ttensor_doc_eq05572125758666918607.png │ │ ├── D_ktensor_doc.html │ │ ├── D_ktensor_doc_eq03981049146616847228.png │ │ ├── D_ktensor_doc_eq06950581413034201722.png │ │ ├── D_ktensor_doc_eq11724614562625913327.png │ │ ├── D_ktensor_doc_eq15815821552081582258.png │ │ ├── M1_multiply_doc.html │ │ ├── N_nvecs_doc.html │ │ ├── Q_collapse_scale_doc.html │ │ ├── S_test_problems_doc.html │ │ ├── T1_algorithms_doc.html │ │ ├── T2_opt_algorithms_doc.html │ │ ├── T3_wopt_algorithms_doc.html │ │ ├── T4_cpapr_doc.html │ │ └── V_SSHOPM_doc.html │ └── images │ │ ├── Workspace.png │ │ ├── banner-background.jpg │ │ └── logo.gif ├── eig_geap.m ├── eig_sshopm.m ├── eig_sshopmc.m ├── export_data.m ├── helpindex.xml ├── helptoc.xml ├── import_data.m ├── info.xml ├── khatrirao.m ├── matrandcong.m ├── matrandnorm.m ├── matrandorth.m ├── met │ ├── Contents.m │ ├── ttm_me.m │ ├── ttm_me_mem.m │ ├── ttm_me_partition.m │ ├── tucker_me.m │ └── tucker_me_test.m ├── parafac_als.m ├── sptendiag.m ├── sptenrand.m ├── tendiag.m ├── teneye.m ├── tenones.m ├── tenrand.m ├── tensor_toolbox_product_page.html ├── tenzeros.m ├── tt_cp_fg.m ├── tt_cp_fun.m ├── tt_cp_vec_to_fac.m ├── tt_dimscheck.m ├── tt_fac_to_vec.m ├── tt_ind2sub.m ├── tt_intvec2str.m ├── tt_matrix2cellstr.m ├── tt_size2str.m ├── tt_sizecheck.m ├── tt_sub2ind.m ├── tt_subscheck.m ├── tt_subsubsref.m ├── tt_valscheck.m ├── tucker_als.m └── tucker_sym.m └── tools ├── GSVT_t.m ├── SVT_t.m ├── SynData2M.m ├── powerMethod_gen.m ├── sparse_inp.mexglx ├── sparse_inp.mexmaci64 ├── sparse_inp.mexw64 ├── sparse_update.mexglx ├── sparse_update.mexmaci64 ├── sparse_update.mexw64 └── synRand.m /README.md: -------------------------------------------------------------------------------- 1 | # NORT 2 | Efficient Nonconvex Regularized Tensor Completion with Structure-aware Proximal Iterations. ICML-2019. 3 | 4 | Matlab code for "Efficient Nonconvex Regularized Tensor Completion with Structure-aware Proximal Iterations. ICML-2019". Quanming Yao, James T. Kwok and Bo Han. (https://arxiv.org/abs/1807.08725) 5 | -------------------------------------------------------------------------------- /Synthetic/2-Mode/NORT/MakePart.m: -------------------------------------------------------------------------------- 1 | function [ part ] = MakePart( row, col, U, S, V, sz, wgt ) 2 | 3 | part1 = makepart1( row, col, U{1}, wgt(1)*S{1}, V{1}, sz ); 4 | part2 = makepart2( row, col, U{2}, wgt(2)*S{2}, V{2}, sz ); 5 | 6 | part = cell(length(row), 1); 7 | for i = 1:length(row) 8 | part{i} = part1{i} + part2{i}; 9 | end 10 | 11 | end 12 | 13 | -------------------------------------------------------------------------------- /Synthetic/2-Mode/NORT/TencompPred.m: -------------------------------------------------------------------------------- 1 | function [ RMSE ] = TencompPred( U, S, V, wgt, test, tenSz ) 2 | 3 | pred1 = makepart1( test.row, test.col, U{1}, S{1}*wgt(1), V{1}, tenSz ); 4 | pred2 = makepart2( test.row, test.col, U{2}, S{2}*wgt(2), V{2}, tenSz ); 5 | 6 | nnzR = 0; 7 | RMSE = 0; 8 | for i = 1:length(pred1) 9 | error = test.data{i} - pred1{i} - pred2{i}; 10 | RMSE = RMSE + sum(error.^2); 11 | nnzR = nnzR + length(error); 12 | end 13 | RMSE = sqrt(RMSE/nnzR); 14 | 15 | end 16 | 17 | -------------------------------------------------------------------------------- /Synthetic/2-Mode/NORT/copyToSpa.m: -------------------------------------------------------------------------------- 1 | function [Spa] = copyToSpa(part, Spa, stepSz) 2 | 3 | for i = 1:length(part) 4 | sparse_update(Spa{i}, part{i}/stepSz); 5 | end 6 | 7 | end -------------------------------------------------------------------------------- /Synthetic/2-Mode/NORT/den-multi/fastMulti1u.m: -------------------------------------------------------------------------------- 1 | function [ x ] = fastMulti1u( U1, V1, u, sz ) 2 | % u2 (U1 V1) 3 | 4 | V = zeros(size(V1,2), sz(3)); 5 | 6 | for i = 1:size(V1, 2) 7 | % v1 = V1(:,i); 8 | v1 = reshape(V1(:,i), sz(2), sz(3)); 9 | v1 = u'*v1; 10 | 11 | V(i, :) = v1; 12 | end 13 | 14 | x = U1*V; 15 | x = reshape(x', 1, numel(x)); 16 | 17 | end 18 | 19 | -------------------------------------------------------------------------------- /Synthetic/2-Mode/NORT/den-multi/fastMulti1v.m: -------------------------------------------------------------------------------- 1 | function [ x ] = fastMulti1v( U1, V1, v, sz) 2 | % (U1 V1) v2 3 | 4 | x = 0; 5 | v = reshape(v, sz(3), sz(1)); 6 | 7 | for j = 1:size(V1, 2) 8 | % u1 = U1(:, j); 9 | % v1 = V1(:, j); 10 | v1 = reshape(V1(:, j), sz(2), sz(3)); 11 | 12 | x = x + v1*(v * U1(:, j)); 13 | end 14 | 15 | end 16 | 17 | -------------------------------------------------------------------------------- /Synthetic/2-Mode/NORT/den-multi/fastMulti2u.m: -------------------------------------------------------------------------------- 1 | function [ x ] = fastMulti2u( U2, V2, u, sz) 2 | % u1 (U2 V2) 3 | 4 | V = zeros(size(V2,2), sz(3)); 5 | 6 | for i = 1:size(U2, 2) 7 | % v2 = V2(:, i); 8 | v2 = reshape(V2(:, i), sz(3), sz(1)); 9 | v2 = v2*u; 10 | 11 | V(i, :) = v2'; 12 | end 13 | 14 | x = U2*V; 15 | x = reshape(x, 1, numel(x)); 16 | 17 | end 18 | 19 | -------------------------------------------------------------------------------- /Synthetic/2-Mode/NORT/den-multi/fastMulti2v.m: -------------------------------------------------------------------------------- 1 | function [ x ] = fastMulti2v( U2, V2, v, sz) 2 | % u1 (U2 V2) 3 | 4 | x = 0; 5 | v = reshape(v, sz(2), sz(3)); 6 | 7 | for j = 1:size(V2, 2) 8 | % u1 = U2(:, j); 9 | % v1 = V2(:, j); 10 | v1 = reshape(V2(:, j), sz(3), sz(1)); 11 | 12 | x = x + v1'*(v' * U2(:, j)); 13 | end 14 | 15 | end 16 | 17 | -------------------------------------------------------------------------------- /Synthetic/2-Mode/NORT/makepart/makepart1.m: -------------------------------------------------------------------------------- 1 | function [ part ] = makepart1( row, col, U1, S1, V1, sz ) 2 | % mode-1 3 | 4 | n = sz(2); 5 | part = cell(length(row), 1); 6 | 7 | U = U1*diag(S1); 8 | 9 | for i = 1:length(row) 10 | V = V1(1 + (i - 1)*n:i*n, :); 11 | 12 | part{i} = sparse_inp(U', V', row{i}, col{i})'; 13 | end 14 | 15 | 16 | end 17 | 18 | -------------------------------------------------------------------------------- /Synthetic/2-Mode/NORT/makepart/makepart2.m: -------------------------------------------------------------------------------- 1 | function [ part ] = makepart2( row, col, U2, S2, V2, sz ) 2 | % mode-2 3 | 4 | n = sz(3); 5 | part = cell(length(row), 1); 6 | 7 | V = U2*diag(S2); 8 | 9 | for i = 1:length(row) 10 | U = V2(i:n:size(V2,1), :); 11 | 12 | part{i} = sparse_inp(U', V', row{i}, col{i})'; 13 | end 14 | 15 | 16 | end 17 | 18 | -------------------------------------------------------------------------------- /Synthetic/2-Mode/NORT/powermethod/subMulti1u.m: -------------------------------------------------------------------------------- 1 | function [ A ] = subMulti1u( U1, V1, U2, V2, U, sz ) 2 | % U1'*(U1 V1' + U2 V2') 3 | 4 | A = zeros(size(U,2), size(V1,1)); 5 | 6 | for i = 1:size(U,2) 7 | u = U(:,i); 8 | 9 | % mode-2 10 | a = fastMulti2u( U2, V2, u, sz); 11 | % mode-1 12 | a = a + (u'*U1)*V1'; 13 | 14 | A(i,:) = a; 15 | end 16 | 17 | end 18 | 19 | -------------------------------------------------------------------------------- /Synthetic/2-Mode/NORT/powermethod/subMulti1v.m: -------------------------------------------------------------------------------- 1 | function [ A ] = subMulti1v( U1, V1, U2, V2, V, sz ) 2 | % (U1 V1' + U2 V2')*V1 3 | 4 | A = zeros(size(U1,1), size(V,2)); 5 | 6 | for i = 1:size(V,2) 7 | v = V(:,i); 8 | 9 | % mode-2 10 | a = fastMulti2v( U2, V2, v, sz); 11 | % mode-1 12 | a = a + U1*(V1'*v); 13 | 14 | A(:,i) = a; 15 | end 16 | 17 | end 18 | 19 | -------------------------------------------------------------------------------- /Synthetic/2-Mode/NORT/powermethod/subMulti2u.m: -------------------------------------------------------------------------------- 1 | function [ A ] = subMulti2u( U1, V1, U2, V2, U, sz ) 2 | % U2'*(U1 V1' + U2 V2') 3 | 4 | A = zeros(size(U,2), size(V2,1)); 5 | 6 | for i = 1:size(U,2) 7 | u = U(:,i); 8 | 9 | % mode-1 10 | a = fastMulti1u( U1, V1, u, sz); 11 | % mode-2 12 | a = a + (u'*U2)*V2'; 13 | 14 | A(i,:) = a; 15 | end 16 | 17 | end 18 | 19 | -------------------------------------------------------------------------------- /Synthetic/2-Mode/NORT/powermethod/subMulti2v.m: -------------------------------------------------------------------------------- 1 | function [ A ] = subMulti2v( U1, V1, U2, V2, V, sz ) 2 | % (U1 V1' + U2 V2')*V2 3 | 4 | A = zeros(size(U2,1), size(V,2)); 5 | 6 | for i = 1:size(V,2) 7 | v = V(:,i); 8 | 9 | a = fastMulti1v( U1, V1, v, sz); 10 | a = a + U2*(V2'*v); 11 | 12 | A(:,i) = a; 13 | end 14 | 15 | end 16 | 17 | -------------------------------------------------------------------------------- /Synthetic/2-Mode/NORT/spa-multi/subSpa1u.m: -------------------------------------------------------------------------------- 1 | function [ A ] = subSpa1u(Spa, U, sz) 2 | % u1' * spa 3 | 4 | n = sz(2); 5 | A = zeros(size(U,2), sz(2)*sz(3)); 6 | 7 | for i = 1:length(Spa) 8 | B = U'*Spa{i}; 9 | 10 | A(:, 1 + n*(i - 1):n*i) = B; 11 | end 12 | 13 | end -------------------------------------------------------------------------------- /Synthetic/2-Mode/NORT/spa-multi/subSpa1v.m: -------------------------------------------------------------------------------- 1 | function [ A ] = subSpa1v(Spa, V, sz) 2 | % spa * v1 3 | 4 | n = size(Spa{1}, 2); 5 | A = zeros(sz(1), size(V,2)); 6 | 7 | for i = 1:length(Spa) 8 | B = V(1 + (i - 1)*n : i*n, :); 9 | A = A + Spa{i}*B; 10 | end 11 | 12 | end -------------------------------------------------------------------------------- /Synthetic/2-Mode/NORT/spa-multi/subSpa2u.m: -------------------------------------------------------------------------------- 1 | function [ A ] = subSpa2u( Spa, U, sz ) 2 | % u2' * spa 3 | 4 | A = zeros(size(U,2), sz(1)*sz(3)); 5 | n = size(A,2); 6 | 7 | for i = 1:length(Spa) 8 | B = Spa{i}*U; 9 | 10 | A(:, i:length(Spa):n) = B'; 11 | end 12 | 13 | end -------------------------------------------------------------------------------- /Synthetic/2-Mode/NORT/spa-multi/subSpa2v.m: -------------------------------------------------------------------------------- 1 | function [ A ] = subSpa2v(Spa, V, sz) 2 | % spa * v2 3 | 4 | n = sz(3); 5 | A = zeros(sz(2), size(V,2)); 6 | 7 | for i = 1:length(Spa) 8 | B = V(i:n:size(V,1), :); 9 | A = A + Spa{i}'*B; 10 | end 11 | 12 | end -------------------------------------------------------------------------------- /Synthetic/2-Mode/NORT/subMulti1u.m: -------------------------------------------------------------------------------- 1 | function [ A ] = subMulti1u( U1, V1, U2, V2, U, sz ) 2 | % U1'*(U1 V1' + U2 V2') 3 | 4 | A = zeros(size(U,2), size(V1,1)); 5 | 6 | for i = 1:size(U,2) 7 | u = U(:,i); 8 | 9 | % mode-2 10 | a = fastMulti2u( U2, V2, u, sz); 11 | % mode-1 12 | a = a + (u'*U1)*V1'; 13 | 14 | A(i,:) = a; 15 | end 16 | 17 | end 18 | 19 | -------------------------------------------------------------------------------- /Synthetic/2-Mode/NORT/subMulti1v.m: -------------------------------------------------------------------------------- 1 | function [ A ] = subMulti1v( U1, V1, U2, V2, V, sz ) 2 | % (U1 V1' + U2 V2')*V1 3 | 4 | A = zeros(size(U1,1), size(V,2)); 5 | 6 | for i = 1:size(V,2) 7 | v = V(:,i); 8 | 9 | % mode-2 10 | a = fastMulti2v( U2, V2, v, sz); 11 | % mode-1 12 | a = a + U1*(V1'*v); 13 | 14 | A(:,i) = a; 15 | end 16 | 17 | end 18 | 19 | -------------------------------------------------------------------------------- /Synthetic/2-Mode/NORT/subMulti2u.m: -------------------------------------------------------------------------------- 1 | function [ A ] = subMulti2u( U1, V1, U2, V2, U, sz ) 2 | % U2'*(U1 V1' + U2 V2') 3 | 4 | A = zeros(size(U,2), size(V2,1)); 5 | 6 | for i = 1:size(U,2) 7 | u = U(:,i); 8 | 9 | % mode-1 10 | a = fastMulti1u( U1, V1, u, sz); 11 | % mode-2 12 | a = a + (u'*U2)*V2'; 13 | 14 | A(i,:) = a; 15 | end 16 | 17 | end 18 | 19 | -------------------------------------------------------------------------------- /Synthetic/2-Mode/NORT/subMulti2v.m: -------------------------------------------------------------------------------- 1 | function [ A ] = subMulti2v( U1, V1, U2, V2, V, sz ) 2 | % (U1 V1' + U2 V2')*V2 3 | 4 | A = zeros(size(U2,1), size(V,2)); 5 | 6 | for i = 1:size(V,2) 7 | v = V(:,i); 8 | 9 | a = fastMulti1v( U1, V1, v, sz); 10 | a = a + U2*(V2'*v); 11 | 12 | A(:,i) = a; 13 | end 14 | 15 | end 16 | 17 | -------------------------------------------------------------------------------- /Synthetic/2-Mode/NORT/warmStart.m: -------------------------------------------------------------------------------- 1 | function [ R ] = warmStart(U1, U0, maxR) 2 | 3 | R = [U1, U0]; 4 | [R, ~] = qr(R, 0); 5 | R = R(:,1:min(size(R,2), maxR)); 6 | 7 | end -------------------------------------------------------------------------------- /Synthetic/2-Mode/setup.m: -------------------------------------------------------------------------------- 1 | clc; clear; 2 | 3 | addpath('ProxAvg'); 4 | addpath(genpath('NORT')); 5 | 6 | addpath(genpath('../../common-tools')); -------------------------------------------------------------------------------- /Synthetic/3-Mode/200-1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/Synthetic/3-Mode/200-1.mat -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/TencompPred.m: -------------------------------------------------------------------------------- 1 | function [ RMSE ] = TencompPred( U, S, V, wgt, test, tenSz ) 2 | 3 | for m = 1:length(U) 4 | U{m} = U{m} * diag(wgt(m)*S{m}); 5 | end 6 | 7 | pred = subMakrPrat(test.subs, U, V, tenSz); 8 | pred = pred - test.vals; 9 | 10 | RMSE = sqrt(sum(pred.^2) / length(pred)); 11 | 12 | end 13 | 14 | -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/filterBase.m: -------------------------------------------------------------------------------- 1 | function [ U, S, V ] = filterBase( U, S, V, maxR ) 2 | 3 | nnzS = min(maxR, nnz(S)); 4 | S = S(1:nnzS); 5 | 6 | U = U(:,1:nnzS); 7 | V = V(:,1:nnzS); 8 | 9 | end -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/makepart/MakepartM1.m: -------------------------------------------------------------------------------- 1 | function [ vals ] = MakepartM1( subs, U, V, szTen ) 2 | % U1 V1 3 | 4 | nnZ = size(subs, 1); 5 | 6 | vals = zeros(nnZ, 1); 7 | 8 | for i = 1:nnZ 9 | sub1 = subs(i, 1); 10 | sub2 = subs(i, 2); 11 | sub3 = subs(i, 3); 12 | 13 | u = U(sub1, :); 14 | v = V((sub3 - 1)*szTen(2) + sub2, :); 15 | 16 | vals(i) = u*v'; 17 | end 18 | 19 | end 20 | 21 | -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/makepart/MakepartM1_c.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/Synthetic/3-Mode/NORT/makepart/MakepartM1_c.mexw64 -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/makepart/MakepartM2.m: -------------------------------------------------------------------------------- 1 | function [ vals ] = MakepartM2( subs, U, V, szTen ) 2 | % U2 V2 3 | 4 | nnZ = size(subs, 1); 5 | 6 | vals = zeros(nnZ, 1); 7 | 8 | for i = 1:nnZ 9 | sub1 = subs(i, 1); 10 | sub2 = subs(i, 2); 11 | sub3 = subs(i, 3); 12 | 13 | u = U(sub2, :); 14 | v = V((sub1 - 1)*szTen(3) + sub3, :); 15 | 16 | vals(i) = u*v'; 17 | end 18 | 19 | end 20 | 21 | -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/makepart/MakepartM2_c.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/Synthetic/3-Mode/NORT/makepart/MakepartM2_c.mexw64 -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/makepart/MakepartM3.m: -------------------------------------------------------------------------------- 1 | function [ vals ] = MakepartM3( subs, U, V, szTen ) 2 | % U3 V3 3 | 4 | nnZ = size(subs, 1); 5 | 6 | vals = zeros(nnZ, 1); 7 | 8 | for i = 1:nnZ 9 | sub1 = subs(i, 1); 10 | sub2 = subs(i, 2); 11 | sub3 = subs(i, 3); 12 | 13 | u = U(sub3, :); 14 | v = V((sub2 - 1)*szTen(1) + sub1, :); 15 | 16 | vals(i) = u*v'; 17 | end 18 | 19 | end 20 | 21 | -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/makepart/MakepartM3_c.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/Synthetic/3-Mode/NORT/makepart/MakepartM3_c.mexw64 -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/makepart/compile.m: -------------------------------------------------------------------------------- 1 | clear; clc; 2 | 3 | % mex -v OPTIMFLAGS="/Ox" MakepartM1_cblas.cpp D:\Programs\Matlab2016a\extern\lib\win64\microsoft\*.lib; 4 | 5 | 6 | mex -v OPTIMFLAGS="/Ox" MakepartM1_c.cpp; 7 | mex -v OPTIMFLAGS="/Ox" MakepartM2_c.cpp; 8 | mex -v OPTIMFLAGS="/Ox" MakepartM3_c.cpp; -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/powermethod/den-multi/subMulti1M2u.m: -------------------------------------------------------------------------------- 1 | function [ x ] = subMulti1M2u( U1, V1, u, sz ) 2 | % u2 (U1 V1) 3 | 4 | V = zeros(size(V1,2), sz(3)); 5 | 6 | for i = 1:size(V1, 2) 7 | % v1 = V1(:,i); 8 | v1 = reshape(V1(:,i), sz(2), sz(3)); 9 | v1 = u'*v1; 10 | 11 | V(i, :) = v1; 12 | end 13 | 14 | x = U1*V; 15 | x = reshape(x', 1, numel(x)); 16 | 17 | end 18 | 19 | -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/powermethod/den-multi/subMulti1M2v.m: -------------------------------------------------------------------------------- 1 | function [ x ] = subMulti1M2v( U1, V1, v, sz ) 2 | % (U1 V1) v2 3 | 4 | x = 0; 5 | v = reshape(v, sz(3), sz(1)); 6 | 7 | for j = 1:size(V1, 2) 8 | % u1 = U1(:, j); 9 | % v1 = V1(:, j); 10 | v1 = reshape(V1(:, j), sz(2), sz(3)); 11 | 12 | x = x + v1*(v * U1(:, j)); 13 | end 14 | 15 | end 16 | 17 | -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/powermethod/den-multi/subMulti1M3u.m: -------------------------------------------------------------------------------- 1 | function [ x ] = subMulti1M3u( U1, V1, u, sz ) 2 | % u3 (U1 V1) 3 | 4 | V = zeros(sz(2), size(V1,2)); 5 | 6 | for i = 1:size(V1, 2) 7 | % v1 = V1(:,i); 8 | v1 = reshape(V1(:,i), sz(2), sz(3)); 9 | v1 = v1*u; 10 | 11 | V(:,i) = v1; 12 | end 13 | 14 | x = U1*V'; 15 | x = reshape(x, 1, numel(x)); 16 | 17 | end 18 | 19 | -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/powermethod/den-multi/subMulti1M3v.m: -------------------------------------------------------------------------------- 1 | function [ x ] = subMulti1M3v( U1, V1, v, sz ) 2 | % (U1 V1) v3 3 | 4 | x = 0; 5 | v = reshape(v, sz(1), sz(2)); 6 | 7 | for j = 1:size(V1, 2) 8 | % u1 = U1(:, j); 9 | % v1 = V1(:, j); 10 | v1 = reshape(V1(:, j), sz(2), sz(3)); 11 | 12 | x = x + v1'*(v'*U1(:, j)); 13 | end 14 | 15 | end 16 | 17 | -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/powermethod/den-multi/subMulti2M1u.m: -------------------------------------------------------------------------------- 1 | function [ x ] = subMulti2M1u( U2, V2, u, sz ) 2 | % u1 (U2 V2) 3 | 4 | V = zeros(size(V2,2), sz(3)); 5 | 6 | for i = 1:size(U2, 2) 7 | % v2 = V2(:, i); 8 | v2 = reshape(V2(:, i), sz(3), sz(1)); 9 | v2 = v2*u; 10 | 11 | V(i, :) = v2'; 12 | end 13 | 14 | x = U2*V; 15 | x = reshape(x, 1, numel(x)); 16 | 17 | end 18 | 19 | -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/powermethod/den-multi/subMulti2M1v.m: -------------------------------------------------------------------------------- 1 | function [ x ] = subMulti2M1v( U2, V2, v, sz ) 2 | % u1 (U2 V2) 3 | 4 | x = 0; 5 | v = reshape(v, sz(2), sz(3)); 6 | 7 | for j = 1:size(V2, 2) 8 | % u1 = U2(:, j); 9 | % v1 = V2(:, j); 10 | v1 = reshape(V2(:, j), sz(3), sz(1)); 11 | 12 | x = x + v1'*(v' * U2(:, j)); 13 | end 14 | 15 | end 16 | 17 | -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/powermethod/den-multi/subMulti2M3u.m: -------------------------------------------------------------------------------- 1 | function [ x ] = subMulti2M3u( U2, V2, u, sz ) 2 | % u3 (U2 V2) 3 | 4 | V = zeros(sz(1), size(V2,2)); 5 | 6 | for i = 1:size(U2, 2) 7 | % v2 = V2(:, i); 8 | v2 = reshape(V2(:, i), sz(3), sz(1)); 9 | v2 = u'*v2; 10 | 11 | V(:,i) = v2'; 12 | end 13 | 14 | x = U2*V'; 15 | x = reshape(x', 1, numel(x)); 16 | 17 | end 18 | 19 | -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/powermethod/den-multi/subMulti2M3v.m: -------------------------------------------------------------------------------- 1 | function [ x ] = subMulti2M3v( U2, V2, v, sz ) 2 | % (U2 V2) v3 3 | 4 | x = 0; 5 | v = reshape(v, sz(1), sz(2)); 6 | 7 | for j = 1:size(V2, 2) 8 | % u1 = U2(:, j); 9 | % v1 = V2(:, j); 10 | v1 = reshape(V2(:, j), sz(3), sz(1)); 11 | 12 | x = x + v1 * (v * U2(:, j)); 13 | end 14 | 15 | end 16 | 17 | -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/powermethod/den-multi/subMulti3M1u.m: -------------------------------------------------------------------------------- 1 | function [ x ] = subMulti3M1u( U3, V3, u, sz ) 2 | % u1 (U3 V3) 3 | 4 | V = zeros(sz(2), size(V3,2)); 5 | 6 | for i = 1:size(U3, 2) 7 | % v2 = V3(:, i); 8 | v2 = reshape(V3(:, i), sz(1), sz(2)); 9 | v2 = u'*v2; 10 | 11 | V(:,i) = v2'; 12 | end 13 | 14 | x = U3*V'; 15 | x = reshape(x', 1, numel(x)); 16 | 17 | end 18 | 19 | -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/powermethod/den-multi/subMulti3M1v.m: -------------------------------------------------------------------------------- 1 | function [ x ] = subMulti3M1v( U3, V3, v, sz ) 2 | % (U3 V3) v1 3 | 4 | x = 0; 5 | v = reshape(v, sz(2), sz(3)); 6 | 7 | for j = 1:size(V3, 2) 8 | % u1 = U3(:, j); 9 | % v1 = V3(:, j); 10 | v1 = reshape(V3(:, j), sz(1), sz(2)); 11 | 12 | x = x + v1 * (v * U3(:, j)); 13 | end 14 | 15 | end 16 | 17 | -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/powermethod/den-multi/subMulti3M2u.m: -------------------------------------------------------------------------------- 1 | function [ x ] = subMulti3M2u( U3, V3, u, sz ) 2 | % u2 (U3 V3) 3 | 4 | V = zeros(sz(1), size(V3,2)); 5 | 6 | for i = 1:size(U3, 2) 7 | % v2 = V3(:, i); 8 | v2 = reshape(V3(:, i), sz(1), sz(2)); 9 | v2 = v2 * u; 10 | 11 | V(:,i) = v2; 12 | end 13 | 14 | x = U3*V'; 15 | x = reshape(x, 1, numel(x)); 16 | 17 | end 18 | 19 | -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/powermethod/den-multi/subMulti3M2v.m: -------------------------------------------------------------------------------- 1 | function [ x ] = subMulti3M2v( U3, V3, v, sz ) 2 | % (U3 V3) v2 3 | 4 | x = 0; 5 | v = reshape(v, sz(3), sz(1)); 6 | 7 | for j = 1:size(V3, 2) 8 | % u1 = U3(:, j); 9 | % v1 = V3(:, j); 10 | v1 = reshape(V3(:, j), sz(1), sz(2)); 11 | 12 | x = x + v1' * (v' * U3(:, j)); 13 | end 14 | 15 | end 16 | 17 | -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/powermethod/spa-multi/compile.m: -------------------------------------------------------------------------------- 1 | clear; clc; 2 | 3 | % mode-1 4 | mex -v OPTIMFLAGS="/Ox" subSpa1Mu_c.cpp; 5 | % mex -v OPTIMFLAGS="/Ox" subSpa1Mu_cblas.cpp D:\Programs\Matlab2016a\extern\lib\win64\microsoft\*.lib 6 | mex -v OPTIMFLAGS="/Ox" subSpa1Mv_c.cpp; 7 | 8 | % mode-2 9 | mex -v OPTIMFLAGS="/Ox" subSpa2Mu_c.cpp; 10 | mex -v OPTIMFLAGS="/Ox" subSpa2Mv_c.cpp; 11 | 12 | % mode-3 13 | mex -v OPTIMFLAGS="/Ox" subSpa3Mu_c.cpp; 14 | mex -v OPTIMFLAGS="/Ox" subSpa3Mv_c.cpp; -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/powermethod/spa-multi/subSpa1Mu.m: -------------------------------------------------------------------------------- 1 | function [ X ] = subSpa1Mu( subs, vals, U, tenSz ) 2 | % u1' * Spa 3 | 4 | nnZ = size(subs, 1); 5 | X = zeros(size(U,2), tenSz(2)*tenSz(3)); 6 | 7 | for i = 1:nnZ 8 | sub1 = subs(i, 1); 9 | sub2 = subs(i, 2); 10 | sub3 = subs(i, 3); 11 | 12 | ui = U(sub1, :); 13 | 14 | ai = vals(i); 15 | pi = sub2 + tenSz(2)*(sub3 - 1); 16 | 17 | X(:,pi) = X(:,pi) + ai*ui'; 18 | end 19 | 20 | fprintf('should not be called\n'); 21 | 22 | end 23 | 24 | -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/powermethod/spa-multi/subSpa1Mu_c.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/Synthetic/3-Mode/NORT/powermethod/spa-multi/subSpa1Mu_c.mexw64 -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/powermethod/spa-multi/subSpa1Mv.m: -------------------------------------------------------------------------------- 1 | function [ X ] = subSpa1Mv( subs, vals, V, tenSz ) 2 | % Spa * v1 3 | 4 | nnZ = size(subs, 1); 5 | X = zeros(tenSz(1), size(V,2)); 6 | 7 | for i = 1:nnZ 8 | sub1 = subs(i, 1); 9 | sub2 = subs(i, 2); 10 | sub3 = subs(i, 3); 11 | 12 | ai = vals(i); 13 | pi = sub2 + tenSz(2)*(sub3 - 1); 14 | 15 | ui = V(pi, :); 16 | 17 | X(sub1,:) = X(sub1,:) + ai*ui; 18 | end 19 | 20 | fprintf('should not be called\n'); 21 | 22 | end 23 | 24 | -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/powermethod/spa-multi/subSpa1Mv_c.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/Synthetic/3-Mode/NORT/powermethod/spa-multi/subSpa1Mv_c.mexw64 -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/powermethod/spa-multi/subSpa2Mu.m: -------------------------------------------------------------------------------- 1 | function [ X ] = subSpa2Mu( subs, vals, U, tenSz ) 2 | % u2' * Spa 3 | 4 | nnZ = size(subs, 1); 5 | X = zeros(size(U,2), tenSz(1)*tenSz(3)); 6 | 7 | for i = 1:nnZ 8 | sub1 = subs(i, 1); 9 | sub2 = subs(i, 2); 10 | sub3 = subs(i, 3); 11 | 12 | ui = U(sub2, :); 13 | 14 | ai = vals(i); 15 | pi = sub3 + tenSz(3)*(sub1 - 1); 16 | 17 | X(:,pi) = X(:,pi) + ai*ui'; 18 | end 19 | 20 | fprintf('should not be called\n'); 21 | 22 | end 23 | 24 | -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/powermethod/spa-multi/subSpa2Mu_c.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/Synthetic/3-Mode/NORT/powermethod/spa-multi/subSpa2Mu_c.mexw64 -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/powermethod/spa-multi/subSpa2Mv.m: -------------------------------------------------------------------------------- 1 | function [ X ] = subSpa2Mv( subs, vals, V, tenSz ) 2 | % Spa * v2 3 | 4 | nnZ = size(subs, 1); 5 | X = zeros(tenSz(2), size(V,2)); 6 | 7 | for i = 1:nnZ 8 | sub1 = subs(i, 1); 9 | sub2 = subs(i, 2); 10 | sub3 = subs(i, 3); 11 | 12 | ai = vals(i); 13 | pi = sub3 + tenSz(3)*(sub1 - 1); 14 | 15 | ui = V(pi, :); 16 | 17 | X(sub2,:) = X(sub2,:) + ai*ui; 18 | end 19 | 20 | fprintf('should not be called\n'); 21 | 22 | end 23 | 24 | -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/powermethod/spa-multi/subSpa2Mv_c.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/Synthetic/3-Mode/NORT/powermethod/spa-multi/subSpa2Mv_c.mexw64 -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/powermethod/spa-multi/subSpa3Mu.m: -------------------------------------------------------------------------------- 1 | function [ X ] = subSpa3Mu( subs, vals, U, tenSz ) 2 | % u3' * Spa 3 | 4 | nnZ = size(subs, 1); 5 | X = zeros(size(U,2), tenSz(1)*tenSz(2)); 6 | 7 | for i = 1:nnZ 8 | sub1 = subs(i, 1); 9 | sub2 = subs(i, 2); 10 | sub3 = subs(i, 3); 11 | 12 | ui = U(sub3, :); 13 | 14 | ai = vals(i); 15 | pi = sub1 + tenSz(1)*(sub2 - 1); 16 | 17 | X(:,pi) = X(:,pi) + ai*ui'; 18 | end 19 | 20 | fprintf('should not be called\n'); 21 | 22 | end 23 | 24 | -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/powermethod/spa-multi/subSpa3Mu_c.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/Synthetic/3-Mode/NORT/powermethod/spa-multi/subSpa3Mu_c.mexw64 -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/powermethod/spa-multi/subSpa3Mv.m: -------------------------------------------------------------------------------- 1 | function [ X ] = subSpa3Mv( subs, vals, V, tenSz ) 2 | % Spa * v3 3 | 4 | nnZ = size(subs, 1); 5 | X = zeros(tenSz(3), size(V,2)); 6 | 7 | for i = 1:nnZ 8 | sub1 = subs(i, 1); 9 | sub2 = subs(i, 2); 10 | sub3 = subs(i, 3); 11 | 12 | ai = vals(i); 13 | pi = sub1 + tenSz(1)*(sub2 - 1); 14 | 15 | ui = V(pi, :); 16 | 17 | X(sub3,:) = X(sub3,:) + ai*ui; 18 | end 19 | 20 | fprintf('should not be called\n'); 21 | 22 | end 23 | 24 | -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/powermethod/spa-multi/subSpa3Mv_c.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/Synthetic/3-Mode/NORT/powermethod/spa-multi/subSpa3Mv_c.mexw64 -------------------------------------------------------------------------------- /Synthetic/3-Mode/NORT/subMakrPrat.m: -------------------------------------------------------------------------------- 1 | function [ prti ] = subMakrPrat(subs, U0, V0, tenSz) 2 | 3 | prti = 0; 4 | prtm = zeros(size(subs,1), 1); 5 | 6 | makeFunc = {@MakepartM1_c, @MakepartM2_c, @MakepartM3_c}; 7 | for m = 1:length(makeFunc) 8 | makeFunc{m}(subs, U0{m}, V0{m}, tenSz, prtm); 9 | prti = prti + prtm; 10 | end 11 | 12 | end -------------------------------------------------------------------------------- /Synthetic/3-Mode/ProxAvg/getX.m: -------------------------------------------------------------------------------- 1 | function [ X ] = getX(M1, M2, M3, tenSz, lambda) 2 | 3 | alpha1 = lambda(1)/sum(lambda); 4 | alpha2 = lambda(2)/sum(lambda); 5 | alpha3 = lambda(3)/sum(lambda); 6 | 7 | X = alpha1 * Fold(M1, tenSz, 1) ... 8 | + alpha2 * Fold(M2, tenSz, 2) ... 9 | + alpha3 * Fold(M3, tenSz, 3); 10 | 11 | end -------------------------------------------------------------------------------- /Synthetic/3-Mode/ProxAvg/proxAvgObj.m: -------------------------------------------------------------------------------- 1 | function [ obj ] = proxAvgObj(O, Omega, X, S, lambda, theta, regType) 2 | 3 | obj = (O - X) .* Omega; 4 | obj = (1/2) * sum(obj(:).^2); 5 | 6 | for m = 1:length(S) 7 | obj = obj + funRegC(S{m}, length(S{m}), lambda(m), theta, regType); 8 | end 9 | 10 | end -------------------------------------------------------------------------------- /Synthetic/3-Mode/setup.m: -------------------------------------------------------------------------------- 1 | clc; clear; 2 | 3 | addpath('ProxAvg'); 4 | addpath(genpath('NORT')); 5 | 6 | addpath(genpath('../../common-tools')); -------------------------------------------------------------------------------- /common-tools/Auxiliary_files/Fold.m: -------------------------------------------------------------------------------- 1 | function [X] = Fold(X, dim, i) 2 | dim = circshift(dim, [1-i, 1-i]); 3 | X = shiftdim(reshape(X, dim), length(dim)+1-i); -------------------------------------------------------------------------------- /common-tools/Auxiliary_files/Unfold.m: -------------------------------------------------------------------------------- 1 | function [X] = Unfold( X, dim, i ) 2 | X = reshape(shiftdim(X,i-1), dim(i), []); -------------------------------------------------------------------------------- /common-tools/Auxiliary_files/calcFunction_mex.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/Auxiliary_files/calcFunction_mex.mexa64 -------------------------------------------------------------------------------- /common-tools/Auxiliary_files/calcFunction_mex.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/Auxiliary_files/calcFunction_mex.mexmaci64 -------------------------------------------------------------------------------- /common-tools/Auxiliary_files/calcFunction_mex.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/Auxiliary_files/calcFunction_mex.mexw64 -------------------------------------------------------------------------------- /common-tools/Auxiliary_files/calcGradient_mex.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/Auxiliary_files/calcGradient_mex.mexa64 -------------------------------------------------------------------------------- /common-tools/Auxiliary_files/calcGradient_mex.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/Auxiliary_files/calcGradient_mex.mexmaci64 -------------------------------------------------------------------------------- /common-tools/Auxiliary_files/calcGradient_mex.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/Auxiliary_files/calcGradient_mex.mexw64 -------------------------------------------------------------------------------- /common-tools/Auxiliary_files/calcInitial_mex.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/Auxiliary_files/calcInitial_mex.mexa64 -------------------------------------------------------------------------------- /common-tools/Auxiliary_files/calcInitial_mex.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/Auxiliary_files/calcInitial_mex.mexmaci64 -------------------------------------------------------------------------------- /common-tools/Auxiliary_files/calcInitial_mex.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/Auxiliary_files/calcInitial_mex.mexw64 -------------------------------------------------------------------------------- /common-tools/Auxiliary_files/calcProjection_mex.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/Auxiliary_files/calcProjection_mex.mexa64 -------------------------------------------------------------------------------- /common-tools/Auxiliary_files/calcProjection_mex.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/Auxiliary_files/calcProjection_mex.mexmaci64 -------------------------------------------------------------------------------- /common-tools/Auxiliary_files/calcProjection_mex.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/Auxiliary_files/calcProjection_mex.mexw64 -------------------------------------------------------------------------------- /common-tools/Auxiliary_files/getValsAtIndex_mex.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/Auxiliary_files/getValsAtIndex_mex.mexa64 -------------------------------------------------------------------------------- /common-tools/Auxiliary_files/getValsAtIndex_mex.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/Auxiliary_files/getValsAtIndex_mex.mexmaci64 -------------------------------------------------------------------------------- /common-tools/Auxiliary_files/getValsAtIndex_mex.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/Auxiliary_files/getValsAtIndex_mex.mexw64 -------------------------------------------------------------------------------- /common-tools/Auxiliary_files/makeOmegaSet.m: -------------------------------------------------------------------------------- 1 | function subs = makeOmegaSet( n, sizeOmega ) 2 | %MAKEOMEGASET Create a sampling set 3 | % SUBS = MAKEOMEGASET( N, SIZEOMEGA ) creates a sampling set of SIZEOMEGA entries chosen uniformly from 4 | % the total amount of PROD( N ) entries. 5 | % 6 | % See also makeRandTensor 7 | % 8 | 9 | % GeomCG Tensor Completion. Copyright 2013 by 10 | % Michael Steinlechner 11 | % Questions and contact: michael.steinlechner@epfl.ch 12 | % BSD 2-clause license, see LICENSE.txt 13 | 14 | if sizeOmega > prod(n) 15 | error('makeOmegaSet:sizeOmegaTooHigh', 'Requested size of Omega is bigger than the tensor itself!') 16 | end 17 | 18 | idx = randi( prod(n), sizeOmega, 1 ); 19 | Omega = unique(idx); 20 | 21 | while length(Omega) < sizeOmega 22 | idx = [ Omega; randi( prod(n) , sizeOmega-length(Omega), 1 )]; 23 | Omega = unique(idx); 24 | end 25 | 26 | Omega = sort( Omega(1:sizeOmega) ); 27 | 28 | [i,j,k] = ind2sub( n, Omega ); 29 | 30 | subs = [i,j,k]; 31 | end 32 | -------------------------------------------------------------------------------- /common-tools/GIST_package/GIST/funRegC.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/GIST_package/GIST/funRegC.mexw64 -------------------------------------------------------------------------------- /common-tools/GIST_package/GIST/proximalRegC.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/GIST_package/GIST/proximalRegC.mexw64 -------------------------------------------------------------------------------- /common-tools/GIST_package/GIST/proximalRegC_warpper.m: -------------------------------------------------------------------------------- 1 | function [ s ] = proximalRegC_warpper( s, lambda, theta, regType ) 2 | 3 | switch(regType) 4 | case 1 % CAP 5 | s = proximalRegC(s, length(s), lambda, theta, 1); 6 | case 2 % Logrithm 7 | s = proximalRegC(s, length(s), lambda, theta, 2); 8 | case 3 % TNN 9 | z = max(s - lambda, 0); 10 | s(theta:end) = z(theta:end); 11 | otherwise 12 | assert(false); 13 | end 14 | 15 | end -------------------------------------------------------------------------------- /common-tools/GIST_package/install.m: -------------------------------------------------------------------------------- 1 | clear 2 | clc 3 | 4 | 5 | currentpath = cd; 6 | 7 | addpath(genpath([currentpath,'/GIST'])); 8 | 9 | cd ./GIST 10 | 11 | mex proximalRegC.cpp 12 | mex funRegC.cpp 13 | 14 | cd .. 15 | 16 | -------------------------------------------------------------------------------- /common-tools/GIST_package/readme.txt: -------------------------------------------------------------------------------- 1 | GIST package version 1.0 (March, 2013) 2 | 3 | Before you run the codes, please first run "install.m" to install the package 4 | 5 | 6 | You are suggested to read the manual (available at the manual folder) before using the functions. 7 | 8 | 9 | The folder "GIST" includes all functions implemented in this package 10 | 11 | The folder "Examples" includes some examples to show how to use this package 12 | 13 | The folder "data" includes a data set used in examples 14 | 15 | The folder "manual" includes a manual on how to use this package. 16 | 17 | 18 | If you use this package, please cite: 19 | 20 | P. Gong, C. Zhang, Z. Lu, J. Huang, and J. Ye. GIST: General Iterative 21 | Shrinkage and Thresholding for Non-convex Sparse Learning. 22 | Tsinghua University, 2013. http://www.public.asu.edu/~jye02/Software/GIST. 23 | 24 | P. Gong, C. Zhang, Z. Lu, J. Huang, and J. Ye. 25 | A General Iterative Shrinkage and Thresholding Algorithm for Non-convex 26 | Regularized Optimization Problems. ICML 2013. 27 | 28 | 29 | If you have any problems, don't hesitate to contact Pinghua Gong via pinghuag@gmail.com -------------------------------------------------------------------------------- /common-tools/PROPACK/Afunc.m: -------------------------------------------------------------------------------- 1 | function y=Afunc(x) 2 | % y=Afunc(x) 3 | % Testfunction returning a linear operator applied to x. 4 | % Used for testing lansvd. 5 | % 6 | % y = A'*x 7 | 8 | % Rasmus Munk Larsen, DAIMI, 1998 9 | 10 | global A MxV 11 | y = A*x; 12 | MxV = MxV + 1; -------------------------------------------------------------------------------- /common-tools/PROPACK/AtAfunc.m: -------------------------------------------------------------------------------- 1 | function y=AtAfunc(x) 2 | % y=AtAfunc(x) 3 | % Testfunction defining a linear operator applied to x. 4 | % Used for testing laneig. 5 | % 6 | % y = A'*(A*x) 7 | 8 | % Rasmus Munk Larsen, DAIMI, 1998 9 | 10 | 11 | global A MxV 12 | y = A'*(A*x); 13 | MxV = MxV + 2; 14 | -------------------------------------------------------------------------------- /common-tools/PROPACK/Atransfunc.m: -------------------------------------------------------------------------------- 1 | function y=Atransfunc(x) 2 | % y=Atransfunc(x) 3 | % Testfunction returning the transpose of a linear operator applied to x. 4 | % Used for testing lansvd. 5 | % 6 | % y = A'*x 7 | 8 | % Rasmus Munk Larsen, DAIMI, 1998 9 | 10 | global A MxV 11 | y = A'*x; 12 | MxV = MxV + 1; 13 | -------------------------------------------------------------------------------- /common-tools/PROPACK/Cfunc.m: -------------------------------------------------------------------------------- 1 | function y = Cfunc(x) 2 | % y=Cfunc(x) 3 | % Testfunction defining a linear operator applied to x. 4 | % Used for testing laneig. 5 | % 6 | % y = [ 0 A ] * x 7 | % [ A' 0 ] 8 | 9 | % Rasmus Munk Larsen, DAIMI, 1998 10 | 11 | 12 | global A MxV 13 | [m n] = size(A); 14 | y = [A*x(m+1:end,:); A'*x(1:m,:)]; 15 | MxV = MxV + 2; -------------------------------------------------------------------------------- /common-tools/PROPACK/bdsqr-csz363.m: -------------------------------------------------------------------------------- 1 | function [sigma,bnd] = bdsqr(alpha,beta) 2 | 3 | % BDSQR: Compute the singular values and bottom element of 4 | % the left singular vectors of a (k+1) x k lower bidiagonal 5 | % matrix with diagonal alpha(1:k) and lower bidiagonal beta(1:k), 6 | % where length(alpha) = length(beta) = k. 7 | % 8 | % [sigma,bnd] = bdsqr(alpha,beta) 9 | % 10 | % Input parameters: 11 | % alpha(1:k) : Diagonal elements. 12 | % beta(1:k) : Sub-diagonal elements. 13 | % Output parameters: 14 | % sigma(1:k) : Computed eigenvalues. 15 | % bnd(1:k) : Bottom elements in left singular vectors. 16 | 17 | % Below is a very slow replacement for the BDSQR MEX-file. 18 | 19 | %warning('PROPACK:NotUsingMex','Using slow matlab code for bdsqr.') 20 | k = length(alpha); 21 | if min(size(alpha)') ~= 1 | min(size(beta)') ~= 1 22 | error('alpha and beta must be vectors') 23 | elseif length(beta) ~= k 24 | error('alpha and beta must have the same lenght') 25 | end 26 | B = spdiags([alpha(:),beta(:)],[0,-1],k+1,k); 27 | [U,S,V] = svd(full(B),0); 28 | sigma = diag(S); 29 | bnd = U(end,1:k)'; 30 | 31 | 32 | -------------------------------------------------------------------------------- /common-tools/PROPACK/bdsqr-csz920.m: -------------------------------------------------------------------------------- 1 | function [sigma,bnd] = bdsqr(alpha,beta) 2 | 3 | % BDSQR: Compute the singular values and bottom element of 4 | % the left singular vectors of a (k+1) x k lower bidiagonal 5 | % matrix with diagonal alpha(1:k) and lower bidiagonal beta(1:k), 6 | % where length(alpha) = length(beta) = k. 7 | % 8 | % [sigma,bnd] = bdsqr(alpha,beta) 9 | % 10 | % Input parameters: 11 | % alpha(1:k) : Diagonal elements. 12 | % beta(1:k) : Sub-diagonal elements. 13 | % Output parameters: 14 | % sigma(1:k) : Computed eigenvalues. 15 | % bnd(1:k) : Bottom elements in left singular vectors. 16 | 17 | % Below is a very slow replacement for the BDSQR MEX-file. 18 | 19 | %warning('PROPACK:NotUsingMex','Using slow matlab code for bdsqr.') 20 | k = length(alpha); 21 | if min(size(alpha)') ~= 1 | min(size(beta)') ~= 1 22 | error('alpha and beta must be vectors') 23 | elseif length(beta) ~= k 24 | error('alpha and beta must have the same lenght') 25 | end 26 | B = spdiags([alpha(:),beta(:)],[0,-1],k+1,k); 27 | [U,S,V] = svd(full(B),0); 28 | sigma = diag(S); 29 | bnd = U(end,1:k)'; 30 | 31 | 32 | -------------------------------------------------------------------------------- /common-tools/PROPACK/bdsqr.m: -------------------------------------------------------------------------------- 1 | function [sigma,bnd] = bdsqr(alpha,beta) 2 | 3 | % BDSQR: Compute the singular values and bottom element of 4 | % the left singular vectors of a (k+1) x k lower bidiagonal 5 | % matrix with diagonal alpha(1:k) and lower bidiagonal beta(1:k), 6 | % where length(alpha) = length(beta) = k. 7 | % 8 | % [sigma,bnd] = bdsqr(alpha,beta) 9 | % 10 | % Input parameters: 11 | % alpha(1:k) : Diagonal elements. 12 | % beta(1:k) : Sub-diagonal elements. 13 | % Output parameters: 14 | % sigma(1:k) : Computed eigenvalues. 15 | % bnd(1:k) : Bottom elements in left singular vectors. 16 | 17 | % Below is a very slow replacement for the BDSQR MEX-file. 18 | 19 | % warning('PROPACK:NotUsingMex','Using slow matlab code for bdsqr.') 20 | k = length(alpha); 21 | if min(size(alpha)') ~= 1 | min(size(beta)') ~= 1 22 | error('alpha and beta must be vectors') 23 | elseif length(beta) ~= k 24 | error('alpha and beta must have the same lenght') 25 | end 26 | B = spdiags([alpha(:),beta(:)],[0,-1],k+1,k); 27 | [U,S,V] = svd(full(B),0); 28 | sigma = diag(S); 29 | bnd = U(end,1:k)'; 30 | 31 | 32 | -------------------------------------------------------------------------------- /common-tools/PROPACK/bdsqr.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/PROPACK/bdsqr.mexglx -------------------------------------------------------------------------------- /common-tools/PROPACK/bdsqr.mexsg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/PROPACK/bdsqr.mexsg -------------------------------------------------------------------------------- /common-tools/PROPACK/bdsqr.mexsg64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/PROPACK/bdsqr.mexsg64 -------------------------------------------------------------------------------- /common-tools/PROPACK/bdsqr.mexsol: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/PROPACK/bdsqr.mexsol -------------------------------------------------------------------------------- /common-tools/PROPACK/bdsqr.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/PROPACK/bdsqr.mexw32 -------------------------------------------------------------------------------- /common-tools/PROPACK/bdsqr_mex.mexw64.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /common-tools/PROPACK/bdsqr_mex.mexw64.map: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/PROPACK/bdsqr_mex.mexw64.map -------------------------------------------------------------------------------- /common-tools/PROPACK/dbdqr.f: -------------------------------------------------------------------------------- 1 | 2 | subroutine dbdqr(n, D, E, c1, c2) 3 | implicit none 4 | integer n 5 | double precision D(*),E(*),c1,c2 6 | 7 | integer i 8 | double precision cs,sn,r 9 | 10 | if (n.lt.2) return 11 | do i=1,n-1 12 | call dlartg(d(i),e(i),cs,sn,r) 13 | d(i) = r 14 | e(i) = sn*d(i+1) 15 | d(i+1) = cs*d(i+1) 16 | enddo 17 | call dlartg(d(n),e(n),cs,sn,r) 18 | d(n) = r 19 | e(n) = 0.0 20 | c1 = sn 21 | c2 = cs 22 | end 23 | 24 | -------------------------------------------------------------------------------- /common-tools/PROPACK/helio.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/PROPACK/helio.mat -------------------------------------------------------------------------------- /common-tools/PROPACK/pythag.m: -------------------------------------------------------------------------------- 1 | function x = pythag(y,z) 2 | %PYTHAG Computes sqrt( y^2 + z^2 ). 3 | % 4 | % x = pythag(y,z) 5 | % 6 | % Returns sqrt(y^2 + z^2) but is careful to scale to avoid overflow. 7 | 8 | % Christian H. Bischof, Argonne National Laboratory, 03/31/89. 9 | 10 | [m n] = size(y); 11 | if m>1 | n>1 12 | y = y(:); z=z(:); 13 | rmax = max(abs([y';z']))'; 14 | id=find(rmax==0); 15 | if length(id)>0 16 | rmax(id) = 1; 17 | x = rmax.*sqrt((y./rmax).^2 + (z./rmax).^2); 18 | x(id)=0; 19 | else 20 | x = rmax.*sqrt((y./rmax).^2 + (z./rmax).^2); 21 | end 22 | x = reshape(x,m,n); 23 | else 24 | rmax = max(abs([y;z])); 25 | if (rmax==0) 26 | x = 0; 27 | else 28 | x = rmax*sqrt((y/rmax)^2 + (z/rmax)^2); 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /common-tools/PROPACK/refinebounds.m: -------------------------------------------------------------------------------- 1 | function [bnd,gap] = refinebounds(D,bnd,tol1) 2 | %REFINEBONDS Refines error bounds for Ritz values based on gap-structure 3 | % 4 | % bnd = refinebounds(lambda,bnd,tol1) 5 | % 6 | % Treat eigenvalues closer than tol1 as a cluster. 7 | 8 | % Rasmus Munk Larsen, DAIMI, 1998 9 | 10 | j = length(D); 11 | 12 | if j<=1 13 | return 14 | end 15 | % Sort eigenvalues to use interlacing theorem correctly 16 | [D,PERM] = sort(D); 17 | bnd = bnd(PERM); 18 | 19 | 20 | % Massage error bounds for very close Ritz values 21 | eps34 = sqrt(eps*sqrt(eps)); 22 | [y,mid] = max(bnd); 23 | for l=[-1,1] 24 | for i=((j+1)-l*(j-1))/2:l:mid-l 25 | if abs(D(i+l)-D(i)) < eps34*abs(D(i)) 26 | if bnd(i)>tol1 & bnd(i+l)>tol1 27 | bnd(i+l) = pythag(bnd(i),bnd(i+l)); 28 | bnd(i) = 0; 29 | end 30 | end 31 | end 32 | end 33 | % Refine error bounds 34 | gap = inf*ones(1,j); 35 | gap(1:j-1) = min([gap(1:j-1);[D(2:j)-bnd(2:j)-D(1:j-1)]']); 36 | gap(2:j) = min([gap(2:j);[D(2:j)-D(1:j-1)-bnd(1:j-1)]']); 37 | gap = gap(:); 38 | I = find(gap>bnd); 39 | bnd(I) = bnd(I).*(bnd(I)./gap(I)); 40 | 41 | bnd(PERM) = bnd; -------------------------------------------------------------------------------- /common-tools/PROPACK/reorth.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/PROPACK/reorth.mexglx -------------------------------------------------------------------------------- /common-tools/PROPACK/reorth.mexsg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/PROPACK/reorth.mexsg -------------------------------------------------------------------------------- /common-tools/PROPACK/reorth.mexsg64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/PROPACK/reorth.mexsg64 -------------------------------------------------------------------------------- /common-tools/PROPACK/reorth.mexsol: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/PROPACK/reorth.mexsol -------------------------------------------------------------------------------- /common-tools/PROPACK/reorth_mex.mexw64.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /common-tools/PROPACK/reorth_mex.mexw64.map: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/PROPACK/reorth_mex.mexw64.map -------------------------------------------------------------------------------- /common-tools/PROPACK/tqlb.m: -------------------------------------------------------------------------------- 1 | function [lambda,top,bot,err] = tqlb(alpha,beta) 2 | 3 | % TQLB: Compute eigenvalues and top and bottom elements of 4 | % eigenvectors of a symmetric tridiagonal matrix T. 5 | % 6 | % [lambda,top,bot,err] = tqlb(alpha,beta) 7 | % 8 | % Input parameters: 9 | % alpha(1:n) : Diagonal elements. 10 | % beta(2:n) : Off-diagonal elements. 11 | % Output parameters: 12 | % lambda(1:n) : Computed eigenvalues. 13 | % top(1:n) : Top elements in eigenvectors. 14 | % bot(1:n) : Bottom elements in eigenvectors. 15 | % err : dummy argument. 16 | 17 | 18 | % Rasmus Munk Larsen, DAIMI, 1998 19 | 20 | 21 | % 22 | % This is a slow Matlab substitute for the 23 | % TQLB MEX-file. 24 | % 25 | 26 | warning('PROPACK:NotUsingMex','Using slow matlab code for tqlb.') 27 | n = length(alpha); 28 | T = spdiags([[beta(2:n);0] alpha(1:n) beta(1:n)],-1:1,n,n); 29 | 30 | [V,lambda] = eig(full(T)); lambda = diag(lambda); 31 | bot = V(end,:)'; 32 | top = V(1,:)'; 33 | err=0; 34 | 35 | 36 | -------------------------------------------------------------------------------- /common-tools/PROPACK/tqlb.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/PROPACK/tqlb.mexglx -------------------------------------------------------------------------------- /common-tools/PROPACK/tqlb.mexsg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/PROPACK/tqlb.mexsg -------------------------------------------------------------------------------- /common-tools/PROPACK/tqlb.mexsg64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/PROPACK/tqlb.mexsg64 -------------------------------------------------------------------------------- /common-tools/PROPACK/tqlb.mexsol: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/PROPACK/tqlb.mexsol -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/Contents.m: -------------------------------------------------------------------------------- 1 | % Poblano Toolbox (Sandia National Labs) 2 | % Version 1.1 30-JAN-2012 3 | % 4 | % Poblano Toolbox for large-scale nonlinear optimization. 5 | % 6 | % cstep - More-Thuente line search step from MINPACK. 7 | % cvsrch - More-Thuente line search from MINPACK. 8 | % example1 - Example function for Poblano Toolbox routines. 9 | % example2 - Matrix factorization. 10 | % example2_extract - Matrix factorization example: extraction. 11 | % example2_init - Matrix factorization example: initialization. 12 | % gradientcheck - Finite difference verification of analytic gradients. 13 | % hessvec_fd - Hessian vector product finite difference approximation. 14 | % install_poblano - Script to install Poblano path. 15 | % lbfgs - Limited-memory BFGS minimization (vector-based). 16 | % ncg - Nonlinear conjugate gradient minimization. 17 | % poblano_linesearch - Line search methods in the Poblano Toolbox. 18 | % poblano_out - Standard output parameters for the Poblano Toolbox. 19 | % poblano_params - Standard input parameters for the Poblano Toolbox. 20 | % tn - Truncated Newton minimization. 21 | -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/INSTALL.txt: -------------------------------------------------------------------------------- 1 | To install the Poblano Toolbox for MATLAB: 2 | 3 | 1. Unpack the compressed file. In a linux environment, for example, this can 4 | be done from the command line via: 5 | 6 | unzip poblano_toolbox_1.1.zip 7 | 8 | *or* 9 | 10 | gunzip -c poblano_toolbox_1.1.tgz | tar xvf - 11 | 12 | This should create a directory named *poblano_toolbox_1.1*. 13 | 14 | 2. Rename the root directory from *poblano_toolbox_1.1* to *poblano_toolbox*. 15 | 16 | 3. Start MATLAB. 17 | 18 | 4. Within MATLAB, cd to the *poblano_toolbox* directory and execute the 19 | following commands: 20 | 21 | addpath(pwd) %<-- Add the Poblano toolbox to the MATLAB path 22 | savepath %<-- Save for future MATLAB sessions 23 | 24 | OR enter the following command: 25 | 26 | install_poblano 27 | -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/RELEASE_NOTES.txt: -------------------------------------------------------------------------------- 1 | Poblano Toolbox version 1.1 2 | by Daniel M. Dunlavy, Tamara G. Kolda, and Evrim Acar. 3 | Copyright 2009-2012, Sandia Corporation. 4 | Released January 30, 2012. 5 | 6 | ============================================ 7 | Changes from Version 1.0 (March 17, 2010.) 8 | ============================================ 9 | New features: 10 | - ExitDescription output parameter: contains text description of 11 | ExitFlag output parameter. 12 | - DisplayIters input parameter: determines how many iterations are 13 | performed before printing output when Display input parameter is 14 | set to 'iter'. Iteration 0 and final iteration are also printed. 15 | New default parameters: 16 | - MaxIters = 1000 (was 100) 17 | - MaxFuncEvals = 10000 (was 100) 18 | Bug fixes: 19 | - Fixed two-loop recursion bug in lbfgs.m (#19). 20 | - Documented initial step for linsearch in poblano_linesearch.m 21 | (#2, #18). 22 | Other changes: 23 | - Updated documentation for input and output parameters. 24 | - Updated URL for Poblano Toolbox. 25 | -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/A1_POBLANO_overview_docs_eq45126.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/A1_POBLANO_overview_docs_eq45126.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/A1_POBLANO_overview_docs_eq52638.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/A1_POBLANO_overview_docs_eq52638.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/A1_POBLANO_overview_docs_eq56797.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/A1_POBLANO_overview_docs_eq56797.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/A1_POBLANO_overview_docs_eq57797.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/A1_POBLANO_overview_docs_eq57797.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/A1_POBLANO_overview_docs_eq92049.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/A1_POBLANO_overview_docs_eq92049.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/A1_POBLANO_overview_docs_eq93418.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/A1_POBLANO_overview_docs_eq93418.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq05153.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq05153.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq06715.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq06715.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq15166.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq15166.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq15843.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq15843.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq18009.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq18009.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq19084.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq19084.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq20021.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq20021.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq21144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq21144.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq21265.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq21265.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq24693.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq24693.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq31302.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq31302.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq31461.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq31461.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq34276.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq34276.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq35707.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq35707.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq37179.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq37179.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq47284.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq47284.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq49857.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq49857.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq72809.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq72809.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq86607.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq86607.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq88356.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/A4_poblano_examples_docs_eq88356.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/B_ncg_docs_eq12896.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/B_ncg_docs_eq12896.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/B_ncg_docs_eq12912.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/B_ncg_docs_eq12912.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/B_ncg_docs_eq21114.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/B_ncg_docs_eq21114.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/B_ncg_docs_eq26687.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/B_ncg_docs_eq26687.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/B_ncg_docs_eq37777.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/B_ncg_docs_eq37777.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/B_ncg_docs_eq38027.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/B_ncg_docs_eq38027.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/B_ncg_docs_eq43170.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/B_ncg_docs_eq43170.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/B_ncg_docs_eq47697.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/B_ncg_docs_eq47697.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/B_ncg_docs_eq48204.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/B_ncg_docs_eq48204.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/B_ncg_docs_eq50028.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/B_ncg_docs_eq50028.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/B_ncg_docs_eq64465.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/B_ncg_docs_eq64465.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/B_ncg_docs_eq69196.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/B_ncg_docs_eq69196.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/B_ncg_docs_eq94234.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/B_ncg_docs_eq94234.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/C_lmbfgs_docs_eq12912.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/C_lmbfgs_docs_eq12912.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/C_lmbfgs_docs_eq26618.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/C_lmbfgs_docs_eq26618.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/C_lmbfgs_docs_eq28128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/C_lmbfgs_docs_eq28128.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/C_lmbfgs_docs_eq37777.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/C_lmbfgs_docs_eq37777.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/C_lmbfgs_docs_eq49162.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/C_lmbfgs_docs_eq49162.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/C_lmbfgs_docs_eq94234.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/C_lmbfgs_docs_eq94234.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/D_tn_docs_eq12912.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/D_tn_docs_eq12912.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/D_tn_docs_eq14236.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/D_tn_docs_eq14236.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/D_tn_docs_eq17182.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/D_tn_docs_eq17182.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/D_tn_docs_eq24873.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/D_tn_docs_eq24873.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/D_tn_docs_eq37600.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/D_tn_docs_eq37600.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/D_tn_docs_eq37777.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/D_tn_docs_eq37777.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/D_tn_docs_eq77996.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/D_tn_docs_eq77996.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/D_tn_docs_eq81624.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/D_tn_docs_eq81624.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/D_tn_docs_eq89032.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/D_tn_docs_eq89032.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/D_tn_docs_eq94234.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/D_tn_docs_eq94234.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/D_tn_docs_eq95956.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/D_tn_docs_eq95956.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/E_gradientcheck_docs_eq28128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/E_gradientcheck_docs_eq28128.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/E_gradientcheck_docs_eq43551.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/E_gradientcheck_docs_eq43551.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/E_gradientcheck_docs_eq57210.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/E_gradientcheck_docs_eq57210.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/E_gradientcheck_docs_eq60012.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/E_gradientcheck_docs_eq60012.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/E_gradientcheck_docs_eq73316.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/E_gradientcheck_docs_eq73316.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/E_gradientcheck_docs_eq81966.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/E_gradientcheck_docs_eq81966.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/E_gradientcheck_docs_eq94104.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/E_gradientcheck_docs_eq94104.png -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/images/banner-background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/images/banner-background.jpg -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/doc/images/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/poblano_toolbox_1.1/doc/images/logo.gif -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/example1.m: -------------------------------------------------------------------------------- 1 | function [f,g]=example1(x,a) 2 | %EXAMPLE1 Example function for Poblano Toolbox routines. 3 | % 4 | % [F,G] = EXAMPLE1(X) computes F = sin(X(N)) + ... sin(X(N)) and G, the 5 | % gradient of F at X, where N is the number of variables in X. 6 | % 7 | % [F,G] = EXAMPLE1(X,A) computes F = sin(A*X(1)) + ... + sin(A*X(N)) and G, 8 | % the gradient of F at X. 9 | % 10 | %MATLAB Poblano Toolbox. 11 | %Copyright 2009-2012, Sandia Corporation. 12 | 13 | if (nargin < 2), a = 1; end 14 | f = sum(sin(a*x)); 15 | g = a*cos(a*x); 16 | 17 | -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/example2_extract.m: -------------------------------------------------------------------------------- 1 | function [U,V] = example2_extract(m,n,k,x) 2 | %EXAMPLE2_EXTRACT Matrix factorization example: extraction. 3 | % 4 | % Helper function to extract factors of an approximate 5 | % (rank-reduced) two-factor decomposition of a matrix: 6 | % 7 | % A \approx U*V' 8 | % 9 | % Input 10 | % m: number of rows of U to be approximated 11 | % n: number of rows of V to be approximated 12 | % k: rank of approximation factors 13 | % x: vector of variables in two-factor approximation 14 | % 15 | % Output 16 | % U: first factor 17 | % V: second factor 18 | % 19 | % Matrix dimensions 20 | % A is m x n 21 | % U is m x k 22 | % V is n x k 23 | % 24 | % Example 25 | % m = 3; n = 2; k = 2; 26 | % [x,Data] = example2_init(m,n,k); 27 | % [U,V] = example_extract(m,n,k,x) 28 | % norm(Data.A-U*V') 29 | % 30 | %MATLAB Poblano Toolbox. 31 | %Copyright 2009-2012, Sandia Corporation. 32 | 33 | %% Perform check on sizes of inputs 34 | [x_m, x_n] = size(x); 35 | if ( (x_n ~= 1) || (x_m ~= (m+n)*k) ) 36 | error('Dimensions do not agree!'); 37 | end 38 | 39 | %% Extract approximation factors from x 40 | U = reshape(x(1:m*k),m,k); 41 | V = reshape(x(m*k+1:m*k+n*k),n,k); 42 | -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/info.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | R2008a 7 | Poblano 8 | toolbox 9 | $toolbox/matlab/icons/unknownicon.gif 10 | doc 11 | 12 | 13 | 14 | 15 | doc poblano_toolbox/ 16 | $toolbox/matlab/icons/webicon.gif 17 | 18 | 19 | 20 | web http://software.sandia.gov/poblano 21 | $toolbox/matlab/icons/webicon.gif 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/install_poblano.m: -------------------------------------------------------------------------------- 1 | %INSTALL_POBLANO Script to install Poblano path. 2 | % 3 | %MATLAB Poblano Toolbox. 4 | %Copyright 2009-2012, Sandia Corporation. 5 | 6 | addpath(pwd) 7 | savepath 8 | 9 | 10 | -------------------------------------------------------------------------------- /common-tools/poblano_toolbox_1.1/setup.m: -------------------------------------------------------------------------------- 1 | clear;clc; 2 | 3 | addpath('Test'); 4 | addpath('F:\WebDisk\Dropbox\experiments\noncvx-lowrank(ICDM 2015)\data\recsys'); 5 | addpath('F:\WebDisk\Dropbox\experiments\AIS-Impute(IJCAI 2015)\tools'); -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ktensor/disp.m: -------------------------------------------------------------------------------- 1 | function disp(t, name) 2 | %DISP Command window display for a ktensor. 3 | % 4 | % DISP(T) displays a Kruskal tensor with no name. 5 | % 6 | % DISP(T,NAME) display a Kruskal tensor with the given name. 7 | % 8 | % See also DISP, KTENSOR/DISPLAY, KTENSOR 9 | % 10 | %MATLAB Tensor Toolbox. 11 | %Copyright 2015, Sandia Corporation. 12 | 13 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 14 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 15 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 16 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 17 | % work by or on behalf of the U.S. Government. Export of this data may 18 | % require a license from the United States Government. 19 | % The full license terms can be found in the file LICENSE.txt 20 | 21 | 22 | if ~exist('name','var') 23 | name = 'ans'; 24 | end 25 | 26 | fprintf('%s is a ktensor of size %s\n', name, tt_size2str(size(t))); 27 | fprintf('\t%s.lambda = %s\n',name, ['[ ' num2str(t.lambda') ' ]'] ); 28 | 29 | if (ndims(t) > 0) 30 | for j = 1 : ndims(t) 31 | fprintf('\t%s.U{%d} = \n', name, j); 32 | output = tt_matrix2cellstr(t.u{j}); 33 | fprintf('\t\t%s\n',output{:}); 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ktensor/display.m: -------------------------------------------------------------------------------- 1 | function display(t) 2 | %DISPLAY Command window display for a ktensor. 3 | % 4 | % DISPLAY(T) displays a Kruskal tensor with its name. 5 | % 6 | % See also DISPLAY, KTENSOR/DISP, KTENSOR. 7 | % 8 | %MATLAB Tensor Toolbox. 9 | %Copyright 2015, Sandia Corporation. 10 | 11 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 12 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 13 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 14 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 15 | % work by or on behalf of the U.S. Government. Export of this data may 16 | % require a license from the United States Government. 17 | % The full license terms can be found in the file LICENSE.txt 18 | 19 | 20 | disp(t,inputname(1)); 21 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ktensor/double.m: -------------------------------------------------------------------------------- 1 | function A = double(X) 2 | %DOUBLE Convert a ktensor to a double array. 3 | % 4 | % A = double(X) converts X to a standard multidimensional array. 5 | % 6 | % See also KTENSOR, KTENSOR/FULL. 7 | % 8 | %MATLAB Tensor Toolbox. 9 | %Copyright 2015, Sandia Corporation. 10 | 11 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 12 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 13 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 14 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 15 | % work by or on behalf of the U.S. Government. Export of this data may 16 | % require a license from the United States Government. 17 | % The full license terms can be found in the file LICENSE.txt 18 | 19 | 20 | if isempty(X.lambda) % check for empty tensor 21 | A = []; 22 | return; 23 | end 24 | 25 | sz = [size(X) 1]; 26 | A = X.lambda' * khatrirao(X.u,'r')'; 27 | A = reshape(A,sz); 28 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ktensor/end.m: -------------------------------------------------------------------------------- 1 | function e = end(X,k,n) 2 | %END Last index of indexing expression for ktensor. 3 | % 4 | % The expression X(end,:,:) will call END(X,1,3) to determine 5 | % the value of the first index. 6 | % 7 | % See also KTENSOR, KTENSOR/SUBSREF, END. 8 | % 9 | %MATLAB Tensor Toolbox. 10 | %Copyright 2015, Sandia Corporation. 11 | 12 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 13 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 14 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 15 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 16 | % work by or on behalf of the U.S. Government. Export of this data may 17 | % require a license from the United States Government. 18 | % The full license terms can be found in the file LICENSE.txt 19 | 20 | 21 | %TODO (after 2.0 release): Resolve ambiguity w.r.t X{end}and X(end,1,1) 22 | %for 1st-order tensors. 23 | 24 | if n > ndims(X) 25 | error('Subscript out of range.'); 26 | end 27 | 28 | if (n ~= 1) 29 | e = size(X,k); 30 | else 31 | e = ndims(X); 32 | end 33 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ktensor/extract.m: -------------------------------------------------------------------------------- 1 | function new_X = extract(X,idx) 2 | %EXTRACT Creates a new ktensor with only the specified components. 3 | % 4 | % Y = EXTRACT(X,S) selected the subset of components in X as defined by 5 | % S. It should be the case that S is a subset of [1,...,NCOMPONENTS(X)]. 6 | % 7 | % See also KTENSOR, NCOMPONENTS. 8 | % 9 | %MATLAB Tensor Toolbox. 10 | %Copyright 2015, Sandia Corporation. 11 | 12 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 13 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 14 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 15 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 16 | % work by or on behalf of the U.S. Government. Export of this data may 17 | % require a license from the United States Government. 18 | % The full license terms can be found in the file LICENSE.txt 19 | 20 | 21 | %% Set-up 22 | N = ndims(X); 23 | %% Extract 24 | new_lambda = X.lambda(idx); 25 | new_U = cell(N,1); 26 | for i = 1 : N 27 | new_U{i} = X.u{i}(:,idx); 28 | end 29 | new_X = ktensor(new_lambda, new_U); 30 | 31 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ktensor/full.m: -------------------------------------------------------------------------------- 1 | function t = full(t) 2 | %FULL Convert a ktensor to a (dense) tensor. 3 | % 4 | % T = FULL(C) converts a ktensor to a (dense) tensor. 5 | % 6 | % Examples 7 | % X = ktensor([3; 2], rand(4,2), rand(5,2), rand(3,2)); 8 | % Y = full(A) %<-- equivalent dense tensor 9 | % 10 | % See also KTENSOR, TENSOR, KTENSOR/DOUBLE. 11 | % 12 | %MATLAB Tensor Toolbox. 13 | %Copyright 2015, Sandia Corporation. 14 | 15 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 16 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 17 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 18 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 19 | % work by or on behalf of the U.S. Government. Export of this data may 20 | % require a license from the United States Government. 21 | % The full license terms can be found in the file LICENSE.txt 22 | 23 | 24 | sz = size(t); 25 | data = t.lambda' * khatrirao(t.u,'r')'; 26 | t = tensor(data,sz); 27 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ktensor/mtimes.m: -------------------------------------------------------------------------------- 1 | function C = mtimes(A,B) 2 | %MTIMES Implement A*B (scalar multiply) for ktensor. 3 | % 4 | % C = mtimes(A,B) computes A * B where A is a Kruskal tensor and B is 5 | % a scalar (or vice versa). The result C is the same size as A. 6 | % 7 | % See also KTENSOR. 8 | % 9 | %MATLAB Tensor Toolbox. 10 | %Copyright 2015, Sandia Corporation. 11 | 12 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 13 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 14 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 15 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 16 | % work by or on behalf of the U.S. Government. Export of this data may 17 | % require a license from the United States Government. 18 | % The full license terms can be found in the file LICENSE.txt 19 | 20 | 21 | % Note: We can do scalar times a tensor, but anything more complex is 22 | % an error. 23 | 24 | if isa(B,'numeric') && isequal(size(B),[1 1]) 25 | C = ktensor(B * A.lambda, A.u); 26 | elseif isa(A,'numeric') && isequal(size(A),[1 1]) 27 | C = ktensor(A * B.lambda, B.u); 28 | else 29 | error('Use mtimes(full(A),full(B)).'); 30 | end 31 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ktensor/ncomponents.m: -------------------------------------------------------------------------------- 1 | function n = ncomponents(t) 2 | %NCOMPONENTS Number of components for a ktensor. 3 | % 4 | % NCOMPONENTS(T) returns the number of compontents in the ktensor T. 5 | % 6 | % See also KTENSOR 7 | % 8 | %MATLAB Tensor Toolbox. 9 | %Copyright 2015, Sandia Corporation. 10 | 11 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 12 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 13 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 14 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 15 | % work by or on behalf of the U.S. Government. Export of this data may 16 | % require a license from the United States Government. 17 | % The full license terms can be found in the file LICENSE.txt 18 | 19 | 20 | n = length(t.lambda); 21 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ktensor/ndims.m: -------------------------------------------------------------------------------- 1 | function n = ndims(t) 2 | %NDIMS Number of dimensions for a ktensor. 3 | % 4 | % NDIMS(T) returns the number of dimensions of tensor T. 5 | % 6 | % See also KTENSOR 7 | % 8 | %MATLAB Tensor Toolbox. 9 | %Copyright 2015, Sandia Corporation. 10 | 11 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 12 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 13 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 14 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 15 | % work by or on behalf of the U.S. Government. Export of this data may 16 | % require a license from the United States Government. 17 | % The full license terms can be found in the file LICENSE.txt 18 | 19 | 20 | n = numel(t.u); 21 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ktensor/norm.m: -------------------------------------------------------------------------------- 1 | function nrm = norm(A) 2 | %NORM Frobenius norm of a ktensor. 3 | % 4 | % NORM(T) returns the Frobenius norm of a ktensor. 5 | % 6 | % See also KTENSOR. 7 | % 8 | %MATLAB Tensor Toolbox. 9 | %Copyright 2015, Sandia Corporation. 10 | 11 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 12 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 13 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 14 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 15 | % work by or on behalf of the U.S. Government. Export of this data may 16 | % require a license from the United States Government. 17 | % The full license terms can be found in the file LICENSE.txt 18 | 19 | 20 | % Retrieve the factors of A 21 | U = A.u; 22 | 23 | % Compute the matrix of correlation coefficients 24 | coefMatrix = A.lambda * A.lambda'; 25 | for i = 1:ndims(A) 26 | coefMatrix = coefMatrix .* (U{i}'*U{i}); 27 | end 28 | 29 | nrm = sqrt(abs(sum(coefMatrix(:)))); 30 | 31 | return; 32 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ktensor/permute.m: -------------------------------------------------------------------------------- 1 | function b = permute(a,order) 2 | %PERMUTE Permute dimensions of a ktensor. 3 | % 4 | % B = PERMUTE(A,ORDER) rearranges the dimensions of A so that they 5 | % are in the order specified by the vector ORDER. The tensor 6 | % produced has the same values of A but the order of the subscripts 7 | % needed to access any particular element are rearranged as 8 | % specified by ORDER. 9 | % 10 | % See also KTENSOR. 11 | % 12 | %MATLAB Tensor Toolbox. 13 | %Copyright 2015, Sandia Corporation. 14 | 15 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 16 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 17 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 18 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 19 | % work by or on behalf of the U.S. Government. Export of this data may 20 | % require a license from the United States Government. 21 | % The full license terms can be found in the file LICENSE.txt 22 | 23 | 24 | N = ndims(a); 25 | 26 | if ~isequal(1:N,sort(order)) 27 | error('Invalid permuation'); 28 | end 29 | 30 | b = ktensor(a.lambda, a.u(order)); 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ktensor/plus.m: -------------------------------------------------------------------------------- 1 | function C = plus(A,B) 2 | %PLUS Binary addition for ktensor. 3 | % 4 | % C = PLUS(A,B) adds two ktensors of the same size, and the 5 | % result is a ktensor of the same size. 6 | % 7 | % See also KTENSOR. 8 | % 9 | %MATLAB Tensor Toolbox. 10 | %Copyright 2015, Sandia Corporation. 11 | 12 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 13 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 14 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 15 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 16 | % work by or on behalf of the U.S. Government. Export of this data may 17 | % require a license from the United States Government. 18 | % The full license terms can be found in the file LICENSE.txt 19 | 20 | 21 | if (isa(A,'ktensor') && isa(B,'ktensor')) 22 | 23 | if ~isequal(size(A),size(B)) 24 | error('Tensor size mismatch.') 25 | end 26 | 27 | lambda = [A.lambda; B.lambda]; 28 | M = ndims(A); 29 | u = cell(M,1); 30 | for m = 1 : M 31 | u{m} = [A.u{m} B.u{m}]; 32 | end 33 | C = ktensor(lambda, u); 34 | return; 35 | end 36 | 37 | error('Use plus(full(A),full(B)).'); 38 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ktensor/redistribute.m: -------------------------------------------------------------------------------- 1 | function X = redistribute(X,mode) 2 | %REDISTRIBUTE Distribute lambda values to a specified mode. 3 | % 4 | % K = REDISTRIBUTE(K,N) absorbs the weights from the lambda vector 5 | % into mode N. Set the lambda vector to all ones. 6 | % 7 | % See also KTENSOR, NORMALIZE. 8 | % 9 | %MATLAB Tensor Toolbox. 10 | %Copyright 2015, Sandia Corporation. 11 | 12 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 13 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 14 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 15 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 16 | % work by or on behalf of the U.S. Government. Export of this data may 17 | % require a license from the United States Government. 18 | % The full license terms can be found in the file LICENSE.txt 19 | 20 | for r = 1:length(X.lambda) 21 | X.u{mode}(:,r) = X.u{mode}(:,r) * X.lambda(r); 22 | X.lambda(r) = 1; 23 | end 24 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ktensor/size.m: -------------------------------------------------------------------------------- 1 | function m = size(t,idx) 2 | %SIZE Size of ktensor. 3 | % 4 | % D = SIZE(T) returns the size of the tensor. 5 | % 6 | % I = SIZE(T,DIM) returns the size of the dimension specified by 7 | % the scalar DIM. 8 | % 9 | % See also KTENSOR, KTENSOR/NDIMS. 10 | % 11 | %MATLAB Tensor Toolbox. 12 | %Copyright 2015, Sandia Corporation. 13 | 14 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 15 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 16 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 17 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 18 | % work by or on behalf of the U.S. Government. Export of this data may 19 | % require a license from the United States Government. 20 | % The full license terms can be found in the file LICENSE.txt 21 | 22 | 23 | if isempty(t.lambda) 24 | m = []; 25 | end 26 | 27 | if exist('idx','var') 28 | m = size(t.u{idx}, 1); 29 | else 30 | for i = 1 : ndims(t) 31 | m(i) = size(t.u{i}, 1); 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ktensor/times.m: -------------------------------------------------------------------------------- 1 | function C = times(A,B) 2 | %TIMES Element-wise multiplication for ktensor. 3 | % 4 | % TIMES(A,B) denotes element-by-element multiplication. 5 | % 6 | % C = TIMES(A,B) is called for the syntax 'A .* B' when A or B is a 7 | % tensor. 8 | % 9 | % See also KTENSOR, SPTENSOR/TIMES. 10 | % 11 | %MATLAB Tensor Toolbox. 12 | %Copyright 2015, Sandia Corporation. 13 | 14 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 15 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 16 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 17 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 18 | % work by or on behalf of the U.S. Government. Export of this data may 19 | % require a license from the United States Government. 20 | % The full license terms can be found in the file LICENSE.txt 21 | 22 | 23 | if ~isequal(size(A),size(B)) 24 | error('Must be two tensors of the same size'); 25 | end 26 | 27 | switch class(B) 28 | case {'sptensor','tensor'} 29 | % Call back to sptensor version. 30 | C = times(B,A); 31 | return; 32 | otherwise 33 | error('Invalid second argument for ktensor/times'); 34 | end 35 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ktensor/tocell.m: -------------------------------------------------------------------------------- 1 | function U = tocell(X,N) 2 | %TOCELL Convert X to a cell array. 3 | % 4 | % TOCELL(X) converts X to a cell array, evenly distributing the 5 | % weight in lambda. 6 | % 7 | % TOCELL(X,N) absorbs the weights into the Nth factor matrix. 8 | % 9 | % See also KTENSOR, NORMALIZE. 10 | % 11 | %MATLAB Tensor Toolbox. 12 | %Copyright 2015, Sandia Corporation. 13 | 14 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 15 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 16 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 17 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 18 | % work by or on behalf of the U.S. Government. Export of this data may 19 | % require a license from the United States Government. 20 | % The full license terms can be found in the file LICENSE.txt 21 | 22 | 23 | if exist('N','var') 24 | X = normalize(X,N); 25 | U = X.u; 26 | return; 27 | end 28 | 29 | if isequal(X.lambda,ones(size(X.lambda))) 30 | U = X.u; 31 | return; 32 | end 33 | 34 | 35 | lsplit = nthroot(X.lambda,ndims(X)); 36 | R = length(X.lambda); 37 | U = X.u; 38 | D = diag(lsplit); 39 | for n = 1:ndims(X) 40 | U{n} = U{n} * D; 41 | end 42 | 43 | 44 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ktensor/uminus.m: -------------------------------------------------------------------------------- 1 | function t = uminus(t) 2 | %UMINUS Unary minus for ktensor. 3 | % 4 | % See also KTENSOR. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | t.lambda = -t.lambda; 19 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ktensor/uplus.m: -------------------------------------------------------------------------------- 1 | function t = uplus(t) 2 | %UPLUS Unary plus for a ktensor. 3 | % 4 | % See also KTENSOR. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | % This function does nothing! 19 | 20 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptenmat/aatx.m: -------------------------------------------------------------------------------- 1 | function z = aatx(a,x) 2 | %AATX Implicitly compute A * A' * x for sptenmat. 3 | % 4 | % Z = AATX(A,X) takes a sptenmat object A and computes A * A' * 5 | % X. This is done without converting A to a standard MATLAB sparse 6 | % matrix. 7 | % 8 | % This function is likely most useful as an argument to a routine 9 | % such as EIGS. 10 | % 11 | % See also SPTENMAT, SPTENSOR/EIGS. 12 | % 13 | %MATLAB Tensor Toolbox. 14 | %Copyright 2015, Sandia Corporation. 15 | 16 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 17 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 18 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 19 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 20 | % work by or on behalf of the U.S. Government. Export of this data may 21 | % require a license from the United States Government. 22 | % The full license terms can be found in the file LICENSE.txt 23 | 24 | 25 | subs = a.subs; 26 | s1 = subs(:,1); 27 | s2 = subs(:,2); 28 | m = size(a,1); 29 | n = size(a,2); 30 | vals = a.vals; 31 | 32 | v1 = x(s1); 33 | v1 = vals .* v1; 34 | y = accumarray(s2, v1, [n 1]); 35 | 36 | v2 = y(s2); 37 | v2 = vals .* v2; 38 | z = accumarray(s1, v2, [m 1]); 39 | 40 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptenmat/display.m: -------------------------------------------------------------------------------- 1 | function display(t) 2 | %DISPLAY Command window display of a sptenmat. 3 | % 4 | % DISPLAY(T) displays the tensor with its name. 5 | % 6 | % See also SPTENMAT/DISP. 7 | % 8 | %MATLAB Tensor Toolbox. 9 | %Copyright 2015, Sandia Corporation. 10 | 11 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 12 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 13 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 14 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 15 | % work by or on behalf of the U.S. Government. Export of this data may 16 | % require a license from the United States Government. 17 | % The full license terms can be found in the file LICENSE.txt 18 | 19 | 20 | disp(t,inputname(1)); 21 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptenmat/double.m: -------------------------------------------------------------------------------- 1 | function A = double(T) 2 | %DOUBLE Convert a sptenmat to a sparse matrix. 3 | % 4 | % A = double(T) converts T stored as a SPTENMAT to a sparse matrix. 5 | % 6 | % See also SPTENMAT. 7 | % 8 | %MATLAB Tensor Toolbox. 9 | %Copyright 2015, Sandia Corporation. 10 | 11 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 12 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 13 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 14 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 15 | % work by or on behalf of the U.S. Government. Export of this data may 16 | % require a license from the United States Government. 17 | % The full license terms can be found in the file LICENSE.txt 18 | 19 | 20 | m = prod(T.tsize(T.rdims)); 21 | n = prod(T.tsize(T.cdims)); 22 | if isempty(T.subs) 23 | A = sparse(m,n); 24 | else 25 | A = sparse(T.subs(:,1), T.subs(:,2), T.vals, m, n); 26 | end 27 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptenmat/end.m: -------------------------------------------------------------------------------- 1 | function e = end(X,k,n) 2 | %END Last index of indexing expression for sptenmat. 3 | % 4 | % The expression X(end,:) will call END(X,1,2) to determine 5 | % the value of the first index. 6 | % 7 | % See also SPTENMAT, SPTENMAT/SUBSREF, END. 8 | % 9 | %MATLAB Tensor Toolbox. 10 | %Copyright 2015, Sandia Corporation. 11 | 12 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 13 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 14 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 15 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 16 | % work by or on behalf of the U.S. Government. Export of this data may 17 | % require a license from the United States Government. 18 | % The full license terms can be found in the file LICENSE.txt 19 | 20 | 21 | if n > 2 22 | error('Subscript out of range.'); 23 | end 24 | e = size(X,k); 25 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptenmat/full.m: -------------------------------------------------------------------------------- 1 | function B = full(A) 2 | %FULL Convert a sptenmat to a (dense) tenmat. 3 | % 4 | % B = FULL(A) converts a sptenmat A to a (dense) tenmat B. 5 | % 6 | % See also SPTENMAT, TENMAT. 7 | % 8 | %MATLAB Tensor Toolbox. 9 | %Copyright 2015, Sandia Corporation. 10 | 11 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 12 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 13 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 14 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 15 | % work by or on behalf of the U.S. Government. Export of this data may 16 | % require a license from the United States Government. 17 | % The full license terms can be found in the file LICENSE.txt 18 | 19 | 20 | % Extract the order and size of A 21 | siz = size(A); 22 | 23 | % Create a dense zero tensor B that is the same size as A 24 | B = tenmat(zeros([siz,1,1]), A.rdims, A.cdims, A.tsize); 25 | 26 | % Extract the linear indices of entries in A 27 | idx = tt_sub2ind(siz,A.subs); 28 | 29 | % Copy the values of A into B using linear indices 30 | B(idx) = A.vals; 31 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptenmat/nnz.m: -------------------------------------------------------------------------------- 1 | function n = nnz(a) 2 | %NNZ Return number of nonzeros in a sptenmat. 3 | % 4 | % nnz(A) returns the number of nonzeros in A. 5 | % 6 | % See also SPTENMAT. 7 | % 8 | %MATLAB Tensor Toolbox. 9 | %Copyright 2015, Sandia Corporation. 10 | 11 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 12 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 13 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 14 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 15 | % work by or on behalf of the U.S. Government. Export of this data may 16 | % require a license from the United States Government. 17 | % The full license terms can be found in the file LICENSE.txt 18 | 19 | 20 | n = length(a.vals); 21 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptenmat/norm.m: -------------------------------------------------------------------------------- 1 | function nrm = norm(T) 2 | %NORM Frobenius norm of a sptenmat. 3 | % 4 | % NORM(T) returns the Frobenius norm of a matricized sparse tensor. 5 | % 6 | % See also SPTENMAT, NORM. 7 | % 8 | %MATLAB Tensor Toolbox. 9 | %Copyright 2015, Sandia Corporation. 10 | 11 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 12 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 13 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 14 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 15 | % work by or on behalf of the U.S. Government. Export of this data may 16 | % require a license from the United States Government. 17 | % The full license terms can be found in the file LICENSE.txt 18 | 19 | 20 | nrm = norm(T.vals); 21 | 22 | return; 23 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptenmat/size.m: -------------------------------------------------------------------------------- 1 | function siz = size(a,idx) 2 | %SIZE Return size of sptenmat. 3 | % 4 | % D = SIZE(T) returns the size of the tensor. 5 | % 6 | % I = size(T,DIM) returns the sizes of the dimensions specified by DIM. 7 | % 8 | % See also SPTENMAT. 9 | % 10 | %MATLAB Tensor Toolbox. 11 | %Copyright 2015, Sandia Corporation. 12 | 13 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 14 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 15 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 16 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 17 | % work by or on behalf of the U.S. Government. Export of this data may 18 | % require a license from the United States Government. 19 | % The full license terms can be found in the file LICENSE.txt 20 | 21 | 22 | if isempty(a.tsize) 23 | siz = []; 24 | return; 25 | end 26 | 27 | m = prod(a.tsize(a.rdims)); 28 | n = prod(a.tsize(a.cdims)); 29 | siz = [m n]; 30 | 31 | if exist('idx','var') 32 | siz = siz(idx); 33 | end 34 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptenmat/tsize.m: -------------------------------------------------------------------------------- 1 | function sz = tsize(a,idx) 2 | %TSIZE Tensor size of sptenmat. 3 | % 4 | % D = TSIZE(X) returns the size of the tensor being stored as a 5 | % matrix. 6 | % 7 | % M = TSIZE(X,DIM) returns the length of the dimension(s) specified 8 | % by DIM. For example, SIZE(X,1) returns the size of the first 9 | % dimension of the tensor. 10 | % 11 | % See also SPTENMAT, SPTENMAT/SIZE. 12 | % 13 | %MATLAB Tensor Toolbox. 14 | %Copyright 2015, Sandia Corporation. 15 | 16 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 17 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 18 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 19 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 20 | % work by or on behalf of the U.S. Government. Export of this data may 21 | % require a license from the United States Government. 22 | % The full license terms can be found in the file LICENSE.txt 23 | 24 | 25 | if isempty(a.tsize) 26 | sz = []; 27 | return; 28 | end 29 | 30 | if exist('idx', 'var') 31 | sz = a.tsize(idx); 32 | else 33 | sz = a.tsize; 34 | end 35 | 36 | return; 37 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptenmat/uminus.m: -------------------------------------------------------------------------------- 1 | function t = uminus(t) 2 | %UMINUS Unary minus (-) for sptenmat. 3 | % 4 | % See also SPTENMAT. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | t.vals = -t.vals; 19 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptenmat/uplus.m: -------------------------------------------------------------------------------- 1 | function t = uplus(t) 2 | %UPLUS Unary plus (+) for sptenmat. 3 | % 4 | % See also TENSOR. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | % This function does nothing! 19 | 20 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptensor/ctranspose.m: -------------------------------------------------------------------------------- 1 | function ctranspose(x) 2 | %CTRANSPOSE is not defined for sparse tensors. 3 | % 4 | % See also SPTENSOR/PERMUTE. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | error('Transpose on sparse tensor is not defined'); 19 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptensor/display.m: -------------------------------------------------------------------------------- 1 | function display(t) 2 | %DISPLAY Command window display of a sparse tensor. 3 | % 4 | % DISPLAY(T) displays the tensor with its name. 5 | % 6 | % See also SPTENSOR, SPTENSOR/DISP. 7 | % 8 | %MATLAB Tensor Toolbox. 9 | %Copyright 2015, Sandia Corporation. 10 | 11 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 12 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 13 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 14 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 15 | % work by or on behalf of the U.S. Government. Export of this data may 16 | % require a license from the United States Government. 17 | % The full license terms can be found in the file LICENSE.txt 18 | 19 | 20 | disp(t,inputname(1)); 21 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptensor/double.m: -------------------------------------------------------------------------------- 1 | function a = double(s) 2 | %DOUBLE Converts a sparse tensor to a dense multidimensional array. 3 | % 4 | % See also SPTENSOR, SPTENSOR/FULL. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | a = zeros([size(s) 1 1]); 19 | if nnz(s) > 0 20 | a(tt_sub2ind(size(s),s.subs)) = s.vals; 21 | end 22 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptensor/end.m: -------------------------------------------------------------------------------- 1 | function e = end(X,k,n) 2 | %END Last index of indexing expression for sparse tensor. 3 | % 4 | % The expression X(end,:,:) will call END(X,1,3) to determine 5 | % the value of the first index. 6 | % 7 | % See also SPTENSOR, SPTENSOR/SUBSREF, END. 8 | % 9 | %MATLAB Tensor Toolbox. 10 | %Copyright 2015, Sandia Corporation. 11 | 12 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 13 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 14 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 15 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 16 | % work by or on behalf of the U.S. Government. Export of this data may 17 | % require a license from the United States Government. 18 | % The full license terms can be found in the file LICENSE.txt 19 | 20 | 21 | if n > ndims(X) 22 | error('Subscript out of range.'); 23 | end 24 | e = X.size(k); 25 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptensor/find.m: -------------------------------------------------------------------------------- 1 | function [subs,vals] = find(t) 2 | %FIND Find subscripts of nonzero elements in a sparse tensor. 3 | % 4 | % [SUBS,VALS] = FIND(T) returns the subscripts and corresponding 5 | % values of the nonzero elements of T. 6 | % 7 | % Note that unlike the standard MATLAB find function for an array, 8 | % find does not return linear indices. Instead, it returns an M x N 9 | % array where M is the number of nonzero values and N = ndims(T). 10 | % Thus, I(k,:) specifies the subscript of value V(k). 11 | % 12 | % See also SPTENSOR, FIND. 13 | % 14 | %MATLAB Tensor Toolbox. 15 | %Copyright 2015, Sandia Corporation. 16 | 17 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 18 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 19 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 20 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 21 | % work by or on behalf of the U.S. Government. Export of this data may 22 | % require a license from the United States Government. 23 | % The full license terms can be found in the file LICENSE.txt 24 | 25 | 26 | subs = t.subs; 27 | vals = t.vals; 28 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptensor/full.m: -------------------------------------------------------------------------------- 1 | function B = full(A) 2 | %FULL Convert a sparse tensor to a (dense) tensor. 3 | % 4 | % B = FULL(A) converts a sptensor A to a (dense) tensor B. 5 | % 6 | % See also SPTENSOR, TENSOR. 7 | % 8 | %MATLAB Tensor Toolbox. 9 | %Copyright 2015, Sandia Corporation. 10 | 11 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 12 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 13 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 14 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 15 | % work by or on behalf of the U.S. Government. Export of this data may 16 | % require a license from the United States Government. 17 | % The full license terms can be found in the file LICENSE.txt 18 | 19 | 20 | % Extract the order and size of A 21 | siz = size(A); 22 | 23 | % Create a dense zero tensor B that is the same size as A 24 | B = tensor(zeros([siz,1,1]),siz); 25 | 26 | if isempty(A.subs) 27 | return; 28 | end 29 | 30 | % Extract the linear indices of entries in A 31 | idx = tt_sub2ind(siz,A.subs); 32 | 33 | % Copy the values of A into B using linear indices 34 | B(idx) = A.vals; 35 | 36 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptensor/isequal.m: -------------------------------------------------------------------------------- 1 | function z = isequal(x,y) 2 | %ISEQUAL for sptensors. 3 | % 4 | % ISEQUAL(A,B) compares the sparse tensors A and B for equality. 5 | % 6 | % See also SPTENSOR. 7 | % 8 | %MATLAB Tensor Toolbox. 9 | %Copyright 2015, Sandia Corporation. 10 | 11 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 12 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 13 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 14 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 15 | % work by or on behalf of the U.S. Government. Export of this data may 16 | % require a license from the United States Government. 17 | % The full license terms can be found in the file LICENSE.txt 18 | 19 | 20 | %% Observations for sparse matrix case. 21 | % The result of isequal(a,full(a)) is true! 22 | 23 | %% 24 | if ~isequal(x.size,y.size) 25 | z = false; 26 | elseif isa(x,'sptensor') && isa(y,'sptensor') 27 | z = (nnz(x-y) == 0); 28 | elseif isa(y,'tensor') 29 | z = isequal(full(x),y); 30 | else 31 | z = false; 32 | end 33 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptensor/ldivide.m: -------------------------------------------------------------------------------- 1 | function C = ldivide(A,B) 2 | %LDIVIDE Array right division for sparse tensors. 3 | % 4 | % LDIVIDE(A,B) is called for the syntax 'A .\ B' when A or B is a sparse 5 | % tensor. A and B must have the same size, unless one is a scalar. 6 | % 7 | % See also SPTENSOR. 8 | % 9 | %MATLAB Tensor Toolbox. 10 | %Copyright 2015, Sandia Corporation. 11 | 12 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 13 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 14 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 15 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 16 | % work by or on behalf of the U.S. Government. Export of this data may 17 | % require a license from the United States Government. 18 | % The full license terms can be found in the file LICENSE.txt 19 | 20 | 21 | C = rdivide(B,A); 22 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptensor/mldivide.m: -------------------------------------------------------------------------------- 1 | function C = mldivide(A,B) 2 | %MLDIVIDE Slash left division for sparse tensors. 3 | % 4 | % MlDIVIDE(A,B) is called for the syntax 'A \ B' when A is a scalar and B 5 | % is a sparse tensor. 6 | % 7 | % Example 8 | % X = sptenrand([4 3 2],5); 9 | % 3 \ X 10 | % 11 | % See also SPTENSOR. 12 | % 13 | %MATLAB Tensor Toolbox. 14 | %Copyright 2015, Sandia Corporation. 15 | 16 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 17 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 18 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 19 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 20 | % work by or on behalf of the U.S. Government. Export of this data may 21 | % require a license from the United States Government. 22 | % The full license terms can be found in the file LICENSE.txt 23 | 24 | 25 | if isscalar(A) 26 | newsubs = B.subs; 27 | newvals = B.vals / A; 28 | if A == 0 29 | nansubs = setdiff(allsubs(A),newsubs,'rows'); 30 | newsubs = [newsubs; nansubs]; 31 | newvals = [newvals; repmat(NaN,size(nansubs,1),1)]; 32 | end 33 | C = sptensor(newsubs,newvals,B.size); 34 | return; 35 | end 36 | 37 | error('MLDIVIDE only supports the scalar case for sparse tensors'); 38 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptensor/ndims.m: -------------------------------------------------------------------------------- 1 | function n = ndims(t) 2 | %NDIMS Number of dimensions of a sparse tensor. 3 | % 4 | % NDIMS(T) returns the number of dimensions of sparse tensor T. 5 | % 6 | % Examples: 7 | % T = sptenrand([3 2 2],5); 8 | % ndims(T) %<-- should return 3 9 | % 10 | % See also SPTENSOR. 11 | % 12 | %MATLAB Tensor Toolbox. 13 | %Copyright 2015, Sandia Corporation. 14 | 15 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 16 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 17 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 18 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 19 | % work by or on behalf of the U.S. Government. Export of this data may 20 | % require a license from the United States Government. 21 | % The full license terms can be found in the file LICENSE.txt 22 | 23 | 24 | n = size(t.size,2); 25 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptensor/nnz.m: -------------------------------------------------------------------------------- 1 | function a = nnz(t) 2 | %NNZ Number of nonzeros in sparse tensor. 3 | % 4 | % NNZ(T) is the number of nonzero elements in T. 5 | % 6 | % See also SPTENSOR, SPTENSOR/FIND. 7 | % 8 | %MATLAB Tensor Toolbox. 9 | %Copyright 2015, Sandia Corporation. 10 | 11 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 12 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 13 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 14 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 15 | % work by or on behalf of the U.S. Government. Export of this data may 16 | % require a license from the United States Government. 17 | % The full license terms can be found in the file LICENSE.txt 18 | 19 | 20 | if isempty(t.subs) 21 | a = 0; 22 | else 23 | a = size(t.subs,1); 24 | end 25 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptensor/norm.m: -------------------------------------------------------------------------------- 1 | function nrm = norm(T) 2 | %NORM Frobenius norm of a sparse tensor. 3 | % 4 | % NORM(T) returns the Frobenius norm of a sparse tensor. 5 | % 6 | % See also SPTENSOR, NORM. 7 | % 8 | %MATLAB Tensor Toolbox. 9 | %Copyright 2015, Sandia Corporation. 10 | 11 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 12 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 13 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 14 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 15 | % work by or on behalf of the U.S. Government. Export of this data may 16 | % require a license from the United States Government. 17 | % The full license terms can be found in the file LICENSE.txt 18 | 19 | 20 | nrm = norm(T.vals); 21 | 22 | return; 23 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptensor/not.m: -------------------------------------------------------------------------------- 1 | function y = not(x) 2 | %NOT Logical NOT (~) for sptensors. 3 | % 4 | % ~X performs a logical not on the input tensor X. The result always 5 | % returned as a sparse tensor. 6 | % 7 | % See also SPTENSOR. 8 | % 9 | %MATLAB Tensor Toolbox. 10 | %Copyright 2015, Sandia Corporation. 11 | 12 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 13 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 14 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 15 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 16 | % work by or on behalf of the U.S. Government. Export of this data may 17 | % require a license from the United States Government. 18 | % The full license terms can be found in the file LICENSE.txt 19 | 20 | 21 | %% Observations for sparse matrix case. 22 | % The result of ~a is sparse. 23 | 24 | %% Then compute those indicies that are not in x 25 | subs = setdiff(allsubs(x),x.subs,'rows'); 26 | 27 | %% Assemble final result 28 | y = sptensor(subs,true,x.size); 29 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptensor/ones.m: -------------------------------------------------------------------------------- 1 | function t = ones(t) 2 | %ONES Replace nonzero elements of sparse tensor with ones. 3 | % 4 | % S = ONES(T) generates a sparse tensor with the same sparsity 5 | % structure as T, but with ones in the nonzero position. 6 | % 7 | % See also SPTENSOR, SPONES. 8 | % 9 | %MATLAB Tensor Toolbox. 10 | %Copyright 2015, Sandia Corporation. 11 | 12 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 13 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 14 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 15 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 16 | % work by or on behalf of the U.S. Government. Export of this data may 17 | % require a license from the United States Government. 18 | % The full license terms can be found in the file LICENSE.txt 19 | 20 | 21 | t.vals = ones(size(t.vals)); 22 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptensor/private/allsubs.m: -------------------------------------------------------------------------------- 1 | function s = allsubs(x) 2 | %ALLSUBS Generate all possible subscripts for a sparse tensor X. 3 | % 4 | % See also SPTENSOR. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | %% Generate all possible indicies 19 | 20 | % Preallocate (discover any memory issues here!) 21 | s = zeros(prod(x.size),ndims(x)); 22 | 23 | % Generate appropriately sized ones vectors. 24 | o = cell(ndims(x),1); 25 | for n = 1:ndims(x) 26 | o{n} = ones(size(x,n),1); 27 | end 28 | 29 | % Generate each column of the subscripts in turn 30 | for n = 1:ndims(x) 31 | i = o; 32 | i{n} = (1:size(x,n))'; 33 | s(:,n) = khatrirao(i); 34 | end 35 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptensor/private/irenumber.m: -------------------------------------------------------------------------------- 1 | function newsubs = irenumber(t, sz, range) 2 | %RENUMBER indices for sptensor subsasgn 3 | % 4 | % See also SPTENSOR/SUBSASGN 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | nz = nnz(t); 19 | if (nz == 0) 20 | newsubs = []; 21 | return; 22 | end 23 | 24 | newsubs = t.subs; 25 | for i = 1 : numel(range) 26 | r = range{i}; 27 | if ischar(r) && r == ':' 28 | continue; 29 | elseif numel(r) == 1 30 | newsubs = [newsubs(:,1:i-1), r*ones(nz,1), newsubs(:,i:end)]; 31 | else 32 | newsubs(:,i) = r(newsubs(:,i)); 33 | end 34 | end 35 | 36 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptensor/size.m: -------------------------------------------------------------------------------- 1 | function m = size(t,idx) 2 | %SIZE Sparse tensor dimensions. 3 | % 4 | % D = SIZE(T) returns the size of the tensor. 5 | % 6 | % I = size(T,DIM) returns the sizes of the dimensions specified by DIM. 7 | % 8 | % See also SPTENSOR, SPTENSOR/NDIMS. 9 | % 10 | %MATLAB Tensor Toolbox. 11 | %Copyright 2015, Sandia Corporation. 12 | 13 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 14 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 15 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 16 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 17 | % work by or on behalf of the U.S. Government. Export of this data may 18 | % require a license from the United States Government. 19 | % The full license terms can be found in the file LICENSE.txt 20 | 21 | 22 | if exist('idx','var') 23 | m = t.size(idx); 24 | else 25 | m = t.size; 26 | end 27 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptensor/spmatrix.m: -------------------------------------------------------------------------------- 1 | function s = spmatrix(a) 2 | %SPMATRIX Converts a two-way sparse tensor to sparse matrix. 3 | % 4 | % SPMATRIX(X) converts a sparse tensor to a sparse matrix. The sparse 5 | % tensor must be two-dimensional. 6 | % 7 | % See also SPTENSOR, SPTENSOR/RESHAPE, SPTENMAT 8 | % 9 | %MATLAB Tensor Toolbox. 10 | %Copyright 2015, Sandia Corporation. 11 | 12 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 13 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 14 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 15 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 16 | % work by or on behalf of the U.S. Government. Export of this data may 17 | % require a license from the United States Government. 18 | % The full license terms can be found in the file LICENSE.txt 19 | 20 | 21 | if ndims(a) ~= 2 22 | error('Sparse tensor must be two dimensional.'); 23 | end 24 | 25 | 26 | if isempty(a.subs) 27 | s = sparse(a.size(1), a.size(2)); 28 | else 29 | s = sparse(a.subs(:,1), a.subs(:,2), a.vals, a.size(1), a.size(2)); 30 | end 31 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptensor/transpose.m: -------------------------------------------------------------------------------- 1 | function transpose(x) 2 | %TRANSPOSE is not defined on sparse tensors. 3 | % 4 | % See also SPTENSOR/PERMUTE. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | error('Transpose on sparse tensor is not defined'); 19 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptensor/uminus.m: -------------------------------------------------------------------------------- 1 | function t = uminus(t) 2 | %UMINUS Unary minus (-) for sptensor. 3 | % 4 | % See also SPTENSOR. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | t.vals = -t.vals; 19 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@sptensor/uplus.m: -------------------------------------------------------------------------------- 1 | function t = uplus(t) 2 | %UPLUS Unary plus (+) for sptensor. 3 | % 4 | % See also SPTENSOR. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | % This function does nothing! 19 | 20 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tenmat/ctranspose.m: -------------------------------------------------------------------------------- 1 | function a = ctranspose(a) 2 | %CTRANSPOSE Complex conjugate transpose for tenmat. 3 | % 4 | % C = CTRANSPOSE(A) swaps the row and column indices of A. 5 | % 6 | % See also TENMAT. 7 | % 8 | %MATLAB Tensor Toolbox. 9 | %Copyright 2015, Sandia Corporation. 10 | 11 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 12 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 13 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 14 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 15 | % work by or on behalf of the U.S. Government. Export of this data may 16 | % require a license from the United States Government. 17 | % The full license terms can be found in the file LICENSE.txt 18 | 19 | 20 | tmp = a.rindices; 21 | a.rindices = a.cindices; 22 | a.cindices = tmp; 23 | a.data = ctranspose(a.data); 24 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tenmat/display.m: -------------------------------------------------------------------------------- 1 | function display(t) 2 | %DISPLAY Command window display of a tenmat. 3 | % 4 | % See also TENMAT. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | disp(t,inputname(1)); 19 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tenmat/double.m: -------------------------------------------------------------------------------- 1 | function a = double(t) 2 | %DOUBLE Convert tenmat to double array. 3 | % 4 | % See also TENMAT. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | a = t.data; 19 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tenmat/end.m: -------------------------------------------------------------------------------- 1 | function e = end(X,k,n) 2 | %END Last index of indexing expression for tenmat. 3 | % 4 | % The expression X(end,:) will call END(X,1,2) to determine 5 | % the value of the first index. 6 | % 7 | % See also TENMAT, TENMAT/SUBSREF, END. 8 | % 9 | %MATLAB Tensor Toolbox. 10 | %Copyright 2015, Sandia Corporation. 11 | 12 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 13 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 14 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 15 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 16 | % work by or on behalf of the U.S. Government. Export of this data may 17 | % require a license from the United States Government. 18 | % The full license terms can be found in the file LICENSE.txt 19 | 20 | 21 | if n > ndims(X) 22 | error('Subscript out of range.'); 23 | end 24 | e = size(X.data,k); 25 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tenmat/minus.m: -------------------------------------------------------------------------------- 1 | function Z = minus(X,Y) 2 | %MINUS Binary subtraction (-) for tenmat. 3 | % 4 | % See also TENMAT, TENMAT/TENMATFUN. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | fun = @minus; 19 | 20 | % One argument is a scalar 21 | if ((prod(size(X)) == 1 || prod(size(Y)) == 1)) 22 | if (prod(size(Y)) == 1) && isa(X,'tenmat') 23 | Z = X; 24 | Z.data = fun(Z.data,Y); 25 | else 26 | Z = Y; 27 | Z.data = fun(X,Z.data); 28 | end 29 | return; 30 | end 31 | 32 | 33 | % Both arguments are tenmats 34 | Z = tenmat(Y); 35 | if ~(isequal(size(Y),size(Z))) 36 | error('Tenmat size mismatch.') 37 | end 38 | Z.data = fun(X.data,Z.data); 39 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tenmat/norm.m: -------------------------------------------------------------------------------- 1 | function n = norm(T) 2 | %NORM Frobenius norm of a tenmat. 3 | % 4 | % NORM(X) returns the Frobenius norm of a tenmat. 5 | % 6 | % See also TENMAT. 7 | % 8 | %MATLAB Tensor Toolbox. 9 | %Copyright 2015, Sandia Corporation. 10 | 11 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 12 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 13 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 14 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 15 | % work by or on behalf of the U.S. Government. Export of this data may 16 | % require a license from the United States Government. 17 | % The full license terms can be found in the file LICENSE.txt 18 | 19 | 20 | v = reshape(T.data, numel(T.data), 1); 21 | n = norm(v); 22 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tenmat/plus.m: -------------------------------------------------------------------------------- 1 | function Z = plus(X,Y) 2 | %PLUS Binary addition (+) for tenmat. 3 | % 4 | % See also TENMAT, TENMAT/TENMATFUN. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | fun = @plus; 19 | 20 | % One argument is a scalar 21 | if ((prod(size(X)) == 1 || prod(size(Y)) == 1)) 22 | if (prod(size(Y)) == 1) && isa(X,'tenmat') 23 | Z = X; 24 | Z.data = fun(Z.data,Y); 25 | else 26 | Z = Y; 27 | Z.data = fun(X,Z.data); 28 | end 29 | return; 30 | end 31 | 32 | 33 | % Both arguments are tenmats 34 | Z = tenmat(Y); 35 | if ~(isequal(size(Y),size(Z))) 36 | error('Tenmat size mismatch.') 37 | end 38 | Z.data = fun(X.data,Z.data); 39 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tenmat/size.m: -------------------------------------------------------------------------------- 1 | function sz = size(a,idx) 2 | %SIZE Size of tenmat. 3 | % 4 | % D = SIZE(X) returns the two-element row vector D = [M N] 5 | % containing the number of rows and columns in the matrix. 6 | % 7 | % M = SIZE(X,DIM) returns the length of the dimension specified by 8 | % the scalar DIM. For example, SIZE(X,1) returns the number of 9 | % rows. 10 | % 11 | % See also TENMAT, TENMAT/TSIZE. 12 | % 13 | %MATLAB Tensor Toolbox. 14 | %Copyright 2015, Sandia Corporation. 15 | 16 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 17 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 18 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 19 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 20 | % work by or on behalf of the U.S. Government. Export of this data may 21 | % require a license from the United States Government. 22 | % The full license terms can be found in the file LICENSE.txt 23 | 24 | 25 | if isempty(a.data) 26 | sz = []; 27 | elseif exist('idx', 'var') 28 | sz = size(a.data, idx); 29 | else 30 | sz = size(a.data); 31 | end 32 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tenmat/subsasgn.m: -------------------------------------------------------------------------------- 1 | function t = subsasgn(t,s,b) 2 | %SUBSASGN Subscripted assignment for tenmat. 3 | % 4 | % Examples 5 | % X = tenmat(rand(3,4,2),1); 6 | % X(1:2,1:2) = ones(2,2); <-- Calls SUBSASGN 7 | % 8 | % See also TENMAT, TENMAT/SUBSREF. 9 | % 10 | %MATLAB Tensor Toolbox. 11 | %Copyright 2015, Sandia Corporation. 12 | 13 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 14 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 15 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 16 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 17 | % work by or on behalf of the U.S. Government. Export of this data may 18 | % require a license from the United States Government. 19 | % The full license terms can be found in the file LICENSE.txt 20 | 21 | 22 | switch s.type 23 | case '()' 24 | [m n] = size(t.data); 25 | t.data(s.subs{:}) = b; 26 | if ~isequal([m n],size(t.data)) 27 | error('Ambiguous change in size') 28 | end 29 | otherwise 30 | error('Invalid assignment for tenmat.') 31 | end 32 | 33 | 34 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tenmat/tsize.m: -------------------------------------------------------------------------------- 1 | function sz = tsize(a,idx) 2 | %TSIZE Tensor size of tenmat. 3 | % 4 | % D = TSIZE(X) returns the size of the tensor being stored as a 5 | % matrix. 6 | % 7 | % M = TSIZE(X,DIM) returns the length of the dimension(s) specified 8 | % by DIM. For example, SIZE(X,1) returns the size of the first 9 | % dimension of the tensor. 10 | % 11 | % See also TENMAT, TENMAT/SIZE. 12 | % 13 | %MATLAB Tensor Toolbox. 14 | %Copyright 2015, Sandia Corporation. 15 | 16 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 17 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 18 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 19 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 20 | % work by or on behalf of the U.S. Government. Export of this data may 21 | % require a license from the United States Government. 22 | % The full license terms can be found in the file LICENSE.txt 23 | 24 | 25 | if isempty(a.data) 26 | sz = []; 27 | elseif exist('idx', 'var') 28 | sz = a.tsize(idx); 29 | else 30 | sz = a.tsize; 31 | end 32 | 33 | return; 34 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tenmat/uminus.m: -------------------------------------------------------------------------------- 1 | function t = uminus(t) 2 | %UMINUS Unary minus (-) for tenmat. 3 | % 4 | % See also TENMAT. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | t.data = -t.data; 19 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tenmat/uplus.m: -------------------------------------------------------------------------------- 1 | function t = uplus(t) 2 | %UPLUS Unary plus (+) for tenmat. 3 | % 4 | % See also TENMAT. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | % This function does nothing! 19 | 20 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/and.m: -------------------------------------------------------------------------------- 1 | function Z = and(X,Y) 2 | %AND Logical AND (&) for tensors. 3 | % 4 | % See also TENSOR. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | Z = tenfun(@and,X,Y); 19 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/ctranspose.m: -------------------------------------------------------------------------------- 1 | function ctranspose(x) 2 | %CTRANSPOSE is not defined for tensors. 3 | % 4 | % See also TENSOR/PERMUTE. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | error('Transpose on tensor is not defined'); 19 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/display.m: -------------------------------------------------------------------------------- 1 | function display(t) 2 | %DISPLAY Command window display of a tensor. 3 | % 4 | % DISPLAY(X) displays a tensor with its name. 5 | % 6 | % See also TENSOR, TENSOR/DISP. 7 | % 8 | %MATLAB Tensor Toolbox. 9 | %Copyright 2015, Sandia Corporation. 10 | 11 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 12 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 13 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 14 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 15 | % work by or on behalf of the U.S. Government. Export of this data may 16 | % require a license from the United States Government. 17 | % The full license terms can be found in the file LICENSE.txt 18 | 19 | 20 | disp(t,inputname(1)); 21 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/double.m: -------------------------------------------------------------------------------- 1 | function A = double(X) 2 | %DOUBLE Convert tensor to double array. 3 | % 4 | % A = double(X) converts X to a standard multidimensional array. 5 | % 6 | % See also TENSOR. 7 | % 8 | %MATLAB Tensor Toolbox. 9 | %Copyright 2015, Sandia Corporation. 10 | 11 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 12 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 13 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 14 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 15 | % work by or on behalf of the U.S. Government. Export of this data may 16 | % require a license from the United States Government. 17 | % The full license terms can be found in the file LICENSE.txt 18 | 19 | 20 | A = double(X.data); 21 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/end.m: -------------------------------------------------------------------------------- 1 | function e = end(X,k,n) 2 | %END Last index of indexing expression for tensor. 3 | % 4 | % The expression X(end,:,:) will call END(X,1,3) to determine 5 | % the value of the first index. 6 | % 7 | % See also TENSOR, TENSOR/SUBSREF, END. 8 | % 9 | %MATLAB Tensor Toolbox. 10 | %Copyright 2015, Sandia Corporation. 11 | 12 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 13 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 14 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 15 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 16 | % work by or on behalf of the U.S. Government. Export of this data may 17 | % require a license from the United States Government. 18 | % The full license terms can be found in the file LICENSE.txt 19 | 20 | 21 | if n > ndims(X) 22 | error('Subscript out of range.'); 23 | end 24 | e = X.size(k); 25 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/eq.m: -------------------------------------------------------------------------------- 1 | function Z = eq(X,Y) 2 | %EQ Equal (==) for tensors. 3 | % 4 | % See also TENSOR. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | Z = tenfun(@eq,X,Y); 19 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/full.m: -------------------------------------------------------------------------------- 1 | function X = full(X) 2 | %FULL Convert to a (dense) tensor. 3 | % 4 | % FULL(X) returns X, i.e., does nothing. 5 | % 6 | % See also TENSOR, SPTENSOR/FULL, KTENSOR/FULL, TTENSOR/FULL. 7 | % 8 | %MATLAB Tensor Toolbox. 9 | %Copyright 2015, Sandia Corporation. 10 | 11 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 12 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 13 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 14 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 15 | % work by or on behalf of the U.S. Government. Export of this data may 16 | % require a license from the United States Government. 17 | % The full license terms can be found in the file LICENSE.txt 18 | 19 | 20 | return; 21 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/ge.m: -------------------------------------------------------------------------------- 1 | function Z = ge(X,Y) 2 | %GE Greater than or equal (>=) for tensors. 3 | % 4 | % See also TENSOR. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | Z = tenfun(@ge,X,Y); 19 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/gt.m: -------------------------------------------------------------------------------- 1 | function Z = gt(X,Y) 2 | %GT Greater than (>) for tensors. 3 | % 4 | % See also TENSOR. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | Z = tenfun(@gt,X,Y); 19 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/isequal.m: -------------------------------------------------------------------------------- 1 | function z = isequal(x,y) 2 | %ISEQUAL for tensors. 3 | % 4 | % ISEQUAL(A,B) compares the tensors A and B for equality. 5 | % 6 | % See also TENSOR. 7 | % 8 | %MATLAB Tensor Toolbox. 9 | %Copyright 2015, Sandia Corporation. 10 | 11 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 12 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 13 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 14 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 15 | % work by or on behalf of the U.S. Government. Export of this data may 16 | % require a license from the United States Government. 17 | % The full license terms can be found in the file LICENSE.txt 18 | 19 | 20 | %% 21 | if ~isequal(x.size,y.size) 22 | z = false; 23 | elseif isa(x,'tensor') && isa(y,'tensor') 24 | z = isequal(x.data,y.data); 25 | elseif isa(y,'sptensor') 26 | z = isequal(x,full(y)); 27 | else 28 | z = false; 29 | end 30 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/ldivide.m: -------------------------------------------------------------------------------- 1 | function Z = ldivide(X,Y) 2 | %LDIVIDE Left array divide for tensor. 3 | % 4 | % LDIVIDE(A,B) is called for the syntax 'A .\ B' when A or B is a tensor. 5 | % A and B must have the same size, unless one is a scalar. 6 | % 7 | % Examples 8 | % X = tenrand([4 3 2],5); 9 | % X .\ 3 10 | % X .\ X 11 | % 12 | % See also TENSOR, TENSOR/RDIVIDE. 13 | % 14 | %MATLAB Tensor Toolbox. 15 | %Copyright 2015, Sandia Corporation. 16 | 17 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 18 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 19 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 20 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 21 | % work by or on behalf of the U.S. Government. Export of this data may 22 | % require a license from the United States Government. 23 | % The full license terms can be found in the file LICENSE.txt 24 | 25 | 26 | Z = tenfun(@ldivide,X,Y); 27 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/le.m: -------------------------------------------------------------------------------- 1 | function Z = le(X,Y) 2 | %LE Less than or equal (<=) for tensor. 3 | % 4 | % See also TENSOR. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | Z = tenfun(@le,X,Y); 19 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/lt.m: -------------------------------------------------------------------------------- 1 | function Z = lt(X,Y) 2 | %LT Less than (<) for tensor. 3 | % 4 | % See also TENSOR. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | Z = tenfun(@lt,X,Y); 19 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/minus.m: -------------------------------------------------------------------------------- 1 | function Z = minus(X,Y) 2 | %MINUS Binary subtraction (-) for tensors. 3 | % 4 | % MINUS(A,B) is called for the syntax 'A - B' when A or B is a tensor. A 5 | % and B must have the same size, unless one is a scalar. A scalar can be 6 | % subtracted from a tensor of any size. 7 | % 8 | % See also TENSOR. 9 | % 10 | %MATLAB Tensor Toolbox. 11 | %Copyright 2015, Sandia Corporation. 12 | 13 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 14 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 15 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 16 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 17 | % work by or on behalf of the U.S. Government. Export of this data may 18 | % require a license from the United States Government. 19 | % The full license terms can be found in the file LICENSE.txt 20 | 21 | 22 | Z = tenfun(@minus,X,Y); 23 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/mldivide.m: -------------------------------------------------------------------------------- 1 | function Z = mldivide(X,Y) 2 | %MLDIVIDE Slash left division for tensors. 3 | % 4 | % MLDIVIDE(A,B) is called for the syntax 'A \ B' when A is a scalar and B 5 | % is a tensor. 6 | % 7 | % Example 8 | % X = tenrand([4 3 2],5); 9 | % 3 \ X 10 | % 11 | % See also TENSOR, TENSOR/LDIVIDE. 12 | % 13 | %MATLAB Tensor Toolbox. 14 | %Copyright 2015, Sandia Corporation. 15 | 16 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 17 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 18 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 19 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 20 | % work by or on behalf of the U.S. Government. Export of this data may 21 | % require a license from the United States Government. 22 | % The full license terms can be found in the file LICENSE.txt 23 | 24 | 25 | if isscalar(X) 26 | Z = tenfun(@ldivide,X,Y); 27 | return; 28 | end 29 | 30 | error('MLDIVIDE only supports the scalar case for tensors'); 31 | 32 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/mrdivide.m: -------------------------------------------------------------------------------- 1 | function Z = mrdivide(X,Y) 2 | %MRDIVIDE Slash right division for tensors. 3 | % 4 | % MRDIVIDE(A,B) is called for the syntax 'A / B' when A is a tensor and B 5 | % is a scalar. 6 | % 7 | % Example 8 | % X = tenrand([4 3 2],5); 9 | % X / 3 10 | % 11 | % See also TENSOR, TENSOR/RDIVIDE. 12 | % 13 | %MATLAB Tensor Toolbox. 14 | %Copyright 2015, Sandia Corporation. 15 | 16 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 17 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 18 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 19 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 20 | % work by or on behalf of the U.S. Government. Export of this data may 21 | % require a license from the United States Government. 22 | % The full license terms can be found in the file LICENSE.txt 23 | 24 | 25 | if isscalar(Y) 26 | Z = tenfun(@rdivide,X,Y); 27 | return; 28 | end 29 | 30 | error('MRDIVIDE only supports the scalar case for tensors'); 31 | 32 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/mttkrp.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/tensor_toolbox_2.6/@tensor/mttkrp.m -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/ndims.m: -------------------------------------------------------------------------------- 1 | function n = ndims(t) 2 | %NDIMS Return the number of dimensions of a tensor. 3 | % 4 | % NDIMS(X) returns the number of dimensions of tensor X. 5 | % 6 | % Examples 7 | % A = rand(4,3,1); ndims(A) %<-- Returns 2 8 | % X = tensor(A); ndims(X) %<-- Returns 2 9 | % X = tensor(A,[4 3 1]); ndims(X) %<-- Returns 3 10 | % 11 | % See also TENSOR 12 | % 13 | %MATLAB Tensor Toolbox. 14 | %Copyright 2015, Sandia Corporation. 15 | 16 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 17 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 18 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 19 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 20 | % work by or on behalf of the U.S. Government. Export of this data may 21 | % require a license from the United States Government. 22 | % The full license terms can be found in the file LICENSE.txt 23 | 24 | 25 | n = numel(t.size); 26 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/ne.m: -------------------------------------------------------------------------------- 1 | function Z = ne(X,Y) 2 | %NE Not equal (~=) for tensors. 3 | % 4 | % See also TENSOR. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | Z = tenfun(@ne,X,Y); 19 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/nnz.m: -------------------------------------------------------------------------------- 1 | function n = nnz(x) 2 | %NNZ Number of nonzeros for tensors. 3 | % 4 | % See also TENSOR, SPTENSOR/NNZ. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | n = nnz(x.data); 19 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/norm.m: -------------------------------------------------------------------------------- 1 | function n = norm(T) 2 | %NORM Frobenius norm of a tensor. 3 | % 4 | % NORM(X) returns the Frobenius norm of a tensor. 5 | % 6 | % See also TENSOR. 7 | % 8 | %MATLAB Tensor Toolbox. 9 | %Copyright 2015, Sandia Corporation. 10 | 11 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 12 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 13 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 14 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 15 | % work by or on behalf of the U.S. Government. Export of this data may 16 | % require a license from the United States Government. 17 | % The full license terms can be found in the file LICENSE.txt 18 | 19 | 20 | v = reshape(T.data, numel(T.data), 1); 21 | n = norm(v); 22 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/not.m: -------------------------------------------------------------------------------- 1 | function B = not(A) 2 | %NOT Logical NOT (~) for tensors. 3 | % 4 | % See also TENSOR. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | B = tensor(not(A.data), size(A)); 19 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/or.m: -------------------------------------------------------------------------------- 1 | function Z = or(X,Y) 2 | %OR Logical OR (|) for tensors. 3 | % 4 | % See also TENSOR. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | Z = tenfun(@or,X,Y); 19 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/plus.m: -------------------------------------------------------------------------------- 1 | function Z = plus(X,Y) 2 | %PLUS Binary addition (+) for tensors. 3 | % 4 | % PLUS(A,B) is called for the syntax 'A + B' when A or B is a tensor. A 5 | % and B must have the same size, unless one is a scalar. A scalar can be 6 | % added to a tensor of any size. 7 | % 8 | % See also TENSOR. 9 | % 10 | %MATLAB Tensor Toolbox. 11 | %Copyright 2015, Sandia Corporation. 12 | 13 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 14 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 15 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 16 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 17 | % work by or on behalf of the U.S. Government. Export of this data may 18 | % require a license from the United States Government. 19 | % The full license terms can be found in the file LICENSE.txt 20 | 21 | 22 | Z = tenfun(@plus,X,Y); 23 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/power.m: -------------------------------------------------------------------------------- 1 | function Z = power(X,Y) 2 | %POWER Elementwise power (.^) operator for a tensor. 3 | % 4 | % See also TENSOR. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | Z = tenfun(@power,X,Y); 19 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/rdivide.m: -------------------------------------------------------------------------------- 1 | function Z = rdivide(X,Y) 2 | %RDIVIDE Right array divide for tensors. 3 | % 4 | % RDIVIDE(A,B) is called for the syntax 'A ./ B' when A or B is a tensor. 5 | % A and B must have the same size, unless one is a scalar. 6 | % 7 | % Examples 8 | % X = tenrand([4 3 2],5); 9 | % X ./ 3 10 | % X ./ X 11 | % 12 | % See also TENSOR. 13 | % 14 | %MATLAB Tensor Toolbox. 15 | %Copyright 2015, Sandia Corporation. 16 | 17 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 18 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 19 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 20 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 21 | % work by or on behalf of the U.S. Government. Export of this data may 22 | % require a license from the United States Government. 23 | % The full license terms can be found in the file LICENSE.txt 24 | 25 | 26 | Z = tenfun(@rdivide,X,Y); 27 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/reshape.m: -------------------------------------------------------------------------------- 1 | function t = reshape(t,siz) 2 | %RESHAPE Change tensor size. 3 | % RESHAPE(X,SIZ) returns the tensor whose elements 4 | % have been reshaped to the appropriate size. 5 | % 6 | % See also TENSOR, TENSOR/SQUEEZE, TENSOR/PERMUTE. 7 | % 8 | %MATLAB Tensor Toolbox. 9 | %Copyright 2015, Sandia Corporation. 10 | 11 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 12 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 13 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 14 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 15 | % work by or on behalf of the U.S. Government. Export of this data may 16 | % require a license from the United States Government. 17 | % The full license terms can be found in the file LICENSE.txt 18 | 19 | 20 | if prod(t.size) ~= prod(siz) 21 | error('Number of elements cannot change'); 22 | end 23 | 24 | t.data = reshape(t.data,siz); 25 | t.size = siz; 26 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/size.m: -------------------------------------------------------------------------------- 1 | function m = size(t,idx) 2 | %SIZE Tensor dimensions. 3 | % 4 | % D = SIZE(T) returns the sizes of each dimension of tensor X in a 5 | % vector D with ndims(X) elements. 6 | % 7 | % I = size(T,DIM) returns the size of the dimension specified by 8 | % the scalar DIM. 9 | % 10 | % Examples 11 | % A = rand(3,4,2,1); T = tensor(A,[3 4 2 1]); 12 | % size(A) %<-- returns a length-3 vector 13 | % size(T) %<-- returns a length-4 vector 14 | % size(A,2) %<-- returns 4 15 | % size(T,2) %<-- same 16 | % size(A,5) %<-- returns 1 17 | % size(T,5) %<-- ERROR! 18 | % 19 | % See also TENSOR, TENSOR/NDIMS, SIZE. 20 | % 21 | %MATLAB Tensor Toolbox. 22 | %Copyright 2015, Sandia Corporation. 23 | 24 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 25 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 26 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 27 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 28 | % work by or on behalf of the U.S. Government. Export of this data may 29 | % require a license from the United States Government. 30 | % The full license terms can be found in the file LICENSE.txt 31 | 32 | 33 | 34 | if exist('idx','var') 35 | m = t.size(idx); 36 | else 37 | m = t.size; 38 | end 39 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/times.m: -------------------------------------------------------------------------------- 1 | function Z = times(X,Y) 2 | %TIMES Array multiplication for tensors. 3 | % 4 | % TIMES(A,B) is called for the syntax 'A .* B' when A or B is a 5 | % tensor. A and B must have the same size, unless one is a scalar. A 6 | % scalar can be multiplied by a tensor of any size. 7 | % 8 | % See also TENSOR. 9 | % 10 | %MATLAB Tensor Toolbox. 11 | %Copyright 2015, Sandia Corporation. 12 | 13 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 14 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 15 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 16 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 17 | % work by or on behalf of the U.S. Government. Export of this data may 18 | % require a license from the United States Government. 19 | % The full license terms can be found in the file LICENSE.txt 20 | 21 | 22 | if isa(Y,'ktensor') || isa(Y,'ttensor') || isa(Y,'sptensor') 23 | Y = full(Y); 24 | end 25 | 26 | Z = tenfun(@times,X,Y); 27 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/transpose.m: -------------------------------------------------------------------------------- 1 | function transpose(x) 2 | %TRANSPOSE is not defined on tensors. 3 | % 4 | % See also TENSOR, TENSOR/PERMUTE. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | error('Transpose on tensor is not defined'); 19 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/uminus.m: -------------------------------------------------------------------------------- 1 | function t = uminus(t) 2 | %UMINUS Unary minus (-) for tensors. 3 | % 4 | % See also TENSOR. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | t.data = -t.data; 19 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/uplus.m: -------------------------------------------------------------------------------- 1 | function t = uplus(t) 2 | %UPLUS Unary plus (+) for tensors. 3 | % 4 | % See also TENSOR. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | % This function does nothing! 19 | 20 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@tensor/xor.m: -------------------------------------------------------------------------------- 1 | function Z = xor(X,Y) 2 | %XOR Logical EXCLUSIVE OR for tensors. 3 | % 4 | % See also TENSOR. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | Z = tenfun(@xor,X,Y); 19 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ttensor/disp.m: -------------------------------------------------------------------------------- 1 | function disp(t,name) 2 | %DISP Command window display of a ttensor. 3 | % 4 | % DISP(T) displays a ttensor with no name. 5 | % 6 | % DISP(T,NAME) display a ttensor with the given name. 7 | % 8 | % See also TTENSOR. 9 | % 10 | %MATLAB Tensor Toolbox. 11 | %Copyright 2015, Sandia Corporation. 12 | 13 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 14 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 15 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 16 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 17 | % work by or on behalf of the U.S. Government. Export of this data may 18 | % require a license from the United States Government. 19 | % The full license terms can be found in the file LICENSE.txt 20 | 21 | if ~exist('name','var') 22 | name = 'ans'; 23 | end 24 | 25 | fprintf(1,'%s is a ttensor of size %s\n', name, tt_size2str(size(t))); 26 | disp(t.core, sprintf('\t%s.core',name)); 27 | 28 | for j = 1 : ndims(t) 29 | fprintf('\t%s.U{%d} = \n', name, j); 30 | output = tt_matrix2cellstr(t.u{j}); 31 | fprintf('\t\t%s\n',output{:}); 32 | end 33 | 34 | 35 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ttensor/display.m: -------------------------------------------------------------------------------- 1 | function display(t) 2 | %DISPLAY Command window display of a ttensor. 3 | % 4 | % See also TTENSOR. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | disp(t,inputname(1)); 18 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ttensor/double.m: -------------------------------------------------------------------------------- 1 | function A = double(T) 2 | %DOUBLE Convert ttensor to double array. 3 | % 4 | % A = double(T) converts T to a standard multidimensional array. 5 | % 6 | % See also TTENSOR. 7 | % 8 | %MATLAB Tensor Toolbox. 9 | %Copyright 2015, Sandia Corporation. 10 | 11 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 12 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 13 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 14 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 15 | % work by or on behalf of the U.S. Government. Export of this data may 16 | % require a license from the United States Government. 17 | % The full license terms can be found in the file LICENSE.txt 18 | 19 | A = double(full(T)); 20 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ttensor/end.m: -------------------------------------------------------------------------------- 1 | function e = end(X,k,n) 2 | %END Last index of indexing expression for ttensor. 3 | % 4 | % The expression X(end,:,:) will call END(X,1,3) to determine 5 | % the value of the first index. 6 | % 7 | % See also TTENSOR, TTENSOR/SUBSREF, END. 8 | % 9 | %MATLAB Tensor Toolbox. 10 | %Copyright 2015, Sandia Corporation. 11 | 12 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 13 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 14 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 15 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 16 | % work by or on behalf of the U.S. Government. Export of this data may 17 | % require a license from the United States Government. 18 | % The full license terms can be found in the file LICENSE.txt 19 | 20 | % Note that this only works with {} because () is not supported by 21 | % subsref. 22 | e = ndims(X); 23 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ttensor/full.m: -------------------------------------------------------------------------------- 1 | function X = full(T) 2 | %FULL Convert a ttensor to a (dense) tensor. 3 | % 4 | % X = FULL(T) converts ttensor T to (dense) tensor X. 5 | % 6 | % See also TTENSOR, TENSOR. 7 | % 8 | %MATLAB Tensor Toolbox. 9 | %Copyright 2015, Sandia Corporation. 10 | 11 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 12 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 13 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 14 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 15 | % work by or on behalf of the U.S. Government. Export of this data may 16 | % require a license from the United States Government. 17 | % The full license terms can be found in the file LICENSE.txt 18 | 19 | % Preallocate to ensure there is enough space 20 | X = tenzeros(size(T)); 21 | 22 | % Now do the calculation 23 | X = ttm(T.core,T.u); 24 | 25 | % Make sure that X is a dense tensor (small chance it could be a sparse 26 | % tensor). 27 | X = tensor(X); 28 | 29 | return; 30 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ttensor/mtimes.m: -------------------------------------------------------------------------------- 1 | function C = mtimes(A,B) 2 | %MTIMES Implement scalar multiplication for a ttensor. 3 | % 4 | % See also TTENSOR. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | if ~isa(B,'ttensor') && numel(B) == 1 18 | C = ttensor(B * A.core, A.u); 19 | elseif ~isa(A,'ttensor') && numel(A) == 1 20 | C = ttensor(A * B.core, B.u); 21 | else 22 | error('Use mtimes(full(A),full(B)).'); 23 | end 24 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ttensor/ndims.m: -------------------------------------------------------------------------------- 1 | function n = ndims(t) 2 | %NDIMS Return the number of dimensions for a ttensor. 3 | % 4 | % NDIMS(T) returns the number of dimensions of tensor T. 5 | % 6 | % See also TTENSOR. 7 | % 8 | %MATLAB Tensor Toolbox. 9 | %Copyright 2015, Sandia Corporation. 10 | 11 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 12 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 13 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 14 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 15 | % work by or on behalf of the U.S. Government. Export of this data may 16 | % require a license from the United States Government. 17 | % The full license terms can be found in the file LICENSE.txt 18 | 19 | n = numel(t.u); 20 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ttensor/norm.m: -------------------------------------------------------------------------------- 1 | function nrm = norm(X) 2 | %NORM Norm of a ttensor. 3 | % 4 | % See also TTENSOR. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | if prod(size(X)) > prod(size(X.core)) 19 | V = cell(ndims(X),1); 20 | for n = 1:ndims(X) 21 | V{n} = X.u{n}'*X.u{n}; 22 | end 23 | Y = ttm(X.core,V); 24 | tmp = innerprod(Y, X.core); 25 | nrm = sqrt(tmp); 26 | else 27 | nrm = norm(full(X)); 28 | end 29 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ttensor/permute.m: -------------------------------------------------------------------------------- 1 | function b = permute(a,order) 2 | %PERMUTE Permute dimensions for a ttensor. 3 | % 4 | % Y = PERMUTE(X,ORDER) rearranges the dimensions of X so that they 5 | % are in the order specified by the vector ORDER. The tensor 6 | % produced has the same values of X but the order of the subscripts 7 | % needed to access any particular element are rearranged as 8 | % specified by ORDER. 9 | % 10 | % See also TTENSOR. 11 | % 12 | %MATLAB Tensor Toolbox. 13 | %Copyright 2015, Sandia Corporation. 14 | 15 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 16 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 17 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 18 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 19 | % work by or on behalf of the U.S. Government. Export of this data may 20 | % require a license from the United States Government. 21 | % The full license terms can be found in the file LICENSE.txt 22 | 23 | N = ndims(a); 24 | 25 | if ~isequal(1:N,sort(order)) 26 | error('Invalid permuation'); 27 | end 28 | 29 | newcore = permute(a.core,order); 30 | newu = a.u(order); 31 | b = ttensor(newcore,newu); 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ttensor/size.m: -------------------------------------------------------------------------------- 1 | function m = size(t,idx) 2 | %SIZE Size of a ttensor. 3 | % 4 | % D = SIZE(T) returns the size of the tensor. 5 | % 6 | % I = size(T,DIM) returns the size of the dimension specified by 7 | % the scalar DIM. 8 | % 9 | % See also TTENSOR, TTENSOR/NDIMS. 10 | % 11 | %MATLAB Tensor Toolbox. 12 | %Copyright 2015, Sandia Corporation. 13 | 14 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 15 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 16 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 17 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 18 | % work by or on behalf of the U.S. Government. Export of this data may 19 | % require a license from the United States Government. 20 | % The full license terms can be found in the file LICENSE.txt 21 | 22 | if ndims(t) == 0 23 | m = []; 24 | end 25 | 26 | if exist('idx','var') 27 | m = size(t.u{idx}, 1); 28 | else 29 | for i = 1 : ndims(t) 30 | m(i) = size(t.u{i}, 1); 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ttensor/uminus.m: -------------------------------------------------------------------------------- 1 | function t = uminus(t) 2 | %UMINUS Unary minus for ttensor. 3 | % 4 | % See also TTENSOR. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | t.core = -t.core; 18 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/@ttensor/uplus.m: -------------------------------------------------------------------------------- 1 | function t = uplus(t) 2 | %UPLUS Unary plus for ttensor. 3 | % 4 | % See also TTENSOR. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | % This function does nothing! 18 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/cp_als.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/tensor_toolbox_2.6/cp_als.m -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/cp_wopt.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/tensor_toolbox_2.6/cp_wopt.m -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/doc/T4_cpapr_doc.m: -------------------------------------------------------------------------------- 1 | %% Alternating Poisson Regression for fitting CP to sparse count data 2 | 3 | %% Set up a sample problem 4 | % We follow the general procedure outlined by E. C. Chi and T. G. Kolda, 5 | % On Tensors, Sparsity, and Nonnegative Factorizations, arXiv:1112.2414 6 | % [math.NA], December 2011 (http://arxiv.org/abs/1112.2414). 7 | 8 | % Pick the size and rank 9 | sz = [100 80 60]; 10 | R = 5; 11 | 12 | % Generate factor matrices with a few large entries in each column; this 13 | % will be the basis of our soln. 14 | A = cell(3,1); 15 | for n = 1:length(sz) 16 | A{n} = rand(sz(n), R); 17 | for r = 1:R 18 | p = randperm(sz(n)); 19 | nbig = round( (1/R)*sz(n) ); 20 | A{n}(p(1:nbig),r) = 100 * A{n}(p(1:nbig),r); 21 | end 22 | end 23 | lambda = rand(R,1); 24 | S = ktensor(lambda, A); 25 | S = normalize(S,'sort',1); 26 | 27 | % Create sparse test problem based on provided solution. 28 | nz = prod(sz) * .05; 29 | info = create_problem('Soln', S, 'Sparse_Generation', nz); 30 | 31 | % Extract data and solution 32 | X = info.Data; 33 | M_true = info.Soln; 34 | 35 | %% Call CP-APR 36 | 37 | % Compute a solution 38 | M = cp_apr(X, R, 'printitn', 10); 39 | 40 | % Score the solution 41 | factor_match_score = score(M, M_true, 'greedy', true) 42 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/doc/V_SSHOPM_doc.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/tensor_toolbox_2.6/doc/V_SSHOPM_doc.m -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/doc/html/C_ttensor_doc_eq05572125758666918607.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/tensor_toolbox_2.6/doc/html/C_ttensor_doc_eq05572125758666918607.png -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/doc/html/D_ktensor_doc_eq03981049146616847228.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/tensor_toolbox_2.6/doc/html/D_ktensor_doc_eq03981049146616847228.png -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/doc/html/D_ktensor_doc_eq06950581413034201722.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/tensor_toolbox_2.6/doc/html/D_ktensor_doc_eq06950581413034201722.png -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/doc/html/D_ktensor_doc_eq11724614562625913327.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/tensor_toolbox_2.6/doc/html/D_ktensor_doc_eq11724614562625913327.png -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/doc/html/D_ktensor_doc_eq15815821552081582258.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/tensor_toolbox_2.6/doc/html/D_ktensor_doc_eq15815821552081582258.png -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/doc/images/Workspace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/tensor_toolbox_2.6/doc/images/Workspace.png -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/doc/images/banner-background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/tensor_toolbox_2.6/doc/images/banner-background.jpg -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/doc/images/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/tensor_toolbox_2.6/doc/images/logo.gif -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/helpindex.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Tensor Toolbox 6 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/info.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | R2006a 7 | Tensor 8 | toolbox 9 | $toolbox/matlab/icons/unknownicon.gif 10 | . 11 | 12 | 13 | 14 | 15 | doc tensor_toolbox/ 16 | $toolbox/matlab/icons/webicon.gif 17 | 18 | 19 | 20 | web http://www.sandia.gov/~tgkolda/TensorToolbox 21 | $toolbox/matlab/icons/webicon.gif 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/khatrirao.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/tensor_toolbox_2.6/khatrirao.m -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/matrandcong.m: -------------------------------------------------------------------------------- 1 | function X = matrandcong(m,n,gamma) 2 | %MATRANDCONG Create a random matrix with a fixed congruence. 3 | % 4 | % X = MATRANDCONG(M,N,GAMMA) creates a matrix X of size M x N such 5 | % that each column of X has norm 1 and any two columns of X have an inner 6 | % product equal to GAMMA. 7 | % 8 | % Based on code from Evrim Acar and the paper G. Tomasi and R. Bro, A 9 | % comparison of algorithms for fitting the PARAFAC model, Computational 10 | % Statistics & Data Analysis, 50: 1700-1734, 2006. 11 | % 12 | % See also MATRANDORTH, MATRANDNORM, CREATE_PROBLEM, CREATE_GUESS. 13 | % 14 | %MATLAB Tensor Toolbox. 15 | %Copyright 2015, Sandia Corporation. 16 | 17 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 18 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 19 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 20 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 21 | % work by or on behalf of the U.S. Government. Export of this data may 22 | % require a license from the United States Government. 23 | % The full license terms can be found in the file LICENSE.txt 24 | 25 | CG = gamma * ones(n,n) + (1-gamma) * eye(n); 26 | CGR = chol(CG); 27 | X = randn(m,n); 28 | [Q,~] = qr(X,0); 29 | X = Q * CGR; 30 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/met/Contents.m: -------------------------------------------------------------------------------- 1 | % ttm_me - Memory-efficient sptensor times matrix. 2 | % ttm_me_mem - Estimates intermediate memory comsumption for ttm_me. 3 | % ttm_me_partition - Finds best order for ttm_me. 4 | % tucker_me - Memory-efficient Tucker higher-order orthogonal iteration. 5 | % tucker_me_test - Very simple tests of tucker_me. 6 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/parafac_als.m: -------------------------------------------------------------------------------- 1 | function [P,Uinit] = parafac_als(X,R,opts) 2 | %PARAFAC_ALS Deprecated. Use CP_ALS instead. 3 | % 4 | % See also CP_ALS. 5 | % 6 | %MATLAB Tensor Toolbox. 7 | %Copyright 2015, Sandia Corporation. 8 | 9 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 10 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 11 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 12 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 13 | % work by or on behalf of the U.S. Government. Export of this data may 14 | % require a license from the United States Government. 15 | % The full license terms can be found in the file LICENSE.txt 16 | 17 | 18 | if (nargout == 2) & (nargin == 3) 19 | [P,Uinit] = cp_als(X,R,opts); 20 | elseif (nargout == 2) & (nargin == 2) 21 | [P,Uinit] = cp_als(X,R); 22 | elseif (nargout == 2) & (nargin == 1) 23 | [P,Uinit] = cp_als(X); 24 | elseif (nargout == 1) & (nargin == 3) 25 | P = cp_als(X,R,opts); 26 | elseif (nargout == 1) & (nargin == 2) 27 | P = cp_als(X,R); 28 | elseif (nargout == 1) & (nargin == 1) 29 | P = cp_als(X); 30 | end 31 | 32 | 33 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/tenones.m: -------------------------------------------------------------------------------- 1 | function X = tenones(varargin) 2 | %TENONES Ones tensor. 3 | % 4 | % X = TENONES(SZ) forms a tensor of size SZ with all ones. 5 | % 6 | % TENONES(SZ) is equivalent to TENSOR(ONES(SZ(1),SZ(2),...),SZ). 7 | % 8 | % See also TENSOR, ONES. 9 | % 10 | %MATLAB Tensor Toolbox. 11 | %Copyright 2015, Sandia Corporation. 12 | 13 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 14 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 15 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 16 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 17 | % work by or on behalf of the U.S. Government. Export of this data may 18 | % require a license from the United States Government. 19 | % The full license terms can be found in the file LICENSE.txt 20 | 21 | 22 | if nargin == 1 23 | sz = varargin{1}; 24 | else 25 | sz = cell2mat(varargin); 26 | end 27 | 28 | if isempty(sz) 29 | X = tensor(); 30 | return; 31 | end 32 | 33 | data = ones([sz 1 1]); 34 | X = tensor(data,sz); 35 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/tenrand.m: -------------------------------------------------------------------------------- 1 | function X = tenrand(varargin) 2 | %TENRAND Uniformly distributed pseudo-random tensor. 3 | % 4 | % X = TENRAND(SZ) forms a tensor of size SZ with pseudo-random 5 | % values drawn from a uniform distribution on the unit interval. 6 | % 7 | % TENRAND(SZ) is equivalent to TENSOR(RAND(SZ(1),SZ(2),...),SZ). 8 | % 9 | % See also TENSOR, SPTENRAND, RAND. 10 | % 11 | %MATLAB Tensor Toolbox. 12 | %Copyright 2015, Sandia Corporation. 13 | 14 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 15 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 16 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 17 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 18 | % work by or on behalf of the U.S. Government. Export of this data may 19 | % require a license from the United States Government. 20 | % The full license terms can be found in the file LICENSE.txt 21 | 22 | 23 | if nargin == 1 24 | sz = varargin{1}; 25 | else 26 | sz = cell2mat(varargin); 27 | end 28 | 29 | data = rand([sz 1 1]); 30 | X = tensor(data,sz); 31 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/tenzeros.m: -------------------------------------------------------------------------------- 1 | function X = tenzeros(varargin) 2 | %TENZEROS Create zeros tensor. 3 | % 4 | % X = TENZEROS(SZ) forms a tensor of size SZ with all zeros. 5 | % 6 | % TENZEROS(SZ) is equivalent to TENSOR(ZEROS(SZ(1),SZ(2),...),SZ). 7 | % 8 | % See also TENSOR, ZEROS. 9 | % 10 | %MATLAB Tensor Toolbox. 11 | %Copyright 2015, Sandia Corporation. 12 | 13 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 14 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 15 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 16 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 17 | % work by or on behalf of the U.S. Government. Export of this data may 18 | % require a license from the United States Government. 19 | % The full license terms can be found in the file LICENSE.txt 20 | 21 | 22 | if nargin == 1 23 | sz = varargin{1}; 24 | else 25 | sz = cell2mat(varargin); 26 | end 27 | 28 | if isempty(sz) 29 | X = tensor; 30 | return; 31 | end 32 | 33 | if nargin == 2 34 | order = sz; 35 | dim = varargin{1}; 36 | sz = dim * ones(1,order); 37 | end 38 | 39 | data = zeros([sz 1 1]); 40 | X = tensor(data,sz); 41 | 42 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/tt_cp_fun.m: -------------------------------------------------------------------------------- 1 | function [f,g] = tt_cp_fun(x,Z,Znormsqr) 2 | %TT_CP_FUN Calculate function and gradient for CP fit function. 3 | % 4 | % [F,G] = TT_CP_FUN(X,Z) where X is a vector containing the entries of the 5 | % components of the model and Z is the tensor to be fit. 6 | % 7 | % See also TT_CP_VEC_TO_FAC, TT_FAC_TO_VEC, TT_CP_FG, CP_OPT 8 | % 9 | %MATLAB Tensor Toolbox. 10 | %Copyright 2015, Sandia Corporation. 11 | 12 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 13 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 14 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 15 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 16 | % work by or on behalf of the U.S. Government. Export of this data may 17 | % require a license from the United States Government. 18 | % The full license terms can be found in the file LICENSE.txt 19 | 20 | 21 | %% Convert x to a cell array of matrices 22 | A = tt_cp_vec_to_fac(x,Z); 23 | 24 | %% Call cp_fit and cp_gradient using cp_fg 25 | [f,G] = tt_cp_fg(Z,A,Znormsqr); 26 | 27 | %% Convert a cell array to a vector 28 | g = tt_fac_to_vec(G); 29 | 30 | 31 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/tt_cp_vec_to_fac.m: -------------------------------------------------------------------------------- 1 | function A = tt_cp_vec_to_fac(x,Z) 2 | %TT_CP_VEC_TO_FAC Converts a vector to a cell array of factor matrices. 3 | % 4 | % A = TT_CP_VEC_TO_FAC(X,Z) converts the vector X into a cell array 5 | % of factor matrices consistent with the size of the tensor Z. 6 | % 7 | % See also TT_FAC_TO_VEC, TT_CP_FUN, TT_CP_OPT. 8 | % 9 | %MATLAB Tensor Toolbox. 10 | %Copyright 2015, Sandia Corporation. 11 | 12 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 13 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 14 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 15 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 16 | % work by or on behalf of the U.S. Government. Export of this data may 17 | % require a license from the United States Government. 18 | % The full license terms can be found in the file LICENSE.txt 19 | 20 | 21 | %% Set-up 22 | P = length(x); 23 | N = ndims(Z); 24 | sz = size(Z); 25 | 26 | %% Determine R 27 | R = P / sum(sz); 28 | 29 | %% Create A 30 | A = cell(N,1); 31 | for n = 1:N 32 | idx1 = sum(sz(1:n-1))*R + 1; 33 | idx2 = sum(sz(1:n))*R; 34 | A{n} = reshape(x(idx1:idx2),sz(n),R); 35 | end 36 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/tt_fac_to_vec.m: -------------------------------------------------------------------------------- 1 | function x = tt_fac_to_vec(A) 2 | %TT_FAC_TO_VEC Converts a set of factor matrices to a vector. 3 | % 4 | % X = TT_FAC_TO_VEC(A) converts a cell array of factor matrices A to a 5 | % vector by vectorizing each matrix and stacking them. 6 | % 7 | % See also TT_CP_VEC_TO_FAC, TT_CP_FUN, CP_OPT. 8 | % 9 | %MATLAB Tensor Toolbox. 10 | %Copyright 2015, Sandia Corporation. 11 | 12 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 13 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 14 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 15 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 16 | % work by or on behalf of the U.S. Government. Export of this data may 17 | % require a license from the United States Government. 18 | % The full license terms can be found in the file LICENSE.txt 19 | 20 | 21 | %% Set-up 22 | N = length(A); 23 | 24 | %% Get sizes 25 | sz = zeros(N,1); 26 | for n = 1:N 27 | sz(n) = size(A{n},1); 28 | end 29 | R = size(A{1},2); 30 | P = sum(sz)*R; 31 | 32 | %% Create x 33 | x = zeros(P,1); 34 | for n = 1:N 35 | idx1 = sum(sz(1:n-1))*R + 1; 36 | idx2 = sum(sz(1:n))*R; 37 | x(idx1:idx2) = reshape(A{n},sz(n)*R,1); 38 | end 39 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/tt_ind2sub.m: -------------------------------------------------------------------------------- 1 | function subs = tt_ind2sub(siz,idx) 2 | %TT_IND2SUB Multiple subscripts from linear indices. 3 | % 4 | % SUBS = TT_IND2SUB(SIZ,INDS) returns that subscripts equivalent 5 | % to the linear indices in INDS for a tensor of size SIZ. 6 | % 7 | % See also TT_SUB2IND, IND2SUB. 8 | % 9 | %MATLAB Tensor Toolbox. 10 | %Copyright 2015, Sandia Corporation. 11 | 12 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 13 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 14 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 15 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 16 | % work by or on behalf of the U.S. Government. Export of this data may 17 | % require a license from the United States Government. 18 | % The full license terms can be found in the file LICENSE.txt 19 | 20 | 21 | if isempty(idx) 22 | subs = []; 23 | return; 24 | end 25 | 26 | k = [1 cumprod(siz(1:end-1))]; 27 | n = length(siz); 28 | idx = idx - 1; 29 | for i = n : -1 : 1 30 | subs(:,i) = floor(idx / k(i)) + 1; 31 | idx = rem(idx,k(i)); 32 | end 33 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/tt_intvec2str.m: -------------------------------------------------------------------------------- 1 | function s = tt_intvec2str(v) 2 | %TT_INTVEC2STR Print integer vector to a string with brackets. 3 | % 4 | %MATLAB Tensor Toolbox. 5 | %Copyright 2015, Sandia Corporation. 6 | 7 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 8 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 9 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 10 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 11 | % work by or on behalf of the U.S. Government. Export of this data may 12 | % require a license from the United States Government. 13 | % The full license terms can be found in the file LICENSE.txt 14 | 15 | 16 | if isempty(v) 17 | s = sprintf('[]'); 18 | return; 19 | end 20 | 21 | s = ['[ ' sprintf('%d ',v(1:end)) ']']; 22 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/tt_matrix2cellstr.m: -------------------------------------------------------------------------------- 1 | function S = tt_matrix2cellstr(M) 2 | %TT_MATRIX2CELLSTR Convert a matrix to a cell array of strings. 3 | % 4 | %MATLAB Tensor Toolbox. 5 | %Copyright 2015, Sandia Corporation. 6 | 7 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 8 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 9 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 10 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 11 | % work by or on behalf of the U.S. Government. Export of this data may 12 | % require a license from the United States Government. 13 | % The full license terms can be found in the file LICENSE.txt 14 | 15 | 16 | fmt = get(0,'FormatSpacing'); 17 | format compact 18 | S = evalc('disp(M)'); 19 | if isempty(S) 20 | S = {''}; 21 | return; 22 | end 23 | set(0,'FormatSpacing',fmt) 24 | S = textscan(S,'%s','delimiter','\n','whitespace',''); 25 | S = S{1}; 26 | end 27 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/tt_size2str.m: -------------------------------------------------------------------------------- 1 | function s = tt_size2str(sz) 2 | %TT_SIZE2STR Convert size to a string that can be printed. 3 | % 4 | %MATLAB Tensor Toolbox. 5 | %Copyright 2015, Sandia Corporation. 6 | 7 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 8 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 9 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 10 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 11 | % work by or on behalf of the U.S. Government. Export of this data may 12 | % require a license from the United States Government. 13 | % The full license terms can be found in the file LICENSE.txt 14 | 15 | 16 | if isempty(sz) 17 | s = sprintf('[empty tensor]'); 18 | return; 19 | end 20 | 21 | if numel(sz) == 1 22 | s = sprintf('%d',sz); 23 | else 24 | s = [sprintf('%d x ',sz(1:end-1)) sprintf('%d', sz(end)) ]; 25 | end 26 | 27 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/tt_sub2ind.m: -------------------------------------------------------------------------------- 1 | function idx = tt_sub2ind(siz,subs) 2 | %TT_SUB2IND Converts multidimensional subscripts to linear indices. 3 | % 4 | % INDS = TT_SUB2IND(SIZ,SUBS) returns the linear indices 5 | % equivalent to the subscripts in the array SUBS for a tensor of 6 | % size SIZ. 7 | % 8 | % See also TT_IND2SUB, SUB2IND. 9 | % 10 | %MATLAB Tensor Toolbox. 11 | %Copyright 2015, Sandia Corporation. 12 | 13 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 14 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 15 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 16 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 17 | % work by or on behalf of the U.S. Government. Export of this data may 18 | % require a license from the United States Government. 19 | % The full license terms can be found in the file LICENSE.txt 20 | 21 | 22 | if isempty(subs) 23 | idx = []; 24 | return; 25 | end 26 | 27 | mult = [1 cumprod(siz(1:end-1))]; 28 | idx = (subs - 1) * mult' + 1; 29 | 30 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/tt_subsubsref.m: -------------------------------------------------------------------------------- 1 | function a = tt_subsubsref(obj,s) 2 | %TT_SUBSUBSREF Helper function for tensor toolbox subsref. 3 | % 4 | %MATLAB Tensor Toolbox. 5 | %Copyright 2015, Sandia Corporation. 6 | 7 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 8 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 9 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 10 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 11 | % work by or on behalf of the U.S. Government. Export of this data may 12 | % require a license from the United States Government. 13 | % The full license terms can be found in the file LICENSE.txt 14 | 15 | 16 | if length(s) == 1 17 | a = obj; 18 | else 19 | a = subsref(obj, s(2:end)); 20 | end 21 | 22 | -------------------------------------------------------------------------------- /common-tools/tensor_toolbox_2.6/tt_valscheck.m: -------------------------------------------------------------------------------- 1 | function ok = tt_valscheck(vals) 2 | %TT_VALSCHECK Checks for valid values. 3 | % 4 | % TT_VALSCHECK(S) throws an error if S is not a valid values 5 | % array, which means that S is a column array. 6 | % 7 | % X = TT_VALSCHECK(S) returns true if S is a valid and false otherwise. 8 | % 9 | %MATLAB Tensor Toolbox. 10 | %Copyright 2015, Sandia Corporation. 11 | 12 | % This is the MATLAB Tensor Toolbox by T. Kolda, B. Bader, and others. 13 | % http://www.sandia.gov/~tgkolda/TensorToolbox. 14 | % Copyright (2015) Sandia Corporation. Under the terms of Contract 15 | % DE-AC04-94AL85000, there is a non-exclusive license for use of this 16 | % work by or on behalf of the U.S. Government. Export of this data may 17 | % require a license from the United States Government. 18 | % The full license terms can be found in the file LICENSE.txt 19 | 20 | 21 | if isempty(vals) 22 | ok = true; 23 | elseif ndims(vals) == 2 && size(vals,2) == 1 24 | ok = true; 25 | else 26 | ok = false; 27 | end 28 | 29 | if ~ok && nargout == 0 30 | error('Values must be a column array'); 31 | end 32 | -------------------------------------------------------------------------------- /common-tools/tools/SVT_t.m: -------------------------------------------------------------------------------- 1 | function [ U, S, V ] = SVT_t( Z, lambda, rnk ) 2 | 3 | Z = real(Z); 4 | 5 | [U, S, V] = safeSVD( Z ); 6 | 7 | s = diag(S); 8 | s = s - lambda; 9 | s = s(s > 0); 10 | svs = length(s); 11 | 12 | U = U(:,1:svs); 13 | V = V(:,1:svs); 14 | S = diag(s); 15 | 16 | end 17 | 18 | %% ------------------------------------------------------------------------ 19 | function [U, S, V] = safeSVD( A ) 20 | 21 | try 22 | [U, S, V] = svd(A, 'econ'); 23 | catch 24 | [U, S, V] = lansvd(A, floor(min(size(A))/4), 'L'); 25 | end 26 | 27 | % [U, S, V] = svd(A, 'econ'); 28 | 29 | end -------------------------------------------------------------------------------- /common-tools/tools/SynData2M.m: -------------------------------------------------------------------------------- 1 | function [ tra, tst ] = SynData2M( tenSz, rnk, ratio) 2 | 3 | I1= tenSz(1); 4 | I2= tenSz(2); 5 | I3= tenSz(3); 6 | 7 | A = randn(I1,rnk); 8 | % [A, ~] = qr(A, 0); 9 | B = randn(I2,rnk); 10 | % [B, ~] = qr(B, 0); 11 | C = randn(I3,rnk); 12 | % [C, ~] = qr(C, 0); 13 | % s = prod(tenSz)*rand(rnk,1); 14 | 15 | X = zeros(I1, I2, I3); 16 | 17 | for i = 1:rnk 18 | x = kron(A(:,i)*B(:,i)', C(:,i)); 19 | x = reshape(x, [I1,I2,I3]); 20 | 21 | X = X + x; 22 | end 23 | 24 | X = X + randn(size(X)) * 0.1; 25 | 26 | tra = cell(I3, 1); 27 | tst = struct; 28 | for i = 1:I3 29 | temp = (rand(I1,I2) < ratio) ; 30 | 31 | tra{i} = temp .* X(:,:,i); 32 | tra{i} = sparse(tra{i}); 33 | 34 | temp = (rand(I1,I2) < 0.005); 35 | temp = temp .* X(:,:,i); 36 | temp = sparse(temp); 37 | 38 | [tst.row{i}, tst.col{i}, tst.data{i}] = find(temp); 39 | end 40 | 41 | end 42 | 43 | -------------------------------------------------------------------------------- /common-tools/tools/powerMethod_gen.m: -------------------------------------------------------------------------------- 1 | function [U, S, V] = powerMethod_gen(Z, R, maxIter) 2 | 3 | Y = Z*R; 4 | for i = 1:maxIter 5 | [Q, ~] = qr(Y, 0); 6 | Y = Z*(Z'*Q); 7 | end 8 | 9 | [U, S, V] = svd(Q'*Z, 'econ'); 10 | U = Q*U; 11 | 12 | end -------------------------------------------------------------------------------- /common-tools/tools/sparse_inp.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/tools/sparse_inp.mexglx -------------------------------------------------------------------------------- /common-tools/tools/sparse_inp.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/tools/sparse_inp.mexmaci64 -------------------------------------------------------------------------------- /common-tools/tools/sparse_inp.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/tools/sparse_inp.mexw64 -------------------------------------------------------------------------------- /common-tools/tools/sparse_update.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/tools/sparse_update.mexglx -------------------------------------------------------------------------------- /common-tools/tools/sparse_update.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/tools/sparse_update.mexmaci64 -------------------------------------------------------------------------------- /common-tools/tools/sparse_update.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanmingyao/FasTer/211373a18de66795e0fbf22df48656ace87ee195/common-tools/tools/sparse_update.mexw64 -------------------------------------------------------------------------------- /common-tools/tools/synRand.m: -------------------------------------------------------------------------------- 1 | function [ X, d ] = synRand( n, k ) 2 | 3 | U1 = rand( n(1), k(1) ); 4 | U1 = bsxfun(@minus, U1, mean(U1, 1)); 5 | U2 = rand( n(2), k(2) ); 6 | U2 = bsxfun(@minus, U2, mean(U2, 1)); 7 | U3 = rand( n(3), k(3) ); 8 | U3 = bsxfun(@minus, U3, mean(U3, 1)); 9 | 10 | d = randn(k(1), 1); 11 | d = d - mean(d); 12 | 13 | C = zeros(k); 14 | for i = 1:length(d) 15 | C(i,i,i) = d(i); 16 | end 17 | 18 | X.U{1} = U1; 19 | X.U{2} = U2; 20 | X.U{3} = U3; 21 | X.G = C; 22 | 23 | end 24 | --------------------------------------------------------------------------------