A single-CRT representation of a ring element. More...
#include <AltCRT.h>
Public Member Functions | |
AltCRT (const ZZX &poly, const FHEcontext &_context) | |
Initializing AltCRT from a ZZX polynomial. | |
AltCRT (const ZZX &poly, const FHEcontext &_context, const IndexSet &indexSet) | |
AltCRT (const ZZX &poly) | |
Context is not specified, use the "active context". | |
AltCRT (const FHEcontext &_context) | |
Without specifying a ZZX, we get the zero polynomial. | |
AltCRT (const FHEcontext &_context, const IndexSet &indexSet) | |
Also specify the IndexSet explicitly. | |
AltCRT & | operator= (const AltCRT &other) |
AltCRT & | operator= (const SingleCRT &other) |
AltCRT & | operator= (const ZZX &poly) |
AltCRT & | operator= (const ZZ &num) |
AltCRT & | operator= (const long num) |
void | toPoly (ZZX &p, bool positive=false) const |
Recovering the polynomial in coefficient representation. | |
void | toPoly (ZZX &p, const IndexSet &s, bool positive=false) const |
Recovering the polynomial in coefficient representation. This yields an integer polynomial with coefficients in [-P/2,P/2], unless the positive flag is set to true, in which case we get coefficients in [0,P-1] (P is the product of all moduli used). Using the optional IndexSet param we compute the polynomial reduced modulo the product of only the ptimes in that set. | |
bool | operator== (const AltCRT &other) const |
bool | operator!= (const AltCRT &other) const |
AltCRT & | SetZero () |
AltCRT & | SetOne () |
void | breakIntoDigits (vector< AltCRT > &dgts, long n) const |
Break into n digits,according to the primeSets in context.digits. See Section 3.1.6 of the design document (re-linearization) | |
void | addPrimes (const IndexSet &s1) |
Expand the index set by s1. It is assumed that s1 is disjoint from the current index set. | |
double | addPrimesAndScale (const IndexSet &s1) |
Expand index set by s1, and multiply by Prod_{q in s1}. s1 is disjoint from the current index set, returns log(product). | |
void | removePrimes (const IndexSet &s1) |
Remove s1 from the index set. | |
const FHEcontext & | getContext () const |
const IndexMap< zz_pX > & | getMap () const |
const IndexSet & | getIndexSet () const |
void | randomize (const ZZ *seed=NULL) |
Fills each row i with random ints mod pi, uses NTL's PRG. | |
void | sampleSmall () |
Coefficients are -1/0/1, Prob[0]=1/2. | |
void | sampleHWt (long Hwt) |
Coefficients are -1/0/1 with pre-specified number of nonzeros. | |
void | sampleGaussian (double stdev=0.0) |
Coefficients are Gaussians. | |
void | toSingleCRT (SingleCRT &scrt, const IndexSet &s) const |
Makes a corresponding SingleCRT object. | |
void | toSingleCRT (SingleCRT &scrt) const |
void | scaleDownToSet (const IndexSet &s, long ptxtSpace) |
Arithmetic operation | |
Only the "destructive" versions are used, i.e., a += b is implemented but not a + b. | |
AltCRT & | Negate (const AltCRT &other) |
AltCRT & | Negate () |
AltCRT & | operator+= (const AltCRT &other) |
AltCRT & | operator+= (const ZZX &poly) |
AltCRT & | operator+= (const ZZ &num) |
AltCRT & | operator+= (long num) |
AltCRT & | operator-= (const AltCRT &other) |
AltCRT & | operator-= (const ZZX &poly) |
AltCRT & | operator-= (const ZZ &num) |
AltCRT & | operator-= (long num) |
AltCRT & | operator++ () |
AltCRT & | operator-- () |
void | operator++ (int) |
void | operator-- (int) |
AltCRT & | operator*= (const AltCRT &other) |
AltCRT & | operator*= (const ZZX &poly) |
AltCRT & | operator*= (const ZZ &num) |
AltCRT & | operator*= (long num) |
void | Add (const AltCRT &other, bool matchIndexSets=true) |
void | Sub (const AltCRT &other, bool matchIndexSets=true) |
void | Mul (const AltCRT &other, bool matchIndexSets=true) |
AltCRT & | operator/= (const ZZ &num) |
AltCRT & | operator/= (long num) |
void | Exp (long k) |
Small-exponent polynomial exponentiation. | |
void | automorph (long k) |
AltCRT & | operator>>= (long k) |
Static Public Member Functions | |
static bool | setDryRun (bool toWhat=true) |
Used for testing/debugging The dry-run option disables most operations, to save time. This lets us quickly go over the evaluation of a circuit and estimate the resulting noise magnitude, without having to actually compute anything. | |
Friends | |
ostream & | operator<< (ostream &s, const AltCRT &d) |
istream & | operator>> (istream &s, AltCRT &d) |
A single-CRT representation of a ring element.
AltCRT offers the same interface as DoubleCRT, but with a different internal representation. That is, polynomials are stored in coefficient representation, modulo each of the small primes in our chain. Currently this class is used only for testing and debugging purposes.
AltCRT::AltCRT | ( | const ZZX & | poly, |
const FHEcontext & | _context, | ||
const IndexSet & | indexSet | ||
) |
poly | The ring element itself, zero if not specified |
_context | The context for this AltCRT object, use "current active context" if not specified |
indexSet | Which primes to use for this object, if not specified then use all of them |