org.apache.commons.math.linear

## Class QRDecompositionImpl.Solver

- java.lang.Object
- - org.apache.commons.math.linear.QRDecompositionImpl.Solver

All Implemented Interfaces:
  DecompositionSolver

Enclosing class:
  QRDecompositionImpl

    private static class QRDecompositionImpl.Solver
    extends Object
    implements DecompositionSolver

Specialized solver.

### Field Summary

Fields
`private double[][]` `qrt` A packed TRANSPOSED representation of the QR decomposition.
`private double[]` `rDiag` The diagonal elements of R.

### Constructor Summary

Constructors
`private` `QRDecompositionImpl.Solver(double[][] qrt, double[] rDiag)` Build a solver from decomposed matrix.

### Method Summary

Methods
`RealMatrix` `getInverse()` Get the inverse (or pseudo-inverse) of the decomposed matrix.
`boolean` `isNonSingular()` Check if the decomposed matrix is non-singular.
`ArrayRealVector` `solve(ArrayRealVector b)` Solve the linear equation A × X = B.
`double[]` `solve(double[] b)` Solve the linear equation A × X = B for matrices A.
`RealMatrix` `solve(RealMatrix b)` Solve the linear equation A × X = B for matrices A.
`RealVector` `solve(RealVector b)` Solve the linear equation A × X = B for matrices A.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### qrt

    private final double[][] qrt

A packed TRANSPOSED representation of the QR decomposition.

The elements BELOW the diagonal are the elements of the UPPER triangular matrix R, and the rows ABOVE the diagonal are the Householder reflector vectors from which an explicit form of Q can be recomputed if desired.

#### rDiag

    private final double[] rDiag

The diagonal elements of R.

### Constructor Detail

#### QRDecompositionImpl.Solver

    private QRDecompositionImpl.Solver(double[][] qrt,
                              double[] rDiag)

Build a solver from decomposed matrix.

Parameters:
  `qrt` - packed TRANSPOSED representation of the QR decomposition
  `rDiag` - diagonal elements of R

### Method Detail

#### isNonSingular

    public boolean isNonSingular()

Check if the decomposed matrix is non-singular.

Specified by:
  `isNonSingular` in interface `DecompositionSolver`
Returns:
  true if the decomposed matrix is non-singular

#### solve

    public double[] solve(double[] b)
                   throws IllegalArgumentException,
                          InvalidMatrixException

Solve the linear equation A × X = B for matrices A.

The A matrix is implicit, it is provided by the underlying decomposition algorithm.

Specified by:
  `solve` in interface `DecompositionSolver`
Parameters:
  `b` - right-hand side of the equation A × X = B
Returns:
  a vector X that minimizes the two norm of A × X - B
Throws:
  `IllegalArgumentException` - if matrices dimensions don't match
  `InvalidMatrixException` - if decomposed matrix is singular

#### solve

    public RealVector solve(RealVector b)
                     throws IllegalArgumentException,
                            InvalidMatrixException

Solve the linear equation A × X = B for matrices A.

The A matrix is implicit, it is provided by the underlying decomposition algorithm.

Specified by:
  `solve` in interface `DecompositionSolver`
Parameters:
  `b` - right-hand side of the equation A × X = B
Returns:
  a vector X that minimizes the two norm of A × X - B
Throws:
  `IllegalArgumentException` - if matrices dimensions don't match
  `InvalidMatrixException` - if decomposed matrix is singular

#### solve

    public ArrayRealVector solve(ArrayRealVector b)
                          throws IllegalArgumentException,
                                 InvalidMatrixException

Solve the linear equation A × X = B.

The A matrix is implicit here. It is

Parameters:
  `b` - right-hand side of the equation A × X = B
Returns:
  a vector X that minimizes the two norm of A × X - B
Throws:
  `IllegalArgumentException` - if matrices dimensions don't match
  `InvalidMatrixException` - if decomposed matrix is singular

#### solve

    public RealMatrix solve(RealMatrix b)
                     throws IllegalArgumentException,
                            InvalidMatrixException

Solve the linear equation A × X = B for matrices A.

The A matrix is implicit, it is provided by the underlying decomposition algorithm.

Specified by:
  `solve` in interface `DecompositionSolver`
Parameters:
  `b` - right-hand side of the equation A × X = B
Returns:
  a matrix X that minimizes the two norm of A × X - B
Throws:
  `IllegalArgumentException` - if matrices dimensions don't match
  `InvalidMatrixException` - if decomposed matrix is singular

#### getInverse

    public RealMatrix getInverse()
                          throws InvalidMatrixException

Get the inverse (or pseudo-inverse) of the decomposed matrix.

Specified by:
  `getInverse` in interface `DecompositionSolver`
Returns:
  inverse matrix
Throws:
  `InvalidMatrixException` - if decomposed matrix is singular