SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions
SGVector< T > Class Template Reference

Detailed Description

template<class T>
class shogun::SGVector< T >

shogun vector

Definition at line 37 of file SGVector.h.

Inheritance diagram for SGVector< T >:
Inheritance graph
[legend]

Public Types

typedef T Scalar

Public Member Functions

 SGVector ()
 SGVector (T *v, index_t len, bool ref_counting=true)
 SGVector (T *m, index_t len, index_t offset)
 SGVector (index_t len, bool ref_counting=true)
 SGVector (const SGVector &orig)
 SGVector (EigenVectorXt &vec)
 SGVector (EigenRowVectorXt &vec)
 operator EigenVectorXtMap () const
 operator EigenRowVectorXtMap () const
void set_const (T const_elem)
SGVector< T > get ()
void set (SGVector< T > orig)
virtual ~SGVector ()
int32_t size () const
 operator T * ()
void zero ()
void range_fill (T start=0)
void random (T min_value, T max_value)
index_t find_position_to_insert (T element)
void qsort ()
SGVector< index_targsort ()
bool is_sorted () const
SGVector< T > clone () const
const T & get_element (index_t index)
void set_element (const T &p_element, index_t index)
void resize_vector (int32_t n)
const T & operator[] (uint64_t index) const
const T & operator[] (int64_t index) const
const T & operator[] (uint32_t index) const
const T & operator[] (int32_t index) const
T & operator[] (uint64_t index)
T & operator[] (int64_t index)
T & operator[] (uint32_t index)
T & operator[] (int32_t index)
void add (const SGVector< T > x)
void add (const SGSparseVector< T > &x)
void add (const T x)
SGVector< T > operator+ (SGVector< T > x)
SGVector< T > operator+= (SGVector< T > x)
SGVector< T > operator+= (SGSparseVector< T > &x)
bool equals (SGVector< T > &other)
product ()
 Return product(vec)
void display_size () const
void display_vector (const char *name="vector", const char *prefix="") const
SGVector< index_tfind (T elem)
template<typename Predicate >
SGVector< index_tfind_if (Predicate p)
void scale (T alpha)
 Scale vector inplace.
