20 #ifndef SELDON_FILE_PARDISO_CXX
22 #include "Pardiso.hxx"
52 if (
sizeof(pardiso_int_t) == 8)
67 pardiso_int_t nrhs = 0;
68 pardiso_int_t phase = 0, error;
70 call_pardiso(pt, &maxfct, &mnum, &mtype, &phase, &size_matrix,
71 valA.GetData(), ptrA.GetData(), indA.GetData(),
72 perm.GetData(), &nrhs, iparm, &msglvl,
73 &ddum, &ddum, &error);
103 perm.Reallocate(permut.GetM());
104 for (
int i = 0; i < perm.GetM(); i++)
105 perm(i) = permut(i) + 1;
137 size_t taille =
sizeof(pardiso_int_t)*ptrA.GetM();
138 if (size_matrix <= 0)
141 taille +=
sizeof(pardiso_int_t)*indA.GetM();
142 taille +=
sizeof(T)*valA.GetM();
143 taille +=
sizeof(pardiso_int_t)*perm.GetM();
144 taille += 1024*size_t(iparm[15]+iparm[16]);
150 template<
class T>
template<
class T0,
class Prop,
class Storage,
class Allocator>
159 ConvertToCSR(mat, prop, ptrA, indA, valA);
177 ptrA.SetData(Ptr); Ptr.Nullify();
178 indA.SetData(IndCol); IndCol.Nullify();
179 valA.SetData(Values); Values.Nullify();
190 size_matrix = ptrA.GetM()-1;
191 if (size_matrix <= 0)
196 pardiso_int_t nrhs = 0;
234 pardiso_int_t error = 0;
int mtype_ = mtype;
235 int iparm_[64]; iparm_[0] = 0; iparm_[2] = 1;
236 pardisoinit(pt, &mtype_, iparm_);
238 for (
int i = 0; i < 64; i++)
239 iparm[i] = iparm_[i];
241 for (
int i = 0; i < ptrA.GetM(); i++)
244 for (
int i = 0; i < indA.GetM(); i++)
248 if (perm.GetM() == size_matrix)
251 iparm[1] = type_ordering;
254 pardiso_int_t phase = 11;
256 call_pardiso(pt, &maxfct, &mnum, &mtype, &phase, &size_matrix,
257 valA.GetData(), ptrA.GetData(), indA.GetData(),
258 perm.GetData(), &nrhs, iparm, &msglvl,
259 &ddum, &ddum, &error);
275 cout <<
"Reordering completed" << endl;
276 cout <<
"Number of non-zero factors = " << iparm[17] << endl;
277 cout <<
"Number of factorization MFLOPS = " << iparm[18] << endl;
283 call_pardiso(pt, &maxfct, &mnum, &mtype, &phase, &size_matrix,
284 valA.GetData(), ptrA.GetData(), indA.GetData(),
285 perm.GetData(), &nrhs, iparm, &msglvl,
286 &ddum, &ddum, &error);
297 cout <<
"Error during factorization " << error << endl;
302 cout <<
"Factorization completed" << endl;
307 template<
class T>
template<
class Allocator2>
310 Solve(SeldonNoTrans, x);
316 template<
class T>
template<
class Allocator2>
320 Solve(TransA, x.GetData(), 1);
330 if (size_matrix <= 0)
334 for (
int i = 0; i < size_matrix; i++)
335 for (
int j = 0; j < nrhs_; j++)
336 b(i, j) = x_ptr[i+j*size_matrix];
338 pardiso_int_t nrhs = nrhs_;
340 pardiso_int_t phase = 33, error;
348 call_pardiso(pt, &maxfct, &mnum, &mtype, &phase, &size_matrix,
349 valA.GetData(), ptrA.GetData(), indA.GetData(),
350 perm.GetData(), &nrhs, iparm, &msglvl,
351 b.GetData(), x_ptr, &error);
364 template<
class Allocator2,
class Prop>
368 Solve(TransA, x.GetData(), x.GetN());
373 template<
class MatrixSparse,
class T>
381 template<
class MatrixSparse,
class T>
383 bool keep_matrix, complex<T>& x)
385 throw WrongArgument(
"GetLU(Matrix<complex<T> >& A, MatrixPardiso<T>& mat_lu, bool)",
386 "The LU matrix must be complex");
391 template<
class MatrixSparse,
class T>
393 bool keep_matrix, T& x)
395 throw WrongArgument(
"GetLU(Matrix<T>& A, MatrixPardiso<complex<T> >& mat_lu, bool)",
396 "The sparse matrix must be complex");
401 template<
class T0,
class Prop,
class Storage,
class Allocator,
class T>
411 GetLU(A, mat_lu, keep_matrix, x);
416 template<
class T,
class Allocator>
425 template<
class T,
class Allocator>
429 mat_lu.
Solve(TransA, x);
434 template<
class T,
class Prop,
class Allocator>
438 mat_lu.
Solve(SeldonNoTrans, x);
444 template<
class T,
class Allocator,
class Prop>
448 mat_lu.
Solve(TransA, x);
453 template<
class Allocator>
459 for (
int i = 0; i < x.GetM(); i++)
461 y(i, 0) = real(x(i));
462 y(i, 1) = imag(x(i));
467 for (
int i = 0; i < x.GetM(); i++)
468 x(i) = complex<double>(y(i, 0), y(i, 1));
473 template<
class Allocator>
480 for (
int i = 0; i < x.GetM(); i++)
482 y(i, 0) = real(x(i));
483 y(i, 1) = imag(x(i));
486 SolveLU(TransA, mat_lu, y);
488 for (
int i = 0; i < x.GetM(); i++)
489 x(i) = complex<double>(y(i, 0), y(i, 1));
494 template<
class Allocator>
498 throw WrongArgument(
"SolveLU(MatrixPardiso<complex<double> >, Vector<double>)",
499 "The result should be a complex vector");
504 template<
class Allocator>
509 throw WrongArgument(
"SolveLU(MatrixPardiso<complex<double> >, Vector<double>)",
510 "The result should be a complex vector");
515 #define SELDON_FILE_PARDISO_CXX