pyva.data.matrixClasses.LinearMatrix
- class pyva.data.matrixClasses.LinearMatrix(data, **kwargs)
Bases:
object
Class for handling 3D data matrices in an efficient way.
- data
3D matrix in 3D or 2D depending on symmetry
- Type:
ndarry
- sym
Type of symmetry 0-no 1-sym 2-hermitian 3-diagonal
- Type:
int
- shape
shape of the matrix
- Type:
tuple
- __init__(data, **kwargs)
Class contructor for LinearMatrix.
When 3D data is provided the constructor checks if the matrix has any symmetry. When 2D data is provided the kwords must specify the detailed shape and symmetry
When only 3D data is given the symmetry will be automatically detected.
When the sym argemunet is used the data is given as 2D ndarray using a linear index for the upper triangle (sym in {1,2}) or the diagonal (sym = 3)
- Parameters:
data (ndarray) – 3D matrix or 2D when kwargs are used
**kwargs – Arbitrary argument list.
shape (tuple of int) – (Nrow,Ncol,Ndepth) shape dimension of the 3D matrix
sym (int) – symmetry sym=0,1,2 or 3 for irregular, symmetric, hermitian and diagonal
- Raises:
ValueError – When data, sym and shape are not consistent.
- Return type:
None.
Examples
import matrixClasses as mC mat3D = mC.LinearMatrix(3Ddata) mat3Dsym = mc.LinearMatrix(2Dtriudata,sym = 1,shape=(3,3,4) )
Methods
Dindex
(iz)Provides 2D matrix of in-depth index iz
H
()Hermitian of linear matrix
HDH
(other)HDH performt the left and right matrix multiplication by the inverse of other from left and right in a numerical stable way using solve
__init__
(data, **kwargs)Class contructor for LinearMatrix.
abs
()Abxolute value of Linear Matrix.
cond
([p])cond of linear matrix
copy
()copy method for LinearMatrix
diag
()Transpose of linear matrix
dot
(other)imag
()inv
()Inverse of linear matrix
isa
(typestr)mean
()Calculates the mean value of all coefficients in the matrix
real
()solve
(other)Solve linear matrix equation.
spy
([res, iz])Show sparasity of matrix in a graphical way.
sqrt
()square root.
sum
()Calculates the full sum of all coefficients in the matrix
Transpose of linear matrix
zeros
(sym, shape, **kwargs)zeros matrix creator with defined dimension
Attributes
Number of columns
Number of matrices
Number of rows
data property method
Shape of LinearMatrix.
Property method for sym
Property method for symstr
- Dindex(iz)
Provides 2D matrix of in-depth index iz
MM.Dindex(iz) == MM.data(:,:,iz)
- Parameters:
iz (int) – index in depth.
- Returns:
2D matrix.
- Return type:
ndarray
- H()
Hermitian of linear matrix
- HDH(other)
HDH performt the left and right matrix multiplication by the inverse of other from left and right in a numerical stable way using solve
- Parameters:
other – NOT inverted matrix D
- Returns:
D^-1 . self . D^-H
- property Ncol
Number of columns
- Returns:
Number of columns.
- Return type:
int
- property Ndepth
Number of matrices
size of third dimension
- Returns:
Number of matrices.
- Return type:
int
- property Nrow
Number of rows
- Returns:
Number of matrix rows.
- Return type:
int
- abs()
Abxolute value of Linear Matrix.
- Returns:
with all absolute value of coefficients.
- Return type:
- cond(p=None)
cond of linear matrix
- copy()
copy method for LinearMatrix
uses deepcopy
- Returns:
Deepcopy instance of LinearMatrix instance.
- Return type:
Linear Matrix
- property data
data property method
The method recreates the 3D data from the efficiently stored 2D data in case of sym in (1,2,3)
- Returns:
3D data.
- Return type:
ndarray
- diag()
Transpose of linear matrix
Returns
- inv()
Inverse of linear matrix
- mean()
Calculates the mean value of all coefficients in the matrix
- property shape
Shape of LinearMatrix.
- Returns:
(Nrow,Ncol,Ndepth) shape vector of Lineax matrix.
- Return type:
tuple
- solve(other)
Solve linear matrix equation.
With self=A and other=B the method returns the solution of A.X = B
- Parameters:
other – dependent variable of matrix equation.
- Raises:
TypeError – DESCRIPTION.
- Returns:
X, the solution of A.X = B
- Return type:
- spy(res='mag', iz=0, **kwargs)
Show sparasity of matrix in a graphical way. Uses matplotlib.pyplot.spy
- Parameters:
res – type of result ‘mag’,’real’,’imag’ or ‘phase’
iz – index of z-dimension
kwargs – for passing to matplotlib routine
- sqrt()
square root.
- Returns:
sqrt(self).
- Return type:
- sum()
Calculates the full sum of all coefficients in the matrix
- property sym
Property method for sym
- Returns:
Symmetry identifier.
- Return type:
int
- property symstr
Property method for symstr
- Returns:
Symmetry string.
- Return type:
str
- transpose()
Transpose of linear matrix
Returns
- static zeros(sym, shape, **kwargs)
zeros matrix creator with defined dimension
- Parameters:
sym (int) – Symmetry identifier.
shape (tuple of int) – (Nrow,Ncol,Ndepth) shape.
**kwargs (dict) – Arbitrary argument list passed to np.zeros method.
- Raises:
ValueError – DESCRIPTION.
- Returns:
zero matrix with defined dimension and shape.
- Return type: