Template Class MatrixStrassen
Defined in File matrixstrassen.h
Nested Relationships
Nested Types
Template Parameter Order
class Element
Class Documentation
-
template<class Element>
class lbcrypto::MatrixStrassen Public Types
Public Functions
-
inline MatrixStrassen(alloc_func allocZero, size_t rows, size_t cols)
Constructor that initializes matrix values using a zero allocator
- Parameters
&allocZero – lambda function for zero initialization.
&rows – number of rows.
&rows – number of columns.
-
MatrixStrassen(alloc_func allocZero, size_t rows, size_t cols, alloc_func allocGen)
Constructor that initializes matrix values using a distribution generation allocator
- Parameters
&allocZero – lambda function for zero initialization (used for initializing derived matrix objects)
&rows – number of rows.
&rows – number of columns.
&allocGen – lambda function for intialization using a distribution generator.
-
inline explicit MatrixStrassen(alloc_func allocZero)
Constructor of an empty matrix; SetSize must be called on this matrix to use it Basically this exists to support deserializing
- Parameters
&allocZero – lambda function for zero initialization.
-
inline void SetSize(size_t rows, size_t cols)
-
inline MatrixStrassen(const MatrixStrassen<Element> &other)
Copy constructor
- Parameters
&other – the matrix object to be copied
-
inline MatrixStrassen<Element> &operator=(const MatrixStrassen<Element> &other)
Assignment operator
- Parameters
&other – the matrix object whose values are to be copied
- Returns
the resulting matrix
-
inline MatrixStrassen<Element> &Ones()
In-place change of the current matrix to a matrix of all ones
- Returns
the resulting matrix
-
inline MatrixStrassen<Element> &Fill(const Element &val)
Fill matrix using the same element
- Parameters
&val – the element the matrix is filled by
- Returns
the resulting matrix
-
inline MatrixStrassen<Element> &Identity()
In-place change of the current matrix to Identity matrix
- Returns
the resulting matrix
-
inline MatrixStrassen<Element> GadgetVector(int32_t base = 2) const
Sets the first row to be powers of two
- Returns
the resulting matrix
-
inline double Norm() const
Computes the infinity norm
- Returns
the norm in double format
-
inline MatrixStrassen<Element> operator*(MatrixStrassen<Element> const &other) const
Operator for matrix multiplication
- Parameters
&other – the multiplier matrix
- Returns
the result of multiplication
-
inline MatrixStrassen<Element> ScalarMult(Element const &other) const
Multiplication of matrix by a scalar
- Parameters
&other – the multiplier element
- Returns
the result of multiplication
-
inline MatrixStrassen<Element> operator*(Element const &other) const
Operator for scalar multiplication
- Parameters
&other – the multiplier element
- Returns
the result of multiplication
-
inline bool Equal(MatrixStrassen<Element> const &other) const
Equality check
- Parameters
&other – the matrix object to compare to
- Returns
the boolean result
-
inline bool operator==(MatrixStrassen<Element> const &other) const
Operator for equality check
- Parameters
&other – the matrix object to compare to
- Returns
the boolean result
-
inline bool operator!=(MatrixStrassen<Element> const &other) const
Operator for non-equality check
- Parameters
&other – the matrix object to compare to
- Returns
the boolean result
-
inline const data_t &GetData() const
Get property to access the data as a vector of vectors
- Returns
the data as vector of vectors
-
inline size_t GetRows() const
Get property to access the number of rows in the matrix
- Returns
the number of rows
-
inline size_t GetCols() const
Get property to access the number of columns in the matrix
- Returns
the number of columns
-
inline alloc_func GetAllocator() const
Get property to access the zero allocator for the matrix
- Returns
the lambda function corresponding to the element zero allocator
-
void SetFormat(Format format)
Sets the evaluation or coefficient representation for all ring elements that support the SetFormat method
- Parameters
&format – the enum value corresponding to coefficient or evaluation representation
-
inline MatrixStrassen<Element> Add(MatrixStrassen<Element> const &other) const
MatrixStrassen addition
- Parameters
&other – the matrix to be added
- Returns
the resulting matrix
-
inline MatrixStrassen<Element> operator+(MatrixStrassen<Element> const &other) const
Operator for matrix addition
- Parameters
&other – the matrix to be added
- Returns
the resulting matrix
-
inline MatrixStrassen<Element> &operator+=(MatrixStrassen<Element> const &other)
Operator for in-place addition
- Parameters
&other – the matrix to be added
- Returns
the resulting matrix (same object)
-
inline MatrixStrassen<Element> Sub(MatrixStrassen<Element> const &other) const
MatrixStrassen substraction
- Parameters
&other – the matrix to be substracted
- Returns
the resulting matrix
-
inline MatrixStrassen<Element> operator-(MatrixStrassen<Element> const &other) const
Operator for matrix substraction
- Parameters
&other – the matrix to be substracted
- Returns
the resulting matrix
-
inline MatrixStrassen<Element> &operator-=(MatrixStrassen<Element> const &other)
Operator for in-place matrix substraction
- Parameters
&other – the matrix to be substracted
- Returns
the resulting matrix (same object)
-
inline MatrixStrassen<Element> Transpose() const
MatrixStrassen transposition
- Returns
the resulting matrix
-
inline void Determinant(Element *result) const
MatrixStrassen determinant - found using Laplace formula with complexity O(d!), where d is the dimension
- Parameters
*result – where the result is stored
-
inline MatrixStrassen<Element> CofactorMatrixStrassen() const
Cofactor matrix - the matrix of determinants of the minors A_{ij} multiplied by -1^{i+j}
- Returns
the cofactor matrix for the given matrix
-
inline MatrixStrassen<Element> &VStack(MatrixStrassen<Element> const &other)
Add rows to bottom of the matrix
- Parameters
&other – the matrix to be added to the bottom of current matrix
- Returns
the resulting matrix
-
inline MatrixStrassen<Element> &HStack(MatrixStrassen<Element> const &other)
Add columns the right of the matrix
- Parameters
&other – the matrix to be added to the right of current matrix
- Returns
the resulting matrix
-
inline Element &operator()(size_t row, size_t col)
MatrixStrassen indexing operator - writeable instance of the element
- Parameters
&row – row index
&col – column index
- Returns
the element at the index
-
inline Element const &operator()(size_t row, size_t col) const
MatrixStrassen indexing operator - read-only instance of the element
- Parameters
&row – row index
&col – column index
- Returns
the element at the index
-
inline MatrixStrassen<Element> ExtractRow(size_t row) const
MatrixStrassen row extractor
- Parameters
&row – row index
- Returns
the row at the index
-
inline void SwitchFormat()
Call switch format for each (ring) element
-
MatrixStrassen<Element> Mult(const MatrixStrassen<Element> &other, int nrec = 0, int pad = -1) const
MatrixStrassen multiplication
- Parameters
&other – the multiplier matrix
- Returns
the result of multiplication
-
MatrixStrassen<Element> MultByUnityVector() const
-
MatrixStrassen<Element> MultByRandomVector(std::vector<int> ranvec) const
-
inline MatrixStrassen(alloc_func allocZero, size_t rows, size_t cols)