Public Member Functions | Static Public Member Functions

CMath Class Reference


Detailed Description

Class which collects generic mathematical functions.

Definition at line 135 of file Math.h.

Inheritance diagram for CMath:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual const char * get_name () const
template<>
void display_vector (const uint8_t *vector, int32_t n, const char *name)
template<>
void display_vector (const int32_t *vector, int32_t n, const char *name)
template<>
void display_vector (const int64_t *vector, int32_t n, const char *name)
template<>
void display_vector (const uint64_t *vector, int32_t n, const char *name)
template<>
void display_vector (const float32_t *vector, int32_t n, const char *name)
template<>
void display_vector (const float64_t *vector, int32_t n, const char *name)
template<>
void display_vector (const floatmax_t *vector, int32_t n, const char *name)
template<>
void display_matrix (const int32_t *matrix, int32_t rows, int32_t cols, const char *name)
template<>
void display_matrix (const float64_t *matrix, int32_t rows, int32_t cols, const char *name)
template<>
void display_matrix (const float32_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
static uint32_t get_log_range ()
 returns range of logtable
static int is_finite (double f)
 checks whether a float is finite
static int is_infinity (double f)
 checks whether a float is infinity
static int is_nan (double f)
 checks whether a float is nan
static SGVector< float64_tfishers_exact_test_for_multiple_2x3_tables (SGMatrix< float64_t > tables)
static float64_t fishers_exact_test_for_2x3_table (SGMatrix< float64_t > table)
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 absolute value of a number
misc functions

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 void resize (T *&data, int64_t old_size, int64_t new_size)
template<class T >
static T twonorm (T *x, int32_t len)
 || x ||_2
template<class T >
static T qsq (T *x, int32_t len, float64_t q)
 || x ||_q^q
template<class T >
static T qnorm (T *x, int32_t len, float64_t q)
 || x ||_q
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 floatmax_t sqrt (floatmax_t x)
 x^0.5
static float32_t invsqrt (float32_t x)
 x^-0.5
static floatmax_t powl (floatmax_t x, floatmax_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 exp (float64_t x)
static float64_t lgamma (float64_t x)
static float64_t tgamma (float64_t x)
static float64_t atan (float64_t x)
static floatmax_t lgammal (floatmax_t x)
static float64_t log10 (float64_t v)
static float64_t log2 (float64_t v)
static float64_t log (float64_t v)
static float64_t area_under_curve (float64_t *xy, int32_t len, bool reversed)
template<class T >
static void transpose_matrix (T *&matrix, int32_t &num_feat, int32_t &num_vec)
static float64_tpinv (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)
static float32_t normal_random (float32_t mean, float32_t std_dev)
static float64_t normal_random (float64_t mean, float64_t std_dev)
static float32_t randn_float ()
static float64_t randn_double ()
template<class T >
static T * clone_vector (const T *vec, int32_t len)
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 bool *v1, const bool *v2, int32_t n)
 compute dot product between v1 and v2 (blas optimized)
static floatmax_t dot (const floatmax_t *v1, const floatmax_t *v2, int32_t n)
 compute dot product between v1 and v2 (blas optimized)
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 uint64_t *v1, const uint64_t *v2, int32_t n)
 compute dot product between v1 and v2 (for 64bit unsigned ints)
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 int32_t *v1, const int32_t *v2, int32_t n)
 compute dot product between v1 and v2 (for 32bit ints)
static float64_t dot (const uint32_t *v1, const uint32_t *v2, int32_t n)
 compute dot product between v1 and v2 (for 32bit unsigned 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 int16_t *v1, const int16_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 int8_t *v1, const int8_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 vector_multiply (T *target, const T *v1, const T *v2, int32_t len)
 compute vector multiplication
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))
template<class T >
static bool fequal (T x, T y, float64_t precision=1e-6)
 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, int32_t size)
