3 # 2009-01-16, Xavier Delacour <xavier.delacour@gmail.com>
7 from numpy.linalg import *;
12 from adaptors import *;
14 ## these are mostly to test bindings, since there are more/better tests in tests/cxcore
18 assert(all(abs(x - y)<1e-4));
20 class roots_test(unittest.TestCase):
22 def test_cvSolvePoly(self):
24 verify(cvSolvePoly(asmatrix([-1,1]).astype(float64)),
25 array([[(1.000000, 0.000000)]]));
27 verify(cvSolvePoly(asmatrix([-1,1]).astype(float32)),
28 array([[(1.000000, 0.000000)]]));
30 verify(cvSolvePoly(asmatrix([-1,0,0,0,0,1]).astype(float64)),
31 array([[(1, 0)],[(0.309017, 0.951057)],[(0.309017, -0.951057)],
32 [(-0.809017, 0.587785)],[(-0.809017, -0.587785)]]))
34 verify(cvSolvePoly(asmatrix([-1,0,0,0,0,1]).astype(float32)),
35 array([[(1, 0)],[(0.309017, 0.951057)],[(0.309017, -0.951057)],
36 [(-0.809017, 0.587785)],[(-0.809017, -0.587785)]]))
38 def test_cvSolveCubic(self):
40 verify(cvSolveCubic(asmatrix([-1,0,0,1]).astype(float32))[1],
41 array([[1],[0],[0]]));
43 verify(cvSolveCubic(asmatrix([-1,0,0,1]).astype(float64))[1],
44 array([[1],[0],[0]]));
47 return unittest.TestLoader().loadTestsFromTestCase(roots_test)
49 if __name__ == '__main__':
50 unittest.TextTestRunner(verbosity=2).run(suite())