home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / pascal / SPARSE.ZIP / TSTSPARS.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1985-11-13  |  1.2 KB  |  49 lines

  1. Program Test_Sparse_Matrix_Library;
  2. {$I SPARSE.LIB }
  3.  
  4. Procedure Testit;
  5.   VAR
  6.     A : NodePtr;
  7.     r : real;
  8.     i,j : integer;
  9.  
  10. BEGIN
  11.   ClrScr;
  12.   Writeln(' This program tests the sparse matrix library in SPARSE.LIB. ');
  13.   Writeln(' The program will first create an unfilled 150 by 150 matrix. ');
  14.   Writeln(' Next, the program will enter elements on the leading, and ');
  15.   Writeln(' first major and minor diagonals. Finally, the program reads the');
  16.   Writeln(' Nonzero elements from A[120,120] to A[150,150] ');
  17.   GoToXY(1,10);
  18.   Writeln(' Press any key to continue...');
  19.   REPEAT UNTIL KeyPressed;
  20.   ClrScr;
  21.   GoToXY(1,5);
  22.   A := CreateArray(150,150);
  23.   writeln(' Begin to fill matrix ');
  24.   EnterElement(A,1,1,3.0);
  25.   For j := 2 to 150 do
  26.     BEGIN
  27.     { entering a tridiagonal matrix }
  28.       EnterElement(A,j,j,3.0);
  29.       EnterElement(A,j,j-1,1.0);
  30.       EnterElement(A,j-1,j,1.0);
  31.     END;
  32.   Writeln(' finished filling matrix ');
  33.   Writeln(' Press return to continue ');
  34.   REPEAT UNTIL KeyPressed;
  35.   For i := 120 to 150 do
  36.     For j := 120 to 150 do
  37.       BEGIN
  38.         r := ReadElement(A,i,j);
  39.         If (r <> 0.0) then
  40.           Writeln('A[',i:3,'-',j:3,'] := ',r:2:0);
  41.       END;
  42. END;
  43.  
  44.  
  45.  
  46.  
  47. BEGIN
  48.   Testit;
  49. END.