package Jampack; /** Inv computes the inverse of a matrix.
Comments: Inv computes the inverse of A by using Solve to solve
the system AX = I. This is inefficient, though
not inordinately so. Eventually these methods will be
replaced.
@version Pre-alphs
@author G. W. Stewart
*/
public class Inv{
/**
Computes the inverse of a Zltmat.
@param L The Zltmat
@return The inverse of L
@exception JampackException
Thrown if L is not square.
Passed from below.
*/
public static Zltmat o(Zltmat L)
throws JampackException{
if (L.nrow != L.ncol)
throw new JampackException
("Cannot compute the inverse of a rectangular matrix.");
return new Zltmat(Solve.aib(L, Eye.o(L.nrow)));
}
/**
Computes the inverse of a Zutmat.
@param U The Zutmat
@return The inverse of U
@exception JampackException
Thrown if U is not square.
Passed from below.
*/
public static Zutmat o(Zutmat U)
throws JampackException{
if (U.nrow != U.ncol)
throw new JampackException
("Cannot compute the inverse of a rectangular matrix.");
return new Zutmat(Solve.aib(U, Eye.o(U.nrow)));
}
/**
Computes the inverse of a square Zmat
@param A The Zmat
@return The inverse of A
@exception JampackException
Thrown if A is not square.
Passed from below.
*/
public static Zmat o(Zmat A)
throws JampackException{
if (A.nrow != A.ncol)
throw new JampackException
("Cannot compute the inverse of a rectangular matrix.");
return Solve.aib(A, Eye.o(A.nrow));
}
/**
Computes the inverse of a Zpsdmat.
@param A The Zpsdmat
@return The inverse of A
@exception JampackException
Thrown if A is not square.
Passed from below.
*/
public static Zpsdmat o(Zpsdmat A)
throws JampackException{
if (A.nrow != A.ncol)
throw new JampackException
("Cannot compute the inverse of a rectangular matrix.");
Zpsdmat B = new Zpsdmat( Solve.aib(A, Eye.o(A.nrow)));
for (int i=0; i