slepc4py.SLEPc.SVD

Package slepc4py :: Module SLEPc :: Class SVD |
[hide private]
[frames] | no frames]

# Class SVD

SVD

Nested Classes | [hide private]
| Conv SVD convergence test
| ConvergedReason SVD convergence reasons
| ErrorType SVD error type to assess accuracy of computed solutions
| ProblemType SVD problem type
| Stop SVD stopping test
| TRLanczosGBidiag SVD TRLanczos bidiagonalization choices for the GSVD case
| Type SVD types
| Which SVD desired part of spectrum

Instance Methods | [hide private]
a new object with type S, a subtype of T |
__new__(S, ...) |
appendOptionsPrefix(self, prefix) Appends to the prefix used for searching for all SVD options in the database. |
cancelMonitor(self) Clears all monitors for an SVD object. |
computeError(self, int i, etype=None) Computes the error (based on the residual norm) associated with the i-th singular triplet. |
create(self, comm=None) Creates the SVD object. |
destroy(self) Destroys the SVD object. |
errorView(self, etype=None, Viewer viewer=None) Displays the errors associated with the computed solution (as well as the eigenvalues). |
getBV(self) Obtain the basis vectors objects associated to the SVD object. |
getConverged(self) Gets the number of converged singular triplets. |
getConvergedReason(self) Gets the reason why the solve() iteration was stopped. |
getConvergenceTest(self) Return the method used to compute the error estimate used in the convergence test. |
getCrossEPS(self) Retrieve the eigensolver object (EPS) associated to the singular value solver. |
getCrossExplicitMatrix(self) Returns the flag indicating if `A^T*A` is built explicitly. |
getCyclicEPS(self) Retrieve the eigensolver object (EPS) associated to the singular value solver. |
getCyclicExplicitMatrix(self) Returns the flag indicating if `H(A) = [ 0 A ; A^T 0 ]` is built explicitly. |
getDS(self) Obtain the direct solver associated to the singular value solver. |
getDimensions(self) Gets the number of singular values to compute and the dimension of the subspace. |
getImplicitTranspose(self) Gets the mode used to handle the transpose of the matrix associated with the singular value problem. |
getIterationNumber(self) Gets the current iteration number. |
getLanczosOneSide(self) Gets if the variant of the Lanczos method to be used is one-sided or two-sided. |
getMonitor(self) Gets the list of monitor functions. |
getOperators(self) Gets the matrices associated with the singular value problem. |
getOptionsPrefix(self) Gets the prefix used for searching for all SVD options in the database. |
getProblemType(self) Gets the problem type from the SVD object. |
getSignature(self) Gets the signature matrix defining a hyperbolic singular value problem. |
getSingularTriplet(self, int i, Vec U=None, Vec V=None) Gets the i-th triplet of the singular value decomposition as computed by solve(). |
getStoppingTest(self) Gets the stopping function. |
getTRLanczosExplicitMatrix(self) Returns the flag indicating if `Z=[A;B]` is built explicitly. |
getTRLanczosGBidiag(self) Returns bidiagonalization choice used in the GSVD TRLanczos solver. |
getTRLanczosKSP(self) Retrieve the linear solver object associated with the SVD solver. |
getTRLanczosLocking(self) Gets the locking flag used in the thick-restart Lanczos method. |
getTRLanczosOneSide(self) Gets if the variant of the thick-restart Lanczos method to be used is one-sided or two-sided. |
getTRLanczosRestart(self) Gets the restart parameter used in the thick-restart Lanczos method. |
getTolerances(self) Gets the tolerance and maximum iteration count used by the default SVD convergence tests. |
getTrackAll(self) Returns the flag indicating whether all residual norms must be computed or not. |
getType(self) Gets the SVD type of this object. |
getValue(self, int i) Gets the i-th singular value as computed by solve(). |
getVectors(self, int i, Vec U, Vec V) Gets the i-th left and right singular vectors as computed by solve(). |
getWhichSingularTriplets(self) Returns which singular triplets are to be sought. |
isGeneralized(self) Tells whether the SVD object corresponds to a generalized singular value problem. |
isHyperbolic(self) Tells whether the SVD object corresponds to a hyperbolic singular value problem. |
reset(self) Resets the SVD object. |
setBV(self, BV V, BV U=None) Associates basis vectors objects to the SVD solver. |
setConvergenceTest(self, conv) Specifies how to compute the error estimate used in the convergence test. |
setCrossEPS(self, EPS eps) Associate an eigensolver object (EPS) to the singular value solver. |
setCrossExplicitMatrix(self, flag=True) Indicate if the eigensolver operator `A^T*A` must be computed explicitly. |
setCyclicEPS(self, EPS eps) Associate an eigensolver object (EPS) to the singular value solver. |
setCyclicExplicitMatrix(self, flag=True) Indicate if the eigensolver operator `H(A) = [ 0 A ; A^T 0 ]` must be computed explicitly. |
setDS(self, DS ds) Associates a direct solver object to the singular value solver. |
setDimensions(self, nsv=None, ncv=None, mpd=None) Sets the number of singular values to compute and the dimension of the subspace. |
setFromOptions(self) Sets SVD options from the options database. |
setImplicitTranspose(self, mode) Indicates how to handle the transpose of the matrix associated with the singular value problem. |
setInitialSpaces(self, spaceright=None, spaceleft=None) Sets the initial spaces from which the SVD solver starts to iterate. |
setLanczosOneSide(self, flag=True) Indicate if the variant of the Lanczos method to be used is one-sided or two-sided. |
setMonitor(self, monitor, args=None, kargs=None) Appends a monitor function to the list of monitors. |
setOperator(self, Mat A, Mat B=None) Sets the matrices associated with the singular value problem. |
setOperators(self, Mat A, Mat B=None) Sets the matrices associated with the singular value problem. |
setOptionsPrefix(self, prefix) Sets the prefix used for searching for all SVD options in the database. |
setProblemType(self, problem_type) Specifies the type of the singular value problem. |
setSignature(self, Vec omega=None) Sets the signature matrix defining a hyperbolic singular value problem. |
setStoppingTest(self, stopping, args=None, kargs=None) Sets a function to decide when to stop the outer iteration of the eigensolver. |
setTRLanczosExplicitMatrix(self, flag=True) Indicate if the matrix `Z=[A;B]` must be built explicitly. |
setTRLanczosGBidiag(self, bidiag) Sets the bidiagonalization choice to use in the GSVD TRLanczos solver. |
setTRLanczosKSP(self, KSP ksp) Associate a linear solver object to the SVD solver. |
setTRLanczosLocking(self, lock) Choose between locking and non-locking variants of the thick-restart Lanczos method. |
setTRLanczosOneSide(self, flag=True) Indicate if the variant of the thick-restart Lanczos method to be used is one-sided or two-sided. |
setTRLanczosRestart(self, keep) Sets the restart parameter for the thick-restart Lanczos method, in particular the proportion of basis vectors that must be kept after restart. |
setTolerances(self, tol=None, max_it=None) Sets the tolerance and maximum iteration count used by the default SVD convergence tests. |
setTrackAll(self, trackall) Specifies if the solver must compute the residual of all approximate singular triplets or not. |
setType(self, svd_type) Selects the particular solver to be used in the SVD object. |
setUp(self) Sets up all the internal data structures necessary for the execution of the singular value solver. |
setWhichSingularTriplets(self, which) Specifies which singular triplets are to be sought. |
solve(self) Solves the singular value problem. |
valuesView(self, Viewer viewer=None) Displays the computed singular values in a viewer. |
vectorsView(self, Viewer viewer=None) Outputs computed singular vectors to a viewer. |
view(self, Viewer viewer=None) Prints the SVD data structure. |
Inherited from `petsc4py.PETSc.Object`: `__copy__`, `__deepcopy__`, `__eq__`, `__ge__`, `__gt__`, `__le__`, `__lt__`, `__ne__`, `__nonzero__`, `compose`, `decRef`, `getAttr`, `getClassId`, `getClassName`, `getComm`, `getDict`, `getName`, `getRefCount`, `getTabLevel`, `incRef`, `incrementTabLevel`, `query`, `setAttr`, `setName`, `setTabLevel`, `stateGet`, `stateIncrease`, `stateSet`, `viewFromOptions` Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__init__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties | [hide private]
| ds
| max_it
| problem_type
| tol
| track_all
| transpose_mode
| which
Inherited from `petsc4py.PETSc.Object`: `classid`, `comm`, `fortran`, `handle`, `klass`, `name`, `prefix`, `refcount`, `type` Inherited from `object`: `__class__`

