#include <selforg/matrix.h>
#include <assert.h>
#include <stdlib.h>
#include <cmath>
#include "stl_adds.h"
#include "noisegenerator.h"
#include "inspectable.h"
Include dependency graph for controller_misc.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Functions | |
template<typename T> | |
T | sign (T v) |
template<typename T> | |
T | sqr (T v) |
template<typename T> | |
T | clip (T x, T lobound, T highbound) |
double | one_over (double x) |
calculates 1/x | |
double | constant (double c, double) |
returns c (useful for Matrix::mapP to fill matrix with constant value) | |
double | random_minusone_to_one (double) |
creates random number from -1 to 1 | |
double | random_minusone_to_one (void *, double) |
creates random number from -1 to 1 | |
double | clip (double r, double) |
clipping function to the interval [-r, r] (for use with mapP) | |
double | lowercutof (void *theta, double) |
cutof function for mapP | |
double | toBinaryWithProbability (void *r, double x) |
returns -1 if probability is to low, otherwise 1 for mapP | |
double | toBinaryWithThreshold (double x, double threshold) |
returns -1 if below threshold, otherwise 1 for map2 | |
double | plus_ (double b, double a) |
plus function for mapP | |
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 elements into a list | |
matrix::I | store4x4AndDiagonal (const matrix::Matrix &m, matrix::D *buffer, matrix::I len) |
stores at least left top 4x4 submatrix (row-wise) (if exists) and then the rest of the diagonal elements | |
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))) | |
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 | |
matrix::I | store4x4AndDiagonalFieldNames (const matrix::Matrix &m, const std::string &matrixName, char **keylist, matrix::I len) |
stores the names of the fields stored by store4x4AndDiagonal | |
std::list< Inspectable::iparamkey > | storeMatrixFieldNames (const matrix::Matrix &m, const std::string &matrixName) |
stores the names of the all matrix fieldnames produces by convertToBuffer into a list | |
std::list< Inspectable::iparamkey > | storeVectorFieldNames (const matrix::Matrix &m, const std::string &vectorName) |
stores the names of the all vector (mx1 matrix) fieldnames produces by convertToBuffer into a list | |
matrix::I | storeMatrixFieldNames (const matrix::Matrix &m, const char *matrixName, char **keylist, matrix::I len) |
stores the names of the all matrix fieldnames produces by convertToBuffer | |
matrix::I | storeVectorFieldNames (const matrix::Matrix &m, const char *vectorName, char **keylist, matrix::I len) |
stores the names of the all vector (mx1 matrix) fieldnames produces by convertToBuffer | |
bool | storeMatrix (const matrix::Matrix &m, FILE *f) |
stores the Matrix into the given file stream (binary) | |
bool | restoreMatrix (matrix::Matrix &m, FILE *f) |
reads a Matrix from the given file stream (binary) | |
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 | |
double | matrixNorm1 (const matrix::Matrix &m) |
calculates to linear matrix norm (sum of absolute values divided by number of values (m*n) ) | |
double | matrixNorm2 (const matrix::Matrix &m) |
calculates to square matrix norm (sum of square values divided by number of values (m*n) ) | |
double | getKthLargestElement (matrix::Matrix &matrix, matrix::I k) |
returns the k. | |
double | getKthSmallestElement (matrix::Matrix &matrix, matrix::I k) |
returns the k. | |
matrix::I | argmin (const matrix::Matrix &v) |
considers the matrix as vector (mx1) and returns the index of the smallest element | |
matrix::I | argmax (const matrix::Matrix &v) |
considers the matrix as vector (mx1) and returns the index of the largest element | |
double | min (const matrix::Matrix &v) |
returns the smallest element | |
double | min (double a, double b) |
minimum function for doubles without templates | |
double | max (const matrix::Matrix &v) |
returns the largest element | |
double | max (double a, double b) |
maximum function for doubles without templates | |
matrix::I | sample (const matrix::Matrix &pdf) |
samples from the pdf (rowwise stored with sum = 1) | |
double | adapt (double p, double actual, double nominal, double up_rate, double down_rate) |
parameter adaptation algorithm. | |
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, _max) | |
std::list< Inspectable::iparamval > | convertArrayToList (double *array, int arraySize) |
Helper function for converting an array with double values to a list. | |
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() interface inspectable. |
double adapt | ( | double | p, | |
double | actual, | |||
double | nominal, | |||
double | up_rate, | |||
double | down_rate | |||
) |
parameter adaptation algorithm.
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, _max)
matrix::I argmax | ( | const matrix::Matrix & | v | ) |
considers the matrix as vector (mx1) and returns the index of the largest element
matrix::I argmin | ( | const matrix::Matrix & | v | ) |
considers the matrix as vector (mx1) and returns the index of the smallest element
double clip | ( | double | r, | |
double | ||||
) |
clipping function to the interval [-r, r] (for use with mapP)
double constant | ( | double | c, | |
double | ||||
) |
returns c (useful for Matrix::mapP to fill matrix with constant value)
std::list<Inspectable::iparamval> convertArrayToList | ( | double * | array, | |
int | arraySize | |||
) |
Helper function for converting an array with double values to a list.
Is used for the method getInternalParams() interface inspectable.
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)))
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() interface inspectable.
double getKthLargestElement | ( | matrix::Matrix & | matrix, | |
matrix::I | k | |||
) |
returns the k.
largest element of the matrix Attention: it will detroy the given matrix! (sorting) Assumption: k>0 and k<=matrixsize
double getKthSmallestElement | ( | matrix::Matrix & | matrix, | |
matrix::I | k | |||
) |
returns the k.
smallest element of the matrix Attention: it will detroy the given matrix! (sorting) Assumption: k>0 and k<=matrixsize
double lowercutof | ( | void * | theta, | |
double | ||||
) |
cutof function for mapP
double matrixNorm1 | ( | const matrix::Matrix & | m | ) |
calculates to linear matrix norm (sum of absolute values divided by number of values (m*n) )
double matrixNorm2 | ( | const matrix::Matrix & | m | ) |
calculates to square matrix norm (sum of square values divided by number of values (m*n) )
double max | ( | double | a, | |
double | b | |||
) |
maximum function for doubles without templates
double max | ( | const matrix::Matrix & | v | ) |
returns the largest element
double min | ( | double | a, | |
double | b | |||
) |
minimum function for doubles without templates
double min | ( | const matrix::Matrix & | v | ) |
returns the smallest element
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
double one_over | ( | double | x | ) |
calculates 1/x
double plus_ | ( | double | b, | |
double | a | |||
) |
plus function for mapP
double random_minusone_to_one | ( | void * | , | |
double | ||||
) |
creates random number from -1 to 1
double random_minusone_to_one | ( | double | ) |
creates random number from -1 to 1
bool restoreMatrix | ( | matrix::Matrix & | m, | |
FILE * | f | |||
) |
reads a Matrix from the given file stream (binary)
matrix::I sample | ( | const matrix::Matrix & | ) |
samples from the pdf (rowwise stored with sum = 1)
matrix::I store4x4AndDiagonal | ( | const matrix::Matrix & | m, | |
matrix::D * | buffer, | |||
matrix::I | len | |||
) |
stores at least left top 4x4 submatrix (row-wise) (if exists) and then the rest of the diagonal elements
m | matrix to be stored | |
len | Length of the provided buffer (should be min(getN(),4)*min(getM(),4)+ max(0,min(getM()-4,getN()-4))) |
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 elements into a list
matrix::I store4x4AndDiagonalFieldNames | ( | const matrix::Matrix & | m, | |
const std::string & | matrixName, | |||
char ** | keylist, | |||
matrix::I | len | |||
) |
stores the names of the fields stored by store4x4AndDiagonal
m | matrix to be stored | |
matrixName | name of the matrix (prefix for all fields) | |
keylist | list for field names | |
len | Length of the provided buffer (should be min(getN(),4)*min(getM(),4)+ max(0,min(getM()-4,getN()-4))) |
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
m | matrix to be stored | |
matrixName | name of the matrix (prefix for all fields) | |
keylist | list for field names | |
len | Length of the provided buffer (should be min(getN(),4)*min(getM(),4)+ max(0,min(getM()-4,getN()-4))) |
bool storeMatrix | ( | const matrix::Matrix & | m, | |
FILE * | f | |||
) |
stores the Matrix into the given file stream (binary)
matrix::I storeMatrixFieldNames | ( | const matrix::Matrix & | m, | |
const char * | matrixName, | |||
char ** | keylist, | |||
matrix::I | len | |||
) |
stores the names of the all matrix fieldnames produces by convertToBuffer
m | matrix to be stored | |
matrixName | name of the matrix (prefix for all fields) | |
keylist | list for field names | |
len | Length of the provided buffer (should be getN()*getM() |
std::list<Inspectable::iparamkey> storeMatrixFieldNames | ( | const matrix::Matrix & | m, | |
const std::string & | matrixName | |||
) |
stores the names of the all matrix fieldnames produces by convertToBuffer into a list
matrix::I storeVectorFieldNames | ( | const matrix::Matrix & | m, | |
const char * | vectorName, | |||
char ** | keylist, | |||
matrix::I | len | |||
) |
stores the names of the all vector (mx1 matrix) fieldnames produces by convertToBuffer
m | vector to be stored | |
vectorName | name of the vector (prefix for all fields) | |
keylist | list for field names | |
len | Length of the provided buffer (should be getM()) |
std::list<Inspectable::iparamkey> storeVectorFieldNames | ( | const matrix::Matrix & | m, | |
const std::string & | vectorName | |||
) |
stores the names of the all vector (mx1 matrix) fieldnames produces by convertToBuffer into a list
double toBinaryWithProbability | ( | void * | r, | |
double | x | |||
) |
returns -1 if probability is to low, otherwise 1 for mapP
double toBinaryWithThreshold | ( | double | x, | |
double | threshold | |||
) |
returns -1 if below threshold, otherwise 1 for map2