124 Quaternion rotTheta(std::cos(0.5 * theta), 0, std::sin(0.5 * theta), 0);
125 rotation = rotTheta.
conjugate() * rotation;
133 Quaternion rotPhi(std::cos(0.5 * phi), std::sin(0.5 * phi), 0, 0);
134 rotation = rotPhi.
conjugate() * rotation;
177 std::vector<std::string> stringVec;
178 stringVec.reserve(v.size());
179 Util::toString(std::begin(v), std::end(v), std::back_inserter(stringVec));
181 std::ostringstream output;
186 for (
auto& s : stringVec) {
190 (i < stringVec.size()) ? (output <<
", ") : (output <<
")");
219 unsigned int rewindLinesSDDS(
const std::string& fileName,
double maxSPos,
bool checkForTime) {
220 if (ippl::Comm->rank() > 0)
223 std::fstream fs(fileName.c_str(), std::fstream::in);
228 std::queue<std::string> allLines;
229 unsigned int numParameters = 0;
230 unsigned int numColumns = 0;
231 unsigned int sposColumnNr = 0;
232 unsigned int timeColumnNr = 0;
233 double spos, time = 0.0;
234 double lastTime = -1.0;
236 boost::regex parameters(
"¶meter");
237 boost::regex column(
"&column");
238 boost::regex data(
"&data");
239 boost::regex
end(
"&end");
240 boost::regex name(
"name=([a-zA-Z0-9\\$_]+)");
243 std::istringstream linestream;
245 while (std::getline(fs, line)) {
250 fs.open(fileName.c_str(), std::fstream::out);
256 line = allLines.front();
259 if (boost::regex_search(line, match, parameters)) {
261 while (!boost::regex_search(line, match,
end)) {
262 line = allLines.front();
266 }
else if (boost::regex_search(line, match, column)) {
268 while (!boost::regex_search(line, match, name)) {
269 line = allLines.front();
273 if (match[1] ==
"s") {
274 sposColumnNr = numColumns;
276 if (match[1] ==
"t") {
277 timeColumnNr = numColumns;
279 while (!boost::regex_search(line, match,
end)) {
280 line = allLines.front();
285 }
while (!boost::regex_search(line, match, data));
287 while (!boost::regex_search(line, match,
end)) {
288 line = allLines.front();
293 for (
unsigned int i = 0; i < numParameters; ++i) {
294 fs << allLines.front() <<
"\n";
298 while (!allLines.empty()) {
299 line = allLines.front();
301 linestream.str(line);
303 for (
unsigned int i = 0; i < timeColumnNr; ++i) {
308 linestream.str(line);
309 for (
unsigned int i = 0; i < sposColumnNr; ++i) {
318 if (!checkForTime || (time - lastTime) > 1e-20)
326 if (!allLines.empty())
327 *ippl::Info << level2 <<
"rewind " + fileName +
" to " + std::to_string(maxSPos) <<
" m"
330 return allLines.size();
370 const char* bytes_to_encode = string_to_encode.c_str();
371 unsigned int in_len = string_to_encode.size();
375 unsigned char char_array_3[3];
376 unsigned char char_array_4[4];
379 char_array_3[i++] = *(bytes_to_encode++);
381 char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
382 char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
383 char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
384 char_array_4[3] = char_array_3[2] & 0x3f;
386 for (i = 0; (i < 4); i++)
387 ret += base64_chars[char_array_4[i]];
393 for (j = i; j < 3; j++)
394 char_array_3[j] =
'\0';
396 char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
397 char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
398 char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
399 char_array_4[3] = char_array_3[2] & 0x3f;
401 for (j = 0; (j < i + 1); j++)
402 ret += base64_chars[char_array_4[j]];
412 int in_len = encoded_string.size();
416 unsigned char char_array_4[4], char_array_3[3];
419 while (in_len-- && (encoded_string[in_] !=
'=') && is_base64(encoded_string[in_])) {
420 char_array_4[i++] = encoded_string[in_];
423 for (i = 0; i < 4; i++)
424 char_array_4[i] = base64_chars.find(char_array_4[i]);
426 char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
427 char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
428 char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
430 for (i = 0; (i < 3); i++)
431 ret += char_array_3[i];
437 for (j = i; j < 4; j++)
440 for (j = 0; j < 4; j++)
441 char_array_4[j] = base64_chars.find(char_array_4[j]);
443 char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
444 char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
445 char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
447 for (j = 0; (j < i - 1); j++)
448 ret += char_array_3[j];