SHOGUN  6.1.3
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Friends
SGVector< T > Class Template Reference

Detailed Description

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

shogun vector

Definition at line 28 of file base/Parameter.h.

Inheritance diagram for SGVector< T >:
[legend]

Public Types

typedef RandomIterator< T > iterator
 
typedef Eigen::Matrix< T,-1, 1, 0,-1, 1 > EigenVectorXt
 
typedef Eigen::Matrix< T, 1,-1, 0x1, 1,-1 > EigenRowVectorXt
 
typedef Eigen::Map< EigenVectorXt, 0, Eigen::Stride< 0, 0 > > EigenVectorXtMap
 
typedef Eigen::Map< EigenRowVectorXt, 0, Eigen::Stride< 0, 0 > > EigenRowVectorXtMap
 
typedef T Scalar
 
template<typename ST >
using container_type = SGVector< ST >
 

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 (SGMatrix< T > matrix)
 
 SGVector (GPUMemoryBase< T > *vector, index_t len)
 
 SGVector (const SGVector &orig)
 
bool on_gpu () const
 
template<typename InputIt >
 SGVector (InputIt begin, InputIt end)
 
 SGVector (std::initializer_list< T > il)
 
 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
 
T * data () const
 
iterator begin () noexcept
 
iterator end () noexcept
 
SGVector< T > & operator= (const SGVector< T > &)
 
 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)
 
SGVector< T > clone () const
 
const T & get_element (index_t index)
 
void set_element (const T &el, 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) More...
 
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. More...
 
void load (CFile *loader)
 
void save (CFile *saver)
 
SGVector< float64_tget_real ()
 
SGVector< float64_tget_imag ()
 
template<>
void zero ()
 
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 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<>
void load (CFile *loader)
 
template<>
void save (CFile *saver)
 
int32_t ref_count ()
 

Static Public Member Functions

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 More...
 
static float64_t onenorm (T *x, int32_t len)
 || x ||_1 More...
 
static T qsq (T *x, int32_t len, float64_t q)
 || x ||_q^q More...
 
static T qnorm (T *x, int32_t len, float64_t q)
 || x ||_q More...
 
static void vec1_plus_scalar_times_vec2 (T *vec1, const T scalar, const T *vec2, int32_t n)
 x=x+alpha*y More...
 
static void vector_multiply (T *target, const T *v1, const T *v2, int32_t len)
 Compute vector multiplication. More...
 
static void add (T *target, T alpha, const T *v1, T beta, const T *v2, int32_t len)
 target=alpha*vec1 + beta*vec2 More...
 
static void add_scalar (T alpha, T *vec, int32_t len)
 Add scalar to vector inplace. More...
 
static void scale_vector (T alpha, T *vec, int32_t len)
 Scale vector inplace. More...
 
static T sum (T *vec, int32_t len)
 Return sum(vec) More...
 
static T sum (SGVector< T > vec)
 Return sum(vec) More...
 
static T product (T *vec, int32_t len)
 Return the product of the vectors elements. More...
 
static T sum_abs (T *vec, int32_t len)
 return sum(abs(vec)) More...
 
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) More...
 
static void display_vector (const SGVector< T >, const char *name="vector", const char *prefix="")
 Display vector (useful for debugging) More...
 
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
 
std::shared_ptr< GPUMemoryBase< T > > gpu_ptr
 

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 ()
 

Friends

class LinalgBackendEigen
 

Member Typedef Documentation

◆ container_type

using container_type = SGVector<ST>

The container type for a given template argument

Definition at line 99 of file SGVector.h.

◆ EigenRowVectorXt

typedef Eigen::Matrix<T,1,-1,0x1,1,-1> EigenRowVectorXt

Definition at line 53 of file SGVector.h.

◆ EigenRowVectorXtMap

Definition at line 56 of file SGVector.h.

◆ EigenVectorXt

typedef Eigen::Matrix<T,-1,1,0,-1,1> EigenVectorXt

Definition at line 52 of file SGVector.h.

◆ EigenVectorXtMap

Definition at line 55 of file SGVector.h.

◆ iterator

Definition at line 49 of file SGVector.h.

◆ Scalar

typedef T Scalar

The scalar type of the vector

Definition at line 59 of file SGVector.h.

Constructor & Destructor Documentation

◆ SGVector() [1/11]

SGVector ( )

Default constructor

Definition at line 72 of file SGVector.cpp.

◆ SGVector() [2/11]

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

Constructor for setting params

Definition at line 78 of file SGVector.cpp.

◆ SGVector() [3/11]

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

Wraps a vector around an existing memory segment with an offset

Definition at line 85 of file SGVector.cpp.

◆ SGVector() [4/11]

SGVector ( index_t  len,
bool  ref_counting = true 
)

Constructor to create new vector in memory

Definition at line 92 of file SGVector.cpp.

◆ SGVector() [5/11]

SGVector ( SGMatrix< T >  matrix)

Constructor to create new vector from a SGMatrix

Definition at line 100 of file SGVector.cpp.

◆ SGVector() [6/11]

SGVector ( GPUMemoryBase< T > *  vector,
index_t  len 
)

Construct SGVector from GPU memory.

Parameters
vectorGPUMemoryBase pointer
lenlength of the data in vector
See also
GPUMemoryBase

Definition at line 110 of file SGVector.cpp.

◆ SGVector() [7/11]

SGVector ( const SGVector< T > &  orig)

Copy constructor

Definition at line 124 of file SGVector.cpp.

◆ SGVector() [8/11]

SGVector ( InputIt  begin,
InputIt  end 
)

Construct SGVector from InputIterator list

Definition at line 103 of file SGVector.h.

◆ SGVector() [9/11]

SGVector ( std::initializer_list< T >  il)

Construct SGVector from initializer list

Definition at line 118 of file SGVector.cpp.

◆ SGVector() [10/11]

SGVector ( EigenVectorXt vec)

Wraps a matrix around the data of an Eigen3 column vector

Definition at line 155 of file SGVector.cpp.

◆ SGVector() [11/11]

Wraps a matrix around the data of an Eigen3 row vector

Definition at line 162 of file SGVector.cpp.

◆ ~SGVector()

~SGVector ( )
virtual

Empty destructor

Definition at line 149 of file SGVector.cpp.

Member Function Documentation

◆ add() [1/4]

void add ( const SGVector< T >  x)

Add vector to current vector

Parameters
xadd vector x to current vector

Definition at line 325 of file SGVector.cpp.

◆ add() [2/4]

void add ( const SGSparseVector< T > &  x)

Add sparse vector to current vector

Parameters
xadd sparse vector x to current vector

Definition at line 345 of file SGVector.cpp.

◆ add() [3/4]

void add ( const T  x)

Add scalar to current vector

Parameters
xadd vector x to current vector

Definition at line 336 of file SGVector.cpp.

◆ add() [4/4]

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 399 of file SGVector.h.

◆ add_scalar()

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

Add scalar to vector inplace.

Definition at line 408 of file SGVector.h.

◆ begin()

iterator begin ( )
noexcept

Returns an iterator to the first element of the container.

Definition at line 166 of file SGVector.h.

◆ clone()

SGVector< T > clone ( ) const

Clone vector

Definition at line 262 of file SGVector.cpp.

◆ clone_vector()

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

Clone vector

Definition at line 271 of file SGVector.cpp.

◆ convert_to_matrix() [1/2]

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

◆ convert_to_matrix() [2/2]

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

◆ copy_data()

void copy_data ( const SGReferencedData orig)
protectedvirtual

needs to be overridden to copy data

Implements SGReferencedData.

Definition at line 367 of file SGVector.cpp.

◆ copy_refcount()

void copy_refcount ( const SGReferencedData orig)
protectedinherited

copy refcount

Definition at line 55 of file SGReferencedData.cpp.

◆ data()

T* data ( ) const

Data pointer

Definition at line 159 of file SGVector.h.

◆ display_size()

void display_size ( ) const

Display array size

Definition at line 360 of file SGVector.cpp.

◆ display_vector() [1/17]

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

Definition at line 425 of file SGVector.cpp.

◆ display_vector() [2/17]

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

Definition at line 436 of file SGVector.cpp.

◆ display_vector() [3/17]

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

Definition at line 447 of file SGVector.cpp.

◆ display_vector() [4/17]

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

Definition at line 458 of file SGVector.cpp.

◆ display_vector() [5/17]

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

Display vector

Definition at line 411 of file SGVector.cpp.

◆ display_vector() [6/17]

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

Display vector (useful for debugging)

◆ display_vector() [7/17]

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

Definition at line 469 of file SGVector.cpp.

◆ display_vector() [8/17]

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

Display vector (useful for debugging)

Definition at line 418 of file SGVector.cpp.

