Skip to content

Commit

Permalink
BMat8: rows array by reference
Browse files Browse the repository at this point in the history
  • Loading branch information
james-d-mitchell committed Jan 15, 2020
1 parent 665c9be commit 3189cc4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/bmat8.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ class BMat8 {
size_t nr_rows() const;
//! Returns a \c std::vector for rows of \c this
std::vector<uint8_t> rows() const;
void rows(std::array<uint8_t, 8>&) const;

//! Returns the cardinality of the row space of \c this
//!
Expand Down
7 changes: 7 additions & 0 deletions include/bmat8_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,13 @@ inline std::vector<uint8_t> BMat8::rows() const {
return rows;
}

inline void BMat8::rows(std::array<uint8_t, 8>& rows) const {
rows.fill(0);
for (size_t i = 0; i < 8; ++i) {
rows[i] = static_cast<uint8_t>(_data << (8 * i) >> 56);
}
}

inline size_t BMat8::nr_rows() const {
epu8 x = _mm_set_epi64x(_data, 0);
return _mm_popcnt_u64(_mm_movemask_epi8(x != epu8 {}));
Expand Down

0 comments on commit 3189cc4

Please sign in to comment.