Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Commit 878388c

Browse files
authored
fix: Eigen Identity matrix and Vc/SMatrix matrix getter and hide arithmetic operators in algebra namespace (#141)
The Eigen Identity matrix in the transform class leads to invalid instructions in CUDA. Also fixes small issues in the matrix getters of the Vc and SMatrix plugins. Also moves the arithmetic operators of the cmath plugin to the algebra namespace, since they were picked up in ACTS builds by Eigen types
1 parent d167b11 commit 878388c

7 files changed

Lines changed: 20 additions & 11 deletions

File tree

frontend/array_cmath/include/algebra/array_cmath.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include "algebra/math/generic.hpp"
1313
#include "algebra/storage/array.hpp"
1414

15+
namespace algebra {
16+
1517
/// @name Operators on @c algebra::array::storage_type
1618
/// @{
1719

@@ -21,8 +23,6 @@ using algebra::cmath::operator+;
2123

2224
/// @}
2325

24-
namespace algebra {
25-
2626
namespace getter {
2727

2828
/// @name Getter functions on @c algebra::array::storage_type

frontend/vecmem_cmath/include/algebra/vecmem_cmath.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include "algebra/math/generic.hpp"
1313
#include "algebra/storage/vecmem.hpp"
1414

15+
namespace algebra {
16+
1517
/// @name Operators on @c algebra::vecmem::storage_type
1618
/// @{
1719

@@ -21,8 +23,6 @@ using algebra::cmath::operator+;
2123

2224
/// @}
2325

24-
namespace algebra {
25-
2626
namespace getter {
2727

2828
/// @name Getter functions on @c algebra::vecmem::matrix_type

math/eigen/include/algebra/math/impl/eigen_transform3.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,8 @@ struct transform3 {
6565
/// @name Data objects
6666
/// @{
6767

68-
Eigen::Transform<scalar_type, 3, Eigen::Affine> _data =
69-
Eigen::Transform<scalar_type, 3, Eigen::Affine>::Identity();
70-
Eigen::Transform<scalar_type, 3, Eigen::Affine> _data_inv =
71-
Eigen::Transform<scalar_type, 3, Eigen::Affine>::Identity();
68+
Eigen::Transform<scalar_type, 3, Eigen::Affine> _data;
69+
Eigen::Transform<scalar_type, 3, Eigen::Affine> _data_inv;
7270

7371
/// @}
7472

@@ -81,6 +79,8 @@ struct transform3 {
8179
ALGEBRA_HOST_DEVICE
8280
transform3(const vector3 &t, const vector3 &x, const vector3 &y,
8381
const vector3 &z, bool get_inverse = true) {
82+
_data.setIdentity();
83+
8484
auto &matrix = _data.matrix();
8585
matrix.template block<3, 1>(0, 0) = x;
8686
matrix.template block<3, 1>(0, 1) = y;
@@ -89,6 +89,8 @@ struct transform3 {
8989

9090
if (get_inverse) {
9191
_data_inv = _data.inverse();
92+
} else {
93+
_data_inv.setIdentity();
9294
}
9395
}
9496

storage/common/include/algebra/storage/matrix_getter.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ ALGEBRA_HOST_DEVICE constexpr void set_block(
241241
if constexpr (ROWS == mROW &&
242242
matrix_t::storage_rows() == input_matrix_t::storage_rows()) {
243243
if (row == 0u) {
244-
for (std::size_t j = col; j < mCOL; ++j) {
244+
for (std::size_t j = col; j < col + COLS; ++j) {
245245
m[j] = b[j - col];
246246
}
247247
return;

storage/smatrix/include/algebra/storage/impl/smatrix_getter.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ struct block_getter {
145145

146146
ROOT::Math::SVector<scalar_t, SIZE> ret;
147147

148-
for (std::size_t irow = row; irow < row + SIZE; ++irow) {
149-
ret[irow - row] = m[col][irow];
148+
for (unsigned int irow = row; irow < row + SIZE; ++irow) {
149+
ret[irow - row] = m(irow, col);
150150
}
151151

152152
return ret;

tests/common/test_device_basics.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class test_device_basics : public test_base<T> {
4040
/// Perform various 2D vector operations, and produce a scalar output
4141
ALGEBRA_HOST_DEVICE
4242
scalar vector_2d_ops(point2 a, point2 b) const {
43+
using namespace algebra;
4344

4445
point2 c = a + b;
4546
point2 c2 = c * 2.0;
@@ -58,6 +59,7 @@ class test_device_basics : public test_base<T> {
5859
/// Perform various 3D vector operations, and produce a scalar output
5960
ALGEBRA_HOST_DEVICE
6061
scalar vector_3d_ops(vector3 a, vector3 b) const {
62+
using namespace algebra;
6163

6264
vector3 c = a + b;
6365
vector3 c2 = c * 2.0;
@@ -78,6 +80,7 @@ class test_device_basics : public test_base<T> {
7880
/// Perform some trivial operations on an asymmetrix matrix
7981
ALGEBRA_HOST_DEVICE
8082
scalar matrix64_ops(const matrix<6, 4>& m) const {
83+
using namespace algebra;
8184

8285
matrix<6, 4> m2;
8386
for (size_type i = 0; i < 6; ++i) {
@@ -139,6 +142,7 @@ class test_device_basics : public test_base<T> {
139142
/// Perform some trivial operations on an asymmetrix matrix
140143
ALGEBRA_HOST_DEVICE
141144
scalar matrix22_ops(const matrix<2, 2>& m22) const {
145+
using namespace algebra;
142146

143147
// Test 2 X 2 matrix determinant
144148
auto m22_det = algebra::matrix::determinant(m22);
@@ -202,6 +206,7 @@ class test_device_basics : public test_base<T> {
202206
ALGEBRA_HOST_DEVICE
203207
scalar transform3_ops(vector3 t1, vector3 t2, vector3 t3, vector3 a,
204208
vector3 b) const {
209+
using namespace algebra;
205210

206211
transform3 tr1(t1, t2, t3);
207212
transform3 tr2;

tests/common/test_host_basics.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include <cmath>
2323
#include <cstddef>
2424

25+
using namespace algebra;
26+
2527
/// Test case class, to be specialised for the different plugins - vectors
2628
template <typename T>
2729
class test_host_basics_vector : public testing::Test, public test_base<T> {};

0 commit comments

Comments
 (0)