C++ API Reference for Intel® Data Analytics Acceleration Library 2018 Update 3

data_utils.h
1 /* file: data_utils.h */
2 /*******************************************************************************
3 * Copyright 2014-2018 Intel Corporation.
4 *
5 * This software and the related documents are Intel copyrighted materials, and
6 * your use of them is governed by the express license under which they were
7 * provided to you (License). Unless the License provides otherwise, you may not
8 * use, modify, copy, publish, distribute, disclose or transmit this software or
9 * the related documents without Intel's prior written permission.
10 *
11 * This software and the related documents are provided as is, with no express
12 * or implied warranties, other than those that are expressly stated in the
13 * License.
14 *******************************************************************************/
15 
16 /*
17 //++
18 // Implementation of data dictionary utilities.
19 //--
20 */
21 
22 #ifndef __DATA_UTILS_H__
23 #define __DATA_UTILS_H__
24 
25 #include <string>
26 #include <climits>
27 #include <cfloat>
28 #include "services/daal_defines.h"
29 
30 namespace daal
31 {
32 namespace data_management
33 {
37 namespace data_feature_utils
38 {
43 enum IndexNumType
44 {
45  DAAL_FLOAT32 = 0,
46  DAAL_FLOAT64 = 1,
47  DAAL_INT32_S = 2,
48  DAAL_INT32_U = 3,
49  DAAL_INT64_S = 4,
50  DAAL_INT64_U = 5,
51  DAAL_INT8_S = 6,
52  DAAL_INT8_U = 7,
53  DAAL_INT16_S = 8,
54  DAAL_INT16_U = 9,
55  DAAL_OTHER_T = 10
56 };
57 const int NumOfIndexNumTypes = (int)DAAL_OTHER_T;
58 
59 enum InternalNumType { DAAL_SINGLE = 0, DAAL_DOUBLE = 1, DAAL_INT32 = 2, DAAL_OTHER = 0xfffffff };
60 enum PMMLNumType { DAAL_GEN_FLOAT = 0, DAAL_GEN_DOUBLE = 1, DAAL_GEN_INTEGER = 2, DAAL_GEN_BOOLEAN = 3,
61  DAAL_GEN_STRING = 4, DAAL_GEN_UNKNOWN = 0xfffffff
62  };
63 enum FeatureType { DAAL_CATEGORICAL = 0, DAAL_ORDINAL = 1, DAAL_CONTINUOUS = 2 };
64 
69 template<typename T> inline IndexNumType getIndexNumType() { return DAAL_OTHER_T; }
70 template<> inline IndexNumType getIndexNumType<float>() { return DAAL_FLOAT32; }
71 template<> inline IndexNumType getIndexNumType<double>() { return DAAL_FLOAT64; }
72 template<> inline IndexNumType getIndexNumType<int>() { return DAAL_INT32_S; }
73 template<> inline IndexNumType getIndexNumType<unsigned int>() { return DAAL_INT32_U; }
74 template<> inline IndexNumType getIndexNumType<DAAL_INT64>() { return DAAL_INT64_S; }
75 template<> inline IndexNumType getIndexNumType<DAAL_UINT64>() { return DAAL_INT64_U; }
76 template<> inline IndexNumType getIndexNumType<char>() { return DAAL_INT8_S; }
77 template<> inline IndexNumType getIndexNumType<unsigned char>() { return DAAL_INT8_U; }
78 template<> inline IndexNumType getIndexNumType<short>() { return DAAL_INT16_S; }
79 template<> inline IndexNumType getIndexNumType<unsigned short>() { return DAAL_INT16_U; }
80 
81 template<> inline IndexNumType getIndexNumType<long>()
82 { return (IndexNumType)(DAAL_INT32_S + (sizeof(long) / 4 - 1) * 2); }
83 
84 #if (defined(__APPLE__) || defined(__MACH__)) && !defined(__x86_64__)
85 template<> inline IndexNumType getIndexNumType<unsigned long>()
86 { return (IndexNumType)(DAAL_INT32_U + (sizeof(unsigned long) / 4 - 1) * 2); }
87 #endif
88 
89 #if !(defined(_WIN32) || defined(_WIN64)) && defined(__x86_64__)
90 template<> inline IndexNumType getIndexNumType<size_t>()
91 { return (IndexNumType)(DAAL_INT32_U + (sizeof(size_t) / 4 - 1) * 2); }
92 #endif
93 
97 template<typename T>
98 inline InternalNumType getInternalNumType() { return DAAL_OTHER; }
99 template<>
100 inline InternalNumType getInternalNumType<int>() { return DAAL_INT32; }
101 template<>
102 inline InternalNumType getInternalNumType<double>() { return DAAL_DOUBLE; }
103 template<>
104 inline InternalNumType getInternalNumType<float>() { return DAAL_SINGLE; }
105 
109 template<typename T>
110 inline PMMLNumType getPMMLNumType() { return DAAL_GEN_UNKNOWN; }
111 template<>
112 inline PMMLNumType getPMMLNumType<int>() { return DAAL_GEN_INTEGER; }
113 template<>
114 inline PMMLNumType getPMMLNumType<double>() { return DAAL_GEN_DOUBLE; }
115 template<>
116 inline PMMLNumType getPMMLNumType<float>() { return DAAL_GEN_FLOAT; }
117 template<>
118 inline PMMLNumType getPMMLNumType<bool>() { return DAAL_GEN_BOOLEAN; }
119 template<>
120 inline PMMLNumType getPMMLNumType<char *>() { return DAAL_GEN_STRING; }
121 template<>
122 inline PMMLNumType getPMMLNumType<std::string>() { return DAAL_GEN_STRING; }
123 
124 typedef void(*vectorConvertFuncType)(size_t n, void *src, void *dst);
125 typedef void(*vectorStrideConvertFuncType)(size_t n, void *src, size_t srcByteStride, void *dst, size_t dstByteStride);
126 
127 DAAL_EXPORT data_feature_utils::vectorConvertFuncType getVectorUpCast(int, int);
128 DAAL_EXPORT data_feature_utils::vectorConvertFuncType getVectorDownCast(int, int);
129 
130 DAAL_EXPORT data_feature_utils::vectorStrideConvertFuncType getVectorStrideUpCast(int, int);
131 DAAL_EXPORT data_feature_utils::vectorStrideConvertFuncType getVectorStrideDownCast(int, int);
132 
135 } // namespace data_feature_utils
136 #define DataFeatureUtils data_feature_utils
137 }
138 } // namespace daal
139 #endif
daal
Definition: algorithm_base_common.h:31
daal_defines.h
daal::data_management::data_feature_utils::getInternalNumType
InternalNumType getInternalNumType()
Definition: data_utils.h:98
daal::data_management::data_feature_utils::getPMMLNumType
PMMLNumType getPMMLNumType()
Definition: data_utils.h:110
daal::data_management::data_feature_utils::getIndexNumType
IndexNumType getIndexNumType()
Definition: data_utils.h:69

For more complete information about compiler optimizations, see our Optimization Notice.