6 #ifndef MYRAMATH_MULTIFRONTAL_ZLDLH_KERNEL_H 7 #define MYRAMATH_MULTIFRONTAL_ZLDLH_KERNEL_H 19 #include <myramath/io/detail/vector.h> 20 #include <myramath/io/detail/complex.h> 26 #include <myramath/dense/detail/nwork.h> 35 template<
class Number>
class MatrixRange;
36 template<
class Number>
class LowerMatrix;
42 typedef std::complex<Precision> Number;
54 { in >> P_swaps >> Q_swaps >> R >> n_plus >> n_minus; }
58 { out << P_swaps << Q_swaps << R << n_plus << n_minus; }
65 P_swaps = result.P_swaps;
66 Q_swaps = result.Q_swaps;
68 n_plus = result.n_plus;
69 n_minus = result.n_minus;
71 uint64_t n_work = L.size();
72 return n_work*(n_work+1)*(n_work+2)/6;
85 if (B.
I != N)
throw eprintf(
"ZLDLHKernel::solveL('L'eft), size mismatch B.I != N [%d != %d]", B.
I, N);
90 uint64_t w = trsm_nwork(
'L',
'N',L,B);
98 iswap_rows(Q_swaps,B);
100 uint64_t w = trsm_nwork(
'L',
'T',L,B);
101 iswap_rows(P_swaps,B);
107 iswap_rows(Q_swaps,B);
109 uint64_t w = trsm_nwork(
'L',
'H',L,B);
110 iswap_rows(P_swaps,B);
116 swap_rows(P_swaps,B);
117 uint64_t w = trsm_nwork(
'L',
'C',L,B);
119 swap_rows(Q_swaps,B);
122 else throw eprintf(
"ZLDLHKernel::solveL('L'eft), didn't understand op = %c", op);
124 else if (side ==
'R')
127 if (B.
J != N)
throw eprintf(
"ZLDLHKernel::solveL('R'ight), size mismatch in B.J != N [%d != %d]", B.
J, N);
131 swap_columns(Q_swaps,B);
133 uint64_t w = trsm_nwork(
'R',
'N',L,B);
134 swap_columns(P_swaps,B);
140 iswap_columns(P_swaps,B);
141 uint64_t w = trsm_nwork(
'R',
'T',L,B);
143 iswap_columns(Q_swaps,B);
149 iswap_columns(P_swaps,B);
150 uint64_t w = trsm_nwork(
'R',
'H',L,B);
152 iswap_columns(Q_swaps,B);
158 swap_columns(Q_swaps,B);
160 uint64_t w = trsm_nwork(
'R',
'C',L,B);
161 swap_columns(P_swaps,B);
164 else throw eprintf(
"ZLDLHKernel::solveL('R'ight), didn't understand op = %c", op);
166 else throw eprintf(
"ZLDLHKernel::solveL(), didn't understand side = %c", side);
173 B.
bottom(n_minus) *= -Number(1);
174 else if (side ==
'R')
175 B.
right(n_minus) *= -Number(1);
176 else throw eprintf(
"ZLDLHKernel::solveI(), didn't understand side = %c", side);
181 {
return std::pair<int,int>(n_plus, n_minus); }
193 std::vector<int> P_swaps;
196 std::vector<int> Q_swaps;
209 {
public:
typedef std::complex<Precision> type; };
Reflects Number trait for a Container, containers of Numbers (Matrix's, Vector's, etc) should special...
Definition: Number.h:55
std::pair< int, int > inertia() const
Returns inertia I, (n_plus, n_minus). Useful for schur downdates.
Definition: Kernel.h:180
Returns a std::runtime_error() whose message has been populated using printf()-style formatting...
int J
---------— Data members, all public ----------------—
Definition: MatrixRange.h:43
Represents a mutable LowerMatrixRange.
Definition: conjugate.h:28
int I
---------— Data members, all public ----------------—
Definition: MatrixRange.h:42
A mostly-identity matrix type, with the occasional Matrix22 at a specific diagonal offset (n...
Definition: PivotMatrix.h:29
LDL' decompositions for real hermitian Matrix A (indefinite is fine).
Factors A into L*L', presents solve methods.
Definition: Kernel.h:39
ReaderWriter<T>, encapsulates a read()/write() pair for type T.
Range construct for a lower triangular matrix stored in rectangular packed format.
ZLDLHKernel(LowerMatrixRange< Number > &A)
Seats reference to L, to be factor()'d later.
Definition: Kernel.h:49
ZLDLHKernel()
Default constructor, initializes to 0 size.
Definition: Kernel.h:45
Routines for backsolving by a triangular Matrix or LowerMatrix.
Abstraction layer, serializable objects write themselves to these.
Definition: Streams.h:39
Various utility functions/classes related to scalar Number types.
Routines related to swap sequences, often used during pivoting.
Represents a mutable MatrixRange.
Definition: conjugate.h:26
uint64_t factor()
Factors A = L*I*L'.
Definition: Kernel.h:61
MatrixRange< Number > bottom(int i) const
Returns the i bottommost rows, this(I-i:I,:)
Definition: MatrixRange.cpp:186
MatrixRange< Number > right(int j) const
Returns the j rightmost columns, this(:,J-j:J)
Definition: MatrixRange.cpp:235
ZLDLHKernel(LowerMatrixRange< Number > &A, InputStream &in)
Constructs from an InputStream, after seating reference to L.
Definition: Kernel.h:53
int size() const
Size inspector.
Definition: Kernel.h:184
void write(OutputStream &out) const
Writes to an OutputStream.
Definition: Kernel.h:57
void solveI(const MatrixRange< Number > &B, char side) const
Solves I*X=B or X*I=B, overwrites B with X.
Definition: Kernel.h:170
Bases classes for binary input/output streams.
Return type of sytrf_inplace() and hetrf_inplace(), holds pivoting metadata.
Definition: LDLSwaps.h:21
uint64_t solveL(const MatrixRange< Number > &B, char side, char op) const
Solves op(L)*X=B or X*op(L)=B, overwrites B with X.
Definition: Kernel.h:78