-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmatlab_io.h
44 lines (36 loc) · 1.02 KB
/
matlab_io.h
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
/*
* output csv subroutine.
*
* copyright@ Yimin Zhong. [email protected].
*/
#ifndef MATLAB_IO_H
#define MATLAB_IO_H
#include "utils.h"
#include "bbfmm.h"
#include "linalg.h"
void write_to_csv(vector<scalar_t> data, std::string filename) {
std::ofstream outfile;
outfile.open(filename);
for (auto it : data) {
outfile << it << "\n";
}
outfile.close();
}
void write_to_csv(bbfmm::Vector data, std::string filename) {
std::ofstream outfile;
outfile.open(filename);
for (int id = 0; id < data.row(); ++id) {
outfile << std::scientific << std::setprecision(32) << std::setw(32) << data(id) << "\n";
}
outfile.close();
}
void write_to_csv(vector<point> data, std::string filename, std::string sep = " ") {
std::ofstream outfile;
outfile.open(filename);
for (auto it : data) {
outfile << std::scientific << std::setprecision(32) << std::setw(32) << it.x << sep << std::setw(32) << it.y
<< "\n";
}
outfile.close();
}
#endif //MATLAB_IO_H