pymoto.EigenSolve

class pymoto.EigenSolve(sorting_func: Callable = <function EigenSolve.<lambda>>, hermitian: bool = None, nmodes: int = None, sigma: complex = None, mode: str = 'normal')

Solves the (generalized) eigenvalue problem \(\mathbf{A}\mathbf{q}_i = \lambda_i \mathbf{B} \mathbf{q}_i\)

Solves the eigenvalue problem \(\mathbf{A}\mathbf{q}_i = \lambda_i \mathbf{q}_i\) with normalization \(\mathbf{q}_i^\text{T} \mathbf{q}_i = 1\) or the generalized eigenvalue problem \(\mathbf{A}\mathbf{q}_i = \lambda_i \mathbf{B} \mathbf{q}_i\) with normalization \(\mathbf{q}_i^\text{T} \mathbf{B} \mathbf{q}_i = 1\) (\(\mathbf{B}\) must be positive definite). The eigenvectors are returned as a dense matrix Q, where eigenvector Q[:, i] belongs to eigenvalue λ[i].

Both real and complex matrices are supported. Correct sensitivities for cases with eigenvalue multiplicity are not implemented yet.

Mode tracking algorithms can be implemented by the user by providing the argument sorting_func, which is a function with arguments (λ, Q).

Input Signal(s):
  • A (dense matrix): The system matrix of size (n, n)

  • B (dense matrix, optional): Second system matrix (must be positive-definite) of size (n, n)

Output Signals:
  • λ (vector): Vector with eigenvalues of size (n)

  • Q (matrix): Matrix with eigenvectors Q[:, i] corresponding to λ[i], of size (n, n)

__init__(sorting_func: Callable = <function EigenSolve.<lambda>>, hermitian: bool = None, nmodes: int = None, sigma: complex = None, mode: str = 'normal')

Initialize the eigenvalue solver module

Parameters:
  • sorting_func (Callable, optional) – Sorting function to sort the eigenvalues, which must have signature func(λ,Q). Defaults to (lambda W, Q: np.argsort(W)).

  • hermitian (bool, optional) – Flag to omit the automatic detection for Hermitian matrix, saves some work for large matrices

  • nmodes (int, optional) – Number of modes to calculate (only for sparse matrices)

  • sigma (complex, optional) – Shift value for the shift-and-invert eigenvalue problem (only for sparse matrices). Eigenvalues around the shift are calculated first. Defaults to None.

  • mode (str, optional) – Mode of the eigensolver (see documentation of scipy.sparse.linalg.eigsh for more info). Defaults to “normal”.

Methods

__init__(sorting_func, hermitian, nmodes, ...)

Initialize the eigenvalue solver module

connect(sig_in[, sig_out])

Connect without automatic adding to a function network

get_input_sensitivities([as_list])

get_input_states([as_list])

get_output_sensitivities([as_list])

get_output_states([as_list])

reset()

Reset the state of the sensitivities (they are set to zero or to None)

response()

Calculate the response from sig_in and output this to sig_out

sensitivity()

Calculate sensitivities using backpropagation

Attributes

n_in

Get the number of input signals

n_out

Get the number of output signals

sig_in

sig_out

connect(sig_in: Signal | Iterable[Signal], sig_out: Signal | Iterable[Signal] = None)

Connect without automatic adding to a function network

get_input_sensitivities(as_list=False)
get_input_states(as_list=False)
get_output_sensitivities(as_list=False)
get_output_states(as_list=False)
property n_in: int

Get the number of input signals

property n_out: int

Get the number of output signals

Note: Cannot be used in the initial __call__()

reset()

Reset the state of the sensitivities (they are set to zero or to None)

response()

Calculate the response from sig_in and output this to sig_out

sensitivity()

Calculate sensitivities using backpropagation

Based on the sensitivity we get from sig_out, reverse the process and output the new sensitivities to sig_in

sig_in: List = None
sig_out: List = None