Method Details | [hide private]

### __new__(S, ...) |
Returns: a new object with type S, a subtype of T Overrides: object.__new__

### appendOptionsPrefix(self, prefix) |
Appends to the prefix used for searching for all SVD options in the database. # Parameters prefix: string The prefix string to prepend to all SVD option requests. Overrides: petsc4py.PETSc.Object.appendOptionsPrefix

### computeError(self, int i, etype=None) |
Computes the error (based on the residual norm) associated with the i-th singular triplet. # Parameters i: int Index of the solution to be considered. etype: SVD.ErrorType enumerate The error type to compute. # Returns e: real The relative error bound, computed in various ways from the residual norm `sqrt(n1^2+n2^2)` where `n1 = ||A*v-sigma*u||_2`, `n2 = ||A^T*u-sigma*v||_2`, `sigma` is the singular value, `u` and `v` are the left and right singular vectors. # Notes The index `i` should be a value between `0` and `nconv-1` (see getConverged()).

### create(self, comm=None) |
Creates the SVD object. # Parameters comm: Comm, optional MPI communicator; if not provided, it defaults to all processes.

### destroy(self) |
Destroys the SVD object. Overrides: petsc4py.PETSc.Object.destroy

### errorView(self, etype=None, Viewer viewer=None) |
Displays the errors associated with the computed solution (as well as the eigenvalues). # Parameters etype: SVD.ErrorType enumerate, optional The error type to compute. viewer: Viewer, optional. Visualization context; if not provided, the standard output is used. # Notes By default, this function checks the error of all eigenpairs and prints the eigenvalues if all of them are below the requested tolerance. If the viewer has format `ASCII_INFO_DETAIL` then a table with eigenvalues and corresponding errors is printed.

