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

  1. //$$ newmat9.cxx         Input and output
  2.  
  3. // Copyright (C) 1991,2: R B Davies
  4.  
  5.  
  6. #define WANT_STREAM
  7.  
  8. #include "include.h"
  9.  
  10. #include "newmat.h"
  11. #include "newmatrc.h"
  12. #include "newmatio.h"
  13.  
  14. //#define REPORT { static ExeCounter ExeCount(__LINE__,9); ExeCount++; }
  15.  
  16. #define REPORT {}
  17.  
  18. ostream& operator<<(ostream& s, const BaseMatrix& X)
  19. {
  20.    GeneralMatrix* gm = ((BaseMatrix&)X).Evaluate(); operator<<(s, *gm);
  21.    gm->tDelete(); return s;
  22. }
  23.  
  24.  
  25. ostream& operator<<(ostream& s, const GeneralMatrix& X)
  26. {
  27.    MatrixRow mr((GeneralMatrix*)&X, LoadOnEntry);
  28.    int w = s.width();  int nr = X.Nrows();  long f = s.flags();
  29.    s.setf(ios::fixed, ios::floatfield);
  30.    for (int i=1; i<=nr; i++)
  31.    {
  32.       int skip = mr.skip;  int storage = mr.storage;
  33.       Real* store = mr.store+skip;  skip *= w+1;
  34.       while (skip--) s << " ";
  35.       while (storage--) s << setw(w) << *store++ << " ";
  36.       mr.Next();  s << "\n";
  37.    }
  38.    s << flush;  s.flags(f); return s;
  39. }
  40.  
  41.