Skip to content

Commit

Permalink
Merge pull request #54 from beomki-yeo/refactor/transform3
Browse files Browse the repository at this point in the history
Refactor Transform3 with Matrix Actor
  • Loading branch information
beomki-yeo authored Mar 25, 2022
2 parents bb634e6 + dbc02df commit 0a525dd
Show file tree
Hide file tree
Showing 20 changed files with 719 additions and 576 deletions.
57 changes: 35 additions & 22 deletions frontend/array_cmath/include/algebra/array_cmath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,6 @@ using algebra::cmath::operator+;
/// @}

namespace algebra {
namespace array {

/// @name cmath based transforms on @c algebra::array::storage_type
/// @{

template <typename T>
using transform3 = cmath::transform3<std::size_t, array::storage_type, T>;
template <typename T>
using cartesian2 = cmath::cartesian2<transform3<T>>;
template <typename T>
using polar2 = cmath::polar2<transform3<T>>;
template <typename T>
using cylindrical2 = cmath::cylindrical2<transform3<T>>;

/// @}

} // namespace array

namespace getter {

Expand Down Expand Up @@ -87,19 +70,26 @@ using cmath::normalize;

namespace matrix {

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

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

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

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

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

namespace determinant {

Expand All @@ -123,7 +113,7 @@ using hard_coded = cmath::matrix::determinant::hard_coded<
// 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>>;
hard_coded<size_type, scalar_t, 2, 4>>;

} // namespace determinant

Expand Down Expand Up @@ -151,10 +141,33 @@ using hard_coded =
// 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>>;
hard_coded<size_type, scalar_t, 2, 4>>;

} // namespace inverse

} // namespace matrix

namespace array {

/// @name cmath based transforms on @c algebra::matrix::actor
/// @{

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>>;

template <typename T>
using transform3 = cmath::transform3<transform3_actor<T>>;
template <typename T>
using cartesian2 = cmath::cartesian2<transform3<T>>;
template <typename T>
using polar2 = cmath::polar2<transform3<T>>;
template <typename T>
using cylindrical2 = cmath::cylindrical2<transform3<T>>;

/// @}

} // namespace array

} // namespace algebra
57 changes: 32 additions & 25 deletions frontend/eigen_cmath/include/algebra/eigen_cmath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,6 @@
#include <type_traits>

namespace algebra {
namespace eigen {

/// @name cmath based transforms on @c algebra::eigen::storage_type
/// @{

template <typename T>
using transform3 = cmath::transform3<
int, eigen::storage_type, T,
typename Eigen::Transform<T, 3, Eigen::Affine>::MatrixType,
math::element_getter, math::block_getter>;
template <typename T>
using cartesian2 = cmath::cartesian2<transform3<T>>;
template <typename T>
using polar2 = cmath::polar2<transform3<T>>;
template <typename T>
using cylindrical2 = cmath::cylindrical2<transform3<T>>;

/// @}

} // namespace eigen

namespace getter {

Expand Down Expand Up @@ -90,16 +70,19 @@ using eigen::math::normalize;

namespace matrix {

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

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

namespace determinant {

Expand All @@ -123,7 +106,7 @@ using hard_coded =
// 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>>;
hard_coded<size_type, scalar_t, 2, 4>>;

} // namespace determinant

Expand All @@ -149,10 +132,34 @@ using hard_coded =
// 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>>;
hard_coded<size_type, scalar_t, 2, 4>>;

} // namespace inverse

} // namespace matrix

namespace eigen {

/// @name cmath based transforms on @c algebra::matrix::actor
/// @{

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

template <typename T>
using transform3 = cmath::transform3<transform3_actor<T>>;
template <typename T>
using cartesian2 = cmath::cartesian2<transform3<T>>;
template <typename T>
using polar2 = cmath::polar2<transform3<T>>;
template <typename T>
using cylindrical2 = cmath::cylindrical2<transform3<T>>;

/// @}

} // namespace eigen

} // namespace algebra
59 changes: 33 additions & 26 deletions frontend/smatrix_cmath/include/algebra/smatrix_cmath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,6 @@
#include <Math/SMatrix.h>

