예제 #1
0
 def test_one_element(self):
     result = solveupper(numpy.asarray([[2.]]), numpy.asarray([4.]))
     assert_array_equal(result, numpy.asarray([2.]))
예제 #2
0
 def test_not_triangular(self):
     m = numpy.array([[2, 1, 0], [1, 1, 0], [0, 0, 1]], dtype='f')
     b = numpy.array([1, 1, 1], dtype='f')
     with self.assertRaises(Exception):
         solveupper(m, b)
예제 #3
0
 def test_three_elements(self):
     m = numpy.array([[1, 4, 2], [0, 1, 3], [0, 0, 1]], dtype='f')
     b = numpy.array([-3, 11, 5], dtype='f')
     r = solveupper(m, b)
     assert_array_equal(r, numpy.array([3, -4, 5]))
예제 #4
0
 def test_division_on_diagonal(self):
     m = numpy.array([[2, 0], [0, 1]], dtype='f')
     b = numpy.array([4, 1], dtype='f')
     r = solveupper(m, b)
     assert_array_equal(r, [2, 1])
예제 #5
0
 def test_id(self):
     m = numpy.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]], dtype='f')
     b = numpy.array([3, 1, 5], dtype='f').T
     r = solveupper(m, b)
     assert_array_equal(r, numpy.asarray([3, 1, 5]).T)