template<class T >
static uint8_t byte (T word, uint16_t p)
template<class T >
static void radix_sort_helper (T *array, int32_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 qsort (SGVector< T * > array)
template<class T >
static void display_bits (T word, int32_t width=8 *sizeof(T))
 display bits (useful for debugging)
template<class T >
static void display_vector (const T *vector, int32_t n, const char *name="vector")
 display vector (useful for debugging)
template<class T >
static void display_matrix (const 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 qsort_backward_index (T1 *output, T2 *index, int32_t size)
template<class T1 , class T2 >
static void parallel_qsort_index (T1 *output, T2 *index, uint32_t size, int32_t n_threads, int32_t limit=262144)
template<class T1 , class T2 >
static void * parallel_qsort_index (void *p)
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)
static double * compute_eigenvectors (double *matrix, int n, int m)
template<class T >
static T * get_row_sum (T *matrix, int32_t m, int32_t n)
template<class T >
static T * get_column_sum (T *matrix, int32_t m, int32_t n)
template<class T >
static void center_matrix (T *matrix, int32_t m, int32_t n)
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 (SGVector< T * > array, 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)
summing functions

static float64_t logarithmic_sum (float64_t p, float64_t q)

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 const float64_t PI = PI
static const float64_t MACHINE_EPSILON = 5E-16
static const float64_t MAX_REAL_NUMBER = 1E300
static const float64_t MIN_REAL_NUMBER = 1E-300
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

Constructor & Destructor Documentation

CMath (  ) 

Constructor - initializes log-table.

Definition at line 55 of file Math.cpp.

~CMath (  )  [virtual]

Destructor - frees logtable.

Definition at line 75 of file Math.cpp.


Member Function Documentation

static T abs ( a  )  [static]

return the absolute value of a number

Definition at line 181 of file Math.h.

static void add ( T *  target,
alpha,
const T *  v1,
beta,
const T *  v2,
int32_t  len 
) [static]

target=alpha*vec1 + beta*vec2

Definition at line 836 of file Math.h.

static void add_scalar ( alpha,
T *  vec,
int32_t  len 
) [static]

add scalar to vector inplace

Definition at line 846 of file Math.h.

float64_t 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 404 of file Math.cpp.

static float64_t area_under_curve ( float64_t xy,
int32_t  len,
bool  reversed 
) [static]

Definition at line 419 of file Math.h.

static float64_t atan ( float64_t  x  )  [static]
Returns:
arcus tangens of input

Definition at line 386 of file Math.h.

static int32_t binary_search ( T *  output,
int32_t  size,
elem 
) [static]

Definition at line 1366 of file Math.h.

static int32_t binary_search ( SGVector< T * >  array,
T *  elem 
) [static]

Definition at line 1381 of file Math.h.

static int32_t binary_search_helper ( T *  output,
int32_t  size,
elem 
) [static]

Definition at line 1340 of file Math.h.

static int32_t binary_search_max_lower_equal ( T *  output,
int32_t  size,
elem 
) [static]

Definition at line 1411 of file Math.h.

static uint8_t byte ( word,
uint16_t  p 
) [static]

Definition at line 944 of file Math.h.

static float64_t ceil ( float64_t  d  )  [static]

Definition at line 207 of file Math.h.

static void center_matrix ( T *  matrix,
int32_t  m,
int32_t  n 
) [static]

Definition at line 1313 of file Math.h.

static T clamp ( value,
lb,
ub 
) [static]

return the value clamped to interval [lb,ub]

Definition at line 169 of file Math.h.

static T* clone_vector ( const T *  vec,
int32_t  len 
) [static]

Definition at line 607 of file Math.h.

static double* compute_eigenvectors ( double *  matrix,
int  n,
int  m 
) [static]

compute eigenvalues and eigenvectors of symmetric matrix

Parameters:
matrix overwritten and contains n orthonormal eigenvectors
n 
m 
Returns:
eigenvalues (array of length n, to be deleted[])

Definition at line 1257 of file Math.h.

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]

Definition at line 466 of file Math.h.

static void 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 476 of file Math.h.

