Ptxt.h
Definition: EncodedPtxt.h:143
Represents the set of long int's plus a distinguished value that can be used to denote "undefined"....
Definition: NumbTh.h:998
An object that mimics the functionality of the Ctxt object, and acts as a convenient entry point for ...
Definition: Ptxt.h:188
Ptxt(const PubKey &pk)
Public key only constructor, defaults all slots to 0.
Definition: Ptxt.h:225
size_t size() const
Returns the size (number of slots) of a Ptxt.
Definition: Ptxt.cpp:91
void encode(EncodedPtxt &eptxt, double mag=-1, OptLong prec=OptLong()) const
Converts the slot data in this to a corresponding EncodedPtxt object. mag,prec must be defaulted for ...
Ptxt< Scheme > & addConstantCKKS(const Scalar &scalar)
Add a constant to a CKKS Ptxt.
Definition: Ptxt.h:564
Ptxt< Scheme > & rotate(long amount)
Rotate slots right by specified amount (slot i goes to slot i+1 mod size).
Definition: Ptxt.cpp:543
static SlotType convertToSlot(const Context &context, long slot)
Conversion function from long to SlotType.
Ptxt< Scheme > & replicate(long pos)
Replicate single slot across all slots.
Definition: Ptxt.cpp:719
Ptxt< Scheme > & operator+=(const Ptxt< Scheme > &otherPtxt)
Plus equals operator with another Ptxt.
Definition: Ptxt.cpp:376
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.
long lsize() const
Returns the size (number of slots) of a Ptxt as long.
Definition: Ptxt.cpp:99
Ptxt< Scheme > & incrementalProduct()
Compute the incremental product (each slot is the product of the previous slots).
Definition: Ptxt.cpp:802
Ptxt< Scheme > & runningSums()
Compute the running sum (each slot is the sum of the previous slots).
Definition: Ptxt.cpp:778
void decodeSetData(const NTL::ZZX &data)
Set the Ptxt slots using values from decoding data to slot representation.
Ptxt(const Context &context, const std::vector< T > &data)
Generic slot vector constructor.
Definition: Ptxt.h:258
const std::vector< SlotType > & getSlotRepr() const
Get the data held in the slots as a std::vector<SlotType>.
Definition: Ptxt.cpp:190
Ptxt< Scheme > & random()
Populate slots with random data.
Definition: Ptxt.cpp:182
static constexpr std::string_view typeName
Class label to be added to JSON serialization as object type information.
Definition: Ptxt.h:199
Ptxt< Scheme > & multiplyBy(const Ptxt< Scheme > &otherPtxt)
Multiplication function between two Ptxt objects.
Definition: Ptxt.cpp:447
void readJSON(std::istream &is)
In-place function to deserialize a Ptxt<Scheme> from a JSON stream.
Definition: Ptxt.cpp:997
Ptxt()
Default constructor results in invalid Ptxt object which throws if used.
Definition: Ptxt.cpp:35
Ptxt< Scheme > & multiplyBy2(const Ptxt &otherPtxt1, const Ptxt &otherPtxt2)
Multiplication function between three Ptxt objects.
Definition: Ptxt.cpp:465
Ptxt< Scheme > & totalProduct()
Compute the total product (each slot contains the total product of every slot).
Definition: Ptxt.cpp:813
Ptxt< Scheme > & cleanUp()
To be inline with the Ctxt interface. However for Ptxt this means do nothing.
Definition: Ptxt.h:872
Ptxt< Scheme > & operator-=(const Scalar &scalar)
Minus equals operator with a scalar.
Definition: Ptxt.h:526
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:602
typename Scheme::SlotType SlotType
Alias for type to be stored in the slots.
Definition: Ptxt.h:206
Ptxt< Scheme > & frobeniusAutomorph(long j)
Apply the frobenius automorphism a(X) -> a(X^(p^j)) mod Phi_m(X).
const Context & getContext() const
Returns the context used to initialize the Ptxt
Definition: Ptxt.h:313
void setData(const std::vector< SlotType > &data)
Set the data.
Definition: Ptxt.cpp:107
Ptxt< Scheme > & operator=(Ptxt< Scheme > &&v) noexcept=default
Move assignment operator with other Ptxt.
static Ptxt< Scheme > readFromJSON(std::istream &is, const Context &context)
Function to deserialize and return a Ptxt<Scheme> from a JSON stream.
Definition: Ptxt.cpp:979
SlotType & operator[](long i)
Square bracket accessor operator.
Definition: Ptxt.cpp:250
Ptxt< Scheme > operator*(const Ptxt< Scheme > &rhs) const
Infix multiplication operator.
Definition: Ptxt.cpp:295
Ptxt< Scheme > & addConstant(const Scalar &scalar)
Add a constant to a BGV Ptxt.
Definition: Ptxt.h:551
Ptxt< Scheme > & operator-=(const Ptxt< Scheme > &otherPtxt)
Minus equals operator with another Ptxt.
Definition: Ptxt.cpp:406
Ptxt< Scheme > & mapTo01()
Map all non-zero slots to 1, keeping zero slots as zero.
Definition: Ptxt.cpp:826
Ptxt< Scheme > & automorph(long k)
Apply the automorphism a(X) -> a(X^k) mod Phi_m(X).
Ptxt< Scheme > & rotate1D(long dim, long amount)
Rotate slots right by specified amount along a specific dimension.
Definition: Ptxt.cpp:559
bool operator==(const Ptxt< Scheme > &other) const
Equals operator between two Ptxt objects.
Definition: Ptxt.cpp:282
std::vector< Ptxt< Scheme > > replicateAll() const
Generate a vector of plaintexts with each slot replicated in each plaintext.
Definition: Ptxt.cpp:729
bool operator!=(const Ptxt< Scheme > &other) const
Not equals operator between two Ptxt objects.
Definition: Ptxt.cpp:289
Ptxt< Scheme > & operator*=(const Scalar &scalar)
Times equals operator with a scalar.
Definition: Ptxt.h:464
NTL::ZZX getPolyRepr() const
Converts the slot data in this to its single polynomial representation.
Ptxt< Scheme > & power(long e)
Power operation to raise a Ptxt to an arbitrary non-negative power.
Definition: Ptxt.cpp:516
Ptxt< Scheme > & complexConj()
Apply complex conjugate of complex numbers in slots of a CKKS Ptxt object.
Ptxt< Scheme > & operator+=(const Scalar &scalar)
Plus equals operator with a scalar.
Definition: Ptxt.h:495
Ptxt< Scheme > operator+(const Ptxt< Scheme > &rhs) const
Infix addition operator.
Definition: Ptxt.cpp:312
Ptxt< Scheme > & totalSums()
Compute the total sum (each slot contains the total sum of every slot).
Definition: Ptxt.cpp:789
Ptxt< Scheme > & shift1D(long dim, long amount)
Shift slots right in one dimension of the hypercube structure with 0 fill.
Definition: Ptxt.cpp:622
Ptxt< Scheme > & operator*=(const Ptxt< Scheme > &otherPtxt)
Times equals operator with another Ptxt.
Definition: Ptxt.cpp:346
Ptxt< Scheme > & operator=(const Ptxt< Scheme > &v)=default
Copy assignment operator with other Ptxt.
JsonWrapper writeToJSON() const
Function to serialize this Ptxt<Scheme>.
Definition: Ptxt.cpp:956
Ptxt< Scheme > operator-(const Ptxt< Scheme > &rhs) const
Infix subtraction operator.
Definition: Ptxt.cpp:329
Definition: apiAttributes.h:21
void innerProduct(Ctxt &result, const CtPtrs &v1, const CtPtrs &v2)
Definition: Ctxt.cpp:2853
std::ostream & operator<<(std::ostream &os, const ContextBuilder< SCHEME > &cb)
ostream operator for serializing the ContextBuilder object.
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:48
Definition: JsonWrapper.h:9