SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
List of all members | Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions
CMath Class Reference

Detailed Description

Class which collects generic mathematical functions.

Definition at line 134 of file Math.h.

Inheritance diagram for CMath:
[legend]

Classes

struct  IndexSorter
 

Public Member Functions

virtual const char * get_name () const
 
template<>
float64_tlinspace (complex128_t start, complex128_t end, int32_t n)
 linspace not implemented for complex128_t, returns null instead More...
 
virtual CSGObjectshallow_copy () const
 
virtual CSGObjectdeep_copy () const
 
virtual bool is_generic (EPrimitiveType *generic) const
 
template<class T >
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
void unset_generic ()
 
virtual void print_serializable (const char *prefix="")
 
virtual bool save_serializable (CSerializableFile *file, const char *prefix="")
 
virtual bool load_serializable (CSerializableFile *file, const char *prefix="")
 
void set_global_io (SGIO *io)
 
SGIOget_global_io ()
 
void set_global_parallel (Parallel *parallel)
 
Parallelget_global_parallel ()
 
void set_global_version (Version *version)
 
Versionget_global_version ()
 
SGStringList< char > get_modelsel_names ()
 
void print_modsel_params ()
 
char * get_modsel_param_descr (const char *param_name)
 
index_t get_modsel_param_index (const char *param_name)
 
void build_gradient_parameter_dictionary (CMap< TParameter *, CSGObject * > *dict)
 
bool has (const std::string &name) const
 
template<typename T >
bool has (const Tag< T > &tag) const
 
template<typename T , typename U = void>
bool has (const std::string &name) const
 
template<typename T >
void set (const Tag< T > &_tag, const T &value)
 
template<typename T , typename U = void>
void set (const std::string &name, const T &value)
 
template<typename T >
get (const Tag< T > &_tag) const
 
template<typename T , typename U = void>
get (const std::string &name) const
 
virtual void update_parameter_hash ()
 
virtual bool parameter_hash_changed ()
 
virtual bool equals (CSGObject *other, float64_t accuracy=0.0, bool tolerant=false)
 
virtual CSGObjectclone ()
 
Constructor/Destructor.
 CMath ()
 Constructor - initializes log-table. More...
 
virtual ~CMath ()
 Destructor - frees logtable. More...
 

Static Public Member Functions

template<class T >
static T min (T *vec, int32_t len)
 
template<class T >
static T max (T *vec, int32_t len)
 
template<class T >
static T clamp (T value, T lb, T ub)
 
template<class T >
static int32_t arg_max (T *vec, int32_t inc, int32_t len, T *maxv_ptr=NULL)
 
template<class T >
static int32_t arg_min (T *vec, int32_t inc, int32_t len, T *minv_ptr=NULL)
 
static float64_t exp (float64_t x)
 
static float64_t dot (const bool *v1, const bool *v2, int32_t n)
 Compute dot product between v1 and v2 (blas optimized) More...
 
static floatmax_t dot (const floatmax_t *v1, const floatmax_t *v2, int32_t n)
 Compute dot product between v1 and v2 (blas optimized) More...
 
static float64_t dot (const float64_t *v1, const float64_t *v2, int32_t n)
 Compute dot product between v1 and v2 (blas optimized) More...
 
static float32_t dot (const float32_t *v1, const float32_t *v2, int32_t n)
 Compute dot product between v1 and v2 (blas optimized) More...
 
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) More...
 
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) More...
 
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) More...
 
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) More...
 
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) More...
 
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) More...
 
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) More...
 
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) More...
 
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) More...
 
static float64_t dot (const float64_t *v1, const char *v2, int32_t n)
 Compute dot product between v1 and v2. More...
 
static float64_t area_under_curve (float64_t *xy, int32_t len, bool reversed)
 
static bool strtof (const char *str, float32_t *float_result)
 
static bool strtod (const char *str, float64_t *double_result)
 
static bool strtold (const char *str, floatmax_t *long_double_result)
 
static int64_t factorial (int32_t n)
 
template<class T >
static void permute (SGVector< T > v, CRandom *rand=NULL)
 
template<class T >
static int32_t get_num_nonzero (T *vec, int32_t len)
 
static int32_t get_num_nonzero (complex128_t *vec, int32_t len)
 
static int64_t nchoosek (int32_t n, int32_t k)
 
static void linspace (float64_t *output, float64_t start, float64_t end, int32_t n=100)
 
template<class T >
static float64_tlinspace (T start, T end, int32_t n)
 
template<class T >
static SGVector< float64_tlinspace_vec (T start, T end, int32_t n)
 
template<class T >
static T log_sum_exp (SGVector< T > values)
 
template<class T >
static T log_mean_exp (SGVector< T > values)
 
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 qsort (T *output, int32_t size)
 
template<class T >
static void insertion_sort (T *output, int32_t size)
 
template<class T >
static void radix_sort (T *array, int32_t size)
 
template<class T >
static uint8_t byte (T word, uint16_t p)
 
static uint8_t byte (complex128_t word, uint16_t p)
 byte not implemented for complex128_t More...
 
template<class T >
static void radix_sort_helper (T *array, int32_t size, uint16_t i)
 
static void radix_sort_helper (complex128_t *array, int32_t size, uint16_t i)
 radix_sort_helper not implemented for complex128_t More...
 
template<class T >
static void qsort (T **vector, index_t length)
 
static void qsort (complex128_t **vector, index_t length)
 qsort not implemented for complex128_t More...
 
template<class T >
static void qsort (SGVector< T > vector)
 
template<class T >
static SGVector< index_targsort (SGVector< T > vector)
 
template<class T >
static bool is_sorted (SGVector< T > vector)
 
template<class T >
static void display_bits (T word, int32_t width=8 *sizeof(T))
 
static void display_bits (complex128_t word, int32_t width=8 *sizeof(complex128_t))
 disply_bits not implemented for complex128_t More...
 
template<class T1 , class T2 >
static void qsort_index (T1 *output, T2 *index, uint32_t size)
 
template<class T >
static void qsort_index (complex128_t *output, T *index, uint32_t size)
 qsort_index not implemented for complex128_t More...
 
template<class T1 , class T2 >
static void qsort_backward_index (T1 *output, T2 *index, int32_t size)
 
