(self, a)
| 1735 | array = np.array |
| 1736 | |
| 1737 | def check_qr(self, a): |
| 1738 | # This test expects the argument `a` to be an ndarray or |
| 1739 | # a subclass of an ndarray of inexact type. |
| 1740 | a_type = type(a) |
| 1741 | a_dtype = a.dtype |
| 1742 | m, n = a.shape |
| 1743 | k = min(m, n) |
| 1744 | |
| 1745 | # mode == 'complete' |
| 1746 | res = linalg.qr(a, mode='complete') |
| 1747 | Q, R = res.Q, res.R |
| 1748 | assert_(Q.dtype == a_dtype) |
| 1749 | assert_(R.dtype == a_dtype) |
| 1750 | assert_(isinstance(Q, a_type)) |
| 1751 | assert_(isinstance(R, a_type)) |
| 1752 | assert_(Q.shape == (m, m)) |
| 1753 | assert_(R.shape == (m, n)) |
| 1754 | assert_almost_equal(dot(Q, R), a) |
| 1755 | assert_almost_equal(dot(Q.T.conj(), Q), np.eye(m)) |
| 1756 | assert_almost_equal(np.triu(R), R) |
| 1757 | |
| 1758 | # mode == 'reduced' |
| 1759 | q1, r1 = linalg.qr(a, mode='reduced') |
| 1760 | assert_(q1.dtype == a_dtype) |
| 1761 | assert_(r1.dtype == a_dtype) |
| 1762 | assert_(isinstance(q1, a_type)) |
| 1763 | assert_(isinstance(r1, a_type)) |
| 1764 | assert_(q1.shape == (m, k)) |
| 1765 | assert_(r1.shape == (k, n)) |
| 1766 | assert_almost_equal(dot(q1, r1), a) |
| 1767 | assert_almost_equal(dot(q1.T.conj(), q1), np.eye(k)) |
| 1768 | assert_almost_equal(np.triu(r1), r1) |
| 1769 | |
| 1770 | # mode == 'r' |
| 1771 | r2 = linalg.qr(a, mode='r') |
| 1772 | assert_(r2.dtype == a_dtype) |
| 1773 | assert_(isinstance(r2, a_type)) |
| 1774 | assert_almost_equal(r2, r1) |
| 1775 | |
| 1776 | @pytest.mark.parametrize(["m", "n"], [ |
| 1777 | (3, 0), |
no test coverage detected