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. 2. Ensure you have the VSL installed. You can do it following the installation guide! 3. Navigate to this directory. 4. Run the example using the following command:
v run vsl/examples/lapack_eigenvalue_problems/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: 1. Computes eigenvalues and eigenvectors 2. Verifies the decomposition by checking Av ≈ λv 3. 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-major - col_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! 🔬