Skip to content

Commit

Permalink
Merge pull request #58 from beomki-yeo/refactor-remove-size_t-templat…
Browse files Browse the repository at this point in the history
…e-parameter

Remove size type parameter in frontend matrix actor
  • Loading branch information
beomki-yeo authored Mar 31, 2022
2 parents 3a89a8a + 5504e09 commit 030f40a
Show file tree
Hide file tree
Showing 17 changed files with 204 additions and 241 deletions.
59 changes: 27 additions & 32 deletions frontend/array_cmath/include/algebra/array_cmath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,79 +70,75 @@ using cmath::normalize;

namespace matrix {

template <typename T, std::size_t N>
using size_type = std::size_t;

template <typename T, size_type N>
using array_type = array::storage_type<T, N>;

template <typename T, std::size_t ROWS, std::size_t COLS>
template <typename T, size_type ROWS, size_type COLS>
using matrix_type = array::matrix_type<T, ROWS, COLS>;

template <typename size_type, typename scalar_t>
template <typename scalar_t>
using element_getter = cmath::element_getter<size_type, array_type, scalar_t>;

template <typename size_type, typename scalar_t>
template <typename scalar_t>
using block_getter = cmath::block_getter<size_type, array_type, scalar_t>;

// matrix actor
template <typename size_type, typename scalar_t, typename determinant_actor_t,
template <typename scalar_t, typename determinant_actor_t,
typename inverse_actor_t>
using actor = cmath::matrix::actor<size_type, array_type, matrix_type, scalar_t,
determinant_actor_t, inverse_actor_t,
element_getter<size_type, scalar_t>,
block_getter<size_type, scalar_t>>;
using actor =
cmath::matrix::actor<size_type, array_type, matrix_type, scalar_t,
determinant_actor_t, inverse_actor_t,
element_getter<scalar_t>, block_getter<scalar_t>>;

namespace determinant {

// determinant aggregation
template <typename size_type, typename scalar_t, class... As>
template <typename scalar_t, class... As>
using actor =
cmath::matrix::determinant::actor<size_type, matrix_type, scalar_t, As...>;

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

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

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

} // namespace determinant

namespace inverse {

// inverion aggregation
template <typename size_type, typename scalar_t, class... As>
template <typename scalar_t, class... As>
using actor =
cmath::matrix::inverse::actor<size_type, matrix_type, scalar_t, As...>;

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

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

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

} // namespace inverse

Expand All @@ -154,9 +150,8 @@ namespace array {
/// @{

template <typename T>
using transform3_actor =
matrix::actor<std::size_t, T, matrix::determinant::preset0<std::size_t, T>,
matrix::inverse::preset0<std::size_t, T>>;
using transform3_actor = matrix::actor<T, matrix::determinant::preset0<T>,
matrix::inverse::preset0<T>>;

template <typename T>
using transform3 = cmath::transform3<transform3_actor<T>>;
Expand Down
35 changes: 17 additions & 18 deletions frontend/eigen_cmath/include/algebra/eigen_cmath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,17 @@ using eigen::math::normalize;

namespace matrix {

template <typename T, int N>
using size_type = int;

template <typename T, size_type N>
using array_type = eigen::storage_type<T, N>;
template <typename T, int ROWS, int COLS>
template <typename T, size_type ROWS, size_type COLS>
using matrix_type = eigen::matrix_type<T, ROWS, COLS>;
using element_getter = eigen::math::element_getter;
using block_getter = eigen::math::block_getter;

// matrix actor
template <typename size_type, typename scalar_t, typename determinant_actor_t,
template <typename scalar_t, typename determinant_actor_t,
typename inverse_actor_t>
using actor = cmath::matrix::actor<size_type, array_type, matrix_type, scalar_t,
determinant_actor_t, inverse_actor_t,
Expand All @@ -87,52 +89,50 @@ using actor = cmath::matrix::actor<size_type, array_type, matrix_type, scalar_t,
namespace determinant {

// determinant aggregation
template <typename size_type, typename scalar_t, class... As>
template <typename scalar_t, class... As>
using actor =
cmath::matrix::determinant::actor<size_type, matrix_type, scalar_t, As...>;

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

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

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

} // namespace determinant

namespace inverse {

// inverion aggregation
template <typename size_type, typename scalar_t, class... As>
template <typename scalar_t, class... As>
using actor =
cmath::matrix::inverse::actor<size_type, matrix_type, scalar_t, As...>;

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

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

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

} // namespace inverse

Expand All @@ -145,9 +145,8 @@ namespace eigen {

template <typename T>
using transform3_actor =
algebra::matrix::actor<int, T,
algebra::matrix::determinant::preset0<int, T>,
algebra::matrix::inverse::preset0<int, T>>;
algebra::matrix::actor<T, algebra::matrix::determinant::preset0<T>,
algebra::matrix::inverse::preset0<T>>;

template <typename T>
using transform3 = cmath::transform3<transform3_actor<T>>;
Expand Down
36 changes: 18 additions & 18 deletions frontend/smatrix_cmath/include/algebra/smatrix_cmath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,19 @@ using smatrix::math::normalize;

namespace matrix {

template <typename T, unsigned int N>
using size_type = unsigned int;

template <typename T, size_type N>
using array_type = smatrix::storage_type<T, N>;
template <typename T, unsigned int ROWS, unsigned int COLS>
template <typename T, size_type ROWS, size_type COLS>
using matrix_type = smatrix::matrix_type<T, ROWS, COLS>;
template <typename scalar_t>
using element_getter = smatrix::math::element_getter<scalar_t>;
template <typename scalar_t>
using block_getter = smatrix::math::block_getter<scalar_t>;

// matrix actor
template <typename size_type, typename scalar_t, typename determinant_actor_t,
template <typename scalar_t, typename determinant_actor_t,
typename inverse_actor_t>
using actor =
cmath::matrix::actor<size_type, array_type, matrix_type, scalar_t,
Expand All @@ -84,52 +86,50 @@ using actor =
namespace determinant {

// determinant aggregation
template <typename size_type, typename scalar_t, class... As>
template <typename scalar_t, class... As>
using actor =
cmath::matrix::determinant::actor<size_type, matrix_type, scalar_t, As...>;

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

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

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

} // namespace determinant

namespace inverse {

// inverion aggregation
template <typename size_type, typename scalar_t, class... As>
template <typename scalar_t, class... As>
using actor =
cmath::matrix::inverse::actor<size_type, matrix_type, scalar_t, As...>;

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

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

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

} // namespace inverse

Expand All @@ -141,9 +141,9 @@ namespace smatrix {
/// @{

template <typename T>
using transform3_actor = algebra::matrix::actor<
unsigned int, T, algebra::matrix::determinant::preset0<unsigned int, T>,
algebra::matrix::inverse::preset0<unsigned int, T>>;
using transform3_actor =
algebra::matrix::actor<T, algebra::matrix::determinant::preset0<T>,
algebra::matrix::inverse::preset0<T>>;

template <typename T>
using transform3 = cmath::transform3<transform3_actor<T>>;
Expand Down
Loading

0 comments on commit 030f40a

Please sign in to comment.