Modify the symmetric permutation to deal with nonsymmetric matrices

This commit is contained in:
Desire NUENTSA 2012-02-10 10:18:38 +01:00
parent 70284b7eff
commit 2ea98594c4

View File

@ -310,9 +310,11 @@ void permute_symm_to_fullsymm(const MatrixType& mat, SparseMatrix<typename Matri
{ {
Index i = it.index(); Index i = it.index();
Index ip = perm ? perm[i] : i; Index ip = perm ? perm[i] : i;
if(i==j) if(UpLo==(Upper|Lower))
count[StorageOrderMatch ? jp : ip]++;
else if(i==j)
count[ip]++; count[ip]++;
else if((UpLo==Lower && i>j) || (UpLo==Upper && i<j)) else if(( UpLo==Lower && i>j) || ( UpLo==Upper && i<j))
{ {
count[ip]++; count[ip]++;
count[jp]++; count[jp]++;
@ -322,7 +324,7 @@ void permute_symm_to_fullsymm(const MatrixType& mat, SparseMatrix<typename Matri
Index nnz = count.sum(); Index nnz = count.sum();
// reserve space // reserve space
dest.reserve(nnz); dest.resizeNonZeros(nnz);
dest.outerIndexPtr()[0] = 0; dest.outerIndexPtr()[0] = 0;
for(Index j=0; j<size; ++j) for(Index j=0; j<size; ++j)
dest.outerIndexPtr()[j+1] = dest.outerIndexPtr()[j] + count[j]; dest.outerIndexPtr()[j+1] = dest.outerIndexPtr()[j] + count[j];
@ -337,15 +339,21 @@ void permute_symm_to_fullsymm(const MatrixType& mat, SparseMatrix<typename Matri
{ {
Index i = it.index(); Index i = it.index();
Index ip = perm ? perm[i] : i; Index ip = perm ? perm[i] : i;
if(i==j) if(UpLo==(Upper|Lower))
{ {
int k = count[ip]++; Index k = count[StorageOrderMatch ? jp : ip]++;
dest.innerIndexPtr()[k] = StorageOrderMatch ? ip : jp;
dest.valuePtr()[k] = it.value();
}
else if(i==j)
{
Index k = count[ip]++;
dest.innerIndexPtr()[k] = ip; dest.innerIndexPtr()[k] = ip;
dest.valuePtr()[k] = it.value(); dest.valuePtr()[k] = it.value();
} }
else if((UpLo==Lower && i>j) || (UpLo==Upper && i<j)) else if(( (UpLo&Lower)==Lower && i>j) || ( (UpLo&Upper)==Upper && i<j))
{ {
int k = count[jp]++; Index k = count[jp]++;
dest.innerIndexPtr()[k] = ip; dest.innerIndexPtr()[k] = ip;
dest.valuePtr()[k] = it.value(); dest.valuePtr()[k] = it.value();
k = count[ip]++; k = count[ip]++;