#include <sstream>
#include <string>
#include <list>
#include <math.h>
#include <cstdlib>
Include dependency graph for Util.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Defines | |
#define | RANDOM_MAX 2147483648.0 |
Functions | |
int | random_int (int nmax) |
Produces a random natural number between 0 and nmax-1. | |
std::string | itos (int i) |
Converts an int to a string. | |
std::string | ftos (double d) |
Converts a double to a string. | |
int | bitstodec (std::list< char >::iterator start, std::list< char >::iterator end) |
Returns the standard decimal value of a part of a bitstring. | |
int | bitstodec (std::list< char > bits) |
Returns the standard decimal value of an entire bitstring. | |
void | bitstodecparts (std::list< char > bits, int partsize, int *decparts) |
Computes the standard decimal value of all equally sized subparts of an entire bitstring. | |
std::string | bitstos (std::list< char > bits) |
Returns a string representation of a bitstring. | |
std::string | rbitstos (std::list< char > bits) |
Returns a string representation of a reversed bitstring. | |
template<typename __Tp> | |
std::_List_iterator< __Tp > & | operator+= (std::_List_iterator< __Tp > &it, int __n) |
Dirty, but useful: increment list iterator by specified nr of positions. | |
template<class T> | |
T ** | newMatrix (int nr, int nc) |
Allocates memory for a new matrix with specified number of rows and cols. | |
template<class T> | |
void | deleteMatrix (T **mtx, int nr, int nc) |
Deletes the memory that was previously allocated for a matrix with specified number of rows and cols. |
|
Returns the standard decimal value of an entire bitstring. Watch out for integer overflows!
|
|
Returns the standard decimal value of a part of a bitstring. Bitstrings often represent one or more numbers. As a help for Chromosome subclasses, this function performs the binary to decimal conversion for (a subpart of) a bitstring. start should point to the least significant bit, end should point 1 element beyond the most significant bit. |
|
Computes the standard decimal value of all equally sized subparts of an entire bitstring. The results are put into an array that is allocated elsewhere at the call site. Watch out for integer overflows when using excessively long bitstrings! Assumes that subparts fit exactly within bitstring (otherwise out-of- bounds problems will occur)
|
|
Returns a string representation of a bitstring. e.g. "10101110" |
|
Deletes the memory that was previously allocated for a matrix with specified number of rows and cols. No explicit template instantiation is necessary, e.g.: double **mtx = newMatrix<double>(7, 4); deleteMatrix(mtx, 7, 4); |
|
Allocates memory for a new matrix with specified number of rows and cols.
Use explicit template instantiation to call this function, e.g.: |
|
Dirty, but useful: increment list iterator by specified nr of positions. Runs in linear time. |
|
Returns a string representation of a reversed bitstring. e.g. "01110101" This is used when the bitstring represents some decimal number. The least significant bit is then commonly placed at the rightmost position. |