static void display_bits ( word,
int32_t  width = 8*sizeof(T) 
) [static]

display bits (useful for debugging)

Definition at line 1157 of file Math.h.

static void display_matrix ( const T *  matrix,
int32_t  rows,
int32_t  cols,
const char *  name = "matrix" 
) [static]

display matrix (useful for debugging)

void display_matrix ( const int32_t *  matrix,
int32_t  rows,
int32_t  cols,
const char *  name 
)

Definition at line 158 of file Math.cpp.

void display_matrix ( const float64_t matrix,
int32_t  rows,
int32_t  cols,
const char *  name 
)

Definition at line 175 of file Math.cpp.

void display_matrix ( const float32_t matrix,
int32_t  rows,
int32_t  cols,
const char *  name 
)

Definition at line 192 of file Math.cpp.

static void display_vector ( const T *  vector,
int32_t  n,
const char *  name = "vector" 
) [static]

display vector (useful for debugging)

void display_vector ( const uint64_t *  vector,
int32_t  n,
const char *  name 
)

Definition at line 118 of file Math.cpp.

void display_vector ( const floatmax_t vector,
int32_t  n,
const char *  name 
)

Definition at line 148 of file Math.cpp.

void display_vector ( const uint8_t *  vector,
int32_t  n,
const char *  name 
)

Definition at line 88 of file Math.cpp.

void display_vector ( const int32_t *  vector,
int32_t  n,
const char *  name 
)

Definition at line 98 of file Math.cpp.

void display_vector ( const int64_t *  vector,
int32_t  n,
const char *  name 
)

Definition at line 108 of file Math.cpp.

void display_vector ( const float32_t vector,
int32_t  n,
const char *  name 
)

Definition at line 128 of file Math.cpp.

void display_vector ( const float64_t vector,
int32_t  n,
const char *  name 
)

Definition at line 138 of file Math.cpp.

static float64_t 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 792 of file Math.h.

static float64_t dot ( const int8_t *  v1,
const int8_t *  v2,
int32_t  n 
) [static]

compute dot product between v1 and v2 (for 8bit (un)signed ints)

Definition at line 803 of file Math.h.

static float64_t dot ( const float64_t v1,
const char *  v2,
int32_t  n 
) [static]

compute dot product between v1 and v2

Definition at line 814 of file Math.h.

static float64_t dot ( const int16_t *  v1,
const int16_t *  v2,
int32_t  n 
) [static]

compute dot product between v1 and v2 (for 16bit unsigned ints)

Definition at line 770 of file Math.h.

static float64_t dot ( const int32_t *  v1,
const int32_t *  v2,
int32_t  n 
) [static]

compute dot product between v1 and v2 (for 32bit ints)

Definition at line 737 of file Math.h.

static float64_t 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 726 of file Math.h.

static float64_t 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 759 of file Math.h.

static float64_t dot ( const bool *  v1,
const bool *  v2,
int32_t  n 
) [static]

compute dot product between v1 and v2 (blas optimized)

Definition at line 668 of file Math.h.

static floatmax_t dot ( const floatmax_t v1,
const floatmax_t v2,
int32_t  n 
) [static]

compute dot product between v1 and v2 (blas optimized)

Definition at line 677 of file Math.h.

static float64_t dot ( const float64_t v1,
const float64_t v2,
int32_t  n 
) [static]

compute dot product between v1 and v2 (blas optimized)

Definition at line 687 of file Math.h.

static float64_t dot ( const uint64_t *  v1,
const uint64_t *  v2,
int32_t  n 
) [static]

compute dot product between v1 and v2 (for 64bit unsigned ints)

Definition at line 716 of file Math.h.

static float32_t dot ( const float32_t v1,
const float32_t v2,
int32_t  n 
) [static]

compute dot product between v1 and v2 (blas optimized)

Definition at line 701 of file Math.h.

static float64_t dot ( const uint32_t *  v1,
const uint32_t *  v2,
int32_t  n 
) [static]

compute dot product between v1 and v2 (for 32bit unsigned ints)

