r"""Compute standard cost matrices of size (`n`, `n`) for OT problems Parameters ---------- n : int Size of the cost matrix. method : str, optional Type of loss matrix chosen from: * 'lin_square' : linear sampling between 0 and `n-1`, quadratic loss Ret
(n, method="lin_square")
| 424 | |
| 425 | |
| 426 | def dist0(n, method="lin_square"): |
| 427 | r"""Compute standard cost matrices of size (`n`, `n`) for OT problems |
| 428 | |
| 429 | Parameters |
| 430 | ---------- |
| 431 | n : int |
| 432 | Size of the cost matrix. |
| 433 | method : str, optional |
| 434 | Type of loss matrix chosen from: |
| 435 | |
| 436 | * 'lin_square' : linear sampling between 0 and `n-1`, quadratic loss |
| 437 | |
| 438 | Returns |
| 439 | ------- |
| 440 | M : ndarray, shape (`n1`, `n2`) |
| 441 | Distance matrix computed with given metric. |
| 442 | """ |
| 443 | res = 0 |
| 444 | if method == "lin_square": |
| 445 | x = np.arange(n, dtype=np.float64).reshape((n, 1)) |
| 446 | res = dist(x, x) |
| 447 | return res |
| 448 | |
| 449 | |
| 450 | def cost_normalization(C, norm=None, return_value=False, value=None): |