nzmath.matrix | (Japanese)

FieldSquareMatrix

The class is for square matrix whose coefficient ring belongs field. It is a subclass of FieldMatrix and RingSquareMatrix.

Constructor

FieldSquareMatrix(row[, column, compo, coeff_ring])

row and column must be a positive integer and row has to equal column. compo must be a list form. coeff_ring must be an instance of ring.Ring. In general, given matrix size and coefficient ring unspecified, you should call createMatrix for your profit.

Methods

triangulate()

Return an upper triangulated matrix obtained by elementary row operations.

>>> A = matrix.FieldSquareMatrix(3, [1,2,3,4,5,6,7,8,9]
>>> print A.triangulate()
  1    2    3
0/1 -3/1 -6/1
0/1  0/1  0/1

determinant()

Return the determinant. It overrides that of RingSquareMatrix.

>>> A = matrix.FieldSquareMatrix(3, [1,2,3,4,5,6,7,8,9])
>>> A.determinant()
Rational(0, 1)

inverse([V])

Return the inverse. If a vector or matrix V is given, then return self^(-1) * V. If the matrix is not invertible, then raise NoInverse.

>>> A = matrix.FieldSquareMatrix(3, [1,2,3,4,5,6,7,8,10])
>>> A.inverse()
-2/3 -4/3  1/1
-2/3 11/3 -2/1
 1/1 -2/1  1/1
>>> V = vector.Vector([-1,-2,-3])
>>> A.inverse(V)
Vector([Rational(1, 3), Rational(-2, 3), Rational(0, 1)])
>>> A.inverse() * V
Vector([Rational(1, 3), Rational(-2, 3), Rational(0, 1)]) 

hessenbergForm()

Compute the Hessenberg form.

>>> A=matrix.FieldSquareMatrix(4, [1,-1,2,-2,3,-3,4,-4,5,-5,6,-6,7,-7,8,0])
>>> print A.hessenbergForm()
1   -7/5 -141/71  -1
5  -27/5 -421/71  -5
0 284/25    42/5 0/1
0      0  -20/71 0/1

LUDecomposition()

return L and U s.t. M == L * U:

>>> A =matrix.FieldSquareMatrix(3, [4,1,1,1,3,1,2,1,5])
>>> L, U = A.LUDecomposition()
>>> print L
1/1  0/1 0/1
1/4  1/1 0/1
1/2 2/11 1/1
>>> print U
  4    1     1
0/1 11/4   3/4
0/1  0/1 48/11
>>> L * U == A
True