ChipMaster's bwBASIC This also includes history going back to v2.10. *WARN* some binary files might have been corrupted by CRLF.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

58 lines
1.1 KiB

  1. 10 PRINT "MATRIX INVERSION"
  2. 20 PRINT
  3. 29 REM - A() AND B() SHOULD BOTH BE SET TO THE DIMENSIONS OF THE MATRIX
  4. 30 DIM A(10,10), B(10,10)
  5. 39 REM - MATRIX IS SQUARE SO ONLY ONE DIMENSION IS NEEDED
  6. 40 PRINT "DIMENSION OF MATRIX";
  7. 50 INPUT R
  8. 60 PRINT "MATRIX ELEMENTS:"
  9. 69 REM - ENTER MATRIX ELEMENTS
  10. 70 FOR J=1 TO R
  11. 80 PRINT "ROW";J
  12. 90 FOR I=1 TO R
  13. 100 PRINT "VALUE COLUMN";I;
  14. 110 INPUT A(J,I)
  15. 120 NEXT I
  16. 130 B(J,J)=1
  17. 140 NEXT J
  18. 149 REM - STATEMENTS 150 TO 420 INVERT MATRIX
  19. 150 FOR J=1 TO R
  20. 160 FOR I=J TO R
  21. 170 IF A(I,J)<>0 THEN 210
  22. 180 NEXT I
  23. 190 PRINT "SINGULAR MATRIX"
  24. 200 GOTO 500
  25. 210 FOR K=1 TO R
  26. 220 S=A(J,K)
  27. 230 A(J,K)=A(I,K)
  28. 240 A(I,K)=S
  29. 250 S=B(J,K)
  30. 260 B(J,K)=B(I,K)
  31. 270 B(I,K)=S
  32. 280 NEXT K
  33. 290 T=1/A(J,J)
  34. 300 FOR K=1 TO R
  35. 310 A(J,K)=T*A(J,K)
  36. 320 B(J,K)=T*B(J,K)
  37. 330 NEXT K
  38. 340 FOR L=1 TO R
  39. 350 IF L=J THEN 410
  40. 360 T=-A(L,J)
  41. 370 FOR K=1 TO R
  42. 380 A(L,K)=A(L,K)+T*A(J,K)
  43. 390 B(L,K)=B(L,K)+T*B(J,K)
  44. 400 NEXT K
  45. 410 NEXT L
  46. 420 NEXT J
  47. 430 PRINT
  48. 439 REM - PRINT RESULTANT MATRIX
  49. 440 FOR I=1 TO R
  50. 450 FOR J=1 TO R
  51. 459 REM - ROUND OFF, PRINT
  52. 460 PRINT INT(B(I,J)*1000+.5)/1000;" ";
  53. 470 NEXT J
  54. 479 REM - ADVANCE OUTPUT DEVICE TO PRINT NEXT LINE
  55. 480 PRINT
  56. 490 NEXT I
  57. 500 END