barretenberg
Loading...
Searching...
No Matches
Classes | Typedefs | Functions
numeric Namespace Reference

Classes

class  sparse_int
 
class  uint256_t
 
class  uintx
 

Typedefs

using uint512_t = uintx< numeric::uint256_t >
 
using uint1024_t = uintx< uint512_t >
 

Functions

template<typename T >
constexpr size_t count_leading_zeros (T const &u)
 
template<>
constexpr size_t count_leading_zeros< uint32_t > (uint32_t const &u)
 
template<>
constexpr size_t count_leading_zeros< uint64_t > (uint64_t const &u)
 
template<>
constexpr size_t count_leading_zeros< uint128_t > (uint128_t const &u)
 
template<>
constexpr size_t count_leading_zeros< uint256_t > (uint256_t const &u)
 
constexpr uint32_t get_msb32 (const uint32_t in)
 
constexpr uint64_t get_msb64 (const uint64_t in)
 
template<typename T >
constexpr T get_msb (const T in)
 
template<typename T >
keep_n_lsb (T const &input, size_t num_bits)
 
constexpr uint64_t pow64 (const uint64_t input, const uint64_t exponent)
 
constexpr bool is_power_of_two (uint64_t x)
 
constexpr uint64_t rotate64 (const uint64_t value, const uint64_t rotation)
 
constexpr uint32_t rotate32 (const uint32_t value, const uint32_t rotation)
 
std::vector< uint64_t > slice_input (const uint256_t &input, const uint64_t base, const size_t num_slices)
 
std::vector< uint64_t > slice_input_using_variable_bases (const uint256_t &input, const std::vector< uint64_t > &bases)
 
template<uint64_t base, uint64_t num_slices>
constexpr std::array< uint256_t, num_slices > get_base_powers ()
 
template<uint64_t base>
constexpr uint256_t map_into_sparse_form (const uint64_t input)
 
template<uint64_t base>
constexpr uint64_t map_from_sparse_form (const uint256_t &input)
 
std::ostream & operator<< (std::ostream &os, uint256_t const &a)
 
template<typename B >
void read (B &it, uint256_t &value)
 
template<typename B >
void write (B &it, uint256_t const &value)
 
template<typename B , typename Params >
void read (B &it, uintx< Params > &value)
 
template<typename B , typename Params >
void write (B &it, uintx< Params > const &value)
 
template<class base_uint >
std::ostream & operator<< (std::ostream &os, uintx< base_uint > const &a)
 

Detailed Description

uint256_t Copyright Aztec 2020

An unsigned 256 bit integer type.

Constructor and all methods are constexpr. Ideally, uint256_t should be able to be treated like any other literal type.

Not optimized for performance, this code doesn't touch any of our hot paths when constructing PLONK proofs.

uintx Copyright Aztec 2020

An unsigned 512 bit integer type.

Constructor and all methods are constexpr. Ideally, uintx should be able to be treated like any other literal type.

Not optimized for performance, this code doesn"t touch any of our hot paths when constructing PLONK proofs

Function Documentation

◆ count_leading_zeros()

template<typename T >
constexpr size_t numeric::count_leading_zeros ( T const &  u)
inlineconstexpr

Returns the number of leading 0 bits for a given integer type. Implemented in terms of intrinsics which will use instructions such as bsr or lzcnt for best performance. Undefined behavior when input is 0.