float64_t mean () const
void load (CFile *loader)
void save (CFile *saver)
SGVector< float64_tget_real ()
SGVector< float64_tget_imag ()
template<>
void zero ()
template<>
SGVector< index_targsort ()
template<>
bool is_sorted () const
template<>
index_t find_position_to_insert (complex128_t element)
template<>
void range_fill_vector (complex128_t *vec, int32_t len, complex128_t start)
template<>
void display_vector (const bool *vector, int32_t n, const char *name, const char *prefix)
template<>
void display_vector (const char *vector, int32_t n, const char *name, const char *prefix)
template<>
void display_vector (const uint8_t *vector, int32_t n, const char *name, const char *prefix)
template<>
void display_vector (const int8_t *vector, int32_t n, const char *name, const char *prefix)
template<>
void display_vector (const uint16_t *vector, int32_t n, const char *name, const char *prefix)
template<>
void display_vector (const int16_t *vector, int32_t n, const char *name, const char *prefix)
template<>
void display_vector (const int32_t *vector, int32_t n, const char *name, const char *prefix)
template<>
void display_vector (const uint32_t *vector, int32_t n, const char *name, const char *prefix)
template<>
void display_vector (const int64_t *vector, int32_t n, const char *name, const char *prefix)
template<>
void display_vector (const uint64_t *vector, int32_t n, const char *name, const char *prefix)
template<>
void display_vector (const float32_t *vector, int32_t n, const char *name, const char *prefix)
template<>
void display_vector (const float64_t *vector, int32_t n, const char *name, const char *prefix)
template<>
void display_vector (const floatmax_t *vector, int32_t n, const char *name, const char *prefix)
template<>
void display_vector (const complex128_t *vector, int32_t n, const char *name, const char *prefix)
template<>
void vec1_plus_scalar_times_vec2 (float64_t *vec1, float64_t scalar, const float64_t *vec2, int32_t n)
template<>
void vec1_plus_scalar_times_vec2 (float32_t *vec1, float32_t scalar, const float32_t *vec2, int32_t n)
template<>
void random_vector (complex128_t *vec, int32_t len, complex128_t min_value, complex128_t max_value)
template<>
bool twonorm (const bool *x, int32_t len)
template<>
char twonorm (const char *x, int32_t len)
template<>
int8_t twonorm (const int8_t *x, int32_t len)
template<>
uint8_t twonorm (const uint8_t *x, int32_t len)
template<>
int16_t twonorm (const int16_t *x, int32_t len)
template<>
uint16_t twonorm (const uint16_t *x, int32_t len)
template<>
int32_t twonorm (const int32_t *x, int32_t len)
template<>
uint32_t twonorm (const uint32_t *x, int32_t len)
template<>
int64_t twonorm (const int64_t *x, int32_t len)
template<>
uint64_t twonorm (const uint64_t *x, int32_t len)
template<>
float32_t twonorm (const float32_t *x, int32_t len)
template<>
float64_t twonorm (const float64_t *v, int32_t n)
template<>
floatmax_t twonorm (const floatmax_t *x, int32_t len)
template<>
complex128_t twonorm (const complex128_t *x, int32_t len)
template<>
complex128_t qsq (complex128_t *x, int32_t len, float64_t q)
template<>
complex128_t qnorm (complex128_t *x, int32_t len, float64_t q)
template<>
float64_t max_abs (float64_t *vec, int32_t len)
template<>
float32_t max_abs (float32_t *vec, int32_t len)
template<>
complex128_t max_abs (complex128_t *vec, int32_t len)
template<>
int32_t arg_max_abs (float64_t *vec, int32_t inc, int32_t len, float64_t *maxv_ptr)
template<>
int32_t arg_max_abs (float32_t *vec, int32_t inc, int32_t len, float32_t *maxv_ptr)
template<>
int32_t arg_max_abs (complex128_t *vec, int32_t inc, int32_t len, complex128_t *maxv_ptr)
template<>
int32_t arg_max (complex128_t *vec, int32_t inc, int32_t len, complex128_t *maxv_ptr)
template<>
int32_t arg_min (complex128_t *vec, int32_t inc, int32_t len, complex128_t *minv_ptr)
template<>
float64_t sum_abs (float64_t *vec, int32_t len)
template<>
float32_t sum_abs (float32_t *vec, int32_t len)
template<>
int32_t unique (complex128_t *output, int32_t size)
template<>
void scale_vector (float64_t alpha, float64_t *vec, int32_t len)
template<>
void scale_vector (float32_t alpha, float32_t *vec, int32_t len)
template<>
float64_t mean () const
template<>
void load (CFile *loader)
template<>
void save (CFile *saver)
template<>
float64_tlinspace (complex128_t start, complex128_t end, int32_t n)
int32_t ref_count ()

Static Public Member Functions

static SGVector< float64_tlinspace_vec (T start, T end, int32_t n)
static float64_tlinspace (T start, T end, int32_t n)
static T * clone_vector (const T *vec, int32_t len)
static void fill_vector (T *vec, int32_t len, T value)
static void range_fill_vector (T *vec, int32_t len, T start=0)
static void random_vector (T *vec, int32_t len, T min_value, T max_value)
static T twonorm (const T *x, int32_t len)
 || x ||_2
static float64_t onenorm (T *x, int32_t len)
 || x ||_1
static T qsq (T *x, int32_t len, float64_t q)
 || x ||_q^q
static T qnorm (T *x, int32_t len, float64_t q)
 || x ||_q
static void vec1_plus_scalar_times_vec2 (T *vec1, const T scalar, const T *vec2, int32_t n)
 x=x+alpha*y
static float64_t dot (const bool *v1, const bool *v2, int32_t n)
 Compute dot product between v1 and v2 (blas optimized)
static floatmax_t dot (const floatmax_t *v1, const floatmax_t *v2, int32_t n)
 Compute dot product between v1 and v2 (blas optimized)
static float64_t dot (const float64_t *v1, const float64_t *v2, int32_t n)
 Compute dot product between v1 and v2 (blas optimized)
static float32_t dot (const float32_t *v1, const float32_t *v2, int32_t n)
 Compute dot product between v1 and v2 (blas optimized)
static float64_t dot (const uint64_t *v1, const uint64_t *v2, int32_t n)
 compute dot product between v1 and v2 (for 64bit unsigned ints)
static float64_t dot (const int64_t *v1, const int64_t *v2, int32_t n)
 Compute dot product between v1 and v2 (for 64bit ints)
static float64_t dot (const int32_t *v1, const int32_t *v2, int32_t n)
 Compute dot product between v1 and v2 (for 32bit ints)
static float64_t dot (const uint32_t *v1, const uint32_t *v2, int32_t n)
 Compute dot product between v1 and v2 (for 32bit unsigned ints)
static float64_t dot (const uint16_t *v1, const uint16_t *v2, int32_t n)
 Compute dot product between v1 and v2 (for 16bit unsigned ints)
static float64_t dot (const int16_t *v1, const int16_t *v2, int32_t n)
 Compute dot product between v1 and v2 (for 16bit unsigned ints)
static float64_t dot (const char *v1, const char *v2, int32_t n)
 Compute dot product between v1 and v2 (for 8bit (un)signed ints)
static float64_t dot (const uint8_t *v1, const uint8_t *v2, int32_t n)
 Compute dot product between v1 and v2 (for 8bit (un)signed ints)
static float64_t dot (const int8_t *v1, const int8_t *v2, int32_t n)
 Compute dot product between v1 and v2 (for 8bit (un)signed ints)
static float64_t dot (const float64_t *v1, const char *v2, int32_t n)
 Compute dot product between v1 and v2.
static void vector_multiply (T *target, const T *v1, const T *v2, int32_t len)
 Compute vector multiplication.
static void add (T *target, T alpha, const T *v1, T beta, const T *v2, int32_t len)
 target=alpha*vec1 + beta*vec2
static void add_scalar (T alpha, T *vec, int32_t len)
 Add scalar to vector inplace.
static void scale_vector (T alpha, T *vec, int32_t len)
 Scale vector inplace.
static T sum (T *vec, int32_t len)
 Return sum(vec)
static T sum (SGVector< T > vec)
 Return sum(vec)
static T product (T *vec, int32_t len)
 Return the product of the vectors elements.
static T min (T *vec, int32_t len)
static T max_abs (T *vec, int32_t len)
static T max (T *vec, int32_t len)
static int32_t arg_max (T *vec, int32_t inc, int32_t len, T *maxv_ptr=NULL)
static int32_t arg_max_abs (T *vec, int32_t inc, int32_t len, T *maxv_ptr=NULL)
static int32_t arg_min (T *vec, int32_t inc, int32_t len, T *minv_ptr=NULL)
 return arg_min(vec)
static T sum_abs (T *vec, int32_t len)
 return sum(abs(vec))
static bool fequal (T x, T y, float64_t precision=1e-6)
 return sum(abs(vec))
static int32_t unique (T *output, int32_t size)
static void display_vector (const T *vector, int32_t n, const char *name="vector", const char *prefix="")
 Display vector (useful for debugging)
static void display_vector (const SGVector< T >, const char *name="vector", const char *prefix="")
 Display vector (useful for debugging)
static SGMatrix< T > convert_to_matrix (SGVector< T > vector, index_t nrows, index_t ncols, bool fortran_order)
static void convert_to_matrix (T *&matrix, index_t nrows, index_t ncols, const T *vector, int32_t vlen, bool fortran_order)

Public Attributes

