50 message =
new char [size + 1];
63 const char*
what() const noexcept (true)
78 #include <type_traits>
86 #define restrict __restrict
89 #warning "Don't know how to use restricted pointers with this compiler. The resulting code will be slow."
109 template<>
template <
class T>
116 #define declareTypeAsScalar(T) \
118 template <> struct is_scalar<T> \
120 static const bool value = true; \
140 static inline std::
string & ltrim (std::
string & s)
149 std::not1(std::ptr_fun<int, int>(std::isspace))
156 static inline std::string & rtrim (std::string & s)
164 std::not1(std::ptr_fun<int, int>(std::isspace))
171 static inline std::string & trim (std::string & s)
173 return ltrim(rtrim(s));
193 template <
typename T> T
mmin (T x)
197 template <
typename T,
class ...Params> T
mmin (T x, Params ...p)
206 template <
typename T> T
mmax (T x)
210 template <
typename T,
class ...Params> T
mmax (T x, Params ...p)
218 template <
class T> constexpr T
const &
larger_of (T
const & a, T
const & b)
220 return (a > b) ? a : b;
233 template <
class ...Params>
char const *
format (Params ...p)
235 static char text[1024];
252 "Conversion to \"%s\" not implemented.",
typeid(T).name()
266 char* tail;
long val = strtol (str.c_str(), &tail, 10);
270 throw exception (
"The string \"%s\" cannot be converted to integer number.", str.c_str());
285 char* tail;
double val = strtod (str.c_str(), &tail);
289 throw exception (
"The string \"%s\" cannot be converted to real number.", str.c_str());
325 if (s.front() ==
'#')
341 T val = string_to<T>(s.c_str());
366 : start_(std::chrono::system_clock::now()) {}
371 start_ = std::chrono::system_clock::now();
377 std::chrono::system_clock::time_point end = std::chrono::system_clock::now();
378 std::chrono::seconds secs = std::chrono::duration_cast<std::chrono::seconds>(end - start_);
385 std::chrono::system_clock::time_point end = std::chrono::system_clock::now();
386 std::chrono::milliseconds misecs = std::chrono::duration_cast<std::chrono::milliseconds>(end - start_);
387 return misecs.count();
393 std::chrono::system_clock::time_point end = std::chrono::system_clock::now();
394 std::chrono::microseconds musecs = std::chrono::duration_cast<std::chrono::microseconds>(end - start_);
395 return musecs.count();
401 mutable std::chrono::system_clock::time_point start_;
T mmin(T x)
Many-argument "min" function.
Definition: misc.h:193
void reset()
Start timer.
Definition: misc.h:369
static const bool value
Definition: misc.h:108
T min(const ArrayView< T > a)
Minimal element of array.
Definition: arrays.h:1663
int size
Definition: misc.h:311
constexpr T const & larger_of(T const &a, T const &b)
Constant-expression max.
Definition: misc.h:218
int signum(T x)
Signum function.
Definition: misc.h:181
T mmax(T x)
Many-argument "max" function.
Definition: misc.h:206
#define declareTypeAsScalar(T)
Definition: misc.h:116
T string_to(std::string str)
Conversion of string to a type.
Definition: misc.h:248
exception exception::Params::::::p exception() noexcept
Destructor.
Definition: misc.h:57
snprintf(message, size+1, p...)
Timer()
Return object reference (singleton interface).
Definition: misc.h:365
class NodeIntegrator exception
unsigned milliseconds()
Return elapsed time in milliseconds.
Definition: misc.h:383
char const * format(Params...p)
printf-like formatting.
Definition: misc.h:233
T read_next(std::ifstream &f)
Read next entry from input stream.
Definition: misc.h:309
unsigned microseconds()
Return elapsed time in microseconds.
Definition: misc.h:391
const char * what() const noexcept(true)
Return pointer to the exception text.
Definition: misc.h:63
Constructor.
Definition: misc.h:44
Exception class.
Definition: misc.h:39
Timing class.
Definition: misc.h:360
T max(const ArrayView< T > a)
Maximal element of array.
Definition: arrays.h:1673
unsigned seconds()
Return elapsed time in seconds.
Definition: misc.h:375
static const bool value
Definition: misc.h:126