Commit Graph

44 Commits

Author SHA1 Message Date
Antonio Sánchez
f6e41e6433 Revert "Clean up stableNorm" 2024-01-19 20:22:47 +00:00
Antonio Sanchez
b2814d53a7 Fix stableNorm when input is zero-sized. 2024-01-16 10:14:51 -08:00
Charles Schlosser
a1a96fafde Clean up stableNorm 2024-01-08 23:28:41 +00:00
Antonio Sánchez
46e9cdb7fe Clang-format tests, examples, libraries, benchmarks, etc. 2023-12-05 21:22:55 +00:00
Antonio Sanchez
25d8498f8b Fix stable_norm_1 test.
Test enters an infinite loop if size is 1x1 when choosing to select
unique indices for adding `inf` and `NaN` to the input. Here we
revert to non-unique indices, and split the `hypotNorm` check into
two cases: one where both `inf` and `NaN` are added, and one where
only `NaN` is added.
2021-01-21 09:44:42 -08:00
Antonio Sanchez
bde6741641 Improved std::complex sqrt and rsqrt.
Replaces `std::sqrt` with `complex_sqrt` for all platforms (previously
`complex_sqrt` was only used for CUDA and MSVC), and implements
custom `complex_rsqrt`.

Also introduces `numext::rsqrt` to simplify implementation, and modified
`numext::hypot` to adhere to IEEE IEC 6059 for special cases.

The `complex_sqrt` and `complex_rsqrt` implementations were found to be
significantly faster than `std::sqrt<std::complex<T>>` and
`1/numext::sqrt<std::complex<T>>`.

