Compression level to use in svd_compressed Given the size ``n`` of a space, compress that that to one of size ``q`` plus n_oversamples. The oversampling allows for greater flexibility in finding an appropriate subspace, a low value is often enough (10 is already a very conserva
(n, q, n_oversamples=10, min_subspace_size=20)
| 620 | |
| 621 | |
| 622 | def compression_level(n, q, n_oversamples=10, min_subspace_size=20): |
| 623 | """Compression level to use in svd_compressed |
| 624 | |
| 625 | Given the size ``n`` of a space, compress that that to one of size |
| 626 | ``q`` plus n_oversamples. |
| 627 | |
| 628 | The oversampling allows for greater flexibility in finding an |
| 629 | appropriate subspace, a low value is often enough (10 is already a |
| 630 | very conservative choice, it can be further reduced). |
| 631 | ``q + oversampling`` should not be larger than ``n``. In this |
| 632 | specific implementation, ``q + n_oversamples`` is at least |
| 633 | ``min_subspace_size``. |
| 634 | |
| 635 | Parameters |
| 636 | ---------- |
| 637 | n: int |
| 638 | Column/row dimension of original matrix |
| 639 | q: int |
| 640 | Size of the desired subspace (the actual size will be bigger, |
| 641 | because of oversampling, see ``da.linalg.compression_level``) |
| 642 | n_oversamples: int, default=10 |
| 643 | Number of oversamples used for generating the sampling matrix. |
| 644 | min_subspace_size : int, default=20 |
| 645 | Minimum subspace size. |
| 646 | |
| 647 | Examples |
| 648 | -------- |
| 649 | >>> compression_level(100, 10) |
| 650 | 20 |
| 651 | """ |
| 652 | return min(max(min_subspace_size, q + n_oversamples), n) |
| 653 | |
| 654 | |
| 655 | def compression_matrix( |
no test coverage detected
searching dependent graphs…