Definition at line 107 of file Mathematics.h.
Public Member Functions | |
template<> | |
void | display_vector (BYTE *vector, INT n, const char *name) |
template<> | |
void | display_vector (INT *vector, INT n, const char *name) |
template<> | |
void | display_vector (LONG *vector, INT n, const char *name) |
template<> | |
void | display_vector (SHORTREAL *vector, INT n, const char *name) |
template<> | |
void | display_vector (DREAL *vector, INT n, const char *name) |
template<> | |
void | display_matrix (INT *matrix, INT rows, INT cols, const char *name) |
template<> | |
void | display_matrix (DREAL *matrix, INT rows, INT cols, const char *name) |
Constructor/Destructor. | |
CMath () | |
Constructor - initializes log-table. | |
virtual | ~CMath () |
Destructor - frees logtable. | |
Static Public Member Functions | |
static double | mutual_info (DREAL *p1, DREAL *p2, INT len) |
static double | relative_entropy (DREAL *p, DREAL *q, INT len) |
static double | entropy (DREAL *p, INT len) |
returns entropy of p which is given in logspace | |
static UINT | 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 UINT | crc32 (BYTE *data, INT len) |
crc32 | |
static DREAL | round (DREAL d) |
static DREAL | floor (DREAL d) |
static DREAL | ceil (DREAL 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 SHORTREAL | sqrt (SHORTREAL x) |
x^0.5 | |
static DREAL | sqrt (DREAL x) |
x^0.5 | |
static LONGREAL | sqrt (LONGREAL x) |
x^0.5 | |
static long double | powl (long double x, long double n) |
x^n | |
static INT | pow (INT x, INT n) |
static DREAL | pow (DREAL x, DREAL n) |
static DREAL | log10 (DREAL v) |
static DREAL | log2 (DREAL v) |
static DREAL | log (DREAL v) |
template<class T> | |
static void | transpose_matrix (T *&matrix, INT &num_feat, INT &num_vec) |
static LONG | factorial (INT n) |
static void | init_random (UINT initseed=0) |
static LONG | random () |
static INT | random (INT min_value, INT max_value) |
static SHORTREAL | random (SHORTREAL min_value, SHORTREAL max_value) |
static DREAL | random (DREAL min_value, DREAL max_value) |
template<class T> | |
static void | fill_vector (T *vec, INT len, T value) |
template<class T> | |
static void | range_fill_vector (T *vec, INT len, T start=0) |
template<class T> | |
static void | random_vector (T *vec, INT len, T min_value, T max_value) |
static INT * | randperm (INT n) |
static LONG | nchoosek (INT n, INT k) |
template<class T> | |
static void | vec1_plus_scalar_times_vec2 (T *vec1, T scalar, const T *vec2, INT n) |
x=x+alpha*y | |
static DREAL | dot (const DREAL *v1, const DREAL *v2, INT n) |
compute dot product between v1 and v2 (blas optimized) | |
static SHORTREAL | dot (const SHORTREAL *v1, const SHORTREAL *v2, INT n) |
compute dot product between v1 and v2 (blas optimized) | |
template<class T> | |
static void | add (T *target, T alpha, const T *v1, T beta, const T *v2, INT len) |
target=alpha*vec1 + beta*vec2 | |
template<class T> | |
static void | add_scalar (T alpha, T *vec, INT len) |
add scalar to vector inplace | |
template<class T> | |
static void | scale_vector (T alpha, T *vec, INT len) |
scale vector inplace | |
template<class T> | |
static T | sum (T *vec, INT len) |
return sum(vec) | |
template<class T> | |
static T | max (T *vec, INT len) |
return max(vec) | |
template<class T> | |
static T | sum_abs (T *vec, INT len) |
return sum(abs(vec)) | |
static DREAL | mean (DREAL *vec, INT len) |
static DREAL | trace (DREAL *mat, INT cols, INT rows) |
static void | sort (INT *a, INT cols, INT sort_col=0) |
static void | sort (DREAL *a, INT *idx, INT N) |
template<class T> | |
static void | radix_sort (T *array, size_t size) |
template<class T> | |
static BYTE | byte (T word, unsigned short p) |
template<class T> | |
static void | radix_sort_helper (T *array, size_t size, unsigned short i) |
template<class T> | |
static void | insertion_sort (T *output, INT size) |
template<class T> | |
static void | qsort (T *output, INT size) |
template<class T> | |
static void | display_vector (T *vector, INT n, const char *name="vector") |
display vector (useful for debugging) | |
template<class T> | |
static void | display_matrix (T *matrix, INT rows, INT cols, const char *name="matrix") |
display matrix (useful for debugging) | |
template<class T1, class T2> | |
static void | qsort_index (T1 *output, T2 *index, UINT 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, INT size) |
template<class T> | |
static void | min (DREAL *output, T *index, INT size) |
template<class T> | |
static void | nmin (DREAL *output, T *index, INT size, INT n) |
template<class T> | |
static INT | unique (T *output, INT size) |
template<class T> | |
static INT | binary_search_helper (T *output, INT size, T elem) |
template<class T> | |
static INT | binary_search (T *output, INT size, T elem) |
template<class T> | |
static INT | binary_search_max_lower_equal (T *output, INT size, T elem) |
static DREAL | Align (CHAR *seq1, CHAR *seq2, INT l1, INT l2, DREAL gapCost) |
static INT | calcroc (DREAL *fp, DREAL *tp, DREAL *output, INT *label, INT &size, INT &possize, INT &negsize, DREAL &tresh, FILE *rocfile) |
summing functions | |
static DREAL | logarithmic_sum (DREAL p, DREAL q) |
Static Public Attributes | |
static CParallel | parallel |
static CIO | io |
static CVersion | version |
constants | |
static const DREAL | INFTY = -log(0.0) |
infinity | |
static const DREAL | ALMOST_INFTY = +1e+20 |
static const DREAL | ALMOST_NEG_INFTY = -1000 |
almost neg (log) infinity | |
static INT | LOGRANGE = 0 |
range for logtable: log(1+exp(x)) -LOGRANGE <= x <= 0 | |
static UINT | seed = 0 |
random generator seed | |
static CHAR * | rand_state = NULL |
CMath::CMath | ( | ) |
CMath::~CMath | ( | ) | [virtual] |
static T CMath::min | ( | T | a, | |
T | b | |||
) | [static] |
static T CMath::max | ( | T | a, | |
T | b | |||
) | [static] |
static T CMath::clamp | ( | T | value, | |
T | lb, | |||
T | ub | |||
) | [static] |
static T CMath::abs | ( | T | a | ) | [static] |
Definition at line 172 of file Mathematics.h.
Definition at line 177 of file Mathematics.h.
Definition at line 182 of file Mathematics.h.
static T CMath::sign | ( | T | a | ) | [static] |
static void CMath::swap | ( | T & | a, | |
T & | b | |||
) | [static] |
static T CMath::sq | ( | T | x | ) | [static] |
static long double CMath::powl | ( | long double | x, | |
long double | n | |||
) | [static] |
Definition at line 249 of file Mathematics.h.
Definition at line 259 of file Mathematics.h.
Definition at line 264 of file Mathematics.h.
Definition at line 275 of file Mathematics.h.
Definition at line 281 of file Mathematics.h.
static void CMath::transpose_matrix | ( | T *& | matrix, | |
INT & | num_feat, | |||
INT & | num_vec | |||
) | [static] |
Definition at line 286 of file Mathematics.h.
Definition at line 329 of file Mathematics.h.
static void CMath::init_random | ( | UINT | initseed = 0 |
) | [static] |
Definition at line 337 of file Mathematics.h.
static LONG CMath::random | ( | ) | [static] |
Definition at line 354 of file Mathematics.h.
Definition at line 363 of file Mathematics.h.
Definition at line 370 of file Mathematics.h.
Definition at line 380 of file Mathematics.h.
static void CMath::fill_vector | ( | T * | vec, | |
INT | len, | |||
T | value | |||
) | [static] |
Definition at line 391 of file Mathematics.h.
static void CMath::range_fill_vector | ( | T * | vec, | |
INT | len, | |||
T | start = 0 | |||
) | [static] |
Definition at line 397 of file Mathematics.h.
static void CMath::random_vector | ( | T * | vec, | |
INT | len, | |||
T | min_value, | |||
T | max_value | |||
) | [static] |
Definition at line 404 of file Mathematics.h.
Definition at line 410 of file Mathematics.h.
Definition at line 423 of file Mathematics.h.
static void CMath::vec1_plus_scalar_times_vec2 | ( | T * | vec1, | |
T | scalar, | |||
const T * | vec2, | |||
INT | n | |||
) | [static] |
compute dot product between v1 and v2 (blas optimized)
Definition at line 443 of file Mathematics.h.
compute dot product between v1 and v2 (blas optimized)
Definition at line 457 of file Mathematics.h.
static void CMath::add | ( | T * | target, | |
T | alpha, | |||
const T * | v1, | |||
T | beta, | |||
const T * | v2, | |||
INT | len | |||
) | [static] |
static void CMath::add_scalar | ( | T | alpha, | |
T * | vec, | |||
INT | len | |||
) | [static] |
static void CMath::scale_vector | ( | T | alpha, | |
T * | vec, | |||
INT | len | |||
) | [static] |
static T CMath::sum | ( | T * | vec, | |
INT | len | |||
) | [static] |
static T CMath::max | ( | T * | vec, | |
INT | len | |||
) | [static] |
static T CMath::sum_abs | ( | T * | vec, | |
INT | len | |||
) | [static] |
Definition at line 529 of file Mathematics.h.
Definition at line 540 of file Mathematics.h.
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.
Definition at line 147 of file Mathematics.cpp.
static void CMath::radix_sort | ( | T * | array, | |
size_t | size | |||
) | [static] |
performs a in-place radix sort in ascending order
Definition at line 562 of file Mathematics.h.
static BYTE CMath::byte | ( | T | word, | |
unsigned short | p | |||
) | [static] |
Definition at line 568 of file Mathematics.h.
static void CMath::radix_sort_helper | ( | T * | array, | |
size_t | size, | |||
unsigned short | i | |||
) | [static] |
Definition at line 574 of file Mathematics.h.
static void CMath::insertion_sort | ( | T * | output, | |
INT | size | |||
) | [static] |
performs insertion sort of an array output of length size it is sorted from in ascending (for type T)
Definition at line 674 of file Mathematics.h.
static void CMath::qsort | ( | T * | output, | |
INT | size | |||
) | [static] |
performs a quicksort on an array output of length size it is sorted from in ascending (for type T)
Definition at line 695 of file Mathematics.h.
static void CMath::display_vector | ( | T * | vector, | |
INT | n, | |||
const char * | name = "vector" | |||
) | [static] |
display vector (useful for debugging)
static void CMath::display_matrix | ( | T * | matrix, | |
INT | rows, | |||
INT | cols, | |||
const char * | name = "matrix" | |||
) | [static] |
display matrix (useful for debugging)
void CMath::qsort_index | ( | T1 * | output, | |
T2 * | index, | |||
UINT | 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 1070 of file Mathematics.h.
void * CMath::parallel_qsort_index | ( | void * | p | ) | [static] |
Definition at line 970 of file Mathematics.h.
void CMath::qsort_backward_index | ( | T1 * | output, | |
T2 * | index, | |||
INT | 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 1110 of file Mathematics.h.
Definition at line 1162 of file Mathematics.h.
Definition at line 1151 of file Mathematics.h.
Definition at line 768 of file Mathematics.h.
Definition at line 781 of file Mathematics.h.
Definition at line 810 of file Mathematics.h.
static INT CMath::binary_search_max_lower_equal | ( | T * | output, | |
INT | size, | |||
T | elem | |||
) | [static] |
Definition at line 823 of file Mathematics.h.
align two sequences seq1 & seq2 of length l1 and l2 using gapCost return alignment cost
Definition at line 167 of file Mathematics.cpp.
INT CMath::calcroc | ( | DREAL * | fp, | |
DREAL * | tp, | |||
DREAL * | output, | |||
INT * | label, | |||
INT & | size, | |||
INT & | possize, | |||
INT & | negsize, | |||
DREAL & | 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.
returns the mutual information of p which is given in logspace where p,q are given in logspace
Definition at line 378 of file Mathematics.cpp.
returns the relative entropy H(P||Q), where p,q are given in logspace
Definition at line 389 of file Mathematics.cpp.
static UINT CMath::get_seed | ( | ) | [static] |
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 900 of file Mathematics.h.
Definition at line 458 of file Mathematics.cpp.
Definition at line 468 of file Mathematics.cpp.
Definition at line 478 of file Mathematics.cpp.
Definition at line 488 of file Mathematics.cpp.
Definition at line 498 of file Mathematics.cpp.
Definition at line 508 of file Mathematics.cpp.
Definition at line 524 of file Mathematics.cpp.
const DREAL CMath::INFTY = -log(0.0) [static] |
const DREAL CMath::ALMOST_INFTY = +1e+20 [static] |
Definition at line 946 of file Mathematics.h.
const DREAL CMath::ALMOST_NEG_INFTY = -1000 [static] |
INT CMath::LOGRANGE = 0 [static] |
UINT CMath::seed = 0 [static] |
CHAR * CMath::rand_state = NULL [static] |
Definition at line 966 of file Mathematics.h.
CParallel CSGObject::parallel [static, inherited] |
Definition at line 105 of file SGObject.h.
CIO CSGObject::io [static, inherited] |
Definition at line 106 of file SGObject.h.
CVersion CSGObject::version [static, inherited] |
Definition at line 107 of file SGObject.h.