Skip to content

Commit

Permalink
fix lambda computations
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinecollas committed Mar 7, 2024
1 parent ea933c0 commit 3767224
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions skada/_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -1012,12 +1012,17 @@ def _kernel_computation(self, X_source, X_target):
R_S = P_S_fat[:, self.n_components :]
P_T = self._compute_pca_subspace(X_target)

U_1, U_2, Gamma, Sigma, Vt = _gsvd(P_S.T @ P_T, R_S.T @ P_T)
U_1, U_2, Gamma, _, Vt = _gsvd(P_S.T @ P_T, R_S.T @ P_T)

theta = np.arccos(Gamma)
Lambda_1 = 1 + (np.sin(2 * theta) / (2 * theta))
Lambda_2 = (np.cos(2 * theta) - 1) / (2 * theta)
Lambda_3 = 1 - (np.sin(2 * theta) / (2 * theta))

Lambda_1 = 1 + np.sinc(2 * theta / np.pi)
Lambda_3 = 1 - np.sinc(2 * theta / np.pi)

EPS_TOL = 1e-14
Lambda_2 = np.zeros_like(theta)
Lambda_2[theta > EPS_TOL] = (np.cos(2 * theta) - 1) / (2 * theta)
Lambda_2[theta <= EPS_TOL] = 0

A = np.block([P_S @ U_1, R_S @ U_2])
B = np.block(
Expand Down

0 comments on commit 3767224

Please sign in to comment.