SHOGUN  6.1.3
List of all members | Classes | Public Types | 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 114 of file Math.h.

Inheritance diagram for CMath:
[legend]

Classes

struct  IndexSorter
 

Public Types

typedef rxcpp::subjects::subject< ObservedValueSGSubject
 
typedef rxcpp::observable< ObservedValue, rxcpp::dynamic_observable< ObservedValue > > SGObservable
 
typedef rxcpp::subscriber< ObservedValue, rxcpp::observer< ObservedValue, void, void, void, void > > SGSubscriber
 

Public Member Functions

virtual const char * get_name () const
 
int32_t ref ()
 
int32_t ref_count ()
 
int32_t unref ()
 
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
 
SGObservableget_parameters_observable ()
 
void subscribe_to_parameters (ParameterObserverInterface *obs)
 
void list_observable_parameters ()
 
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 , class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
static T clamp (T value, T lb, T ub)
 
template<class T , class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
static int32_t arg_max (T *vec, int32_t inc, int32_t len, T *maxv_ptr=NULL)
 
template<class T , class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
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 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)
 
static int32_t gcd (int32_t a, int32_t b)
 
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 , class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
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 , class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
static void qsort (T *output, int32_t size)
 
template<class T , class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
static void insertion_sort (T *output, int32_t size)
 
template<class T , class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
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 , class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
static void qsort (T **vector, index_t length)
 
template<class T , class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
static void qsort (SGVector< T > vector)
 
template<class T , class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
static SGVector< index_targsort (SGVector< T > vector)
 
template<class T , class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
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 , class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
static T min (T a, T b)
 
template<class T , class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
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 , class = typename std::enable_if<std::is_floating_point<T>::value>::type>
static bool fequals_abs (const T &a, const T &b, const float64_t eps)
 
template<class T , class = typename std::enable_if<std::is_floating_point<T>::value>::type>
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)
 
template<class T >
static T sqrt (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)
 
bool clone_parameters (CSGObject *other)
 
void observe (const ObservedValue value)
 
void register_observable_param (const std::string &name, const SG_OBS_VALUE_TYPE type, const std::string &description)
 

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...
 

Member Typedef Documentation

◆ SGObservable

Definition at line 130 of file SGObject.h.

◆ SGSubject

Definition at line 127 of file SGObject.h.

◆ SGSubscriber

typedef rxcpp::subscriber< ObservedValue, rxcpp::observer<ObservedValue, void, void, void, void> > SGSubscriber
inherited

Definition at line 133 of file SGObject.h.

Constructor & Destructor Documentation

◆ CMath()

CMath ( )

Constructor - initializes log-table.

Definition at line 59 of file Math.cpp.

◆ ~CMath()

~CMath ( )
virtual

Destructor - frees logtable.

Definition at line 76 of file Math.cpp.

Member Function Documentation

◆ abs() [1/2]

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

◆ abs() [2/2]

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

◆ acos()

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

◆ Align()

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

◆ area_under_curve()

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

◆ arg_max()

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

◆ arg_min()

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

◆ argsort()

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

◆ asin()

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

◆ atan()

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

◆ atan2()

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

◆ binary_search() [1/4]

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

◆ binary_search() [2/4]

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

◆ binary_search() [3/4]

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

◆ binary_search() [4/4]

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

◆ binary_search_helper() [1/2]

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

◆ binary_search_helper() [2/2]

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

◆ binary_search_max_lower_equal() [1/2]

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

◆ binary_search_max_lower_equal() [2/2]

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

◆ build_gradient_parameter_dictionary()

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 635 of file SGObject.cpp.

◆ byte() [1/2]

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

◆ byte() [2/2]

static uint8_t byte ( complex128_t  word,
uint16_t  p 
)
static

byte not implemented for complex128_t

Definition at line 1219 of file Math.h.

◆ ceil()

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

◆ clamp()

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

◆ clone()

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

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

Definition at line 734 of file SGObject.cpp.

◆ clone_parameters()

bool clone_parameters ( CSGObject other)
protectedinherited

Definition at line 759 of file SGObject.cpp.

◆ cos()

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

◆ cosh()

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

