24 template <
typename AT,
typename LT,
typename UT,
typename PT>
25 void lu(
const AT& A, LT& L, UT& U, PT& P) {
34 for (
size_t i = 0; i < n; ++i) {
38 for (
size_t i = 0; i < n; ++i) {
41 for (
size_t j = i; j < n; ++j) {
42 if (
std::abs(A(j, i)) > A(max_j, i)) {
48 for (
size_t k = 0; k < n; ++k) {
50 swap(P(i, k), P(max_j, k));
57 for (
size_t i = 0; i < n; ++i) {
61 for (
size_t i = 0; i < n; ++i) {
62 for (
size_t j = 0; j < n; ++j) {
65 for (
size_t k = 0; k < j; ++k) {
66 s += L(j, k) * U(k, i);
69 U(j, i) = Ap(j, i) -
s;
74 for (
size_t k = 0; k < i; ++k) {
75 s += L(j, k) * U(k, i);
78 L(j, i) = (Ap(j, i) -
s) / U(i, i);
90 template <
typename AT,
typename QT,
typename RT>
94 const auto m = etl::dim<0>(A);
95 const auto n = etl::dim<1>(A);
97 std::vector<etl::dyn_matrix<T, 2>> q;
100 for (
size_t i = 0; i < m; ++i) {
101 q.emplace_back(m, m);
107 for (
size_t k = 0; k < n && k < m - 1; k++) {
110 for (
size_t i = 0; i < k; ++i) {
114 for (
size_t i = k; i < m; ++i) {
115 for (
size_t j = k; j < n; ++j) {
125 for (
size_t i = 0; i < m; ++i) {
138 for (
size_t i = 0; i < m; ++i) {
139 for (
size_t j = 0; j < m; ++j) {
140 q[k](i, j) = T(-2) * x[i] * x[j];
151 for (
size_t i = 1; i < n && i < m - 1; i++) {
166 template <
typename AT,
typename QT,
typename RT>
167 void qr(AT& A, QT& Q, RT& R) {
auto s(T &&value)
Force the evaluation of the given expression.
Definition: stop.hpp:18
bool qr(AT &A, QT &Q, RT &R)
Decomposition the matrix so that A = Q * R.
Definition: globals.hpp:332
Definition: prob_pooling.hpp:10
auto abs(E &&value)
Apply absolute on each value of the given expression.
Definition: expression_builder.hpp:54
auto transpose(const E &value)
Returns the transpose of the given expression.
Definition: expression_builder.hpp:528
auto dim(E &&value, size_t i) -> detail::identity_helper< E, dim_view< detail::build_identity_type< E >, D >>
Return a view representing the ith Dth dimension.
Definition: view_expression_builder.hpp:25
bool lu(const AT &A, LT &L, UT &U, PT &P)
Decomposition the matrix so that P * A = L * U.
Definition: globals.hpp:308
Matrix with run-time fixed dimensions.
Definition: dyn.hpp:26
void swap(custom_dyn_matrix_impl< T, SO, D > &lhs, custom_dyn_matrix_impl< T, SO, D > &rhs)
Swap two dyn matrix.
Definition: custom_dyn.hpp:403
void householder(AT &A, QT &Q, RT &R)
Use the householder algorithm to perform the A=QR decomposition of the matrix A.
Definition: decomposition.hpp:91
decltype(auto) force_temporary(E &&expr)
Force a temporary out of the expression.
Definition: temporary.hpp:91
typename decay_traits< E >::value_type value_t
Traits to extract the value type out of an ETL type.
Definition: tmp.hpp:81
value_t< A > norm(const A &a)
Returns euclidean norm of the given expression.
Definition: expression_builder.hpp:578