Toolbox
- sisyphe.toolbox.volume_ball(d)
Volume of the ball of radius 1 in dimension d
- sisyphe.toolbox.uniform_grid_separation(x, r, L)
Return the label of the cell to which each row of x belongs.
The box \([0,L[0]]\times ...\times [0,L[d-1]]\) is divided in cells of size r. The cells are numbered as follows in dimension 2:
(K[1]-1)*K[0]
(K[1]-1)*K[0]+1
…
K[0]*K[1]-1
…
…
…
…
K[0]
K[0]+1
…
2*K[0]-1
0
1
…
K[0]-1
where
K[i]
is the number of cells along the dimensioni
.- Parameters
x ((N,d) Tensor) – Positions.
r ((d,) Tensor) – Size of the cells at each dimension.
L ((d,) Tensor) – Box size.
- Returns
The Tensor of labels.
- Return type
(N,) IntTensor
- Raises
NotImplementedError – if the dimension is \(d=1\) or \(d>3\).
- sisyphe.toolbox.uniform_grid_centroids(r, L, d)
Return the coordinates of the centroids.
The box \([0,L[0]]\times ...\times [0,L[d-1]]\) is divided in cells of size r. The cells are numbered as follows in dimension 2:
(K[1]-1)*K[0]
(K[1]-1)*K[0]+1
…
K[0]*K[1]-1
…
…
…
…
K[0]
K[0]+1
…
2*K[0]-1
0
1
…
K[0]-1
where
K[i]
is the number of cells along the dimensioni
.- Parameters
r ((d,) Tensor) – Size of the cells at each dimension.
L ((d,) Tensor) – Box size.
d (int) – Dimension.
- Returns
The Tensor of centroids: the \(i\) component is the center of the cell numbered
i
. The first dimensionN_cell
is the total number of cells (in the example above,N_cell = K[0]*K[1]
).- Return type
(N_cell,d) Tensor
- Raises
NotImplementedError – if \(d=1\) or \(d>3\).
- sisyphe.toolbox.block_sparse_reduction_parameters(x, y, centroids, eps, L, keep, where_dummies=False)
Compute the block sparse reduction parameters.
Classical block sparse reduction as explained in the documentation of the KeOps library. The main difference is that the centroids and labels are computed using the
uniform_grid_centroids()
and theuniform_grid_separation()
respectively. With this method a cell may be empty. Dummy particles are thus added to x and y at the positions of the centroids.- Parameters
x ((M,d) Tensor) – Rows.
y ((N,d) Tensor) – Columns
centroids ((nb_centr,d) Tensor) – Centroids.
eps ((d,) Tensor) – Size of the cells.
L ((d,) Tensor) – Size of the box.
keep ((nb_centro,nb_centro) BoolTensor) –
keep[i,j]
is True whencentroids[i,:]
andcentroids[j,:]
are contiguous.where_dummies (bool, optional) – Default is False.
- Returns
The tuple of block sparse parameters:
x_sorted ((M+nb_centro,d) Tensor): The sorted x_plus where x_plus is the concatenation of x and the centroids.
y_sorted ((N+nb_centro,d) Tensor): The sorted y_plus where y_plus is the concatenation of y and the centroids.
nb_centro (int): Number of centroids.
labels_x ((M+nb_centro,) IntTensor): The labels of x_plus.
labels_y ((n+nb_centro,) IntTensor): The labels of y_plus.
permutation_x ((M+nb_centro,) IntTensor): The permutation of the x_plus such that
x_plus[permutation_x,:]
is equal to x_sorted.ranges_ij: Result of
from_matrix()
.map_dummies ((M+nb_centro,N+nb_centro) LazyTensor): The \((i,j)\) coordinate is 0 if either
x_sorted[i,:]
ory_sorted[j,:]
is a centroid and 1 otherwise. map_dummies is None when where_dummies is False.
- Return type
tuple
- sisyphe.toolbox.maximal_eigenvector_dim2(J)
Eigenvectors of maximum eigenvalue for symmetric matrices in dimension 2.
- Parameters
J ((N,2,2) Tensor) – Batch of N 2D symmetric matrices.
- Returns
Unit eigenvector associated to the maximal eigenvalue of each matrix.
- Return type
(N,2) Tensor
- sisyphe.toolbox.quat_mult(q_1, q_2)
Multiplication in the space of quaternions.
- sisyphe.toolbox.angles_directions_to_quat(angles, directions)
Represents a list of rotation angles and axes as quaternions.