◆ deep_copy()

CSGObject * deep_copy ( ) const
virtualinherited

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

Definition at line 232 of file SGObject.cpp.

◆ display_bits() [1/2]

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

◆ display_bits() [2/2]

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

◆ equals()

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 656 of file SGObject.cpp.

◆ exp()

static float64_t exp ( float64_t  x)
static

Computes e^x where e=2.71828 approx.

Parameters
xexponent

Definition at line 551 of file Math.h.

◆ factorial()

static int64_t factorial ( int32_t  n)
static

Computes factorial of input

Parameters
ninput
Returns
factorial of n (n!)

Definition at line 783 of file Math.h.

◆ fequals()

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

◆ fequals_abs()

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

◆ floor()

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

◆ floor_log()

static index_t floor_log ( index_t  n)
static

log(x), x being a complex128_t

Definition at line 722 of file Math.h.

◆ gcd()

static int32_t gcd ( int32_t  a,
int32_t  b 
)
static

Implements the greatest common divisor (gcd) via modulo operations. Requires that either a>0 and b>=0 or vice versa.

Parameters
afirst number
bsecond number
Returns
gcd between the two numbers

Definition at line 937 of file Math.h.

◆ get() [1/2]

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 381 of file SGObject.h.

◆ get() [2/2]

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 404 of file SGObject.h.

◆ get_abs_tolerance()

float64_t get_abs_tolerance ( float64_t  true_value,
float64_t  rel_tolerance 
)
static

Definition at line 325 of file Math.cpp.

◆ get_global_io()

SGIO * get_global_io ( )
inherited

get the io object

Returns
io object

Definition at line 269 of file SGObject.cpp.

◆ get_global_parallel()

Parallel * get_global_parallel ( )
inherited

get the parallel object

Returns
parallel object

Definition at line 311 of file SGObject.cpp.

◆ get_global_version()

Version * get_global_version ( )
inherited

get the version object

Returns
version object

Definition at line 324 of file SGObject.cpp.

◆ get_log_range()

static uint32_t get_log_range ( )
static

returns range of logtable

Definition at line 1757 of file Math.h.

◆ get_modelsel_names()

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

Definition at line 536 of file SGObject.cpp.

◆ get_modsel_param_descr()

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 560 of file SGObject.cpp.

◆ get_modsel_param_index()

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 573 of file SGObject.cpp.

◆ get_name()

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

Implements CSGObject.

Definition at line 1861 of file Math.h.

◆ get_num_nonzero() [1/2]

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

◆ get_num_nonzero() [2/2]

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

◆ get_parameters_observable()

SGObservable* get_parameters_observable ( )
inherited

Get parameters observable

Returns
RxCpp observable

Definition at line 415 of file SGObject.h.

◆ get_seed()

static uint32_t get_seed ( )
static

returns number generator seed

Definition at line 1751 of file Math.h.

◆ has() [1/3]

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 304 of file SGObject.h.

◆ has() [2/3]

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 315 of file SGObject.h.

◆ has() [3/3]

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 326 of file SGObject.h.

◆ imag()

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

◆ init_random()

static void init_random ( uint32_t  initseed = 0)
static

Initiates seed for pseudo random generator

Parameters
initseedvalue of seed

Definition at line 798 of file Math.h.

◆ insertion_sort()

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

◆ invsqrt()

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

◆ is_finite()

int is_finite ( double  f)
static

checks whether a float is finite

Definition at line 220 of file Math.cpp.

◆ is_generic()

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 330 of file SGObject.cpp.

◆ is_infinity()

int is_infinity ( double  f)
static

checks whether a float is infinity

Definition at line 215 of file Math.cpp.

◆ is_nan()

int is_nan ( double  f)
static

checks whether a float is nan

Definition at line 210 of file Math.cpp.

◆ is_sorted()

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

◆ linspace() [1/2]

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

◆ linspace() [2/2]

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

◆ linspace_vec()

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

◆ list_observable_parameters()

void list_observable_parameters ( )
inherited

Print to stdout a list of observable parameters

Definition at line 878 of file SGObject.cpp.

◆ load_serializable()

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 403 of file SGObject.cpp.

