-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain5de.py
28 lines (27 loc) · 1.08 KB
/
main5de.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import pandas as pandas
import numpy as numpy
from scipy.linalg import eig
matrixA = numpy.array(pandas.read_csv("MatrixA.csv", sep =',', header = None, index_col = False))#.astype("float")
numberOfRows_MatrixA, numberOfColumns_MatrixA = matrixA.shape
print("Matrix A")
for i in range(numberOfRows_MatrixA):
for j in range(numberOfColumns_MatrixA):
space = ' '
if(matrixA[i][j] < 0):
space = ''
print(space + format(numpy.round(matrixA[i][j], 2)), end = "\t")
print(" ")
print(" ")
eigenValuesOfMatrixA, eigenVectorsOfMatrixA = eig(matrixA)
diagonalizedMatrix = numpy.zeros((numberOfRows_MatrixA, numberOfColumns_MatrixA))
for i in range(numberOfRows_MatrixA):
diagonalizedMatrix[i][i] = eigenValuesOfMatrixA[i].real
print("Diagonalized Matrix")
for i in range(numberOfRows_MatrixA):
for j in range(numberOfColumns_MatrixA):
space = ' '
if(diagonalizedMatrix[i][j] < 0):
space = ''
print(space + format(numpy.round(diagonalizedMatrix[i][j], 2)), end = "\t")
print(" ")
print(" ")