-
Notifications
You must be signed in to change notification settings - Fork 1
/
arith_extras.h
30 lines (23 loc) · 1.15 KB
/
arith_extras.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// FILE ARITH_EXTRAS.H: miscellaneous integer (int/long) functions
#if !defined(_ARITH_EXTRAS_H)
#define _ARITH_EXTRAS_H 1 //flags that this file has been included
// for convenience we put all the includes from eclib here, since all
// other files include this one directly or indirectly:
#include <eclib/xsplit.h> // which includes method.h
#include <eclib/rat.h>
#include <eclib/unimod.h>
#include <eclib/timer.h>
#include <eclib/curvesort.h> // for letter codes
void sqrt_mod_p(long & x, long a, long p);
// return the dot product (0/1) of a and b bitwise, with 0<=a,b<2^r
int dotbits(long a, long b, int r);
// return list of bits of a
vector<int> bits(long a, int r);
// recover a from its bit vector of length r
long from_bits(const vector<int>& aa, int r);
inline long from_bits(const vector<int>& aa) {return from_bits(aa, aa.size());}
// return a basis for the orthogonal complement of a<2^r (viewed as a bit vector of length r)
vector<long> dotperp(long a, int r);
// return a basis for the orthogonal complement of the span of a in alist (viewed as bit vectors of length r)
vector<long> dotperp(const vector<long>& alist, int r);
#endif