◆ load_serializable_post()

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 460 of file SGObject.cpp.

◆ load_serializable_pre()

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 455 of file SGObject.cpp.

◆ log()

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

◆ log10()

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

◆ log2()

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

◆ log_mean_exp()

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

◆ log_sum_exp()

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

◆ logarithmic_sum()

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

◆ max() [1/2]

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

◆ max() [2/2]

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

◆ min() [1/4]

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

◆ min() [2/4]

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

◆ min() [3/4]

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

◆ min() [4/4]

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

complex128_t cannot be used as index

Definition at line 1567 of file Math.h.

◆ nchoosek()

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

◆ nmin() [1/2]

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

◆ nmin() [2/2]

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

◆ normal_random() [1/2]

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

◆ normal_random() [2/2]

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

◆ observe()

void observe ( const ObservedValue  value)
protectedinherited

Observe a parameter value and emit them to observer.

Parameters
valueObserved parameter's value

Definition at line 828 of file SGObject.cpp.

◆ parallel_qsort_index() [1/3]

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

◆ parallel_qsort_index() [2/3]

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

◆ parallel_qsort_index() [3/3]

void * parallel_qsort_index ( void *  p)
static

helper function for parallel_qsort_index.

Definition at line 1913 of file Math.h.

◆ parameter_hash_changed()

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

Definition at line 296 of file SGObject.cpp.

◆ permute()

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

◆ pow() [1/8]

static int32_t pow ( bool  x,
int32_t  n 
)
static

Definition at line 474 of file Math.h.

◆ pow() [2/8]

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

Definition at line 483 of file Math.h.

◆ pow() [3/8]

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

Definition at line 497 of file Math.h.

◆ pow() [4/8]

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

Definition at line 506 of file Math.h.

◆ pow() [5/8]

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

Definition at line 515 of file Math.h.

◆ pow() [6/8]

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

Definition at line 524 of file Math.h.

◆ pow() [7/8]

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

Definition at line 533 of file Math.h.

◆ pow() [8/8]

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

Definition at line 542 of file Math.h.

◆ powl()

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

◆ print_modsel_params()

void print_modsel_params ( )
inherited

prints all parameter registered for model selection and their type

Definition at line 512 of file SGObject.cpp.

◆ print_serializable()

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

prints registered parameters out

Parameters
prefixprefix for members

Definition at line 342 of file SGObject.cpp.

◆ qsort() [1/3]

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

◆ qsort() [2/3]

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

◆ qsort() [3/3]

static void qsort ( SGVector< T >  vector)
static

Quicksort the vector in ascending order (for type T)

Parameters
vectorvector to be sorted

Definition at line 1385 of file Math.h.

◆ qsort_backward_index()

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

◆ qsort_backword_index()

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

◆ qsort_index() [1/2]

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

◆ qsort_index() [2/2]

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

qsort_index not implemented for complex128_t

Definition at line 1493 of file Math.h.

◆ radix_sort()

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

◆ radix_sort_helper() [1/2]

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

◆ radix_sort_helper() [2/2]

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

◆ randn_double()

static float64_t randn_double ( )
static

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

Definition at line 924 of file Math.h.

◆ randn_float()

static float32_t randn_float ( )
static

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

Definition at line 917 of file Math.h.

◆ random() [1/8]

static uint64_t random ( )
static

Returns random number

Returns
unsigned 64 bit integer

Definition at line 811 of file Math.h.

◆ random() [2/8]

static uint64_t random ( uint64_t  min_value,
uint64_t  max_value 
)
static

Returns random number

Returns
unsigned 64 bit integer

Definition at line 819 of file Math.h.

◆ random() [3/8]

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

◆ random() [4/8]

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

◆ random() [5/8]

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

◆ random() [6/8]

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

◆ random() [7/8]

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

◆ random() [8/8]

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

◆ real()

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

◆ ref()

int32_t ref ( )
inherited

increase reference counter

Returns
reference count

Definition at line 186 of file SGObject.cpp.

◆ ref_count()

int32_t ref_count ( )
inherited

display reference counter

Returns
reference count

Definition at line 193 of file SGObject.cpp.

