14 #ifndef __SGVECTOR_H__
15 #define __SGVECTOR_H__
24 template <
class,
int,
int,
int,
int,
int>
class Matrix;
25 template<
int,
int>
class Stride;
26 template <
class,
int,
class>
class Map;
31 template <
class T>
class SGSparseVector;
32 template <
class T>
class SGMatrix;
37 template<
class T>
class SGVector :
public SGReferencedData
65 #ifndef SWIG // SWIG should skip this part
66 #if defined(HAVE_CXX0X) || defined(HAVE_CXX11)
69 template <
typename ST>
using container_type =
SGVector<ST>;
71 #endif // define (HAVE_CXX0X) || defined(HAVE_CXX11)
102 #ifndef SWIG // SWIG should skip this part
138 void random(T min_value, T max_value);
155 static void fill_vector(T* vec, int32_t len, T value);
161 static void random_vector(T* vec, int32_t len, T min_value, T max_value);
162 #endif // SWIG // SWIG should skip this part
179 #ifndef SWIG // SWIG should skip this part
310 static T
twonorm(
const T* x, int32_t len);
323 const T scalar,
const T* vec2, int32_t n);
327 T* target,
const T* v1,
const T* v2,int32_t len)
329 for (int32_t i=0; i<len; i++)
330 target[i]=v1[i]*v2[i];
336 T* target, T alpha,
const T* v1, T beta,
const T* v2,
339 for (int32_t i=0; i<len; i++)
340 target[i]=alpha*v1[i]+beta*v2[i];
346 for (int32_t i=0; i<len; i++)
354 static inline T
sum(T* vec, int32_t len)
357 for (int32_t i=0; i<len; i++)
366 return sum(vec.vector, vec.vlen);
373 for (int32_t i=0; i<len; i++)
386 static T
sum_abs(T* vec, int32_t len);
391 static int32_t
unique(T* output, int32_t
size);
398 const char* prefix=
"")
const;
402 const T*
vector, int32_t n,
const char* name=
"vector",
403 const char* prefix=
"");
408 const char* prefix=
"");
418 template <
typename Predicate>
479 #endif // #ifndef SWIG // SWIG should skip this part
497 #ifndef DOXYGEN_SHOULD_SKIP_THIS
503 #endif // DOXYGEN_SHOULD_SKIP_THIS
505 #endif // __SGVECTOR_H__
static T twonorm(const T *x, int32_t len)
|| x ||_2
void range_fill(T start=0)
static void fill_vector(T *vec, int32_t len, T value)
SGVector< float64_t > get_real()
Eigen::Matrix< T, 1,-1, 0x1, 1,-1 > EigenRowVectorXt
T & operator[](uint64_t index)
SGVector(T *m, index_t len, index_t offset)
Eigen::Map< EigenVectorXt, 0, Eigen::Stride< 0, 0 > > EigenVectorXtMap
void set(SGVector< T > orig)
bool equals(SGVector< T > &other)
SGVector< float64_t > get_imag()
void random(T min_value, T max_value)
void display_size() const
const T & operator[](int32_t index) const
void scale(T alpha)
Scale vector inplace.
const T & get_element(index_t index)
static SGMatrix< T > convert_to_matrix(SGVector< T > vector, index_t nrows, index_t ncols, bool fortran_order)
static T qnorm(T *x, int32_t len, float64_t q)
|| x ||_q
static void scale_vector(T alpha, T *vec, int32_t len)
Scale vector inplace.
void display_vector(const char *name="vector", const char *prefix="") const
static T * clone_vector(const T *vec, int32_t len)
void set_element(const T &p_element, index_t index)
SGVector< index_t > find_if(Predicate p)
static T product(T *vec, int32_t len)
Return the product of the vectors elements.
static T sum_abs(T *vec, int32_t len)
return sum(abs(vec))
const T & operator[](uint64_t index) const
static void vector_multiply(T *target, const T *v1, const T *v2, int32_t len)
Compute vector multiplication.
static void add_scalar(T alpha, T *vec, int32_t len)
Add scalar to vector inplace.
shogun reference count managed data
static void range_fill_vector(T *vec, int32_t len, T start=0)
A File access base class.
static T sum(T *vec, int32_t len)
Return sum(vec)
T & operator[](int32_t index)
SGVector< T > operator+=(SGVector< T > x)
T & operator[](uint32_t index)
static void vec1_plus_scalar_times_vec2(T *vec1, const T scalar, const T *vec2, int32_t n)
x=x+alpha*y
static T sum(SGVector< T > vec)
Return sum(vec)
index_t find_position_to_insert(T element)
all of classes and functions are contained in the shogun namespace
SGVector< T > operator+(SGVector< T > x)
T product()
Return product(vec)
SGVector< T > clone() const
template class SGSparseVector The assumtion is that the stored SGSparseVectorEntry* vector is orde...
T & operator[](int64_t index)
virtual void copy_data(const SGReferencedData &orig)
Eigen::Matrix< T,-1, 1, 0,-1, 1 > EigenVectorXt
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
void resize_vector(int32_t n)
static void add(T *target, T alpha, const T *v1, T beta, const T *v2, int32_t len)
target=alpha*vec1 + beta*vec2
const T & operator[](uint32_t index) const
const T & operator[](int64_t index) const
Eigen::Map< EigenRowVectorXt, 0, Eigen::Stride< 0, 0 > > EigenRowVectorXtMap
SGVector< index_t > find(T elem)
static int32_t unique(T *output, int32_t size)
void set_const(T const_elem)
void add(const SGVector< T > x)
static void random_vector(T *vec, int32_t len, T min_value, T max_value)