PTile#
- class PTile#
A class representing an encoded (unencrypted) plaintext. It’s called a PTile because from a high-level point of view we’ll usually use several of these combined for holding a more complicated object such as a matrix.
- get_current_device(self: pyhelayers.PTile) Tuple[pyhelayers.DeviceType, int] #
Returns the current device of this PTile.
- Return type:
DeviceType, int
- is_all_zeroes(self: pyhelayers.PTile) bool #
Returns true if this PTile encodes all zeroes plaintext, and false otherwise.
- to_device(self: pyhelayers.PTile, type: pyhelayers.DeviceType, device_id: int = 0) None #
Move this PTile to another device.
- Parameters:
type – The device type to move to.
device_id – The device ID to move to. Device ID can be from 0 to n-1,
where n is the the number of devices of the specified type.
-
class PTile : public helayers::Tile#
A class representing an encoded (unencrypted) plaintext.
It’s called a PTile because from a high-level point of view we’ll usually use several of these combined for holding a more complicated object such as a matrix.
Public Functions
-
PTile(const HeContext &he)#
Constructs an empty object.
- Parameters:
he – [in] the underlying context.
-
virtual ~PTile()#
-
PTile &operator=(const PTile &src)#
Copy from another object.
- Parameters:
src – [in] Object to copy.
-
virtual void toDevice(DeviceType type, int deviceId = 0) override#
Move this PTile to another device.
- Parameters:
type – [in] The device type to move to.
deviceId – [in] The device ID to move to. Device ID can be from 0 to n-1, where n is the the number of devices of the specified type.
-
virtual std::pair<DeviceType, int> getCurrentDevice() const override#
Returns the current device of this PTile.
-
virtual void reduceChainIndex() override#
Reduces the chain-index property of this object by 1.
Ignored if not supported.
- Throws:
runtime_error – If chain index is already at lowest value
-
virtual void setChainIndex(int chainIndex) override#
Sets the chain-index property of this object to equal the specified value.
Can only be used if the specified value is less than or equal to the chain index of this object. Ignored if not supported.
- Parameters:
chainIndex – [in] The target value to set the chain index to
- Throws:
runtime_error – If the specified chain index is higher than this
-
virtual int getChainIndex() const override#
Returns the value of the chain-index property of this object, which is a non-negative integer.
Returns a negative value if not supported.
-
virtual void setScale(double scale) override#
Sets the attached meta data scale of the plaintext.
This may change the way its content are interpreted.
- Parameters:
scale – [in] the new scale
- Throws:
runtime_error – If not supported
-
virtual double getScale() const override#
Returns the attached meta data scale of the plaintext.
-
virtual int slotCount() const override#
A PTile represents a plaintext consisting of multiple slots.
This method returns the number of slots in this object.
-
bool isAllZeroes() const#
-
inline const AbstractPlaintext &getImpl() const#
Reserved for debugging and internal use.
-
virtual int64_t getEstimatedMemoryUsageBytes() const override#
Returns an estimation of the memory usage, or -1 if not supported.
-
inline virtual int32_t getContextId() const override#
Returns the contextId of the HeContext this object was initialized with.
This contextId can be used, for example, to verify HeContext match when loading a saved Saveable object. Returning -1 signals no HeContext.
-
virtual void debugPrint(const std::string &title = "", Verbosity verbosity = VERBOSITY_REGULAR, std::ostream &out = std::cout) const override#
Prints the content of this object.
- Parameters:
title – Text to add to the print
verbosity – Verbosity level
out – Output stream
-
void reencode(PTile &res, int newChainIndex) const#
Decodes this PTile and encodes the result into a new PTile whose chain index is equal to the given chain index.
Returns the new encoded PTile in the output parameter.
-
PTile(const HeContext &he)#