edu.stanford.rsl.konrad.numerics
Class DecompositionRQ

java.lang.Object
  extended by edu.stanford.rsl.konrad.numerics.DecompositionRQ

public class DecompositionRQ
extends java.lang.Object

Implements an RQ decomposition for arbitrary matrices. This functor object allows to decompose any matrix $\mathbf{A}$ into matrices $\mathbf{R}$ and $\mathbf{Q}$ such that

\[
Use it for solving systems of linear equations and for computing the infinite set of solutions for an under-determined system of equations. The RQ decomposition is not suited for minimization problems (with more equations than variables). Assuming $\mathbf{A}$ is a $m \times n$ matrix, the decomposition is performed such that the matrix $\mathbf{R}$ has dimensions $m \times n$ and has upper triangular form ($r_{i,j} = 0$ for $m-i < n-j$) and the matrix $\mathbf{Q}$ has dimensions $n \times n$ and is orthogonal. Internally, only a compressed version of the factors $\mathbf{R}$ and $\mathbf{Q}$ is stored which together needs approximately as much space as the original matrix $\mathbf{A}$. Usage: Nude::Decomposition::RQ<> rq; rq(A); rq.solve(b);

Author:
Andreas Keil (Implementations started from JAMA code but now contain strong modifications. Actually, now it's a mix of JAMA and the version in Deuflhard/Hohmann: Numerische Mathematik I.)
See Also:
DecompositionQR, Projection

Constructor Summary
DecompositionRQ(SimpleMatrix A)
          Constructor performing the actual decomposition of a matrix $\mathbf{A}$ and storing the result in an internal format.
 
Method Summary
 SimpleMatrix getQ()
          Computes the orthogonal $n \times n$ matrix $\mathbf{Q}$.
 SimpleMatrix getR()
          Computes the upper-triangular $m \times n$ matrix $\mathbf{R}$.
 boolean isFullRank()
          Specifies whether the input Matrix $A$ has full rank.
 SimpleMatrix solve(SimpleMatrix B)
          Computes solution Matrix $\mathbf X$ for the right-hand-side $\mathbf B$.
 SimpleVector solve(SimpleVector b)
          Computes solution Vector $\mathbf{x}$ for the right-hand-side $\mathbf b$.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DecompositionRQ

public DecompositionRQ(SimpleMatrix A)
Constructor performing the actual decomposition of a matrix $\mathbf{A}$ and storing the result in an internal format. Decomposition is performed as soon as a Matrix is given to this constructor and the result is stored internally. Afterwards, the other other members (solve(SimpleVector b), solve(SimpleMatrix B), getQ(), and getR()) can be used multiple times without having to recompute the decomposition.

Parameters:
A - The Matrix to be decomposed.
Method Detail

isFullRank

public boolean isFullRank()
Specifies whether the input Matrix $A$ has full rank.

Returns:
Whether the input Matrix has full rank ($\min\{m, n\}$).

solve

public SimpleVector solve(SimpleVector b)
Computes solution Vector $\mathbf{x}$ for the right-hand-side $\mathbf b$. Depending on the size of $\mathbf A \in \mathbb{R}^{m \times n}$, the problem task can be either the solution of a system of equations with one or an infinite number of solutions:
%preamble{\usepackage{amsmath}} \begin{align}
$m > n$ throws an exception, since the RQ decomposition is not suited for solving minimization problems. Use a QR decomposition in this case. For $m < n$ the RQ decomposition computes the minimum norm solution to the under-determined system of equations. The $n-m$ dimensional set of all solutions can then be obtained by adding any linear combination of the first $n-m$ rows of $\mathbf{Q}$.

Remark: If you want to further improve the accuracy of your solution in case (1), perform a correction step in the following manner:
x = rq.solve(b); x += rq.solve(b - A*x);

Parameters:
b - The right-hand-side Vector.
Returns:
The solution Vector $\mathbf x$.
See Also:
solve(SimpleMatrix)

solve

public SimpleMatrix solve(SimpleMatrix B)
Computes solution Matrix $\mathbf X$ for the right-hand-side $\mathbf B$. This method does the same as @link{#solve(SimpleVector)} but for multiple right-hand-side vectors, given as a Matrix.

Parameters:
B - The right-hand-side Matrix for which a solution is computed column-wise.
Returns:
The solution Matrix $\mathbf X$.
See Also:
solve(SimpleVector)

getR

public SimpleMatrix getR()
Computes the upper-triangular $m \times n$ matrix $\mathbf{R}$. The matrices $\mathbf{R}$ and $\mathbf{Q}$ are stored in an internal format and only explicitly computed on request. They are not needed for solving one of the equations mentioned in the solve() members! Only call this method if you really actually need the full decomposed matrices.

Returns:
The upper-triangular Matrix $\mathbf{R} \in \mathbb{R}^{m \times n}$.
See Also:
getQ(), solve(SimpleVector), solve(SimpleMatrix)

getQ

public SimpleMatrix getQ()
Computes the orthogonal $n \times n$ matrix $\mathbf{Q}$. The matrices $\mathbf{Q}$ and $\mathbf{R}$ are stored in an internal format and only explicitly computed on request. They are not needed for solving one of the equations mentioned in the solve() members! Only call this method if you really actually need the full decomposed matrices.

Returns:
The orthogonal Matrix $\mathbf{Q} \in \mathbb{R}^{n \times n}$.
See Also:
getR(), solve(SimpleVector), solve(SimpleMatrix)