Skip to content

Commit

Permalink
ff/baby_bear.hpp: add czero to bb31_4_t and adjust constructor availa…
Browse files Browse the repository at this point in the history
…bility.
  • Loading branch information
dot-asm committed Nov 27, 2024
1 parent ba732d8 commit b2ceb63
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ff/baby_bear.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ class __align__(16) bb31_4_t {
inline const bb31_t& operator[](size_t i) const { return c[i]; }
inline size_t len() const { return 4; }

inline bb31_4_t() {}
inline bb31_4_t(bb31_t a) { c[0] = a; u[1] = u[2] = u[3] = 0; }
__host__ inline bb31_4_t() {}
__host__ inline bb31_4_t(bb31_t a) { c[0] = a; u[1] = u[2] = u[3] = 0; }
// this is used in constant declaration, e.g. as bb31_4_t{1, 2, 3, 4}
__host__ inline bb31_4_t(int a)
{ c[0] = bb31_t{a}; u[1] = u[2] = u[3] = 0; }
Expand Down Expand Up @@ -641,6 +641,14 @@ class __align__(16) bb31_4_t {
inline bool is_zero() const
{ return (u[0] | u[1] | u[2] | u[3]) == 0; }

friend inline bb31_4_t czero(const bb31_4_t& a, int set_z)
{
bb31_4_t ret;
for (size_t i = 0; i < 4; i++)
ret[i] = czero(a[i], set_z);
return ret;
}

// raise to a variable power, variable in respect to threadIdx,
// but mind the ^ operator's precedence!
inline bb31_4_t& operator^=(uint32_t p)
Expand Down

0 comments on commit b2ceb63

Please sign in to comment.