-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtools.cpp
More file actions
45 lines (36 loc) · 975 Bytes
/
tools.cpp
File metadata and controls
45 lines (36 loc) · 975 Bytes
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
//
// Created by xixuan on 10/10/16.
//
#include "tools.h"
#include <iostream>
#include <chrono>
#include <fstream>
Time_measurer::Time_measurer() {
begin_time = std::clock();
end_time = begin_time;
std::cout << std::endl
<< "Timer at " << this
<< " ---> Start recording time..."
<< std::endl << std::endl;
}
Time_measurer::~Time_measurer() {
end_time = std::clock();
std::cout << std::endl
<< "Timer at " << this
<< " ---> " << "Elapsed Time: "
<< double(end_time - begin_time) / CLOCKS_PER_SEC
<< " seconds"
<< std::endl << std::endl;
}
void print_to_file(std::string const &file_name, double const *mat_ptr, int num_rows, int num_cols) {
std::ofstream file;
file.open(file_name);
for (int i = 0; i < num_rows; i++) {
for (int j = 0; j < num_cols; j++) {
file << mat_ptr[IDX(i, j, num_rows)] << '\t';
}
file << std::endl;
}
file << std::endl;
file.close();
}