slepc4py.SLEPc.SVD#

class slepc4py.SLEPc.SVD#

Bases: Object

Singular Value Decomposition Solver.

The Singular Value Decomposition Solver (SVD) is very similar to the EPS object, but intended for the computation of the partial SVD of a rectangular matrix. With this type of object, the user can specify an SVD problem and solve it with any of the different solvers encapsulated by the package. Some of these solvers are actually implemented through calls to EPS eigensolvers.

Enumerations

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 type.

Which

SVD desired part of spectrum.

Methods Summary

appendOptionsPrefix([prefix])

Append to the prefix used for searching for all SVD options in the database.

cancelMonitor()

Clear all monitors for an SVD object.

computeError(i[, etype])

Compute the error associated with the i-th singular triplet.

create([comm])

Create the SVD object.

destroy()

Destroy the SVD object.

errorView([etype, viewer])

Display the errors associated with the computed solution.

getBV()

Get the basis vectors objects associated to the SVD object.

getConverged()

Get the number of converged singular triplets.

getConvergedReason()

Get the reason why the solve() iteration was stopped.

getConvergenceTest()

Get the method used to compute the error estimate used in the convergence test.

getCrossEPS()

Get the eigensolver object associated to the singular value solver.

getCrossExplicitMatrix()

Get the flag indicating if A^T*A is built explicitly.

getCyclicEPS()

Get the eigensolver object associated to the singular value solver.

getCyclicExplicitMatrix()

Get the flag indicating if \(H(A)\) is built explicitly.

getDS()

Get the direct solver associated to the singular value solver.

getDimensions()

Get the number of singular values to compute and the dimension of the subspace.

getImplicitTranspose()

Get the mode used to handle the transpose of the matrix associated.

getIterationNumber()

Get the current iteration number.

getLanczosOneSide()

Get if the variant of the Lanczos method to be used is one-sided or two-sided.

getMonitor()

Get the list of monitor functions.

getOperators()

Get the matrices associated with the singular value problem.

getOptionsPrefix()

Get the prefix used for searching for all SVD options in the database.

getProblemType()

Get the problem type from the SVD object.

getSignature([omega])

Get the signature matrix defining a hyperbolic singular value problem.

getSingularTriplet(i[, U, V])

Get the i-th triplet of the singular value decomposition.

getStoppingTest()

Get the stopping function.

getTRLanczosExplicitMatrix()

Get the flag indicating if \(Z=[A;B]\) is built explicitly.

getTRLanczosGBidiag()

Get bidiagonalization choice used in the GSVD TRLanczos solver.

getTRLanczosKSP()

Get the linear solver object associated with the SVD solver.

getTRLanczosLocking()

Get the locking flag used in the thick-restart Lanczos method.

getTRLanczosOneSide()

Get if the variant of the method to be used is one-sided or two-sided.

getTRLanczosRestart()

Get the restart parameter used in the thick-restart Lanczos method.

getThreshold()

Get the threshold used in the threshold stopping test.

getTolerances()

Get the tolerance and maximum iteration count.

getTrackAll()

Get the flag indicating if all residual norms must be computed or not.

getType()

Get the SVD type of this object.

getValue(i)

Get the i-th singular value as computed by solve().

getVectors(i, U, V)

Get the i-th left and right singular vectors as computed by solve().

getWhichSingularTriplets()

Get which singular triplets are to be sought.

isGeneralized()

Tell if the SVD corresponds to a generalized singular value problem.

isHyperbolic()

Tell whether the SVD object corresponds to a hyperbolic singular value problem.

reset()

Reset the SVD object.

setBV(V[, U])

Set basis vectors objects associated to the SVD solver.

setConvergenceTest(conv)

Set how to compute the error estimate used in the convergence test.

setCrossEPS(eps)

Set an eigensolver object associated to the singular value solver.

setCrossExplicitMatrix([flag])

Set if the eigensolver operator \(A^T A\) must be computed.

setCyclicEPS(eps)

Set an eigensolver object associated to the singular value solver.

setCyclicExplicitMatrix([flag])

