Tomographer
v5.4
Tomographer C++ Framework Documentation
|
Various useful tools. More...
Functions | |
template<typename F > | |
tomo_internal::FinalAction< F > | finally (F f) |
implementation of a finally clause, somewhat like in Python More... | |
template<typename T > | |
std::ostream & | operator<< (std::ostream &str, const StoreIfEnabled< T, false > &) |
C++ Stream operators for StoreIfEnabled. More... | |
template<typename T > | |
std::ostream & | operator<< (std::ostream &str, const StoreIfEnabled< T, true > &val) |
C++ Stream operators for StoreIfEnabled. More... | |
template<typename IntType = int> | |
constexpr bool | isPowerOfTwo (IntType N) |
Return true if the argument is a power of two, false otherwise. | |
template<typename X > | |
std::enable_if< std::is_unsigned< X >::value, bool >::type | isPositive (const X) |
Test whether the given value is positive or zero. More... | |
template<typename X > | |
std::enable_if<!std::is_unsigned< X >::value, bool >::type | isPositive (const X val) |
See isPositive() | |
template<typename X > | |
bool | isFinite (const X val) |
Test whether floating-point value is finite. More... | |
template<typename IntType > | |
constexpr bool | additionWillOverflow (IntType a, IntType b) |
Test whether the sum of two integers will cause an overflow/underflow for that integer type. More... | |
template<typename IntType , typename ... IntTypes> | |
constexpr bool | additionWillOverflow (IntType a, IntType b, IntType c, IntTypes ... rest) |
Test whether the sum of several integers will cause an overflow/underflow for that integer type. More... | |
template<typename IntType > | |
constexpr bool | multiplicationWillOverflow (IntType a, IntType b) |
Test whether a multiplication of two integers will cause an overflow/underflow for that integer type. More... | |
int | getWidthForTerminalOutput (int max_width=0) |
Return a suitable width for displaying stuff on the standard output. More... | |
constexpr conststr | extractFuncName (const conststr &funcname) |
Extract the function name from its signature. More... | |
template<typename ExceptionClass = std::runtime_error> | |
void | tomographerEnsure (bool condition, std::string message) |
Ensure that a condition is met, or throw an exception. More... | |
template<typename Der , typename Rng , typename RndDist , typename... IndexTypes> | |
auto | denseRandom (Rng &rng, RndDist &rnddist, IndexTypes... sizes) -> const Eigen::CwiseNullaryOp< tomo_internal::random_generator< Rng, RndDist, typename Eigen::internal::traits< Der >::Scalar >, Der > |
a matrix populated with random entries using C++'s random framework More... | |
template<typename Der , typename IndexType > | |
auto | canonicalBasisVec (IndexType k, IndexType size) -> const Eigen::CwiseNullaryOp< tomo_internal::can_basis_vec_generator< typename Eigen::internal::traits< Der >::Scalar, IndexType >, Der > |
Expression for the k-th canonical basis vector of given dimension. More... | |
template<typename Der , typename IndexType > | |
auto | canonicalBasisVec (IndexType k, IndexType j, IndexType rows, IndexType cols) -> const Eigen::CwiseNullaryOp< tomo_internal::can_basis_vec_generator< typename Eigen::internal::traits< Der >::Scalar, IndexType >, Der > |
Expression for the (k,j)-th canonical basis matrix of given dimension. More... | |
template<typename Der , typename... IndexTypes> | |
auto | powersOfTwo (IndexTypes... sizes) -> const Eigen::CwiseNullaryOp< tomo_internal::powers_of_two_generator< typename Eigen::internal::traits< Der >::Scalar >, Der > |
Expression for a 1-D expression of powers of two. More... | |
template<int RowFactorCTime, int ColFactorCTime, typename Derived , typename std::enable_if<(RowFactorCTime==Eigen::Dynamic||ColFactorCTime==Eigen::Dynamic), bool >::type dummy = true> | |
auto | replicated (const Eigen::DenseBase< Derived > &x, int row_factor, int col_factor) -> const Eigen::Replicate< Derived, Eigen::Dynamic, Eigen::Dynamic > |
Replicate a Eigen Dense object; same call for compile-time & run-time dimensions. More... | |
std::string | vfmts (const char *fmt, va_list vl) |
printf- formatting to a std::string , with va_list pointer More... | |
std::string | fmts (const char *fmt,...) |
printf- format to a std::string More... | |
template<typename T > | |
_Unspecified | streamIfPossible (const T &obj) |
Utility to stream an object, but only if "<<" overload exists. More... | |
template<typename T > | |
_Unspecified | streamIfPossible (const T &obj, std::string before, std::string after=std::string(), std::string alternative="<"+std::string(typeid(T).name())+">") |
A slightly more sophisticated alternative to streamIfPossible() More... | |
std::string | fmtDuration (double seconds) |
Format a number of seconds into a human-readable string. More... | |
template<typename Rep , typename Period > | |
std::string | fmtDuration (std::chrono::duration< Rep, Period > dt) |
Format a std::chrono::duration into a human-readable string. More... | |
std::ostream & | operator<< (std::ostream &stream, const FmtFootnotes &f) |
void | installSignalHandler (int signum, SignalHandler *sobj) |
Installs the given signal handler to catch the signal signum. More... | |
template<typename TaskDispatcher , typename LoggerT > | |
SigHandlerTaskDispatcherStatusReporter< TaskDispatcher, LoggerT > | makeSigHandlerTaskDispatcherStatusReporter (TaskDispatcher *tasks, LoggerT &logger) |
template<typename TaskDispatcher , typename LoggerT , typename CallbackFn > | |
SigHandlerTaskDispatcherStatusReporter< TaskDispatcher, LoggerT > | makeSigHandlerTaskDispatcherStatusReporter (TaskDispatcher *tasks, LoggerT &logger, CallbackFn &&fn) |
Various useful tools.
|
inline |
|
inline |
Test whether the sum of several integers will cause an overflow/underflow for that integer type.
Provided for convenience. See additionWillOverflow(IntType,IntType)
|
inline |
Expression for the k-th canonical basis vector of given dimension.
Definition at line 214 of file eigenutil.h.
|
inline |
Expression for the (k,j)-th canonical basis matrix of given dimension.
This is a matrix of zeros except for the entry (k,j) which is one.
Definition at line 232 of file eigenutil.h.
|
inline |
a matrix populated with random entries using C++'s random
framework
rng | the std::random generator, such as a std::mt19937 instance |
rnddist | the std::random distribution to sample from, such as a std::normal_distribution instance |
sizes | either no parameter, one parameter or two parameters specifying the sizes of the dense object to return. |
Definition at line 154 of file eigenutil.h.
|
inline |
|
inline |
|
inline |
Format a std::chrono::duration into a human-readable string.
This formats the duration into a human-readable string with hours, minutes seconds and milliseconds.
dt | the duration, a std::chrono::duration |
See also fmtDuration(double)
|
inline |
|
inline |
Return a suitable width for displaying stuff on the standard output.
If max_width > 0, return that value as is.
If max_width <= 0, return the width of the screen (or default width) as given by the environment variable COLUMNS
, minus the absolute value of the given number. [E.g. if the screen width is 100, then if maxwidth=-4, then return 96.]
|
inline |
Installs the given signal handler to catch the signal signum.
If other handlers are alreay set for a different signal number, they are not overridden.
Definition at line 190 of file signal_handler.h.
|
inline |
Test whether floating-point value is finite.
Potentially extends std::isfinite() in that we can specialize the template for custom types.
|
inline |
|
inline |
|
inline |
C++ Stream operators for StoreIfEnabled.
Produces human-readable output.
This implementation kicks in if the value is not streamable, and simply outputs the fixed string "[-]"
.
|
inline |
C++ Stream operators for StoreIfEnabled.
Produces human-readable output.
This implementation kicks in if the value is indeed streamable, and outputs the given value into the stream.
|
inline |
Expression for a 1-D expression of powers of two.
An Eigen template expression yielding powers of two as a column vector. The \( i\) -th item is \( 2^i \).
sizes | You may either specify the length of the vector (1 parameter), or the size of a column matrix (2 parameters, the second being equal to one). |
If you specify a 2-D matrix size here (not a column or row vector), then the elements of the matrix are populated linearly with powers of two (with linear access, i.e. by default column-wise).
Definition at line 307 of file eigenutil.h.
|
inline |
Replicate a Eigen Dense object; same call for compile-time & run-time dimensions.
See replicated<RowFactorCTime, ColFactorCTime, Derived, dummy>
Allow our libraries to use the same syntax, for example
for replicating a matrix for which one might, or might not, know the factor at compile time.
The corresponding factor template parameter should be either Eigen::Dynamic or a fixed value. If a fixed value is given, you need to specify the same value in the runtime argument (done as an eigen_assert() check, i.e. this is compiled out if -DNDEBUG is used)
This is the implementation for fixed RowFactorCTime and ColFactorCTime.
Definition at line 344 of file eigenutil.h.
|
inline |
Utility to stream an object, but only if "<<"
overload exists.
You may use this function in a sequence of objects passed to a std::ostream, so that the object gets printed if it is streamable and it is ignored if not. The return type of this function is guaranteed to be streamable for any type T.
A typical use of this function is to generate debugging messages in generic templated classes for which the data type is not certain to be streamable.
Example use:
Would output:
|
inline |
A slightly more sophisticated alternative to streamIfPossible()
With this wrapper, you can also specify text to add before and after the object if it is streamed, and you can specify the alternative text to display if the object is not streamable.
Example:
might give you either
Hello! object is = ..... string representation of MyObjectType ..... Done !
if the object type MyObjectType is streamable, or
Hello! [not streamable] Done !
if it is not.
Specify the object const reference in obj, the string to display before the object's string representation (before), the string to display after the object's string representation (after), and the alternative string to display if the object is not streamable (alternative).
|
inline |
Ensure that a condition is met, or throw an exception.
If condition is true, no action is taken. If condition is false, then an instance of the exception ExceptionClass is thrown. The exception is instantiated using message as parameter.
ExceptionClass | is the exception to throw if the given condition is false |
condition | controls whether to throw an error (if its value is false) |
message | is the string to pass on to the exception class if condition is false |
|
inline |
printf-
formatting to a std::string
, with va_list
pointer
Does safe allocation, etc.