diff options
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/linalg/linalg.py | 26 | ||||
| -rw-r--r-- | numpy/linalg/umath_linalg.c.src | 38 |
2 files changed, 20 insertions, 44 deletions
diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py index b7f21b1b7..560b7e9dc 100644 --- a/numpy/linalg/linalg.py +++ b/numpy/linalg/linalg.py @@ -940,20 +940,17 @@ def qr(a, mode='reduced'): # handle modes that don't return q if mode == 'r': r = triu(a[..., :mn, :]) - if t != result_t: - r = r.astype(result_t, copy=False) + r = r.astype(result_t, copy=False) return wrap(r) if mode == 'raw': q = transpose(a) - if t != result_t: - q = q.astype(result_t, copy=False) - tau = tau.astype(result_t, copy=False) + q = q.astype(result_t, copy=False) + tau = tau.astype(result_t, copy=False) return wrap(q), tau if mode == 'economic': - if t != result_t : - a = a.astype(result_t, copy=False) + a = a.astype(result_t, copy=False) return wrap(a) # mc is the number of columns in the resulting q @@ -962,25 +959,18 @@ def qr(a, mode='reduced'): # then it is the minimum of number of rows and columns. if mode == 'complete' and m > n: mc = m - if m <= n: - gufunc = _umath_linalg.qr_complete_m - else: - gufunc = _umath_linalg.qr_complete_n + gufunc = _umath_linalg.qr_complete else: mc = mn - if m <= n: - gufunc = _umath_linalg.qr_reduced_m - else: - gufunc = _umath_linalg.qr_reduced_n + gufunc = _umath_linalg.qr_reduced signature = 'DD->D' if isComplexType(t) else 'dd->d' extobj = get_linalg_error_extobj(_raise_linalgerror_qr) q = gufunc(a, tau, signature=signature, extobj=extobj) r = triu(a[..., :mc, :]) - if t != result_t: - q = q.astype(result_t, copy=False) - r = r.astype(result_t, copy=False) + q = q.astype(result_t, copy=False) + r = r.astype(result_t, copy=False) return wrap(q), wrap(r) diff --git a/numpy/linalg/umath_linalg.c.src b/numpy/linalg/umath_linalg.c.src index 27fe51732..a486e9e5b 100644 --- a/numpy/linalg/umath_linalg.c.src +++ b/numpy/linalg/umath_linalg.c.src @@ -3973,6 +3973,10 @@ static void *array_of_nulls[] = { CDOUBLE_ ## NAME \ } +/* The single precision functions are not used at all, + * due to input data being promoted to double precision + * in Python, so they are not implemented here. + */ #define GUFUNC_FUNC_ARRAY_QR(NAME) \ static PyUFuncGenericFunction \ FUNC_ARRAY_NAME(NAME)[] = { \ @@ -4285,7 +4289,7 @@ GUFUNC_DESCRIPTOR_t gufunc_descriptors [] = { "(m,n)->(m)", "Compute TAU vector for the last two dimensions \n"\ "and broadcast to the rest. For m <= n. \n", - 4, 1, 1, + 2, 1, 1, FUNC_ARRAY_NAME(qr_r_raw), qr_r_raw_types }, @@ -4294,43 +4298,25 @@ GUFUNC_DESCRIPTOR_t gufunc_descriptors [] = { "(m,n)->(n)", "Compute TAU vector for the last two dimensions \n"\ "and broadcast to the rest. For m > n. \n", - 4, 1, 1, + 2, 1, 1, FUNC_ARRAY_NAME(qr_r_raw), qr_r_raw_types }, { - "qr_reduced_m", - "(m,n),(m)->(m,m)", - "Compute Q matrix for the last two dimensions \n"\ - "and broadcast to the rest. For m <= n. \n", - 4, 2, 1, - FUNC_ARRAY_NAME(qr_reduced), - qr_reduced_types - }, - { - "qr_reduced_n", - "(m,n),(n)->(m,n)", + "qr_reduced", + "(m,n),(k)->(m,k)", "Compute Q matrix for the last two dimensions \n"\ - "and broadcast to the rest. For m > n. \n", - 4, 2, 1, + "and broadcast to the rest. \n", + 2, 2, 1, FUNC_ARRAY_NAME(qr_reduced), qr_reduced_types }, { - "qr_complete_m", - "(m,n),(m)->(m,m)", - "Compute Q matrix for the last two dimensions \n"\ - "and broadcast to the rest. For m <= n. \n", - 4, 2, 1, - FUNC_ARRAY_NAME(qr_complete), - qr_complete_types - }, - { - "qr_complete_n", + "qr_complete", "(m,n),(n)->(m,m)", "Compute Q matrix for the last two dimensions \n"\ "and broadcast to the rest. For m > n. \n", - 4, 2, 1, + 2, 2, 1, FUNC_ARRAY_NAME(qr_complete), qr_complete_types }, |
