Skip to content
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
25 changes: 14 additions & 11 deletions lib/kitty/kitty/bit_operations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@

#pragma once

#include <cstdint>
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <algorithm>

#include "detail/mscfix.hpp"
#include "partial_truth_table.hpp"
#include "quaternary_truth_table.hpp"
#include "static_truth_table.hpp"
#include "ternary_truth_table.hpp"
#include "quaternary_truth_table.hpp"
#include "partial_truth_table.hpp"
#include "detail/mscfix.hpp"

namespace kitty
{
Expand Down Expand Up @@ -342,8 +342,7 @@ template<typename TT>
inline uint64_t count_ones( const TT& tt )
{
return std::accumulate( tt.cbegin(), tt.cend(), uint64_t( 0 ),
[]( auto accu, auto word )
{
[]( auto accu, auto word ) {
return accu + __builtin_popcountll( word );
} );
}
Expand All @@ -354,6 +353,12 @@ inline uint64_t count_ones( const static_truth_table<NumVars, true>& tt )
{
return __builtin_popcountll( tt._bits );
}

template<typename TT>
inline uint64_t count_ones( const ternary_truth_table<TT>& tt )
{
return count_ones( tt._bits & tt._care );
}
/*! \endcond */

/*! \brief Count zeros in truth table
Expand Down Expand Up @@ -471,8 +476,7 @@ int64_t find_first_one_bit( const TT& tt, int64_t start = 0 )
return -1;
}

it = std::find_if( it + 1, tt.cend(), []( auto word )
{ return word != 0; } );
it = std::find_if( it + 1, tt.cend(), []( auto word ) { return word != 0; } );

if ( it == tt.cend() )
{
Expand All @@ -491,8 +495,7 @@ int64_t find_first_one_bit( const TT& tt, int64_t start = 0 )
template<typename TT>
int64_t find_last_one_bit( const TT& tt )
{
const auto it = std::find_if( tt.crbegin(), tt.crend(), []( auto word )
{ return word != 0; } );
const auto it = std::find_if( tt.crbegin(), tt.crend(), []( auto word ) { return word != 0; } );

if ( it == tt.crend() )
{
Expand Down
Loading
Loading