Skip to content

Commit

Permalink
Merge pull request #80 from beomki-yeo/LU-decomposition
Browse files Browse the repository at this point in the history
Partial Pivot LU decomposition for matrix inversion
  • Loading branch information
beomki-yeo authored Nov 21, 2022
2 parents 73c29e9 + 8fb2f5c commit 8d53967
Show file tree
Hide file tree
Showing 12 changed files with 488 additions and 16 deletions.
17 changes: 15 additions & 2 deletions frontend/array_cmath/include/algebra/array_cmath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ using cofactor =
cmath::matrix::determinant::cofactor<size_type, matrix_type, scalar_t,
element_getter<scalar_t>, Ds...>;

// determinant::partial_pivot_lud
template <typename scalar_t, size_type... Ds>
using partial_pivot_lud = cmath::matrix::determinant::partial_pivot_lud<
size_type, matrix_type, scalar_t, element_getter<scalar_t>, Ds...>;

// determinant::hard_coded
template <typename scalar_t, size_type... Ds>
using hard_coded =
Expand All @@ -113,7 +118,8 @@ using hard_coded =

// preset(s) as standard option(s) for user's convenience
template <typename scalar_t>
using preset0 = actor<scalar_t, cofactor<scalar_t>, hard_coded<scalar_t, 2, 4>>;
using preset0 =
actor<scalar_t, partial_pivot_lud<scalar_t>, hard_coded<scalar_t, 2, 4>>;

} // namespace determinant

Expand All @@ -130,6 +136,12 @@ using cofactor =
cmath::matrix::inverse::cofactor<size_type, matrix_type, scalar_t,
element_getter<scalar_t>, Ds...>;

// inverse::partial_pivot_lud
template <typename scalar_t, size_type... Ds>
using partial_pivot_lud =
cmath::matrix::inverse::partial_pivot_lud<size_type, matrix_type, scalar_t,
element_getter<scalar_t>, Ds...>;

// inverse::hard_coded
template <typename scalar_t, size_type... Ds>
using hard_coded =
Expand All @@ -138,7 +150,8 @@ using hard_coded =

// preset(s) as standard option(s) for user's convenience
template <typename scalar_t>
using preset0 = actor<scalar_t, cofactor<scalar_t>, hard_coded<scalar_t, 2, 4>>;
using preset0 =
actor<scalar_t, partial_pivot_lud<scalar_t>, hard_coded<scalar_t, 2, 4>>;

} // namespace inverse

Expand Down
17 changes: 15 additions & 2 deletions frontend/eigen_cmath/include/algebra/eigen_cmath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ using cofactor =
cmath::matrix::determinant::cofactor<size_type, matrix_type, scalar_t,
element_getter, Ds...>;

// determinant::partial_pivot_lud
template <typename scalar_t, size_type... Ds>
using partial_pivot_lud = cmath::matrix::determinant::partial_pivot_lud<
size_type, matrix_type, scalar_t, element_getter, Ds...>;

// determinant::hard_coded
template <typename scalar_t, size_type... Ds>
using hard_coded =
Expand All @@ -106,7 +111,8 @@ using hard_coded =

// preset(s) as standard option(s) for user's convenience
template <typename scalar_t>
using preset0 = actor<scalar_t, cofactor<scalar_t>, hard_coded<scalar_t, 2, 4>>;
using preset0 =
actor<scalar_t, partial_pivot_lud<scalar_t>, hard_coded<scalar_t, 2, 4>>;

} // namespace determinant

Expand All @@ -123,6 +129,12 @@ using cofactor =
cmath::matrix::inverse::cofactor<size_type, matrix_type, scalar_t,
element_getter, Ds...>;

// inverse::partial_pivot_lud
template <typename scalar_t, size_type... Ds>
using partial_pivot_lud =
cmath::matrix::inverse::partial_pivot_lud<size_type, matrix_type, scalar_t,
element_getter, Ds...>;

// inverse::hard_coded
template <typename scalar_t, size_type... Ds>
using hard_coded =
Expand All @@ -131,7 +143,8 @@ using hard_coded =

// preset(s) as standard option(s) for user's convenience
template <typename scalar_t>
using preset0 = actor<scalar_t, cofactor<scalar_t>, hard_coded<scalar_t, 2, 4>>;
using preset0 =
actor<scalar_t, partial_pivot_lud<scalar_t>, hard_coded<scalar_t, 2, 4>>;

} // namespace inverse

Expand Down
17 changes: 15 additions & 2 deletions frontend/smatrix_cmath/include/algebra/smatrix_cmath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ using cofactor =
cmath::matrix::determinant::cofactor<size_type, matrix_type, scalar_t,
element_getter<scalar_t>, Ds...>;

