SHOGUN  v2.1.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 
21 namespace shogun
22 {
23 
24 #ifndef DOXYGEN_SHOULD_SKIP_THIS
25 enum EContainerType
26 {
27  CT_SCALAR=0,
28  CT_VECTOR=1,
29  CT_MATRIX=2,
30  CT_NDARRAY=3,
31  CT_SGVECTOR=4,
32  CT_SGMATRIX=5
33 };
34 
35 enum EStructType
36 {
37  ST_NONE=0,
38  ST_STRING=1,
39  ST_SPARSE=2
40 };
41 
42 enum EPrimitiveType
43 {
44  PT_BOOL=0,
45  PT_CHAR=1,
46  PT_INT8=2,
47  PT_UINT8=3,
48  PT_INT16=4,
49  PT_UINT16=5,
50  PT_INT32=6,
51  PT_UINT32=7,
52  PT_INT64=8,
53  PT_UINT64=9,
54  PT_FLOAT32=10,
55  PT_FLOAT64=11,
56  PT_FLOATMAX=12,
57  PT_SGOBJECT=13
58 };
59 #endif
60 
63 {
65  EContainerType m_ctype;
67  EStructType m_stype;
69  EPrimitiveType m_ptype;
70 
75 
81  explicit TSGDataType(EContainerType ctype, EStructType stype,
82  EPrimitiveType ptype);
89  explicit TSGDataType(EContainerType ctype, EStructType stype,
90  EPrimitiveType ptype, index_t* length);
98  explicit TSGDataType(EContainerType ctype, EStructType stype,
99  EPrimitiveType ptype, index_t* length_y,
100  index_t* length_x);
101 
103  bool operator==(const TSGDataType& a);
107  inline bool operator!=(const TSGDataType& a)
108  {
109  return !(*this == a);
110  }
111 
116  void to_string(char* dest, size_t n) const;
117 
119  size_t sizeof_stype() const;
121  size_t sizeof_ptype() const;
122 
126  static size_t sizeof_sparseentry(EPrimitiveType ptype);
127 
131  static size_t offset_sparseentry(EPrimitiveType ptype);
132 
139  static void stype_to_string(char* dest, EStructType stype,
140  EPrimitiveType ptype, size_t n);
146  static void ptype_to_string(char* dest, EPrimitiveType ptype,
147  size_t n);
152  static bool string_to_ptype(EPrimitiveType* ptype,
153  const char* str);
154 
158  size_t get_size();
159 
163  int64_t get_num_elements();
164 };
165 }
166 #endif /* __DATATYPE_H__ */

SHOGUN Machine Learning Toolbox - Documentation