Set if the eigensolver operator H(A) must be computed explicitly.

setDS(ds)

Set a direct solver object associated to the singular value solver.

setDimensions([nsv, ncv, mpd])

Set the number of singular values to compute and the dimension of the subspace.

setFromOptions()

Set SVD options from the options database.

setImplicitTranspose(mode)

Set how to handle the transpose of the matrix associated.

setInitialSpace([spaceright, spaceleft])

Set the initial spaces from which the SVD solver starts to iterate.

setLanczosOneSide([flag])

Set if the variant of the Lanczos method to be used is one-sided or two-sided.

setMonitor(monitor[, args, kargs])

Append a monitor function to the list of monitors.

setOperators(A[, B])

Set the matrices associated with the singular value problem.

setOptionsPrefix([prefix])

Set the prefix used for searching for all SVD options in the database.

setProblemType(problem_type)

Set the type of the singular value problem.

setSignature([omega])

Set the signature matrix defining a hyperbolic singular value problem.

setStoppingTest(stopping[, args, kargs])

Set a function to decide when to stop the outer iteration of the eigensolver.

setTRLanczosExplicitMatrix([flag])

Set if the matrix \(Z=[A;B]\) must be built explicitly.

setTRLanczosGBidiag(bidiag)

Set the bidiagonalization choice to use in the GSVD TRLanczos solver.

setTRLanczosKSP(ksp)

Set a linear solver object associated to the SVD solver.

setTRLanczosLocking(lock)

Toggle between locking and non-locking variants of the method.

setTRLanczosOneSide([flag])

Set if the variant of the method to be used is one-sided or two-sided.

setTRLanczosRestart(keep)

Set the restart parameter for the thick-restart Lanczos method.

setThreshold(thres[, rel])

Set the threshold used in the threshold stopping test.

setTolerances([tol, max_it])

Set the tolerance and maximum iteration count used.

setTrackAll(trackall)

Set flag to compute the residual of all singular triplets.

setType(svd_type)

Set the particular solver to be used in the SVD object.

setUp()

Set up all the necessary internal data structures.

setWhichSingularTriplets(which)

Set which singular triplets are to be sought.

solve()

Solve the singular value problem.

valuesView([viewer])

Display the computed singular values in a viewer.

vectorsView([viewer])

Output computed singular vectors to a viewer.

view([viewer])

Print the SVD data structure.

Attributes Summary

ds

The direct solver (DS) object associated.

max_it

The maximum iteration count.

problem_type

The type of the eigenvalue problem.

tol

The tolerance.

track_all

Compute the residual norm of all approximate eigenpairs.

transpose_mode

How to handle the transpose of the matrix.

which

The portion of the spectrum to be sought.

Methods Documentation

appendOptionsPrefix(prefix=None)#

Append to the prefix used for searching for all SVD options in the database.

Logically collective.

Parameters:

prefix (str | None) – The prefix string to prepend to all SVD option requests.

Return type:

None

Source code at slepc4py/SLEPc/SVD.pyx:299

cancelMonitor()#

Clear all monitors for an SVD object.

Logically collective.

Source code at slepc4py/SLEPc/SVD.pyx:927

Return type:

None

computeError(i, etype=None)#

Compute the error associated with the i-th singular triplet.

Collective.

Compute 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 (ErrorType | None) – The error type to compute.

Returns:

The relative error bound, computed in various ways from the residual norm \(\sqrt{n_1^2+n_2^2}\) where \(n_1 = \|A v - \sigma u\|_2\), \(n_2 = \|A^T u - \sigma v\|_2\), \(\sigma\) is the singular value, \(u\) and \(v\) are the left and right singular vectors.

Return type:

float

Notes

The index i should be a value between 0 and nconv-1 (see getConverged()).

Source code at slepc4py/SLEPc/SVD.pyx:1106

create(comm=None)#

Create the SVD object.

Collective.

Parameters:

comm (Comm | None) – MPI communicator; if not provided, it defaults to all processes.

Return type:

Self

Source code at slepc4py/SLEPc/SVD.pyx:201

