# eigensolvers - meanas
Electromagnetic simulation tools

Skip to content

# eigensolvers

## `` meanas.eigensolvers

Solvers for eigenvalue / eigenvector problems

### `` power_iteration

    power_iteration(
        operator: spmatrix,
        guess_vector: NDArray[complex128] | None = None,
        iterations: int = 20,
    ) -> tuple[complex, NDArray[numpy.complex128]]

Use power iteration to estimate the dominant eigenvector of a matrix.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`operator` | `spmatrix` | Matrix to analyze. | required
`guess_vector` | `NDArray[complex128] | None` | Starting point for the eigenvector. Default is a randomly chosen vector. | `None`
`iterations` | `int` | Number of iterations to perform. Default 20. | `20`

Returns:

Type | Description
--- | ---
`tuple[complex, NDArray[complex128]]` | (Largest-magnitude eigenvalue, Corresponding eigenvector estimate)

### `` rayleigh_quotient_iteration

    rayleigh_quotient_iteration(
        operator: spmatrix | LinearOperator,
        guess_vector: NDArray[complex128],
        iterations: int = 40,
        tolerance: float = 1e-13,
        solver: Callable[..., NDArray[complex128]]
        | None = None,
    ) -> tuple[complex, NDArray[numpy.complex128]]

Use Rayleigh quotient iteration to refine an eigenvector guess.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`operator` | `spmatrix | LinearOperator` | Matrix to analyze. | required
`guess_vector` | `NDArray[complex128]` | Eigenvector to refine. | required
`iterations` | `int` | Maximum number of iterations to perform. Default 40. | `40`
`tolerance` | `float` | Stop iteration if `(A - I*eigenvalue) @ v < num_vectors * tolerance`, Default 1e-13. | `1e-13`
`solver` | `Callable[..., NDArray[complex128]] | None` | Solver function of the form `x = solver(A, b)`. By default, use scipy.sparse.spsolve for sparse matrices and scipy.sparse.bicgstab for general LinearOperator instances. | `None`

Returns:

Type | Description
--- | ---
`tuple[complex, NDArray[complex128]]` | (eigenvalues, eigenvectors)

### `` signed_eigensolve

    signed_eigensolve(
        operator: spmatrix | LinearOperator,
        how_many: int,
        negative: bool = False,
    ) -> tuple[
        NDArray[numpy.complex128], NDArray[numpy.complex128]
    ]

Find the largest-magnitude positive-only (or negative-only) eigenvalues and eigenvectors of the provided matrix.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`operator` | `spmatrix | LinearOperator` | Matrix to analyze. | required
`how_many` | `int` | How many eigenvalues to find. | required
`negative` | `bool` | Whether to find negative-only eigenvalues. Default False (positive only). | `False`

Returns:

Type | Description
--- | ---
`NDArray[complex128]` | (sorted list of eigenvalues, 2D ndarray of corresponding eigenvectors)
`NDArray[complex128]` | `eigenvectors[:, k]` corresponds to the k-th eigenvalue