42 #ifndef GETFEM_SUPERLU
43 #define GETFEM_SUPERLU
44 #ifndef GMM_USES_SUPERLU
45 #define GMM_USES_SUPERLU
53 int SuperLU_solve(
const gmm::csc_matrix<T> &A, T *X_, T *B,
double& rcond_,
int permc_spec = 3);
63 template<
typename MAT,
typename V1,
typename V2>
64 int SuperLU_solve(
const MAT &A,
const V1& X,
const V2& B,
double& rcond_,
int permc_spec = 3) {
65 typedef typename gmm::linalg_traits<MAT>::value_type T;
67 int m = int(mat_nrows(A)), n = int(mat_ncols(A));
68 gmm::csc_matrix<T> csc_A(m,n);
70 std::vector<T> rhs(m), sol(m);
73 int info = SuperLU_solve(csc_A, &sol[0], &rhs[0], rcond_, permc_spec);
74 gmm::copy(sol,
const_cast<V1 &
>(X));
78 struct SuperLU_factor_impl_common;
85 std::shared_ptr<SuperLU_factor_impl_common> impl;
87 enum { LU_NOTRANSP, LU_TRANSP, LU_CONJUGATED };
90 template <
class MAT>
void build_with(
const MAT &A,
int permc_spec = 3) {
91 int m = int(mat_nrows(A)), n = int(mat_ncols(A));
92 gmm::csc_matrix<T> csc_A(m,n);
96 void build_with(
const gmm::csc_matrix<T> &A,
int permc_spec = 3);
97 template <
typename VECTX,
typename VECTB>
103 void solve(
const VECTX &X,
const VECTB &B,
int transp=LU_NOTRANSP)
const {
106 gmm::copy(sol(),
const_cast<VECTX &
>(X));
108 void solve(
int transp=LU_NOTRANSP)
const;
109 std::vector<T> &sol()
const;
110 std::vector<T> &rhs()
const;
112 float memsize()
const;
117 template <
typename T,
typename V1,
typename V2>
inline
118 void mult(
const SuperLU_factor<T>& P,
const V1 &v1,
const V2 &v2) {
122 template <
typename T,
typename V1,
typename V2>
inline
123 void transposed_mult(
const SuperLU_factor<T>& P,
const V1 &v1,
const V2 &v2) {
124 P.solve(v2, v1, SuperLU_factor<T>::LU_TRANSP);
128 extern "C" void set_superlu_callback(
int (*cb)());