// determinant::partial_pivot_lud
template <typename scalar_t, size_type... Ds>
using partial_pivot_lud = cmath::matrix::determinant::partial_pivot_lud<
size_type, matrix_type, scalar_t, element_getter<scalar_t>, Ds...>;

// determinant::hard_coded
template <typename scalar_t, size_type... Ds>
using hard_coded =
Expand All @@ -103,7 +108,8 @@ using hard_coded =

// preset(s) as standard option(s) for user's convenience
template <typename scalar_t>
using preset0 = actor<scalar_t, cofactor<scalar_t>, hard_coded<scalar_t, 2, 4>>;
using preset0 =
actor<scalar_t, partial_pivot_lud<scalar_t>, hard_coded<scalar_t, 2, 4>>;

} // namespace determinant

Expand All @@ -120,6 +126,12 @@ using cofactor =
cmath::matrix::inverse::cofactor<size_type, matrix_type, scalar_t,
element_getter<scalar_t>, Ds...>;

// inverse::partial_pivot_lud
template <typename scalar_t, size_type... Ds>
using partial_pivot_lud =
cmath::matrix::inverse::partial_pivot_lud<size_type, matrix_type, scalar_t,
element_getter<scalar_t>, Ds...>;

// inverse::hard_coded
template <typename scalar_t, size_type... Ds>
using hard_coded =
Expand All @@ -128,7 +140,8 @@ using hard_coded =

// preset(s) as standard option(s) for user's convenience
template <typename scalar_t>
using preset0 = actor<scalar_t, cofactor<scalar_t>, hard_coded<scalar_t, 2, 4>>;
using preset0 =
actor<scalar_t, partial_pivot_lud<scalar_t>, hard_coded<scalar_t, 2, 4>>;

} // namespace inverse

Expand Down
17 changes: 15 additions & 2 deletions frontend/vc_cmath/include/algebra/vc_cmath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ using cofactor =
cmath::matrix::determinant::cofactor<size_type, matrix_type, scalar_t,
element_getter<scalar_t>, Ds...>;

// determinant::partial_pivot_lud
template <typename scalar_t, size_type... Ds>
using partial_pivot_lud = cmath::matrix::determinant::partial_pivot_lud<
size_type, matrix_type, scalar_t, element_getter<scalar_t>, Ds...>;

// determinant::hard_coded
template <typename scalar_t, size_type... Ds>
using hard_coded =
Expand All @@ -124,7 +129,8 @@ using hard_coded =

// preset(s) as standard option(s) for user's convenience
template <typename scalar_t>
using preset0 = actor<scalar_t, cofactor<scalar_t>, hard_coded<scalar_t, 2, 4>>;
using preset0 =
actor<scalar_t, partial_pivot_lud<scalar_t>, hard_coded<scalar_t, 2, 4>>;

} // namespace determinant

Expand All @@ -141,6 +147,12 @@ using cofactor =
cmath::matrix::inverse::cofactor<size_type, matrix_type, scalar_t,
element_getter<scalar_t>, Ds...>;

// inverse::partial_pivot_lud
template <typename scalar_t, size_type... Ds>
using partial_pivot_lud =
cmath::matrix::inverse::partial_pivot_lud<size_type, matrix_type, scalar_t,
element_getter<scalar_t>, Ds...>;

// inverse::hard_coded
template <typename scalar_t, size_type... Ds>
using hard_coded =
Expand All @@ -149,7 +161,8 @@ using hard_coded =

// preset(s) as standard option(s) for user's convenience
template <typename scalar_t>
using preset0 = actor<scalar_t, cofactor<scalar_t>, hard_coded<scalar_t, 2, 4>>;
using preset0 =
actor<scalar_t, partial_pivot_lud<scalar_t>, hard_coded<scalar_t, 2, 4>>;

} // namespace inverse

Expand Down
17 changes: 15 additions & 2 deletions frontend/vc_vc/include/algebra/vc_vc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ using cofactor =
cmath::matrix::determinant::cofactor<size_type, matrix_type, scalar_t,
element_getter<scalar_t>, Ds...>;

// determinant::partial_pivot_lud
template <typename scalar_t, size_type... Ds>
using partial_pivot_lud = cmath::matrix::determinant::partial_pivot_lud<
size_type, matrix_type, scalar_t, element_getter<scalar_t>, Ds...>;

// determinant::hard_coded
template <typename scalar_t, size_type... Ds>
using hard_coded =
Expand All @@ -186,7 +191,8 @@ using hard_coded =

// preset(s) as standard option(s) for user's convenience
template <typename scalar_t>
using preset0 = actor<scalar_t, cofactor<scalar_t>, hard_coded<scalar_t, 2, 4>>;
using preset0 =
actor<scalar_t, partial_pivot_lud<scalar_t>, hard_coded<scalar_t, 2, 4>>;

} // namespace determinant