destroy()#

Destroy the SVD object.

Collective.

Source code at slepc4py/SLEPc/SVD.pyx:183

Return type:

Self

errorView(etype=None, viewer=None)#

Display the errors associated with the computed solution.

Collective.

Display the errors and the eigenvalues.

Parameters:
Return type:

None

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.

Source code at slepc4py/SLEPc/SVD.pyx:1143

getBV()#

Get the basis vectors objects associated to the SVD object.

Not collective.

Returns:

  • V (BV) – The basis vectors context for right singular vectors.

  • U (BV) – The basis vectors context for left singular vectors.

Return type:

tuple[BV, BV]

Source code at slepc4py/SLEPc/SVD.pyx:691

getConverged()#

Get the number of converged singular triplets.

Not collective.

Returns:

Number of converged singular triplets.

Return type:

int

Notes

This function should be called after solve() has finished.

Source code at slepc4py/SLEPc/SVD.pyx:996

getConvergedReason()#

Get the reason why the solve() iteration was stopped.

Not collective.

Returns:

Negative value indicates diverged, positive value converged.

Return type:

ConvergedReason

Source code at slepc4py/SLEPc/SVD.pyx:981

getConvergenceTest()#

Get the method used to compute the error estimate used in the convergence test.

Not collective.

Returns:

The method used to compute the error estimate used in the convergence test.

Return type:

Conv

Source code at slepc4py/SLEPc/SVD.pyx:561

getCrossEPS()#

Get the eigensolver object associated to the singular value solver.

Collective.

Returns:

The eigensolver object.

Return type:

EPS

Source code at slepc4py/SLEPc/SVD.pyx:1217

getCrossExplicitMatrix()#

Get the flag indicating if A^T*A is built explicitly.

Not collective.

Returns:

True if A^T*A is built explicitly.

Return type:

bool

Source code at slepc4py/SLEPc/SVD.pyx:1247

getCyclicEPS()#

Get the eigensolver object associated to the singular value solver.

Collective.

Returns:

The eigensolver object.

Return type:

EPS

Source code at slepc4py/SLEPc/SVD.pyx:1275

getCyclicExplicitMatrix()#

Get the flag indicating if \(H(A)\) is built explicitly.

Not collective.

Get the flag indicating if \(H(A) = [ 0\; A ; A^T\; 0 ]\) is built explicitly.

Returns:

True if \(H(A)\) is built explicitly.

Return type:

bool

Source code at slepc4py/SLEPc/SVD.pyx:1308

getDS()#

Get the direct solver associated to the singular value solver.

Not collective.

Returns:

The direct solver context.

Return type:

DS

Source code at slepc4py/SLEPc/SVD.pyx:728

getDimensions()#

Get the number of singular values to compute and the dimension of the subspace.

Not collective.

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.

Return type:

tuple[int, int, int]

Source code at slepc4py/SLEPc/SVD.pyx:624

getImplicitTranspose()#

Get the mode used to handle the transpose of the matrix associated.

Not collective.

Get the mode used to handle the transpose of the matrix associated with the singular value problem.

Returns:

How to handle the transpose (implicitly or not).

Return type:

bool

Source code at slepc4py/SLEPc/SVD.pyx:394

getIterationNumber()#

Get the current iteration number.

Not collective.

If the call to solve() is complete, then it returns the number of iterations carried out by the solution method.

Returns:

Iteration number.

Return type:

int

Source code at slepc4py/SLEPc/SVD.pyx:963

getLanczosOneSide()#

Get if the variant of the Lanczos method to be used is one-sided or two-sided.

Not collective.

Returns:

True if the method is one-sided.

Return type:

bool

Source code at slepc4py/SLEPc/SVD.pyx:1348

getMonitor()#

Get the list of monitor functions.

Source code at slepc4py/SLEPc/SVD.pyx:923

Return type:

SVDMonitorFunction

getOperators()#

Get the matrices associated with the singular value problem.

Collective.

Returns:

Return type:

