120 Quaternion rotTheta(std::cos(0.5 * theta), 0, std::sin(0.5 * theta), 0);
121 rotation = rotTheta.
conjugate() * rotation;
129 Quaternion rotPhi(std::cos(0.5 * phi), std::sin(0.5 * phi), 0, 0);
130 rotation = rotPhi.
conjugate() * rotation;
173 std::vector<std::string> stringVec;
174 stringVec.reserve(v.size());
175 Util::toString(std::begin(v), std::end(v), std::back_inserter(stringVec));
177 std::ostringstream output;
182 for (
auto& s : stringVec) {
186 (i < stringVec.size()) ? (output <<
", ") : (output <<
")");
214 unsigned int rewindLinesSDDS(
const std::string& fileName,
double maxSPos,
bool checkForTime) {
215 if (ippl::Comm->rank() > 0)
return 0;
217 std::fstream fs(fileName.c_str(), std::fstream::in);
218 if (!fs.is_open())
return 0;
221 std::queue<std::string> allLines;
222 unsigned int numParameters = 0;
223 unsigned int numColumns = 0;
224 unsigned int sposColumnNr = 0;
225 unsigned int timeColumnNr = 0;
226 double spos, time = 0.0;
227 double lastTime = -1.0;
229 std::regex parameters(
"¶meter");
230 std::regex column(
"&column");
231 std::regex data(
"&data");
232 std::regex end(
"&end");
233 std::regex name(
"name=([a-zA-Z0-9\\$_]+)");
236 std::istringstream linestream;
238 while (std::getline(fs, line)) {
243 fs.open(fileName.c_str(), std::fstream::out);
245 if (!fs.is_open())
return 0;
248 line = allLines.front();
251 if (std::regex_search(line, match, parameters)) {
253 while (!std::regex_search(line, match, end)) {
254 line = allLines.front();
258 }
else if (std::regex_search(line, match, column)) {
260 while (!std::regex_search(line, match, name)) {
261 line = allLines.front();
265 if (match[1] ==
"s") {
266 sposColumnNr = numColumns;
268 if (match[1] ==
"t") {
269 timeColumnNr = numColumns;
271 while (!std::regex_search(line, match, end)) {
272 line = allLines.front();
277 }
while (!std::regex_search(line, match, data));
279 while (!std::regex_search(line, match, end)) {
280 line = allLines.front();
285 for (
unsigned int i = 0; i < numParameters; ++i) {
286 fs << allLines.front() <<
"\n";
290 while (!allLines.empty()) {
291 line = allLines.front();
293 linestream.str(line);
295 for (
unsigned int i = 0; i < timeColumnNr; ++i) {
300 linestream.str(line);
301 for (
unsigned int i = 0; i < sposColumnNr; ++i) {
305 if ((spos - maxSPos) > 1e-20 *
Physics::c)
break;
309 if (!checkForTime || (time - lastTime) > 1e-20) fs << line <<
"\n";
316 if (!allLines.empty())
317 *ippl::Info << level2 <<
"rewind " + fileName +
" to " + std::to_string(maxSPos) <<
" m"
320 return allLines.size();
360 const char* bytes_to_encode = string_to_encode.c_str();
361 unsigned int in_len = string_to_encode.size();
365 unsigned char char_array_3[3];
366 unsigned char char_array_4[4];
369 char_array_3[i++] = *(bytes_to_encode++);
371 char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
372 char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
373 char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
374 char_array_4[3] = char_array_3[2] & 0x3f;
376 for (i = 0; (i < 4); i++)
377 ret += base64_chars[char_array_4[i]];
383 for (j = i; j < 3; j++)
384 char_array_3[j] =
'\0';
386 char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
387 char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
388 char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
389 char_array_4[3] = char_array_3[2] & 0x3f;
391 for (j = 0; (j < i + 1); j++)
392 ret += base64_chars[char_array_4[j]];
402 int in_len = encoded_string.size();
406 unsigned char char_array_4[4], char_array_3[3];
409 while (in_len-- && (encoded_string[in_] !=
'=') && is_base64(encoded_string[in_])) {
410 char_array_4[i++] = encoded_string[in_];
413 for (i = 0; i < 4; i++)
414 char_array_4[i] = base64_chars.find(char_array_4[i]);
416 char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
417 char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
418 char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
420 for (i = 0; (i < 3); i++)
421 ret += char_array_3[i];
427 for (j = i; j < 4; j++)
430 for (j = 0; j < 4; j++)
431 char_array_4[j] = base64_chars.find(char_array_4[j]);
433 char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
434 char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
435 char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
437 for (j = 0; (j < i - 1); j++)
438 ret += char_array_3[j];