21 #ifndef SELDON_FILE_SOLVER_ORDERING_CXX
22 #define SELDON_FILE_SOLVER_ORDERING_CXX
25 #include "Ordering.hxx"
33 template<
class T,
class Prop,
class Storage,
class Allocator,
34 class Tint,
class Alloc>
36 Storage, Allocator>& A,
51 ConvertToCSC(A, sym, Ptr, Ind, Value,
true);
68 int nb_active_row = 1;
72 int first_free_row = 1;
79 for (
int i = 0; i < nb_active_row; i++)
82 for (
int j = Ptr(irow); j < Ptr(irow+1); j++)
89 nb_neighbor(nb) = Ptr(icol+1) - Ptr(icol);
99 while (RowUsed(first_free_row))
102 RowUsed(first_free_row) =
true;
103 num(nb_row) = first_free_row;
105 vertex(0) = first_free_row;
112 Sort(nb, nb_neighbor, neighbor);
116 for (
int i = 0; i < nb; i++)
118 vertex(i) = neighbor(i);
119 num(nb_row) = neighbor(i);
126 for (
int i = 0; i < n; i++)
129 for (
int i = 0; i < n; i++)
130 num(n-1-i) = vertex(i);
135 template<
class T,
class Prop,
class Storage,
class Allocator,
136 class Tint,
class Alloc>
148 if (type == SparseMatrixOrdering::AUTO)
150 #if defined(SELDON_WITH_MUMPS) || defined(SELDON_WITH_PASTIX)
151 type = SparseMatrixOrdering::SCOTCH;
152 #elif defined(SELDON_WITH_MUMPS) || defined(SELDON_WITH_PASTIX)
153 type = SparseMatrixOrdering::COLAMD;
155 type = SparseMatrixOrdering::IDENTITY;
161 case SparseMatrixOrdering::IDENTITY :
169 case SparseMatrixOrdering::REVERSE_CUTHILL_MCKEE :
176 case SparseMatrixOrdering::PORD :
179 #ifdef SELDON_WITH_MUMPS
184 throw Error(
"FindSparseOrdering(Matrix&, Vector&, int)",
185 "PORD is supported when Mumps is available.");
190 case SparseMatrixOrdering::SCOTCH :
193 #ifdef SELDON_WITH_PASTIX
196 #elif defined(SELDON_WITH_MUMPS)
201 throw Error(
"FindSparseOrdering(Matrix&, Vector&, int)",
202 "SCOTCH is supported when Mumps or Pastix is available.");
207 case SparseMatrixOrdering::METIS :
210 #ifdef SELDON_WITH_MUMPS
215 throw Error(
"FindSparseOrdering(Matrix&, Vector&, int)",
216 "METIS is supported when Mumps is available.");
221 case SparseMatrixOrdering::AMD :
224 #ifdef SELDON_WITH_UMFPACK
232 ConvertToCSC(A, sym, Ptr, Ind, Value,
true);
238 double Control[CAMD_CONTROL], Info[CAMD_INFO];
239 camd_defaults(Control);
240 camd_order(n, Ptr.GetData(), Ind.GetData(),
241 num.GetData(), Control, Info, C.GetData());
244 throw Error(
"FindSparseOrdering(Matrix&, Vector&, int)",
245 "AMD is supported when UmfPack is available.");
250 case SparseMatrixOrdering::COLAMD :
253 #ifdef SELDON_WITH_UMFPACK
261 ConvertToCSC(A, sym, Ptr, Ind, Value,
true);
264 int nnz = Ind.GetM();
265 Ind.Resize(2*nnz + 12*n);
268 int Stats[COLAMD_STATS];
269 int ok = colamd(n, n, Ind.GetM(), Ind.GetData(), Ptr.GetData(), NULL, Stats);
272 #ifndef SELDON_WITH_SUPERLU_MT
273 colamd_report(Stats);
274 throw Error(
"FindSparseOrdering(Matrix&, Vector&, int)",
279 for (
int i = 0; i < n; i++)
282 throw Error(
"FindSparseOrdering(Matrix&, Vector&, int)",
283 "COLAMD is supported when UmfPack is available.");
288 case SparseMatrixOrdering::QAMD :
291 #ifdef SELDON_WITH_MUMPS
296 throw Error(
"FindSparseOrdering(Matrix&, Vector&, int)",
297 "QAMD is supported when Mumps is available.");
302 case SparseMatrixOrdering::USER :