SHOGUN
v3.0.0
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
shogun
lib
SGNDArray.h
Go to the documentation of this file.
1
/*
2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation; either version 3 of the License, or
5
* (at your option) any later version.
6
*
7
* Written (W) 2012 Fernando José Iglesias García
8
* Written (W) 2010,2012 Soeren Sonnenburg
9
* Copyright (C) 2010 Berlin Institute of Technology
10
* Copyright (C) 2012 Soeren Sonnenburg
11
*/
12
13
#ifndef __SGNDARRAY_H__
14
#define __SGNDARRAY_H__
15
16
#include <
shogun/lib/config.h
>
17
#include <
shogun/lib/DataType.h
>
18
#include <
shogun/lib/SGReferencedData.h
>
19
20
namespace
shogun
21
{
23
template
<
class
T>
class
SGNDArray
:
public
SGReferencedData
24
{
25
public
:
27
SGNDArray
();
28
30
SGNDArray
(T* a,
index_t
* d,
index_t
nd,
bool
ref_counting=
true
);
31
33
SGNDArray
(
index_t
* d,
index_t
nd,
bool
ref_counting=
true
);
34
36
SGNDArray
(
const
SGNDArray
&orig);
37
39
virtual
~SGNDArray
();
40
46
T*
get_matrix
(
index_t
matIdx)
const
47
{
48
ASSERT
(
array
&&
dims
&&
num_dims
> 2 &&
dims
[2] > matIdx)
49
return
&
array
[matIdx*
dims
[0]*
dims
[1]];
50
}
51
56
void
transpose_matrix
(
index_t
matIdx)
const
;
57
62
inline
const
T&
operator[]
(
index_t
index)
const
63
{
64
return
array
[index];
65
}
66
71
inline
T&
operator[]
(
index_t
index)
72
{
73
return
array
[index];
74
}
75
76
protected
:
77
79
virtual
void
copy_data
(
const
SGReferencedData
&orig);
80
82
virtual
void
init_data
();
83
85
virtual
void
free_data
();
86
87
public
:
88
90
T*
array
;
91
93
index_t
*
dims
;
94
96
index_t
num_dims
;
97
};
98
}
99
#endif // __SGNDARRAY_H__
SHOGUN
Machine Learning Toolbox - Documentation