T * vector
index_t vlen

Protected Member Functions

virtual void copy_data (const SGReferencedData &orig)
virtual void init_data ()
virtual void free_data ()
void copy_refcount (const SGReferencedData &orig)
int32_t ref ()
int32_t unref ()

Member Typedef Documentation

typedef T Scalar

The scalar type of the vector

Definition at line 47 of file SGVector.h.

Constructor & Destructor Documentation

SGVector ( )

Default constructor

Definition at line 73 of file SGVector.cpp.

SGVector ( T *  v,
index_t  len,
bool  ref_counting = true 
)

Constructor for setting params

Definition at line 79 of file SGVector.cpp.

SGVector ( T *  m,
index_t  len,
index_t  offset 
)

Wraps a vector around an existing memory segment with an offset

Definition at line 56 of file SGVector.h.

SGVector ( index_t  len,
bool  ref_counting = true 
)

Constructor to create new vector in memory

Definition at line 85 of file SGVector.cpp.

SGVector ( const SGVector< T > &  orig)

Copy constructor

Definition at line 92 of file SGVector.cpp.

SGVector ( EigenVectorXt &  vec)

Wraps a matrix around the data of an Eigen3 column vector

Definition at line 111 of file SGVector.cpp.

SGVector ( EigenRowVectorXt &  vec)

Wraps a matrix around the data of an Eigen3 row vector

Definition at line 118 of file SGVector.cpp.

~SGVector ( )
virtual

Empty destructor

Definition at line 104 of file SGVector.cpp.

Member Function Documentation

void add ( const SGVector< T >  x)

Add vector to current vector

Parameters
xadd vector x to current vector

Definition at line 350 of file SGVector.cpp.

void add ( const SGSparseVector< T > &  x)

Add sparse vector to current vector

Parameters
xadd sparse vector x to current vector

Definition at line 369 of file SGVector.cpp.

void add ( const T  x)

Add scalar to current vector

Parameters
xadd vector x to current vector

Definition at line 360 of file SGVector.cpp.

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

target=alpha*vec1 + beta*vec2

Definition at line 493 of file SGVector.h.

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

Add scalar to vector inplace.

Definition at line 502 of file SGVector.h.

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

Definition at line 987 of file SGVector.cpp.

int32_t arg_max ( complex128_t vec,
int32_t  inc,
int32_t  len,
complex128_t maxv_ptr 
)

Definition at line 1007 of file SGVector.cpp.

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

Definition at line 958 of file SGVector.cpp.

int32_t arg_max_abs ( float64_t vec,
int32_t  inc,
int32_t  len,
float64_t maxv_ptr 
)

Definition at line 933 of file SGVector.cpp.

int32_t arg_max_abs ( float32_t vec,
int32_t  inc,
int32_t  len,
float32_t maxv_ptr 
)

Definition at line 945 of file SGVector.cpp.

int32_t arg_max_abs ( complex128_t vec,
int32_t  inc,
int32_t  len,
complex128_t maxv_ptr 
)

Definition at line 978 of file SGVector.cpp.

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

return arg_min(vec)

Returns
arg_min(vec)

Definition at line 1018 of file SGVector.cpp.

int32_t arg_min ( complex128_t vec,
int32_t  inc,
int32_t  len,
complex128_t minv_ptr 
)

Definition at line 1038 of file SGVector.cpp.

SGVector< index_t > argsort ( )

Get sorted index.

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

Returns
sorted index for this vector

Definition at line 215 of file SGVector.cpp.

SGVector< index_t > argsort ( )

Definition at line 228 of file SGVector.cpp.

SGVector< T > clone ( ) const

Clone vector

Definition at line 278 of file SGVector.cpp.

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

Clone vector

Definition at line 284 of file SGVector.cpp.

SGMatrix< T > convert_to_matrix ( SGVector< T >  vector,
index_t  nrows,
index_t  ncols,
bool  fortran_order 
)
static

