acts-project / algebra-plugins

Mozilla Public License 2.0
3 stars 10 forks source link

```operator==``` for vector types #76

Open niermann999 opened 1 year ago

niermann999 commented 1 year ago

Is there an operator== for vector types? I am comparing point types in detray on device and get a warning that this is a __host__ function

beomki-yeo commented 1 year ago

Is there warning Even with --expt-relaxed-constexpr CUDA compiler flag? Anyway, I very much like to have operator == for vector type for cmath plugin, but it's not possible because it is just std::array type. We need to refactor the vector and matrix type of cmath plugin, which I want to do.

niermann999 commented 1 year ago

Is there warning Even with --expt-relaxed-constexpr CUDA compiler flag? Anyway, I very much like to have operator == for vector type for cmath plugin, but it's not possible because it is just std::array type. We need to refactor the vector and matrix type of cmath plugin, which I want to do.

Hm, yes, I do get a warning in the detray grid unittest (complete and attach populator), but maybe I am comparing apples and oranges there. Essentially, the populator tries to find out where to put the next point3 by checking against an invalid point value. And that check, which involves operator== on std::array, works, but gives a warning. On cppreference at least the operator== is not listed as a constexpr function for c++17?

Anyway, it is not a priority right now, since it is only really needed for traccc, I guess

niermann999 commented 1 year ago

Oh, yes, I see. I might also have to figure out how to do boolean operations like these for vectorized types at some point...

beomki-yeo commented 1 year ago

OK. In the end, we might want to have something like the following for cmath:

template <typename scalar_t, int COLS, int ROWS>
struct matrix{
   std::array< std::array<scalar_t, COLS>, ROWS> m_data;
}

template < typename scalar_t, int ROWS>
struct vector: public_matrix<scalar_t, 1, ROWS>{};

Then we will be able to define the operators