Expand All @@ -203,6 +209,12 @@ using cofactor =
cmath::matrix::inverse::cofactor<size_type, matrix_type, scalar_t,
element_getter<scalar_t>, Ds...>;

// inverse::partial_pivot_lud
template <typename scalar_t, size_type... Ds>
using partial_pivot_lud =
cmath::matrix::inverse::partial_pivot_lud<size_type, matrix_type, scalar_t,
element_getter<scalar_t>, Ds...>;

// inverse::hard_coded
template <typename scalar_t, size_type... Ds>
using hard_coded =
Expand All @@ -211,7 +223,8 @@ using hard_coded =

// preset(s) as standard option(s) for user's convenience
template <typename scalar_t>
using preset0 = actor<scalar_t, cofactor<scalar_t>, hard_coded<scalar_t, 2, 4>>;
using preset0 =
actor<scalar_t, partial_pivot_lud<scalar_t>, hard_coded<scalar_t, 2, 4>>;

} // namespace inverse

Expand Down
17 changes: 15 additions & 2 deletions frontend/vecmem_cmath/include/algebra/vecmem_cmath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ using cofactor =
cmath::matrix::determinant::cofactor<size_type, matrix_type, scalar_t,
element_getter<scalar_t>, Ds...>;

// determinant::partial_pivot_lud
template <typename scalar_t, size_type... Ds>
using partial_pivot_lud = cmath::matrix::determinant::partial_pivot_lud<
size_type, matrix_type, scalar_t, element_getter<scalar_t>, Ds...>;

// determinant::hard_coded
template <typename scalar_t, size_type... Ds>
using hard_coded =
Expand All @@ -114,7 +119,8 @@ using hard_coded =

// preset(s) as standard option(s) for user's convenience
template <typename scalar_t>
using preset0 = actor<scalar_t, cofactor<scalar_t>, hard_coded<scalar_t, 2, 4>>;
using preset0 =
actor<scalar_t, partial_pivot_lud<scalar_t>, hard_coded<scalar_t, 2, 4>>;

} // namespace determinant

Expand All @@ -131,6 +137,12 @@ using cofactor =
cmath::matrix::inverse::cofactor<size_type, matrix_type, scalar_t,
element_getter<scalar_t>, Ds...>;

// inverse::partial_pivot_lud
template <typename scalar_t, size_type... Ds>
using partial_pivot_lud =
cmath::matrix::inverse::partial_pivot_lud<size_type, matrix_type, scalar_t,
element_getter<scalar_t>, Ds...>;

// inverse::hard_coded
template <typename scalar_t, size_type... Ds>
using hard_coded =
Expand All @@ -139,7 +151,8 @@ using hard_coded =

// preset(s) as standard option(s) for user's convenience
template <typename scalar_t>
using preset0 = actor<scalar_t, cofactor<scalar_t>, hard_coded<scalar_t, 2, 4>>;
using preset0 =
actor<scalar_t, partial_pivot_lud<scalar_t>, hard_coded<scalar_t, 2, 4>>;

} // namespace inverse

Expand Down
11 changes: 7 additions & 4 deletions math/cmath/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Mozilla Public License Version 2.0

# Set up the library.
algebra_add_library( algebra_cmath_math cmath_math
algebra_add_library(algebra_cmath_math cmath_math
# impl include
"include/algebra/math/cmath_operators.hpp"
"include/algebra/math/cmath.hpp"
Expand All @@ -15,10 +15,13 @@ algebra_add_library( algebra_cmath_math cmath_math
"include/algebra/math/impl/cmath_transform3.hpp"
"include/algebra/math/impl/cmath_vector.hpp"
# algorithms include
"include/algebra/math/algorithms/matrix/decomposition/partial_pivot_lud.hpp"
"include/algebra/math/algorithms/matrix/determinant/cofactor.hpp"
"include/algebra/math/algorithms/matrix/determinant/hard_coded.hpp"
"include/algebra/math/algorithms/matrix/determinant/partial_pivot_lud.hpp"
"include/algebra/math/algorithms/matrix/inverse/cofactor.hpp"
"include/algebra/math/algorithms/matrix/inverse/hard_coded.hpp"
"include/algebra/math/algorithms/utils/algorithm_finder.hpp" )
target_link_libraries( algebra_cmath_math
INTERFACE algebra::common algebra::common_math )
"include/algebra/math/algorithms/matrix/inverse/partial_pivot_lud.hpp"
"include/algebra/math/algorithms/utils/algorithm_finder.hpp")
target_link_libraries(algebra_cmath_math
INTERFACE algebra::common algebra::common_math)
Loading

0 comments on commit 8d53967

Please sign in to comment.