◆ register_observable_param()

void register_observable_param ( const std::string &  name,
const SG_OBS_VALUE_TYPE  type,
const std::string &  description 
)
protectedinherited

Register which params this object can emit.

Parameters
namethe param name
typethe param type
descriptiona user oriented description

Definition at line 871 of file SGObject.cpp.

◆ register_param() [1/2]

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 472 of file SGObject.h.

◆ register_param() [2/2]

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 485 of file SGObject.h.

◆ round()

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

◆ save_serializable()

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 348 of file SGObject.cpp.

◆ save_serializable_post()

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 470 of file SGObject.cpp.

◆ save_serializable_pre()

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 465 of file SGObject.cpp.

◆ set() [1/2]

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 342 of file SGObject.h.

◆ set() [2/2]

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 368 of file SGObject.h.

◆ set_generic() [1/16]

void set_generic ( )
inherited

Definition at line 73 of file SGObject.cpp.

◆ set_generic() [2/16]

void set_generic ( )
inherited

Definition at line 78 of file SGObject.cpp.

◆ set_generic() [3/16]

void set_generic ( )
inherited

Definition at line 83 of file SGObject.cpp.

◆ set_generic() [4/16]

void set_generic ( )
inherited

Definition at line 88 of file SGObject.cpp.

◆ set_generic() [5/16]

void set_generic ( )
inherited

Definition at line 93 of file SGObject.cpp.

◆ set_generic() [6/16]

void set_generic ( )
inherited

Definition at line 98 of file SGObject.cpp.

◆ set_generic() [7/16]

void set_generic ( )
inherited

Definition at line 103 of file SGObject.cpp.

◆ set_generic() [8/16]

void set_generic ( )
inherited

Definition at line 108 of file SGObject.cpp.

◆ set_generic() [9/16]

void set_generic ( )
inherited

Definition at line 113 of file SGObject.cpp.

◆ set_generic() [10/16]

void set_generic ( )
inherited

Definition at line 118 of file SGObject.cpp.

◆ set_generic() [11/16]

void set_generic ( )
inherited

Definition at line 123 of file SGObject.cpp.

◆ set_generic() [12/16]

void set_generic ( )
inherited

Definition at line 128 of file SGObject.cpp.

◆ set_generic() [13/16]

void set_generic ( )
inherited

Definition at line 133 of file SGObject.cpp.

◆ set_generic() [14/16]

void set_generic ( )
inherited

Definition at line 138 of file SGObject.cpp.

◆ set_generic() [15/16]

void set_generic ( )
inherited

Definition at line 143 of file SGObject.cpp.

◆ set_generic() [16/16]

void set_generic ( )
inherited

set generic type to T

◆ set_global_io()

void set_global_io ( SGIO io)
inherited

set the io object

Parameters
ioio object to use

Definition at line 262 of file SGObject.cpp.

◆ set_global_parallel()

void set_global_parallel ( Parallel parallel)
inherited

set the parallel object

Parameters
parallelparallel object to use

Definition at line 275 of file SGObject.cpp.

◆ set_global_version()

void set_global_version ( Version version)
inherited

set the version object

Parameters
versionversion object to use

Definition at line 317 of file SGObject.cpp.

◆ shallow_copy()

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 226 of file SGObject.cpp.

◆ sign()

static T sign ( a)
static

Signum of input value

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

Definition at line 394 of file Math.h.

◆ sin()

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

◆ sinh()

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

◆ sort() [1/2]

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

◆ sort() [2/2]

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

◆ sq()

static T sq ( x)
static

Computes square of the input

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

Definition at line 418 of file Math.h.

◆ sqrt()

static T sqrt ( x)
static

Computes square-root of the input

Parameters
xinput value
Returns
x^0.5

Definition at line 428 of file Math.h.

◆ strtod()

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

◆ strtof()

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

◆ strtold()

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

◆ subscribe_to_parameters()

void subscribe_to_parameters ( ParameterObserverInterface obs)
inherited

Subscribe a parameter observer to watch over params

Definition at line 811 of file SGObject.cpp.

◆ swap()

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

Swaps a and b

Parameters
afirst input value
bsecond input value

