slepc4py.SLEPc.ST#
- class slepc4py.SLEPc.ST#
Bases:
ObjectSpectral Transformation.
The Spectral Transformation (
ST) class encapsulates the functionality required for acceleration techniques based on the transformation of the spectrum. The eigensolvers implemented inEPSwork by applying an operator to a set of vectors and this operator can adopt different forms. TheSTobject handles all the different possibilities in a uniform way, so that the solver can proceed without knowing which transformation has been selected. Polynomial eigensolvers inPEPalso support spectral transformation.Enumerations
ST filter damping.
ST filter type.
ST matrix mode.
ST type.
Methods Summary
appendOptionsPrefix([prefix])Append to the prefix used for searching for all ST options in the database.
apply(x, y)Apply the spectral transformation operator to a vector.
applyHermitianTranspose(x, y)Apply the Hermitian-transpose of the operator to a vector.
applyMat(X, Y)Apply the spectral transformation operator to a matrix.
applyTranspose(x, y)Apply the transpose of the operator to a vector.
create([comm])Create the ST object.
destroy()Destroy the ST object.
Get the value of the anti-shift for the Cayley spectral transformation.
Get the type of damping used in the polynomial filter.
Get the degree of the filter polynomial.
Get the interval containing the desired eigenvalues.
Get the interval containing all eigenvalues.
Get the method to be used to build the polynomial filter.
getKSP()Get the
KSPobject associated with the spectral transformation.Get a flag that indicates how the matrix is being shifted.
Get the internal matrix structure attribute.
Get the matrices associated with the eigenvalue problem.
Get a shell matrix that represents the operator of the spectral transformation.
Get the prefix used for searching for all ST options in the database.
Get the matrix previously set by
setPreconditionerMat().getShift()Get the shift associated with the spectral transformation.
Get the matrices to be used to build the preconditioner.
Get the flag indicating whether the transformed matrices are computed or not.
getType()Get the ST type of this object.
reset()Reset the ST object.
restoreOperator(op)Restore the previously seized operator matrix.
Set the value of the anti-shift for the Cayley spectral transformation.
setFilterDamping(damping)Set the type of damping to be used in the polynomial filter.
setFilterDegree(deg)Set the degree of the filter polynomial.
setFilterInterval(inta, intb)Set the interval containing the desired eigenvalues.
setFilterRange(left, right)Set the numerical range (or field of values) of the matrix.
setFilterType(filter_type)Set the method to be used to build the polynomial filter.
Set ST options from the options database.
setKSP(ksp)Set the
KSPobject associated with the spectral transformation.setMatMode(mode)Set a flag related to management of transformed matrices.
setMatStructure(structure)Set the matrix structure attribute.
setMatrices(operators)Set the matrices associated with the eigenvalue problem.
setOptionsPrefix([prefix])Set the prefix used for searching for all ST options in the database.
setPreconditionerMat([P])Set the matrix to be used to build the preconditioner.
setShift(shift)Set the shift associated with the spectral transformation.
setSplitPreconditioner(operators[, structure])Set the matrices to be used to build the preconditioner.
setTransform([flag])Set a flag to indicate whether the transformed matrices are computed or not.
setType(st_type)Set the particular spectral transformation to be used.
setUp()Prepare for the use of a spectral transformation.
view([viewer])Print the ST data structure.
Attributes Summary
KSP object associated with the spectral transformation.
How the transformed matrices are being stored in the ST.
Relation of the sparsity pattern of all ST matrices.
Value of the shift.
If the transformed matrices are computed.
Methods Documentation
- appendOptionsPrefix(prefix=None)#
Append to the prefix used for searching for all ST options in the database.
Logically collective.
- apply(x, y)#
Apply the spectral transformation operator to a vector.
Collective.
Apply the spectral transformation operator to a vector, for instance \(y=(A-\sigma B)^{-1}Bx\) in the case of the shift-and-invert transformation and generalized eigenproblem.
See also
- applyHermitianTranspose(x, y)#
Apply the Hermitian-transpose of the operator to a vector.
Collective.
Apply the Hermitian-transpose of the operator to a vector, for instance \(y=B^*(A - \sigma B)^{-*}x\) in the case of the shift-and-invert transformation and generalized eigenproblem.
See also
- applyMat(X, Y)#
Apply the spectral transformation operator to a matrix.
Collective.
Apply the spectral transformation operator to a matrix, for instance \(Y=(A-\sigma B)^{-1}BX\) in the case of the shift-and-invert transformation and generalized eigenproblem.
See also
- applyTranspose(x, y)#
Apply the transpose of the operator to a vector.
Collective.
Apply the transpose of the operator to a vector, for instance \(y=B^T(A-\sigma B)^{-T}x\) in the case of the shift-and-invert transformation and generalized eigenproblem.
See also
- create(comm=None)#
Create the ST object.
Collective.
- Parameters:
comm (Comm | None) – MPI communicator; if not provided, it defaults to all processes.
- Return type:
See also
- destroy()#
Destroy the ST object.
Collective.
See also
Source code at slepc4py/SLEPc/ST.pyx:119
- Return type:
- getCayleyAntishift()#
Get the value of the anti-shift for the Cayley spectral transformation.
Not collective.
- Returns:
The anti-shift.
- Return type:
See also
- getFilterDamping()#
Get the type of damping used in the polynomial filter.
Not collective.
- Returns:
The type of damping.
- Return type:
See also
- getFilterDegree()#
Get the degree of the filter polynomial.
Not collective.
- Returns:
The polynomial degree.
- Return type:
See also
- getFilterInterval()#
Get the interval containing the desired eigenvalues.
Not collective.
- Returns:
- Return type:
See also
- getFilterRange()#
Get the interval containing all eigenvalues.
Not collective.
- Returns:
- Return type:
See also
- getFilterType()#
Get the method to be used to build the polynomial filter.
Not collective.
- Returns:
The type of filter.
- Return type:
See also
- getKSP()#
Get the
KSPobject associated with the spectral transformation.Collective.
- Returns:
The linear solver object.
- Return type:
- getMatMode()#
Get a flag that indicates how the matrix is being shifted.
Not collective.
Get a flag that indicates how the matrix is being shifted in the shift-and-invert and Cayley spectral transformations.
- Returns:
The mode flag.
- Return type:
See also
- getMatStructure()#
Get the internal matrix structure attribute.
Not collective.
Get the internal
petsc4py.PETSc.Mat.Structureattribute to indicate which is the relation of the sparsity pattern of the matrices.- Returns:
The structure flag.
- Return type:
See also
- getMatrices()#
Get the matrices associated with the eigenvalue problem.
Collective.
- Returns:
The matrices associated with the eigensystem.
- Return type:
See also
- getOperator()#
Get a shell matrix that represents the operator of the spectral transformation.
Collective.
- Returns:
Operator matrix.
- Return type:
Notes
The operator is defined in linear eigenproblems only, not in polynomial ones, so the call will fail if more than 2 matrices were passed in
setMatrices().The returned shell matrix is essentially a wrapper to the
apply()andapplyTranspose()operations. The operator can often be expressed as\[Op = D K^{-1} M D^{-1}\]where \(D\) is the balancing matrix, and \(M\) and \(K\) are two matrices corresponding to the numerator and denominator for spectral transformations that represent a rational matrix function.
The preconditioner matrix \(K\) typically depends on the value of the shift, and its inverse is handled via an internal
KSPobject. Normal usage does not require explicitly callinggetOperator(), but it can be used to force the creation of \(K\) and \(M\), and then \(K\) is passed to theKSP. This is useful for setting options associated with thePCFactor(to set MUMPS options, for instance).The returned matrix must NOT be destroyed by the user. Instead, when no longer needed it must be returned with
restoreOperator(). In particular, this is required before modifying theSTmatrices or the shift.See also
apply,setMatrices,setShift,restoreOperator,STGetOperator
- getOptionsPrefix()#
Get the prefix used for searching for all ST options in the database.
Not collective.
- Returns:
The prefix string set for this ST object.
- Return type:
- getPreconditionerMat()#
Get the matrix previously set by
setPreconditionerMat().Not collective.
- Returns:
The matrix that will be used in constructing the preconditioner.
- Return type:
See also
- getShift()#
Get the shift associated with the spectral transformation.
Not collective.
- Returns:
The value of the shift.
- Return type:
See also
- getSplitPreconditioner()#
Get the matrices to be used to build the preconditioner.
Not collective.
- Returns:
listofpetsc4py.PETSc.Mat– The list of matrices associated with the preconditioner.petsc4py.PETSc.Mat.Structure– The structure flag.
- Return type:
tuple[list[petsc4py.PETSc.Mat], petsc4py.PETSc.Mat.Structure]
- getTransform()#
Get the flag indicating whether the transformed matrices are computed or not.
Not collective.
- Returns:
This flag is intended for the case of polynomial eigenproblems solved via linearization. If this flag is
False(default) the spectral transformation is applied to the linearization (handled by the eigensolver), otherwise it is applied to the original problem.- Return type:
See also
- getType()#
Get the ST type of this object.
Not collective.
- Returns:
The spectral transformation currently being used.
- Return type:
- reset()#
Reset the ST object.
Collective.
See also
Source code at slepc4py/SLEPc/ST.pyx:133
- Return type:
- restoreOperator(op)#
Restore the previously seized operator matrix.
Logically collective.
- Parameters:
op (Mat) – Operator matrix previously obtained with
getOperator().- Return type:
See also
- setCayleyAntishift(mu)#
Set the value of the anti-shift for the Cayley spectral transformation.
Logically collective.
Notes
In the generalized Cayley transform, the operator can be expressed as \((A - \sigma B)^{-1}(A + \mu B)\). This function sets the value of \(mu\). Use
setShift()for setting \(\sigma\).See also
- setFilterDamping(damping)#
Set the type of damping to be used in the polynomial filter.
Logically collective.
Parameter#
- damping
The type of damping.
Notes
Only used in
FilterType.CHEBYSHEVfilters.See also
- Parameters:
damping (FilterDamping)
- Return type:
- setFilterDegree(deg)#
Set the degree of the filter polynomial.
Logically collective.
See also
- setFilterInterval(inta, intb)#
Set the interval containing the desired eigenvalues.
Logically collective.
- Parameters:
- Return type:
Notes
The filter will be configured to emphasize eigenvalues contained in the given interval, and damp out eigenvalues outside it. If the interval is open, then the filter is low- or high-pass, otherwise it is mid-pass.
Common usage is to set the interval in
EPSwithEPS.setInterval().The interval must be contained within the numerical range of the matrix, see
setFilterRange().See also
- setFilterRange(left, right)#
Set the numerical range (or field of values) of the matrix.
Logically collective.
Set the numerical range (or field of values) of the matrix, that is, the interval containing all eigenvalues.
- Parameters:
- Return type:
Notes
The filter will be most effective if the numerical range is tight, that is,
leftandrightare good approximations to the leftmost and rightmost eigenvalues, respectively.See also
- setFilterType(filter_type)#
Set the method to be used to build the polynomial filter.
Logically collective.
Parameter#
- filter_type
The type of filter.
See also
- Parameters:
filter_type (FilterType)
- Return type:
- setFromOptions()#
Set ST options from the options database.
Collective.
Notes
To see all options, run your program with the
-helpoption.This routine must be called before
setUp()if the user is to be allowed to set the solver type.See also
Source code at slepc4py/SLEPc/ST.pyx:275
- Return type:
- setKSP(ksp)#
Set the
KSPobject associated with the spectral transformation.Collective.
- setMatMode(mode)#
Set a flag related to management of transformed matrices.
Logically collective.
The flag indicates how the transformed matrices are being stored in the spectral transformation.
Notes
By default (
ST.MatMode.COPY), a copy of matrix \(A\) is made and then this copy is modified explicitly, e.g., \(A \leftarrow (A - \sigma B)\).With
ST.MatMode.INPLACE, the original matrix \(A\) is modified atsetUp()and reverted at the end of the computations. With respect to the previous one, this mode avoids a copy of matrix \(A\). However, a backdraw is that the recovered matrix might be slightly different from the original one (due to roundoff).With
ST.MatMode.SHELL, the solver works with an implicit shell matrix that represents the shifted matrix. This mode is the most efficient in creating the transformed matrix but it places serious limitations to the linear solves performed in each iteration of the eigensolver (typically, only iterative solvers with Jacobi preconditioning can be used).In the two first modes the efficiency of this computation can be controlled with
setMatStructure().See also
- setMatStructure(structure)#
Set the matrix structure attribute.
Logically collective.
Set an internal
petsc4py.PETSc.Mat.Structureattribute to indicate which is the relation of the sparsity pattern of all theSTmatrices.- Parameters:
structure (petsc4py.PETSc.Mat.Structure) – The matrix structure specification.
- Return type:
Notes
By default, the sparsity patterns are assumed to be different. If the patterns are equal or a subset then it is recommended to set this attribute for efficiency reasons (in particular, for internal
Mat.axpy()operations).This function has no effect in the case of standard eigenproblems.
In case of polynomial eigenproblems, the flag applies to all matrices relative to the first one.
See also
- setMatrices(operators)#
Set the matrices associated with the eigenvalue problem.
Collective.
Notes
It must be called before
setUp(). If it is called again aftersetUp()then theSTobject is reset.In standard eigenproblems only one matrix is passed, while in generalized problems two matrices are provided. The number of matrices is larger in polynomial eigenproblems.
In normal usage, matrices are provided via the corresponding
EPSofPEPinterface function.See also
- setOptionsPrefix(prefix=None)#
Set the prefix used for searching for all ST options in the database.
Logically collective.
- Parameters:
prefix (str | None) – The prefix string to prepend to all ST option requests.
- Return type:
Notes
A hyphen (
-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen.
- setPreconditionerMat(P=None)#
Set the matrix to be used to build the preconditioner.
Collective.
- Parameters:
P (Mat | None) – The matrix that will be used in constructing the preconditioner.
- Return type:
Notes
This matrix will be passed to the internal
KSPobject (via the last argument ofKSP.setOperators()) as the matrix to be used when constructing the preconditioner. If no matrix is set then \(A-\sigma B\) will be used to build the preconditioner, being \(\sigma\) the value set bysetShift().More precisely, this is relevant for spectral transformations that represent a rational matrix function, and use a
KSPobject for the denominator. It includes also thePRECONDcase. If the user has a good approximation to matrix that can be used to build a cheap preconditioner, it can be passed with this function. Note that it affects only thePmatargument ofKSP.setOperators(), not theAmatargument.If a preconditioner matrix is set, the default is to use an iterative
KSPrather than a direct method.An alternative to pass an approximation of \(A-\sigma B\) with this function is to provide approximations of \(A\) and \(B\) via
setSplitPreconditioner(). The difference is that when \(\sigma\) changes the preconditioner is recomputed.A call with no matrix argument will remove a previously set matrix.
See also
- setShift(shift)#
Set the shift associated with the spectral transformation.
Collective.
Notes
In some spectral transformations, changing the shift may have associated a lot of work, for example recomputing a factorization.
This function is normally not directly called by users, since the shift is indirectly set by
EPS.setTarget().See also
- setSplitPreconditioner(operators, structure=None)#
Set the matrices to be used to build the preconditioner.
Collective.
- Parameters:
operators (list[petsc4py.PETSc.Mat]) – The matrices associated with the preconditioner.
structure (petsc4py.PETSc.Mat.Structure | None) – The matrix structure specification.
- Return type:
Notes
The number of matrices passed here must be the same as in
setMatrices().For linear eigenproblems, the preconditioner matrix is computed as \(P(\sigma) = A_0-\sigma B_0\), where \(A_0,B_0\) are approximations of \(A,B\) (the eigenproblem matrices) provided via the
operatorsargument in this function. Compared tosetPreconditionerMat(), this function allows setting a preconditioner in a way that is independent of the shift \(\sigma\). Whenever the value of \(\sigma\) changes the preconditioner is recomputed.Similarly, for polynomial eigenproblems the matrix for the preconditioner is expressed as \(P(\sigma) = \sum_i P_i \phi_i(\sigma)\), for \(i=1,\dots,n\), where \(P_i\) are given in
operatorsand the \(\phi_i\)’s are the polynomial basis functions.The
structureflag provides information about the relative nonzero pattern of theoperatorsmatrices, in the same way as insetMatStructure().
- setTransform(flag=True)#
Set a flag to indicate whether the transformed matrices are computed or not.
Logically collective.
- Parameters:
flag (bool) – This flag is intended for the case of polynomial eigenproblems solved via linearization. If this flag is
False(default) the spectral transformation is applied to the linearization (handled by the eigensolver), otherwise it is applied to the original problem.- Return type:
See also
- setType(st_type)#
Set the particular spectral transformation to be used.
Logically collective.
Notes
The default is
SHIFTwith a zero shift. Normally, it is best to usesetFromOptions()and then set the ST type from the options database rather than by using this routine. Using the options database provides the user with maximum flexibility in evaluating the different available methods.
- setUp()#
Prepare for the use of a spectral transformation.
Collective.
Source code at slepc4py/SLEPc/ST.pyx:746
- Return type:
- view(viewer=None)#
Print the ST data structure.
Collective.
- Parameters:
viewer (Viewer | None) – Visualization context; if not provided, the standard output is used.
- Return type:
See also
Attributes Documentation
- ksp#
KSP object associated with the spectral transformation.
- mat_mode#
How the transformed matrices are being stored in the ST.
- mat_structure#
Relation of the sparsity pattern of all ST matrices.
- shift#
Value of the shift.
- transform#
If the transformed matrices are computed.