Solve and Inverse for Triangular Matrices

DESCRIPTION:
Either solves a system of linear equations with a triangular coefficient matrix or else finds the inverse of a triangular matrix.

USAGE:
solve.LowerTriangular(a, b, tol=0, transpose=F, left=T, scale.b=1)
solve.UpperTriangular(a, b, tol=0, transpose=F, left=T, scale.b=1)
solve.UnitLowerTriangular(a, b, tol=0, transpose=F, left=T, scale.b=1)
solve.UnitUpperTriangular(a, b, tol=0, transpose=F, left=T, scale.b=1)

REQUIRED ARGUMENTS:
a:
A triangular Matrix, inheriting from class "Matrix" and one of "LowerTriangular", "UpperTriangular", "UnitLowerTriangular", or "UnitUpperTriangular".

OPTIONAL ARGUMENTS:
b:
A matrix or vector. The number of rows in b must equal the dimension of a.
tol:
Tolerance for reciprocal condition estimation. If tol is negative, no condition estimation is done. Otherwise, the reciprocal infinity norm condition estimate is computed and the solve or inverse computation is done only if the condition estimate is greater than tol. By default, tol = 0.
transpose:
A logical variable indicating whether or not the transpose (conjugate transpose if complex) of a is to be used in the solve or inverse operation. The default is to use the untransposed matrix.
left:
A logical variable indicating whether or not the coefficient matrix a appears on the left of the solution in the set of linear equations to be solved. The default assumes that a appears to the left of the solution. This argument is ignored when b is missing.
scale.b:
Scale factor to apply to the matrix b. The default is scale.b = 1, so that b is unscaled.

VALUE:
An object of class "Matrix" that is the solution x to the system of equations a %*% x = scale.b * b if b is present and otherwise the inverse of a. Attributes include a copy of the call to solve, and the one norm reciprocal condition estimate if tol is nonnegative.

DETAILS:
Based on the functions dtrcon, dtrtrf, dtrtri, ztrcon, ztrtrf, and ztrtri from LAPACK (Anderson et al. 1994).

REFERENCES:
Anderson, E., et al. (1994). LAPACK User's Guide, 2nd edition, SIAM, Philadelphia.

SEE ALSO:
rcond.LowerTriangular , solve , solve.Matrix .

EXAMPLES:
 n <- 5
 a <- Matrix( rnorm(n*n), n, n)
 a[row(a) < col(a)] <- 0                 # form lower triangular matrix
 class(a) <- Matrix.class(x)
 b <- rnorm(n)
 a %*% solve(a,b) - b                    # residual
 solve(a) %*% a                          # should be identity