Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
RealMatrix.Matrix Class Reference

Public Member Functions

 __init__ (self, Optional[NestedList] data=None, *Optional[int] rows=None, Optional[int] cols=None, Optional[Sequence[Number]] flat=None)
 
"Matrix" from_cpp (cls, cpp_obj)
 
int rows (self)
 
int cols (self)
 
Tuple[int, int] shape (self)
 
List[List[float]] to_list (self)
 
str __repr__ (self)
 
float __getitem__ (self, Tuple[int, int] idx)
 
None __setitem__ (self, Tuple[int, int] idx, Number value)
 
bool is_symmetric (self)
 
"Matrix" T (self)
 
"Matrix" inv (self)
 
SignedLogDet slogdet (self)
 
Tuple["Matrix", "Matrix"] eig (self)
 
 to_cpp (self)
 
"Matrix" __neg__ (self)
 
"Matrix" __add__ (self, Union["Matrix", NestedList] other)
 
"Matrix" __sub__ (self, Union["Matrix", NestedList] other)
 
"Matrix" __mul__ (self, Union["Matrix", NestedList, Number] other)
 
"Matrix" __rmul__ (self, Number other)
 
"Matrix" __truediv__ (self, Number other)
 
"Matrix" __matmul__ (self, Union["Matrix", NestedList] other)
 

Protected Member Functions

"Matrix" _from_cpp (cls, cpp_obj)
 

Static Protected Member Functions

 _as_cpp (Union["Matrix", NestedList] other)
 

Protected Attributes

 _cpp_obj
 

Detailed Description

Python wrapper for the C++ ``RealMatrix`` class.

The wrapper accepts common Python matrix representations and exposes Python
arithmetic operators. Matrix-matrix multiplication is also mapped to the
``@`` operator.

Args:
    data: Optional nested sequence representing a dense matrix.
    rows: Number of rows for an empty matrix or flat initialization.
    cols: Number of columns for an empty matrix or flat initialization.
    flat: Optional row-major flat values. Requires ``rows`` and ``cols``.

Raises:
    ValueError: If constructor arguments are incomplete or inconsistent.

Example:
    >>> A = Matrix([[1.0, 2.0], [3.0, 4.0]])
    >>> I = eye(2)
    >>> (A @ I).to_list()
    [[1.0, 2.0], [3.0, 4.0]]

Definition at line 34 of file RealMatrix.py.

Constructor & Destructor Documentation

◆ __init__()

RealMatrix.Matrix.__init__ (   self,
Optional[NestedList]   data = None,
*Optional[int]   rows = None,
Optional[int]   cols = None,
Optional[Sequence[Number]]   flat = None 
)

Definition at line 59 of file RealMatrix.py.

Member Function Documentation

◆ __add__()

"Matrix" RealMatrix.Matrix.__add__ (   self,
Union["Matrix", NestedList]  other 
)
Return matrix addition with another matrix-like object.

Definition at line 200 of file RealMatrix.py.

◆ __getitem__()

float RealMatrix.Matrix.__getitem__ (   self,
Tuple[int, int]  idx 
)
Return one matrix entry using ``matrix[i, j]`` indexing.

Definition at line 133 of file RealMatrix.py.

◆ __matmul__()

"Matrix" RealMatrix.Matrix.__matmul__ (   self,
Union["Matrix", NestedList]  other 
)
Return matrix multiplication using the Python ``@`` operator.

Definition at line 226 of file RealMatrix.py.

◆ __mul__()

"Matrix" RealMatrix.Matrix.__mul__ (   self,
Union["Matrix", NestedList, Number]  other 
)
Return C++ multiplication by a scalar or matrix-like object.

Definition at line 208 of file RealMatrix.py.

◆ __neg__()

"Matrix" RealMatrix.Matrix.__neg__ (   self)
Return ``-self``.

Definition at line 196 of file RealMatrix.py.

◆ __repr__()

str RealMatrix.Matrix.__repr__ (   self)
Return a compact representation containing the matrix shape.

Definition at line 128 of file RealMatrix.py.

◆ __rmul__()