Create SGMatrix from linear vector

Parameters
vectorsource vector
nrowsnumber of rows
ncolsnumber of cols
fortran_orderorder of stroing matrix in linear vector true - column-major order (FORTRAN, MATLAB, R) false - row-major order (C, Python)
Returns
matrix

Definition at line 1236 of file SGVector.cpp.

void convert_to_matrix ( T *&  matrix,
index_t  nrows,
index_t  ncols,
const T *  vector,
int32_t  vlen,
bool  fortran_order 
)
static

Create matrix from linear vector

Parameters
matrixdestination memory
nrowsnumber of rows
ncolsnumber of cols
vectorsource vector
vlenlenght of source vector
fortran_orderorder of stroing matrix in linear vector true - column-major order (FORTRAN, MATLAB, R) false - row-major order (C, Python)
Returns
matrix

Definition at line 1250 of file SGVector.cpp.

void copy_data ( const SGReferencedData orig)
protectedvirtual

needs to be overridden to copy data

Implements SGReferencedData.

Definition at line 389 of file SGVector.cpp.

void copy_refcount ( const SGReferencedData orig)
protectedinherited

copy refcount

Definition at line 55 of file SGReferencedData.cpp.

void display_size ( ) const

Display array size

Definition at line 383 of file SGVector.cpp.

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

Definition at line 440 of file SGVector.cpp.

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

Definition at line 451 of file SGVector.cpp.

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

Definition at line 462 of file SGVector.cpp.

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

Definition at line 473 of file SGVector.cpp.

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

Definition at line 484 of file SGVector.cpp.

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

Definition at line 495 of file SGVector.cpp.

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

Definition at line 506 of file SGVector.cpp.

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

Definition at line 517 of file SGVector.cpp.

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

Definition at line 529 of file SGVector.cpp.

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

Definition at line 540 of file SGVector.cpp.

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

Definition at line 551 of file SGVector.cpp.

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

Definition at line 562 of file SGVector.cpp.

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

Definition at line 573 of file SGVector.cpp.

void display_vector ( const char *  name = "vector",
const char *  prefix = "" 
) const

Display vector

Definition at line 426 of file SGVector.cpp.

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

Display vector (useful for debugging)

void display_vector ( const SGVector< T >  vector,
const char *  name = "vector",
const char *  prefix = "" 
)
static

Display vector (useful for debugging)

Definition at line 433 of file SGVector.cpp.

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

Definition at line 587 of file SGVector.cpp.

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 350 of file SGVector.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 359 of file SGVector.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 635 of file SGVector.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 653 of file SGVector.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 375 of file SGVector.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 385 of file SGVector.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 396 of file SGVector.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 407 of file SGVector.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 418 of file SGVector.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 429 of file SGVector.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 440 of file SGVector.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 451 of file SGVector.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 462 of file SGVector.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 473 of file SGVector.h.

bool equals ( SGVector< T > &  other)

Equals method up to precision for vectors (element-wise)

Parameters
othervector to compare with
Returns
false if any element differs or if sizes are different, true otherwise

Definition at line 411 of file SGVector.cpp.

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

return sum(abs(vec))

Returns
sum(abs(vec))

Definition at line 1077 of file SGVector.cpp.

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

Fill vector

Definition at line 292 of file SGVector.cpp.

SGVector< index_t > find ( elem)

Find index for occurance of an element

Parameters
elemthe element to find

Definition at line 1105 of file SGVector.cpp.

SGVector<index_t> find_if ( Predicate  p)

Find index for elements where the predicate returns true

Parameters
pthe predicate, it should accept the value of the element and return a bool

Definition at line 598 of file SGVector.h.

index_t find_position_to_insert ( element)

For a sorted (ascending) vector, gets the index after the first element that is smaller than the given one

Parameters
elementelement to find index for
Returns
index of the first element greater than given one

Definition at line 258 of file SGVector.cpp.

index_t find_position_to_insert ( complex128_t  element)