### getBV(self) |
Obtain the basis vectors objects associated to the SVD object. # Returns V: BV The basis vectors context for right singular vectors. U: BV The basis vectors context for left singular vectors.

### getConverged(self) |
Gets the number of converged singular triplets. # Returns nconv: int Number of converged singular triplets. # Notes This function should be called after solve() has finished.

### getConvergedReason(self) |
Gets the reason why the solve() iteration was stopped. # Returns reason: SVD.ConvergedReason enumerate Negative value indicates diverged, positive value converged.

### getConvergenceTest(self) |
Return the method used to compute the error estimate used in the convergence test. # Returns conv: SVD.Conv The method used to compute the error estimate used in the convergence test.

### getCrossEPS(self) |
Retrieve the eigensolver object (EPS) associated to the singular value solver. # Returns eps: EPS The eigensolver object.

### getCrossExplicitMatrix(self) |
Returns the flag indicating if `A^T*A` is built explicitly. # Returns flag: bool True if `A^T*A` is built explicitly.

### getCyclicEPS(self) |
Retrieve the eigensolver object (EPS) associated to the singular value solver. # Returns eps: EPS The eigensolver object.

### getCyclicExplicitMatrix(self) |
Returns the flag indicating if `H(A) = [ 0 A ; A^T 0 ]` is built explicitly. # Returns flag: bool True if `H(A)` is built explicitly.

### getDS(self) |
Obtain the direct solver associated to the singular value solver. # Returns ds: DS The direct solver context.

### getDimensions(self) |
Gets the number of singular values to compute and the dimension of the subspace. # Returns nsv: int Number of singular values to compute. ncv: int Maximum dimension of the subspace to be used by the solver. mpd: int Maximum dimension allowed for the projected problem.

### getImplicitTranspose(self) |
Gets the mode used to handle the transpose of the matrix associated with the singular value problem. # Returns impl: bool How to handle the transpose (implicitly or not).

