SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
List of all members | Public Member Functions | Public Attributes | Protected Member Functions
SGNDArray< T > Class Template Reference

Detailed Description

template<class T>
class shogun::SGNDArray< T >

shogun n-dimensional array

Definition at line 25 of file SGNDArray.h.

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

Public Member Functions

 SGNDArray ()
 
 SGNDArray (T *a, index_t *d, index_t nd, bool ref_counting=true)
 
 SGNDArray (index_t *d, index_t nd, bool ref_counting=true)
 
 SGNDArray (SGVector< index_t > d, bool ref_counting=true)
 
 SGNDArray (const SGNDArray &orig)
 
virtual ~SGNDArray ()
 
SGNDArray< T > clone () const
 
T * get_matrix (index_t matIdx) const
 
void transpose_matrix (index_t matIdx) const
 
const T & operator[] (index_t index) const
 
T & operator[] (index_t index)
 
SGVector< index_tget_dimensions () const
 
void set_const (T const_elem)
 
SGNDArray< T > & operator*= (T val)
 
SGNDArray< T > & operator+= (SGNDArray &ndarray)
 
SGNDArray< T > & operator-= (SGNDArray &ndarray)
 
max_element (index_t &max_at)
 
void expand (SGNDArray &big_array, SGVector< index_t > &axes)
 
get_value (SGVector< index_t > index) const
 
void next_index (SGVector< index_t > &curr_index) const
 
template<>
SGNDArray< bool > & operator*= (bool val)
 
template<>
SGNDArray< char > & operator*= (char val)
 
template<>
SGNDArray< bool > & operator+= (SGNDArray &ndarray)
 
template<>
SGNDArray< char > & operator+= (SGNDArray &ndarray)
 
template<>
SGNDArray< bool > & operator-= (SGNDArray &ndarray)
 
template<>
SGNDArray< char > & operator-= (SGNDArray &ndarray)
 
template<>
bool max_element (int32_t &max_at)
 
template<>
char max_element (int32_t &max_at)
 
int32_t ref_count ()
 

Public Attributes

T * array
 
index_tdims
 
index_t num_dims
 
index_t len_array
 

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

Constructor & Destructor Documentation

SGNDArray ( )

default constructor

Definition at line 20 of file SGNDArray.cpp.

SGNDArray ( T *  a,
index_t d,
index_t  nd,
bool  ref_counting = true 
)

constructor for setting params

Parameters
adata of the array
ddimentions of the array
ndnumber of dimentions
ref_countingif true, count the reference

Definition at line 26 of file SGNDArray.cpp.

SGNDArray ( index_t d,
index_t  nd,
bool  ref_counting = true 
)

constructor to create new ndarray in memory

Parameters
ddimentions of the array
ndnumber of dimentions
ref_countingif true, count the reference

Definition at line 39 of file SGNDArray.cpp.

SGNDArray ( SGVector< index_t d,
bool  ref_counting = true 
)

constructor to create new ndarray of given bases

Parameters
ddimentions of the array
ref_countingif true, count the reference

Definition at line 50 of file SGNDArray.cpp.

SGNDArray ( const SGNDArray< T > &  orig)

copy constructor

Parameters
origthe original N-d array

Definition at line 67 of file SGNDArray.cpp.

~SGNDArray ( )
virtual

empty destructor

Definition at line 73 of file SGNDArray.cpp.

Member Function Documentation

SGNDArray< T > clone ( ) const
Returns
the cloned N-d array

Definition at line 105 of file SGNDArray.cpp.

void copy_data ( const SGReferencedData orig)
protectedvirtual

copy data

Implements SGReferencedData.

Definition at line 78 of file SGNDArray.cpp.

void copy_refcount ( const SGReferencedData orig)
protectedinherited

copy refcount

Definition at line 55 of file SGReferencedData.cpp.

void expand ( SGNDArray< T > &  big_array,
SGVector< index_t > &  axes 
)

expand to a big size array

Parameters
big_arraythe target big size array
axesthe axis where the current ndarray will be replicated

