-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.hpp
60 lines (42 loc) · 853 Bytes
/
functions.hpp
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
#ifndef FUNCTIONS_H_
#define FUNCTIONS_H_
#include <string>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <vector>
using namespace std;
namespace functions
{
vector<float> loadFromFile(string fileName, vector<float>& vec2){
vector<float> vec;
ifstream file;
string line, str;
float number;
file.open(fileName, ios::in);
if(file.good() == false){
return vec;
}
getline(file,line);
stringstream ss(line);
while(!ss.eof()){
ss >> str;
if(stringstream(str) >> number){
vec.push_back(atof(str.c_str()));
}
str = "";
}
getline(file,line);
stringstream sss(line);
while(!sss.eof()){
sss >> str;
if(stringstream(str) >> number){
vec2.push_back(atof(str.c_str()));
}
str = "";
}
file.close();
return vec;
}
}
#endif /* FUNCTIONS_H_ */