def _eig_from_lowrank_op(Atilde, Y, U, s, V, exact):
"""
Private method that computes eigenvalues and eigenvectors of the
high-dimensional operator from the low-dimensional operator and the
input matrix.
:param numpy.ndarray Atilde: the lowrank operator.
:param numpy.ndarray Y: input matrix Y.
:param numpy.ndarray U: 2D matrix that contains the left-singular
vectors of X, stored by column.
:param numpy.ndarray s: 1D array that contains the singular values of X.
:param numpy.ndarray V: 2D matrix that contains the right-singular
vectors of X, stored by row.
:param bool exact: if True, the exact modes are computed; otherwise,
the projected ones are computed.
:return: eigenvalues, eigenvectors
:rtype: numpy.ndarray, numpy.ndarray
"""
lowrank_eigenvalues, lowrank_eigenvectors = np.linalg.eig(Atilde)
# Compute the eigenvectors of the high-dimensional operator
if exact:
eigenvectors = (
(Y.dot(V) * np.reciprocal(s)).dot(lowrank_eigenvectors)
)
else:
eigenvectors = U.dot(lowrank_eigenvectors)
# The eigenvalues are the same
eigenvalues = lowrank_eigenvalues
return eigenvalues, eigenvectors
评论列表
文章目录