template<class T >
static void qsort_backword_index (complex128_t *output, T *index, uint32_t size)
 qsort_backword_index not implemented for complex128_t More...
 
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 T >
static void parallel_qsort_index (complex128_t *output, T *index, uint32_t size, int32_t n_threads, int32_t limit=0)
 parallel_qsort_index not implemented for complex128_t More...
 
template<class T1 , class T2 >
static void * parallel_qsort_index (void *p)
 helper function for parallel_qsort_index. More...
 
template<class T >
static void min (float64_t *output, T *index, int32_t size)
 
static void min (float64_t *output, complex128_t *index, int32_t size)
 complex128_t cannot be used as index More...
 
template<class T >
static void nmin (float64_t *output, T *index, int32_t size, int32_t n)
 
static void nmin (float64_t *output, complex128_t *index, int32_t size, int32_t n)
 complex128_t cannot be used as index More...
 
template<class T >
static int32_t binary_search_helper (T *output, int32_t size, T elem)
 
static int32_t binary_search_helper (complex128_t *output, int32_t size, complex128_t elem)
 binary_search_helper not implemented for complex128_t More...
 
template<class T >
static int32_t binary_search (T *output, int32_t size, T elem)
 
static int32_t binary_search (complex128_t *output, int32_t size, complex128_t elem)
 binary_search not implemented for complex128_t More...
 
template<class T >
static int32_t binary_search (T **vector, index_t length, T *elem)
 
static int32_t binary_search (complex128_t **vector, index_t length, complex128_t *elem)
 binary_search not implemented for complex128_t More...
 
template<class T >
static int32_t binary_search_max_lower_equal (T *output, int32_t size, T elem)
 
static int32_t binary_search_max_lower_equal (complex128_t *output, int32_t size, complex128_t elem)
 binary_search_max_lower_equal not implemented for complex128_t More...
 
static float64_t Align (char *seq1, char *seq2, int32_t l1, int32_t l2, float64_t gapCost)
 
static float64_t real (complex128_t c)
 
static float64_t imag (complex128_t c)
 
static uint32_t get_seed ()
 returns number generator seed More...
 
static uint32_t get_log_range ()
 returns range of logtable More...
 
static int is_finite (double f)
 checks whether a float is finite More...
 
static int is_infinity (double f)
 checks whether a float is infinity More...
 
static int is_nan (double f)
 checks whether a float is nan More...
 
min/max/abs functions.
template<class T >
static T min (T a, T b)
 
template<class T >
static T max (T a, T b)
 
template<class T >
static T abs (T a)
 
static float64_t abs (complex128_t a)
 
misc functions
template<class T >
static bool fequals_abs (const T &a, const T &b, const float64_t eps)
 
template<class T >
static bool fequals (const T &a, const T &b, const float64_t eps, bool tolerant=false)
 
static float64_t get_abs_tolerance (float64_t true_value, float64_t rel_tolerance)
 
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)
 
template<class T >
static void swap (T &a, T &b)
 
template<class T >
static T sq (T x)
 
static float32_t sqrt (float32_t x)
 
static float64_t sqrt (float64_t x)
 
static floatmax_t sqrt (floatmax_t x)
 
static float32_t invsqrt (float32_t x)
 x^0.5, x being a complex128_t More...
 
Exponential methods (x^n)
static floatmax_t powl (floatmax_t x, floatmax_t n)
 
