(DataSet<Type> data, FloatStorageMethod method)
| 208 | abstract protected boolean noLoss(double orig); |
| 209 | |
| 210 | static public <Type extends DataSet<Type>> FloatStorageMethod getMethod(DataSet<Type> data, FloatStorageMethod method) |
| 211 | { |
| 212 | if (method == FloatStorageMethod.AUTO)//figure out what storage method to use! |
| 213 | { |
| 214 | EnumSet<FloatStorageMethod> storageCandidates = EnumSet.complementOf(EnumSet.of(FloatStorageMethod.AUTO)); |
| 215 | |
| 216 | //loop through all the data and remove invalid candidates |
| 217 | for(int i = 0; i < data.getSampleSize(); i++) |
| 218 | { |
| 219 | DataPoint dp = data.getDataPoint(i); |
| 220 | for (IndexValue iv : dp.getNumericalValues()) |
| 221 | { |
| 222 | Iterator<FloatStorageMethod> iter = storageCandidates.iterator(); |
| 223 | while (iter.hasNext()) |
| 224 | { |
| 225 | if (!iter.next().noLoss(iv.getValue())) |
| 226 | iter.remove(); |
| 227 | } |
| 228 | if (storageCandidates.size() == 1) |
| 229 | break; |
| 230 | } |
| 231 | |
| 232 | Iterator<FloatStorageMethod> iter = storageCandidates.iterator(); |
| 233 | while (iter.hasNext()) |
| 234 | { |
| 235 | if (!iter.next().noLoss(dp.getWeight())) |
| 236 | iter.remove(); |
| 237 | } |
| 238 | if (storageCandidates.size() == 1) |
| 239 | break; |
| 240 | } |
| 241 | |
| 242 | if(data instanceof RegressionDataSet) |
| 243 | { |
| 244 | for(IndexValue iv : ((RegressionDataSet)data).getTargetValues()) |
| 245 | { |
| 246 | Iterator<FloatStorageMethod> iter = storageCandidates.iterator(); |
| 247 | while (iter.hasNext()) |
| 248 | { |
| 249 | if (!iter.next().noLoss(iv.getValue())) |
| 250 | iter.remove(); |
| 251 | } |
| 252 | if (storageCandidates.size() == 1) |
| 253 | break; |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | if(storageCandidates.contains(BYTE)) |
| 258 | return BYTE; |
| 259 | else if(storageCandidates.contains(U_BYTE)) |
| 260 | return U_BYTE; |
| 261 | else if(storageCandidates.contains(SHORT)) |
| 262 | return SHORT; |
| 263 | else if(storageCandidates.contains(FP32)) |
| 264 | return FP32; |
| 265 | return FP64; |
| 266 | |
| 267 |
no test coverage detected