Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sparse sparse product A^T*A optim in Eigen lib

In the case of multiple of same matrix matA, like

matA.transpose()*matA, 

You don't have to compute all result product, because the result matrix is symmetric(so only if the m>n), in my specific case is always symmetric! square.

So its enough the compute only for. ex. lower triangular part and rest only copy..... because the results of the multiple 2nd and 3rd row, resp.col, is the same like 3rd and 2nd.....And etc....

So my question is , exist way how to tell Eigen, to compute only lower part. and optionally save to only lower trinaguler part the product?

    DATA = SparseMatrix<double>((SparseMatrix<double>(matA.transpose()) * matA).pruned()).toDense();
like image 539
user2165656 Avatar asked Oct 28 '25 13:10

user2165656


1 Answers

https://eigen.tuxfamily.org/dox/classEigen_1_1SparseSelfAdjointView.html

The symmetric rank update is defined as:

B = B + alpha * A * A^T

where alpha is a scalar. In your case, you are doing A^T * A, so you should pass the transposed matrix instead. The resulting matrix will only store the upper or lower portion of the matrix, whichever you prefer. For example:

SparseMatrix<double> B;
B.selfadjointView<Lower>().rankUpdate(A.transpose());
like image 187
Charlie S Avatar answered Oct 31 '25 03:10

Charlie S