|
template<class Matrix , class Permutation > |
static auto | decompose (Matrix &&A, Permutation &&P, double tol=std::numeric_limits< double >::epsilon()) |
|
template<class Matrix , class Permutation , class VectorSol > |
static auto | solve (Matrix const &LU, Permutation const &P, VectorSol &&x) -> VectorSol && |
|
|
template<class Matrix , class Permutation , class Index > |
static auto | permute_max_diagonal (Matrix &&LU, Permutation &&P, Index i) |
|
template<class Permutation , class Vector > |
static auto | permute (Permutation const &p, Vector &&data) -> Vector && |
|
template<class LUMatrix , class Vector > |
static auto | lower_solve (LUMatrix const &LU, Vector &&x) -> Vector && |
|
template<class LUMatrix , class Vector > |
static auto | upper_solve (LUMatrix const &LU, Vector &&x) -> Vector && |
|
Definition at line 32 of file MatrixOps.h.
◆ decompose()
static auto decompose |
( |
Matrix && |
A, |
|
|
Permutation && |
P, |
|
|
double |
tol = std::numeric_limits<double>::epsilon() |
|
) |
| |
|
inlinestatic |
Definition at line 36 of file MatrixOps.h.
References qmcplusplus::Units::distance::A, omptarget::min(), qmcplusplus::Units::force::N, and permute_max_diagonal().
40 assert( P.size() >=
N );
42 auto&& ret =
A({0,
N}, {0,
N});
43 for(
auto i : extension(ret)){
46 for(
auto&& row :
A({i + 1,
N})){
47 auto&& urow = row({i + 1,
N});
49 cbegin(urow), cend(urow), cbegin(
A[i]({i + 1,
N})), begin(urow),
50 [f = row[i] /=
A[i][i]](
auto const& a,
auto const& b){
return a - f*b;}
54 return A({0,
N}, {0,
N});
static auto permute_max_diagonal(Matrix &&LU, Permutation &&P, Index i)
QMCTraits::FullPrecRealType value_type
◆ lower_solve()
static auto lower_solve |
( |
LUMatrix const & |
LU, |
|
|
Vector && |
x |
|
) |
| -> Vector&& |
|
inlinestaticprivate |
Definition at line 92 of file MatrixOps.h.
References qmcplusplus::Units::force::N.
Referenced by solve().
93 assert(size(LU) <= size(x));
94 auto const N = size(LU);
95 for(
typename LUMatrix::size_type i = 0; i !=
N; ++i){
96 auto const& Lrowi = LU[i]({0, i});
97 x[i] -= std::inner_product(begin(Lrowi), end(Lrowi), cbegin(x), 0.);
99 return std::forward<Vector>(x);
◆ permute()
static auto permute |
( |
Permutation const & |
p, |
|
|
Vector && |
data |
|
) |
| -> Vector&& |
|
inlinestaticprivate |
Definition at line 73 of file MatrixOps.h.
Referenced by solve().
74 assert(size(p) <= size(data));
75 using index =
typename Permutation::size_type;
76 for(index i = 0; i != size(p); ++i){
78 for( ; k > i; k = p[k]){}
80 if(k >=i and pk != i){
81 auto const t = data[i];
82 for( ; pk != i; k = pk, pk = p[k]){
88 return std::forward<Vector>(data);
◆ permute_max_diagonal()
static auto permute_max_diagonal |
( |
Matrix && |
LU, |
|
|
Permutation && |
P, |
|
|
Index |
i |
|
) |
| |
|
inlinestaticprivate |
Definition at line 65 of file MatrixOps.h.
References qmcplusplus::abs().
Referenced by decompose().
66 auto mi = std::max_element(begin(LU) + i, end(LU), [i](
auto const& a,
auto const& b){
return std::abs(a[i]) <
std::abs(b[i]);}) - begin(LU);
68 std::swap(P [i], P [mi]);
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
◆ solve()
static auto solve |
( |
Matrix const & |
LU, |
|
|
Permutation const & |
P, |
|
|
VectorSol && |
x |
|
) |
| -> VectorSol&& |
|
inlinestatic |
Definition at line 58 of file MatrixOps.h.
References lower_solve(), permute(), and upper_solve().
static auto lower_solve(LUMatrix const &LU, Vector &&x) -> Vector &&
static auto permute(Permutation const &p, Vector &&data) -> Vector &&
static auto upper_solve(LUMatrix const &LU, Vector &&x) -> Vector &&
◆ upper_solve()
static auto upper_solve |
( |
LUMatrix const & |
LU, |
|
|
Vector && |
x |
|
) |
| -> Vector&& |
|
inlinestaticprivate |
Definition at line 103 of file MatrixOps.h.
References qmcplusplus::Units::force::N.
Referenced by solve().
104 assert(size(LU) <= size(x));
105 auto const N = size(LU);
106 for(
typename LUMatrix::size_type i =
N - 1; i >= 0; --i){
107 auto const& Urowi = LU[i]({i + 1,
N});
108 (x[i] -= std::inner_product(begin(Urowi), end(Urowi), cbegin(x) + i + 1, 0.)) /= LU[i][i];
110 return std::forward<Vector>(x);
The documentation for this struct was generated from the following file:
- /home/pk7/projects/qmc/for_cron_doxygen/qmcpack/src/QMCTools/ppconvert/src/common/MatrixOps.h