Exemplo n.º 1
0
 def testMatrixInverse(self):
     im = IM(((1, 2, 3), (4, 5, 6), (7, 8, 10)))
     inverseIm = im.inverse()
     inverseImReference = [[-0.66666666666666663, -1.3333333333333333, 1.0],
                           [-0.66666666666666663, 3.6666666666666665, -2.0],
                           [1.0, -2.0, 1.0]]
     EDAssert.equal(inverseImReference, inverseIm)
Exemplo n.º 2
0
from GPLinearAlgebra import GPIntVector as IV
from GPLinearAlgebra import GPFloatVector as FV
from GPLinearAlgebra import GPUnitVector as UV
from GPLinearAlgebra import GPIntMatrix as IM
from GPLinearAlgebra import GPFloatMatrix as FM
from GPLinearAlgebra import GPRotation as R

# A couple of simple instantiations (integer vector and integer matrix)
iv = IV((2, 4, 6))
im = IM(((1, 2, 3), (4, 5, 6), (7, 8, 10)))

print "Integer vector iv: ", iv
print "Integer matrix im: ", im
print "im * iv: ", im * iv
print "iv * im: ", iv * im
print "im.determinant(), im.inverse(): ", im.determinant(), im.inverse()
print "im ** 2", im**2
print

m1 = FM(((7, 0, 0), (2, 4, 0), (3, 5, 6)))
m2 = m1 * m1.transpose()

print "Matrix m1: ", m1
print "Matrix m2 (m1 * m1.transpose()): ", m2
print "m2.cholesky(): ", m2.cholesky(tolerance=1e-8)
print "m2.trace(): ", m2.trace()
print "m2.determinant(): ", m2.determinant()
print "m2.inverse(): ", m2.inverse(tolerance=1e-8)
print "m2.cofactor(): ", m2.cofactor()
print "m2.adjugate(): ", m2.adjugate()
Exemplo n.º 3
0
 def testMatrixDeterminant(self):
     im = IM(((1, 2, 3), (4, 5, 6), (7, 8, 10)))
     determinantIm = im.determinant()
     determinantImReference = -3
     EDAssert.equal(determinantImReference, determinantIm)
Exemplo n.º 4
0
from GPLinearAlgebra import GPIntVector   as IV
from GPLinearAlgebra import GPFloatVector as FV
from GPLinearAlgebra import GPUnitVector  as UV
from GPLinearAlgebra import GPIntMatrix   as IM
from GPLinearAlgebra import GPFloatMatrix as FM
from GPLinearAlgebra import GPRotation    as R

# A couple of simple instantiations (integer vector and integer matrix)
iv = IV((2,4,6))
im = IM(((1,2,3),(4,5,6),(7,8,10)))

print "Integer vector iv: ", iv
print "Integer matrix im: ", im
print "im * iv: ", im * iv
print "iv * im: ", iv * im
print "im.determinant(), im.inverse(): ", im.determinant(), im.inverse()
print "im ** 2", im ** 2
print

m1 = FM( ( (7,0,0), (2,4,0), (3,5,6) ) )
m2 = m1 * m1.transpose()

print "Matrix m1: ", m1
print "Matrix m2 (m1 * m1.transpose()): ", m2
print "m2.cholesky(): ", m2.cholesky( tolerance=1e-8 )
print "m2.trace(): ", m2.trace()
print "m2.determinant(): ", m2.determinant()
print "m2.inverse(): ", m2.inverse( tolerance=1e-8 )
print "m2.cofactor(): ", m2.cofactor()
print "m2.adjugate(): ", m2.adjugate()
Exemplo n.º 5
0
 def testMatrixInverse(self):
     im = IM(((1, 2, 3), (4, 5, 6), (7, 8, 10)))
     inverseIm = im.inverse()
     inverseImReference = [[-0.66666666666666663, -1.3333333333333333, 1.0], [-0.66666666666666663, 3.6666666666666665, -2.0], [1.0, -2.0, 1.0]]
     EDAssert.equal(inverseImReference, inverseIm)
Exemplo n.º 6
0
 def testMatrixDeterminant(self):
     im = IM(((1, 2, 3), (4, 5, 6), (7, 8, 10)))
     determinantIm = im.determinant()
     determinantImReference = -3
     EDAssert.equal(determinantImReference, determinantIm)