5 #include <boost/regex.hpp>
7 #include <boost/filesystem.hpp>
22 #define erfinv_a3 -0.140543331
23 #define erfinv_a2 0.914624893
24 #define erfinv_a1 -1.645349621
25 #define erfinv_a0 0.886226899
27 #define erfinv_b4 0.012229801
28 #define erfinv_b3 -0.329097515
29 #define erfinv_b2 1.442710462
30 #define erfinv_b1 -2.118377725
33 #define erfinv_c3 1.641345311
34 #define erfinv_c2 3.429567803
35 #define erfinv_c1 -1.62490649
36 #define erfinv_c0 -1.970840454
38 #define erfinv_d2 1.637067800
39 #define erfinv_d1 3.543889200
112 rotation = rotTheta.
conjugate() * rotation;
121 rotation = rotPhi.
conjugate() * rotation;
133 std::string output = str;
134 std::transform(output.begin(), output.end(), output.begin(), [](
const char c) { return toupper(c);});
140 boost::filesystem::path path;
141 for (
auto entry : ilist) {
144 return path.string();
155 long double t = this->
sum + y;
156 this->correction = (t - this->
sum) - y;
164 unsigned int rewindLinesSDDS(
const std::string &fileName,
double maxSPos,
bool checkForTime) {
167 std::fstream
fs(fileName.c_str(), std::fstream::in);
168 if (!
fs.is_open())
return 0;
171 std::queue<std::string> allLines;
172 unsigned int numParameters = 0;
173 unsigned int numColumns = 0;
174 unsigned int sposColumnNr = 0;
175 unsigned int timeColumnNr = 0;
176 double spos, time = 0.0;
177 double lastTime = -1.0;
179 boost::regex parameters(
"¶meter");
180 boost::regex column(
"&column");
181 boost::regex data(
"&data");
182 boost::regex
end(
"&end");
183 boost::regex
name(
"name=([a-zA-Z0-9\\$_]+)");
186 std::istringstream linestream;
188 while (getline(
fs, line)) {
194 fs.open (fileName.c_str(), std::fstream::out);
196 if (!
fs.is_open())
return 0;
199 line = allLines.front();
202 if (boost::regex_search(line, match, parameters)) {
204 while (!boost::regex_search(line, match,
end)) {
205 line = allLines.front();
209 }
else if (boost::regex_search(line, match, column)) {
211 while (!boost::regex_search(line, match,
name)) {
212 line = allLines.front();
216 if (match[1] ==
"s") {
217 sposColumnNr = numColumns;
219 if (match[1] ==
"t") {
220 timeColumnNr = numColumns;
222 while (!boost::regex_search(line, match,
end)) {
223 line = allLines.front();
228 }
while (!boost::regex_search(line, match, data));
230 while (!boost::regex_search(line, match,
end)) {
231 line = allLines.front();
236 for (
unsigned int i = 0; i < numParameters; ++ i) {
237 fs << allLines.front() <<
"\n";
241 while (allLines.size() > 0) {
242 line = allLines.front();
244 linestream.str(line);
246 for (
unsigned int i = 0; i < timeColumnNr; ++ i) {
251 linestream.str(line);
252 for (
unsigned int i = 0; i < sposColumnNr; ++ i) {
260 if (!checkForTime || (time - lastTime) > 1
e-20)
268 if (allLines.size() > 0)
269 INFOMSG(
level2 <<
"rewind " + fileName +
" to " + std::to_string(maxSPos) <<
" m" <<
endl);
271 return allLines.size();
301 static const std::string base64_chars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
302 "abcdefghijklmnopqrstuvwxyz"
306 static inline bool is_base64(
unsigned char c) {
307 return (isalnum(
c) || (
c ==
'+') || (
c ==
'/'));
311 const char* bytes_to_encode = string_to_encode.c_str();
312 unsigned int in_len = string_to_encode.size();
316 unsigned char char_array_3[3];
317 unsigned char char_array_4[4];
320 char_array_3[i++] = *(bytes_to_encode++);
322 char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
323 char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
324 char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
325 char_array_4[3] = char_array_3[2] & 0x3f;
327 for (i = 0; (i <4) ; i++)
328 ret += base64_chars[char_array_4[i]];
335 for (j = i; j < 3; j++)
336 char_array_3[j] =
'\0';
338 char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
339 char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
340 char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
341 char_array_4[3] = char_array_3[2] & 0x3f;
343 for (j = 0; (j < i + 1); j++)
344 ret += base64_chars[char_array_4[j]];
355 int in_len = encoded_string.size();
359 unsigned char char_array_4[4], char_array_3[3];
362 while (in_len-- && ( encoded_string[in_] !=
'=') && is_base64(encoded_string[in_])) {
363 char_array_4[i++] = encoded_string[in_]; in_++;
365 for (i = 0; i <4; i++)
366 char_array_4[i] = base64_chars.find(char_array_4[i]);
368 char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
369 char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
370 char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
372 for (i = 0; (i < 3); i++)
373 ret += char_array_3[i];
379 for (j = i; j <4; j++)
382 for (j = 0; j <4; j++)
383 char_array_4[j] = base64_chars.find(char_array_4[j]);
385 char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
386 char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
387 char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
389 for (j = 0; (j < i - 1); j++) ret += char_array_3[j];
Tps< T > log(const Tps< T > &x)
Natural logarithm.
Tps< T > cos(const Tps< T > &x)
Cosine.
Tps< T > exp(const Tps< T > &x)
Exponential.
Tps< T > sin(const Tps< T > &x)
Sine.
Tps< T > sqrt(const Tps< T > &x)
Square root.
T euclidean_norm(const Vector< T > &)
Euclidean norm.
PartBunchBase< T, Dim >::ConstIterator end(PartBunchBase< T, Dim > const &bunch)
FTps< T, N > erf(const FTps< T, N > &x, int trunc=(FTps< T, N >::EXACT))
Error function.
PETE_TBTree< FnFmod, PETE_Scalar< Vektor< T1, Dim > >, typename T2::PETE_Expr_t > fmod(const Vektor< T1, Dim > &l, const PETE_Expr< T2 > &r)
PETE_TBTree< FnArcTan2, PETE_Scalar< Vektor< T1, Dim > >, typename T2::PETE_Expr_t > atan2(const Vektor< T1, Dim > &l, const PETE_Expr< T2 > &r)
T::PETE_Expr_t::PETE_Return_t sum(const PETE_Expr< T > &expr)
Inform & endl(Inform &inf)
Inform & level2(Inform &inf)
constexpr double two_pi
The value of.
constexpr double e
The value of.
constexpr double c
The velocity of light in m/s.
std::string combineFilePath(std::initializer_list< std::string > ilist)
Vector_t getTaitBryantAngles(Quaternion rotation, const std::string &)
std::string toUpper(const std::string &str)
std::string base64_decode(std::string const &encoded_string)
unsigned int rewindLinesSDDS(const std::string &fileName, double maxSPos, bool checkForTime)
rewind the SDDS file such that the spos of the last step is less or equal to maxSPos
std::string getGitRevision()
std::string base64_encode(const std::string &string_to_encode)
Vector_t rotate(const Vector_t &) const
Quaternion conjugate() const
KahanAccumulation & operator+=(double value)
Vektor< double, 3 > Vector_t