Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Eigen Identity matrix and Vc/SMatrix matrix getter and hide arithmetic operators in algebra namespace #141

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frontend/array_cmath/include/algebra/array_cmath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "algebra/math/generic.hpp"
#include "algebra/storage/array.hpp"

namespace algebra {

/// @name Operators on @c algebra::array::storage_type
/// @{

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

/// @}

namespace algebra {

namespace getter {

/// @name Getter functions on @c algebra::array::storage_type
Expand Down
4 changes: 2 additions & 2 deletions frontend/vecmem_cmath/include/algebra/vecmem_cmath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "algebra/math/generic.hpp"
#include "algebra/storage/vecmem.hpp"

namespace algebra {

/// @name Operators on @c algebra::vecmem::storage_type
/// @{

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

/// @}

namespace algebra {

namespace getter {

/// @name Getter functions on @c algebra::vecmem::matrix_type
Expand Down
10 changes: 6 additions & 4 deletions math/eigen/include/algebra/math/impl/eigen_transform3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,8 @@ struct transform3 {
/// @name Data objects
/// @{

Eigen::Transform<scalar_type, 3, Eigen::Affine> _data =
Eigen::Transform<scalar_type, 3, Eigen::Affine>::Identity();
Eigen::Transform<scalar_type, 3, Eigen::Affine> _data_inv =
Eigen::Transform<scalar_type, 3, Eigen::Affine>::Identity();
Eigen::Transform<scalar_type, 3, Eigen::Affine> _data;
Eigen::Transform<scalar_type, 3, Eigen::Affine> _data_inv;

/// @}

Expand All @@ -81,6 +79,8 @@ struct transform3 {
ALGEBRA_HOST_DEVICE
transform3(const vector3 &t, const vector3 &x, const vector3 &y,
const vector3 &z, bool get_inverse = true) {
_data.setIdentity();
niermann999 marked this conversation as resolved.
Show resolved Hide resolved

auto &matrix = _data.matrix();
matrix.template block<3, 1>(0, 0) = x;
matrix.template block<3, 1>(0, 1) = y;
Expand All @@ -89,6 +89,8 @@ struct transform3 {

if (get_inverse) {
_data_inv = _data.inverse();
} else {
_data_inv.setIdentity();
}
}

Expand Down
2 changes: 1 addition & 1 deletion storage/common/include/algebra/storage/matrix_getter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ ALGEBRA_HOST_DEVICE constexpr void set_block(
if constexpr (ROWS == mROW &&
matrix_t::storage_rows() == input_matrix_t::storage_rows()) {
if (row == 0u) {
for (std::size_t j = col; j < mCOL; ++j) {
for (std::size_t j = col; j < col + COLS; ++j) {
niermann999 marked this conversation as resolved.
Show resolved Hide resolved
m[j] = b[j - col];
}
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ struct block_getter {

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

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

return ret;
Expand Down
5 changes: 5 additions & 0 deletions tests/common/test_device_basics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class test_device_basics : public test_base<T> {
/// Perform various 2D vector operations, and produce a scalar output
ALGEBRA_HOST_DEVICE
scalar vector_2d_ops(point2 a, point2 b) const {
using namespace algebra;

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

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

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

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

transform3 tr1(t1, t2, t3);
transform3 tr2;
Expand Down
2 changes: 2 additions & 0 deletions tests/common/test_host_basics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include <climits>
#include <cmath>

using namespace algebra;

/// Test case class, to be specialised for the different plugins - vectors
template <typename T>
class test_host_basics_vector : public testing::Test, public test_base<T> {};
Expand Down
Loading