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/config.h>
18 
19 #include <shogun/lib/common.h>
20 
21 #define PT_NOT_GENERIC PT_SGOBJECT
22 
23 namespace shogun
24 {
25 
26 #ifndef DOXYGEN_SHOULD_SKIP_THIS
27 enum EContainerType
28 {
29  CT_SCALAR=0,
30  CT_VECTOR=1,
31  CT_MATRIX=2,
32  CT_NDARRAY=3,
33  CT_SGVECTOR=4,
34  CT_SGMATRIX=5,
35  CT_UNDEFINED=6
36 };
37 
38 enum EStructType
39 {
40  ST_NONE=0,
41  ST_STRING=1,
42  ST_SPARSE=2,
43  ST_UNDEFINED=3
44 };
45 
46 enum EPrimitiveType
47 {
48  PT_BOOL=0,
49  PT_CHAR=1,
50  PT_INT8=2,
51  PT_UINT8=3,
52  PT_INT16=4,
53  PT_UINT16=5,
54  PT_INT32=6,
55  PT_UINT32=7,
56  PT_INT64=8,
57  PT_UINT64=9,
58  PT_FLOAT32=10,
59  PT_FLOAT64=11,
60  PT_FLOATMAX=12,
61  PT_SGOBJECT=13,
62  PT_COMPLEX128=14,
63  PT_UNDEFINED=15
64 };
65 #endif
66 
69 {
71  EContainerType m_ctype;
73  EStructType m_stype;
75  EPrimitiveType m_ptype;
76 
81 
87  explicit TSGDataType(EContainerType ctype, EStructType stype,
88  EPrimitiveType ptype);
95  explicit TSGDataType(EContainerType ctype, EStructType stype,
96  EPrimitiveType ptype, index_t* length);
104  explicit TSGDataType(EContainerType ctype, EStructType stype,
105  EPrimitiveType ptype, index_t* length_y,
106  index_t* length_x);
107 
113  bool equals(TSGDataType other);
114 
120 
122  bool operator==(const TSGDataType& a);
126  inline bool operator!=(const TSGDataType& a)
127  {
128  return !(*this == a);
129  }
130 
135  void to_string(char* dest, size_t n) const;
136 
138  size_t sizeof_stype() const;
140  size_t sizeof_ptype() const;
141 
147  static size_t sizeof_ptype(EPrimitiveType ptype);
148 
156  static size_t sizeof_stype(EStructType stype, EPrimitiveType ptype);
157 
161  static size_t sizeof_sparseentry(EPrimitiveType ptype);
162 
166  static size_t offset_sparseentry(EPrimitiveType ptype);
167 
174  static void stype_to_string(char* dest, EStructType stype,
175  EPrimitiveType ptype, size_t n);
181  static void ptype_to_string(char* dest, EPrimitiveType ptype,
182  size_t n);
187  static bool string_to_ptype(EPrimitiveType* ptype,
188  const char* str);
189 
193  size_t get_size();
194 
198  int64_t get_num_elements();
199 };
200 }
201 #endif /* __DATATYPE_H__ */

SHOGUN Machine Learning Toolbox - Documentation