12#include "algebra/impl/eigen_types.hpp"
13#include "detray/algebra/concepts.hpp"
14#include "detray/definitions/detail/qualifiers.hpp"
18#pragma warning(push, 0)
20#ifdef __NVCC_DIAG_PRAGMA_SUPPORT__
21#pragma nv_diagnostic push
22#pragma nv_diag_suppress 20012
24#include <Eigen/Cholesky>
29#ifdef __NVCC_DIAG_PRAGMA_SUPPORT__
30#pragma nv_diagnostic pop
33namespace detray::algebra::eigen::math {
36template <concepts::matrix matrix_t>
37DETRAY_HOST_DEVICE
constexpr matrix_t zero() {
38 return matrix_t::Zero();
42template <concepts::matrix matrix_t>
43DETRAY_HOST_DEVICE
constexpr matrix_t identity() {
44 return matrix_t::Identity();
48template <
typename derived_type>
49DETRAY_HOST_DEVICE
constexpr void set_zero(Eigen::MatrixBase<derived_type> &m) {
54template <
typename derived_type>
55DETRAY_HOST_DEVICE
constexpr void set_identity(
56 Eigen::MatrixBase<derived_type> &m) {
61template <
typename derived_type>
62DETRAY_HOST_DEVICE
constexpr matrix_type<
63 typename Eigen::MatrixBase<derived_type>::value_type,
64 Eigen::MatrixBase<derived_type>::ColsAtCompileTime,
65 Eigen::MatrixBase<derived_type>::RowsAtCompileTime>
66transpose(
const Eigen::MatrixBase<derived_type> &m) {
71template <
typename derived_type_1,
typename derived_type_2>
72 requires(Eigen::MatrixBase<derived_type_2>::RowsAtCompileTime == 3)
73DETRAY_HOST_DEVICE
constexpr matrix_type<
74 typename Eigen::MatrixBase<derived_type_1>::value_type,
75 Eigen::MatrixBase<derived_type_1>::RowsAtCompileTime,
76 Eigen::MatrixBase<derived_type_1>::ColsAtCompileTime>
77column_wise_cross(
const Eigen::MatrixBase<derived_type_1> &m,
78 const Eigen::MatrixBase<derived_type_2> &v) {
79 return m.colwise().cross(v);
83template <
typename derived_type_1,
typename derived_type_2>
84 requires(Eigen::MatrixBase<derived_type_1>::RowsAtCompileTime ==
85 Eigen::MatrixBase<derived_type_2>::RowsAtCompileTime)
86DETRAY_HOST_DEVICE
constexpr matrix_type<
87 typename Eigen::MatrixBase<derived_type_1>::value_type,
88 Eigen::MatrixBase<derived_type_1>::RowsAtCompileTime,
89 Eigen::MatrixBase<derived_type_1>::ColsAtCompileTime>
90column_wise_multiply(
const Eigen::MatrixBase<derived_type_1> &m,
91 const Eigen::MatrixBase<derived_type_2> &v) {
92 return m.array().colwise() * v.array();
96template <
typename derived_type_1,
typename derived_type_2>
97 requires(Eigen::MatrixBase<derived_type_1>::RowsAtCompileTime ==
98 Eigen::MatrixBase<derived_type_2>::RowsAtCompileTime)
99DETRAY_HOST_DEVICE
constexpr matrix_type<
100 typename Eigen::MatrixBase<derived_type_1>::value_type,
101 Eigen::MatrixBase<derived_type_1>::RowsAtCompileTime,
102 Eigen::MatrixBase<derived_type_1>::RowsAtCompileTime>
103outer_product(
const Eigen::MatrixBase<derived_type_1> &a,
104 const Eigen::MatrixBase<derived_type_2> &b) {
105 return a * b.transpose();
109template <
typename derived_type>
110DETRAY_HOST_DEVICE
constexpr
111 typename Eigen::MatrixBase<derived_type>::value_type
112 determinant(
const Eigen::MatrixBase<derived_type> &m) {
113 return m.determinant();
117template <
typename derived_type>
118DETRAY_HOST_DEVICE
constexpr matrix_type<
119 typename Eigen::MatrixBase<derived_type>::value_type,
120 Eigen::MatrixBase<derived_type>::RowsAtCompileTime,
121 Eigen::MatrixBase<derived_type>::ColsAtCompileTime>
122inverse(
const Eigen::MatrixBase<derived_type> &m) {
127template <
typename derived_type>
128DETRAY_HOST_DEVICE
constexpr matrix_type<
129 typename Eigen::MatrixBase<derived_type>::value_type,
130 Eigen::MatrixBase<derived_type>::RowsAtCompileTime,
131 Eigen::MatrixBase<derived_type>::ColsAtCompileTime>
132cholesky_decomposition(
const Eigen::MatrixBase<derived_type> &m) {
133 Eigen::LLT<derived_type> LL_T(m);
134 return LL_T.matrixL();
constexpr double m
Meter.
Definition Units.hpp:97