Definition at line 270 of file SGVector.cpp.

void free_data ( )
protectedvirtual

needs to be overridden to free data

Implements SGReferencedData.

Definition at line 403 of file SGVector.cpp.

SGVector<T> get ( )

Get the vector (no copying is done here)

Returns
the refcount increased vector

Definition at line 92 of file SGVector.h.

const T & get_element ( index_t  index)

Get vector element at index

Parameters
indexindex
Returns
vector element at index

Definition at line 314 of file SGVector.cpp.

SGVector< float64_t > get_imag ( )

Imag part of a complex128_t vector

Definition at line 1227 of file SGVector.cpp.

SGVector< float64_t > get_real ( )

Real part of a complex128_t vector

Definition at line 1219 of file SGVector.cpp.

void init_data ( )
protectedvirtual

needs to be overridden to initialize empty data

Implements SGReferencedData.

Definition at line 396 of file SGVector.cpp.

bool is_sorted ( ) const

Check if vector is sorted

Returns
true if vector is sorted, false otherwise

Definition at line 236 of file SGVector.cpp.

bool is_sorted ( ) const

Definition at line 251 of file SGVector.cpp.

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 1203 of file SGVector.cpp.

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

Definition at line 1212 of file SGVector.cpp.

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 1197 of file SGVector.cpp.

void load ( CFile loader)

Load vector from file

Parameters
loaderFile object via which to load data

Definition at line 1161 of file SGVector.cpp.

void load ( CFile loader)

Definition at line 1176 of file SGVector.cpp.

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

Definition at line 920 of file SGVector.cpp.

T max_abs ( T *  vec,
int32_t  len 
)
static
Returns
max(abs(vec))
max_abs(vec)

Definition at line 900 of file SGVector.cpp.

float64_t max_abs ( float64_t vec,
int32_t  len 
)

Definition at line 878 of file SGVector.cpp.

float32_t max_abs ( float32_t vec,
int32_t  len 
)

Definition at line 888 of file SGVector.cpp.

complex128_t max_abs ( complex128_t vec,
int32_t  len 
)

Definition at line 912 of file SGVector.cpp.

float64_t mean ( ) const

Compute the mean value of the vector

Returns
the mean value

Definition at line 1144 of file SGVector.cpp.

float64_t mean ( ) const

Definition at line 1155 of file SGVector.cpp.

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

Definition at line 865 of file SGVector.cpp.

float64_t onenorm ( T *  x,
int32_t  len 
)
static

|| x ||_1

Definition at line 821 of file SGVector.cpp.

operator EigenRowVectorXtMap ( ) const

Wraps an Eigen3 row vector around the data of this matrix

Definition at line 131 of file SGVector.cpp.

operator EigenVectorXtMap ( ) const

Wraps an Eigen3 column vector around the data of this matrix

Definition at line 125 of file SGVector.cpp.

operator T * ( )

Cast to pointer

Definition at line 111 of file SGVector.h.

SGVector< T > operator+ ( SGVector< T >  x)

Addition operator

addition operator

Definition at line 339 of file SGVector.cpp.

SGVector<T> operator+= ( SGVector< T >  x)

Inplace addition operator

Definition at line 313 of file SGVector.h.

SGVector<T> operator+= ( SGSparseVector< T > &  x)

Inplace addition operator for sparse vector

Definition at line 320 of file SGVector.h.

const T& operator[] ( uint64_t  index) const

Operator overload for vector read only access

Parameters
indexdimension to access

Definition at line 216 of file SGVector.h.

const T& operator[] ( int64_t  index) const

Operator overload for vector read only access

Parameters
indexdimension to access

Definition at line 226 of file SGVector.h.

const T& operator[] ( uint32_t  index) const

Operator overload for vector read only access

Parameters
indexdimension to access

Definition at line 236 of file SGVector.h.

const T& operator[] ( int32_t  index) const

Operator overload for vector read only access

