Blame view

src/Parameters/ParamData.cc 4.51 KB
fbe3c2bb   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
/**
 * ParamData.cc
 *
 *  Created on: 17 oct. 2012
 *      Author: AKKA IS
 */

#include "ParamData.hh"

#include <string.h>
#include <stdlib.h>
#include <iostream>

using namespace log4cxx;

namespace AMDA {
namespace Parameters {

LoggerPtr ParamData::_logger(Logger::getLogger("AMDA-Kernel.ParamData"));

ParamData::ParamData() : _minSampling(0.0) {
}

ParamData::~ParamData() {
}

}
/* namespace Parameters */
} /* namespace AMDA */


const NotANumber notANumber;
const ElemNull elemNull;

#define GENARATED_SCALAIRE_IMPL(type, val) void operator <<(type &a, NotANumber b) {\
a = (type)val;\
}\
void operator <<(type &a, ElemNull b) {\
a = (type)0;\
}

GENARATED_SCALAIRE_IMPL(short, 0)
GENARATED_SCALAIRE_IMPL(float, NAN)
GENARATED_SCALAIRE_IMPL(double, NAN)
GENARATED_SCALAIRE_IMPL(long double, NAN)
GENARATED_SCALAIRE_IMPL(int, 0)
GENARATED_SCALAIRE_IMPL(AMDA::Parameters::LogicalData, AMDA::Parameters::NaN)

#define GENARATED_VECTOR_IMPL(type, val) void operator <<(std::vector<type> &a, NotANumber b) {\
for(std::vector<type>::iterator it = a.begin(); it != a.end(); ++it) {\
	*it = (type)val;\
}\
}\
void operator <<(std::vector<type> &a, ElemNull b) {\
for(std::vector<type>::iterator it = a.begin(); it != a.end(); ++it) {\
	*it = (type)0;\
}\
}

GENARATED_VECTOR_IMPL(short,0)
GENARATED_VECTOR_IMPL(float, NAN)
GENARATED_VECTOR_IMPL(double, NAN)
GENARATED_VECTOR_IMPL(long double, NAN)
GENARATED_VECTOR_IMPL(int, 0)
GENARATED_VECTOR_IMPL(AMDA::Parameters::LogicalData, AMDA::Parameters::NaN)

#define GENARATED_TAB2D_IMPL(type, val) void operator <<(AMDA::Parameters::Tab2DData<type> &a, NotANumber b) {\
for(int i = 0; i < a.getDim1Size(); ++i) {\
	for(int j = 0; j < a.getDim2Size(); ++j) {\
		a[i][j] = (type)val;\
	}\
}\
}\
void operator <<(AMDA::Parameters::Tab2DData<type> &a, ElemNull b) {\
for(int i = 0; i < a.getDim1Size(); ++i) {\
	for(int j = 0; j < a.getDim2Size(); ++j) {\
		a[i][j] = (type)0;\
	}\
}\
}

GENARATED_TAB2D_IMPL(short,0)
GENARATED_TAB2D_IMPL(float, NAN)
GENARATED_TAB2D_IMPL(double, NAN)
GENARATED_TAB2D_IMPL(long double, NAN)
GENARATED_TAB2D_IMPL(int, 0)
GENARATED_TAB2D_IMPL(AMDA::Parameters::LogicalData, AMDA::Parameters::NaN)

bool isNAN(short pval){
	return isnan(pval);
}

bool isNAN(float pval){
	return isnan(pval);
}

bool isNAN(double pval){
	return isnan(pval);
}

bool isNAN(long double pval){
	return isnan(pval);
}

bool isNAN(int pval){
	return isnan(pval);
}

bool isNAN(AMDA::Parameters::LogicalData pval){
	return (pval == AMDA::Parameters::NaN);
}


bool isNAN(std::vector<short> pval){
	for(auto subval : pval){
			if(isnan(subval)){
				return true;
			}
		}
		return false;
}

bool isNAN(std::vector<float> pval){
	for(auto subval : pval){
			if(isnan(subval)){
				return true;
			}
		}
		return false;
}

bool isNAN(std::vector<double> pval){
	for(auto subval : pval){
			if(isnan(subval)){
				return true;
			}
		}
		return false;
}

bool isNAN(std::vector<long double> pval){
	for(auto subval : pval){
			if(isnan(subval)){
				return true;
			}
		}
		return false;
}

bool isNAN(std::vector<int> pval){
	for(auto subval : pval){
		if(isnan(subval)){
			return true;
		}
	}
	return false;
}

bool isNAN(std::vector<AMDA::Parameters::LogicalData> pval){
	for(auto subval : pval){
			if(subval == AMDA::Parameters::NaN){
				return true;
			}
		}
		return false;
}

bool isNAN(AMDA::Parameters::Tab2DData<short> pval){
	for (int i = 0; i < pval.getDim1Size(); ++i)
		for (int j = 0; j < pval.getDim2Size(); ++j)
			if(isnan(pval[i][j]))
				return true;
	return false;
}

bool isNAN(AMDA::Parameters::Tab2DData<float> pval){
	for (int i = 0; i < pval.getDim1Size(); ++i)
		for (int j = 0; j < pval.getDim2Size(); ++j)
			if(isnan(pval[i][j]))
				return true;
	return false;
}

bool isNAN(AMDA::Parameters::Tab2DData<double> pval){
	for (int i = 0; i < pval.getDim1Size(); ++i)
		for (int j = 0; j < pval.getDim2Size(); ++j)
			if(isnan(pval[i][j]))
				return true;
	return false;
}

bool isNAN(AMDA::Parameters::Tab2DData<long double> pval){
	for (int i = 0; i < pval.getDim1Size(); ++i)
		for (int j = 0; j < pval.getDim2Size(); ++j)
			if(isnan(pval[i][j]))
				return true;
	return false;
}

bool isNAN(AMDA::Parameters::Tab2DData<int> pval){
	for (int i = 0; i < pval.getDim1Size(); ++i)
		for (int j = 0; j < pval.getDim2Size(); ++j)
			if(isnan(pval[i][j]))
				return true;
	return false;
}

bool isNAN(AMDA::Parameters::Tab2DData<AMDA::Parameters::LogicalData> pval){
	for (int i = 0; i < pval.getDim1Size(); ++i)
		for (int j = 0; j < pval.getDim2Size(); ++j)
			if(pval[i][j] == AMDA::Parameters::NaN)
				return true;
	return false;
}