kronecker

版本 1.2.0.0 (1.9 KB) 作者: Bruno Luong
Kronecker tensor product
2.1K 次下载
更新时间 2009/6/22

查看许可证

This function does exactly what Matlab KRON does, but for large full matrices, the engine uses BSXFUN to accelerate the calculation.
Another advantage is no intermediate large matrices are generated (four temporary arrays in case of KRON).

Here is the benchmark code and result:

clear,
gain=[];
mem = memory;
maxn = (mem.MaxPossibleArrayBytes/32)^0.25;
n = 10:10:maxn;
for sz=n
A=rand(sz); B=rand(sz);
t1=Inf;
for ntry=1:10
tic; K = kron(A,B); t1=min(t1,toc);
end
clear K
t2=Inf;
for ntry=1:10
tic; K = kronecker(A,B); t2=min(t2,toc);
end
clear K
gain(end+1) = t1/t2;
end

fprintf('Size A/B Speed gain\n');
fprintf(' %02d %1.2f \n', [n; gain]);

Size A/B Speed gain
10 1.17
20 3.48
30 3.78
40 3.73
50 3.68
60 4.22
70 3.81

引用格式

Bruno Luong (2024). kronecker (https://www.mathworks.com/matlabcentral/fileexchange/24499-kronecker), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2007a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Networks 的更多信息
标签 添加标签
致谢

启发作品: Kronecker product

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.2.0.0

Miss spelling corrected

1.0.0.0