93 {
96
97 std::string bnFileName = path + "bn.csv";
98 std::string inFileName = path + "in.csv";
99
100 std::vector<std::vector<MFloat>> bnData;
101 std::ifstream bnFile(bnFileName);
103
104 while(bnFile) {
105 l++;
106 std::string s;
107 if(!getline(bnFile, s)) break;
108 if(s[0] != '#') {
109 std::istringstream ss(s);
110 std::vector<MFloat> record;
111
112 while(ss) {
113 std::string line;
114 if(!getline(ss, line, ',')) break;
115 record.push_back(std::stof(line));
116 }
117 bnData.push_back(record);
118 }
119 }
120
121 if(!bnFile.eof()) {
122 std::cerr << "Could not read file " << bnFileName << "\n";
123 std::__throw_invalid_argument("File not found.");
124 }
125
126 std::vector<std::vector<MFloat>> inData;
127 std::ifstream inFile(inFileName);
128 l = 0;
129
130 while(inFile) {
131 l++;
132 std::string s;
134 if(s[0] != '#') {
135 std::istringstream ss(s);
136 std::vector<MFloat> record;
137
138 while(ss) {
139 std::string line;
140 if(!
getline(ss, line,
','))
break;
141 record.push_back(std::stof(line));
142 }
143 inData.push_back(record);
144 }
145 }
146
147 if(!inFile.eof()) {
148 std::cerr << "Could not read file " << inFileName << "\n";
149 std::__throw_invalid_argument("File not found.");
150 }
151
152 const MInt q = bnData.size();
153 const MInt r = bnData[0].size();
154
156
157 for(
MInt i = 0; i < q; i++) {
158 for(
MInt j = 0; j < r; j++) {
159 projBn(i, j) = bnData[i][j];
160 }
161 }
162
163 const MInt numInternal = inData.
size();
164
166
167 for(
MInt i = 0; i < numInternal; i++) {
168 projIn(i) = inData[i][0];
169 }
170}
void set(const T &value)
Initializes tensor to constant value.
size_type size() const
Returns the size of the array as product of all five dimensions (i.e. not the actual array size but t...
std::istream & getline(std::istream &input, std::string &line)
maia::tensor::Tensor< MFloat > MFloatMatrix
maia::tensor::Tensor< MFloat > MFloatVector