tuple[petsc4py.PETSc.Mat, petsc4py.PETSc.Mat] | tuple[petsc4py.PETSc.Mat, None]

Source code at slepc4py/SLEPc/SVD.pyx:757

getOptionsPrefix()#

Get the prefix used for searching for all SVD options in the database.

Not collective.

Returns:

The prefix string set for this SVD object.

Return type:

str

Source code at slepc4py/SLEPc/SVD.pyx:257

getProblemType()#

Get the problem type from the SVD object.

Not collective.

Returns:

The problem type that was previously set.

Return type:

ProblemType

Source code at slepc4py/SLEPc/SVD.pyx:330

getSignature(omega=None)#

Get the signature matrix defining a hyperbolic singular value problem.

Collective.

Parameters:

omega (petsc4py.PETSc.Vec | None) – Optional vector to store the diagonal elements of the signature matrix.

Returns:

A vector containing the diagonal elements of the signature matrix.

Return type:

petsc4py.PETSc.Vec

Source code at slepc4py/SLEPc/SVD.pyx:797

getSingularTriplet(i, U=None, V=None)#

Get the i-th triplet of the singular value decomposition.

Collective.

Get 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 | None) – Placeholder for the returned left singular vector.

  • V (Vec | None) – Placeholder for the returned right singular vector.

Returns:

The computed singular value.

Return type:

float

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().

Source code at slepc4py/SLEPc/SVD.pyx:1067

getStoppingTest()#

Get the stopping function.

Not collective.

Source code at slepc4py/SLEPc/SVD.pyx:892

Return type:

SVDStoppingFunction

getTRLanczosExplicitMatrix()#

Get the flag indicating if \(Z=[A;B]\) is built explicitly.

Not collective.

Returns:

True if \(Z=[A;B]\) is built explicitly.

Return type:

bool

Source code at slepc4py/SLEPc/SVD.pyx:1553

getTRLanczosGBidiag()#

Get bidiagonalization choice used in the GSVD TRLanczos solver.

Not collective.

Returns:

The bidiagonalization choice.

Return type:

TRLanczosGBidiag

Source code at slepc4py/SLEPc/SVD.pyx:1419

getTRLanczosKSP()#

Get the linear solver object associated with the SVD solver.

Collective.

Returns:

The linear solver object.

Return type:

petsc4py.PETSc.KSP

Source code at slepc4py/SLEPc/SVD.pyx:1523

getTRLanczosLocking()#

Get the locking flag used in the thick-restart Lanczos method.

Not collective.

Returns:

The locking flag.

Return type:

bool

Source code at slepc4py/SLEPc/SVD.pyx:1495

getTRLanczosOneSide()#

Get if the variant of the method to be used is one-sided or two-sided.

Not collective.

Get if the variant of the thick-restart Lanczos method to be used is one-sided or two-sided.

Returns:

True if the method is one-sided.

Return type:

bool

Source code at slepc4py/SLEPc/SVD.pyx:1387

getTRLanczosRestart()#

Get the restart parameter used in the thick-restart Lanczos method.

Not collective.

Returns:

The number of vectors to be kept at restart.

Return type:

float

Source code at slepc4py/SLEPc/SVD.pyx:1456

getThreshold()#

Get the threshold used in the threshold stopping test.

Not collective.

Returns:

  • thres (float) – The threshold.

  • rel (bool) – Whether the threshold is relative or not.

Return type:

tuple[float, bool]

Source code at slepc4py/SLEPc/SVD.pyx:466

getTolerances()#

Get the tolerance and maximum iteration count.

Not collective.

Get 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

Return type:

tuple[float, int]

Source code at slepc4py/SLEPc/SVD.pyx:513

getTrackAll()#

Get the flag indicating if all residual norms must be computed or not.

Not collective.

Returns:

Whether the solver compute all residuals or not.

Return type:

bool

Source code at slepc4py/SLEPc/SVD.pyx:592

getType()#

Get the SVD type of this object.

Not collective.

Returns:

The solver currently being used.

Return type:

str

Source code at slepc4py/SLEPc/SVD.pyx:242

