# maxvolpy.maxvol.rect_maxvol_qr¶

maxvolpy.maxvol.rect_maxvol_qr(A, tol=1.0, maxK=None, min_add_K=None, minK=None, start_maxvol_iters=10, identity_submatrix=True, top_k_index=-1)

Finds good rectangular submatrix in Q factor of QR of A.

When rank of N-by-r matrix A is not guaranteed to be equal to r, good submatrix in A can be found as good submatrix in Q factor of QR decomposition of A.

Parameters: A : numpy.ndarray(ndim=2) Real or complex matrix of shape (N, r), N >= r. tol : float Upper bound for euclidian norm of coefficients of expansion of rows of A by rows of good submatrix. maxK : integer Maximum number of rows in good submatrix. minK : integer Minimum number of rows in good submatrix. min_add_K : integer Minimum number of rows to add to the square submatrix. Resulting good matrix will have minimum of r+min_add_K rows. start_maxvol_iters : integer How many iterations of square maxvol (optimization of 1-volume) is required to be done before actual rectangular 2-volume maximization. identity_submatrix : boolean Coefficients of expansions are computed as least squares solution. If identity_submatrix is True, returned matrix of coefficients will have submatrix, corresponding to good rows, set to identity. top_k_index : integer Pivot rows for good submatrix will be in range from 0 to (top_k_index-1). This restriction is ignored, if top_k_index is -1. piv : numpy.ndarray(ndim=1, dtype=numpy.int32) Rows of matrix A, corresponding to submatrix, good in terms of 2-volume. Shape is (K, ). C : numpy.ndarray(ndim=2) Matrix of coefficients of expansions of all rows of A by good rows piv. Shape is (N, K).

Examples

>>> import numpy as np
>>> from maxvolpy.maxvol import rect_maxvol_qr
>>> np.random.seed(100)
>>> a = np.random.rand(1000, 30, 2).view(dtype=np.complex128)[:,:,0]
>>> piv, C = rect_maxvol_qr(a, 1.0)
>>> np.allclose(a, C.dot(a[piv]))
True
>>> print('maximum euclidian norm of row in matrix C: {:.5f}'.
... format(max([np.linalg.norm(C[i], 2) for i in range(1000)])))
maximum euclidian norm of row in matrix C: 1.00000
>>> piv, C = rect_maxvol_qr(a, 1.5)
>>> np.allclose(a, C.dot(a[piv]))
True
>>> print('maximum euclidian norm of row in matrix C: {:.5f}'.
... format(max([np.linalg.norm(C[i], 2) for i in range(1000)])))
maximum euclidian norm of row in matrix C: 1.49193
>>> piv, C = rect_maxvol_qr(a, 2.0)
>>> np.allclose(a, C.dot(a[piv]))
True
>>> print('maximum euclidian norm of row in matrix C: {:.5f}'.
... format(max([np.linalg.norm(C[i], 2) for i in range(1000)])))
maximum euclidian norm of row in matrix C: 1.91954