namespace algebra {
namespace smatrix {

/// @name cmath based transforms on @c algebra::smatrix::storage_type
/// @{

template <typename T>
using transform3 =
cmath::transform3<unsigned int, smatrix::storage_type, T,
ROOT::Math::SMatrix<T, 4, 4>, math::element_getter<T>,
math::block_getter<T>>;
template <typename T>
using cartesian2 = cmath::cartesian2<transform3<T>>;
template <typename T>
using polar2 = cmath::polar2<transform3<T>>;
template <typename T>
using cylindrical2 = cmath::cylindrical2<transform3<T>>;

/// @}

} // namespace smatrix

namespace getter {

/// @name Getter functions on @c algebra::smatrix::storage_type
Expand Down Expand Up @@ -85,17 +64,22 @@ using smatrix::math::normalize;

namespace matrix {

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

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

namespace determinant {

Expand All @@ -118,7 +102,7 @@ using hard_coded = cmath::matrix::determinant::hard_coded<
// 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>>;
hard_coded<size_type, scalar_t, 2, 4>>;

} // namespace determinant

Expand All @@ -144,10 +128,33 @@ using hard_coded =
// 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>>;
hard_coded<size_type, scalar_t, 2, 4>>;

} // namespace inverse

} // namespace matrix

namespace smatrix {

/// @name cmath based transforms on @c algebra::matrix::actor
/// @{

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>>;

template <typename T>
using transform3 = cmath::transform3<transform3_actor<T>>;
template <typename T>
using cartesian2 = cmath::cartesian2<transform3<T>>;
template <typename T>
using polar2 = cmath::polar2<transform3<T>>;
template <typename T>
using cylindrical2 = cmath::cylindrical2<transform3<T>>;

/// @}

} // namespace smatrix

} // namespace algebra
68 changes: 35 additions & 33 deletions frontend/vc_cmath/include/algebra/vc_cmath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,6 @@ using algebra::cmath::operator+;
/// @}

namespace algebra {
namespace vc {

/// @name cmath based transforms on @c algebra::vc types
/// @{

// Pull in the definitions needed by the cmath transforms, into this namespace.
using math::cross;
using math::perp;
using math::phi;

template <typename T>
using transform3 =
cmath::transform3<std::size_t, vc::storage_type, T,
Vc::array<Vc::array<T, 4>, 4>,
cmath::element_getter<std::size_t, Vc::array, T>,
cmath::block_getter<std::size_t, Vc::array, T>,
vc::vector3<T>, vc::point2<T>>;
template <typename T>
using cartesian2 = cmath::cartesian2<transform3<T>>;
template <typename T>
using polar2 = cmath::polar2<transform3<T>>;
template <typename T>
using cylindrical2 = cmath::cylindrical2<transform3<T>>;

/// @}

} // namespace vc

namespace getter {

/// @name Getter functions on @c algebra::vc types
Expand Down Expand Up @@ -109,19 +81,26 @@ using vc::math::normalize;

namespace matrix {

template <typename T, std::size_t N>
using array_type = Vc::array<T, N>;

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

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

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

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

namespace determinant {

Expand All @@ -145,7 +124,7 @@ using hard_coded = cmath::matrix::determinant::hard_coded<
// 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>>;
hard_coded<size_type, scalar_t, 2, 4>>;

} // namespace determinant

Expand Down Expand Up @@ -173,10 +152,33 @@ using hard_coded =
// 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>>;
hard_coded<size_type, scalar_t, 2, 4>>;

} // namespace inverse

} // namespace matrix

namespace vc {

/// @name cmath based transforms on @c algebra::matrix::actor
/// @{

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>>;

template <typename T>
using transform3 = cmath::transform3<transform3_actor<T>>;
template <typename T>
using cartesian2 = cmath::cartesian2<transform3<T>>;
template <typename T>
using polar2 = cmath::polar2<transform3<T>>;
template <typename T>
using cylindrical2 = cmath::cylindrical2<transform3<T>>;

/// @}

} // namespace vc

} // namespace algebra
Loading

0 comments on commit 0a525dd

Please sign in to comment.