r""" This function constructs an augmented matrix for the first iteration of the semi-relaxed regularization path .. math:: \text{Augmented}_H = \begin{bmatrix} 0 & H_{c A} \\ H_{c A}^T & H_{r A}^T H_{r A} \end{bmatrix} where : - :ma
(active_index, m, Hc, HrHr)
| 496 | |
| 497 | |
| 498 | def construct_augmented_H(active_index, m, Hc, HrHr): |
| 499 | r""" This function constructs an augmented matrix for the first iteration |
| 500 | of the semi-relaxed regularization path |
| 501 | |
| 502 | .. math:: |
| 503 | \text{Augmented}_H = |
| 504 | \begin{bmatrix} |
| 505 | 0 & H_{c A} \\ |
| 506 | H_{c A}^T & H_{r A}^T H_{r A} |
| 507 | \end{bmatrix} |
| 508 | |
| 509 | where : |
| 510 | |
| 511 | - :math:`H_{r A}` is the sub-matrix constructed by the columns of \ |
| 512 | :math:`H_r` whose indices belong to the active set A |
| 513 | - :math:`H_{c A}` is the sub-matrix constructed by the columns of \ |
| 514 | :math:`H_c` whose indices belong to the active set A |
| 515 | |
| 516 | |
| 517 | Parameters |
| 518 | ---------- |
| 519 | active_index : list |
| 520 | Indices of the active variables |
| 521 | m : int |
| 522 | Length of the target distribution |
| 523 | Hc : np.ndarray (dim_b, dim_a * dim_b) |
| 524 | Matrix that computes the sum along the columns of the transport plan \ |
| 525 | :math:`T` |
| 526 | HrHr : np.ndarray (dim_a * dim_b, dim_a * dim_b) |
| 527 | Matrix product of :math:`H_r^T H_r` |
| 528 | |
| 529 | Returns |
| 530 | ------- |
| 531 | H_augmented : np.ndarray (dim_b + size(A), dim_b + size(A)) |
| 532 | Augmented matrix for the first iteration of the semi-relaxed |
| 533 | regularization path |
| 534 | """ |
| 535 | Hc_sub = Hc[:, active_index].toarray() |
| 536 | HrHr_sub = HrHr[:, active_index] |
| 537 | HrHr_sub = HrHr_sub[active_index, :].toarray() |
| 538 | H_augmented = np.block([[np.zeros((m, m)), Hc_sub], [Hc_sub.T, HrHr_sub]]) |
| 539 | return H_augmented |
| 540 | |
| 541 | |
| 542 | def fully_relaxed_path(a: np.array, b: np.array, C: np.array, reg=1e-4, itmax=50000): |
no test coverage detected