static int32_t pow (bool x, int32_t 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 complex128_t pow (complex128_t x, int32_t n)
 
static complex128_t pow (complex128_t x, complex128_t n)
 
static complex128_t pow (complex128_t x, float64_t n)
 
static complex128_t pow (float64_t x, complex128_t n)
 
Trignometric and Hyperbolic Functions

exp(x), x being a complex128_t

static float64_t tan (float64_t x)
 
static float64_t atan (float64_t x)
 tan(x), x being a complex128_t More...
 
static float64_t atan2 (float64_t y, float64_t x)
 atan(x), x being a complex128_t not implemented More...
 
static float64_t tanh (float64_t x)
 atan2(x), x being a complex128_t not implemented More...
 
static float64_t sin (float64_t x)
 tanh(x), x being a complex128_t More...
 
static float64_t asin (float64_t x)
 sin(x), x being a complex128_t More...
 
static float64_t sinh (float64_t x)
 asin(x), x being a complex128_t not implemented More...
 
static float64_t cos (float64_t x)
 sinh(x), x being a complex128_t More...
 
static float64_t acos (float64_t x)
 cos(x), x being a complex128_t More...
 
static float64_t cosh (float64_t x)
 acos(x), x being a complex128_t not implemented More...
 
Logarithmic functions

cosh(x), x being a complex128_t

static float64_t log10 (float64_t v)
 
static float64_t log2 (float64_t v)
 log10(x), x being a complex128_t More...
 
static float64_t log (float64_t v)
 
static index_t floor_log (index_t n)
 log(x), x being a complex128_t More...
 
Random Functions
static void init_random (uint32_t initseed=0)
 
static uint64_t random ()
 
static uint64_t random (uint64_t min_value, uint64_t max_value)
 
static int64_t random (int64_t min_value, int64_t max_value)
 
static uint32_t random (uint32_t min_value, uint32_t max_value)
 
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 floatmax_t random (floatmax_t min_value, floatmax_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 ()
 
summing functions
static float64_t logarithmic_sum (float64_t p, float64_t q)
 

Public Attributes

SGIOio
 
Parallelparallel
 
Versionversion
 
Parameterm_parameters
 
Parameterm_model_selection_parameters
 
Parameterm_gradient_parameters
 
uint32_t m_hash
 

Protected Member Functions

virtual void load_serializable_pre () throw (ShogunException)
 
virtual void load_serializable_post () throw (ShogunException)
 
virtual void save_serializable_pre () throw (ShogunException)
 
virtual void save_serializable_post () throw (ShogunException)
 
template<typename T >
void register_param (Tag< T > &_tag, const T &value)
 
template<typename T >
void register_param (const std::string &name, const T &value)
 

constants

static const float64_t NOT_A_NUMBER = NAN
 not a number More...
 
static const float64_t INFTY = INFINITY
 infinity More...
 
static const float64_t ALMOST_INFTY = +1e+300
 
static const float64_t ALMOST_NEG_INFTY = -1e+300
 almost neg (log) infinity More...
 
static const float64_t PI =M_PI
 
static const float64_t MACHINE_EPSILON =DBL_EPSILON
 
static const float64_t MAX_REAL_NUMBER =DBL_MAX
 
static const float64_t MIN_REAL_NUMBER =DBL_MIN
 
static const float32_t F_MAX_VAL32 =FLT_MAX
 
static const float32_t F_MIN_NORM_VAL32 =FLT_MIN
 
static const float64_t F_MAX_VAL64 =DBL_MAX
 
static const float64_t F_MIN_NORM_VAL64 =DBL_MIN
 
static const float32_t F_MIN_VAL32 =(FLT_MIN * FLT_EPSILON)
 
static const float64_t F_MIN_VAL64 =(DBL_MIN * DBL_EPSILON)
 
static int32_t LOGRANGE = 0
 range for logtable: log(1+exp(x)) -LOGRANGE <= x <= 0 More...
 
static uint32_t seed = 0
 random generator seed More...
 

Constructor & Destructor Documentation

CMath ( )

Constructor - initializes log-table.

Definition at line 65 of file Math.cpp.

~CMath ( )
virtual

Destructor - frees logtable.

Definition at line 82 of file Math.cpp.

Member Function Documentation

static T abs ( a)
static

Returns the absolute value of a number, that is if a>0, output is a; if a<0 ,output is -a

Parameters
acomplex number
Returns
the corresponding absolute value

Definition at line 179 of file Math.h.

static float64_t abs ( complex128_t  a)
static

Returns the absolute value of a complex number

Parameters
acomplex number
Returns
the corresponding absolute value

Definition at line 195 of file Math.h.

static float64_t acos ( float64_t  x)
static

cos(x), x being a complex128_t

Computes arc cosine of input

Parameters
xinput
Returns
arccos(x)

Definition at line 868 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

Parameters
seq1first sequence
seq2second sequence
l1length of first sequence
l2length of second sequence
gapCost
Returns
alignment cost

Definition at line 178 of file Math.cpp.

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

Computes area under the curve

Parameters
xy
lenlength
reversedboolean
Returns
area

Definition at line 946 of file Math.h.

static int32_t arg_max ( T *  vec,
int32_t  inc,
int32_t  len,
T *  maxv_ptr = NULL 
)
static

Returns the index of the maximum value

Parameters
vecinput vector
incincrement factor
lenlength of the input vector
maxv_ptrpointer to store the maximum value
Returns
index of the maximum value

Definition at line 262 of file Math.h.

static int32_t arg_min ( T *  vec,
int32_t  inc,
int32_t  len,
T *  minv_ptr = NULL 
)
static

Returns the index of the minimum value

Parameters
vecinput vector
incincrement factor
lenlength of the input vector
minv_ptrpointer to store the minimum value
Returns
index of the minimum value

Definition at line 289 of file Math.h.

static SGVector<index_t> argsort ( SGVector< T >  vector)
static

Get sorted index.

idx = v.argsort() is similar to Matlab [~, idx] = sort(v)

Parameters
vectorvector to be sorted
Returns
sorted index for this vector

Definition at line 1599 of file Math.h.

static float64_t asin ( float64_t  x)
static

sin(x), x being a complex128_t

Computes arc sine of input

Parameters
xinput
Returns
arcsin(x)

Definition at line 832 of file Math.h.

static float64_t atan ( float64_t  x)
static

tan(x), x being a complex128_t

Computes arc tangent of input

Parameters
xinput
Returns
arctan(x)

Definition at line 783 of file Math.h.

static float64_t atan2 ( float64_t  y,
float64_t  x 
)
static

atan(x), x being a complex128_t not implemented

Computes arc tangent with 2 parameters

Parameters
yinput(numerator)
xinput(denominator)
Returns
arctan(y/x)

Definition at line 796 of file Math.h.

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

Finds an element in a sorted array via binary search

Parameters
outputarray to search
sizesize of array
elemelement to search
Returns
-1 if not found

Definition at line 1809 of file Math.h.

static int32_t binary_search ( complex128_t output,
int32_t  size,
complex128_t  elem 
)
static

binary_search not implemented for complex128_t

Definition at line 1818 of file Math.h.

static int32_t binary_search ( T **  vector,
index_t  length,
T *  elem 
)
static

Finds an element in a sorted array of pointers via binary search Every element is dereferenced once before being compared

Parameters
vectorarray of pointers to search in (assumed being sorted)
lengthlength of array
elempointer to element to search for
Returns
index of elem, -1 if not found

Definition at line 1833 of file Math.h.

static int32_t binary_search ( complex128_t **  vector,
index_t  length,
complex128_t elem 
)
static

binary_search not implemented for complex128_t

Definition at line 1864 of file Math.h.

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

Finds an element in a sorted array via binary search returns -1 if not found

Definition at line 1772 of file Math.h.

static int32_t binary_search_helper ( complex128_t output,
int32_t  size,
complex128_t  elem 
)
static

binary_search_helper not implemented for complex128_t

Definition at line 1796 of file Math.h.

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

Finds greatest element which is less than or equal to the searched element (query).

Parameters
outputarray to search
sizesize of the array
elemelement that needs to be searched

Definition at line 1877 of file Math.h.

static int32_t binary_search_max_lower_equal ( complex128_t output,
int32_t  size,
complex128_t  elem 
)
static

binary_search_max_lower_equal not implemented for complex128_t

Definition at line 1890 of file Math.h.

void build_gradient_parameter_dictionary ( CMap< TParameter *, CSGObject * > *  dict)
inherited

Builds a dictionary of all parameters in SGObject as well of those of SGObjects that are parameters of this object. Dictionary maps parameters to the objects that own them.

Parameters
dictdictionary of parameters to be built.

Definition at line 630 of file SGObject.cpp.

static uint8_t byte ( word,
uint16_t  p 
)
static

Extract the byte at position p (from left) of a 64 bit integer. The function is somewhat identical to accessing an array of characters via [].

Parameters
wordinput from which byte is extracted
pposition
Returns
byte

Definition at line 1391 of file Math.h.

static uint8_t byte ( complex128_t  word,
uint16_t  p 
)
static

byte not implemented for complex128_t

Definition at line 1397 of file Math.h.

static float64_t ceil ( float64_t  d)
static

The value of x rounded upward (as a floating-point value)

Parameters
dinput decimal value
Returns
rounded off value

Definition at line 416 of file Math.h.

static T clamp ( value,
lb,
ub 
)
static

Returns the value clamped to interval [lb,ub]

Parameters
valueinput value
lblower bound
ubupper bound
Returns
the corresponding clamped value

Definition at line 244 of file Math.h.

CSGObject * clone ( )
virtualinherited

Creates a clone of the current object. This is done via recursively traversing all parameters, which corresponds to a deep copy. Calling equals on the cloned object always returns true although none of the memory of both objects overlaps.

Returns
an identical copy of the given object, which is disjoint in memory. NULL if the clone fails. Note that the returned object is SG_REF'ed

Definition at line 747 of file SGObject.cpp.

static float64_t cos ( float64_t  x)
static

sinh(x), x being a complex128_t

Computes cosine of input

Parameters
xinput
Returns
cos(x)

Definition at line 856 of file Math.h.

static float64_t cosh ( float64_t  x)
static

acos(x), x being a complex128_t not implemented

Computes hyperbolic cosine of input

Parameters
xinput
Returns
cosh(x)

Definition at line 880 of file Math.h.

CSGObject * deep_copy ( ) const
virtualinherited

A deep copy. All the instance variables will also be copied.

Definition at line 231 of file SGObject.cpp.

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

Display bits (useful for debugging)

Parameters
wordinput to be displayed as bits
widthnumber of bits displayed

Definition at line 1635 of file Math.h.

static void display_bits ( complex128_t  word,
int32_t  width = 8*sizeof(complex128_t) 
)
static

disply_bits not implemented for complex128_t

Definition at line 1654 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 627 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 636 of file Math.h.

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

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

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 652 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 662 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 673 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 684 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 695 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 706 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 717 of file Math.h.

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 728 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 739 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 750 of file Math.h.

bool equals ( CSGObject other,
float64_t  accuracy = 0.0,
bool  tolerant = false 
)
virtualinherited

Recursively compares the current SGObject to another one. Compares all registered numerical parameters, recursion upon complex (SGObject) parameters. Does not compare pointers!

May be overwritten but please do with care! Should not be necessary in most cases.

Parameters
otherobject to compare with
accuracyaccuracy to use for comparison (optional)
tolerantallows linient check on float equality (within accuracy)
Returns
true if all parameters were equal, false if not

Definition at line 651 of file SGObject.cpp.

static float64_t exp ( float64_t  x)
static

Computes e^x where e=2.71828 approx.

Parameters
xexponent

Definition at line 621 of file Math.h.

static int64_t factorial ( int32_t  n)
static

Computes factorial of input

Parameters
ninput
Returns
factorial of n (n!)

Definition at line 991 of file Math.h.

static bool fequals ( const T &  a,
const T &  b,
const float64_t  eps,
bool  tolerant = false 
)
static

Compares the value of two floats (handles special cases, such as NaN, Inf etc.) Note: returns true if a == b == NAN Implementation inspired by http://floating-point-gui.de/errors/comparison/

Parameters
afirst value to compare
bsecond value to compare
epsthreshold for values to be equal/different
tolerantallows linient check on float equality (within accuracy)
Returns
true if values are equal within eps accuracy, false if not.

Definition at line 335 of file Math.h.

static bool fequals_abs ( const T &  a,
const T &  b,
const float64_t  eps 
)
static

Compares the value of two floats based on eps only

Parameters
afirst value to compare
bsecond value to compare
epsthreshold for values to be equal/different
Returns
true if values are equal within eps accuracy, false if not.

Definition at line 318 of file Math.h.

static float64_t floor ( float64_t  d)
static

The value of x rounded downward (as a floating-point value)

Parameters
dinput decimal value
Returns
rounded off value

Definition at line 407 of file Math.h.

static index_t floor_log ( index_t  n)
static

log(x), x being a complex128_t

Definition at line 930 of file Math.h.

T get ( const Tag< T > &  _tag) const
inherited

Getter for a class parameter, identified by a Tag. Throws an exception if the class does not have such a parameter.

Parameters
_tagname and type information of parameter
Returns
value of the parameter identified by the input tag

Definition at line 367 of file SGObject.h.

T get ( const std::string &  name) const
inherited

Getter for a class parameter, identified by a name. Throws an exception if the class does not have such a parameter.

Parameters
namename of the parameter
Returns
value of the parameter corresponding to the input name and type

Definition at line 388 of file SGObject.h.

float64_t get_abs_tolerance ( float64_t  true_value,
float64_t  rel_tolerance 
)
static

Definition at line 381 of file Math.cpp.

SGIO * get_global_io ( )
inherited

get the io object

Returns
io object

Definition at line 268 of file SGObject.cpp.

Parallel * get_global_parallel ( )
inherited

get the parallel object

Returns
parallel object

Definition at line 310 of file SGObject.cpp.

Version * get_global_version ( )
inherited

get the version object

Returns
version object

Definition at line 323 of file SGObject.cpp.

static uint32_t get_log_range ( )
static

returns range of logtable

Definition at line 1937 of file Math.h.

SGStringList< char > get_modelsel_names ( )
inherited
Returns
vector of names of all parameters which are registered for model selection

Definition at line 531 of file SGObject.cpp.

char * get_modsel_param_descr ( const char *  param_name)
inherited

Returns description of a given parameter string, if it exists. SG_ERROR otherwise

Parameters
param_namename of the parameter
Returns
description of the parameter

Definition at line 555 of file SGObject.cpp.

index_t get_modsel_param_index ( const char *  param_name)
inherited

Returns index of model selection parameter with provided index

Parameters
param_namename of model selection parameter
Returns
index of model selection parameter with provided name, -1 if there is no such

Definition at line 568 of file SGObject.cpp.

virtual const char* get_name ( ) const
virtual
Returns
object name

Implements CSGObject.

Definition at line 2041 of file Math.h.

static int32_t get_num_nonzero ( T *  vec,
int32_t  len 
)
static

Computes sum of non-zero elements

Parameters
vecvector
lenlength
Returns
non-zero sum

Definition at line 1164 of file Math.h.

static int32_t get_num_nonzero ( complex128_t vec,
int32_t  len 
)
static

Computes sum of non-zero elements

Parameters
vecvector of complex numbers
lenlength
Returns
non-zero sum

Definition at line 1178 of file Math.h.

static uint32_t get_seed ( )
static

returns number generator seed

Definition at line 1931 of file Math.h.

bool has ( const std::string &  name) const
inherited

Checks if object has a class parameter identified by a name.

Parameters
namename of the parameter
Returns
true if the parameter exists with the input name

Definition at line 289 of file SGObject.h.

bool has ( const Tag< T > &  tag) const
inherited

Checks if object has a class parameter identified by a Tag.

Parameters
tagtag of the parameter containing name and type information
Returns
true if the parameter exists with the input tag

Definition at line 301 of file SGObject.h.

bool has ( const std::string &  name) const
inherited

Checks if a type exists for a class parameter identified by a name.

Parameters
namename of the parameter
Returns
true if the parameter exists with the input name and type

Definition at line 312 of file SGObject.h.

static float64_t imag ( complex128_t  c)
static

Returns imaginary part of a complex128_t number

Parameters
ccomplex number
Returns
imaginary part of the complex number

Definition at line 1925 of file Math.h.

static void init_random ( uint32_t  initseed = 0)
static

Initiates seed for pseudo random generator

Parameters
initseedvalue of seed

Definition at line 1006 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)

Parameters
outputarray to be sorted
sizesize of array

Definition at line 1358 of file Math.h.

static float32_t invsqrt ( float32_t  x)
static

x^0.5, x being a complex128_t

Computes inverse square-root of the input

Parameters
xinput value
Returns
x^-0.5

Definition at line 495 of file Math.h.

int is_finite ( double  f)
static

checks whether a float is finite

Definition at line 266 of file Math.cpp.

bool is_generic ( EPrimitiveType *  generic) const
virtualinherited

If the SGSerializable is a class template then TRUE will be returned and GENERIC is set to the type of the generic.

Parameters
genericset to the type of the generic if returning TRUE
Returns
TRUE if a class template.

Definition at line 329 of file SGObject.cpp.

int is_infinity ( double  f)
static

checks whether a float is infinity

Definition at line 247 of file Math.cpp.

int is_nan ( double  f)
static

checks whether a float is nan

Definition at line 234 of file Math.cpp.

static bool is_sorted ( SGVector< T >  vector)
static

Check if vector is sorted

Parameters
vectorinput vector
Returns
true if vector is sorted, false otherwise

Definition at line 1617 of file Math.h.

void linspace ( float64_t output,
float64_t  start,
float64_t  end,
int32_t  n = 100 
)
static

Builds an array with n linearly spaced elements between start and end.

Parameters
outputarray with linearly spaced elements within the interval
startbeginning of the interval to divide
endupper bound of the interval to divide
nnumber of elements used to divide the interval

Definition at line 221 of file Math.cpp.

static float64_t* linspace ( start,
end,
int32_t  n 
)
static

Returns an array with n linearly spaced elements between start and end.

Parameters
startbeginning of the interval to divide
endupper bound of the interval to divide
nnumber of elements used to divide the interval
Returns
array with linearly spaced elements within the interval

Definition at line 1216 of file Math.h.

float64_t* linspace ( complex128_t  start,
complex128_t  end,
int32_t  n 
)

linspace not implemented for complex128_t, returns null instead

Definition at line 2322 of file Math.h.

static SGVector<float64_t> linspace_vec ( start,
end,
int32_t  n 
)
static

Returns a vector with n linearly spaced elements between start and end.

Parameters
startbeginning of the interval to divide
endupper bound of the interval to divide
nnumber of elements used to divide the interval
Returns
vector with linearly spaced elements within the interval

Definition at line 1231 of file Math.h.

bool load_serializable ( CSerializableFile file,
const char *  prefix = "" 
)
virtualinherited

Load this object from file. If it will fail (returning FALSE) then this object will contain inconsistent data and should not be used!

Parameters
filewhere to load from
prefixprefix for members
Returns
TRUE if done, otherwise FALSE

Definition at line 402 of file SGObject.cpp.

void load_serializable_post ( )
throw (ShogunException
)
protectedvirtualinherited

Can (optionally) be overridden to post-initialize some member variables which are not PARAMETER::ADD'ed. Make sure that at first the overridden method BASE_CLASS::LOAD_SERIALIZABLE_POST is called.

Exceptions
ShogunExceptionwill be thrown if an error occurs.

Reimplemented in CKernel, CWeightedDegreePositionStringKernel, CList, CAlphabet, CLinearHMM, CGaussianKernel, CInverseMultiQuadricKernel, CCircularKernel, and CExponentialKernel.

Definition at line 459 of file SGObject.cpp.

void load_serializable_pre ( )
throw (ShogunException
)
protectedvirtualinherited

Can (optionally) be overridden to pre-initialize some member variables which are not PARAMETER::ADD'ed. Make sure that at first the overridden method BASE_CLASS::LOAD_SERIALIZABLE_PRE is called.

Exceptions
ShogunExceptionwill be thrown if an error occurs.

Reimplemented in CDynamicArray< T >, CDynamicArray< float64_t >, CDynamicArray< float32_t >, CDynamicArray< int32_t >, CDynamicArray< char >, CDynamicArray< bool >, and CDynamicObjectArray.

Definition at line 454 of file SGObject.cpp.

static float64_t log ( float64_t  v)
static

Computes natural logarithm input

Parameters
vinput
Returns
log base e of v or ln(v)

Definition at line 922 of file Math.h.

static float64_t log10 ( float64_t  v)
static

Computes logarithm base 10 of input

Parameters
vinput
Returns
log base 10 of v

Definition at line 897 of file Math.h.

static float64_t log2 ( float64_t  v)
static

log10(x), x being a complex128_t

Computes logarithm base 2 of input

Parameters
vinput
Returns
log base 2 of v

Definition at line 909 of file Math.h.

static T log_mean_exp ( SGVector< T >  values)
static

Computes \(\log(\frac{1}{n}\sum_{i=1}^n \exp(x_i))\) for given \(x_i\) using the log-sum-exp trick which avoids numerical problems.

Parameters
valuesthe vector of \(x_i\)
Returns
\(\log(\frac{1}{n}\sum_{i=1}^n \exp(x_i))\)

Definition at line 1285 of file Math.h.

static T log_sum_exp ( SGVector< T >  values)
static

Computes \(\log(\sum_{i=1}^n \exp(x_i))\) for given \(x_i\) using the log-sum-exp trick which avoids numerical problems.

Parameters
valuesthe vector of \(x_i\)
Returns
\(\log(\sum_{i=1}^n \exp(x_i))\) for given \(x_i\)

Definition at line 1242 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 1996 of file Math.h.

static T max ( a,
b 
)
static

Returns the greatest element amongst two input values

Parameters
afirst value
bsecond value
Returns
maximum value amongst a and b

Definition at line 168 of file Math.h.

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

Returns the greatest element in the vector

Parameters
vecinput vector
lenlength of vector
Returns
maximum value in the vector

Definition at line 226 of file Math.h.

static T min ( a,
b 
)
static

Returns the smallest element amongst two input values

Parameters
afirst value
bsecond value
Returns
minimum value amongst a and b

Definition at line 157 of file Math.h.

static T min ( T *  vec,
int32_t  len 
)
static

Returns the smallest element in the vector

Parameters
vecinput vector
lenlength of vector
Returns
minimum value in the vector

Definition at line 209 of file Math.h.

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

Finds the smallest element in output and puts that element as the first element

Parameters
outputelement array
indexindex array
sizesize of arrays

Definition at line 2302 of file Math.h.

static void min ( float64_t output,
complex128_t index,
int32_t  size 
)
static

complex128_t cannot be used as index

Definition at line 1747 of file Math.h.

static int64_t nchoosek ( int32_t  n,
int32_t  k 
)
static

Computes binomial coefficient or all possible combinations of n items taken k at a time.

Parameters
ntotal number of items
knumber of items to be chosen

Definition at line 1191 of file Math.h.

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

Finds the n smallest elements in output and puts these elements as the first n elements

Definition at line 2291 of file Math.h.

static void nmin ( float64_t output,
complex128_t index,
int32_t  size,
int32_t  n 
)
static

complex128_t cannot be used as index

Definition at line 1760 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 1095 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 1118 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

Parameters
outputinput array
indexindex array
sizesize of the array
n_threadsnumber of threads
limitsort limit

Definition at line 1711 of file Math.h.

static void parallel_qsort_index ( complex128_t output,
T *  index,
uint32_t  size,
int32_t  n_threads,
int32_t  limit = 0 
)
static

parallel_qsort_index not implemented for complex128_t

Definition at line 1726 of file Math.h.

void * parallel_qsort_index ( void *  p)
static

helper function for parallel_qsort_index.

Definition at line 2093 of file Math.h.

bool parameter_hash_changed ( )
virtualinherited
Returns
whether parameter combination has changed since last update

Definition at line 295 of file SGObject.cpp.

static void permute ( SGVector< T >  v,
CRandom rand = NULL 
)
static

Permute randomly the elements of the vector. If provided, use the random object to generate the permutations.

Parameters
vthe vector to permute.
randrandom object that might be used to generate the permutations.

Definition at line 1144 of file Math.h.

static int32_t pow ( bool  x,
int32_t  n 
)
static

Definition at line 535 of file Math.h.

static int32_t pow ( int32_t  x,
int32_t  n 
)
static
Parameters
xbase (integer)
nexponent (integer)

Definition at line 544 of file Math.h.

static float64_t pow ( float64_t  x,
int32_t  n 
)
static
Parameters
xbase (decimal)
nexponent (integer)

Definition at line 558 of file Math.h.

static float64_t pow ( float64_t  x,
float64_t  n 
)
static
Parameters
xbase (decimal)
nexponent (decimal)

Definition at line 576 of file Math.h.

static complex128_t pow ( complex128_t  x,
int32_t  n 
)
static
Parameters
xbase (complex)
nexponent (integer)

Definition at line 585 of file Math.h.

static complex128_t pow ( complex128_t  x,
complex128_t  n 
)
static
Parameters
xbase (complex)
nexponent (complex)

Definition at line 594 of file Math.h.

static complex128_t pow ( complex128_t  x,
float64_t  n 
)
static
Parameters
xbase (complex)
nexponent (decimal)

Definition at line 603 of file Math.h.

static complex128_t pow ( float64_t  x,
complex128_t  n 
)
static
Parameters
xbase (decimal)
nexponent (complex)

Definition at line 612 of file Math.h.

static floatmax_t powl ( floatmax_t  x,
floatmax_t  n 
)
static

Computes x raised to the power n

Parameters
xbase
nexponent
Returns
x^n

Definition at line 524 of file Math.h.

void print_modsel_params ( )
inherited

prints all parameter registered for model selection and their type

Definition at line 507 of file SGObject.cpp.

void print_serializable ( const char *  prefix = "")
virtualinherited

prints registered parameters out

Parameters
prefixprefix for members

Definition at line 341 of file SGObject.cpp.

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)

