Skip to content

attractive — Attractive Forces

Attractive forces for SG-t-SNE-Pi (sparse PQ component).

attractive_forces(P, Y)

Compute attractive forces from sparse probability matrix P.

Parameters:

Name Type Description Default
P csc_matrix of shape (n, n)

Sparse probability matrix.

required
Y ndarray of shape (n, d)

Current embedding coordinates.

required

Returns:

Type Description
ndarray of shape (n, d)

Attractive force on each point.

Source code in src/pysgtsnepi/attractive.py
def attractive_forces(P: csc_matrix, Y: np.ndarray) -> np.ndarray:
    """Compute attractive forces from sparse probability matrix P.

    Parameters
    ----------
    P : csc_matrix of shape (n, n)
        Sparse probability matrix.
    Y : ndarray of shape (n, d)
        Current embedding coordinates.

    Returns
    -------
    ndarray of shape (n, d)
        Attractive force on each point.
    """
    n, d = Y.shape
    return _attractive_forces_kernel(
        P.indices, P.indptr, P.data, np.ascontiguousarray(Y), n, d
    )