### getIterationNumber(self) |
Gets the current iteration number. If the call to solve() is complete, then it returns the number of iterations carried out by the solution method. # Returns its: int Iteration number.

### getLanczosOneSide(self) |
Gets if the variant of the Lanczos method to be used is one-sided or two-sided. # Returns delayed: bool True if the method is one-sided.

### getOperators(self) |
Gets the matrices associated with the singular value problem. # Returns A: Mat The matrix associated with the singular value problem. B: Mat The second matrix in the case of GSVD.

### getOptionsPrefix(self) |
Gets the prefix used for searching for all SVD options in the database. # Returns prefix: string The prefix string set for this SVD object. Overrides: petsc4py.PETSc.Object.getOptionsPrefix

### getProblemType(self) |
Gets the problem type from the SVD object. # Returns problem_type: SVD.ProblemType enumerate The problem type that was previously set.

### getSignature(self) |
Gets the signature matrix defining a hyperbolic singular value problem. # Returns omega: Vec A vector containing the diagonal elements of the signature matrix.

### getSingularTriplet(self, int i, Vec U=None, Vec V=None) |
Gets the i-th triplet of the singular value decomposition as computed by solve(). The solution consists of the singular value and its left and right singular vectors. # Parameters i: int Index of the solution to be obtained. U: Vec Placeholder for the returned left singular vector. V: Vec Placeholder for the returned right singular vector. # Returns s: float The computed singular value. # Notes The index `i` should be a value between `0` and `nconv-1` (see getConverged(). Singular triplets are indexed according to the ordering criterion established with setWhichSingularTriplets().

### getTRLanczosExplicitMatrix(self) |
Returns the flag indicating if `Z=[A;B]` is built explicitly. # Returns flag: bool True if `Z=[A;B]` is built explicitly.

### getTRLanczosGBidiag(self) |
Returns bidiagonalization choice used in the GSVD TRLanczos solver. # Returns bidiag: SVD.TRLanczosGBidiag enumerate The bidiagonalization choice.

### getTRLanczosKSP(self) |
Retrieve the linear solver object associated with the SVD solver. # Returns ksp: `KSP` The linear solver object.

### getTRLanczosLocking(self) |
Gets the locking flag used in the thick-restart Lanczos method. # Returns lock: bool The locking flag.

### getTRLanczosOneSide(self) |
Gets if the variant of the thick-restart Lanczos method to be used is one-sided or two-sided. # Returns delayed: bool True if the method is one-sided.

### getTRLanczosRestart(self) |
Gets the restart parameter used in the thick-restart Lanczos method. # Returns keep: float The number of vectors to be kept at restart.

### getTolerances(self) |
Gets the tolerance and maximum iteration count used by the default SVD convergence tests. # Returns tol: float The convergence tolerance. max_it: int The maximum number of iterations

### getTrackAll(self) |
Returns the flag indicating whether all residual norms must be computed or not. # Returns trackall: bool Whether the solver compute all residuals or not.

### getType(self) |
Gets the SVD type of this object. # Returns type: SVD.Type enumerate The solver currently being used. Overrides: petsc4py.PETSc.Object.getType

### getValue(self, int i) |
Gets the i-th singular value as computed by solve(). # Parameters i: int Index of the solution to be obtained. # Returns s: float The computed singular value. # Notes The index `i` should be a value between `0` and `nconv-1` (see getConverged(). Singular triplets are indexed according to the ordering criterion established with setWhichSingularTriplets().

### getVectors(self, int i, Vec U, Vec V) |
Gets the i-th left and right singular vectors as computed by solve(). # Parameters i: int Index of the solution to be obtained. U: Vec Placeholder for the returned left singular vector. V: Vec Placeholder for the returned right singular vector. # Notes The index `i` should be a value between `0` and `nconv-1` (see getConverged(). Singular triplets are indexed according to the ordering criterion established with setWhichSingularTriplets().

### getWhichSingularTriplets(self) |
Returns which singular triplets are to be sought. # Returns which: SVD.Which enumerate The singular values to be sought (either largest or smallest).

### isGeneralized(self) |
Tells whether the SVD object corresponds to a generalized singular value problem. # Returns flag: bool True if two matrices were set with setOperators().

