Vlasiator ebf0dd394 on dev (v5.4.0 + 1054 commits)
Loading...
Searching...
No Matches
matrixCondition.py
Go to the documentation of this file.
1#!/usr/bin/python3
2
3import sys
4import numpy
5
6filename = sys.argv[1]
7
8A = numpy.loadtxt(filename)
9
10# Calc eigenvalues
11λ,ev=numpy.linalg.eig(0.5*(A + numpy.transpose(A)))
12
13ev = ev[numpy.argsort(λ)]
14λ = numpy.sort(λ);
15
16print("Matrix condution: " + str(λ[-1] / λ[0]))
17print("(Largest eigenvalue: " + str(λ[-1]) + ", smallest eigenvalue: " + str(λ[0]))
18
19for i in λ:
20 if i < 0:
21 print("WARNING: Matrix has negative eigenvalue " + str(i))
22 sys.exit()