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

data_utils.h
1 /* file: data_utils.h */
2 /*******************************************************************************
3 * Copyright 2014-2017 Intel Corporation
4 * All Rights Reserved.
5 *
6 * If this software was obtained under the Intel Simplified Software License,
7 * the following terms apply:
8 *
9 * The source code, information and material ("Material") contained herein is
10 * owned by Intel Corporation or its suppliers or licensors, and title to such
11 * Material remains with Intel Corporation or its suppliers or licensors. The
12 * Material contains proprietary information of Intel or its suppliers and
13 * licensors. The Material is protected by worldwide copyright laws and treaty
14 * provisions. No part of the Material may be used, copied, reproduced,
15 * modified, published, uploaded, posted, transmitted, distributed or disclosed
16 * in any way without Intel's prior express written permission. No license under
17 * any patent, copyright or other intellectual property rights in the Material
18 * is granted to or conferred upon you, either expressly, by implication,
19 * inducement, estoppel or otherwise. Any license under such intellectual
20 * property rights must be express and approved by Intel in writing.
21 *
22 * Unless otherwise agreed by Intel in writing, you may not remove or alter this
23 * notice or any other notice embedded in Materials by Intel or Intel's
24 * suppliers or licensors in any way.
25 *
26 *
27 * If this software was obtained under the Apache License, Version 2.0 (the
28 * "License"), the following terms apply:
29 *
30 * You may not use this file except in compliance with the License. You may
31 * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
32 *
33 *
34 * Unless required by applicable law or agreed to in writing, software
35 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
36 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37 *
38 * See the License for the specific language governing permissions and
39 * limitations under the License.
40 *******************************************************************************/
41 
42 /*
43 //++
44 // Implementation of data dictionary utilities.
45 //--
46 */
47 
48 #ifndef __DATA_UTILS_H__
49 #define __DATA_UTILS_H__
50 
51 #include <string>
52 #include <climits>
53 #include <cfloat>
54 #include "services/daal_defines.h"
55 
56 namespace daal
57 {
58 namespace data_management
59 {
63 namespace data_feature_utils
64 {
69 enum IndexNumType
70 {
71  DAAL_FLOAT32 = 0,
72  DAAL_FLOAT64 = 1,
73  DAAL_INT32_S = 2,
74  DAAL_INT32_U = 3,
75  DAAL_INT64_S = 4,
76  DAAL_INT64_U = 5,
77  DAAL_INT8_S = 6,
78  DAAL_INT8_U = 7,
79  DAAL_INT16_S = 8,
80  DAAL_INT16_U = 9,
81  DAAL_OTHER_T = 10
82 };
83 const int NumOfIndexNumTypes = (int)DAAL_OTHER_T;
84 
85 enum InternalNumType { DAAL_SINGLE = 0, DAAL_DOUBLE = 1, DAAL_INT32 = 2, DAAL_OTHER = 0xfffffff };
86 enum PMMLNumType { DAAL_GEN_FLOAT = 0, DAAL_GEN_DOUBLE = 1, DAAL_GEN_INTEGER = 2, DAAL_GEN_BOOLEAN = 3,
87  DAAL_GEN_STRING = 4, DAAL_GEN_UNKNOWN = 0xfffffff
88  };
89 enum FeatureType { DAAL_CATEGORICAL = 0, DAAL_ORDINAL = 1, DAAL_CONTINUOUS = 2 };
90 
95 template<typename T> inline IndexNumType getIndexNumType() { return DAAL_OTHER_T; }
96 template<> inline IndexNumType getIndexNumType<float>() { return DAAL_FLOAT32; }
97 template<> inline IndexNumType getIndexNumType<double>() { return DAAL_FLOAT64; }
98 template<> inline IndexNumType getIndexNumType<int>() { return DAAL_INT32_S; }
99 template<> inline IndexNumType getIndexNumType<unsigned int>() { return DAAL_INT32_U; }
100 template<> inline IndexNumType getIndexNumType<DAAL_INT64>() { return DAAL_INT64_S; }
101 template<> inline IndexNumType getIndexNumType<DAAL_UINT64>() { return DAAL_INT64_U; }
102 template<> inline IndexNumType getIndexNumType<char>() { return DAAL_INT8_S; }
103 template<> inline IndexNumType getIndexNumType<unsigned char>() { return DAAL_INT8_U; }
104 template<> inline IndexNumType getIndexNumType<short>() { return DAAL_INT16_S; }
105 template<> inline IndexNumType getIndexNumType<unsigned short>() { return DAAL_INT16_U; }
106 
107 template<> inline IndexNumType getIndexNumType<long>()
108 { return (IndexNumType)(DAAL_INT32_S + (sizeof(long) / 4 - 1) * 2); }
109 
110 #if (defined(__APPLE__) || defined(__MACH__)) && !defined(__x86_64__)
111 template<> inline IndexNumType getIndexNumType<unsigned long>()
112 { return (IndexNumType)(DAAL_INT32_U + (sizeof(unsigned long) / 4 - 1) * 2); }
113 #endif
114 
115 #if !(defined(_WIN32) || defined(_WIN64)) && defined(__x86_64__)
116 template<> inline IndexNumType getIndexNumType<size_t>()
117 { return (IndexNumType)(DAAL_INT32_U + (sizeof(size_t) / 4 - 1) * 2); }
118 #endif
119 
123 template<typename T>
124 inline InternalNumType getInternalNumType() { return DAAL_OTHER; }
125 template<>
126 inline InternalNumType getInternalNumType<int>() { return DAAL_INT32; }
127 template<>
128 inline InternalNumType getInternalNumType<double>() { return DAAL_DOUBLE; }
129 template<>
130 inline InternalNumType getInternalNumType<float>() { return DAAL_SINGLE; }
131 
135 template<typename T>
136 inline PMMLNumType getPMMLNumType() { return DAAL_GEN_UNKNOWN; }
137 template<>
138 inline PMMLNumType getPMMLNumType<int>() { return DAAL_GEN_INTEGER; }
139 template<>
140 inline PMMLNumType getPMMLNumType<double>() { return DAAL_GEN_DOUBLE; }
141 template<>
142 inline PMMLNumType getPMMLNumType<float>() { return DAAL_GEN_FLOAT; }
143 template<>
144 inline PMMLNumType getPMMLNumType<bool>() { return DAAL_GEN_BOOLEAN; }
145 template<>
146 inline PMMLNumType getPMMLNumType<char *>() { return DAAL_GEN_STRING; }
147 template<>
148 inline PMMLNumType getPMMLNumType<std::string>() { return DAAL_GEN_STRING; }
149 
153 template<typename T>
154 inline T getMaxVal() { return 0; }
155 template<>
156 inline int getMaxVal<int>() { return INT_MAX; }
157 template<>
158 inline double getMaxVal<double>() { return DBL_MAX; }
159 template<>
160 inline float getMaxVal<float>() { return FLT_MAX; }
161 
165 template<typename T>
166 inline T getMinVal() { return 0; }
167 template<>
168 inline int getMinVal<int>() { return INT_MIN; }
169 template<>
170 inline double getMinVal<double>() { return DBL_MIN; }
171 template<>
172 inline float getMinVal<float>() { return FLT_MIN; }
173 
177 template<typename T>
178 inline T getEpsilonVal() { return 0; }
179 template<>
180 inline double getEpsilonVal<double>() { return DBL_EPSILON; }
181 template<>
182 inline float getEpsilonVal<float>() { return FLT_EPSILON; }
183 
184 typedef void(*vectorConvertFuncType)(size_t n, void *src, void *dst);
185 typedef void(*vectorStrideConvertFuncType)(size_t n, void *src, size_t srcByteStride, void *dst, size_t dstByteStride);
186 
187 DAAL_EXPORT data_feature_utils::vectorConvertFuncType getVectorUpCast(int, int);
188 DAAL_EXPORT data_feature_utils::vectorConvertFuncType getVectorDownCast(int, int);
189 
190 DAAL_EXPORT data_feature_utils::vectorStrideConvertFuncType getVectorStrideUpCast(int, int);
191 DAAL_EXPORT data_feature_utils::vectorStrideConvertFuncType getVectorStrideDownCast(int, int);
192 
195 } // namespace data_feature_utils
196 #define DataFeatureUtils data_feature_utils
197 }
198 } // namespace daal
199 #endif
daal::data_management::data_feature_utils::getMaxVal
T getMaxVal()
Definition: data_utils.h:154
daal::data_management::data_feature_utils::getMinVal
T getMinVal()
Definition: data_utils.h:166
daal
Definition: algorithm_base_common.h:57
daal_defines.h
daal::data_management::data_feature_utils::getEpsilonVal
T getEpsilonVal()
Definition: data_utils.h:178
daal::data_management::data_feature_utils::getInternalNumType
InternalNumType getInternalNumType()
Definition: data_utils.h:124
daal::data_management::data_feature_utils::getPMMLNumType
PMMLNumType getPMMLNumType()
Definition: data_utils.h:136
daal::data_management::data_feature_utils::getIndexNumType
IndexNumType getIndexNumType()
Definition: data_utils.h:95

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