Benchmark file attached.
```
GCC 10, Intel Xeon, x86_64:
---------------------------------------------------------------------------
Benchmark                                 Time             CPU   Iterations
---------------------------------------------------------------------------
BM_Sqrt<std::complex<float>>           9.21 ns         9.21 ns     73225448
BM_StdSqrt<std::complex<float>>        17.1 ns         17.1 ns     40966545
BM_Sqrt<std::complex<double>>          8.53 ns         8.53 ns     81111062
BM_StdSqrt<std::complex<double>>       21.5 ns         21.5 ns     32757248
BM_Rsqrt<std::complex<float>>          10.3 ns         10.3 ns     68047474
BM_DivSqrt<std::complex<float>>        16.3 ns         16.3 ns     42770127
BM_Rsqrt<std::complex<double>>         11.3 ns         11.3 ns     61322028
BM_DivSqrt<std::complex<double>>       16.5 ns         16.5 ns     42200711

Clang 11, Intel Xeon, x86_64:
---------------------------------------------------------------------------
Benchmark                                 Time             CPU   Iterations
---------------------------------------------------------------------------
BM_Sqrt<std::complex<float>>           7.46 ns         7.45 ns     90742042
BM_StdSqrt<std::complex<float>>        16.6 ns         16.6 ns     42369878
BM_Sqrt<std::complex<double>>          8.49 ns         8.49 ns     81629030
BM_StdSqrt<std::complex<double>>       21.8 ns         21.7 ns     31809588
BM_Rsqrt<std::complex<float>>          8.39 ns         8.39 ns     82933666
BM_DivSqrt<std::complex<float>>        14.4 ns         14.4 ns     48638676
BM_Rsqrt<std::complex<double>>         9.83 ns         9.82 ns     70068956
BM_DivSqrt<std::complex<double>>       15.7 ns         15.7 ns     44487798

Clang 9, Pixel 2, aarch64:
---------------------------------------------------------------------------
Benchmark                                 Time             CPU   Iterations
---------------------------------------------------------------------------
BM_Sqrt<std::complex<float>>           24.2 ns         24.1 ns     28616031
BM_StdSqrt<std::complex<float>>         104 ns          103 ns      6826926
BM_Sqrt<std::complex<double>>          31.8 ns         31.8 ns     22157591
BM_StdSqrt<std::complex<double>>        128 ns          128 ns      5437375
BM_Rsqrt<std::complex<float>>          31.9 ns         31.8 ns     22384383
BM_DivSqrt<std::complex<float>>        99.2 ns         98.9 ns      7250438
BM_Rsqrt<std::complex<double>>         46.0 ns         45.8 ns     15338689
BM_DivSqrt<std::complex<double>>        119 ns          119 ns      5898944
```
2021-01-17 08:50:57 -08:00
Gael Guennebaud
82f0ce2726 Get rid of EIGEN_TEST_FUNC, unit tests must now be declared with EIGEN_DECLARE_TEST(mytest) { /* code */ }.
This provide several advantages:
- more flexibility in designing unit tests
- unit tests can be glued to speed up compilation
- unit tests are compiled with same predefined macros, which is a requirement for zapcc
2018-07-17 14:46:15 +02:00
Gael Guennebaud
12e1ebb68b Remove local Index typedef from unit-tests 2018-07-12 17:16:40 +02:00
Gael Guennebaud
403f09ccef Make stableNorm and blueNorm compatible with 2D matrices. 2018-04-04 15:13:31 +02:00
Gael Guennebaud
73729025a4 bug #1521: add unit test dedicated to numbest::hypos 2018-04-04 13:45:34 +02:00
Gael Guennebaud
06bf1047f9 Fix compilation of stableNorm with some expressions as input 2017-12-15 15:15:37 +01:00
Gael Guennebaud
a4e4542b89 Avoid overflow in unit test. 2016-01-30 22:26:17 +01:00
Gael Guennebaud
1cf85bd875 bug #977: add stableNormalize[d] methods: they are analogues to normalize[d] but with carefull handling of under/over-flow 2016-01-23 22:40:11 +01:00
Christoph Hertzberg
d6a4805fdf Protect further isnan/isfinite/isinf calls 2015-08-16 14:00:02 +02:00
Gael Guennebaud
bb6acc561e Workaround broken complex*real product on old clang versions 2015-06-17 16:11:58 +02:00
Gael Guennebaud
b0d5aaafcc Rename free functions isFinite, isInf, isNaN to be compatible with c++11 2015-06-10 16:17:09 +02:00
Deanna Hood
8878e1c1de Remove ambiguity with recent numext methods isNaN and isInf 2015-03-17 22:39:51 +10:00
Gael Guennebaud
aa5f79206f Fix bug #859: pexp(NaN) returned Inf instead of NaN 2014-10-20 11:38:51 +02:00
Gael Guennebaud
341ae8665d avoid division by 0 2014-09-16 16:05:06 -07:00
Gael Guennebaud
42e27d41a2 Fix hypot() and hypotNorm() wrt NaN and INF values. 2014-09-02 16:09:39 +02:00
Gael Guennebaud
a44a343f03 Fix blueNorm wrt NaN/INF. 2014-09-02 15:06:24 +02:00
Gael Guennebaud
18fbe7e7d4 Fix stableNorm() with respect to NaN and inf, and add respective unit tests. blueNorm() and hypotNorm() are broken wrt to NaN/inf 2014-09-02 14:49:23 +02:00
Gael Guennebaud
0715d49908 Fix stable_norm unit test for complexes 2014-02-13 15:49:54 +01:00
Gael Guennebaud
3291580630 Fix bug #740: overflow issue in stableNorm 2014-02-13 15:44:01 +01:00
Gael Guennebaud
a76fbbf397 Fix bug #314:
- remove most of the metaprogramming kung fu in MathFunctions.h (only keep functions that differs from the std)
- remove the overloads for array expression that were in the std namespace
2012-11-06 15:25:50 +01:00
Benoit Jacob
69124cfca2 Automatic relicensing to MPL2 using Keirs script. Manual fixup follows. 2012-07-13 14:42:47 -04:00
Gael Guennebaud
42e2578ef9 the min/max macros to detect unprotected min/max were undefined by some std header,
so let's declare them after and do the respective fixes ;)
2011-08-19 14:18:05 +02:00
Benoit Jacob
8cad73072e fix stable_norm test: the |small| value was 0 on clang with complex<float>. 2011-02-27 22:35:49 -05:00
Gael Guennebaud
8bee573a78 workaround ICC aggressive optimization 2011-02-21 16:17:58 +01:00
Benoit Jacob
aa966ca319 fix bug #187: stable norm test was quite broken 2011-02-18 09:46:49 -05:00
Benoit Jacob
4716040703 bug #86 : use internal:: namespace instead of ei_ prefix 2010-10-25 10:15:22 -04:00
Gael Guennebaud
28e64b0da3 email change 2010-06-24 23:21:58 +02:00
Hauke Heibel
f1679c7185 Utilize Index in all unit tests. 2010-06-20 17:37:56 +02:00
Hauke Heibel
8cc02169fd Fix devision by zero warning. 2010-06-09 09:48:06 +02:00
Hauke Heibel
8b0da2de64 Fix stable_norm compilation. 2010-06-08 20:09:39 +02:00
Gael Guennebaud
4b5d359c3a improve/fix stable_norm unit test 2010-06-08 13:29:27 +02:00
Carlos Becker
c4dda79904 Fixed stablenorm test, condition was not met when running tests 2010-04-26 00:20:20 +02:00
Thomas Capricelli
f795681da0 export stableNorm(), blueNorm() and hypotNorm() to colwise() and rowwise()
+ rudimentary test
2009-11-26 02:28:13 +01:00
Benoit Jacob
2840ac7e94 big huge changes, so i dont remember everything.
* renaming, e.g. LU ---> FullPivLU
* split tests framework: more robust, e.g. dont generate empty tests if a number is skipped
* make all remaining tests use that splitting, as needed.
* Fix 4x4 inversion (see stable branch)
* Transform::inverse() and geo_transform test : adapt to new inverse() API, it was also trying to instantiate inverse() for 3x4 matrices.
* CMakeLists: more robust regexp to parse the version number
* misc fixes in unit tests
2009-10-28 18:19:29 -04:00
Gael Guennebaud
af31345df3 really fix stable norm compilation for older gcc 2009-10-07 14:25:12 +02:00
Gael Guennebaud
4cf7366027 fix compilation in stable norm, move a platform check to the unit tests 2009-10-06 10:24:41 +02:00
Gael Guennebaud
3b5a9acba8 fix stable_norm unit test 2009-09-18 11:41:38 +02:00
Hauke Heibel
e6cac85333 Added missing casts. 2009-09-08 08:27:18 +02:00
Gael Guennebaud
b56bb441dd add a stable_norm unit test 2009-09-07 12:46:16 +02:00