Definition at line 303 of file SGNDArray.cpp.

void free_data ( )
protectedvirtual

free data

Implements SGReferencedData.

Definition at line 94 of file SGNDArray.cpp.

SGVector< index_t > get_dimensions ( ) const
Returns
dimentions of the N-d array

Definition at line 112 of file SGNDArray.cpp.

T* get_matrix ( index_t  matIdx) const

get a matrix formed by the two first dimensions

Parameters
matIdxmatrix index
Returns
pointer to the matrix

Definition at line 72 of file SGNDArray.h.

T get_value ( SGVector< index_t index) const

get the value at index

Parameters
indexvector of indices where the value to retrieve of the array is located
Returns
the value at index

Definition at line 266 of file SGNDArray.cpp.

void init_data ( )
protectedvirtual

init data

Implements SGReferencedData.

Definition at line 86 of file SGNDArray.cpp.

T max_element ( index_t max_at)

find the maximum value of the elements

Parameters
max_atthe index of the maximum element, index is in 1-d flattend array. If there are multiple maximum element, return the last index.
Returns
the maximum value

Definition at line 232 of file SGNDArray.cpp.

bool max_element ( int32_t &  max_at)

Definition at line 252 of file SGNDArray.cpp.

char max_element ( int32_t &  max_at)

Definition at line 259 of file SGNDArray.cpp.

void next_index ( SGVector< index_t > &  curr_index) const

get the next index from the current one

Parameters
curr_indexthe current index

Definition at line 286 of file SGNDArray.cpp.

SGNDArray< T > & operator*= ( val)

operator overload of multiplication assignment

Parameters
vala scalar value to multiply
Returns
the result N-d array

Definition at line 153 of file SGNDArray.cpp.

SGNDArray< bool > & operator*= ( bool  val)

Definition at line 162 of file SGNDArray.cpp.

SGNDArray< char > & operator*= ( char  val)

Definition at line 169 of file SGNDArray.cpp.

SGNDArray< T > & operator+= ( SGNDArray< T > &  ndarray)

operator overload of addition assignment

Parameters
ndarrayN-d array to add
Returns
the result N-d array

Definition at line 176 of file SGNDArray.cpp.

SGNDArray< bool > & operator+= ( SGNDArray< T > &  ndarray)

Definition at line 190 of file SGNDArray.cpp.

SGNDArray< char > & operator+= ( SGNDArray< T > &  ndarray)

Definition at line 197 of file SGNDArray.cpp.

SGNDArray< T > & operator-= ( SGNDArray< T > &  ndarray)

operator overload of subtruction assignment

Parameters
ndarrayN-d array to add
Returns
the result N-d array

Definition at line 204 of file SGNDArray.cpp.

SGNDArray< bool > & operator-= ( SGNDArray< T > &  ndarray)

Definition at line 218 of file SGNDArray.cpp.

SGNDArray< char > & operator-= ( SGNDArray< T > &  ndarray)

Definition at line 225 of file SGNDArray.cpp.

const T& operator[] ( index_t  index) const

operator overload for ndarray read only access

Parameters
indexto access

Definition at line 88 of file SGNDArray.h.

T& operator[] ( index_t  index)

operator overload for ndarray r/w access

Parameters
indexto access

Definition at line 97 of file SGNDArray.h.

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

set N-d array to a constant

Parameters
const_elemconstant value to set N-d array to

Definition at line 146 of file SGNDArray.cpp.

void transpose_matrix ( index_t  matIdx) const

transposes a matrix formed by the two first dimensions

Parameters
matIdxmatrix index

Definition at line 122 of file SGNDArray.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.

Member Data Documentation

T* array

array

Definition at line 174 of file SGNDArray.h.

index_t* dims

dimension sizes

Definition at line 177 of file SGNDArray.h.

index_t len_array

the flatten length of the N-d array

Definition at line 183 of file SGNDArray.h.

index_t num_dims

number of dimensions

Definition at line 180 of file SGNDArray.h.


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

SHOGUN Machine Learning Toolbox - Documentation