getValue(i)#

Get the i-th singular value as computed by solve().

Collective.

Parameters:

i (int) – Index of the solution to be obtained.

Returns:

The computed singular value.

Return type:

float

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().

Source code at slepc4py/SLEPc/SVD.pyx:1015

getVectors(i, U, V)#

Get the i-th left and right singular vectors as computed by solve().

Collective.

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.

Return type:

None

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().

Source code at slepc4py/SLEPc/SVD.pyx:1042

getWhichSingularTriplets()#

Get which singular triplets are to be sought.

Not collective.

Returns:

The singular values to be sought (either largest or smallest).

Return type:

Which

Source code at slepc4py/SLEPc/SVD.pyx:437

isGeneralized()#

Tell if the SVD corresponds to a generalized singular value problem.

Not collective.

Tell whether the SVD object corresponds to a generalized singular value problem.

Returns:

True if two matrices were set with setOperators().

Return type:

bool

Source code at slepc4py/SLEPc/SVD.pyx:359

isHyperbolic()#

Tell whether the SVD object corresponds to a hyperbolic singular value problem.

Not collective.

Returns:

True if the problem was specified as hyperbolic.

Return type:

bool

Source code at slepc4py/SLEPc/SVD.pyx:377

reset()#

Reset the SVD object.

Collective.

Source code at slepc4py/SLEPc/SVD.pyx:193

Return type:

None

setBV(V, U=None)#

Set basis vectors objects associated to the SVD solver.

Collective.

Parameters:
  • V (BV) – The basis vectors context for right singular vectors.

  • U (BV | None) – The basis vectors context for left singular vectors.

Return type:

None

Source code at slepc4py/SLEPc/SVD.pyx:711

setConvergenceTest(conv)#

Set how to compute the error estimate used in the convergence test.

Logically collective.

Parameters:

conv (Conv) – The method used to compute the error estimate used in the convergence test.

Return type:

None

Source code at slepc4py/SLEPc/SVD.pyx:577

setCrossEPS(eps)#

Set an eigensolver object associated to the singular value solver.

Collective.

Parameters:

eps (EPS) – The eigensolver object.

Return type:

None

Source code at slepc4py/SLEPc/SVD.pyx:1204

setCrossExplicitMatrix(flag=True)#

Set if the eigensolver operator \(A^T A\) must be computed.

Logically collective.

Parameters:

flag (bool) – True to build \(A^T A\) explicitly.

Return type:

None

Source code at slepc4py/SLEPc/SVD.pyx:1233

setCyclicEPS(eps)#

Set an eigensolver object associated to the singular value solver.

Collective.

Parameters:

eps (EPS) – The eigensolver object.

Return type:

None

Source code at slepc4py/SLEPc/SVD.pyx:1262

setCyclicExplicitMatrix(flag=True)#

Set if the eigensolver operator H(A) must be computed explicitly.

Logically collective.

Set 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.

Return type:

None

Source code at slepc4py/SLEPc/SVD.pyx:1291

setDS(ds)#

Set a direct solver object associated to the singular value solver.

Collective.

Parameters:

ds (DS) – The direct solver context.

Return type:

None

Source code at slepc4py/SLEPc/SVD.pyx:744

setDimensions(nsv=None, ncv=None, mpd=None)#

Set the number of singular values to compute and the dimension of the subspace.

Logically collective.

Parameters:
  • nsv (int | None) – Number of singular values to compute.

  • ncv (int | None) – Maximum dimension of the subspace to be used by the solver.

  • mpd (int | None) – Maximum dimension allowed for the projected problem.

Return type:

None

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.

Source code at slepc4py/SLEPc/SVD.pyx:645

setFromOptions()#

Set SVD options from the options database.

Collective.

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.

Source code at slepc4py/SLEPc/SVD.pyx:314

Return type:

None

setImplicitTranspose(mode)#

Set how to handle the transpose of the matrix associated.

Logically collective.

Set how to handle the transpose of the matrix associated with the singular value problem.

Parameters:
  • impl – How to handle the transpose (implicitly or not).

  • mode (bool)