Definition at line 748 of file Math.h.

static float64_t 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 781 of file Math.h.

float64_t entropy ( float64_t p,
int32_t  len 
) [static]

returns entropy of p which is given in logspace

Definition at line 468 of file Math.cpp.

static float64_t exp ( float64_t  x  )  [static]

Definition at line 368 of file Math.h.

static int64_t factorial ( int32_t  n  )  [static]

Definition at line 487 of file Math.h.

static bool fequal ( x,
y,
float64_t  precision = 1e-6 
) [static]

return sum(abs(vec))

Definition at line 897 of file Math.h.

static void fill_vector ( T *  vec,
int32_t  len,
value 
) [static]

Definition at line 616 of file Math.h.

float64_t fishers_exact_test_for_2x3_table ( SGMatrix< float64_t table  )  [static]

fisher's test for 2x3 table

Parameters:
table 

Definition at line 224 of file Math.cpp.

SGVector< float64_t > fishers_exact_test_for_multiple_2x3_tables ( SGMatrix< float64_t tables  )  [static]

fisher's test for multiple 2x3 tables

Parameters:
tables 

Definition at line 210 of file Math.cpp.

static float64_t floor ( float64_t  d  )  [static]

Definition at line 202 of file Math.h.

static T* get_column_sum ( T *  matrix,
int32_t  m,
int32_t  n 
) [static]

Definition at line 1299 of file Math.h.

static uint32_t get_log_range (  )  [static]

returns range of logtable

Definition at line 1450 of file Math.h.

virtual const char* get_name (  )  const [virtual]
Returns:
object name

Implements CSGObject.

Definition at line 1589 of file Math.h.

static T* get_row_sum ( T *  matrix,
int32_t  m,
int32_t  n 
) [static]

Definition at line 1285 of file Math.h.

static uint32_t get_seed (  )  [static]

returns number generator seed

Definition at line 1444 of file Math.h.

static void init_random ( uint32_t  initseed = 0  )  [static]

Definition at line 495 of file Math.h.

static void 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 1051 of file Math.h.

static float32_t invsqrt ( float32_t  x  )  [static]

x^-0.5

Definition at line 307 of file Math.h.

static int is_finite ( double  f  )  [static]

checks whether a float is finite

Definition at line 1464 of file Math.h.

static int is_infinity ( double  f  )  [static]

checks whether a float is infinity

Definition at line 1474 of file Math.h.

static int is_nan ( double  f  )  [static]

checks whether a float is nan

Definition at line 1487 of file Math.h.

static float64_t lgamma ( float64_t  x  )  [static]
Returns:
natural logarithm of the gamma function of input

Definition at line 374 of file Math.h.

static floatmax_t lgammal ( floatmax_t  x  )  [static]

Definition at line 391 of file Math.h.

static float64_t log ( float64_t  v  )  [static]

Definition at line 414 of file Math.h.

static float64_t log10 ( float64_t  v  )  [static]

Definition at line 400 of file Math.h.

static float64_t log2 ( float64_t  v  )  [static]

Definition at line 405 of file Math.h.

