SHOGUN  v3.2.0
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 
SGNDArray.h
浏览该文件的文档.
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>
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[int64_t(matIdx)*int64_t(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 
94 
97 };
98 }
99 #endif // __SGNDARRAY_H__
void transpose_matrix(index_t matIdx) const
Definition: SGNDArray.cpp:79
virtual void init_data()
Definition: SGNDArray.cpp:62
T & operator[](index_t index)
Definition: SGNDArray.h:71
int32_t index_t
Definition: common.h:60
virtual ~SGNDArray()
Definition: SGNDArray.cpp:50
T * get_matrix(index_t matIdx) const
Definition: SGNDArray.h:46
#define ASSERT(x)
Definition: SGIO.h:203
virtual void free_data()
Definition: SGNDArray.cpp:69
shogun reference count managed data
index_t num_dims
Definition: SGNDArray.h:96
virtual void copy_data(const SGReferencedData &orig)
Definition: SGNDArray.cpp:55
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:16
index_t * dims
Definition: SGNDArray.h:93
const T & operator[](index_t index) const
Definition: SGNDArray.h:62
shogun n-dimensional array
Definition: SGNDArray.h:23

SHOGUN Machine Learning Toolbox - Documentation