6 #ifndef MYRAMATH_MULTIFRONTAL_ZLDLT_KERNEL_H 7 #define MYRAMATH_MULTIFRONTAL_ZLDLT_KERNEL_H 19 #include <myramath/io/detail/vector.h> 20 #include <myramath/io/detail/complex.h> 27 #include <myramath/dense/detail/nwork.h> 36 template<
class Number>
class MatrixRange;
37 template<
class Number>
class LowerMatrix;
43 typedef std::complex<Precision> Number;
55 { in >> P_swaps >> Q_swaps >> R >> n_plus >> n_minus; }
59 { out << P_swaps << Q_swaps << R << n_plus << n_minus; }
66 P_swaps = result.P_swaps;
67 Q_swaps = result.Q_swaps;
69 n_plus = result.n_plus;
70 n_minus = result.n_minus;
72 uint64_t n_work = L.size();
73 return n_work*(n_work+1)*(n_work+2)/6;
86 if (B.
I != N)
throw eprintf(
"ZLDLTKernel::solveL('L'eft), size mismatch B.I != N [%d != %d]", B.
I, N);
91 uint64_t w = trsm_nwork(
'L',
'N',L,B);
99 iswap_rows(Q_swaps,B);
101 uint64_t w = trsm_nwork(
'L',
'T',L,B);
102 iswap_rows(P_swaps,B);
108 iswap_rows(Q_swaps,B);
110 uint64_t w = trsm_nwork(
'L',
'H',L,B);
111 iswap_rows(P_swaps,B);
117 swap_rows(P_swaps,B);
118 uint64_t w = trsm_nwork(
'L',
'C',L,B);
120 swap_rows(Q_swaps,B);
123 else throw eprintf(
"ZLDLTKernel::solveL('L'eft), didn't understand op = %c", op);
125 else if (side ==
'R')
128 if (B.
J != N)
throw eprintf(
"ZLDLTKernel::solveL('R'ight), size mismatch B.J != N [%d != %d]", B.
J, N);
132 swap_columns(Q_swaps,B);
134 uint64_t w = trsm_nwork(
'R',
'N',L,B);
135 swap_columns(P_swaps,B);
141 iswap_columns(P_swaps,B);
142 uint64_t w = trsm_nwork(
'R',
'T',L,B);
144 iswap_columns(Q_swaps,B);
150 iswap_columns(P_swaps,B);
151 uint64_t w = trsm_nwork(
'R',
'H',L,B);
153 iswap_columns(Q_swaps,B);
159 swap_columns(Q_swaps,B);
161 uint64_t w = trsm_nwork(
'R',
'C',L,B);
162 swap_columns(P_swaps,B);
165 else throw eprintf(
"ZLDLTKernel::solveL('R'ight), didn't understand op = %c", op);
167 else throw eprintf(
"ZLDLTKernel::solveL(), didn't understand side = %c", side);
174 B.
bottom(n_minus) *= -Number(1);
175 else if (side ==
'R')
176 B.
right(n_minus) *= -Number(1);
177 else throw eprintf(
"ZLDLTKernel::solveI(), didn't understand side = %c", side);
182 {
return std::pair<int,int>(n_plus, n_minus); }
194 std::vector<int> P_swaps;
197 std::vector<int> Q_swaps;
210 {
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
Returns a std::runtime_error() whose message has been populated using printf()-style formatting...
Interface class for representing subranges of dense Matrix's.
int J
---------— Data members, all public ----------------—
Definition: MatrixRange.h:43
void write(OutputStream &out) const
Writes to an OutputStream.
Definition: Kernel.h:58
Represents a mutable LowerMatrixRange.
Definition: conjugate.h:28
int I
---------— Data members, all public ----------------—
Definition: MatrixRange.h:42
std::pair< int, int > inertia() const
Returns inertia I, (n_plus, n_minus). Useful for schur downdates.
Definition: Kernel.h:181
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).
ReaderWriter<T>, encapsulates a read()/write() pair for type T.
Range construct for a lower triangular matrix stored in rectangular packed format.
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
void solveI(const MatrixRange< Number > &B, char side) const
Solves I*X=B or X*I=B, overwrites B with X.
Definition: Kernel.h:171
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:79
ZLDLTKernel()
Default constructor, initializes to 0 size.
Definition: Kernel.h:46
Factors A into L*L', presents solve methods.
Definition: Kernel.h:40
ZLDLTKernel(LowerMatrixRange< Number > &A)
Seats reference to L, to be factor()'d later.
Definition: Kernel.h:50
uint64_t factor()
Factors A = L*I*L'.
Definition: Kernel.h:62
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
ZLDLTKernel(LowerMatrixRange< Number > &A, InputStream &in)
Constructs from an InputStream, after seating reference to L.
Definition: Kernel.h:54
int size() const
Size inspector.
Definition: Kernel.h:185
Bases classes for binary input/output streams.
Return type of sytrf_inplace() and hetrf_inplace(), holds pivoting metadata.
Definition: LDLSwaps.h:21