Example: Eigenvalues and Eigenvectors of a Symmetric Matrix

The eigenvalues and eigenvectors of a symmetric matrix are computed.
import com.imsl.math.*;

public class SymEigenEx1 {
    public static void main(String args[]) {
        double	a[][] = {
            {1, 1, 1},
            {1, 1, 1},
            {1, 1, 1}
        };
        
        SymEigen eigen = new SymEigen(a);
        new PrintMatrix("Eigenvalues").print(eigen.getValues());
        new PrintMatrix("Eigenvectors").print(eigen.getVectors());
    }
}

Output

Eigenvalues
   0   
0   3  
1  -0  
2  -0  

       Eigenvectors
     0      1       2     
0  0.577   0.816   0      
1  0.577  -0.408  -0.707  
2  0.577  -0.408   0.707  

Link to Java source.