Parameters
outputarray to be sorted
sizesize of array

Definition at line 1313 of file Math.h.

static void qsort ( T **  vector,
index_t  length 
)
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
vectorarray of pointers to sort
lengthlength of array

Definition at line 1520 of file Math.h.

static void qsort ( complex128_t **  vector,
index_t  length 
)
static

qsort not implemented for complex128_t

Definition at line 1559 of file Math.h.

static void qsort ( SGVector< T >  vector)
static

Quicksort the vector in ascending order (for type T)

Parameters
vectorvector to be sorted

Definition at line 1568 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)

Parameters
outputarray to be sorted
indexindex array
sizesize of array

Definition at line 2246 of file Math.h.

static void qsort_backword_index ( complex128_t output,
T *  index,
uint32_t  size 
)
static

qsort_backword_index not implemented for complex128_t

Definition at line 1692 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)

Parameters
outputarray to be sorted
indexindex array
sizesize of arrays

Definition at line 2202 of file Math.h.

static void qsort_index ( complex128_t output,
T *  index,
uint32_t  size 
)
static

qsort_index not implemented for complex128_t

Definition at line 1673 of file Math.h.

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

Performs a in-place radix sort in ascending order

Parameters
arrayarray to be sorted
sizesize of array

Definition at line 1378 of file Math.h.

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

