22#include <boost/filesystem.hpp>
23#include <boost/regex.hpp>
36#define erfinv_a3 -0.140543331
37#define erfinv_a2 0.914624893
38#define erfinv_a1 -1.645349621
39#define erfinv_a0 0.886226899
41#define erfinv_b4 0.012229801
42#define erfinv_b3 -0.329097515
43#define erfinv_b2 1.442710462
44#define erfinv_b1 -2.118377725
47#define erfinv_c3 1.641345311
48#define erfinv_c2 3.429567803
49#define erfinv_c1 -1.62490649
50#define erfinv_c0 -1.970840454
52#define erfinv_d2 1.637067800
53#define erfinv_d1 3.543889200
126 rotation = rotTheta.
conjugate() * rotation;
135 rotation = rotPhi.
conjugate() * rotation;
147 std::string output = str;
148 std::transform(output.begin(), output.end(), output.begin(), [](
const char c) { return std::toupper(c);});
154 std::ostringstream valueStream;
155 valueStream << std::boolalpha << b;
161 std::ostringstream output;
165 for (
size_t i = 0; i < b.size(); ++i) {
168 (i < (b.size()-1)) ? (output <<
", ") : (output <<
")");
176 std::vector<std::string> stringVec;
177 stringVec.reserve(v.size());
180 std::ostringstream output;
185 for (
auto& s: stringVec) {
189 (i < stringVec.size()) ? (output <<
", ") : (output <<
")");
197 boost::filesystem::path path;
198 for (
auto entry : ilist) {
201 return path.string();
211 long double t = this->
sum + y;
212 this->correction = (t - this->
sum) - y;
220 unsigned int rewindLinesSDDS(
const std::string& fileName,
double maxSPos,
bool checkForTime) {
223 std::fstream
fs(fileName.c_str(), std::fstream::in);
224 if (!
fs.is_open())
return 0;
227 std::queue<std::string> allLines;
228 unsigned int numParameters = 0;
229 unsigned int numColumns = 0;
230 unsigned int sposColumnNr = 0;
231 unsigned int timeColumnNr = 0;
232 double spos, time = 0.0;
233 double lastTime = -1.0;
235 boost::regex parameters(
"¶meter");
236 boost::regex column(
"&column");
237 boost::regex data(
"&data");
238 boost::regex
end(
"&end");
239 boost::regex
name(
"name=([a-zA-Z0-9\\$_]+)");
242 std::istringstream linestream;
244 while (std::getline(
fs, line)) {
249 fs.open (fileName.c_str(), std::fstream::out);
251 if (!
fs.is_open())
return 0;
254 line = allLines.front();
257 if (boost::regex_search(line, match, parameters)) {
259 while (!boost::regex_search(line, match,
end)) {
260 line = allLines.front();
264 }
else if (boost::regex_search(line, match, column)) {
266 while (!boost::regex_search(line, match,
name)) {
267 line = allLines.front();
271 if (match[1] ==
"s") {
272 sposColumnNr = numColumns;
274 if (match[1] ==
"t") {
275 timeColumnNr = numColumns;
277 while (!boost::regex_search(line, match,
end)) {
278 line = allLines.front();
283 }
while (!boost::regex_search(line, match, data));
285 while (!boost::regex_search(line, match,
end)) {
286 line = allLines.front();
291 for (
unsigned int i = 0; i < numParameters; ++ i) {
292 fs << allLines.front() <<
"\n";
296 while (!allLines.empty()) {
297 line = allLines.front();
299 linestream.str(line);
301 for (
unsigned int i = 0; i < timeColumnNr; ++ i) {
306 linestream.str(line);
307 for (
unsigned int i = 0; i < sposColumnNr; ++ i) {
315 if (!checkForTime || (time - lastTime) > 1
e-20)
323 if (!allLines.empty())
324 INFOMSG(
level2 <<
"rewind " + fileName +
" to " + std::to_string(maxSPos) <<
" m" <<
endl);
326 return allLines.size();
356 static const std::string base64_chars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
357 "abcdefghijklmnopqrstuvwxyz"
360 static inline bool is_base64(
unsigned char c) {
361 return (std::isalnum(
c) || (
c ==
'+') || (
c ==
'/'));
365 const char* bytes_to_encode = string_to_encode.c_str();
366 unsigned int in_len = string_to_encode.size();
370 unsigned char char_array_3[3];
371 unsigned char char_array_4[4];
374 char_array_3[i++] = *(bytes_to_encode++);
376 char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
377 char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
378 char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
379 char_array_4[3] = char_array_3[2] & 0x3f;
381 for (i = 0; (i <4) ; i++)
382 ret += base64_chars[char_array_4[i]];
389 for (j = i; j < 3; j++)
390 char_array_3[j] =
'\0';
392 char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
393 char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
394 char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
395 char_array_4[3] = char_array_3[2] & 0x3f;
397 for (j = 0; (j < i + 1); j++)
398 ret += base64_chars[char_array_4[j]];
409 int in_len = encoded_string.size();
413 unsigned char char_array_4[4], char_array_3[3];
416 while (in_len-- && ( encoded_string[in_] !=
'=') && is_base64(encoded_string[in_])) {
417 char_array_4[i++] = encoded_string[in_]; in_++;
419 for (i = 0; i <4; i++)
420 char_array_4[i] = base64_chars.find(char_array_4[i]);
422 char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
423 char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
424 char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
426 for (i = 0; (i < 3); i++)
427 ret += char_array_3[i];
433 for (j = i; j <4; j++)
436 for (j = 0; j <4; j++)
437 char_array_4[j] = base64_chars.find(char_array_4[j]);
439 char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
440 char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
441 char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
443 for (j = 0; (j < i - 1); j++) ret += char_array_3[j];
FTps< T, N > erf(const FTps< T, N > &x, int trunc=(FTps< T, N >::EXACT))
Error function.
PartBunchBase< T, Dim >::ConstIterator end(PartBunchBase< T, Dim > const &bunch)
PartBunchBase< T, Dim >::ConstIterator begin(PartBunchBase< T, Dim > const &bunch)
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.
T::PETE_Expr_t::PETE_Return_t sum(const PETE_Expr< T > &expr)
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)
Inform & level2(Inform &inf)
Inform & endl(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)
std::string doubleVectorToString(const std::vector< double > &v)
Vector_t getTaitBryantAngles(Quaternion rotation, const std::string &)
std::string boolVectorToUpperString(const std::vector< bool > &b)
void toString(IteratorIn first, IteratorIn last, IteratorOut out)
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)
std::string boolToUpperString(const bool &b)
Vector_t rotate(const Vector_t &) const
Quaternion conjugate() const
KahanAccumulation & operator+=(double value)
Vektor< double, 3 > Vector_t