Eigen  3.4.90 (git rev 5a9f66fb35d03a4da9ef8976e67a61b30aa16dcf)
 
Loading...
Searching...
No Matches
UmfPackSupport.h
1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2008-2011 Gael Guennebaud <[email protected]>
5//
6// This Source Code Form is subject to the terms of the Mozilla
7// Public License v. 2.0. If a copy of the MPL was not distributed
8// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
10#ifndef EIGEN_UMFPACKSUPPORT_H
11#define EIGEN_UMFPACKSUPPORT_H
12
13// for compatibility with super old version of umfpack,
14// not sure this is really needed, but this is harmless.
15#ifndef SuiteSparse_long
16#ifdef UF_long
17#define SuiteSparse_long UF_long
18#else
19#error neither SuiteSparse_long nor UF_long are defined
20#endif
21#endif
22
23// IWYU pragma: private
24#include "./InternalHeaderCheck.h"
25
26namespace Eigen {
27
28/* TODO extract L, extract U, compute det, etc... */
29
30// generic double/complex<double> wrapper functions:
31
32// Defaults
33inline void umfpack_defaults(double control[UMFPACK_CONTROL], double, int) { umfpack_di_defaults(control); }
34
35inline void umfpack_defaults(double control[UMFPACK_CONTROL], std::complex<double>, int) {
36 umfpack_zi_defaults(control);
37}
38
39inline void umfpack_defaults(double control[UMFPACK_CONTROL], double, SuiteSparse_long) {
40 umfpack_dl_defaults(control);
41}
42
43inline void umfpack_defaults(double control[UMFPACK_CONTROL], std::complex<double>, SuiteSparse_long) {
44 umfpack_zl_defaults(control);
45}
46
47// Report info
48inline void umfpack_report_info(double control[UMFPACK_CONTROL], double info[UMFPACK_INFO], double, int) {
49 umfpack_di_report_info(control, info);
50}
51
52inline void umfpack_report_info(double control[UMFPACK_CONTROL], double info[UMFPACK_INFO], std::complex<double>, int) {
53 umfpack_zi_report_info(control, info);
54}
55
56inline void umfpack_report_info(double control[UMFPACK_CONTROL], double info[UMFPACK_INFO], double, SuiteSparse_long) {
57 umfpack_dl_report_info(control, info);
58}
59
60inline void umfpack_report_info(double control[UMFPACK_CONTROL], double info[UMFPACK_INFO], std::complex<double>,
61 SuiteSparse_long) {
62 umfpack_zl_report_info(control, info);
63}
64
65// Report status
66inline void umfpack_report_status(double control[UMFPACK_CONTROL], int status, double, int) {
67 umfpack_di_report_status(control, status);
68}
69
70inline void umfpack_report_status(double control[UMFPACK_CONTROL], int status, std::complex<double>, int) {
71 umfpack_zi_report_status(control, status);
72}
73
74inline void umfpack_report_status(double control[UMFPACK_CONTROL], int status, double, SuiteSparse_long) {
75 umfpack_dl_report_status(control, status);
76}
77
78inline void umfpack_report_status(double control[UMFPACK_CONTROL], int status, std::complex<double>, SuiteSparse_long) {
79 umfpack_zl_report_status(control, status);
80}
81
82// report control
83inline void umfpack_report_control(double control[UMFPACK_CONTROL], double, int) { umfpack_di_report_control(control); }
84
85inline void umfpack_report_control(double control[UMFPACK_CONTROL], std::complex<double>, int) {
86 umfpack_zi_report_control(control);
87}
88
89inline void umfpack_report_control(double control[UMFPACK_CONTROL], double, SuiteSparse_long) {
90 umfpack_dl_report_control(control);
91}
92
93inline void umfpack_report_control(double control[UMFPACK_CONTROL], std::complex<double>, SuiteSparse_long) {
94 umfpack_zl_report_control(control);
95}
96
97// Free numeric
98inline void umfpack_free_numeric(void **Numeric, double, int) {
99 umfpack_di_free_numeric(Numeric);
100 *Numeric = 0;
101}
102
103inline void umfpack_free_numeric(void **Numeric, std::complex<double>, int) {
104 umfpack_zi_free_numeric(Numeric);
105 *Numeric = 0;
106}
107
108inline void umfpack_free_numeric(void **Numeric, double, SuiteSparse_long) {
109 umfpack_dl_free_numeric(Numeric);
110 *Numeric = 0;
111}
112
113inline void umfpack_free_numeric(void **Numeric, std::complex<double>, SuiteSparse_long) {
114 umfpack_zl_free_numeric(Numeric);
115 *Numeric = 0;
116}
117
118// Free symbolic
119inline void umfpack_free_symbolic(void **Symbolic, double, int) {
120 umfpack_di_free_symbolic(Symbolic);
121 *Symbolic = 0;
122}
123
124inline void umfpack_free_symbolic(void **Symbolic, std::complex<double>, int) {
125 umfpack_zi_free_symbolic(Symbolic);
126 *Symbolic = 0;
127}
128
129inline void umfpack_free_symbolic(void **Symbolic, double, SuiteSparse_long) {
130 umfpack_dl_free_symbolic(Symbolic);
131 *Symbolic = 0;
132}
133
134inline void umfpack_free_symbolic(void **Symbolic, std::complex<double>, SuiteSparse_long) {
135 umfpack_zl_free_symbolic(Symbolic);
136 *Symbolic = 0;
137}
138
139// Symbolic
140inline int umfpack_symbolic(int n_row, int n_col, const int Ap[], const int Ai[], const double Ax[], void **Symbolic,
141 const double Control[UMFPACK_CONTROL], double Info[UMFPACK_INFO]) {
142 return umfpack_di_symbolic(n_row, n_col, Ap, Ai, Ax, Symbolic, Control, Info);
143}
144
145inline int umfpack_symbolic(int n_row, int n_col, const int Ap[], const int Ai[], const std::complex<double> Ax[],
146 void **Symbolic, const double Control[UMFPACK_CONTROL], double Info[UMFPACK_INFO]) {
147 return umfpack_zi_symbolic(n_row, n_col, Ap, Ai, &numext::real_ref(Ax[0]), 0, Symbolic, Control, Info);
148}
149inline SuiteSparse_long umfpack_symbolic(SuiteSparse_long n_row, SuiteSparse_long n_col, const SuiteSparse_long Ap[],
150 const SuiteSparse_long Ai[], const double Ax[], void **Symbolic,
151 const double Control[UMFPACK_CONTROL], double Info[UMFPACK_INFO]) {
152 return umfpack_dl_symbolic(n_row, n_col, Ap, Ai, Ax, Symbolic, Control, Info);
153}
154
155inline SuiteSparse_long umfpack_symbolic(SuiteSparse_long n_row, SuiteSparse_long n_col, const SuiteSparse_long Ap[],
156 const SuiteSparse_long Ai[], const std::complex<double> Ax[], void **Symbolic,
157 const double Control[UMFPACK_CONTROL], double Info[UMFPACK_INFO]) {
158 return umfpack_zl_symbolic(n_row, n_col, Ap, Ai, &numext::real_ref(Ax[0]), 0, Symbolic, Control, Info);
159}
160
161// Numeric
162inline int umfpack_numeric(const int Ap[], const int Ai[], const double Ax[], void *Symbolic, void **Numeric,
163 const double Control[UMFPACK_CONTROL], double Info[UMFPACK_INFO]) {
164 return umfpack_di_numeric(Ap, Ai, Ax, Symbolic, Numeric, Control, Info);
165}
166
167inline int umfpack_numeric(const int Ap[], const int Ai[], const std::complex<double> Ax[], void *Symbolic,
168 void **Numeric, const double Control[UMFPACK_CONTROL], double Info[UMFPACK_INFO]) {
169 return umfpack_zi_numeric(Ap, Ai, &numext::real_ref(Ax[0]), 0, Symbolic, Numeric, Control, Info);
170}
171inline SuiteSparse_long umfpack_numeric(const SuiteSparse_long Ap[], const SuiteSparse_long Ai[], const double Ax[],
172 void *Symbolic, void **Numeric, const double Control[UMFPACK_CONTROL],
173 double Info[UMFPACK_INFO]) {
174 return umfpack_dl_numeric(Ap, Ai, Ax, Symbolic, Numeric, Control, Info);
175}
176
177inline SuiteSparse_long umfpack_numeric(const SuiteSparse_long Ap[], const SuiteSparse_long Ai[],
178 const std::complex<double> Ax[], void *Symbolic, void **Numeric,
179 const double Control[UMFPACK_CONTROL], double Info[UMFPACK_INFO]) {
180 return umfpack_zl_numeric(Ap, Ai, &numext::real_ref(Ax[0]), 0, Symbolic, Numeric, Control, Info);
181}
182
183// solve
184inline int umfpack_solve(int sys, const int Ap[], const int Ai[], const double Ax[], double X[], const double B[],
185 void *Numeric, const double Control[UMFPACK_CONTROL], double Info[UMFPACK_INFO]) {
186 return umfpack_di_solve(sys, Ap, Ai, Ax, X, B, Numeric, Control, Info);
187}
188
189inline int umfpack_solve(int sys, const int Ap[], const int Ai[], const std::complex<double> Ax[],
190 std::complex<double> X[], const std::complex<double> B[], void *Numeric,
191 const double Control[UMFPACK_CONTROL], double Info[UMFPACK_INFO]) {
192 return umfpack_zi_solve(sys, Ap, Ai, &numext::real_ref(Ax[0]), 0, &numext::real_ref(X[0]), 0, &numext::real_ref(B[0]),
193 0, Numeric, Control, Info);
194}
195
196inline SuiteSparse_long umfpack_solve(int sys, const SuiteSparse_long Ap[], const SuiteSparse_long Ai[],
197 const double Ax[], double X[], const double B[], void *Numeric,
198 const double Control[UMFPACK_CONTROL], double Info[UMFPACK_INFO]) {
199 return umfpack_dl_solve(sys, Ap, Ai, Ax, X, B, Numeric, Control, Info);
200}
201
202inline SuiteSparse_long umfpack_solve(int sys, const SuiteSparse_long Ap[], const SuiteSparse_long Ai[],
203 const std::complex<double> Ax[], std::complex<double> X[],
204 const std::complex<double> B[], void *Numeric,
205 const double Control[UMFPACK_CONTROL], double Info[UMFPACK_INFO]) {
206 return umfpack_zl_solve(sys, Ap, Ai, &numext::real_ref(Ax[0]), 0, &numext::real_ref(X[0]), 0, &numext::real_ref(B[0]),
207 0, Numeric, Control, Info);
208}
209
210// Get Lunz
211inline int umfpack_get_lunz(int *lnz, int *unz, int *n_row, int *n_col, int *nz_udiag, void *Numeric, double) {
212 return umfpack_di_get_lunz(lnz, unz, n_row, n_col, nz_udiag, Numeric);
213}
214
215inline int umfpack_get_lunz(int *lnz, int *unz, int *n_row, int *n_col, int *nz_udiag, void *Numeric,
216 std::complex<double>) {
217 return umfpack_zi_get_lunz(lnz, unz, n_row, n_col, nz_udiag, Numeric);
218}
219
220inline SuiteSparse_long umfpack_get_lunz(SuiteSparse_long *lnz, SuiteSparse_long *unz, SuiteSparse_long *n_row,
221 SuiteSparse_long *n_col, SuiteSparse_long *nz_udiag, void *Numeric, double) {
222 return umfpack_dl_get_lunz(lnz, unz, n_row, n_col, nz_udiag, Numeric);
223}
224
225inline SuiteSparse_long umfpack_get_lunz(SuiteSparse_long *lnz, SuiteSparse_long *unz, SuiteSparse_long *n_row,
226 SuiteSparse_long *n_col, SuiteSparse_long *nz_udiag, void *Numeric,
227 std::complex<double>) {
228 return umfpack_zl_get_lunz(lnz, unz, n_row, n_col, nz_udiag, Numeric);
229}
230
231// Get Numeric
232inline int umfpack_get_numeric(int Lp[], int Lj[], double Lx[], int Up[], int Ui[], double Ux[], int P[], int Q[],
233 double Dx[], int *do_recip, double Rs[], void *Numeric) {
234 return umfpack_di_get_numeric(Lp, Lj, Lx, Up, Ui, Ux, P, Q, Dx, do_recip, Rs, Numeric);
235}
236
237inline int umfpack_get_numeric(int Lp[], int Lj[], std::complex<double> Lx[], int Up[], int Ui[],
238 std::complex<double> Ux[], int P[], int Q[], std::complex<double> Dx[], int *do_recip,
239 double Rs[], void *Numeric) {
240 double &lx0_real = numext::real_ref(Lx[0]);
241 double &ux0_real = numext::real_ref(Ux[0]);
242 double &dx0_real = numext::real_ref(Dx[0]);
243 return umfpack_zi_get_numeric(Lp, Lj, Lx ? &lx0_real : 0, 0, Up, Ui, Ux ? &ux0_real : 0, 0, P, Q, Dx ? &dx0_real : 0,
244 0, do_recip, Rs, Numeric);
245}
246inline SuiteSparse_long umfpack_get_numeric(SuiteSparse_long Lp[], SuiteSparse_long Lj[], double Lx[],
247 SuiteSparse_long Up[], SuiteSparse_long Ui[], double Ux[],
248 SuiteSparse_long P[], SuiteSparse_long Q[], double Dx[],
249 SuiteSparse_long *do_recip, double Rs[], void *Numeric) {
250 return umfpack_dl_get_numeric(Lp, Lj, Lx, Up, Ui, Ux, P, Q, Dx, do_recip, Rs, Numeric);
251}
252
253inline SuiteSparse_long umfpack_get_numeric(SuiteSparse_long Lp[], SuiteSparse_long Lj[], std::complex<double> Lx[],
254 SuiteSparse_long Up[], SuiteSparse_long Ui[], std::complex<double> Ux[],
255 SuiteSparse_long P[], SuiteSparse_long Q[], std::complex<double> Dx[],
256 SuiteSparse_long *do_recip, double Rs[], void *Numeric) {
257 double &lx0_real = numext::real_ref(Lx[0]);
258 double &ux0_real = numext::real_ref(Ux[0]);
259 double &dx0_real = numext::real_ref(Dx[0]);
260 return umfpack_zl_get_numeric(Lp, Lj, Lx ? &lx0_real : 0, 0, Up, Ui, Ux ? &ux0_real : 0, 0, P, Q, Dx ? &dx0_real : 0,
261 0, do_recip, Rs, Numeric);
262}
263
264// Get Determinant
265inline int umfpack_get_determinant(double *Mx, double *Ex, void *NumericHandle, double User_Info[UMFPACK_INFO], int) {
266 return umfpack_di_get_determinant(Mx, Ex, NumericHandle, User_Info);
267}
268
269inline int umfpack_get_determinant(std::complex<double> *Mx, double *Ex, void *NumericHandle,
270 double User_Info[UMFPACK_INFO], int) {
271 double &mx_real = numext::real_ref(*Mx);
272 return umfpack_zi_get_determinant(&mx_real, 0, Ex, NumericHandle, User_Info);
273}
274
275inline SuiteSparse_long umfpack_get_determinant(double *Mx, double *Ex, void *NumericHandle,
276 double User_Info[UMFPACK_INFO], SuiteSparse_long) {
277 return umfpack_dl_get_determinant(Mx, Ex, NumericHandle, User_Info);
278}
279
280inline SuiteSparse_long umfpack_get_determinant(std::complex<double> *Mx, double *Ex, void *NumericHandle,
281 double User_Info[UMFPACK_INFO], SuiteSparse_long) {
282 double &mx_real = numext::real_ref(*Mx);
283 return umfpack_zl_get_determinant(&mx_real, 0, Ex, NumericHandle, User_Info);
284}
285
301template <typename MatrixType_>
302class UmfPackLU : public SparseSolverBase<UmfPackLU<MatrixType_> > {
303 protected:
305 using Base::m_isInitialized;
306
307 public:
308 using Base::_solve_impl;
309 typedef MatrixType_ MatrixType;
310 typedef typename MatrixType::Scalar Scalar;
311 typedef typename MatrixType::RealScalar RealScalar;
312 typedef typename MatrixType::StorageIndex StorageIndex;
319 enum { ColsAtCompileTime = MatrixType::ColsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime };
320
321 public:
324
325 UmfPackLU() : m_dummy(0, 0), mp_matrix(m_dummy) { init(); }
326
327 template <typename InputMatrixType>
328 explicit UmfPackLU(const InputMatrixType &matrix) : mp_matrix(matrix) {
329 init();
330 compute(matrix);
331 }
332
333 ~UmfPackLU() {
334 if (m_symbolic) umfpack_free_symbolic(&m_symbolic, Scalar(), StorageIndex());
335 if (m_numeric) umfpack_free_numeric(&m_numeric, Scalar(), StorageIndex());
336 }
337
338 inline Index rows() const { return mp_matrix.rows(); }
339 inline Index cols() const { return mp_matrix.cols(); }
340
347 eigen_assert(m_isInitialized && "Decomposition is not initialized.");
348 return m_info;
349 }
350
351 inline const LUMatrixType &matrixL() const {
352 if (m_extractedDataAreDirty) extractData();
353 return m_l;
354 }
355
356 inline const LUMatrixType &matrixU() const {
357 if (m_extractedDataAreDirty) extractData();
358 return m_u;
359 }
360
361 inline const IntColVectorType &permutationP() const {
362 if (m_extractedDataAreDirty) extractData();
363 return m_p;
364 }
365
366 inline const IntRowVectorType &permutationQ() const {
367 if (m_extractedDataAreDirty) extractData();
368 return m_q;
369 }
370
375 template <typename InputMatrixType>
376 void compute(const InputMatrixType &matrix) {
377 if (m_symbolic) umfpack_free_symbolic(&m_symbolic, Scalar(), StorageIndex());
378 if (m_numeric) umfpack_free_numeric(&m_numeric, Scalar(), StorageIndex());
379 grab(matrix.derived());
380 analyzePattern_impl();
381 factorize_impl();
382 }
383
390 template <typename InputMatrixType>
391 void analyzePattern(const InputMatrixType &matrix) {
392 if (m_symbolic) umfpack_free_symbolic(&m_symbolic, Scalar(), StorageIndex());
393 if (m_numeric) umfpack_free_numeric(&m_numeric, Scalar(), StorageIndex());
394
395 grab(matrix.derived());
396
397 analyzePattern_impl();
398 }
399
405 inline int umfpackFactorizeReturncode() const {
406 eigen_assert(m_numeric && "UmfPackLU: you must first call factorize()");
407 return m_fact_errorCode;
408 }
409
416 inline const UmfpackControl &umfpackControl() const { return m_control; }
417
424 inline UmfpackControl &umfpackControl() { return m_control; }
425
432 template <typename InputMatrixType>
433 void factorize(const InputMatrixType &matrix) {
434 eigen_assert(m_analysisIsOk && "UmfPackLU: you must first call analyzePattern()");
435 if (m_numeric) umfpack_free_numeric(&m_numeric, Scalar(), StorageIndex());
436
437 grab(matrix.derived());
438
439 factorize_impl();
440 }
441
446 void printUmfpackControl() { umfpack_report_control(m_control.data(), Scalar(), StorageIndex()); }
447
453 eigen_assert(m_analysisIsOk && "UmfPackLU: you must first call analyzePattern()");
454 umfpack_report_info(m_control.data(), m_umfpackInfo.data(), Scalar(), StorageIndex());
455 }
456
463 eigen_assert(m_analysisIsOk && "UmfPackLU: you must first call analyzePattern()");
464 umfpack_report_status(m_control.data(), m_fact_errorCode, Scalar(), StorageIndex());
465 }
466
468 template <typename BDerived, typename XDerived>
469 bool _solve_impl(const MatrixBase<BDerived> &b, MatrixBase<XDerived> &x) const;
470
471 Scalar determinant() const;
472
473 void extractData() const;
474
475 protected:
476 void init() {
477 m_info = InvalidInput;
478 m_isInitialized = false;
479 m_numeric = 0;
480 m_symbolic = 0;
481 m_extractedDataAreDirty = true;
482
483 umfpack_defaults(m_control.data(), Scalar(), StorageIndex());
484 }
485
486 void analyzePattern_impl() {
487 m_fact_errorCode = umfpack_symbolic(internal::convert_index<StorageIndex>(mp_matrix.rows()),
488 internal::convert_index<StorageIndex>(mp_matrix.cols()),
489 mp_matrix.outerIndexPtr(), mp_matrix.innerIndexPtr(), mp_matrix.valuePtr(),
490 &m_symbolic, m_control.data(), m_umfpackInfo.data());
491
492 m_isInitialized = true;
493 m_info = m_fact_errorCode ? InvalidInput : Success;
494 m_analysisIsOk = true;
495 m_factorizationIsOk = false;
496 m_extractedDataAreDirty = true;
497 }
498
499 void factorize_impl() {
500 m_fact_errorCode = umfpack_numeric(mp_matrix.outerIndexPtr(), mp_matrix.innerIndexPtr(), mp_matrix.valuePtr(),
501 m_symbolic, &m_numeric, m_control.data(), m_umfpackInfo.data());
502
503 m_info = m_fact_errorCode == UMFPACK_OK ? Success : NumericalIssue;
504 m_factorizationIsOk = true;
505 m_extractedDataAreDirty = true;
506 }
507
508 template <typename MatrixDerived>
509 void grab(const EigenBase<MatrixDerived> &A) {
510 internal::destroy_at(&mp_matrix);
511 internal::construct_at(&mp_matrix, A.derived());
512 }
513
514 void grab(const UmfpackMatrixRef &A) {
515 if (&(A.derived()) != &mp_matrix) {
516 internal::destroy_at(&mp_matrix);
517 internal::construct_at(&mp_matrix, A);
518 }
519 }
520
521 // cached data to reduce reallocation, etc.
522 mutable LUMatrixType m_l;
523 StorageIndex m_fact_errorCode;
524 UmfpackControl m_control;
525 mutable UmfpackInfo m_umfpackInfo;
526
527 mutable LUMatrixType m_u;
528 mutable IntColVectorType m_p;
529 mutable IntRowVectorType m_q;
530
531 UmfpackMatrixType m_dummy;
532 UmfpackMatrixRef mp_matrix;
533
534 void *m_numeric;
535 void *m_symbolic;
536
537 mutable ComputationInfo m_info;
538 int m_factorizationIsOk;
539 int m_analysisIsOk;
540 mutable bool m_extractedDataAreDirty;
541
542 private:
543 UmfPackLU(const UmfPackLU &) {}
544};
545
546template <typename MatrixType>
547void UmfPackLU<MatrixType>::extractData() const {
548 if (m_extractedDataAreDirty) {
549 // get size of the data
550 StorageIndex lnz, unz, rows, cols, nz_udiag;
551 umfpack_get_lunz(&lnz, &unz, &rows, &cols, &nz_udiag, m_numeric, Scalar());
552
553 // allocate data
554 m_l.resize(rows, (std::min)(rows, cols));
555 m_l.resizeNonZeros(lnz);
556
557 m_u.resize((std::min)(rows, cols), cols);
558 m_u.resizeNonZeros(unz);
559
560 m_p.resize(rows);
561 m_q.resize(cols);
562
563 // extract
564 umfpack_get_numeric(m_l.outerIndexPtr(), m_l.innerIndexPtr(), m_l.valuePtr(), m_u.outerIndexPtr(),
565 m_u.innerIndexPtr(), m_u.valuePtr(), m_p.data(), m_q.data(), 0, 0, 0, m_numeric);
566
567 m_extractedDataAreDirty = false;
568 }
569}
570
571template <typename MatrixType>
572typename UmfPackLU<MatrixType>::Scalar UmfPackLU<MatrixType>::determinant() const {
573 Scalar det;
574 umfpack_get_determinant(&det, 0, m_numeric, 0, StorageIndex());
575 return det;
576}
577
578template <typename MatrixType>
579template <typename BDerived, typename XDerived>
580bool UmfPackLU<MatrixType>::_solve_impl(const MatrixBase<BDerived> &b, MatrixBase<XDerived> &x) const {
581 Index rhsCols = b.cols();
582 eigen_assert((BDerived::Flags & RowMajorBit) == 0 && "UmfPackLU backend does not support non col-major rhs yet");
583 eigen_assert((XDerived::Flags & RowMajorBit) == 0 && "UmfPackLU backend does not support non col-major result yet");
584 eigen_assert(b.derived().data() != x.derived().data() && " Umfpack does not support inplace solve");
585
586 Scalar *x_ptr = 0;
587 Matrix<Scalar, Dynamic, 1> x_tmp;
588 if (x.innerStride() != 1) {
589 x_tmp.resize(x.rows());
590 x_ptr = x_tmp.data();
591 }
592 for (int j = 0; j < rhsCols; ++j) {
593 if (x.innerStride() == 1) x_ptr = &x.col(j).coeffRef(0);
594 StorageIndex errorCode =
595 umfpack_solve(UMFPACK_A, mp_matrix.outerIndexPtr(), mp_matrix.innerIndexPtr(), mp_matrix.valuePtr(), x_ptr,
596 &b.const_cast_derived().col(j).coeffRef(0), m_numeric, m_control.data(), m_umfpackInfo.data());
597 if (x.innerStride() != 1) x.col(j) = x_tmp;
598 if (errorCode != 0) return false;
599 }
600
601 return true;
602}
603
604} // end namespace Eigen
605
606#endif // EIGEN_UMFPACKSUPPORT_H
General-purpose arrays with easy API for coefficient-wise operations.
Definition Array.h:48
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:52
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:186
const Scalar * data() const
Definition PlainObjectBase.h:273
A matrix or vector expression mapping an existing expression.
Definition Ref.h:264
A versatible sparse matrix representation.
Definition SparseUtil.h:47
A base class for sparse solvers.
Definition SparseSolverBase.h:67
A sparse LU factorization and solver based on UmfPack.
Definition UmfPackSupport.h:302
void printUmfpackControl()
Definition UmfPackSupport.h:446
void compute(const InputMatrixType &matrix)
Definition UmfPackSupport.h:376
void factorize(const InputMatrixType &matrix)
Definition UmfPackSupport.h:433
int umfpackFactorizeReturncode() const
Definition UmfPackSupport.h:405
ComputationInfo info() const
Reports whether previous computation was successful.
Definition UmfPackSupport.h:346
UmfpackControl & umfpackControl()
Definition UmfPackSupport.h:424
void printUmfpackInfo()
Definition UmfPackSupport.h:452
const UmfpackControl & umfpackControl() const
Definition UmfPackSupport.h:416
void analyzePattern(const InputMatrixType &matrix)
Definition UmfPackSupport.h:391
void printUmfpackStatus()
Definition UmfPackSupport.h:462
ComputationInfo
Definition Constants.h:438
@ NumericalIssue
Definition Constants.h:442
@ InvalidInput
Definition Constants.h:447
@ Success
Definition Constants.h:440
Namespace containing all symbols from the Eigen library.
Definition Core:137
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:83