-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLog.cpp
70 lines (66 loc) · 1.45 KB
/
Log.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "Log.h"
using namespace std;
// Constructor
Log::Log(ostream& out, int level): ostream(out.rdbuf()), level(level) {
return;
}
Log::~Log()
{
}
void Log::message(string text)
{
if (level < 1) {
return;
}
(ostream&)*this << text << endl;
}
void Log::vec(vector< my_rational > v, string name)
{
if (level < 1) {
return;
}
(ostream&)*this << "Dumping " << v.size() << "-vector " << name << ":" << endl;
for (unsigned i = 0; i < v.size(); i++) {
(ostream&)*this << v[i] << endl;
}
}
void Log::vec(vector< unsigned > v, string name)
{
if (level < 1) {
return;
}
(ostream&)*this << "Dumping " << v.size() << "-vector " << name << ":" << endl;
for (unsigned i = 0; i < v.size(); i++) {
(ostream&)*this << v[i] << endl;
}
}
void Log::vec(vector< string > v, string name)
{
if (level < 1) {
return;
}
(ostream&)*this << "Dumping " << v.size() << "-vector " << name << ":" << endl;
for (unsigned i = 0; i < v.size(); i++) {
(ostream&)*this << v[i] << endl;
}
}
void Log::matrix(vector< vector< my_rational > > m, string name, bool tofloat)
{
if (level < 1) {
return;
}
(ostream&)*this << "Dumping " << m.size() << "x" << m[0].size() << " matrix " << name << ":" << endl;
for (unsigned i = 0; i < m.size(); i++) {
for (unsigned j = 0; j < m[i].size(); j++) {
if (tofloat)
{
(ostream&)*this << (my_float)m[i][j] << "\t";
}
else
{
(ostream&)*this << (my_rational)m[i][j] << "\t";
}
}
(ostream&)*this << endl;
}
}