Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
utils.hpp
Go to the documentation of this file.
1
10#ifndef UTILS_HPP_
11#define UTILS_HPP_
12
13#include <cassert>
14#include <iostream>
15#include <sstream>
16#include <string>
17#include <vector>
18
19namespace libff {
20
21typedef std::vector<bool> bit_vector;
22
23size_t get_power_of_two(size_t n);
24
26size_t log2(size_t n);
27
28inline size_t exp2(size_t k) { return size_t(1) << k; }
29
30size_t to_twos_complement(int i, size_t w);
31int from_twos_complement(size_t i, size_t w);
32
33size_t bitreverse(size_t n, const size_t l);
34bit_vector int_list_to_bits(const std::initializer_list<unsigned long> &l, const size_t wordsize);
35long long div_ceil(long long x, long long y);
36
37bool is_little_endian();
38
39std::string FORMAT(const std::string &prefix, const char* format, ...);
40
41/* A variadic template to suppress unused argument warnings */
42template<typename ... Types>
43void UNUSED(Types&&...) {}
44
45#ifdef DEBUG
46#define FMT libff::FORMAT
47#else
48#define FMT(...) (libff::UNUSED(__VA_ARGS__), "")
49#endif
50
51void serialize_bit_vector(std::ostream &out, const bit_vector &v);
52void deserialize_bit_vector(std::istream &in, bit_vector &v);
53
54template<typename T>
55size_t size_in_bits(const std::vector<T> &v);
56
57#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
58
59} // libff
60
61#include <libff/common/utils.tcc> /* note that utils has a templatized part (utils.tcc) and non-templatized part (utils.cpp) */
62#endif // UTILS_HPP_
void deserialize_bit_vector(std::istream &in, bit_vector &v)
Definition utils.cpp:117
size_t bitreverse(size_t n, const size_t l)
Definition utils.cpp:60
size_t size_in_bits(const std::vector< T > &v)
size_t get_power_of_two(size_t n)
Definition utils.cpp:19
std::vector< bool > bit_vector
Definition utils.hpp:21
size_t log2(size_t n)
returns ceil(log2(n)), so 1ul<<log2(n) is the smallest power of 2, that is not less than n
Definition utils.cpp:32
bool is_little_endian()
Definition utils.cpp:89
std::string FORMAT(const std::string &prefix, const char *format,...)
Definition utils.cpp:96
bit_vector int_list_to_bits(const std::initializer_list< unsigned long > &l, const size_t wordsize)
Definition utils.cpp:71
size_t to_twos_complement(int i, size_t w)
Definition utils.cpp:47
int from_twos_complement(size_t i, size_t w)
Definition utils.cpp:54
size_t exp2(size_t k)
Definition utils.hpp:28
void serialize_bit_vector(std::ostream &out, const bit_vector &v)
Definition utils.cpp:108
long long div_ceil(long long x, long long y)
Definition utils.cpp:84
cmd_format format
#define UNUSED(x)
int l