62 void (*Fnc)(ZZ&,
const ZZ&,
const ZZ&,
const ZZ&),
63 bool matchIndexSets=
true);
66 void (*Fnc)(ZZ&,
const ZZ&,
const ZZ&,
const ZZ&));
67 SingleCRT& Op(
const ZZ &num,
void (*Fnc)(ZZX&,
const ZZX&,
const ZZ&));
97 SingleCRT& operator=(
const ZZ& num) { *
this = to_ZZX(num);
return *
this; }
98 SingleCRT& operator=(
const long num) { *
this = to_ZZX(num);
return *
this; }
100 bool operator==(
const SingleCRT& other)
const {
101 return &context == &other.context && map == other.map;
104 bool operator!=(
const SingleCRT& other)
const {
105 return !(*
this==other);
110 SingleCRT& setZero() { *
this = ZZX::zero();
return *
this; }
111 SingleCRT& setOne() { *
this = 1;
return *
this; }
129 SingleCRT& operator+=(
const ZZX &poly) {
return Op(poly, NTL::AddMod);}
130 SingleCRT& operator+=(
const ZZ &num) {
return Op(num, NTL::add); }
131 SingleCRT& operator+=(
long num) {
return Op(to_ZZ(num), NTL::add); }
134 SingleCRT& operator-=(
const ZZX &poly) {
return Op(poly, NTL::SubMod); }
135 SingleCRT& operator-=(
const ZZ &num) {
return Op(num, NTL::sub); }
136 SingleCRT& operator-=(
long num) {
return Op(to_ZZ(num), NTL::sub); }
139 void Add(
const SingleCRT &other,
bool matchIndexSet=
true)
140 { Op(other, NTL::AddMod, matchIndexSet); }
141 void Sub(
const SingleCRT &other,
bool matchIndexSet=
true)
142 { Op(other, NTL::SubMod, matchIndexSet); }
145 SingleCRT& operator++() {
return (*
this += 1); };
146 SingleCRT& operator--() {
return (*
this -= 1); };
149 void operator++(
int) { *
this += 1; };
150 void operator--(
int) { *
this -= 1; };
153 SingleCRT& operator*=(
const ZZ &num) {
return Op(num,NTL::mul); }
154 SingleCRT& operator*=(
long num) {
return Op(to_ZZ(num),NTL::mul); }
158 SingleCRT& operator/=(
long num) {
return (*
this /= to_ZZ(num)); }
166 void toPoly(ZZX& p)
const;
172 friend ostream& operator<<(ostream &s,
const SingleCRT &scrt)
173 { s << scrt.polys;
return s; }
175 friend istream& operator>> (istream &s,
SingleCRT &scrt)
176 { s >> scrt.polys; scrt.verify();
return s; }
181 const FHEcontext& getContext()
const {
return context; }
183 inline void conv(
SingleCRT &s,
const ZZX &p) { s=p; }
186 inline void conv(ZZX &p,
const SingleCRT &s) { s.toPoly(p); }
187 inline ZZX to_ZZX(
const SingleCRT &s) { ZZX p; s.toPoly(p);
return p; }
190 #endif // #ifndef _SingleCRT_H_