24 #ifndef __CONTOLLER_MISC_H
25 #define __CONTOLLER_MISC_H
27 #include <selforg/matrix.h>
41 inline T sqr(
T v) {
return v*v; }
45 return (x)<(lobound) ? (lobound) : ( (x) > (highbound) ? (highbound) : (x) );
56 double power(
void*
c,
double x);
69 double clip(
double r,
double);
81 double plus_(
double b,
double a);
110 const std::string& matrixName);
121 const std::string& matrixName,
169 double strength,
double unused = 0);
210 double min(
double a,
double b);
216 double max(
double a,
double b);
230 double adapt(
double p,
double actual,
double nominal,
double up_rate,
double down_rate);
233 double adaptMinMax(
double p,
double actual,
double _min,
double _max,
double up_rate,
double down_rate);
244 std::list<Inspectable::iparamkey>
getArrayNames(
int arraySize,
const char* name);
Matrix type.
Definition: matrix.h:65
T clip(T x, T lobound, T highbound)
Definition: controller_misc.h:44
matrix::I sample(const matrix::Matrix &pdf)
samples from the pdf (rowwise stored with sum = 1)
Definition: controller_misc.cpp:328
double max(const matrix::Matrix &v)
returns the largest element
Definition: controller_misc.cpp:318
matrix::Matrix matrixNormalized(const matrix::Matrix &m)
Matrix/matrixNorm2 )
Definition: controller_misc.cpp:253
double getKthSmallestElement(matrix::Matrix &matrix, matrix::I k)
returns the k.
Definition: controller_misc.cpp:269
double plus_(double b, double a)
plus function for mapP
Definition: controller_misc.cpp:58
double toBinaryWithProbability(void *r, double x)
returns -1 if probability is to low, otherwise 1 for mapP
Definition: controller_misc.cpp:47
random generator with 48bit integer arithmentic
Definition: randomgenerator.h:34
double random_minusone_to_one(double)
creates random number from -1 to 1
Definition: controller_misc.cpp:27
std::list< Inspectable::iparamval > convertArrayToList(double *array, int arraySize)
Helper function for converting an array with double values to a list.
Definition: controller_misc.cpp:371
T sign(T v)
Definition: controller_misc.h:38
matrix::I argmax(const matrix::Matrix &v)
considers the matrix as vector (mx1) and returns the index of the largest element ...
Definition: controller_misc.cpp:293
std::list< Inspectable::iparamkey > storeVectorFieldNames(const matrix::Matrix &m, const std::string &vectorName)
stores the names of all vector (mx1 or 1xn matrix) fieldnames in the order produced by convertToBuffe...
unsigned int I
type for matrix indices
Definition: matrix.h:36
matrix::I argmin(const matrix::Matrix &v)
considers the matrix as vector (mx1) and returns the index of the smallest element ...
Definition: controller_misc.cpp:279
std::list< Inspectable::iparamkey > storeMatrixFieldNames(const matrix::Matrix &m, const std::string &matrixName)
stores the names of all matrix fieldnames in the order produced by convertToBuffer (row-wise) ...
double one_over(double x)
calculates 1/x
Definition: controller_misc.cpp:9
std::list< Inspectable::iparamkey > getArrayNames(int arraySize, const char *name)
Helper function for getting the array names of an array Is used for the method getInternalParamNames(...
Definition: controller_misc.cpp:383
double power(void *c, double x)
returns x the power c (as a double)
Definition: controller_misc.cpp:17
double toBinaryWithThreshold(double x, double threshold)
returns -1 if below threshold, otherwise 1 for map2
Definition: controller_misc.cpp:53
double matrixNorm2(const matrix::Matrix &m)
calculates to square matrix norm (sum of square values divided by number of values (m*n) ) ...
Definition: controller_misc.cpp:249
std::list< Inspectable::iparamkey > store4x4AndDiagonalFieldNames(const matrix::Matrix &m, const std::string &matrixName)
writes the names of the fields stored by store4x4AndDiagonal into a list
Definition: controller_misc.cpp:116
matrix::Matrix noiseMatrix(matrix::I m, matrix::I n, NoiseGenerator &ng, double strength, double unused=0)
returns a Matrix with values generated by the given noise generator
Definition: controller_misc.cpp:223
bool storeMatrix(const matrix::Matrix &m, FILE *f)
stores the Matrix into the given file stream (binary)
double min(const matrix::Matrix &v)
returns the smallest element
Definition: controller_misc.cpp:307
double power3(double x)
power 3 for matrix::map
Definition: controller_misc.cpp:21
const int T
integer constant for use with exp function and (^) operator to transpose the matrix ...
Definition: matrix.cpp:21
T sqr(T v)
Definition: controller_misc.h:41
std::list< matrix::D > store4x4AndDiagonal(const matrix::Matrix &m)
stores at least left top 4x4 submatrix (row-wise) (if exists) and then the rest of the diagonal eleme...
Definition: controller_misc.cpp:67
double getKthLargestElement(matrix::Matrix &matrix, matrix::I k)
returns the k.
Definition: controller_misc.cpp:260
double lowercutof(void *theta, double)
cutof function for mapP
Definition: controller_misc.cpp:43
double constant(double c, double)
returns c (useful for Matrix::mapP to fill matrix with constant value)
Definition: controller_misc.cpp:13
bool restoreMatrix(matrix::Matrix &m, FILE *f)
reads a Matrix from the given file stream (binary)
double matrixNorm1(const matrix::Matrix &m)
calculates to linear matrix norm (sum of absolute values divided by number of values (m*n) ) ...
Definition: controller_misc.cpp:245
RandGen * splitRandGen(RandGen *randGen)
geneterates deterministically a new random generator from the given one.
Definition: controller_misc.cpp:233
double adaptMinMax(double p, double actual, double _min, double _max, double up_rate, double down_rate)
like adapt but that the adaption is just done if the actual value is outside the given interval (_min...
Definition: controller_misc.cpp:355
double adapt(double p, double actual, double nominal, double up_rate, double down_rate)
parameter adaptation algorithm.
Definition: controller_misc.cpp:347
matrix::I get4x4AndDiagonalSize(const matrix::Matrix &m)
returns the number of elements stored by store4x4AndDiagonal (should be min(getN(),4)*min(getM(),4)+ max(0,min(getM()-4,getN()-4)))
Definition: controller_misc.cpp:107
double D
type for matrix elements
Definition: matrix.h:38
int c
Definition: hexapod.cpp:56
Interface and basic class for noise generator.
Definition: noisegenerator.h:37