Ptxt.h
typename Scheme::SlotType SlotType
Alias for type to be stored in the slots.
Definition: Ptxt.h:292
An object that mimics the functionality of the Ctxt object, and acts as a convenient entry point for ...
Definition: Ptxt.h:280
void deserialize(std::istream &is, std::complex< double > &num)
Deserialize a std::complex<double> from the input stream is delimited by '[' and ']' (instead of the ...
Definition: Ptxt.cpp:19
Ptxt< Scheme > & totalSums()
Compute the total sum (each slot contains the total sum of every slot).
Definition: Ptxt.cpp:812
Ptxt< Scheme > & operator=(Ptxt< Scheme > &&v) noexcept=default
Move assignment operator with other Ptxt.
Ptxt< Scheme > & random()
Populate slots with random data.
Definition: Ptxt.cpp:222
Ptxt< Scheme > & incrementalProduct()
Compute the incremental product (each slot is the product of the previous slots).
Definition: Ptxt.cpp:825
const std::vector< SlotType > & getSlotRepr() const
Get the data held in the slots as a std::vector<SlotType>.
Definition: Ptxt.cpp:230
long lsize() const
Returns the size (number of slots) of a Ptxt as long.
Definition: Ptxt.cpp:143
Ptxt< Scheme > & frobeniusAutomorph(long j)
Apply the frobenius automorphism a(X) -> a(X^(p^j)) mod Phi_m(X).
Ptxt< Scheme > & replicate(long pos)
Replicate single slot across all slots.
Definition: Ptxt.cpp:742
Ptxt< Scheme > & rotate(long amount)
Rotate slots right by specified amount (slot i goes to slot i+1 mod size).
Definition: Ptxt.cpp:567
Ptxt< Scheme > & multiplyBy(const Ptxt< Scheme > &otherPtxt)
Multiplication function between two Ptxt objects.
Definition: Ptxt.cpp:471
Ptxt< Scheme > operator+(const Ptxt< Scheme > &rhs) const
Infix addition operator.
Definition: Ptxt.cpp:336
std::vector< typename Scheme::SlotType > convertDataToSlotVector(const std::vector< From > &data, const Context &context)
Converts std::vector<From> to std::vector<Scheme::SlotType>.
Definition: Ptxt.h:69
std::complex< double > SlotType
Slot type used for CKKS plaintexts: std::complex<double>.
Definition: Ptxt.h:43
Ptxt< Scheme > & rotate1D(long dim, long amount)
Rotate slots right by specified amount along a specific dimension.
Definition: Ptxt.cpp:583
Ptxt< Scheme > & power(long e)
Power operation to raise a Ptxt to an arbitrary non-negative power.
Definition: Ptxt.cpp:540
Ptxt< Scheme > & addConstantCKKS(const Scalar &scalar)
Add a constant to a CKKS Ptxt.
Definition: Ptxt.h:635
Ptxt< Scheme > & multiplyBy2(const Ptxt &otherPtxt1, const Ptxt &otherPtxt2)
Multiplication function between three Ptxt objects.
Definition: Ptxt.cpp:489
Ptxt< Scheme > & complexConj()
Apply complex conjugate of complex numbers in slots of a CKKS Ptxt object.
Ptxt< Scheme > & addConstant(const Scalar &scalar)
Add a constant to a BGV Ptxt.
Definition: Ptxt.h:622
void serialize(std::ostream &os, const std::complex< double > &num)
Serialize a std::complex<double> to the output stream os delimited by '[' and ']' (instead of the def...
Definition: Ptxt.cpp:47
bool operator!=(const Ptxt< Scheme > &other) const
Not equals operator between two Ptxt objects.
Definition: Ptxt.cpp:313
Ptxt< Scheme > & automorph(long k)
Apply the automorphism a(X) -> a(X^k) mod Phi_m(X).
Ptxt(const Context &context, const NTL::ZZX &value)
BGV plaintext polynomial constructor, set all slots to the value polynomial.
void setData(const NTL::ZZX &value)
Set the Ptxt data replicating the input polynomial on all slots.
Ptxt< Scheme > & shift1D(long dim, long amount)
Shift slots right in one dimension of the hypercube structure with 0 fill.
Definition: Ptxt.cpp:646
Ptxt< Scheme > & shift(long amount)
Shifts slots right by specified amount with 0 fill (slot i goes to slot i+1 mod size).
Definition: Ptxt.cpp:626
Ptxt< Scheme > & operator-=(const Ptxt< Scheme > &otherPtxt)
Minus equals operator with another Ptxt.
Definition: Ptxt.cpp:430
void setData(const std::vector< SlotType > &data)
Set the data.
Definition: Ptxt.cpp:151
Ptxt< Scheme > & cleanUp()
To be inline with the Ctxt interface. However for Ptxt this means do nothing.
Definition: Ptxt.h:827
Ptxt< Scheme > & runningSums()
Compute the running sum (each slot is the sum of the previous slots).
Definition: Ptxt.cpp:801
void innerProduct(Ctxt &result, const CtPtrs &v1, const CtPtrs &v2)
Definition: Ctxt.cpp:2318
static SlotType convertToSlot(const Context &context, long slot)
Conversion function from long to SlotType.
Definition: apiAttributes.h:21
Ptxt< Scheme > & mapTo01()
Map all non-zero slots to 1, keeping zero slots as zero.
Definition: Ptxt.cpp:849
Ptxt< Scheme > & operator+=(const Scalar &scalar)
Plus equals operator with a scalar.
Definition: Ptxt.h:566
Ptxt< Scheme > & operator+=(const Ptxt< Scheme > &otherPtxt)
Plus equals operator with another Ptxt.
Definition: Ptxt.cpp:400
Ptxt< Scheme > operator-(const Ptxt< Scheme > &rhs) const
Infix subtraction operator.
Definition: Ptxt.cpp:353
std::ostream & operator<<(std::ostream &s, const SKHandle &handle)
Definition: Ctxt.h:190
Ptxt< Scheme > & operator-=(const Scalar &scalar)
Minus equals operator with a scalar.
Definition: Ptxt.h:597
const Context & getContext() const
Returns the context used to initialize the Ptxt
Definition: Ptxt.h:392
std::vector< Ptxt< Scheme > > replicateAll() const
Generate a vector of plaintexts with each slot replicated in each plaintext.
Definition: Ptxt.cpp:752
Ptxt< Scheme > & operator*=(const Scalar &scalar)
Times equals operator with a scalar.
Definition: Ptxt.h:535
NTL::ZZX getPolyRepr() const
Converts the slot data in this to its single polynomial representation.
Ptxt< Scheme > & operator*=(const Ptxt< Scheme > &otherPtxt)
Times equals operator with another Ptxt.
Definition: Ptxt.cpp:370
Ptxt< Scheme > operator*(const Ptxt< Scheme > &rhs) const
Infix multiplication operator.
Definition: Ptxt.cpp:319
An object that contains an NTL::ZZX polynomial along with a coefficient modulus p2r and a polynomial ...
Definition: PolyMod.h:47
Ptxt(const Context &context, const std::vector< T > &data)
Generic slot vector constructor.
Definition: Ptxt.h:337
SlotType & operator[](long i)
Square bracket accessor operator.
Definition: Ptxt.cpp:274
Ptxt()
Default constructor results in invalid Ptxt object which throws if used.
Definition: Ptxt.cpp:79
size_t size() const
Returns the size (number of slots) of a Ptxt.
Definition: Ptxt.cpp:135
Ptxt< Scheme > & operator=(const Ptxt< Scheme > &v)=default
Copy assignment operator with other Ptxt.
Ptxt< Scheme > & totalProduct()
Compute the total product (each slot contains the total product of every slot).
Definition: Ptxt.cpp:836
bool operator==(const Ptxt< Scheme > &other) const
Equals operator between two Ptxt objects.
Definition: Ptxt.cpp:306
void decodeSetData(const NTL::ZZX &data)
Set the Ptxt slots using values from decoding data to slot representation.