◆ display_vector() [9/17]

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

Definition at line 480 of file SGVector.cpp.

◆ display_vector() [10/17]

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

Definition at line 491 of file SGVector.cpp.

◆ display_vector() [11/17]

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

Definition at line 502 of file SGVector.cpp.

◆ display_vector() [12/17]

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

Definition at line 514 of file SGVector.cpp.

◆ display_vector() [13/17]

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

Definition at line 525 of file SGVector.cpp.

◆ display_vector() [14/17]

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

Definition at line 536 of file SGVector.cpp.

◆ display_vector() [15/17]

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

Definition at line 547 of file SGVector.cpp.

◆ display_vector() [16/17]

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

Definition at line 558 of file SGVector.cpp.

◆ display_vector() [17/17]

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

Definition at line 572 of file SGVector.cpp.

◆ end()

iterator end ( )
noexcept

Returns an iterator to the element following the last element of the container.

Definition at line 169 of file SGVector.h.

◆ equals()

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

◆ fill_vector()

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

Fill vector

Definition at line 279 of file SGVector.cpp.

◆ find()

SGVector< index_t > find ( elem)

Find index for occurance of an element

Parameters
elemthe element to find

Definition at line 863 of file SGVector.cpp.

◆ find_if()

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 483 of file SGVector.h.

◆ find_position_to_insert() [1/2]

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

◆ find_position_to_insert() [2/2]

index_t find_position_to_insert ( complex128_t  element)

Definition at line 254 of file SGVector.cpp.

◆ free_data()

void free_data ( )
protectedvirtual

needs to be overridden to free data

Implements SGReferencedData.

Definition at line 386 of file SGVector.cpp.

◆ get()

SGVector<T> get ( )

Get the vector (no copying is done here)

Returns
the refcount increased vector

Definition at line 140 of file SGVector.h.

◆ get_element()

const T& get_element ( index_t  index)

Get element at index

Parameters
indexindex
Returns
element at index

Definition at line 221 of file SGVector.h.

◆ get_imag()

SGVector< float64_t > get_imag ( )

Imag part of a complex128_t vector

Definition at line 949 of file SGVector.cpp.

◆ get_real()

SGVector< float64_t > get_real ( )

Real part of a complex128_t vector

Definition at line 940 of file SGVector.cpp.

◆ init_data()

void init_data ( )
protectedvirtual

needs to be overridden to initialize empty data

Implements SGReferencedData.

Definition at line 377 of file SGVector.cpp.

◆ load() [1/2]

void load ( CFile loader)

Load vector from file

Parameters
loaderFile object via which to load data

Definition at line 903 of file SGVector.cpp.

◆ load() [2/2]

void load ( CFile loader)

Definition at line 919 of file SGVector.cpp.

◆ on_gpu()

bool on_gpu ( ) const

Check whether data is stored on GPU

Returns
true if vector is on GPU

Definition at line 91 of file SGVector.h.

◆ onenorm()

float64_t onenorm ( T *  x,
int32_t  len 
)
static

|| x ||_1

Definition at line 769 of file SGVector.cpp.

◆ operator EigenRowVectorXtMap()

operator EigenRowVectorXtMap ( ) const

Wraps an Eigen3 row vector around the data of this matrix

Definition at line 176 of file SGVector.cpp.

◆ operator EigenVectorXtMap()

operator EigenVectorXtMap ( ) const

Wraps an Eigen3 column vector around the data of this matrix

Definition at line 169 of file SGVector.cpp.

◆ operator T*()

operator T* ( )

Cast to pointer

Definition at line 174 of file SGVector.h.

◆ operator+()

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

Addition operator

addition operator

Definition at line 313 of file SGVector.cpp.

◆ operator+=() [1/2]

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

Inplace addition operator

Definition at line 353 of file SGVector.h.

◆ operator+=() [2/2]

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

Inplace addition operator for sparse vector

Definition at line 360 of file SGVector.h.

◆ operator=()

SGVector< T > & operator= ( const SGVector< T > &  other)

Definition at line 130 of file SGVector.cpp.

◆ operator[]() [1/8]

const T& operator[] ( uint64_t  index) const

Operator overload for vector read only access

Parameters
indexdimension to access

Definition at line 248 of file SGVector.h.

◆ operator[]() [2/8]

const T& operator[] ( int64_t  index) const

Operator overload for vector read only access

Parameters
indexdimension to access