Return type:

None

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().

Source code at slepc4py/SLEPc/SVD.pyx:412

setInitialSpace(spaceright=None, spaceleft=None)#

Set the initial spaces from which the SVD solver starts to iterate.

Collective.

Parameters:
  • spaceright (list[Vec] | None) – The right initial space.

  • spaceleft (list[Vec] | None) – The left initial space.

Return type:

None

Source code at slepc4py/SLEPc/SVD.pyx:838

setLanczosOneSide(flag=True)#

Set if the variant of the Lanczos method to be used is one-sided or two-sided.

Logically collective.

Parameters:

flag (bool) – True if the method is one-sided.

Return type:

None

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.

Source code at slepc4py/SLEPc/SVD.pyx:1326

setMonitor(monitor, args=None, kargs=None)#

Append a monitor function to the list of monitors.

Logically collective.

Source code at slepc4py/SLEPc/SVD.pyx:902

Parameters:
Return type:

None

setOperators(A, B=None)#

Set the matrices associated with the singular value problem.

Collective.

Parameters:
  • A (Mat) – The matrix associated with the singular value problem.

  • B (Mat | None) – The second matrix in the case of GSVD; if not provided, a usual SVD is assumed.

Return type:

None

Source code at slepc4py/SLEPc/SVD.pyx:780

setOptionsPrefix(prefix=None)#

Set the prefix used for searching for all SVD options in the database.

Logically collective.

Parameters:

prefix (str | None) – The prefix string to prepend to all SVD option requests.

Return type:

None

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_")

Source code at slepc4py/SLEPc/SVD.pyx:272

setProblemType(problem_type)#

Set the type of the singular value problem.

Logically collective.

Parameters:

problem_type (ProblemType) – The problem type to be set.

Return type:

None

Source code at slepc4py/SLEPc/SVD.pyx:345

setSignature(omega=None)#

Set the signature matrix defining a hyperbolic singular value problem.

Collective.

Parameters:

omega (Vec | None) – A vector containing the diagonal elements of the signature matrix.

Return type:

None

Source code at slepc4py/SLEPc/SVD.pyx:822

setStoppingTest(stopping, args=None, kargs=None)#

Set a function to decide when to stop the outer iteration of the eigensolver.

Logically collective.

Source code at slepc4py/SLEPc/SVD.pyx:872

Parameters:
Return type:

None

setTRLanczosExplicitMatrix(flag=True)#

Set if the matrix \(Z=[A;B]\) must be built explicitly.

Logically collective.

Parameters:

flag (bool) – True if \(Z=[A;B]\) is built explicitly.

Return type:

None

Source code at slepc4py/SLEPc/SVD.pyx:1539

setTRLanczosGBidiag(bidiag)#

Set the bidiagonalization choice to use in the GSVD TRLanczos solver.

Logically collective.

Parameters:

bidiag (TRLanczosGBidiag) – The bidiagonalization choice.

Return type:

None

Source code at slepc4py/SLEPc/SVD.pyx:1405

setTRLanczosKSP(ksp)#

Set a linear solver object associated to the SVD solver.

Collective.

Parameters:

ksp (petsc4py.PETSc.KSP) – The linear solver object.

Return type:

None

Source code at slepc4py/SLEPc/SVD.pyx:1510

setTRLanczosLocking(lock)#

Toggle between locking and non-locking variants of the method.

Logically collective.

Toggle between locking and non-locking variants of the thick-restart Lanczos method.

Parameters:

lock (bool) – True if the locking variant must be selected.

Return type:

None

Notes

The default is to lock converged singular triplets when the method restarts. This behavior can be changed so that all directions are kept in the working subspace even if already converged to working accuracy (the non-locking variant).

Source code at slepc4py/SLEPc/SVD.pyx:1471

setTRLanczosOneSide(flag=True)#

Set if the variant of the method to be used is one-sided or two-sided.

Logically collective.

Set 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.

Return type:

None

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.

Source code at slepc4py/SLEPc/SVD.pyx:1363

setTRLanczosRestart(keep)#

