Hex: src/factorizers/lu-umfpack.h Source File

| Hex 2.2 Hydrogen-electron collision solver

lu-umfpack.h
Go to the documentation of this file.
1 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
2 // //
3 // / / / / __ \ \ / / //
4 // / /__ / / / _ \ \ \/ / //
5 // / ___ / | |/_/ / /\ \ //
6 // / / / / \_\ / / \ \ //
7 // //
8 // //
9 // Copyright (c) 2016, Jakub Benda, Charles University in Prague //
10 // //
11 // MIT License: //
12 // //
13 // Permission is hereby granted, free of charge, to any person obtaining a //
14 // copy of this software and associated documentation files (the "Software"), //
15 // to deal in the Software without restriction, including without limitation //
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense, //
17 // and/or sell copies of the Software, and to permit persons to whom the //
18 // Software is furnished to do so, subject to the following conditions: //
19 // //
20 // The above copyright notice and this permission notice shall be included //
21 // in all copies or substantial portions of the Software. //
22 // //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS //
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE //
26 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, //
27 // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF //
28 // OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. //
29 // //
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31
32 #if (!defined(HEX_LU_UMFPACK) && defined(WITH_UMFPACK))
33 #define HEX_LU_UMFPACK
34
35 // --------------------------------------------------------------------------------- //
36
37 #include <umfpack.h>
38
39 // --------------------------------------------------------------------------------- //
40
41 #include "hex-csrmatrix.h"
42
43 // --------------------------------------------------------------------------------- //
44
45 #include "luft.h"
46
47 // --------------------------------------------------------------------------------- //
48
49 #ifdef _LONGINT
50 #define UMFPACK_DEFAULTS_F umfpack_zl_defaults
51 #define UMFPACK_SYMBOLIC_F umfpack_zl_symbolic
52 #define UMFPACK_FREE_SYMBOLIC_F umfpack_zl_free_symbolic
53 #define UMFPACK_NUMERIC_F umfpack_zl_numeric
54 #define UMFPACK_SAVE_NUMERIC_F umfpack_zl_save_numeric
55 #define UMFPACK_LOAD_NUMERIC_F umfpack_zl_load_numeric
56 #define UMFPACK_FREE_NUMERIC_F umfpack_zl_free_numeric
57 #define UMFPACK_SOLVE_F umfpack_zl_solve
58 #define UMFPACK_GET_LUNZ_F umfpack_zl_get_lunz
59 #define UMFPACK_REPORT_STATUS_F umfpack_zl_report_status
60 #define UMFPACK_COL_TO_TRIPLET_F umfpack_zl_col_to_triplet
61 #define UMFPACK_TRIPLET_TO_COL_F umfpack_zl_triplet_to_col
62 #else
63 #define UMFPACK_DEFAULTS_F umfpack_zi_defaults
64 #define UMFPACK_SYMBOLIC_F umfpack_zi_symbolic
65 #define UMFPACK_FREE_SYMBOLIC_F umfpack_zi_free_symbolic
66 #define UMFPACK_NUMERIC_F umfpack_zi_numeric
67 #define UMFPACK_SAVE_NUMERIC_F umfpack_zi_save_numeric
68 #define UMFPACK_LOAD_NUMERIC_F umfpack_zi_load_numeric
69 #define UMFPACK_FREE_NUMERIC_F umfpack_zi_free_numeric
70 #define UMFPACK_SOLVE_F umfpack_zi_solve
71 #define UMFPACK_GET_LUNZ_F umfpack_zi_get_lunz
72 #define UMFPACK_REPORT_STATUS_F umfpack_zi_report_status
73 #define UMFPACK_COL_TO_TRIPLET_F umfpack_zi_col_to_triplet
74 #define UMFPACK_TRIPLET_TO_COL_F umfpack_zi_triplet_to_col
75 #endif
76
77 // --------------------------------------------------------------------------------- //
78
86 class LUft_UMFPACK : public LUft
87 {
88 public:
89
90 // run-time selection mechanism
91 factorizerRunTimeSelectionDefinitions(LUft_UMFPACK, "umfpack")
92
93
94 LUft_UMFPACK ()
95 : LUft(), numeric_(nullptr), info_(UMFPACK_INFO) {}
96
98 virtual ~LUft_UMFPACK () { drop(); }
99
100 // Disable bitwise copy
101 LUft_UMFPACK const & operator= (LUft_UMFPACK const &) = delete;
102
104 virtual void factorize (CsrMatrix<LU_int_t,Complex> const & matrix, LUftData data);
105
107 NumberArray<double> const & info () const { return info_; }
108
110 virtual bool valid () const;
111
113 virtual std::size_t size () const;
114
116 virtual Real cond () const;
117
119 virtual void solve (const cArrayView b, cArrayView x, int eqs) const;
120
122 virtual void save (std::string name) const;
123
125 virtual void load (std::string name, bool throw_on_io_failure = true);
126
128 virtual void drop ();
129
130 private:
131
133 void * numeric_;
134
136 NumberArray<LU_int_t> p_;
137 NumberArray<LU_int_t> i_;
138 NumberArray<std::complex<double>> x_;
139
140 public:
141
143 mutable NumberArray<double> info_;
144 };
145
146 #endif // WITH_UMFPACK
LUft_UMFPACK::factorize
virtual void factorize(CsrMatrix< LU_int_t, Complex > const &matrix, LUftData data)
Factorize.
Definition: lu-umfpack.cpp:69
LUft_UMFPACK::cond
virtual Real cond() const
Return condition number.
Definition: lu-umfpack.cpp:64
LUft_UMFPACK::operator=
LUft_UMFPACK const & operator=(LUft_UMFPACK const &)=delete
LUft_UMFPACK::valid
virtual bool valid() const
Validity indicator.
Definition: lu-umfpack.cpp:59
luft.h
LUft
LU factorization object.
Definition: luft.h:74
CsrMatrix
Definition: luft.h:42
LUft_UMFPACK::drop
virtual void drop()
Release memory.
Definition: lu-umfpack.cpp:244
LUft_UMFPACK::info
NumberArray< double > const & info() const
Return factorization information.
Definition: lu-umfpack.h:107
LUft_UMFPACK::~LUft_UMFPACK
virtual ~LUft_UMFPACK()
Destructor.
Definition: lu-umfpack.h:98
LUft_UMFPACK::info_
NumberArray< double > info_
Set of status flags produced by UMFPACK.
Definition: lu-umfpack.h:143
LUft::save
virtual void save() const
Definition: luft.h:181
LUft_UMFPACK
LU factorization object - UMFPACK specialization.
Definition: lu-umfpack.h:86
LUft::load
virtual void load()
Definition: luft.h:187
LUftData
Definition: luft.h:46
LUft_UMFPACK::size
virtual std::size_t size() const
Return LU byte size.
Definition: lu-umfpack.cpp:40
LUft_UMFPACK::factorizerRunTimeSelectionDefinitions
factorizerRunTimeSelectionDefinitions(LUft_UMFPACK, "umfpack") LUft_UMFPACK()
Default constructor.
Definition: lu-umfpack.h:91
LUft_UMFPACK::solve
virtual void solve(const cArrayView b, cArrayView x, int eqs) const
Solve equations.
Definition: lu-umfpack.cpp:142