Go to the documentation of this file.
19 #ifndef LIBMESH_UTILITY_H
20 #define LIBMESH_UTILITY_H
23 #include "libmesh/libmesh_common.h"
38 #define libmesh_map_find(map, key) Utility::map_find((map), (key), __FILE__, __LINE__)
63 template<
typename Map>
65 typename Map::mapped_type &
67 const typename Map::key_type & key,
68 const char * filename,
71 auto it = map.find(key);
73 libmesh_error_msg(
"map_find() error: key not found in file " \
74 << filename <<
" on line " << line_number);
81 template<
typename Map>
83 const typename Map::mapped_type &
85 const typename Map::key_type & key,
86 const char * filename,
89 auto it = map.find(key);
91 libmesh_error_msg(
"map_find() error: key not found in file " \
92 << filename <<
" on line " << line_number);
104 template <
typename ForwardIter,
typename T>
105 void iota (ForwardIter first, ForwardIter last, T
value)
108 libmesh_deprecated();
110 while (first != last)
124 template<
class InputIterator >
142 InputIterator
prev( first );
143 for (++first; first != last; ++
prev, ++first)
182 template<
class ForwardIterator,
class T>
185 ForwardIterator it = std::lower_bound(first, last,
value);
186 return (it == last ||
value < *it) ? last : it;
192 template<
class ForwardIterator,
class T,
class Compare>
193 ForwardIterator
binary_find(ForwardIterator first, ForwardIterator last,
const T &
value, Compare comp)
195 ForwardIterator it = std::lower_bound(first, last,
value, comp);
196 return (it == last || comp(
value,*it)) ? last : it;
204 template <
int N,
typename T>
215 return xNover2*xNover2;
222 template <
typename T>
233 template <
typename T>
235 static inline T
apply (
const T & x) {
return x; }
238 template <
typename T>
240 static inline T
apply (
const T &) {
return 1; }
244 template <
int N,
typename T>
258 unsigned int factorial_n = 1;
263 for (
unsigned int i=1; i<n; i++)
271 template <
typename T>
281 for (T i = 0; i < k; ++i)
294 template <
typename T>
297 std::vector<T>().swap(vec);
303 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
311 unsigned int r_o_c=0);
317 std::vector<Real> & real_part,
318 std::vector<Real> & imag_part);
320 #endif // #ifdef LIBMESH_USE_COMPLEX_NUMBERS
326 int mkdir(
const char* pathname);
352 template <
typename T>
377 template <
typename T>
384 unsigned char * b = (
unsigned char *) &
data;
387 int j=(
sizeof(T) - 1);
404 #endif // LIBMESH_UTILITY_H
Map::mapped_type & map_find(Map &map, const typename Map::key_type &key, const char *filename, int line_number)
This function should not be called directly (although it can be), instead see the libmesh_map_find() ...
The libMesh namespace provides an interface to certain functionality in the library.
ReverseBytes(const bool dr)
Constructor.
static T apply(const T &x)
void iota(ForwardIter first, ForwardIter last, T value)
Utility::iota is a duplication of the SGI STL extension std::iota.
void prepare_complex_data(const std::vector< Complex > &source, std::vector< Real > &real_part, std::vector< Real > &imag_part)
Prepare complex data for writing.
ForwardIterator binary_find(ForwardIterator first, ForwardIterator last, const T &value)
The STL provides std::binary_search() which returns true or false depending on whether the searched-f...
An efficient template instantiation for raising to an arbitrary integer power.
static T apply(const T &x)
static T apply(const T &x)
This Functor simply takes an object and reverses its byte representation.
int mkdir(const char *pathname)
Create a directory.
void swap(Iterator &lhs, Iterator &rhs)
swap, used to implement op=
const bool _do_reverse
flag
bool is_sorted(InputIterator first, InputIterator last)
Utility::is_sorted mimics the behavior of the SGI STL extension std::is_sorted.
unsigned int factorial(unsigned int n)
A simple implementation of the factorial.
static T apply(const T &)
IterBase * data
Ideally this private member data should have protected access.
void deallocate(std::vector< T > &vec)
A convenient method to truly empty a vector using the "swap trick".
T operator()(T &data) const
Functor.
std::string complex_filename(const std::string &basename, unsigned int r_o_c=0)
std::string system_info()