### isHyperbolic(self) |
Tells whether the SVD object corresponds to a hyperbolic singular value problem. # Returns flag: bool True if the problem was specified as hyperbolic.

### setBV(self, BV V, BV U=None) |
Associates basis vectors objects to the SVD solver. # Parameters V: BV The basis vectors context for right singular vectors. U: BV The basis vectors context for left singular vectors.

### setConvergenceTest(self, conv) |
Specifies how to compute the error estimate used in the convergence test. # Parameters conv: SVD.Conv The method used to compute the error estimate used in the convergence test.

### setCrossEPS(self, EPS eps) |
Associate an eigensolver object (EPS) to the singular value solver. # Parameters eps: EPS The eigensolver object.

### setCrossExplicitMatrix(self, flag=True) |
Indicate if the eigensolver operator `A^T*A` must be computed explicitly. # Parameters flag: bool True if `A^T*A` is built explicitly.

### setCyclicEPS(self, EPS eps) |
Associate an eigensolver object (EPS) to the singular value solver. # Parameters eps: EPS The eigensolver object.

### setCyclicExplicitMatrix(self, flag=True) |
Indicate if the eigensolver operator `H(A) = [ 0 A ; A^T 0 ]` must be computed explicitly. # Parameters flag: bool True if `H(A)` is built explicitly.

### setDS(self, DS ds) |
Associates a direct solver object to the singular value solver. # Parameters ds: DS The direct solver context.

### setDimensions(self, nsv=None, ncv=None, mpd=None) |
Sets the number of singular values to compute and the dimension of the subspace. # Parameters nsv: int, optional Number of singular values to compute. ncv: int, optional Maximum dimension of the subspace to be used by the solver. mpd: int, optional Maximum dimension allowed for the projected problem. # Notes Use DECIDE for `ncv` and `mpd` to assign a reasonably good value, which is dependent on the solution method. The parameters `ncv` and `mpd` are intimately related, so that the user is advised to set one of them at most. Normal usage is the following: In cases where `nsv` is small, the user sets `ncv` (a reasonable default is 2 * `nsv`). In cases where `nsv` is large, the user sets `mpd`. The value of `ncv` should always be between `nsv` and (`nsv` + `mpd`), typically `ncv` = `nsv` + `mpd`. If `nsv` is not too large, `mpd` = `nsv` is a reasonable choice, otherwise a smaller value should be used.

### setFromOptions(self) |
Sets SVD options from the options database. This routine must be called before setUp() if the user is to be allowed to set the solver type. # Notes To see all options, run your program with the `-help` option. Overrides: petsc4py.PETSc.Object.setFromOptions

### setImplicitTranspose(self, mode) |
Indicates how to handle the transpose of the matrix associated with the singular value problem. # Parameters impl: bool How to handle the transpose (implicitly or not). # Notes By default, the transpose of the matrix is explicitly built (if the matrix has defined the MatTranspose operation). If this flag is set to true, the solver does not build the transpose, but handles it implicitly via MatMultTranspose().

### setInitialSpaces(self, spaceright=None, spaceleft=None) |
Sets the initial spaces from which the SVD solver starts to iterate. # Parameters spaceright: sequence of Vec The right initial space. spaceleft: sequence of Vec The left initial space.

### setLanczosOneSide(self, flag=True) |
Indicate if the variant of the Lanczos method to be used is one-sided or two-sided. # Parameters flag: bool True if the method is one-sided. # Notes By default, a two-sided variant is selected, which is sometimes slightly more robust. However, the one-sided variant is faster because it avoids the orthogonalization associated to left singular vectors. It also saves the memory required for storing such vectors.

### setOperator(self, Mat A, Mat B=None) |
Sets the matrices associated with the singular value problem. # Parameters A: Mat The matrix associated with the singular value problem. B: Mat, optional The second matrix in the case of GSVD; if not provided, a usual SVD is assumed.

### setOperators(self, Mat A, Mat B=None) |
Sets the matrices associated with the singular value problem. # Parameters A: Mat The matrix associated with the singular value problem. B: Mat, optional The second matrix in the case of GSVD; if not provided, a usual SVD is assumed.

