Utilities Namespace Reference
[Utility functions and classes]


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< intstring_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 intget_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 >
fixed_power (const T t)
std::vector< unsigned intreverse_permutation (const std::vector< unsigned int > &permutation)
std::vector< unsigned intinvert_permutation (const std::vector< unsigned int > &permutation)

Detailed Description

A namespace for utility functions that are not particularly specific to finite element computing or numerical programs, but nevertheless are needed in various contexts when writing applications.

Author:
Wolfgang Bangerth, 2005


Function Documentation

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.

unsigned int Utilities::needed_digits ( const unsigned int  max_number  ) 

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)

double Utilities::generate_normal_random_number ( const double  a,
const double  sigma 
)

Generate a random number from a normalized Gaussian probability distribution centered around a and with standard deviation sigma.

template<int N, typename T >
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 $p_0\ldots p_{N-1}$ where each $p_i\in [0,N)$ and $p_i\neq p_j$ for $i\neq j$), produce the reverse permutation $q_i=N-1-p_i$.

std::vector<unsigned int> Utilities::invert_permutation ( const std::vector< unsigned int > &  permutation  ) 

Given a permutation vector (i.e. a vector $p_0\ldots p_{N-1}$ where each $p_i\in [0,N)$ and $p_i\neq p_j$ for $i\neq j$), produce the inverse permutation $q_0\ldots q_{N-1}$ so that $q_{p_i}=p_{q_i}=i$.


deal.II documentation generated on Sat Aug 15 16:52:56 2009 by doxygen 1.5.9