Homepage Demos Overview Downloads Tutorials Reference
Credits

newmat9.cpp

Go to the documentation of this file.
00001 //$$ newmat9.cpp         Input and output
00002 
00003 // Copyright (C) 1991,2,3,4: R B Davies
00004 
00005 
00006 #define WANT_STREAM
00007 
00008 #include "include.h"
00009 
00010 #include "newmat.h"
00011 #include "newmatio.h"
00012 #include "newmatrc.h"
00013 
00014 #ifdef use_namespace
00015 namespace NEWMAT {
00016 #endif
00017 
00018 
00019 
00020 #ifdef DO_REPORT
00021 #define REPORT { static ExeCounter ExeCount(__LINE__,9); ++ExeCount; }
00022 #else
00023 #define REPORT {}
00024 #endif
00025 
00026 // for G++ 3.01
00027 #ifndef ios_format_flags
00028 #define ios_format_flags long
00029 #endif
00030 
00031 ostream& operator<<(ostream& s, const BaseMatrix& X)
00032 {
00033    GeneralMatrix* gm = ((BaseMatrix&)X).Evaluate(); operator<<(s, *gm);
00034    gm->tDelete(); return s;
00035 }
00036 
00037 
00038 ostream& operator<<(ostream& s, const GeneralMatrix& X)
00039 {
00040    MatrixRow mr(const_cast<GeneralMatrix*>(&X), LoadOnEntry);
00041    int w = s.width();  int nr = X.Nrows();  ios_format_flags f = s.flags();
00042    s.setf(ios::fixed, ios::floatfield);
00043    for (int i=1; i<=nr; i++)
00044    {
00045       int skip = mr.skip;  int storage = mr.storage;
00046       Real* store = mr.data;  skip *= w+1;
00047       while (skip--) s << " ";
00048       while (storage--) { s.width(w); s << *store++ << " "; }
00049 //      while (storage--) s << setw(w) << *store++ << " ";
00050       mr.Next();  s << "\n";
00051    }
00052    s << flush;  s.flags(f); return s;
00053 }
00054 
00055 ostream& operator<<(ostream& s, const printmat& p) {
00056   const int printwidth = s.width();
00057   s.width(0);
00058   s << "[";
00059   for (int i = 1; i <= p.mat.Nrows(); i++) {
00060     if (i > 1) s << "; ";
00061     for (int j = 1; j <= p.mat.Ncols(); j++) {
00062       if ( j > 1 ) s << ", ";
00063       s << setw(printwidth) << p.mat(i,j);
00064     }
00065   }
00066   s << "]";
00067   return s;
00068 }
00069 
00070 
00071 // include this stuff if you are using an old version of G++
00072 // with an incomplete io library
00073 
00074 /*
00075 
00076 ostream& operator<<(ostream& os, Omanip_precision i)
00077    { os.precision(i.x); return os; }
00078 
00079 Omanip_precision setprecision(int i) { return Omanip_precision(i); }
00080 
00081 ostream& operator<<(ostream& os, Omanip_width i)
00082    { os.width(i.x); return os; }
00083 
00084 Omanip_width setw(int i) { return Omanip_width(i); }
00085 
00086 */
00087 
00088 #ifdef use_namespace
00089 }
00090 #endif
00091 
00092 

newmat11b
Generated Tue Jan 4 15:42:11 2005 by Doxygen 1.4.0