SHOGUN  v2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DataType.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 __DATATYPE_H__
14 #define __DATATYPE_H__
15 
16 #include <shogun/lib/common.h>
17 #include <shogun/io/SGIO.h>
18 
19 #define PT_NOT_GENERIC PT_SGOBJECT
20 #define PT_LONGEST floatmax_t
21 
22 namespace shogun
23 {
24 
25 //class CMath;
26 template<class T> class CCache;
27 
29 typedef int32_t index_t;
30 
31 
32 #ifndef DOXYGEN_SHOULD_SKIP_THIS
33 enum EContainerType
34 {
35  CT_SCALAR=0,
36  CT_VECTOR=1,
37  CT_MATRIX=2,
38  CT_NDARRAY=3,
39  CT_SGVECTOR=4,
40  CT_SGMATRIX=5
41 };
42 
43 enum EStructType
44 {
45  ST_NONE=0,
46  ST_STRING=1,
47  ST_SPARSE=2
48 };
49 
50 enum EPrimitiveType
51 {
52  PT_BOOL=0,
53  PT_CHAR=1,
54  PT_INT8=2,
55  PT_UINT8=3,
56  PT_INT16=4,
57  PT_UINT16=5,
58  PT_INT32=6,
59  PT_UINT32=7,
60  PT_INT64=8,
61  PT_UINT64=9,
62  PT_FLOAT32=10,
63  PT_FLOAT64=11,
64  PT_FLOATMAX=12,
65  PT_SGOBJECT=13
66 };
67 #endif
68 
71 {
73  EContainerType m_ctype;
75  EStructType m_stype;
77  EPrimitiveType m_ptype;
78 
83 
89  explicit TSGDataType(EContainerType ctype, EStructType stype,
90  EPrimitiveType ptype);
97  explicit TSGDataType(EContainerType ctype, EStructType stype,
98  EPrimitiveType ptype, index_t* length);
106  explicit TSGDataType(EContainerType ctype, EStructType stype,
107  EPrimitiveType ptype, index_t* length_y,
108  index_t* length_x);
109 
111  bool operator==(const TSGDataType& a);
115  inline bool operator!=(const TSGDataType& a)
116  {
117  return !(*this == a);
118  }
119 
124  void to_string(char* dest, size_t n) const;
125 
127  size_t sizeof_stype() const;
129  size_t sizeof_ptype() const;
130 
134  static size_t sizeof_sparseentry(EPrimitiveType ptype);
135 
139  static size_t offset_sparseentry(EPrimitiveType ptype);
140 
147  static void stype_to_string(char* dest, EStructType stype,
148  EPrimitiveType ptype, size_t n);
154  static void ptype_to_string(char* dest, EPrimitiveType ptype,
155  size_t n);
160  static bool string_to_ptype(EPrimitiveType* ptype,
161  const char* str);
162 
166  size_t get_size();
167 
172 };
173 }
174 #endif /* __DATATYPE_H__ */

SHOGUN Machine Learning Toolbox - Documentation