Speed up repeated kronecker product
4 次查看(过去 30 天)
显示 更早的评论
I need to run several times (around 70-80 times) few lines of code, that include a kronecker product with a huge matrix.
In the code below this huge matrix is the sparse nanYt of dimensions 15k x 15k or greater, depending on t it can reach 50kx50k.
denom = zeros(n*r,n*r);
nom = zeros(n,r);
y_b_nan = ~isnan(y_b(:,t))
y_b(isnan(y_b(:,t))) = 0
for t=1:T
nanYt = sparse(diag(y_b_nan));
denom = denom + kron(Z(:,t+1)*Z(:,t+1)',nanYt);
nom = nom + y_b(:,t)*Zsmooth(r_cb_ind,t+1)';
end
vec_C = denom\nom(:);
C_par = reshape(vec_C,n,r);
The three lines within the cycle need to be called 100 times. And, in particular, the one udating denom takes quite a while (4.5 second) and for repeated calculiations computational time increases too much.
Parallelizing is not an option, because this is a third-level cycle and I need to parallelize at the first (the more external) level.
Any idea or suggestion to speed up here?
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!