Parameters
indexdimension to access

Definition at line 246 of file SGVector.h.

T& operator[] ( uint64_t  index)

Operator overload for vector r/w access

Parameters
indexdimension to access

Definition at line 256 of file SGVector.h.

T& operator[] ( int64_t  index)

Operator overload for vector r/w access

Parameters
indexdimension to access

Definition at line 266 of file SGVector.h.

T& operator[] ( uint32_t  index)

Operator overload for vector r/w access

Parameters
indexdimension to access

Definition at line 276 of file SGVector.h.

T& operator[] ( int32_t  index)

Operator overload for vector r/w access

Parameters
indexdimension to access

Definition at line 286 of file SGVector.h.

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

Return the product of the vectors elements.

Definition at line 528 of file SGVector.h.

T product ( )

Return product(vec)

Definition at line 538 of file SGVector.h.

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

|| x ||_q

Definition at line 850 of file SGVector.cpp.

complex128_t qnorm ( complex128_t x,
int32_t  len,
float64_t  q 
)

Definition at line 857 of file SGVector.cpp.

void qsort ( )

Quicksort the vector it is sorted from in ascending (for type T)

Definition at line 189 of file SGVector.cpp.

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

|| x ||_q^q

Definition at line 832 of file SGVector.cpp.

complex128_t qsq ( complex128_t x,
int32_t  len,
float64_t  q 
)

Definition at line 842 of file SGVector.cpp.

void random ( min_value,
max_value 
)

Create random vector

Parameters
min_value[min_value,max_value]
max_value

Definition at line 181 of file SGVector.cpp.

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

Random vector

Definition at line 671 of file SGVector.cpp.

void random_vector ( complex128_t vec,
int32_t  len,
complex128_t  min_value,
complex128_t  max_value 
)

Definition at line 678 of file SGVector.cpp.

void range_fill ( start = 0)

Range fill a vector with start...start+len-1

Parameters
start- value to be assigned to first element of vector

Definition at line 173 of file SGVector.cpp.

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

Range fill vector

Definition at line 299 of file SGVector.cpp.

void range_fill_vector ( complex128_t vec,
int32_t  len,
complex128_t  start 
)

Definition at line 306 of file SGVector.cpp.

int32_t ref ( )
protectedinherited

increase reference counter

Returns
reference count

Definition at line 64 of file SGReferencedData.cpp.

int32_t ref_count ( )
inherited

display reference counter

Returns
reference count

Definition at line 41 of file SGReferencedData.cpp.

void resize_vector ( int32_t  n)

Resize vector

Parameters
nnew size
Returns
if resizing was successful

Definition at line 328 of file SGVector.cpp.

void save ( CFile saver)

Save vector to file

Parameters
saverFile object via which to save data

Definition at line 1181 of file SGVector.cpp.

void save ( CFile saver)

Definition at line 1191 of file SGVector.cpp.

void scale ( alpha)

Scale vector inplace.

Definition at line 1139 of file SGVector.cpp.

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

Scale vector inplace.

Definition at line 1118 of file SGVector.cpp.

void scale_vector ( float64_t  alpha,
float64_t vec,
int32_t  len 
)

Definition at line 1126 of file SGVector.cpp.

void scale_vector ( float32_t  alpha,
float32_t vec,
int32_t  len 
)

Definition at line 1132 of file SGVector.cpp.

void set ( SGVector< T >  orig)

Wrapper for the copy constructor useful for SWIG interfaces

Parameters
origvector to set

Definition at line 98 of file SGVector.cpp.

void set_const ( const_elem)

Set vector to a constant

Parameters
const_elem- value to set vector to

Definition at line 152 of file SGVector.cpp.

void set_element ( const T &  p_element,
index_t  index 
)

Set vector element at index 'index' return false in case of trouble

Parameters
p_elementvector element to set
indexindex
Returns
if setting was successful

Definition at line 321 of file SGVector.cpp.

