public class AccelerateSolver extends DirectSolverBase
Symmetric matrices are factored with LDL^T with threshold partial
pivoting (SparseFactorizationLDLTTPP), which is the only Accelerate LDL^T
variant that is reliable for saddle point (KKT) systems: the
Bunch-Kaufman variant (SBK) returns wrong solutions without reporting an
error, and the unpivoted one fails on the zero diagonal block.
Unsymmetric matrices are factored with LU with threshold partial pivoting
(SparseFactorizationLUTPP), which Accelerate provides only on macOS 15.5
and later; on earlier systems, isLUAvailable() returns false and
analyzing an unsymmetric matrix fails. The fill-reducing ordering
defaults to METIS; it can be changed with the environment variable
ACCELERATE_ORDER (amd, metis or mtmetis).
Each solve is followed by iterative refinement steps (default 1, as
for Pardiso with symmetric matrices; see setMaxRefinementSteps(int)),
which Accelerate does not provide itself: the residual r = b - A x is
computed from the factored matrix, A dx = r is solved, and x += dx. The
environment variable ACCELERATE_REFINE sets the initial number of steps.
Iterative (hybrid) solves are supported, using the most recent
factorization as a preconditioner; see iterativeSolve(double[], double[], double[]).
Accelerate parallelizes internally and provides no thread control, so the thread count methods have no effect, and results can differ slightly from run to run.
DirectSolver.IterativeMethodDEFAULT_GMRES_RESTARTANALYZED, DEFAULT_ITERATIVE_MAX_SOLVES, DEFAULT_ITERATIVE_TOLERANCE, FACTORED, UNSET| Constructor and Description |
|---|
AccelerateSolver()
Creates a new AccelerateSolver.
|
| Modifier and Type | Method and Description |
|---|---|
double[] |
getLastIterativeTimes()
Returns a time breakdown of the most recent call to
iterativeSolve(double[], double[], double[]), in msec: the total time spent in the native code, the
time spent in preconditioner solves, and the time spent in matrix-vector
products. |
int |
getMaxRefinementSteps()
Returns the maximum number of iterative refinement steps that this solver
will perform after a solve, or 0 if iterative refinement is not
supported.
|
int |
getNumNegEigenvalues()
Returns the number of negative eigenvalues (pivots) of the most recent
factorization, or -1 if this is not available (as for unsymmetric
matrices).
|
long |
getNumNonZerosInFactors()
If possible, returns the number of non-zero elements in the
factorization.
|
int |
getNumPerturbedPivots()
Returns the number of zero pivots (pivots below Accelerate's zero
tolerance) in the most recent factorization, which, as with pivot
perturbation in other solvers, indicates a singular or nearly singular
matrix.
|
int |
getNumPosEigenvalues()
Returns the number of positive eigenvalues (pivots) of the most recent
factorization, or -1 if this is not available (as for unsymmetric
matrices).
|
int |
getNumRefinementSteps()
Returns the number of iterative refinement steps performed in the most
recent solve.
|
boolean |
hasIterativeSolves()
Returns true if this solver supports iterative solving, using a recent
directly-factored matrix as a preconditioner.
|
boolean |
hasMultipleRhsSolves()
Returns true if this solver can solve for multiple right hand sides,
using
solve(X,B,nrhs). |
static boolean |
isAvailable()
Returns true if the native library for this solver can be loaded.
|
static boolean |
isLUAvailable()
Returns true if this solver is available and can factor unsymmetric
matrices, which requires macOS 15.5 or later.
|
int |
iterativeSolve(double[] vals,
double[] x,
double[] b)
Solves the system
|
void |
setMaxRefinementSteps(int nsteps)
Sets the maximum number of iterative refinement steps performed after
each solve.
|
analyze, analyze, analyzeAndFactor, dispose, factor, factor, finalize, getDefaultNumThreads, getErrorMessage, getGmresRestart, getIterativeMaxSolves, getIterativeMethod, getIterativeTolerance, getLastIterativeResidual, getLastIterativeSolves, getNumThreads, getPhysicalCoreCount, getState, getUseCriticalArrayAccess, residual, setDefaultNumThreads, setGmresRestart, setIterativeMaxSolves, setIterativeMethod, setIterativeTolerance, setNumThreads, setUseCriticalArrayAccess, solve, solve, solveequals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waititerativeSolve, residualpublic static boolean isAvailable()
public static boolean isLUAvailable()
public long getNumNonZerosInFactors()
analyze(). If the solver does not report this quantity, -1 is returned.public int getNumNegEigenvalues()
public int getNumPosEigenvalues()
public int getNumPerturbedPivots()
public void setMaxRefinementSteps(int nsteps)
nsteps - maximum number of refinement stepsDirectSolver.getMaxRefinementSteps()public int getMaxRefinementSteps()
DirectSolver.setMaxRefinementSteps(int)public int getNumRefinementSteps()
public boolean hasMultipleRhsSolves()
DirectSolversolve(X,B,nrhs).public boolean hasIterativeSolves()
DirectSolverDirectSolver.IterativeMethod are available, as are the
settings DirectSolver.setIterativeMethod(maspack.solvers.DirectSolver.IterativeMethod), DirectSolver.setIterativeMaxSolves(int) and
DirectSolver.setIterativeTolerance(double).public int iterativeSolve(double[] vals,
double[] x,
double[] b)
M x = biteratively, using the most recent factorization as a preconditioner and the matrix values supplied by
vals. If the current values
are close to those associated with the factorization, this can be
considerably faster than an explicit factor()
and solve(). The method, maximum number
of preconditioner solves and tolerance are set by DirectSolver.setIterativeMethod(maspack.solvers.DirectSolver.IterativeMethod), DirectSolver.setIterativeMaxSolves(int) and DirectSolver.setIterativeTolerance(double).
This method is only available if DirectSolver.hasIterativeSolves() returns
true; otherwise, it returns 0 and the caller should fall
back on factoring and solving directly.
Accelerate does not provide iterative solves itself. Instead, the iteration is performed in the native wrapper, using the most recent factorization as a preconditioner and the supplied values for matrix products.
vals - current values of the non-zero matrix elements, in the same
ordering as that supplied to analyze()x - vector in which the result is returnedb - right hand vector of the matrix equation<= 0 if the
iterative solve was not performed or did not succeedpublic double[] getLastIterativeTimes()
iterativeSolve(double[], double[], double[]), in msec: the total time spent in the native code, the
time spent in preconditioner solves, and the time spent in matrix-vector
products. The remainder of the total is vector operations and setup.
Intended for performance analysis.null if not available