Definition at line 259 of file SGVector.h.

◆ operator[]() [3/8]

const T& operator[] ( uint32_t  index) const

Operator overload for vector read only access

Parameters
indexdimension to access

Definition at line 270 of file SGVector.h.

◆ operator[]() [4/8]

const T& operator[] ( int32_t  index) const

Operator overload for vector read only access

Parameters
indexdimension to access

Definition at line 281 of file SGVector.h.

◆ operator[]() [5/8]

T& operator[] ( uint64_t  index)

Operator overload for vector r/w access

Parameters
indexdimension to access

Definition at line 292 of file SGVector.h.

◆ operator[]() [6/8]

T& operator[] ( int64_t  index)

Operator overload for vector r/w access

Parameters
indexdimension to access

Definition at line 303 of file SGVector.h.

◆ operator[]() [7/8]

T& operator[] ( uint32_t  index)

Operator overload for vector r/w access

Parameters
indexdimension to access

Definition at line 314 of file SGVector.h.

◆ operator[]() [8/8]

T& operator[] ( int32_t  index)

Operator overload for vector r/w access

Parameters
indexdimension to access

Definition at line 325 of file SGVector.h.

◆ product() [1/2]

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

Return the product of the vectors elements.

Definition at line 434 of file SGVector.h.

◆ product() [2/2]

T product ( )

Return product(vec)

Definition at line 444 of file SGVector.h.

◆ qnorm() [1/2]

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

|| x ||_q

Definition at line 798 of file SGVector.cpp.

◆ qnorm() [2/2]

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

Definition at line 805 of file SGVector.cpp.

◆ qsq() [1/2]

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

|| x ||_q^q

Definition at line 780 of file SGVector.cpp.

◆ qsq() [2/2]

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

Definition at line 790 of file SGVector.cpp.

◆ random()

void random ( min_value,
max_value 
)

Create random vector

Parameters
min_value[min_value,max_value]
max_value

Definition at line 232 of file SGVector.cpp.

◆ random_vector() [1/2]

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

Random vector

Definition at line 620 of file SGVector.cpp.

◆ random_vector() [2/2]

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

Definition at line 627 of file SGVector.cpp.

◆ range_fill()

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

◆ range_fill_vector() [1/2]

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

Range fill vector

Definition at line 286 of file SGVector.cpp.

◆ range_fill_vector() [2/2]

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

Definition at line 293 of file SGVector.cpp.

◆ ref()

int32_t ref ( )
protectedinherited

increase reference counter

Returns
reference count

Definition at line 64 of file SGReferencedData.cpp.

◆ ref_count()

int32_t ref_count ( )
inherited

display reference counter

Returns
reference count

Definition at line 41 of file SGReferencedData.cpp.

◆ resize_vector()

void resize_vector ( int32_t  n)

Resize vector, with zero padding

Parameters
nnew size

Definition at line 301 of file SGVector.cpp.

◆ save() [1/2]

void save ( CFile saver)

Save vector to file

Parameters
saverFile object via which to save data

Definition at line 924 of file SGVector.cpp.

◆ save() [2/2]

void save ( CFile saver)

Definition at line 935 of file SGVector.cpp.

◆ scale()

void scale ( alpha)

Scale vector inplace.

Definition at line 898 of file SGVector.cpp.

◆ scale_vector() [1/3]

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

Scale vector inplace.

Definition at line 877 of file SGVector.cpp.

◆ scale_vector() [2/3]

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

Definition at line 885 of file SGVector.cpp.

◆ scale_vector() [3/3]

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

Definition at line 891 of file SGVector.cpp.

◆ set()

void set ( SGVector< T >  orig)

Wrapper for the copy constructor useful for SWIG interfaces

Parameters
origvector to set

Definition at line 143 of file SGVector.cpp.

◆ set_const()

void set_const ( const_elem)

Set vector to a constant

Parameters
const_elem- value to set vector to

Definition at line 199 of file SGVector.cpp.

◆ set_element()

void set_element ( const T &  el,
index_t  index 
)

Set element at index

Parameters
elelement to set
indexindex

Definition at line 231 of file SGVector.h.

◆ size()

int32_t size ( ) const

Size

Definition at line 156 of file SGVector.h.

◆ sum() [1/2]

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

Return sum(vec)

Definition at line 418 of file SGVector.h.

◆ sum() [2/2]

static T sum ( SGVector< T >  vec)
static

