00001
00002
00003
00004
00005
00006 #ifndef WANT_STREAM
00007 #define WANT_STREAM
00008 #endif
00009
00010 #include "include.h"
00011
00012 #include "newmat.h"
00013 #include "newmatio.h"
00014 #include "newmatrc.h"
00015 #include <iomanip>
00016
00017 #ifdef use_namespace
00018 namespace NEWMAT {
00019 #endif
00020
00021
00022
00023 #ifdef DO_REPORT
00024 #define REPORT { static ExeCounter ExeCount(__LINE__,9); ++ExeCount; }
00025 #else
00026 #define REPORT {}
00027 #endif
00028
00029
00030 #ifndef ios_format_flags
00031 #define ios_format_flags long
00032 #endif
00033
00034 ostream& operator<<(ostream& s, const BaseMatrix& X)
00035 {
00036 GeneralMatrix* gm = ((BaseMatrix&)X).Evaluate(); operator<<(s, *gm);
00037 gm->tDelete(); return s;
00038 }
00039
00040
00041 ostream& operator<<(ostream& s, const GeneralMatrix& X)
00042 {
00043 MatrixRow mr(const_cast<GeneralMatrix*>(&X), LoadOnEntry);
00044 int w = s.width(); int nr = X.Nrows(); ios_format_flags f = s.flags();
00045 s.setf(ios::fixed, ios::floatfield);
00046 for (int i=1; i<=nr; i++)
00047 {
00048 int skip = mr.skip; int storage = mr.storage;
00049 Real* store = mr.data; skip *= w+1;
00050 while (skip--) s << " ";
00051 while (storage--) { s.width(w); s << *store++ << " "; }
00052
00053 mr.Next(); s << "\n";
00054 }
00055 s << flush; s.flags(f); return s;
00056 }
00057
00058 ostream& operator<<(ostream& s, const printmat& p) {
00059 const int printwidth = s.width();
00060 s.width(0);
00061 s << "[";
00062 for (int i = 1; i <= p.mat.Nrows(); i++) {
00063 if (i > 1) s << "; ";
00064 for (int j = 1; j <= p.mat.Ncols(); j++) {
00065 if ( j > 1 ) s << ", ";
00066 s << setw(printwidth) << p.mat(i,j);
00067 }
00068 }
00069 s << "]";
00070 return s;
00071 }
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 #ifdef use_namespace
00092 }
00093 #endif
00094
00095