// XY is a square matrix
s = XY.shape[0]
Id = np.identity(s)
if self.p is not None:
P = np.eye(XY.shape[0])
S = self._mu[0] * P
for k in self._mu[1:]:
P *= XY
S += k*P
else:
if self.kernel_type == "geometric":
S = inv(Id - self.lamda*XY).T
elif self.kernel_type == "exponential":
S = expm(self.lamda*XY).T
p = np.ones(shape=(1, s))
return p.dot(S).dot(p.T)
elif self.method_type == "fast":
// Spectral demoposition algorithm as presented in
// [Vishwanathan et al., 2006] p.13, s.4.4, with
// complexity of O((|E|+|V|)|E||V|^2) for graphs
After Change
S += k*P
else:
if self.kernel_type == "geometric":
S = inv(np.identity(s) - self.lamda*XY).T
elif self.kernel_type == "exponential":
S = expm(self.lamda*XY).T
return np.sum(S)
elif self.method_type == "fast":
// Spectral demoposition algorithm as presented in
// [Vishwanathan et al., 2006] p.13, s.4.4, with
// complexity of O((|E|+|V|)|E||V|^2) for graphs