Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def main():
- print("Insert the dimension of matrix")
- n = int(input())
- print("\nType of input\n")
- print("\t1 - File\n\t2 - Use formula")
- typ = int(input())
- A = np.zeros(shape=(n, n), dtype=np.float64)
- b = np.zeros(shape=(n, 1), dtype=np.float64)
- if typ == 1:
- print("\nEnter filename\n")
- filename = input()
- with open(filename) as f:
- for i in range(n):
- line = list(f.readline().split())
- for j, elem in enumerate(line[:n]):
- A[i][j] = np.float64(elem)
- b[i][0] = np.float64(line[n])
- elif typ == 2:
- print("\nEnter parametr m\n")
- m = np.float64(input())
- for i in range(n):
- for j in range(n):
- if i == j:
- A[i][j] = n + m ** 2 + j / m + i / n
- else:
- A[i][j] = (i + j) / (m + n)
- b[i][0] = 200 + 50 * i
- print(A)
- print(b)
- print("\nChoose operation\n")
- print("\t1 - Find determinant\n\t2 - Find reverse matrix\n" +
- "\t3 - Find Gauss solution\n\t4 - Find Gauss solution with main element\n" +
- "\t5 - Find condition number")
- operation = int(input())
- for operation in range(1, 6):
- if operation == 1:
- print("detrminate = {0}".format(determinate(A))
- if operation == 2:
- print("reverse(A) = {0}".format(reverse(A)))
- if operation == 3:
- print("X = {0}".format(gauss(A, b)))
- if operation == 4:
- print("X = {0}".format(gauss_main_elem(A, b)))
- if operation == 5:
- print("cond = {0}".format(cond(A)))
- print("check: {0}\n".format(check(A, b, operation)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement