Question

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?

Was it helpful?

Solution

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));

OTHER TIPS

Instead of using naive matrix multiplication, you can specialised asymptotically faster ones. Strassen's algorithm comes to mind but if I recall correctly it typically has a high constant, despite it's better asymptotic complexity. If you have a very limited set of possible values in your matrices, you can use a variation of the "four Russians" method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top