int32_t size ( ) const

Size

Definition at line 108 of file SGVector.h.

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

Return sum(vec)

Definition at line 512 of file SGVector.h.

static T sum ( SGVector< T >  vec)
static

Return sum(vec)

Definition at line 522 of file SGVector.h.

T sum_abs ( T *  vec,
int32_t  len 
)
static

return sum(abs(vec))

Returns
sum(abs(vec))

Definition at line 1048 of file SGVector.cpp.

float64_t sum_abs ( float64_t vec,
int32_t  len 
)

Definition at line 1059 of file SGVector.cpp.

float32_t sum_abs ( float32_t vec,
int32_t  len 
)

Definition at line 1067 of file SGVector.cpp.

static T twonorm ( const T *  x,
int32_t  len 
)
static

|| x ||_2

bool twonorm ( const bool *  x,
int32_t  len 
)

Definition at line 685 of file SGVector.cpp.

char twonorm ( const char *  x,
int32_t  len 
)

Definition at line 692 of file SGVector.cpp.

int8_t twonorm ( const int8_t *  x,
int32_t  len 
)

Definition at line 699 of file SGVector.cpp.

uint8_t twonorm ( const uint8_t *  x,
int32_t  len 
)

Definition at line 709 of file SGVector.cpp.

int16_t twonorm ( const int16_t *  x,
int32_t  len 
)

Definition at line 719 of file SGVector.cpp.

uint16_t twonorm ( const uint16_t *  x,
int32_t  len 
)

Definition at line 729 of file SGVector.cpp.

int32_t twonorm ( const int32_t *  x,
int32_t  len 
)

Definition at line 739 of file SGVector.cpp.

uint32_t twonorm ( const uint32_t *  x,
int32_t  len 
)

Definition at line 749 of file SGVector.cpp.

int64_t twonorm ( const int64_t *  x,
int32_t  len 
)

Definition at line 759 of file SGVector.cpp.

uint64_t twonorm ( const uint64_t *  x,
int32_t  len 
)

Definition at line 769 of file SGVector.cpp.

float32_t twonorm ( const float32_t x,
int32_t  len 
)

Definition at line 779 of file SGVector.cpp.

float64_t twonorm ( const float64_t v,
int32_t  n 
)

Definition at line 789 of file SGVector.cpp.

floatmax_t twonorm ( const floatmax_t x,
int32_t  len 
)

Definition at line 801 of file SGVector.cpp.

complex128_t twonorm ( const complex128_t x,
int32_t  len 
)

Definition at line 811 of file SGVector.cpp.

int32_t unique ( T *  output,
int32_t  size 
)
static

Performs a inplace unique of a vector of type T using quicksort returns the new number of elements

Definition at line 1083 of file SGVector.cpp.

int32_t unique ( complex128_t output,
int32_t  size 
)

Definition at line 1097 of file SGVector.cpp.

int32_t unref ( )
protectedinherited

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

Returns
reference count

Definition at line 84 of file SGReferencedData.cpp.

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

x=x+alpha*y

Definition at line 601 of file SGVector.cpp.

void vec1_plus_scalar_times_vec2 ( float64_t vec1,
float64_t  scalar,
const float64_t vec2,
int32_t  n 
)

Definition at line 609 of file SGVector.cpp.

void vec1_plus_scalar_times_vec2 ( float32_t vec1,
float32_t  scalar,
const float32_t vec2,
int32_t  n 
)

Definition at line 622 of file SGVector.cpp.

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

Compute vector multiplication.

Definition at line 484 of file SGVector.h.

void zero ( )

Fill vector with zeros

Definition at line 138 of file SGVector.cpp.

void zero ( )

Definition at line 145 of file SGVector.cpp.

Member Data Documentation

T* vector

vector

Definition at line 677 of file SGVector.h.

index_t vlen

length of vector

Definition at line 679 of file SGVector.h.


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

SHOGUN Machine Learning Toolbox - Documentation