Definition at line 406 of file Math.h.

◆ tan()

static float64_t tan ( float64_t  x)
static

Computes tangent of input

Parameters
xinput
Returns
tan(x)

Definition at line 567 of file Math.h.

◆ tanh()

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

◆ unref()

int32_t unref ( )
inherited

decrement reference counter and deallocate object if refcount is zero before or after decrementing it

Returns
reference count

Definition at line 200 of file SGObject.cpp.

◆ unset_generic()

void unset_generic ( )
inherited

unset generic type

this has to be called in classes specializing a template class

Definition at line 337 of file SGObject.cpp.

◆ update_parameter_hash()

void update_parameter_hash ( )
virtualinherited

Updates the hash of current parameter combination

Definition at line 282 of file SGObject.cpp.

Member Data Documentation

◆ ALMOST_INFTY

const float64_t ALMOST_INFTY = +1e+300
static

Definition at line 1869 of file Math.h.

◆ ALMOST_NEG_INFTY

const float64_t ALMOST_NEG_INFTY = -1e+300
static

almost neg (log) infinity

Definition at line 1872 of file Math.h.

◆ F_MAX_VAL32

const float32_t F_MAX_VAL32 =FLT_MAX
static

Definition at line 1885 of file Math.h.

◆ F_MAX_VAL64

const float64_t F_MAX_VAL64 =DBL_MAX
static

Definition at line 1887 of file Math.h.

◆ F_MIN_NORM_VAL32

const float32_t F_MIN_NORM_VAL32 =FLT_MIN
static

Definition at line 1886 of file Math.h.

◆ F_MIN_NORM_VAL64

const float64_t F_MIN_NORM_VAL64 =DBL_MIN
static

Definition at line 1888 of file Math.h.

◆ F_MIN_VAL32

const float32_t F_MIN_VAL32 =(FLT_MIN * FLT_EPSILON)
static

Definition at line 1891 of file Math.h.

◆ F_MIN_VAL64

const float64_t F_MIN_VAL64 =(DBL_MIN * DBL_EPSILON)
static

Definition at line 1892 of file Math.h.

◆ INFTY

const float64_t INFTY = INFINITY
static

infinity

Definition at line 1868 of file Math.h.

◆ io

SGIO* io
inherited

io

Definition at line 600 of file SGObject.h.

◆ LOGRANGE

int32_t LOGRANGE = 0
staticprotected

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

Definition at line 1896 of file Math.h.

◆ m_gradient_parameters

Parameter* m_gradient_parameters
inherited

parameters wrt which we can compute gradients

Definition at line 615 of file SGObject.h.

◆ m_hash

uint32_t m_hash
inherited

Hash of parameter values

Definition at line 618 of file SGObject.h.

◆ m_model_selection_parameters

Parameter* m_model_selection_parameters
inherited

model selection parameters

Definition at line 612 of file SGObject.h.

◆ m_parameters

Parameter* m_parameters
inherited

parameters

Definition at line 609 of file SGObject.h.

◆ MACHINE_EPSILON

const float64_t MACHINE_EPSILON =DBL_EPSILON
static

Machine epsilon for float64_t

Definition at line 1878 of file Math.h.

◆ MAX_REAL_NUMBER

const float64_t MAX_REAL_NUMBER =DBL_MAX
static

Definition at line 1881 of file Math.h.

◆ MIN_REAL_NUMBER

const float64_t MIN_REAL_NUMBER =DBL_MIN
static

Definition at line 1882 of file Math.h.

◆ NOT_A_NUMBER

const float64_t NOT_A_NUMBER = NAN
static

not a number

Definition at line 1866 of file Math.h.

◆ parallel

Parallel* parallel
inherited

parallel

Definition at line 603 of file SGObject.h.

◆ PI

const float64_t PI =M_PI
static

The number pi

Definition at line 1875 of file Math.h.

◆ seed

uint32_t seed = 0
staticprotected

random generator seed

Definition at line 1899 of file Math.h.

◆ version

Version* version
inherited

version

Definition at line 606 of file SGObject.h.


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

SHOGUN Machine Learning Toolbox - Documentation