46 #ifndef _PEXSI_SPARSE_MATRIX_IMPL_HPP_
47 #define _PEXSI_SPARSE_MATRIX_IMPL_HPP_
63 bool operator() (
int i,
int j) {
return (lookup[i]<lookup[j]);}
72 PushCallStack(
"DistSparseMatrix<F>::SortIndices");
75 for(Int col = 0; col<colptrLocal.m()-1;++col){
76 Int colbeg = colptrLocal[col]-1;
77 Int colend = colptrLocal[col+1]-1;
79 Int numRow = colend - colbeg;
81 std::vector<Int> rowsPerm(numRow);
82 std::vector<Int> rowsSorted(numRow);
83 std::vector<F> valsSorted(numRow);
84 Int * rows = &rowindLocal[colbeg];
85 F * vals = &nzvalLocal[colbeg];
87 for(Int i = 0; i<rowsPerm.size(); ++i){ rowsPerm[i] = i;}
90 std::sort(rowsPerm.begin(),rowsPerm.end(),cmp);
92 for(Int i = 0; i<numRow; ++i){ rowsSorted[i] = rows[rowsPerm[i]]; }
93 std::copy(rowsSorted.begin(),rowsSorted.end(),rows);
95 for(Int i = 0; i<numRow; ++i){ valsSorted[i] = vals[rowsPerm[i]]; }
96 std::copy(valsSorted.begin(),valsSorted.end(),vals);
110 PushCallStack(
"DistSparseMatrix<F>::Nnz");
112 LongInt nnzLocalLong = nnzLocal;
115 MPI_Allreduce( &nnzLocalLong, &nnz, 1, MPI_LONG_LONG, MPI_SUM,
129 PushCallStack(
"DistSparseMatrix<F>::Clear");
156 #endif // _PEXSI_SPARSE_MATRIX_IMPL_HPP_
Definition: sparse_matrix_impl.hpp:60
void SortIndices()
Locally sorts the row indices within every column.
Definition: sparse_matrix_impl.hpp:68
Various utility subroutines.
LongInt Nnz()
Compute the total number of nonzeros through MPI_Allreduce.
Definition: sparse_matrix_impl.hpp:107
void Clear()
Clear all memory (The matrix becomes a 0-by-0 matrix)
Definition: sparse_matrix_impl.hpp:125