SHOGUN  v3.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
DataType.h
Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Written (W) 2012 Fernando Jose Iglesias Garcia
00008  * Written (W) 2010,2012 Soeren Sonnenburg
00009  * Written (W) 2011-2013 Heiko Strathmann
00010  * Copyright (C) 2010 Berlin Institute of Technology
00011  * Copyright (C) 2012 Soeren Sonnenburg
00012  */
00013 
00014 #ifndef __DATATYPE_H__
00015 #define __DATATYPE_H__
00016 
00017 #include <shogun/lib/common.h>
00018 #include <shogun/io/SGIO.h>
00019 
00020 #define PT_NOT_GENERIC  PT_SGOBJECT
00021 
00022 namespace shogun
00023 {
00024 
00025 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00026 enum EContainerType
00027 {
00028     CT_SCALAR=0,
00029     CT_VECTOR=1,
00030     CT_MATRIX=2,
00031     CT_NDARRAY=3,
00032     CT_SGVECTOR=4,
00033     CT_SGMATRIX=5,
00034     CT_UNDEFINED=6
00035 };
00036 
00037 enum EStructType
00038 {
00039     ST_NONE=0,
00040     ST_STRING=1,
00041     ST_SPARSE=2,
00042     ST_UNDEFINED=3
00043 };
00044 
00045 enum EPrimitiveType
00046 {
00047     PT_BOOL=0,
00048     PT_CHAR=1,
00049     PT_INT8=2,
00050     PT_UINT8=3,
00051     PT_INT16=4,
00052     PT_UINT16=5,
00053     PT_INT32=6,
00054     PT_UINT32=7,
00055     PT_INT64=8,
00056     PT_UINT64=9,
00057     PT_FLOAT32=10,
00058     PT_FLOAT64=11,
00059     PT_FLOATMAX=12,
00060     PT_SGOBJECT=13,
00061     PT_COMPLEX128=14,
00062     PT_UNDEFINED=15
00063 };
00064 #endif
00065 
00067 struct TSGDataType
00068 {
00070     EContainerType m_ctype;
00072     EStructType m_stype;
00074     EPrimitiveType m_ptype;
00075 
00077     index_t *m_length_y;
00079     index_t *m_length_x;
00080 
00086     explicit TSGDataType(EContainerType ctype, EStructType stype,
00087                          EPrimitiveType ptype);
00094     explicit TSGDataType(EContainerType ctype, EStructType stype,
00095                          EPrimitiveType ptype, index_t* length);
00103     explicit TSGDataType(EContainerType ctype, EStructType stype,
00104                          EPrimitiveType ptype, index_t* length_y,
00105                          index_t* length_x);
00106 
00112     bool equals(TSGDataType other);
00113 
00118     bool equals_without_length(TSGDataType other);
00119 
00121     bool operator==(const TSGDataType& a);
00125     inline bool operator!=(const TSGDataType& a)
00126     {
00127         return !(*this == a);
00128     }
00129 
00134     void to_string(char* dest, size_t n) const;
00135 
00137     size_t sizeof_stype() const;
00139     size_t sizeof_ptype() const;
00140 
00146     static size_t sizeof_ptype(EPrimitiveType ptype);
00147 
00155     static size_t sizeof_stype(EStructType stype, EPrimitiveType ptype);
00156 
00160     static size_t sizeof_sparseentry(EPrimitiveType ptype);
00161 
00165     static size_t offset_sparseentry(EPrimitiveType ptype);
00166 
00173     static void stype_to_string(char* dest, EStructType stype,
00174                                 EPrimitiveType ptype, size_t n);
00180     static void ptype_to_string(char* dest, EPrimitiveType ptype,
00181                                 size_t n);
00186     static bool string_to_ptype(EPrimitiveType* ptype,
00187                                 const char* str);
00188 
00192     size_t get_size();
00193 
00197     int64_t get_num_elements();
00198 };
00199 }
00200 #endif /* __DATATYPE_H__  */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation