Advertisement
Guest User

Untitled

a guest
Feb 14th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3.  
  4. import numpy as num
  5.  
  6. # cont = True
  7. print('***Linear System solver***\n')
  8. print('Insert the coeficient matrix like this:\n \
  9. |a1||b1||c1| \n \
  10. |a2||b2||c2| \n \
  11. |a3||b3||c3| \n')
  12.  
  13. A = num.array([list(map(float, input('Insert coeficient matrix line: ').split(' ')))])
  14. cont = True if (input('More lines? (y or n): ') == 'y') else False
  15.  
  16. while cont:
  17. A = num.append(A, [list(map(float, input('Insert coeficient matrix line: ').split(' ')))], axis = 0)
  18. cont = True if (input('More lines? (y or n): ') == 'y') else False
  19. else:
  20. print(A)
  21. b = list(map(float, input('Insert results array: ').split(' ')))
  22.  
  23. x = num.linalg.solve(A, b)
  24. # print(x)
  25. j = 1
  26. for i in x:
  27. print('x' + str(j) + ': '+ str(i) +'\n')
  28. j = j + 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement