SHOGUN  3.2.1
 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 Jose Iglesias Garcia
8  * Written (W) 2010,2012 Soeren Sonnenburg
9  * Written (W) 2011-2013 Heiko Strathmann
10  * Copyright (C) 2010 Berlin Institute of Technology
11  * Copyright (C) 2012 Soeren Sonnenburg
12  */
13 
14 #ifndef __DATATYPE_H__
15 #define __DATATYPE_H__
16 
17 #include <shogun/lib/common.h>
18 #include <shogun/io/SGIO.h>
19 
20 #define PT_NOT_GENERIC PT_SGOBJECT
21 
22 namespace shogun
23 {
24 
25 #ifndef DOXYGEN_SHOULD_SKIP_THIS
26 enum EContainerType
27 {
28  CT_SCALAR=0,
29  CT_VECTOR=1,
30  CT_MATRIX=2,
31  CT_NDARRAY=3,
32  CT_SGVECTOR=4,
33  CT_SGMATRIX=5,
34  CT_UNDEFINED=6
35 };
36 
37 enum EStructType
38 {
39  ST_NONE=0,
40  ST_STRING=1,
41  ST_SPARSE=2,
42  ST_UNDEFINED=3
43 };
44 
45 enum EPrimitiveType
46 {
47  PT_BOOL=0,
48  PT_CHAR=1,
49  PT_INT8=2,
50  PT_UINT8=3,
51  PT_INT16=4,
52  PT_UINT16=5,
53  PT_INT32=6,
54  PT_UINT32=7,
55  PT_INT64=8,
56  PT_UINT64=9,
57  PT_FLOAT32=10,
58  PT_FLOAT64=11,
59  PT_FLOATMAX=12,
60  PT_SGOBJECT=13,
61  PT_COMPLEX128=14,
62  PT_UNDEFINED=15
63 };
64 #endif
65 
68 {
70  EContainerType m_ctype;
72  EStructType m_stype;
74  EPrimitiveType m_ptype;
75 
80 
86  explicit TSGDataType(EContainerType ctype, EStructType stype,
87  EPrimitiveType ptype);
94  explicit TSGDataType(EContainerType ctype, EStructType stype,
95  EPrimitiveType ptype, index_t* length);
103  explicit TSGDataType(EContainerType ctype, EStructType stype,
104  EPrimitiveType ptype, index_t* length_y,
105  index_t* length_x);
106 
112  bool equals(TSGDataType other);
113 
119 
121  bool operator==(const TSGDataType& a);
125  inline bool operator!=(const TSGDataType& a)
126  {
127  return !(*this == a);
128  }
129 
134  void to_string(char* dest, size_t n) const;
135 
137  size_t sizeof_stype() const;
139  size_t sizeof_ptype() const;
140 
146  static size_t sizeof_ptype(EPrimitiveType ptype);
147 
155  static size_t sizeof_stype(EStructType stype, EPrimitiveType ptype);
156 
160  static size_t sizeof_sparseentry(EPrimitiveType ptype);
161 
165  static size_t offset_sparseentry(EPrimitiveType ptype);
166 
173  static void stype_to_string(char* dest, EStructType stype,
174  EPrimitiveType ptype, size_t n);
180  static void ptype_to_string(char* dest, EPrimitiveType ptype,
181  size_t n);
186  static bool string_to_ptype(EPrimitiveType* ptype,
187  const char* str);
188 
192  size_t get_size();
193 
197  int64_t get_num_elements();
198 };
199 }
200 #endif /* __DATATYPE_H__ */
EStructType m_stype
Definition: DataType.h:72
int32_t index_t
Definition: common.h:60
static bool string_to_ptype(EPrimitiveType *ptype, const char *str)
Definition: DataType.cpp:392
static size_t offset_sparseentry(EPrimitiveType ptype)
Definition: DataType.cpp:307
index_t * m_length_x
Definition: DataType.h:79
size_t sizeof_ptype() const
Definition: DataType.cpp:182
int64_t get_num_elements()
Definition: DataType.cpp:463
bool operator!=(const TSGDataType &a)
Definition: DataType.h:125
static void ptype_to_string(char *dest, EPrimitiveType ptype, size_t n)
Definition: DataType.cpp:364
TSGDataType(EContainerType ctype, EStructType stype, EPrimitiveType ptype)
Definition: DataType.cpp:21
Datatypes that shogun supports.
Definition: DataType.h:67
bool equals_without_length(TSGDataType other)
Definition: DataType.cpp:66
static void stype_to_string(char *dest, EStructType stype, EPrimitiveType ptype, size_t n)
Definition: DataType.cpp:336
size_t sizeof_stype() const
Definition: DataType.cpp:176
bool operator==(const TSGDataType &a)
Definition: DataType.cpp:44
index_t * m_length_y
Definition: DataType.h:77
void to_string(char *dest, size_t n) const
Definition: DataType.cpp:144
EContainerType m_ctype
Definition: DataType.h:70
bool equals(TSGDataType other)
Definition: DataType.cpp:94
EPrimitiveType m_ptype
Definition: DataType.h:74
static size_t sizeof_sparseentry(EPrimitiveType ptype)
Definition: DataType.cpp:278

SHOGUN Machine Learning Toolbox - Documentation