Namespaces | |
namespace | System |
namespace | Trilinos |
Functions | |
std::string | int_to_string (const unsigned int i, const unsigned int digits=numbers::invalid_unsigned_int) |
unsigned int | needed_digits (const unsigned int max_number) |
int | string_to_int (const std::string &s) |
std::vector< int > | string_to_int (const std::vector< std::string > &s) |
std::vector< std::string > | split_string_list (const std::string &s, const char delimiter= ',') |
std::vector< std::string > | break_text_into_lines (const std::string &original_text, const unsigned int width, const char delimiter= ' ') |
bool | match_at_string_start (const std::string &name, const std::string &pattern) |
std::pair< int, unsigned int > | get_integer_at_position (const std::string &name, const unsigned int position) |
double | generate_normal_random_number (const double a, const double sigma) |
template<int N, typename T > | |
T | fixed_power (const T t) |
std::vector< unsigned int > | reverse_permutation (const std::vector< unsigned int > &permutation) |
std::vector< unsigned int > | invert_permutation (const std::vector< unsigned int > &permutation) |
std::string Utilities::int_to_string | ( | const unsigned int | i, | |
const unsigned int | digits = numbers::invalid_unsigned_int | |||
) |
Convert a number i
to a string, with as many digits as given to fill with leading zeros.
If the second parameter is left at its default value, the number is not padded with leading zeros. The result is then the same as of the standard C function itoa()
had been called.
Determine how many digits are needed to represent numbers at most as large as the given number.
int Utilities::string_to_int | ( | const std::string & | s | ) |
Given a string, convert it to an integer. Throw an assertion if that is not possible.
std::vector<int> Utilities::string_to_int | ( | const std::vector< std::string > & | s | ) |
Given a list of strings, convert it to a list of integers. Throw an assertion if that is not possible.
std::vector<std::string> Utilities::split_string_list | ( | const std::string & | s, | |
const char | delimiter = ',' | |||
) |
Given a string that contains text separated by a delimiter
, split it into its components; for each component, remove leading and trailing spaces.
The default value of the delimiter is a comma, so that the function splits comma separated lists of strings.
std::vector<std::string> Utilities::break_text_into_lines | ( | const std::string & | original_text, | |
const unsigned int | width, | |||
const char | delimiter = ' ' | |||
) |
Take a text, usually a documentation or something, and try to break it into individual lines of text at most width
characters wide, by breaking at positions marked by delimiter
in the text. If this is not possible, return the shortest lines than are longer than width
. The default value of the delimiter is a space character.
bool Utilities::match_at_string_start | ( | const std::string & | name, | |
const std::string & | pattern | |||
) |
Return true if the given pattern string appears in the first position of the string.
std::pair<int, unsigned int> Utilities::get_integer_at_position | ( | const std::string & | name, | |
const unsigned int | position | |||
) |
Read a (signed) integer starting at the position in name
indicated by the second argument, and retun this integer as a pair together with how many characters it takes up in the string.
If no integer can be read at the indicated position, return (-1,numbers::invalid_unsigned_int)
Generate a random number from a normalized Gaussian probability distribution centered around a
and with standard deviation sigma
.
T Utilities::fixed_power | ( | const T | t | ) | [inline] |
Calculate a fixed power, provided as a template argument, of a number.
This function provides an efficient way to calculate things like t^N
where N
is a known number at compile time.
Use this function as in fixed_power<dim> (n)
.
References Assert, LAPACKSupport::N, and LAPACKSupport::T.
std::vector<unsigned int> Utilities::reverse_permutation | ( | const std::vector< unsigned int > & | permutation | ) |
Given a permutation vector (i.e. a vector where each
and
for
), produce the reverse permutation
.
std::vector<unsigned int> Utilities::invert_permutation | ( | const std::vector< unsigned int > & | permutation | ) |
Given a permutation vector (i.e. a vector where each
and
for
), produce the inverse permutation
so that
.