newmat9.cpp
Go to the documentation of this file.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 using namespace std;
00018
00019 #ifdef use_namespace
00020 namespace NEWMAT {
00021 #endif
00022
00023
00024
00025 #ifdef DO_REPORT
00026 #define REPORT { static ExeCounter ExeCount(__LINE__,9); ++ExeCount; }
00027 #else
00028 #define REPORT {}
00029 #endif
00030
00031
00032 #ifndef ios_format_flags
00033 #define ios_format_flags long
00034 #endif
00035
00036 ostream& operator<<(ostream& s, const BaseMatrix& X)
00037 {
00038 GeneralMatrix* gm = (const_cast<BaseMatrix&>(X)).Evaluate(); operator<<(s, *gm);
00039 gm->tDelete(); return s;
00040 }
00041
00042
00043 ostream& operator<<(ostream& s, const GeneralMatrix& X)
00044 {
00045 MatrixRow mr(const_cast<GeneralMatrix*>(&X), LoadOnEntry);
00046 int w = s.width(); int nr = X.Nrows(); ios_format_flags f = s.flags();
00047 s.setf(ios::fixed, ios::floatfield);
00048 for (int i=1; i<=nr; i++)
00049 {
00050 int skip = mr.skip; int storage = mr.storage;
00051 Real* store = mr.data; skip *= w+1;
00052 while (skip--) s << " ";
00053 while (storage--) { s.width(w); s << *store++ << " "; }
00054
00055 mr.Next(); s << "\n";
00056 }
00057 s << flush; s.flags(f); return s;
00058 }
00059
00060 ostream& operator<<(ostream& s, const printmat& p) {
00061 const int printwidth = s.width();
00062 s.width(0);
00063 s << "[";
00064 for (int i = 1; i <= p.mat.Nrows(); i++) {
00065 if (i > 1) s << "; ";
00066 for (int j = 1; j <= p.mat.Ncols(); j++) {
00067 if ( j > 1 ) s << ", ";
00068 s << setw(printwidth) << p.mat(i,j);
00069 }
00070 }
00071 s << "]";
00072 return s;
00073 }
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 #ifdef use_namespace
00094 }
00095 #endif
00096
00097