Skip to content

Commit

Permalink
Clang-Format fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JuliusDiestra committed Jan 14, 2024
1 parent b7b7439 commit 90fd667
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
1 change: 0 additions & 1 deletion core/include/marsvin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@
#include "marsvin/tools/logger.hpp"

#endif // MARSVIN_HPP_

Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,18 @@ void backward_substitution(const ::marsvin::Matrix<T>& U,

template<typename T>
marsvin::Vector<T> backward_substitution(const ::marsvin::Matrix<T>& U,
const ::marsvin::Vector<T>& b) {
const ::marsvin::Vector<T>& b) {
marsvin::Vector<T> x(b.size());
backward_substitution(U, b, x);
return x;
};

template<typename T>
void backward_substitution_memory(const ::marsvin::Matrix<T>& U,
::marsvin::Vector<T>& b) {
::marsvin::Vector<T>& b) {
backward_substitution(U, b, b);
};


} // namespace marsvin

#endif // MARSVIN_TRIANGULAR_SYSTEMS_BACKWARD_SUBSTITUTION_HPP_
14 changes: 7 additions & 7 deletions core/include/marsvin/triangular_systems/lower_inverse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ void lower_inverse(const ::marsvin::Matrix<T>& L, ::marsvin::Matrix<T>& X) {
if (X.empty()) {
X.resize(L.rows(), L.columns());
} else {
if ( (L.rows() != X.rows()) || (L.columns() != X.columns()) ) {
if ((L.rows() != X.rows()) || (L.columns() != X.columns())) {
throw marsvin::Exception(marsvin::StatusCode::TypeErrorEqualSize());
}
}
std::size_t n{L.rows()};
T sum;
for (std::size_t k = 0; k <= (n-1); ++k) {
X.at(k,k) = 1/L.at(k,k);
for (std::size_t i = k+1; i <= (n-1); ++i) {
for (std::size_t k = 0; k <= (n - 1); ++k) {
X.at(k, k) = 1 / L.at(k, k);
for (std::size_t i = k + 1; i <= (n - 1); ++i) {
sum = 0;
for (std::size_t j = k; j <= (i -1); ++j) {
sum = sum + L.at(i,j)*X.at(j,k);
for (std::size_t j = k; j <= (i - 1); ++j) {
sum = sum + L.at(i, j) * X.at(j, k);
}
X.at(i,k) = -sum/L.at(i,i);
X.at(i, k) = -sum / L.at(i, i);
}
}
};
Expand Down
18 changes: 9 additions & 9 deletions core/include/marsvin/triangular_systems/upper_inverse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ void upper_inverse(const ::marsvin::Matrix<T>& U, ::marsvin::Matrix<T>& X) {
if (X.empty()) {
X.resize(U.rows(), U.columns());
} else {
if ( (U.rows() != X.rows()) || (U.columns() != U.columns()) ) {
if ((U.rows() != X.rows()) || (U.columns() != U.columns())) {
throw marsvin::Exception(marsvin::StatusCode::TypeErrorEqualSize());
}
}
std::size_t n{U.rows()};
T sum;
for (std::size_t k = 0; k <= (n-1); ++k) {
for (std::size_t j = 0; j <= (n-1); ++j) {
if (k==j) {
X.at(k,j) = 1/U.at(k,j);
for (std::size_t k = 0; k <= (n - 1); ++k) {
for (std::size_t j = 0; j <= (n - 1); ++j) {
if (k == j) {
X.at(k, j) = 1 / U.at(k, j);
} else if (k < j) {
sum = 0;
for (std::size_t i = k; i <= j-1; ++i) {
sum = sum + U.at(i,j)*X.at(k,i);
for (std::size_t i = k; i <= j - 1; ++i) {
sum = sum + U.at(i, j) * X.at(k, i);
}
X.at(k,j) = -sum/U.at(j,j);
X.at(k, j) = -sum / U.at(j, j);
} else {
X.at(k,j) = 0;
X.at(k, j) = 0;
}
}
}
Expand Down

0 comments on commit 90fd667

Please sign in to comment.