Helper function for radix sort.

Parameters
arrayarray to be sorted
sizesize of array
iindex

Definition at line 1409 of file Math.h.

static void radix_sort_helper ( complex128_t array,
int32_t  size,
uint16_t  i 
)
static

radix_sort_helper not implemented for complex128_t

Definition at line 1508 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 1132 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 1125 of file Math.h.

static uint64_t random ( )
static

Returns random number

Returns
unsigned 64 bit integer

Definition at line 1019 of file Math.h.

static uint64_t random ( uint64_t  min_value,
uint64_t  max_value 
)
static

Returns random number

Returns
unsigned 64 bit integer

Definition at line 1027 of file Math.h.

static int64_t random ( int64_t  min_value,
int64_t  max_value 
)
static

Returns random number between minimum and maximum value

Parameters
min_valueminimum value (64 bit integer)
max_valuemaximum value (64 bit integer)
Returns
signed 64 bit integer

Definition at line 1037 of file Math.h.

static uint32_t random ( uint32_t  min_value,
uint32_t  max_value 
)
static

Returns random number between minimum and maximum value

Parameters
min_valueminimum value (32 bit unsigned integer)
max_valuemaximum value (32 bit unsigned integer)
Returns
unsigned 32 bit integer

Definition at line 1047 of file Math.h.

