Skip to content

Commit

Permalink
Merge pull request #52 from beomki-yeo/feat/matrix_operations
Browse files Browse the repository at this point in the history
general matrix operations
  • Loading branch information
beomki-yeo authored Mar 24, 2022
2 parents 9e2a527 + dbc5e8c commit bb634e6
Show file tree
Hide file tree
Showing 49 changed files with 1,706 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- OS: "macos-latest"
GENERATOR: "Xcode"
- OS: "windows-latest"
GENERATOR: "Visual Studio 16 2019"
GENERATOR: "Visual Studio 17 2022"

# The system to run on.
runs-on: ${{ matrix.PLATFORM.OS }}
Expand Down
79 changes: 76 additions & 3 deletions frontend/array_cmath/include/algebra/array_cmath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ namespace array {
template <typename T>
using transform3 = cmath::transform3<std::size_t, array::storage_type, T>;
template <typename T>
using cartesian2 = cmath::cartesian2<transform3<T> >;
using cartesian2 = cmath::cartesian2<transform3<T>>;
template <typename T>
using polar2 = cmath::polar2<transform3<T> >;
using polar2 = cmath::polar2<transform3<T>>;
template <typename T>
using cylindrical2 = cmath::cylindrical2<transform3<T> >;
using cylindrical2 = cmath::cylindrical2<transform3<T>>;

/// @}

Expand Down Expand Up @@ -84,4 +84,77 @@ using cmath::normalize;
/// @}

} // namespace vector

namespace matrix {

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

// 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<size_type, scalar_t>>;

namespace determinant {

// determinant aggregation
template <typename size_type, 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>
using cofactor = cmath::matrix::determinant::cofactor<
size_type, matrix_type, scalar_t, element_getter_type<size_type, scalar_t>,
Ds...>;

// determinant::hard_coded
template <typename size_type, typename scalar_t, size_type... Ds>
using hard_coded = cmath::matrix::determinant::hard_coded<
size_type, matrix_type, scalar_t, element_getter_type<size_type, 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>>;

} // namespace determinant

namespace inverse {

// inverion aggregation
template <typename size_type, 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>
using cofactor =
cmath::matrix::inverse::cofactor<size_type, matrix_type, scalar_t,
element_getter_type<size_type, scalar_t>,
Ds...>;

// inverse::hard_coded
template <typename size_type, typename scalar_t, size_type... Ds>
using hard_coded =
cmath::matrix::inverse::hard_coded<size_type, matrix_type, scalar_t,
element_getter_type<size_type, 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>>;

} // namespace inverse

} // namespace matrix

} // namespace algebra
76 changes: 72 additions & 4 deletions frontend/eigen_cmath/include/algebra/eigen_cmath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ namespace eigen {

template <typename T>
using transform3 = cmath::transform3<
std::size_t, eigen::storage_type, T,
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> >;
using cartesian2 = cmath::cartesian2<transform3<T>>;
template <typename T>
using polar2 = cmath::polar2<transform3<T> >;
using polar2 = cmath::polar2<transform3<T>>;
template <typename T>
using cylindrical2 = cmath::cylindrical2<transform3<T> >;
using cylindrical2 = cmath::cylindrical2<transform3<T>>;

/// @}

Expand Down Expand Up @@ -87,4 +87,72 @@ using eigen::math::normalize;
/// @}

} // namespace vector

namespace matrix {

template <typename T, int ROWS, int COLS>
using matrix_type = eigen::matrix_type<T, ROWS, COLS>;
using element_getter_type = eigen::math::element_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>;

namespace determinant {

// determinant aggregation
template <typename size_type, 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>
using cofactor =
cmath::matrix::determinant::cofactor<size_type, matrix_type, scalar_t,
element_getter_type, Ds...>;

// determinant::hard_coded
template <typename size_type, typename scalar_t, size_type... Ds>
using hard_coded =
cmath::matrix::determinant::hard_coded<size_type, matrix_type, scalar_t,
element_getter_type, 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>>;

} // namespace determinant

namespace inverse {

// inverion aggregation
template <typename size_type, 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>
using cofactor =
cmath::matrix::inverse::cofactor<size_type, matrix_type, scalar_t,
element_getter_type, Ds...>;

// inverse::hard_coded
template <typename size_type, typename scalar_t, size_type... Ds>
using hard_coded =
cmath::matrix::inverse::hard_coded<size_type, matrix_type, scalar_t,
element_getter_type, 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>>;

} // namespace inverse

} // namespace matrix

} // namespace algebra
8 changes: 8 additions & 0 deletions frontend/eigen_eigen/include/algebra/eigen_eigen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,12 @@ using eigen::math::normalize;
/// @}

} // namespace vector

namespace matrix {

template <typename scalar_t>
using actor = eigen::matrix::actor<scalar_t>;

} // namespace matrix

} // namespace algebra
78 changes: 73 additions & 5 deletions frontend/smatrix_cmath/include/algebra/smatrix_cmath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ 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> >;
math::block_getter<T>>;
template <typename T>
using cartesian2 = cmath::cartesian2<transform3<T> >;
using cartesian2 = cmath::cartesian2<transform3<T>>;
template <typename T>
using polar2 = cmath::polar2<transform3<T> >;
using polar2 = cmath::polar2<transform3<T>>;
template <typename T>
using cylindrical2 = cmath::cylindrical2<transform3<T> >;
using cylindrical2 = cmath::cylindrical2<transform3<T>>;

/// @}

Expand All @@ -58,7 +58,7 @@ ALGEBRA_HOST_DEVICE inline auto vector(
const ROOT::Math::SMatrix<scalar_t, ROWS, COLS>& m, unsigned int row,
unsigned int col) {

return m.template SubCol<smatrix::storage_type<scalar_t, SIZE> >(col, row);
return m.template SubCol<smatrix::storage_type<scalar_t, SIZE>>(col, row);
}

/// @name Getter functions on @c algebra::smatrix::matrix_type
Expand All @@ -82,4 +82,72 @@ using smatrix::math::normalize;
/// @}

} // namespace vector

namespace matrix {

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

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

namespace determinant {

// determinant aggregation
template <typename size_type, 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>
using cofactor =
cmath::matrix::determinant::cofactor<size_type, matrix_type, scalar_t,
element_getter_type<scalar_t>, Ds...>;

// determinant::hard_coded
template <typename size_type, typename scalar_t, size_type... Ds>
using hard_coded = cmath::matrix::determinant::hard_coded<
size_type, matrix_type, scalar_t, element_getter_type<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>>;

} // namespace determinant

namespace inverse {

// inverion aggregation
template <typename size_type, 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>
using cofactor =
cmath::matrix::inverse::cofactor<size_type, matrix_type, scalar_t,
element_getter_type<scalar_t>, Ds...>;

// inverse::hard_coded
template <typename size_type, typename scalar_t, size_type... Ds>
using hard_coded =
cmath::matrix::inverse::hard_coded<size_type, matrix_type, scalar_t,
element_getter_type<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>>;

} // namespace inverse

} // namespace matrix

} // namespace algebra
8 changes: 8 additions & 0 deletions frontend/smatrix_smatrix/include/algebra/smatrix_smatrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,12 @@ using smatrix::math::normalize;
/// @}

} // namespace vector

namespace matrix {

template <typename scalar_t>
using actor = smatrix::matrix::actor<scalar_t>;

} // namespace matrix

} // namespace algebra
Loading

0 comments on commit bb634e6

Please sign in to comment.