"Matrix" RealMatrix.Matrix.__rmul__ (   self,
Number  other 
)
Return scalar multiplication from the left.

Definition at line 214 of file RealMatrix.py.

◆ __setitem__()

None RealMatrix.Matrix.__setitem__ (   self,
Tuple[int, int]  idx,
Number  value 
)
Set one matrix entry using ``matrix[i, j] = value`` indexing.

Definition at line 138 of file RealMatrix.py.

◆ __sub__()

"Matrix" RealMatrix.Matrix.__sub__ (   self,
Union["Matrix", NestedList]  other 
)
Return matrix subtraction with another matrix-like object.

Definition at line 204 of file RealMatrix.py.

◆ __truediv__()

"Matrix" RealMatrix.Matrix.__truediv__ (   self,
Number  other 
)
Return division by a scalar.

Definition at line 220 of file RealMatrix.py.

◆ _as_cpp()

RealMatrix.Matrix._as_cpp ( Union["Matrix", NestedList]  other)
staticprotected
Convert a Python matrix-like object to a C++ ``RealMatrix``.

Definition at line 190 of file RealMatrix.py.

◆ _from_cpp()

"Matrix" RealMatrix.Matrix._from_cpp (   cls,
  cpp_obj 
)
protected
Wrap an existing C++ ``RealMatrix`` object.

Args:
    cpp_obj: Bound C++ matrix object.

Returns:
    Matrix: Python wrapper sharing the provided C++ object.

Definition at line 86 of file RealMatrix.py.

◆ cols()

int RealMatrix.Matrix.cols (   self)
Number of matrix columns.

Definition at line 110 of file RealMatrix.py.

◆ eig()

Tuple["Matrix", "Matrix"] RealMatrix.Matrix.eig (   self)
Compute the eigensystem of the matrix.

Returns:
    tuple[Matrix, Matrix]: ``(D, P)``, where ``D`` is a diagonal matrix
    of eigenvalues and ``P`` contains eigenvectors as returned by C++.

Definition at line 175 of file RealMatrix.py.

◆ from_cpp()

"Matrix" RealMatrix.Matrix.from_cpp (   cls,
  cpp_obj 
)
Public alias for wrapping a C++ ``RealMatrix`` object.

Definition at line 100 of file RealMatrix.py.

◆ inv()

"Matrix" RealMatrix.Matrix.inv (   self)
Return the matrix inverse.

Returns:
    Matrix: Inverse matrix computed by C++.

Raises:
    RuntimeError: Propagated from the C++ backend if inversion fails.

Definition at line 155 of file RealMatrix.py.

◆ is_symmetric()

bool RealMatrix.Matrix.is_symmetric (   self)
Return whether the C++ backend considers the matrix symmetric.

Definition at line 143 of file RealMatrix.py.

◆ rows()

int RealMatrix.Matrix.rows (   self)
Number of matrix rows.

Definition at line 105 of file RealMatrix.py.

◆ shape()

Tuple[int, int] RealMatrix.Matrix.shape (   self)
Matrix shape as ``(rows, cols)``.

Definition at line 115 of file RealMatrix.py.

◆ slogdet()

SignedLogDet RealMatrix.Matrix.slogdet (   self)
Compute the signed logarithmic determinant.

Returns:
    SignedLogDet: Determinant sign and log-absolute determinant.

Definition at line 166 of file RealMatrix.py.

◆ T()

"Matrix" RealMatrix.Matrix.T (   self)
Return the transpose of the matrix.

Returns:
    Matrix: Transposed matrix.

Definition at line 147 of file RealMatrix.py.

◆ to_cpp()

RealMatrix.Matrix.to_cpp (   self)
Return the wrapped C++ matrix object.

Definition at line 185 of file RealMatrix.py.

◆ to_list()

List[List[float]] RealMatrix.Matrix.to_list (   self)
Return a nested Python list copy of the matrix.

Returns:
    list[list[float]]: Row-major matrix values.

Definition at line 120 of file RealMatrix.py.

Member Data Documentation

◆ _cpp_obj

RealMatrix.Matrix._cpp_obj
protected

Definition at line 68 of file RealMatrix.py.


The documentation for this class was generated from the following file: