Speed up repeated kronecker product
조회 수: 3 (최근 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!