forked from data61/MP-SPDZ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MamaRectangle.h
93 lines (76 loc) · 1.93 KB
/
MamaRectangle.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
* MamaRectangle.h
*
*/
#ifndef OT_MAMARECTANGLE_H_
#define OT_MAMARECTANGLE_H_
#include "Math/FixedVec.h"
#include "Math/gfp.h"
#include "Tools/BitVector.h"
template<class T, int N>
class MamaRectangle
{
typedef MamaRectangle This;
typename T::Square squares[N];
public:
typedef GC::NoValue RowType;
static int n_rows() { return T::Square::n_rows(); }
static int n_rows_allocated() { return n_rows(); }
static int n_columns() { return T::Square::n_columns(); }
static int n_row_bytes() { return T::Square::n_row_bytes(); }
static int size()
{
return N * T::Square::size();
}
void conditional_add(BitVector& conditions, This& other,
int offset)
{
for (int i = 0; i < N; i++)
squares[i].conditional_add(conditions, other.squares[i],
offset * N + i);
}
This& sub(const This& other)
{
for (int i = 0; i < N; i++)
squares[i].sub(other.squares[i]);
return *this;
}
This& rsub(const This& other)
{
for (int i = 0; i < N; i++)
squares[i].rsub(other.squares[i]);
return *this;
}
This& sub(const void* other)
{
for (int i = 0; i < N; i++)
squares[i].sub(other);
return *this;
}
void bit_sub(const BitVector&, int)
{
throw not_implemented();
}
void randomize(int row, PRNG& G)
{
squares[row / T::Square::n_rows()].randomize(
row % T::Square::n_rows(), G);
}
void pack(octetStream& os) const
{
for (int i = 0; i < N; i++)
squares[i].pack(os);
}
void unpack(octetStream& os)
{
for (int i = 0; i < N; i++)
squares[i].unpack(os);
}
template<class U>
void to(FixedVec<U, N>& result)
{
for (int i = 0; i < N; i++)
squares[i].to(result[i]);
}
};
#endif /* OT_MAMARECTANGLE_H_ */