static int32_t random ( int32_t  min_value,
int32_t  max_value 
)
static

Returns random number between minimum and maximum value

Parameters
min_valueminimum value (32 bit signed integer)
max_valuemaximum value (32 bit signed integer)
Returns
signed 32 bit integer

Definition at line 1057 of file Math.h.

static float32_t random ( float32_t  min_value,
float32_t  max_value 
)
static

Returns random number between minimum and maximum value

Parameters
min_valueminimum value (32 bit float)
max_valuemaximum value (32 bit float)
Returns
32 bit float

Definition at line 1067 of file Math.h.

static float64_t random ( float64_t  min_value,
float64_t  max_value 
)
static

Returns random number between minimum and maximum value

Parameters
min_valueminimum value (64 bit float)
max_valuemaximum value (64 bit float)
Returns
64 bit float

Definition at line 1077 of file Math.h.

static floatmax_t random ( floatmax_t  min_value,
floatmax_t  max_value 
)
static

Returns random number between minimum and maximum value

Parameters
min_valueminimum value (128 bit float)
max_valuemaximum value (128 bit float)
Returns
128 bit float

Definition at line 1087 of file Math.h.

static float64_t real ( complex128_t  c)
static

Returns real part of a complex128_t number

Parameters
ccomplex number
Returns
real part of the complex number

