1 | /// \ingroup newmat
|
---|
2 | ///@{
|
---|
3 |
|
---|
4 | /// \file newmat9.cpp
|
---|
5 | /// Output.
|
---|
6 |
|
---|
7 | // Copyright (C) 1991,2,3,4: R B Davies
|
---|
8 |
|
---|
9 |
|
---|
10 | #define WANT_FSTREAM
|
---|
11 |
|
---|
12 | #include "include.h"
|
---|
13 |
|
---|
14 | #include "newmat.h"
|
---|
15 | #include "newmatio.h"
|
---|
16 | #include "newmatrc.h"
|
---|
17 |
|
---|
18 | #ifdef use_namespace
|
---|
19 | namespace NEWMAT {
|
---|
20 | #endif
|
---|
21 |
|
---|
22 |
|
---|
23 |
|
---|
24 | #ifdef DO_REPORT
|
---|
25 | #define REPORT { static ExeCounter ExeCount(__LINE__,9); ++ExeCount; }
|
---|
26 | #else
|
---|
27 | #define REPORT {}
|
---|
28 | #endif
|
---|
29 |
|
---|
30 | // for G++ 3.01
|
---|
31 | #ifndef ios_format_flags
|
---|
32 | #define ios_format_flags long
|
---|
33 | #endif
|
---|
34 |
|
---|
35 | ostream& operator<<(ostream& s, const BaseMatrix& X)
|
---|
36 | {
|
---|
37 | GeneralMatrix* gm = ((BaseMatrix&)X).Evaluate(); operator<<(s, *gm);
|
---|
38 | gm->tDelete(); return s;
|
---|
39 | }
|
---|
40 |
|
---|
41 |
|
---|
42 | ostream& operator<<(ostream& s, const GeneralMatrix& X)
|
---|
43 | {
|
---|
44 | MatrixRow mr((GeneralMatrix*)&X, LoadOnEntry);
|
---|
45 | int w = s.width(); int nr = X.Nrows(); ios_format_flags f = s.flags();
|
---|
46 | if (f & ios::scientific) s.setf(ios::scientific, ios::floatfield);
|
---|
47 | else s.setf(ios::fixed, ios::floatfield);
|
---|
48 | for (int i=1; i<=nr; i++)
|
---|
49 | {
|
---|
50 | int skip = mr.skip; int storage = mr.storage;
|
---|
51 | Real* store = mr.data; skip *= w+1;
|
---|
52 | while (skip--) s << " ";
|
---|
53 | while (storage--) { s.width(w); s << *store++ << " "; }
|
---|
54 | // while (storage--) s << setw(w) << *store++ << " ";
|
---|
55 | mr.Next(); s << "\n";
|
---|
56 | }
|
---|
57 | s << flush; s.flags(f); return s;
|
---|
58 | }
|
---|
59 |
|
---|
60 | // include this stuff if you are using an old version of G++
|
---|
61 | // with an incomplete io library
|
---|
62 |
|
---|
63 | /*
|
---|
64 |
|
---|
65 | ostream& operator<<(ostream& os, Omanip_precision i)
|
---|
66 | { os.precision(i.x); return os; }
|
---|
67 |
|
---|
68 | Omanip_precision setprecision(int i) { return Omanip_precision(i); }
|
---|
69 |
|
---|
70 | ostream& operator<<(ostream& os, Omanip_width i)
|
---|
71 | { os.width(i.x); return os; }
|
---|
72 |
|
---|
73 | Omanip_width setw(int i) { return Omanip_width(i); }
|
---|
74 |
|
---|
75 | */
|
---|
76 |
|
---|
77 | #ifdef use_namespace
|
---|
78 | }
|
---|
79 | #endif
|
---|
80 |
|
---|
81 |
|
---|
82 | ///@}
|
---|