Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

TST: fix linalg.qz test to avoid seg fault on Windows. Closes #1717.

(backported from baa8f73)
  • Loading branch information...
commit c30added774ee0245fd4e20db32ed8a38b75ab09 1 parent fefca77
@jseabold jseabold authored rgommers committed
Showing with 67 additions and 32 deletions.
  1. +67 −32 scipy/linalg/tests/test_decomp.py
View
99 scipy/linalg/tests/test_decomp.py
@@ -1691,46 +1691,81 @@ def test_qz_double_complex(self):
def test_qz_double_sort(self):
#from http://www.nag.com/lapack-ex/node119.html
- A = np.array([[3.9, 12.5, -34.5, -0.5],
- [ 4.3, 21.5, -47.5, 7.5],
- [ 4.3, 21.5, -43.5, 3.5],
- [ 4.4, 26.0, -46.0, 6.0 ]])
-
- B = np.array([[ 1.0, 2.0, -3.0, 1.0],
- [1.0, 3.0, -5.0, 4.0],
- [1.0, 3.0, -4.0, 3.0],
- [1.0, 3.0, -4.0, 4.0]])
+ #NOTE: These matrices may be ill-conditioned and lead to a
+ # seg fault on certain python versions when compiled with
+ # sse2 or sse3 older ATLAS/LAPACK binaries for windows
+ #A = np.array([[3.9, 12.5, -34.5, -0.5],
+ # [ 4.3, 21.5, -47.5, 7.5],
+ # [ 4.3, 21.5, -43.5, 3.5],
+ # [ 4.4, 26.0, -46.0, 6.0 ]])
+
+ #B = np.array([[ 1.0, 2.0, -3.0, 1.0],
+ # [1.0, 3.0, -5.0, 4.0],
+ # [1.0, 3.0, -4.0, 3.0],
+ # [1.0, 3.0, -4.0, 4.0]])
+ A = np.array([[3.9, 12.5, -34.5, 2.5],
+ [ 4.3, 21.5, -47.5, 7.5],
+ [ 4.3, 1.5, -43.5, 3.5],
+ [ 4.4, 6.0, -46.0, 6.0 ]])
+
+ B = np.array([[ 1.0, 1.0, -3.0, 1.0],
+ [1.0, 3.0, -5.0, 4.4],
+ [1.0, 2.0, -4.0, 1.0],
+ [1.2, 3.0, -4.0, 4.0]])
+
sort = lambda ar,ai,beta : ai == 0
AA,BB,Q,Z,sdim = qz(A,B,sort=sort)
- assert_(sdim == 2)
+ #assert_(sdim == 2)
+ assert_(sdim == 4)
assert_array_almost_equal(dot(dot(Q,AA),Z.T), A)
assert_array_almost_equal(dot(dot(Q,BB),Z.T), B)
+ assert_array_almost_equal(AA, np.array(
+ [[ 35.7864, -80.9061, -12.0629, -9.498 ],
+ [ 0. , 2.7638, -2.3505, 7.3256],
+ [ 0. , 0. , 0.6258, -0.0398],
+ [ 0. , 0. , 0. , -12.8217]]), 4)
+ assert_array_almost_equal(BB, np.array(
+ [[ 4.5324, -8.7878, 3.2357, -3.5526],
+ [ 0. , 1.4314, -2.1894, 0.9709],
+ [ 0. , 0. , 1.3126, -0.3468],
+ [ 0. , 0. , 0. , 0.559 ]]), 4)
+ assert_array_almost_equal(Q, np.array(
+ [[-0.4193, -0.605 , -0.1894, -0.6498],
+ [-0.5495, 0.6987, 0.2654, -0.3734],
+ [-0.4973, -0.3682, 0.6194, 0.4832],
+ [-0.5243, 0.1008, -0.7142, 0.4526]]), 4)
+ assert_array_almost_equal(Z, np.array(
+ [[-0.9471, -0.2971, -0.1217, 0.0055],
+ [-0.0367, 0.1209, 0.0358, 0.9913],
+ [ 0.3171, -0.9041, -0.2547, 0.1312],
+ [ 0.0346, 0.2824, -0.9587, 0.0014]]), 4)
+
# test absolute values bc the sign is ambiguous and might be platform
# dependent
- assert_array_almost_equal(abs(AA), abs(np.array([
- [3.8009, -69.4505, 50.3135, -43.2884],
- [0.0000, 9.2033, -0.2001, 5.9881],
- [0.0000, 0.0000, 1.4279, 4.4453],
- [0.0000, 0.0000, 0.9019, -1.1962]])), 4)
- assert_array_almost_equal(abs(BB), abs(np.array([
- [1.9005, -10.2285, 0.8658, -5.2134],
- [0.0000, 2.3008, 0.7915, 0.4262],
- [0.0000, 0.0000, 0.8101, 0.0000],
- [0.0000, 0.0000, 0.0000, -0.2823]])), 4)
- assert_array_almost_equal(abs(Q), abs(np.array([
- [0.4642, 0.7886, 0.2915, -0.2786],
- [0.5002, -0.5986, 0.5638, -0.2713],
- [0.5002, 0.0154, -0.0107, 0.8657],
- [0.5331, -0.1395, -0.7727, -0.3151]])), 4)
- assert_array_almost_equal(dot(Q,Q.T), eye(4))
- assert_array_almost_equal(abs(Z), abs(np.array([
- [0.9961, -0.0014, 0.0887, -0.0026],
- [0.0057, -0.0404, -0.0938, -0.9948],
- [0.0626, 0.7194, -0.6908, 0.0363],
- [0.0626, -0.6934, -0.7114, 0.0956]])), 4)
- assert_array_almost_equal(dot(Z,Z.T), eye(4))
+ #assert_array_almost_equal(abs(AA), abs(np.array([
+ # [3.8009, -69.4505, 50.3135, -43.2884],
+ # [0.0000, 9.2033, -0.2001, 5.9881],
+ # [0.0000, 0.0000, 1.4279, 4.4453],
+ # [0.0000, 0.0000, 0.9019, -1.1962]])), 4)
+ #assert_array_almost_equal(abs(BB), abs(np.array([
+ # [1.9005, -10.2285, 0.8658, -5.2134],
+ # [0.0000, 2.3008, 0.7915, 0.4262],
+ # [0.0000, 0.0000, 0.8101, 0.0000],
+ # [0.0000, 0.0000, 0.0000, -0.2823]])), 4)
+ #assert_array_almost_equal(abs(Q), abs(np.array([
+ # [0.4642, 0.7886, 0.2915, -0.2786],
+ # [0.5002, -0.5986, 0.5638, -0.2713],
+ # [0.5002, 0.0154, -0.0107, 0.8657],
+ # [0.5331, -0.1395, -0.7727, -0.3151]])), 4)
+ #assert_array_almost_equal(dot(Q,Q.T), eye(4))
+ #assert_array_almost_equal(abs(Z), abs(np.array([
+ # [0.9961, -0.0014, 0.0887, -0.0026],
+ # [0.0057, -0.0404, -0.0938, -0.9948],
+ # [0.0626, 0.7194, -0.6908, 0.0363],
+ # [0.0626, -0.6934, -0.7114, 0.0956]])), 4)
+ #assert_array_almost_equal(dot(Z,Z.T), eye(4))
def test_qz_complex_sort(self):
cA = np.array([
Please sign in to comment.
Something went wrong with that request. Please try again.