Definition at line 1916 of file Math.h.

void register_param ( Tag< T > &  _tag,
const T &  value 
)
protectedinherited

Registers a class parameter which is identified by a tag. This enables the parameter to be modified by set() and retrieved by get(). Parameters can be registered in the constructor of the class.

Parameters
_tagname and type information of parameter
valuevalue of the parameter

Definition at line 439 of file SGObject.h.

void register_param ( const std::string &  name,
const T &  value 
)
protectedinherited

Registers a class parameter which is identified by a name. This enables the parameter to be modified by set() and retrieved by get(). Parameters can be registered in the constructor of the class.

Parameters
namename of the parameter
valuevalue of the parameter along with type information

Definition at line 452 of file SGObject.h.

static float64_t round ( float64_t  d)
static

Rounds off the input value to it's nearest integer (as a floating-point value)

Parameters
dinput decimal value
Returns
rounded off value

Definition at line 398 of file Math.h.

bool save_serializable ( CSerializableFile file,
const char *  prefix = "" 
)
virtualinherited

Save this object to file.

Parameters
filewhere to save the object; will be closed during returning if PREFIX is an empty string.
prefixprefix for members
Returns
TRUE if done, otherwise FALSE

Definition at line 347 of file SGObject.cpp.

void save_serializable_post ( )
throw (ShogunException
)
protectedvirtualinherited

Can (optionally) be overridden to post-initialize some member variables which are not PARAMETER::ADD'ed. Make sure that at first the overridden method BASE_CLASS::SAVE_SERIALIZABLE_POST is called.

Exceptions
ShogunExceptionwill be thrown if an error occurs.

Reimplemented in CKernel.

Definition at line 469 of file SGObject.cpp.

void save_serializable_pre ( )
throw (ShogunException
)
protectedvirtualinherited

Can (optionally) be overridden to pre-initialize some member variables which are not PARAMETER::ADD'ed. Make sure that at first the overridden method BASE_CLASS::SAVE_SERIALIZABLE_PRE is called.

Exceptions
ShogunExceptionwill be thrown if an error occurs.

Reimplemented in CKernel, CDynamicArray< T >, CDynamicArray< float64_t >, CDynamicArray< float32_t >, CDynamicArray< int32_t >, CDynamicArray< char >, CDynamicArray< bool >, and CDynamicObjectArray.

Definition at line 464 of file SGObject.cpp.

void set ( const Tag< T > &  _tag,
const T &  value 
)
inherited

Setter for a class parameter, identified by a Tag. Throws an exception if the class does not have such a parameter.

Parameters
_tagname and type information of parameter
valuevalue of the parameter

Definition at line 328 of file SGObject.h.

void set ( const std::string &  name,
const T &  value 
)
inherited

Setter for a class parameter, identified by a name. Throws an exception if the class does not have such a parameter.

Parameters
namename of the parameter
valuevalue of the parameter along with type information

Definition at line 354 of file SGObject.h.

void set_generic ( )
inherited

Definition at line 74 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 79 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 84 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 89 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 94 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 99 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 104 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 109 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 114 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 119 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 124 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 129 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 134 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 139 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 144 of file SGObject.cpp.

void set_generic ( )
inherited

set generic type to T

void set_global_io ( SGIO io)
inherited

set the io object

Parameters
ioio object to use

