Example #1
0
 def test_unit_arrays_3(self):
     a = numpy.array([[1.0, 0.0, 0.0]], floattype)
     b = numpy.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]], floattype).T
     result = sasmath.matrix_multiply(a, b)[1]
     expected = numpy.array([[1.0, 0.0]], floattype)
     self.assert_list_almost_equal(result, expected)
     result_error = sasmath.matrix_multiply(a, b)[0]
     expected_error = []
     self.assertEqual(result_error, expected_error)
    def test_unit_arrays_3(self):
        a=numpy.array([[1.0, 0.0, 0.0]],floattype)
        b=numpy.array([[1.0, 0.0, 0.0],[0.0, 1.0, 0.0]],floattype).T
        result = sasmath.matrix_multiply(a,b)[1]
        expected = numpy.array([[1.0, 0.0]],floattype)
        self.assert_list_almost_equal(result,expected)
	result_error = sasmath.matrix_multiply(a,b)[0]
	expected_error = []
	self.assertEqual(result_error, expected_error)
    def test_zero(self):
        a=numpy.array([[util.ZERO, -20.0, 80.0],[2.02, util.ZERO, 20.0]],floattype)
        b=numpy.array([[1.23, 2.0, 20.0],[10.0, 21.0, util.ZERO]],floattype).T
        result = sasmath.matrix_multiply(a,b)[1]
        expected = numpy.array([[1560.0, -420.0],[402.4846, 20.2]],floattype)
	print result
        self.assert_list_almost_equal(result,expected)
	result_error = sasmath.matrix_multiply(a,b)[0]
	expected_error = []
	self.assertEqual(result_error, expected_error)
    def test_nan_inf(self):
        a=numpy.array([[util.INF, -20.0, 80.0],[2.02, util.NAN, 20.0]],floattype)
        b=numpy.array([[1.23, 2.0, 20.0],[10.0, 21.0, util.NAN]],floattype).T
        result = sasmath.matrix_multiply(a,b)[1]
        expected = numpy.array([[util.INF, util.NAN],[util.NAN, util.NAN]],floattype)
	print result
        self.assert_list_almost_equal(result,expected)
	result_error = sasmath.matrix_multiply(a,b)[0]
	expected_error = []
	self.assertEqual(result_error, expected_error)
    def test_arb_2(self):
        a=numpy.array([[1.0168308, -1.35572028, -1.35362422],[-0.69958848, 1.66901076, 0.49978462]],floattype)
        b=numpy.array([-20.69958848, 16.66901076, 20.49978462],floattype)
        result = sasmath.matrix_multiply(a,b)[1]
        expected = numpy.array([[-71.396],[52.547]],floattype)
	print result
        self.assert_list_almost_equal(result,expected,3)
	result_error = sasmath.matrix_multiply(a,b)[0]
	expected_error = []
	self.assertEqual(result_error, expected_error)
    def test_arb_1(self):
        a=numpy.array([[12.0, -20.0, -80.0],[2.02, -901.0, 0.0]],floattype)
        b=numpy.array([[1.23, 0.03, 20.0],[10.0, 1.0, 3.0]],floattype).T
        result = sasmath.matrix_multiply(a,b)[1]
        expected = numpy.array([[-1585.84, -140.0],[-24.5454, -880.8]],floattype)
	print result
        self.assert_list_almost_equal(result,expected)
	result_error = sasmath.matrix_multiply(a,b)[0]
	expected_error = []
	self.assertEqual(result_error, expected_error)
Example #7
0
 def test_arb_2(self):
     a = numpy.array([[1.0168308, -1.35572028, -1.35362422],
                      [-0.69958848, 1.66901076, 0.49978462]], floattype)
     b = numpy.array([-20.69958848, 16.66901076, 20.49978462], floattype)
     result = sasmath.matrix_multiply(a, b)[1]
     expected = numpy.array([[-71.396], [52.547]], floattype)
     print result
     self.assert_list_almost_equal(result, expected, 3)
     result_error = sasmath.matrix_multiply(a, b)[0]
     expected_error = []
     self.assertEqual(result_error, expected_error)
Example #8
0
 def test_arb_1(self):
     a = numpy.array([[12.0, -20.0, -80.0], [2.02, -901.0, 0.0]], floattype)
     b = numpy.array([[1.23, 0.03, 20.0], [10.0, 1.0, 3.0]], floattype).T
     result = sasmath.matrix_multiply(a, b)[1]
     expected = numpy.array([[-1585.84, -140.0], [-24.5454, -880.8]],
                            floattype)
     print result
     self.assert_list_almost_equal(result, expected)
     result_error = sasmath.matrix_multiply(a, b)[0]
     expected_error = []
     self.assertEqual(result_error, expected_error)
Example #9
0
 def test_zero(self):
     a = numpy.array([[util.ZERO, -20.0, 80.0], [2.02, util.ZERO, 20.0]],
                     floattype)
     b = numpy.array([[1.23, 2.0, 20.0], [10.0, 21.0, util.ZERO]],
                     floattype).T
     result = sasmath.matrix_multiply(a, b)[1]
     expected = numpy.array([[1560.0, -420.0], [402.4846, 20.2]], floattype)
     print result
     self.assert_list_almost_equal(result, expected)
     result_error = sasmath.matrix_multiply(a, b)[0]
     expected_error = []
     self.assertEqual(result_error, expected_error)
Example #10
0
 def test_nan_inf(self):
     a = numpy.array([[util.INF, -20.0, 80.0], [2.02, util.NAN, 20.0]],
                     floattype)
     b = numpy.array([[1.23, 2.0, 20.0], [10.0, 21.0, util.NAN]],
                     floattype).T
     result = sasmath.matrix_multiply(a, b)[1]
     expected = numpy.array([[util.INF, util.NAN], [util.NAN, util.NAN]],
                            floattype)
     print result
     self.assert_list_almost_equal(result, expected)
     result_error = sasmath.matrix_multiply(a, b)[0]
     expected_error = []
     self.assertEqual(result_error, expected_error)