Statistics.cpp
Go to the documentation of this file.
2 
3 #define OUTPUTPRECISION 12
4 
6 {
7  int file_n = 0;
8  std::string UniqueFullFileName;
9  bool fexists = true;
10  do
11  {
12  if (file_n == 0)
13  {
14  UniqueFullFileName = store_path_ + "/" + filename_;
15  }
16  else
17  {
18  UniqueFullFileName = store_path_ + "/" + std::to_string(file_n) + filename_;
19  }
20  //UniqueFullFileName.c_str();
21  std::ifstream iff(UniqueFullFileName);
22  if (!iff.good())
23  {
24  fexists = false;
25  break;
26  }
27  ++file_n;
28  } while (file_n < 100000);
29 
30  filename_ = UniqueFullFileName;
31  return !fexists;
32 }
33 
35 {
36  if (iteration_ != -1)
37  {
38  std::cout << "---------------------------------------------" << std::endl;
39  std::cout << "Iteration " << iteration_ << std::endl;
40  }
41  for (int i = 0; i < Vx_.size(); i++)
42  {
43  std::cout << name_ << "[" << i << "]" << " = " << std::setprecision(OUTPUTPRECISION) << Vx_[i] << std::endl;
44  }
45  std::cout << "------------------------------" << std::endl;
46 }
47 
49 {
50  assert(SpMat_.cols() != 0 && SpMat_.rows() != 0);
51  int c = SpMat_.cols();
52  int r = SpMat_.rows();
53  std::cout << "------------------------------" << std::endl;
54  for (int i = 0; i < r; i++)
55  {
56  for (int j = 0; j < c; j++)
57  {
58  std::cout << std::setprecision(OUTPUTPRECISION) << SpMat_.coeff(i, j) << " ";
59  if (c - 1 == j)
60  {
61  std::cout << "\n";
62  }
63  }
64  }
65  std::cout << "------------------------------" << std::endl;
66 }
67 
69 {
70  std::cout << "------------------------------" << std::endl;
71  assert(denMat_.cols() != 0 && denMat_.rows() != 0);
72  int c = denMat_.cols();
73  int r = denMat_.rows();
74  for (int i = 0; i < r; i++)
75  {
76  for (int j = 0; j < c; j++)
77  {
78  std::cout << std::setprecision(OUTPUTPRECISION) << denMat_(i, j) << " ";
79  if (c - 1 == j)
80  {
81  std::cout << "\n";
82  }
83  }
84  }
85  std::cout << "------------------------------" << std::endl;
86 }
87 
89 {
90 
91  if (iteration_ != -1)
92  {
93  std::string iter = std::to_string(iteration_);
94  std::string postfix = ".txt";
95  filename_ = name_ + iter + postfix;
96  }
97  else
98  {
99  std::string postfix = ".txt";
100  filename_ = name_ + postfix;
101  }
102 
103  UniqueFileName();
104 
105  std::ofstream file;
106  file.open(filename_);
107 
108  file << std::setprecision(16);
109  for (int i = 0; i < Vx_.size(); i++)
110  {
111  file << Vx_[i] << std::endl;
112  }
113 
114  file.close();
115 }
116 
118 {
119 
120  if (iteration_ != -1)
121  {
122  std::string iter = std::to_string(iteration_);
123  std::string postfix = ".txt";
124  filename_ = name_ + iter + postfix;
125  }
126  else
127  {
128  std::string postfix = ".txt";
129  filename_ = name_ + postfix;
130  }
131 
132  UniqueFileName();
133 
134  std::ofstream file;
135  file.open(filename_);
136 
137  file << std::setprecision(16);
138  for (int i = 0; i < stdVec_.size(); i++)
139  {
140  file << stdVec_[i] << std::endl;
141  }
142 
143  file.close();
144 }
145 
147 {
148  if (denMat_.cols() == 0 && denMat_.rows() == 0)
149  {
150  return;
151  }
152 
153  std::string postfix = ".txt";
154 
155  filename_ = name_ + postfix;
156 
157  int r = denMat_.rows();
158  int c = denMat_.cols();
159 
160  UniqueFileName();
161 
162  std::ofstream file;
163  file.open(filename_);
164 
165 
166  file << std::setprecision(5);
167  for (int i = 0; i < r; i++)
168  {
169  for (int j = 0; j < c; j++)
170  {
171  file << denMat_(i,j) << " ";
172  if (j == c-1)
173  {
174  file << "\n";
175  }
176  }
177  }
178  file.close();
179 }
180 
182 {
183  if (SpMat_.cols() == 0 && SpMat_.rows() == 0)
184  {
185  return;
186  }
187 
188  std::string postfix = ".txt";
189 
190  filename_ = name_ + postfix;
191 
192  UniqueFileName();
193 
194  std::ofstream file;
195  file.open(filename_);
196 
197  file << std::setprecision(5);
198 
199  for (int k = 0; k < SpMat_.outerSize(); ++k)
200  {
201  for (SparseMatrix<double>::InnerIterator it(SpMat_, k); it; ++it)
202  {
203  int r = it.row();
204  int c = it.col();
205  double v = it.value();
206  file << "(" << r << "," << c << ") " << v << "\n";
207  }
208  }
209 
210  file.close();
211 }
std::string store_path_
Definition: Statistics.h:108
void GenerateVectorFile()
Definition: Statistics.cpp:88
Eigen::VectorXd Vx_
Definition: Statistics.h:111
Eigen::SparseMatrix< double > SpMat_
Definition: Statistics.h:109
void StreamVectorOutPut()
Definition: Statistics.cpp:34
bool UniqueFileName()
Definition: Statistics.cpp:5
#define OUTPUTPRECISION
Definition: Statistics.cpp:3
void GenerateMatrixFile()
Definition: Statistics.cpp:146
std::vector< double > stdVec_
Definition: Statistics.h:112
const GLubyte * c
int iteration_
Definition: Statistics.h:105
void StreamSpMatrixOutput()
Definition: Statistics.cpp:48
std::string name_
Definition: Statistics.h:104
std::string filename_
Definition: Statistics.h:107
void GenerateStdVecFile()
Definition: Statistics.cpp:117
void StreamDenMatrixOutput()
Definition: Statistics.cpp:68
const GLdouble * v
Eigen::MatrixXd denMat_
Definition: Statistics.h:110
GLboolean r
void GenerateSpFile()
Definition: Statistics.cpp:181


choreo_task_sequence_planner
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:03:14