I wanna to try calculate multiply of three matrix in matlab. The formation of matrices described below:
L = D^(-1/2) * A * D^(-1/2);
D
, A
and L
are a n*n
matrices. A
and L
are not diagonal or sparse but D
is diagonal. In this case n = 16900
. When I calculate L
in matlab, it takes a long time, about 4 hours!
My question is: Is there a more efficient way to calculate L
?
You can use bsxfun
twice. I'm not sure it will be faster or not:
v = diag(D).^(-1/2); %// this is the same as diag(D.^(-1/2))
L = bsxfun(@times, v.', bsxfun(@times, A, v));