I have a cell array myBasis
of sparse matricies B_1
,...,B_n
.
I want to evaluate with Matlab the matrix Q(i,j) = trace (B^T_i * B_j)
.
Therefore, I wrote the following code:
for i=1:n
for j=1:n
B=myBasis{i};
C=myBasis{j};
Q(i,j)=trace(B'*C);
end
end
Which takes already 68 seconds when n=1226
and B_i
has 50 rows, and 50 colums.
Is there any chance to speed this up? Usually I exclude for-loops from my matlab code in a c++ file - but I have no experience how to handle a sparse cell array in C++.