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();
According to the documentation, you can evaluate the lower triangle of a matrix with:
or in your case:
(where it says "Writing to a specific triangular part: (only the referenced triangular part is evaluated)"). Otherwise, in the line you've written Eigen will calculate the entire sparse matrix
matA.transpose()*matA
.Regarding saving the resulting
m1
matrix, it is the same as saving whatever type of matrix it is (Eigen::MatrixXt
orEigen::SparseMatrix<t>
). Ifm1
is sparse, then it will be only half the size of a straightforwardmatA.transpose()*matA
. Ifm1
is dense, then it will be the full square matrix.