Solve Linear Equations and Invert Matrices - Generic Function

DESCRIPTION:
Performs matrix inversion if given a single argument, or solves systems of linear equations if given two arguments. There are solve methods in the Matrix library that differ (both in argument list, as well as in returned value) from the S-PLUS default.

This function is generic (see Methods); method functions can be written to handle specific classes of data. Classes which already have methods for this function include: svd.right, upper.


USAGE:
solve(a, b, ...)
solve.default(a, b)

REQUIRED ARGUMENTS:
a:
a representation of a square non-singular matrix. In particular a QR decomposition as output by the qr function is suitable.

OPTIONAL ARGUMENTS:
b:
vector or matrix of coefficients.

VALUE:
the solution x to the system of equations a %*% x = b, if b is present. Otherwise, the inverse of a.

DETAILS:
If given a non-singular matrix a, will give the inversion of the matrix. If given two arguments, a and b, will give the solution x for the system of equations.

SEE ALSO:
chol , matrix , qr , qr.coef , solve.Matrix , svd .

t for the transpose of a matrix.


EXAMPLES:
amat <- matrix(c(19,8,11,2,18,17,15,19,10), nrow = 3)
ainv <- solve(amat)    # invert amat

aqr <- qr(amat) b1 <- c(9,5,14) solve(aqr, b1)