Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef __DATATYPE_H__
00014 #define __DATATYPE_H__
00015
00016 #include <shogun/lib/common.h>
00017 #include <shogun/io/SGIO.h>
00018
00019 #define PT_NOT_GENERIC PT_SGOBJECT
00020 #define PT_LONGEST floatmax_t
00021
00022 namespace shogun
00023 {
00024
00025
00026 template<class T> class CCache;
00027
00029 typedef int32_t index_t;
00030
00031
00032 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00033 enum EContainerType
00034 {
00035 CT_SCALAR=0,
00036 CT_VECTOR=1,
00037 CT_MATRIX=2,
00038 CT_NDARRAY=3,
00039 CT_SGVECTOR=4,
00040 CT_SGMATRIX=5
00041 };
00042
00043 enum EStructType
00044 {
00045 ST_NONE=0,
00046 ST_STRING=1,
00047 ST_SPARSE=2
00048 };
00049
00050 enum EPrimitiveType
00051 {
00052 PT_BOOL=0,
00053 PT_CHAR=1,
00054 PT_INT8=2,
00055 PT_UINT8=3,
00056 PT_INT16=4,
00057 PT_UINT16=5,
00058 PT_INT32=6,
00059 PT_UINT32=7,
00060 PT_INT64=8,
00061 PT_UINT64=9,
00062 PT_FLOAT32=10,
00063 PT_FLOAT64=11,
00064 PT_FLOATMAX=12,
00065 PT_SGOBJECT=13
00066 };
00067 #endif
00068
00070 struct TSGDataType
00071 {
00073 EContainerType m_ctype;
00075 EStructType m_stype;
00077 EPrimitiveType m_ptype;
00078
00080 index_t *m_length_y;
00082 index_t *m_length_x;
00083
00089 explicit TSGDataType(EContainerType ctype, EStructType stype,
00090 EPrimitiveType ptype);
00097 explicit TSGDataType(EContainerType ctype, EStructType stype,
00098 EPrimitiveType ptype, index_t* length);
00106 explicit TSGDataType(EContainerType ctype, EStructType stype,
00107 EPrimitiveType ptype, index_t* length_y,
00108 index_t* length_x);
00109
00111 bool operator==(const TSGDataType& a);
00115 inline bool operator!=(const TSGDataType& a)
00116 {
00117 return !(*this == a);
00118 }
00119
00124 void to_string(char* dest, size_t n) const;
00125
00127 size_t sizeof_stype() const;
00129 size_t sizeof_ptype() const;
00130
00134 static size_t sizeof_sparseentry(EPrimitiveType ptype);
00135
00139 static size_t offset_sparseentry(EPrimitiveType ptype);
00140
00147 static void stype_to_string(char* dest, EStructType stype,
00148 EPrimitiveType ptype, size_t n);
00154 static void ptype_to_string(char* dest, EPrimitiveType ptype,
00155 size_t n);
00160 static bool string_to_ptype(EPrimitiveType* ptype,
00161 const char* str);
00162
00166 size_t get_size();
00167
00171 index_t get_num_elements();
00172 };
00173 }
00174 #endif