Eigenvalues and eigenvectors
Overview
Multik provides two functions for eigenvalue computation:
Function | Description |
|---|---|
| Computes both eigenvalues and eigenvectors. |
| Computes eigenvalues only (more efficient when vectors are not needed). |
Both functions return complex results because eigenvalues of a real matrix can be complex.
eig
Computes the eigenvalues and eigenvectors of a square matrix.
Signatures
Parameters
Parameter | Type | Description |
|---|---|---|
|
| Square matrix to decompose. |
Returns: Pair<eigenvalues, eigenvectors> where:
eigenvalues— a 1D array of complex eigenvalues.eigenvectors— a 2D matrix whose columns are the corresponding eigenvectors.
Example
eigVals
Computes only the eigenvalues of a square matrix (without eigenvectors).
Signatures
Parameters
Parameter | Type | Description |
|---|---|---|
|
| Square matrix. |
Returns: D1Array of complex eigenvalues.
Example
Pitfalls
Eigenvalue results are always complex (
ComplexDoubleorComplexFloat), even for symmetric matrices where all eigenvalues are real. Access the real part with.reand imaginary part with.im.The input matrix must be square. Non-square matrices will cause an error.
The pure Kotlin engine does not support
eigoreigVals— use the OpenBLAS or default engine.