예제 #1
0
 def testRandom(self):
   m = Matrix(5)
   m.random(3)
   q, r = m.QRSimple()
   one = Matrix(5)
   one.one()
   self.assertTrue(m.isAlmostEqual(q*r))
   self.assertTrue(one.isAlmostEqual(q*q.transpose()))
예제 #2
0
 def testRandom(self):
   m = Matrix(self.size)
   m.random(3)
   q, r = m.QRHouseholder()
   one = Matrix(self.size)
   one.one()
   self.assertTrue(m.isAlmostEqual(q*r))
   self.assertTrue(one.isAlmostEqual(q*q.transpose()))
예제 #3
0
  def test(self, m, size):
    one = Matrix(size)
    one.one()

    e_lu = (m * m.invertLU() - one).frobeniusNorm()
    e_qr_simple = (m * m.invertQRSimple() - one).frobeniusNorm()
    e_qr_house = (m * m.invertQRHouseholder() - one).frobeniusNorm()

    self.putMany([size, e_lu, e_qr_simple, e_qr_house])
예제 #4
0
  def testRandom(self):
    l = Matrix(self.size) 
    u = Matrix(self.size)
    l.randomLowerTriangular(5)
    u.randomUpperTriangular(5)

    m = l * u
    one = Matrix(self.size)
    one.one()
    self.assertTrue(one.isAlmostEqual(m * m.invertLU()))
  def testUpperTriangularInversion(self):
    a = Matrix(15)
    a.randomUpperTriangular(87)
    b = a.invertUpperTriangular()
    c = Matrix(15)
    c.one()

    print (c - a * b).frobeniusNorm()

    self.assertTrue(c.isAlmostEqual(a * b))
    self.assertTrue(c.isAlmostEqual(b * a))
예제 #6
0
  def test(self, m, size):
    one = Matrix(size)
    one.one()
    m.random(int(time()))

    q, r = m.QRSimple()
    a_simple = (q*q.transpose() - one).frobeniusNorm()
    b_simple = (m - q*r).frobeniusNorm()
    
    q, r = m.QRHouseholder()
    a_house = (q*q.transpose() - one).frobeniusNorm()
    b_house = (m - q*r).frobeniusNorm()
     
    self.putMany([size, a_simple, b_simple, a_house, b_house])
예제 #7
0
 def testManipulators(self):
   a = Matrix(44)
   a.zero()
   a.one()
   a.hilbert()
예제 #8
0
 def testUnit(self):
   one = Matrix(self.size)
   one.one()
   self.assertTrue(one.isAlmostEqual(one.invertLU()))
예제 #9
0
 def testRandom(self):
   m = Matrix(self.size) 
   m.random(3);
   one = Matrix(self.size)
   one.one()
   self.assertTrue(one.isAlmostEqual(m * m.invertQRHouseholder()))