LinearSolverFactory
org.ejml.factory

Class LinearSolverFactory



  • public class LinearSolverFactoryextends Object
    A factory for generating solvers for systems of the form A*x=b, where A and B are known and x is unknown.
    • Constructor Detail

      • LinearSolverFactory

        public LinearSolverFactory()
    • Method Detail

      • general

        public static LinearSolver<DenseMatrix64F> general(int numRows,                                   int numCols)
        Creates a general purpose solver. Use this if you are not sure what you need.
        Parameters:
        numRows - The number of rows that the decomposition is optimized for.
        numCols - The number of columns that the decomposition is optimized for.
      • linear

        public static LinearSolver<DenseMatrix64F> linear(int matrixSize)
        Creates a solver for linear systems. The A matrix will have dimensions (m,m).
        Returns:
        A new linear solver.
      • leastSquares

        public static LinearSolver<DenseMatrix64F> leastSquares(int numRows,                                        int numCols)
        Creates a good general purpose solver for over determined systems and returns the optimal least-squares solution. The A matrix will have dimensions (m,n) where m ≥ n.
        Parameters:
        numRows - The number of rows that the decomposition is optimized for.
        numCols - The number of columns that the decomposition is optimized for.
        Returns:
        A new least-squares solver for over determined systems.
      • symmPosDef

        public static LinearSolver<DenseMatrix64F> symmPosDef(int matrixWidth)
        Creates a solver for symmetric positive definite matrices.
        Returns:
        A new solver for symmetric positive definite matrices.
      • leastSquaresQrPivot

        public static LinearSolver<DenseMatrix64F> leastSquaresQrPivot(boolean computeNorm2,                                               boolean computeQ)

        Linear solver which uses QR pivot decomposition. These solvers can handle singular systems and should never fail. For singular systems, the solution might not be as accurate as a pseudo inverse that uses SVD.

        For singular systems there are multiple correct solutions. The optimal 2-norm solution is the solution vector with the minimal 2-norm and is unique. If the optimal solution is not computed then the basic solution is returned. See BaseLinearSolverQrp for details. There is only a runtime difference for small matrices, 2-norm solution is slower.

        Two different solvers are available. Compute Q will compute the Q matrix once then use it multiple times. If the solution for a single vector is being found then this should be set to false. If the pseudo inverse is being found or the solution matrix has more than one columns AND solve is being called numerous multiples times then this should be set to true.

        Parameters:
        computeNorm2 - true to compute the minimum 2-norm solution for singular systems. Try true.
        computeQ - Should it precompute Q or use house holder. Try false;
        Returns:
        Pseudo inverse type solver using QR with column pivots.
      • pseudoInverse

        public static LinearSolver<DenseMatrix64F> pseudoInverse(boolean useSVD)

        Returns a solver which uses the pseudo inverse. Useful when a matrix needs to be inverted which is singular. Two variants of pseudo inverse are provided. SVD will tend to be the most robust but the slowest and QR decomposition with column pivots will be faster, but less robust.

        See leastSquaresQrPivot(boolean, boolean) for additional options specific to QR decomposition based pseudo inverse. These options allow for better runtime performance in different situations.

        Parameters:
        useSVD - If true SVD will be used, otherwise QR with column pivot will be used.
        Returns:
        Solver for singular matrices.
      • adjustable

        public static AdjustableLinearSolver adjustable()
        Create a solver which can efficiently add and remove elements instead of recomputing everything from scratch.

SCaVis 2.1 © jWork.ORG