MCPcopy Create free account
hub / github.com/dask/dask / compression_matrix

Function compression_matrix

dask/array/linalg.py:657–745  ·  view source on GitHub ↗

Randomly sample matrix to find most active subspace This compression matrix returned by this algorithm can be used to compute both the QR decomposition and the Singular Value Decomposition. Parameters ---------- data: Array q: int Size of the desired subspace (t

(
    data,
    q,
    iterator="power",
    n_power_iter=0,
    n_oversamples=10,
    seed=None,
    compute=False,
)

Source from the content-addressed store, hash-verified

655
656
657def compression_matrix(
658 data,
659 q,
660 iterator="power",
661 n_power_iter=0,
662 n_oversamples=10,
663 seed=None,
664 compute=False,
665):
666 """Randomly sample matrix to find most active subspace
667
668 This compression matrix returned by this algorithm can be used to
669 compute both the QR decomposition and the Singular Value
670 Decomposition.
671
672 Parameters
673 ----------
674 data: Array
675 q: int
676 Size of the desired subspace (the actual size will be bigger,
677 because of oversampling, see ``da.linalg.compression_level``)
678 iterator: {'power', 'QR'}, default='power'
679 Define the technique used for iterations to cope with flat
680 singular spectra or when the input matrix is very large.
681 n_power_iter: int
682 Number of power iterations, useful when the singular values
683 decay slowly. Error decreases exponentially as `n_power_iter`
684 increases. In practice, set `n_power_iter` <= 4.
685 n_oversamples: int, default=10
686 Number of oversamples used for generating the sampling matrix.
687 This value increases the size of the subspace computed, which is more
688 accurate at the cost of efficiency. Results are rarely sensitive to this choice
689 though and in practice a value of 10 is very commonly high enough.
690 compute : bool
691 Whether or not to compute data at each use.
692 Recomputing the input while performing several passes reduces memory
693 pressure, but means that we have to compute the input multiple times.
694 This is a good choice if the data is larger than memory and cheap to
695 recreate.
696
697 References
698 ----------
699 N. Halko, P. G. Martinsson, and J. A. Tropp.
700 Finding structure with randomness: Probabilistic algorithms for
701 constructing approximate matrix decompositions.
702 SIAM Rev., Survey and Review section, Vol. 53, num. 2,
703 pp. 217-288, June 2011
704 https://arxiv.org/abs/0909.4061
705 """
706 if iterator not in ["power", "QR"]:
707 raise ValueError(
708 f"Iterator '{iterator}' not valid, must one one of ['power', 'QR']"
709 )
710 m, n = data.shape
711 comp_level = compression_level(min(m, n), q, n_oversamples=n_oversamples)
712 if isinstance(seed, RandomState):
713 state = seed
714 else:

Callers 1

svd_compressedFunction · 0.85

Calls 9

default_rngFunction · 0.90
waitFunction · 0.90
compression_levelFunction · 0.85
minFunction · 0.85
tsqrFunction · 0.85
astypeMethod · 0.45
standard_normalMethod · 0.45
dotMethod · 0.45
persistMethod · 0.45

Tested by

no test coverage detected