Solve and Inverse for General Matrices

DESCRIPTION:
Either solves a system of linear equations or else finds the inverse or pseudo-inverse of a matrix.

USAGE:
solve.Matrix(a, b, tol=0, transpose=F, tune, workspace)

REQUIRED ARGUMENTS:
a:
A numeric or complex Matrix, inheriting from class "Matrix".

OPTIONAL ARGUMENTS:
b:
A matrix or vector. If transpose=T The number of rows of b must equal the number of rows of a, while if transpose=F the number of rows of b must equal the number of columns of a.
tol:
Tolerance for reciprocal condition estimation. If tol is negative, no condition estimation is done. Otherwise, the reciprocal one 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.
tune:
a integer vector or list of named tuning parameters that may affect computational efficiency. The relevant parameters are the blocksize parameters NB, NBMIN, and NX as described in .laenv.
workspace:
workspace provided to the underlying software. The default is to use the optimum value relative to the tuning parameters. The optimal workspace for the problem (with the given tuning parameters) is included as part of the output attributes.

VALUE:
An object of class Matrix". If a is square, it is the solution x to the system of equations a %*% x = scale.b * b if b is present and otherwise the inverse of a. If ais not square, it is the the minimum l-2 norm solution to the system of equations if b is present and otherwise the pseudo-inverse of a. Attributes include a copy of the call to solve, the optimal workspace for the underlying software, and the one norm reciprocal condition estimate if tol is nonnegative.

DETAILS:
Based on the functions dgecon, dgetrf, dgetri, zgecon, zgetrf, zgetri, dtrcon, dgeqpf, dormqr, dorgqr, ztrcon, zgeqpf, zunmqr, and zungqr from LAPACK (Anderson et al. 1994).

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

SEE ALSO:
rcond.Matrix , solve , solve.Hermitian , solve.lu.Matrix , solve.qr.Matrix , solve.svd.Matrix .

EXAMPLES:
m <- sample(1:9,1); n <- sample(1:9,1)
a <- Matrix( rnorm(m*n), nrow = m, ncol = n)
b <- rnorm(m)
t(a) %*% (a%*% solve(a,b) - b)            # residual of normal equations
(solve(a) %*% b) - solve(a,b)