Definition at line 261 of file SGObject.cpp.

void set_global_parallel ( Parallel parallel)
inherited

set the parallel object

Parameters
parallelparallel object to use

Definition at line 274 of file SGObject.cpp.

void set_global_version ( Version version)
inherited

set the version object

Parameters
versionversion object to use

Definition at line 316 of file SGObject.cpp.

CSGObject * shallow_copy ( ) const
virtualinherited

A shallow copy. All the SGObject instance variables will be simply assigned and SG_REF-ed.

Reimplemented in CGaussianKernel.

Definition at line 225 of file SGObject.cpp.

static T sign ( a)
static

Signum of input value

Parameters
ainput value
Returns
1 if a>0, -1 if a<0

Definition at line 426 of file Math.h.

static float64_t sin ( float64_t  x)
static

tanh(x), x being a complex128_t

Computes sine of input

Parameters
xinput
Returns
sin(x)

Definition at line 820 of file Math.h.

static float64_t sinh ( float64_t  x)
static

asin(x), x being a complex128_t not implemented

Computes hyperbolic sine of input

Parameters
xinput
Returns
sinh(x)

Definition at line 844 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

Parameters
amatrix to be sorted
colsnumber of columns
sort_col

Definition at line 139 of file Math.cpp.

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

Performs a bubblesort on a given array a. it is sorted in ascending order from left to right

Parameters
aarray to be sorted
idxindex array
Nlength of array

Definition at line 159 of file Math.cpp.

static T sq ( x)
static

Computes square of the input

Parameters
xinput value
Returns
x*x (x^2)

Definition at line 450 of file Math.h.

static float32_t sqrt ( float32_t  x)
static

Computes square-root of the input

Parameters
xinput value
Returns
x^0.5

Definition at line 459 of file Math.h.

static float64_t sqrt ( float64_t  x)
static

Computes square-root of the input

Parameters
xinput value
Returns
x^0.5

Definition at line 468 of file Math.h.

static floatmax_t sqrt ( floatmax_t  x)
static

Computes square-root of the input

Parameters
xinput value
Returns
x^0.5

Definition at line 477 of file Math.h.

bool strtod ( const char *  str,
float64_t double_result 
)
static

Converts string to double

Parameters
strinput string
double_resultdouble pointer
Returns
returns true if successful, else returns false

Definition at line 312 of file Math.cpp.

bool strtof ( const char *  str,
float32_t float_result 
)
static

Converts string to float

Parameters
strinput string
float_resultfloat pointer
Returns
returns true if successful, else returns false

Definition at line 281 of file Math.cpp.

bool strtold ( const char *  str,
floatmax_t long_double_result 
)
static

Converts string to long double

Parameters
strinput string
long_double_resultlong double pointer
Returns
returns true if successful, else returns false

Definition at line 343 of file Math.cpp.

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

Swaps a and b

Parameters
afirst input value
bsecond input value

Definition at line 438 of file Math.h.

static float64_t tan ( float64_t  x)
static

Computes tangent of input

Parameters
xinput
Returns
tan(x)

Definition at line 771 of file Math.h.

static float64_t tanh ( float64_t  x)
static

atan2(x), x being a complex128_t not implemented

Computes hyperbolic tangent of input

Parameters
xinput
Returns
tanh(x)

Definition at line 808 of file Math.h.

void unset_generic ( )
inherited

unset generic type

this has to be called in classes specializing a template class

Definition at line 336 of file SGObject.cpp.

void update_parameter_hash ( )
virtualinherited

Updates the hash of current parameter combination

Definition at line 281 of file SGObject.cpp.

Member Data Documentation

const float64_t ALMOST_INFTY = +1e+300
static

Definition at line 2049 of file Math.h.

const float64_t ALMOST_NEG_INFTY = -1e+300
static

almost neg (log) infinity

Definition at line 2052 of file Math.h.

const float32_t F_MAX_VAL32 =FLT_MAX
static

Definition at line 2065 of file Math.h.

const float64_t F_MAX_VAL64 =DBL_MAX
static

Definition at line 2067 of file Math.h.

const float32_t F_MIN_NORM_VAL32 =FLT_MIN
static

Definition at line 2066 of file Math.h.

const float64_t F_MIN_NORM_VAL64 =DBL_MIN
static

Definition at line 2068 of file Math.h.

const float32_t F_MIN_VAL32 =(FLT_MIN * FLT_EPSILON)
static

Definition at line 2071 of file Math.h.

const float64_t F_MIN_VAL64 =(DBL_MIN * DBL_EPSILON)
static

Definition at line 2072 of file Math.h.

const float64_t INFTY = INFINITY
static

infinity

Definition at line 2048 of file Math.h.

SGIO* io
inherited

io

Definition at line 537 of file SGObject.h.

int32_t LOGRANGE = 0
staticprotected

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

Definition at line 2076 of file Math.h.

Parameter* m_gradient_parameters
inherited

parameters wrt which we can compute gradients

Definition at line 552 of file SGObject.h.

uint32_t m_hash
inherited

Hash of parameter values

Definition at line 555 of file SGObject.h.

Parameter* m_model_selection_parameters
inherited

model selection parameters

Definition at line 549 of file SGObject.h.

Parameter* m_parameters
inherited

parameters

Definition at line 546 of file SGObject.h.

const float64_t MACHINE_EPSILON =DBL_EPSILON
static

Machine epsilon for float64_t

Definition at line 2058 of file Math.h.

const float64_t MAX_REAL_NUMBER =DBL_MAX
static

Definition at line 2061 of file Math.h.

const float64_t MIN_REAL_NUMBER =DBL_MIN
static

Definition at line 2062 of file Math.h.

const float64_t NOT_A_NUMBER = NAN
static

not a number

Definition at line 2046 of file Math.h.

Parallel* parallel
inherited

parallel

Definition at line 540 of file SGObject.h.

const float64_t PI =M_PI
static

The number pi

Definition at line 2055 of file Math.h.

uint32_t seed = 0
staticprotected

random generator seed

Definition at line 2079 of file Math.h.

Version* version
inherited

version

Definition at line 543 of file SGObject.h.


The documentation for this class was generated from the following files:

SHOGUN Machine Learning Toolbox - Documentation