This example demonstrates eigenvalue decomposition using LAPACK:
- dsyev: Symmetric eigenvalue decomposition (computes eigenvalues and eigenvectors)
- Ensure you have the V compiler installed. You can download it from here.
- Ensure you have the VSL installed. You can do it following the installation guide!
- Navigate to this directory.
- Run the example using the following command:
v run main.vComputes eigenvalues and eigenvectors of a symmetric matrix A:
- Eigenvalues: Scalar values λ such that Av = λv
- Eigenvectors: Vectors v corresponding to each eigenvalue
The example:
- Computes eigenvalues and eigenvectors
- Verifies the decomposition by checking Av ≈ λv
- Shows the relationship between eigenvalues, eigenvectors, and the original matrix
Eigenvalue decomposition is fundamental in many areas:
- Principal Component Analysis (PCA): Find principal directions in data
- Vibration Analysis: Natural frequencies and modes
- Quantum Mechanics: Energy levels and states
- Graph Theory: Spectral properties of graphs
- Data Compression: Dimensionality reduction
Important: Pure V LAPACK uses column-major storage.
This example includes helper functions for conversion:
row_to_col_major(): Convert V's row-major arrays to column-majorcol_to_row_major(): Convert column-major back to row-major for display
This example uses the pure V LAPACK backend by default (zero dependencies).
To use the LAPACKE C backend:
v -d vsl_lapack_lapacke run main.v- Pure V backend provides excellent performance with zero dependencies
- Eigenvalue decomposition is computationally intensive (O(n³))
- For very large matrices, C backend may offer better performance
Enjoy exploring eigenvalue problems! 🔬