home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / n / newmat06.zip / TMT2.CXX < prev    next >
C/C++ Source or Header  |  1992-11-26  |  2KB  |  62 lines

  1.  
  2. //#define WANT_STREAM
  3.  
  4.  
  5. #include "include.h"
  6.  
  7. #include "newmat.h"
  8.  
  9. /**************************** test program ******************************/
  10.  
  11. void Print(const Matrix& X);
  12. void Print(const UpperTriangularMatrix& X);
  13. void Print(const DiagonalMatrix& X);
  14. void Print(const SymmetricMatrix& X);
  15. void Print(const LowerTriangularMatrix& X);
  16.  
  17.  
  18. void trymat2()
  19. {
  20. //   cout << "\nSecond test of Matrix package\n\n";
  21.    Tracer et("Second test of Matrix package");
  22.    Exception::PrintTrace(TRUE);
  23.  
  24.    int i,j;
  25.    Matrix M(3,5);
  26.    for (i=1; i<=3; i++) for (j=1; j<=5; j++) M(i,j) = 100*i + j;
  27.    Matrix X(8,10);
  28.    for (i=1; i<=8; i++) for (j=1; j<=10; j++) X(i,j) = 1000*i + 10*j;
  29.    Matrix Y = X; Matrix Z = X;
  30.    { X.SubMatrix(2,4,3,7) << M; }
  31.    for (i=1; i<=3; i++) for (j=1; j<=5; j++) Y(i+1,j+2) = 100*i + j;
  32.    Print(Matrix(X-Y));
  33.  
  34.  
  35.    Real a[15]; Real* r = a;
  36.    for (i=1; i<=3; i++) for (j=1; j<=5; j++) *r++ = 100*i + j;
  37.    { Z.SubMatrix(2,4,3,7) << a; }
  38.    Print(Matrix(Z-Y));
  39.  
  40.    { M=33; X.SubMatrix(2,4,3,7) << M; }
  41.    { Z.SubMatrix(2,4,3,7) << 33; }
  42.    Print(Matrix(Z-X));
  43.  
  44.    for (i=1; i<=8; i++) for (j=1; j<=10; j++) X(i,j) = 1000*i + 10*j;
  45.    Y = X;
  46.    UpperTriangularMatrix U(5);
  47.    for (i=1; i<=5; i++) for (j=i; j<=5; j++) U(i,j) = 100*i + j;
  48.    { X.SubMatrix(3,7,5,9) << U; }
  49.    for (i=1; i<=5; i++) for (j=i; j<=5; j++) Y(i+2,j+4) = 100*i + j;
  50.    for (i=1; i<=5; i++) for (j=1; j<i; j++) Y(i+2,j+4) = 0.0;
  51.    Print(Matrix(X-Y));
  52.    for (i=1; i<=8; i++) for (j=1; j<=10; j++) X(i,j) = 1000*i + 10*j;
  53.    Y = X;
  54.    for (i=1; i<=5; i++) for (j=i; j<=5; j++) U(i,j) = 100*i + j;
  55.    { X.SubMatrix(3,7,5,9).Inject(U); }
  56.    for (i=1; i<=5; i++) for (j=i; j<=5; j++) Y(i+2,j+4) = 100*i + j;
  57.    Print(Matrix(X-Y));
  58.  
  59.  
  60. //   cout << "\nEnd of second test\n";
  61. }
  62.