Return sum(vec)

Definition at line 428 of file SGVector.h.

◆ sum_abs() [1/3]

T sum_abs ( T *  vec,
int32_t  len 
)
static

return sum(abs(vec))

Returns
sum(abs(vec))

Definition at line 813 of file SGVector.cpp.

◆ sum_abs() [2/3]

float64_t sum_abs ( float64_t vec,
int32_t  len 
)

Definition at line 824 of file SGVector.cpp.

◆ sum_abs() [3/3]

float32_t sum_abs ( float32_t vec,
int32_t  len 
)

Definition at line 832 of file SGVector.cpp.

◆ twonorm() [1/15]

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

|| x ||_2

◆ twonorm() [2/15]

bool twonorm ( const bool *  x,
int32_t  len 
)

Definition at line 634 of file SGVector.cpp.

◆ twonorm() [3/15]

char twonorm ( const char *  x,
int32_t  len 
)

Definition at line 641 of file SGVector.cpp.

◆ twonorm() [4/15]

int8_t twonorm ( const int8_t *  x,
int32_t  len 
)

Definition at line 648 of file SGVector.cpp.

◆ twonorm() [5/15]

uint8_t twonorm ( const uint8_t *  x,
int32_t  len 
)

Definition at line 658 of file SGVector.cpp.

◆ twonorm() [6/15]

int16_t twonorm ( const int16_t *  x,
int32_t  len 
)

Definition at line 668 of file SGVector.cpp.

◆ twonorm() [7/15]

uint16_t twonorm ( const uint16_t *  x,
int32_t  len 
)

Definition at line 678 of file SGVector.cpp.

◆ twonorm() [8/15]

int32_t twonorm ( const int32_t *  x,
int32_t  len 
)

Definition at line 688 of file SGVector.cpp.

◆ twonorm() [9/15]

uint32_t twonorm ( const uint32_t *  x,
int32_t  len 
)

Definition at line 698 of file SGVector.cpp.

◆ twonorm() [10/15]

int64_t twonorm ( const int64_t *  x,
int32_t  len 
)

Definition at line 708 of file SGVector.cpp.

◆ twonorm() [11/15]

uint64_t twonorm ( const uint64_t *  x,
int32_t  len 
)

Definition at line 718 of file SGVector.cpp.

◆ twonorm() [12/15]

float32_t twonorm ( const float32_t x,
int32_t  len 
)

Definition at line 728 of file SGVector.cpp.

◆ twonorm() [13/15]

float64_t twonorm ( const float64_t v,
int32_t  n 
)

Definition at line 738 of file SGVector.cpp.

◆ twonorm() [14/15]

floatmax_t twonorm ( const floatmax_t x,
int32_t  len 
)

Definition at line 749 of file SGVector.cpp.

◆ twonorm() [15/15]

complex128_t twonorm ( const complex128_t x,
int32_t  len 
)

Definition at line 759 of file SGVector.cpp.

◆ unique() [1/2]

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

◆ unique() [2/2]

int32_t unique ( complex128_t output,
int32_t  size 
)

Definition at line 855 of file SGVector.cpp.

◆ unref()

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.

◆ vec1_plus_scalar_times_vec2() [1/3]

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

◆ vec1_plus_scalar_times_vec2() [2/3]

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

Definition at line 594 of file SGVector.cpp.

◆ vec1_plus_scalar_times_vec2() [3/3]

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

Definition at line 607 of file SGVector.cpp.

◆ vector_multiply()

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

Compute vector multiplication.

Definition at line 390 of file SGVector.h.

◆ zero() [1/2]

void zero ( )

Fill vector with zeros

Definition at line 183 of file SGVector.cpp.

◆ zero() [2/2]

void zero ( )

Definition at line 191 of file SGVector.cpp.

Friends And Related Function Documentation

◆ LinalgBackendEigen

friend class LinalgBackendEigen
friend

Definition at line 46 of file SGVector.h.

Member Data Documentation

◆ gpu_ptr

std::shared_ptr<GPUMemoryBase<T> > gpu_ptr

GPU Vector structure. Stores pointer to the data on GPU.

Definition at line 573 of file SGVector.h.

◆ vector

T* vector

Pointer to memory where vector data is stored

Definition at line 569 of file SGVector.h.

◆ vlen

index_t vlen

Length of vector

Definition at line 571 of file SGVector.h.


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

SHOGUN Machine Learning Toolbox - Documentation