Public Member Functions | Protected Attributes

CArray2< T > Class Template Reference


Detailed Description

template<class T>
class shogun::CArray2< T >

Template class Array2 implements a dense two dimensional array.

Note that depending on compile options everything will be inlined, such that this is as high performance 2d-array implementation without error checking.

Definition at line 28 of file Array2.h.

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

List of all members.

Public Member Functions

 CArray2 (int32_t dim1=1, int32_t dim2=1)
 CArray2 (T *p_array, int32_t dim1, int32_t dim2, bool p_free_array=true, bool p_copy_array=false)
 CArray2 (const T *p_array, int32_t dim1, int32_t dim2)
virtual ~CArray2 ()
void get_array_size (int32_t &dim1, int32_t &dim2)
int32_t get_dim1 ()
int32_t get_dim2 ()
void zero ()
void set_const (T const_elem)
T * get_array ()
void set_array_name (const char *p_name)
void set_array (T *p_array, int32_t dim1, int32_t dim2, bool p_free_array=true, bool copy_array=false)
bool resize_array (int32_t dim1, int32_t dim2)
const T & get_element (int32_t idx1, int32_t idx2) const
bool set_element (const T &p_element, int32_t idx1, int32_t idx2)
const T & element (int32_t idx1, int32_t idx2) const
T & element (int32_t idx1, int32_t idx2)
T & element (T *p_array, int32_t idx1, int32_t idx2)
T & element (T *p_array, int32_t idx1, int32_t idx2, int32_t p_dim1_size)
CArray2< T > & operator= (CArray2< T > &orig)
void display_array () const
void display_size () const
virtual const char * get_name ()

Protected Attributes

int32_t dim1_size
int32_t dim2_size

Constructor & Destructor Documentation

CArray2 ( int32_t  dim1 = 1,
int32_t  dim2 = 1 
)

constructor

Parameters:
dim1 dimension 1
dim2 dimension 2

Definition at line 36 of file Array2.h.

CArray2 ( T *  p_array,
int32_t  dim1,
int32_t  dim2,
bool  p_free_array = true,
bool  p_copy_array = false 
)

constructor

Parameters:
p_array another array
dim1 dimension 1
dim2 dimension 2
p_free_array if array must be freed
p_copy_array if array must be copied

Definition at line 49 of file Array2.h.

CArray2 ( const T *  p_array,
int32_t  dim1,
int32_t  dim2 
)

constructor

Parameters:
p_array another array
dim1 dimension 1
dim2 dimension 2

Definition at line 61 of file Array2.h.

virtual ~CArray2 (  )  [virtual]

Definition at line 66 of file Array2.h.


Member Function Documentation

void display_array (  )  const

display array

Reimplemented from CArray< T >.

Definition at line 243 of file Array2.h.

void display_size (  )  const

display array size

Reimplemented from CArray< T >.

Definition at line 259 of file Array2.h.

const T& element ( int32_t  idx1,
int32_t  idx2 
) const

get array element at index

Parameters:
idx1 index 1
idx2 index 2
Returns:
array element at index

Definition at line 179 of file Array2.h.

T& element ( int32_t  idx1,
int32_t  idx2 
)

get array element at index

Parameters:
idx1 index 1
idx2 index 2
Returns:
array element at index

Definition at line 190 of file Array2.h.

T& element ( T *  p_array,
int32_t  idx1,
int32_t  idx2 
)

get element of given array at given index

Parameters:
p_array another array
idx1 index 1
idx2 index 2
Returns:
element of given array at given index

Definition at line 204 of file Array2.h.

T& element ( T *  p_array,
int32_t  idx1,
int32_t  idx2,
int32_t  p_dim1_size 
)

get element of given array at given index

Parameters:
p_array another array
idx1 index 1
idx2 index 2
p_dim1_size size of dimension 1
Returns:
element of given array at given index

Definition at line 220 of file Array2.h.

T* get_array ( void   ) 

get the array call get_array just before messing with it DO NOT call any [],resize/delete functions after get_array(), the pointer may become invalid !

Returns:
the array

Reimplemented from CArray< T >.

Definition at line 107 of file Array2.h.

void get_array_size ( int32_t &  dim1,
int32_t &  dim2 
)

return total array size (including granularity buffer)

Parameters:
dim1 dimension 1 will be stored here
dim2 dimension 2 will be stored here

Definition at line 73 of file Array2.h.

int32_t get_dim1 (  ) 

get dimension 1

Returns:
dimension 1

Reimplemented from CArray< T >.

Definition at line 83 of file Array2.h.

int32_t get_dim2 (  ) 

get dimension 2

Returns:
dimension 2

Definition at line 89 of file Array2.h.

const T& get_element ( int32_t  idx1,
int32_t  idx2 
) const

get array element at index

Parameters:
idx1 index 1
idx2 index 2
Returns:
array element at index

Definition at line 152 of file Array2.h.

virtual const char* get_name ( void   )  [virtual]
Returns:
object name

Implements CSGObject.

Definition at line 265 of file Array2.h.

CArray2<T>& operator= ( CArray2< T > &  orig  ) 

operator overload for array assignment

Parameters:
orig original array
Returns:
new array

Definition at line 234 of file Array2.h.

bool resize_array ( int32_t  dim1,
int32_t  dim2 
)

resize array

Parameters:
dim1 new dimension 1
dim2 new dimension 2
Returns:
if resizing was successful

Definition at line 139 of file Array2.h.

void set_array ( T *  p_array,
int32_t  dim1,
int32_t  dim2,
bool  p_free_array = true,
bool  copy_array = false 
)

set the array pointer and free previously allocated memory

Parameters:
p_array another array
dim1 dimension 1
dim2 dimensino 2
p_free_array if array must be freed
copy_array if array must be copied

Definition at line 126 of file Array2.h.

void set_array_name ( const char *  p_name  ) 

set array's name

Parameters:
p_name new name

Reimplemented from CArray< T >.

Definition at line 113 of file Array2.h.

void set_const ( const_elem  ) 

set array with a constant

Reimplemented from CArray< T >.

Definition at line 95 of file Array2.h.

bool set_element ( const T &  p_element,
int32_t  idx1,
int32_t  idx2 
)

set array element at index 'index'

Parameters:
p_element array element
idx1 index 1
idx2 index 2
Returns:
if setting was successful

Definition at line 166 of file Array2.h.

void zero (  ) 

zero array

Reimplemented from CArray< T >.

Definition at line 92 of file Array2.h.


Member Data Documentation

int32_t dim1_size [protected]

size of array's dimension 1

Definition at line 269 of file Array2.h.

int32_t dim2_size [protected]

size of array's dimension 2

Definition at line 271 of file Array2.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation