1)matlab tensor张量库的安装
最新版本 Tensor Toolbox 2.6,下载地址:http://www.sandia.gov/~tgkolda/TensorToolbox/index-2.6.html下载之前需要简单的注册一下,提交相关的使用者基本信息,点击提交后直接跳转到下载页面,下载即可,有zip和tar.gz格式。http://www.sandia.gov/~tgkolda/TensorToolbox/thankyou-2.6.html
Download
Installation
Unpack the files.
Rename the root directory of the toolbox from tensor_toolbox_2.6 to tensor_toolbox.
Start MATLAB.
Within MATLAB, cd to the tensor_toolbox directory and execute the following commands.
addpath(pwd)%
安装的具体方法是:
(1).解压当前安装包;
(2).将tensor_toolbox_2.6改名为tensor_toolbox
(3).启动matlab,选择toolsbox所在的路径,然后在matlab的命令窗口中键入如下命令:
addpath(pwd) %将当前路径添加到matlab工作路径中去
cd met; addpath(pwd) %将子目录met也添加进来
savepath %为后续进程保存这两个路径
2)张量的测试
%创建一个4*3*2的一个张量,元素都为 1
>> M = ones(4,3,2); %
X = tensor(M) %
X is a tensor of size 4 x 3 x 2
X(:,:,1) =
1 1 1
1 1 1
1 1 1
1 1 1
X(:,:,2) =
1 1 1
1 1 1
1 1 1
1 1 1
>> X = tensor(rand(5,1)) %
X is a tensor of size 5 x 1
X(:,:) =
0.0821
0.1057
0.1420
0.1665
0.6210
>> Y = tensor(rand(4,3,1)) %
Y is a tensor of size 4 x 3
Y(:,:) =
0.5737 0.7378 0.9844
0.0521 0.0634 0.8589
0.9312 0.8604 0.7856
0.7287 0.9344 0.5134
X = tenrand([4 3 2]); %
X.data %
ans(:,:,1) =
0.0971 0.9502 0.7655
0.8235 0.0344 0.7952
0.6948 0.4387 0.1869
0.3171 0.3816 0.4898
ans(:,:,2) =
0.4456 0.2760 0.1190
0.6463 0.6797 0.4984
0.7094 0.6551 0.9597
0.7547 0.1626 0.3404
>> X.size %
ans =
4 3 2
最后,介绍一个matlab 的tensorlab库,官网http://www.tensorlab.net/也非常不错,最新更新2016年