Round to nearest even integer, assume CPU control register is set to rounding. Test intrinsics: npyv_round_s32_##SFX
(self)
| 331 | To only test single precision |
| 332 | """ |
| 333 | def test_conversions(self): |
| 334 | """ |
| 335 | Round to nearest even integer, assume CPU control register is set to rounding. |
| 336 | Test intrinsics: |
| 337 | npyv_round_s32_##SFX |
| 338 | """ |
| 339 | features = self._cpu_features() |
| 340 | if not self.npyv.simd_f64 and re.match(r".*(NEON|ASIMD)", features): |
| 341 | # very costly to emulate nearest even on Armv7 |
| 342 | # instead we round halves to up. e.g. 0.5 -> 1, -0.5 -> -1 |
| 343 | _round = lambda v: int(v + (0.5 if v >= 0 else -0.5)) |
| 344 | else: |
| 345 | _round = round |
| 346 | vdata_a = self.load(self._data()) |
| 347 | vdata_a = self.sub(vdata_a, self.setall(0.5)) |
| 348 | data_round = [_round(x) for x in vdata_a] |
| 349 | vround = self.round_s32(vdata_a) |
| 350 | assert vround == data_round |
| 351 | |
| 352 | class _SIMD_FP64(_Test_Utility): |
| 353 | """ |
nothing calls this directly
no test coverage detected