I have a sparse matrix S.
I perform the following operation
D1 = diag(sum(S,2))
, basically forming a diagonal matrix.
Now I need to perform (D1)^(-0.5)
, but I get an error
"Error using mpower, use full(x)^full(y)"
Converting to full will defeat the purpose of using a spa开发者_Go百科rse matrix.
Any advice will be very helpful.
Raising a diagonal matrix to a power can be done simply by doing the operation on the diagonal elements elementwise... so:
D1_diagonal_elements = sum(S,2);
your_result = diag(D1_diagonal_elements .^ (-0.5));
精彩评论