static float64_t logarithmic_sum ( float64_t  p,
float64_t  q 
) [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 1544 of file Math.h.

static T max ( T *  vec,
int32_t  len 
) [static]

return max(vec)

Definition at line 873 of file Math.h.

static T max ( a,
b 
) [static]

return the maximum of two integers

Definition at line 162 of file Math.h.

static float64_t mean ( float64_t vec,
int32_t  len 
) [static]
Deprecated:
use CStatistics::mean() instead

Definition at line 903 of file Math.h.

static T min ( a,
b 
) [static]

return the minimum of two integers

Definition at line 155 of file Math.h.

void min ( float64_t output,
T *  index,
int32_t  size 
) [static]

Definition at line 1831 of file Math.h.

float64_t mutual_info ( float64_t p1,
float64_t p2,
int32_t  len 
) [static]

returns the mutual information of p which is given in logspace where p,q are given in logspace

Definition at line 447 of file Math.cpp.

static int64_t nchoosek ( int32_t  n,
int32_t  k 
) [static]

Definition at line 648 of file Math.h.

void nmin ( float64_t output,
T *  index,
int32_t  size,
int32_t  n 
) [static]

Definition at line 1820 of file Math.h.

static float32_t normal_random ( float32_t  mean,
float32_t  std_dev 
) [static]

Returns a Gaussian or Normal random number. Using the polar form of the Box-Muller transform. http://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform#Polar_form

Definition at line 551 of file Math.h.

static float64_t normal_random ( float64_t  mean,
float64_t  std_dev 
) [static]

Returns a Gaussian or Normal random number. Using the polar form of the Box-Muller transform. http://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform#Polar_form

Definition at line 574 of file Math.h.

static void parallel_qsort_index ( T1 *  output,
T2 *  index,
uint32_t  size,
int32_t  n_threads,
int32_t  limit = 262144 
) [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)

parallel version

Definition at line 1208 of file Math.h.

void * parallel_qsort_index ( void *  p  )  [static]

Definition at line 1630 of file Math.h.

float64_t * 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 489 of file Math.cpp.

static int32_t pow ( int32_t  x,
int32_t  n 
) [static]

Definition at line 339 of file Math.h.

static float64_t pow ( float64_t  x,
float64_t  n 
) [static]

Definition at line 363 of file Math.h.

static float64_t pow ( float64_t  x,
int32_t  n 
) [static]

Definition at line 349 of file Math.h.

static floatmax_t powl ( floatmax_t  x,
floatmax_t  n 
) [static]

x^n

Definition at line 328 of file Math.h.

static T qnorm ( T *  x,
int32_t  len,
float64_t  q 
) [static]

|| x ||_q

Definition at line 269 of file Math.h.

static void 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 1070 of file Math.h.

static void qsort ( SGVector< T * >  array  )  [static]

Performs a quicksort on an array of pointers. It is sorted from in ascending (for type T)

Every element is dereferenced once before being compared

Parameters:
array array of pointers to sort

Definition at line 1118 of file Math.h.

void 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 descending order (for type T1) and returns the index (type T2) matlab alike [sorted,index]=sort(output)

Definition at line 1778 of file Math.h.

void 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 1734 of file Math.h.

static T qsq ( T *  x,
int32_t  len,
float64_t  q 
) [static]

|| x ||_q^q

Definition at line 258 of file Math.h.

static void radix_sort ( T *  array,
int32_t  size 
) [static]

performs a in-place radix sort in ascending order

Definition at line 938 of file Math.h.

static void radix_sort_helper ( T *  array,
int32_t  size,
uint16_t  i 
) [static]

Definition at line 950 of file Math.h.

static float64_t randn_double (  )  [static]

Convenience method for generating Standard Normal random numbers Double: Mean = 0 and Standard Deviation = 1

Definition at line 601 of file Math.h.

static float32_t randn_float (  )  [static]

Convenience method for generating Standard Normal random numbers Float: Mean = 0 and Standard Deviation = 1

Definition at line 594 of file Math.h.

static int64_t random (  )  [static]

Definition at line 512 of file Math.h.

static float32_t random ( float32_t  min_value,
float32_t  max_value 
) [static]

Definition at line 528 of file Math.h.

static float64_t random ( float64_t  min_value,
float64_t  max_value 
) [static]

Definition at line 538 of file Math.h.

static int32_t random ( int32_t  min_value,
int32_t  max_value 
) [static]

Definition at line 521 of file Math.h.

static void random_vector ( T *  vec,
int32_t  len,
min_value,
max_value 
) [static]

Definition at line 629 of file Math.h.

static int32_t* randperm ( int32_t  n  )  [static]

Definition at line 635 of file Math.h.

static void range_fill_vector ( T *  vec,
int32_t  len,
start = 0 
) [static]

Definition at line 622 of file Math.h.

float64_t relative_entropy ( float64_t p,
float64_t q,
int32_t  len 
) [static]

returns the relative entropy H(P||Q), where p,q are given in logspace

Definition at line 458 of file Math.cpp.

static void resize ( T *&  data,
int64_t  old_size,
int64_t  new_size 
) [static]

resize array from old_size to new_size (keeping as much array content as possible intact)

Definition at line 234 of file Math.h.

static float64_t round ( float64_t  d  )  [static]

Definition at line 197 of file Math.h.

static void scale_vector ( alpha,
T *  vec,
int32_t  len 
) [static]

scale vector inplace

Definition at line 854 of file Math.h.

static T sign ( a  )  [static]

signum of type T variable a

Definition at line 214 of file Math.h.

void 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 365 of file Math.cpp.

void sort ( float64_t a,
int32_t *  idx,
int32_t  N 
) [static]

Definition at line 385 of file Math.cpp.

static T sq ( x  )  [static]

x^2

Definition at line 277 of file Math.h.

static float64_t sqrt ( float64_t  x  )  [static]

x^0.5

Definition at line 289 of file Math.h.

static float32_t sqrt ( float32_t  x  )  [static]

x^0.5

Definition at line 283 of file Math.h.

static floatmax_t sqrt ( floatmax_t  x  )  [static]

x^0.5

Definition at line 295 of file Math.h.

static T sum ( T *  vec,
int32_t  len 
) [static]

return sum(vec)

Definition at line 862 of file Math.h.

static T sum_abs ( T *  vec,
int32_t  len 
) [static]

return sum(abs(vec))

Definition at line 886 of file Math.h.

static void swap ( T &  a,
T &  b 
) [static]

swap e.g. floats a and b

Definition at line 223 of file Math.h.

static float64_t tgamma ( float64_t  x  )  [static]
Returns:
gamma function of input

Definition at line 380 of file Math.h.

static float64_t trace ( float64_t mat,
int32_t  cols,
int32_t  rows 
) [static]

Definition at line 915 of file Math.h.

static void transpose_matrix ( T *&  matrix,
int32_t &  num_feat,
int32_t &  num_vec 
) [static]

Definition at line 440 of file Math.h.

static T twonorm ( T *  x,
int32_t  len 
) [static]

|| x ||_2

Definition at line 247 of file Math.h.

static int32_t unique ( T *  output,
int32_t  size 
) [static]

Definition at line 1240 of file Math.h.

static void vec1_plus_scalar_times_vec2 ( T *  vec1,
scalar,
const T *  vec2,
int32_t  n 
) [static]

x=x+alpha*y

Definition at line 660 of file Math.h.

static void vector_multiply ( T *  target,
const T *  v1,
const T *  v2,
int32_t  len 
) [static]

compute vector multiplication

Definition at line 826 of file Math.h.


Member Data Documentation

const float64_t ALMOST_INFTY = +1e+20 [static]

Definition at line 1595 of file Math.h.

const float64_t ALMOST_NEG_INFTY = -1000 [static]

almost neg (log) infinity

Definition at line 1598 of file Math.h.

const float64_t INFTY = -log(0.0) [static]

infinity

Definition at line 1594 of file Math.h.

int32_t LOGRANGE = 0 [static, protected]

range for logtable: log(1+exp(x)) -LOGRANGE <= x <= 0

Definition at line 1612 of file Math.h.

const float64_t MACHINE_EPSILON = 5E-16 [static]

machine epsilon for float64_t

Definition at line 1604 of file Math.h.

const float64_t MAX_REAL_NUMBER = 1E300 [static]

Definition at line 1607 of file Math.h.

const float64_t MIN_REAL_NUMBER = 1E-300 [static]

Definition at line 1608 of file Math.h.

const float64_t PI = PI [static]

the number pi

Definition at line 1601 of file Math.h.

char * rand_state = NULL [static, protected]

Definition at line 1616 of file Math.h.

uint32_t seed = 0 [static, protected]

random generator seed

Definition at line 1615 of file Math.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation