def test_one_element(self): result = solveupper(numpy.asarray([[2.]]), numpy.asarray([4.])) assert_array_equal(result, numpy.asarray([2.]))
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)
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]))
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])
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)