mirror of
https://github.com/data61/MP-SPDZ.git
synced 2026-01-10 14:08:09 -05:00
51 lines
969 B
C++
51 lines
969 B
C++
/*
|
|
* gf2n_longlong.cpp
|
|
*
|
|
*/
|
|
|
|
#include "gf2nlong.h"
|
|
#include "gf2n.h"
|
|
|
|
#include "Tools/intrinsics.h"
|
|
#include "Tools/Exceptions.h"
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
bool is_ge(__m128i a, __m128i b)
|
|
{
|
|
word aa[2], bb[2];
|
|
_mm_storeu_si128((__m128i*)aa, a);
|
|
_mm_storeu_si128((__m128i*)bb, b);
|
|
// cout << hex << "is_ge " << aa[1] << " " << bb[1] << " " << (aa[1] > bb[1]) << " ";
|
|
// cout << aa[0] << " " << bb[0] << " " << (aa[0] >= bb[0]) << endl;
|
|
return aa[1] == bb[1] ? aa[0] >= bb[0] : aa[1] > bb[1];
|
|
}
|
|
|
|
|
|
ostream& operator<<(ostream& s, const int128& a)
|
|
{
|
|
word* tmp = (word*)&a.a;
|
|
s << hex;
|
|
s << noshowbase;
|
|
s.width(16);
|
|
s.fill('0');
|
|
s << tmp[1];
|
|
s.width(16);
|
|
s << tmp[0] << dec;
|
|
return s;
|
|
}
|
|
|
|
istream& operator>>(istream& s, int128& a)
|
|
{
|
|
bigint tmp;
|
|
s >> hex >> tmp;
|
|
a = 0;
|
|
auto size = tmp.get_mpz_t()->_mp_size;
|
|
assert(size >= 0);
|
|
assert(size <= 2);
|
|
mpn_copyi((mp_limb_t*) &a.a, tmp.get_mpz_t()->_mp_d, size);
|
|
s >> dec;
|
|
return s;
|
|
}
|