custom_types
Classes:
-
Shape
–Enumeration for different matrix shapes and structural properties.
-
Printable
–Base class for objects that can be printed as \(\rm\LaTeX\).
-
PartGen
–Represents a matrix as the sum of a particular solution and a general solution.
-
ScalarFactor
–Represents a matrix factored into a diagonal matrix and a full matrix.
-
PLU
–Represents a PLU decomposition of a matrix.
-
RREF
–Represents the reduced row echelon form (RREF) of a matrix.
-
VecDecomp
–Represents a vector decomposition into projection and normal components.
-
QR
–Represents a QR decomposition of a matrix.
-
PDP
–Represents a PDP diagonalization of a matrix.
-
SVD
–Represents a symbolic Singular Value Decomposition (SVD) of a matrix.
-
NumSVD
–Represents a numerical Singular Value Decomposition (SVD) of a matrix.
Shape
¶
Bases: Enum
Enumeration for different matrix shapes and structural properties.
This enum defines various matrix shapes that can be used to specify the structure of matrices in mathematical operations and optimizations. Each shape represents a specific pattern of zero and non-zero elements.
Examples:
Attributes:
-
DIAGONAL
–Diagonal matrix.
-
SCALAR
–Scalar matrix (diagonal matrix with equal diagonal entries).
-
STRICT_UPPER
–Strictly upper triangular matrix.
-
STRICT_LOWER
–Strictly lower triangular matrix.
-
UPPER
–Upper triangular matrix.
-
LOWER
–Lower triangular matrix.
-
SYMMETRIC
–Symmetric matrix.
DIAGONAL = 'DIAGONAL'
class-attribute
instance-attribute
¶
Diagonal matrix.
A matrix where all off-diagonal entries are zero. Only elements on the main diagonal (\(i,j\) where \(i = j\)) can be non-zero. The diagonal entries can have different values and need not be square (unlike SCALAR matrices).
Example
SCALAR = 'SCALAR'
class-attribute
instance-attribute
¶
Scalar matrix (diagonal matrix with equal diagonal entries).
A square matrix where all diagonal entries are equal to the same scalar value, and all off-diagonal entries are zero. This is also known as a scalar matrix or scalar multiple of the identity matrix.
Example
STRICT_UPPER = 'STRICT_UPPER'
class-attribute
instance-attribute
¶
Strictly upper triangular matrix.
A matrix where all elements on and below the main diagonal are zero. Only elements above the main diagonal (\(i,j\) where \(i < j\)) can be non-zero.
Example
STRICT_LOWER = 'STRICT_LOWER'
class-attribute
instance-attribute
¶
Strictly lower triangular matrix.
A matrix where all elements on and above the main diagonal are zero. Only elements below the main diagonal (\(i,j\) where \(i > j\)) can be non-zero.
Example
UPPER = 'UPPER'
class-attribute
instance-attribute
¶
Upper triangular matrix.
A matrix where all elements below the main diagonal are zero. Elements on and above the main diagonal (\(i,j\) where \(i <= j\)) can be non-zero.
Example
LOWER = 'LOWER'
class-attribute
instance-attribute
¶
Lower triangular matrix.
A matrix where all elements above the main diagonal are zero. Elements on and below the main diagonal (\(i,j\) where \(i >= j\)) can be non-zero.
Example
SYMMETRIC = 'SYMMETRIC'
class-attribute
instance-attribute
¶
Symmetric matrix.
A square matrix where elements are symmetric about the main diagonal, meaning \(A_{i, j} = A_{j,i}\) for all valid indices \(i\) and \(j\).
Example
Printable()
dataclass
¶
Base class for objects that can be printed as \(\rm\LaTeX\).
Methods:
eval() -> Matrix
abstractmethod
¶
evalf(*args, **kwargs)
¶
Evaluates the object to a matrix of floats.
See Also
- SymPy's
Matrix.evalf()
PartGen(part_sol: Matrix, gen_sol: Matrix)
dataclass
¶
Bases: Printable
Represents a matrix as the sum of a particular solution and a general solution.
This dataclass is used to express the general solution to a linear system as the sum of a particular solution (with all free variables set to zero) and a general solution (the homogeneous part).
Attributes:
-
part_sol
(Matrix
) –The particular solution matrix.
-
gen_sol
(Matrix
) –The general (homogeneous) solution matrix.
ScalarFactor(diag: Matrix, full: Matrix, order: Literal['FD', 'DF'])
dataclass
¶
Bases: Printable
Represents a matrix factored into a diagonal matrix and a full matrix.
This dataclass is used to express a matrix as the product of a diagonal matrix (containing scalar factors) and a matrix with the common divisors factored out. The order of multiplication is specified by the 'order' attribute.
Attributes:
-
diag
(Matrix
) –The diagonal matrix containing the scalar factors.
-
full
(Matrix
) –The matrix with common divisors factored out.
-
order
(Literal['FD', 'DF']
) –The order of multiplication, either 'FD' (full @ diag) or 'DF' (diag @ full).
PLU(P: Matrix, L: Matrix, U: Matrix)
dataclass
¶
Bases: Printable
Represents a PLU decomposition of a matrix.
This dataclass stores the permutation matrix (P), lower triangular matrix (L), and upper triangular matrix (U) such that the original matrix can be written as P @ L @ U.
Attributes:
-
P
(Matrix
) –The permutation matrix.
-
L
(Matrix
) –The lower triangular matrix.
-
U
(Matrix
) –The upper triangular matrix.
RREF(rref: Matrix, pivots: tuple[int, ...])
dataclass
¶
VecDecomp(proj: Matrix, norm: Matrix)
dataclass
¶
Bases: Printable
Represents a vector decomposition into projection and normal components.
This dataclass is used to express a vector as the sum of its projection onto a subspace and its orthogonal component.
Attributes:
QR(Q: Matrix, R: Matrix)
dataclass
¶
PDP(P: Matrix, D: Matrix)
dataclass
¶
SVD(U: Matrix, S: Matrix, V: Matrix)
dataclass
¶
Bases: Printable
Represents a symbolic Singular Value Decomposition (SVD) of a matrix.
This dataclass stores the matrices U, S, and V such that the original matrix = U @ S @ V.T.
Attributes:
-
U
(Matrix
) –The left singular vectors.
-
S
(Matrix
) –The diagonal matrix of singular values.
-
V
(Matrix
) –The right singular vectors.
NumSVD
¶
Bases: NamedTuple
Represents a numerical Singular Value Decomposition (SVD) of a matrix.
This named tuple stores the numerical matrices U, S, and V from a numerical SVD computation.
Attributes:
-
U
(NDArray
) –The left singular vectors.
-
S
(NDArray
) –The diagonal matrix of singular values.
-
V
(NDArray
) –The right singular vectors.