maxvolpy.maxvol.maxvol_svd

maxvolpy.maxvol.maxvol_svd(A, svd_tol=0.001, svd_alpha=0.0, tol=1.05, max_iters=100, job='F', top_k_index=-1)

Applies SVD truncation and finds good square 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 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 infinite norm of coefficients of expansion of rows/columns of approximant of A good rows/columns of approximant. Minimum value is 1.

max_iters : integer

Maximum number of iterations. Each iteration swaps 2 rows.

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 1-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 maxvol_svd
>>> np.random.seed(100)
>>> a = np.random.rand(1000, 30, 2).view(dtype=np.complex128)[:,:,0]
>>> piv, C = 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.24684
>>> print('Chebyshev norm of matrix C: {:.5f}'.format(abs(C).max()))
Chebyshev norm of matrix C: 1.00000
>>> piv, C = maxvol_svd(a, svd_tol=1e-1, tol=1.05, 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.24684
>>> print('Chebyshev norm of matrix C: {:.5f}'.format(abs(C).max()))
Chebyshev norm of matrix C: 1.00000
>>> piv, C = maxvol_svd(a, svd_tol=1e-1, tol=1.10, 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.25485
>>> print('Chebyshev norm of matrix C: {:.5f}'.format(abs(C).max()))
Chebyshev norm of matrix C: 1.06825