Reputation: 1942
As the subject line suggests, what would be the most efficient way to copy the lower triangular part of a sparse matrix to the upper triangular part and complete the matrix entries to create the symmetric sparse matrix?
Assume that I have the triplets I, J, X for the lower triangle including the diagonal. I am reading these arrays from a commercial program and for storage space reasons, I believe, they only store the lower triangular part.
Well I will start testing different options soon, but wanted to see if someone else has experienced this before or not.
Upvotes: 1
Views: 452
Reputation: 11
Another way to appraoch this problem, which is what I usually do, is to use the following code:
L = sparse(I, J, X, n, n);
S = L + L' - diag(L);
Where L
is the lower-triangular matrix, S
is the required symmetric matrix, and n
is the number of rows/columns of the full square matrix.
Upvotes: 1