polymat-bad.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. from Numeric import *
  2. import LinearAlgebra as la
  3. import sys
  4. n = 15
  5. m = zeros(((n + 1) * 4, (n + 1) * 4), Float)
  6. for i in range(n):
  7. m[4 * i + 2][4 * i + 0] = .5
  8. m[4 * i + 2][4 * i + 1] = -1./12
  9. m[4 * i + 2][4 * i + 2] = 1./48
  10. m[4 * i + 2][4 * i + 3] = -1./480
  11. m[4 * i + 2][4 * i + 4] = .5
  12. m[4 * i + 2][4 * i + 5] = 1./12
  13. m[4 * i + 2][4 * i + 6] = 1./48
  14. m[4 * i + 2][4 * i + 7] = 1./480
  15. m[4 * i + 3][4 * i + 0] = 1
  16. m[4 * i + 3][4 * i + 1] = .5
  17. m[4 * i + 3][4 * i + 2] = .125
  18. m[4 * i + 3][4 * i + 3] = 1./48
  19. m[4 * i + 3][4 * i + 4] = -1
  20. m[4 * i + 3][4 * i + 5] = .5
  21. m[4 * i + 3][4 * i + 6] = -.125
  22. m[4 * i + 3][4 * i + 7] = 1./48
  23. m[4 * i + 4][4 * i + 0] = 0
  24. m[4 * i + 4][4 * i + 1] = 1
  25. m[4 * i + 4][4 * i + 2] = .5
  26. m[4 * i + 4][4 * i + 3] = .125
  27. m[4 * i + 4][4 * i + 4] = 0
  28. m[4 * i + 4][4 * i + 5] = -1
  29. m[4 * i + 4][4 * i + 6] = .5
  30. m[4 * i + 4][4 * i + 7] = -.125
  31. m[4 * i + 5][4 * i + 0] = 0
  32. m[4 * i + 5][4 * i + 1] = 0
  33. m[4 * i + 5][4 * i + 2] = 1
  34. m[4 * i + 5][4 * i + 3] = .5
  35. m[4 * i + 5][4 * i + 4] = 0
  36. m[4 * i + 5][4 * i + 5] = 0
  37. m[4 * i + 5][4 * i + 6] = -1
  38. m[4 * i + 5][4 * i + 7] = .5
  39. m[n * 4 + 2][2] = 1
  40. m[n * 4 + 3][3] = 1
  41. m[0][n * 4 + 2] = 1
  42. m[1][n * 4 + 3] = 1
  43. def printarr(m):
  44. for j in range(n * 4 + 4):
  45. for i in range(n * 4 + 4):
  46. print '%6.1f' % m[j][i],
  47. print ''
  48. sys.output_line_width = 160
  49. #print array2string(m, precision = 3)
  50. mi = la.inverse(m)
  51. #printarr(mi)
  52. print ''
  53. for j in range(n + 1):
  54. for k in range(4):
  55. print '%7.2f' % mi[j * 4 + k][(n / 2) * 4 + 2],
  56. print ''