maxvolpy.maxvol.rect_maxvol_svd

maxvolpy.maxvol.rect_maxvol_svd(A, svd_tol=0.001, svd_alpha=0.0, tol=1.0, maxK=None, min_add_K=None, minK=None, start_maxvol_iters=10, identity_submatrix=True, job='F', top_k_index=-1)

Applies SVD truncation and finds good rectangular submatrix.

Computes SVD for top_k_index rows and/or columns of given matrix A, increases singular values by regularizing parameter svd_alpha, cuts off singular values, lower than svd_tol (relatively, getting only highest singular vectors), projects rows and/or columns, starting from top_k_index, to space of first top_k_index rows and/or columns and runs rect_maxvol for left and/or right singular vectors.

Parameters:

A : numpy.ndarray(ndim=2)

Real or complex matrix.

svd_tol : float

Cut-off singular values parameter.

svd_alpha : float

Regularizing parameter for misc.svd_cut.

tol : float

Upper bound for euclidian norm of coefficients of expansion of rows/columns of approximant of A by good rows/columns of approximant.

maxK : integer

Maximum number of rows/columns in good submatrix.

minK : integer

Minimum number of rows/columns in good submatrix.

min_add_K : integer

Minimum number of rows/columns to add to the square submatrix. Resulting good matrix will have minimum of r+min_add_K rows/columns.

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/columns, set to identity.

job : character

‘R’ to find good rows in approximant, ‘C’ to find good columns in approximant and ‘F’ for both rows and columns.

top_k_index : integer

Pivot rows/columns for good submatrix will be in range from 0 to (top_k_index-1). This restriction is ignored, if top_k_index is -1.

Returns:

Depending on job parameter, returns result of rect_maxvol for left and/or right singular vectors of approximant.

piv : numpy.ndarray(ndim=1, dtype=numpy.int32)

Rows/columns of approximant of A, corresponding to submatrix, good in terms of 2-volume.

C : numpy.ndarray(ndim=2)

Coefficients of expansions of all rows/columns of approximant by good rows/columns piv of approximant.

Examples

>>> import numpy as np
>>> from maxvolpy.maxvol import rect_maxvol_svd
>>> np.random.seed(100)
>>> a = np.random.rand(1000, 30, 2).view(dtype=np.complex128)[:,:,0]
>>> piv, C = rect_maxvol_svd(a, svd_tol=1e-1, tol=1.0, job='R')
>>> print('relative maxvol approximation error: {:.5f}'.format(
... np.linalg.norm(a-C.dot(a[piv]), 2)/np.linalg.norm(a, 2)))
relative maxvol approximation error: 0.14497
>>> 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_svd(a, svd_tol=1e-1, tol=1.5, job='R')
>>> print('relative maxvol approximation error: {:.5f}'.format(
... np.linalg.norm(a-C.dot(a[piv]), 2)/np.linalg.norm(a, 2)))
relative maxvol approximation error: 0.19640
>>> 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.49535
>>> piv, C = rect_maxvol_svd(a, svd_tol=1e-1, tol=2.0, job='R')
>>> print('relative maxvol approximation error: {:.5f}'.format(
... np.linalg.norm(a-C.dot(a[piv]), 2)/np.linalg.norm(a, 2)))
relative maxvol approximation error: 0.22981
>>> 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.88485