Set the restart parameter for the thick-restart Lanczos method.

Logically collective.

Set 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.

Return type:

None

Notes

Allowed values are in the range [0.1,0.9]. The default is 0.5.

Source code at slepc4py/SLEPc/SVD.pyx:1434

setThreshold(thres, rel=False)#

Set the threshold used in the threshold stopping test.

Logically collective.

Parameters:
  • thres (float) – The threshold.

  • rel (bool) – Whether the threshold is relative or not.

Return type:

None

Notes

This function internally sets a special stopping test based on the threshold, where singular values are computed in sequence until one of the computed singular values is below/above the threshold (depending on whether largest or smallest singular values are computed).

In the case of largest singular values, the threshold can be made relative with respect to the largest singular value (i.e., the matrix norm).

Source code at slepc4py/SLEPc/SVD.pyx:484

setTolerances(tol=None, max_it=None)#

Set the tolerance and maximum iteration count used.

Logically collective.

Set the tolerance and maximum iteration count used by the default SVD convergence tests.

Parameters:
  • tol (float | None) – The convergence tolerance.

  • max_it (int | None) – The maximum number of iterations

Return type:

None

Notes

Use DECIDE for max_it to assign a reasonably good value, which is dependent on the solution method.

Source code at slepc4py/SLEPc/SVD.pyx:534

setTrackAll(trackall)#

Set flag to compute the residual of all singular triplets.

Logically collective.

Set if the solver must compute the residual of all approximate singular triplets or not.

Parameters:

trackall (bool) – Whether compute all residuals or not.

Return type:

None

Source code at slepc4py/SLEPc/SVD.pyx:607

setType(svd_type)#

Set the particular solver to be used in the SVD object.

Logically collective.

Parameters:

svd_type (Type | str) – The solver to be used.

Return type:

None

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.

Source code at slepc4py/SLEPc/SVD.pyx:218

setUp()#

Set up all the necessary internal data structures.

Collective.

Set 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.

Source code at slepc4py/SLEPc/SVD.pyx:938

Return type:

None

setWhichSingularTriplets(which)#

Set which singular triplets are to be sought.

Logically collective.

Parameters:

which (Which) – The singular values to be sought (either largest or smallest).

Return type:

None

Source code at slepc4py/SLEPc/SVD.pyx:452

solve()#

Solve the singular value problem.

Collective.

Source code at slepc4py/SLEPc/SVD.pyx:955

Return type:

None

valuesView(viewer=None)#

Display the computed singular values in a viewer.

Collective.

Parameters:

viewer (Viewer | None) – Visualization context; if not provided, the standard output is used.

Return type:

None

Source code at slepc4py/SLEPc/SVD.pyx:1172

vectorsView(viewer=None)#

Output computed singular vectors to a viewer.

Collective.

Parameters:

viewer (Viewer | None) – Visualization context; if not provided, the standard output is used.

Return type:

None

Source code at slepc4py/SLEPc/SVD.pyx:1187

view(viewer=None)#

Print the SVD data structure.

Collective.

Parameters:

viewer (Viewer | None) – Visualization context; if not provided, the standard output is used.

Return type:

None

Source code at slepc4py/SLEPc/SVD.pyx:168

Attributes Documentation

ds#

The direct solver (DS) object associated.

Source code at slepc4py/SLEPc/SVD.pyx:1614

max_it#

The maximum iteration count.

Source code at slepc4py/SLEPc/SVD.pyx:1600

problem_type#

The type of the eigenvalue problem.

Source code at slepc4py/SLEPc/SVD.pyx:1572

tol#

The tolerance.

Source code at slepc4py/SLEPc/SVD.pyx:1593

track_all#

Compute the residual norm of all approximate eigenpairs.

Source code at slepc4py/SLEPc/SVD.pyx:1607

transpose_mode#

How to handle the transpose of the matrix.

Source code at slepc4py/SLEPc/SVD.pyx:1579

which#

The portion of the spectrum to be sought.

Source code at slepc4py/SLEPc/SVD.pyx:1586