Public Member Functions | |
template<> | |
void | display_vector (uint8_t *vector, int32_t n, const char *name) |
template<> | |
void | display_vector (int32_t *vector, int32_t n, const char *name) |
template<> | |
void | display_vector (int64_t *vector, int32_t n, const char *name) |
template<> | |
void | display_vector (float32_t *vector, int32_t n, const char *name) |
template<> | |
void | display_vector (float64_t *vector, int32_t n, const char *name) |
template<> | |
void | display_matrix (int32_t *matrix, int32_t rows, int32_t cols, const char *name) |
template<> | |
void | display_matrix (float64_t *matrix, int32_t rows, int32_t cols, const char *name) |
Constructor/Destructor. | |
CMath () | |
Constructor - initializes log-table. | |
virtual | ~CMath () |
Destructor - frees logtable. | |
Static Public Member Functions | |
static float64_t | mutual_info (float64_t *p1, float64_t *p2, int32_t len) |
static float64_t | relative_entropy (float64_t *p, float64_t *q, int32_t len) |
static float64_t | entropy (float64_t *p, int32_t len) |
returns entropy of p which is given in logspace | |
static uint32_t | get_seed () |
returns number generator seed | |
min/max/abs functions. | |
template<class T > | |
static T | min (T a, T b) |
return the minimum of two integers | |
template<class T > | |
static T | max (T a, T b) |
return the maximum of two integers | |
template<class T > | |
static T | clamp (T value, T lb, T ub) |
return the value clamped to interval [lb,ub] | |
template<class T > | |
static T | abs (T a) |
return the maximum of two integers | |
misc functions | |
static uint32_t | crc32 (uint8_t *data, int32_t len) |
crc32 | |
static float64_t | round (float64_t d) |
static float64_t | floor (float64_t d) |
static float64_t | ceil (float64_t d) |
template<class T > | |
static T | sign (T a) |
signum of type T variable a | |
template<class T > | |
static void | swap (T &a, T &b) |
swap e.g. floats a and b | |
template<class T > | |
static T | sq (T x) |
x^2 | |
static float32_t | sqrt (float32_t x) |
x^0.5 | |
static float64_t | sqrt (float64_t x) |
x^0.5 | |
static float128_t | sqrt (float128_t x) |
x^0.5 | |
static float128_t | powl (float128_t x, float128_t n) |
x^n | |
static int32_t | pow (int32_t x, int32_t n) |
static float64_t | pow (float64_t x, int32_t n) |
static float64_t | pow (float64_t x, float64_t n) |
static float64_t | log10 (float64_t v) |
static float64_t | log2 (float64_t v) |
static float64_t | log (float64_t v) |
template<class T > | |
static void | transpose_matrix (T *&matrix, int32_t &num_feat, int32_t &num_vec) |
static float64_t * | pinv (float64_t *matrix, int32_t rows, int32_t cols, float64_t *target=NULL) |
static void | dgemm (double alpha, const double *A, int rows, int cols, CBLAS_TRANSPOSE transposeA, double *B, int cols_B, CBLAS_TRANSPOSE transposeB, double beta, double *C) |
static void | dgemv (double alpha, const double *A, int rows, int cols, const CBLAS_TRANSPOSE transposeA, const double *X, double beta, double *Y) |
static int64_t | factorial (int32_t n) |
static void | init_random (uint32_t initseed=0) |
static int64_t | random () |
static int32_t | random (int32_t min_value, int32_t max_value) |
static float32_t | random (float32_t min_value, float32_t max_value) |
static float64_t | random (float64_t min_value, float64_t max_value) |
template<class T > | |
static void | fill_vector (T *vec, int32_t len, T value) |
template<class T > | |
static void | range_fill_vector (T *vec, int32_t len, T start=0) |
template<class T > | |
static void | random_vector (T *vec, int32_t len, T min_value, T max_value) |
static int32_t * | randperm (int32_t n) |
static int64_t | nchoosek (int32_t n, int32_t k) |
template<class T > | |
static void | vec1_plus_scalar_times_vec2 (T *vec1, T scalar, const T *vec2, int32_t n) |
x=x+alpha*y | |
static float64_t | dot (const float64_t *v1, const float64_t *v2, int32_t n) |
compute dot product between v1 and v2 (blas optimized) | |
static float32_t | dot (const float32_t *v1, const float32_t *v2, int32_t n) |
compute dot product between v1 and v2 (blas optimized) | |
static float64_t | dot (const int64_t *v1, const int64_t *v2, int32_t n) |
compute dot product between v1 and v2 (for 64bit ints) | |
static float64_t | dot (const uint16_t *v1, const uint16_t *v2, int32_t n) |
compute dot product between v1 and v2 (for 16bit unsigned ints) | |
static float64_t | dot (const char *v1, const char *v2, int32_t n) |
compute dot product between v1 and v2 (for 8bit (un)signed ints) | |
static float64_t | dot (const uint8_t *v1, const uint8_t *v2, int32_t n) |
compute dot product between v1 and v2 (for 8bit (un)signed ints) | |
static float64_t | dot (const float64_t *v1, const char *v2, int32_t n) |
compute dot product between v1 and v2 | |
template<class T > | |
static void | add (T *target, T alpha, const T *v1, T beta, const T *v2, int32_t len) |
target=alpha*vec1 + beta*vec2 | |
template<class T > | |
static void | add_scalar (T alpha, T *vec, int32_t len) |
add scalar to vector inplace | |
template<class T > | |
static void | scale_vector (T alpha, T *vec, int32_t len) |
scale vector inplace | |
template<class T > | |
static T | sum (T *vec, int32_t len) |
return sum(vec) | |
template<class T > | |
static T | max (T *vec, int32_t len) |
return max(vec) | |
template<class T > | |
static T | sum_abs (T *vec, int32_t len) |
return sum(abs(vec)) | |
static float64_t | mean (float64_t *vec, int32_t len) |
static float64_t | trace (float64_t *mat, int32_t cols, int32_t rows) |
static void | sort (int32_t *a, int32_t cols, int32_t sort_col=0) |
static void | sort (float64_t *a, int32_t *idx, int32_t N) |
template<class T > | |
static void | radix_sort (T *array, size_t size) |
template<class T > | |
static uint8_t | byte (T word, uint16_t p) |
template<class T > | |
static void | radix_sort_helper (T *array, size_t size, uint16_t i) |
template<class T > | |
static void | insertion_sort (T *output, int32_t size) |
template<class T > | |
static void | qsort (T *output, int32_t size) |
template<class T > | |
static void | display_vector (T *vector, int32_t n, const char *name="vector") |
display vector (useful for debugging) | |
template<class T > | |
static void | display_matrix (T *matrix, int32_t rows, int32_t cols, const char *name="matrix") |
display matrix (useful for debugging) | |
template<class T1 , class T2 > | |
static void | qsort_index (T1 *output, T2 *index, uint32_t size) |
template<class T1 , class T2 > | |
static void * | parallel_qsort_index (void *p) |
template<class T1 , class T2 > | |
static void | qsort_backward_index (T1 *output, T2 *index, int32_t size) |
template<class T > | |
static void | min (float64_t *output, T *index, int32_t size) |
template<class T > | |
static void | nmin (float64_t *output, T *index, int32_t size, int32_t n) |
template<class T > | |
static int32_t | unique (T *output, int32_t size) |
template<class T > | |
static int32_t | binary_search_helper (T *output, int32_t size, T elem) |
template<class T > | |
static int32_t | binary_search (T *output, int32_t size, T elem) |
template<class T > | |
static int32_t | binary_search_max_lower_equal (T *output, int32_t size, T elem) |
static float64_t | Align (char *seq1, char *seq2, int32_t l1, int32_t l2, float64_t gapCost) |
static int32_t | calcroc (float64_t *fp, float64_t *tp, float64_t *output, int32_t *label, int32_t &size, int32_t &possize, int32_t &negsize, float64_t &tresh, FILE *rocfile) |
summing functions | |
static float64_t | logarithmic_sum (float64_t p, float64_t q) |
Static Public Attributes | |
constants | |
static const float64_t | INFTY = -log(0.0) |
infinity | |
static const float64_t | ALMOST_INFTY = +1e+20 |
static const float64_t | ALMOST_NEG_INFTY = -1000 |
almost neg (log) infinity | |
static int32_t | LOGRANGE = 0 |
range for logtable: log(1+exp(x)) -LOGRANGE <= x <= 0 | |
static uint32_t | seed = 0 |
random generator seed | |
static char * | rand_state = NULL |
Definition at line 103 of file Mathematics.h.
CMath::CMath | ( | ) |
CMath::~CMath | ( | ) | [virtual] |
static T CMath::abs | ( | T | a | ) | [static] |
static void CMath::add | ( | T * | target, | |
T | alpha, | |||
const T * | v1, | |||
T | beta, | |||
const T * | v2, | |||
int32_t | len | |||
) | [static] |
static void CMath::add_scalar | ( | T | alpha, | |
T * | vec, | |||
int32_t | len | |||
) | [static] |
float64_t CMath::Align | ( | char * | seq1, | |
char * | seq2, | |||
int32_t | l1, | |||
int32_t | l2, | |||
float64_t | gapCost | |||
) | [static] |
align two sequences seq1 & seq2 of length l1 and l2 using gapCost return alignment cost
Definition at line 166 of file Mathematics.cpp.
static int32_t CMath::binary_search | ( | T * | output, | |
int32_t | size, | |||
T | elem | |||
) | [static] |
Definition at line 884 of file Mathematics.h.
static int32_t CMath::binary_search_helper | ( | T * | output, | |
int32_t | size, | |||
T | elem | |||
) | [static] |
Definition at line 855 of file Mathematics.h.
static int32_t CMath::binary_search_max_lower_equal | ( | T * | output, | |
int32_t | size, | |||
T | elem | |||
) | [static] |
Definition at line 897 of file Mathematics.h.
static uint8_t CMath::byte | ( | T | word, | |
uint16_t | p | |||
) | [static] |
Definition at line 638 of file Mathematics.h.
int32_t CMath::calcroc | ( | float64_t * | fp, | |
float64_t * | tp, | |||
float64_t * | output, | |||
int32_t * | label, | |||
int32_t & | size, | |||
int32_t & | possize, | |||
int32_t & | negsize, | |||
float64_t & | tresh, | |||
FILE * | rocfile | |||
) | [static] |
calculates ROC into (fp,tp) from output and label of length size returns index with smallest error=fp+fn
Definition at line 211 of file Mathematics.cpp.
Definition at line 178 of file Mathematics.h.
static T CMath::clamp | ( | T | value, | |
T | lb, | |||
T | ub | |||
) | [static] |
uint32_t CMath::crc32 | ( | uint8_t * | data, | |
int32_t | len | |||
) | [static] |
static void CMath::dgemm | ( | double | alpha, | |
const double * | A, | |||
int | rows, | |||
int | cols, | |||
CBLAS_TRANSPOSE | transposeA, | |||
double * | B, | |||
int | cols_B, | |||
CBLAS_TRANSPOSE | transposeB, | |||
double | beta, | |||
double * | C | |||
) | [static] |
Definition at line 319 of file Mathematics.h.
static void CMath::dgemv | ( | double | alpha, | |
const double * | A, | |||
int | rows, | |||
int | cols, | |||
const CBLAS_TRANSPOSE | transposeA, | |||
const double * | X, | |||
double | beta, | |||
double * | Y | |||
) | [static] |
Definition at line 329 of file Mathematics.h.
void CMath::display_matrix | ( | float64_t * | matrix, | |
int32_t | rows, | |||
int32_t | cols, | |||
const char * | name | |||
) |
Definition at line 528 of file Mathematics.cpp.
void CMath::display_matrix | ( | int32_t * | matrix, | |
int32_t | rows, | |||
int32_t | cols, | |||
const char * | name | |||
) |
Definition at line 511 of file Mathematics.cpp.
static void CMath::display_matrix | ( | T * | matrix, | |
int32_t | rows, | |||
int32_t | cols, | |||
const char * | name = "matrix" | |||
) | [static] |
display matrix (useful for debugging)
void CMath::display_vector | ( | float64_t * | vector, | |
int32_t | n, | |||
const char * | name | |||
) |
Definition at line 501 of file Mathematics.cpp.
void CMath::display_vector | ( | float32_t * | vector, | |
int32_t | n, | |||
const char * | name | |||
) |
Definition at line 491 of file Mathematics.cpp.
void CMath::display_vector | ( | int64_t * | vector, | |
int32_t | n, | |||
const char * | name | |||
) |
Definition at line 481 of file Mathematics.cpp.
void CMath::display_vector | ( | int32_t * | vector, | |
int32_t | n, | |||
const char * | name | |||
) |
Definition at line 471 of file Mathematics.cpp.
void CMath::display_vector | ( | uint8_t * | vector, | |
int32_t | n, | |||
const char * | name | |||
) |
Definition at line 461 of file Mathematics.cpp.
static void CMath::display_vector | ( | T * | vector, | |
int32_t | n, | |||
const char * | name = "vector" | |||
) | [static] |
display vector (useful for debugging)
static float64_t CMath::dot | ( | const uint8_t * | v1, | |
const uint8_t * | v2, | |||
int32_t | n | |||
) | [static] |
compute dot product between v1 and v2 (for 8bit (un)signed ints)
Definition at line 516 of file Mathematics.h.
static float64_t CMath::dot | ( | const char * | v1, | |
const char * | v2, | |||
int32_t | n | |||
) | [static] |
compute dot product between v1 and v2 (for 8bit (un)signed ints)
Definition at line 505 of file Mathematics.h.
static float64_t CMath::dot | ( | const uint16_t * | v1, | |
const uint16_t * | v2, | |||
int32_t | n | |||
) | [static] |
compute dot product between v1 and v2 (for 16bit unsigned ints)
Definition at line 494 of file Mathematics.h.
static float64_t CMath::dot | ( | const int64_t * | v1, | |
const int64_t * | v2, | |||
int32_t | n | |||
) | [static] |
compute dot product between v1 and v2 (for 64bit ints)
Definition at line 483 of file Mathematics.h.
compute dot product between v1 and v2 (blas optimized)
Definition at line 468 of file Mathematics.h.
compute dot product between v1 and v2 (blas optimized)
Definition at line 454 of file Mathematics.h.
static int64_t CMath::factorial | ( | int32_t | n | ) | [static] |
Definition at line 340 of file Mathematics.h.
static void CMath::fill_vector | ( | T * | vec, | |
int32_t | len, | |||
T | value | |||
) | [static] |
Definition at line 402 of file Mathematics.h.
Definition at line 173 of file Mathematics.h.
static uint32_t CMath::get_seed | ( | ) | [static] |
static void CMath::init_random | ( | uint32_t | initseed = 0 |
) | [static] |
Definition at line 348 of file Mathematics.h.
static void CMath::insertion_sort | ( | T * | output, | |
int32_t | size | |||
) | [static] |
performs insertion sort of an array output of length size it is sorted from in ascending (for type T)
Definition at line 744 of file Mathematics.h.
Definition at line 287 of file Mathematics.h.
Definition at line 270 of file Mathematics.h.
Definition at line 281 of file Mathematics.h.
sum logarithmic probabilities. Probability measures are summed up but are now given in logspace where direct summation of exp(operand) is not possible due to numerical problems, i.e. eg. exp(-1000)=0. Therefore we do log( exp(a) + exp(b)) = a + log (1 + exp (b-a)) where a = max(p,q) and b min(p,q).
Definition at line 980 of file Mathematics.h.
static T CMath::max | ( | T * | vec, | |
int32_t | len | |||
) | [static] |
static T CMath::max | ( | T | a, | |
T | b | |||
) | [static] |
Definition at line 598 of file Mathematics.h.
void CMath::min | ( | float64_t * | output, | |
T * | index, | |||
int32_t | size | |||
) | [static] |
Definition at line 1244 of file Mathematics.h.
static T CMath::min | ( | T | a, | |
T | b | |||
) | [static] |
returns the mutual information of p which is given in logspace where p,q are given in logspace
Definition at line 380 of file Mathematics.cpp.
static int64_t CMath::nchoosek | ( | int32_t | n, | |
int32_t | k | |||
) | [static] |
Definition at line 434 of file Mathematics.h.
void CMath::nmin | ( | float64_t * | output, | |
T * | index, | |||
int32_t | size, | |||
int32_t | n | |||
) | [static] |
Definition at line 1233 of file Mathematics.h.
void * CMath::parallel_qsort_index | ( | void * | p | ) | [static] |
Definition at line 1052 of file Mathematics.h.
float64_t * CMath::pinv | ( | float64_t * | matrix, | |
int32_t | rows, | |||
int32_t | cols, | |||
float64_t * | target = NULL | |||
) | [static] |
return the pseudo inverse for matrix when matrix has shape (rows, cols) the pseudo inverse has (cols, rows)
Definition at line 422 of file Mathematics.cpp.
Definition at line 265 of file Mathematics.h.
Definition at line 255 of file Mathematics.h.
static int32_t CMath::pow | ( | int32_t | x, | |
int32_t | n | |||
) | [static] |
Definition at line 245 of file Mathematics.h.
static float128_t CMath::powl | ( | float128_t | x, | |
float128_t | n | |||
) | [static] |
static void CMath::qsort | ( | T * | output, | |
int32_t | size | |||
) | [static] |
performs a quicksort on an array output of length size it is sorted from in ascending (for type T)
Definition at line 765 of file Mathematics.h.
void CMath::qsort_backward_index | ( | T1 * | output, | |
T2 * | index, | |||
int32_t | size | |||
) | [static] |
performs a quicksort on an array output of length size it is sorted in ascending order (for type T1) and returns the index (type T2) matlab alike [sorted,index]=sort(output)
Definition at line 1192 of file Mathematics.h.
void CMath::qsort_index | ( | T1 * | output, | |
T2 * | index, | |||
uint32_t | size | |||
) | [static] |
performs a quicksort on an array output of length size it is sorted in ascending order (for type T1) and returns the index (type T2) matlab alike [sorted,index]=sort(output)
Definition at line 1152 of file Mathematics.h.
static void CMath::radix_sort | ( | T * | array, | |
size_t | size | |||
) | [static] |
performs a in-place radix sort in ascending order
Definition at line 632 of file Mathematics.h.
static void CMath::radix_sort_helper | ( | T * | array, | |
size_t | size, | |||
uint16_t | i | |||
) | [static] |
Definition at line 644 of file Mathematics.h.
Definition at line 391 of file Mathematics.h.
Definition at line 381 of file Mathematics.h.
static int32_t CMath::random | ( | int32_t | min_value, | |
int32_t | max_value | |||
) | [static] |
Definition at line 374 of file Mathematics.h.
static int64_t CMath::random | ( | ) | [static] |
Definition at line 365 of file Mathematics.h.
static void CMath::random_vector | ( | T * | vec, | |
int32_t | len, | |||
T | min_value, | |||
T | max_value | |||
) | [static] |
Definition at line 415 of file Mathematics.h.
static int32_t* CMath::randperm | ( | int32_t | n | ) | [static] |
Definition at line 421 of file Mathematics.h.
static void CMath::range_fill_vector | ( | T * | vec, | |
int32_t | len, | |||
T | start = 0 | |||
) | [static] |
Definition at line 408 of file Mathematics.h.
returns the relative entropy H(P||Q), where p,q are given in logspace
Definition at line 391 of file Mathematics.cpp.
Definition at line 168 of file Mathematics.h.
static void CMath::scale_vector | ( | T | alpha, | |
T * | vec, | |||
int32_t | len | |||
) | [static] |
static T CMath::sign | ( | T | a | ) | [static] |
void CMath::sort | ( | float64_t * | a, | |
int32_t * | idx, | |||
int32_t | N | |||
) | [static] |
Definition at line 147 of file Mathematics.cpp.
void CMath::sort | ( | int32_t * | a, | |
int32_t | cols, | |||
int32_t | sort_col = 0 | |||
) | [static] |
performs a bubblesort on a given matrix a. it is sorted in ascending order from top to bottom and left to right
Definition at line 127 of file Mathematics.cpp.
static T CMath::sq | ( | T | x | ) | [static] |
static float128_t CMath::sqrt | ( | float128_t | x | ) | [static] |
static T CMath::sum | ( | T * | vec, | |
int32_t | len | |||
) | [static] |
static T CMath::sum_abs | ( | T * | vec, | |
int32_t | len | |||
) | [static] |
static void CMath::swap | ( | T & | a, | |
T & | b | |||
) | [static] |
Definition at line 609 of file Mathematics.h.
static void CMath::transpose_matrix | ( | T *& | matrix, | |
int32_t & | num_feat, | |||
int32_t & | num_vec | |||
) | [static] |
Definition at line 293 of file Mathematics.h.
static int32_t CMath::unique | ( | T * | output, | |
int32_t | size | |||
) | [static] |
Definition at line 842 of file Mathematics.h.
static void CMath::vec1_plus_scalar_times_vec2 | ( | T * | vec1, | |
T | scalar, | |||
const T * | vec2, | |||
int32_t | n | |||
) | [static] |
const float64_t CMath::ALMOST_INFTY = +1e+20 [static] |
Definition at line 1028 of file Mathematics.h.
const float64_t CMath::ALMOST_NEG_INFTY = -1000 [static] |
const float64_t CMath::INFTY = -log(0.0) [static] |
int32_t CMath::LOGRANGE = 0 [static] |
range for logtable: log(1+exp(x)) -LOGRANGE <= x <= 0
Definition at line 1034 of file Mathematics.h.
char * CMath::rand_state = NULL [static] |
Definition at line 1048 of file Mathematics.h.
uint32_t CMath::seed = 0 [static] |