### setOptionsPrefix(self, prefix) |
Sets the prefix used for searching for all SVD options in the database. # Parameters prefix: string The prefix string to prepend to all SVD option requests. # 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. For example, to distinguish between the runtime options for two different SVD contexts, one could call:
    S1.setOptionsPrefix("svd1_")
    S2.setOptionsPrefix("svd2_")
Overrides: petsc4py.PETSc.Object.setOptionsPrefix

### setProblemType(self, problem_type) |
Specifies the type of the singular value problem. # Parameters problem_type: SVD.ProblemType enumerate The problem type to be set.

### setSignature(self, Vec omega=None) |
Sets the signature matrix defining a hyperbolic singular value problem. # Parameters omega: Vec, optional A vector containing the diagonal elements of the signature matrix.

### setTRLanczosExplicitMatrix(self, flag=True) |
Indicate if the matrix `Z=[A;B]` must be built explicitly. # Parameters flag: bool True if `Z=[A;B]` is built explicitly.

### setTRLanczosGBidiag(self, bidiag) |
Sets the bidiagonalization choice to use in the GSVD TRLanczos solver. # Parameters bidiag: SVD.TRLanczosGBidiag enumerate The bidiagonalization choice.

### setTRLanczosKSP(self, KSP ksp) |
Associate a linear solver object to the SVD solver. # Parameters ksp: `KSP` The linear solver object.

### setTRLanczosLocking(self, lock) |
Choose between locking and non-locking variants of the thick-restart Lanczos method. # Parameters lock: bool True if the locking variant must be selected. # Notes The default is to lock converged singular triplets when the method restarts. This behaviour can be changed so that all directions are kept in the working subspace even if already converged to working accuracy (the non-locking variant).

### setTRLanczosOneSide(self, flag=True) |
Indicate if the variant of the thick-restart Lanczos method to be used is one-sided or two-sided. # Parameters flag: bool True if the method is one-sided. # Notes By default, a two-sided variant is selected, which is sometimes slightly more robust. However, the one-sided variant is faster because it avoids the orthogonalization associated to left singular vectors.

### setTRLanczosRestart(self, keep) |
Sets the restart parameter for the thick-restart Lanczos method, in particular the proportion of basis vectors that must be kept after restart. # Parameters keep: float The number of vectors to be kept at restart. # Notes Allowed values are in the range [0.1,0.9]. The default is 0.5.

### setTolerances(self, tol=None, max_it=None) |
Sets the tolerance and maximum iteration count used by the default SVD convergence tests. # Parameters tol: float, optional The convergence tolerance. max_it: int, optional The maximum number of iterations # Notes Use DECIDE for max_it to assign a reasonably good value, which is dependent on the solution method.

### setTrackAll(self, trackall) |
Specifies if the solver must compute the residual of all approximate singular triplets or not. # Parameters trackall: bool Whether compute all residuals or not.

### setType(self, svd_type) |
Selects the particular solver to be used in the SVD object. # Parameters svd_type: SVD.Type enumerate The solver to be used. # Notes See SVD.Type for available methods. The default is CROSS. Normally, it is best to use setFromOptions() and then set the SVD 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(self) |
Sets up all the internal data structures necessary for the execution of the singular value solver. # Notes This function need not be called explicitly in most cases, since solve() calls it. It can be useful when one wants to measure the set-up time separately from the solve time.

### setWhichSingularTriplets(self, which) |
Specifies which singular triplets are to be sought. # Parameters which: SVD.Which enumerate The singular values to be sought (either largest or smallest).

### valuesView(self, Viewer viewer=None) |
Displays the computed singular values in a viewer. # Parameters viewer: Viewer, optional. Visualization context; if not provided, the standard output is used.

### vectorsView(self, Viewer viewer=None) |
Outputs computed singular vectors to a viewer. # Parameters viewer: Viewer, optional. Visualization context; if not provided, the standard output is used.

### view(self, Viewer viewer=None) |
Prints the SVD data structure. # Parameters viewer: Viewer, optional Visualization context; if not provided, the standard output is used. Overrides: petsc4py.PETSc.Object.view