Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- import numpy as num
- # cont = True
- print('***Linear System solver***\n')
- print('Insert the coeficient matrix like this:\n \
- |a1||b1||c1| \n \
- |a2||b2||c2| \n \
- |a3||b3||c3| \n')
- A = num.array([list(map(float, input('Insert coeficient matrix line: ').split(' ')))])
- cont = True if (input('More lines? (y or n): ') == 'y') else False
- while cont:
- A = num.append(A, [list(map(float, input('Insert coeficient matrix line: ').split(' ')))], axis = 0)
- cont = True if (input('More lines? (y or n): ') == 'y') else False
- else:
- print(A)
- b = list(map(float, input('Insert results array: ').split(' ')))
- x = num.linalg.solve(A, b)
- # print(x)
- j = 1
- for i in x:
- print('x' + str(j) + ': '+ str(i) +'\n')
- j = j + 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement