--- /srv/reproducible-results/rbuild-debian/r-b-build.mhZyZNGU/b1/dune-common_2.10.0-5_amd64.changes +++ /srv/reproducible-results/rbuild-debian/r-b-build.mhZyZNGU/b2/dune-common_2.10.0-5_amd64.changes ├── Files │ @@ -1,4 +1,4 @@ │ │ 4c1f3b0bb86e07031626e4275ac06e1f 521888 debug optional libdune-common-dev-dbgsym_2.10.0-5_amd64.deb │ 9338fa222853197099c99521e022f302 411704 libdevel optional libdune-common-dev_2.10.0-5_amd64.deb │ - c40f6b3439678b516d623f5e124cb642 3178848 doc optional libdune-common-doc_2.10.0-5_all.deb │ + e7f8532ff57c5287c9a1dc62d8a6c573 3179144 doc optional libdune-common-doc_2.10.0-5_all.deb ├── libdune-common-doc_2.10.0-5_all.deb │ ├── file list │ │ @@ -1,3 +1,3 @@ │ │ -rw-r--r-- 0 0 0 4 2025-09-15 05:59:28.000000 debian-binary │ │ --rw-r--r-- 0 0 0 28184 2025-09-15 05:59:28.000000 control.tar.xz │ │ --rw-r--r-- 0 0 0 3150472 2025-09-15 05:59:28.000000 data.tar.xz │ │ +-rw-r--r-- 0 0 0 28164 2025-09-15 05:59:28.000000 control.tar.xz │ │ +-rw-r--r-- 0 0 0 3150788 2025-09-15 05:59:28.000000 data.tar.xz │ ├── control.tar.xz │ │ ├── control.tar │ │ │ ├── ./control │ │ │ │ @@ -1,13 +1,13 @@ │ │ │ │ Package: libdune-common-doc │ │ │ │ Source: dune-common │ │ │ │ Version: 2.10.0-5 │ │ │ │ Architecture: all │ │ │ │ Maintainer: Debian Science Maintainers │ │ │ │ -Installed-Size: 23530 │ │ │ │ +Installed-Size: 23531 │ │ │ │ Depends: libjs-sphinxdoc (>= 8.2) │ │ │ │ Built-Using: doxygen (= 1.9.8+ds-2.1) │ │ │ │ Section: doc │ │ │ │ Priority: optional │ │ │ │ Multi-Arch: foreign │ │ │ │ Homepage: https://www.dune-project.org/ │ │ │ │ Description: toolbox for solving PDEs -- basic classes (documentation) │ │ │ ├── ./md5sums │ │ │ │ ├── ./md5sums │ │ │ │ │┄ Files differ │ │ │ │ ├── line order │ │ │ │ │ @@ -20,26 +20,27 @@ │ │ │ │ │ usr/share/doc/libdune-common-doc/changelog.gz │ │ │ │ │ usr/share/doc/libdune-common-doc/copyright │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00002.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00008.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00008_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00011.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00011_source.html │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00014.html │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00014_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00017.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00017_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00020.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00020_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00023.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00023_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00026.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00026_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00029.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00029_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00032.html │ │ │ │ │ -usr/share/doc/libdune-common-doc/doxygen/a00032_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00035.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00035_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00038.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00038_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00041.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00041_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00044.html │ │ │ │ │ @@ -65,18 +66,18 @@ │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00074.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00074_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00077.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00077_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00080.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00080_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00083.html │ │ │ │ │ -usr/share/doc/libdune-common-doc/doxygen/a00083_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00086.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00086_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00089.html │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00089_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00092.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00092_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00095.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00095_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00098.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00098_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00101.html │ │ │ │ │ @@ -86,19 +87,17 @@ │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00107.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00107_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00110.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00110_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00113.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00113_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00116.html │ │ │ │ │ -usr/share/doc/libdune-common-doc/doxygen/a00116_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00119.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00119_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00122.html │ │ │ │ │ -usr/share/doc/libdune-common-doc/doxygen/a00122_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00125.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00125_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00128.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00128_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00131.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00131_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00134.html │ │ │ │ │ @@ -116,14 +115,15 @@ │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00152.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00152_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00155.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00155_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00158.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00158_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00161.html │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00161_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00164.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00164_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00167.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00167_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00170.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00170_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00173.html │ │ │ │ │ @@ -139,23 +139,25 @@ │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00188.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00188_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00191.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00191_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00194.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00194_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00197.html │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00197_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00200.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00203.html │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00203_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00206.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00206_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00209.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00209_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00212.html │ │ │ │ │ -usr/share/doc/libdune-common-doc/doxygen/a00212_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00215.html │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00215_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00218.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00218_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00221.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00221_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00224.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00224_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00227.html │ │ │ │ │ @@ -197,43 +199,41 @@ │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00281.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00281_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00284.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00284_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00287.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00287_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00290.html │ │ │ │ │ -usr/share/doc/libdune-common-doc/doxygen/a00290_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00293.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00293_source.html │ │ │ │ │ -usr/share/doc/libdune-common-doc/doxygen/a00296.html │ │ │ │ │ -usr/share/doc/libdune-common-doc/doxygen/a00296_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00299.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00299_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00302.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00302_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00305.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00305_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00308.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00308_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00311.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00311_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00314.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00314_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00317.html │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00317_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00320.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00320_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00323.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00323_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00326.html │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00326_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00329.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00329_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00332.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00332_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00335.html │ │ │ │ │ -usr/share/doc/libdune-common-doc/doxygen/a00335_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00338.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00338_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00341.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00341_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00344.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00344_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00347.html │ │ │ │ │ @@ -243,26 +243,26 @@ │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00353.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00353_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00356.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00356_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00359.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00359_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00362.html │ │ │ │ │ -usr/share/doc/libdune-common-doc/doxygen/a00362_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00365.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00365_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00368.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00368_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00371.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00371_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00374.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00374_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00377.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00377_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00380.html │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00380_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00383.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00383_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00386.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00386_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00389.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00389_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00392.html │ │ │ │ │ @@ -270,16 +270,16 @@ │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00395.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00395_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00398.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00398_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00401.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00401_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00404.html │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00404_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00407.html │ │ │ │ │ -usr/share/doc/libdune-common-doc/doxygen/a00407_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00410.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00410_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00413.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00413_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00416.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00416_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00419.html │ ├── data.tar.xz │ │ ├── data.tar │ │ │ ├── file list │ │ │ │ @@ -26,282 +26,282 @@ │ │ │ │ -rw-r--r-- 0 root (0) root (0) 2825 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/buildsystem/html/search.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 11208 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/buildsystem/html/searchindex.js │ │ │ │ -rw-r--r-- 0 root (0) root (0) 2498 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/changelog.Debian.gz │ │ │ │ -rw-r--r-- 0 root (0) root (0) 10768 2024-10-04 18:52:15.000000 ./usr/share/doc/libdune-common-doc/changelog.gz │ │ │ │ -rw-r--r-- 0 root (0) root (0) 9815 2023-01-12 15:06:30.000000 ./usr/share/doc/libdune-common-doc/copyright │ │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/ │ │ │ │ -rw-r--r-- 0 root (0) root (0) 3044 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00002.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9860 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00008.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 20795 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00008_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 13870 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00011.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 20197 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00011_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 24038 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00017.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 42062 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00017_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6712 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00020.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 11002 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00020_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3817 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00023.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6524 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00023_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 81299 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00026.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 145525 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00026_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 33482 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00029.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 357624 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00029_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 14004 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00032.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 86151 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00032_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4992 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00008.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 31443 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00008_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 24240 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00011.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 39035 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00011_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8689 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00014.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 15574 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00014_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10744 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00017.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 109175 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00017_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8833 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00020.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 15784 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00020_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5204 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00023.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 29990 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00023_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 17515 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00026.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 45457 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00026_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5355 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00029.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 41537 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00029_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6924 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00032.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 13604 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00035.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 28674 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00035_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5979 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00038.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 21113 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00038_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4992 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00041.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 31443 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00041_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6383 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00044.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 16095 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00044_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6555 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00047.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 18101 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00047_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5204 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00050.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 29990 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00050_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5324 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00053.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10218 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00053_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4958 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00056.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6603 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00056_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10468 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00059.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 33173 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00059_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5274 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00062.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 11329 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00062_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8835 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00065.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10531 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00065_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7355 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00068.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9907 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00068_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10744 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00071.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 109175 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00071_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 20534 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00074.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 80039 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00074_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5346 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00077.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 33491 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00077_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 21360 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00080.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 122172 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00080_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8193 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00083.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 41652 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00083_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 11653 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00086.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 55283 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00086_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8438 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00089.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 60433 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00092.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 122588 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00092_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5213 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00095.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 15231 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00095_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7918 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00098.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 127860 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00098_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3371 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00101.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 88030 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00101_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 17881 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00104.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 79928 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00104_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9498 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00107.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 250587 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00107_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3365 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00110.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10369 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00110_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5246 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00113.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9924 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00113_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6818 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00116.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 100135 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00116_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 13584 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00119.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 94213 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00119_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10990 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00122.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 22882 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00122_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 14994 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00125.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 142940 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00125_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6855 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00128.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 112076 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00128_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6585 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00131.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 44036 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00131_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4767 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00134.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 14347 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00134_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6286 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00137.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 21544 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00137_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3473 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00140.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 14821 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00140_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3471 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00143.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9186 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00143_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5059 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00146.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 23627 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00146_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8195 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00149.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 144459 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00149_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 14429 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00152.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 51306 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00152_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8833 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00155.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 15784 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00155_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6780 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00158.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8262 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00158_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3898 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00161.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 17901 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00164.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 167128 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00164_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 39912 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00167.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 14840 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00167_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5042 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00170.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6949 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00170_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4365 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00173.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5135 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00173_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6186 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00176.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 17740 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00176_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7720 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00179.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10467 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00179_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 22052 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00182.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 46229 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00182_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3371 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00185.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7706 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00185_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5325 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00188.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 22981 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00188_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5766 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00191.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 16720 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00191_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5114 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00194.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9510 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00194_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4910 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00197.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4124 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00200.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4978 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00203.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5081 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00206.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7897 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00206_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6997 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00038.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 54427 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00038_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 13174 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00041.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 35626 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00041_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5881 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00044.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 13121 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00044_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 12424 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00047.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 91584 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00047_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6400 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00050.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 151816 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00050_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6381 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00053.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10393 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00053_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4899 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00056.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 13459 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00056_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5662 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00059.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 50072 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00059_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5397 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00062.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 14949 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00062_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5660 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00065.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 39763 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00065_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5441 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00068.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9255 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00068_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5664 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00071.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 39917 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00071_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 13246 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00074.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 83988 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00074_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 14429 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00077.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 51306 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00077_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6855 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00080.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 112076 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00080_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4910 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00083.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10990 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00086.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 22882 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00086_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5621 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00089.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7109 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00089_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5979 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00092.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 21113 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00092_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 26302 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00095.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 62033 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00095_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 14004 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00098.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 86151 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00098_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7493 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00101.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 31465 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00101_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8195 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00104.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 144459 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00104_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4958 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00107.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6603 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00107_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5274 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00110.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 11329 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00110_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5604 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00113.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9237 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00113_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4124 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00116.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7918 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00119.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 127860 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00119_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4127 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00122.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8730 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00125.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 61448 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00125_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3371 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00128.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 88030 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00128_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 39912 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00131.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 14840 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00131_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6661 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00134.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 52850 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00134_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5059 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00137.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 23627 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00137_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4393 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00140.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7511 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00140_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4767 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00143.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 14347 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00143_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10468 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00146.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 33173 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00146_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5213 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00149.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 15231 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00149_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 20534 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00152.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 80039 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00152_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 30299 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00155.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 192703 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00155_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 21234 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00158.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 71204 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00158_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6555 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00161.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 18101 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00161_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7123 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00164.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 23204 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00164_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7264 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00167.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 14137 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00167_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5766 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00170.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 16720 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00170_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 60433 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00173.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 122588 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00173_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8169 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00176.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 63827 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00176_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6818 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00179.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 100135 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00179_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6157 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00182.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 19958 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00182_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8322 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00185.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 40739 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00185_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4309 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00188.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 17896 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00188_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 12793 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00191.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 124302 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00191_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5324 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00194.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10218 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00194_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5246 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00197.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9924 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00197_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3948 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00200.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5114 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00203.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9510 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00203_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7344 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00206.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 18649 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00206_source.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 7773 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00209.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 22676 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00209_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6806 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00212.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 12869 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00212_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3948 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00215.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5397 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00218.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 14949 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00218_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5662 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00221.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 50072 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00221_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 13246 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00224.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 83988 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00224_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6997 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00227.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 54427 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00227_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5881 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00230.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 13121 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00230_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5660 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00233.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 39763 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00233_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 13174 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00236.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 35626 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00236_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5664 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00239.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 39917 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00239_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5441 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00242.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9255 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00242_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 12424 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00245.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 91584 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00245_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6400 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00248.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 151816 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00248_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4899 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00251.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 13459 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00251_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6381 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00254.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10393 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00254_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7782 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00257.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 12395 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00257_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5602 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00260.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9345 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00260_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4393 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00263.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7511 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00263_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 26302 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00266.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 62033 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00266_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 16770 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00269.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 48541 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00269_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 30299 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00272.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 192703 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00272_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8689 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00275.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 15574 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00275_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 17515 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00278.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 45457 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00278_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7493 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00281.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 31465 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00281_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 12793 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00284.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 124302 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00284_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7264 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00287.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 14137 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00287_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 24717 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00290.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 122775 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00290_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5653 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00293.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7232 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00293_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5355 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00296.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 41537 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00296_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4309 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00299.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 17896 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00299_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9720 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00302.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 240953 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00302_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8730 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00305.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 61448 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00305_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5048 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00308.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 23174 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00308_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 24240 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00311.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 39035 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00311_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4654 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00314.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7264 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00314_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4127 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00317.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6661 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00320.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 52850 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00320_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 21234 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00323.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 71204 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00323_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6924 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00326.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6157 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00329.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 19958 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00329_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5124 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00332.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 29705 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00332_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7194 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00335.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 151467 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00335_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5604 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00338.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9237 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00338_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6611 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00341.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 19944 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00341_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3657 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00344.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4978 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00344_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9111 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00347.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 53122 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00347_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3471 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00350.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10170 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00350_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8765 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00353.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 72000 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00353_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 11615 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00356.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 103142 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00356_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6914 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00359.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 47730 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00359_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6031 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00362.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 51849 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00362_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6490 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00365.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 34021 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00365_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7456 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00368.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 33695 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00368_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 13224 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00371.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 179116 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00371_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5637 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00374.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 33707 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00374_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6676 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00377.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 58446 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00377_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 23464 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00380.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 11466 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00383.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 291478 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00383_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3648 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00386.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4981 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00386_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9140 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00389.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 173678 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00389_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 19994 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00392.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 180715 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00392_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7591 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00395.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 138694 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00395_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6822 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00398.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 40313 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00398_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8504 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00401.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 45745 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00401_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9164 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00404.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8322 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00407.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 40739 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00407_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7344 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00410.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 18649 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00410_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3383 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00413.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 51919 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00413_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7123 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00416.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 23204 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00416_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8169 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00419.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 63827 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00419_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 14827 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00422.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 23435 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00422_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5621 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00425.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7109 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00425_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4978 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00212.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3383 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00215.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 51919 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00215_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6383 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00218.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 16095 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00218_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7782 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00221.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 12395 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00221_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3365 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00224.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10369 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00224_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5124 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00227.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 29705 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00227_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3817 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00230.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6524 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00230_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 13584 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00233.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 94213 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00233_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9720 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00236.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 240953 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00236_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 17901 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00239.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 167128 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00239_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 19994 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00242.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 180715 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00242_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8504 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00245.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 45745 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00245_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7456 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00248.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 33695 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00248_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3648 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00251.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4981 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00251_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 11466 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00254.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 291478 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00254_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9140 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00257.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 173678 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00257_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5637 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00260.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 33707 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00260_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 13224 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00263.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 179116 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00263_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9111 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00266.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 53122 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00266_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6914 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00269.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 47730 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00269_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8765 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00272.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 72000 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00272_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6031 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00275.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 51849 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00275_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6490 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00278.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 34021 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00278_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3657 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00281.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4978 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00281_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3471 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00284.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10170 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00284_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6676 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00287.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 58446 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00287_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 23464 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00290.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7591 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00293.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 138694 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00293_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 11615 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00299.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 103142 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00299_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6822 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00302.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 40313 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00302_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6611 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00305.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 19944 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00305_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5081 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00308.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7897 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00308_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6186 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00311.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 17740 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00311_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7720 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00314.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10467 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00314_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5346 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00317.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 33491 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00317_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6806 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00320.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 12869 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00320_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5048 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00323.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 23174 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00323_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5325 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00326.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 22981 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00326_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 11653 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00329.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 55283 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00329_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 21360 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00332.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 122172 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00332_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3898 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00335.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6712 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00338.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 11002 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00338_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 81299 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00341.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 145525 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00341_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 24038 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00344.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 42062 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00344_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 13870 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00347.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 20197 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00347_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 33482 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00350.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 357624 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00350_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9860 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00353.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 20795 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00353_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7355 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00356.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9907 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00356_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8835 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00359.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10531 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00359_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9164 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00362.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6286 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00365.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 21544 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00365_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9498 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00368.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 250587 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00368_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5653 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00371.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7232 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00371_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 17881 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00374.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 79928 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00374_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8193 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00377.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 41652 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00377_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 22052 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00380.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 46229 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00380_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 16770 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00383.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 48541 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00383_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3371 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00386.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7706 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00386_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6780 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00389.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8262 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00389_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3473 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00392.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 14821 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00392_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3471 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00395.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9186 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00395_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5042 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00398.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6949 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00398_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 14994 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00401.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 142940 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00401_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7194 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00404.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 151467 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00404_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8438 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00407.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6585 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00410.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 44036 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00410_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 24717 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00413.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 122775 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00413_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 14827 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00416.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 23435 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00416_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4654 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00419.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7264 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00419_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4365 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00422.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5135 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00422_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5602 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00425.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9345 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00425_source.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 5173 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00428.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 49335 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00428_source.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 7896 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00431.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 5292 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00432.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 262467 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00433.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 27946 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00433.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 39664 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00434.html │ │ │ │ @@ -1185,15 +1185,15 @@ │ │ │ │ -rw-r--r-- 0 root (0) root (0) 2402 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/dir_be46aaae597ce098e36afa8d6ef4f49b_dep.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 4890 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/dir_cf308425303dd5c426fac7b7f2967d96.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 1621 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/dir_cf308425303dd5c426fac7b7f2967d96_dep.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 49658 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/dir_e151556194dc695299293609645e9437.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 11161 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/dir_e151556194dc695299293609645e9437_dep.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 3668 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/dir_e68e8157741866f444e17edd764ebbae.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 45631 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/doxygen.css │ │ │ │ --rw-r--r-- 0 root (0) root (0) 165834 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/dune-common.tag.gz │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 165936 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/dune-common.tag.gz │ │ │ │ -rw-r--r-- 0 root (0) root (0) 7704 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/dynsections.js │ │ │ │ -rw-r--r-- 0 root (0) root (0) 56072 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/files.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 1145 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/form_0.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 1167 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/form_0_dark.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 1153 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/form_1.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 403 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/form_10.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 422 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/form_10_dark.png │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00008.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: io.hh File Reference │ │ │ │ +dune-common: parameterizedobject.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,76 +65,43 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces | │ │ │ │ -Functions
│ │ │ │ - │ │ │ │ +Namespaces
│ │ │ │ +
parameterizedobject.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ - │ │ │ │ -

IO interface of the SIMD abstraction. │ │ │ │ -More...

│ │ │ │ -
#include <ios>
│ │ │ │ -#include <type_traits>
│ │ │ │ -#include <dune/common/rangeutilities.hh>
│ │ │ │ -#include <dune/common/simd/simd.hh>
│ │ │ │ -#include <dune/common/typetraits.hh>
│ │ │ │ +
#include <functional>
│ │ │ │ +#include <map>
│ │ │ │ +#include <memory>
│ │ │ │ +#include <dune/common/exceptions.hh>
│ │ │ │ +#include <dune/common/typeutilities.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::SimdImpl::Inserter< T >
class  Dune::ParameterizedObjectFactory< TypeT(Args...), KeyT >
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::SimdImpl
 
namespace  Dune::Simd
 Namespace for vectorization interface functions used by library developers.
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │

│ │ │ │ -Functions

template<class V , class = std::enable_if_t<Simd::lanes<V>() != 1>>
Inserter< V > Dune::SimdImpl::io (const V &v)
 
template<class V , class = std::enable_if_t<Simd::lanes<V>() == 1>>
Simd::Scalar< V > Dune::SimdImpl::io (const V &v)
 
IO interface

Templates and functions in this group provide syntactic sugar for IO. They are implemented using the functionality from SimdInterfaceBase, and are not customizable by implementations.

│ │ │ │ -
template<class V >
auto Dune::Simd::vio (const V &v)
 construct a stream inserter
 
template<class V >
auto Dune::Simd::io (const V &v)
 construct a stream inserter
 
│ │ │ │ -

Detailed Description

│ │ │ │ -

IO interface of the SIMD abstraction.

│ │ │ │ -

This file provides IO interface functions of the SIMD abstraction layer.

│ │ │ │ -

This file is intended for direct inclusion by header making use of the IO interface.

│ │ │ │ -
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,56 +1,23 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * simd │ │ │ │ │ -Classes | Namespaces | Functions │ │ │ │ │ -io.hh File Reference │ │ │ │ │ -Common » Vectorization » Library_Developer's_Interface │ │ │ │ │ -IO interface of the SIMD abstraction. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +parameterizedobject.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class   Dune::SimdImpl::Inserter<_T_> │ │ │ │ │ +class   Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_> │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -namespace   Dune::SimdImpl │ │ │ │ │ -  │ │ │ │ │ -namespace   Dune::Simd │ │ │ │ │ -  Namespace for vectorization interface functions used by library │ │ │ │ │ - developers. │ │ │ │ │ -  │ │ │ │ │ -Functions │ │ │ │ │ -template() != 1>> │ │ │ │ │ - Inserter< V >  Dune::SimdImpl::io (const V &v) │ │ │ │ │ -  │ │ │ │ │ -template() == 1>> │ │ │ │ │ -Simd::Scalar< V >  Dune::SimdImpl::io (const V &v) │ │ │ │ │ -  │ │ │ │ │ -IO interface │ │ │ │ │ -Templates and functions in this group provide syntactic sugar for IO. They are │ │ │ │ │ -implemented using the functionality from SimdInterfaceBase, and are not │ │ │ │ │ -customizable by implementations. │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::Simd::vio (const V &v) │ │ │ │ │ -  construct a stream inserter │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::Simd::io (const V &v) │ │ │ │ │ -  construct a stream inserter │ │ │ │ │ -  │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -IO interface of the SIMD abstraction. │ │ │ │ │ -This file provides IO interface functions of the SIMD abstraction layer. │ │ │ │ │ -This file is intended for direct inclusion by header making use of the IO │ │ │ │ │ -interface. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00008_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: io.hh Source File │ │ │ │ +dune-common: parameterizedobject.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,125 +70,182 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
io.hh
│ │ │ │ +
parameterizedobject.hh
│ │ │ │
│ │ │ │
│ │ │ │ -Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ -
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
3#ifndef DUNE_COMMON_SIMD_IO_HH
│ │ │ │ -
4#define DUNE_COMMON_SIMD_IO_HH
│ │ │ │ -
5
│ │ │ │ -
16#include <ios>
│ │ │ │ -
17#include <type_traits>
│ │ │ │ -
18
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
22
│ │ │ │ -
23namespace Dune {
│ │ │ │ -
24
│ │ │ │ -
│ │ │ │ -
25 namespace SimdImpl {
│ │ │ │ -
26
│ │ │ │ -
27 template<class T>
│ │ │ │ -
│ │ │ │ -
28 class Inserter {
│ │ │ │ -
29 T value_;
│ │ │ │ -
30
│ │ │ │ -
31 public:
│ │ │ │ -
32 Inserter(const T &value) : value_(value) {}
│ │ │ │ -
33
│ │ │ │ -
34 template<class Stream,
│ │ │ │ -
35 class = std::enable_if_t<std::is_base_of<std::ios_base,
│ │ │ │ -
36 Stream>::value> >
│ │ │ │ -
│ │ │ │ -
37 friend Stream& operator<<(Stream &out, const Inserter &ins)
│ │ │ │ -
38 {
│ │ │ │ -
39 const char *sep = "<";
│ │ │ │ -
40 for(auto l : range(Simd::lanes(ins.value_)))
│ │ │ │ -
41 {
│ │ │ │ -
42 out << sep << autoCopy(Simd::lane(l, ins.value_));
│ │ │ │ -
43 sep = ", ";
│ │ │ │ -
44 }
│ │ │ │ -
45 out << '>';
│ │ │ │ -
46 return out;
│ │ │ │ -
47 }
│ │ │ │ -
│ │ │ │ -
48 };
│ │ │ │ -
│ │ │ │ -
49
│ │ │ │ -
50 template<class V, class = std::enable_if_t<Simd::lanes<V>() != 1> >
│ │ │ │ -
│ │ │ │ -
51 Inserter<V> io(const V &v)
│ │ │ │ -
52 {
│ │ │ │ -
53 return { v };
│ │ │ │ -
54 }
│ │ │ │ -
│ │ │ │ -
55
│ │ │ │ -
56 template<class V, class = std::enable_if_t<Simd::lanes<V>() == 1> >
│ │ │ │ -
│ │ │ │ -
57 Simd::Scalar<V> io(const V &v)
│ │ │ │ -
58 {
│ │ │ │ -
59 return Simd::lane(0, v);
│ │ │ │ -
60 }
│ │ │ │ +Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
│ │ │ │ +
2// vi: set et ts=4 sw=4 sts=4:
│ │ │ │ +
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ +
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ +
5#ifndef DUNE_COMMON_PARAMETERIZEDOBJECT_HH
│ │ │ │ +
6#define DUNE_COMMON_PARAMETERIZEDOBJECT_HH
│ │ │ │ +
7
│ │ │ │ +
8#include <functional>
│ │ │ │ +
9#include <map>
│ │ │ │ +
10#include <memory>
│ │ │ │ +
11
│ │ │ │ + │ │ │ │ + │ │ │ │ +
14
│ │ │ │ +
15namespace Dune {
│ │ │ │ +
16
│ │ │ │ +
34template<typename Signature,
│ │ │ │ +
35 typename KeyT = std::string>
│ │ │ │ + │ │ │ │ +
37
│ │ │ │ +
38template<typename TypeT,
│ │ │ │ +
39 typename KeyT,
│ │ │ │ +
40 typename... Args>
│ │ │ │ +
│ │ │ │ +
41class ParameterizedObjectFactory<TypeT(Args...), KeyT>
│ │ │ │ +
42{
│ │ │ │ +
43 public:
│ │ │ │ +
44
│ │ │ │ +
46 typedef KeyT Key;
│ │ │ │ +
47
│ │ │ │ +
49 using Type = TypeT;
│ │ │ │ +
50
│ │ │ │ +
51 protected:
│ │ │ │ +
52
│ │ │ │ +
53 using Creator = std::function<Type(Args...)>;
│ │ │ │ +
54
│ │ │ │ +
55 template<class F>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
57 -> decltype( std::declval<F>()(std::declval<Args>()...), std::true_type())
│ │ │ │ +
58 {
│ │ │ │ +
59 return {};
│ │ │ │ +
60 }
│ │ │ │
│ │ │ │
61
│ │ │ │ -
62 }
│ │ │ │ -
│ │ │ │ -
63
│ │ │ │ -
64 namespace Simd {
│ │ │ │ -
65
│ │ │ │ -
82
│ │ │ │ -
89 template<class V>
│ │ │ │ -
│ │ │ │ -
90 auto vio(const V &v)
│ │ │ │ -
91 {
│ │ │ │ -
92 return SimdImpl::Inserter<V>{ v };
│ │ │ │ -
93 }
│ │ │ │ -
│ │ │ │ -
94
│ │ │ │ -
96
│ │ │ │ -
105 template<class V>
│ │ │ │ -
│ │ │ │ -
106 auto io(const V &v)
│ │ │ │ -
107 {
│ │ │ │ -
108 return SimdImpl::io(v);
│ │ │ │ -
109 }
│ │ │ │ -
│ │ │ │ -
110
│ │ │ │ -
112
│ │ │ │ -
114
│ │ │ │ -
115 } // namespace Simd
│ │ │ │ -
116} // namespace Dune
│ │ │ │ -
117
│ │ │ │ -
118#endif // DUNE_COMMON_SIMD_IO_HH
│ │ │ │ -
Utilities for reduction like operations on ranges.
│ │ │ │ -
Traits for type conversions and type information.
│ │ │ │ -
static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from >, std::integral_constant< T, to >) noexcept
Definition rangeutilities.hh:312
│ │ │ │ -
constexpr AutonomousValue< T > autoCopy(T &&v)
Autonomous copy of an expression's value for use in auto type deduction.
Definition typetraits.hh:672
│ │ │ │ -
auto io(const V &v)
construct a stream inserter
Definition io.hh:106
│ │ │ │ -
auto vio(const V &v)
construct a stream inserter
Definition io.hh:90
│ │ │ │ -
constexpr std::size_t lanes()
Number of lanes in a SIMD type.
Definition simd/interface.hh:305
│ │ │ │ -
decltype(auto) lane(std::size_t l, V &&v)
Extract an element of a SIMD type.
Definition simd/interface.hh:324
│ │ │ │ -
typename Overloads::ScalarType< std::decay_t< V > >::type Scalar
Element type of some SIMD type.
Definition simd/interface.hh:235
│ │ │ │ +
62 template<class F>
│ │ │ │ +
│ │ │ │ +
63 static constexpr std::false_type has_proper_signature(Dune::PriorityTag<0>)
│ │ │ │ +
64 {
│ │ │ │ +
65 return {};
│ │ │ │ +
66 }
│ │ │ │ +
│ │ │ │ +
67
│ │ │ │ +
68 public:
│ │ │ │ +
69
│ │ │ │ +
│ │ │ │ +
77 Type create(Key const& key, Args ... args) const {
│ │ │ │ +
78 typename Registry::const_iterator i = registry_.find(key);
│ │ │ │ +
79 if (i == registry_.end()) {
│ │ │ │ + │ │ │ │ +
81 "ParametrizedObjectFactory: key ``" <<
│ │ │ │ +
82 key << "'' not registered");
│ │ │ │ +
83 }
│ │ │ │ +
84 else return i->second(args...);
│ │ │ │ +
85 }
│ │ │ │ +
│ │ │ │ +
86
│ │ │ │ +
100 template<class Impl>
│ │ │ │ +
│ │ │ │ +
101 void define(Key const& key)
│ │ │ │ +
102 {
│ │ │ │ +
103 registry_[key] = DefaultCreator<Impl>();
│ │ │ │ +
104 }
│ │ │ │ +
│ │ │ │ +
105
│ │ │ │ +
119 template<class F,
│ │ │ │ +
120 typename std::enable_if<has_proper_signature<F>(PriorityTag<42>()), int>::type = 0>
│ │ │ │ +
│ │ │ │ +
121 void define(Key const& key, F&& f)
│ │ │ │ +
122 {
│ │ │ │ +
123 registry_[key] = f;
│ │ │ │ +
124 }
│ │ │ │ +
│ │ │ │ +
125
│ │ │ │ +
140 template<class Impl,
│ │ │ │ +
141 typename std::enable_if<
│ │ │ │ +
142 std::is_convertible<Impl, Type>::value
│ │ │ │ +
143 and not std::is_convertible<Impl, Creator>::value,
│ │ │ │ +
144 int>::type = 0>
│ │ │ │ +
│ │ │ │ +
145 void define(Key const& key, Impl&& t)
│ │ │ │ +
146 {
│ │ │ │ +
147 registry_[key] = [=](Args...) { return t;};
│ │ │ │ +
148 }
│ │ │ │ +
│ │ │ │ +
149
│ │ │ │ +
│ │ │ │ +
150 bool contains(Key const& key) const
│ │ │ │ +
151 {
│ │ │ │ +
152 return registry_.count(key);
│ │ │ │ +
153 }
│ │ │ │ +
│ │ │ │ +
154
│ │ │ │ +
155 private:
│ │ │ │ +
156
│ │ │ │ +
157 template<class T>
│ │ │ │ +
158 struct Tag{};
│ │ │ │ +
159
│ │ │ │ +
160 template<class Impl>
│ │ │ │ +
161 struct DefaultCreator
│ │ │ │ +
162 {
│ │ │ │ +
163 template<class... T>
│ │ │ │ +
164 Type operator()(T&&... args) const
│ │ │ │ +
165 {
│ │ │ │ +
166 return DefaultCreator::create(Tag<Type>(), PriorityTag<42>(), std::forward<T>(args)...);
│ │ │ │ +
167 }
│ │ │ │ +
168
│ │ │ │ +
169 template<class Target, class... T>
│ │ │ │ +
170 static Type create(Tag<Target>, PriorityTag<1>, T&& ... args) {
│ │ │ │ +
171 return Impl(std::forward<T>(args)...);
│ │ │ │ +
172 }
│ │ │ │ +
173
│ │ │ │ +
174 template<class Target, class... T>
│ │ │ │ +
175 static Type create(Tag<std::unique_ptr<Target>>, PriorityTag<2>, T&& ... args) {
│ │ │ │ +
176 return std::make_unique<Impl>(std::forward<T>(args)...);
│ │ │ │ +
177 }
│ │ │ │ +
178
│ │ │ │ +
179 template<class Target, class... T>
│ │ │ │ +
180 static Type create(Tag<std::shared_ptr<Target>>, PriorityTag<3>, T&& ... args) {
│ │ │ │ +
181 return std::make_shared<Impl>(std::forward<T>(args)...);
│ │ │ │ +
182 }
│ │ │ │ +
183
│ │ │ │ +
184 };
│ │ │ │ +
185
│ │ │ │ +
186 typedef std::map<Key, Creator> Registry;
│ │ │ │ +
187 Registry registry_;
│ │ │ │ +
188};
│ │ │ │ +
│ │ │ │ +
189
│ │ │ │ +
190
│ │ │ │ +
191
│ │ │ │ +
192} // end namespace Dune
│ │ │ │ +
193
│ │ │ │ +
194#endif // DUNE_COMMON_PARAMETERIZEDOBJECT_HH
│ │ │ │ +
A few common exception classes.
│ │ │ │ +
Utilities for type computations, constraining overloads, ...
│ │ │ │ +
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
Inserter< V > io(const V &v)
Definition io.hh:51
│ │ │ │ -
Definition io.hh:28
│ │ │ │ -
Inserter(const T &value)
Definition io.hh:32
│ │ │ │ -
friend Stream & operator<<(Stream &out, const Inserter &ins)
Definition io.hh:37
│ │ │ │ -
Include file for users of the SIMD abstraction layer.
│ │ │ │ +
Default exception if a function was called while the object is not in a valid state for that function...
Definition exceptions.hh:281
│ │ │ │ +
A factory class for parameterized objects.
Definition parameterizedobject.hh:36
│ │ │ │ +
std::function< Type(Args...)> Creator
Definition parameterizedobject.hh:53
│ │ │ │ +
static constexpr auto has_proper_signature(Dune::PriorityTag< 1 >) -> decltype(std::declval< F >()(std::declval< Args >()...), std::true_type())
Definition parameterizedobject.hh:56
│ │ │ │ +
TypeT Type
The type of objects created by the factory.
Definition parameterizedobject.hh:49
│ │ │ │ +
void define(Key const &key, Impl &&t)
Registers a new type with a key.
Definition parameterizedobject.hh:145
│ │ │ │ +
KeyT Key
The typ of the keys.
Definition parameterizedobject.hh:46
│ │ │ │ +
Type create(Key const &key, Args ... args) const
Creates an object identified by a key from given parameters.
Definition parameterizedobject.hh:77
│ │ │ │ +
void define(Key const &key)
Registers a new type with a key.
Definition parameterizedobject.hh:101
│ │ │ │ +
void define(Key const &key, F &&f)
Registers a new creator with a key.
Definition parameterizedobject.hh:121
│ │ │ │ +
static constexpr std::false_type has_proper_signature(Dune::PriorityTag< 0 >)
Definition parameterizedobject.hh:63
│ │ │ │ +
bool contains(Key const &key) const
Definition parameterizedobject.hh:150
│ │ │ │ +
Helper class for tagging priorities.
Definition typeutilities.hh:73
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,135 +1,200 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * simd │ │ │ │ │ -io.hh │ │ │ │ │ +parameterizedobject.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ -1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ +1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- │ │ │ │ │ +2// vi: set et ts=4 sw=4 sts=4: │ │ │ │ │ +3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ -2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -3#ifndef DUNE_COMMON_SIMD_IO_HH │ │ │ │ │ -4#define DUNE_COMMON_SIMD_IO_HH │ │ │ │ │ -5 │ │ │ │ │ -16#include │ │ │ │ │ -17#include │ │ │ │ │ -18 │ │ │ │ │ -19#include │ │ │ │ │ -20#include │ │ │ │ │ -21#include │ │ │ │ │ -22 │ │ │ │ │ -23namespace Dune { │ │ │ │ │ -24 │ │ │ │ │ -25 namespace SimdImpl { │ │ │ │ │ -26 │ │ │ │ │ -27 template │ │ │ │ │ -28 class Inserter { │ │ │ │ │ -29 T value_; │ │ │ │ │ -30 │ │ │ │ │ -31 public: │ │ │ │ │ -32 Inserter(const T &value) : value_(value) {} │ │ │ │ │ -33 │ │ │ │ │ -34 template::value> > │ │ │ │ │ -37 friend Stream& operator<<(Stream &out, const Inserter &ins) │ │ │ │ │ -38 { │ │ │ │ │ -39 const char *sep = "<"; │ │ │ │ │ -40 for(auto l : range(Simd::lanes(ins.value_))) │ │ │ │ │ -41 { │ │ │ │ │ -42 out << sep << autoCopy(Simd::lane(l, ins.value_)); │ │ │ │ │ -43 sep = ", "; │ │ │ │ │ -44 } │ │ │ │ │ -45 out << '>'; │ │ │ │ │ -46 return out; │ │ │ │ │ -47 } │ │ │ │ │ -48 }; │ │ │ │ │ -49 │ │ │ │ │ -50 template() != 1> > │ │ │ │ │ -51 Inserter io(const V &v) │ │ │ │ │ -52 { │ │ │ │ │ -53 return { v }; │ │ │ │ │ -54 } │ │ │ │ │ -55 │ │ │ │ │ -56 template() == 1> > │ │ │ │ │ -57 Simd::Scalar io(const V &v) │ │ │ │ │ +4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ +5#ifndef DUNE_COMMON_PARAMETERIZEDOBJECT_HH │ │ │ │ │ +6#define DUNE_COMMON_PARAMETERIZEDOBJECT_HH │ │ │ │ │ +7 │ │ │ │ │ +8#include │ │ │ │ │ +9#include │ │ │ │ │ +10#include │ │ │ │ │ +11 │ │ │ │ │ +12#include │ │ │ │ │ +13#include │ │ │ │ │ +14 │ │ │ │ │ +15namespace Dune { │ │ │ │ │ +16 │ │ │ │ │ +34template │ │ │ │ │ +36class ParameterizedObjectFactory; │ │ │ │ │ +37 │ │ │ │ │ +38template │ │ │ │ │ +41class ParameterizedObjectFactory │ │ │ │ │ +42{ │ │ │ │ │ +43 public: │ │ │ │ │ +44 │ │ │ │ │ +46 typedef KeyT Key; │ │ │ │ │ +47 │ │ │ │ │ +49 using Type = TypeT; │ │ │ │ │ +50 │ │ │ │ │ +51 protected: │ │ │ │ │ +52 │ │ │ │ │ +53 using Creator = std::function; │ │ │ │ │ +54 │ │ │ │ │ +55 template │ │ │ │ │ +56 static constexpr auto has_proper_signature(Dune::PriorityTag<1>) │ │ │ │ │ +57 -> decltype( std::declval()(std::declval()...), std::true_type()) │ │ │ │ │ 58 { │ │ │ │ │ -59 return Simd::lane(0, v); │ │ │ │ │ +59 return {}; │ │ │ │ │ 60 } │ │ │ │ │ 61 │ │ │ │ │ -62 } │ │ │ │ │ -63 │ │ │ │ │ -64 namespace Simd { │ │ │ │ │ -65 │ │ │ │ │ -82 │ │ │ │ │ -89 template │ │ │ │ │ -90 auto vio(const V &v) │ │ │ │ │ -91 { │ │ │ │ │ -92 return SimdImpl::Inserter{ v }; │ │ │ │ │ -93 } │ │ │ │ │ -94 │ │ │ │ │ -96 │ │ │ │ │ -105 template │ │ │ │ │ -106 auto io(const V &v) │ │ │ │ │ -107 { │ │ │ │ │ -108 return SimdImpl::io(v); │ │ │ │ │ -109 } │ │ │ │ │ -110 │ │ │ │ │ -112 │ │ │ │ │ -114 │ │ │ │ │ -115 } // namespace Simd │ │ │ │ │ -116} // namespace Dune │ │ │ │ │ -117 │ │ │ │ │ -118#endif // DUNE_COMMON_SIMD_IO_HH │ │ │ │ │ -rangeutilities.hh │ │ │ │ │ -Utilities for reduction like operations on ranges. │ │ │ │ │ -typetraits.hh │ │ │ │ │ -Traits for type conversions and type information. │ │ │ │ │ -Dune::range │ │ │ │ │ -static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from │ │ │ │ │ ->, std::integral_constant< T, to >) noexcept │ │ │ │ │ -Definition rangeutilities.hh:312 │ │ │ │ │ -Dune::autoCopy │ │ │ │ │ -constexpr AutonomousValue< T > autoCopy(T &&v) │ │ │ │ │ -Autonomous copy of an expression's value for use in auto type deduction. │ │ │ │ │ -Definition typetraits.hh:672 │ │ │ │ │ -Dune::Simd::io │ │ │ │ │ -auto io(const V &v) │ │ │ │ │ -construct a stream inserter │ │ │ │ │ -Definition io.hh:106 │ │ │ │ │ -Dune::Simd::vio │ │ │ │ │ -auto vio(const V &v) │ │ │ │ │ -construct a stream inserter │ │ │ │ │ -Definition io.hh:90 │ │ │ │ │ -Dune::Simd::lanes │ │ │ │ │ -constexpr std::size_t lanes() │ │ │ │ │ -Number of lanes in a SIMD type. │ │ │ │ │ -Definition simd/interface.hh:305 │ │ │ │ │ -Dune::Simd::lane │ │ │ │ │ -decltype(auto) lane(std::size_t l, V &&v) │ │ │ │ │ -Extract an element of a SIMD type. │ │ │ │ │ -Definition simd/interface.hh:324 │ │ │ │ │ -Dune::Simd::Scalar │ │ │ │ │ -typename Overloads::ScalarType< std::decay_t< V > >::type Scalar │ │ │ │ │ -Element type of some SIMD type. │ │ │ │ │ -Definition simd/interface.hh:235 │ │ │ │ │ +62 template │ │ │ │ │ +63 static constexpr std::false_type has_proper_signature(Dune::PriorityTag<0>) │ │ │ │ │ +64 { │ │ │ │ │ +65 return {}; │ │ │ │ │ +66 } │ │ │ │ │ +67 │ │ │ │ │ +68 public: │ │ │ │ │ +69 │ │ │ │ │ +77 Type create(Key const& key, Args ... args) const { │ │ │ │ │ +78 typename Registry::const_iterator i = registry_.find(key); │ │ │ │ │ +79 if (i == registry_.end()) { │ │ │ │ │ +80 DUNE_THROW(Dune::InvalidStateException, │ │ │ │ │ +81 "ParametrizedObjectFactory: key ``" << │ │ │ │ │ +82 key << "'' not registered"); │ │ │ │ │ +83 } │ │ │ │ │ +84 else return i->second(args...); │ │ │ │ │ +85 } │ │ │ │ │ +86 │ │ │ │ │ +100 template │ │ │ │ │ +101 void define(Key const& key) │ │ │ │ │ +102 { │ │ │ │ │ +103 registry_[key] = DefaultCreator(); │ │ │ │ │ +104 } │ │ │ │ │ +105 │ │ │ │ │ +119 template(PriorityTag<42>()), int>:: │ │ │ │ │ +type = 0> │ │ │ │ │ +121 void define(Key const& key, F&& f) │ │ │ │ │ +122 { │ │ │ │ │ +123 registry_[key] = f; │ │ │ │ │ +124 } │ │ │ │ │ +125 │ │ │ │ │ +140 template::value │ │ │ │ │ +143 and not std::is_convertible::value, │ │ │ │ │ +144 int>::type = 0> │ │ │ │ │ +145 void define(Key const& key, Impl&& t) │ │ │ │ │ +146 { │ │ │ │ │ +147 registry_[key] = [=](Args...) { return t;}; │ │ │ │ │ +148 } │ │ │ │ │ +149 │ │ │ │ │ +150 bool contains(Key const& key) const │ │ │ │ │ +151 { │ │ │ │ │ +152 return registry_.count(key); │ │ │ │ │ +153 } │ │ │ │ │ +154 │ │ │ │ │ +155 private: │ │ │ │ │ +156 │ │ │ │ │ +157 template │ │ │ │ │ +158 struct Tag{}; │ │ │ │ │ +159 │ │ │ │ │ +160 template │ │ │ │ │ +161 struct DefaultCreator │ │ │ │ │ +162 { │ │ │ │ │ +163 template │ │ │ │ │ +164 Type operator()(T&&... args) const │ │ │ │ │ +165 { │ │ │ │ │ +166 return DefaultCreator::create(Tag(), PriorityTag<42>(), std:: │ │ │ │ │ +forward(args)...); │ │ │ │ │ +167 } │ │ │ │ │ +168 │ │ │ │ │ +169 template │ │ │ │ │ +170 static Type create(Tag, PriorityTag<1>, T&& ... args) { │ │ │ │ │ +171 return Impl(std::forward(args)...); │ │ │ │ │ +172 } │ │ │ │ │ +173 │ │ │ │ │ +174 template │ │ │ │ │ +175 static Type create(Tag>, PriorityTag<2>, T&& ... │ │ │ │ │ +args) { │ │ │ │ │ +176 return std::make_unique(std::forward(args)...); │ │ │ │ │ +177 } │ │ │ │ │ +178 │ │ │ │ │ +179 template │ │ │ │ │ +180 static Type create(Tag>, PriorityTag<3>, T&& ... │ │ │ │ │ +args) { │ │ │ │ │ +181 return std::make_shared(std::forward(args)...); │ │ │ │ │ +182 } │ │ │ │ │ +183 │ │ │ │ │ +184 }; │ │ │ │ │ +185 │ │ │ │ │ +186 typedef std::map Registry; │ │ │ │ │ +187 Registry registry_; │ │ │ │ │ +188}; │ │ │ │ │ +189 │ │ │ │ │ +190 │ │ │ │ │ +191 │ │ │ │ │ +192} // end namespace Dune │ │ │ │ │ +193 │ │ │ │ │ +194#endif // DUNE_COMMON_PARAMETERIZEDOBJECT_HH │ │ │ │ │ +exceptions.hh │ │ │ │ │ +A few common exception classes. │ │ │ │ │ +typeutilities.hh │ │ │ │ │ +Utilities for type computations, constraining overloads, ... │ │ │ │ │ +DUNE_THROW │ │ │ │ │ +#define DUNE_THROW(E, m) │ │ │ │ │ +Definition exceptions.hh:218 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::SimdImpl::io │ │ │ │ │ -Inserter< V > io(const V &v) │ │ │ │ │ -Definition io.hh:51 │ │ │ │ │ -Dune::SimdImpl::Inserter │ │ │ │ │ -Definition io.hh:28 │ │ │ │ │ -Dune::SimdImpl::Inserter::Inserter │ │ │ │ │ -Inserter(const T &value) │ │ │ │ │ -Definition io.hh:32 │ │ │ │ │ -Dune::SimdImpl::Inserter::operator<< │ │ │ │ │ -friend Stream & operator<<(Stream &out, const Inserter &ins) │ │ │ │ │ -Definition io.hh:37 │ │ │ │ │ -simd.hh │ │ │ │ │ -Include file for users of the SIMD abstraction layer. │ │ │ │ │ +Dune::InvalidStateException │ │ │ │ │ +Default exception if a function was called while the object is not in a valid │ │ │ │ │ +state for that function... │ │ │ │ │ +Definition exceptions.hh:281 │ │ │ │ │ +Dune::ParameterizedObjectFactory │ │ │ │ │ +A factory class for parameterized objects. │ │ │ │ │ +Definition parameterizedobject.hh:36 │ │ │ │ │ +Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::Creator │ │ │ │ │ +std::function< Type(Args...)> Creator │ │ │ │ │ +Definition parameterizedobject.hh:53 │ │ │ │ │ +Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::has_proper_signature │ │ │ │ │ +static constexpr auto has_proper_signature(Dune::PriorityTag< 1 >) -> decltype │ │ │ │ │ +(std::declval< F >()(std::declval< Args >()...), std::true_type()) │ │ │ │ │ +Definition parameterizedobject.hh:56 │ │ │ │ │ +Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::Type │ │ │ │ │ +TypeT Type │ │ │ │ │ +The type of objects created by the factory. │ │ │ │ │ +Definition parameterizedobject.hh:49 │ │ │ │ │ +Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::define │ │ │ │ │ +void define(Key const &key, Impl &&t) │ │ │ │ │ +Registers a new type with a key. │ │ │ │ │ +Definition parameterizedobject.hh:145 │ │ │ │ │ +Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::Key │ │ │ │ │ +KeyT Key │ │ │ │ │ +The typ of the keys. │ │ │ │ │ +Definition parameterizedobject.hh:46 │ │ │ │ │ +Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::create │ │ │ │ │ +Type create(Key const &key, Args ... args) const │ │ │ │ │ +Creates an object identified by a key from given parameters. │ │ │ │ │ +Definition parameterizedobject.hh:77 │ │ │ │ │ +Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::define │ │ │ │ │ +void define(Key const &key) │ │ │ │ │ +Registers a new type with a key. │ │ │ │ │ +Definition parameterizedobject.hh:101 │ │ │ │ │ +Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::define │ │ │ │ │ +void define(Key const &key, F &&f) │ │ │ │ │ +Registers a new creator with a key. │ │ │ │ │ +Definition parameterizedobject.hh:121 │ │ │ │ │ +Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::has_proper_signature │ │ │ │ │ +static constexpr std::false_type has_proper_signature(Dune::PriorityTag< 0 >) │ │ │ │ │ +Definition parameterizedobject.hh:63 │ │ │ │ │ +Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::contains │ │ │ │ │ +bool contains(Key const &key) const │ │ │ │ │ +Definition parameterizedobject.hh:150 │ │ │ │ │ +Dune::PriorityTag │ │ │ │ │ +Helper class for tagging priorities. │ │ │ │ │ +Definition typeutilities.hh:73 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00011.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: standard.hh File Reference │ │ │ │ +dune-common: indices.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,86 +65,137 @@ │ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Classes | │ │ │ │ -Namespaces
│ │ │ │ - │ │ │ │ +Namespaces | │ │ │ │ +Typedefs | │ │ │ │ +Functions | │ │ │ │ +Variables
│ │ │ │ +
indices.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ - │ │ │ │ -

SIMD abstractions for the standard built-in types. │ │ │ │ -More...

│ │ │ │
#include <cstddef>
│ │ │ │ +#include <stdexcept>
│ │ │ │ #include <type_traits>
│ │ │ │ #include <utility>
│ │ │ │ -#include <dune/common/indices.hh>
│ │ │ │ -#include <dune/common/simd/base.hh>
│ │ │ │ -#include <dune/common/simd/defaults.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Classes

struct  Dune::Simd::Overloads::ScalarType< V, class >
 should have a member type type More...
 
struct  Dune::Simd::Overloads::RebindType< S, class, class >
 should have a member type type More...
 
struct  Dune::Simd::Overloads::LaneCount< class, class >
 should be derived from a Dune::index_constant More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::Simd
 Namespace for vectorization interface functions used by library developers.
namespace  Dune::Indices
 Namespace with predefined compile time indices for the range [0,19].
 
namespace  Dune::Simd::Overloads
 Namespace for the overloads and specializations that make up a SIMD implementation.
namespace  Dune::Indices::Literals
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Typedefs

template<std::size_t i>
using Dune::index_constant = std::integral_constant< std::size_t, i >
 An index constant with value i.
 
│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ Functions

Specialized classes and overloaded functions
template<class V >
Dune::Simd::Overloads::lane (ADLTag< 2 >, std::size_t, V v)
 implements Simd::lane()
 
template<class V >
V & Dune::Simd::Overloads::lane (ADLTag< 3 >, std::size_t, V &v)
 
bool Dune::Simd::Overloads::anyTrue (ADLTag< 2 >, bool mask)
 implements Simd::anyTrue()
 
bool Dune::Simd::Overloads::allTrue (ADLTag< 2 >, bool mask)
 implements Simd::allTrue()
 
bool Dune::Simd::Overloads::anyFalse (ADLTag< 2 >, bool mask)
 implements Simd::anyFalse()
 
bool Dune::Simd::Overloads::allFalse (ADLTag< 2 >, bool mask)
 implements Simd::allFalse()
 
template<class F , class I , I... i>
decltype(auto) constexpr Dune::unpackIntegerSequence (F &&f, std::integer_sequence< I, i... > sequence)
 Unpack an std::integer_sequence<I,i...> to std::integral_constant<I,i>...
 
template<char... digits>
constexpr auto Dune::Indices::Literals::operator""_ic ()
 Literal to create an index compile-time constant.
 
template<char... digits>
constexpr auto Dune::Indices::Literals::operator""_uc ()
 Literal to create an unsigned integer compile-time constant.
 
template<char... digits>
constexpr auto Dune::Indices::Literals::operator""_sc ()
 Literal to create a signed integer compile-time constant.
 
template<class T , T value>
constexpr auto Dune::Indices::Literals::operator- (std::integral_constant< T, value >)
 Negation operator for integral constants.
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ +Variables

constexpr index_constant< 0 > Dune::Indices::_0 = {}
 Compile time index with value 0.
 
constexpr index_constant< 1 > Dune::Indices::_1 = {}
 Compile time index with value 1.
 
constexpr index_constant< 2 > Dune::Indices::_2 = {}
 Compile time index with value 2.
 
constexpr index_constant< 3 > Dune::Indices::_3 = {}
 Compile time index with value 3.
 
constexpr index_constant< 4 > Dune::Indices::_4 = {}
 Compile time index with value 4.
 
constexpr index_constant< 5 > Dune::Indices::_5 = {}
 Compile time index with value 5.
 
constexpr index_constant< 6 > Dune::Indices::_6 = {}
 Compile time index with value 6.
 
constexpr index_constant< 7 > Dune::Indices::_7 = {}
 Compile time index with value 7.
 
constexpr index_constant< 8 > Dune::Indices::_8 = {}
 Compile time index with value 8.
 
constexpr index_constant< 9 > Dune::Indices::_9 = {}
 Compile time index with value 9.
 
constexpr index_constant< 10 > Dune::Indices::_10 = {}
 Compile time index with value 10.
 
constexpr index_constant< 11 > Dune::Indices::_11 = {}
 Compile time index with value 11.
 
constexpr index_constant< 12 > Dune::Indices::_12 = {}
 Compile time index with value 12.
 
constexpr index_constant< 13 > Dune::Indices::_13 = {}
 Compile time index with value 13.
 
constexpr index_constant< 14 > Dune::Indices::_14 = {}
 Compile time index with value 14.
 
constexpr index_constant< 15 > Dune::Indices::_15 = {}
 Compile time index with value 15.
 
constexpr index_constant< 16 > Dune::Indices::_16 = {}
 Compile time index with value 16.
 
constexpr index_constant< 17 > Dune::Indices::_17 = {}
 Compile time index with value 17.
 
constexpr index_constant< 18 > Dune::Indices::_18 = {}
 Compile time index with value 18.
 
constexpr index_constant< 19 > Dune::Indices::_19 = {}
 Compile time index with value 19.
 
│ │ │ │ -

Detailed Description

│ │ │ │ -

SIMD abstractions for the standard built-in types.

│ │ │ │ -

This file should not normally be included by users of the SIMD abstraction (i.e. other Dune headers). Neither should it be included by the translation units passing built-in types to Dune headers that in turn support SIMD types through the SIMD abstraction. Dune-functionality always supports built-in types. Either because that functionality does not support SIMD types and so only supports built-in types, or if it does support SIMD types it must include <dune/common/simd/simd.hh>, which in turn includes this header.

│ │ │ │ -
│ │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,73 +1,117 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * simd │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -standard.hh File Reference │ │ │ │ │ -Common » Vectorization » Application_Developer's_Interface » SIMD_Abstraction │ │ │ │ │ -Implementation_for_standard_types │ │ │ │ │ -SIMD abstractions for the standard built-in types. More... │ │ │ │ │ +Namespaces | Typedefs | Functions | Variables │ │ │ │ │ +indices.hh File Reference │ │ │ │ │ #include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ -Classes │ │ │ │ │ -struct   Dune::Simd::Overloads::ScalarType<_V,_class_> │ │ │ │ │ -  should have a member type type More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::Simd::Overloads::RebindType<_S,_class,_class_> │ │ │ │ │ -  should have a member type type More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::Simd::Overloads::LaneCount<_class,_class_> │ │ │ │ │ -  should be derived from a Dune::index_constant More... │ │ │ │ │ -  │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -namespace   Dune::Simd │ │ │ │ │ -  Namespace for vectorization interface functions used by library │ │ │ │ │ - developers. │ │ │ │ │ -  │ │ │ │ │ -namespace   Dune::Simd::Overloads │ │ │ │ │ -  Namespace for the overloads and specializations that make up a SIMD │ │ │ │ │ - implementation. │ │ │ │ │ +namespace   Dune::Indices │ │ │ │ │ +  Namespace with predefined compile time indices for the range │ │ │ │ │ + [0,19]. │ │ │ │ │ +  │ │ │ │ │ +namespace   Dune::Indices::Literals │ │ │ │ │ +  │ │ │ │ │ +Typedefs │ │ │ │ │ +template │ │ │ │ │ +using  Dune::index_constant = std::integral_constant< std::size_t, i > │ │ │ │ │ +  An index constant with value i. │ │ │ │ │   │ │ │ │ │ Functions │ │ │ │ │ -Specialized classes and overloaded functions │ │ │ │ │ -template │ │ │ │ │ - V  Dune::Simd::Overloads::lane (ADLTag< 2 >, std::size_t, V v) │ │ │ │ │ -  implements Simd::lane() │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - V &  Dune::Simd::Overloads::lane (ADLTag< 3 >, std::size_t, V &v) │ │ │ │ │ -  │ │ │ │ │ -bool  Dune::Simd::Overloads::anyTrue (ADLTag< 2 >, bool mask) │ │ │ │ │ -  implements Simd::anyTrue() │ │ │ │ │ -  │ │ │ │ │ -bool  Dune::Simd::Overloads::allTrue (ADLTag< 2 >, bool mask) │ │ │ │ │ -  implements Simd::allTrue() │ │ │ │ │ -  │ │ │ │ │ -bool  Dune::Simd::Overloads::anyFalse (ADLTag< 2 >, bool mask) │ │ │ │ │ -  implements Simd::anyFalse() │ │ │ │ │ -  │ │ │ │ │ -bool  Dune::Simd::Overloads::allFalse (ADLTag< 2 >, bool mask) │ │ │ │ │ -  implements Simd::allFalse() │ │ │ │ │ -  │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -SIMD abstractions for the standard built-in types. │ │ │ │ │ -This file should not normally be included by users of the SIMD abstraction │ │ │ │ │ -(i.e. other Dune headers). Neither should it be included by the translation │ │ │ │ │ -units passing built-in types to Dune headers that in turn support SIMD types │ │ │ │ │ -through the SIMD abstraction. Dune-functionality always supports built-in │ │ │ │ │ -types. Either because that functionality does not support SIMD types and so │ │ │ │ │ -only supports built-in types, or if it does support SIMD types it must include │ │ │ │ │ -, which in turn includes this header. │ │ │ │ │ +template │ │ │ │ │ +decltype(auto) constexpr  Dune::unpackIntegerSequence (F &&f, std::integer_ │ │ │ │ │ + sequence< I, i... > sequence) │ │ │ │ │ +  Unpack an std::integer_sequence to std:: │ │ │ │ │ + integral_constant... │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + constexpr auto  Dune::Indices::Literals::operator""_ic () │ │ │ │ │ +  Literal to create an index compile-time constant. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + constexpr auto  Dune::Indices::Literals::operator""_uc () │ │ │ │ │ +  Literal to create an unsigned integer compile-time │ │ │ │ │ + constant. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + constexpr auto  Dune::Indices::Literals::operator""_sc () │ │ │ │ │ +  Literal to create a signed integer compile-time │ │ │ │ │ + constant. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + constexpr auto  Dune::Indices::Literals::operator- (std::integral_ │ │ │ │ │ + constant< T, value >) │ │ │ │ │ +  Negation operator for integral constants. │ │ │ │ │ +  │ │ │ │ │ +Variables │ │ │ │ │ + constexpr index_constant< 0 >  Dune::Indices::_0 = {} │ │ │ │ │ +  Compile time index with value 0. │ │ │ │ │ +  │ │ │ │ │ + constexpr index_constant< 1 >  Dune::Indices::_1 = {} │ │ │ │ │ +  Compile time index with value 1. │ │ │ │ │ +  │ │ │ │ │ + constexpr index_constant< 2 >  Dune::Indices::_2 = {} │ │ │ │ │ +  Compile time index with value 2. │ │ │ │ │ +  │ │ │ │ │ + constexpr index_constant< 3 >  Dune::Indices::_3 = {} │ │ │ │ │ +  Compile time index with value 3. │ │ │ │ │ +  │ │ │ │ │ + constexpr index_constant< 4 >  Dune::Indices::_4 = {} │ │ │ │ │ +  Compile time index with value 4. │ │ │ │ │ +  │ │ │ │ │ + constexpr index_constant< 5 >  Dune::Indices::_5 = {} │ │ │ │ │ +  Compile time index with value 5. │ │ │ │ │ +  │ │ │ │ │ + constexpr index_constant< 6 >  Dune::Indices::_6 = {} │ │ │ │ │ +  Compile time index with value 6. │ │ │ │ │ +  │ │ │ │ │ + constexpr index_constant< 7 >  Dune::Indices::_7 = {} │ │ │ │ │ +  Compile time index with value 7. │ │ │ │ │ +  │ │ │ │ │ + constexpr index_constant< 8 >  Dune::Indices::_8 = {} │ │ │ │ │ +  Compile time index with value 8. │ │ │ │ │ +  │ │ │ │ │ + constexpr index_constant< 9 >  Dune::Indices::_9 = {} │ │ │ │ │ +  Compile time index with value 9. │ │ │ │ │ +  │ │ │ │ │ +constexpr index_constant< 10 >  Dune::Indices::_10 = {} │ │ │ │ │ +  Compile time index with value 10. │ │ │ │ │ +  │ │ │ │ │ +constexpr index_constant< 11 >  Dune::Indices::_11 = {} │ │ │ │ │ +  Compile time index with value 11. │ │ │ │ │ +  │ │ │ │ │ +constexpr index_constant< 12 >  Dune::Indices::_12 = {} │ │ │ │ │ +  Compile time index with value 12. │ │ │ │ │ +  │ │ │ │ │ +constexpr index_constant< 13 >  Dune::Indices::_13 = {} │ │ │ │ │ +  Compile time index with value 13. │ │ │ │ │ +  │ │ │ │ │ +constexpr index_constant< 14 >  Dune::Indices::_14 = {} │ │ │ │ │ +  Compile time index with value 14. │ │ │ │ │ +  │ │ │ │ │ +constexpr index_constant< 15 >  Dune::Indices::_15 = {} │ │ │ │ │ +  Compile time index with value 15. │ │ │ │ │ +  │ │ │ │ │ +constexpr index_constant< 16 >  Dune::Indices::_16 = {} │ │ │ │ │ +  Compile time index with value 16. │ │ │ │ │ +  │ │ │ │ │ +constexpr index_constant< 17 >  Dune::Indices::_17 = {} │ │ │ │ │ +  Compile time index with value 17. │ │ │ │ │ +  │ │ │ │ │ +constexpr index_constant< 18 >  Dune::Indices::_18 = {} │ │ │ │ │ +  Compile time index with value 18. │ │ │ │ │ +  │ │ │ │ │ +constexpr index_constant< 19 >  Dune::Indices::_19 = {} │ │ │ │ │ +  Compile time index with value 19. │ │ │ │ │ +  │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00011_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: standard.hh Source File │ │ │ │ +dune-common: indices.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,102 +70,195 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
standard.hh
│ │ │ │ +
indices.hh
│ │ │ │
│ │ │ │
│ │ │ │ -Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ -
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
3#ifndef DUNE_COMMON_SIMD_STANDARD_HH
│ │ │ │ -
4#define DUNE_COMMON_SIMD_STANDARD_HH
│ │ │ │ +Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │ +
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │ +
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ +
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │
5
│ │ │ │ -
20#include <cstddef>
│ │ │ │ -
21#include <type_traits>
│ │ │ │ -
22#include <utility>
│ │ │ │ -
23
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
27
│ │ │ │ -
45namespace Dune {
│ │ │ │ -
46 namespace Simd {
│ │ │ │ -
47
│ │ │ │ -
48 namespace Overloads {
│ │ │ │ -
49
│ │ │ │ +
6#ifndef DUNE_COMMON_INDICES_HH
│ │ │ │ +
7#define DUNE_COMMON_INDICES_HH
│ │ │ │ +
8
│ │ │ │ +
9#include <cstddef>
│ │ │ │ +
10#include <stdexcept>
│ │ │ │ +
11#include <type_traits>
│ │ │ │ +
12#include <utility>
│ │ │ │ +
13
│ │ │ │ +
14namespace Dune
│ │ │ │ +
15{
│ │ │ │ +
28 template<std::size_t i>
│ │ │ │ +
29 using index_constant = std::integral_constant<std::size_t, i>;
│ │ │ │ +
30
│ │ │ │ +
31
│ │ │ │ +
32
│ │ │ │ +
│ │ │ │ +
49 namespace Indices
│ │ │ │ +
50 {
│ │ │ │ +
52 inline constexpr index_constant< 0> _0 = {};
│ │ │ │ +
53
│ │ │ │ +
55 inline constexpr index_constant< 1> _1 = {};
│ │ │ │
56
│ │ │ │ -
59 template<class V, class>
│ │ │ │ -
60 struct ScalarType { using type = V; };
│ │ │ │ -
61
│ │ │ │ -
63
│ │ │ │ -
66 template<class S, class, class>
│ │ │ │ -
67 struct RebindType { using type = S; };
│ │ │ │ +
58 inline constexpr index_constant< 2> _2 = {};
│ │ │ │ +
59
│ │ │ │ +
61 inline constexpr index_constant< 3> _3 = {};
│ │ │ │ +
62
│ │ │ │ +
64 inline constexpr index_constant< 4> _4 = {};
│ │ │ │ +
65
│ │ │ │ +
67 inline constexpr index_constant< 5> _5 = {};
│ │ │ │
68
│ │ │ │ -
70
│ │ │ │ -
73 template<class, class>
│ │ │ │ -
74 struct LaneCount : public index_constant<1> { };
│ │ │ │ -
75
│ │ │ │ +
70 inline constexpr index_constant< 6> _6 = {};
│ │ │ │ +
71
│ │ │ │ +
73 inline constexpr index_constant< 7> _7 = {};
│ │ │ │ +
74
│ │ │ │ +
76 inline constexpr index_constant< 8> _8 = {};
│ │ │ │
77
│ │ │ │ -
86 template<class V>
│ │ │ │ -
│ │ │ │ -
87 V lane(ADLTag<2>, std::size_t, V v)
│ │ │ │ -
88 {
│ │ │ │ -
89 return v;
│ │ │ │ -
90 }
│ │ │ │ -
│ │ │ │ -
91
│ │ │ │ -
92 template<class V>
│ │ │ │ -
│ │ │ │ -
93 V &lane(ADLTag<3>, std::size_t, V &v)
│ │ │ │ -
94 {
│ │ │ │ -
95 return v;
│ │ │ │ -
96 }
│ │ │ │ -
│ │ │ │ -
97
│ │ │ │ -
98 // No Simd::cond() implementation, the overload for bool masks in the
│ │ │ │ -
99 // interface is sufficient
│ │ │ │ -
100
│ │ │ │ -
102 inline bool anyTrue(ADLTag<2>, bool mask) { return mask; }
│ │ │ │ -
103
│ │ │ │ -
105 inline bool allTrue(ADLTag<2>, bool mask) { return mask; }
│ │ │ │ -
106
│ │ │ │ -
108 inline bool anyFalse(ADLTag<2>, bool mask) { return !mask; }
│ │ │ │ -
109
│ │ │ │ -
111 inline bool allFalse(ADLTag<2>, bool mask) { return !mask; }
│ │ │ │ +
79 inline constexpr index_constant< 9> _9 = {};
│ │ │ │ +
80
│ │ │ │ +
82 inline constexpr index_constant<10> _10 = {};
│ │ │ │ +
83
│ │ │ │ +
85 inline constexpr index_constant<11> _11 = {};
│ │ │ │ +
86
│ │ │ │ +
88 inline constexpr index_constant<12> _12 = {};
│ │ │ │ +
89
│ │ │ │ +
91 inline constexpr index_constant<13> _13 = {};
│ │ │ │ +
92
│ │ │ │ +
94 inline constexpr index_constant<14> _14 = {};
│ │ │ │ +
95
│ │ │ │ +
97 inline constexpr index_constant<15> _15 = {};
│ │ │ │ +
98
│ │ │ │ +
100 inline constexpr index_constant<16> _16 = {};
│ │ │ │ +
101
│ │ │ │ +
103 inline constexpr index_constant<17> _17 = {};
│ │ │ │ +
104
│ │ │ │ +
106 inline constexpr index_constant<18> _18 = {};
│ │ │ │ +
107
│ │ │ │ +
109 inline constexpr index_constant<19> _19 = {};
│ │ │ │ +
110
│ │ │ │ +
111 } // namespace Indices
│ │ │ │ +
│ │ │ │
112
│ │ │ │ -
114
│ │ │ │ -
115 } // namespace Overloads
│ │ │ │ -
116 } // namespace Simd
│ │ │ │ -
117} // namespace Dune
│ │ │ │ -
118
│ │ │ │ -
119#endif // DUNE_COMMON_SIMD_STANDARD_HH
│ │ │ │ -
Default implementations for SIMD Implementations.
│ │ │ │ -
Basic definitions for SIMD Implementations.
│ │ │ │ - │ │ │ │ +
123 template<class F, class I, I... i>
│ │ │ │ +
│ │ │ │ +
124 decltype(auto) constexpr unpackIntegerSequence(F&& f, std::integer_sequence<I, i...> sequence)
│ │ │ │ +
125 {
│ │ │ │ +
126 return f(std::integral_constant<I, i>()...);
│ │ │ │ +
127 }
│ │ │ │ +
│ │ │ │ +
128
│ │ │ │ +
129
│ │ │ │ +
│ │ │ │ +
130 namespace Indices { inline namespace Literals
│ │ │ │ +
131 {
│ │ │ │ +
132 namespace Impl
│ │ │ │ +
133 {
│ │ │ │ +
134 // convert a single character into an unsigned integer
│ │ │ │ +
135 constexpr unsigned char2digit (const char c)
│ │ │ │ +
136 {
│ │ │ │ +
137 if (c >= '0' && c <= '9')
│ │ │ │ +
138 return unsigned(c) - unsigned('0');
│ │ │ │ +
139 else {
│ │ │ │ +
140 throw std::invalid_argument("Character is not a digit.");
│ │ │ │ +
141 return 0u;
│ │ │ │ +
142 }
│ │ │ │ +
143 }
│ │ │ │ +
144
│ │ │ │ +
145 // convert a sequence of character digits into an unsigned integer
│ │ │ │ +
146 template <class T, char... digits>
│ │ │ │ +
147 constexpr T chars2number ()
│ │ │ │ +
148 {
│ │ │ │ +
149 const char arr[] = {digits...};
│ │ │ │ +
150 T result = 0;
│ │ │ │ +
151 T power = 1;
│ │ │ │ +
152 const T base = 10;
│ │ │ │ +
153
│ │ │ │ +
154 const int N = sizeof...(digits);
│ │ │ │ +
155 for (int i = 0; i < N; ++i) {
│ │ │ │ +
156 char c = arr[N - 1 - i];
│ │ │ │ +
157 result+= char2digit(c) * power;
│ │ │ │ +
158 power *= base;
│ │ │ │ +
159 }
│ │ │ │ +
160
│ │ │ │ +
161 return result;
│ │ │ │ +
162 }
│ │ │ │ +
163
│ │ │ │ +
164 } //namespace Impl
│ │ │ │ +
165
│ │ │ │ +
172 template <char... digits>
│ │ │ │ +
│ │ │ │ +
173 constexpr auto operator"" _ic()
│ │ │ │ +
174 {
│ │ │ │ +
175 return std::integral_constant<std::size_t, Impl::chars2number<std::size_t,digits...>()>{};
│ │ │ │ +
176 }
│ │ │ │ +
│ │ │ │ +
177
│ │ │ │ +
184 template <char... digits>
│ │ │ │ +
│ │ │ │ +
185 constexpr auto operator"" _uc()
│ │ │ │ +
186 {
│ │ │ │ +
187 return std::integral_constant<unsigned, Impl::chars2number<unsigned,digits...>()>{};
│ │ │ │ +
188 }
│ │ │ │ +
│ │ │ │ +
189
│ │ │ │ +
196 template <char... digits>
│ │ │ │ +
│ │ │ │ +
197 constexpr auto operator"" _sc()
│ │ │ │ +
198 {
│ │ │ │ +
199 return std::integral_constant<int, Impl::chars2number<int,digits...>()>{};
│ │ │ │ +
200 }
│ │ │ │ +
│ │ │ │ +
201
│ │ │ │ +
208 template <class T, T value>
│ │ │ │ +
│ │ │ │ +
209 constexpr auto operator- (std::integral_constant<T,value>)
│ │ │ │ +
210 {
│ │ │ │ +
211 return std::integral_constant<std::make_signed_t<T>, -value>{};
│ │ │ │ +
212 }
│ │ │ │ +
│ │ │ │ +
213
│ │ │ │ +
214 }} //namespace Indices::Literals
│ │ │ │ +
│ │ │ │ +
215} //namespace Dune
│ │ │ │ +
216
│ │ │ │ +
217#endif // DUNE_COMMON_INDICES_HH
│ │ │ │ +
constexpr index_constant< 16 > _16
Compile time index with value 16.
Definition indices.hh:100
│ │ │ │ +
constexpr index_constant< 15 > _15
Compile time index with value 15.
Definition indices.hh:97
│ │ │ │ +
constexpr index_constant< 8 > _8
Compile time index with value 8.
Definition indices.hh:76
│ │ │ │ +
constexpr index_constant< 7 > _7
Compile time index with value 7.
Definition indices.hh:73
│ │ │ │ +
constexpr index_constant< 0 > _0
Compile time index with value 0.
Definition indices.hh:52
│ │ │ │ +
constexpr index_constant< 9 > _9
Compile time index with value 9.
Definition indices.hh:79
│ │ │ │ +
constexpr index_constant< 14 > _14
Compile time index with value 14.
Definition indices.hh:94
│ │ │ │ +
constexpr index_constant< 1 > _1
Compile time index with value 1.
Definition indices.hh:55
│ │ │ │ +
constexpr index_constant< 3 > _3
Compile time index with value 3.
Definition indices.hh:61
│ │ │ │ +
constexpr index_constant< 12 > _12
Compile time index with value 12.
Definition indices.hh:88
│ │ │ │ +
decltype(auto) constexpr unpackIntegerSequence(F &&f, std::integer_sequence< I, i... > sequence)
Unpack an std::integer_sequence<I,i...> to std::integral_constant<I,i>...
Definition indices.hh:124
│ │ │ │ +
constexpr auto operator-(std::integral_constant< T, value >)
Negation operator for integral constants.
Definition indices.hh:209
│ │ │ │ +
constexpr index_constant< 11 > _11
Compile time index with value 11.
Definition indices.hh:85
│ │ │ │ +
constexpr index_constant< 18 > _18
Compile time index with value 18.
Definition indices.hh:106
│ │ │ │ +
constexpr index_constant< 13 > _13
Compile time index with value 13.
Definition indices.hh:91
│ │ │ │ +
constexpr index_constant< 5 > _5
Compile time index with value 5.
Definition indices.hh:67
│ │ │ │ +
constexpr index_constant< 17 > _17
Compile time index with value 17.
Definition indices.hh:103
│ │ │ │ +
constexpr index_constant< 10 > _10
Compile time index with value 10.
Definition indices.hh:82
│ │ │ │ +
constexpr index_constant< 2 > _2
Compile time index with value 2.
Definition indices.hh:58
│ │ │ │
std::integral_constant< std::size_t, i > index_constant
An index constant with value i.
Definition indices.hh:29
│ │ │ │ -
Mask< V > mask(ADLTag< 0, std::is_same< V, Mask< V > >::value >, const V &v)
implements Simd::mask()
Definition defaults.hh:153
│ │ │ │ -
bool allFalse(ADLTag< 0 >, const Mask &mask)
implements Simd::allFalse()
Definition defaults.hh:124
│ │ │ │ -
bool allTrue(ADLTag< 0 >, const Mask &mask)
implements Simd::allTrue()
Definition defaults.hh:104
│ │ │ │ -
bool anyFalse(ADLTag< 0 >, const Mask &mask)
implements Simd::anyFalse()
Definition defaults.hh:114
│ │ │ │ +
constexpr index_constant< 19 > _19
Compile time index with value 19.
Definition indices.hh:109
│ │ │ │ +
constexpr index_constant< 6 > _6
Compile time index with value 6.
Definition indices.hh:70
│ │ │ │ +
constexpr index_constant< 4 > _4
Compile time index with value 4.
Definition indices.hh:64
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
bool anyTrue(ADLTag< 5 >, const AlignedNumber< bool, align > &mask)
Definition debugalign.hh:556
│ │ │ │ -
T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v)
Definition debugalign.hh:533
│ │ │ │ -
Tag used to force late-binding lookup in Dune::Simd::Overloads.
Definition base.hh:182
│ │ │ │ -
should have a member type type
Definition standard.hh:60
│ │ │ │ -
V type
Definition standard.hh:60
│ │ │ │ -
should have a member type type
Definition standard.hh:67
│ │ │ │ -
S type
Definition standard.hh:67
│ │ │ │ -
should be derived from a Dune::index_constant
Definition standard.hh:74
│ │ │ │ +
constexpr Base power(Base m, Exponent p)
Power method for integer exponents.
Definition math.hh:75
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,124 +1,249 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * simd │ │ │ │ │ -standard.hh │ │ │ │ │ +indices.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ -1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ +1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ +2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ +3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ -2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -3#ifndef DUNE_COMMON_SIMD_STANDARD_HH │ │ │ │ │ -4#define DUNE_COMMON_SIMD_STANDARD_HH │ │ │ │ │ +4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ 5 │ │ │ │ │ -20#include │ │ │ │ │ -21#include │ │ │ │ │ -22#include │ │ │ │ │ -23 │ │ │ │ │ -24#include │ │ │ │ │ -25#include │ │ │ │ │ -26#include │ │ │ │ │ -27 │ │ │ │ │ -45namespace Dune { │ │ │ │ │ -46 namespace Simd { │ │ │ │ │ -47 │ │ │ │ │ -48 namespace Overloads { │ │ │ │ │ -49 │ │ │ │ │ +6#ifndef DUNE_COMMON_INDICES_HH │ │ │ │ │ +7#define DUNE_COMMON_INDICES_HH │ │ │ │ │ +8 │ │ │ │ │ +9#include │ │ │ │ │ +10#include │ │ │ │ │ +11#include │ │ │ │ │ +12#include │ │ │ │ │ +13 │ │ │ │ │ +14namespace Dune │ │ │ │ │ +15{ │ │ │ │ │ +28 template │ │ │ │ │ +29 using index_constant = std::integral_constant; │ │ │ │ │ +30 │ │ │ │ │ +31 │ │ │ │ │ +32 │ │ │ │ │ +49 namespace Indices │ │ │ │ │ +50 { │ │ │ │ │ +52 inline constexpr index_constant<_0> _0 = {}; │ │ │ │ │ +53 │ │ │ │ │ +55 inline constexpr index_constant<_1> _1 = {}; │ │ │ │ │ 56 │ │ │ │ │ -59 template │ │ │ │ │ -60 struct ScalarType { using type = V; }; │ │ │ │ │ -61 │ │ │ │ │ -63 │ │ │ │ │ -66 template │ │ │ │ │ -67 struct RebindType { using type = S; }; │ │ │ │ │ +58 inline constexpr index_constant<_2> _2 = {}; │ │ │ │ │ +59 │ │ │ │ │ +61 inline constexpr index_constant<_3> _3 = {}; │ │ │ │ │ +62 │ │ │ │ │ +64 inline constexpr index_constant<_4> _4 = {}; │ │ │ │ │ +65 │ │ │ │ │ +67 inline constexpr index_constant<_5> _5 = {}; │ │ │ │ │ 68 │ │ │ │ │ -70 │ │ │ │ │ -73 template │ │ │ │ │ -74 struct LaneCount : public index_constant<1> { }; │ │ │ │ │ -75 │ │ │ │ │ +70 inline constexpr index_constant<_6> _6 = {}; │ │ │ │ │ +71 │ │ │ │ │ +73 inline constexpr index_constant<_7> _7 = {}; │ │ │ │ │ +74 │ │ │ │ │ +76 inline constexpr index_constant<_8> _8 = {}; │ │ │ │ │ 77 │ │ │ │ │ -86 template │ │ │ │ │ -87 V lane(ADLTag<2>, std::size_t, V v) │ │ │ │ │ -88 { │ │ │ │ │ -89 return v; │ │ │ │ │ -90 } │ │ │ │ │ -91 │ │ │ │ │ -92 template │ │ │ │ │ -93 V &lane(ADLTag<3>, std::size_t, V &v) │ │ │ │ │ -94 { │ │ │ │ │ -95 return v; │ │ │ │ │ -96 } │ │ │ │ │ -97 │ │ │ │ │ -98 // No Simd::cond() implementation, the overload for bool masks in the │ │ │ │ │ -99 // interface is sufficient │ │ │ │ │ -100 │ │ │ │ │ -102 inline bool anyTrue(ADLTag<2>, bool mask) { return mask; } │ │ │ │ │ -103 │ │ │ │ │ -105 inline bool allTrue(ADLTag<2>, bool mask) { return mask; } │ │ │ │ │ -106 │ │ │ │ │ -108 inline bool anyFalse(ADLTag<2>, bool mask) { return !mask; } │ │ │ │ │ -109 │ │ │ │ │ -111 inline bool allFalse(ADLTag<2>, bool mask) { return !mask; } │ │ │ │ │ +79 inline constexpr index_constant<_9> _9 = {}; │ │ │ │ │ +80 │ │ │ │ │ +82 inline constexpr index_constant<10> _10 = {}; │ │ │ │ │ +83 │ │ │ │ │ +85 inline constexpr index_constant<11> _11 = {}; │ │ │ │ │ +86 │ │ │ │ │ +88 inline constexpr index_constant<12> _12 = {}; │ │ │ │ │ +89 │ │ │ │ │ +91 inline constexpr index_constant<13> _13 = {}; │ │ │ │ │ +92 │ │ │ │ │ +94 inline constexpr index_constant<14> _14 = {}; │ │ │ │ │ +95 │ │ │ │ │ +97 inline constexpr index_constant<15> _15 = {}; │ │ │ │ │ +98 │ │ │ │ │ +100 inline constexpr index_constant<16> _16 = {}; │ │ │ │ │ +101 │ │ │ │ │ +103 inline constexpr index_constant<17> _17 = {}; │ │ │ │ │ +104 │ │ │ │ │ +106 inline constexpr index_constant<18> _18 = {}; │ │ │ │ │ +107 │ │ │ │ │ +109 inline constexpr index_constant<19> _19 = {}; │ │ │ │ │ +110 │ │ │ │ │ +111 } // namespace Indices │ │ │ │ │ 112 │ │ │ │ │ -114 │ │ │ │ │ -115 } // namespace Overloads │ │ │ │ │ -116 } // namespace Simd │ │ │ │ │ -117} // namespace Dune │ │ │ │ │ -118 │ │ │ │ │ -119#endif // DUNE_COMMON_SIMD_STANDARD_HH │ │ │ │ │ -defaults.hh │ │ │ │ │ -Default implementations for SIMD Implementations. │ │ │ │ │ -base.hh │ │ │ │ │ -Basic definitions for SIMD Implementations. │ │ │ │ │ -indices.hh │ │ │ │ │ +123 template │ │ │ │ │ +124 decltype(auto) constexpr unpackIntegerSequence(F&& f, std::integer_ │ │ │ │ │ +sequence sequence) │ │ │ │ │ +125 { │ │ │ │ │ +126 return f(std::integral_constant()...); │ │ │ │ │ +127 } │ │ │ │ │ +128 │ │ │ │ │ +129 │ │ │ │ │ +130 namespace Indices { inline namespace Literals │ │ │ │ │ +131 { │ │ │ │ │ +132 namespace Impl │ │ │ │ │ +133 { │ │ │ │ │ +134 // convert a single character into an unsigned integer │ │ │ │ │ +135 constexpr unsigned char2digit (const char c) │ │ │ │ │ +136 { │ │ │ │ │ +137 if (c >= '0' && c <= '9') │ │ │ │ │ +138 return unsigned(c) - unsigned('0'); │ │ │ │ │ +139 else { │ │ │ │ │ +140 throw std::invalid_argument("Character is not a digit."); │ │ │ │ │ +141 return 0u; │ │ │ │ │ +142 } │ │ │ │ │ +143 } │ │ │ │ │ +144 │ │ │ │ │ +145 // convert a sequence of character digits into an unsigned integer │ │ │ │ │ +146 template │ │ │ │ │ +147 constexpr T chars2number () │ │ │ │ │ +148 { │ │ │ │ │ +149 const char arr[] = {digits...}; │ │ │ │ │ +150 T result = 0; │ │ │ │ │ +151 T power = 1; │ │ │ │ │ +152 const T base = 10; │ │ │ │ │ +153 │ │ │ │ │ +154 const int N = sizeof...(digits); │ │ │ │ │ +155 for (int i = 0; i < N; ++i) { │ │ │ │ │ +156 char c = arr[N - 1 - i]; │ │ │ │ │ +157 result+= char2digit(c) * power; │ │ │ │ │ +158 power *= base; │ │ │ │ │ +159 } │ │ │ │ │ +160 │ │ │ │ │ +161 return result; │ │ │ │ │ +162 } │ │ │ │ │ +163 │ │ │ │ │ +164 } //namespace Impl │ │ │ │ │ +165 │ │ │ │ │ +172 template │ │ │ │ │ +173 constexpr auto operator"" _ic() │ │ │ │ │ +174 { │ │ │ │ │ +175 return std::integral_constant()>{}; │ │ │ │ │ +176 } │ │ │ │ │ +177 │ │ │ │ │ +184 template │ │ │ │ │ +185 constexpr auto operator"" _uc() │ │ │ │ │ +186 { │ │ │ │ │ +187 return std::integral_constant()>{}; │ │ │ │ │ +188 } │ │ │ │ │ +189 │ │ │ │ │ +196 template │ │ │ │ │ +197 constexpr auto operator"" _sc() │ │ │ │ │ +198 { │ │ │ │ │ +199 return std::integral_constant()>{}; │ │ │ │ │ +200 } │ │ │ │ │ +201 │ │ │ │ │ +208 template │ │ │ │ │ +209 constexpr auto operator-_(std::integral_constant) │ │ │ │ │ +210 { │ │ │ │ │ +211 return std::integral_constant, -value>{}; │ │ │ │ │ +212 } │ │ │ │ │ +213 │ │ │ │ │ +214 }} //namespace Indices::Literals │ │ │ │ │ +215} //namespace Dune │ │ │ │ │ +216 │ │ │ │ │ +217#endif // DUNE_COMMON_INDICES_HH │ │ │ │ │ +Dune::Indices::_16 │ │ │ │ │ +constexpr index_constant< 16 > _16 │ │ │ │ │ +Compile time index with value 16. │ │ │ │ │ +Definition indices.hh:100 │ │ │ │ │ +Dune::Indices::_15 │ │ │ │ │ +constexpr index_constant< 15 > _15 │ │ │ │ │ +Compile time index with value 15. │ │ │ │ │ +Definition indices.hh:97 │ │ │ │ │ +Dune::Indices::_8 │ │ │ │ │ +constexpr index_constant< 8 > _8 │ │ │ │ │ +Compile time index with value 8. │ │ │ │ │ +Definition indices.hh:76 │ │ │ │ │ +Dune::Indices::_7 │ │ │ │ │ +constexpr index_constant< 7 > _7 │ │ │ │ │ +Compile time index with value 7. │ │ │ │ │ +Definition indices.hh:73 │ │ │ │ │ +Dune::Indices::_0 │ │ │ │ │ +constexpr index_constant< 0 > _0 │ │ │ │ │ +Compile time index with value 0. │ │ │ │ │ +Definition indices.hh:52 │ │ │ │ │ +Dune::Indices::_9 │ │ │ │ │ +constexpr index_constant< 9 > _9 │ │ │ │ │ +Compile time index with value 9. │ │ │ │ │ +Definition indices.hh:79 │ │ │ │ │ +Dune::Indices::_14 │ │ │ │ │ +constexpr index_constant< 14 > _14 │ │ │ │ │ +Compile time index with value 14. │ │ │ │ │ +Definition indices.hh:94 │ │ │ │ │ +Dune::Indices::_1 │ │ │ │ │ +constexpr index_constant< 1 > _1 │ │ │ │ │ +Compile time index with value 1. │ │ │ │ │ +Definition indices.hh:55 │ │ │ │ │ +Dune::Indices::_3 │ │ │ │ │ +constexpr index_constant< 3 > _3 │ │ │ │ │ +Compile time index with value 3. │ │ │ │ │ +Definition indices.hh:61 │ │ │ │ │ +Dune::Indices::_12 │ │ │ │ │ +constexpr index_constant< 12 > _12 │ │ │ │ │ +Compile time index with value 12. │ │ │ │ │ +Definition indices.hh:88 │ │ │ │ │ +Dune::unpackIntegerSequence │ │ │ │ │ +decltype(auto) constexpr unpackIntegerSequence(F &&f, std::integer_sequence< I, │ │ │ │ │ +i... > sequence) │ │ │ │ │ +Unpack an std::integer_sequence to std::integral_constant... │ │ │ │ │ +Definition indices.hh:124 │ │ │ │ │ +Dune::Indices::Literals::operator- │ │ │ │ │ +constexpr auto operator-(std::integral_constant< T, value >) │ │ │ │ │ +Negation operator for integral constants. │ │ │ │ │ +Definition indices.hh:209 │ │ │ │ │ +Dune::Indices::_11 │ │ │ │ │ +constexpr index_constant< 11 > _11 │ │ │ │ │ +Compile time index with value 11. │ │ │ │ │ +Definition indices.hh:85 │ │ │ │ │ +Dune::Indices::_18 │ │ │ │ │ +constexpr index_constant< 18 > _18 │ │ │ │ │ +Compile time index with value 18. │ │ │ │ │ +Definition indices.hh:106 │ │ │ │ │ +Dune::Indices::_13 │ │ │ │ │ +constexpr index_constant< 13 > _13 │ │ │ │ │ +Compile time index with value 13. │ │ │ │ │ +Definition indices.hh:91 │ │ │ │ │ +Dune::Indices::_5 │ │ │ │ │ +constexpr index_constant< 5 > _5 │ │ │ │ │ +Compile time index with value 5. │ │ │ │ │ +Definition indices.hh:67 │ │ │ │ │ +Dune::Indices::_17 │ │ │ │ │ +constexpr index_constant< 17 > _17 │ │ │ │ │ +Compile time index with value 17. │ │ │ │ │ +Definition indices.hh:103 │ │ │ │ │ +Dune::Indices::_10 │ │ │ │ │ +constexpr index_constant< 10 > _10 │ │ │ │ │ +Compile time index with value 10. │ │ │ │ │ +Definition indices.hh:82 │ │ │ │ │ +Dune::Indices::_2 │ │ │ │ │ +constexpr index_constant< 2 > _2 │ │ │ │ │ +Compile time index with value 2. │ │ │ │ │ +Definition indices.hh:58 │ │ │ │ │ Dune::index_constant │ │ │ │ │ std::integral_constant< std::size_t, i > index_constant │ │ │ │ │ An index constant with value i. │ │ │ │ │ Definition indices.hh:29 │ │ │ │ │ -Dune::Simd::Overloads::mask │ │ │ │ │ -Mask< V > mask(ADLTag< 0, std::is_same< V, Mask< V > >::value >, const V &v) │ │ │ │ │ -implements Simd::mask() │ │ │ │ │ -Definition defaults.hh:153 │ │ │ │ │ -Dune::Simd::Overloads::allFalse │ │ │ │ │ -bool allFalse(ADLTag< 0 >, const Mask &mask) │ │ │ │ │ -implements Simd::allFalse() │ │ │ │ │ -Definition defaults.hh:124 │ │ │ │ │ -Dune::Simd::Overloads::allTrue │ │ │ │ │ -bool allTrue(ADLTag< 0 >, const Mask &mask) │ │ │ │ │ -implements Simd::allTrue() │ │ │ │ │ -Definition defaults.hh:104 │ │ │ │ │ -Dune::Simd::Overloads::anyFalse │ │ │ │ │ -bool anyFalse(ADLTag< 0 >, const Mask &mask) │ │ │ │ │ -implements Simd::anyFalse() │ │ │ │ │ -Definition defaults.hh:114 │ │ │ │ │ +Dune::Indices::_19 │ │ │ │ │ +constexpr index_constant< 19 > _19 │ │ │ │ │ +Compile time index with value 19. │ │ │ │ │ +Definition indices.hh:109 │ │ │ │ │ +Dune::Indices::_6 │ │ │ │ │ +constexpr index_constant< 6 > _6 │ │ │ │ │ +Compile time index with value 6. │ │ │ │ │ +Definition indices.hh:70 │ │ │ │ │ +Dune::Indices::_4 │ │ │ │ │ +constexpr index_constant< 4 > _4 │ │ │ │ │ +Compile time index with value 4. │ │ │ │ │ +Definition indices.hh:64 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::Simd::Overloads::anyTrue │ │ │ │ │ -bool anyTrue(ADLTag< 5 >, const AlignedNumber< bool, align > &mask) │ │ │ │ │ -Definition debugalign.hh:556 │ │ │ │ │ -Dune::Simd::Overloads::lane │ │ │ │ │ -T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v) │ │ │ │ │ -Definition debugalign.hh:533 │ │ │ │ │ -Dune::Simd::Overloads::ADLTag │ │ │ │ │ -Tag used to force late-binding lookup in Dune::Simd::Overloads. │ │ │ │ │ -Definition base.hh:182 │ │ │ │ │ -Dune::Simd::Overloads::ScalarType │ │ │ │ │ -should have a member type type │ │ │ │ │ -Definition standard.hh:60 │ │ │ │ │ -Dune::Simd::Overloads::ScalarType::type │ │ │ │ │ -V type │ │ │ │ │ -Definition standard.hh:60 │ │ │ │ │ -Dune::Simd::Overloads::RebindType │ │ │ │ │ -should have a member type type │ │ │ │ │ -Definition standard.hh:67 │ │ │ │ │ -Dune::Simd::Overloads::RebindType::type │ │ │ │ │ -S type │ │ │ │ │ -Definition standard.hh:67 │ │ │ │ │ -Dune::Simd::Overloads::LaneCount │ │ │ │ │ -should be derived from a Dune::index_constant │ │ │ │ │ -Definition standard.hh:74 │ │ │ │ │ +Dune::power │ │ │ │ │ +constexpr Base power(Base m, Exponent p) │ │ │ │ │ +Power method for integer exponents. │ │ │ │ │ +Definition math.hh:75 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00017.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: defaults.hh File Reference │ │ │ │ +dune-common: fmatrixev.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,127 +65,72 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Namespaces
│ │ │ │ - │ │ │ │ +Namespaces | │ │ │ │ +Functions
│ │ │ │ +
fmatrixev.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

Default implementations for SIMD Implementations. │ │ │ │ +

Eigenvalue computations for the FieldMatrix class. │ │ │ │ More...

│ │ │ │
#include <algorithm>
│ │ │ │ -#include <cstddef>
│ │ │ │ -#include <type_traits>
│ │ │ │ -#include <dune/common/rangeutilities.hh>
│ │ │ │ -#include <dune/common/simd/base.hh>
│ │ │ │ -#include <dune/common/simd/interface.hh>
│ │ │ │ -#include <dune/common/typelist.hh>
│ │ │ │ -#include <dune/common/typetraits.hh>
│ │ │ │ +#include <iostream>
│ │ │ │ +#include <cmath>
│ │ │ │ +#include <cassert>
│ │ │ │ +#include <dune-common-config.hh>
│ │ │ │ +#include <dune/common/exceptions.hh>
│ │ │ │ +#include <dune/common/fvector.hh>
│ │ │ │ +#include <dune/common/fmatrix.hh>
│ │ │ │ +#include <dune/common/math.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::Simd
 Namespace for vectorization interface functions used by library developers.
 
namespace  Dune::Simd::Overloads
 Namespace for the overloads and specializations that make up a SIMD implementation.
namespace  Dune::FMatrixHelp
 
│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Functions

Overloadable and default functions

This group contains functions that you, as an abstraction developer, must implement. All functions that are deleted must be provided, functions that have a default implementation may be left unimplemented if the default behaviour is satisfactory.

│ │ │ │ -
template<class V >
decltype(auto) Dune::Simd::Overloads::lane (ADLTag< 0 >, std::size_t l, V v)=delete
 implements Simd::lane()
 
template<class V >
constexpr V Dune::Simd::Overloads::implCast (ADLTag< 0 >, MetaType< V >, const V &u)
 implements Simd::implCast<V>(V)
 
template<class V , class U >
constexpr V Dune::Simd::Overloads::implCast (ADLTag< 0 >, MetaType< V >, const U &u)
 implements Simd::implCast<V>(U)
 
template<class V , class S >
auto Dune::Simd::Overloads::broadcast (ADLTag< 0 >, MetaType< V >, S s)
 implements Simd::broadcast<V>()
 
template<class V >
Dune::Simd::Overloads::cond (ADLTag< 0 >, const Mask< V > &mask, const V &ifTrue, const V &ifFalse)=delete
 implements Simd::cond()
 
template<class V >
auto Dune::Simd::Overloads::max (ADLTag< 0 >, const V &v1, const V &v2)
 implements binary Simd::max()
 
template<class V >
auto Dune::Simd::Overloads::min (ADLTag< 0 >, const V &v1, const V &v2)
 implements binary Simd::min()
 
template<class Mask >
bool Dune::Simd::Overloads::anyTrue (ADLTag< 0 >, const Mask &mask)=delete
 implements Simd::anyTrue()
 
template<class Mask >
bool Dune::Simd::Overloads::allTrue (ADLTag< 0 >, const Mask &mask)
 implements Simd::allTrue()
 
template<class Mask >
bool Dune::Simd::Overloads::anyFalse (ADLTag< 0 >, const Mask &mask)
 implements Simd::anyFalse()
 
template<class Mask >
bool Dune::Simd::Overloads::allFalse (ADLTag< 0 >, const Mask &mask)
 implements Simd::allFalse()
 
template<class V >
auto Dune::Simd::Overloads::max (ADLTag< 0 >, const V &v)
 implements Simd::maxValue()
 
template<class V >
auto Dune::Simd::Overloads::min (ADLTag< 0 >, const V &v)
 implements Simd::minValue()
 
template<class V >
Mask< V > Dune::Simd::Overloads::mask (ADLTag< 0, std::is_same< V, Mask< V > >::value >, const V &v)
 implements Simd::mask()
 
template<class V >
auto Dune::Simd::Overloads::mask (ADLTag< 0, !std::is_same< V, Mask< V > >::value >, const V &v)
 implements Simd::mask()
 
template<class V1 , class V2 >
auto Dune::Simd::Overloads::maskOr (ADLTag< 0 >, const V1 &v1, const V2 &v2)
 implements Simd::maskOr()
 
template<class V1 , class V2 >
auto Dune::Simd::Overloads::maskAnd (ADLTag< 0 >, const V1 &v1, const V2 &v2)
 implements Simd::maskAnd()
 
template<int dim, typename K >
static void Dune::FMatrixHelp::eigenValues (const FieldMatrix< K, dim, dim > &matrix, FieldVector< K, dim > &eigenValues)
 calculates the eigenvalues of a symmetric field matrix
 
template<int dim, typename K >
static void Dune::FMatrixHelp::eigenValuesVectors (const FieldMatrix< K, dim, dim > &matrix, FieldVector< K, dim > &eigenValues, FieldMatrix< K, dim, dim > &eigenVectors)
 calculates the eigenvalues and eigenvectors of a symmetric field matrix
 
template<int dim, typename K >
static void Dune::FMatrixHelp::eigenValuesLapack (const FieldMatrix< K, dim, dim > &matrix, FieldVector< K, dim > &eigenValues)
 calculates the eigenvalues of a symmetric field matrix
 
template<int dim, typename K >
static void Dune::FMatrixHelp::eigenValuesVectorsLapack (const FieldMatrix< K, dim, dim > &matrix, FieldVector< K, dim > &eigenValues, FieldMatrix< K, dim, dim > &eigenVectors)
 calculates the eigenvalues and -vectors of a symmetric field matrix
 
template<int dim, typename K , class C >
static void Dune::FMatrixHelp::eigenValuesNonSym (const FieldMatrix< K, dim, dim > &matrix, FieldVector< C, dim > &eigenValues)
 calculates the eigenvalues of a non-symmetric field matrix
 
│ │ │ │

Detailed Description

│ │ │ │ -

Default implementations for SIMD Implementations.

│ │ │ │ -

This file provides default overloads for SIMD implementation functions, and deleted placeholders where there are no default implementations.

│ │ │ │ -

This file should never be included by users of the SIMD abstraction. Include <dune/common/simd/simd.hh> instead.

│ │ │ │ +

Eigenvalue computations for the FieldMatrix class.

│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,126 +1,59 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * simd │ │ │ │ │ -Namespaces │ │ │ │ │ -defaults.hh File Reference │ │ │ │ │ -Common » Vectorization » Abstraction_Developer's_Interface │ │ │ │ │ -Default implementations for SIMD Implementations. More... │ │ │ │ │ +Namespaces | Functions │ │ │ │ │ +fmatrixev.hh File Reference │ │ │ │ │ +Eigenvalue computations for the FieldMatrix class. More... │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -namespace   Dune::Simd │ │ │ │ │ -  Namespace for vectorization interface functions used by library │ │ │ │ │ - developers. │ │ │ │ │ -  │ │ │ │ │ -namespace   Dune::Simd::Overloads │ │ │ │ │ -  Namespace for the overloads and specializations that make up a SIMD │ │ │ │ │ - implementation. │ │ │ │ │ +namespace   Dune::FMatrixHelp │ │ │ │ │   │ │ │ │ │ Functions │ │ │ │ │ -Overloadable and default functions │ │ │ │ │ -This group contains functions that you, as an abstraction developer, must │ │ │ │ │ -implement. All functions that are deleted must be provided, functions that have │ │ │ │ │ -a default implementation may be left unimplemented if the default behaviour is │ │ │ │ │ -satisfactory. │ │ │ │ │ -template │ │ │ │ │ -decltype(auto)  Dune::Simd::Overloads::lane (ADLTag< 0 >, std::size_t l, V │ │ │ │ │ - v)=delete │ │ │ │ │ -  implements Simd::lane() │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - constexpr V  Dune::Simd::Overloads::implCast (ADLTag< 0 >, MetaType< V >, │ │ │ │ │ - const V &u) │ │ │ │ │ -  implements Simd::implCast(V) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - constexpr V  Dune::Simd::Overloads::implCast (ADLTag< 0 >, MetaType< V >, │ │ │ │ │ - const U &u) │ │ │ │ │ -  implements Simd::implCast(U) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::Simd::Overloads::broadcast (ADLTag< 0 >, MetaType< V >, S │ │ │ │ │ - s) │ │ │ │ │ -  implements Simd::broadcast() │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - V  Dune::Simd::Overloads::cond (ADLTag< 0 >, const Mask< V > │ │ │ │ │ - &mask, const V &ifTrue, const V &ifFalse)=delete │ │ │ │ │ -  implements Simd::cond() │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::Simd::Overloads::max (ADLTag< 0 >, const V &v1, const V │ │ │ │ │ - &v2) │ │ │ │ │ -  implements binary Simd::max() │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::Simd::Overloads::min (ADLTag< 0 >, const V &v1, const V │ │ │ │ │ - &v2) │ │ │ │ │ -  implements binary Simd::min() │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - bool  Dune::Simd::Overloads::anyTrue (ADLTag< 0 >, const Mask │ │ │ │ │ - &mask)=delete │ │ │ │ │ -  implements Simd::anyTrue() │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - bool  Dune::Simd::Overloads::allTrue (ADLTag< 0 >, const Mask &mask) │ │ │ │ │ -  implements Simd::allTrue() │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - bool  Dune::Simd::Overloads::anyFalse (ADLTag< 0 >, const Mask &mask) │ │ │ │ │ -  implements Simd::anyFalse() │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - bool  Dune::Simd::Overloads::allFalse (ADLTag< 0 >, const Mask &mask) │ │ │ │ │ -  implements Simd::allFalse() │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::Simd::Overloads::max (ADLTag< 0 >, const V &v) │ │ │ │ │ -  implements Simd::maxValue() │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::Simd::Overloads::min (ADLTag< 0 >, const V &v) │ │ │ │ │ -  implements Simd::minValue() │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - Mask< V >  Dune::Simd::Overloads::mask (ADLTag< 0, std::is_same< V, Mask< │ │ │ │ │ - V > >::value >, const V &v) │ │ │ │ │ -  implements Simd::mask() │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::Simd::Overloads::mask (ADLTag< 0, !std::is_same< V, Mask< │ │ │ │ │ - V > >::value >, const V &v) │ │ │ │ │ -  implements Simd::mask() │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::Simd::Overloads::maskOr (ADLTag< 0 >, const V1 &v1, const │ │ │ │ │ - V2 &v2) │ │ │ │ │ -  implements Simd::maskOr() │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::Simd::Overloads::maskAnd (ADLTag< 0 >, const V1 &v1, │ │ │ │ │ - const V2 &v2) │ │ │ │ │ -  implements Simd::maskAnd() │ │ │ │ │ +template │ │ │ │ │ +static void  Dune::FMatrixHelp::eigenValues (const FieldMatrix< K, dim, dim > │ │ │ │ │ + &matrix, FieldVector< K, dim > &eigenValues) │ │ │ │ │ +  calculates the eigenvalues of a symmetric field matrix │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +static void  Dune::FMatrixHelp::eigenValuesVectors (const FieldMatrix< K, dim, │ │ │ │ │ + dim > &matrix, FieldVector< K, dim > &eigenValues, FieldMatrix< K, │ │ │ │ │ + dim, dim > &eigenVectors) │ │ │ │ │ +  calculates the eigenvalues and eigenvectors of a symmetric field │ │ │ │ │ + matrix │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +static void  Dune::FMatrixHelp::eigenValuesLapack (const FieldMatrix< K, dim, │ │ │ │ │ + dim > &matrix, FieldVector< K, dim > &eigenValues) │ │ │ │ │ +  calculates the eigenvalues of a symmetric field matrix │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +static void  Dune::FMatrixHelp::eigenValuesVectorsLapack (const FieldMatrix< K, │ │ │ │ │ + dim, dim > &matrix, FieldVector< K, dim > &eigenValues, │ │ │ │ │ + FieldMatrix< K, dim, dim > &eigenVectors) │ │ │ │ │ +  calculates the eigenvalues and -vectors of a symmetric field │ │ │ │ │ + matrix │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +static void  Dune::FMatrixHelp::eigenValuesNonSym (const FieldMatrix< K, dim, │ │ │ │ │ + dim > &matrix, FieldVector< C, dim > &eigenValues) │ │ │ │ │ +  calculates the eigenvalues of a non-symmetric field matrix │ │ │ │ │   │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Default implementations for SIMD Implementations. │ │ │ │ │ -This file provides default overloads for SIMD implementation functions, and │ │ │ │ │ -deleted placeholders where there are no default implementations. │ │ │ │ │ -This file should never be included by users of the SIMD abstraction. Include │ │ │ │ │ - instead. │ │ │ │ │ +Eigenvalue computations for the FieldMatrix class. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00017_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: defaults.hh Source File │ │ │ │ +dune-common: fmatrixev.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,215 +70,645 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
defaults.hh
│ │ │ │ +
fmatrixev.hh
│ │ │ │
│ │ │ │
│ │ │ │ -Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ -
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
3#ifndef DUNE_COMMON_SIMD_DEFAULTS_HH
│ │ │ │ -
4#define DUNE_COMMON_SIMD_DEFAULTS_HH
│ │ │ │ -
5
│ │ │ │ -
17#include <algorithm>
│ │ │ │ -
18#include <cstddef>
│ │ │ │ -
19#include <type_traits>
│ │ │ │ -
20
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
26
│ │ │ │ -
27namespace Dune {
│ │ │ │ -
28 namespace Simd {
│ │ │ │ -
29 namespace Overloads {
│ │ │ │ -
30
│ │ │ │ -
47 template<class V>
│ │ │ │ -
48 decltype(auto) lane(ADLTag<0>, std::size_t l, V v) = delete;
│ │ │ │ +Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │ +
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │ +
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ +
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ +
5#ifndef DUNE_FMATRIXEIGENVALUES_HH
│ │ │ │ +
6#define DUNE_FMATRIXEIGENVALUES_HH
│ │ │ │ +
7
│ │ │ │ +
12#include <algorithm>
│ │ │ │ +
13#include <iostream>
│ │ │ │ +
14#include <cmath>
│ │ │ │ +
15#include <cassert>
│ │ │ │ +
16
│ │ │ │ +
17#include <dune-common-config.hh> // HAVE_LAPACK
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
21#include <dune/common/math.hh>
│ │ │ │ +
22
│ │ │ │ +
23namespace Dune {
│ │ │ │ +
24
│ │ │ │ +
30 namespace FMatrixHelp {
│ │ │ │ +
31
│ │ │ │ +
32#if HAVE_LAPACK
│ │ │ │ +
33 // defined in fmatrixev.cc
│ │ │ │ +
34 extern void eigenValuesLapackCall(
│ │ │ │ +
35 const char* jobz, const char* uplo, const long
│ │ │ │ +
36 int* n, double* a, const long int* lda, double* w,
│ │ │ │ +
37 double* work, const long int* lwork, long int* info);
│ │ │ │ +
38
│ │ │ │ +
39 extern void eigenValuesNonsymLapackCall(
│ │ │ │ +
40 const char* jobvl, const char* jobvr, const long
│ │ │ │ +
41 int* n, double* a, const long int* lda, double* wr, double* wi, double* vl,
│ │ │ │ +
42 const long int* ldvl, double* vr, const long int* ldvr, double* work,
│ │ │ │ +
43 const long int* lwork, long int* info);
│ │ │ │ +
44
│ │ │ │ +
45 extern void eigenValuesLapackCall(
│ │ │ │ +
46 const char* jobz, const char* uplo, const long
│ │ │ │ +
47 int* n, float* a, const long int* lda, float* w,
│ │ │ │ +
48 float* work, const long int* lwork, long int* info);
│ │ │ │
49
│ │ │ │ -
51 template<class V>
│ │ │ │ -
│ │ │ │ -
52 constexpr V implCast(ADLTag<0>, MetaType<V>, const V &u)
│ │ │ │ -
53 {
│ │ │ │ -
54 return u;
│ │ │ │ -
55 }
│ │ │ │ -
│ │ │ │ -
56
│ │ │ │ -
58 template<class V, class U>
│ │ │ │ -
│ │ │ │ -
59 constexpr V implCast(ADLTag<0>, MetaType<V>, const U &u)
│ │ │ │ -
60 {
│ │ │ │ -
61 V result(Simd::Scalar<V>(0));
│ │ │ │ -
62 for(auto l : range(Simd::lanes(u)))
│ │ │ │ -
63 Simd::lane(l, result) = Simd::lane(l, u);
│ │ │ │ -
64 return result;
│ │ │ │ -
65 }
│ │ │ │ -
│ │ │ │ -
66
│ │ │ │ -
68 template<class V, class S>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
70 {
│ │ │ │ -
71 return V(Simd::Scalar<V>(s));
│ │ │ │ -
72 }
│ │ │ │ -
│ │ │ │ -
73
│ │ │ │ -
75 template<class V>
│ │ │ │ - │ │ │ │ -
77 const V &ifTrue, const V &ifFalse) = delete;
│ │ │ │ -
78
│ │ │ │ -
80 template<class V>
│ │ │ │ -
│ │ │ │ -
81 auto max(ADLTag<0>, const V &v1, const V &v2)
│ │ │ │ -
82 {
│ │ │ │ -
83 using std::max;
│ │ │ │ -
84 return max(v1, v2);
│ │ │ │ -
85 }
│ │ │ │ -
│ │ │ │ -
86
│ │ │ │ -
88 template<class V>
│ │ │ │ -
│ │ │ │ -
89 auto min(ADLTag<0>, const V &v1, const V &v2)
│ │ │ │ -
90 {
│ │ │ │ -
91 using std::min;
│ │ │ │ -
92 return min(v1, v2);
│ │ │ │ -
93 }
│ │ │ │ -
│ │ │ │ -
94
│ │ │ │ -
96 template<class Mask>
│ │ │ │ -
97 bool anyTrue(ADLTag<0>, const Mask &mask) = delete;
│ │ │ │ -
98
│ │ │ │ -
100
│ │ │ │ -
103 template<class Mask>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
105 {
│ │ │ │ -
106 return !Dune::Simd::anyTrue(!mask);
│ │ │ │ -
107 }
│ │ │ │ -
│ │ │ │ -
108
│ │ │ │ -
110
│ │ │ │ -
113 template<class Mask>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
115 {
│ │ │ │ -
116 return Dune::Simd::anyTrue(!mask);
│ │ │ │ -
117 }
│ │ │ │ -
│ │ │ │ -
118
│ │ │ │ -
120
│ │ │ │ -
123 template<class Mask>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
125 {
│ │ │ │ -
126 return !Dune::Simd::anyTrue(mask);
│ │ │ │ -
127 }
│ │ │ │ -
│ │ │ │ +
50 extern void eigenValuesNonsymLapackCall(
│ │ │ │ +
51 const char* jobvl, const char* jobvr, const long
│ │ │ │ +
52 int* n, float* a, const long int* lda, float* wr, float* wi, float* vl,
│ │ │ │ +
53 const long int* ldvl, float* vr, const long int* ldvr, float* work,
│ │ │ │ +
54 const long int* lwork, long int* info);
│ │ │ │ +
55
│ │ │ │ +
56#endif
│ │ │ │ +
57
│ │ │ │ +
58 namespace Impl {
│ │ │ │ +
59 //internal tag to activate/disable code for eigenvector calculation at compile time
│ │ │ │ +
60 enum Jobs { OnlyEigenvalues=0, EigenvaluesEigenvectors=1 };
│ │ │ │ +
61
│ │ │ │ +
62 //internal dummy used if only eigenvalues are to be calculated
│ │ │ │ +
63 template<typename K, int dim>
│ │ │ │ +
64 using EVDummy = FieldMatrix<K, dim, dim>;
│ │ │ │ +
65
│ │ │ │ +
66 //compute the cross-product of two vectors
│ │ │ │ +
67 template<typename K>
│ │ │ │ +
68 inline FieldVector<K,3> crossProduct(const FieldVector<K,3>& vec0, const FieldVector<K,3>& vec1) {
│ │ │ │ +
69 return {vec0[1]*vec1[2] - vec0[2]*vec1[1], vec0[2]*vec1[0] - vec0[0]*vec1[2], vec0[0]*vec1[1] - vec0[1]*vec1[0]};
│ │ │ │ +
70 }
│ │ │ │ +
71
│ │ │ │ +
72 template <typename K>
│ │ │ │ +
73 static void eigenValues2dImpl(const FieldMatrix<K, 2, 2>& matrix,
│ │ │ │ +
74 FieldVector<K, 2>& eigenvalues)
│ │ │ │ +
75 {
│ │ │ │ +
76 using std::sqrt;
│ │ │ │ +
77 const K p = 0.5 * (matrix[0][0] + matrix [1][1]);
│ │ │ │ +
78 const K p2 = p - matrix[1][1];
│ │ │ │ +
79 K q = p2 * p2 + matrix[1][0] * matrix[0][1];
│ │ │ │ +
80 if( q < 0 && q > -1e-14 ) q = 0;
│ │ │ │ +
81 if (q < 0)
│ │ │ │ +
82 {
│ │ │ │ +
83 std::cout << matrix << std::endl;
│ │ │ │ +
84 // Complex eigenvalues are either caused by non-symmetric matrices or by round-off errors
│ │ │ │ +
85 DUNE_THROW(MathError, "Complex eigenvalue detected (which this implementation cannot handle).");
│ │ │ │ +
86 }
│ │ │ │ +
87
│ │ │ │ +
88 // get square root
│ │ │ │ +
89 q = sqrt(q);
│ │ │ │ +
90
│ │ │ │ +
91 // store eigenvalues in ascending order
│ │ │ │ +
92 eigenvalues[0] = p - q;
│ │ │ │ +
93 eigenvalues[1] = p + q;
│ │ │ │ +
94 }
│ │ │ │ +
95
│ │ │ │ +
96 /*
│ │ │ │ +
97 This implementation was adapted from the pseudo-code (Python?) implementation found on
│ │ │ │ +
98 http://en.wikipedia.org/wiki/Eigenvalue_algorithm (retrieved late August 2014).
│ │ │ │ +
99 Wikipedia claims to have taken it from
│ │ │ │ +
100 Smith, Oliver K. (April 1961), Eigenvalues of a symmetric 3 × 3 matrix.,
│ │ │ │ +
101 Communications of the ACM 4 (4): 168, doi:10.1145/355578.366316
│ │ │ │ +
102 */
│ │ │ │ +
103 template <typename K>
│ │ │ │ +
104 static K eigenValues3dImpl(const FieldMatrix<K, 3, 3>& matrix,
│ │ │ │ +
105 FieldVector<K, 3>& eigenvalues)
│ │ │ │ +
106 {
│ │ │ │ +
107 using std::sqrt;
│ │ │ │ +
108 using std::acos;
│ │ │ │ +
109 using real_type = typename FieldTraits<K>::real_type;
│ │ │ │ +
110 const K pi = MathematicalConstants<K>::pi();
│ │ │ │ +
111 K p1 = matrix[0][1]*matrix[0][1] + matrix[0][2]*matrix[0][2] + matrix[1][2]*matrix[1][2];
│ │ │ │ +
112
│ │ │ │ +
113 if (p1 <= std::numeric_limits<K>::epsilon()) {
│ │ │ │ +
114 // A is diagonal.
│ │ │ │ +
115 eigenvalues[0] = matrix[0][0];
│ │ │ │ +
116 eigenvalues[1] = matrix[1][1];
│ │ │ │ +
117 eigenvalues[2] = matrix[2][2];
│ │ │ │ +
118 std::sort(eigenvalues.begin(), eigenvalues.end());
│ │ │ │ +
119
│ │ │ │ +
120 return 0.0;
│ │ │ │ +
121 }
│ │ │ │ +
122 else
│ │ │ │ +
123 {
│ │ │ │ +
124 // q = trace(A)/3
│ │ │ │ +
125 K q = 0;
│ │ │ │ +
126 for (int i=0; i<3; i++)
│ │ │ │ +
127 q += matrix[i][i] / 3.0;
│ │ │ │
128
│ │ │ │ -
130 template<class V>
│ │ │ │ -
│ │ │ │ -
131 auto max(ADLTag<0>, const V &v)
│ │ │ │ -
132 {
│ │ │ │ -
133 Scalar<V> m = Simd::lane(0, v);
│ │ │ │ -
134 for(std::size_t l = 1; l < Simd::lanes(v); ++l)
│ │ │ │ -
135 if(m < Simd::lane(l, v))
│ │ │ │ -
136 m = Simd::lane(l, v);
│ │ │ │ -
137 return m;
│ │ │ │ -
138 }
│ │ │ │ -
│ │ │ │ -
139
│ │ │ │ -
141 template<class V>
│ │ │ │ -
│ │ │ │ -
142 auto min(ADLTag<0>, const V &v)
│ │ │ │ -
143 {
│ │ │ │ -
144 Scalar<V> m = Simd::lane(0, v);
│ │ │ │ -
145 for(std::size_t l = 1; l < Simd::lanes(v); ++l)
│ │ │ │ -
146 if(Simd::lane(l, v) < m)
│ │ │ │ -
147 m = Simd::lane(l, v);
│ │ │ │ -
148 return m;
│ │ │ │ -
149 }
│ │ │ │ -
│ │ │ │ -
150
│ │ │ │ -
152 template<class V>
│ │ │ │ -
│ │ │ │ -
153 Mask<V> mask(ADLTag<0, std::is_same<V, Mask<V> >::value>,
│ │ │ │ -
154 const V &v)
│ │ │ │ -
155 {
│ │ │ │ -
156 return v;
│ │ │ │ -
157 }
│ │ │ │ -
│ │ │ │ -
158
│ │ │ │ -
160 template<class V>
│ │ │ │ -
│ │ │ │ -
161 auto mask(ADLTag<0, !std::is_same<V, Mask<V> >::value>,
│ │ │ │ -
162 const V &v)
│ │ │ │ -
163 {
│ │ │ │ -
164 using Copy = AutonomousValue<V>; // just in case we are handed a proxy
│ │ │ │ -
165 return v != Copy(Scalar<Copy>(0));
│ │ │ │ -
166 }
│ │ │ │ -
│ │ │ │ -
167
│ │ │ │ -
169 template<class V1, class V2>
│ │ │ │ -
│ │ │ │ -
170 auto maskOr(ADLTag<0>, const V1 &v1, const V2 &v2)
│ │ │ │ -
171 {
│ │ │ │ -
172 return Simd::mask(v1) || Simd::mask(v2);
│ │ │ │ -
173 }
│ │ │ │ -
│ │ │ │ -
174
│ │ │ │ -
176 template<class V1, class V2>
│ │ │ │ -
│ │ │ │ -
177 auto maskAnd(ADLTag<0>, const V1 &v1, const V2 &v2)
│ │ │ │ -
178 {
│ │ │ │ -
179 return Simd::mask(v1) && Simd::mask(v2);
│ │ │ │ -
180 }
│ │ │ │ -
│ │ │ │ -
181
│ │ │ │ -
184 } // namespace Overloads
│ │ │ │ -
185 } // namespace Simd
│ │ │ │ -
186} // namespace Dune
│ │ │ │ -
187
│ │ │ │ -
188#endif // DUNE_COMMON_SIMD_DEFAULTS_HH
│ │ │ │ -
Basic definitions for SIMD Implementations.
│ │ │ │ - │ │ │ │ -
Utilities for reduction like operations on ranges.
│ │ │ │ -
Traits for type conversions and type information.
│ │ │ │ -
static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from >, std::integral_constant< T, to >) noexcept
Definition rangeutilities.hh:312
│ │ │ │ -
typename AutonomousValueType< T >::type AutonomousValue
Type free of internal references that T can be converted to.
Definition typetraits.hh:588
│ │ │ │ -
bool anyTrue(const Mask &mask)
Whether any entry is true
Definition simd/interface.hh:429
│ │ │ │ -
auto mask(const V &v)
Convert to mask, analogue of bool(s) for scalars.
Definition simd/interface.hh:489
│ │ │ │ -
constexpr std::size_t lanes()
Number of lanes in a SIMD type.
Definition simd/interface.hh:305
│ │ │ │ -
decltype(auto) lane(std::size_t l, V &&v)
Extract an element of a SIMD type.
Definition simd/interface.hh:324
│ │ │ │ -
Rebind< bool, V > Mask
Mask type type of some SIMD type.
Definition simd/interface.hh:289
│ │ │ │ -
typename Overloads::ScalarType< std::decay_t< V > >::type Scalar
Element type of some SIMD type.
Definition simd/interface.hh:235
│ │ │ │ -
Mask< V > mask(ADLTag< 0, std::is_same< V, Mask< V > >::value >, const V &v)
implements Simd::mask()
Definition defaults.hh:153
│ │ │ │ -
constexpr V implCast(ADLTag< 0 >, MetaType< V >, const V &u)
implements Simd::implCast<V>(V)
Definition defaults.hh:52
│ │ │ │ -
bool allFalse(ADLTag< 0 >, const Mask &mask)
implements Simd::allFalse()
Definition defaults.hh:124
│ │ │ │ -
bool allTrue(ADLTag< 0 >, const Mask &mask)
implements Simd::allTrue()
Definition defaults.hh:104
│ │ │ │ -
auto maskAnd(ADLTag< 0 >, const V1 &v1, const V2 &v2)
implements Simd::maskAnd()
Definition defaults.hh:177
│ │ │ │ -
auto maskOr(ADLTag< 0 >, const V1 &v1, const V2 &v2)
implements Simd::maskOr()
Definition defaults.hh:170
│ │ │ │ -
bool anyFalse(ADLTag< 0 >, const Mask &mask)
implements Simd::anyFalse()
Definition defaults.hh:114
│ │ │ │ -
auto min(ADLTag< 0 >, const V &v1, const V &v2)
implements binary Simd::min()
Definition defaults.hh:89
│ │ │ │ -
auto broadcast(ADLTag< 0 >, MetaType< V >, S s)
implements Simd::broadcast<V>()
Definition defaults.hh:69
│ │ │ │ -
auto max(ADLTag< 0 >, const V &v1, const V &v2)
implements binary Simd::max()
Definition defaults.hh:81
│ │ │ │ +
129 K p2 = (matrix[0][0] - q)*(matrix[0][0] - q) + (matrix[1][1] - q)*(matrix[1][1] - q) + (matrix[2][2] - q)*(matrix[2][2] - q) + 2.0 * p1;
│ │ │ │ +
130 K p = sqrt(p2 / 6);
│ │ │ │ +
131 // B = (1 / p) * (A - q * I); // I is the identity matrix
│ │ │ │ +
132 FieldMatrix<K,3,3> B;
│ │ │ │ +
133 for (int i=0; i<3; i++)
│ │ │ │ +
134 for (int j=0; j<3; j++)
│ │ │ │ +
135 B[i][j] = (real_type(1.0)/p) * (matrix[i][j] - q*(i==j));
│ │ │ │ +
136
│ │ │ │ +
137 K r = B.determinant() / 2.0;
│ │ │ │ +
138
│ │ │ │ +
139 /*In exact arithmetic for a symmetric matrix -1 <= r <= 1
│ │ │ │ +
140 but computation error can leave it slightly outside this range.
│ │ │ │ +
141 acos(z) function requires |z| <= 1, but will fail silently
│ │ │ │ +
142 and return NaN if the input is larger than 1 in magnitude.
│ │ │ │ +
143 Thus r is clamped to [-1,1].*/
│ │ │ │ +
144 using std::clamp;
│ │ │ │ +
145 r = clamp<K>(r, -1.0, 1.0);
│ │ │ │ +
146 K phi = acos(r) / 3.0;
│ │ │ │ +
147
│ │ │ │ +
148 // the eigenvalues satisfy eig[2] <= eig[1] <= eig[0]
│ │ │ │ +
149 eigenvalues[2] = q + 2 * p * cos(phi);
│ │ │ │ +
150 eigenvalues[0] = q + 2 * p * cos(phi + (2*pi/3));
│ │ │ │ +
151 eigenvalues[1] = 3 * q - eigenvalues[0] - eigenvalues[2]; // since trace(matrix) = eig1 + eig2 + eig3
│ │ │ │ +
152
│ │ │ │ +
153 return r;
│ │ │ │ +
154 }
│ │ │ │ +
155 }
│ │ │ │ +
156
│ │ │ │ +
157 //see https://www.geometrictools.com/Documentation/RobustEigenSymmetric3x3.pdf
│ │ │ │ +
158 //Robustly compute a right-handed orthonormal set {u, v, evec0}.
│ │ │ │ +
159 template<typename K>
│ │ │ │ +
160 void orthoComp(const FieldVector<K,3>& evec0, FieldVector<K,3>& u, FieldVector<K,3>& v) {
│ │ │ │ +
161 using std::abs;
│ │ │ │ +
162 if(abs(evec0[0]) > abs(evec0[1])) {
│ │ │ │ +
163 //The component of maximum absolute value is either evec0[0] or evec0[2].
│ │ │ │ +
164 FieldVector<K,2> temp = {evec0[0], evec0[2]};
│ │ │ │ +
165 auto L = 1.0 / temp.two_norm();
│ │ │ │ +
166 u = L * FieldVector<K,3>({-evec0[2], 0.0, evec0[0]});
│ │ │ │ +
167 }
│ │ │ │ +
168 else {
│ │ │ │ +
169 //The component of maximum absolute value is either evec0[1] or evec0[2].
│ │ │ │ +
170 FieldVector<K,2> temp = {evec0[1], evec0[2]};
│ │ │ │ +
171 auto L = 1.0 / temp.two_norm();
│ │ │ │ +
172 u = L * FieldVector<K,3>({0.0, evec0[2], -evec0[1]});
│ │ │ │ +
173 }
│ │ │ │ +
174 v = crossProduct(evec0, u);
│ │ │ │ +
175 }
│ │ │ │ +
176
│ │ │ │ +
177 //see https://www.geometrictools.com/Documentation/RobustEigenSymmetric3x3.pdf
│ │ │ │ +
178 template<typename K>
│ │ │ │ +
179 void eig0(const FieldMatrix<K,3,3>& matrix, K eval0, FieldVector<K,3>& evec0) {
│ │ │ │ +
180 /* Compute a unit-length eigenvector for eigenvalue[i0]. The
│ │ │ │ +
181 matrix is rank 2, so two of the rows are linearly independent.
│ │ │ │ +
182 For a robust computation of the eigenvector, select the two
│ │ │ │ +
183 rows whose cross product has largest length of all pairs of
│ │ │ │ +
184 rows. */
│ │ │ │ +
185 using Vector = FieldVector<K,3>;
│ │ │ │ +
186 Vector row0 = {matrix[0][0]-eval0, matrix[0][1], matrix[0][2]};
│ │ │ │ +
187 Vector row1 = {matrix[1][0], matrix[1][1]-eval0, matrix[1][2]};
│ │ │ │ +
188 Vector row2 = {matrix[2][0], matrix[2][1], matrix[2][2]-eval0};
│ │ │ │ +
189
│ │ │ │ +
190 Vector r0xr1 = crossProduct(row0, row1);
│ │ │ │ +
191 Vector r0xr2 = crossProduct(row0, row2);
│ │ │ │ +
192 Vector r1xr2 = crossProduct(row1, row2);
│ │ │ │ +
193 auto d0 = r0xr1.two_norm();
│ │ │ │ +
194 auto d1 = r0xr2.two_norm();
│ │ │ │ +
195 auto d2 = r1xr2.two_norm();
│ │ │ │ +
196
│ │ │ │ +
197 auto dmax = d0 ;
│ │ │ │ +
198 int imax = 0;
│ │ │ │ +
199 if(d1>dmax) {
│ │ │ │ +
200 dmax = d1;
│ │ │ │ +
201 imax = 1;
│ │ │ │ +
202 }
│ │ │ │ +
203 if(d2>dmax)
│ │ │ │ +
204 imax = 2;
│ │ │ │ +
205
│ │ │ │ +
206 if(imax == 0)
│ │ │ │ +
207 evec0 = r0xr1 / d0;
│ │ │ │ +
208 else if(imax == 1)
│ │ │ │ +
209 evec0 = r0xr2 / d1;
│ │ │ │ +
210 else
│ │ │ │ +
211 evec0 = r1xr2 / d2;
│ │ │ │ +
212 }
│ │ │ │ +
213
│ │ │ │ +
214 //see https://www.geometrictools.com/Documentation/RobustEigenSymmetric3x3.pdf
│ │ │ │ +
215 template<typename K>
│ │ │ │ +
216 void eig1(const FieldMatrix<K,3,3>& matrix, const FieldVector<K,3>& evec0, FieldVector<K,3>& evec1, K eval1) {
│ │ │ │ +
217 using Vector = FieldVector<K,3>;
│ │ │ │ +
218
│ │ │ │ +
219 //Robustly compute a right-handed orthonormal set {u, v, evec0}.
│ │ │ │ +
220 Vector u,v;
│ │ │ │ +
221 orthoComp(evec0, u, v);
│ │ │ │ +
222
│ │ │ │ +
223 /* Let e be eval1 and let E be a corresponding eigenvector which
│ │ │ │ +
224 is a solution to the linear system (A - e*I)*E = 0. The matrix
│ │ │ │ +
225 (A - e*I) is 3x3, not invertible (so infinitely many
│ │ │ │ +
226 solutions), and has rank 2 when eval1 and eval are different.
│ │ │ │ +
227 It has rank 1 when eval1 and eval2 are equal. Numerically, it
│ │ │ │ +
228 is difficult to compute robustly the rank of a matrix. Instead,
│ │ │ │ +
229 the 3x3 linear system is reduced to a 2x2 system as follows.
│ │ │ │ +
230 Define the 3x2 matrix J = [u,v] whose columns are the u and v
│ │ │ │ +
231 computed previously. Define the 2x1 vector X = J*E. The 2x2
│ │ │ │ +
232 system is 0 = M * X = (J^T * (A - e*I) * J) * X where J^T is
│ │ │ │ +
233 the transpose of J and M = J^T * (A - e*I) * J is a 2x2 matrix.
│ │ │ │ +
234 The system may be written as
│ │ │ │ +
235 +- -++- -+ +- -+
│ │ │ │ +
236 | U^T*A*U - e U^T*A*V || x0 | = e * | x0 |
│ │ │ │ +
237 | V^T*A*U V^T*A*V - e || x1 | | x1 |
│ │ │ │ +
238 +- -++ -+ +- -+
│ │ │ │ +
239 where X has row entries x0 and x1. */
│ │ │ │ +
240
│ │ │ │ +
241 Vector Au, Av;
│ │ │ │ +
242 matrix.mv(u, Au);
│ │ │ │ +
243 matrix.mv(v, Av);
│ │ │ │ +
244
│ │ │ │ +
245 auto m00 = u.dot(Au) - eval1;
│ │ │ │ +
246 auto m01 = u.dot(Av);
│ │ │ │ +
247 auto m11 = v.dot(Av) - eval1;
│ │ │ │ +
248
│ │ │ │ +
249 /* For robustness, choose the largest-length row of M to compute
│ │ │ │ +
250 the eigenvector. The 2-tuple of coefficients of U and V in the
│ │ │ │ +
251 assignments to eigenvector[1] lies on a circle, and U and V are
│ │ │ │ +
252 unit length and perpendicular, so eigenvector[1] is unit length
│ │ │ │ +
253 (within numerical tolerance). */
│ │ │ │ +
254 using std::abs, std::sqrt, std::max;
│ │ │ │ +
255 auto absM00 = abs(m00);
│ │ │ │ +
256 auto absM01 = abs(m01);
│ │ │ │ +
257 auto absM11 = abs(m11);
│ │ │ │ +
258 if(absM00 >= absM11) {
│ │ │ │ +
259 auto maxAbsComp = max(absM00, absM01);
│ │ │ │ +
260 if(maxAbsComp > 0.0) {
│ │ │ │ +
261 if(absM00 >= absM01) {
│ │ │ │ +
262 m01 /= m00;
│ │ │ │ +
263 m00 = 1.0 / sqrt(1.0 + m01*m01);
│ │ │ │ +
264 m01 *= m00;
│ │ │ │ +
265 }
│ │ │ │ +
266 else {
│ │ │ │ +
267 m00 /= m01;
│ │ │ │ +
268 m01 = 1.0 / sqrt(1.0 + m00*m00);
│ │ │ │ +
269 m00 *= m01;
│ │ │ │ +
270 }
│ │ │ │ +
271 evec1 = m01*u - m00*v;
│ │ │ │ +
272 }
│ │ │ │ +
273 else
│ │ │ │ +
274 evec1 = u;
│ │ │ │ +
275 }
│ │ │ │ +
276 else {
│ │ │ │ +
277 auto maxAbsComp = max(absM11, absM01);
│ │ │ │ +
278 if(maxAbsComp > 0.0) {
│ │ │ │ +
279 if(absM11 >= absM01) {
│ │ │ │ +
280 m01 /= m11;
│ │ │ │ +
281 m11 = 1.0 / sqrt(1.0 + m01*m01);
│ │ │ │ +
282 m01 *= m11;
│ │ │ │ +
283 }
│ │ │ │ +
284 else {
│ │ │ │ +
285 m11 /= m01;
│ │ │ │ +
286 m01 = 1.0 / sqrt(1.0 + m11*m11);
│ │ │ │ +
287 m11 *= m01;
│ │ │ │ +
288 }
│ │ │ │ +
289 evec1 = m11*u - m01*v;
│ │ │ │ +
290 }
│ │ │ │ +
291 else
│ │ │ │ +
292 evec1 = u;
│ │ │ │ +
293 }
│ │ │ │ +
294 }
│ │ │ │ +
295
│ │ │ │ +
296 // 1d specialization
│ │ │ │ +
297 template<Jobs Tag, typename K>
│ │ │ │ +
298 static void eigenValuesVectorsImpl(const FieldMatrix<K, 1, 1>& matrix,
│ │ │ │ +
299 FieldVector<K, 1>& eigenValues,
│ │ │ │ +
300 FieldMatrix<K, 1, 1>& eigenVectors)
│ │ │ │ +
301 {
│ │ │ │ +
302 eigenValues[0] = matrix[0][0];
│ │ │ │ +
303 if constexpr(Tag==EigenvaluesEigenvectors)
│ │ │ │ +
304 eigenVectors[0] = {1.0};
│ │ │ │ +
305 }
│ │ │ │ +
306
│ │ │ │ +
307
│ │ │ │ +
308 // 2d specialization
│ │ │ │ +
309 template <Jobs Tag, typename K>
│ │ │ │ +
310 static void eigenValuesVectorsImpl(const FieldMatrix<K, 2, 2>& matrix,
│ │ │ │ +
311 FieldVector<K, 2>& eigenValues,
│ │ │ │ +
312 FieldMatrix<K, 2, 2>& eigenVectors)
│ │ │ │ +
313 {
│ │ │ │ +
314 // Compute eigen values
│ │ │ │ +
315 Impl::eigenValues2dImpl(matrix, eigenValues);
│ │ │ │ +
316
│ │ │ │ +
317 // Compute eigenvectors by exploiting the Cayley–Hamilton theorem.
│ │ │ │ +
318 // If λ_1, λ_2 are the eigenvalues, then (A - λ_1I )(A - λ_2I ) = (A - λ_2I )(A - λ_1I ) = 0,
│ │ │ │ +
319 // so the columns of (A - λ_2I ) are annihilated by (A - λ_1I ) and vice versa.
│ │ │ │ +
320 // Assuming neither matrix is zero, the columns of each must include eigenvectors
│ │ │ │ +
321 // for the other eigenvalue. (If either matrix is zero, then A is a multiple of the
│ │ │ │ +
322 // identity and any non-zero vector is an eigenvector.)
│ │ │ │ +
323 // From: https://en.wikipedia.org/wiki/Eigenvalue_algorithm#2x2_matrices
│ │ │ │ +
324 if constexpr(Tag==EigenvaluesEigenvectors) {
│ │ │ │ +
325
│ │ │ │ +
326 // Special casing for multiples of the identity
│ │ │ │ +
327 FieldMatrix<K,2,2> temp = matrix;
│ │ │ │ +
328 temp[0][0] -= eigenValues[0];
│ │ │ │ +
329 temp[1][1] -= eigenValues[0];
│ │ │ │ +
330 if(temp.infinity_norm() <= 1e-14) {
│ │ │ │ +
331 eigenVectors[0] = {1.0, 0.0};
│ │ │ │ +
332 eigenVectors[1] = {0.0, 1.0};
│ │ │ │ +
333 }
│ │ │ │ +
334 else {
│ │ │ │ +
335 // The columns of A - λ_2I are eigenvectors for λ_1, or zero.
│ │ │ │ +
336 // Take the column with the larger norm to avoid zero columns.
│ │ │ │ +
337 FieldVector<K,2> ev0 = {matrix[0][0]-eigenValues[1], matrix[1][0]};
│ │ │ │ +
338 FieldVector<K,2> ev1 = {matrix[0][1], matrix[1][1]-eigenValues[1]};
│ │ │ │ +
339 eigenVectors[0] = (ev0.two_norm2() >= ev1.two_norm2()) ? ev0/ev0.two_norm() : ev1/ev1.two_norm();
│ │ │ │ +
340
│ │ │ │ +
341 // The columns of A - λ_1I are eigenvectors for λ_2, or zero.
│ │ │ │ +
342 // Take the column with the larger norm to avoid zero columns.
│ │ │ │ +
343 ev0 = {matrix[0][0]-eigenValues[0], matrix[1][0]};
│ │ │ │ +
344 ev1 = {matrix[0][1], matrix[1][1]-eigenValues[0]};
│ │ │ │ +
345 eigenVectors[1] = (ev0.two_norm2() >= ev1.two_norm2()) ? ev0/ev0.two_norm() : ev1/ev1.two_norm();
│ │ │ │ +
346 }
│ │ │ │ +
347 }
│ │ │ │ +
348 }
│ │ │ │ +
349
│ │ │ │ +
350 // 3d specialization
│ │ │ │ +
351 template <Jobs Tag, typename K>
│ │ │ │ +
352 static void eigenValuesVectorsImpl(const FieldMatrix<K, 3, 3>& matrix,
│ │ │ │ +
353 FieldVector<K, 3>& eigenValues,
│ │ │ │ +
354 FieldMatrix<K, 3, 3>& eigenVectors)
│ │ │ │ +
355 {
│ │ │ │ +
356 using Vector = FieldVector<K,3>;
│ │ │ │ +
357 using Matrix = FieldMatrix<K,3,3>;
│ │ │ │ +
358
│ │ │ │ +
359 //compute eigenvalues
│ │ │ │ +
360 /* Precondition the matrix by factoring out the maximum absolute
│ │ │ │ +
361 value of the components. This guards against floating-point
│ │ │ │ +
362 overflow when computing the eigenvalues.*/
│ │ │ │ +
363 using std::isnormal;
│ │ │ │ +
364 K maxAbsElement = (isnormal(matrix.infinity_norm())) ? matrix.infinity_norm() : K(1.0);
│ │ │ │ +
365 Matrix scaledMatrix = matrix / maxAbsElement;
│ │ │ │ +
366 K r = Impl::eigenValues3dImpl(scaledMatrix, eigenValues);
│ │ │ │ +
367
│ │ │ │ +
368 if constexpr(Tag==EigenvaluesEigenvectors) {
│ │ │ │ +
369 K offDiagNorm = Vector{scaledMatrix[0][1],scaledMatrix[0][2],scaledMatrix[1][2]}.two_norm2();
│ │ │ │ +
370 if (offDiagNorm <= std::numeric_limits<K>::epsilon())
│ │ │ │ +
371 {
│ │ │ │ +
372 eigenValues = {scaledMatrix[0][0], scaledMatrix[1][1], scaledMatrix[2][2]};
│ │ │ │ +
373 eigenVectors = {{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}};
│ │ │ │ +
374
│ │ │ │ +
375 // Use bubble sort to jointly sort eigenvalues and eigenvectors
│ │ │ │ +
376 // such that eigenvalues are ascending
│ │ │ │ +
377 if (eigenValues[0] > eigenValues[1])
│ │ │ │ +
378 {
│ │ │ │ +
379 std::swap(eigenValues[0], eigenValues[1]);
│ │ │ │ +
380 std::swap(eigenVectors[0], eigenVectors[1]);
│ │ │ │ +
381 }
│ │ │ │ +
382 if (eigenValues[1] > eigenValues[2])
│ │ │ │ +
383 {
│ │ │ │ +
384 std::swap(eigenValues[1], eigenValues[2]);
│ │ │ │ +
385 std::swap(eigenVectors[1], eigenVectors[2]);
│ │ │ │ +
386 }
│ │ │ │ +
387 if (eigenValues[0] > eigenValues[1])
│ │ │ │ +
388 {
│ │ │ │ +
389 std::swap(eigenValues[0], eigenValues[1]);
│ │ │ │ +
390 std::swap(eigenVectors[0], eigenVectors[1]);
│ │ │ │ +
391 }
│ │ │ │ +
392 }
│ │ │ │ +
393 else {
│ │ │ │ +
394 /*Compute the eigenvectors so that the set
│ │ │ │ +
395 [evec[0], evec[1], evec[2]] is right handed and
│ │ │ │ +
396 orthonormal. */
│ │ │ │ +
397
│ │ │ │ +
398 Matrix evec(0.0);
│ │ │ │ +
399 Vector eval(eigenValues);
│ │ │ │ +
400 if(r >= 0) {
│ │ │ │ +
401 Impl::eig0(scaledMatrix, eval[2], evec[2]);
│ │ │ │ +
402 Impl::eig1(scaledMatrix, evec[2], evec[1], eval[1]);
│ │ │ │ +
403 evec[0] = Impl::crossProduct(evec[1], evec[2]);
│ │ │ │ +
404 }
│ │ │ │ +
405 else {
│ │ │ │ +
406 Impl::eig0(scaledMatrix, eval[0], evec[0]);
│ │ │ │ +
407 Impl::eig1(scaledMatrix, evec[0], evec[1], eval[1]);
│ │ │ │ +
408 evec[2] = Impl::crossProduct(evec[0], evec[1]);
│ │ │ │ +
409 }
│ │ │ │ +
410 //sort eval/evec-pairs in ascending order
│ │ │ │ +
411 using EVPair = std::pair<K, Vector>;
│ │ │ │ +
412 std::vector<EVPair> pairs;
│ │ │ │ +
413 for(std::size_t i=0; i<=2; ++i)
│ │ │ │ +
414 pairs.push_back(EVPair(eval[i], evec[i]));
│ │ │ │ +
415 auto comp = [](EVPair x, EVPair y){ return x.first < y.first; };
│ │ │ │ +
416 std::sort(pairs.begin(), pairs.end(), comp);
│ │ │ │ +
417 for(std::size_t i=0; i<=2; ++i){
│ │ │ │ +
418 eigenValues[i] = pairs[i].first;
│ │ │ │ +
419 eigenVectors[i] = pairs[i].second;
│ │ │ │ +
420 }
│ │ │ │ +
421 }
│ │ │ │ +
422 }
│ │ │ │ +
423 //The preconditioning scaled the matrix, which scales the eigenvalues. Revert the scaling.
│ │ │ │ +
424 eigenValues *= maxAbsElement;
│ │ │ │ +
425 }
│ │ │ │ +
426
│ │ │ │ +
427 // forwarding to LAPACK with corresponding tag
│ │ │ │ +
428 template <Jobs Tag, int dim, typename K>
│ │ │ │ +
429 static void eigenValuesVectorsLapackImpl(const FieldMatrix<K, dim, dim>& matrix,
│ │ │ │ +
430 FieldVector<K, dim>& eigenValues,
│ │ │ │ +
431 FieldMatrix<K, dim, dim>& eigenVectors)
│ │ │ │ +
432 {
│ │ │ │ +
433 {
│ │ │ │ +
434#if HAVE_LAPACK
│ │ │ │ +
435 /*Lapack uses a proprietary tag to determine whether both eigenvalues and
│ │ │ │ +
436 -vectors ('v') or only eigenvalues ('n') should be calculated */
│ │ │ │ +
437 const char jobz = "nv"[Tag];
│ │ │ │ +
438
│ │ │ │ +
439 const long int N = dim ;
│ │ │ │ +
440 const char uplo = 'u'; // use upper triangular matrix
│ │ │ │ +
441
│ │ │ │ +
442 // length of matrix vector, LWORK >= max(1,3*N-1)
│ │ │ │ +
443 const long int lwork = 3*N -1 ;
│ │ │ │ +
444
│ │ │ │ +
445 constexpr bool isKLapackType = std::is_same_v<K,double> || std::is_same_v<K,float>;
│ │ │ │ +
446 using LapackNumType = std::conditional_t<isKLapackType, K, double>;
│ │ │ │ +
447
│ │ │ │ +
448 // matrix to put into dsyev
│ │ │ │ +
449 LapackNumType matrixVector[dim * dim];
│ │ │ │ +
450
│ │ │ │ +
451 // copy matrix
│ │ │ │ +
452 int row = 0;
│ │ │ │ +
453 for(int i=0; i<dim; ++i)
│ │ │ │ +
454 {
│ │ │ │ +
455 for(int j=0; j<dim; ++j, ++row)
│ │ │ │ +
456 {
│ │ │ │ +
457 matrixVector[ row ] = matrix[ i ][ j ];
│ │ │ │ +
458 }
│ │ │ │ +
459 }
│ │ │ │ +
460
│ │ │ │ +
461 // working memory
│ │ │ │ +
462 LapackNumType workSpace[lwork];
│ │ │ │ +
463
│ │ │ │ +
464 // return value information
│ │ │ │ +
465 long int info = 0;
│ │ │ │ +
466 LapackNumType* ev;
│ │ │ │ +
467 if constexpr (isKLapackType){
│ │ │ │ +
468 ev = &eigenValues[0];
│ │ │ │ +
469 }else{
│ │ │ │ +
470 ev = new LapackNumType[dim];
│ │ │ │ +
471 }
│ │ │ │ +
472
│ │ │ │ +
473 // call LAPACK routine (see fmatrixev.cc)
│ │ │ │ +
474 eigenValuesLapackCall(&jobz, &uplo, &N, &matrixVector[0], &N,
│ │ │ │ +
475 ev, &workSpace[0], &lwork, &info);
│ │ │ │ +
476
│ │ │ │ +
477 if constexpr (!isKLapackType){
│ │ │ │ +
478 for(size_t i=0;i<dim;++i)
│ │ │ │ +
479 eigenValues[i] = ev[i];
│ │ │ │ +
480 delete[] ev;
│ │ │ │ +
481 }
│ │ │ │ +
482
│ │ │ │ +
483 // restore eigenvectors matrix
│ │ │ │ +
484 if (Tag==Jobs::EigenvaluesEigenvectors){
│ │ │ │ +
485 row = 0;
│ │ │ │ +
486 for(int i=0; i<dim; ++i)
│ │ │ │ +
487 {
│ │ │ │ +
488 for(int j=0; j<dim; ++j, ++row)
│ │ │ │ +
489 {
│ │ │ │ +
490 eigenVectors[ i ][ j ] = matrixVector[ row ];
│ │ │ │ +
491 }
│ │ │ │ +
492 }
│ │ │ │ +
493 }
│ │ │ │ +
494
│ │ │ │ +
495 if( info != 0 )
│ │ │ │ +
496 {
│ │ │ │ +
497 std::cerr << "For matrix " << matrix << " eigenvalue calculation failed! " << std::endl;
│ │ │ │ +
498 DUNE_THROW(InvalidStateException,"eigenValues: Eigenvalue calculation failed!");
│ │ │ │ +
499 }
│ │ │ │ +
500#else
│ │ │ │ +
501 DUNE_THROW(NotImplemented,"LAPACK not found!");
│ │ │ │ +
502#endif
│ │ │ │ +
503 }
│ │ │ │ +
504 }
│ │ │ │ +
505
│ │ │ │ +
506 // generic specialization
│ │ │ │ +
507 template <Jobs Tag, int dim, typename K>
│ │ │ │ +
508 static void eigenValuesVectorsImpl(const FieldMatrix<K, dim, dim>& matrix,
│ │ │ │ +
509 FieldVector<K, dim>& eigenValues,
│ │ │ │ +
510 FieldMatrix<K, dim, dim>& eigenVectors)
│ │ │ │ +
511 {
│ │ │ │ +
512 eigenValuesVectorsLapackImpl<Tag>(matrix,eigenValues,eigenVectors);
│ │ │ │ +
513 }
│ │ │ │ +
514 } //namespace Impl
│ │ │ │ +
515
│ │ │ │ +
523 template <int dim, typename K>
│ │ │ │ +
│ │ │ │ +
524 static void eigenValues(const FieldMatrix<K, dim, dim>& matrix,
│ │ │ │ + │ │ │ │ +
526 {
│ │ │ │ + │ │ │ │ +
528 Impl::eigenValuesVectorsImpl<Impl::Jobs::OnlyEigenvalues>(matrix, eigenValues, dummy);
│ │ │ │ +
529 }
│ │ │ │ +
│ │ │ │ +
530
│ │ │ │ +
539 template <int dim, typename K>
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ +
542 FieldMatrix<K, dim, dim>& eigenVectors)
│ │ │ │ +
543 {
│ │ │ │ +
544 Impl::eigenValuesVectorsImpl<Impl::Jobs::EigenvaluesEigenvectors>(matrix, eigenValues, eigenVectors);
│ │ │ │ +
545 }
│ │ │ │ +
│ │ │ │ +
546
│ │ │ │ +
554 template <int dim, typename K>
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ +
557 {
│ │ │ │ + │ │ │ │ +
559 Impl::eigenValuesVectorsLapackImpl<Impl::Jobs::EigenvaluesEigenvectors>(matrix, eigenValues, dummy);
│ │ │ │ +
560 }
│ │ │ │ +
│ │ │ │ +
561
│ │ │ │ +
570 template <int dim, typename K>
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ +
573 FieldMatrix<K, dim, dim>& eigenVectors)
│ │ │ │ +
574 {
│ │ │ │ +
575 Impl::eigenValuesVectorsLapackImpl<Impl::Jobs::EigenvaluesEigenvectors>(matrix, eigenValues, eigenVectors);
│ │ │ │ +
576 }
│ │ │ │ +
│ │ │ │ +
577
│ │ │ │ +
585 template <int dim, typename K, class C>
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ +
588 {
│ │ │ │ +
589#if HAVE_LAPACK
│ │ │ │ +
590 {
│ │ │ │ +
591 const long int N = dim ;
│ │ │ │ +
592 const char jobvl = 'n';
│ │ │ │ +
593 const char jobvr = 'n';
│ │ │ │ +
594
│ │ │ │ +
595 constexpr bool isKLapackType = std::is_same_v<K,double> || std::is_same_v<K,float>;
│ │ │ │ +
596 using LapackNumType = std::conditional_t<isKLapackType, K, double>;
│ │ │ │ +
597
│ │ │ │ +
598 // matrix to put into dgeev
│ │ │ │ +
599 LapackNumType matrixVector[dim * dim];
│ │ │ │ +
600
│ │ │ │ +
601 // copy matrix
│ │ │ │ +
602 int row = 0;
│ │ │ │ +
603 for(int i=0; i<dim; ++i)
│ │ │ │ +
604 {
│ │ │ │ +
605 for(int j=0; j<dim; ++j, ++row)
│ │ │ │ +
606 {
│ │ │ │ +
607 matrixVector[ row ] = matrix[ i ][ j ];
│ │ │ │ +
608 }
│ │ │ │ +
609 }
│ │ │ │ +
610
│ │ │ │ +
611 // working memory
│ │ │ │ +
612 LapackNumType eigenR[dim];
│ │ │ │ +
613 LapackNumType eigenI[dim];
│ │ │ │ +
614 LapackNumType work[3*dim];
│ │ │ │ +
615
│ │ │ │ +
616 // return value information
│ │ │ │ +
617 long int info = 0;
│ │ │ │ +
618 const long int lwork = 3*dim;
│ │ │ │ +
619
│ │ │ │ +
620 // call LAPACK routine (see fmatrixev_ext.cc)
│ │ │ │ +
621 eigenValuesNonsymLapackCall(&jobvl, &jobvr, &N, &matrixVector[0], &N,
│ │ │ │ +
622 &eigenR[0], &eigenI[0], nullptr, &N, nullptr, &N, &work[0],
│ │ │ │ +
623 &lwork, &info);
│ │ │ │ +
624
│ │ │ │ +
625 if( info != 0 )
│ │ │ │ +
626 {
│ │ │ │ +
627 std::cerr << "For matrix " << matrix << " eigenvalue calculation failed! " << std::endl;
│ │ │ │ +
628 DUNE_THROW(InvalidStateException,"eigenValues: Eigenvalue calculation failed!");
│ │ │ │ +
629 }
│ │ │ │ +
630 for (int i=0; i<N; ++i) {
│ │ │ │ +
631 eigenValues[i].real = eigenR[i];
│ │ │ │ +
632 eigenValues[i].imag = eigenI[i];
│ │ │ │ +
633 }
│ │ │ │ +
634 }
│ │ │ │ +
635#else
│ │ │ │ +
636 DUNE_THROW(NotImplemented,"LAPACK not found!");
│ │ │ │ +
637#endif
│ │ │ │ +
638 }
│ │ │ │ +
│ │ │ │ +
639 } // end namespace FMatrixHelp
│ │ │ │ +
640
│ │ │ │ +
643} // end namespace Dune
│ │ │ │ +
644#endif
│ │ │ │ +
A few common exception classes.
│ │ │ │ +
Some useful basic math stuff.
│ │ │ │ +
Implements a vector constructed from a given type representing a field and a compile-time given size.
│ │ │ │ +
Implements a matrix constructed from a given type representing a field and compile-time given number ...
│ │ │ │ +
constexpr auto max
Function object that returns the greater of the given values.
Definition hybridutilities.hh:484
│ │ │ │ +
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
bool anyTrue(ADLTag< 5 >, const AlignedNumber< bool, align > &mask)
Definition debugalign.hh:556
│ │ │ │ -
const AlignedNumber< T, align > & cond(ADLTag< 5 >, AlignedNumber< bool, align > mask, const AlignedNumber< T, align > &ifTrue, const AlignedNumber< T, align > &ifFalse)
Definition debugalign.hh:548
│ │ │ │ -
T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v)
Definition debugalign.hh:533
│ │ │ │ -
Tag used to force late-binding lookup in Dune::Simd::Overloads.
Definition base.hh:182
│ │ │ │ -
A type that refers to another type.
Definition typelist.hh:33
│ │ │ │ -
User interface of the SIMD abstraction.
│ │ │ │ +
static void eigenValuesNonSym(const FieldMatrix< K, dim, dim > &matrix, FieldVector< C, dim > &eigenValues)
calculates the eigenvalues of a non-symmetric field matrix
Definition fmatrixev.hh:586
│ │ │ │ +
static void eigenValues(const FieldMatrix< K, dim, dim > &matrix, FieldVector< K, dim > &eigenValues)
calculates the eigenvalues of a symmetric field matrix
Definition fmatrixev.hh:524
│ │ │ │ +
static void eigenValuesLapack(const FieldMatrix< K, dim, dim > &matrix, FieldVector< K, dim > &eigenValues)
calculates the eigenvalues of a symmetric field matrix
Definition fmatrixev.hh:555
│ │ │ │ +
static void eigenValuesVectors(const FieldMatrix< K, dim, dim > &matrix, FieldVector< K, dim > &eigenValues, FieldMatrix< K, dim, dim > &eigenVectors)
calculates the eigenvalues and eigenvectors of a symmetric field matrix
Definition fmatrixev.hh:540
│ │ │ │ +
static void eigenValuesVectorsLapack(const FieldMatrix< K, dim, dim > &matrix, FieldVector< K, dim > &eigenValues, FieldMatrix< K, dim, dim > &eigenVectors)
calculates the eigenvalues and -vectors of a symmetric field matrix
Definition fmatrixev.hh:571
│ │ │ │ +
A dense n x m matrix.
Definition fmatrix.hh:117
│ │ │ │ +
vector space out of a tensor product of fields.
Definition fvector.hh:91
│ │ │ │ +
Default exception for dummy implementations.
Definition exceptions.hh:263
│ │ │ │ +
Default exception if a function was called while the object is not in a valid state for that function...
Definition exceptions.hh:281
│ │ │ │ +
T real_type
export the type representing the real type of the field
Definition ftraits.hh:30
│ │ │ │ +
static const Field pi()
Archimedes' constant.
Definition math.hh:48
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,250 +1,710 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * simd │ │ │ │ │ -defaults.hh │ │ │ │ │ +fmatrixev.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ -1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ +1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ +2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ +3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ -2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -3#ifndef DUNE_COMMON_SIMD_DEFAULTS_HH │ │ │ │ │ -4#define DUNE_COMMON_SIMD_DEFAULTS_HH │ │ │ │ │ -5 │ │ │ │ │ -17#include │ │ │ │ │ -18#include │ │ │ │ │ -19#include │ │ │ │ │ -20 │ │ │ │ │ -21#include │ │ │ │ │ -22#include │ │ │ │ │ -23#include │ │ │ │ │ -24#include │ │ │ │ │ -25#include │ │ │ │ │ -26 │ │ │ │ │ -27namespace Dune { │ │ │ │ │ -28 namespace Simd { │ │ │ │ │ -29 namespace Overloads { │ │ │ │ │ -30 │ │ │ │ │ -47 template │ │ │ │ │ -48 decltype(auto) lane(ADLTag<0>, std::size_t l, V v) = delete; │ │ │ │ │ +4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ +5#ifndef DUNE_FMATRIXEIGENVALUES_HH │ │ │ │ │ +6#define DUNE_FMATRIXEIGENVALUES_HH │ │ │ │ │ +7 │ │ │ │ │ +12#include │ │ │ │ │ +13#include │ │ │ │ │ +14#include │ │ │ │ │ +15#include │ │ │ │ │ +16 │ │ │ │ │ +17#include // HAVE_LAPACK │ │ │ │ │ +18#include │ │ │ │ │ +19#include │ │ │ │ │ +20#include │ │ │ │ │ +21#include │ │ │ │ │ +22 │ │ │ │ │ +23namespace Dune { │ │ │ │ │ +24 │ │ │ │ │ +30 namespace FMatrixHelp { │ │ │ │ │ +31 │ │ │ │ │ +32#if HAVE_LAPACK │ │ │ │ │ +33 // defined in fmatrixev.cc │ │ │ │ │ +34 extern void eigenValuesLapackCall( │ │ │ │ │ +35 const char* jobz, const char* uplo, const long │ │ │ │ │ +36 int* n, double* a, const long int* lda, double* w, │ │ │ │ │ +37 double* work, const long int* lwork, long int* info); │ │ │ │ │ +38 │ │ │ │ │ +39 extern void eigenValuesNonsymLapackCall( │ │ │ │ │ +40 const char* jobvl, const char* jobvr, const long │ │ │ │ │ +41 int* n, double* a, const long int* lda, double* wr, double* wi, double* vl, │ │ │ │ │ +42 const long int* ldvl, double* vr, const long int* ldvr, double* work, │ │ │ │ │ +43 const long int* lwork, long int* info); │ │ │ │ │ +44 │ │ │ │ │ +45 extern void eigenValuesLapackCall( │ │ │ │ │ +46 const char* jobz, const char* uplo, const long │ │ │ │ │ +47 int* n, float* a, const long int* lda, float* w, │ │ │ │ │ +48 float* work, const long int* lwork, long int* info); │ │ │ │ │ 49 │ │ │ │ │ -51 template │ │ │ │ │ -52 constexpr V implCast(ADLTag<0>, MetaType, const V &u) │ │ │ │ │ -53 { │ │ │ │ │ -54 return u; │ │ │ │ │ -55 } │ │ │ │ │ -56 │ │ │ │ │ -58 template │ │ │ │ │ -59 constexpr V implCast(ADLTag<0>, MetaType, const U &u) │ │ │ │ │ -60 { │ │ │ │ │ -61 V result(Simd::Scalar(0)); │ │ │ │ │ -62 for(auto l : range(Simd::lanes(u))) │ │ │ │ │ -63 Simd::lane(l, result) = Simd::lane(l, u); │ │ │ │ │ -64 return result; │ │ │ │ │ -65 } │ │ │ │ │ -66 │ │ │ │ │ -68 template │ │ │ │ │ -69 auto broadcast(ADLTag<0>, MetaType, S s) │ │ │ │ │ -70 { │ │ │ │ │ -71 return V(Simd::Scalar(s)); │ │ │ │ │ -72 } │ │ │ │ │ -73 │ │ │ │ │ -75 template │ │ │ │ │ -76 V cond(ADLTag<0>, const Mask &mask, │ │ │ │ │ -77 const V &ifTrue, const V &ifFalse) = delete; │ │ │ │ │ -78 │ │ │ │ │ -80 template │ │ │ │ │ -81 auto max(ADLTag<0>, const V &v1, const V &v2) │ │ │ │ │ +50 extern void eigenValuesNonsymLapackCall( │ │ │ │ │ +51 const char* jobvl, const char* jobvr, const long │ │ │ │ │ +52 int* n, float* a, const long int* lda, float* wr, float* wi, float* vl, │ │ │ │ │ +53 const long int* ldvl, float* vr, const long int* ldvr, float* work, │ │ │ │ │ +54 const long int* lwork, long int* info); │ │ │ │ │ +55 │ │ │ │ │ +56#endif │ │ │ │ │ +57 │ │ │ │ │ +58 namespace Impl { │ │ │ │ │ +59 //internal tag to activate/disable code for eigenvector calculation at │ │ │ │ │ +compile time │ │ │ │ │ +60 enum Jobs { OnlyEigenvalues=0, EigenvaluesEigenvectors=1 }; │ │ │ │ │ +61 │ │ │ │ │ +62 //internal dummy used if only eigenvalues are to be calculated │ │ │ │ │ +63 template │ │ │ │ │ +64 using EVDummy = FieldMatrix; │ │ │ │ │ +65 │ │ │ │ │ +66 //compute the cross-product of two vectors │ │ │ │ │ +67 template │ │ │ │ │ +68 inline FieldVector crossProduct(const FieldVector& vec0, const │ │ │ │ │ +FieldVector& vec1) { │ │ │ │ │ +69 return {vec0[1]*vec1[2] - vec0[2]*vec1[1], vec0[2]*vec1[0] - vec0[0]*vec1 │ │ │ │ │ +[2], vec0[0]*vec1[1] - vec0[1]*vec1[0]}; │ │ │ │ │ +70 } │ │ │ │ │ +71 │ │ │ │ │ +72 template │ │ │ │ │ +73 static void eigenValues2dImpl(const FieldMatrix& matrix, │ │ │ │ │ +74 FieldVector& eigenvalues) │ │ │ │ │ +75 { │ │ │ │ │ +76 using std::sqrt; │ │ │ │ │ +77 const K p = 0.5 * (matrix[0][0] + matrix [1][1]); │ │ │ │ │ +78 const K p2 = p - matrix[1][1]; │ │ │ │ │ +79 K q = p2 * p2 + matrix[1][0] * matrix[0][1]; │ │ │ │ │ +80 if( q < 0 && q > -1e-14 ) q = 0; │ │ │ │ │ +81 if (q < 0) │ │ │ │ │ 82 { │ │ │ │ │ -83 using std::max; │ │ │ │ │ -84 return max(v1, v2); │ │ │ │ │ -85 } │ │ │ │ │ -86 │ │ │ │ │ -88 template │ │ │ │ │ -89 auto min(ADLTag<0>, const V &v1, const V &v2) │ │ │ │ │ -90 { │ │ │ │ │ -91 using std::min; │ │ │ │ │ -92 return min(v1, v2); │ │ │ │ │ -93 } │ │ │ │ │ -94 │ │ │ │ │ -96 template │ │ │ │ │ -97 bool anyTrue(ADLTag<0>, const Mask &mask) = delete; │ │ │ │ │ -98 │ │ │ │ │ -100 │ │ │ │ │ -103 template │ │ │ │ │ -104 bool allTrue(ADLTag<0>, const Mask &mask) │ │ │ │ │ -105 { │ │ │ │ │ -106 return !Dune::Simd::anyTrue(!mask); │ │ │ │ │ -107 } │ │ │ │ │ -108 │ │ │ │ │ -110 │ │ │ │ │ -113 template │ │ │ │ │ -114 bool anyFalse(ADLTag<0>, const Mask &mask) │ │ │ │ │ -115 { │ │ │ │ │ -116 return Dune::Simd::anyTrue(!mask); │ │ │ │ │ -117 } │ │ │ │ │ -118 │ │ │ │ │ -120 │ │ │ │ │ -123 template │ │ │ │ │ -124 bool allFalse(ADLTag<0>, const Mask &mask) │ │ │ │ │ -125 { │ │ │ │ │ -126 return !Dune::Simd::anyTrue(mask); │ │ │ │ │ -127 } │ │ │ │ │ +83 std::cout << matrix << std::endl; │ │ │ │ │ +84 // Complex eigenvalues are either caused by non-symmetric matrices or by │ │ │ │ │ +round-off errors │ │ │ │ │ +85 DUNE_THROW(MathError, "Complex eigenvalue detected (which this │ │ │ │ │ +implementation cannot handle)."); │ │ │ │ │ +86 } │ │ │ │ │ +87 │ │ │ │ │ +88 // get square root │ │ │ │ │ +89 q = sqrt(q); │ │ │ │ │ +90 │ │ │ │ │ +91 // store eigenvalues in ascending order │ │ │ │ │ +92 eigenvalues[0] = p - q; │ │ │ │ │ +93 eigenvalues[1] = p + q; │ │ │ │ │ +94 } │ │ │ │ │ +95 │ │ │ │ │ +96 /* │ │ │ │ │ +97 This implementation was adapted from the pseudo-code (Python?) │ │ │ │ │ +implementation found on │ │ │ │ │ +98 http://en.wikipedia.org/wiki/Eigenvalue_algorithm (retrieved late August │ │ │ │ │ +2014). │ │ │ │ │ +99 Wikipedia claims to have taken it from │ │ │ │ │ +100 Smith, Oliver K. (April 1961), Eigenvalues of a symmetric 3 × 3 matrix., │ │ │ │ │ +101 Communications of the ACM 4 (4): 168, doi:10.1145/355578.366316 │ │ │ │ │ +102 */ │ │ │ │ │ +103 template │ │ │ │ │ +104 static K eigenValues3dImpl(const FieldMatrix& matrix, │ │ │ │ │ +105 FieldVector& eigenvalues) │ │ │ │ │ +106 { │ │ │ │ │ +107 using std::sqrt; │ │ │ │ │ +108 using std::acos; │ │ │ │ │ +109 using real_type = typename FieldTraits::real_type; │ │ │ │ │ +110 const K pi = MathematicalConstants::pi(); │ │ │ │ │ +111 K p1 = matrix[0][1]*matrix[0][1] + matrix[0][2]*matrix[0][2] + matrix[1] │ │ │ │ │ +[2]*matrix[1][2]; │ │ │ │ │ +112 │ │ │ │ │ +113 if (p1 <= std::numeric_limits::epsilon()) { │ │ │ │ │ +114 // A is diagonal. │ │ │ │ │ +115 eigenvalues[0] = matrix[0][0]; │ │ │ │ │ +116 eigenvalues[1] = matrix[1][1]; │ │ │ │ │ +117 eigenvalues[2] = matrix[2][2]; │ │ │ │ │ +118 std::sort(eigenvalues.begin(), eigenvalues.end()); │ │ │ │ │ +119 │ │ │ │ │ +120 return 0.0; │ │ │ │ │ +121 } │ │ │ │ │ +122 else │ │ │ │ │ +123 { │ │ │ │ │ +124 // q = trace(A)/3 │ │ │ │ │ +125 K q = 0; │ │ │ │ │ +126 for (int i=0; i<3; i++) │ │ │ │ │ +127 q += matrix[i][i] / 3.0; │ │ │ │ │ 128 │ │ │ │ │ -130 template │ │ │ │ │ -131 auto max(ADLTag<0>, const V &v) │ │ │ │ │ -132 { │ │ │ │ │ -133 Scalar m = Simd::lane(0, v); │ │ │ │ │ -134 for(std::size_t l = 1; l < Simd::lanes(v); ++l) │ │ │ │ │ -135 if(m < Simd::lane(l, v)) │ │ │ │ │ -136 m = Simd::lane(l, v); │ │ │ │ │ -137 return m; │ │ │ │ │ -138 } │ │ │ │ │ -139 │ │ │ │ │ -141 template │ │ │ │ │ -142 auto min(ADLTag<0>, const V &v) │ │ │ │ │ -143 { │ │ │ │ │ -144 Scalar m = Simd::lane(0, v); │ │ │ │ │ -145 for(std::size_t l = 1; l < Simd::lanes(v); ++l) │ │ │ │ │ -146 if(Simd::lane(l, v) < m) │ │ │ │ │ -147 m = Simd::lane(l, v); │ │ │ │ │ -148 return m; │ │ │ │ │ -149 } │ │ │ │ │ -150 │ │ │ │ │ -152 template │ │ │ │ │ -153 Mask mask(ADLTag<0, std::is_same >::value>, │ │ │ │ │ -154 const V &v) │ │ │ │ │ -155 { │ │ │ │ │ -156 return v; │ │ │ │ │ -157 } │ │ │ │ │ -158 │ │ │ │ │ -160 template │ │ │ │ │ -161 auto mask(ADLTag<0, !std::is_same >::value>, │ │ │ │ │ -162 const V &v) │ │ │ │ │ -163 { │ │ │ │ │ -164 using Copy = AutonomousValue; // just in case we are handed a proxy │ │ │ │ │ -165 return v != Copy(Scalar(0)); │ │ │ │ │ -166 } │ │ │ │ │ -167 │ │ │ │ │ -169 template │ │ │ │ │ -170 auto maskOr(ADLTag<0>, const V1 &v1, const V2 &v2) │ │ │ │ │ -171 { │ │ │ │ │ -172 return Simd::mask(v1) || Simd::mask(v2); │ │ │ │ │ +129 K p2 = (matrix[0][0] - q)*(matrix[0][0] - q) + (matrix[1][1] - q)*(matrix │ │ │ │ │ +[1][1] - q) + (matrix[2][2] - q)*(matrix[2][2] - q) + 2.0 * p1; │ │ │ │ │ +130 K p = sqrt(p2 / 6); │ │ │ │ │ +131 // B = (1 / p) * (A - q * I); // I is the identity matrix │ │ │ │ │ +132 FieldMatrix B; │ │ │ │ │ +133 for (int i=0; i<3; i++) │ │ │ │ │ +134 for (int j=0; j<3; j++) │ │ │ │ │ +135 B[i][j] = (real_type(1.0)/p) * (matrix[i][j] - q*(i==j)); │ │ │ │ │ +136 │ │ │ │ │ +137 K r = B.determinant() / 2.0; │ │ │ │ │ +138 │ │ │ │ │ +139 /*In exact arithmetic for a symmetric matrix -1 <= r <= 1 │ │ │ │ │ +140 but computation error can leave it slightly outside this range. │ │ │ │ │ +141 acos(z) function requires |z| <= 1, but will fail silently │ │ │ │ │ +142 and return NaN if the input is larger than 1 in magnitude. │ │ │ │ │ +143 Thus r is clamped to [-1,1].*/ │ │ │ │ │ +144 using std::clamp; │ │ │ │ │ +145 r = clamp(r, -1.0, 1.0); │ │ │ │ │ +146 K phi = acos(r) / 3.0; │ │ │ │ │ +147 │ │ │ │ │ +148 // the eigenvalues satisfy eig[2] <= eig[1] <= eig[0] │ │ │ │ │ +149 eigenvalues[2] = q + 2 * p * cos(phi); │ │ │ │ │ +150 eigenvalues[0] = q + 2 * p * cos(phi + (2*pi/3)); │ │ │ │ │ +151 eigenvalues[1] = 3 * q - eigenvalues[0] - eigenvalues[2]; // since trace │ │ │ │ │ +(matrix) = eig1 + eig2 + eig3 │ │ │ │ │ +152 │ │ │ │ │ +153 return r; │ │ │ │ │ +154 } │ │ │ │ │ +155 } │ │ │ │ │ +156 │ │ │ │ │ +157 //see https://www.geometrictools.com/Documentation/ │ │ │ │ │ +RobustEigenSymmetric3x3.pdf │ │ │ │ │ +158 //Robustly compute a right-handed orthonormal set {u, v, evec0}. │ │ │ │ │ +159 template │ │ │ │ │ +160 void orthoComp(const FieldVector& evec0, FieldVector& u, │ │ │ │ │ +FieldVector& v) { │ │ │ │ │ +161 using std::abs; │ │ │ │ │ +162 if(abs(evec0[0]) > abs(evec0[1])) { │ │ │ │ │ +163 //The component of maximum absolute value is either evec0[0] or evec0[2]. │ │ │ │ │ +164 FieldVector temp = {evec0[0], evec0[2]}; │ │ │ │ │ +165 auto L = 1.0 / temp.two_norm(); │ │ │ │ │ +166 u = L * FieldVector({-evec0[2], 0.0, evec0[0]}); │ │ │ │ │ +167 } │ │ │ │ │ +168 else { │ │ │ │ │ +169 //The component of maximum absolute value is either evec0[1] or evec0[2]. │ │ │ │ │ +170 FieldVector temp = {evec0[1], evec0[2]}; │ │ │ │ │ +171 auto L = 1.0 / temp.two_norm(); │ │ │ │ │ +172 u = L * FieldVector({0.0, evec0[2], -evec0[1]}); │ │ │ │ │ 173 } │ │ │ │ │ -174 │ │ │ │ │ -176 template │ │ │ │ │ -177 auto maskAnd(ADLTag<0>, const V1 &v1, const V2 &v2) │ │ │ │ │ -178 { │ │ │ │ │ -179 return Simd::mask(v1) && Simd::mask(v2); │ │ │ │ │ -180 } │ │ │ │ │ -181 │ │ │ │ │ -184 } // namespace Overloads │ │ │ │ │ -185 } // namespace Simd │ │ │ │ │ -186} // namespace Dune │ │ │ │ │ -187 │ │ │ │ │ -188#endif // DUNE_COMMON_SIMD_DEFAULTS_HH │ │ │ │ │ -base.hh │ │ │ │ │ -Basic definitions for SIMD Implementations. │ │ │ │ │ -typelist.hh │ │ │ │ │ -rangeutilities.hh │ │ │ │ │ -Utilities for reduction like operations on ranges. │ │ │ │ │ -typetraits.hh │ │ │ │ │ -Traits for type conversions and type information. │ │ │ │ │ -Dune::range │ │ │ │ │ -static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from │ │ │ │ │ ->, std::integral_constant< T, to >) noexcept │ │ │ │ │ -Definition rangeutilities.hh:312 │ │ │ │ │ -Dune::AutonomousValue │ │ │ │ │ -typename AutonomousValueType< T >::type AutonomousValue │ │ │ │ │ -Type free of internal references that T can be converted to. │ │ │ │ │ -Definition typetraits.hh:588 │ │ │ │ │ -Dune::Simd::anyTrue │ │ │ │ │ -bool anyTrue(const Mask &mask) │ │ │ │ │ -Whether any entry is true │ │ │ │ │ -Definition simd/interface.hh:429 │ │ │ │ │ -Dune::Simd::mask │ │ │ │ │ -auto mask(const V &v) │ │ │ │ │ -Convert to mask, analogue of bool(s) for scalars. │ │ │ │ │ -Definition simd/interface.hh:489 │ │ │ │ │ -Dune::Simd::lanes │ │ │ │ │ -constexpr std::size_t lanes() │ │ │ │ │ -Number of lanes in a SIMD type. │ │ │ │ │ -Definition simd/interface.hh:305 │ │ │ │ │ -Dune::Simd::lane │ │ │ │ │ -decltype(auto) lane(std::size_t l, V &&v) │ │ │ │ │ -Extract an element of a SIMD type. │ │ │ │ │ -Definition simd/interface.hh:324 │ │ │ │ │ -Dune::Simd::Mask │ │ │ │ │ -Rebind< bool, V > Mask │ │ │ │ │ -Mask type type of some SIMD type. │ │ │ │ │ -Definition simd/interface.hh:289 │ │ │ │ │ -Dune::Simd::Scalar │ │ │ │ │ -typename Overloads::ScalarType< std::decay_t< V > >::type Scalar │ │ │ │ │ -Element type of some SIMD type. │ │ │ │ │ -Definition simd/interface.hh:235 │ │ │ │ │ -Dune::Simd::Overloads::mask │ │ │ │ │ -Mask< V > mask(ADLTag< 0, std::is_same< V, Mask< V > >::value >, const V &v) │ │ │ │ │ -implements Simd::mask() │ │ │ │ │ -Definition defaults.hh:153 │ │ │ │ │ -Dune::Simd::Overloads::implCast │ │ │ │ │ -constexpr V implCast(ADLTag< 0 >, MetaType< V >, const V &u) │ │ │ │ │ -implements Simd::implCast(V) │ │ │ │ │ -Definition defaults.hh:52 │ │ │ │ │ -Dune::Simd::Overloads::allFalse │ │ │ │ │ -bool allFalse(ADLTag< 0 >, const Mask &mask) │ │ │ │ │ -implements Simd::allFalse() │ │ │ │ │ -Definition defaults.hh:124 │ │ │ │ │ -Dune::Simd::Overloads::allTrue │ │ │ │ │ -bool allTrue(ADLTag< 0 >, const Mask &mask) │ │ │ │ │ -implements Simd::allTrue() │ │ │ │ │ -Definition defaults.hh:104 │ │ │ │ │ -Dune::Simd::Overloads::maskAnd │ │ │ │ │ -auto maskAnd(ADLTag< 0 >, const V1 &v1, const V2 &v2) │ │ │ │ │ -implements Simd::maskAnd() │ │ │ │ │ -Definition defaults.hh:177 │ │ │ │ │ -Dune::Simd::Overloads::maskOr │ │ │ │ │ -auto maskOr(ADLTag< 0 >, const V1 &v1, const V2 &v2) │ │ │ │ │ -implements Simd::maskOr() │ │ │ │ │ -Definition defaults.hh:170 │ │ │ │ │ -Dune::Simd::Overloads::anyFalse │ │ │ │ │ -bool anyFalse(ADLTag< 0 >, const Mask &mask) │ │ │ │ │ -implements Simd::anyFalse() │ │ │ │ │ -Definition defaults.hh:114 │ │ │ │ │ -Dune::Simd::Overloads::min │ │ │ │ │ -auto min(ADLTag< 0 >, const V &v1, const V &v2) │ │ │ │ │ -implements binary Simd::min() │ │ │ │ │ -Definition defaults.hh:89 │ │ │ │ │ -Dune::Simd::Overloads::broadcast │ │ │ │ │ -auto broadcast(ADLTag< 0 >, MetaType< V >, S s) │ │ │ │ │ -implements Simd::broadcast() │ │ │ │ │ -Definition defaults.hh:69 │ │ │ │ │ -Dune::Simd::Overloads::max │ │ │ │ │ -auto max(ADLTag< 0 >, const V &v1, const V &v2) │ │ │ │ │ -implements binary Simd::max() │ │ │ │ │ -Definition defaults.hh:81 │ │ │ │ │ +174 v = crossProduct(evec0, u); │ │ │ │ │ +175 } │ │ │ │ │ +176 │ │ │ │ │ +177 //see https://www.geometrictools.com/Documentation/ │ │ │ │ │ +RobustEigenSymmetric3x3.pdf │ │ │ │ │ +178 template │ │ │ │ │ +179 void eig0(const FieldMatrix& matrix, K eval0, FieldVector& │ │ │ │ │ +evec0) { │ │ │ │ │ +180 /* Compute a unit-length eigenvector for eigenvalue[i0]. The │ │ │ │ │ +181 matrix is rank 2, so two of the rows are linearly independent. │ │ │ │ │ +182 For a robust computation of the eigenvector, select the two │ │ │ │ │ +183 rows whose cross product has largest length of all pairs of │ │ │ │ │ +184 rows. */ │ │ │ │ │ +185 using Vector = FieldVector; │ │ │ │ │ +186 Vector row0 = {matrix[0][0]-eval0, matrix[0][1], matrix[0][2]}; │ │ │ │ │ +187 Vector row1 = {matrix[1][0], matrix[1][1]-eval0, matrix[1][2]}; │ │ │ │ │ +188 Vector row2 = {matrix[2][0], matrix[2][1], matrix[2][2]-eval0}; │ │ │ │ │ +189 │ │ │ │ │ +190 Vector r0xr1 = crossProduct(row0, row1); │ │ │ │ │ +191 Vector r0xr2 = crossProduct(row0, row2); │ │ │ │ │ +192 Vector r1xr2 = crossProduct(row1, row2); │ │ │ │ │ +193 auto d0 = r0xr1.two_norm(); │ │ │ │ │ +194 auto d1 = r0xr2.two_norm(); │ │ │ │ │ +195 auto d2 = r1xr2.two_norm(); │ │ │ │ │ +196 │ │ │ │ │ +197 auto dmax = d0 ; │ │ │ │ │ +198 int imax = 0; │ │ │ │ │ +199 if(d1>dmax) { │ │ │ │ │ +200 dmax = d1; │ │ │ │ │ +201 imax = 1; │ │ │ │ │ +202 } │ │ │ │ │ +203 if(d2>dmax) │ │ │ │ │ +204 imax = 2; │ │ │ │ │ +205 │ │ │ │ │ +206 if(imax == 0) │ │ │ │ │ +207 evec0 = r0xr1 / d0; │ │ │ │ │ +208 else if(imax == 1) │ │ │ │ │ +209 evec0 = r0xr2 / d1; │ │ │ │ │ +210 else │ │ │ │ │ +211 evec0 = r1xr2 / d2; │ │ │ │ │ +212 } │ │ │ │ │ +213 │ │ │ │ │ +214 //see https://www.geometrictools.com/Documentation/ │ │ │ │ │ +RobustEigenSymmetric3x3.pdf │ │ │ │ │ +215 template │ │ │ │ │ +216 void eig1(const FieldMatrix& matrix, const FieldVector& evec0, │ │ │ │ │ +FieldVector& evec1, K eval1) { │ │ │ │ │ +217 using Vector = FieldVector; │ │ │ │ │ +218 │ │ │ │ │ +219 //Robustly compute a right-handed orthonormal set {u, v, evec0}. │ │ │ │ │ +220 Vector u,v; │ │ │ │ │ +221 orthoComp(evec0, u, v); │ │ │ │ │ +222 │ │ │ │ │ +223 /* Let e be eval1 and let E be a corresponding eigenvector which │ │ │ │ │ +224 is a solution to the linear system (A - e*I)*E = 0. The matrix │ │ │ │ │ +225 (A - e*I) is 3x3, not invertible (so infinitely many │ │ │ │ │ +226 solutions), and has rank 2 when eval1 and eval are different. │ │ │ │ │ +227 It has rank 1 when eval1 and eval2 are equal. Numerically, it │ │ │ │ │ +228 is difficult to compute robustly the rank of a matrix. Instead, │ │ │ │ │ +229 the 3x3 linear system is reduced to a 2x2 system as follows. │ │ │ │ │ +230 Define the 3x2 matrix J = [u,v] whose columns are the u and v │ │ │ │ │ +231 computed previously. Define the 2x1 vector X = J*E. The 2x2 │ │ │ │ │ +232 system is 0 = M * X = (J^T * (A - e*I) * J) * X where J^T is │ │ │ │ │ +233 the transpose of J and M = J^T * (A - e*I) * J is a 2x2 matrix. │ │ │ │ │ +234 The system may be written as │ │ │ │ │ +235 +- -++- -+ +- -+ │ │ │ │ │ +236 | U^T*A*U - e U^T*A*V || x0 | = e * | x0 | │ │ │ │ │ +237 | V^T*A*U V^T*A*V - e || x1 | | x1 | │ │ │ │ │ +238 +- -++ -+ +- -+ │ │ │ │ │ +239 where X has row entries x0 and x1. */ │ │ │ │ │ +240 │ │ │ │ │ +241 Vector Au, Av; │ │ │ │ │ +242 matrix.mv(u, Au); │ │ │ │ │ +243 matrix.mv(v, Av); │ │ │ │ │ +244 │ │ │ │ │ +245 auto m00 = u.dot(Au) - eval1; │ │ │ │ │ +246 auto m01 = u.dot(Av); │ │ │ │ │ +247 auto m11 = v.dot(Av) - eval1; │ │ │ │ │ +248 │ │ │ │ │ +249 /* For robustness, choose the largest-length row of M to compute │ │ │ │ │ +250 the eigenvector. The 2-tuple of coefficients of U and V in the │ │ │ │ │ +251 assignments to eigenvector[1] lies on a circle, and U and V are │ │ │ │ │ +252 unit length and perpendicular, so eigenvector[1] is unit length │ │ │ │ │ +253 (within numerical tolerance). */ │ │ │ │ │ +254 using std::abs, std::sqrt, std::max; │ │ │ │ │ +255 auto absM00 = abs(m00); │ │ │ │ │ +256 auto absM01 = abs(m01); │ │ │ │ │ +257 auto absM11 = abs(m11); │ │ │ │ │ +258 if(absM00 >= absM11) { │ │ │ │ │ +259 auto maxAbsComp = max(absM00, absM01); │ │ │ │ │ +260 if(maxAbsComp > 0.0) { │ │ │ │ │ +261 if(absM00 >= absM01) { │ │ │ │ │ +262 m01 /= m00; │ │ │ │ │ +263 m00 = 1.0 / sqrt(1.0 + m01*m01); │ │ │ │ │ +264 m01 *= m00; │ │ │ │ │ +265 } │ │ │ │ │ +266 else { │ │ │ │ │ +267 m00 /= m01; │ │ │ │ │ +268 m01 = 1.0 / sqrt(1.0 + m00*m00); │ │ │ │ │ +269 m00 *= m01; │ │ │ │ │ +270 } │ │ │ │ │ +271 evec1 = m01*u - m00*v; │ │ │ │ │ +272 } │ │ │ │ │ +273 else │ │ │ │ │ +274 evec1 = u; │ │ │ │ │ +275 } │ │ │ │ │ +276 else { │ │ │ │ │ +277 auto maxAbsComp = max(absM11, absM01); │ │ │ │ │ +278 if(maxAbsComp > 0.0) { │ │ │ │ │ +279 if(absM11 >= absM01) { │ │ │ │ │ +280 m01 /= m11; │ │ │ │ │ +281 m11 = 1.0 / sqrt(1.0 + m01*m01); │ │ │ │ │ +282 m01 *= m11; │ │ │ │ │ +283 } │ │ │ │ │ +284 else { │ │ │ │ │ +285 m11 /= m01; │ │ │ │ │ +286 m01 = 1.0 / sqrt(1.0 + m11*m11); │ │ │ │ │ +287 m11 *= m01; │ │ │ │ │ +288 } │ │ │ │ │ +289 evec1 = m11*u - m01*v; │ │ │ │ │ +290 } │ │ │ │ │ +291 else │ │ │ │ │ +292 evec1 = u; │ │ │ │ │ +293 } │ │ │ │ │ +294 } │ │ │ │ │ +295 │ │ │ │ │ +296 // 1d specialization │ │ │ │ │ +297 template │ │ │ │ │ +298 static void eigenValuesVectorsImpl(const FieldMatrix& matrix, │ │ │ │ │ +299 FieldVector& eigenValues, │ │ │ │ │ +300 FieldMatrix& eigenVectors) │ │ │ │ │ +301 { │ │ │ │ │ +302 eigenValues[0] = matrix[0][0]; │ │ │ │ │ +303 if constexpr(Tag==EigenvaluesEigenvectors) │ │ │ │ │ +304 eigenVectors[0] = {1.0}; │ │ │ │ │ +305 } │ │ │ │ │ +306 │ │ │ │ │ +307 │ │ │ │ │ +308 // 2d specialization │ │ │ │ │ +309 template │ │ │ │ │ +310 static void eigenValuesVectorsImpl(const FieldMatrix& matrix, │ │ │ │ │ +311 FieldVector& eigenValues, │ │ │ │ │ +312 FieldMatrix& eigenVectors) │ │ │ │ │ +313 { │ │ │ │ │ +314 // Compute eigen values │ │ │ │ │ +315 Impl::eigenValues2dImpl(matrix, eigenValues); │ │ │ │ │ +316 │ │ │ │ │ +317 // Compute eigenvectors by exploiting the Cayley–Hamilton theorem. │ │ │ │ │ +318 // If λ_1, λ_2 are the eigenvalues, then (A - λ_1I )(A - λ_2I ) = (A - │ │ │ │ │ +λ_2I )(A - λ_1I ) = 0, │ │ │ │ │ +319 // so the columns of (A - λ_2I ) are annihilated by (A - λ_1I ) and vice │ │ │ │ │ +versa. │ │ │ │ │ +320 // Assuming neither matrix is zero, the columns of each must include │ │ │ │ │ +eigenvectors │ │ │ │ │ +321 // for the other eigenvalue. (If either matrix is zero, then A is a │ │ │ │ │ +multiple of the │ │ │ │ │ +322 // identity and any non-zero vector is an eigenvector.) │ │ │ │ │ +323 // From: https://en.wikipedia.org/wiki/Eigenvalue_algorithm#2x2_matrices │ │ │ │ │ +324 if constexpr(Tag==EigenvaluesEigenvectors) { │ │ │ │ │ +325 │ │ │ │ │ +326 // Special casing for multiples of the identity │ │ │ │ │ +327 FieldMatrix temp = matrix; │ │ │ │ │ +328 temp[0][0] -= eigenValues[0]; │ │ │ │ │ +329 temp[1][1] -= eigenValues[0]; │ │ │ │ │ +330 if(temp.infinity_norm() <= 1e-14) { │ │ │ │ │ +331 eigenVectors[0] = {1.0, 0.0}; │ │ │ │ │ +332 eigenVectors[1] = {0.0, 1.0}; │ │ │ │ │ +333 } │ │ │ │ │ +334 else { │ │ │ │ │ +335 // The columns of A - λ_2I are eigenvectors for λ_1, or zero. │ │ │ │ │ +336 // Take the column with the larger norm to avoid zero columns. │ │ │ │ │ +337 FieldVector ev0 = {matrix[0][0]-eigenValues[1], matrix[1][0]}; │ │ │ │ │ +338 FieldVector ev1 = {matrix[0][1], matrix[1][1]-eigenValues[1]}; │ │ │ │ │ +339 eigenVectors[0] = (ev0.two_norm2() >= ev1.two_norm2()) ? ev0/ev0.two_norm() │ │ │ │ │ +: ev1/ev1.two_norm(); │ │ │ │ │ +340 │ │ │ │ │ +341 // The columns of A - λ_1I are eigenvectors for λ_2, or zero. │ │ │ │ │ +342 // Take the column with the larger norm to avoid zero columns. │ │ │ │ │ +343 ev0 = {matrix[0][0]-eigenValues[0], matrix[1][0]}; │ │ │ │ │ +344 ev1 = {matrix[0][1], matrix[1][1]-eigenValues[0]}; │ │ │ │ │ +345 eigenVectors[1] = (ev0.two_norm2() >= ev1.two_norm2()) ? ev0/ev0.two_norm() │ │ │ │ │ +: ev1/ev1.two_norm(); │ │ │ │ │ +346 } │ │ │ │ │ +347 } │ │ │ │ │ +348 } │ │ │ │ │ +349 │ │ │ │ │ +350 // 3d specialization │ │ │ │ │ +351 template │ │ │ │ │ +352 static void eigenValuesVectorsImpl(const FieldMatrix& matrix, │ │ │ │ │ +353 FieldVector& eigenValues, │ │ │ │ │ +354 FieldMatrix& eigenVectors) │ │ │ │ │ +355 { │ │ │ │ │ +356 using Vector = FieldVector; │ │ │ │ │ +357 using Matrix = FieldMatrix; │ │ │ │ │ +358 │ │ │ │ │ +359 //compute eigenvalues │ │ │ │ │ +360 /* Precondition the matrix by factoring out the maximum absolute │ │ │ │ │ +361 value of the components. This guards against floating-point │ │ │ │ │ +362 overflow when computing the eigenvalues.*/ │ │ │ │ │ +363 using std::isnormal; │ │ │ │ │ +364 K maxAbsElement = (isnormal(matrix.infinity_norm())) ? matrix.infinity_norm │ │ │ │ │ +() : K(1.0); │ │ │ │ │ +365 Matrix scaledMatrix = matrix / maxAbsElement; │ │ │ │ │ +366 K r = Impl::eigenValues3dImpl(scaledMatrix, eigenValues); │ │ │ │ │ +367 │ │ │ │ │ +368 if constexpr(Tag==EigenvaluesEigenvectors) { │ │ │ │ │ +369 K offDiagNorm = Vector{scaledMatrix[0][1],scaledMatrix[0][2],scaledMatrix │ │ │ │ │ +[1][2]}.two_norm2(); │ │ │ │ │ +370 if (offDiagNorm <= std::numeric_limits::epsilon()) │ │ │ │ │ +371 { │ │ │ │ │ +372 eigenValues = {scaledMatrix[0][0], scaledMatrix[1][1], scaledMatrix[2][2]}; │ │ │ │ │ +373 eigenVectors = {{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}}; │ │ │ │ │ +374 │ │ │ │ │ +375 // Use bubble sort to jointly sort eigenvalues and eigenvectors │ │ │ │ │ +376 // such that eigenvalues are ascending │ │ │ │ │ +377 if (eigenValues[0] > eigenValues[1]) │ │ │ │ │ +378 { │ │ │ │ │ +379 std::swap(eigenValues[0], eigenValues[1]); │ │ │ │ │ +380 std::swap(eigenVectors[0], eigenVectors[1]); │ │ │ │ │ +381 } │ │ │ │ │ +382 if (eigenValues[1] > eigenValues[2]) │ │ │ │ │ +383 { │ │ │ │ │ +384 std::swap(eigenValues[1], eigenValues[2]); │ │ │ │ │ +385 std::swap(eigenVectors[1], eigenVectors[2]); │ │ │ │ │ +386 } │ │ │ │ │ +387 if (eigenValues[0] > eigenValues[1]) │ │ │ │ │ +388 { │ │ │ │ │ +389 std::swap(eigenValues[0], eigenValues[1]); │ │ │ │ │ +390 std::swap(eigenVectors[0], eigenVectors[1]); │ │ │ │ │ +391 } │ │ │ │ │ +392 } │ │ │ │ │ +393 else { │ │ │ │ │ +394 /*Compute the eigenvectors so that the set │ │ │ │ │ +395 [evec[0], evec[1], evec[2]] is right handed and │ │ │ │ │ +396 orthonormal. */ │ │ │ │ │ +397 │ │ │ │ │ +398 Matrix evec(0.0); │ │ │ │ │ +399 Vector eval(eigenValues); │ │ │ │ │ +400 if(r >= 0) { │ │ │ │ │ +401 Impl::eig0(scaledMatrix, eval[2], evec[2]); │ │ │ │ │ +402 Impl::eig1(scaledMatrix, evec[2], evec[1], eval[1]); │ │ │ │ │ +403 evec[0] = Impl::crossProduct(evec[1], evec[2]); │ │ │ │ │ +404 } │ │ │ │ │ +405 else { │ │ │ │ │ +406 Impl::eig0(scaledMatrix, eval[0], evec[0]); │ │ │ │ │ +407 Impl::eig1(scaledMatrix, evec[0], evec[1], eval[1]); │ │ │ │ │ +408 evec[2] = Impl::crossProduct(evec[0], evec[1]); │ │ │ │ │ +409 } │ │ │ │ │ +410 //sort eval/evec-pairs in ascending order │ │ │ │ │ +411 using EVPair = std::pair; │ │ │ │ │ +412 std::vector pairs; │ │ │ │ │ +413 for(std::size_t i=0; i<=2; ++i) │ │ │ │ │ +414 pairs.push_back(EVPair(eval[i], evec[i])); │ │ │ │ │ +415 auto comp = [](EVPair x, EVPair y){ return x.first < y.first; }; │ │ │ │ │ +416 std::sort(pairs.begin(), pairs.end(), comp); │ │ │ │ │ +417 for(std::size_t i=0; i<=2; ++i){ │ │ │ │ │ +418 eigenValues[i] = pairs[i].first; │ │ │ │ │ +419 eigenVectors[i] = pairs[i].second; │ │ │ │ │ +420 } │ │ │ │ │ +421 } │ │ │ │ │ +422 } │ │ │ │ │ +423 //The preconditioning scaled the matrix, which scales the eigenvalues. │ │ │ │ │ +Revert the scaling. │ │ │ │ │ +424 eigenValues *= maxAbsElement; │ │ │ │ │ +425 } │ │ │ │ │ +426 │ │ │ │ │ +427 // forwarding to LAPACK with corresponding tag │ │ │ │ │ +428 template │ │ │ │ │ +429 static void eigenValuesVectorsLapackImpl(const FieldMatrix& │ │ │ │ │ +matrix, │ │ │ │ │ +430 FieldVector& eigenValues, │ │ │ │ │ +431 FieldMatrix& eigenVectors) │ │ │ │ │ +432 { │ │ │ │ │ +433 { │ │ │ │ │ +434#if HAVE_LAPACK │ │ │ │ │ +435 /*Lapack uses a proprietary tag to determine whether both eigenvalues and │ │ │ │ │ +436 -vectors ('v') or only eigenvalues ('n') should be calculated */ │ │ │ │ │ +437 const char jobz = "nv"[Tag]; │ │ │ │ │ +438 │ │ │ │ │ +439 const long int N = dim ; │ │ │ │ │ +440 const char uplo = 'u'; // use upper triangular matrix │ │ │ │ │ +441 │ │ │ │ │ +442 // length of matrix vector, LWORK >= max(1,3*N-1) │ │ │ │ │ +443 const long int lwork = 3*N -1 ; │ │ │ │ │ +444 │ │ │ │ │ +445 constexpr bool isKLapackType = std::is_same_v || std::is_same_ │ │ │ │ │ +v; │ │ │ │ │ +446 using LapackNumType = std::conditional_t; │ │ │ │ │ +447 │ │ │ │ │ +448 // matrix to put into dsyev │ │ │ │ │ +449 LapackNumType matrixVector[dim * dim]; │ │ │ │ │ +450 │ │ │ │ │ +451 // copy matrix │ │ │ │ │ +452 int row = 0; │ │ │ │ │ +453 for(int i=0; i │ │ │ │ │ +508 static void eigenValuesVectorsImpl(const FieldMatrix& matrix, │ │ │ │ │ +509 FieldVector& eigenValues, │ │ │ │ │ +510 FieldMatrix& eigenVectors) │ │ │ │ │ +511 { │ │ │ │ │ +512 eigenValuesVectorsLapackImpl(matrix,eigenValues,eigenVectors); │ │ │ │ │ +513 } │ │ │ │ │ +514 } //namespace Impl │ │ │ │ │ +515 │ │ │ │ │ +523 template │ │ │ │ │ +524 static void eigenValues(const FieldMatrix& matrix, │ │ │ │ │ +525 FieldVector& eigenValues) │ │ │ │ │ +526 { │ │ │ │ │ +527 Impl::EVDummy dummy; │ │ │ │ │ +528 Impl::eigenValuesVectorsImpl(matrix, │ │ │ │ │ +eigenValues, dummy); │ │ │ │ │ +529 } │ │ │ │ │ +530 │ │ │ │ │ +539 template │ │ │ │ │ +540 static void eigenValuesVectors(const FieldMatrix& matrix, │ │ │ │ │ +541 FieldVector& eigenValues, │ │ │ │ │ +542 FieldMatrix& eigenVectors) │ │ │ │ │ +543 { │ │ │ │ │ +544 Impl::eigenValuesVectorsImpl(matrix, │ │ │ │ │ +eigenValues, eigenVectors); │ │ │ │ │ +545 } │ │ │ │ │ +546 │ │ │ │ │ +554 template │ │ │ │ │ +555 static void eigenValuesLapack(const FieldMatrix& matrix, │ │ │ │ │ +556 FieldVector& eigenValues) │ │ │ │ │ +557 { │ │ │ │ │ +558 Impl::EVDummy dummy; │ │ │ │ │ +559 Impl::eigenValuesVectorsLapackImpl │ │ │ │ │ +(matrix, eigenValues, dummy); │ │ │ │ │ +560 } │ │ │ │ │ +561 │ │ │ │ │ +570 template │ │ │ │ │ +571 static void eigenValuesVectorsLapack(const FieldMatrix& │ │ │ │ │ +matrix, │ │ │ │ │ +572 FieldVector& eigenValues, │ │ │ │ │ +573 FieldMatrix& eigenVectors) │ │ │ │ │ +574 { │ │ │ │ │ +575 Impl::eigenValuesVectorsLapackImpl │ │ │ │ │ +(matrix, eigenValues, eigenVectors); │ │ │ │ │ +576 } │ │ │ │ │ +577 │ │ │ │ │ +585 template │ │ │ │ │ +586 static void eigenValuesNonSym(const FieldMatrix& matrix, │ │ │ │ │ +587 FieldVector& eigenValues) │ │ │ │ │ +588 { │ │ │ │ │ +589#if HAVE_LAPACK │ │ │ │ │ +590 { │ │ │ │ │ +591 const long int N = dim ; │ │ │ │ │ +592 const char jobvl = 'n'; │ │ │ │ │ +593 const char jobvr = 'n'; │ │ │ │ │ +594 │ │ │ │ │ +595 constexpr bool isKLapackType = std::is_same_v || std::is_same_ │ │ │ │ │ +v; │ │ │ │ │ +596 using LapackNumType = std::conditional_t; │ │ │ │ │ +597 │ │ │ │ │ +598 // matrix to put into dgeev │ │ │ │ │ +599 LapackNumType matrixVector[dim * dim]; │ │ │ │ │ +600 │ │ │ │ │ +601 // copy matrix │ │ │ │ │ +602 int row = 0; │ │ │ │ │ +603 for(int i=0; i, const AlignedNumber< bool, align > &mask) │ │ │ │ │ -Definition debugalign.hh:556 │ │ │ │ │ -Dune::Simd::Overloads::cond │ │ │ │ │ -const AlignedNumber< T, align > & cond(ADLTag< 5 >, AlignedNumber< bool, align │ │ │ │ │ -> mask, const AlignedNumber< T, align > &ifTrue, const AlignedNumber< T, align │ │ │ │ │ -> &ifFalse) │ │ │ │ │ -Definition debugalign.hh:548 │ │ │ │ │ -Dune::Simd::Overloads::lane │ │ │ │ │ -T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v) │ │ │ │ │ -Definition debugalign.hh:533 │ │ │ │ │ -Dune::Simd::Overloads::ADLTag │ │ │ │ │ -Tag used to force late-binding lookup in Dune::Simd::Overloads. │ │ │ │ │ -Definition base.hh:182 │ │ │ │ │ -Dune::MetaType │ │ │ │ │ -A type that refers to another type. │ │ │ │ │ -Definition typelist.hh:33 │ │ │ │ │ -interface.hh │ │ │ │ │ -User interface of the SIMD abstraction. │ │ │ │ │ +Dune::FMatrixHelp::eigenValuesNonSym │ │ │ │ │ +static void eigenValuesNonSym(const FieldMatrix< K, dim, dim > &matrix, │ │ │ │ │ +FieldVector< C, dim > &eigenValues) │ │ │ │ │ +calculates the eigenvalues of a non-symmetric field matrix │ │ │ │ │ +Definition fmatrixev.hh:586 │ │ │ │ │ +Dune::FMatrixHelp::eigenValues │ │ │ │ │ +static void eigenValues(const FieldMatrix< K, dim, dim > &matrix, FieldVector< │ │ │ │ │ +K, dim > &eigenValues) │ │ │ │ │ +calculates the eigenvalues of a symmetric field matrix │ │ │ │ │ +Definition fmatrixev.hh:524 │ │ │ │ │ +Dune::FMatrixHelp::eigenValuesLapack │ │ │ │ │ +static void eigenValuesLapack(const FieldMatrix< K, dim, dim > &matrix, │ │ │ │ │ +FieldVector< K, dim > &eigenValues) │ │ │ │ │ +calculates the eigenvalues of a symmetric field matrix │ │ │ │ │ +Definition fmatrixev.hh:555 │ │ │ │ │ +Dune::FMatrixHelp::eigenValuesVectors │ │ │ │ │ +static void eigenValuesVectors(const FieldMatrix< K, dim, dim > &matrix, │ │ │ │ │ +FieldVector< K, dim > &eigenValues, FieldMatrix< K, dim, dim > &eigenVectors) │ │ │ │ │ +calculates the eigenvalues and eigenvectors of a symmetric field matrix │ │ │ │ │ +Definition fmatrixev.hh:540 │ │ │ │ │ +Dune::FMatrixHelp::eigenValuesVectorsLapack │ │ │ │ │ +static void eigenValuesVectorsLapack(const FieldMatrix< K, dim, dim > &matrix, │ │ │ │ │ +FieldVector< K, dim > &eigenValues, FieldMatrix< K, dim, dim > &eigenVectors) │ │ │ │ │ +calculates the eigenvalues and -vectors of a symmetric field matrix │ │ │ │ │ +Definition fmatrixev.hh:571 │ │ │ │ │ +Dune::FieldMatrix │ │ │ │ │ +A dense n x m matrix. │ │ │ │ │ +Definition fmatrix.hh:117 │ │ │ │ │ +Dune::FieldVector │ │ │ │ │ +vector space out of a tensor product of fields. │ │ │ │ │ +Definition fvector.hh:91 │ │ │ │ │ +Dune::NotImplemented │ │ │ │ │ +Default exception for dummy implementations. │ │ │ │ │ +Definition exceptions.hh:263 │ │ │ │ │ +Dune::InvalidStateException │ │ │ │ │ +Default exception if a function was called while the object is not in a valid │ │ │ │ │ +state for that function... │ │ │ │ │ +Definition exceptions.hh:281 │ │ │ │ │ +Dune::FieldTraits::real_type │ │ │ │ │ +T real_type │ │ │ │ │ +export the type representing the real type of the field │ │ │ │ │ +Definition ftraits.hh:30 │ │ │ │ │ +Dune::StandardMathematicalConstants<_Field_>::pi │ │ │ │ │ +static const Field pi() │ │ │ │ │ +Archimedes' constant. │ │ │ │ │ +Definition math.hh:48 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00020.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: base.hh File Reference │ │ │ │ +dune-common: dotproduct.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,53 +65,60 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces
│ │ │ │ - │ │ │ │ +Namespaces | │ │ │ │ +Functions
│ │ │ │ +
dotproduct.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

Basic definitions for SIMD Implementations. │ │ │ │ +

Provides the functions dot(a,b) := $a^H \cdot b $ and dotT(a,b) := $a^T \cdot b $. │ │ │ │ More...

│ │ │ │ - │ │ │ │ +
#include "ftraits.hh"
│ │ │ │ +#include "typetraits.hh"
│ │ │ │ +
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

struct  Dune::Simd::Overloads::ADLTag< i >
struct  Dune::IsVector< T, class >
 
struct  Dune::Simd::Overloads::ADLTag< 0 >
struct  Dune::IsVector< T, std::void_t< typename T::field_type > >
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ +

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::Simd
 Namespace for vectorization interface functions used by library developers.
 
namespace  Dune::Simd::Overloads
 Namespace for the overloads and specializations that make up a SIMD implementation.
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ +Functions

template<class A , class B >
auto Dune::dot (const A &a, const B &b) -> typename std::enable_if< IsNumber< A >::value &&!IsVector< A >::value &&!std::is_same< typename FieldTraits< A >::field_type, typename FieldTraits< A >::real_type > ::value, decltype(conj(a) *b)>::type
 computes the dot product for fundamental data types according to Petsc's VectDot function: dot(a,b) := std::conj(a)*b
 
template<class A , class B >
auto Dune::dotT (const A &a, const B &b) -> decltype(a *b)
 Computes an indefinite vector dot product for fundamental data types according to Petsc's VectTDot function: dotT(a,b) := a*b.
 
│ │ │ │

Detailed Description

│ │ │ │ -

Basic definitions for SIMD Implementations.

│ │ │ │ -

This file provides basic definitions and template declarations that are used to write SIMD abstraction layers.

│ │ │ │ -

This file should never be included by users of the SIMD abstraction. Include <dune/common/simd/simd.hh> instead.

│ │ │ │ +

Provides the functions dot(a,b) := $a^H \cdot b $ and dotT(a,b) := $a^T \cdot b $.

│ │ │ │ +

The provided dot products dot,dotT are used to compute (indefinite) dot products for fundamental types as well as DUNE vector types, such as DenseVector, FieldVector, ISTLVector. Note that the definition of dot(a,b) conjugates the first argument. This agrees with the behaviour of Matlab and Petsc, but not with BLAS.

Author
Jö Fahlke, Matthias Wohlmuth
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── encoding │ │ │ │ │ @@ -1 +1 @@ │ │ │ │ │ -us-ascii │ │ │ │ │ +utf-8 │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,37 +1,48 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * simd │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -base.hh File Reference │ │ │ │ │ -Common » Vectorization » Abstraction_Developer's_Interface │ │ │ │ │ -Basic definitions for SIMD Implementations. More... │ │ │ │ │ +Classes | Namespaces | Functions │ │ │ │ │ +dotproduct.hh File Reference │ │ │ │ │ +Provides the functions dot(a,b) := [$a^H \cdot b $]and dotT(a,b) := [$a^T \cdot │ │ │ │ │ +b $]. More... │ │ │ │ │ +#include "ftraits.hh" │ │ │ │ │ +#include "typetraits.hh" │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -struct   Dune::Simd::Overloads::ADLTag<_i_> │ │ │ │ │ +struct   Dune::IsVector<_T,_class_> │ │ │ │ │   │ │ │ │ │ -struct   Dune::Simd::Overloads::ADLTag<_0_> │ │ │ │ │ +struct   Dune::IsVector<_T,_std::void_t<_typename_T::field_type_>_> │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -namespace   Dune::Simd │ │ │ │ │ -  Namespace for vectorization interface functions used by library │ │ │ │ │ - developers. │ │ │ │ │ +Functions │ │ │ │ │ +template │ │ │ │ │ +auto  Dune::dot (const A &a, const B &b) -> typename std::enable_if< IsNumber< │ │ │ │ │ + A >::value &&!IsVector< A >::value &&!std::is_same< typename FieldTraits< │ │ │ │ │ + A >::field_type, typename FieldTraits< A >::real_type > ::value, decltype │ │ │ │ │ + (conj(a) *b)>::type │ │ │ │ │ +  computes the dot product for fundamental data types according to Petsc's │ │ │ │ │ + VectDot function: dot(a,b) := std::conj(a)*b │ │ │ │ │   │ │ │ │ │ -namespace   Dune::Simd::Overloads │ │ │ │ │ -  Namespace for the overloads and specializations that make up a SIMD │ │ │ │ │ - implementation. │ │ │ │ │ +template │ │ │ │ │ +auto  Dune::dotT (const A &a, const B &b) -> decltype(a *b) │ │ │ │ │ +  Computes an indefinite vector dot product for fundamental data types │ │ │ │ │ + according to Petsc's VectTDot function: dotT(a,b) := a*b. │ │ │ │ │   │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Basic definitions for SIMD Implementations. │ │ │ │ │ -This file provides basic definitions and template declarations that are used to │ │ │ │ │ -write SIMD abstraction layers. │ │ │ │ │ -This file should never be included by users of the SIMD abstraction. Include │ │ │ │ │ - instead. │ │ │ │ │ +Provides the functions dot(a,b) := [$a^H \cdot b $]and dotT(a,b) := [$a^T \cdot │ │ │ │ │ +b $]. │ │ │ │ │ +The provided dot products dot,dotT are used to compute (indefinite) dot │ │ │ │ │ +products for fundamental types as well as DUNE vector types, such as │ │ │ │ │ +DenseVector, FieldVector, ISTLVector. Note that the definition of dot(a,b) │ │ │ │ │ +conjugates the first argument. This agrees with the behaviour of Matlab and │ │ │ │ │ +Petsc, but not with BLAS. │ │ │ │ │ + Author │ │ │ │ │ + Jö Fahlke, Matthias Wohlmuth │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00020_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: base.hh Source File │ │ │ │ +dune-common: dotproduct.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,66 +70,86 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
base.hh
│ │ │ │ +
dotproduct.hh
│ │ │ │
│ │ │ │
│ │ │ │ -Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ -
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
3#ifndef DUNE_COMMON_SIMD_BASE_HH
│ │ │ │ -
4#define DUNE_COMMON_SIMD_BASE_HH
│ │ │ │ -
5
│ │ │ │ -
92namespace Dune {
│ │ │ │ -
93 namespace Simd {
│ │ │ │ -
94
│ │ │ │ -
97
│ │ │ │ -
112 namespace Overloads {
│ │ │ │ -
113
│ │ │ │ -
116
│ │ │ │ -
118
│ │ │ │ -
181 template<unsigned i, bool = true>
│ │ │ │ -
182 struct ADLTag;
│ │ │ │ -
183
│ │ │ │ -
184 template<unsigned i>
│ │ │ │ -
185 struct ADLTag<i> : ADLTag<i-1> {};
│ │ │ │ -
186
│ │ │ │ -
187 template<>
│ │ │ │ -
188 struct ADLTag<0> {};
│ │ │ │ -
189
│ │ │ │ -
191
│ │ │ │ -
195 template<class V, class SFINAETag = void>
│ │ │ │ -
196 struct ScalarType;
│ │ │ │ -
197
│ │ │ │ -
199
│ │ │ │ -
203 template<class S, class V, class SFINAETag = void>
│ │ │ │ -
204 struct RebindType;
│ │ │ │ -
205
│ │ │ │ -
207
│ │ │ │ -
211 template<class V, class SFINAETag = void>
│ │ │ │ -
212 struct LaneCount;
│ │ │ │ -
213
│ │ │ │ -
215
│ │ │ │ -
216 } // namespace Overloads
│ │ │ │ -
217 } // namespace Simd
│ │ │ │ -
218} // namespace Dune
│ │ │ │ -
219
│ │ │ │ -
220#endif // DUNE_COMMON_SIMD_BASE_HH
│ │ │ │ +Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │ +
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │ +
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ +
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ +
5#ifndef DUNE_DOTPRODUCT_HH
│ │ │ │ +
6#define DUNE_DOTPRODUCT_HH
│ │ │ │ +
7
│ │ │ │ +
8#include "ftraits.hh"
│ │ │ │ +
9#include "typetraits.hh"
│ │ │ │ +
10
│ │ │ │ +
11namespace Dune {
│ │ │ │ +
26 template<class T, class = void>
│ │ │ │ +
27 struct IsVector : std::false_type {};
│ │ │ │ +
28
│ │ │ │ +
29 template<class T>
│ │ │ │ +
│ │ │ │ +
30 struct IsVector<T, std::void_t<typename T::field_type> >
│ │ │ │ +
31 : std::true_type {};
│ │ │ │ +
│ │ │ │ +
32
│ │ │ │ +
40 template<class A, class B>
│ │ │ │ +
41 auto
│ │ │ │ +
│ │ │ │ +
42 dot(const A & a, const B & b) -> typename std::enable_if<IsNumber<A>::value && !IsVector<A>::value && !std::is_same<typename FieldTraits<A>::field_type,typename FieldTraits<A>::real_type> ::value, decltype(conj(a)*b)>::type
│ │ │ │ +
43 {
│ │ │ │ +
44 return conj(a)*b;
│ │ │ │ +
45 }
│ │ │ │ +
│ │ │ │ +
46
│ │ │ │ +
56 // fundamental type with A being a real type
│ │ │ │ +
57 template<class A, class B>
│ │ │ │ +
58 auto
│ │ │ │ +
59 dot(const A & a, const B & b) -> typename std::enable_if<IsNumber<A>::value && !IsVector<A>::value && std::is_same<typename FieldTraits<A>::field_type,typename FieldTraits<A>::real_type>::value, decltype(a*b)>::type
│ │ │ │ +
60 {
│ │ │ │ +
61 return a*b;
│ │ │ │ +
62 }
│ │ │ │ +
63
│ │ │ │ +
73 template<typename A, typename B>
│ │ │ │ +
74 auto
│ │ │ │ +
75 dot(const A & a, const B & b) -> typename std::enable_if<IsVector<A>::value, decltype(a.dot(b))>::type
│ │ │ │ +
76 {
│ │ │ │ +
77 return a.dot(b);
│ │ │ │ +
78 }
│ │ │ │ +
79
│ │ │ │ +
87 template<class A, class B>
│ │ │ │ +
88 auto
│ │ │ │ +
│ │ │ │ +
89 dotT(const A & a, const B & b) -> decltype(a*b)
│ │ │ │ +
90 {
│ │ │ │ +
91 return a*b;
│ │ │ │ +
92 }
│ │ │ │ +
│ │ │ │ +
93
│ │ │ │ +
95} // end namespace DUNE
│ │ │ │ +
96
│ │ │ │ +
97#endif // DUNE_DOTPRODUCT_HH
│ │ │ │ +
Traits for type conversions and type information.
│ │ │ │ +
Type traits to determine the type of reals (when working with complex numbers)
│ │ │ │ +
auto dotT(const A &a, const B &b) -> decltype(a *b)
Computes an indefinite vector dot product for fundamental data types according to Petsc's VectTDot fu...
Definition dotproduct.hh:89
│ │ │ │ +
auto dot(const A &a, const B &b) -> typename std::enable_if< IsNumber< A >::value &&!IsVector< A >::value &&!std::is_same< typename FieldTraits< A >::field_type, typename FieldTraits< A >::real_type > ::value, decltype(conj(a) *b)>::type
computes the dot product for fundamental data types according to Petsc's VectDot function: dot(a,...
Definition dotproduct.hh:42
│ │ │ │ +
typename Impl::voider< Types... >::type void_t
Is void for all valid input types. The workhorse for C++11 SFINAE-techniques.
Definition typetraits.hh:40
│ │ │ │ +
STL namespace.
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
Tag used to force late-binding lookup in Dune::Simd::Overloads.
Definition base.hh:182
│ │ │ │ -
should have a member type type
Definition standard.hh:60
│ │ │ │ -
should have a member type type
Definition standard.hh:67
│ │ │ │ -
should be derived from a Dune::index_constant
Definition standard.hh:74
│ │ │ │ +
Definition dotproduct.hh:27
│ │ │ │ +
T real_type
export the type representing the real type of the field
Definition ftraits.hh:30
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,67 +1,98 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * simd │ │ │ │ │ -base.hh │ │ │ │ │ +dotproduct.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ -1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ +1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ +2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ +3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ -2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -3#ifndef DUNE_COMMON_SIMD_BASE_HH │ │ │ │ │ -4#define DUNE_COMMON_SIMD_BASE_HH │ │ │ │ │ -5 │ │ │ │ │ -92namespace Dune { │ │ │ │ │ -93 namespace Simd { │ │ │ │ │ -94 │ │ │ │ │ -97 │ │ │ │ │ -112 namespace Overloads { │ │ │ │ │ -113 │ │ │ │ │ -116 │ │ │ │ │ -118 │ │ │ │ │ -181 template │ │ │ │ │ -182 struct ADLTag; │ │ │ │ │ -183 │ │ │ │ │ -184 template │ │ │ │ │ -185 struct ADLTag : ADLTag {}; │ │ │ │ │ -186 │ │ │ │ │ -187 template<> │ │ │ │ │ -188 struct ADLTag<0> {}; │ │ │ │ │ -189 │ │ │ │ │ -191 │ │ │ │ │ -195 template │ │ │ │ │ -196 struct ScalarType; │ │ │ │ │ -197 │ │ │ │ │ -199 │ │ │ │ │ -203 template │ │ │ │ │ -204 struct RebindType; │ │ │ │ │ -205 │ │ │ │ │ -207 │ │ │ │ │ -211 template │ │ │ │ │ -212 struct LaneCount; │ │ │ │ │ -213 │ │ │ │ │ -215 │ │ │ │ │ -216 } // namespace Overloads │ │ │ │ │ -217 } // namespace Simd │ │ │ │ │ -218} // namespace Dune │ │ │ │ │ -219 │ │ │ │ │ -220#endif // DUNE_COMMON_SIMD_BASE_HH │ │ │ │ │ +4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ +5#ifndef DUNE_DOTPRODUCT_HH │ │ │ │ │ +6#define DUNE_DOTPRODUCT_HH │ │ │ │ │ +7 │ │ │ │ │ +8#include "ftraits.hh" │ │ │ │ │ +9#include "typetraits.hh" │ │ │ │ │ +10 │ │ │ │ │ +11namespace Dune { │ │ │ │ │ +26 template │ │ │ │ │ +27 struct IsVector : std::false_type {}; │ │ │ │ │ +28 │ │ │ │ │ +29 template │ │ │ │ │ +30 struct IsVector > │ │ │ │ │ +31 : std::true_type {}; │ │ │ │ │ +32 │ │ │ │ │ +40 template │ │ │ │ │ +41 auto │ │ │ │ │ +42 dot(const A & a, const B & b) -> typename std::enable_if::value │ │ │ │ │ +&& !IsVector::value && !std::is_same::field_ │ │ │ │ │ +type,typename FieldTraits::real_type> ::value, decltype(conj(a)*b)>::type │ │ │ │ │ +43 { │ │ │ │ │ +44 return conj(a)*b; │ │ │ │ │ +45 } │ │ │ │ │ +46 │ │ │ │ │ +56 // fundamental type with A being a real type │ │ │ │ │ +57 template │ │ │ │ │ +58 auto │ │ │ │ │ +59 dot(const A & a, const B & b) -> typename std::enable_if::value │ │ │ │ │ +&& !IsVector::value && std::is_same::field_ │ │ │ │ │ +type,typename FieldTraits::real_type>::value, decltype(a*b)>::type │ │ │ │ │ +60 { │ │ │ │ │ +61 return a*b; │ │ │ │ │ +62 } │ │ │ │ │ +63 │ │ │ │ │ +73 template │ │ │ │ │ +74 auto │ │ │ │ │ +75 dot(const A & a, const B & b) -> typename std::enable_if::value, │ │ │ │ │ +decltype(a.dot(b))>::type │ │ │ │ │ +76 { │ │ │ │ │ +77 return a.dot(b); │ │ │ │ │ +78 } │ │ │ │ │ +79 │ │ │ │ │ +87 template │ │ │ │ │ +88 auto │ │ │ │ │ +89 dotT(const A & a, const B & b) -> decltype(a*b) │ │ │ │ │ +90 { │ │ │ │ │ +91 return a*b; │ │ │ │ │ +92 } │ │ │ │ │ +93 │ │ │ │ │ +95} // end namespace DUNE │ │ │ │ │ +96 │ │ │ │ │ +97#endif // DUNE_DOTPRODUCT_HH │ │ │ │ │ +typetraits.hh │ │ │ │ │ +Traits for type conversions and type information. │ │ │ │ │ +ftraits.hh │ │ │ │ │ +Type traits to determine the type of reals (when working with complex numbers) │ │ │ │ │ +Dune::dotT │ │ │ │ │ +auto dotT(const A &a, const B &b) -> decltype(a *b) │ │ │ │ │ +Computes an indefinite vector dot product for fundamental data types according │ │ │ │ │ +to Petsc's VectTDot fu... │ │ │ │ │ +Definition dotproduct.hh:89 │ │ │ │ │ +Dune::dot │ │ │ │ │ +auto dot(const A &a, const B &b) -> typename std::enable_if< IsNumber< A >:: │ │ │ │ │ +value &&!IsVector< A >::value &&!std::is_same< typename FieldTraits< A >:: │ │ │ │ │ +field_type, typename FieldTraits< A >::real_type > ::value, decltype(conj(a) │ │ │ │ │ +*b)>::type │ │ │ │ │ +computes the dot product for fundamental data types according to Petsc's │ │ │ │ │ +VectDot function: dot(a,... │ │ │ │ │ +Definition dotproduct.hh:42 │ │ │ │ │ +Dune::void_t │ │ │ │ │ +typename Impl::voider< Types... >::type void_t │ │ │ │ │ +Is void for all valid input types. The workhorse for C++11 SFINAE-techniques. │ │ │ │ │ +Definition typetraits.hh:40 │ │ │ │ │ +std │ │ │ │ │ +STL namespace. │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::Simd::Overloads::ADLTag │ │ │ │ │ -Tag used to force late-binding lookup in Dune::Simd::Overloads. │ │ │ │ │ -Definition base.hh:182 │ │ │ │ │ -Dune::Simd::Overloads::ScalarType │ │ │ │ │ -should have a member type type │ │ │ │ │ -Definition standard.hh:60 │ │ │ │ │ -Dune::Simd::Overloads::RebindType │ │ │ │ │ -should have a member type type │ │ │ │ │ -Definition standard.hh:67 │ │ │ │ │ -Dune::Simd::Overloads::LaneCount │ │ │ │ │ -should be derived from a Dune::index_constant │ │ │ │ │ -Definition standard.hh:74 │ │ │ │ │ +Dune::IsVector │ │ │ │ │ +Definition dotproduct.hh:27 │ │ │ │ │ +Dune::FieldTraits::real_type │ │ │ │ │ +T real_type │ │ │ │ │ +export the type representing the real type of the field │ │ │ │ │ +Definition ftraits.hh:30 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00023.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: vc.hh File Reference │ │ │ │ +dune-common: copyableoptional.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -69,25 +69,41 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
vc.hh File Reference
│ │ │ │ +
│ │ │ │ +Classes | │ │ │ │ +Namespaces
│ │ │ │ +
copyableoptional.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ - │ │ │ │ -

Compatibility header for including <Vc/Vc> │ │ │ │ -More...

│ │ │ │ - │ │ │ │ +
#include <cassert>
│ │ │ │ +#include <iostream>
│ │ │ │ +#include <memory>
│ │ │ │ +#include <optional>
│ │ │ │ +#include <type_traits>
│ │ │ │ +#include <dune/common/typeutilities.hh>
│ │ │ │ +
│ │ │ │

Go to the source code of this file.

│ │ │ │ -

Detailed Description

│ │ │ │ -

Compatibility header for including <Vc/Vc>

│ │ │ │ -

Certain versions (1.3.2) of Vc (https://github.com/VcDevel/Vc) have a problem with certain compiler versions (g++ 7.2.0) in c++17 mode, see #88.

│ │ │ │ -
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Classes

class  Dune::CopyableOptional< Type >
 A copyable type wrapper that provides copy/move assignment operations for types that are only copy/move constructible. More...
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,15 +1,26 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -vc.hh File Reference │ │ │ │ │ -Compatibility header for including More... │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +copyableoptional.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -Compatibility header for including │ │ │ │ │ -Certain versions (1.3.2) of Vc (https://github.com/VcDevel/Vc) have a problem │ │ │ │ │ -with certain compiler versions (g++ 7.2.0) in c++17 mode, see #88. │ │ │ │ │ +Classes │ │ │ │ │ +class   Dune::CopyableOptional<_Type_> │ │ │ │ │ +  A copyable type wrapper that provides copy/move assignment operations │ │ │ │ │ + for types that are only copy/move constructible. More... │ │ │ │ │ +  │ │ │ │ │ +Namespaces │ │ │ │ │ +namespace   Dune │ │ │ │ │ +  Dune namespace. │ │ │ │ │ +  │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00023_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: vc.hh Source File │ │ │ │ +dune-common: copyableoptional.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,38 +74,169 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
vc.hh
│ │ │ │ +
copyableoptional.hh
│ │ │ │
│ │ │ │
│ │ │ │ -Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ -
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
3#ifndef DUNE_COMMON_VC_HH
│ │ │ │ -
4#define DUNE_COMMON_VC_HH
│ │ │ │ -
5
│ │ │ │ -
15#if HAVE_VC
│ │ │ │ -
16
│ │ │ │ -
17// include Vc's macro definitions
│ │ │ │ -
18#include <Vc/global.h>
│ │ │ │ -
19
│ │ │ │ -
20// undefine the macro that signals C++17 support, if set
│ │ │ │ -
21#ifdef Vc_CXX17
│ │ │ │ -
22#undef Vc_CXX17
│ │ │ │ -
23#endif
│ │ │ │ -
24
│ │ │ │ -
25// include the rest of Vc
│ │ │ │ -
26#include <Vc/Vc>
│ │ │ │ -
27
│ │ │ │ -
28#endif // HAVE_VC
│ │ │ │ -
29
│ │ │ │ -
30#endif // DUNE_COMMON_VC_HH
│ │ │ │ +Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │ +
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │ +
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ +
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ +
5#ifndef DUNE_COMMON_COPYABLE_OPTIONAL_HH
│ │ │ │ +
6#define DUNE_COMMON_COPYABLE_OPTIONAL_HH
│ │ │ │ +
7
│ │ │ │ +
8#include <cassert>
│ │ │ │ +
9#include <iostream>
│ │ │ │ +
10#include <memory>
│ │ │ │ +
11#include <optional>
│ │ │ │ +
12#include <type_traits>
│ │ │ │ +
13
│ │ │ │ + │ │ │ │ +
15
│ │ │ │ +
16namespace Dune {
│ │ │ │ +
17
│ │ │ │ +
32template <class Type>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
34 : public std::optional<Type>
│ │ │ │ +
35{
│ │ │ │ +
36 static_assert(std::is_copy_constructible_v<Type>);
│ │ │ │ +
37 static_assert(std::is_object_v<Type>);
│ │ │ │ +
38
│ │ │ │ +
39 using Base = std::optional<Type>;
│ │ │ │ +
40
│ │ │ │ +
41public:
│ │ │ │ +
42
│ │ │ │ +
47 template <class T = Type,
│ │ │ │ +
48 std::enable_if_t<std::is_default_constructible_v<T>, int> = 0>
│ │ │ │ +
│ │ │ │ +
49 constexpr CopyableOptional ()
│ │ │ │ +
50 noexcept(std::is_nothrow_default_constructible_v<T>)
│ │ │ │ +
51 : Base{std::in_place}
│ │ │ │ +
52 {}
│ │ │ │ +
│ │ │ │ +
53
│ │ │ │ +
58 template <class T = Type,
│ │ │ │ +
59 disableCopyMove<CopyableOptional,T> = 0,
│ │ │ │ +
60 std::enable_if_t<std::is_constructible_v<Type,T&&>, int> = 0,
│ │ │ │ +
61 std::enable_if_t<std::is_convertible_v<T&&,Type>, int> = 0>
│ │ │ │ +
│ │ │ │ +
62 constexpr CopyableOptional (T&& value)
│ │ │ │ +
63 noexcept(std::is_nothrow_constructible_v<Type,T&&>)
│ │ │ │ +
64 : Base{std::in_place, std::forward<T>(value)}
│ │ │ │ +
65 {}
│ │ │ │ +
│ │ │ │ +
66
│ │ │ │ +
71 template <class T = Type,
│ │ │ │ + │ │ │ │ +
73 std::enable_if_t<std::is_constructible_v<Type,T&&>, int> = 0,
│ │ │ │ +
74 std::enable_if_t<not std::is_convertible_v<T&&,Type>, int> = 0>
│ │ │ │ +
│ │ │ │ +
75 explicit constexpr CopyableOptional (T&& value)
│ │ │ │ +
76 noexcept(std::is_nothrow_constructible_v<Type,T&&>)
│ │ │ │ +
77 : Base{std::in_place, std::forward<T>(value)}
│ │ │ │ +
78 {}
│ │ │ │ +
│ │ │ │ +
79
│ │ │ │ +
81 template <class... Args,
│ │ │ │ + │ │ │ │ +
83 std::enable_if_t<(sizeof...(Args) > 1), int> = 0,
│ │ │ │ +
84 std::enable_if_t<std::is_constructible_v<Type,Args&&...>, int> = 0>
│ │ │ │ +
│ │ │ │ +
85 constexpr CopyableOptional (Args&&... args)
│ │ │ │ +
86 noexcept(std::is_nothrow_constructible_v<Type,Args&&...>)
│ │ │ │ +
87 : Base{std::in_place, std::forward<Args>(args)...}
│ │ │ │ +
88 {}
│ │ │ │ +
│ │ │ │ +
89
│ │ │ │ +
91 constexpr CopyableOptional (const CopyableOptional&) = default;
│ │ │ │ +
92
│ │ │ │ +
94 constexpr CopyableOptional (CopyableOptional&&) = default;
│ │ │ │ +
95
│ │ │ │ +
97 ~CopyableOptional () = default;
│ │ │ │ +
98
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
101 noexcept(std::is_nothrow_copy_assignable_v<Type> ||
│ │ │ │ +
102 (!std::is_copy_assignable_v<Type> && std::is_nothrow_copy_constructible_v<Type>))
│ │ │ │ +
103 {
│ │ │ │ +
104 if constexpr(std::is_copy_assignable_v<Type>)
│ │ │ │ +
105 Base::operator=(that);
│ │ │ │ +
106 else {
│ │ │ │ +
107 // no self-assignment
│ │ │ │ +
108 if (this != std::addressof(that)) {
│ │ │ │ +
109 if (that)
│ │ │ │ +
110 Base::emplace(*that);
│ │ │ │ +
111 else
│ │ │ │ +
112 Base::reset();
│ │ │ │ +
113 }
│ │ │ │ +
114 }
│ │ │ │ +
115 return *this;
│ │ │ │ +
116 }
│ │ │ │ +
│ │ │ │ +
117
│ │ │ │ +
119 template <class T = Type,
│ │ │ │ +
120 std::enable_if_t<std::is_move_constructible_v<T>, int> = 0>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
122 noexcept(std::is_nothrow_move_assignable_v<Type> ||
│ │ │ │ +
123 (!std::is_move_assignable_v<Type> && std::is_nothrow_move_constructible_v<Type>))
│ │ │ │ +
124 {
│ │ │ │ +
125 if constexpr(std::is_move_assignable_v<Type>)
│ │ │ │ +
126 Base::operator=(std::move(that));
│ │ │ │ +
127 else {
│ │ │ │ +
128 // no self-assignment
│ │ │ │ +
129 if (this != std::addressof(that)) {
│ │ │ │ +
130 if (that)
│ │ │ │ +
131 Base::emplace(std::move(*that));
│ │ │ │ +
132 else
│ │ │ │ +
133 Base::reset();
│ │ │ │ +
134 }
│ │ │ │ +
135 }
│ │ │ │ +
136 return *this;
│ │ │ │ +
137 }
│ │ │ │ +
│ │ │ │ +
138
│ │ │ │ +
140 template <class T = Type,
│ │ │ │ +
141 std::enable_if_t<not std::is_same_v<std::decay_t<T>, CopyableOptional>, int> = 0,
│ │ │ │ +
142 std::enable_if_t<(std::is_assignable_v<Type&,T> || std::is_constructible_v<Type,T>), int> = 0>
│ │ │ │ +
│ │ │ │ +
143 constexpr CopyableOptional& operator= (T&& value)
│ │ │ │ +
144 noexcept(std::is_nothrow_assignable_v<Type&,T> ||
│ │ │ │ +
145 (!std::is_assignable_v<Type&,T> && std::is_nothrow_constructible_v<Type,T>))
│ │ │ │ +
146 {
│ │ │ │ +
147 if constexpr(std::is_assignable_v<Type&,T>)
│ │ │ │ +
148 Base::operator=(std::forward<T>(value));
│ │ │ │ +
149 else
│ │ │ │ +
150 Base::emplace(std::forward<T>(value));
│ │ │ │ +
151 return *this;
│ │ │ │ +
152 }
│ │ │ │ +
│ │ │ │ +
153};
│ │ │ │ +
│ │ │ │ +
154
│ │ │ │ +
155} // end namespace Dune
│ │ │ │ +
156
│ │ │ │ +
157#endif // DUNE_COMMON_COPYABLE_OPTIONAL_HH
│ │ │ │ +
Utilities for type computations, constraining overloads, ...
│ │ │ │ +
std::enable_if_t< not Impl::disableCopyMoveHelper< This, T... >::value, int > disableCopyMove
Helper to disable constructor as copy and move constructor.
Definition typeutilities.hh:45
│ │ │ │ +
STL namespace.
│ │ │ │ +
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ +
A copyable type wrapper that provides copy/move assignment operations for types that are only copy/mo...
Definition copyableoptional.hh:35
│ │ │ │ +
constexpr CopyableOptional(CopyableOptional &&)=default
Move construct the contained value.
│ │ │ │ +
constexpr CopyableOptional(T &&value) noexcept(std::is_nothrow_constructible_v< Type, T && >)
Construct the internal data from perfect forwarding of the passed arguments. Participates in overload...
Definition copyableoptional.hh:62
│ │ │ │ +
constexpr CopyableOptional & operator=(const CopyableOptional &that) noexcept(std::is_nothrow_copy_assignable_v< Type >||(!std::is_copy_assignable_v< Type > &&std::is_nothrow_copy_constructible_v< Type >))
Copy assignment in terms of copy constructor.
Definition copyableoptional.hh:100
│ │ │ │ +
constexpr CopyableOptional() noexcept(std::is_nothrow_default_constructible_v< T >)
Implementation of a default constructor, if the Type is itself default constructible....
Definition copyableoptional.hh:49
│ │ │ │ +
constexpr CopyableOptional(const CopyableOptional &)=default
Copy construct the contained value.
│ │ │ │ +
constexpr CopyableOptional(Args &&... args) noexcept(std::is_nothrow_constructible_v< Type, Args &&... >)
Construct the internal data from perfect forwarding of the passed arguments.
Definition copyableoptional.hh:85
│ │ │ │ +
~CopyableOptional()=default
Default destructor.
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,32 +1,188 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -vc.hh │ │ │ │ │ +copyableoptional.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ -1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ +1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ +2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ +3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ -2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -3#ifndef DUNE_COMMON_VC_HH │ │ │ │ │ -4#define DUNE_COMMON_VC_HH │ │ │ │ │ -5 │ │ │ │ │ -15#if HAVE_VC │ │ │ │ │ -16 │ │ │ │ │ -17// include Vc's macro definitions │ │ │ │ │ -18#include │ │ │ │ │ -19 │ │ │ │ │ -20// undefine the macro that signals C++17 support, if set │ │ │ │ │ -21#ifdef Vc_CXX17 │ │ │ │ │ -22#undef Vc_CXX17 │ │ │ │ │ -23#endif │ │ │ │ │ -24 │ │ │ │ │ -25// include the rest of Vc │ │ │ │ │ -26#include │ │ │ │ │ -27 │ │ │ │ │ -28#endif // HAVE_VC │ │ │ │ │ -29 │ │ │ │ │ -30#endif // DUNE_COMMON_VC_HH │ │ │ │ │ +4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ +5#ifndef DUNE_COMMON_COPYABLE_OPTIONAL_HH │ │ │ │ │ +6#define DUNE_COMMON_COPYABLE_OPTIONAL_HH │ │ │ │ │ +7 │ │ │ │ │ +8#include │ │ │ │ │ +9#include │ │ │ │ │ +10#include │ │ │ │ │ +11#include │ │ │ │ │ +12#include │ │ │ │ │ +13 │ │ │ │ │ +14#include │ │ │ │ │ +15 │ │ │ │ │ +16namespace Dune { │ │ │ │ │ +17 │ │ │ │ │ +32template │ │ │ │ │ +33class CopyableOptional │ │ │ │ │ +34 : public std::optional │ │ │ │ │ +35{ │ │ │ │ │ +36 static_assert(std::is_copy_constructible_v); │ │ │ │ │ +37 static_assert(std::is_object_v); │ │ │ │ │ +38 │ │ │ │ │ +39 using Base = std::optional; │ │ │ │ │ +40 │ │ │ │ │ +41public: │ │ │ │ │ +42 │ │ │ │ │ +47 template , int> = 0> │ │ │ │ │ +49 constexpr CopyableOptional () │ │ │ │ │ +50 noexcept(std::is_nothrow_default_constructible_v) │ │ │ │ │ +51 : Base{std::in_place} │ │ │ │ │ +52 {} │ │ │ │ │ +53 │ │ │ │ │ +58 template = 0, │ │ │ │ │ +60 std::enable_if_t, int> = 0, │ │ │ │ │ +61 std::enable_if_t, int> = 0> │ │ │ │ │ +62 constexpr CopyableOptional (T&& value) │ │ │ │ │ +63 noexcept(std::is_nothrow_constructible_v) │ │ │ │ │ +64 : Base{std::in_place, std::forward(value)} │ │ │ │ │ +65 {} │ │ │ │ │ +66 │ │ │ │ │ +71 template = 0, │ │ │ │ │ +73 std::enable_if_t, int> = 0, │ │ │ │ │ +74 std::enable_if_t, int> = 0> │ │ │ │ │ +75 explicit constexpr CopyableOptional (T&& value) │ │ │ │ │ +76 noexcept(std::is_nothrow_constructible_v) │ │ │ │ │ +77 : Base{std::in_place, std::forward(value)} │ │ │ │ │ +78 {} │ │ │ │ │ +79 │ │ │ │ │ +81 template = 0, │ │ │ │ │ +83 std::enable_if_t<(sizeof...(Args) > 1), int> = 0, │ │ │ │ │ +84 std::enable_if_t, int> = 0> │ │ │ │ │ +85 constexpr CopyableOptional (Args&&... args) │ │ │ │ │ +86 noexcept(std::is_nothrow_constructible_v) │ │ │ │ │ +87 : Base{std::in_place, std::forward(args)...} │ │ │ │ │ +88 {} │ │ │ │ │ +89 │ │ │ │ │ +91 constexpr CopyableOptional (const CopyableOptional&) = default; │ │ │ │ │ +92 │ │ │ │ │ +94 constexpr CopyableOptional (CopyableOptional&&) = default; │ │ │ │ │ +95 │ │ │ │ │ +97 ~CopyableOptional () = default; │ │ │ │ │ +98 │ │ │ │ │ +100 constexpr CopyableOptional& operator=_(const CopyableOptional& that) │ │ │ │ │ +101 noexcept(std::is_nothrow_copy_assignable_v || │ │ │ │ │ +102 (!std::is_copy_assignable_v && std::is_nothrow_copy_constructible_ │ │ │ │ │ +v)) │ │ │ │ │ +103 { │ │ │ │ │ +104 if constexpr(std::is_copy_assignable_v) │ │ │ │ │ +105 Base::operator=(that); │ │ │ │ │ +106 else { │ │ │ │ │ +107 // no self-assignment │ │ │ │ │ +108 if (this != std::addressof(that)) { │ │ │ │ │ +109 if (that) │ │ │ │ │ +110 Base::emplace(*that); │ │ │ │ │ +111 else │ │ │ │ │ +112 Base::reset(); │ │ │ │ │ +113 } │ │ │ │ │ +114 } │ │ │ │ │ +115 return *this; │ │ │ │ │ +116 } │ │ │ │ │ +117 │ │ │ │ │ +119 template , int> = 0> │ │ │ │ │ +121 constexpr CopyableOptional& operator=_(CopyableOptional&& that) │ │ │ │ │ +122 noexcept(std::is_nothrow_move_assignable_v || │ │ │ │ │ +123 (!std::is_move_assignable_v && std::is_nothrow_move_constructible_ │ │ │ │ │ +v)) │ │ │ │ │ +124 { │ │ │ │ │ +125 if constexpr(std::is_move_assignable_v) │ │ │ │ │ +126 Base::operator=(std::move(that)); │ │ │ │ │ +127 else { │ │ │ │ │ +128 // no self-assignment │ │ │ │ │ +129 if (this != std::addressof(that)) { │ │ │ │ │ +130 if (that) │ │ │ │ │ +131 Base::emplace(std::move(*that)); │ │ │ │ │ +132 else │ │ │ │ │ +133 Base::reset(); │ │ │ │ │ +134 } │ │ │ │ │ +135 } │ │ │ │ │ +136 return *this; │ │ │ │ │ +137 } │ │ │ │ │ +138 │ │ │ │ │ +140 template , CopyableOptional>, │ │ │ │ │ +int> = 0, │ │ │ │ │ +142 std::enable_if_t<(std::is_assignable_v || std::is_constructible_ │ │ │ │ │ +v), int> = 0> │ │ │ │ │ +143 constexpr CopyableOptional& operator= (T&& value) │ │ │ │ │ +144 noexcept(std::is_nothrow_assignable_v || │ │ │ │ │ +145 (!std::is_assignable_v && std::is_nothrow_constructible_ │ │ │ │ │ +v)) │ │ │ │ │ +146 { │ │ │ │ │ +147 if constexpr(std::is_assignable_v) │ │ │ │ │ +148 Base::operator=(std::forward(value)); │ │ │ │ │ +149 else │ │ │ │ │ +150 Base::emplace(std::forward(value)); │ │ │ │ │ +151 return *this; │ │ │ │ │ +152 } │ │ │ │ │ +153}; │ │ │ │ │ +154 │ │ │ │ │ +155} // end namespace Dune │ │ │ │ │ +156 │ │ │ │ │ +157#endif // DUNE_COMMON_COPYABLE_OPTIONAL_HH │ │ │ │ │ +typeutilities.hh │ │ │ │ │ +Utilities for type computations, constraining overloads, ... │ │ │ │ │ +Dune::disableCopyMove │ │ │ │ │ +std::enable_if_t< not Impl::disableCopyMoveHelper< This, T... >::value, int > │ │ │ │ │ +disableCopyMove │ │ │ │ │ +Helper to disable constructor as copy and move constructor. │ │ │ │ │ +Definition typeutilities.hh:45 │ │ │ │ │ +std │ │ │ │ │ +STL namespace. │ │ │ │ │ +Dune │ │ │ │ │ +Dune namespace. │ │ │ │ │ +Definition alignedallocator.hh:13 │ │ │ │ │ +Dune::CopyableOptional │ │ │ │ │ +A copyable type wrapper that provides copy/move assignment operations for types │ │ │ │ │ +that are only copy/mo... │ │ │ │ │ +Definition copyableoptional.hh:35 │ │ │ │ │ +Dune::CopyableOptional::CopyableOptional │ │ │ │ │ +constexpr CopyableOptional(CopyableOptional &&)=default │ │ │ │ │ +Move construct the contained value. │ │ │ │ │ +Dune::CopyableOptional::CopyableOptional │ │ │ │ │ +constexpr CopyableOptional(T &&value) noexcept(std::is_nothrow_constructible_v< │ │ │ │ │ +Type, T && >) │ │ │ │ │ +Construct the internal data from perfect forwarding of the passed arguments. │ │ │ │ │ +Participates in overload... │ │ │ │ │ +Definition copyableoptional.hh:62 │ │ │ │ │ +Dune::CopyableOptional::operator= │ │ │ │ │ +constexpr CopyableOptional & operator=(const CopyableOptional &that) noexcept │ │ │ │ │ +(std::is_nothrow_copy_assignable_v< Type >||(!std::is_copy_assignable_v< Type > │ │ │ │ │ +&&std::is_nothrow_copy_constructible_v< Type >)) │ │ │ │ │ +Copy assignment in terms of copy constructor. │ │ │ │ │ +Definition copyableoptional.hh:100 │ │ │ │ │ +Dune::CopyableOptional::CopyableOptional │ │ │ │ │ +constexpr CopyableOptional() noexcept(std::is_nothrow_default_constructible_v< │ │ │ │ │ +T >) │ │ │ │ │ +Implementation of a default constructor, if the Type is itself default │ │ │ │ │ +constructible.... │ │ │ │ │ +Definition copyableoptional.hh:49 │ │ │ │ │ +Dune::CopyableOptional::CopyableOptional │ │ │ │ │ +constexpr CopyableOptional(const CopyableOptional &)=default │ │ │ │ │ +Copy construct the contained value. │ │ │ │ │ +Dune::CopyableOptional::CopyableOptional │ │ │ │ │ +constexpr CopyableOptional(Args &&... args) noexcept(std::is_nothrow_ │ │ │ │ │ +constructible_v< Type, Args &&... >) │ │ │ │ │ +Construct the internal data from perfect forwarding of the passed arguments. │ │ │ │ │ +Definition copyableoptional.hh:85 │ │ │ │ │ +Dune::CopyableOptional::~CopyableOptional │ │ │ │ │ +~CopyableOptional()=default │ │ │ │ │ +Default destructor. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00026.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: loop.hh File Reference │ │ │ │ +dune-common: hash.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,679 +65,183 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ Namespaces | │ │ │ │ Macros | │ │ │ │ Functions
│ │ │ │ -
loop.hh File Reference
│ │ │ │ +
hash.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ -
#include <array>
│ │ │ │ -#include <cmath>
│ │ │ │ -#include <cstddef>
│ │ │ │ -#include <cstdlib>
│ │ │ │ -#include <cstdint>
│ │ │ │ -#include <ostream>
│ │ │ │ -#include <dune/common/math.hh>
│ │ │ │ -#include <dune/common/simd/simd.hh>
│ │ │ │ -#include <dune/common/typetraits.hh>
│ │ │ │ + │ │ │ │ +

Support for calculating hash values of objects. │ │ │ │ +More...

│ │ │ │ +
#include <functional>
│ │ │ │ +#include <dune/common/typetraits.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::LoopSIMD< T, S, A >
 
struct  Dune::Simd::Overloads::ScalarType< LoopSIMD< T, S, A > >
 
struct  Dune::Simd::Overloads::RebindType< U, LoopSIMD< T, S, A > >
 
struct  Dune::Simd::Overloads::LaneCount< LoopSIMD< T, S, A > >
 
struct  Dune::IsNumber< LoopSIMD< T, S, A > >
struct  Dune::hash< T >
 Functor for hashing objects of type T. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::Simd
 Namespace for vectorization interface functions used by library developers.
 
namespace  Dune::Simd::Overloads
 Namespace for the overloads and specializations that make up a SIMD implementation.
 
namespace  Dune::MathOverloads
 namespace for customization of math functions with Dune-Semantics
 
│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Macros

#define DUNE_PRAGMA_OMP_SIMD
 
#define DUNE_SIMD_LOOP_PREFIX_OP(SYMBOL)
 
#define DUNE_SIMD_LOOP_UNARY_OP(SYMBOL)
 
#define DUNE_SIMD_LOOP_POSTFIX_OP(SYMBOL)
 
#define DUNE_SIMD_LOOP_ASSIGNMENT_OP(SYMBOL)
 
#define DUNE_SIMD_LOOP_BINARY_OP(SYMBOL)
 
#define DUNE_SIMD_LOOP_BITSHIFT_OP(SYMBOL)
 
#define DUNE_SIMD_LOOP_COMPARISON_OP(SYMBOL)
 
#define DUNE_SIMD_LOOP_BOOLEAN_OP(SYMBOL)
 
#define DUNE_SIMD_LOOP_CMATH_UNARY_OP(expr)
 
#define DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN(expr, returnType)
 
#define DUNE_SIMD_LOOP_STD_UNARY_OP(expr)
 
#define DUNE_SIMD_LOOP_STD_BINARY_OP(expr)
 
#define DUNE_DEFINE_HASH(template_args, type)
 Defines the required struct specialization to make type hashable via Dune::hash.
 
#define DUNE_HASH_TEMPLATE_ARGS(...)
 Wrapper macro for the template arguments in DUNE_DEFINE_HASH.
 
#define DUNE_HASH_TYPE(...)
 Wrapper macro for the type to be hashed in DUNE_DEFINE_HASH.
 
│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Functions

 Dune::DUNE_SIMD_LOOP_BINARY_OP (+)
 
 Dune::DUNE_SIMD_LOOP_BINARY_OP (-)
 
DUNE_SIMD_LOOP_BINARY_OP * Dune::DUNE_SIMD_LOOP_BINARY_OP (/);DUNE_SIMD_LOOP_BINARY_OP(%
 
DUNE_SIMD_LOOP_BINARY_OP & Dune::DUNE_SIMD_LOOP_BINARY_OP (|);DUNE_SIMD_LOOP_BINARY_OP(^
 
 Dune::DUNE_SIMD_LOOP_BITSHIFT_OP (<<)
 
 Dune::DUNE_SIMD_LOOP_BITSHIFT_OP (> >)
 
 Dune::DUNE_SIMD_LOOP_COMPARISON_OP (<)
 
 Dune::DUNE_SIMD_LOOP_COMPARISON_OP (<=)
 
 Dune::DUNE_SIMD_LOOP_COMPARISON_OP (>=)
 
 Dune::DUNE_SIMD_LOOP_COMPARISON_OP (!=)
 
DUNE_SIMD_LOOP_BOOLEAN_OP && Dune::DUNE_SIMD_LOOP_BOOLEAN_OP (||);template< class T, std::size_t S, std::size_t A > std::ostream &operator<<(std::ostream &os, const LoopSIMD< T, S, A > &v
 
template<class T , std::size_t S, std::size_t A>
auto Dune::Simd::Overloads::lane (ADLTag< 5 >, std::size_t l, LoopSIMD< T, S, A > &&v) -> decltype(std::move(Simd::lane(l%lanes< T >(), v[l/lanes< T >()])))
 
template<class T , std::size_t S, std::size_t A>
auto Dune::Simd::Overloads::lane (ADLTag< 5 >, std::size_t l, const LoopSIMD< T, S, A > &v) -> decltype(Simd::lane(l%lanes< T >(), v[l/lanes< T >()]))
 
template<class T , std::size_t S, std::size_t A>
auto Dune::Simd::Overloads::lane (ADLTag< 5 >, std::size_t l, LoopSIMD< T, S, A > &v) -> decltype(Simd::lane(l%lanes< T >(), v[l/lanes< T >()]))
 
template<class T , std::size_t S, std::size_t AM, std::size_t AD>
auto Dune::Simd::Overloads::cond (ADLTag< 5 >, Simd::Mask< LoopSIMD< T, S, AM > > mask, LoopSIMD< T, S, AD > ifTrue, LoopSIMD< T, S, AD > ifFalse)
 
template<class M , class T , std::size_t S, std::size_t A>
auto Dune::Simd::Overloads::cond (ADLTag< 5, std::is_same< bool, Simd::Scalar< M > >::value &&Simd::lanes< M >()==Simd::lanes< LoopSIMD< T, S, A > >()>, M mask, LoopSIMD< T, S, A > ifTrue, LoopSIMD< T, S, A > ifFalse)
 
template<class M , std::size_t S, std::size_t A>
bool Dune::Simd::Overloads::anyTrue (ADLTag< 5 >, LoopSIMD< M, S, A > mask)
 
template<class M , std::size_t S, std::size_t A>
bool Dune::Simd::Overloads::allTrue (ADLTag< 5 >, LoopSIMD< M, S, A > mask)
 
template<class M , std::size_t S, std::size_t A>
bool Dune::Simd::Overloads::anyFalse (ADLTag< 5 >, LoopSIMD< M, S, A > mask)
 
template<class M , std::size_t S, std::size_t A>
bool Dune::Simd::Overloads::allFalse (ADLTag< 5 >, LoopSIMD< M, S, A > mask)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (cos)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (sin)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (tan)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (acos)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (asin)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (atan)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (cosh)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (sinh)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (tanh)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (acosh)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (asinh)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (atanh)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (exp)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (log)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (log10)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (exp2)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (expm1)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN (ilogb, int)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (log1p)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (log2)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (logb)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (sqrt)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (cbrt)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (erf)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (erfc)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (tgamma)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (lgamma)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (ceil)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (floor)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (trunc)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (round)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN (lround, long)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN (llround, long long)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (rint)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN (lrint, long)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN (llrint, long long)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (nearbyint)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (fabs)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (abs)
 
 Dune::DUNE_SIMD_LOOP_STD_UNARY_OP (real)
 
 Dune::DUNE_SIMD_LOOP_STD_UNARY_OP (imag)
 
 Dune::DUNE_SIMD_LOOP_STD_BINARY_OP (max)
 
 Dune::DUNE_SIMD_LOOP_STD_BINARY_OP (min)
 
template<class T , std::size_t S, std::size_t A>
auto Dune::MathOverloads::isNaN (const LoopSIMD< T, S, A > &v, PriorityTag< 3 >, ADLTag)
 
template<class T , std::size_t S, std::size_t A>
auto Dune::MathOverloads::isInf (const LoopSIMD< T, S, A > &v, PriorityTag< 3 >, ADLTag)
 
template<class T , std::size_t S, std::size_t A>
auto Dune::MathOverloads::isFinite (const LoopSIMD< T, S, A > &v, PriorityTag< 3 >, ADLTag)
 
template<typename T >
void Dune::hash_combine (std::size_t &seed, const T &arg)
 Calculates the hash value of arg and combines it in-place with seed.
 
template<typename It >
std::size_t Dune::hash_range (It first, It last)
 Hashes all elements in the range [first,last) and returns the combined hash.
 
template<typename It >
void Dune::hash_range (std::size_t &seed, It first, It last)
 Hashes all elements in the range [first,last) and combines the hashes in-place with seed.
 
│ │ │ │ -

Macro Definition Documentation

│ │ │ │ - │ │ │ │ -

◆ DUNE_PRAGMA_OMP_SIMD

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_PRAGMA_OMP_SIMD
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ DUNE_SIMD_LOOP_ASSIGNMENT_OP

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_SIMD_LOOP_ASSIGNMENT_OP( SYMBOL)
│ │ │ │ -
│ │ │ │ -Value:
auto operator SYMBOL(const Simd::Scalar<T> s) { \
│ │ │ │ -
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
(*this)[i] SYMBOL s; \
│ │ │ │ -
} \
│ │ │ │ -
return *this; \
│ │ │ │ -
} \
│ │ │ │ -
\
│ │ │ │ -
auto operator SYMBOL(const LoopSIMD<T,S,A> &v) { \
│ │ │ │ -
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
(*this)[i] SYMBOL v[i]; \
│ │ │ │ -
} \
│ │ │ │ -
return *this; \
│ │ │ │ -
} \
│ │ │ │ -
static_assert(true, "expecting ;")
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ DUNE_SIMD_LOOP_BINARY_OP

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_SIMD_LOOP_BINARY_OP( SYMBOL)
│ │ │ │ -
│ │ │ │ -Value:
template<class T, std::size_t S, std::size_t A> \
│ │ │ │ -
auto operator SYMBOL(const LoopSIMD<T,S,A> &v, const Simd::Scalar<T> s) { \
│ │ │ │ -
LoopSIMD<T,S,A> out; \
│ │ │ │ -
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
out[i] = v[i] SYMBOL s; \
│ │ │ │ -
} \
│ │ │ │ -
return out; \
│ │ │ │ -
} \
│ │ │ │ -
template<class T, std::size_t S, std::size_t A> \
│ │ │ │ -
auto operator SYMBOL(const Simd::Scalar<T> s, const LoopSIMD<T,S,A> &v) { \
│ │ │ │ -
LoopSIMD<T,S,A> out; \
│ │ │ │ -
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
out[i] = s SYMBOL v[i]; \
│ │ │ │ -
} \
│ │ │ │ -
return out; \
│ │ │ │ -
} \
│ │ │ │ -
template<class T, std::size_t S, std::size_t A> \
│ │ │ │ -
auto operator SYMBOL(const LoopSIMD<T,S,A> &v, \
│ │ │ │ -
const LoopSIMD<T,S,A> &w) { \
│ │ │ │ -
LoopSIMD<T,S,A> out; \
│ │ │ │ -
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
out[i] = v[i] SYMBOL w[i]; \
│ │ │ │ -
} \
│ │ │ │ -
return out; \
│ │ │ │ -
} \
│ │ │ │ -
static_assert(true, "expecting ;")
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ DUNE_SIMD_LOOP_BITSHIFT_OP

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_SIMD_LOOP_BITSHIFT_OP( SYMBOL)
│ │ │ │ -
│ │ │ │ -Value:
template<class T, std::size_t S, std::size_t A, class U> \
│ │ │ │ -
auto operator SYMBOL(const LoopSIMD<T,S,A> &v, const U s) { \
│ │ │ │ -
LoopSIMD<T,S,A> out; \
│ │ │ │ -
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
out[i] = v[i] SYMBOL s; \
│ │ │ │ -
} \
│ │ │ │ -
return out; \
│ │ │ │ -
} \
│ │ │ │ -
template<class T, std::size_t S, std::size_t A, class U, std::size_t AU> \
│ │ │ │ -
auto operator SYMBOL(const LoopSIMD<T,S,A> &v, \
│ │ │ │ -
const LoopSIMD<U,S,AU> &w) { \
│ │ │ │ -
LoopSIMD<T,S,A> out; \
│ │ │ │ -
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
out[i] = v[i] SYMBOL w[i]; \
│ │ │ │ -
} \
│ │ │ │ -
return out; \
│ │ │ │ -
} \
│ │ │ │ -
static_assert(true, "expecting ;")
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ DUNE_SIMD_LOOP_BOOLEAN_OP

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_SIMD_LOOP_BOOLEAN_OP( SYMBOL)
│ │ │ │ -
│ │ │ │ -Value:
template<class T, std::size_t S, std::size_t A> \
│ │ │ │ -
auto operator SYMBOL(const LoopSIMD<T,S,A> &v, const Simd::Scalar<T> s) { \
│ │ │ │ -
Simd::Mask<LoopSIMD<T,S,A>> out; \
│ │ │ │ -
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
out[i] = v[i] SYMBOL s; \
│ │ │ │ -
} \
│ │ │ │ -
return out; \
│ │ │ │ -
} \
│ │ │ │ -
template<class T, std::size_t S, std::size_t A> \
│ │ │ │ -
auto operator SYMBOL(const Simd::Mask<T> s, const LoopSIMD<T,S,A> &v) { \
│ │ │ │ -
Simd::Mask<LoopSIMD<T,S,A>> out; \
│ │ │ │ -
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
out[i] = s SYMBOL v[i]; \
│ │ │ │ -
} \
│ │ │ │ -
return out; \
│ │ │ │ -
} \
│ │ │ │ -
template<class T, std::size_t S, std::size_t A> \
│ │ │ │ -
auto operator SYMBOL(const LoopSIMD<T,S,A> &v, \
│ │ │ │ -
const LoopSIMD<T,S,A> &w) { \
│ │ │ │ -
Simd::Mask<LoopSIMD<T,S,A>> out; \
│ │ │ │ -
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
out[i] = v[i] SYMBOL w[i]; \
│ │ │ │ -
} \
│ │ │ │ -
return out; \
│ │ │ │ -
} \
│ │ │ │ -
static_assert(true, "expecting ;")
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ DUNE_SIMD_LOOP_CMATH_UNARY_OP

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_SIMD_LOOP_CMATH_UNARY_OP( expr)
│ │ │ │ -
│ │ │ │ -Value:
template<class T, std::size_t S, std::size_t A, typename Sfinae = \
│ │ │ │ -
typename std::enable_if_t<!std::is_integral<Simd::Scalar<T>>::value> > \
│ │ │ │ -
auto expr(const LoopSIMD<T,S,A> &v) { \
│ │ │ │ -
using std::expr; \
│ │ │ │ -
LoopSIMD<T,S,A> out; \
│ │ │ │ -
for(std::size_t i=0; i<S; i++) { \
│ │ │ │ -
out[i] = expr(v[i]); \
│ │ │ │ -
} \
│ │ │ │ -
return out; \
│ │ │ │ -
} \
│ │ │ │ -
static_assert(true, "expecting ;")
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN

│ │ │ │ +

Detailed Description

│ │ │ │ +

Support for calculating hash values of objects.

│ │ │ │ +

This file provides the functor Dune::hash to calculate hash values and some infrastructure to simplify extending Dune::hash for user-defined types, independent of the actual underlying implementation.

│ │ │ │ +

Macro Definition Documentation

│ │ │ │ + │ │ │ │ +

◆ DUNE_DEFINE_HASH

│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
#define DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN#define DUNE_DEFINE_HASH( expr, template_args,
 returnType type 
)
│ │ │ │
│ │ │ │ -Value:
template<class T, std::size_t S, std::size_t A, typename Sfinae = \
│ │ │ │ -
typename std::enable_if_t<!std::is_integral<Simd::Scalar<T>>::value> > \
│ │ │ │ -
auto expr(const LoopSIMD<T,S,A> &v) { \
│ │ │ │ -
using std::expr; \
│ │ │ │ -
LoopSIMD<returnType,S> out; \
│ │ │ │ -
for(std::size_t i=0; i<S; i++) { \
│ │ │ │ -
out[i] = expr(v[i]); \
│ │ │ │ -
} \
│ │ │ │ -
return out; \
│ │ │ │ -
} \
│ │ │ │ -
static_assert(true, "expecting ;")
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ DUNE_SIMD_LOOP_COMPARISON_OP

│ │ │ │ │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_SIMD_LOOP_COMPARISON_OP( SYMBOL)
│ │ │ │ -
│ │ │ │ -Value:
template<class T, std::size_t S, std::size_t A, class U> \
│ │ │ │ -
auto operator SYMBOL(const LoopSIMD<T,S,A> &v, const U s) { \
│ │ │ │ -
Simd::Mask<LoopSIMD<T,S,A>> out; \
│ │ │ │ -
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
out[i] = v[i] SYMBOL s; \
│ │ │ │ -
} \
│ │ │ │ -
return out; \
│ │ │ │ -
} \
│ │ │ │ -
template<class T, std::size_t S, std::size_t A> \
│ │ │ │ -
auto operator SYMBOL(const Simd::Scalar<T> s, const LoopSIMD<T,S,A> &v) { \
│ │ │ │ -
Simd::Mask<LoopSIMD<T,S,A>> out; \
│ │ │ │ -
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
out[i] = s SYMBOL v[i]; \
│ │ │ │ -
} \
│ │ │ │ -
return out; \
│ │ │ │ -
} \
│ │ │ │ -
template<class T, std::size_t S, std::size_t A> \
│ │ │ │ -
auto operator SYMBOL(const LoopSIMD<T,S,A> &v, \
│ │ │ │ -
const LoopSIMD<T,S,A> &w) { \
│ │ │ │ -
Simd::Mask<LoopSIMD<T,S,A>> out; \
│ │ │ │ -
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
out[i] = v[i] SYMBOL w[i]; \
│ │ │ │ -
} \
│ │ │ │ -
return out; \
│ │ │ │ -
} \
│ │ │ │ -
static_assert(true, "expecting ;")
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ DUNE_SIMD_LOOP_POSTFIX_OP

│ │ │ │ +

Defines the required struct specialization to make type hashable via Dune::hash.

│ │ │ │ +

In order to calculate the hash, operator() of the generated specialization will return the result of an unqualified call to the global function hash_value(const type&). As the call is not qualified, the function will be found using argument-dependent lookup, allowing implementors to conveniently place it inside the class body.

│ │ │ │ +

Consider the following type:

│ │ │ │ +
namespace ns {
│ │ │ │ +
template<typename A, int i>
│ │ │ │ +
class Foo
│ │ │ │ +
{
│ │ │ │ +
...
│ │ │ │ +
};
│ │ │ │ +
}
│ │ │ │ +

In order to add support for Dune::hash, you need to extend the definition like this:

│ │ │ │ +
namespace ns {
│ │ │ │ +
template<typename A, int i>
│ │ │ │ +
class Foo
│ │ │ │ +
{
│ │ │ │ +
...
│ │ │ │ +
// The keyword "friend" turns this into a global function that is a friend of Foo.
│ │ │ │ +
inline friend std::size_t hash_value(const Foo& arg)
│ │ │ │ +
{
│ │ │ │ +
return ...;
│ │ │ │ +
}
│ │ │ │ +
};
│ │ │ │ +
}
│ │ │ │ +
│ │ │ │ +
// Define hash struct specialization
│ │ │ │ + │ │ │ │ +
#define DUNE_DEFINE_HASH(template_args, type)
Defines the required struct specialization to make type hashable via Dune::hash.
Definition hash.hh:100
│ │ │ │ +
#define DUNE_HASH_TYPE(...)
Wrapper macro for the type to be hashed in DUNE_DEFINE_HASH.
Definition hash.hh:117
│ │ │ │ +
#define DUNE_HASH_TEMPLATE_ARGS(...)
Wrapper macro for the template arguments in DUNE_DEFINE_HASH.
Definition hash.hh:109
│ │ │ │ +
Warning
As the specialization has to be placed in the original namespace of the hash struct (e.g. std), this macro must be called from the global namespace!
│ │ │ │ +
Parameters
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
template_argsThe template arguments required by the hash struct specialization, wrapped in a call to DUNE_HASH_TEMPLATE_ARGS. If this is a complete specialization, call DUNE_HASH_TEMPLATE_ARGS without arguments.
typeThe exact type of the specialization, wrapped in a call to DUNE_HASH_TYPE.
│ │ │ │ +
│ │ │ │ +
│ │ │ │ │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_SIMD_LOOP_POSTFIX_OP( SYMBOL)
│ │ │ │ -
│ │ │ │ -Value:
auto operator SYMBOL(int){ \
│ │ │ │ -
LoopSIMD<T,S,A> out = *this; \
│ │ │ │ -
SYMBOL(*this); \
│ │ │ │ -
return out; \
│ │ │ │ -
} \
│ │ │ │ -
static_assert(true, "expecting ;")
│ │ │ │ -
│ │ │ │
│ │ │ │
│ │ │ │ - │ │ │ │ -

◆ DUNE_SIMD_LOOP_PREFIX_OP

│ │ │ │ + │ │ │ │ +

◆ DUNE_HASH_TEMPLATE_ARGS

│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │
#define DUNE_SIMD_LOOP_PREFIX_OP#define DUNE_HASH_TEMPLATE_ARGS( SYMBOL)...)
│ │ │ │
│ │ │ │ -Value:
auto operator SYMBOL() { \
│ │ │ │ -
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
SYMBOL(*this)[i]; \
│ │ │ │ -
} \
│ │ │ │ -
return *this; \
│ │ │ │ -
} \
│ │ │ │ -
static_assert(true, "expecting ;")
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ DUNE_SIMD_LOOP_STD_BINARY_OP

│ │ │ │ │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_SIMD_LOOP_STD_BINARY_OP( expr)
│ │ │ │ -
│ │ │ │ -Value:
template<class T, std::size_t S, std::size_t A> \
│ │ │ │ -
auto expr(const LoopSIMD<T,S,A> &v, const LoopSIMD<T,S,A> &w) { \
│ │ │ │ -
using std::expr; \
│ │ │ │ -
LoopSIMD<T,S,A> out; \
│ │ │ │ -
for(std::size_t i=0; i<S; i++) { \
│ │ │ │ -
out[i] = expr(v[i],w[i]); \
│ │ │ │ -
} \
│ │ │ │ -
return out; \
│ │ │ │ -
} \
│ │ │ │ -
static_assert(true, "expecting ;")
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ DUNE_SIMD_LOOP_STD_UNARY_OP

│ │ │ │ +

Wrapper macro for the template arguments in DUNE_DEFINE_HASH.

│ │ │ │ +

This macro should always be used as a wrapper for the template arguments when calling DUNE_DEFINE_HASH. It works around some preprocessor limitations when the template arguments contain commas or the list is completely empty.

│ │ │ │ │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_SIMD_LOOP_STD_UNARY_OP( expr)
│ │ │ │ -
│ │ │ │ -Value:
template<class T, std::size_t S, std::size_t A> \
│ │ │ │ -
auto expr(const LoopSIMD<T,S,A> &v) { \
│ │ │ │ -
using std::expr; \
│ │ │ │ -
LoopSIMD<T,S,A> out; \
│ │ │ │ -
for(std::size_t i=0; i<S; i++) { \
│ │ │ │ -
out[i] = expr(v[i]); \
│ │ │ │ -
} \
│ │ │ │ -
return out; \
│ │ │ │ -
} \
│ │ │ │ -
\
│ │ │ │ -
template<class T, std::size_t S, std::size_t A> \
│ │ │ │ -
auto expr(const LoopSIMD<std::complex<T>,S,A> &v) { \
│ │ │ │ -
using std::expr; \
│ │ │ │ -
LoopSIMD<T,S,A> out; \
│ │ │ │ -
for(std::size_t i=0; i<S; i++) { \
│ │ │ │ -
out[i] = expr(v[i]); \
│ │ │ │ -
} \
│ │ │ │ -
return out; \
│ │ │ │ -
} \
│ │ │ │ -
static_assert(true, "expecting ;")
│ │ │ │ -
│ │ │ │
│ │ │ │
│ │ │ │ - │ │ │ │ -

◆ DUNE_SIMD_LOOP_UNARY_OP

│ │ │ │ + │ │ │ │ +

◆ DUNE_HASH_TYPE

│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │
#define DUNE_SIMD_LOOP_UNARY_OP#define DUNE_HASH_TYPE( SYMBOL)...)
│ │ │ │
│ │ │ │ -Value:
auto operator SYMBOL() const { \
│ │ │ │ -
LoopSIMD<T,S,A> out; \
│ │ │ │ -
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
out[i] = SYMBOL((*this)[i]); \
│ │ │ │ -
} \
│ │ │ │ -
return out; \
│ │ │ │ -
} \
│ │ │ │ -
static_assert(true, "expecting ;")
│ │ │ │ -
│ │ │ │ + │ │ │ │ +

Wrapper macro for the type to be hashed in DUNE_DEFINE_HASH.

│ │ │ │ +

This macro should always be used as a wrapper for the type of the specialization when calling DUNE_DEFINE_HASH. It works around some preprocessor limitations when the type contains commas.

│ │ │ │ + │ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,489 +1,128 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * simd │ │ │ │ │ Classes | Namespaces | Macros | Functions │ │ │ │ │ -loop.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +hash.hh File Reference │ │ │ │ │ +Support for calculating hash values of objects. More... │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ - class   Dune::LoopSIMD<_T,_S,_A_> │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::Simd::Overloads::ScalarType<_LoopSIMD<_T,_S,_A_>_> │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::Simd::Overloads::RebindType<_U,_LoopSIMD<_T,_S,_A_>_> │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::Simd::Overloads::LaneCount<_LoopSIMD<_T,_S,_A_>_> │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::IsNumber<_LoopSIMD<_T,_S,_A_>_> │ │ │ │ │ +struct   Dune::hash<_T_> │ │ │ │ │ +  Functor for hashing objects of type T. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -namespace   Dune::Simd │ │ │ │ │ -  Namespace for vectorization interface functions used by library │ │ │ │ │ - developers. │ │ │ │ │ -  │ │ │ │ │ -namespace   Dune::Simd::Overloads │ │ │ │ │ -  Namespace for the overloads and specializations that make up a SIMD │ │ │ │ │ - implementation. │ │ │ │ │ -  │ │ │ │ │ -namespace   Dune::MathOverloads │ │ │ │ │ -  namespace for customization of math functions with Dune-Semantics │ │ │ │ │ -  │ │ │ │ │ Macros │ │ │ │ │ -#define  DUNE_PRAGMA_OMP_SIMD │ │ │ │ │ -  │ │ │ │ │ -#define  DUNE_SIMD_LOOP_PREFIX_OP(SYMBOL) │ │ │ │ │ -  │ │ │ │ │ -#define  DUNE_SIMD_LOOP_UNARY_OP(SYMBOL) │ │ │ │ │ -  │ │ │ │ │ -#define  DUNE_SIMD_LOOP_POSTFIX_OP(SYMBOL) │ │ │ │ │ -  │ │ │ │ │ -#define  DUNE_SIMD_LOOP_ASSIGNMENT_OP(SYMBOL) │ │ │ │ │ +#define  DUNE_DEFINE_HASH(template_args, type) │ │ │ │ │ +  Defines the required struct specialization to make type hashable via │ │ │ │ │ + Dune::hash. │ │ │ │ │   │ │ │ │ │ -#define  DUNE_SIMD_LOOP_BINARY_OP(SYMBOL) │ │ │ │ │ +#define  DUNE_HASH_TEMPLATE_ARGS(...) │ │ │ │ │ +  Wrapper macro for the template arguments in DUNE_DEFINE_HASH. │ │ │ │ │   │ │ │ │ │ -#define  DUNE_SIMD_LOOP_BITSHIFT_OP(SYMBOL) │ │ │ │ │ -  │ │ │ │ │ -#define  DUNE_SIMD_LOOP_COMPARISON_OP(SYMBOL) │ │ │ │ │ -  │ │ │ │ │ -#define  DUNE_SIMD_LOOP_BOOLEAN_OP(SYMBOL) │ │ │ │ │ -  │ │ │ │ │ -#define  DUNE_SIMD_LOOP_CMATH_UNARY_OP(expr) │ │ │ │ │ -  │ │ │ │ │ -#define  DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN(expr, returnType) │ │ │ │ │ -  │ │ │ │ │ -#define  DUNE_SIMD_LOOP_STD_UNARY_OP(expr) │ │ │ │ │ -  │ │ │ │ │ -#define  DUNE_SIMD_LOOP_STD_BINARY_OP(expr) │ │ │ │ │ +#define  DUNE_HASH_TYPE(...) │ │ │ │ │ +  Wrapper macro for the type to be hashed in DUNE_DEFINE_HASH. │ │ │ │ │   │ │ │ │ │ Functions │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_BINARY_OP (+) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_BINARY_OP (-) │ │ │ │ │ -  │ │ │ │ │ - DUNE_SIMD_LOOP_BINARY_OP *  Dune::DUNE_SIMD_LOOP_BINARY_OP (/);DUNE_SIMD_ │ │ │ │ │ - LOOP_BINARY_OP(% │ │ │ │ │ -  │ │ │ │ │ - DUNE_SIMD_LOOP_BINARY_OP &  Dune::DUNE_SIMD_LOOP_BINARY_OP (|);DUNE_SIMD_ │ │ │ │ │ - LOOP_BINARY_OP(^ │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_BITSHIFT_OP (<<) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_BITSHIFT_OP (> >) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_COMPARISON_OP (<) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_COMPARISON_OP (<=) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_COMPARISON_OP (>=) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_COMPARISON_OP (!=) │ │ │ │ │ -  │ │ │ │ │ -DUNE_SIMD_LOOP_BOOLEAN_OP &&  Dune::DUNE_SIMD_LOOP_BOOLEAN_OP (||);template< │ │ │ │ │ - class T, std::size_t S, std::size_t A > std:: │ │ │ │ │ - ostream &operator<<(std::ostream &os, const │ │ │ │ │ - LoopSIMD< T, S, A > &v │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::Simd::Overloads::lane (ADLTag< 5 >, std:: │ │ │ │ │ - size_t l, LoopSIMD< T, S, A > &&v) -> decltype │ │ │ │ │ - (std::move(Simd::lane(l%lanes< T >(), v[l/lanes< │ │ │ │ │ - T >()]))) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::Simd::Overloads::lane (ADLTag< 5 >, std:: │ │ │ │ │ - size_t l, const LoopSIMD< T, S, A > &v) - │ │ │ │ │ - > decltype(Simd::lane(l%lanes< T >(), v[l/lanes< │ │ │ │ │ - T >()])) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::Simd::Overloads::lane (ADLTag< 5 >, std:: │ │ │ │ │ - size_t l, LoopSIMD< T, S, A > &v) -> decltype │ │ │ │ │ - (Simd::lane(l%lanes< T >(), v[l/lanes< T >()])) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::Simd::Overloads::cond (ADLTag< 5 >, Simd:: │ │ │ │ │ - Mask< LoopSIMD< T, S, AM > > mask, LoopSIMD< T, │ │ │ │ │ - S, AD > ifTrue, LoopSIMD< T, S, AD > ifFalse) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::Simd::Overloads::cond (ADLTag< 5, std::is_ │ │ │ │ │ - same< bool, Simd::Scalar< M > >::value &&Simd:: │ │ │ │ │ - lanes< M >()==Simd::lanes< LoopSIMD< T, S, A > > │ │ │ │ │ - ()>, M mask, LoopSIMD< T, S, A > ifTrue, │ │ │ │ │ - LoopSIMD< T, S, A > ifFalse) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - bool  Dune::Simd::Overloads::anyTrue (ADLTag< 5 >, │ │ │ │ │ - LoopSIMD< M, S, A > mask) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - bool  Dune::Simd::Overloads::allTrue (ADLTag< 5 >, │ │ │ │ │ - LoopSIMD< M, S, A > mask) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - bool  Dune::Simd::Overloads::anyFalse (ADLTag< 5 >, │ │ │ │ │ - LoopSIMD< M, S, A > mask) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - bool  Dune::Simd::Overloads::allFalse (ADLTag< 5 >, │ │ │ │ │ - LoopSIMD< M, S, A > mask) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (cos) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (sin) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (tan) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (acos) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (asin) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (atan) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (cosh) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (sinh) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (tanh) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (acosh) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (asinh) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (atanh) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (exp) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (log) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (log10) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (exp2) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (expm1) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN │ │ │ │ │ - (ilogb, int) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (log1p) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (log2) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (logb) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (sqrt) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (cbrt) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (erf) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (erfc) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (tgamma) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (lgamma) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (ceil) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (floor) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (trunc) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (round) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN │ │ │ │ │ - (lround, long) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN │ │ │ │ │ - (llround, long long) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (rint) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN │ │ │ │ │ - (lrint, long) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN │ │ │ │ │ - (llrint, long long) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (nearbyint) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (fabs) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (abs) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_STD_UNARY_OP (real) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_STD_UNARY_OP (imag) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_STD_BINARY_OP (max) │ │ │ │ │ -  │ │ │ │ │ -   Dune::DUNE_SIMD_LOOP_STD_BINARY_OP (min) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::MathOverloads::isNaN (const LoopSIMD< T, S, │ │ │ │ │ - A > &v, PriorityTag< 3 >, ADLTag) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::MathOverloads::isInf (const LoopSIMD< T, S, │ │ │ │ │ - A > &v, PriorityTag< 3 >, ADLTag) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::MathOverloads::isFinite (const LoopSIMD< T, │ │ │ │ │ - S, A > &v, PriorityTag< 3 >, ADLTag) │ │ │ │ │ -  │ │ │ │ │ +template │ │ │ │ │ + void  Dune::hash_combine (std::size_t &seed, const T &arg) │ │ │ │ │ +  Calculates the hash value of arg and combines it in-place with │ │ │ │ │ + seed. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +std::size_t  Dune::hash_range (It first, It last) │ │ │ │ │ +  Hashes all elements in the range [first,last) and returns the │ │ │ │ │ + combined hash. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + void  Dune::hash_range (std::size_t &seed, It first, It last) │ │ │ │ │ +  Hashes all elements in the range [first,last) and combines the │ │ │ │ │ + hashes in-place with seed. │ │ │ │ │ +  │ │ │ │ │ +***** Detailed Description ***** │ │ │ │ │ +Support for calculating hash values of objects. │ │ │ │ │ +This file provides the functor Dune::hash to calculate hash values and some │ │ │ │ │ +infrastructure to simplify extending Dune::hash for user-defined types, │ │ │ │ │ +independent of the actual underlying implementation. │ │ │ │ │ ***** Macro Definition Documentation ***** │ │ │ │ │ -***** ◆ DUNE_PRAGMA_OMP_SIMD ***** │ │ │ │ │ -#define DUNE_PRAGMA_OMP_SIMD │ │ │ │ │ -***** ◆ DUNE_SIMD_LOOP_ASSIGNMENT_OP ***** │ │ │ │ │ -#define DUNE_SIMD_LOOP_ASSIGNMENT_OP (   SYMBOL ) │ │ │ │ │ -Value: │ │ │ │ │ -auto operator SYMBOL(const Simd::Scalar s) { \ │ │ │ │ │ -DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -for(std::size_t i=0; i &v) { \ │ │ │ │ │ -DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -for(std::size_t i=0; i \ │ │ │ │ │ -auto operator SYMBOL(const LoopSIMD &v, const Simd::Scalar s) { \ │ │ │ │ │ -LoopSIMD out; \ │ │ │ │ │ -DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -for(std::size_t i=0; i \ │ │ │ │ │ -auto operator SYMBOL(const Simd::Scalar s, const LoopSIMD &v) { \ │ │ │ │ │ -LoopSIMD out; \ │ │ │ │ │ -DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -for(std::size_t i=0; i \ │ │ │ │ │ -auto operator SYMBOL(const LoopSIMD &v, \ │ │ │ │ │ -const LoopSIMD &w) { \ │ │ │ │ │ -LoopSIMD out; \ │ │ │ │ │ -DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -for(std::size_t i=0; i \ │ │ │ │ │ -auto operator SYMBOL(const LoopSIMD &v, const U s) { \ │ │ │ │ │ -LoopSIMD out; \ │ │ │ │ │ -DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -for(std::size_t i=0; i \ │ │ │ │ │ -auto operator SYMBOL(const LoopSIMD &v, \ │ │ │ │ │ -const LoopSIMD &w) { \ │ │ │ │ │ -LoopSIMD out; \ │ │ │ │ │ -DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -for(std::size_t i=0; i \ │ │ │ │ │ -auto operator SYMBOL(const LoopSIMD &v, const Simd::Scalar s) { \ │ │ │ │ │ -Simd::Mask> out; \ │ │ │ │ │ -DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -for(std::size_t i=0; i \ │ │ │ │ │ -auto operator SYMBOL(const Simd::Mask s, const LoopSIMD &v) { \ │ │ │ │ │ -Simd::Mask> out; \ │ │ │ │ │ -DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -for(std::size_t i=0; i \ │ │ │ │ │ -auto operator SYMBOL(const LoopSIMD &v, \ │ │ │ │ │ -const LoopSIMD &w) { \ │ │ │ │ │ -Simd::Mask> out; \ │ │ │ │ │ -DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -for(std::size_t i=0; i>::value> > \ │ │ │ │ │ -auto expr(const LoopSIMD &v) { \ │ │ │ │ │ -using std::expr; \ │ │ │ │ │ -LoopSIMD out; \ │ │ │ │ │ -for(std::size_t i=0; i>::value> > \ │ │ │ │ │ -auto expr(const LoopSIMD &v) { \ │ │ │ │ │ -using std::expr; \ │ │ │ │ │ -LoopSIMD out; \ │ │ │ │ │ -for(std::size_t i=0; i \ │ │ │ │ │ -auto operator SYMBOL(const LoopSIMD &v, const U s) { \ │ │ │ │ │ -Simd::Mask> out; \ │ │ │ │ │ -DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -for(std::size_t i=0; i \ │ │ │ │ │ -auto operator SYMBOL(const Simd::Scalar s, const LoopSIMD &v) { \ │ │ │ │ │ -Simd::Mask> out; \ │ │ │ │ │ -DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -for(std::size_t i=0; i \ │ │ │ │ │ -auto operator SYMBOL(const LoopSIMD &v, \ │ │ │ │ │ -const LoopSIMD &w) { \ │ │ │ │ │ -Simd::Mask> out; \ │ │ │ │ │ -DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -for(std::size_t i=0; i out = *this; \ │ │ │ │ │ -SYMBOL(*this); \ │ │ │ │ │ -return out; \ │ │ │ │ │ -} \ │ │ │ │ │ -static_assert(true, "expecting ;") │ │ │ │ │ -***** ◆ DUNE_SIMD_LOOP_PREFIX_OP ***** │ │ │ │ │ -#define DUNE_SIMD_LOOP_PREFIX_OP (   SYMBOL ) │ │ │ │ │ -Value: │ │ │ │ │ -auto operator SYMBOL() { \ │ │ │ │ │ -DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -for(std::size_t i=0; i \ │ │ │ │ │ -auto expr(const LoopSIMD &v, const LoopSIMD &w) { \ │ │ │ │ │ -using std::expr; \ │ │ │ │ │ -LoopSIMD out; \ │ │ │ │ │ -for(std::size_t i=0; i \ │ │ │ │ │ -auto expr(const LoopSIMD &v) { \ │ │ │ │ │ -using std::expr; \ │ │ │ │ │ -LoopSIMD out; \ │ │ │ │ │ -for(std::size_t i=0; i \ │ │ │ │ │ -auto expr(const LoopSIMD,S,A> &v) { \ │ │ │ │ │ -using std::expr; \ │ │ │ │ │ -LoopSIMD out; \ │ │ │ │ │ -for(std::size_t i=0; i out; \ │ │ │ │ │ -DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -for(std::size_t i=0; i │ │ │ │ │ +class Foo │ │ │ │ │ +{ │ │ │ │ │ +... │ │ │ │ │ +}; │ │ │ │ │ +} │ │ │ │ │ +In order to add support for Dune::hash, you need to extend the definition like │ │ │ │ │ +this: │ │ │ │ │ +namespace ns { │ │ │ │ │ +template │ │ │ │ │ +class Foo │ │ │ │ │ +{ │ │ │ │ │ +... │ │ │ │ │ +// The keyword "friend" turns this into a global function that is a friend of │ │ │ │ │ +Foo. │ │ │ │ │ +inline friend std::size_t hash_value(const Foo& arg) │ │ │ │ │ +{ │ │ │ │ │ +return ...; │ │ │ │ │ +} │ │ │ │ │ +}; │ │ │ │ │ +} │ │ │ │ │ +// Define hash struct specialization │ │ │ │ │ +DUNE_DEFINE_HASH(DUNE_HASH_TEMPLATE_ARGS(typename A, int i),DUNE_HASH_TYPE │ │ │ │ │ +(Foo)) │ │ │ │ │ +DUNE_DEFINE_HASH │ │ │ │ │ +#define DUNE_DEFINE_HASH(template_args, type) │ │ │ │ │ +Defines the required struct specialization to make type hashable via Dune:: │ │ │ │ │ +hash. │ │ │ │ │ +Definition hash.hh:100 │ │ │ │ │ +DUNE_HASH_TYPE │ │ │ │ │ +#define DUNE_HASH_TYPE(...) │ │ │ │ │ +Wrapper macro for the type to be hashed in DUNE_DEFINE_HASH. │ │ │ │ │ +Definition hash.hh:117 │ │ │ │ │ +DUNE_HASH_TEMPLATE_ARGS │ │ │ │ │ +#define DUNE_HASH_TEMPLATE_ARGS(...) │ │ │ │ │ +Wrapper macro for the template arguments in DUNE_DEFINE_HASH. │ │ │ │ │ +Definition hash.hh:109 │ │ │ │ │ + Warning │ │ │ │ │ + As the specialization has to be placed in the original namespace of the │ │ │ │ │ + hash struct (e.g. std), this macro must be called from the global │ │ │ │ │ + namespace! │ │ │ │ │ + Parameters │ │ │ │ │ + The template arguments required by the hash struct │ │ │ │ │ + template_args specialization, wrapped in a call to DUNE_HASH_TEMPLATE_ │ │ │ │ │ + ARGS. If this is a complete specialization, call DUNE_HASH_ │ │ │ │ │ + TEMPLATE_ARGS without arguments. │ │ │ │ │ + type The exact type of the specialization, wrapped in a call to │ │ │ │ │ + DUNE_HASH_TYPE. │ │ │ │ │ +***** ◆ DUNE_HASH_TEMPLATE_ARGS ***** │ │ │ │ │ +#define DUNE_HASH_TEMPLATE_ARGS (   ... ) │ │ │ │ │ +Wrapper macro for the template arguments in DUNE_DEFINE_HASH. │ │ │ │ │ +This macro should always be used as a wrapper for the template arguments when │ │ │ │ │ +calling DUNE_DEFINE_HASH. It works around some preprocessor limitations when │ │ │ │ │ +the template arguments contain commas or the list is completely empty. │ │ │ │ │ +***** ◆ DUNE_HASH_TYPE ***** │ │ │ │ │ +#define DUNE_HASH_TYPE (   ... ) │ │ │ │ │ +Wrapper macro for the type to be hashed in DUNE_DEFINE_HASH. │ │ │ │ │ +This macro should always be used as a wrapper for the type of the │ │ │ │ │ +specialization when calling DUNE_DEFINE_HASH. It works around some preprocessor │ │ │ │ │ +limitations when the type contains commas. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00026_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: loop.hh Source File │ │ │ │ +dune-common: hash.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,766 +70,293 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
loop.hh
│ │ │ │ +
hash.hh
│ │ │ │
│ │ │ │
│ │ │ │ -Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ -
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
3#ifndef DUNE_COMMON_SIMD_LOOP_HH
│ │ │ │ -
4#define DUNE_COMMON_SIMD_LOOP_HH
│ │ │ │ -
5
│ │ │ │ -
6#include <array>
│ │ │ │ -
7#include <cmath>
│ │ │ │ -
8#include <cstddef>
│ │ │ │ -
9#include <cstdlib>
│ │ │ │ -
10#include <cstdint>
│ │ │ │ -
11#include <ostream>
│ │ │ │ -
12
│ │ │ │ -
13#include <dune/common/math.hh>
│ │ │ │ - │ │ │ │ - │ │ │ │ -
16
│ │ │ │ -
17namespace Dune {
│ │ │ │ -
18
│ │ │ │ -
19
│ │ │ │ -
20/*
│ │ │ │ -
21 * silence warnings from GCC about using integer operands on a bool
│ │ │ │ -
22 * (when instantiated for T=bool)
│ │ │ │ -
23 */
│ │ │ │ -
24#if __GNUC__ >= 7
│ │ │ │ -
25# pragma GCC diagnostic push
│ │ │ │ -
26# pragma GCC diagnostic ignored "-Wbool-operation"
│ │ │ │ -
27# pragma GCC diagnostic ignored "-Wint-in-bool-context"
│ │ │ │ -
28# define GCC_WARNING_DISABLED
│ │ │ │ -
29#endif
│ │ │ │ -
30
│ │ │ │ -
31/*
│ │ │ │ -
32 * silence warnings from Clang about using bitwise operands on
│ │ │ │ -
33 * a bool (when instantiated for T=bool)
│ │ │ │ -
34 */
│ │ │ │ -
35#ifdef __clang__
│ │ │ │ -
36#if __has_warning("-Wbitwise-instead-of-logical")
│ │ │ │ -
37# pragma clang diagnostic push
│ │ │ │ -
38# pragma clang diagnostic ignored "-Wbitwise-instead-of-logical"
│ │ │ │ -
39# define CLANG_WARNING_DISABLED
│ │ │ │ -
40#endif
│ │ │ │ -
41#endif
│ │ │ │ -
42
│ │ │ │ -
43/*
│ │ │ │ -
44 * Introduce a simd pragma if OpenMP is available in standard version >= 4
│ │ │ │ -
45 */
│ │ │ │ -
46#if _OPENMP >= 201307
│ │ │ │ -
47 #define DUNE_PRAGMA_OMP_SIMD _Pragma("omp simd")
│ │ │ │ -
48#else
│ │ │ │ -
49 #define DUNE_PRAGMA_OMP_SIMD
│ │ │ │ -
50#endif
│ │ │ │ +Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │ +
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │ +
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ +
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ +
5#ifndef DUNE_COMMON_HASH_HH
│ │ │ │ +
6#define DUNE_COMMON_HASH_HH
│ │ │ │ +
7
│ │ │ │ +
8#include <functional>
│ │ │ │ +
9
│ │ │ │ + │ │ │ │ +
11
│ │ │ │ +
24// ********************************************************************************
│ │ │ │ +
25// Doxygen documentation
│ │ │ │ +
26// ********************************************************************************
│ │ │ │ +
27
│ │ │ │ +
28#ifdef DOXYGEN
│ │ │ │ +
29
│ │ │ │ +
30namespace Dune {
│ │ │ │ +
31
│ │ │ │ +
33
│ │ │ │ +
38 template<typename T>
│ │ │ │ +
│ │ │ │ +
39 struct hash
│ │ │ │ +
40 {
│ │ │ │ +
41
│ │ │ │ +
│ │ │ │ +
43 std::size_t operator()(const T& t) const
│ │ │ │ +
44 {
│ │ │ │ +
45 return hash(t);
│ │ │ │ +
46 }
│ │ │ │ +
│ │ │ │ +
47
│ │ │ │ +
48 };
│ │ │ │ +
│ │ │ │ +
49
│ │ │ │ +
50}
│ │ │ │
51
│ │ │ │ -
52
│ │ │ │ -
64 template<class T, std::size_t S, std::size_t A = 0>
│ │ │ │ -
│ │ │ │ -
65 class alignas(A==0?alignof(T):A) LoopSIMD : public std::array<T,S> {
│ │ │ │ -
66
│ │ │ │ -
67 public:
│ │ │ │ -
68
│ │ │ │ -
69 //default constructor
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
71 assert(reinterpret_cast<uintptr_t>(this) % std::min(alignof(LoopSIMD<T,S,A>),alignof(std::max_align_t)) == 0);
│ │ │ │ -
72 }
│ │ │ │ -
│ │ │ │ -
73
│ │ │ │ -
74 // broadcast constructor initializing the content with a given value
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
76 this->fill(i);
│ │ │ │ -
77 }
│ │ │ │ -
│ │ │ │ -
78
│ │ │ │ -
79 template<std::size_t OA>
│ │ │ │ -
│ │ │ │ -
80 explicit LoopSIMD(const LoopSIMD<T,S,OA>& other)
│ │ │ │ -
81 : std::array<T,S>(other)
│ │ │ │ -
82 {
│ │ │ │ -
83 assert(reinterpret_cast<uintptr_t>(this) % std::min(alignof(LoopSIMD<T,S,A>),alignof(std::max_align_t)) == 0);
│ │ │ │ -
84 }
│ │ │ │ -
│ │ │ │ -
85
│ │ │ │ -
86 /*
│ │ │ │ -
87 * Definition of basic operators
│ │ │ │ -
88 */
│ │ │ │ -
89
│ │ │ │ -
90 //Prefix operators
│ │ │ │ -
│ │ │ │ -
91#define DUNE_SIMD_LOOP_PREFIX_OP(SYMBOL) \
│ │ │ │ -
92 auto operator SYMBOL() { \
│ │ │ │ -
93 DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
94 for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
95 SYMBOL(*this)[i]; \
│ │ │ │ -
96 } \
│ │ │ │ -
97 return *this; \
│ │ │ │ -
98 } \
│ │ │ │ -
99 static_assert(true, "expecting ;")
│ │ │ │ -
│ │ │ │ -
100
│ │ │ │ - │ │ │ │ - │ │ │ │ -
103#undef DUNE_SIMD_LOOP_PREFIX_OP
│ │ │ │ +
53
│ │ │ │ +
100#define DUNE_DEFINE_HASH(template_args,type)
│ │ │ │ +
101
│ │ │ │ +
102
│ │ │ │
104
│ │ │ │ -
105 //Unary operators
│ │ │ │ -
│ │ │ │ -
106#define DUNE_SIMD_LOOP_UNARY_OP(SYMBOL) \
│ │ │ │ -
107 auto operator SYMBOL() const { \
│ │ │ │ -
108 LoopSIMD<T,S,A> out; \
│ │ │ │ -
109 DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
110 for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
111 out[i] = SYMBOL((*this)[i]); \
│ │ │ │ -
112 } \
│ │ │ │ -
113 return out; \
│ │ │ │ -
114 } \
│ │ │ │ -
115 static_assert(true, "expecting ;")
│ │ │ │ -
│ │ │ │ -
116
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ +
109#define DUNE_HASH_TEMPLATE_ARGS(...)
│ │ │ │ +
110
│ │ │ │ +
112
│ │ │ │ +
117#define DUNE_HASH_TYPE(...)
│ │ │ │ +
118
│ │ │ │ +
119#else // DOXYGEN - hide all the ugly implementation
│ │ │ │
120
│ │ │ │ -
│ │ │ │ -
121 auto operator!() const {
│ │ │ │ - │ │ │ │ - │ │ │ │ -
124 for(std::size_t i=0; i<S; i++){
│ │ │ │ -
125 out[i] = !((*this)[i]);
│ │ │ │ -
126 }
│ │ │ │ -
127 return out;
│ │ │ │ -
128 }
│ │ │ │ -
│ │ │ │ -
129#undef DUNE_SIMD_LOOP_UNARY_OP
│ │ │ │ -
130
│ │ │ │ -
131 //Postfix operators
│ │ │ │ -
│ │ │ │ -
132#define DUNE_SIMD_LOOP_POSTFIX_OP(SYMBOL) \
│ │ │ │ -
133 auto operator SYMBOL(int){ \
│ │ │ │ -
134 LoopSIMD<T,S,A> out = *this; \
│ │ │ │ -
135 SYMBOL(*this); \
│ │ │ │ -
136 return out; \
│ │ │ │ -
137 } \
│ │ │ │ -
138 static_assert(true, "expecting ;")
│ │ │ │ -
│ │ │ │ -
139
│ │ │ │ - │ │ │ │ - │ │ │ │ -
142#undef DUNE_SIMD_LOOP_POSTFIX_OP
│ │ │ │ -
143
│ │ │ │ -
144 //Assignment operators
│ │ │ │ -
│ │ │ │ -
145#define DUNE_SIMD_LOOP_ASSIGNMENT_OP(SYMBOL) \
│ │ │ │ -
146 auto operator SYMBOL(const Simd::Scalar<T> s) { \
│ │ │ │ -
147 DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
148 for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
149 (*this)[i] SYMBOL s; \
│ │ │ │ -
150 } \
│ │ │ │ -
151 return *this; \
│ │ │ │ -
152 } \
│ │ │ │ -
153 \
│ │ │ │ -
154 auto operator SYMBOL(const LoopSIMD<T,S,A> &v) { \
│ │ │ │ -
155 DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
156 for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
157 (*this)[i] SYMBOL v[i]; \
│ │ │ │ -
158 } \
│ │ │ │ -
159 return *this; \
│ │ │ │ -
160 } \
│ │ │ │ -
161 static_assert(true, "expecting ;")
│ │ │ │ -
│ │ │ │ -
162
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
173#undef DUNE_SIMD_LOOP_ASSIGNMENT_OP
│ │ │ │ -
174 };
│ │ │ │ -
│ │ │ │ -
175
│ │ │ │ -
176 //Arithmetic operators
│ │ │ │ -
│ │ │ │ -
177#define DUNE_SIMD_LOOP_BINARY_OP(SYMBOL) \
│ │ │ │ -
178 template<class T, std::size_t S, std::size_t A> \
│ │ │ │ -
179 auto operator SYMBOL(const LoopSIMD<T,S,A> &v, const Simd::Scalar<T> s) { \
│ │ │ │ -
180 LoopSIMD<T,S,A> out; \
│ │ │ │ -
181 DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
182 for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
183 out[i] = v[i] SYMBOL s; \
│ │ │ │ -
184 } \
│ │ │ │ -
185 return out; \
│ │ │ │ -
186 } \
│ │ │ │ -
187 template<class T, std::size_t S, std::size_t A> \
│ │ │ │ -
188 auto operator SYMBOL(const Simd::Scalar<T> s, const LoopSIMD<T,S,A> &v) { \
│ │ │ │ -
189 LoopSIMD<T,S,A> out; \
│ │ │ │ -
190 DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
191 for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
192 out[i] = s SYMBOL v[i]; \
│ │ │ │ -
193 } \
│ │ │ │ -
194 return out; \
│ │ │ │ -
195 } \
│ │ │ │ -
196 template<class T, std::size_t S, std::size_t A> \
│ │ │ │ -
197 auto operator SYMBOL(const LoopSIMD<T,S,A> &v, \
│ │ │ │ -
198 const LoopSIMD<T,S,A> &w) { \
│ │ │ │ -
199 LoopSIMD<T,S,A> out; \
│ │ │ │ -
200 DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
201 for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
202 out[i] = v[i] SYMBOL w[i]; \
│ │ │ │ -
203 } \
│ │ │ │ -
204 return out; \
│ │ │ │ -
205 } \
│ │ │ │ -
206 static_assert(true, "expecting ;")
│ │ │ │ -
│ │ │ │ -
207
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
213
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
217
│ │ │ │ -
218#undef DUNE_SIMD_LOOP_BINARY_OP
│ │ │ │ -
219
│ │ │ │ -
220 //Bitshift operators
│ │ │ │ -
│ │ │ │ -
221#define DUNE_SIMD_LOOP_BITSHIFT_OP(SYMBOL) \
│ │ │ │ -
222 template<class T, std::size_t S, std::size_t A, class U> \
│ │ │ │ -
223 auto operator SYMBOL(const LoopSIMD<T,S,A> &v, const U s) { \
│ │ │ │ -
224 LoopSIMD<T,S,A> out; \
│ │ │ │ -
225 DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
226 for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
227 out[i] = v[i] SYMBOL s; \
│ │ │ │ -
228 } \
│ │ │ │ -
229 return out; \
│ │ │ │ -
230 } \
│ │ │ │ -
231 template<class T, std::size_t S, std::size_t A, class U, std::size_t AU> \
│ │ │ │ -
232 auto operator SYMBOL(const LoopSIMD<T,S,A> &v, \
│ │ │ │ -
233 const LoopSIMD<U,S,AU> &w) { \
│ │ │ │ -
234 LoopSIMD<T,S,A> out; \
│ │ │ │ -
235 DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
236 for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
237 out[i] = v[i] SYMBOL w[i]; \
│ │ │ │ -
238 } \
│ │ │ │ -
239 return out; \
│ │ │ │ -
240 } \
│ │ │ │ -
241 static_assert(true, "expecting ;")
│ │ │ │ -
│ │ │ │ -
242
│ │ │ │ - │ │ │ │ - │ │ │ │ -
245
│ │ │ │ -
246#undef DUNE_SIMD_LOOP_BITSHIFT_OP
│ │ │ │ -
247
│ │ │ │ -
248 //Comparison operators
│ │ │ │ -
│ │ │ │ -
249#define DUNE_SIMD_LOOP_COMPARISON_OP(SYMBOL) \
│ │ │ │ -
250 template<class T, std::size_t S, std::size_t A, class U> \
│ │ │ │ -
251 auto operator SYMBOL(const LoopSIMD<T,S,A> &v, const U s) { \
│ │ │ │ -
252 Simd::Mask<LoopSIMD<T,S,A>> out; \
│ │ │ │ -
253 DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
254 for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
255 out[i] = v[i] SYMBOL s; \
│ │ │ │ -
256 } \
│ │ │ │ -
257 return out; \
│ │ │ │ -
258 } \
│ │ │ │ -
259 template<class T, std::size_t S, std::size_t A> \
│ │ │ │ -
260 auto operator SYMBOL(const Simd::Scalar<T> s, const LoopSIMD<T,S,A> &v) { \
│ │ │ │ -
261 Simd::Mask<LoopSIMD<T,S,A>> out; \
│ │ │ │ -
262 DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
263 for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
264 out[i] = s SYMBOL v[i]; \
│ │ │ │ -
265 } \
│ │ │ │ -
266 return out; \
│ │ │ │ -
267 } \
│ │ │ │ -
268 template<class T, std::size_t S, std::size_t A> \
│ │ │ │ -
269 auto operator SYMBOL(const LoopSIMD<T,S,A> &v, \
│ │ │ │ -
270 const LoopSIMD<T,S,A> &w) { \
│ │ │ │ -
271 Simd::Mask<LoopSIMD<T,S,A>> out; \
│ │ │ │ -
272 DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
273 for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
274 out[i] = v[i] SYMBOL w[i]; \
│ │ │ │ -
275 } \
│ │ │ │ -
276 return out; \
│ │ │ │ -
277 } \
│ │ │ │ -
278 static_assert(true, "expecting ;")
│ │ │ │ -
│ │ │ │ -
279
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
286#undef DUNE_SIMD_LOOP_COMPARISON_OP
│ │ │ │ -
287
│ │ │ │ -
288 //Boolean operators
│ │ │ │ -
│ │ │ │ -
289#define DUNE_SIMD_LOOP_BOOLEAN_OP(SYMBOL) \
│ │ │ │ -
290 template<class T, std::size_t S, std::size_t A> \
│ │ │ │ -
291 auto operator SYMBOL(const LoopSIMD<T,S,A> &v, const Simd::Scalar<T> s) { \
│ │ │ │ -
292 Simd::Mask<LoopSIMD<T,S,A>> out; \
│ │ │ │ -
293 DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
294 for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
295 out[i] = v[i] SYMBOL s; \
│ │ │ │ -
296 } \
│ │ │ │ -
297 return out; \
│ │ │ │ -
298 } \
│ │ │ │ -
299 template<class T, std::size_t S, std::size_t A> \
│ │ │ │ -
300 auto operator SYMBOL(const Simd::Mask<T> s, const LoopSIMD<T,S,A> &v) { \
│ │ │ │ -
301 Simd::Mask<LoopSIMD<T,S,A>> out; \
│ │ │ │ -
302 DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
303 for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
304 out[i] = s SYMBOL v[i]; \
│ │ │ │ -
305 } \
│ │ │ │ -
306 return out; \
│ │ │ │ -
307 } \
│ │ │ │ -
308 template<class T, std::size_t S, std::size_t A> \
│ │ │ │ -
309 auto operator SYMBOL(const LoopSIMD<T,S,A> &v, \
│ │ │ │ -
310 const LoopSIMD<T,S,A> &w) { \
│ │ │ │ -
311 Simd::Mask<LoopSIMD<T,S,A>> out; \
│ │ │ │ -
312 DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ -
313 for(std::size_t i=0; i<S; i++){ \
│ │ │ │ -
314 out[i] = v[i] SYMBOL w[i]; \
│ │ │ │ -
315 } \
│ │ │ │ -
316 return out; \
│ │ │ │ -
317 } \
│ │ │ │ -
318 static_assert(true, "expecting ;")
│ │ │ │ -
│ │ │ │ -
319
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ -
322#undef DUNE_SIMD_LOOP_BOOLEAN_OP
│ │ │ │ -
323
│ │ │ │ -
324 //prints a given LoopSIMD
│ │ │ │ -
325 template<class T, std::size_t S, std::size_t A>
│ │ │ │ -
326 std::ostream& operator<< (std::ostream &os, const LoopSIMD<T,S,A> &v) {
│ │ │ │ -
327 os << "[";
│ │ │ │ -
328 for(std::size_t i=0; i<S-1; i++) {
│ │ │ │ -
329 os << v[i] << ", ";
│ │ │ │ -
330 }
│ │ │ │ -
331 os << v[S-1] << "]";
│ │ │ │ -
332 return os;
│ │ │ │ -
333 }
│ │ │ │ -
│ │ │ │ -
334
│ │ │ │ -
335 namespace Simd {
│ │ │ │ -
336 namespace Overloads {
│ │ │ │ -
337 /*
│ │ │ │ -
338 * Implementation/Overloads of the functions needed for
│ │ │ │ -
339 * SIMD-interface-compatibility
│ │ │ │ -
340 */
│ │ │ │ -
341
│ │ │ │ -
342 //Implementation of SIMD-interface-types
│ │ │ │ -
343 template<class T, std::size_t S, std::size_t A>
│ │ │ │ -
│ │ │ │ -
344 struct ScalarType<LoopSIMD<T,S,A>> {
│ │ │ │ - │ │ │ │ -
346 };
│ │ │ │ -
│ │ │ │ -
347
│ │ │ │ -
348 template<class U, class T, std::size_t S, std::size_t A>
│ │ │ │ -
│ │ │ │ -
349 struct RebindType<U, LoopSIMD<T,S,A>> {
│ │ │ │ - │ │ │ │ -
351 };
│ │ │ │ -
│ │ │ │ -
352
│ │ │ │ -
353 //Implementation of SIMD-interface-functionality
│ │ │ │ -
354 template<class T, std::size_t S, std::size_t A>
│ │ │ │ -
355 struct LaneCount<LoopSIMD<T,S,A>> : index_constant<S*lanes<T>()> {};
│ │ │ │ -
356
│ │ │ │ -
357 template<class T, std::size_t S, std::size_t A>
│ │ │ │ -
│ │ │ │ -
358 auto lane(ADLTag<5>, std::size_t l, LoopSIMD<T,S,A> &&v)
│ │ │ │ -
359 -> decltype(std::move(Simd::lane(l%lanes<T>(), v[l/lanes<T>()])))
│ │ │ │ -
360 {
│ │ │ │ -
361 return std::move(Simd::lane(l%lanes<T>(), v[l/lanes<T>()]));
│ │ │ │ -
362 }
│ │ │ │ -
│ │ │ │ -
363
│ │ │ │ -
364 template<class T, std::size_t S, std::size_t A>
│ │ │ │ -
│ │ │ │ -
365 auto lane(ADLTag<5>, std::size_t l, const LoopSIMD<T,S,A> &v)
│ │ │ │ -
366 -> decltype(Simd::lane(l%lanes<T>(), v[l/lanes<T>()]))
│ │ │ │ -
367 {
│ │ │ │ -
368 return Simd::lane(l%lanes<T>(), v[l/lanes<T>()]);
│ │ │ │ -
369 }
│ │ │ │ -
│ │ │ │ -
370
│ │ │ │ -
371 template<class T, std::size_t S, std::size_t A>
│ │ │ │ -
│ │ │ │ -
372 auto lane(ADLTag<5>, std::size_t l, LoopSIMD<T,S,A> &v)
│ │ │ │ -
373 -> decltype(Simd::lane(l%lanes<T>(), v[l/lanes<T>()]))
│ │ │ │ -
374 {
│ │ │ │ -
375 return Simd::lane(l%lanes<T>(), v[l/lanes<T>()]);
│ │ │ │ -
376 }
│ │ │ │ -
│ │ │ │ -
377
│ │ │ │ -
378 template<class T, std::size_t S, std::size_t AM, std::size_t AD>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
380 LoopSIMD<T,S,AD> ifTrue, LoopSIMD<T,S,AD> ifFalse) {
│ │ │ │ - │ │ │ │ -
382 for(std::size_t i=0; i<S; i++) {
│ │ │ │ -
383 out[i] = Simd::cond(mask[i], ifTrue[i], ifFalse[i]);
│ │ │ │ -
384 }
│ │ │ │ -
385 return out;
│ │ │ │ -
386 }
│ │ │ │ -
│ │ │ │ -
387
│ │ │ │ -
388 template<class M, class T, std::size_t S, std::size_t A>
│ │ │ │ -
│ │ │ │ -
389 auto cond(ADLTag<5, std::is_same<bool, Simd::Scalar<M> >::value
│ │ │ │ -
390 && Simd::lanes<M>() == Simd::lanes<LoopSIMD<T,S,A> >()>,
│ │ │ │ -
391 M mask, LoopSIMD<T,S,A> ifTrue, LoopSIMD<T,S,A> ifFalse)
│ │ │ │ -
392 {
│ │ │ │ -
393 LoopSIMD<T,S,A> out;
│ │ │ │ -
394 for(auto l : range(Simd::lanes(mask)))
│ │ │ │ -
395 Simd::lane(l, out) = Simd::lane(l, mask) ? Simd::lane(l, ifTrue) : Simd::lane(l, ifFalse);
│ │ │ │ -
396 return out;
│ │ │ │ -
397 }
│ │ │ │ -
│ │ │ │ -
398
│ │ │ │ -
399 template<class M, std::size_t S, std::size_t A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
401 bool out = false;
│ │ │ │ -
402 for(std::size_t i=0; i<S; i++) {
│ │ │ │ -
403 out |= Simd::anyTrue(mask[i]);
│ │ │ │ -
404 }
│ │ │ │ -
405 return out;
│ │ │ │ -
406 }
│ │ │ │ -
│ │ │ │ -
407
│ │ │ │ -
408 template<class M, std::size_t S, std::size_t A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
410 bool out = true;
│ │ │ │ -
411 for(std::size_t i=0; i<S; i++) {
│ │ │ │ -
412 out &= Simd::allTrue(mask[i]);
│ │ │ │ -
413 }
│ │ │ │ -
414 return out;
│ │ │ │ -
415 }
│ │ │ │ -
│ │ │ │ -
416
│ │ │ │ -
417 template<class M, std::size_t S, std::size_t A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
419 bool out = false;
│ │ │ │ -
420 for(std::size_t i=0; i<S; i++) {
│ │ │ │ -
421 out |= Simd::anyFalse(mask[i]);
│ │ │ │ -
422 }
│ │ │ │ -
423 return out;
│ │ │ │ -
424 }
│ │ │ │ -
│ │ │ │ -
425
│ │ │ │ -
426 template<class M, std::size_t S, std::size_t A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
428 bool out = true;
│ │ │ │ -
429 for(std::size_t i=0; i<S; i++) {
│ │ │ │ -
430 out &= Simd::allFalse(mask[i]);
│ │ │ │ -
431 }
│ │ │ │ -
432 return out;
│ │ │ │ -
433 }
│ │ │ │ -
│ │ │ │ -
434 } //namespace Overloads
│ │ │ │ -
435
│ │ │ │ -
436 } //namespace Simd
│ │ │ │ -
437
│ │ │ │ -
438
│ │ │ │ -
439 /*
│ │ │ │ -
440 * Overloads the unary cmath-operations. Operations requiring
│ │ │ │ -
441 * or returning more than one argument are not supported.
│ │ │ │ -
442 * Due to inconsistency with the return values, cmath-operations
│ │ │ │ -
443 * on integral types are also not supported-
│ │ │ │ -
444 */
│ │ │ │ -
445
│ │ │ │ -
│ │ │ │ -
446#define DUNE_SIMD_LOOP_CMATH_UNARY_OP(expr) \
│ │ │ │ -
447 template<class T, std::size_t S, std::size_t A, typename Sfinae = \
│ │ │ │ -
448 typename std::enable_if_t<!std::is_integral<Simd::Scalar<T>>::value> > \
│ │ │ │ -
449 auto expr(const LoopSIMD<T,S,A> &v) { \
│ │ │ │ -
450 using std::expr; \
│ │ │ │ -
451 LoopSIMD<T,S,A> out; \
│ │ │ │ -
452 for(std::size_t i=0; i<S; i++) { \
│ │ │ │ -
453 out[i] = expr(v[i]); \
│ │ │ │ -
454 } \
│ │ │ │ -
455 return out; \
│ │ │ │ -
456 } \
│ │ │ │ -
457 static_assert(true, "expecting ;")
│ │ │ │ -
│ │ │ │ -
458
│ │ │ │ -
│ │ │ │ -
459#define DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN(expr, returnType) \
│ │ │ │ -
460 template<class T, std::size_t S, std::size_t A, typename Sfinae = \
│ │ │ │ -
461 typename std::enable_if_t<!std::is_integral<Simd::Scalar<T>>::value> > \
│ │ │ │ -
462 auto expr(const LoopSIMD<T,S,A> &v) { \
│ │ │ │ -
463 using std::expr; \
│ │ │ │ -
464 LoopSIMD<returnType,S> out; \
│ │ │ │ -
465 for(std::size_t i=0; i<S; i++) { \
│ │ │ │ -
466 out[i] = expr(v[i]); \
│ │ │ │ -
467 } \
│ │ │ │ -
468 return out; \
│ │ │ │ -
469 } \
│ │ │ │ -
470 static_assert(true, "expecting ;")
│ │ │ │ -
│ │ │ │ -
471
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
484
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
494
│ │ │ │ - │ │ │ │ - │ │ │ │ -
497
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
502
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
513
│ │ │ │ - │ │ │ │ - │ │ │ │ -
516
│ │ │ │ -
517#undef DUNE_SIMD_LOOP_CMATH_UNARY_OP
│ │ │ │ -
518#undef DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN
│ │ │ │ -
519
│ │ │ │ -
520
│ │ │ │ -
521 /* not implemented cmath-functions:
│ │ │ │ -
522 * atan2
│ │ │ │ -
523 * frexp, idexp
│ │ │ │ -
524 * modf
│ │ │ │ -
525 * scalbn, scalbln
│ │ │ │ -
526 * pow
│ │ │ │ -
527 * hypot
│ │ │ │ -
528 * remainder, remquo
│ │ │ │ -
529 * copysign
│ │ │ │ -
530 * nan
│ │ │ │ -
531 * nextafter, nexttoward
│ │ │ │ -
532 * fdim, fmax, fmin
│ │ │ │ -
533 */
│ │ │ │ -
534
│ │ │ │ -
535 /*
│ │ │ │ -
536 * Overloads specific functions usually provided by the std library
│ │ │ │ -
537 * More overloads will be provided should the need arise.
│ │ │ │ -
538 */
│ │ │ │ -
539
│ │ │ │ -
│ │ │ │ -
540#define DUNE_SIMD_LOOP_STD_UNARY_OP(expr) \
│ │ │ │ -
541 template<class T, std::size_t S, std::size_t A> \
│ │ │ │ -
542 auto expr(const LoopSIMD<T,S,A> &v) { \
│ │ │ │ -
543 using std::expr; \
│ │ │ │ -
544 LoopSIMD<T,S,A> out; \
│ │ │ │ -
545 for(std::size_t i=0; i<S; i++) { \
│ │ │ │ -
546 out[i] = expr(v[i]); \
│ │ │ │ -
547 } \
│ │ │ │ -
548 return out; \
│ │ │ │ -
549 } \
│ │ │ │ -
550 \
│ │ │ │ -
551 template<class T, std::size_t S, std::size_t A> \
│ │ │ │ -
552 auto expr(const LoopSIMD<std::complex<T>,S,A> &v) { \
│ │ │ │ -
553 using std::expr; \
│ │ │ │ -
554 LoopSIMD<T,S,A> out; \
│ │ │ │ -
555 for(std::size_t i=0; i<S; i++) { \
│ │ │ │ -
556 out[i] = expr(v[i]); \
│ │ │ │ -
557 } \
│ │ │ │ -
558 return out; \
│ │ │ │ -
559 } \
│ │ │ │ -
560 static_assert(true, "expecting ;")
│ │ │ │ -
│ │ │ │ -
561
│ │ │ │ - │ │ │ │ - │ │ │ │ -
564
│ │ │ │ -
565#undef DUNE_SIMD_LOOP_STD_UNARY_OP
│ │ │ │ -
566
│ │ │ │ -
│ │ │ │ -
567#define DUNE_SIMD_LOOP_STD_BINARY_OP(expr) \
│ │ │ │ -
568 template<class T, std::size_t S, std::size_t A> \
│ │ │ │ -
569 auto expr(const LoopSIMD<T,S,A> &v, const LoopSIMD<T,S,A> &w) { \
│ │ │ │ -
570 using std::expr; \
│ │ │ │ -
571 LoopSIMD<T,S,A> out; \
│ │ │ │ -
572 for(std::size_t i=0; i<S; i++) { \
│ │ │ │ -
573 out[i] = expr(v[i],w[i]); \
│ │ │ │ -
574 } \
│ │ │ │ -
575 return out; \
│ │ │ │ -
576 } \
│ │ │ │ -
577 static_assert(true, "expecting ;")
│ │ │ │ -
│ │ │ │ -
578
│ │ │ │ - │ │ │ │ - │ │ │ │ -
581
│ │ │ │ -
582#undef DUNE_SIMD_LOOP_STD_BINARY_OP
│ │ │ │ -
583
│ │ │ │ -
584 namespace MathOverloads {
│ │ │ │ -
585 template<class T, std::size_t S, std::size_t A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ -
588 for(auto l : range(S))
│ │ │ │ -
589 out[l] = Dune::isNaN(v[l]);
│ │ │ │ -
590 return out;
│ │ │ │ -
591 }
│ │ │ │ -
│ │ │ │ -
592
│ │ │ │ -
593 template<class T, std::size_t S, std::size_t A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ -
596 for(auto l : range(S))
│ │ │ │ -
597 out[l] = Dune::isInf(v[l]);
│ │ │ │ -
598 return out;
│ │ │ │ -
599 }
│ │ │ │ -
│ │ │ │ -
600
│ │ │ │ -
601 template<class T, std::size_t S, std::size_t A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ -
604 for(auto l : range(S))
│ │ │ │ -
605 out[l] = Dune::isFinite(v[l]);
│ │ │ │ -
606 return out;
│ │ │ │ -
607 }
│ │ │ │ -
│ │ │ │ -
608 } //namespace MathOverloads
│ │ │ │ -
609
│ │ │ │ -
610 template<class T, std::size_t S, std::size_t A>
│ │ │ │ -
│ │ │ │ -
611 struct IsNumber<LoopSIMD<T,S,A>> :
│ │ │ │ -
612 public std::integral_constant<bool, IsNumber<T>::value>{
│ │ │ │ -
613 };
│ │ │ │ -
│ │ │ │ -
614
│ │ │ │ -
615#ifdef CLANG_WARNING_DISABLED
│ │ │ │ -
616# pragma clang diagnostic pop
│ │ │ │ -
617# undef CLANG_WARNING_DISABLED
│ │ │ │ -
618#endif
│ │ │ │ -
619
│ │ │ │ -
620#ifdef GCC_WARNING_DISABLED
│ │ │ │ -
621# pragma GCC diagnostic pop
│ │ │ │ -
622# undef GCC_WARNING_DISABLED
│ │ │ │ -
623#endif
│ │ │ │ -
624
│ │ │ │ -
625} //namespace Dune
│ │ │ │ -
626
│ │ │ │ -
627#endif
│ │ │ │ -
#define DUNE_SIMD_LOOP_BINARY_OP(SYMBOL)
Definition loop.hh:177
│ │ │ │ -
#define DUNE_SIMD_LOOP_BOOLEAN_OP(SYMBOL)
Definition loop.hh:289
│ │ │ │ -
#define DUNE_SIMD_LOOP_STD_BINARY_OP(expr)
Definition loop.hh:567
│ │ │ │ -
#define DUNE_SIMD_LOOP_STD_UNARY_OP(expr)
Definition loop.hh:540
│ │ │ │ -
#define DUNE_SIMD_LOOP_BITSHIFT_OP(SYMBOL)
Definition loop.hh:221
│ │ │ │ -
#define DUNE_SIMD_LOOP_CMATH_UNARY_OP(expr)
Definition loop.hh:446
│ │ │ │ -
#define DUNE_PRAGMA_OMP_SIMD
Definition loop.hh:49
│ │ │ │ -
#define DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN(expr, returnType)
Definition loop.hh:459
│ │ │ │ -
#define DUNE_SIMD_LOOP_ASSIGNMENT_OP(SYMBOL)
Definition loop.hh:145
│ │ │ │ -
Some useful basic math stuff.
│ │ │ │ -
Traits for type conversions and type information.
│ │ │ │ -
std::integral_constant< std::size_t, i > index_constant
An index constant with value i.
Definition indices.hh:29
│ │ │ │ -
static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from >, std::integral_constant< T, to >) noexcept
Definition rangeutilities.hh:312
│ │ │ │ -
std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x)
Definition bigunsignedint.hh:278
│ │ │ │ -
bool anyTrue(const Mask &mask)
Whether any entry is true
Definition simd/interface.hh:429
│ │ │ │ -
V cond(M &&mask, const V &ifTrue, const V &ifFalse)
Like the ?: operator.
Definition simd/interface.hh:386
│ │ │ │ -
bool allTrue(const Mask &mask)
Whether all entries are true
Definition simd/interface.hh:439
│ │ │ │ -
bool anyFalse(const Mask &mask)
Whether any entry is false
Definition simd/interface.hh:449
│ │ │ │ -
constexpr std::size_t lanes()
Number of lanes in a SIMD type.
Definition simd/interface.hh:305
│ │ │ │ -
decltype(auto) lane(std::size_t l, V &&v)
Extract an element of a SIMD type.
Definition simd/interface.hh:324
│ │ │ │ -
Rebind< bool, V > Mask
Mask type type of some SIMD type.
Definition simd/interface.hh:289
│ │ │ │ -
bool allFalse(const Mask &mask)
Whether all entries are false
Definition simd/interface.hh:459
│ │ │ │ -
typename Overloads::ScalarType< std::decay_t< V > >::type Scalar
Element type of some SIMD type.
Definition simd/interface.hh:235
│ │ │ │ -
Mask< V > mask(ADLTag< 0, std::is_same< V, Mask< V > >::value >, const V &v)
implements Simd::mask()
Definition defaults.hh:153
│ │ │ │ -
bool allFalse(ADLTag< 0 >, const Mask &mask)
implements Simd::allFalse()
Definition defaults.hh:124
│ │ │ │ -
bool allTrue(ADLTag< 0 >, const Mask &mask)
implements Simd::allTrue()
Definition defaults.hh:104
│ │ │ │ -
bool anyFalse(ADLTag< 0 >, const Mask &mask)
implements Simd::anyFalse()
Definition defaults.hh:114
│ │ │ │ -
STL namespace.
│ │ │ │ +
121
│ │ │ │ +
122
│ │ │ │ +
123// ********************************************************************************
│ │ │ │ +
124// C++11 support
│ │ │ │ +
125// ********************************************************************************
│ │ │ │ +
126
│ │ │ │ +
127// import std::hash into Dune namespace
│ │ │ │ +
128namespace Dune {
│ │ │ │ +
129
│ │ │ │ +
130 using std::hash;
│ │ │ │ +
131
│ │ │ │ +
132}
│ │ │ │ +
133
│ │ │ │ +
134// Macro for defining a std::hash specialization for type.
│ │ │ │ +
135// This should not be called directly. Call DUNE_DEFINE_HASH
│ │ │ │ +
136// instead.
│ │ │ │ +
137#define DUNE_DEFINE_STD_HASH(template_args,type) \
│ │ │ │ +
138 namespace std { \
│ │ │ │ +
139 \
│ │ │ │ +
140 template<template_args> \
│ │ │ │ +
141 struct hash<type> \
│ │ │ │ +
142 { \
│ │ │ │ +
143 \
│ │ │ │ +
144 typedef type argument_type; \
│ │ │ │ +
145 typedef std::size_t result_type; \
│ │ │ │ +
146 \
│ │ │ │ +
147 std::size_t operator()(const type& arg) const \
│ │ │ │ +
148 { \
│ │ │ │ +
149 return hash_value(arg); \
│ │ │ │ +
150 } \
│ │ │ │ +
151 }; \
│ │ │ │ +
152 \
│ │ │ │ +
153 template<template_args> \
│ │ │ │ +
154 struct hash<const type> \
│ │ │ │ +
155 { \
│ │ │ │ +
156 \
│ │ │ │ +
157 typedef type argument_type; \
│ │ │ │ +
158 typedef std::size_t result_type; \
│ │ │ │ +
159 \
│ │ │ │ +
160 std::size_t operator()(const type& arg) const \
│ │ │ │ +
161 { \
│ │ │ │ +
162 return hash_value(arg); \
│ │ │ │ +
163 } \
│ │ │ │ +
164 }; \
│ │ │ │ +
165 \
│ │ │ │ +
166 } \
│ │ │ │ +
167
│ │ │ │ +
168// Wrapper macro for template arguments.
│ │ │ │ +
169// This is required because the template arguments can contain commas,
│ │ │ │ +
170// which will create a macro argument list of unknown length. That in itself
│ │ │ │ +
171// would not be a problem, but DUNE_DEFINE_HASH has to be called with two argument
│ │ │ │ +
172// lists of unknown length. So this macro wraps its arguments with parentheses,
│ │ │ │ +
173// turning it into a single argument. The result is used as the parameter list of
│ │ │ │ +
174// an expansion macro in the calls to the implementation-specific macros
│ │ │ │ +
175// for C++11 and TR1. Noto that technically, this trick is only legal for C++11,
│ │ │ │ +
176// but pretty much every compiler supports variadic macros in C++03 mode, as they
│ │ │ │ +
177// are part of C99.
│ │ │ │ +
178#define DUNE_HASH_TEMPLATE_ARGS(...) (__VA_ARGS__)
│ │ │ │ +
179
│ │ │ │ +
180// Wrapper macro for type to be hashed.
│ │ │ │ +
181// See above for rationale.
│ │ │ │ +
182#define DUNE_HASH_TYPE(...) (__VA_ARGS__)
│ │ │ │ +
183
│ │ │ │ +
184// Expansion macro for the parenthesized argument lists created by
│ │ │ │ +
185// DUNE_HASH_TEMPLATE_ARGS and DUNE_HASH_TYPE.
│ │ │ │ +
186#define DUNE_HASH_EXPAND_VA_ARGS(...) __VA_ARGS__
│ │ │ │ +
187
│ │ │ │ +
188// Define specializations for all discovered hash implementations.
│ │ │ │ +
189#define DUNE_DEFINE_HASH(template_args,type) \
│ │ │ │ +
190 DUNE_DEFINE_STD_HASH(DUNE_HASH_EXPAND_VA_ARGS template_args, DUNE_HASH_EXPAND_VA_ARGS type) \
│ │ │ │ +
191
│ │ │ │ +
192
│ │ │ │ +
193#endif // DOXYGEN
│ │ │ │ +
194
│ │ │ │ +
195
│ │ │ │ +
196
│ │ │ │ +
197// ********************************************************************************
│ │ │ │ +
198// Some utility functions for combining hashes of member variables.
│ │ │ │ +
199// ********************************************************************************
│ │ │ │ +
200
│ │ │ │ +
201namespace Dune {
│ │ │ │ +
202
│ │ │ │ +
203 // The following functions are an implementation of the proposed hash extensions for
│ │ │ │ +
204 // the C++ standard by Peter Dimov
│ │ │ │ +
205 // (cf. http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf, issue 6.18).
│ │ │ │ +
206 // They are also contained in the boost::functional::hash library by Daniel James, but
│ │ │ │ +
207 // that implementation uses boost::hash internally, while we want to use Dune::hash. They
│ │ │ │ +
208 // are also considered for inclusion in TR2 (then based on std::hash, of course).
│ │ │ │ +
209
│ │ │ │ +
210#ifndef DOXYGEN
│ │ │ │ +
211
│ │ │ │ +
212 // helper struct for providing different hash combining algorithms dependent on
│ │ │ │ +
213 // the size of size_t.
│ │ │ │ +
214 // hash_combiner has to be specialized for the size (in bytes) of std::size_t.
│ │ │ │ +
215 // Specialized versions should provide a method
│ │ │ │ +
216 //
│ │ │ │ +
217 // template <typename typeof_size_t, typename T>
│ │ │ │ +
218 // void operator()(typeof_size_t& seed, const T& arg) const;
│ │ │ │ +
219 //
│ │ │ │ +
220 // that will be called by the interface function hash_combine() described further below.
│ │ │ │ +
221 // The redundant template parameter typeof_size_t is needed to avoid warnings for the
│ │ │ │ +
222 // unused 64-bit specialization on 32-bit systems.
│ │ │ │ +
223 //
│ │ │ │ +
224 // There is no default implementation!
│ │ │ │ +
225 template<int sizeof_size_t>
│ │ │ │ +
226 struct hash_combiner;
│ │ │ │ +
227
│ │ │ │ +
228
│ │ │ │ +
229 // hash combining for 64-bit platforms.
│ │ │ │ +
230 template<>
│ │ │ │ +
231 struct hash_combiner<8>
│ │ │ │ +
232 {
│ │ │ │ +
233
│ │ │ │ +
234 template<typename typeof_size_t, typename T>
│ │ │ │ +
235 void operator()(typeof_size_t& seed, const T& arg) const
│ │ │ │ +
236 {
│ │ │ │ +
237 static_assert(sizeof(typeof_size_t)==8, "hash_combiner::operator() instantiated with nonmatching type and size");
│ │ │ │ +
238
│ │ │ │ +
239 // The following algorithm for combining two 64-bit hash values is inspired by a similar
│ │ │ │ +
240 // function in CityHash (http://cityhash.googlecode.com/svn-history/r2/trunk/src/city.h),
│ │ │ │ +
241 // which is in turn based on ideas from the MurmurHash library. The basic idea is easy to
│ │ │ │ +
242 // grasp, though: New information is XORed into the existing hash multiple times at different
│ │ │ │ +
243 // places (using shift operations), and the resulting pattern is spread over the complete
│ │ │ │ +
244 // range of available bits via multiplication with a "magic" constant. The constants used
│ │ │ │ +
245 // below (47 and 0x9ddfea08eb382d69ULL) are taken from the CityHash implementation.
│ │ │ │ +
246 //
│ │ │ │ +
247 // We opted not to use the mixing algorithm proposed in the C++ working group defect list at
│ │ │ │ +
248 // http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf, p. 57f. because it
│ │ │ │ +
249 // has very bad hash distribution properties if you apply it to lists of very small numbers,
│ │ │ │ +
250 // an application that is frequent in PDELab's ordering framework.
│ │ │ │ +
251
│ │ │ │ +
252 Dune::hash<T> hasher;
│ │ │ │ +
253 const typeof_size_t kMul = 0x9ddfea08eb382d69ULL;
│ │ │ │ +
254 typeof_size_t h = hasher(arg);
│ │ │ │ +
255 typeof_size_t a = (seed ^ h) * kMul;
│ │ │ │ +
256 a ^= (a >> 47);
│ │ │ │ +
257 typeof_size_t b = (h ^ a) * kMul;
│ │ │ │ +
258 b ^= (b >> 47);
│ │ │ │ +
259 b *= kMul;
│ │ │ │ +
260 seed = b;
│ │ │ │ +
261 }
│ │ │ │ +
262
│ │ │ │ +
263 };
│ │ │ │ +
264
│ │ │ │ +
265
│ │ │ │ +
266 // hash combining for 32-bit platforms.
│ │ │ │ +
267 template<>
│ │ │ │ +
268 struct hash_combiner<4>
│ │ │ │ +
269 {
│ │ │ │ +
270
│ │ │ │ +
271 template<typename typeof_size_t, typename T>
│ │ │ │ +
272 void operator()(typeof_size_t& seed, const T& arg) const
│ │ │ │ +
273 {
│ │ │ │ +
274 static_assert(sizeof(typeof_size_t)==4, "hash_combiner::operator() instantiated with nonmatching type and size");
│ │ │ │ +
275
│ │ │ │ +
276 // The default algorithm above requires a 64-bit std::size_t. The following algorithm is a
│ │ │ │ +
277 // 32-bit compatible fallback, again inspired by CityHash and MurmurHash
│ │ │ │ +
278 // (http://cityhash.googlecode.com/svn-history/r2/trunk/src/city.cc).
│ │ │ │ +
279 // It uses 32-bit constants and relies on rotation instead of multiplication to spread the
│ │ │ │ +
280 // mixed bits as that is apparently more efficient on IA-32. The constants used below are again
│ │ │ │ +
281 // taken from CityHash, in particular from the file referenced above.
│ │ │ │ +
282
│ │ │ │ +
283 Dune::hash<T> hasher;
│ │ │ │ +
284 const typeof_size_t c1 = 0xcc9e2d51;
│ │ │ │ +
285 const typeof_size_t c2 = 0x1b873593;
│ │ │ │ +
286 const typeof_size_t c3 = 0xe6546b64;
│ │ │ │ +
287 typeof_size_t h = hasher(arg);
│ │ │ │ +
288 typeof_size_t a = seed * c1;
│ │ │ │ +
289 a = (a >> 17) | (a << (32 - 17));
│ │ │ │ +
290 a *= c2;
│ │ │ │ +
291 h ^= a;
│ │ │ │ +
292 h = (h >> 19) | (h << (32 - 19));
│ │ │ │ +
293 seed = h * 5 + c3;
│ │ │ │ +
294 }
│ │ │ │ +
295
│ │ │ │ +
296 };
│ │ │ │ +
297
│ │ │ │ +
298#endif // DOXYGEN
│ │ │ │ +
299
│ │ │ │ +
301
│ │ │ │ +
306 template<typename T>
│ │ │ │ +
│ │ │ │ +
307 inline void hash_combine(std::size_t& seed, const T& arg)
│ │ │ │ +
308 {
│ │ │ │ +
309 hash_combiner<sizeof(std::size_t)>()(seed,arg);
│ │ │ │ +
310 }
│ │ │ │ +
│ │ │ │ +
311
│ │ │ │ +
313
│ │ │ │ +
321 template<typename It>
│ │ │ │ +
│ │ │ │ +
322 inline std::size_t hash_range(It first, It last)
│ │ │ │ +
323 {
│ │ │ │ +
324 std::size_t seed = 0;
│ │ │ │ +
325 for (; first != last; ++first)
│ │ │ │ +
326 {
│ │ │ │ +
327 hash_combine(seed,*first);
│ │ │ │ +
328 }
│ │ │ │ +
329 return seed;
│ │ │ │ +
330 }
│ │ │ │ +
│ │ │ │ +
331
│ │ │ │ +
333
│ │ │ │ +
340 template<typename It>
│ │ │ │ +
│ │ │ │ +
341 inline void hash_range(std::size_t& seed, It first, It last)
│ │ │ │ +
342 {
│ │ │ │ +
343 for (; first != last; ++first)
│ │ │ │ +
344 {
│ │ │ │ +
345 hash_combine(seed,*first);
│ │ │ │ +
346 }
│ │ │ │ +
347 }
│ │ │ │ +
│ │ │ │ +
348
│ │ │ │ +
349} // end namespace Dune
│ │ │ │ +
350
│ │ │ │ +
351#endif // DUNE_COMMON_HASH_HH
│ │ │ │ +
Traits for type conversions and type information.
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
DUNE_SIMD_LOOP_COMPARISON_OP(<)
│ │ │ │ -
bool anyTrue(ADLTag< 5 >, const AlignedNumber< bool, align > &mask)
Definition debugalign.hh:556
│ │ │ │ -
const AlignedNumber< T, align > & cond(ADLTag< 5 >, AlignedNumber< bool, align > mask, const AlignedNumber< T, align > &ifTrue, const AlignedNumber< T, align > &ifFalse)
Definition debugalign.hh:548
│ │ │ │ -
T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v)
Definition debugalign.hh:533
│ │ │ │ -
bool isNaN(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag)
Returns whether any entry is NaN.
Definition fvector.hh:627
│ │ │ │ -
bool isInf(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag)
Returns whether any entry is infinite.
Definition fvector.hh:615
│ │ │ │ -
auto isFinite(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag)
Returns whether all entries are finite.
Definition fvector.hh:604
│ │ │ │ -
Whether this type acts as a scalar in the context of (hierarchically blocked) containers.
Definition typetraits.hh:194
│ │ │ │ -
Tag to make sure the functions in this namespace can be found by ADL.
Definition math.hh:230
│ │ │ │ -
Tag used to force late-binding lookup in Dune::Simd::Overloads.
Definition base.hh:182
│ │ │ │ -
should have a member type type
Definition standard.hh:60
│ │ │ │ -
should have a member type type
Definition standard.hh:67
│ │ │ │ -
should be derived from a Dune::index_constant
Definition standard.hh:74
│ │ │ │ -
Definition loop.hh:65
│ │ │ │ -
LoopSIMD(Simd::Scalar< T > i)
Definition loop.hh:75
│ │ │ │ -
DUNE_SIMD_LOOP_PREFIX_OP(++)
│ │ │ │ -
auto operator!() const
Definition loop.hh:121
│ │ │ │ -
DUNE_SIMD_LOOP_POSTFIX_OP(--)
│ │ │ │ -
DUNE_SIMD_LOOP_ASSIGNMENT_OP * DUNE_SIMD_LOOP_ASSIGNMENT_OP(/=);DUNE_SIMD_LOOP_ASSIGNMENT_OP(%=
│ │ │ │ -
DUNE_SIMD_LOOP_ASSIGNMENT_OP & DUNE_SIMD_LOOP_ASSIGNMENT_OP(|=);DUNE_SIMD_LOOP_ASSIGNMENT_OP(^=
│ │ │ │ -
DUNE_SIMD_LOOP_UNARY_OP(-)
│ │ │ │ -
DUNE_SIMD_LOOP_PREFIX_OP(--)
│ │ │ │ -
DUNE_SIMD_LOOP_POSTFIX_OP(++)
│ │ │ │ -
DUNE_SIMD_LOOP_ASSIGNMENT_OP(-=)
│ │ │ │ -
LoopSIMD(const LoopSIMD< T, S, OA > &other)
Definition loop.hh:80
│ │ │ │ -
LoopSIMD()
Definition loop.hh:70
│ │ │ │ -
DUNE_SIMD_LOOP_UNARY_OP(~)
│ │ │ │ -
DUNE_SIMD_LOOP_ASSIGNMENT_OP(+=)
│ │ │ │ -
DUNE_SIMD_LOOP_UNARY_OP(+)
│ │ │ │ -
DUNE_SIMD_LOOP_ASSIGNMENT_OP(<<=)
│ │ │ │ -
DUNE_SIMD_LOOP_ASSIGNMENT_OP(> >=)
│ │ │ │ -
Simd::Scalar< T > type
Definition loop.hh:345
│ │ │ │ -
Helper class for tagging priorities.
Definition typeutilities.hh:73
│ │ │ │ -
Include file for users of the SIMD abstraction layer.
│ │ │ │ +
std::size_t hash_range(It first, It last)
Hashes all elements in the range [first,last) and returns the combined hash.
Definition hash.hh:322
│ │ │ │ +
void hash_combine(std::size_t &seed, const T &arg)
Calculates the hash value of arg and combines it in-place with seed.
Definition hash.hh:307
│ │ │ │ +
Functor for hashing objects of type T.
Definition hash.hh:40
│ │ │ │ +
std::size_t operator()(const T &t) const
Calculates the hash of t.
Definition hash.hh:43
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,824 +1,329 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * simd │ │ │ │ │ -loop.hh │ │ │ │ │ +hash.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ -1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ +1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ +2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ +3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ -2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -3#ifndef DUNE_COMMON_SIMD_LOOP_HH │ │ │ │ │ -4#define DUNE_COMMON_SIMD_LOOP_HH │ │ │ │ │ -5 │ │ │ │ │ -6#include │ │ │ │ │ -7#include │ │ │ │ │ -8#include │ │ │ │ │ -9#include │ │ │ │ │ -10#include │ │ │ │ │ -11#include │ │ │ │ │ -12 │ │ │ │ │ -13#include │ │ │ │ │ -14#include │ │ │ │ │ -15#include │ │ │ │ │ -16 │ │ │ │ │ -17namespace Dune { │ │ │ │ │ -18 │ │ │ │ │ -19 │ │ │ │ │ -20/* │ │ │ │ │ -21 * silence warnings from GCC about using integer operands on a bool │ │ │ │ │ -22 * (when instantiated for T=bool) │ │ │ │ │ -23 */ │ │ │ │ │ -24#if __GNUC__ >= 7 │ │ │ │ │ -25# pragma GCC diagnostic push │ │ │ │ │ -26# pragma GCC diagnostic ignored "-Wbool-operation" │ │ │ │ │ -27# pragma GCC diagnostic ignored "-Wint-in-bool-context" │ │ │ │ │ -28# define GCC_WARNING_DISABLED │ │ │ │ │ -29#endif │ │ │ │ │ -30 │ │ │ │ │ -31/* │ │ │ │ │ -32 * silence warnings from Clang about using bitwise operands on │ │ │ │ │ -33 * a bool (when instantiated for T=bool) │ │ │ │ │ -34 */ │ │ │ │ │ -35#ifdef __clang__ │ │ │ │ │ -36#if __has_warning("-Wbitwise-instead-of-logical") │ │ │ │ │ -37# pragma clang diagnostic push │ │ │ │ │ -38# pragma clang diagnostic ignored "-Wbitwise-instead-of-logical" │ │ │ │ │ -39# define CLANG_WARNING_DISABLED │ │ │ │ │ -40#endif │ │ │ │ │ -41#endif │ │ │ │ │ -42 │ │ │ │ │ -43/* │ │ │ │ │ -44 * Introduce a simd pragma if OpenMP is available in standard version >= 4 │ │ │ │ │ -45 */ │ │ │ │ │ -46#if _OPENMP >= 201307 │ │ │ │ │ -47 #define DUNE_PRAGMA_OMP_SIMD _Pragma("omp simd") │ │ │ │ │ -48#else │ │ │ │ │ -49 #define DUNE_PRAGMA_OMP_SIMD │ │ │ │ │ -50#endif │ │ │ │ │ +4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ +5#ifndef DUNE_COMMON_HASH_HH │ │ │ │ │ +6#define DUNE_COMMON_HASH_HH │ │ │ │ │ +7 │ │ │ │ │ +8#include │ │ │ │ │ +9 │ │ │ │ │ +10#include │ │ │ │ │ +11 │ │ │ │ │ +24/ │ │ │ │ │ +/ │ │ │ │ │ +******************************************************************************** │ │ │ │ │ +25// Doxygen documentation │ │ │ │ │ +26/ │ │ │ │ │ +/ │ │ │ │ │ +******************************************************************************** │ │ │ │ │ +27 │ │ │ │ │ +28#ifdef DOXYGEN │ │ │ │ │ +29 │ │ │ │ │ +30namespace Dune { │ │ │ │ │ +31 │ │ │ │ │ +33 │ │ │ │ │ +38 template │ │ │ │ │ +39 struct hash │ │ │ │ │ +40 { │ │ │ │ │ +41 │ │ │ │ │ +43 std::size_t operator()(const T& t) const │ │ │ │ │ +44 { │ │ │ │ │ +45 return hash(t); │ │ │ │ │ +46 } │ │ │ │ │ +47 │ │ │ │ │ +48 }; │ │ │ │ │ +49 │ │ │ │ │ +50} │ │ │ │ │ 51 │ │ │ │ │ -52 │ │ │ │ │ -64 template │ │ │ │ │ -65 class alignas(A==0?alignof(T):A) LoopSIMD : public std::array { │ │ │ │ │ -66 │ │ │ │ │ -67 public: │ │ │ │ │ -68 │ │ │ │ │ -69 //default constructor │ │ │ │ │ -70 LoopSIMD() { │ │ │ │ │ -71 assert(reinterpret_cast(this) % std::min(alignof │ │ │ │ │ -(LoopSIMD),alignof(std::max_align_t)) == 0); │ │ │ │ │ -72 } │ │ │ │ │ -73 │ │ │ │ │ -74 // broadcast constructor initializing the content with a given value │ │ │ │ │ -75 LoopSIMD(Simd::Scalar i) : LoopSIMD() { │ │ │ │ │ -76 this->fill(i); │ │ │ │ │ -77 } │ │ │ │ │ -78 │ │ │ │ │ -79 template │ │ │ │ │ -80 explicit LoopSIMD(const LoopSIMD& other) │ │ │ │ │ -81 : std::array(other) │ │ │ │ │ -82 { │ │ │ │ │ -83 assert(reinterpret_cast(this) % std::min(alignof │ │ │ │ │ -(LoopSIMD),alignof(std::max_align_t)) == 0); │ │ │ │ │ -84 } │ │ │ │ │ -85 │ │ │ │ │ -86 /* │ │ │ │ │ -87 * Definition of basic operators │ │ │ │ │ -88 */ │ │ │ │ │ -89 │ │ │ │ │ -90 //Prefix operators │ │ │ │ │ -91#define DUNE_SIMD_LOOP_PREFIX_OP(SYMBOL) \ │ │ │ │ │ -92 auto operator SYMBOL() { \ │ │ │ │ │ -93 DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -94 for(std::size_t i=0; i out; \ │ │ │ │ │ -109 DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -110 for(std::size_t i=0; i> out; │ │ │ │ │ -123 DUNE_PRAGMA_OMP_SIMD │ │ │ │ │ -124 for(std::size_t i=0; i out = *this; \ │ │ │ │ │ -135 SYMBOL(*this); \ │ │ │ │ │ -136 return out; \ │ │ │ │ │ -137 } \ │ │ │ │ │ -138 static_assert(true, "expecting ;") │ │ │ │ │ -139 │ │ │ │ │ -140 DUNE_SIMD_LOOP_POSTFIX_OP(++); │ │ │ │ │ -141 DUNE_SIMD_LOOP_POSTFIX_OP(--); │ │ │ │ │ -142#undef DUNE_SIMD_LOOP_POSTFIX_OP │ │ │ │ │ -143 │ │ │ │ │ -144 //Assignment operators │ │ │ │ │ -145#define DUNE_SIMD_LOOP_ASSIGNMENT_OP(SYMBOL) \ │ │ │ │ │ -146 auto operator SYMBOL(const Simd::Scalar s) { \ │ │ │ │ │ -147 DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -148 for(std::size_t i=0; i \ │ │ │ │ │ +141 struct hash \ │ │ │ │ │ +142 { \ │ │ │ │ │ +143 \ │ │ │ │ │ +144 typedef type argument_type; \ │ │ │ │ │ +145 typedef std::size_t result_type; \ │ │ │ │ │ +146 \ │ │ │ │ │ +147 std::size_t operator()(const type& arg) const \ │ │ │ │ │ +148 { \ │ │ │ │ │ +149 return hash_value(arg); \ │ │ │ │ │ 150 } \ │ │ │ │ │ -151 return *this; \ │ │ │ │ │ -152 } \ │ │ │ │ │ -153 \ │ │ │ │ │ -154 auto operator SYMBOL(const LoopSIMD &v) { \ │ │ │ │ │ -155 DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -156 for(std::size_t i=0; i>=); │ │ │ │ │ -170 DUNE_SIMD_LOOP_ASSIGNMENT_OP(&=); │ │ │ │ │ -171 DUNE_SIMD_LOOP_ASSIGNMENT_OP(|=); │ │ │ │ │ -172 DUNE_SIMD_LOOP_ASSIGNMENT_OP(^=); │ │ │ │ │ -173#undef DUNE_SIMD_LOOP_ASSIGNMENT_OP │ │ │ │ │ -174 }; │ │ │ │ │ -175 │ │ │ │ │ -176 //Arithmetic operators │ │ │ │ │ -177#define DUNE_SIMD_LOOP_BINARY_OP(SYMBOL) \ │ │ │ │ │ -178 template \ │ │ │ │ │ -179 auto operator SYMBOL(const LoopSIMD &v, const Simd::Scalar s) { \ │ │ │ │ │ -180 LoopSIMD out; \ │ │ │ │ │ -181 DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -182 for(std::size_t i=0; i \ │ │ │ │ │ -188 auto operator SYMBOL(const Simd::Scalar s, const LoopSIMD &v) { \ │ │ │ │ │ -189 LoopSIMD out; \ │ │ │ │ │ -190 DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -191 for(std::size_t i=0; i \ │ │ │ │ │ -197 auto operator SYMBOL(const LoopSIMD &v, \ │ │ │ │ │ -198 const LoopSIMD &w) { \ │ │ │ │ │ -199 LoopSIMD out; \ │ │ │ │ │ -200 DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -201 for(std::size_t i=0; i \ │ │ │ │ │ -223 auto operator SYMBOL(const LoopSIMD &v, const U s) { \ │ │ │ │ │ -224 LoopSIMD out; \ │ │ │ │ │ -225 DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -226 for(std::size_t i=0; i \ │ │ │ │ │ -232 auto operator SYMBOL(const LoopSIMD &v, \ │ │ │ │ │ -233 const LoopSIMD &w) { \ │ │ │ │ │ -234 LoopSIMD out; \ │ │ │ │ │ -235 DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -236 for(std::size_t i=0; i>); │ │ │ │ │ -245 │ │ │ │ │ -246#undef DUNE_SIMD_LOOP_BITSHIFT_OP │ │ │ │ │ -247 │ │ │ │ │ -248 //Comparison operators │ │ │ │ │ -249#define DUNE_SIMD_LOOP_COMPARISON_OP(SYMBOL) \ │ │ │ │ │ -250 template \ │ │ │ │ │ -251 auto operator SYMBOL(const LoopSIMD &v, const U s) { \ │ │ │ │ │ -252 Simd::Mask> out; \ │ │ │ │ │ -253 DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -254 for(std::size_t i=0; i \ │ │ │ │ │ -260 auto operator SYMBOL(const Simd::Scalar s, const LoopSIMD &v) { \ │ │ │ │ │ -261 Simd::Mask> out; \ │ │ │ │ │ -262 DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -263 for(std::size_t i=0; i \ │ │ │ │ │ -269 auto operator SYMBOL(const LoopSIMD &v, \ │ │ │ │ │ -270 const LoopSIMD &w) { \ │ │ │ │ │ -271 Simd::Mask> out; \ │ │ │ │ │ -272 DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -273 for(std::size_t i=0; i); │ │ │ │ │ -282 DUNE_SIMD_LOOP_COMPARISON_OP(<=); │ │ │ │ │ -283 DUNE_SIMD_LOOP_COMPARISON_OP(>=); │ │ │ │ │ -284 DUNE_SIMD_LOOP_COMPARISON_OP(==); │ │ │ │ │ -285 DUNE_SIMD_LOOP_COMPARISON_OP(!=); │ │ │ │ │ -286#undef DUNE_SIMD_LOOP_COMPARISON_OP │ │ │ │ │ -287 │ │ │ │ │ -288 //Boolean operators │ │ │ │ │ -289#define DUNE_SIMD_LOOP_BOOLEAN_OP(SYMBOL) \ │ │ │ │ │ -290 template \ │ │ │ │ │ -291 auto operator SYMBOL(const LoopSIMD &v, const Simd::Scalar s) { \ │ │ │ │ │ -292 Simd::Mask> out; \ │ │ │ │ │ -293 DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -294 for(std::size_t i=0; i \ │ │ │ │ │ -300 auto operator SYMBOL(const Simd::Mask s, const LoopSIMD &v) { \ │ │ │ │ │ -301 Simd::Mask> out; \ │ │ │ │ │ -302 DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -303 for(std::size_t i=0; i \ │ │ │ │ │ -309 auto operator SYMBOL(const LoopSIMD &v, \ │ │ │ │ │ -310 const LoopSIMD &w) { \ │ │ │ │ │ -311 Simd::Mask> out; \ │ │ │ │ │ -312 DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ -313 for(std::size_t i=0; i │ │ │ │ │ -326 std::ostream& operator<<_(std::ostream &os, const LoopSIMD &v) { │ │ │ │ │ -327 os << "["; │ │ │ │ │ -328 for(std::size_t i=0; i \ │ │ │ │ │ +154 struct hash \ │ │ │ │ │ +155 { \ │ │ │ │ │ +156 \ │ │ │ │ │ +157 typedef type argument_type; \ │ │ │ │ │ +158 typedef std::size_t result_type; \ │ │ │ │ │ +159 \ │ │ │ │ │ +160 std::size_t operator()(const type& arg) const \ │ │ │ │ │ +161 { \ │ │ │ │ │ +162 return hash_value(arg); \ │ │ │ │ │ +163 } \ │ │ │ │ │ +164 }; \ │ │ │ │ │ +165 \ │ │ │ │ │ +166 } \ │ │ │ │ │ +167 │ │ │ │ │ +168// Wrapper macro for template arguments. │ │ │ │ │ +169// This is required because the template arguments can contain commas, │ │ │ │ │ +170// which will create a macro argument list of unknown length. That in itself │ │ │ │ │ +171// would not be a problem, but DUNE_DEFINE_HASH has to be called with two │ │ │ │ │ +argument │ │ │ │ │ +172// lists of unknown length. So this macro wraps its arguments with │ │ │ │ │ +parentheses, │ │ │ │ │ +173// turning it into a single argument. The result is used as the parameter │ │ │ │ │ +list of │ │ │ │ │ +174// an expansion macro in the calls to the implementation-specific macros │ │ │ │ │ +175// for C++11 and TR1. Noto that technically, this trick is only legal for │ │ │ │ │ +C++11, │ │ │ │ │ +176// but pretty much every compiler supports variadic macros in C++03 mode, as │ │ │ │ │ +they │ │ │ │ │ +177// are part of C99. │ │ │ │ │ +178#define DUNE_HASH_TEMPLATE_ARGS(...) (__VA_ARGS__) │ │ │ │ │ +179 │ │ │ │ │ +180// Wrapper macro for type to be hashed. │ │ │ │ │ +181// See above for rationale. │ │ │ │ │ +182#define DUNE_HASH_TYPE(...) (__VA_ARGS__) │ │ │ │ │ +183 │ │ │ │ │ +184// Expansion macro for the parenthesized argument lists created by │ │ │ │ │ +185// DUNE_HASH_TEMPLATE_ARGS and DUNE_HASH_TYPE. │ │ │ │ │ +186#define DUNE_HASH_EXPAND_VA_ARGS(...) __VA_ARGS__ │ │ │ │ │ +187 │ │ │ │ │ +188// Define specializations for all discovered hash implementations. │ │ │ │ │ +189#define DUNE_DEFINE_HASH(template_args,type) \ │ │ │ │ │ +190 DUNE_DEFINE_STD_HASH(DUNE_HASH_EXPAND_VA_ARGS template_args, DUNE_HASH_ │ │ │ │ │ +EXPAND_VA_ARGS type) \ │ │ │ │ │ +191 │ │ │ │ │ +192 │ │ │ │ │ +193#endif // DOXYGEN │ │ │ │ │ +194 │ │ │ │ │ +195 │ │ │ │ │ +196 │ │ │ │ │ +197/ │ │ │ │ │ +/ │ │ │ │ │ +******************************************************************************** │ │ │ │ │ +198// Some utility functions for combining hashes of member variables. │ │ │ │ │ +199/ │ │ │ │ │ +/ │ │ │ │ │ +******************************************************************************** │ │ │ │ │ +200 │ │ │ │ │ +201namespace Dune { │ │ │ │ │ +202 │ │ │ │ │ +203 // The following functions are an implementation of the proposed hash │ │ │ │ │ +extensions for │ │ │ │ │ +204 // the C++ standard by Peter Dimov │ │ │ │ │ +205 // (cf. http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf, │ │ │ │ │ +issue 6.18). │ │ │ │ │ +206 // They are also contained in the boost::functional::hash library by Daniel │ │ │ │ │ +James, but │ │ │ │ │ +207 // that implementation uses boost::hash internally, while we want to use │ │ │ │ │ +Dune::hash. They │ │ │ │ │ +208 // are also considered for inclusion in TR2 (then based on std::hash, of │ │ │ │ │ +course). │ │ │ │ │ +209 │ │ │ │ │ +210#ifndef DOXYGEN │ │ │ │ │ +211 │ │ │ │ │ +212 // helper struct for providing different hash combining algorithms │ │ │ │ │ +dependent on │ │ │ │ │ +213 // the size of size_t. │ │ │ │ │ +214 // hash_combiner has to be specialized for the size (in bytes) of std:: │ │ │ │ │ +size_t. │ │ │ │ │ +215 // Specialized versions should provide a method │ │ │ │ │ +216 // │ │ │ │ │ +217 // template │ │ │ │ │ +218 // void operator()(typeof_size_t& seed, const T& arg) const; │ │ │ │ │ +219 // │ │ │ │ │ +220 // that will be called by the interface function hash_combine() described │ │ │ │ │ +further below. │ │ │ │ │ +221 // The redundant template parameter typeof_size_t is needed to avoid │ │ │ │ │ +warnings for the │ │ │ │ │ +222 // unused 64-bit specialization on 32-bit systems. │ │ │ │ │ +223 // │ │ │ │ │ +224 // There is no default implementation! │ │ │ │ │ +225 template │ │ │ │ │ +226 struct hash_combiner; │ │ │ │ │ +227 │ │ │ │ │ +228 │ │ │ │ │ +229 // hash combining for 64-bit platforms. │ │ │ │ │ +230 template<> │ │ │ │ │ +231 struct hash_combiner<8> │ │ │ │ │ +232 { │ │ │ │ │ +233 │ │ │ │ │ +234 template │ │ │ │ │ +235 void operator()(typeof_size_t& seed, const T& arg) const │ │ │ │ │ +236 { │ │ │ │ │ +237 static_assert(sizeof(typeof_size_t)==8, "hash_combiner::operator() │ │ │ │ │ +instantiated with nonmatching type and size"); │ │ │ │ │ +238 │ │ │ │ │ +239 // The following algorithm for combining two 64-bit hash values is inspired │ │ │ │ │ +by a similar │ │ │ │ │ +240 // function in CityHash (http://cityhash.googlecode.com/svn-history/r2/ │ │ │ │ │ +trunk/src/city.h), │ │ │ │ │ +241 // which is in turn based on ideas from the MurmurHash library. The basic │ │ │ │ │ +idea is easy to │ │ │ │ │ +242 // grasp, though: New information is XORed into the existing hash multiple │ │ │ │ │ +times at different │ │ │ │ │ +243 // places (using shift operations), and the resulting pattern is spread │ │ │ │ │ +over the complete │ │ │ │ │ +244 // range of available bits via multiplication with a "magic" constant. The │ │ │ │ │ +constants used │ │ │ │ │ +245 // below (47 and 0x9ddfea08eb382d69ULL) are taken from the CityHash │ │ │ │ │ +implementation. │ │ │ │ │ +246 // │ │ │ │ │ +247 // We opted not to use the mixing algorithm proposed in the C++ working │ │ │ │ │ +group defect list at │ │ │ │ │ +248 // http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf, p. │ │ │ │ │ +57f. because it │ │ │ │ │ +249 // has very bad hash distribution properties if you apply it to lists of │ │ │ │ │ +very small numbers, │ │ │ │ │ +250 // an application that is frequent in PDELab's ordering framework. │ │ │ │ │ +251 │ │ │ │ │ +252 Dune::hash hasher; │ │ │ │ │ +253 const typeof_size_t kMul = 0x9ddfea08eb382d69ULL; │ │ │ │ │ +254 typeof_size_t h = hasher(arg); │ │ │ │ │ +255 typeof_size_t a = (seed ^ h) * kMul; │ │ │ │ │ +256 a ^= (a >> 47); │ │ │ │ │ +257 typeof_size_t b = (h ^ a) * kMul; │ │ │ │ │ +258 b ^= (b >> 47); │ │ │ │ │ +259 b *= kMul; │ │ │ │ │ +260 seed = b; │ │ │ │ │ +261 } │ │ │ │ │ +262 │ │ │ │ │ +263 }; │ │ │ │ │ +264 │ │ │ │ │ +265 │ │ │ │ │ +266 // hash combining for 32-bit platforms. │ │ │ │ │ +267 template<> │ │ │ │ │ +268 struct hash_combiner<4> │ │ │ │ │ +269 { │ │ │ │ │ +270 │ │ │ │ │ +271 template │ │ │ │ │ +272 void operator()(typeof_size_t& seed, const T& arg) const │ │ │ │ │ +273 { │ │ │ │ │ +274 static_assert(sizeof(typeof_size_t)==4, "hash_combiner::operator() │ │ │ │ │ +instantiated with nonmatching type and size"); │ │ │ │ │ +275 │ │ │ │ │ +276 // The default algorithm above requires a 64-bit std::size_t. The following │ │ │ │ │ +algorithm is a │ │ │ │ │ +277 // 32-bit compatible fallback, again inspired by CityHash and MurmurHash │ │ │ │ │ +278 // (http://cityhash.googlecode.com/svn-history/r2/trunk/src/city.cc). │ │ │ │ │ +279 // It uses 32-bit constants and relies on rotation instead of │ │ │ │ │ +multiplication to spread the │ │ │ │ │ +280 // mixed bits as that is apparently more efficient on IA-32. The constants │ │ │ │ │ +used below are again │ │ │ │ │ +281 // taken from CityHash, in particular from the file referenced above. │ │ │ │ │ +282 │ │ │ │ │ +283 Dune::hash hasher; │ │ │ │ │ +284 const typeof_size_t c1 = 0xcc9e2d51; │ │ │ │ │ +285 const typeof_size_t c2 = 0x1b873593; │ │ │ │ │ +286 const typeof_size_t c3 = 0xe6546b64; │ │ │ │ │ +287 typeof_size_t h = hasher(arg); │ │ │ │ │ +288 typeof_size_t a = seed * c1; │ │ │ │ │ +289 a = (a >> 17) | (a << (32 - 17)); │ │ │ │ │ +290 a *= c2; │ │ │ │ │ +291 h ^= a; │ │ │ │ │ +292 h = (h >> 19) | (h << (32 - 19)); │ │ │ │ │ +293 seed = h * 5 + c3; │ │ │ │ │ +294 } │ │ │ │ │ +295 │ │ │ │ │ +296 }; │ │ │ │ │ +297 │ │ │ │ │ +298#endif // DOXYGEN │ │ │ │ │ +299 │ │ │ │ │ +301 │ │ │ │ │ +306 template │ │ │ │ │ +307 inline void hash_combine(std::size_t& seed, const T& arg) │ │ │ │ │ +308 { │ │ │ │ │ +309 hash_combiner()(seed,arg); │ │ │ │ │ +310 } │ │ │ │ │ +311 │ │ │ │ │ +313 │ │ │ │ │ +321 template │ │ │ │ │ +322 inline std::size_t hash_range(It first, It last) │ │ │ │ │ +323 { │ │ │ │ │ +324 std::size_t seed = 0; │ │ │ │ │ +325 for (; first != last; ++first) │ │ │ │ │ +326 { │ │ │ │ │ +327 hash_combine(seed,*first); │ │ │ │ │ +328 } │ │ │ │ │ +329 return seed; │ │ │ │ │ 330 } │ │ │ │ │ -331 os << v[S-1] << "]"; │ │ │ │ │ -332 return os; │ │ │ │ │ -333 } │ │ │ │ │ -334 │ │ │ │ │ -335 namespace Simd { │ │ │ │ │ -336 namespace Overloads { │ │ │ │ │ -337 /* │ │ │ │ │ -338 * Implementation/Overloads of the functions needed for │ │ │ │ │ -339 * SIMD-interface-compatibility │ │ │ │ │ -340 */ │ │ │ │ │ -341 │ │ │ │ │ -342 //Implementation of SIMD-interface-types │ │ │ │ │ -343 template │ │ │ │ │ -344 struct ScalarType> { │ │ │ │ │ -345 using type = Simd::Scalar; │ │ │ │ │ -346 }; │ │ │ │ │ -347 │ │ │ │ │ -348 template │ │ │ │ │ -349 struct RebindType> { │ │ │ │ │ -350 using type = LoopSIMD,S,A>; │ │ │ │ │ -351 }; │ │ │ │ │ -352 │ │ │ │ │ -353 //Implementation of SIMD-interface-functionality │ │ │ │ │ -354 template │ │ │ │ │ -355 struct LaneCount> : index_constant()> {}; │ │ │ │ │ -356 │ │ │ │ │ -357 template │ │ │ │ │ -358 auto lane(ADLTag<5>, std::size_t l, LoopSIMD &&v) │ │ │ │ │ -359 -> decltype(std::move(Simd::lane(l%lanes(), v[l/lanes()]))) │ │ │ │ │ -360 { │ │ │ │ │ -361 return std::move(Simd::lane(l%lanes(), v[l/lanes()])); │ │ │ │ │ -362 } │ │ │ │ │ -363 │ │ │ │ │ -364 template │ │ │ │ │ -365 auto lane(ADLTag<5>, std::size_t l, const LoopSIMD &v) │ │ │ │ │ -366 -> decltype(Simd::lane(l%lanes(), v[l/lanes()])) │ │ │ │ │ -367 { │ │ │ │ │ -368 return Simd::lane(l%lanes(), v[l/lanes()]); │ │ │ │ │ -369 } │ │ │ │ │ -370 │ │ │ │ │ -371 template │ │ │ │ │ -372 auto lane(ADLTag<5>, std::size_t l, LoopSIMD &v) │ │ │ │ │ -373 -> decltype(Simd::lane(l%lanes(), v[l/lanes()])) │ │ │ │ │ -374 { │ │ │ │ │ -375 return Simd::lane(l%lanes(), v[l/lanes()]); │ │ │ │ │ -376 } │ │ │ │ │ -377 │ │ │ │ │ -378 template │ │ │ │ │ -379 auto cond(ADLTag<5>, Simd::Mask> mask, │ │ │ │ │ -380 LoopSIMD ifTrue, LoopSIMD ifFalse) { │ │ │ │ │ -381 LoopSIMD out; │ │ │ │ │ -382 for(std::size_t i=0; i │ │ │ │ │ -389 auto cond(ADLTag<5, std::is_same >::value │ │ │ │ │ -390 && Simd::lanes() == Simd::lanes >()>, │ │ │ │ │ -391 M mask, LoopSIMD ifTrue, LoopSIMD ifFalse) │ │ │ │ │ -392 { │ │ │ │ │ -393 LoopSIMD out; │ │ │ │ │ -394 for(auto l : range(Simd::lanes(mask))) │ │ │ │ │ -395 Simd::lane(l, out) = Simd::lane(l, mask) ? Simd::lane(l, ifTrue) : Simd:: │ │ │ │ │ -lane(l, ifFalse); │ │ │ │ │ -396 return out; │ │ │ │ │ -397 } │ │ │ │ │ -398 │ │ │ │ │ -399 template │ │ │ │ │ -400 bool anyTrue(ADLTag<5>, LoopSIMD mask) { │ │ │ │ │ -401 bool out = false; │ │ │ │ │ -402 for(std::size_t i=0; i │ │ │ │ │ -409 bool allTrue(ADLTag<5>, LoopSIMD mask) { │ │ │ │ │ -410 bool out = true; │ │ │ │ │ -411 for(std::size_t i=0; i │ │ │ │ │ -418 bool anyFalse(ADLTag<5>, LoopSIMD mask) { │ │ │ │ │ -419 bool out = false; │ │ │ │ │ -420 for(std::size_t i=0; i │ │ │ │ │ -427 bool allFalse(ADLTag<5>, LoopSIMD mask) { │ │ │ │ │ -428 bool out = true; │ │ │ │ │ -429 for(std::size_t i=0; i>::value> > \ │ │ │ │ │ -449 auto expr(const LoopSIMD &v) { \ │ │ │ │ │ -450 using std::expr; \ │ │ │ │ │ -451 LoopSIMD out; \ │ │ │ │ │ -452 for(std::size_t i=0; i>::value> > \ │ │ │ │ │ -462 auto expr(const LoopSIMD &v) { \ │ │ │ │ │ -463 using std::expr; \ │ │ │ │ │ -464 LoopSIMD out; \ │ │ │ │ │ -465 for(std::size_t i=0; i \ │ │ │ │ │ -542 auto expr(const LoopSIMD &v) { \ │ │ │ │ │ -543 using std::expr; \ │ │ │ │ │ -544 LoopSIMD out; \ │ │ │ │ │ -545 for(std::size_t i=0; i \ │ │ │ │ │ -552 auto expr(const LoopSIMD,S,A> &v) { \ │ │ │ │ │ -553 using std::expr; \ │ │ │ │ │ -554 LoopSIMD out; \ │ │ │ │ │ -555 for(std::size_t i=0; i \ │ │ │ │ │ -569 auto expr(const LoopSIMD &v, const LoopSIMD &w) { \ │ │ │ │ │ -570 using std::expr; \ │ │ │ │ │ -571 LoopSIMD out; \ │ │ │ │ │ -572 for(std::size_t i=0; i │ │ │ │ │ -586 auto isNaN(const LoopSIMD &v, PriorityTag<3>, ADLTag) { │ │ │ │ │ -587 Simd::Mask> out; │ │ │ │ │ -588 for(auto l : range(S)) │ │ │ │ │ -589 out[l] = Dune::isNaN(v[l]); │ │ │ │ │ -590 return out; │ │ │ │ │ -591 } │ │ │ │ │ -592 │ │ │ │ │ -593 template │ │ │ │ │ -594 auto isInf(const LoopSIMD &v, PriorityTag<3>, ADLTag) { │ │ │ │ │ -595 Simd::Mask> out; │ │ │ │ │ -596 for(auto l : range(S)) │ │ │ │ │ -597 out[l] = Dune::isInf(v[l]); │ │ │ │ │ -598 return out; │ │ │ │ │ -599 } │ │ │ │ │ -600 │ │ │ │ │ -601 template │ │ │ │ │ -602 auto isFinite(const LoopSIMD &v, PriorityTag<3>, ADLTag) { │ │ │ │ │ -603 Simd::Mask> out; │ │ │ │ │ -604 for(auto l : range(S)) │ │ │ │ │ -605 out[l] = Dune::isFinite(v[l]); │ │ │ │ │ -606 return out; │ │ │ │ │ -607 } │ │ │ │ │ -608 } //namespace MathOverloads │ │ │ │ │ -609 │ │ │ │ │ -610 template │ │ │ │ │ -611 struct IsNumber> : │ │ │ │ │ -612 public std::integral_constant::value>{ │ │ │ │ │ -613 }; │ │ │ │ │ -614 │ │ │ │ │ -615#ifdef CLANG_WARNING_DISABLED │ │ │ │ │ -616# pragma clang diagnostic pop │ │ │ │ │ -617# undef CLANG_WARNING_DISABLED │ │ │ │ │ -618#endif │ │ │ │ │ -619 │ │ │ │ │ -620#ifdef GCC_WARNING_DISABLED │ │ │ │ │ -621# pragma GCC diagnostic pop │ │ │ │ │ -622# undef GCC_WARNING_DISABLED │ │ │ │ │ -623#endif │ │ │ │ │ -624 │ │ │ │ │ -625} //namespace Dune │ │ │ │ │ -626 │ │ │ │ │ -627#endif │ │ │ │ │ -DUNE_SIMD_LOOP_BINARY_OP │ │ │ │ │ -#define DUNE_SIMD_LOOP_BINARY_OP(SYMBOL) │ │ │ │ │ -Definition loop.hh:177 │ │ │ │ │ -DUNE_SIMD_LOOP_BOOLEAN_OP │ │ │ │ │ -#define DUNE_SIMD_LOOP_BOOLEAN_OP(SYMBOL) │ │ │ │ │ -Definition loop.hh:289 │ │ │ │ │ -DUNE_SIMD_LOOP_STD_BINARY_OP │ │ │ │ │ -#define DUNE_SIMD_LOOP_STD_BINARY_OP(expr) │ │ │ │ │ -Definition loop.hh:567 │ │ │ │ │ -DUNE_SIMD_LOOP_STD_UNARY_OP │ │ │ │ │ -#define DUNE_SIMD_LOOP_STD_UNARY_OP(expr) │ │ │ │ │ -Definition loop.hh:540 │ │ │ │ │ -DUNE_SIMD_LOOP_BITSHIFT_OP │ │ │ │ │ -#define DUNE_SIMD_LOOP_BITSHIFT_OP(SYMBOL) │ │ │ │ │ -Definition loop.hh:221 │ │ │ │ │ -DUNE_SIMD_LOOP_CMATH_UNARY_OP │ │ │ │ │ -#define DUNE_SIMD_LOOP_CMATH_UNARY_OP(expr) │ │ │ │ │ -Definition loop.hh:446 │ │ │ │ │ -DUNE_PRAGMA_OMP_SIMD │ │ │ │ │ -#define DUNE_PRAGMA_OMP_SIMD │ │ │ │ │ -Definition loop.hh:49 │ │ │ │ │ -DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN │ │ │ │ │ -#define DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN(expr, returnType) │ │ │ │ │ -Definition loop.hh:459 │ │ │ │ │ -DUNE_SIMD_LOOP_ASSIGNMENT_OP │ │ │ │ │ -#define DUNE_SIMD_LOOP_ASSIGNMENT_OP(SYMBOL) │ │ │ │ │ -Definition loop.hh:145 │ │ │ │ │ -math.hh │ │ │ │ │ -Some useful basic math stuff. │ │ │ │ │ +331 │ │ │ │ │ +333 │ │ │ │ │ +340 template │ │ │ │ │ +341 inline void hash_range(std::size_t& seed, It first, It last) │ │ │ │ │ +342 { │ │ │ │ │ +343 for (; first != last; ++first) │ │ │ │ │ +344 { │ │ │ │ │ +345 hash_combine(seed,*first); │ │ │ │ │ +346 } │ │ │ │ │ +347 } │ │ │ │ │ +348 │ │ │ │ │ +349} // end namespace Dune │ │ │ │ │ +350 │ │ │ │ │ +351#endif // DUNE_COMMON_HASH_HH │ │ │ │ │ typetraits.hh │ │ │ │ │ Traits for type conversions and type information. │ │ │ │ │ -Dune::index_constant │ │ │ │ │ -std::integral_constant< std::size_t, i > index_constant │ │ │ │ │ -An index constant with value i. │ │ │ │ │ -Definition indices.hh:29 │ │ │ │ │ -Dune::range │ │ │ │ │ -static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from │ │ │ │ │ ->, std::integral_constant< T, to >) noexcept │ │ │ │ │ -Definition rangeutilities.hh:312 │ │ │ │ │ -Dune::operator<< │ │ │ │ │ -std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x) │ │ │ │ │ -Definition bigunsignedint.hh:278 │ │ │ │ │ -Dune::Simd::anyTrue │ │ │ │ │ -bool anyTrue(const Mask &mask) │ │ │ │ │ -Whether any entry is true │ │ │ │ │ -Definition simd/interface.hh:429 │ │ │ │ │ -Dune::Simd::cond │ │ │ │ │ -V cond(M &&mask, const V &ifTrue, const V &ifFalse) │ │ │ │ │ -Like the ?: operator. │ │ │ │ │ -Definition simd/interface.hh:386 │ │ │ │ │ -Dune::Simd::allTrue │ │ │ │ │ -bool allTrue(const Mask &mask) │ │ │ │ │ -Whether all entries are true │ │ │ │ │ -Definition simd/interface.hh:439 │ │ │ │ │ -Dune::Simd::anyFalse │ │ │ │ │ -bool anyFalse(const Mask &mask) │ │ │ │ │ -Whether any entry is false │ │ │ │ │ -Definition simd/interface.hh:449 │ │ │ │ │ -Dune::Simd::lanes │ │ │ │ │ -constexpr std::size_t lanes() │ │ │ │ │ -Number of lanes in a SIMD type. │ │ │ │ │ -Definition simd/interface.hh:305 │ │ │ │ │ -Dune::Simd::lane │ │ │ │ │ -decltype(auto) lane(std::size_t l, V &&v) │ │ │ │ │ -Extract an element of a SIMD type. │ │ │ │ │ -Definition simd/interface.hh:324 │ │ │ │ │ -Dune::Simd::Mask │ │ │ │ │ -Rebind< bool, V > Mask │ │ │ │ │ -Mask type type of some SIMD type. │ │ │ │ │ -Definition simd/interface.hh:289 │ │ │ │ │ -Dune::Simd::allFalse │ │ │ │ │ -bool allFalse(const Mask &mask) │ │ │ │ │ -Whether all entries are false │ │ │ │ │ -Definition simd/interface.hh:459 │ │ │ │ │ -Dune::Simd::Scalar │ │ │ │ │ -typename Overloads::ScalarType< std::decay_t< V > >::type Scalar │ │ │ │ │ -Element type of some SIMD type. │ │ │ │ │ -Definition simd/interface.hh:235 │ │ │ │ │ -Dune::Simd::Overloads::mask │ │ │ │ │ -Mask< V > mask(ADLTag< 0, std::is_same< V, Mask< V > >::value >, const V &v) │ │ │ │ │ -implements Simd::mask() │ │ │ │ │ -Definition defaults.hh:153 │ │ │ │ │ -Dune::Simd::Overloads::allFalse │ │ │ │ │ -bool allFalse(ADLTag< 0 >, const Mask &mask) │ │ │ │ │ -implements Simd::allFalse() │ │ │ │ │ -Definition defaults.hh:124 │ │ │ │ │ -Dune::Simd::Overloads::allTrue │ │ │ │ │ -bool allTrue(ADLTag< 0 >, const Mask &mask) │ │ │ │ │ -implements Simd::allTrue() │ │ │ │ │ -Definition defaults.hh:104 │ │ │ │ │ -Dune::Simd::Overloads::anyFalse │ │ │ │ │ -bool anyFalse(ADLTag< 0 >, const Mask &mask) │ │ │ │ │ -implements Simd::anyFalse() │ │ │ │ │ -Definition defaults.hh:114 │ │ │ │ │ -std │ │ │ │ │ -STL namespace. │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::DUNE_SIMD_LOOP_COMPARISON_OP │ │ │ │ │ -DUNE_SIMD_LOOP_COMPARISON_OP(<) │ │ │ │ │ -Dune::Simd::Overloads::anyTrue │ │ │ │ │ -bool anyTrue(ADLTag< 5 >, const AlignedNumber< bool, align > &mask) │ │ │ │ │ -Definition debugalign.hh:556 │ │ │ │ │ -Dune::Simd::Overloads::cond │ │ │ │ │ -const AlignedNumber< T, align > & cond(ADLTag< 5 >, AlignedNumber< bool, align │ │ │ │ │ -> mask, const AlignedNumber< T, align > &ifTrue, const AlignedNumber< T, align │ │ │ │ │ -> &ifFalse) │ │ │ │ │ -Definition debugalign.hh:548 │ │ │ │ │ -Dune::Simd::Overloads::lane │ │ │ │ │ -T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v) │ │ │ │ │ -Definition debugalign.hh:533 │ │ │ │ │ -Dune::MathOverloads::isNaN │ │ │ │ │ -bool isNaN(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag) │ │ │ │ │ -Returns whether any entry is NaN. │ │ │ │ │ -Definition fvector.hh:627 │ │ │ │ │ -Dune::MathOverloads::isInf │ │ │ │ │ -bool isInf(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag) │ │ │ │ │ -Returns whether any entry is infinite. │ │ │ │ │ -Definition fvector.hh:615 │ │ │ │ │ -Dune::MathOverloads::isFinite │ │ │ │ │ -auto isFinite(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag) │ │ │ │ │ -Returns whether all entries are finite. │ │ │ │ │ -Definition fvector.hh:604 │ │ │ │ │ -Dune::IsNumber │ │ │ │ │ -Whether this type acts as a scalar in the context of (hierarchically blocked) │ │ │ │ │ -containers. │ │ │ │ │ -Definition typetraits.hh:194 │ │ │ │ │ -Dune::MathOverloads::ADLTag │ │ │ │ │ -Tag to make sure the functions in this namespace can be found by ADL. │ │ │ │ │ -Definition math.hh:230 │ │ │ │ │ -Dune::Simd::Overloads::ADLTag │ │ │ │ │ -Tag used to force late-binding lookup in Dune::Simd::Overloads. │ │ │ │ │ -Definition base.hh:182 │ │ │ │ │ -Dune::Simd::Overloads::ScalarType │ │ │ │ │ -should have a member type type │ │ │ │ │ -Definition standard.hh:60 │ │ │ │ │ -Dune::Simd::Overloads::RebindType │ │ │ │ │ -should have a member type type │ │ │ │ │ -Definition standard.hh:67 │ │ │ │ │ -Dune::Simd::Overloads::LaneCount │ │ │ │ │ -should be derived from a Dune::index_constant │ │ │ │ │ -Definition standard.hh:74 │ │ │ │ │ -Dune::LoopSIMD │ │ │ │ │ -Definition loop.hh:65 │ │ │ │ │ -Dune::LoopSIMD::LoopSIMD │ │ │ │ │ -LoopSIMD(Simd::Scalar< T > i) │ │ │ │ │ -Definition loop.hh:75 │ │ │ │ │ -Dune::LoopSIMD::DUNE_SIMD_LOOP_PREFIX_OP │ │ │ │ │ -DUNE_SIMD_LOOP_PREFIX_OP(++) │ │ │ │ │ -Dune::LoopSIMD::operator! │ │ │ │ │ -auto operator!() const │ │ │ │ │ -Definition loop.hh:121 │ │ │ │ │ -Dune::LoopSIMD::DUNE_SIMD_LOOP_POSTFIX_OP │ │ │ │ │ -DUNE_SIMD_LOOP_POSTFIX_OP(--) │ │ │ │ │ -Dune::LoopSIMD::DUNE_SIMD_LOOP_ASSIGNMENT_OP │ │ │ │ │ -DUNE_SIMD_LOOP_ASSIGNMENT_OP * DUNE_SIMD_LOOP_ASSIGNMENT_OP(/=);DUNE_SIMD_LOOP_ │ │ │ │ │ -ASSIGNMENT_OP(%= │ │ │ │ │ -Dune::LoopSIMD::DUNE_SIMD_LOOP_ASSIGNMENT_OP │ │ │ │ │ -DUNE_SIMD_LOOP_ASSIGNMENT_OP & DUNE_SIMD_LOOP_ASSIGNMENT_OP(|=);DUNE_SIMD_LOOP_ │ │ │ │ │ -ASSIGNMENT_OP(^= │ │ │ │ │ -Dune::LoopSIMD::DUNE_SIMD_LOOP_UNARY_OP │ │ │ │ │ -DUNE_SIMD_LOOP_UNARY_OP(-) │ │ │ │ │ -Dune::LoopSIMD::DUNE_SIMD_LOOP_PREFIX_OP │ │ │ │ │ -DUNE_SIMD_LOOP_PREFIX_OP(--) │ │ │ │ │ -Dune::LoopSIMD::DUNE_SIMD_LOOP_POSTFIX_OP │ │ │ │ │ -DUNE_SIMD_LOOP_POSTFIX_OP(++) │ │ │ │ │ -Dune::LoopSIMD::DUNE_SIMD_LOOP_ASSIGNMENT_OP │ │ │ │ │ -DUNE_SIMD_LOOP_ASSIGNMENT_OP(-=) │ │ │ │ │ -Dune::LoopSIMD::LoopSIMD │ │ │ │ │ -LoopSIMD(const LoopSIMD< T, S, OA > &other) │ │ │ │ │ -Definition loop.hh:80 │ │ │ │ │ -Dune::LoopSIMD::LoopSIMD │ │ │ │ │ -LoopSIMD() │ │ │ │ │ -Definition loop.hh:70 │ │ │ │ │ -Dune::LoopSIMD::DUNE_SIMD_LOOP_UNARY_OP │ │ │ │ │ -DUNE_SIMD_LOOP_UNARY_OP(~) │ │ │ │ │ -Dune::LoopSIMD::DUNE_SIMD_LOOP_ASSIGNMENT_OP │ │ │ │ │ -DUNE_SIMD_LOOP_ASSIGNMENT_OP(+=) │ │ │ │ │ -Dune::LoopSIMD::DUNE_SIMD_LOOP_UNARY_OP │ │ │ │ │ -DUNE_SIMD_LOOP_UNARY_OP(+) │ │ │ │ │ -Dune::LoopSIMD::DUNE_SIMD_LOOP_ASSIGNMENT_OP │ │ │ │ │ -DUNE_SIMD_LOOP_ASSIGNMENT_OP(<<=) │ │ │ │ │ -Dune::LoopSIMD::DUNE_SIMD_LOOP_ASSIGNMENT_OP │ │ │ │ │ -DUNE_SIMD_LOOP_ASSIGNMENT_OP(> >=) │ │ │ │ │ -Dune::Simd::Overloads::ScalarType<_LoopSIMD<_T,_S,_A_>_>::type │ │ │ │ │ -Simd::Scalar< T > type │ │ │ │ │ -Definition loop.hh:345 │ │ │ │ │ -Dune::PriorityTag │ │ │ │ │ -Helper class for tagging priorities. │ │ │ │ │ -Definition typeutilities.hh:73 │ │ │ │ │ -simd.hh │ │ │ │ │ -Include file for users of the SIMD abstraction layer. │ │ │ │ │ +Dune::hash_range │ │ │ │ │ +std::size_t hash_range(It first, It last) │ │ │ │ │ +Hashes all elements in the range [first,last) and returns the combined hash. │ │ │ │ │ +Definition hash.hh:322 │ │ │ │ │ +Dune::hash_combine │ │ │ │ │ +void hash_combine(std::size_t &seed, const T &arg) │ │ │ │ │ +Calculates the hash value of arg and combines it in-place with seed. │ │ │ │ │ +Definition hash.hh:307 │ │ │ │ │ +Dune::hash │ │ │ │ │ +Functor for hashing objects of type T. │ │ │ │ │ +Definition hash.hh:40 │ │ │ │ │ +Dune::hash::operator() │ │ │ │ │ +std::size_t operator()(const T &t) const │ │ │ │ │ +Calculates the hash of t. │ │ │ │ │ +Definition hash.hh:43 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00029.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: test.hh File Reference │ │ │ │ +dune-common: lru.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,496 +65,50 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces | │ │ │ │ -Macros | │ │ │ │ -Typedefs
│ │ │ │ -
test.hh File Reference
│ │ │ │ +Namespaces
│ │ │ │ +
lru.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

Common tests for simd abstraction implementations. │ │ │ │ +

LRU Cache Container, using an STL like interface. │ │ │ │ More...

│ │ │ │ -
#include <algorithm>
│ │ │ │ -#include <cstddef>
│ │ │ │ -#include <iostream>
│ │ │ │ -#include <sstream>
│ │ │ │ -#include <string>
│ │ │ │ -#include <type_traits>
│ │ │ │ -#include <typeindex>
│ │ │ │ -#include <typeinfo>
│ │ │ │ -#include <unordered_set>
│ │ │ │ +
#include <list>
│ │ │ │ #include <utility>
│ │ │ │ -#include <dune/common/classname.hh>
│ │ │ │ -#include <dune/common/hybridutilities.hh>
│ │ │ │ -#include <dune/common/rangeutilities.hh>
│ │ │ │ -#include <dune/common/simd/io.hh>
│ │ │ │ -#include <dune/common/simd/loop.hh>
│ │ │ │ -#include <dune/common/simd/simd.hh>
│ │ │ │ -#include <dune/common/std/type_traits.hh>
│ │ │ │ -#include <dune/common/typelist.hh>
│ │ │ │ -#include <dune/common/typetraits.hh>
│ │ │ │ +#include <map>
│ │ │ │ +#include <memory>
│ │ │ │ +#include <dune/common/exceptions.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

struct  Dune::Simd::EndMark
 final element marker for RebindList More...
 
class  Dune::Simd::UnitTest
class  Dune::lru< Key, Tp, Traits >
 LRU Cache Container. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::Simd
 Namespace for vectorization interface functions used by library developers.
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Macros

#define DUNE_SIMD_CHECK(expr)    ((expr) ? void() : complain(__FILE__, __LINE__, __func__, #expr))
 
#define DUNE_SIMD_CHECK_OP(expr)
 
#define DUNE_SIMD_POSTFIX_OP(NAME, SYMBOL)
 
#define DUNE_SIMD_PREFIX_OP(NAME, SYMBOL)
 
#define DUNE_SIMD_OPNAME   (className<Op(V)>())
 
#define DUNE_SIMD_INFIX_OP(NAME, SYMBOL)
 
#define DUNE_SIMD_ASSIGN_OP(NAME, SYMBOL)
 
#define DUNE_SIMD_REPL_OP(NAME, REPLFN, SYMBOL)
 
#define DUNE_SIMD_OPNAME   (className<OpInfixComma(T1, T2)>())
 
#define DUNE_SIMD_OPNAME   (className<Op(V1, V2)>())
 
#define DUNE_SIMD_OPNAME   (className<Op(V1, T2)>())
 
#define DUNE_SIMD_OPNAME   (className<Op(V1, T2)>())
 
#define DUNE_SIMD_OPNAME   (className<Op(V1, P2)>())
 
#define DUNE_SIMD_DO(M1, M2, M3, V1, V2, V3, NAME)
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │

│ │ │ │ -Typedefs

template<class... Types>
using Dune::Simd::RebindList = typename Impl::RemoveEnd< EndMark, TypeList< Types... > >::type
 A list of types with the final element removed.
 
template<class T >
using Dune::Simd::IsLoop = typename Impl::IsLoop< T >::type
 check whether a type is an instance of LoopSIMD
 
│ │ │ │

Detailed Description

│ │ │ │ -

Common tests for simd abstraction implementations.

│ │ │ │ -

This file is an interface header and may be included without restrictions.

│ │ │ │ -

Macro Definition Documentation

│ │ │ │ - │ │ │ │ -

◆ DUNE_SIMD_ASSIGN_OP

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_SIMD_ASSIGN_OP( NAME,
 SYMBOL 
)
│ │ │ │ -
│ │ │ │ -Value:
struct OpInfix##NAME \
│ │ │ │ -
{ \
│ │ │ │ -
template<class V1, class V2> \
│ │ │ │ -
decltype(auto) operator()(V1&& v1, V2&& v2) const \
│ │ │ │ -
{ \
│ │ │ │ -
return std::forward<V1>(v1) SYMBOL std::forward<V2>(v2); \
│ │ │ │ -
} \
│ │ │ │ -
template<class S1, class S2> \
│ │ │ │ -
auto scalar(S1& s1, S2&& s2) const \
│ │ │ │ -
-> decltype(s1 SYMBOL std::forward<S2>(s2)); \
│ │ │ │ -
}
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ DUNE_SIMD_CHECK

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_SIMD_CHECK( expr)    ((expr) ? void() : complain(__FILE__, __LINE__, __func__, #expr))
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ DUNE_SIMD_CHECK_OP

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_SIMD_CHECK_OP( expr)
│ │ │ │ -
│ │ │ │ -Value:
((expr) ? void() : complain(__FILE__, __LINE__, __func__, \
│ │ │ │ - │ │ │ │ -
#define DUNE_SIMD_OPNAME
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ DUNE_SIMD_DO

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_SIMD_DO( M1,
 M2,
 M3,
 V1,
 V2,
 V3,
 NAME 
)
│ │ │ │ -
│ │ │ │ -Value:
checker(bool_constant<isMask ? do_##M1 : do_##V1>{}, \
│ │ │ │ -
bool_constant<isMask ? do_##M2 : do_##V2>{}, \
│ │ │ │ -
bool_constant<isMask ? do_##M3 : do_##V3>{}, \
│ │ │ │ -
Op##NAME{})
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ DUNE_SIMD_INFIX_OP

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_SIMD_INFIX_OP( NAME,
 SYMBOL 
)
│ │ │ │ -
│ │ │ │ -Value:
struct OpInfix##NAME \
│ │ │ │ -
{ \
│ │ │ │ -
template<class V1, class V2> \
│ │ │ │ -
decltype(auto) operator()(V1&& v1, V2&& v2) const \
│ │ │ │ -
{ \
│ │ │ │ -
return std::forward<V1>(v1) SYMBOL std::forward<V2>(v2); \
│ │ │ │ -
} \
│ │ │ │ -
template<class S1, class S2> \
│ │ │ │ -
auto scalar(S1&& s1, S2&& s2) const \
│ │ │ │ -
-> decltype(std::forward<S1>(s1) SYMBOL std::forward<S2>(s2)); \
│ │ │ │ -
}
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ DUNE_SIMD_OPNAME [1/6]

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_SIMD_OPNAME   (className<Op(V)>())
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ DUNE_SIMD_OPNAME [2/6]

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_SIMD_OPNAME   (className<OpInfixComma(T1, T2)>())
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ DUNE_SIMD_OPNAME [3/6]

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_SIMD_OPNAME   (className<Op(V1, V2)>())
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ DUNE_SIMD_OPNAME [4/6]

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_SIMD_OPNAME   (className<Op(V1, T2)>())
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ DUNE_SIMD_OPNAME [5/6]

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_SIMD_OPNAME   (className<Op(V1, T2)>())
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ DUNE_SIMD_OPNAME [6/6]

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_SIMD_OPNAME   (className<Op(V1, P2)>())
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ DUNE_SIMD_POSTFIX_OP

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_SIMD_POSTFIX_OP( NAME,
 SYMBOL 
)
│ │ │ │ -
│ │ │ │ -Value:
struct OpPostfix##NAME \
│ │ │ │ -
{ \
│ │ │ │ -
template<class V> \
│ │ │ │ -
auto operator()(V&& v) const \
│ │ │ │ -
-> decltype(std::forward<V>(v) SYMBOL) \
│ │ │ │ -
{ \
│ │ │ │ -
return std::forward<V>(v) SYMBOL; \
│ │ │ │ -
} \
│ │ │ │ -
}
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ DUNE_SIMD_PREFIX_OP

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_SIMD_PREFIX_OP( NAME,
 SYMBOL 
)
│ │ │ │ -
│ │ │ │ -Value:
struct OpPrefix##NAME \
│ │ │ │ -
{ \
│ │ │ │ -
template<class V> \
│ │ │ │ -
auto operator()(V&& v) const \
│ │ │ │ -
-> decltype(SYMBOL std::forward<V>(v)) \
│ │ │ │ -
{ \
│ │ │ │ -
return SYMBOL std::forward<V>(v); \
│ │ │ │ -
} \
│ │ │ │ -
}
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ DUNE_SIMD_REPL_OP

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_SIMD_REPL_OP( NAME,
 REPLFN,
 SYMBOL 
)
│ │ │ │ -
│ │ │ │ -Value:
struct OpInfix##NAME \
│ │ │ │ -
{ \
│ │ │ │ -
template<class V1, class V2> \
│ │ │ │ -
decltype(auto) operator()(V1&& v1, V2&& v2) const \
│ │ │ │ -
{ \
│ │ │ │ -
return Simd::REPLFN(std::forward<V1>(v1), std::forward<V2>(v2)); \
│ │ │ │ -
} \
│ │ │ │ -
template<class S1, class S2> \
│ │ │ │ -
auto scalar(S1&& s1, S2&& s2) const \
│ │ │ │ -
-> decltype(std::forward<S1>(s1) SYMBOL std::forward<S2>(s2)); \
│ │ │ │ -
}
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ +

LRU Cache Container, using an STL like interface.

│ │ │ │ +
Author
Christian Engwer
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,203 +1,29 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * simd │ │ │ │ │ -Classes | Namespaces | Macros | Typedefs │ │ │ │ │ -test.hh File Reference │ │ │ │ │ -Common tests for simd abstraction implementations. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +lru.hh File Reference │ │ │ │ │ +LRU Cache Container, using an STL like interface. More... │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -struct   Dune::Simd::EndMark │ │ │ │ │ -  final element marker for RebindList More... │ │ │ │ │ -  │ │ │ │ │ - class   Dune::Simd::UnitTest │ │ │ │ │ +class   Dune::lru<_Key,_Tp,_Traits_> │ │ │ │ │ +  LRU Cache Container. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -namespace   Dune::Simd │ │ │ │ │ -  Namespace for vectorization interface functions used by library │ │ │ │ │ - developers. │ │ │ │ │ -  │ │ │ │ │ -Macros │ │ │ │ │ -#define  DUNE_SIMD_CHECK(expr)    ((expr) ? void() : complain(__FILE__, __LINE_ │ │ │ │ │ - _, __func__, #expr)) │ │ │ │ │ -  │ │ │ │ │ -#define  DUNE_SIMD_CHECK_OP(expr) │ │ │ │ │ -  │ │ │ │ │ -#define  DUNE_SIMD_POSTFIX_OP(NAME, SYMBOL) │ │ │ │ │ -  │ │ │ │ │ -#define  DUNE_SIMD_PREFIX_OP(NAME, SYMBOL) │ │ │ │ │ -  │ │ │ │ │ -#define  DUNE_SIMD_OPNAME   (className()) │ │ │ │ │ -  │ │ │ │ │ -#define  DUNE_SIMD_INFIX_OP(NAME, SYMBOL) │ │ │ │ │ -  │ │ │ │ │ -#define  DUNE_SIMD_ASSIGN_OP(NAME, SYMBOL) │ │ │ │ │ -  │ │ │ │ │ -#define  DUNE_SIMD_REPL_OP(NAME, REPLFN, SYMBOL) │ │ │ │ │ -  │ │ │ │ │ -#define  DUNE_SIMD_OPNAME   (className()) │ │ │ │ │ -  │ │ │ │ │ -#define  DUNE_SIMD_OPNAME   (className()) │ │ │ │ │ -  │ │ │ │ │ -#define  DUNE_SIMD_OPNAME   (className()) │ │ │ │ │ -  │ │ │ │ │ -#define  DUNE_SIMD_OPNAME   (className()) │ │ │ │ │ -  │ │ │ │ │ -#define  DUNE_SIMD_OPNAME   (className()) │ │ │ │ │ -  │ │ │ │ │ -#define  DUNE_SIMD_DO(M1, M2, M3, V1, V2, V3, NAME) │ │ │ │ │ -  │ │ │ │ │ -Typedefs │ │ │ │ │ -template │ │ │ │ │ -using  Dune::Simd::RebindList = typename Impl::RemoveEnd< EndMark, TypeList< │ │ │ │ │ - Types... > >::type │ │ │ │ │ -  A list of types with the final element removed. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -using  Dune::Simd::IsLoop = typename Impl::IsLoop< T >::type │ │ │ │ │ -  check whether a type is an instance of LoopSIMD │ │ │ │ │ -  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Common tests for simd abstraction implementations. │ │ │ │ │ -This file is an interface header and may be included without restrictions. │ │ │ │ │ -***** Macro Definition Documentation ***** │ │ │ │ │ -***** ◆ DUNE_SIMD_ASSIGN_OP ***** │ │ │ │ │ -#define DUNE_SIMD_ASSIGN_OP (   NAME, │ │ │ │ │ -   SYMBOL  │ │ │ │ │ - ) │ │ │ │ │ -Value: │ │ │ │ │ -struct OpInfix##NAME \ │ │ │ │ │ -{ \ │ │ │ │ │ -template \ │ │ │ │ │ -decltype(auto) operator()(V1&& v1, V2&& v2) const \ │ │ │ │ │ -{ \ │ │ │ │ │ -return std::forward(v1) SYMBOL std::forward(v2); \ │ │ │ │ │ -} \ │ │ │ │ │ -template \ │ │ │ │ │ -auto scalar(S1& s1, S2&& s2) const \ │ │ │ │ │ --> decltype(s1 SYMBOL std::forward(s2)); \ │ │ │ │ │ -} │ │ │ │ │ -***** ◆ DUNE_SIMD_CHECK ***** │ │ │ │ │ -#define DUNE_SIMD_CHECK (   expr )     ((expr) ? void() : complain(__FILE__, __ │ │ │ │ │ - LINE__, __func__, #expr)) │ │ │ │ │ -***** ◆ DUNE_SIMD_CHECK_OP ***** │ │ │ │ │ -#define DUNE_SIMD_CHECK_OP (   expr ) │ │ │ │ │ -Value: │ │ │ │ │ -((expr) ? void() : complain(__FILE__, __LINE__, __func__, \ │ │ │ │ │ -DUNE_SIMD_OPNAME, #expr)) │ │ │ │ │ -DUNE_SIMD_OPNAME │ │ │ │ │ -#define DUNE_SIMD_OPNAME │ │ │ │ │ -***** ◆ DUNE_SIMD_DO ***** │ │ │ │ │ -#define DUNE_SIMD_DO (   M1, │ │ │ │ │ -   M2, │ │ │ │ │ -   M3, │ │ │ │ │ -   V1, │ │ │ │ │ -   V2, │ │ │ │ │ -   V3, │ │ │ │ │ -   NAME  │ │ │ │ │ - ) │ │ │ │ │ -Value: │ │ │ │ │ -checker(bool_constant{}, \ │ │ │ │ │ -bool_constant{}, \ │ │ │ │ │ -bool_constant{}, \ │ │ │ │ │ -Op##NAME{}) │ │ │ │ │ -***** ◆ DUNE_SIMD_INFIX_OP ***** │ │ │ │ │ -#define DUNE_SIMD_INFIX_OP (   NAME, │ │ │ │ │ -   SYMBOL  │ │ │ │ │ - ) │ │ │ │ │ -Value: │ │ │ │ │ -struct OpInfix##NAME \ │ │ │ │ │ -{ \ │ │ │ │ │ -template \ │ │ │ │ │ -decltype(auto) operator()(V1&& v1, V2&& v2) const \ │ │ │ │ │ -{ \ │ │ │ │ │ -return std::forward(v1) SYMBOL std::forward(v2); \ │ │ │ │ │ -} \ │ │ │ │ │ -template \ │ │ │ │ │ -auto scalar(S1&& s1, S2&& s2) const \ │ │ │ │ │ --> decltype(std::forward(s1) SYMBOL std::forward(s2)); \ │ │ │ │ │ -} │ │ │ │ │ -***** ◆ DUNE_SIMD_OPNAME [1/6] ***** │ │ │ │ │ -#define DUNE_SIMD_OPNAME   (className()) │ │ │ │ │ -***** ◆ DUNE_SIMD_OPNAME [2/6] ***** │ │ │ │ │ -#define DUNE_SIMD_OPNAME   (className()) │ │ │ │ │ -***** ◆ DUNE_SIMD_OPNAME [3/6] ***** │ │ │ │ │ -#define DUNE_SIMD_OPNAME   (className()) │ │ │ │ │ -***** ◆ DUNE_SIMD_OPNAME [4/6] ***** │ │ │ │ │ -#define DUNE_SIMD_OPNAME   (className()) │ │ │ │ │ -***** ◆ DUNE_SIMD_OPNAME [5/6] ***** │ │ │ │ │ -#define DUNE_SIMD_OPNAME   (className()) │ │ │ │ │ -***** ◆ DUNE_SIMD_OPNAME [6/6] ***** │ │ │ │ │ -#define DUNE_SIMD_OPNAME   (className()) │ │ │ │ │ -***** ◆ DUNE_SIMD_POSTFIX_OP ***** │ │ │ │ │ -#define DUNE_SIMD_POSTFIX_OP (   NAME, │ │ │ │ │ -   SYMBOL  │ │ │ │ │ - ) │ │ │ │ │ -Value: │ │ │ │ │ -struct OpPostfix##NAME \ │ │ │ │ │ -{ \ │ │ │ │ │ -template \ │ │ │ │ │ -auto operator()(V&& v) const \ │ │ │ │ │ --> decltype(std::forward(v) SYMBOL) \ │ │ │ │ │ -{ \ │ │ │ │ │ -return std::forward(v) SYMBOL; \ │ │ │ │ │ -} \ │ │ │ │ │ -} │ │ │ │ │ -***** ◆ DUNE_SIMD_PREFIX_OP ***** │ │ │ │ │ -#define DUNE_SIMD_PREFIX_OP (   NAME, │ │ │ │ │ -   SYMBOL  │ │ │ │ │ - ) │ │ │ │ │ -Value: │ │ │ │ │ -struct OpPrefix##NAME \ │ │ │ │ │ -{ \ │ │ │ │ │ -template \ │ │ │ │ │ -auto operator()(V&& v) const \ │ │ │ │ │ --> decltype(SYMBOL std::forward(v)) \ │ │ │ │ │ -{ \ │ │ │ │ │ -return SYMBOL std::forward(v); \ │ │ │ │ │ -} \ │ │ │ │ │ -} │ │ │ │ │ -***** ◆ DUNE_SIMD_REPL_OP ***** │ │ │ │ │ -#define DUNE_SIMD_REPL_OP (   NAME, │ │ │ │ │ -   REPLFN, │ │ │ │ │ -   SYMBOL  │ │ │ │ │ - ) │ │ │ │ │ -Value: │ │ │ │ │ -struct OpInfix##NAME \ │ │ │ │ │ -{ \ │ │ │ │ │ -template \ │ │ │ │ │ -decltype(auto) operator()(V1&& v1, V2&& v2) const \ │ │ │ │ │ -{ \ │ │ │ │ │ -return Simd::REPLFN(std::forward(v1), std::forward(v2)); \ │ │ │ │ │ -} \ │ │ │ │ │ -template \ │ │ │ │ │ -auto scalar(S1&& s1, S2&& s2) const \ │ │ │ │ │ --> decltype(std::forward(s1) SYMBOL std::forward(s2)); \ │ │ │ │ │ -} │ │ │ │ │ +LRU Cache Container, using an STL like interface. │ │ │ │ │ + Author │ │ │ │ │ + Christian Engwer │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00029_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: test.hh Source File │ │ │ │ +dune-common: lru.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,2027 +70,242 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
test.hh
│ │ │ │ +
lru.hh
│ │ │ │
│ │ │ │
│ │ │ │ -Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ -
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
3#ifndef DUNE_COMMON_SIMD_TEST_HH
│ │ │ │ -
4#define DUNE_COMMON_SIMD_TEST_HH
│ │ │ │ -
5
│ │ │ │ -
12#include <algorithm>
│ │ │ │ -
13#include <cstddef>
│ │ │ │ -
14#include <iostream>
│ │ │ │ -
15#include <sstream>
│ │ │ │ -
16#include <string>
│ │ │ │ -
17#include <type_traits>
│ │ │ │ -
18#include <typeindex>
│ │ │ │ -
19#include <typeinfo>
│ │ │ │ -
20#include <unordered_set>
│ │ │ │ -
21#include <utility>
│ │ │ │ -
22
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
32
│ │ │ │ -
33namespace Dune {
│ │ │ │ -
34 namespace Simd {
│ │ │ │ -
35
│ │ │ │ -
36 namespace Impl {
│ │ │ │ -
37
│ │ │ │ -
38 template<class T, class SFINAE = void>
│ │ │ │ -
39 struct LessThenComparable : std::false_type {};
│ │ │ │ -
40 template<class T>
│ │ │ │ -
41 struct LessThenComparable<T, std::void_t<decltype(std::declval<T>()
│ │ │ │ -
42 < std::declval<T>())> > :
│ │ │ │ -
43 std::true_type
│ │ │ │ -
44 {};
│ │ │ │ -
45
│ │ │ │ -
46 template<class Dst, class Src>
│ │ │ │ -
47 struct CopyConstHelper
│ │ │ │ -
48 {
│ │ │ │ -
49 using type = Dst;
│ │ │ │ -
50 };
│ │ │ │ -
51 template<class Dst, class Src>
│ │ │ │ -
52 struct CopyConstHelper<Dst, const Src>
│ │ │ │ -
53 {
│ │ │ │ -
54 using type = std::add_const_t<Dst>;
│ │ │ │ -
55 };
│ │ │ │ -
56
│ │ │ │ -
57 template<class Dst, class Src>
│ │ │ │ -
58 struct CopyVolatileHelper
│ │ │ │ -
59 {
│ │ │ │ -
60 using type = Dst;
│ │ │ │ -
61 };
│ │ │ │ -
62 template<class Dst, class Src>
│ │ │ │ -
63 struct CopyVolatileHelper<Dst, volatile Src>
│ │ │ │ -
64 {
│ │ │ │ -
65 using type = std::add_volatile_t<Dst>;
│ │ │ │ -
66 };
│ │ │ │ -
67
│ │ │ │ -
68 template<class Dst, class Src>
│ │ │ │ -
69 struct CopyReferenceHelper
│ │ │ │ -
70 {
│ │ │ │ -
71 using type = Dst;
│ │ │ │ -
72 };
│ │ │ │ -
73 template<class Dst, class Src>
│ │ │ │ -
74 struct CopyReferenceHelper<Dst, Src&>
│ │ │ │ -
75 {
│ │ │ │ -
76 using type = std::add_lvalue_reference_t<Dst>;
│ │ │ │ -
77 };
│ │ │ │ +Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │ +
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │ +
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ +
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ +
5#ifndef DUNE_COMMON_LRU_HH
│ │ │ │ +
6#define DUNE_COMMON_LRU_HH
│ │ │ │ +
7
│ │ │ │ +
8#include <list>
│ │ │ │ +
9#include <utility>
│ │ │ │ +
10#include <map>
│ │ │ │ +
11#include <memory>
│ │ │ │ +
12
│ │ │ │ + │ │ │ │ +
14
│ │ │ │ +
20namespace Dune {
│ │ │ │ +
21
│ │ │ │ +
22 namespace {
│ │ │ │ +
23
│ │ │ │ +
24 /*
│ │ │ │ +
25 hide the default traits in an empty namespace
│ │ │ │ +
26 */
│ │ │ │ +
27 template <typename Key, typename Tp,
│ │ │ │ +
28 typename Alloc = std::allocator<Tp> >
│ │ │ │ +
29 struct _lru_default_traits
│ │ │ │ +
30 {
│ │ │ │ +
31 typedef Key key_type;
│ │ │ │ +
32 typedef Alloc allocator;
│ │ │ │ +
33 typedef std::list< std::pair<Key, Tp> > list_type;
│ │ │ │ +
34 typedef typename list_type::iterator iterator;
│ │ │ │ +
35 typedef typename std::less<key_type> cmp;
│ │ │ │ +
36 typedef std::map< key_type, iterator, cmp,
│ │ │ │ +
37 typename std::allocator_traits<allocator>::template rebind_alloc<std::pair<const key_type, iterator> > > map_type;
│ │ │ │ +
38 };
│ │ │ │ +
39
│ │ │ │ +
40 } // end empty namespace
│ │ │ │ +
41
│ │ │ │ +
49 template <typename Key, typename Tp,
│ │ │ │ +
50 typename Traits = _lru_default_traits<Key, Tp> >
│ │ │ │ +
│ │ │ │ +
51 class lru
│ │ │ │ +
52 {
│ │ │ │ +
53 typedef typename Traits::list_type list_type;
│ │ │ │ +
54 typedef typename Traits::map_type map_type;
│ │ │ │ +
55 typedef typename Traits::allocator allocator;
│ │ │ │ +
56 typedef typename map_type::iterator map_iterator;
│ │ │ │ +
57 typedef typename map_type::const_iterator const_map_iterator;
│ │ │ │ +
58
│ │ │ │ +
59 public:
│ │ │ │ +
60 typedef typename Traits::key_type key_type;
│ │ │ │ +
61 typedef typename allocator::value_type value_type;
│ │ │ │ +
62 using pointer = typename allocator::value_type*;
│ │ │ │ +
63 using const_pointer = typename allocator::value_type const*;
│ │ │ │ +
64 using const_reference = typename allocator::value_type const&;
│ │ │ │ +
65 using reference = typename allocator::value_type&;
│ │ │ │ +
66 typedef typename allocator::size_type size_type;
│ │ │ │ +
67 typedef typename list_type::iterator iterator;
│ │ │ │ +
68 typedef typename list_type::const_iterator const_iterator;
│ │ │ │ +
69
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
75 {
│ │ │ │ +
76 return _data.front().second;
│ │ │ │ +
77 }
│ │ │ │ +
│ │ │ │
78
│ │ │ │ -
79 template<class Dst, class Src>
│ │ │ │ -
80 struct CopyReferenceHelper<Dst, Src&&>
│ │ │ │ -
81 {
│ │ │ │ -
82 using type = std::add_rvalue_reference_t<Dst>;
│ │ │ │ -
83 };
│ │ │ │ -
84
│ │ │ │ -
85 template<class Dst, class Src>
│ │ │ │ -
86 using CopyRefQual = typename CopyReferenceHelper<
│ │ │ │ -
87 typename CopyVolatileHelper<
│ │ │ │ -
88 typename CopyConstHelper<
│ │ │ │ -
89 std::decay_t<Dst>,
│ │ │ │ -
90 std::remove_reference_t<Src>
│ │ │ │ -
91 >::type,
│ │ │ │ -
92 std::remove_reference_t<Src>
│ │ │ │ -
93 >::type,
│ │ │ │ -
94 Src
│ │ │ │ -
95 >::type;
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
84 {
│ │ │ │ +
85 return _data.front().second;
│ │ │ │ +
86 }
│ │ │ │ +
│ │ │ │ +
87
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
93 {
│ │ │ │ +
94 return _data.back().second;
│ │ │ │ +
95 }
│ │ │ │ +
│ │ │ │
96
│ │ │ │ -
97 template<class Mark, class Types,
│ │ │ │ -
98 class Indices =
│ │ │ │ -
99 std::make_index_sequence<TypeListSize<Types>::value - 1> >
│ │ │ │ -
100 struct RemoveEnd;
│ │ │ │ -
101 template<class Mark, class Types, std::size_t... I>
│ │ │ │ -
102 struct RemoveEnd<Mark, Types, std::index_sequence<I...>>
│ │ │ │ -
103 {
│ │ │ │ -
104 using Back = TypeListEntry_t<TypeListSize<Types>::value - 1, Types>;
│ │ │ │ -
105 static_assert(std::is_same<Mark, Back>::value,
│ │ │ │ -
106 "TypeList not terminated by proper EndMark");
│ │ │ │ -
107 using type = TypeList<TypeListEntry_t<I, Types>...>;
│ │ │ │ -
108 };
│ │ │ │ -
109
│ │ │ │ -
110 template<class T, class List, class = void>
│ │ │ │ -
111 struct TypeInList;
│ │ │ │ -
112
│ │ │ │ -
113 template<class T>
│ │ │ │ -
114 struct TypeInList<T, TypeList<> > : std::false_type {};
│ │ │ │ -
115
│ │ │ │ -
116 template<class T, class... Rest>
│ │ │ │ -
117 struct TypeInList<T, TypeList<T, Rest...> > : std::true_type {};
│ │ │ │ -
118
│ │ │ │ -
119 template<class T, class Head, class... Rest>
│ │ │ │ -
120 struct TypeInList<T, TypeList<Head, Rest...>,
│ │ │ │ -
121 std::enable_if_t<!std::is_same<T, Head>::value> > :
│ │ │ │ -
122 TypeInList<T, TypeList<Rest...> >::type
│ │ │ │ -
123 {};
│ │ │ │ -
124
│ │ │ │ -
125 template<class T>
│ │ │ │ -
126 struct IsLoop : std::false_type {};
│ │ │ │ -
127 template<class T, std::size_t S>
│ │ │ │ -
128 struct IsLoop<LoopSIMD<T, S> > : std::true_type {};
│ │ │ │ -
129
│ │ │ │ -
130 // used inside static_assert to trick the compiler into printing a list
│ │ │ │ -
131 // of types:
│ │ │ │ -
132 //
│ │ │ │ -
133 // static_assert(debugTypes<V>(Std::bool_constant<condition>{}), "msg");
│ │ │ │ -
134 //
│ │ │ │ -
135 // Should include what the type `V` expands to in the error message.
│ │ │ │ -
136 template<class...>
│ │ │ │ -
137 constexpr bool debugTypes(std::true_type) { return true; }
│ │ │ │ -
138 template<class... Types>
│ │ │ │ -
139 [[deprecated]]
│ │ │ │ -
140 constexpr bool debugTypes(std::false_type) { return false; }
│ │ │ │ -
141
│ │ │ │ -
142 } // namespace Impl
│ │ │ │ -
143
│ │ │ │ -
145 struct EndMark {};
│ │ │ │ -
147
│ │ │ │ -
156 template<class... Types>
│ │ │ │ - │ │ │ │ -
158 typename Impl::RemoveEnd<EndMark, TypeList<Types...> >::type;
│ │ │ │ -
159
│ │ │ │ -
161 template<class T>
│ │ │ │ -
162 using IsLoop = typename Impl::IsLoop<T>::type;
│ │ │ │ -
163
│ │ │ │ -
│ │ │ │ -
164 class UnitTest {
│ │ │ │ -
165 bool good_ = true;
│ │ │ │ -
166 std::ostream &log_ = std::cerr;
│ │ │ │ -
167 // records the types for which checks have started running to avoid
│ │ │ │ -
168 // infinite recursion
│ │ │ │ -
169 std::unordered_set<std::type_index> seen_;
│ │ │ │ -
170
│ │ │ │ -
172 //
│ │ │ │ -
173 // Helper functions
│ │ │ │ -
174 //
│ │ │ │ -
175
│ │ │ │ -
176 void complain(const char *file, int line, const char *func,
│ │ │ │ -
177 const char *expr);
│ │ │ │ -
178
│ │ │ │ -
179 void complain(const char *file, int line, const char *func,
│ │ │ │ -
180 const std::string &opname, const char *expr);
│ │ │ │ -
181
│ │ │ │ -
182 // This macro is defined only within this file, do not use anywhere
│ │ │ │ -
183 // else. Doing the actual printing in an external function dramatically
│ │ │ │ -
184 // reduces memory use during compilation. Defined in such a way that
│ │ │ │ -
185 // the call will only happen for failed checks.
│ │ │ │ -
│ │ │ │ -
186#define DUNE_SIMD_CHECK(expr) \
│ │ │ │ -
187 ((expr) ? void() : complain(__FILE__, __LINE__, __func__, #expr))
│ │ │ │ -
│ │ │ │ -
188
│ │ │ │ -
189 // the function using this macro must define a way to compute the
│ │ │ │ -
190 // operator name in DUNE_SIMD_OPNAME
│ │ │ │ -
│ │ │ │ -
191#define DUNE_SIMD_CHECK_OP(expr) \
│ │ │ │ -
192 ((expr) ? void() : complain(__FILE__, __LINE__, __func__, \
│ │ │ │ -
193 DUNE_SIMD_OPNAME, #expr))
│ │ │ │ -
│ │ │ │ -
194
│ │ │ │ -
195 // "cast" into a prvalue
│ │ │ │ -
196 template<class T>
│ │ │ │ -
197 static std::decay_t<T> prvalue(T &&t)
│ │ │ │ -
198 {
│ │ │ │ -
199 return std::forward<T>(t);
│ │ │ │ -
200 }
│ │ │ │ -
201
│ │ │ │ -
202 // whether the vector is 42 in all lanes
│ │ │ │ -
203 template<class V>
│ │ │ │ -
204 static bool is42(const V &v)
│ │ │ │ -
205 {
│ │ │ │ -
206 bool good = true;
│ │ │ │ -
207
│ │ │ │ -
208 for(std::size_t l = 0; l < lanes(v); ++l)
│ │ │ │ -
209 // need to cast in case we have a mask type
│ │ │ │ -
210 good &= (lane(l, v) == Scalar<V>(42));
│ │ │ │ -
211
│ │ │ │ -
212 return good;
│ │ │ │ -
213 }
│ │ │ │ -
214
│ │ │ │ -
215 // make a vector that contains the sequence { 1, 2, ... }
│ │ │ │ -
216 template<class V>
│ │ │ │ -
217 static V make123()
│ │ │ │ -
218 {
│ │ │ │ -
219 // initialize to avoid undefined behaviour if assigning to lane()
│ │ │ │ -
220 // involves lvalue-to-rvalue conversions, e.g. due to bitmask
│ │ │ │ -
221 // operations. Avoid using broadcast<V>() for initialization to avoid
│ │ │ │ -
222 // test interdependencies.
│ │ │ │ -
223 V vec(Scalar<V>(0));
│ │ │ │ -
224 for(std::size_t l = 0; l < lanes(vec); ++l)
│ │ │ │ -
225 lane(l, vec) = l + 1;
│ │ │ │ -
226 return vec;
│ │ │ │ -
227 }
│ │ │ │ -
228
│ │ │ │ -
229 // whether the vector contains the sequence { 1, 2, ... }
│ │ │ │ -
230 template<class V>
│ │ │ │ -
231 static bool is123(const V &v)
│ │ │ │ -
232 {
│ │ │ │ -
233 bool good = true;
│ │ │ │ -
234
│ │ │ │ -
235 for(std::size_t l = 0; l < lanes(v); ++l)
│ │ │ │ -
236 // need to cast in case we have a mask type
│ │ │ │ -
237 good &= (lane(l, v) == Scalar<V>(l+1));
│ │ │ │ -
238
│ │ │ │ -
239 return good;
│ │ │ │ -
240 }
│ │ │ │ -
241
│ │ │ │ -
242 template<class V>
│ │ │ │ -
243 static V leftVector()
│ │ │ │ -
244 {
│ │ │ │ -
245 // Avoid using broadcast<V>() for initialization to avoid test
│ │ │ │ -
246 // interdependencies.
│ │ │ │ -
247 V res(Scalar<V>(0));
│ │ │ │ -
248 for(std::size_t l = 0; l < lanes(res); ++l)
│ │ │ │ -
249 lane(l, res) = Scalar<V>(l+1);
│ │ │ │ -
250 return res;
│ │ │ │ -
251 }
│ │ │ │ -
252
│ │ │ │ -
253 template<class V>
│ │ │ │ -
254 static V rightVector()
│ │ │ │ -
255 {
│ │ │ │ -
256 // Avoid using broadcast<V>() for initialization to avoid test
│ │ │ │ -
257 // interdependencies.
│ │ │ │ -
258 V res(Scalar<V>(0));
│ │ │ │ -
259 for(std::size_t l = 0; l < lanes(res); ++l)
│ │ │ │ -
260 // do not exceed number of bits in char (for shifts)
│ │ │ │ -
261 // avoid 0 (for / and %)
│ │ │ │ -
262 lane(l, res) = Scalar<V>((l)%7+1);
│ │ │ │ -
263 return res;
│ │ │ │ -
264 }
│ │ │ │ -
265
│ │ │ │ -
266 template<class T>
│ │ │ │ -
267 static T leftScalar()
│ │ │ │ -
268 {
│ │ │ │ -
269 return T(42);
│ │ │ │ -
270 }
│ │ │ │ -
271
│ │ │ │ -
272 template<class T>
│ │ │ │ -
273 static T rightScalar()
│ │ │ │ -
274 {
│ │ │ │ -
275 // do not exceed number of bits in char (for shifts)
│ │ │ │ -
276 // avoid 0 (for / and %)
│ │ │ │ -
277 return T(5);
│ │ │ │ -
278 }
│ │ │ │ -
279
│ │ │ │ -
280 template<class Dst, class Src>
│ │ │ │ -
281 using CopyRefQual = Impl::CopyRefQual<Dst, Src>;
│ │ │ │ -
282
│ │ │ │ -
283 // test whether the Op supports the operation on scalars. We do not use
│ │ │ │ -
284 // `lane()` to obtain the scalars, because that might return a proxy
│ │ │ │ -
285 // object, and we are interested in what exactly the scalar type can do,
│ │ │ │ -
286 // no a proxy that might have more overloads than needed. In addition,
│ │ │ │ -
287 // `lane()` may not preserve `const` and reference qualifiers.
│ │ │ │ -
288 template<class Op, class... Vectors>
│ │ │ │ -
289 using ScalarResult =
│ │ │ │ -
290 decltype(std::declval<Op>().
│ │ │ │ -
291 scalar(std::declval<CopyRefQual<Scalar<Vectors>,
│ │ │ │ -
292 Vectors> >()...));
│ │ │ │ -
293
│ │ │ │ -
295 //
│ │ │ │ -
296 // Check associated types
│ │ │ │ -
297 //
│ │ │ │ -
298
│ │ │ │ -
299 template<class V>
│ │ │ │ -
300 void checkScalar()
│ │ │ │ -
301 {
│ │ │ │ -
302 // check that the type Scalar<V> exists
│ │ │ │ -
303 using T = Scalar<V>;
│ │ │ │ -
304
│ │ │ │ -
305 static_assert(std::is_same<T, std::decay_t<T> >::value, "Scalar types "
│ │ │ │ -
306 "must not be references, and must not include "
│ │ │ │ -
307 "cv-qualifiers");
│ │ │ │ -
308 [[maybe_unused]] T a{};
│ │ │ │ -
309 }
│ │ │ │ -
310
│ │ │ │ -
311 template<class V>
│ │ │ │ -
312 [[deprecated("Warning: please include bool in the Rebinds for "
│ │ │ │ -
313 "simd type V, as Masks are not checked otherwise.")]]
│ │ │ │ -
314 void warnMissingMaskRebind(std::true_type) {}
│ │ │ │ -
315 template<class V>
│ │ │ │ -
316 void warnMissingMaskRebind(std::false_type) {}
│ │ │ │ -
317
│ │ │ │ -
318 template<class V, class Rebinds, template<class> class RebindPrune,
│ │ │ │ -
319 template<class> class RebindAccept, class Recurse>
│ │ │ │ -
320 void checkRebindOf(Recurse recurse)
│ │ │ │ -
321 {
│ │ │ │ -
322 Hybrid::forEach(Rebinds{}, [this,recurse](auto target) {
│ │ │ │ -
323 using T = typename decltype(target)::type;
│ │ │ │ -
324
│ │ │ │ -
325 // check that the rebound type exists
│ │ │ │ -
326 using W = Rebind<T, V>;
│ │ │ │ -
327 log_ << "Type " << className<V>() << " rebound to "
│ │ │ │ -
328 << className<T>() << " is " << className<W>() << std::endl;
│ │ │ │ -
329
│ │ │ │ -
330 static_assert(std::is_same<W, std::decay_t<W> >::value, "Rebound "
│ │ │ │ -
331 "types must not be references, and must not include "
│ │ │ │ -
332 "cv-qualifiers");
│ │ │ │ -
333 static_assert(lanes<V>() == lanes<W>(), "Rebound types must have "
│ │ │ │ -
334 "the same number of lanes as the original vector "
│ │ │ │ -
335 "types");
│ │ │ │ -
336 static_assert(std::is_same<T, Scalar<W> >::value, "Rebound types "
│ │ │ │ -
337 "must have the bound-to scalar type");
│ │ │ │ -
338
│ │ │ │ -
339 if constexpr (RebindPrune<W>{}) {
│ │ │ │ -
340 log_ << "Pruning check of Simd type " << className<W>()
│ │ │ │ -
341 << std::endl;
│ │ │ │ -
342 }
│ │ │ │ -
343 else {
│ │ │ │ -
344 using Impl::debugTypes;
│ │ │ │ -
345 static_assert(debugTypes<T, V, W>(RebindAccept<W>{}),
│ │ │ │ -
346 "Rebind<T, V> is W, but that is not accepted "
│ │ │ │ -
347 "by RebindAccept");
│ │ │ │ -
348 recurse(MetaType<W>{});
│ │ │ │ -
349 }
│ │ │ │ -
350 });
│ │ │ │ -
351
│ │ │ │ -
352 static_assert(std::is_same<Rebind<Scalar<V>, V>, V>::value, "A type "
│ │ │ │ -
353 "rebound to its own scalar type must be the same type "
│ │ │ │ -
354 "as the original type");
│ │ │ │ -
355 static_assert(std::is_same<Rebind<bool, V>, Mask<V> >::value, "A type "
│ │ │ │ -
356 "rebound to bool must be the mask type for that type");
│ │ │ │ -
357
│ │ │ │ -
358 constexpr bool hasBool = Impl::TypeInList<bool, Rebinds>::value;
│ │ │ │ -
359 warnMissingMaskRebind<V>(Std::bool_constant<!hasBool>{});
│ │ │ │ -
360 }
│ │ │ │ -
361
│ │ │ │ -
363 //
│ │ │ │ -
364 // Fundamental checks
│ │ │ │ -
365 //
│ │ │ │ -
366
│ │ │ │ -
367 template<class V>
│ │ │ │ -
368 void checkLanes()
│ │ │ │ -
369 {
│ │ │ │ -
370 // check lanes
│ │ │ │ -
371 static_assert(std::is_same<std::size_t, decltype(lanes<V>())>::value,
│ │ │ │ -
372 "return type of lanes<V>() should be std::size_t");
│ │ │ │ -
373 static_assert(std::is_same<std::size_t, decltype(lanes(V{}))>::value,
│ │ │ │ -
374 "return type of lanes(V{}) should be std::size_t");
│ │ │ │ -
375
│ │ │ │ -
376 // the result of lanes<V>() must be constexpr
│ │ │ │ -
377 [[maybe_unused]] constexpr auto size = lanes<V>();
│ │ │ │ -
378 // but the result of lanes(vec) does not need to be constexpr
│ │ │ │ -
379 DUNE_SIMD_CHECK(lanes<V>() == lanes(V{}));
│ │ │ │ -
380 }
│ │ │ │ -
381
│ │ │ │ -
382 template<class V>
│ │ │ │ -
383 void checkDefaultConstruct()
│ │ │ │ -
384 {
│ │ │ │ -
385 { [[maybe_unused]] V vec; }
│ │ │ │ -
386 { [[maybe_unused]] V vec{}; }
│ │ │ │ -
387 { [[maybe_unused]] V vec = {}; }
│ │ │ │ -
388 }
│ │ │ │ -
389
│ │ │ │ -
390 template<class V>
│ │ │ │ -
391 void checkLane()
│ │ │ │ -
392 {
│ │ │ │ -
393 // Avoid using broadcast<V>() for initialization to avoid test
│ │ │ │ -
394 // interdependencies.
│ │ │ │ -
395 V vec(Scalar<V>(0));
│ │ │ │ -
396 // check lane() on mutable lvalues
│ │ │ │ -
397 for(std::size_t l = 0; l < lanes(vec); ++l)
│ │ │ │ -
398 lane(l, vec) = l + 1;
│ │ │ │ -
399 for(std::size_t l = 0; l < lanes(vec); ++l)
│ │ │ │ -
400 DUNE_SIMD_CHECK(lane(l, vec) == Scalar<V>(l + 1));
│ │ │ │ -
401 using MLRes = decltype(lane(0, vec));
│ │ │ │ -
402 static_assert(std::is_same<MLRes, Scalar<V>&>::value ||
│ │ │ │ -
403 std::is_same<MLRes, std::decay_t<MLRes> >::value,
│ │ │ │ -
404 "Result of lane() on a mutable lvalue vector must "
│ │ │ │ -
405 "either be a mutable reference to a scalar of that "
│ │ │ │ -
406 "vector or a proxy object (which itself may not be a "
│ │ │ │ -
407 "reference nor const).");
│ │ │ │ -
408
│ │ │ │ -
409 // check lane() on const lvalues
│ │ │ │ -
410 const V &vec2 = vec;
│ │ │ │ -
411 for(std::size_t l = 0; l < lanes(vec); ++l)
│ │ │ │ -
412 DUNE_SIMD_CHECK(lane(l, vec2) == Scalar<V>(l + 1));
│ │ │ │ -
413 using CLRes = decltype(lane(0, vec2));
│ │ │ │ -
414 static_assert(std::is_same<CLRes, const Scalar<V>&>::value ||
│ │ │ │ -
415 std::is_same<CLRes, std::decay_t<CLRes> >::value,
│ │ │ │ -
416 "Result of lane() on a const lvalue vector must "
│ │ │ │ -
417 "either be a const lvalue reference to a scalar of that "
│ │ │ │ -
418 "vector or a proxy object (which itself may not be a "
│ │ │ │ -
419 "reference nor const).");
│ │ │ │ -
420 static_assert(!std::is_assignable<CLRes, Scalar<V> >::value,
│ │ │ │ -
421 "Result of lane() on a const lvalue vector must not be "
│ │ │ │ -
422 "assignable from a scalar.");
│ │ │ │ -
423
│ │ │ │ -
424 // check lane() on rvalues
│ │ │ │ -
425 for(std::size_t l = 0; l < lanes(vec); ++l)
│ │ │ │ -
426 DUNE_SIMD_CHECK(lane(l, prvalue(vec)) == Scalar<V>(l + 1));
│ │ │ │ -
427 using RRes = decltype(lane(0, prvalue(vec)));
│ │ │ │ -
428 // TODO: do we really want to allow Scalar<V>&& here? If we allow it,
│ │ │ │ -
429 // then `auto &&res = lane(0, vec*vec);` creates a dangling reference,
│ │ │ │ -
430 // and the scalar (and even the vector types) are small enough to be
│ │ │ │ -
431 // passed in registers anyway. On the other hand, the only comparable
│ │ │ │ -
432 // accessor function in the standard library that I can think of is
│ │ │ │ -
433 // std::get(), and that does return an rvalue reference in this
│ │ │ │ -
434 // situation. However, that cannot assume anything about the size of
│ │ │ │ -
435 // the returned types.
│ │ │ │ -
436 static_assert(std::is_same<RRes, Scalar<V> >::value ||
│ │ │ │ -
437 std::is_same<RRes, Scalar<V>&&>::value,
│ │ │ │ -
438 "Result of lane() on a rvalue vector V must be "
│ │ │ │ -
439 "Scalar<V> or Scalar<V>&&.");
│ │ │ │ -
440 // Can't assert non-assignable, fails for any typical class,
│ │ │ │ -
441 // e.g. std::complex<>. Would need to return const Scalar<V> or const
│ │ │ │ -
442 // Scalar<V>&&, which would inhibit moving from the return value.
│ │ │ │ -
443 // static_assert(!std::is_assignable<RRes, Scalar<V> >::value,
│ │ │ │ -
444 // "Result of lane() on a rvalue vector must not be "
│ │ │ │ -
445 // "assignable from a scalar.");
│ │ │ │ -
446 }
│ │ │ │ -
447
│ │ │ │ -
448 // check non-default constructors
│ │ │ │ -
449 template<class V>
│ │ │ │ -
450 void checkCopyMoveConstruct()
│ │ │ │ -
451 {
│ │ │ │ -
452 // elided copy/move constructors
│ │ │ │ -
453 { V vec (make123<V>()); DUNE_SIMD_CHECK(is123(vec)); }
│ │ │ │ -
454 { V vec = make123<V>() ; DUNE_SIMD_CHECK(is123(vec)); }
│ │ │ │ -
455 { V vec {make123<V>()}; DUNE_SIMD_CHECK(is123(vec)); }
│ │ │ │ -
456 { V vec = {make123<V>()}; DUNE_SIMD_CHECK(is123(vec)); }
│ │ │ │ -
457
│ │ │ │ -
458 // copy constructors
│ │ │ │ -
459 { V ref(make123<V>()); V vec (ref);
│ │ │ │ -
460 DUNE_SIMD_CHECK(is123(vec)); DUNE_SIMD_CHECK(is123(ref)); }
│ │ │ │ -
461 { V ref(make123<V>()); V vec = ref ;
│ │ │ │ -
462 DUNE_SIMD_CHECK(is123(vec)); DUNE_SIMD_CHECK(is123(ref)); }
│ │ │ │ -
463 { V ref(make123<V>()); V vec {ref};
│ │ │ │ -
464 DUNE_SIMD_CHECK(is123(vec)); DUNE_SIMD_CHECK(is123(ref)); }
│ │ │ │ -
465 { V ref(make123<V>()); V vec = {ref};
│ │ │ │ -
466 DUNE_SIMD_CHECK(is123(vec)); DUNE_SIMD_CHECK(is123(ref)); }
│ │ │ │ -
467 { const V ref(make123<V>()); V vec (ref);
│ │ │ │ -
468 DUNE_SIMD_CHECK(is123(vec)); }
│ │ │ │ -
469 { const V ref(make123<V>()); V vec = ref ;
│ │ │ │ -
470 DUNE_SIMD_CHECK(is123(vec)); }
│ │ │ │ -
471 { const V ref(make123<V>()); V vec {ref};
│ │ │ │ -
472 DUNE_SIMD_CHECK(is123(vec)); }
│ │ │ │ -
473 { const V ref(make123<V>()); V vec = {ref};
│ │ │ │ -
474 DUNE_SIMD_CHECK(is123(vec)); }
│ │ │ │ -
475
│ │ │ │ -
476 // move constructors
│ │ │ │ -
477 { V ref(make123<V>()); V vec (std::move(ref));
│ │ │ │ -
478 DUNE_SIMD_CHECK(is123(vec)); }
│ │ │ │ -
479 { V ref(make123<V>()); V vec = std::move(ref) ;
│ │ │ │ -
480 DUNE_SIMD_CHECK(is123(vec)); }
│ │ │ │ -
481 { V ref(make123<V>()); V vec {std::move(ref)};
│ │ │ │ -
482 DUNE_SIMD_CHECK(is123(vec)); }
│ │ │ │ -
483 { V ref(make123<V>()); V vec = {std::move(ref)};
│ │ │ │ -
484 DUNE_SIMD_CHECK(is123(vec)); }
│ │ │ │ -
485 }
│ │ │ │ -
486
│ │ │ │ -
487 template<class V>
│ │ │ │ -
488 void checkBroadcastVectorConstruct()
│ │ │ │ -
489 {
│ │ │ │ -
490 // broadcast copy constructors
│ │ │ │ -
491 { Scalar<V> ref = 42; V vec (ref);
│ │ │ │ -
492 DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar<V>(42)); }
│ │ │ │ -
493 { Scalar<V> ref = 42; V vec = ref ;
│ │ │ │ -
494 DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar<V>(42)); }
│ │ │ │ -
495 // { Scalar<V> ref = 42; V vec {ref};
│ │ │ │ -
496 // DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar<V>(42)); }
│ │ │ │ -
497 // { Scalar<V> ref = 42; V vec = {ref};
│ │ │ │ -
498 // DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar<V>(42)); }
│ │ │ │ -
499 { const Scalar<V> ref = 42; V vec (ref);
│ │ │ │ -
500 DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ -
501 { const Scalar<V> ref = 42; V vec = ref ;
│ │ │ │ -
502 DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ -
503 // { const Scalar<V> ref = 42; V vec {ref};
│ │ │ │ -
504 // DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ -
505 // { const Scalar<V> ref = 42; V vec = {ref};
│ │ │ │ -
506 // DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ -
507
│ │ │ │ -
508 // broadcast move constructors
│ │ │ │ -
509 { Scalar<V> ref = 42; V vec (std::move(ref));
│ │ │ │ -
510 DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ -
511 { Scalar<V> ref = 42; V vec = std::move(ref) ;
│ │ │ │ -
512 DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ -
513 // { Scalar<V> ref = 42; V vec {std::move(ref)};
│ │ │ │ -
514 // DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ -
515 // { Scalar<V> ref = 42; V vec = {std::move(ref)};
│ │ │ │ -
516 // DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ -
517 }
│ │ │ │ -
518
│ │ │ │ -
519 template<class V>
│ │ │ │ -
520 void checkBroadcastMaskConstruct()
│ │ │ │ -
521 {
│ │ │ │ -
522 // broadcast copy constructors
│ │ │ │ -
523 { Scalar<V> ref = 42; V vec (ref);
│ │ │ │ -
524 DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar<V>(42)); }
│ │ │ │ -
525 // { Scalar<V> ref = 42; V vec = ref ;
│ │ │ │ -
526 // DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar<V>(42)); }
│ │ │ │ -
527 { Scalar<V> ref = 42; V vec {ref};
│ │ │ │ -
528 DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar<V>(42)); }
│ │ │ │ -
529 // { Scalar<V> ref = 42; V vec = {ref};
│ │ │ │ -
530 // DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar<V>(42)); }
│ │ │ │ -
531 { const Scalar<V> ref = 42; V vec (ref);
│ │ │ │ -
532 DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ -
533 // { const Scalar<V> ref = 42; V vec = ref ;
│ │ │ │ -
534 // DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ -
535 { const Scalar<V> ref = 42; V vec {ref};
│ │ │ │ -
536 DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ -
537 // { const Scalar<V> ref = 42; V vec = {ref};
│ │ │ │ -
538 // DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ -
539
│ │ │ │ -
540 // broadcast move constructors
│ │ │ │ -
541 { Scalar<V> ref = 42; V vec (std::move(ref));
│ │ │ │ -
542 DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ -
543 // { Scalar<V> ref = 42; V vec = std::move(ref) ;
│ │ │ │ -
544 // DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ -
545 { Scalar<V> ref = 42; V vec {std::move(ref)};
│ │ │ │ -
546 DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ -
547 // { Scalar<V> ref = 42; V vec = {std::move(ref)};
│ │ │ │ -
548 // DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ -
549 }
│ │ │ │ -
550
│ │ │ │ -
551 // check the implCast function
│ │ │ │ -
552 template<class FromV, class ToV>
│ │ │ │ -
553 void checkImplCast()
│ │ │ │ -
554 {
│ │ │ │ -
555 { // lvalue arg
│ │ │ │ -
556 FromV fromVec = make123<FromV>();
│ │ │ │ -
557 auto toVec = implCast<ToV>(fromVec);
│ │ │ │ -
558 static_assert(std::is_same<decltype(toVec), ToV>::value,
│ │ │ │ -
559 "Unexpected result type for implCast<ToV>(FromV&)");
│ │ │ │ -
560 DUNE_SIMD_CHECK(is123(fromVec));
│ │ │ │ -
561 DUNE_SIMD_CHECK(is123(toVec));
│ │ │ │ -
562 }
│ │ │ │ -
563
│ │ │ │ -
564 { // const lvalue arg
│ │ │ │ -
565 const FromV fromVec = make123<FromV>();
│ │ │ │ -
566 auto toVec = implCast<ToV>(fromVec);
│ │ │ │ -
567 static_assert(std::is_same<decltype(toVec), ToV>::value,
│ │ │ │ -
568 "Unexpected result type for implCast<ToV>(const "
│ │ │ │ -
569 "FromV&)");
│ │ │ │ -
570 DUNE_SIMD_CHECK(is123(toVec));
│ │ │ │ -
571 }
│ │ │ │ -
572
│ │ │ │ -
573 { // rvalue arg
│ │ │ │ -
574 auto toVec = implCast<ToV>(make123<FromV>());
│ │ │ │ -
575 static_assert(std::is_same<decltype(toVec), ToV>::value,
│ │ │ │ -
576 "Unexpected result type for implCast<ToV>(FromV&&)");
│ │ │ │ -
577 DUNE_SIMD_CHECK(is123(toVec));
│ │ │ │ -
578 }
│ │ │ │ -
579 }
│ │ │ │ -
580
│ │ │ │ -
581 // check the implCast function
│ │ │ │ -
582 template<class V>
│ │ │ │ -
583 void checkImplCast()
│ │ │ │ -
584 {
│ │ │ │ -
585 // check against LoopSIMD
│ │ │ │ -
586 using LoopV = Dune::LoopSIMD<Scalar<V>, lanes<V>()>;
│ │ │ │ -
587
│ │ │ │ -
588 checkImplCast<V, V>();
│ │ │ │ -
589 checkImplCast<V, LoopV>();
│ │ │ │ -
590 checkImplCast<LoopV, V>();
│ │ │ │ -
591 }
│ │ │ │ -
592
│ │ │ │ -
593 // check the broadcast function
│ │ │ │ -
594 template<class V>
│ │ │ │ -
595 void checkBroadcast()
│ │ │ │ -
596 {
│ │ │ │ -
597 // broadcast function
│ │ │ │ -
598 { // lvalue arg
│ │ │ │ -
599 Scalar<V> ref = 42;
│ │ │ │ -
600 auto vec = broadcast<V>(ref);
│ │ │ │ -
601 static_assert(std::is_same<decltype(vec), V>::value,
│ │ │ │ -
602 "Unexpected result type for broadcast<V>()");
│ │ │ │ -
603 DUNE_SIMD_CHECK(is42(vec));
│ │ │ │ -
604 DUNE_SIMD_CHECK(ref == Scalar<V>(42));
│ │ │ │ -
605 }
│ │ │ │ -
606
│ │ │ │ -
607 { // const lvalue arg
│ │ │ │ -
608 const Scalar<V> ref = 42;
│ │ │ │ -
609 auto vec = broadcast<V>(ref);
│ │ │ │ -
610 static_assert(std::is_same<decltype(vec), V>::value,
│ │ │ │ -
611 "Unexpected result type for broadcast<V>()");
│ │ │ │ -
612 DUNE_SIMD_CHECK(is42(vec));
│ │ │ │ -
613 }
│ │ │ │ -
614
│ │ │ │ -
615 { // rvalue arg
│ │ │ │ -
616 auto vec = broadcast<V>(Scalar<V>(42));
│ │ │ │ -
617 static_assert(std::is_same<decltype(vec), V>::value,
│ │ │ │ -
618 "Unexpected result type for broadcast<V>()");
│ │ │ │ -
619 DUNE_SIMD_CHECK(is42(vec));
│ │ │ │ -
620 }
│ │ │ │ -
621
│ │ │ │ -
622 { // int arg
│ │ │ │ -
623 auto vec = broadcast<V>(42);
│ │ │ │ -
624 static_assert(std::is_same<decltype(vec), V>::value,
│ │ │ │ -
625 "Unexpected result type for broadcast<V>()");
│ │ │ │ -
626 DUNE_SIMD_CHECK(is42(vec));
│ │ │ │ -
627 }
│ │ │ │ -
628
│ │ │ │ -
629 { // double arg
│ │ │ │ -
630 auto vec = broadcast<V>(42.0);
│ │ │ │ -
631 static_assert(std::is_same<decltype(vec), V>::value,
│ │ │ │ -
632 "Unexpected result type for broadcast<V>()");
│ │ │ │ -
633 DUNE_SIMD_CHECK(is42(vec));
│ │ │ │ -
634 }
│ │ │ │ -
635 }
│ │ │ │ -
636
│ │ │ │ -
637 template<class V>
│ │ │ │ -
638 void checkBracedAssign()
│ │ │ │ -
639 {
│ │ │ │ -
640 // copy assignment
│ │ │ │ -
641 { V ref = make123<V>(); V vec; vec = {ref};
│ │ │ │ -
642 DUNE_SIMD_CHECK(is123(vec)); DUNE_SIMD_CHECK(is123(ref)); }
│ │ │ │ -
643 { const V ref = make123<V>(); V vec; vec = {ref};
│ │ │ │ -
644 DUNE_SIMD_CHECK(is123(vec)); DUNE_SIMD_CHECK(is123(ref)); }
│ │ │ │ -
645
│ │ │ │ -
646 // move assignment
│ │ │ │ -
647 { V vec; vec = {make123<V>()}; DUNE_SIMD_CHECK(is123(vec)); }
│ │ │ │ -
648 }
│ │ │ │ -
649
│ │ │ │ -
650 template<class V>
│ │ │ │ -
651 void checkBracedBroadcastAssign()
│ │ │ │ -
652 {
│ │ │ │ -
653 // nothing works here
│ │ │ │ -
654 // // broadcast copy assignment
│ │ │ │ -
655 // { Scalar<V> ref = 42; V vec; vec = {ref};
│ │ │ │ -
656 // DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar<V>(42)); }
│ │ │ │ -
657 // { const Scalar<V> ref = 42; V vec; vec = {ref};
│ │ │ │ -
658 // DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ -
659
│ │ │ │ -
660 // // broadcast move assignment
│ │ │ │ -
661 // { Scalar<V> ref = 42; V vec; vec = {std::move(ref)};
│ │ │ │ -
662 // DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ -
663 }
│ │ │ │ -
664
│ │ │ │ -
666 //
│ │ │ │ -
667 // checks for unary operators
│ │ │ │ -
668 //
│ │ │ │ -
669
│ │ │ │ -
│ │ │ │ -
670#define DUNE_SIMD_POSTFIX_OP(NAME, SYMBOL) \
│ │ │ │ -
671 struct OpPostfix##NAME \
│ │ │ │ -
672 { \
│ │ │ │ -
673 template<class V> \
│ │ │ │ -
674 auto operator()(V&& v) const \
│ │ │ │ -
675 -> decltype(std::forward<V>(v) SYMBOL) \
│ │ │ │ -
676 { \
│ │ │ │ -
677 return std::forward<V>(v) SYMBOL; \
│ │ │ │ -
678 } \
│ │ │ │ -
679 }
│ │ │ │ -
│ │ │ │ -
680
│ │ │ │ -
│ │ │ │ -
681#define DUNE_SIMD_PREFIX_OP(NAME, SYMBOL) \
│ │ │ │ -
682 struct OpPrefix##NAME \
│ │ │ │ -
683 { \
│ │ │ │ -
684 template<class V> \
│ │ │ │ -
685 auto operator()(V&& v) const \
│ │ │ │ -
686 -> decltype(SYMBOL std::forward<V>(v)) \
│ │ │ │ -
687 { \
│ │ │ │ -
688 return SYMBOL std::forward<V>(v); \
│ │ │ │ -
689 } \
│ │ │ │ -
690 }
│ │ │ │ -
│ │ │ │ -
691
│ │ │ │ -
692 DUNE_SIMD_POSTFIX_OP(Decrement, -- );
│ │ │ │ -
693 DUNE_SIMD_POSTFIX_OP(Increment, ++ );
│ │ │ │ -
694
│ │ │ │ -
695 DUNE_SIMD_PREFIX_OP (Decrement, -- );
│ │ │ │ -
696 DUNE_SIMD_PREFIX_OP (Increment, ++ );
│ │ │ │ -
697
│ │ │ │ -
698 DUNE_SIMD_PREFIX_OP (Plus, + );
│ │ │ │ -
699 DUNE_SIMD_PREFIX_OP (Minus, - );
│ │ │ │ -
700 DUNE_SIMD_PREFIX_OP (LogicNot, ! );
│ │ │ │ -
701 // Do not warn about ~ being applied to bool. (1) Yes, doing that is
│ │ │ │ -
702 // weird, but we do want to test the weird stuff too. (2) It avoids
│ │ │ │ -
703 // running into <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82040> on
│ │ │ │ -
704 // g++-7.0 through 7.2. Also, ignore -Wpragmas to not warn about an
│ │ │ │ -
705 // unknown -Wbool-operation on compilers that do not know that option.
│ │ │ │ -
706#pragma GCC diagnostic push
│ │ │ │ -
707#pragma GCC diagnostic ignored "-Wpragmas"
│ │ │ │ -
708#pragma GCC diagnostic ignored "-Wunknown-warning-option" // clang 6.0.1
│ │ │ │ -
709#pragma GCC diagnostic ignored "-Wbool-operation"
│ │ │ │ -
710 DUNE_SIMD_PREFIX_OP (BitNot, ~ );
│ │ │ │ -
711#pragma GCC diagnostic pop
│ │ │ │ -
712
│ │ │ │ -
713#undef DUNE_SIMD_POSTFIX_OP
│ │ │ │ -
714#undef DUNE_SIMD_PREFIX_OP
│ │ │ │ -
715
│ │ │ │ -
716 template<class V, class Op>
│ │ │ │ -
717 std::enable_if_t<
│ │ │ │ -
718 IsCallable<Op(decltype(lane(0, std::declval<V>())))>::value>
│ │ │ │ -
719 checkUnaryOpV(Op op)
│ │ │ │ -
720 {
│ │ │ │ -
721#define DUNE_SIMD_OPNAME (className<Op(V)>())
│ │ │ │ -
722 // arguments
│ │ │ │ -
723 auto val = leftVector<std::decay_t<V>>();
│ │ │ │ -
724
│ │ │ │ -
725 // copy the arguments in case V is a references
│ │ │ │ -
726 auto arg = val;
│ │ │ │ -
727 auto &&result = op(static_cast<V>(arg));
│ │ │ │ -
728 using T = Scalar<std::decay_t<decltype(result)> >;
│ │ │ │ -
729 for(std::size_t l = 0; l < lanes(val); ++l)
│ │ │ │ -
730 {
│ │ │ │ -
731 // `op` might promote the argument. This is a problem if the
│ │ │ │ -
732 // argument of the operation on the right of the `==` is
│ │ │ │ -
733 // e.g. `(unsigned short)1` and the operation is e.g. unary `-`.
│ │ │ │ -
734 // Then the argument is promoted to `int` before applying the
│ │ │ │ -
735 // negation, and the result is `(int)-1`. However, the left side of
│ │ │ │ -
736 // the `==` is still `(unsigned short)-1`, which typically is the
│ │ │ │ -
737 // same as `(unsigned short)65535`. The `==` promotes the left side
│ │ │ │ -
738 // before comparing, so that becomes `(int)65535`. It will then
│ │ │ │ -
739 // compare `(int)65535` and `(int)-1` and rightly declare them to be
│ │ │ │ -
740 // not equal.
│ │ │ │ -
741
│ │ │ │ -
742 // To work around this, we explicitly convert the right side of the
│ │ │ │ -
743 // `==` to the scalar type before comparing.
│ │ │ │ - │ │ │ │ -
745 (lane(l, result)
│ │ │ │ -
746 == static_cast<T>(op(lane(l, static_cast<V>(val)))));
│ │ │ │ -
747 }
│ │ │ │ -
748 // op might modify val, verify that any such modification also happens
│ │ │ │ -
749 // in the vector case
│ │ │ │ -
750 for(std::size_t l = 0; l < lanes<std::decay_t<V> >(); ++l)
│ │ │ │ -
751 DUNE_SIMD_CHECK_OP(lane(l, val) == lane(l, arg));
│ │ │ │ -
752#undef DUNE_SIMD_OPNAME
│ │ │ │ -
753 }
│ │ │ │ -
754
│ │ │ │ -
755 template<class V, class Op>
│ │ │ │ -
756 std::enable_if_t<
│ │ │ │ -
757 not IsCallable<Op(decltype(lane(0, std::declval<V>())))>::value>
│ │ │ │ -
758 checkUnaryOpV(Op op)
│ │ │ │ -
759 {
│ │ │ │ -
760 // log_ << "No " << className<Op(decltype(lane(0, std::declval<V>())))>()
│ │ │ │ -
761 // << std::endl
│ │ │ │ -
762 // << " ==> Not checking " << className<Op(V)>() << std::endl;
│ │ │ │ -
763 }
│ │ │ │ -
764
│ │ │ │ -
765 template<class V, class Op>
│ │ │ │ -
766 void checkUnaryOpsV(Op op)
│ │ │ │ -
767 {
│ │ │ │ -
768 checkUnaryOpV<V&>(op);
│ │ │ │ -
769 checkUnaryOpV<const V&>(op);
│ │ │ │ -
770 checkUnaryOpV<V&&>(op);
│ │ │ │ -
771 }
│ │ │ │ -
772
│ │ │ │ -
774 //
│ │ │ │ -
775 // checks for binary operators
│ │ │ │ -
776 //
│ │ │ │ -
777
│ │ │ │ -
778 // The operators contain an `operator()`, which will be invoked for both
│ │ │ │ -
779 // scalar and vector arguments. The function `scalar()` is used the
│ │ │ │ -
780 // test whether the scalar types support the operation (via
│ │ │ │ -
781 // `ScalarResult`). The difference is that `scalar()` should only ever
│ │ │ │ -
782 // receive `const`-ref-qualified version of `Scalar<V>`, while the
│ │ │ │ -
783 // `operator()` may also be called with proxies representing scalars.
│ │ │ │ -
│ │ │ │ -
784#define DUNE_SIMD_INFIX_OP(NAME, SYMBOL) \
│ │ │ │ -
785 struct OpInfix##NAME \
│ │ │ │ -
786 { \
│ │ │ │ -
787 template<class V1, class V2> \
│ │ │ │ -
788 decltype(auto) operator()(V1&& v1, V2&& v2) const \
│ │ │ │ -
789 { \
│ │ │ │ -
790 return std::forward<V1>(v1) SYMBOL std::forward<V2>(v2); \
│ │ │ │ -
791 } \
│ │ │ │ -
792 template<class S1, class S2> \
│ │ │ │ -
793 auto scalar(S1&& s1, S2&& s2) const \
│ │ │ │ -
794 -> decltype(std::forward<S1>(s1) SYMBOL std::forward<S2>(s2)); \
│ │ │ │ -
795 }
│ │ │ │ -
│ │ │ │ -
796
│ │ │ │ -
797 // for assign ops, accept only non-const lvalue arguments for scalars.
│ │ │ │ -
798 // This is needed for class scalars (e.g. std::complex) because
│ │ │ │ -
799 // non-const class rvalues are actually usually assignable. Though that
│ │ │ │ -
800 // assignment happens to a temporary, and thus is lost. Except that the
│ │ │ │ -
801 // tests would bind the result of the assignment to a reference. And
│ │ │ │ -
802 // because that result is returned from a function by reference, even
│ │ │ │ -
803 // though it is a temporary passed as an argument to that function,
│ │ │ │ -
804 // accessing the result later is undefined behaviour.
│ │ │ │ -
│ │ │ │ -
805#define DUNE_SIMD_ASSIGN_OP(NAME, SYMBOL) \
│ │ │ │ -
806 struct OpInfix##NAME \
│ │ │ │ -
807 { \
│ │ │ │ -
808 template<class V1, class V2> \
│ │ │ │ -
809 decltype(auto) operator()(V1&& v1, V2&& v2) const \
│ │ │ │ -
810 { \
│ │ │ │ -
811 return std::forward<V1>(v1) SYMBOL std::forward<V2>(v2); \
│ │ │ │ -
812 } \
│ │ │ │ -
813 template<class S1, class S2> \
│ │ │ │ -
814 auto scalar(S1& s1, S2&& s2) const \
│ │ │ │ -
815 -> decltype(s1 SYMBOL std::forward<S2>(s2)); \
│ │ │ │ -
816 }
│ │ │ │ -
│ │ │ │ -
817
│ │ │ │ -
│ │ │ │ -
818#define DUNE_SIMD_REPL_OP(NAME, REPLFN, SYMBOL) \
│ │ │ │ -
819 struct OpInfix##NAME \
│ │ │ │ -
820 { \
│ │ │ │ -
821 template<class V1, class V2> \
│ │ │ │ -
822 decltype(auto) operator()(V1&& v1, V2&& v2) const \
│ │ │ │ -
823 { \
│ │ │ │ -
824 return Simd::REPLFN(std::forward<V1>(v1), std::forward<V2>(v2)); \
│ │ │ │ -
825 } \
│ │ │ │ -
826 template<class S1, class S2> \
│ │ │ │ -
827 auto scalar(S1&& s1, S2&& s2) const \
│ │ │ │ -
828 -> decltype(std::forward<S1>(s1) SYMBOL std::forward<S2>(s2)); \
│ │ │ │ -
829 }
│ │ │ │ -
│ │ │ │ -
830
│ │ │ │ -
831 DUNE_SIMD_INFIX_OP(Mul, * );
│ │ │ │ -
832 DUNE_SIMD_INFIX_OP(Div, / );
│ │ │ │ -
833 DUNE_SIMD_INFIX_OP(Remainder, % );
│ │ │ │ -
834
│ │ │ │ -
835 DUNE_SIMD_INFIX_OP(Plus, + );
│ │ │ │ -
836 DUNE_SIMD_INFIX_OP(Minus, - );
│ │ │ │ -
837
│ │ │ │ -
838 DUNE_SIMD_INFIX_OP(LeftShift, << );
│ │ │ │ -
839 DUNE_SIMD_INFIX_OP(RightShift, >> );
│ │ │ │ -
840
│ │ │ │ -
841 DUNE_SIMD_INFIX_OP(Less, < );
│ │ │ │ -
842 DUNE_SIMD_INFIX_OP(Greater, > );
│ │ │ │ -
843 DUNE_SIMD_INFIX_OP(LessEqual, <= );
│ │ │ │ -
844 DUNE_SIMD_INFIX_OP(GreaterEqual, >= );
│ │ │ │ -
845
│ │ │ │ -
846 DUNE_SIMD_INFIX_OP(Equal, == );
│ │ │ │ -
847 DUNE_SIMD_INFIX_OP(NotEqual, != );
│ │ │ │ -
848
│ │ │ │ -
849 DUNE_SIMD_INFIX_OP(BitAnd, & );
│ │ │ │ -
850 DUNE_SIMD_INFIX_OP(BitXor, ^ );
│ │ │ │ -
851 DUNE_SIMD_INFIX_OP(BitOr, | );
│ │ │ │ -
852
│ │ │ │ -
853 // Those are not supported in any meaningful way by vectorclass
│ │ │ │ -
854 // We need to test replacement functions maskAnd() and maskOr() instead.
│ │ │ │ -
855 DUNE_SIMD_REPL_OP(LogicAnd, maskAnd, && );
│ │ │ │ -
856 DUNE_SIMD_REPL_OP(LogicOr, maskOr, || );
│ │ │ │ -
857
│ │ │ │ -
858 DUNE_SIMD_ASSIGN_OP(Assign, = );
│ │ │ │ -
859 DUNE_SIMD_ASSIGN_OP(AssignMul, *= );
│ │ │ │ -
860 DUNE_SIMD_ASSIGN_OP(AssignDiv, /= );
│ │ │ │ -
861 DUNE_SIMD_ASSIGN_OP(AssignRemainder, %= );
│ │ │ │ -
862 DUNE_SIMD_ASSIGN_OP(AssignPlus, += );
│ │ │ │ -
863 DUNE_SIMD_ASSIGN_OP(AssignMinus, -= );
│ │ │ │ -
864 DUNE_SIMD_ASSIGN_OP(AssignLeftShift, <<=);
│ │ │ │ -
865 DUNE_SIMD_ASSIGN_OP(AssignRightShift, >>=);
│ │ │ │ -
866 DUNE_SIMD_ASSIGN_OP(AssignAnd, &= );
│ │ │ │ -
867 DUNE_SIMD_ASSIGN_OP(AssignXor, ^= );
│ │ │ │ -
868 DUNE_SIMD_ASSIGN_OP(AssignOr, |= );
│ │ │ │ -
869
│ │ │ │ -
870#undef DUNE_SIMD_INFIX_OP
│ │ │ │ -
871#undef DUNE_SIMD_REPL_OP
│ │ │ │ -
872#undef DUNE_SIMD_ASSIGN_OP
│ │ │ │ -
873
│ │ │ │ -
874 // just used as a tag
│ │ │ │ -
875 struct OpInfixComma {};
│ │ │ │ -
876
│ │ │ │ -
877 template<class T1, class T2>
│ │ │ │ -
878 void checkCommaOp(const std::decay_t<T1> &val1,
│ │ │ │ -
879 const std::decay_t<T2> &val2)
│ │ │ │ -
880 {
│ │ │ │ -
881#define DUNE_SIMD_OPNAME (className<OpInfixComma(T1, T2)>())
│ │ │ │ -
882 static_assert(std::is_same<decltype((std::declval<T1>(),
│ │ │ │ -
883 std::declval<T2>())), T2>::value,
│ │ │ │ -
884 "Type and value category of the comma operator must "
│ │ │ │ -
885 "match that of the second operand");
│ │ │ │ -
886
│ │ │ │ -
887 // copy the arguments in case T1 or T2 are references
│ │ │ │ -
888 auto arg1 = val1;
│ │ │ │ -
889 auto arg2 = val2;
│ │ │ │ -
890 // Do not warn that the left side of the comma operator is unused.
│ │ │ │ -
891 // Seems to work for g++-4.9 and clang++-3.8. Appears to be harmless
│ │ │ │ -
892 // for icpc (14 and 17), and icpc does not seem to issue a warning
│ │ │ │ -
893 // anyway.
│ │ │ │ -
894#pragma GCC diagnostic push
│ │ │ │ -
895#pragma GCC diagnostic ignored "-Wunused-value"
│ │ │ │ -
896 auto &&result = (static_cast<T1>(arg1),
│ │ │ │ -
897 static_cast<T2>(arg2));
│ │ │ │ -
898#pragma GCC diagnostic pop
│ │ │ │ -
899 if(std::is_reference<T2>::value)
│ │ │ │ -
900 {
│ │ │ │ -
901 // comma should return the same object as the second argument for
│ │ │ │ -
902 // lvalues and xvalues
│ │ │ │ -
903 DUNE_SIMD_CHECK_OP(&result == &arg2);
│ │ │ │ -
904 // it should not modify any arguments
│ │ │ │ -
905 DUNE_SIMD_CHECK_OP(allTrue(val1 == arg1));
│ │ │ │ -
906 DUNE_SIMD_CHECK_OP(allTrue(val2 == arg2));
│ │ │ │ -
907 }
│ │ │ │ -
908 else
│ │ │ │ -
909 {
│ │ │ │ -
910 // comma should return the same value as the second argument for
│ │ │ │ -
911 // prvalues
│ │ │ │ -
912 DUNE_SIMD_CHECK_OP(allTrue(result == arg2));
│ │ │ │ -
913 // it should not modify any arguments
│ │ │ │ -
914 DUNE_SIMD_CHECK_OP(allTrue(val1 == arg1));
│ │ │ │ -
915 // second argument is a prvalue, any modifications happen to a
│ │ │ │ -
916 // temporary and we can't detect them
│ │ │ │ -
917 }
│ │ │ │ -
918#undef DUNE_SIMD_OPNAME
│ │ │ │ -
919 }
│ │ │ │ -
920
│ │ │ │ -
922 //
│ │ │ │ -
923 // checks for vector-vector binary operations
│ │ │ │ -
924 //
│ │ │ │ -
925
│ │ │ │ -
926 // We check the following candidate operation
│ │ │ │ -
927 //
│ │ │ │ -
928 // vopres = vop1 @ vop2
│ │ │ │ -
929 //
│ │ │ │ -
930 // against the reference operation
│ │ │ │ -
931 //
│ │ │ │ -
932 // arefres[l] = aref1[l] @ aref2[l] foreach l
│ │ │ │ -
933 //
│ │ │ │ -
934 // v... variables are simd-vectors and a... variables are arrays. The
│ │ │ │ -
935 // operation may modify the operands, but if is does the modification
│ │ │ │ -
936 // needs to happen in both the candidate and the reference.
│ │ │ │ -
937 //
│ │ │ │ -
938 // We do the following checks:
│ │ │ │ -
939 // 1. lanes(vopres) == lanes(vop1)
│ │ │ │ -
940 // 2. lane(l, vopres) == arefres[l] foreach l
│ │ │ │ -
941 // 3. lane(l, vop1) == aref1[l] foreach l
│ │ │ │ -
942 // 4. lane(l, vop2) == aref2[l] foreach l
│ │ │ │ -
943 template<class V1, class V2, class Op>
│ │ │ │ -
944 std::enable_if_t<Std::is_detected_v<ScalarResult, Op, V1, V2> >
│ │ │ │ -
945 checkBinaryOpVV(MetaType<V1>, MetaType<V2>, Op op)
│ │ │ │ -
946 {
│ │ │ │ -
947#define DUNE_SIMD_OPNAME (className<Op(V1, V2)>())
│ │ │ │ -
948 static_assert(std::is_same<std::decay_t<V1>, std::decay_t<V2> >::value,
│ │ │ │ -
949 "Internal testsystem error: called with two types that "
│ │ │ │ -
950 "don't decay to the same thing");
│ │ │ │ -
951
│ │ │ │ -
952 // reference arguments
│ │ │ │ -
953 auto vref1 = leftVector<std::decay_t<V1>>();
│ │ │ │ -
954 auto vref2 = rightVector<std::decay_t<V2>>();
│ │ │ │ -
955
│ │ │ │ -
956 // candidate arguments
│ │ │ │ -
957 auto vop1 = vref1;
│ │ │ │ -
958 auto vop2 = vref2;
│ │ │ │ -
959
│ │ │ │ -
960 // candidate operation
│ │ │ │ -
961 auto &&vopres = op(static_cast<V1>(vop1), static_cast<V2>(vop2));
│ │ │ │ -
962 using VR = decltype(vopres);
│ │ │ │ -
963
│ │ │ │ -
964 // check 1. lanes(vopres) == lanes(vop1)
│ │ │ │ -
965 static_assert(lanes<std::decay_t<VR> >() == lanes<std::decay_t<V1> >(),
│ │ │ │ -
966 "The result must have the same number of lanes as the "
│ │ │ │ -
967 "operands.");
│ │ │ │ -
968
│ │ │ │ -
969 // do the reference operation, and simultaneously
│ │ │ │ -
970 // check 2. lane(l, vopres) == arefres[l] foreach l
│ │ │ │ -
971 using T = Scalar<std::decay_t<VR> >;
│ │ │ │ -
972 for(auto l : range(lanes(vopres)))
│ │ │ │ -
973 {
│ │ │ │ -
974 // see the lengthy comment in `checkUnaryOpV()` as to why the
│ │ │ │ -
975 // `static_cast` around the `op()` is necessary
│ │ │ │ - │ │ │ │ -
977 (lane(l, vopres)
│ │ │ │ -
978 == static_cast<T>(op(lane(l, static_cast<V1>(vref1)),
│ │ │ │ -
979 lane(l, static_cast<V2>(vref2)))));
│ │ │ │ -
980 }
│ │ │ │ -
981
│ │ │ │ -
982 // check 3. lane(l, vop1) == aref1[l] foreach l
│ │ │ │ -
983 for(auto l : range(lanes(vop1)))
│ │ │ │ -
984 DUNE_SIMD_CHECK_OP(lane(l, vop1) == lane(l, vref1));
│ │ │ │ -
985
│ │ │ │ -
986 // check 4. lane(l, vop2) == aref2[l] foreach l
│ │ │ │ -
987 for(auto l : range(lanes(vop2)))
│ │ │ │ -
988 DUNE_SIMD_CHECK_OP(lane(l, vop2) == lane(l, vref2));
│ │ │ │ -
989
│ │ │ │ -
990#undef DUNE_SIMD_OPNAME
│ │ │ │ -
991 }
│ │ │ │ -
992
│ │ │ │ -
993 template<class V1, class V2, class Op>
│ │ │ │ -
994 std::enable_if_t<!Std::is_detected_v<ScalarResult, Op, V1, V2> >
│ │ │ │ -
995 checkBinaryOpVV(MetaType<V1>, MetaType<V2>, Op op)
│ │ │ │ -
996 {
│ │ │ │ -
997 // log_ << "No " << className<Op(decltype(lane(0, std::declval<V1>())),
│ │ │ │ -
998 // decltype(lane(0, std::declval<V2>())))>()
│ │ │ │ -
999 // << std::endl
│ │ │ │ -
1000 // << " ==> Not checking " << className<Op(V1, V2)>() << std::endl;
│ │ │ │ -
1001 }
│ │ │ │ -
1002
│ │ │ │ -
1003 template<class V1, class V2>
│ │ │ │ -
1004 void checkBinaryOpVV(MetaType<V1>, MetaType<V2>, OpInfixComma)
│ │ │ │ -
1005 {
│ │ │ │ -
1006 static_assert(std::is_same<std::decay_t<V1>, std::decay_t<V2> >::value,
│ │ │ │ -
1007 "Internal testsystem error: called with two types that "
│ │ │ │ -
1008 "don't decay to the same thing");
│ │ │ │ -
1009
│ │ │ │ -
1010 checkCommaOp<V1, V2>(leftVector<std::decay_t<V1>>(),
│ │ │ │ -
1011 rightVector<std::decay_t<V2>>());
│ │ │ │ -
1012 }
│ │ │ │ -
1013
│ │ │ │ -
1015 //
│ │ │ │ -
1016 // checks for vector-scalar binary operations
│ │ │ │ -
1017 //
│ │ │ │ -
1018
│ │ │ │ -
1019 // We check the following candidate operation
│ │ │ │ -
1020 //
│ │ │ │ -
1021 // vopres = vop1 @ sop2
│ │ │ │ -
1022 //
│ │ │ │ -
1023 // against the reference operation
│ │ │ │ -
1024 //
│ │ │ │ -
1025 // arefres[l] = aref1[l] @ sref2 foreach l
│ │ │ │ -
1026 //
│ │ │ │ -
1027 // v... variables are simd-vectors, a... variables are arrays, and
│ │ │ │ -
1028 // s... variables are scalars. The operation may modify the left
│ │ │ │ -
1029 // operand, but if is does the modifications needs to happen in both the
│ │ │ │ -
1030 // candidate and the reference.
│ │ │ │ -
1031 //
│ │ │ │ -
1032 // We do the following checks:
│ │ │ │ -
1033 // 1. lanes(vopres) == lanes(vop1)
│ │ │ │ -
1034 // 2. lane(l, vopres) == arefres[l] foreach l
│ │ │ │ -
1035 // 3. lane(l, vop1) == aref1[l] foreach l
│ │ │ │ -
1036 // 4. sop2 is never modified
│ │ │ │ -
1037 // 5. sref2 is never modified
│ │ │ │ -
1038 //
│ │ │ │ -
1039 // In fact, if the property "sref2 is never modified" is violated that
│ │ │ │ -
1040 // means the operation is unsuitable for an automatic broadcast of the
│ │ │ │ -
1041 // second operand and should not be checked. There are no operations in
│ │ │ │ -
1042 // the standard where the second operand is modified like this, but
│ │ │ │ -
1043 // there are operations where the first operand is modified -- and this
│ │ │ │ -
1044 // check is used for those ops as well by exchanging the first and second
│ │ │ │ -
1045 // argument below.
│ │ │ │ -
1046
│ │ │ │ -
1047 template<class V1, class T2, class Op>
│ │ │ │ -
1048 std::enable_if_t<Std::is_detected_v<ScalarResult, Op, V1, T2> >
│ │ │ │ -
1049 checkBinaryOpVS(MetaType<V1>, MetaType<T2>, Op op)
│ │ │ │ -
1050 {
│ │ │ │ -
1051#define DUNE_SIMD_OPNAME (className<Op(V1, T2)>())
│ │ │ │ -
1052 static_assert(std::is_same<Scalar<std::decay_t<V1> >,
│ │ │ │ -
1053 std::decay_t<T2> >::value,
│ │ │ │ -
1054 "Internal testsystem error: called with a scalar that "
│ │ │ │ -
1055 "does not match the vector type.");
│ │ │ │ -
1056
│ │ │ │ -
1057 // initial values
│ │ │ │ -
1058 auto sinit2 = rightScalar<std::decay_t<T2>>();
│ │ │ │ -
1059
│ │ │ │ -
1060 // reference arguments
│ │ │ │ -
1061 auto vref1 = leftVector<std::decay_t<V1>>();
│ │ │ │ -
1062 auto sref2 = sinit2;
│ │ │ │ -
1063
│ │ │ │ -
1064 // candidate arguments
│ │ │ │ -
1065 auto vop1 = vref1;
│ │ │ │ -
1066 auto sop2 = sref2;
│ │ │ │ -
1067
│ │ │ │ -
1068 // candidate operation
│ │ │ │ -
1069 auto &&vopres = op(static_cast<V1>(vop1), static_cast<T2>(sop2));
│ │ │ │ -
1070 using VR = decltype(vopres);
│ │ │ │ -
1071
│ │ │ │ -
1072 // check 1. lanes(vopres) == lanes(vop1)
│ │ │ │ -
1073 static_assert(lanes<std::decay_t<VR> >() == lanes<std::decay_t<V1> >(),
│ │ │ │ -
1074 "The result must have the same number of lanes as the "
│ │ │ │ -
1075 "operands.");
│ │ │ │ -
1076
│ │ │ │ -
1077 // check 4. sop2 is never modified
│ │ │ │ -
1078 DUNE_SIMD_CHECK_OP(sop2 == sinit2);
│ │ │ │ -
1079
│ │ │ │ -
1080 // do the reference operation, and simultaneously check 2. and 5.
│ │ │ │ -
1081 using T = Scalar<std::decay_t<decltype(vopres)> >;
│ │ │ │ -
1082 for(auto l : range(lanes(vopres)))
│ │ │ │ -
1083 {
│ │ │ │ -
1084 // check 2. lane(l, vopres) == arefres[l] foreach l
│ │ │ │ -
1085 // see the lengthy comment in `checkUnaryOpV()` as to why the
│ │ │ │ -
1086 // `static_cast` around the `op()` is necessary
│ │ │ │ - │ │ │ │ -
1088 (lane(l, vopres)
│ │ │ │ -
1089 == static_cast<T>(op(lane(l, static_cast<V1>(vref1)),
│ │ │ │ -
1090 static_cast<T2>(sref2) )));
│ │ │ │ -
1091 // check 5. sref2 is never modified
│ │ │ │ -
1092 DUNE_SIMD_CHECK_OP(sref2 == sinit2);
│ │ │ │ -
1093 }
│ │ │ │ -
1094
│ │ │ │ -
1095 // check 3. lane(l, vop1) == aref1[l] foreach l
│ │ │ │ -
1096 for(auto l : range(lanes(vop1)))
│ │ │ │ -
1097 DUNE_SIMD_CHECK_OP(lane(l, vop1) == lane(l, vref1));
│ │ │ │ -
1098
│ │ │ │ -
1099#undef DUNE_SIMD_OPNAME
│ │ │ │ -
1100 }
│ │ │ │ -
1101
│ │ │ │ -
1102 template<class V1, class T2, class Op>
│ │ │ │ -
1103 std::enable_if_t<!Std::is_detected_v<ScalarResult, Op, V1, T2> >
│ │ │ │ -
1104 checkBinaryOpVS(MetaType<V1>, MetaType<T2>, Op op)
│ │ │ │ -
1105 {
│ │ │ │ -
1106 // log_ << "No "
│ │ │ │ -
1107 // << className<Op(decltype(lane(0, std::declval<V1>())), T2)>()
│ │ │ │ -
1108 // << std::endl
│ │ │ │ -
1109 // << " ==> Not checking " << className<Op(V1, T2)>() << std::endl;
│ │ │ │ -
1110 }
│ │ │ │ -
1111
│ │ │ │ -
1112 template<class V1, class T2>
│ │ │ │ -
1113 void checkBinaryOpVS(MetaType<V1>, MetaType<T2>, OpInfixComma)
│ │ │ │ -
1114 {
│ │ │ │ -
1115 static_assert(std::is_same<Scalar<std::decay_t<V1> >,
│ │ │ │ -
1116 std::decay_t<T2> >::value,
│ │ │ │ -
1117 "Internal testsystem error: called with a scalar that "
│ │ │ │ -
1118 "does not match the vector type.");
│ │ │ │ -
1119
│ │ │ │ -
1120 checkCommaOp<V1, T2>(leftVector<std::decay_t<V1>>(),
│ │ │ │ -
1121 rightScalar<std::decay_t<T2>>());
│ │ │ │ -
1122 }
│ │ │ │ -
1123
│ │ │ │ -
1125 //
│ │ │ │ -
1126 // cross-check scalar-vector binary operations against vector-vector
│ │ │ │ -
1127 //
│ │ │ │ -
1128
│ │ │ │ -
1129 // We check the following candidate operation
│ │ │ │ -
1130 //
│ │ │ │ -
1131 // vopres = vop1 @ vop2, where vop2 = broadcast(sref2)
│ │ │ │ -
1132 //
│ │ │ │ -
1133 // against the reference operation
│ │ │ │ -
1134 //
│ │ │ │ -
1135 // vrefres = vref1 @ sref2
│ │ │ │ -
1136 //
│ │ │ │ -
1137 // v... variables are simd-vectors, a... variables are arrays, and
│ │ │ │ -
1138 // s... variables are scalars.
│ │ │ │ -
1139 //
│ │ │ │ -
1140 // We could check the following properties
│ │ │ │ -
1141 // 1. lanes(vopres) == lanes(vop1)
│ │ │ │ -
1142 // 2. lane(l, vopres) == lane(l, vrefres) foreach l
│ │ │ │ -
1143 // 3. lane(l, vop1) == lane(l, vref1) foreach l
│ │ │ │ -
1144 // but these are given by checking the operation against the scalar
│ │ │ │ -
1145 // operation in the vector@vector and vector@scalar cases above.
│ │ │ │ -
1146 //
│ │ │ │ -
1147 // The only thing left to check is:
│ │ │ │ -
1148 // 4. lane(l, vop2) foreach l is never modified
│ │ │ │ -
1149
│ │ │ │ -
1150 template<class V1, class T2, class Op>
│ │ │ │ -
1151 std::enable_if_t<Std::is_detected_v<ScalarResult, Op, V1, T2> >
│ │ │ │ -
1152 checkBinaryOpVVAgainstVS(MetaType<V1>, MetaType<T2>, Op op)
│ │ │ │ -
1153 {
│ │ │ │ -
1154#define DUNE_SIMD_OPNAME (className<Op(V1, T2)>())
│ │ │ │ -
1155 static_assert(std::is_same<Scalar<std::decay_t<V1> >,
│ │ │ │ -
1156 std::decay_t<T2> >::value,
│ │ │ │ -
1157 "Internal testsystem error: called with a scalar that "
│ │ │ │ -
1158 "does not match the vector type.");
│ │ │ │ -
1159
│ │ │ │ -
1160 // initial values
│ │ │ │ -
1161 auto sinit2 = rightScalar<std::decay_t<T2>>();
│ │ │ │ -
1162
│ │ │ │ -
1163 // reference arguments
│ │ │ │ -
1164 auto vop1 = leftVector<std::decay_t<V1>>();
│ │ │ │ -
1165 using V2 = CopyRefQual<V1, T2>;
│ │ │ │ -
1166 std::decay_t<V2> vop2(sinit2);
│ │ │ │ -
1167
│ │ │ │ -
1168 // candidate operation
│ │ │ │ -
1169 op(static_cast<V1>(vop1), static_cast<V2>(vop2));
│ │ │ │ -
1170
│ │ │ │ -
1171 // 4. lane(l, vop2) foreach l is never modified
│ │ │ │ -
1172 for(auto l : range(lanes(vop2)))
│ │ │ │ -
1173 DUNE_SIMD_CHECK_OP(lane(l, vop2) == sinit2);
│ │ │ │ -
1174
│ │ │ │ -
1175#undef DUNE_SIMD_OPNAME
│ │ │ │ -
1176 }
│ │ │ │ -
1177
│ │ │ │ -
1178 template<class V1, class T2, class Op>
│ │ │ │ -
1179 std::enable_if_t<!Std::is_detected_v<ScalarResult, Op, V1, T2> >
│ │ │ │ -
1180 checkBinaryOpVVAgainstVS(MetaType<V1>, MetaType<T2>, Op op)
│ │ │ │ -
1181 {
│ │ │ │ -
1182 // log_ << "No "
│ │ │ │ -
1183 // << className<Op(decltype(lane(0, std::declval<V1>())), T2)>()
│ │ │ │ -
1184 // << std::endl
│ │ │ │ -
1185 // << " ==> Not checking " << className<Op(V1, T2)>() << std::endl;
│ │ │ │ -
1186 }
│ │ │ │ -
1187
│ │ │ │ -
1188 template<class V1, class T2>
│ │ │ │ -
1189 void checkBinaryOpVVAgainstVS(MetaType<V1>, MetaType<T2>, OpInfixComma)
│ │ │ │ -
1190 { }
│ │ │ │ -
1191
│ │ │ │ -
1193 //
│ │ │ │ -
1194 // checks for vector-proxy binary operations
│ │ │ │ -
1195 //
│ │ │ │ -
1196
│ │ │ │ -
1197 // We check the following candidate operation
│ │ │ │ -
1198 //
│ │ │ │ -
1199 // vopres = vop1 @ pop2
│ │ │ │ -
1200 //
│ │ │ │ -
1201 // against the reference operation
│ │ │ │ -
1202 //
│ │ │ │ -
1203 // arefres[l] = aref1[l] @ sref2 foreach l
│ │ │ │ -
1204 //
│ │ │ │ -
1205 // v... variables are simd-vectors, a... variables are arrays,
│ │ │ │ -
1206 // p... variables are proxies of simd-vector entries and s... variables
│ │ │ │ -
1207 // are scalars. The operation may modify the left operand, but if is
│ │ │ │ -
1208 // does the modifications needs to happen in both the candidate and the
│ │ │ │ -
1209 // reference.
│ │ │ │ -
1210 //
│ │ │ │ -
1211 // We do the following checks:
│ │ │ │ -
1212 // 1. lanes(vopres) == lanes(vop1)
│ │ │ │ -
1213 // 2. lane(l, vopres) == arefres[l] foreach l
│ │ │ │ -
1214 // 3. lane(l, vop1) == aref1[l] foreach l
│ │ │ │ -
1215 // 4. pop2 is never modified
│ │ │ │ -
1216 // 5. sref2 is never modified
│ │ │ │ -
1217 //
│ │ │ │ -
1218 // In fact, if the property "sref2 is never modified" is violated that
│ │ │ │ -
1219 // means the operation is unsuitable for an automatic broadcast of the
│ │ │ │ -
1220 // second operand and should not be checked. There are no operations in
│ │ │ │ -
1221 // the standard where the second operand is modified like this, but
│ │ │ │ -
1222 // there are operations where the first operand is modified -- and this
│ │ │ │ -
1223 // check is used for those ops as well by exchanging the first and second
│ │ │ │ -
1224 // argument below.
│ │ │ │ -
1225
│ │ │ │ -
1226 template<class V1, class V2, class Op>
│ │ │ │ -
1227 std::enable_if_t<Std::is_detected_v<ScalarResult, Op, V1, V2> >
│ │ │ │ -
1228 checkBinaryOpVP(MetaType<V1>, MetaType<V2>, Op op)
│ │ │ │ -
1229 {
│ │ │ │ -
1230 using P2 = decltype(lane(0, std::declval<V2>()));
│ │ │ │ -
1231 using T2 = CopyRefQual<Scalar<V2>, V2>;
│ │ │ │ -
1232#define DUNE_SIMD_OPNAME (className<Op(V1, P2)>())
│ │ │ │ -
1233 static_assert(std::is_same<Scalar<V1>, Scalar<V2> >::value,
│ │ │ │ -
1234 "Internal testsystem error: called with two vector "
│ │ │ │ -
1235 "types whose scalar types don't match.");
│ │ │ │ -
1236
│ │ │ │ -
1237 // initial values
│ │ │ │ -
1238 auto sinit2 = rightScalar<Scalar<V2>>();
│ │ │ │ -
1239
│ │ │ │ -
1240 // reference arguments
│ │ │ │ -
1241 auto vref1 = leftVector<std::decay_t<V1>>();
│ │ │ │ -
1242 auto sref2 = sinit2;
│ │ │ │ -
1243
│ │ │ │ -
1244 // candidate arguments
│ │ │ │ -
1245 auto vop1 = vref1;
│ │ │ │ -
1246 auto vop2 = std::decay_t<V2>(Scalar<V2>(0));
│ │ │ │ -
1247 lane(0, vop2) = sref2; // pop2 is just a name for `lane(0, vop2)`
│ │ │ │ -
1248
│ │ │ │ -
1249 // candidate operation
│ │ │ │ -
1250 auto &&vopres =
│ │ │ │ -
1251 op(static_cast<V1>(vop1), lane(0, static_cast<V2>(vop2)));
│ │ │ │ -
1252 using VR = decltype(vopres);
│ │ │ │ -
1253
│ │ │ │ -
1254 // check 1. lanes(vopres) == lanes(vop1)
│ │ │ │ -
1255 static_assert(lanes<std::decay_t<VR> >() == lanes<std::decay_t<V1> >(),
│ │ │ │ -
1256 "The result must have the same number of lanes as the "
│ │ │ │ -
1257 "operands.");
│ │ │ │ -
1258
│ │ │ │ -
1259 // check 4. pop2 is never modified
│ │ │ │ -
1260 DUNE_SIMD_CHECK_OP(lane(0, vop2) == sinit2);
│ │ │ │ -
1261
│ │ │ │ -
1262 // do the reference operation, and simultaneously check 2. and 5.
│ │ │ │ -
1263 using T = Scalar<decltype(vopres)>;
│ │ │ │ -
1264 for(auto l : range(lanes(vopres)))
│ │ │ │ -
1265 {
│ │ │ │ -
1266 // check 2. lane(l, vopres) == arefres[l] foreach l
│ │ │ │ -
1267 // see the lengthy comment in `checkUnaryOpV()` as to why the
│ │ │ │ -
1268 // `static_cast` around the `op()` is necessary
│ │ │ │ - │ │ │ │ -
1270 (lane(l, vopres)
│ │ │ │ -
1271 == static_cast<T>(op(lane(l, static_cast<V1>(vref1)),
│ │ │ │ -
1272 static_cast<T2>(sref2) )));
│ │ │ │ -
1273 // check 5. sref2 is never modified
│ │ │ │ -
1274 DUNE_SIMD_CHECK_OP(sref2 == sinit2);
│ │ │ │ -
1275 }
│ │ │ │ -
1276
│ │ │ │ -
1277 // check 3. lane(l, vop1) == aref1[l] foreach l
│ │ │ │ -
1278 for(auto l : range(lanes(vop1)))
│ │ │ │ -
1279 DUNE_SIMD_CHECK_OP(lane(l, vop1) == lane(l, vref1));
│ │ │ │ -
1280
│ │ │ │ -
1281#undef DUNE_SIMD_OPNAME
│ │ │ │ -
1282 }
│ │ │ │ -
1283
│ │ │ │ -
1284 template<class V1, class V2, class Op>
│ │ │ │ -
1285 std::enable_if_t<!Std::is_detected_v<ScalarResult, Op, V1, V2> >
│ │ │ │ -
1286 checkBinaryOpVP(MetaType<V1>, MetaType<V2>, Op op)
│ │ │ │ -
1287 {
│ │ │ │ -
1288 // log_ << "No "
│ │ │ │ -
1289 // << className<Op(decltype(lane(0, std::declval<V1>())), T2)>()
│ │ │ │ -
1290 // << std::endl
│ │ │ │ -
1291 // << " ==> Not checking " << className<Op(V1, T2)>() << std::endl;
│ │ │ │ -
1292 }
│ │ │ │ -
1293
│ │ │ │ -
1294 template<class V1, class V2>
│ │ │ │ -
1295 void checkBinaryOpVP(MetaType<V1>, MetaType<V2>, OpInfixComma)
│ │ │ │ -
1296 {
│ │ │ │ -
1297 // Don't really know how to check comma operator for proxies
│ │ │ │ -
1298 }
│ │ │ │ -
1299
│ │ │ │ -
1301 //
│ │ │ │ -
1302 // checks for (scalar/proxy)-vector binary operations
│ │ │ │ -
1303 //
│ │ │ │ -
1304
│ │ │ │ -
1305 template<class Op>
│ │ │ │ -
1306 struct OpInfixSwappedArgs
│ │ │ │ -
1307 {
│ │ │ │ -
1308 Op orig;
│ │ │ │ -
1309
│ │ │ │ -
1310 template<class V1, class V2>
│ │ │ │ -
1311 decltype(auto) operator()(V1&& v1, V2&& v2) const
│ │ │ │ -
1312 {
│ │ │ │ -
1313 return orig(std::forward<V2>(v2), std::forward<V1>(v1));
│ │ │ │ -
1314 }
│ │ │ │ -
1315 template<class S1, class S2>
│ │ │ │ -
1316 auto scalar(S1&& s1, S2&& s2) const
│ │ │ │ -
1317 -> decltype(orig.scalar(std::forward<S2>(s2), std::forward<S1>(s1)));
│ │ │ │ -
1318 };
│ │ │ │ -
1319
│ │ │ │ -
1320 template<class T1, class V2, class Op>
│ │ │ │ -
1321 void checkBinaryOpSV(MetaType<T1> t1, MetaType<V2> v2, Op op)
│ │ │ │ -
1322 {
│ │ │ │ -
1323 checkBinaryOpVS(v2, t1, OpInfixSwappedArgs<Op>{op});
│ │ │ │ -
1324 }
│ │ │ │ -
1325
│ │ │ │ -
1326 template<class T1, class V2>
│ │ │ │ -
1327 void checkBinaryOpSV(MetaType<T1>, MetaType<V2>, OpInfixComma)
│ │ │ │ -
1328 {
│ │ │ │ -
1329 static_assert(std::is_same<std::decay_t<T1>,
│ │ │ │ -
1330 Scalar<std::decay_t<V2> > >::value,
│ │ │ │ -
1331 "Internal testsystem error: called with a scalar that "
│ │ │ │ -
1332 "does not match the vector type.");
│ │ │ │ -
1333
│ │ │ │ -
1334 checkCommaOp<T1, V2>(leftScalar<std::decay_t<T1>>(),
│ │ │ │ -
1335 rightVector<std::decay_t<V2>>());
│ │ │ │ -
1336 }
│ │ │ │ -
1337
│ │ │ │ -
1338 template<class V1, class V2, class Op>
│ │ │ │ -
1339 void checkBinaryOpPV(MetaType<V1> v1, MetaType<V2> v2, Op op)
│ │ │ │ -
1340 {
│ │ │ │ -
1341 checkBinaryOpVP(v2, v1, OpInfixSwappedArgs<Op>{op});
│ │ │ │ -
1342 }
│ │ │ │ -
1343
│ │ │ │ -
1344 template<class V1, class V2>
│ │ │ │ -
1345 void checkBinaryOpPV(MetaType<V1>, MetaType<V2>, OpInfixComma)
│ │ │ │ -
1346 {
│ │ │ │ -
1347 // Don't really know how to check comma operator for proxies
│ │ │ │ -
1348 }
│ │ │ │ -
1349
│ │ │ │ -
1351 //
│ │ │ │ -
1352 // cross-check scalar-vector binary operations against vector-vector
│ │ │ │ -
1353 //
│ │ │ │ -
1354
│ │ │ │ -
1355 // We check the following candidate operation
│ │ │ │ -
1356 //
│ │ │ │ -
1357 // vopres = vop1 @ vop2, where vop2 = broadcast(sref2)
│ │ │ │ -
1358 //
│ │ │ │ -
1359 // against the reference operation
│ │ │ │ -
1360 //
│ │ │ │ -
1361 // vrefres = vref1 @ sref2
│ │ │ │ -
1362 //
│ │ │ │ -
1363 // v... variables are simd-vectors, a... variables are arrays, and
│ │ │ │ -
1364 // s... variables are scalars.
│ │ │ │ -
1365 //
│ │ │ │ -
1366 // We could check the following properties
│ │ │ │ -
1367 // 1. lanes(vopres) == lanes(vop1)
│ │ │ │ -
1368 // 2. lane(l, vopres) == lane(l, vrefres) foreach l
│ │ │ │ -
1369 // 3. lane(l, vop1) == lane(l, vref1) foreach l
│ │ │ │ -
1370 // but these are given by checking the operation against the scalar
│ │ │ │ -
1371 // operation in the vector@vector and vector@scalar cases above.
│ │ │ │ -
1372 //
│ │ │ │ -
1373 // The only thing left to check is:
│ │ │ │ -
1374 // 4. lane(l, vop2) foreach l is never modified
│ │ │ │ -
1375
│ │ │ │ -
1376 template<class T1, class V2, class Op>
│ │ │ │ -
1377 void checkBinaryOpVVAgainstSV(MetaType<T1> t1, MetaType<V2> v2, Op op)
│ │ │ │ -
1378 {
│ │ │ │ -
1379 checkBinaryOpVVAgainstVS(v2, t1, OpInfixSwappedArgs<Op>{op});
│ │ │ │ -
1380 }
│ │ │ │ -
1381
│ │ │ │ -
1382 template<class V1, class T2>
│ │ │ │ -
1383 void checkBinaryOpVVAgainstSV(MetaType<V1>, MetaType<T2>, OpInfixComma)
│ │ │ │ -
1384 { }
│ │ │ │ -
1385
│ │ │ │ -
1387 //
│ │ │ │ -
1388 // Invoke the checks for all combinations
│ │ │ │ -
1389 //
│ │ │ │ -
1390
│ │ │ │ -
1391 template<class T1, class T2, bool condition, class Checker>
│ │ │ │ -
1392 void checkBinaryRefQual(Checker checker)
│ │ │ │ -
1393 {
│ │ │ │ -
1394 if constexpr (condition) {
│ │ │ │ -
1395 Hybrid::forEach(TypeList<T1&, const T1&, T1&&>{}, [=] (auto t1) {
│ │ │ │ -
1396 Hybrid::forEach(TypeList<T2&, const T2&, T2&&>{}, [=] (auto t2) {
│ │ │ │ -
1397 checker(t1, t2);
│ │ │ │ -
1398 });
│ │ │ │ -
1399 });
│ │ │ │ -
1400 }
│ │ │ │ -
1401 }
│ │ │ │ -
1402
│ │ │ │ -
1403 template<class V, class Checker>
│ │ │ │ -
1404 void checkBinaryOps(Checker checker)
│ │ │ │ -
1405 {
│ │ │ │ -
1406 using Std::bool_constant;
│ │ │ │ -
1407
│ │ │ │ -
1408 constexpr bool isMask = std::is_same<Scalar<V>, bool>::value;
│ │ │ │ -
1409
│ │ │ │ -
1410 constexpr bool do_ = false;
│ │ │ │ -
1411 constexpr bool do_SV = true;
│ │ │ │ -
1412 constexpr bool do_VV = true;
│ │ │ │ -
1413 constexpr bool do_VS = true;
│ │ │ │ -
1414
│ │ │ │ -
1415#define DUNE_SIMD_DO(M1, M2, M3, V1, V2, V3, NAME) \
│ │ │ │ -
1416 checker(bool_constant<isMask ? do_##M1 : do_##V1>{}, \
│ │ │ │ -
1417 bool_constant<isMask ? do_##M2 : do_##V2>{}, \
│ │ │ │ -
1418 bool_constant<isMask ? do_##M3 : do_##V3>{}, \
│ │ │ │ -
1419 Op##NAME{})
│ │ │ │ -
1420
│ │ │ │ -
1421 // (Mask , Vector , Name );
│ │ │ │ -
1422
│ │ │ │ -
1423 DUNE_SIMD_DO( , , , SV, VV, VS, InfixMul );
│ │ │ │ -
1424 DUNE_SIMD_DO( , , , SV, VV, VS, InfixDiv );
│ │ │ │ -
1425 DUNE_SIMD_DO( , , , SV, VV, VS, InfixRemainder );
│ │ │ │ -
1426
│ │ │ │ -
1427 DUNE_SIMD_DO( , , , SV, VV, VS, InfixPlus );
│ │ │ │ -
1428 DUNE_SIMD_DO( , , , SV, VV, VS, InfixMinus );
│ │ │ │ -
1429
│ │ │ │ -
1430 DUNE_SIMD_DO( , , , , VV, VS, InfixLeftShift );
│ │ │ │ -
1431 DUNE_SIMD_DO( , , , , VV, VS, InfixRightShift );
│ │ │ │ -
1432
│ │ │ │ -
1433 DUNE_SIMD_DO( , , , SV, VV, VS, InfixLess );
│ │ │ │ -
1434 DUNE_SIMD_DO( , , , SV, VV, VS, InfixGreater );
│ │ │ │ -
1435 DUNE_SIMD_DO( , , , SV, VV, VS, InfixLessEqual );
│ │ │ │ -
1436 DUNE_SIMD_DO( , , , SV, VV, VS, InfixGreaterEqual );
│ │ │ │ -
1437
│ │ │ │ -
1438 DUNE_SIMD_DO( , , , SV, VV, VS, InfixEqual );
│ │ │ │ -
1439 DUNE_SIMD_DO( , , , SV, VV, VS, InfixNotEqual );
│ │ │ │ -
1440
│ │ │ │ -
1441 DUNE_SIMD_DO( , VV, , SV, VV, VS, InfixBitAnd );
│ │ │ │ -
1442 DUNE_SIMD_DO( , VV, , SV, VV, VS, InfixBitXor );
│ │ │ │ -
1443 DUNE_SIMD_DO( , VV, , SV, VV, VS, InfixBitOr );
│ │ │ │ -
1444
│ │ │ │ -
1445 DUNE_SIMD_DO(SV, VV, VS, SV, VV, VS, InfixLogicAnd );
│ │ │ │ -
1446 DUNE_SIMD_DO(SV, VV, VS, SV, VV, VS, InfixLogicOr );
│ │ │ │ -
1447
│ │ │ │ -
1448 DUNE_SIMD_DO( , VV, , , VV, VS, InfixAssign );
│ │ │ │ -
1449 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignMul );
│ │ │ │ -
1450 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignDiv );
│ │ │ │ -
1451 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignRemainder );
│ │ │ │ -
1452 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignPlus );
│ │ │ │ -
1453 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignMinus );
│ │ │ │ -
1454 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignLeftShift );
│ │ │ │ -
1455 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignRightShift);
│ │ │ │ -
1456 DUNE_SIMD_DO( , VV, , , VV, VS, InfixAssignAnd );
│ │ │ │ -
1457 DUNE_SIMD_DO( , VV, , , VV, VS, InfixAssignXor );
│ │ │ │ -
1458 DUNE_SIMD_DO( , VV, , , VV, VS, InfixAssignOr );
│ │ │ │ -
1459
│ │ │ │ -
1460 DUNE_SIMD_DO(SV, VV, VS, SV, , VS, InfixComma );
│ │ │ │ -
1461
│ │ │ │ -
1462#undef DUNE_SIMD_DO
│ │ │ │ -
1463 }
│ │ │ │ -
1464
│ │ │ │ -
1466 //
│ │ │ │ -
1467 // SIMD interface functions
│ │ │ │ -
1468 //
│ │ │ │ -
1469
│ │ │ │ -
1470 template<class V>
│ │ │ │ -
1471 void checkAutoCopy()
│ │ │ │ -
1472 {
│ │ │ │ -
1473 using RValueResult = decltype(autoCopy(lane(0, std::declval<V>())));
│ │ │ │ -
1474 static_assert(std::is_same<RValueResult, Scalar<V> >::value,
│ │ │ │ -
1475 "Result of autoCopy() must always be Scalar<V>");
│ │ │ │ -
1476
│ │ │ │ -
1477 using MutableLValueResult =
│ │ │ │ -
1478 decltype(autoCopy(lane(0, std::declval<V&>())));
│ │ │ │ -
1479 static_assert(std::is_same<MutableLValueResult, Scalar<V> >::value,
│ │ │ │ -
1480 "Result of autoCopy() must always be Scalar<V>");
│ │ │ │ -
1481
│ │ │ │ -
1482 using ConstLValueResult =
│ │ │ │ -
1483 decltype(autoCopy(lane(0, std::declval<const V&>())));
│ │ │ │ -
1484 static_assert(std::is_same<ConstLValueResult, Scalar<V> >::value,
│ │ │ │ -
1485 "Result of autoCopy() must always be Scalar<V>");
│ │ │ │ -
1486
│ │ │ │ -
1487 V vec = make123<V>();
│ │ │ │ -
1488 for(std::size_t l = 0; l < lanes(vec); ++l)
│ │ │ │ -
1489 DUNE_SIMD_CHECK(autoCopy(lane(l, vec)) == Scalar<V>(l+1));
│ │ │ │ -
1490 }
│ │ │ │ -
1491
│ │ │ │ -
1492 // may only be called for mask types
│ │ │ │ -
1493 template<class M>
│ │ │ │ -
1494 void checkBoolReductions()
│ │ │ │ -
1495 {
│ │ │ │ -
1496 M trueVec(true);
│ │ │ │ -
1497
│ │ │ │ -
1498 // mutable lvalue
│ │ │ │ -
1499 DUNE_SIMD_CHECK(allTrue (static_cast<M&>(trueVec)) == true);
│ │ │ │ -
1500 DUNE_SIMD_CHECK(anyTrue (static_cast<M&>(trueVec)) == true);
│ │ │ │ -
1501 DUNE_SIMD_CHECK(allFalse(static_cast<M&>(trueVec)) == false);
│ │ │ │ -
1502 DUNE_SIMD_CHECK(anyFalse(static_cast<M&>(trueVec)) == false);
│ │ │ │ -
1503
│ │ │ │ -
1504 // const lvalue
│ │ │ │ -
1505 DUNE_SIMD_CHECK(allTrue (static_cast<const M&>(trueVec)) == true);
│ │ │ │ -
1506 DUNE_SIMD_CHECK(anyTrue (static_cast<const M&>(trueVec)) == true);
│ │ │ │ -
1507 DUNE_SIMD_CHECK(allFalse(static_cast<const M&>(trueVec)) == false);
│ │ │ │ -
1508 DUNE_SIMD_CHECK(anyFalse(static_cast<const M&>(trueVec)) == false);
│ │ │ │ -
1509
│ │ │ │ -
1510 // rvalue
│ │ │ │ -
1511 DUNE_SIMD_CHECK(allTrue (M(true)) == true);
│ │ │ │ -
1512 DUNE_SIMD_CHECK(anyTrue (M(true)) == true);
│ │ │ │ -
1513 DUNE_SIMD_CHECK(allFalse(M(true)) == false);
│ │ │ │ -
1514 DUNE_SIMD_CHECK(anyFalse(M(true)) == false);
│ │ │ │ -
1515
│ │ │ │ -
1516 M falseVec(false);
│ │ │ │ -
1517
│ │ │ │ -
1518 // mutable lvalue
│ │ │ │ -
1519 DUNE_SIMD_CHECK(allTrue (static_cast<M&>(falseVec)) == false);
│ │ │ │ -
1520 DUNE_SIMD_CHECK(anyTrue (static_cast<M&>(falseVec)) == false);
│ │ │ │ -
1521 DUNE_SIMD_CHECK(allFalse(static_cast<M&>(falseVec)) == true);
│ │ │ │ -
1522 DUNE_SIMD_CHECK(anyFalse(static_cast<M&>(falseVec)) == true);
│ │ │ │ -
1523
│ │ │ │ -
1524 // const lvalue
│ │ │ │ -
1525 DUNE_SIMD_CHECK(allTrue (static_cast<const M&>(falseVec)) == false);
│ │ │ │ -
1526 DUNE_SIMD_CHECK(anyTrue (static_cast<const M&>(falseVec)) == false);
│ │ │ │ -
1527 DUNE_SIMD_CHECK(allFalse(static_cast<const M&>(falseVec)) == true);
│ │ │ │ -
1528 DUNE_SIMD_CHECK(anyFalse(static_cast<const M&>(falseVec)) == true);
│ │ │ │ -
1529
│ │ │ │ -
1530 // rvalue
│ │ │ │ -
1531 DUNE_SIMD_CHECK(allTrue (M(false)) == false);
│ │ │ │ -
1532 DUNE_SIMD_CHECK(anyTrue (M(false)) == false);
│ │ │ │ -
1533 DUNE_SIMD_CHECK(allFalse(M(false)) == true);
│ │ │ │ -
1534 DUNE_SIMD_CHECK(anyFalse(M(false)) == true);
│ │ │ │ -
1535
│ │ │ │ -
1536 auto mixedVec = broadcast<M>(0);
│ │ │ │ -
1537 for(std::size_t l = 0; l < lanes(mixedVec); ++l)
│ │ │ │ -
1538 lane(l, mixedVec) = (l % 2);
│ │ │ │ -
1539
│ │ │ │ -
1540 // mutable lvalue
│ │ │ │ - │ │ │ │ -
1542 (allTrue (static_cast<M&>(mixedVec)) == false);
│ │ │ │ - │ │ │ │ -
1544 (anyTrue (static_cast<M&>(mixedVec)) == (lanes<M>() > 1));
│ │ │ │ - │ │ │ │ -
1546 (allFalse(static_cast<M&>(mixedVec)) == (lanes<M>() == 1));
│ │ │ │ - │ │ │ │ -
1548 (anyFalse(static_cast<M&>(mixedVec)) == true);
│ │ │ │ -
1549
│ │ │ │ -
1550 // const lvalue
│ │ │ │ - │ │ │ │ -
1552 (allTrue (static_cast<const M&>(mixedVec)) == false);
│ │ │ │ - │ │ │ │ -
1554 (anyTrue (static_cast<const M&>(mixedVec)) == (lanes<M>() > 1));
│ │ │ │ - │ │ │ │ -
1556 (allFalse(static_cast<const M&>(mixedVec)) == (lanes<M>() == 1));
│ │ │ │ - │ │ │ │ -
1558 (anyFalse(static_cast<const M&>(mixedVec)) == true);
│ │ │ │ -
1559
│ │ │ │ -
1560 // rvalue
│ │ │ │ -
1561 DUNE_SIMD_CHECK(allTrue (M(mixedVec)) == false);
│ │ │ │ -
1562 DUNE_SIMD_CHECK(anyTrue (M(mixedVec)) == (lanes<M>() > 1));
│ │ │ │ -
1563 DUNE_SIMD_CHECK(allFalse(M(mixedVec)) == (lanes<M>() == 1));
│ │ │ │ -
1564 DUNE_SIMD_CHECK(anyFalse(M(mixedVec)) == true);
│ │ │ │ -
1565 }
│ │ │ │ -
1566
│ │ │ │ -
1567 template<class V>
│ │ │ │ -
1568 void checkCond()
│ │ │ │ -
1569 {
│ │ │ │ -
1570 using M = Mask<V>;
│ │ │ │ -
1571
│ │ │ │ -
1572 static_assert
│ │ │ │ -
1573 (std::is_same<decltype(cond(std::declval<M>(), std::declval<V>(),
│ │ │ │ -
1574 std::declval<V>())), V>::value,
│ │ │ │ -
1575 "The result of cond(M, V, V) should have exactly the type V");
│ │ │ │ -
1576
│ │ │ │ -
1577 static_assert
│ │ │ │ -
1578 (std::is_same<decltype(cond(std::declval<const M&>(),
│ │ │ │ -
1579 std::declval<const V&>(),
│ │ │ │ -
1580 std::declval<const V&>())), V>::value,
│ │ │ │ -
1581 "The result of cond(const M&, const V&, const V&) should have "
│ │ │ │ -
1582 "exactly the type V");
│ │ │ │ -
1583
│ │ │ │ -
1584 static_assert
│ │ │ │ -
1585 (std::is_same<decltype(cond(std::declval<M&>(), std::declval<V&>(),
│ │ │ │ -
1586 std::declval<V&>())), V>::value,
│ │ │ │ -
1587 "The result of cond(M&, V&, V&) should have exactly the type V");
│ │ │ │ -
1588
│ │ │ │ -
1589 V vec1 = leftVector<V>();
│ │ │ │ -
1590 V vec2 = rightVector<V>();
│ │ │ │ -
1591
│ │ │ │ -
1592 DUNE_SIMD_CHECK(allTrue(cond(M(true), vec1, vec2) == vec1));
│ │ │ │ -
1593 DUNE_SIMD_CHECK(allTrue(cond(M(false), vec1, vec2) == vec2));
│ │ │ │ -
1594
│ │ │ │ -
1595 auto mixedResult = broadcast<V>(0);
│ │ │ │ -
1596 auto mixedMask = broadcast<M>(false);
│ │ │ │ -
1597 for(std::size_t l = 0; l < lanes(mixedMask); ++l)
│ │ │ │ -
1598 {
│ │ │ │ -
1599 lane(l, mixedMask ) = (l % 2);
│ │ │ │ -
1600 lane(l, mixedResult) = lane(l, (l % 2) ? vec1 : vec2);
│ │ │ │ -
1601 }
│ │ │ │ -
1602
│ │ │ │ -
1603 DUNE_SIMD_CHECK(allTrue(cond(mixedMask, vec1, vec2) == mixedResult));
│ │ │ │ -
1604 }
│ │ │ │ -
1605
│ │ │ │ -
1606 template<class V>
│ │ │ │ -
1607 void checkBoolCond()
│ │ │ │ -
1608 {
│ │ │ │ -
1609 static_assert
│ │ │ │ -
1610 (std::is_same<decltype(cond(std::declval<bool>(), std::declval<V>(),
│ │ │ │ -
1611 std::declval<V>())), V>::value,
│ │ │ │ -
1612 "The result of cond(bool, V, V) should have exactly the type V");
│ │ │ │ -
1613
│ │ │ │ -
1614 static_assert
│ │ │ │ -
1615 (std::is_same<decltype(cond(std::declval<const bool&>(),
│ │ │ │ -
1616 std::declval<const V&>(),
│ │ │ │ -
1617 std::declval<const V&>())), V>::value,
│ │ │ │ -
1618 "The result of cond(const bool&, const V&, const V&) should have "
│ │ │ │ -
1619 "exactly the type V");
│ │ │ │ -
1620
│ │ │ │ -
1621 static_assert
│ │ │ │ -
1622 (std::is_same<decltype(cond(std::declval<bool&>(),
│ │ │ │ -
1623 std::declval<V&>(),
│ │ │ │ -
1624 std::declval<V&>())), V>::value,
│ │ │ │ -
1625 "The result of cond(bool&, V&, V&) should have exactly the type V");
│ │ │ │ -
1626
│ │ │ │ -
1627 V vec1 = leftVector<V>();
│ │ │ │ -
1628 V vec2 = rightVector<V>();
│ │ │ │ -
1629
│ │ │ │ -
1630 DUNE_SIMD_CHECK(allTrue(cond(true, vec1, vec2) == vec1));
│ │ │ │ -
1631 DUNE_SIMD_CHECK(allTrue(cond(false, vec1, vec2) == vec2));
│ │ │ │ -
1632 }
│ │ │ │ -
1633
│ │ │ │ -
1634 template<class V>
│ │ │ │ -
1635 std::enable_if_t<!Impl::LessThenComparable<Scalar<V> >::value>
│ │ │ │ -
1636 checkHorizontalMinMax() {}
│ │ │ │ -
1637
│ │ │ │ -
1638 template<class V>
│ │ │ │ -
1639 std::enable_if_t<Impl::LessThenComparable<Scalar<V> >::value>
│ │ │ │ -
1640 checkHorizontalMinMax()
│ │ │ │ -
1641 {
│ │ │ │ -
1642 static_assert
│ │ │ │ -
1643 (std::is_same<decltype(max(std::declval<V>())), Scalar<V> >::value,
│ │ │ │ -
1644 "The result of max(V) should be exactly Scalar<V>");
│ │ │ │ -
1645
│ │ │ │ -
1646 static_assert
│ │ │ │ -
1647 (std::is_same<decltype(min(std::declval<V>())), Scalar<V> >::value,
│ │ │ │ -
1648 "The result of min(V) should be exactly Scalar<V>");
│ │ │ │ -
1649
│ │ │ │ -
1650 static_assert
│ │ │ │ -
1651 (std::is_same<decltype(max(std::declval<V&>())), Scalar<V> >::value,
│ │ │ │ -
1652 "The result of max(V) should be exactly Scalar<V>");
│ │ │ │ -
1653
│ │ │ │ -
1654 static_assert
│ │ │ │ -
1655 (std::is_same<decltype(min(std::declval<V&>())), Scalar<V> >::value,
│ │ │ │ -
1656 "The result of min(V) should be exactly Scalar<V>");
│ │ │ │ -
1657
│ │ │ │ -
1658 const V vec1 = leftVector<V>();
│ │ │ │ -
1659
│ │ │ │ -
1660 DUNE_SIMD_CHECK(max(vec1) == Scalar<V>(lanes(vec1)));
│ │ │ │ -
1661 DUNE_SIMD_CHECK(min(vec1) == Scalar<V>(1));
│ │ │ │ -
1662 }
│ │ │ │ -
1663
│ │ │ │ -
1664 template<class V>
│ │ │ │ -
1665 std::enable_if_t<!Impl::LessThenComparable<Scalar<V> >::value>
│ │ │ │ -
1666 checkBinaryMinMax() {}
│ │ │ │ -
1667
│ │ │ │ -
1668 template<class V>
│ │ │ │ -
1669 std::enable_if_t<Impl::LessThenComparable<Scalar<V> >::value>
│ │ │ │ -
1670 checkBinaryMinMax()
│ │ │ │ -
1671 {
│ │ │ │ -
1672 using std::max;
│ │ │ │ -
1673 using std::min;
│ │ │ │ -
1674
│ │ │ │ -
1675 static_assert
│ │ │ │ -
1676 (std::is_same<decltype(Simd::max(std::declval<V>(),
│ │ │ │ -
1677 std::declval<V>())), V>::value,
│ │ │ │ -
1678 "The result of Simd::max(V, V) should be exactly V");
│ │ │ │ -
1679 static_assert
│ │ │ │ -
1680 (std::is_same<decltype(Simd::min(std::declval<V>(),
│ │ │ │ -
1681 std::declval<V>())), V>::value,
│ │ │ │ -
1682 "The result of Simd::min(V, V) should be exactly V");
│ │ │ │ -
1683
│ │ │ │ -
1684 static_assert
│ │ │ │ -
1685 (std::is_same<decltype(Simd::max(std::declval<V&>(),
│ │ │ │ -
1686 std::declval<V&>())), V>::value,
│ │ │ │ -
1687 "The result of Simd::max(V&, V&) should be exactly V");
│ │ │ │ -
1688 static_assert
│ │ │ │ -
1689 (std::is_same<decltype(Simd::min(std::declval<V&>(),
│ │ │ │ -
1690 std::declval<V&>())), V>::value,
│ │ │ │ -
1691 "The result of Simd::min(V&, V&) should be exactly V");
│ │ │ │ -
1692
│ │ │ │ -
1693 const V arg1 = leftVector<V>();
│ │ │ │ -
1694 const V arg2 = rightVector<V>();
│ │ │ │ -
1695
│ │ │ │ -
1696 V maxExp(Scalar<V>(0)), minExp(Scalar<V>(0));
│ │ │ │ -
1697 for(auto l : range(lanes<V>()))
│ │ │ │ -
1698 {
│ │ │ │ -
1699 lane(l, maxExp) = max(lane(l, arg1), lane(l, arg2));
│ │ │ │ -
1700 lane(l, minExp) = min(lane(l, arg1), lane(l, arg2));
│ │ │ │ -
1701 }
│ │ │ │ -
1702
│ │ │ │ -
1703 DUNE_SIMD_CHECK(allTrue(maxExp == Simd::max(arg1, arg2)));
│ │ │ │ -
1704 DUNE_SIMD_CHECK(allTrue(minExp == Simd::min(arg1, arg2)));
│ │ │ │ -
1705 }
│ │ │ │ -
1706
│ │ │ │ -
1707 template<class V>
│ │ │ │ -
1708 void checkIO()
│ │ │ │ -
1709 {
│ │ │ │ -
1710 const V vec1 = leftVector<V>();
│ │ │ │ -
1711
│ │ │ │ -
1712 std::string reference;
│ │ │ │ -
1713 {
│ │ │ │ -
1714 const char *sep = "";
│ │ │ │ -
1715 for(auto l : range(lanes(vec1)))
│ │ │ │ -
1716 {
│ │ │ │ -
1717 std::ostringstream stream;
│ │ │ │ -
1718 stream << lane(l, vec1);
│ │ │ │ -
1719
│ │ │ │ -
1720 reference += sep;
│ │ │ │ -
1721 reference += stream.str();
│ │ │ │ -
1722 sep = ", ";
│ │ │ │ -
1723 }
│ │ │ │ -
1724 }
│ │ │ │ -
1725
│ │ │ │ -
1726 {
│ │ │ │ -
1727 std::ostringstream stream;
│ │ │ │ -
1728 stream << io(vec1);
│ │ │ │ -
1729 if(lanes(vec1) == 1)
│ │ │ │ -
1730 DUNE_SIMD_CHECK(stream.str() == reference);
│ │ │ │ -
1731 else
│ │ │ │ -
1732 DUNE_SIMD_CHECK(stream.str() == "<" + reference + ">");
│ │ │ │ -
1733 }
│ │ │ │ -
1734
│ │ │ │ -
1735 {
│ │ │ │ -
1736 std::ostringstream stream;
│ │ │ │ -
1737 stream << vio(vec1);
│ │ │ │ -
1738 DUNE_SIMD_CHECK(stream.str() == "<" + reference + ">");
│ │ │ │ -
1739 }
│ │ │ │ -
1740 }
│ │ │ │ -
1741
│ │ │ │ -
1742#undef DUNE_SIMD_CHECK
│ │ │ │ -
1743
│ │ │ │ -
1744 public:
│ │ │ │ -
1807 template<class V> void checkType();
│ │ │ │ -
1808 template<class V> void checkNonOps();
│ │ │ │ -
1809 template<class V> void checkUnaryOps();
│ │ │ │ -
1810 template<class V> void checkBinaryOps();
│ │ │ │ -
1811 template<class V> void checkBinaryOpsVectorVector();
│ │ │ │ -
1812 template<class V> void checkBinaryOpsScalarVector();
│ │ │ │ -
1813 template<class V> void checkBinaryOpsVectorScalar();
│ │ │ │ -
1814 template<class V> void checkBinaryOpsProxyVector();
│ │ │ │ -
1815 template<class V> void checkBinaryOpsVectorProxy();
│ │ │ │ -
1819
│ │ │ │ -
1836 template<class V, class Rebinds,
│ │ │ │ -
1837 template<class> class RebindPrune = IsLoop,
│ │ │ │ -
1838 template<class> class RebindAccept = Dune::AlwaysTrue>
│ │ │ │ -
│ │ │ │ -
1839 void check() {
│ │ │ │ -
1840 // check whether the test for this type already started
│ │ │ │ -
1841 if(seen_.emplace(typeid (V)).second == false)
│ │ │ │ -
1842 {
│ │ │ │ -
1843 // type already seen, nothing to do
│ │ │ │ -
1844 return;
│ │ │ │ -
1845 }
│ │ │ │ -
1846
│ │ │ │ -
1847 // do these first so everything that appears after "Checking SIMD type
│ │ │ │ -
1848 // ..." really pertains to that type
│ │ │ │ -
1849 auto recurse = [this](auto w) {
│ │ │ │ -
1850 using W = typename decltype(w)::type;
│ │ │ │ -
1851 this->template check<W, Rebinds, RebindPrune, RebindAccept>();
│ │ │ │ -
1852 };
│ │ │ │ -
1853 checkRebindOf<V, Rebinds, RebindPrune, RebindAccept>(recurse);
│ │ │ │ -
1854
│ │ │ │ -
1855 checkType<V>();
│ │ │ │ -
1856 }
│ │ │ │ -
│ │ │ │ -
1857
│ │ │ │ -
│ │ │ │ -
1859 bool good() const
│ │ │ │ -
1860 {
│ │ │ │ -
1861 return good_;
│ │ │ │ -
1862 }
│ │ │ │ -
│ │ │ │ -
1863
│ │ │ │ -
1864 }; // class UnitTest
│ │ │ │ -
│ │ │ │ -
1865
│ │ │ │ -
│ │ │ │ -
1866 template<class V> void UnitTest::checkType()
│ │ │ │ -
1867 {
│ │ │ │ -
1868 static_assert(std::is_same<V, std::decay_t<V> >::value, "Simd types "
│ │ │ │ -
1869 "must not be references, and must not include "
│ │ │ │ -
1870 "cv-qualifiers");
│ │ │ │ -
1871
│ │ │ │ -
1872 log_ << "Checking SIMD type " << className<V>() << std::endl;
│ │ │ │ -
1873
│ │ │ │ -
1874 checkNonOps<V>();
│ │ │ │ -
1875 checkUnaryOps<V>();
│ │ │ │ -
1876 checkBinaryOps<V>();
│ │ │ │ -
1877 }
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
1878 template<class V> void UnitTest::checkNonOps()
│ │ │ │ -
1879 {
│ │ │ │ -
1880 constexpr auto isMask = typename std::is_same<Scalar<V>, bool>::type{};
│ │ │ │ -
1881
│ │ │ │ -
1882 checkLanes<V>();
│ │ │ │ -
1883 checkScalar<V>();
│ │ │ │ -
1884
│ │ │ │ -
1885 checkDefaultConstruct<V>();
│ │ │ │ -
1886 checkLane<V>();
│ │ │ │ -
1887 checkCopyMoveConstruct<V>();
│ │ │ │ -
1888 checkImplCast<V>();
│ │ │ │ -
1889 checkBroadcast<V>();
│ │ │ │ -
1890 if constexpr (isMask)
│ │ │ │ -
1891 this->template checkBroadcastMaskConstruct<V>();
│ │ │ │ -
1892 else
│ │ │ │ -
1893 this->template checkBroadcastVectorConstruct<V>();
│ │ │ │ -
1894 checkBracedAssign<V>();
│ │ │ │ -
1895 checkBracedBroadcastAssign<V>();
│ │ │ │ -
1896
│ │ │ │ -
1897 checkAutoCopy<V>();
│ │ │ │ -
1898 checkCond<V>();
│ │ │ │ -
1899 checkBoolCond<V>();
│ │ │ │ -
1900
│ │ │ │ -
1901 if constexpr (isMask)
│ │ │ │ -
1902 this->template checkBoolReductions<V>();
│ │ │ │ -
1903 // checkBoolReductions() is not applicable for non-masks
│ │ │ │ -
1904
│ │ │ │ -
1905 checkHorizontalMinMax<V>();
│ │ │ │ -
1906 checkBinaryMinMax<V>();
│ │ │ │ -
1907 checkIO<V>();
│ │ │ │ -
1908 }
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
1909 template<class V> void UnitTest::checkUnaryOps()
│ │ │ │ -
1910 {
│ │ │ │ -
1911 if constexpr (std::is_same_v<Scalar<V>, bool>) {
│ │ │ │ -
1912 // check mask
│ │ │ │ -
1913 auto check = [this](auto op) {
│ │ │ │ -
1914 this->template checkUnaryOpsV<V>(op);
│ │ │ │ -
1915 };
│ │ │ │ -
1916
│ │ │ │ -
1917 // postfix
│ │ │ │ -
1918 // check(OpPostfixDecrement{});
│ │ │ │ -
1919 // clang deprecation warning if bool++ is tested
│ │ │ │ -
1920 // check(OpPostfixIncrement{});
│ │ │ │ -
1921
│ │ │ │ -
1922 // prefix
│ │ │ │ -
1923 // check(OpPrefixDecrement{});
│ │ │ │ -
1924 // clang deprecation warning if ++bool is tested
│ │ │ │ -
1925 // check(OpPrefixIncrement{});
│ │ │ │ -
1926
│ │ │ │ -
1927 // check(OpPrefixPlus{});
│ │ │ │ -
1928 // check(OpPrefixMinus{});
│ │ │ │ -
1929 check(OpPrefixLogicNot{});
│ │ │ │ -
1930 // check(OpPrefixBitNot{});
│ │ │ │ -
1931 }
│ │ │ │ -
1932 else {
│ │ │ │ -
1933 // check vector
│ │ │ │ -
1934 auto check = [this](auto op) {
│ │ │ │ -
1935 this->template checkUnaryOpsV<V>(op);
│ │ │ │ -
1936 };
│ │ │ │ -
1937
│ │ │ │ -
1938 // postfix
│ │ │ │ -
1939 // check(OpPostfixDecrement{});
│ │ │ │ -
1940 // check(OpPostfixIncrement{});
│ │ │ │ -
1941
│ │ │ │ -
1942 // prefix
│ │ │ │ -
1943 // check(OpPrefixDecrement{});
│ │ │ │ -
1944 // check(OpPrefixIncrement{});
│ │ │ │ -
1945
│ │ │ │ -
1946 // check(OpPrefixPlus{});
│ │ │ │ -
1947 check(OpPrefixMinus{});
│ │ │ │ -
1948 check(OpPrefixLogicNot{});
│ │ │ │ -
1949 check(OpPrefixBitNot{});
│ │ │ │ -
1950 }
│ │ │ │ -
1951 }
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
1952 template<class V> void UnitTest::checkBinaryOps()
│ │ │ │ -
1953 {
│ │ │ │ -
1954 checkBinaryOpsVectorVector<V>();
│ │ │ │ -
1955 checkBinaryOpsScalarVector<V>();
│ │ │ │ -
1956 checkBinaryOpsVectorScalar<V>();
│ │ │ │ -
1957 checkBinaryOpsProxyVector<V>();
│ │ │ │ -
1958 checkBinaryOpsVectorProxy<V>();
│ │ │ │ -
1959 }
│ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
1961 {
│ │ │ │ -
1962 auto checker = [this](auto doSV, auto doVV, auto doVS, auto op) {
│ │ │ │ -
1963 auto check = [this,op](auto t1, auto t2) {
│ │ │ │ -
1964 this->checkBinaryOpVV(t1, t2, op);
│ │ │ │ -
1965 };
│ │ │ │ -
1966 this->checkBinaryRefQual<V, V, doVV>(check);
│ │ │ │ -
1967 };
│ │ │ │ -
1968 checkBinaryOps<V>(checker);
│ │ │ │ -
1969 }
│ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
1971 {
│ │ │ │ -
1972 auto checker = [this](auto doSV, auto doVV, auto doVS, auto op) {
│ │ │ │ -
1973 auto check = [this,op](auto t1, auto t2) {
│ │ │ │ -
1974 this->checkBinaryOpSV(t1, t2, op);
│ │ │ │ -
1975 };
│ │ │ │ -
1976 this->checkBinaryRefQual<Scalar<V>, V, doSV>(check);
│ │ │ │ -
1977
│ │ │ │ -
1978 auto crossCheck = [this,op](auto t1, auto t2) {
│ │ │ │ -
1979 this->checkBinaryOpVVAgainstSV(t1, t2, op);
│ │ │ │ -
1980 };
│ │ │ │ -
1981 this->checkBinaryRefQual<Scalar<V>, V, doSV && doVV>(crossCheck);
│ │ │ │ -
1982 };
│ │ │ │ -
1983 checkBinaryOps<V>(checker);
│ │ │ │ -
1984 }
│ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
1986 {
│ │ │ │ -
1987 auto checker = [this](auto doSV, auto doVV, auto doVS, auto op) {
│ │ │ │ -
1988 auto check = [this,op](auto t1, auto t2) {
│ │ │ │ -
1989 this->checkBinaryOpVS(t1, t2, op);
│ │ │ │ -
1990 };
│ │ │ │ -
1991 this->checkBinaryRefQual<V, Scalar<V>, doVS>(check);
│ │ │ │ -
1992
│ │ │ │ -
1993 auto crossCheck = [this,op](auto t1, auto t2) {
│ │ │ │ -
1994 this->checkBinaryOpVVAgainstVS(t1, t2, op);
│ │ │ │ -
1995 };
│ │ │ │ -
1996 this->checkBinaryRefQual<V, Scalar<V>, doVV && doVS>(crossCheck);
│ │ │ │ -
1997 };
│ │ │ │ -
1998 checkBinaryOps<V>(checker);
│ │ │ │ -
1999 }
│ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
2001 {
│ │ │ │ -
2002 auto checker = [this](auto doSV, auto doVV, auto doVS, auto op) {
│ │ │ │ -
2003 auto check = [this,op](auto t1, auto t2) {
│ │ │ │ -
2004 this->checkBinaryOpPV(t1, t2, op);
│ │ │ │ -
2005 };
│ │ │ │ -
2006 this->checkBinaryRefQual<V, V, doSV>(check);
│ │ │ │ -
2007 };
│ │ │ │ -
2008 checkBinaryOps<V>(checker);
│ │ │ │ -
2009 }
│ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
2011 {
│ │ │ │ -
2012 auto checker = [this](auto doSV, auto doVV, auto doVS, auto op) {
│ │ │ │ -
2013 auto check = [this,op](auto t1, auto t2) {
│ │ │ │ -
2014 this->checkBinaryOpVP(t1, t2, op);
│ │ │ │ -
2015 };
│ │ │ │ -
2016 this->checkBinaryRefQual<V, V, doVS>(check);
│ │ │ │ -
2017 };
│ │ │ │ -
2018 checkBinaryOps<V>(checker);
│ │ │ │ -
2019 }
│ │ │ │ -
│ │ │ │ -
2020
│ │ │ │ -
2021 } // namespace Simd
│ │ │ │ -
2022} // namespace Dune
│ │ │ │ -
2023
│ │ │ │ -
2024#endif // DUNE_COMMON_SIMD_TEST_HH
│ │ │ │ -
IO interface of the SIMD abstraction.
│ │ │ │ - │ │ │ │ -
#define DUNE_SIMD_POSTFIX_OP(NAME, SYMBOL)
Definition test.hh:670
│ │ │ │ -
#define DUNE_SIMD_INFIX_OP(NAME, SYMBOL)
Definition test.hh:784
│ │ │ │ -
#define DUNE_SIMD_CHECK_OP(expr)
Definition test.hh:191
│ │ │ │ -
#define DUNE_SIMD_CHECK(expr)
Definition test.hh:186
│ │ │ │ -
#define DUNE_SIMD_REPL_OP(NAME, REPLFN, SYMBOL)
Definition test.hh:818
│ │ │ │ -
#define DUNE_SIMD_ASSIGN_OP(NAME, SYMBOL)
Definition test.hh:805
│ │ │ │ -
#define DUNE_SIMD_PREFIX_OP(NAME, SYMBOL)
Definition test.hh:681
│ │ │ │ -
#define DUNE_SIMD_DO(M1, M2, M3, V1, V2, V3, NAME)
│ │ │ │ - │ │ │ │ -
A free function to provide the demangled class name of a given object or type as a string.
│ │ │ │ - │ │ │ │ -
Utilities for reduction like operations on ranges.
│ │ │ │ - │ │ │ │ -
Traits for type conversions and type information.
│ │ │ │ -
static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from >, std::integral_constant< T, to >) noexcept
Definition rangeutilities.hh:312
│ │ │ │ -
std::tuple< MetaType< T >... > TypeList
A simple type list.
Definition typelist.hh:87
│ │ │ │ -
constexpr void forEach(Range &&range, F &&f)
Range based for loop.
Definition hybridutilities.hh:256
│ │ │ │ -
constexpr AutonomousValue< T > autoCopy(T &&v)
Autonomous copy of an expression's value for use in auto type deduction.
Definition typetraits.hh:672
│ │ │ │ -
typename Impl::voider< Types... >::type void_t
Is void for all valid input types. The workhorse for C++11 SFINAE-techniques.
Definition typetraits.hh:40
│ │ │ │ -
bool anyTrue(const Mask &mask)
Whether any entry is true
Definition simd/interface.hh:429
│ │ │ │ -
auto maskOr(const V1 &v1, const V2 &v2)
Logic or of masks.
Definition simd/interface.hh:499
│ │ │ │ -
V cond(M &&mask, const V &ifTrue, const V &ifFalse)
Like the ?: operator.
Definition simd/interface.hh:386
│ │ │ │ -
auto io(const V &v)
construct a stream inserter
Definition io.hh:106
│ │ │ │ -
bool allTrue(const Mask &mask)
Whether all entries are true
Definition simd/interface.hh:439
│ │ │ │ -
auto vio(const V &v)
construct a stream inserter
Definition io.hh:90
│ │ │ │ -
auto max(const V &v1, const V &v2)
The binary maximum value over two simd objects.
Definition simd/interface.hh:409
│ │ │ │ -
bool anyFalse(const Mask &mask)
Whether any entry is false
Definition simd/interface.hh:449
│ │ │ │ -
constexpr std::size_t lanes()
Number of lanes in a SIMD type.
Definition simd/interface.hh:305
│ │ │ │ -
decltype(auto) lane(std::size_t l, V &&v)
Extract an element of a SIMD type.
Definition simd/interface.hh:324
│ │ │ │ -
bool allFalse(const Mask &mask)
Whether all entries are false
Definition simd/interface.hh:459
│ │ │ │ -
auto maskAnd(const V1 &v1, const V2 &v2)
Logic and of masks.
Definition simd/interface.hh:509
│ │ │ │ -
typename Overloads::ScalarType< std::decay_t< V > >::type Scalar
Element type of some SIMD type.
Definition simd/interface.hh:235
│ │ │ │ -
auto min(const V &v1, const V &v2)
The binary minimum value over two simd objects.
Definition simd/interface.hh:419
│ │ │ │ -
STL namespace.
│ │ │ │ +
│ │ │ │ +
101 const_reference back ([[maybe_unused]] int i) const
│ │ │ │ +
102 {
│ │ │ │ +
103 return _data.back().second;
│ │ │ │ +
104 }
│ │ │ │ +
│ │ │ │ +
105
│ │ │ │ +
106
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
111 {
│ │ │ │ +
112 key_type k = _data.front().first;
│ │ │ │ +
113 _data.pop_front();
│ │ │ │ +
114 _index.erase(k);
│ │ │ │ +
115 }
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
119 void pop_back()
│ │ │ │ +
120 {
│ │ │ │ +
121 key_type k = _data.back().first;
│ │ │ │ +
122 _data.pop_back();
│ │ │ │ +
123 _index.erase(k);
│ │ │ │ +
124 }
│ │ │ │ +
│ │ │ │ +
125
│ │ │ │ +
│ │ │ │ +
131 iterator find (const key_type & key)
│ │ │ │ +
132 {
│ │ │ │ +
133 const map_iterator it = _index.find(key);
│ │ │ │ +
134 if (it == _index.end()) return _data.end();
│ │ │ │ +
135 return it->second;
│ │ │ │ +
136 }
│ │ │ │ +
│ │ │ │ +
137
│ │ │ │ +
│ │ │ │ +
143 const_iterator find (const key_type & key) const
│ │ │ │ +
144 {
│ │ │ │ +
145 const map_iterator it = _index.find(key);
│ │ │ │ +
146 if (it == _index.end()) return _data.end();
│ │ │ │ +
147 return it->second;
│ │ │ │ +
148 }
│ │ │ │ +
│ │ │ │ +
149
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
162 {
│ │ │ │ +
163 std::pair<key_type, value_type> x(key, data);
│ │ │ │ +
164 /* insert item as mru */
│ │ │ │ +
165 iterator it = _data.insert(_data.begin(), x);
│ │ │ │ +
166 /* store index */
│ │ │ │ +
167 _index.insert(std::make_pair(key,it));
│ │ │ │ +
168
│ │ │ │ +
169 return it->second;
│ │ │ │ +
170 }
│ │ │ │ +
│ │ │ │ +
171
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
176 {
│ │ │ │ +
177 return touch (key);
│ │ │ │ +
178 }
│ │ │ │ +
│ │ │ │ +
179
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
186 {
│ │ │ │ +
187 /* query _index for iterator */
│ │ │ │ +
188 map_iterator it = _index.find(key);
│ │ │ │ +
189 if (it == _index.end())
│ │ │ │ + │ │ │ │ +
191 "Failed to touch key " << key << ", it is not in the lru container");
│ │ │ │ +
192 /* update _data
│ │ │ │ +
193 move it to the front
│ │ │ │ +
194 */
│ │ │ │ +
195 _data.splice(_data.begin(), _data, it->second);
│ │ │ │ +
196 return it->second->second;
│ │ │ │ +
197 }
│ │ │ │ +
│ │ │ │ +
198
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
203 {
│ │ │ │ +
204 return _data.size();
│ │ │ │ +
205 }
│ │ │ │ +
│ │ │ │ +
206
│ │ │ │ +
│ │ │ │ +
213 void resize(size_type new_size)
│ │ │ │ +
214 {
│ │ │ │ +
215 assert(new_size <= size());
│ │ │ │ +
216
│ │ │ │ +
217 while (new_size < size())
│ │ │ │ +
218 pop_back();
│ │ │ │ +
219 }
│ │ │ │ +
│ │ │ │ +
220
│ │ │ │ +
│ │ │ │ +
224 void clear()
│ │ │ │ +
225 {
│ │ │ │ +
226 _data.clear();
│ │ │ │ +
227 _index.clear();
│ │ │ │ +
228 }
│ │ │ │ +
│ │ │ │ +
229
│ │ │ │ +
230 private:
│ │ │ │ +
231 list_type _data;
│ │ │ │ +
232 map_type _index;
│ │ │ │ +
233
│ │ │ │ +
234 };
│ │ │ │ +
│ │ │ │ +
235
│ │ │ │ +
236} // namespace Dune
│ │ │ │ +
237
│ │ │ │ +
238#endif // DUNE_COMMON_LRU_HH
│ │ │ │ +
A few common exception classes.
│ │ │ │ +
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition integersequence.hh:75
│ │ │ │ -
typename Impl::RemoveEnd< EndMark, TypeList< Types... > >::type RebindList
A list of types with the final element removed.
Definition test.hh:158
│ │ │ │ -
typename Impl::IsLoop< T >::type IsLoop
check whether a type is an instance of LoopSIMD
Definition test.hh:162
│ │ │ │ -
Definition loop.hh:65
│ │ │ │ -
final element marker for RebindList
Definition test.hh:145
│ │ │ │ -
Definition test.hh:164
│ │ │ │ -
void checkUnaryOps()
Definition test.hh:1909
│ │ │ │ -
void checkBinaryOps()
Definition test.hh:1952
│ │ │ │ -
void checkBinaryOpsScalarVector()
Definition test.hh:1970
│ │ │ │ -
void checkType()
Definition test.hh:1866
│ │ │ │ -
void check()
run unit tests for simd vector type V
Definition test.hh:1839
│ │ │ │ -
void checkBinaryOpsVectorScalar()
Definition test.hh:1985
│ │ │ │ -
bool good() const
whether all tests succeeded
Definition test.hh:1859
│ │ │ │ -
void checkBinaryOpsVectorVector()
Definition test.hh:1960
│ │ │ │ -
void checkNonOps()
Definition test.hh:1878
│ │ │ │ -
void checkBinaryOpsVectorProxy()
Definition test.hh:2010
│ │ │ │ -
void checkBinaryOpsProxyVector()
Definition test.hh:2000
│ │ │ │ -
template which always yields a true value
Definition typetraits.hh:134
│ │ │ │ -
Include file for users of the SIMD abstraction layer.
│ │ │ │ +
Default exception class for range errors.
Definition exceptions.hh:254
│ │ │ │ +
LRU Cache Container.
Definition lru.hh:52
│ │ │ │ +
void pop_back()
Removes the last element.
Definition lru.hh:119
│ │ │ │ +
iterator find(const key_type &key)
Finds the element whose key is k.
Definition lru.hh:131
│ │ │ │ +
reference insert(const key_type &key)
mark data associated with key as most recent
Definition lru.hh:175
│ │ │ │ +
list_type::const_iterator const_iterator
Definition lru.hh:68
│ │ │ │ +
void resize(size_type new_size)
ensure a maximum size of the container
Definition lru.hh:213
│ │ │ │ +
allocator::size_type size_type
Definition lru.hh:66
│ │ │ │ +
list_type::iterator iterator
Definition lru.hh:67
│ │ │ │ +
allocator::value_type value_type
Definition lru.hh:61
│ │ │ │ +
const_reference front() const
Definition lru.hh:83
│ │ │ │ +
typename allocator::value_type const * const_pointer
Definition lru.hh:63
│ │ │ │ +
size_type size() const
Retrieve number of entries in the container.
Definition lru.hh:202
│ │ │ │ +
typename allocator::value_type & reference
Definition lru.hh:65
│ │ │ │ +
reference back()
Definition lru.hh:92
│ │ │ │ +
void pop_front()
Removes the first element.
Definition lru.hh:110
│ │ │ │ +
reference front()
Definition lru.hh:74
│ │ │ │ +
void clear()
Definition lru.hh:224
│ │ │ │ +
reference touch(const key_type &key)
mark data associated with key as most recent
Definition lru.hh:185
│ │ │ │ +
reference insert(const key_type &key, const_reference data)
Insert a value into the container.
Definition lru.hh:161
│ │ │ │ +
typename allocator::value_type * pointer
Definition lru.hh:62
│ │ │ │ +
const_iterator find(const key_type &key) const
Finds the element whose key is k.
Definition lru.hh:143
│ │ │ │ +
typename allocator::value_type const & const_reference
Definition lru.hh:64
│ │ │ │ +
Traits::key_type key_type
Definition lru.hh:60
│ │ │ │ +
const_reference back(int i) const
Definition lru.hh:101
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,2101 +1,267 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * simd │ │ │ │ │ -test.hh │ │ │ │ │ +lru.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ -1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ +1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ +2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ +3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ -2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -3#ifndef DUNE_COMMON_SIMD_TEST_HH │ │ │ │ │ -4#define DUNE_COMMON_SIMD_TEST_HH │ │ │ │ │ -5 │ │ │ │ │ -12#include │ │ │ │ │ -13#include │ │ │ │ │ -14#include │ │ │ │ │ -15#include │ │ │ │ │ -16#include │ │ │ │ │ -17#include │ │ │ │ │ -18#include │ │ │ │ │ -19#include │ │ │ │ │ -20#include │ │ │ │ │ -21#include │ │ │ │ │ -22 │ │ │ │ │ -23#include │ │ │ │ │ -24#include │ │ │ │ │ -25#include │ │ │ │ │ -26#include │ │ │ │ │ -27#include │ │ │ │ │ -28#include │ │ │ │ │ -29#include │ │ │ │ │ -30#include │ │ │ │ │ -31#include │ │ │ │ │ -32 │ │ │ │ │ -33namespace Dune { │ │ │ │ │ -34 namespace Simd { │ │ │ │ │ -35 │ │ │ │ │ -36 namespace Impl { │ │ │ │ │ -37 │ │ │ │ │ -38 template │ │ │ │ │ -39 struct LessThenComparable : std::false_type {}; │ │ │ │ │ -40 template │ │ │ │ │ -41 struct LessThenComparable() │ │ │ │ │ -42 < std::declval())> > : │ │ │ │ │ -43 std::true_type │ │ │ │ │ -44 {}; │ │ │ │ │ -45 │ │ │ │ │ -46 template │ │ │ │ │ -47 struct CopyConstHelper │ │ │ │ │ -48 { │ │ │ │ │ -49 using type = Dst; │ │ │ │ │ -50 }; │ │ │ │ │ -51 template │ │ │ │ │ -52 struct CopyConstHelper │ │ │ │ │ -53 { │ │ │ │ │ -54 using type = std::add_const_t; │ │ │ │ │ -55 }; │ │ │ │ │ -56 │ │ │ │ │ -57 template │ │ │ │ │ -58 struct CopyVolatileHelper │ │ │ │ │ -59 { │ │ │ │ │ -60 using type = Dst; │ │ │ │ │ -61 }; │ │ │ │ │ -62 template │ │ │ │ │ -63 struct CopyVolatileHelper │ │ │ │ │ -64 { │ │ │ │ │ -65 using type = std::add_volatile_t; │ │ │ │ │ -66 }; │ │ │ │ │ -67 │ │ │ │ │ -68 template │ │ │ │ │ -69 struct CopyReferenceHelper │ │ │ │ │ -70 { │ │ │ │ │ -71 using type = Dst; │ │ │ │ │ -72 }; │ │ │ │ │ -73 template │ │ │ │ │ -74 struct CopyReferenceHelper │ │ │ │ │ +4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ +5#ifndef DUNE_COMMON_LRU_HH │ │ │ │ │ +6#define DUNE_COMMON_LRU_HH │ │ │ │ │ +7 │ │ │ │ │ +8#include │ │ │ │ │ +9#include │ │ │ │ │ +10#include │ │ │ │ │ +11#include │ │ │ │ │ +12 │ │ │ │ │ +13#include │ │ │ │ │ +14 │ │ │ │ │ +20namespace Dune { │ │ │ │ │ +21 │ │ │ │ │ +22 namespace { │ │ │ │ │ +23 │ │ │ │ │ +24 /* │ │ │ │ │ +25 hide the default traits in an empty namespace │ │ │ │ │ +26 */ │ │ │ │ │ +27 template > │ │ │ │ │ +29 struct _lru_default_traits │ │ │ │ │ +30 { │ │ │ │ │ +31 typedef Key key_type; │ │ │ │ │ +32 typedef Alloc allocator; │ │ │ │ │ +33 typedef std::list< std::pair > list_type; │ │ │ │ │ +34 typedef typename list_type::iterator iterator; │ │ │ │ │ +35 typedef typename std::less cmp; │ │ │ │ │ +36 typedef std::map< key_type, iterator, cmp, │ │ │ │ │ +37 typename std::allocator_traits::template rebind_alloc > > map_type; │ │ │ │ │ +38 }; │ │ │ │ │ +39 │ │ │ │ │ +40 } // end empty namespace │ │ │ │ │ +41 │ │ │ │ │ +49 template > │ │ │ │ │ +51 class lru │ │ │ │ │ +52 { │ │ │ │ │ +53 typedef typename Traits::list_type list_type; │ │ │ │ │ +54 typedef typename Traits::map_type map_type; │ │ │ │ │ +55 typedef typename Traits::allocator allocator; │ │ │ │ │ +56 typedef typename map_type::iterator map_iterator; │ │ │ │ │ +57 typedef typename map_type::const_iterator const_map_iterator; │ │ │ │ │ +58 │ │ │ │ │ +59 public: │ │ │ │ │ +60 typedef typename Traits::key_type key_type; │ │ │ │ │ +61 typedef typename allocator::value_type value_type; │ │ │ │ │ +62 using pointer = typename allocator::value_type*; │ │ │ │ │ +63 using const_pointer = typename allocator::value_type const*; │ │ │ │ │ +64 using const_reference = typename allocator::value_type const&; │ │ │ │ │ +65 using reference = typename allocator::value_type&; │ │ │ │ │ +66 typedef typename allocator::size_type size_type; │ │ │ │ │ +67 typedef typename list_type::iterator iterator; │ │ │ │ │ +68 typedef typename list_type::const_iterator const_iterator; │ │ │ │ │ +69 │ │ │ │ │ +74 reference front() │ │ │ │ │ 75 { │ │ │ │ │ -76 using type = std::add_lvalue_reference_t; │ │ │ │ │ -77 }; │ │ │ │ │ +76 return _data.front().second; │ │ │ │ │ +77 } │ │ │ │ │ 78 │ │ │ │ │ -79 template │ │ │ │ │ -80 struct CopyReferenceHelper │ │ │ │ │ -81 { │ │ │ │ │ -82 using type = std::add_rvalue_reference_t; │ │ │ │ │ -83 }; │ │ │ │ │ -84 │ │ │ │ │ -85 template │ │ │ │ │ -86 using CopyRefQual = typename CopyReferenceHelper< │ │ │ │ │ -87 typename CopyVolatileHelper< │ │ │ │ │ -88 typename CopyConstHelper< │ │ │ │ │ -89 std::decay_t, │ │ │ │ │ -90 std::remove_reference_t │ │ │ │ │ -91 >::type, │ │ │ │ │ -92 std::remove_reference_t │ │ │ │ │ -93 >::type, │ │ │ │ │ -94 Src │ │ │ │ │ -95 >::type; │ │ │ │ │ +83 const_reference front() const │ │ │ │ │ +84 { │ │ │ │ │ +85 return _data.front().second; │ │ │ │ │ +86 } │ │ │ │ │ +87 │ │ │ │ │ +92 reference back() │ │ │ │ │ +93 { │ │ │ │ │ +94 return _data.back().second; │ │ │ │ │ +95 } │ │ │ │ │ 96 │ │ │ │ │ -97 template::value - 1> > │ │ │ │ │ -100 struct RemoveEnd; │ │ │ │ │ -101 template │ │ │ │ │ -102 struct RemoveEnd> │ │ │ │ │ -103 { │ │ │ │ │ -104 using Back = TypeListEntry_t::value - 1, Types>; │ │ │ │ │ -105 static_assert(std::is_same::value, │ │ │ │ │ -106 "TypeList not terminated by proper EndMark"); │ │ │ │ │ -107 using type = TypeList...>; │ │ │ │ │ -108 }; │ │ │ │ │ -109 │ │ │ │ │ -110 template │ │ │ │ │ -111 struct TypeInList; │ │ │ │ │ -112 │ │ │ │ │ -113 template │ │ │ │ │ -114 struct TypeInList > : std::false_type {}; │ │ │ │ │ -115 │ │ │ │ │ -116 template │ │ │ │ │ -117 struct TypeInList > : std::true_type {}; │ │ │ │ │ -118 │ │ │ │ │ -119 template │ │ │ │ │ -120 struct TypeInList, │ │ │ │ │ -121 std::enable_if_t::value> > : │ │ │ │ │ -122 TypeInList >::type │ │ │ │ │ -123 {}; │ │ │ │ │ -124 │ │ │ │ │ -125 template │ │ │ │ │ -126 struct IsLoop : std::false_type {}; │ │ │ │ │ -127 template │ │ │ │ │ -128 struct IsLoop > : std::true_type {}; │ │ │ │ │ -129 │ │ │ │ │ -130 // used inside static_assert to trick the compiler into printing a list │ │ │ │ │ -131 // of types: │ │ │ │ │ -132 // │ │ │ │ │ -133 // static_assert(debugTypes(Std::bool_constant{}), "msg"); │ │ │ │ │ -134 // │ │ │ │ │ -135 // Should include what the type `V` expands to in the error message. │ │ │ │ │ -136 template │ │ │ │ │ -137 constexpr bool debugTypes(std::true_type) { return true; } │ │ │ │ │ -138 template │ │ │ │ │ -139 [[deprecated]] │ │ │ │ │ -140 constexpr bool debugTypes(std::false_type) { return false; } │ │ │ │ │ -141 │ │ │ │ │ -142 } // namespace Impl │ │ │ │ │ -143 │ │ │ │ │ -145 struct EndMark {}; │ │ │ │ │ -147 │ │ │ │ │ -156 template │ │ │ │ │ -157 using RebindList = │ │ │ │ │ -158 typename Impl::RemoveEnd >::type; │ │ │ │ │ -159 │ │ │ │ │ -161 template │ │ │ │ │ -162 using IsLoop = typename Impl::IsLoop::type; │ │ │ │ │ -163 │ │ │ │ │ -164 class UnitTest { │ │ │ │ │ -165 bool good_ = true; │ │ │ │ │ -166 std::ostream &log_ = std::cerr; │ │ │ │ │ -167 // records the types for which checks have started running to avoid │ │ │ │ │ -168 // infinite recursion │ │ │ │ │ -169 std::unordered_set seen_; │ │ │ │ │ -170 │ │ │ │ │ -172 // │ │ │ │ │ -173 // Helper functions │ │ │ │ │ -174 // │ │ │ │ │ -175 │ │ │ │ │ -176 void complain(const char *file, int line, const char *func, │ │ │ │ │ -177 const char *expr); │ │ │ │ │ -178 │ │ │ │ │ -179 void complain(const char *file, int line, const char *func, │ │ │ │ │ -180 const std::string &opname, const char *expr); │ │ │ │ │ -181 │ │ │ │ │ -182 // This macro is defined only within this file, do not use anywhere │ │ │ │ │ -183 // else. Doing the actual printing in an external function dramatically │ │ │ │ │ -184 // reduces memory use during compilation. Defined in such a way that │ │ │ │ │ -185 // the call will only happen for failed checks. │ │ │ │ │ -186#define DUNE_SIMD_CHECK(expr) \ │ │ │ │ │ -187 ((expr) ? void() : complain(__FILE__, __LINE__, __func__, #expr)) │ │ │ │ │ -188 │ │ │ │ │ -189 // the function using this macro must define a way to compute the │ │ │ │ │ -190 // operator name in DUNE_SIMD_OPNAME │ │ │ │ │ -191#define DUNE_SIMD_CHECK_OP(expr) \ │ │ │ │ │ -192 ((expr) ? void() : complain(__FILE__, __LINE__, __func__, \ │ │ │ │ │ -193 DUNE_SIMD_OPNAME, #expr)) │ │ │ │ │ -194 │ │ │ │ │ -195 // "cast" into a prvalue │ │ │ │ │ -196 template │ │ │ │ │ -197 static std::decay_t prvalue(T &&t) │ │ │ │ │ -198 { │ │ │ │ │ -199 return std::forward(t); │ │ │ │ │ -200 } │ │ │ │ │ -201 │ │ │ │ │ -202 // whether the vector is 42 in all lanes │ │ │ │ │ -203 template │ │ │ │ │ -204 static bool is42(const V &v) │ │ │ │ │ -205 { │ │ │ │ │ -206 bool good = true; │ │ │ │ │ -207 │ │ │ │ │ -208 for(std::size_t l = 0; l < lanes(v); ++l) │ │ │ │ │ -209 // need to cast in case we have a mask type │ │ │ │ │ -210 good &= (lane(l, v) == Scalar(42)); │ │ │ │ │ -211 │ │ │ │ │ -212 return good; │ │ │ │ │ -213 } │ │ │ │ │ -214 │ │ │ │ │ -215 // make a vector that contains the sequence { 1, 2, ... } │ │ │ │ │ -216 template │ │ │ │ │ -217 static V make123() │ │ │ │ │ -218 { │ │ │ │ │ -219 // initialize to avoid undefined behaviour if assigning to lane() │ │ │ │ │ -220 // involves lvalue-to-rvalue conversions, e.g. due to bitmask │ │ │ │ │ -221 // operations. Avoid using broadcast() for initialization to avoid │ │ │ │ │ -222 // test interdependencies. │ │ │ │ │ -223 V vec(Scalar(0)); │ │ │ │ │ -224 for(std::size_t l = 0; l < lanes(vec); ++l) │ │ │ │ │ -225 lane(l, vec) = l + 1; │ │ │ │ │ -226 return vec; │ │ │ │ │ -227 } │ │ │ │ │ -228 │ │ │ │ │ -229 // whether the vector contains the sequence { 1, 2, ... } │ │ │ │ │ -230 template │ │ │ │ │ -231 static bool is123(const V &v) │ │ │ │ │ -232 { │ │ │ │ │ -233 bool good = true; │ │ │ │ │ -234 │ │ │ │ │ -235 for(std::size_t l = 0; l < lanes(v); ++l) │ │ │ │ │ -236 // need to cast in case we have a mask type │ │ │ │ │ -237 good &= (lane(l, v) == Scalar(l+1)); │ │ │ │ │ -238 │ │ │ │ │ -239 return good; │ │ │ │ │ -240 } │ │ │ │ │ -241 │ │ │ │ │ -242 template │ │ │ │ │ -243 static V leftVector() │ │ │ │ │ -244 { │ │ │ │ │ -245 // Avoid using broadcast() for initialization to avoid test │ │ │ │ │ -246 // interdependencies. │ │ │ │ │ -247 V res(Scalar(0)); │ │ │ │ │ -248 for(std::size_t l = 0; l < lanes(res); ++l) │ │ │ │ │ -249 lane(l, res) = Scalar(l+1); │ │ │ │ │ -250 return res; │ │ │ │ │ -251 } │ │ │ │ │ -252 │ │ │ │ │ -253 template │ │ │ │ │ -254 static V rightVector() │ │ │ │ │ -255 { │ │ │ │ │ -256 // Avoid using broadcast() for initialization to avoid test │ │ │ │ │ -257 // interdependencies. │ │ │ │ │ -258 V res(Scalar(0)); │ │ │ │ │ -259 for(std::size_t l = 0; l < lanes(res); ++l) │ │ │ │ │ -260 // do not exceed number of bits in char (for shifts) │ │ │ │ │ -261 // avoid 0 (for / and %) │ │ │ │ │ -262 lane(l, res) = Scalar((l)%7+1); │ │ │ │ │ -263 return res; │ │ │ │ │ -264 } │ │ │ │ │ -265 │ │ │ │ │ -266 template │ │ │ │ │ -267 static T leftScalar() │ │ │ │ │ -268 { │ │ │ │ │ -269 return T(42); │ │ │ │ │ -270 } │ │ │ │ │ -271 │ │ │ │ │ -272 template │ │ │ │ │ -273 static T rightScalar() │ │ │ │ │ -274 { │ │ │ │ │ -275 // do not exceed number of bits in char (for shifts) │ │ │ │ │ -276 // avoid 0 (for / and %) │ │ │ │ │ -277 return T(5); │ │ │ │ │ -278 } │ │ │ │ │ -279 │ │ │ │ │ -280 template │ │ │ │ │ -281 using CopyRefQual = Impl::CopyRefQual; │ │ │ │ │ -282 │ │ │ │ │ -283 // test whether the Op supports the operation on scalars. We do not use │ │ │ │ │ -284 // `lane()` to obtain the scalars, because that might return a proxy │ │ │ │ │ -285 // object, and we are interested in what exactly the scalar type can do, │ │ │ │ │ -286 // no a proxy that might have more overloads than needed. In addition, │ │ │ │ │ -287 // `lane()` may not preserve `const` and reference qualifiers. │ │ │ │ │ -288 template │ │ │ │ │ -289 using ScalarResult = │ │ │ │ │ -290 decltype(std::declval(). │ │ │ │ │ -291 scalar(std::declval, │ │ │ │ │ -292 Vectors> >()...)); │ │ │ │ │ -293 │ │ │ │ │ -295 // │ │ │ │ │ -296 // Check associated types │ │ │ │ │ -297 // │ │ │ │ │ -298 │ │ │ │ │ -299 template │ │ │ │ │ -300 void checkScalar() │ │ │ │ │ -301 { │ │ │ │ │ -302 // check that the type Scalar exists │ │ │ │ │ -303 using T = Scalar; │ │ │ │ │ -304 │ │ │ │ │ -305 static_assert(std::is_same >::value, "Scalar types " │ │ │ │ │ -306 "must not be references, and must not include " │ │ │ │ │ -307 "cv-qualifiers"); │ │ │ │ │ -308 [[maybe_unused]] T a{}; │ │ │ │ │ -309 } │ │ │ │ │ -310 │ │ │ │ │ -311 template │ │ │ │ │ -312 [[deprecated("Warning: please include bool in the Rebinds for " │ │ │ │ │ -313 "simd type V, as Masks are not checked otherwise.")]] │ │ │ │ │ -314 void warnMissingMaskRebind(std::true_type) {} │ │ │ │ │ -315 template │ │ │ │ │ -316 void warnMissingMaskRebind(std::false_type) {} │ │ │ │ │ -317 │ │ │ │ │ -318 template class RebindPrune, │ │ │ │ │ -319 template class RebindAccept, class Recurse> │ │ │ │ │ -320 void checkRebindOf(Recurse recurse) │ │ │ │ │ -321 { │ │ │ │ │ -322 Hybrid::forEach(Rebinds{}, [this,recurse](auto target) { │ │ │ │ │ -323 using T = typename decltype(target)::type; │ │ │ │ │ -324 │ │ │ │ │ -325 // check that the rebound type exists │ │ │ │ │ -326 using W = Rebind; │ │ │ │ │ -327 log_ << "Type " << className() << " rebound to " │ │ │ │ │ -328 << className() << " is " << className() << std::endl; │ │ │ │ │ -329 │ │ │ │ │ -330 static_assert(std::is_same >::value, "Rebound " │ │ │ │ │ -331 "types must not be references, and must not include " │ │ │ │ │ -332 "cv-qualifiers"); │ │ │ │ │ -333 static_assert(lanes() == lanes(), "Rebound types must have " │ │ │ │ │ -334 "the same number of lanes as the original vector " │ │ │ │ │ -335 "types"); │ │ │ │ │ -336 static_assert(std::is_same >::value, "Rebound types " │ │ │ │ │ -337 "must have the bound-to scalar type"); │ │ │ │ │ -338 │ │ │ │ │ -339 if constexpr (RebindPrune{}) { │ │ │ │ │ -340 log_ << "Pruning check of Simd type " << className() │ │ │ │ │ -341 << std::endl; │ │ │ │ │ -342 } │ │ │ │ │ -343 else { │ │ │ │ │ -344 using Impl::debugTypes; │ │ │ │ │ -345 static_assert(debugTypes(RebindAccept{}), │ │ │ │ │ -346 "Rebind is W, but that is not accepted " │ │ │ │ │ -347 "by RebindAccept"); │ │ │ │ │ -348 recurse(MetaType{}); │ │ │ │ │ -349 } │ │ │ │ │ -350 }); │ │ │ │ │ -351 │ │ │ │ │ -352 static_assert(std::is_same, V>, V>::value, "A type " │ │ │ │ │ -353 "rebound to its own scalar type must be the same type " │ │ │ │ │ -354 "as the original type"); │ │ │ │ │ -355 static_assert(std::is_same, Mask >::value, "A type " │ │ │ │ │ -356 "rebound to bool must be the mask type for that type"); │ │ │ │ │ -357 │ │ │ │ │ -358 constexpr bool hasBool = Impl::TypeInList::value; │ │ │ │ │ -359 warnMissingMaskRebind(Std::bool_constant{}); │ │ │ │ │ -360 } │ │ │ │ │ -361 │ │ │ │ │ -363 // │ │ │ │ │ -364 // Fundamental checks │ │ │ │ │ -365 // │ │ │ │ │ -366 │ │ │ │ │ -367 template │ │ │ │ │ -368 void checkLanes() │ │ │ │ │ -369 { │ │ │ │ │ -370 // check lanes │ │ │ │ │ -371 static_assert(std::is_same())>::value, │ │ │ │ │ -372 "return type of lanes() should be std::size_t"); │ │ │ │ │ -373 static_assert(std::is_same::value, │ │ │ │ │ -374 "return type of lanes(V{}) should be std::size_t"); │ │ │ │ │ -375 │ │ │ │ │ -376 // the result of lanes() must be constexpr │ │ │ │ │ -377 [[maybe_unused]] constexpr auto size = lanes(); │ │ │ │ │ -378 // but the result of lanes(vec) does not need to be constexpr │ │ │ │ │ -379 DUNE_SIMD_CHECK(lanes() == lanes(V{})); │ │ │ │ │ -380 } │ │ │ │ │ -381 │ │ │ │ │ -382 template │ │ │ │ │ -383 void checkDefaultConstruct() │ │ │ │ │ -384 { │ │ │ │ │ -385 { [[maybe_unused]] V vec; } │ │ │ │ │ -386 { [[maybe_unused]] V vec{}; } │ │ │ │ │ -387 { [[maybe_unused]] V vec = {}; } │ │ │ │ │ -388 } │ │ │ │ │ -389 │ │ │ │ │ -390 template │ │ │ │ │ -391 void checkLane() │ │ │ │ │ -392 { │ │ │ │ │ -393 // Avoid using broadcast() for initialization to avoid test │ │ │ │ │ -394 // interdependencies. │ │ │ │ │ -395 V vec(Scalar(0)); │ │ │ │ │ -396 // check lane() on mutable lvalues │ │ │ │ │ -397 for(std::size_t l = 0; l < lanes(vec); ++l) │ │ │ │ │ -398 lane(l, vec) = l + 1; │ │ │ │ │ -399 for(std::size_t l = 0; l < lanes(vec); ++l) │ │ │ │ │ -400 DUNE_SIMD_CHECK(lane(l, vec) == Scalar(l + 1)); │ │ │ │ │ -401 using MLRes = decltype(lane(0, vec)); │ │ │ │ │ -402 static_assert(std::is_same&>::value || │ │ │ │ │ -403 std::is_same >::value, │ │ │ │ │ -404 "Result of lane() on a mutable lvalue vector must " │ │ │ │ │ -405 "either be a mutable reference to a scalar of that " │ │ │ │ │ -406 "vector or a proxy object (which itself may not be a " │ │ │ │ │ -407 "reference nor const)."); │ │ │ │ │ -408 │ │ │ │ │ -409 // check lane() on const lvalues │ │ │ │ │ -410 const V &vec2 = vec; │ │ │ │ │ -411 for(std::size_t l = 0; l < lanes(vec); ++l) │ │ │ │ │ -412 DUNE_SIMD_CHECK(lane(l, vec2) == Scalar(l + 1)); │ │ │ │ │ -413 using CLRes = decltype(lane(0, vec2)); │ │ │ │ │ -414 static_assert(std::is_same&>::value || │ │ │ │ │ -415 std::is_same >::value, │ │ │ │ │ -416 "Result of lane() on a const lvalue vector must " │ │ │ │ │ -417 "either be a const lvalue reference to a scalar of that " │ │ │ │ │ -418 "vector or a proxy object (which itself may not be a " │ │ │ │ │ -419 "reference nor const)."); │ │ │ │ │ -420 static_assert(!std::is_assignable >::value, │ │ │ │ │ -421 "Result of lane() on a const lvalue vector must not be " │ │ │ │ │ -422 "assignable from a scalar."); │ │ │ │ │ -423 │ │ │ │ │ -424 // check lane() on rvalues │ │ │ │ │ -425 for(std::size_t l = 0; l < lanes(vec); ++l) │ │ │ │ │ -426 DUNE_SIMD_CHECK(lane(l, prvalue(vec)) == Scalar(l + 1)); │ │ │ │ │ -427 using RRes = decltype(lane(0, prvalue(vec))); │ │ │ │ │ -428 // TODO: do we really want to allow Scalar&& here? If we allow it, │ │ │ │ │ -429 // then `auto &&res = lane(0, vec*vec);` creates a dangling reference, │ │ │ │ │ -430 // and the scalar (and even the vector types) are small enough to be │ │ │ │ │ -431 // passed in registers anyway. On the other hand, the only comparable │ │ │ │ │ -432 // accessor function in the standard library that I can think of is │ │ │ │ │ -433 // std::get(), and that does return an rvalue reference in this │ │ │ │ │ -434 // situation. However, that cannot assume anything about the size of │ │ │ │ │ -435 // the returned types. │ │ │ │ │ -436 static_assert(std::is_same >::value || │ │ │ │ │ -437 std::is_same&&>::value, │ │ │ │ │ -438 "Result of lane() on a rvalue vector V must be " │ │ │ │ │ -439 "Scalar or Scalar&&."); │ │ │ │ │ -440 // Can't assert non-assignable, fails for any typical class, │ │ │ │ │ -441 // e.g. std::complex<>. Would need to return const Scalar or const │ │ │ │ │ -442 // Scalar&&, which would inhibit moving from the return value. │ │ │ │ │ -443 // static_assert(!std::is_assignable >::value, │ │ │ │ │ -444 // "Result of lane() on a rvalue vector must not be " │ │ │ │ │ -445 // "assignable from a scalar."); │ │ │ │ │ -446 } │ │ │ │ │ -447 │ │ │ │ │ -448 // check non-default constructors │ │ │ │ │ -449 template │ │ │ │ │ -450 void checkCopyMoveConstruct() │ │ │ │ │ -451 { │ │ │ │ │ -452 // elided copy/move constructors │ │ │ │ │ -453 { V vec (make123()); DUNE_SIMD_CHECK(is123(vec)); } │ │ │ │ │ -454 { V vec = make123() ; DUNE_SIMD_CHECK(is123(vec)); } │ │ │ │ │ -455 { V vec {make123()}; DUNE_SIMD_CHECK(is123(vec)); } │ │ │ │ │ -456 { V vec = {make123()}; DUNE_SIMD_CHECK(is123(vec)); } │ │ │ │ │ -457 │ │ │ │ │ -458 // copy constructors │ │ │ │ │ -459 { V ref(make123()); V vec (ref); │ │ │ │ │ -460 DUNE_SIMD_CHECK(is123(vec)); DUNE_SIMD_CHECK(is123(ref)); } │ │ │ │ │ -461 { V ref(make123()); V vec = ref ; │ │ │ │ │ -462 DUNE_SIMD_CHECK(is123(vec)); DUNE_SIMD_CHECK(is123(ref)); } │ │ │ │ │ -463 { V ref(make123()); V vec {ref}; │ │ │ │ │ -464 DUNE_SIMD_CHECK(is123(vec)); DUNE_SIMD_CHECK(is123(ref)); } │ │ │ │ │ -465 { V ref(make123()); V vec = {ref}; │ │ │ │ │ -466 DUNE_SIMD_CHECK(is123(vec)); DUNE_SIMD_CHECK(is123(ref)); } │ │ │ │ │ -467 { const V ref(make123()); V vec (ref); │ │ │ │ │ -468 DUNE_SIMD_CHECK(is123(vec)); } │ │ │ │ │ -469 { const V ref(make123()); V vec = ref ; │ │ │ │ │ -470 DUNE_SIMD_CHECK(is123(vec)); } │ │ │ │ │ -471 { const V ref(make123()); V vec {ref}; │ │ │ │ │ -472 DUNE_SIMD_CHECK(is123(vec)); } │ │ │ │ │ -473 { const V ref(make123()); V vec = {ref}; │ │ │ │ │ -474 DUNE_SIMD_CHECK(is123(vec)); } │ │ │ │ │ -475 │ │ │ │ │ -476 // move constructors │ │ │ │ │ -477 { V ref(make123()); V vec (std::move(ref)); │ │ │ │ │ -478 DUNE_SIMD_CHECK(is123(vec)); } │ │ │ │ │ -479 { V ref(make123()); V vec = std::move(ref) ; │ │ │ │ │ -480 DUNE_SIMD_CHECK(is123(vec)); } │ │ │ │ │ -481 { V ref(make123()); V vec {std::move(ref)}; │ │ │ │ │ -482 DUNE_SIMD_CHECK(is123(vec)); } │ │ │ │ │ -483 { V ref(make123()); V vec = {std::move(ref)}; │ │ │ │ │ -484 DUNE_SIMD_CHECK(is123(vec)); } │ │ │ │ │ -485 } │ │ │ │ │ -486 │ │ │ │ │ -487 template │ │ │ │ │ -488 void checkBroadcastVectorConstruct() │ │ │ │ │ -489 { │ │ │ │ │ -490 // broadcast copy constructors │ │ │ │ │ -491 { Scalar ref = 42; V vec (ref); │ │ │ │ │ -492 DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar(42)); } │ │ │ │ │ -493 { Scalar ref = 42; V vec = ref ; │ │ │ │ │ -494 DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar(42)); } │ │ │ │ │ -495 // { Scalar ref = 42; V vec {ref}; │ │ │ │ │ -496 // DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar(42)); } │ │ │ │ │ -497 // { Scalar ref = 42; V vec = {ref}; │ │ │ │ │ -498 // DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar(42)); } │ │ │ │ │ -499 { const Scalar ref = 42; V vec (ref); │ │ │ │ │ -500 DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ -501 { const Scalar ref = 42; V vec = ref ; │ │ │ │ │ -502 DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ -503 // { const Scalar ref = 42; V vec {ref}; │ │ │ │ │ -504 // DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ -505 // { const Scalar ref = 42; V vec = {ref}; │ │ │ │ │ -506 // DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ -507 │ │ │ │ │ -508 // broadcast move constructors │ │ │ │ │ -509 { Scalar ref = 42; V vec (std::move(ref)); │ │ │ │ │ -510 DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ -511 { Scalar ref = 42; V vec = std::move(ref) ; │ │ │ │ │ -512 DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ -513 // { Scalar ref = 42; V vec {std::move(ref)}; │ │ │ │ │ -514 // DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ -515 // { Scalar ref = 42; V vec = {std::move(ref)}; │ │ │ │ │ -516 // DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ -517 } │ │ │ │ │ -518 │ │ │ │ │ -519 template │ │ │ │ │ -520 void checkBroadcastMaskConstruct() │ │ │ │ │ -521 { │ │ │ │ │ -522 // broadcast copy constructors │ │ │ │ │ -523 { Scalar ref = 42; V vec (ref); │ │ │ │ │ -524 DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar(42)); } │ │ │ │ │ -525 // { Scalar ref = 42; V vec = ref ; │ │ │ │ │ -526 // DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar(42)); } │ │ │ │ │ -527 { Scalar ref = 42; V vec {ref}; │ │ │ │ │ -528 DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar(42)); } │ │ │ │ │ -529 // { Scalar ref = 42; V vec = {ref}; │ │ │ │ │ -530 // DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar(42)); } │ │ │ │ │ -531 { const Scalar ref = 42; V vec (ref); │ │ │ │ │ -532 DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ -533 // { const Scalar ref = 42; V vec = ref ; │ │ │ │ │ -534 // DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ -535 { const Scalar ref = 42; V vec {ref}; │ │ │ │ │ -536 DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ -537 // { const Scalar ref = 42; V vec = {ref}; │ │ │ │ │ -538 // DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ -539 │ │ │ │ │ -540 // broadcast move constructors │ │ │ │ │ -541 { Scalar ref = 42; V vec (std::move(ref)); │ │ │ │ │ -542 DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ -543 // { Scalar ref = 42; V vec = std::move(ref) ; │ │ │ │ │ -544 // DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ -545 { Scalar ref = 42; V vec {std::move(ref)}; │ │ │ │ │ -546 DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ -547 // { Scalar ref = 42; V vec = {std::move(ref)}; │ │ │ │ │ -548 // DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ -549 } │ │ │ │ │ -550 │ │ │ │ │ -551 // check the implCast function │ │ │ │ │ -552 template │ │ │ │ │ -553 void checkImplCast() │ │ │ │ │ -554 { │ │ │ │ │ -555 { // lvalue arg │ │ │ │ │ -556 FromV fromVec = make123(); │ │ │ │ │ -557 auto toVec = implCast(fromVec); │ │ │ │ │ -558 static_assert(std::is_same::value, │ │ │ │ │ -559 "Unexpected result type for implCast(FromV&)"); │ │ │ │ │ -560 DUNE_SIMD_CHECK(is123(fromVec)); │ │ │ │ │ -561 DUNE_SIMD_CHECK(is123(toVec)); │ │ │ │ │ -562 } │ │ │ │ │ -563 │ │ │ │ │ -564 { // const lvalue arg │ │ │ │ │ -565 const FromV fromVec = make123(); │ │ │ │ │ -566 auto toVec = implCast(fromVec); │ │ │ │ │ -567 static_assert(std::is_same::value, │ │ │ │ │ -568 "Unexpected result type for implCast(const " │ │ │ │ │ -569 "FromV&)"); │ │ │ │ │ -570 DUNE_SIMD_CHECK(is123(toVec)); │ │ │ │ │ -571 } │ │ │ │ │ -572 │ │ │ │ │ -573 { // rvalue arg │ │ │ │ │ -574 auto toVec = implCast(make123()); │ │ │ │ │ -575 static_assert(std::is_same::value, │ │ │ │ │ -576 "Unexpected result type for implCast(FromV&&)"); │ │ │ │ │ -577 DUNE_SIMD_CHECK(is123(toVec)); │ │ │ │ │ -578 } │ │ │ │ │ -579 } │ │ │ │ │ -580 │ │ │ │ │ -581 // check the implCast function │ │ │ │ │ -582 template │ │ │ │ │ -583 void checkImplCast() │ │ │ │ │ -584 { │ │ │ │ │ -585 // check against LoopSIMD │ │ │ │ │ -586 using LoopV = Dune::LoopSIMD, lanes()>; │ │ │ │ │ -587 │ │ │ │ │ -588 checkImplCast(); │ │ │ │ │ -589 checkImplCast(); │ │ │ │ │ -590 checkImplCast(); │ │ │ │ │ -591 } │ │ │ │ │ -592 │ │ │ │ │ -593 // check the broadcast function │ │ │ │ │ -594 template │ │ │ │ │ -595 void checkBroadcast() │ │ │ │ │ -596 { │ │ │ │ │ -597 // broadcast function │ │ │ │ │ -598 { // lvalue arg │ │ │ │ │ -599 Scalar ref = 42; │ │ │ │ │ -600 auto vec = broadcast(ref); │ │ │ │ │ -601 static_assert(std::is_same::value, │ │ │ │ │ -602 "Unexpected result type for broadcast()"); │ │ │ │ │ -603 DUNE_SIMD_CHECK(is42(vec)); │ │ │ │ │ -604 DUNE_SIMD_CHECK(ref == Scalar(42)); │ │ │ │ │ -605 } │ │ │ │ │ -606 │ │ │ │ │ -607 { // const lvalue arg │ │ │ │ │ -608 const Scalar ref = 42; │ │ │ │ │ -609 auto vec = broadcast(ref); │ │ │ │ │ -610 static_assert(std::is_same::value, │ │ │ │ │ -611 "Unexpected result type for broadcast()"); │ │ │ │ │ -612 DUNE_SIMD_CHECK(is42(vec)); │ │ │ │ │ -613 } │ │ │ │ │ -614 │ │ │ │ │ -615 { // rvalue arg │ │ │ │ │ -616 auto vec = broadcast(Scalar(42)); │ │ │ │ │ -617 static_assert(std::is_same::value, │ │ │ │ │ -618 "Unexpected result type for broadcast()"); │ │ │ │ │ -619 DUNE_SIMD_CHECK(is42(vec)); │ │ │ │ │ -620 } │ │ │ │ │ -621 │ │ │ │ │ -622 { // int arg │ │ │ │ │ -623 auto vec = broadcast(42); │ │ │ │ │ -624 static_assert(std::is_same::value, │ │ │ │ │ -625 "Unexpected result type for broadcast()"); │ │ │ │ │ -626 DUNE_SIMD_CHECK(is42(vec)); │ │ │ │ │ -627 } │ │ │ │ │ -628 │ │ │ │ │ -629 { // double arg │ │ │ │ │ -630 auto vec = broadcast(42.0); │ │ │ │ │ -631 static_assert(std::is_same::value, │ │ │ │ │ -632 "Unexpected result type for broadcast()"); │ │ │ │ │ -633 DUNE_SIMD_CHECK(is42(vec)); │ │ │ │ │ -634 } │ │ │ │ │ -635 } │ │ │ │ │ -636 │ │ │ │ │ -637 template │ │ │ │ │ -638 void checkBracedAssign() │ │ │ │ │ -639 { │ │ │ │ │ -640 // copy assignment │ │ │ │ │ -641 { V ref = make123(); V vec; vec = {ref}; │ │ │ │ │ -642 DUNE_SIMD_CHECK(is123(vec)); DUNE_SIMD_CHECK(is123(ref)); } │ │ │ │ │ -643 { const V ref = make123(); V vec; vec = {ref}; │ │ │ │ │ -644 DUNE_SIMD_CHECK(is123(vec)); DUNE_SIMD_CHECK(is123(ref)); } │ │ │ │ │ -645 │ │ │ │ │ -646 // move assignment │ │ │ │ │ -647 { V vec; vec = {make123()}; DUNE_SIMD_CHECK(is123(vec)); } │ │ │ │ │ -648 } │ │ │ │ │ -649 │ │ │ │ │ -650 template │ │ │ │ │ -651 void checkBracedBroadcastAssign() │ │ │ │ │ -652 { │ │ │ │ │ -653 // nothing works here │ │ │ │ │ -654 // // broadcast copy assignment │ │ │ │ │ -655 // { Scalar ref = 42; V vec; vec = {ref}; │ │ │ │ │ -656 // DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar(42)); } │ │ │ │ │ -657 // { const Scalar ref = 42; V vec; vec = {ref}; │ │ │ │ │ -658 // DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ -659 │ │ │ │ │ -660 // // broadcast move assignment │ │ │ │ │ -661 // { Scalar ref = 42; V vec; vec = {std::move(ref)}; │ │ │ │ │ -662 // DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ -663 } │ │ │ │ │ -664 │ │ │ │ │ -666 // │ │ │ │ │ -667 // checks for unary operators │ │ │ │ │ -668 // │ │ │ │ │ -669 │ │ │ │ │ -670#define DUNE_SIMD_POSTFIX_OP(NAME, SYMBOL) \ │ │ │ │ │ -671 struct OpPostfix##NAME \ │ │ │ │ │ -672 { \ │ │ │ │ │ -673 template \ │ │ │ │ │ -674 auto operator()(V&& v) const \ │ │ │ │ │ -675 -> decltype(std::forward(v) SYMBOL) \ │ │ │ │ │ -676 { \ │ │ │ │ │ -677 return std::forward(v) SYMBOL; \ │ │ │ │ │ -678 } \ │ │ │ │ │ -679 } │ │ │ │ │ -680 │ │ │ │ │ -681#define DUNE_SIMD_PREFIX_OP(NAME, SYMBOL) \ │ │ │ │ │ -682 struct OpPrefix##NAME \ │ │ │ │ │ -683 { \ │ │ │ │ │ -684 template \ │ │ │ │ │ -685 auto operator()(V&& v) const \ │ │ │ │ │ -686 -> decltype(SYMBOL std::forward(v)) \ │ │ │ │ │ -687 { \ │ │ │ │ │ -688 return SYMBOL std::forward(v); \ │ │ │ │ │ -689 } \ │ │ │ │ │ -690 } │ │ │ │ │ -691 │ │ │ │ │ -692 DUNE_SIMD_POSTFIX_OP(Decrement, -- ); │ │ │ │ │ -693 DUNE_SIMD_POSTFIX_OP(Increment, ++ ); │ │ │ │ │ -694 │ │ │ │ │ -695 DUNE_SIMD_PREFIX_OP (Decrement, -- ); │ │ │ │ │ -696 DUNE_SIMD_PREFIX_OP (Increment, ++ ); │ │ │ │ │ -697 │ │ │ │ │ -698 DUNE_SIMD_PREFIX_OP (Plus, + ); │ │ │ │ │ -699 DUNE_SIMD_PREFIX_OP (Minus, - ); │ │ │ │ │ -700 DUNE_SIMD_PREFIX_OP (LogicNot, ! ); │ │ │ │ │ -701 // Do not warn about ~ being applied to bool. (1) Yes, doing that is │ │ │ │ │ -702 // weird, but we do want to test the weird stuff too. (2) It avoids │ │ │ │ │ -703 // running into on │ │ │ │ │ -704 // g++-7.0 through 7.2. Also, ignore -Wpragmas to not warn about an │ │ │ │ │ -705 // unknown -Wbool-operation on compilers that do not know that option. │ │ │ │ │ -706#pragma GCC diagnostic push │ │ │ │ │ -707#pragma GCC diagnostic ignored "-Wpragmas" │ │ │ │ │ -708#pragma GCC diagnostic ignored "-Wunknown-warning-option" // clang 6.0.1 │ │ │ │ │ -709#pragma GCC diagnostic ignored "-Wbool-operation" │ │ │ │ │ -710 DUNE_SIMD_PREFIX_OP (BitNot, ~ ); │ │ │ │ │ -711#pragma GCC diagnostic pop │ │ │ │ │ -712 │ │ │ │ │ -713#undef DUNE_SIMD_POSTFIX_OP │ │ │ │ │ -714#undef DUNE_SIMD_PREFIX_OP │ │ │ │ │ -715 │ │ │ │ │ -716 template │ │ │ │ │ -717 std::enable_if_t< │ │ │ │ │ -718 IsCallable())))>::value> │ │ │ │ │ -719 checkUnaryOpV(Op op) │ │ │ │ │ -720 { │ │ │ │ │ -721#define DUNE_SIMD_OPNAME (className()) │ │ │ │ │ -722 // arguments │ │ │ │ │ -723 auto val = leftVector>(); │ │ │ │ │ -724 │ │ │ │ │ -725 // copy the arguments in case V is a references │ │ │ │ │ -726 auto arg = val; │ │ │ │ │ -727 auto &&result = op(static_cast(arg)); │ │ │ │ │ -728 using T = Scalar >; │ │ │ │ │ -729 for(std::size_t l = 0; l < lanes(val); ++l) │ │ │ │ │ -730 { │ │ │ │ │ -731 // `op` might promote the argument. This is a problem if the │ │ │ │ │ -732 // argument of the operation on the right of the `==` is │ │ │ │ │ -733 // e.g. `(unsigned short)1` and the operation is e.g. unary `-`. │ │ │ │ │ -734 // Then the argument is promoted to `int` before applying the │ │ │ │ │ -735 // negation, and the result is `(int)-1`. However, the left side of │ │ │ │ │ -736 // the `==` is still `(unsigned short)-1`, which typically is the │ │ │ │ │ -737 // same as `(unsigned short)65535`. The `==` promotes the left side │ │ │ │ │ -738 // before comparing, so that becomes `(int)65535`. It will then │ │ │ │ │ -739 // compare `(int)65535` and `(int)-1` and rightly declare them to be │ │ │ │ │ -740 // not equal. │ │ │ │ │ -741 │ │ │ │ │ -742 // To work around this, we explicitly convert the right side of the │ │ │ │ │ -743 // `==` to the scalar type before comparing. │ │ │ │ │ -744 DUNE_SIMD_CHECK_OP │ │ │ │ │ -745 (lane(l, result) │ │ │ │ │ -746 == static_cast(op(lane(l, static_cast(val))))); │ │ │ │ │ -747 } │ │ │ │ │ -748 // op might modify val, verify that any such modification also happens │ │ │ │ │ -749 // in the vector case │ │ │ │ │ -750 for(std::size_t l = 0; l < lanes >(); ++l) │ │ │ │ │ -751 DUNE_SIMD_CHECK_OP(lane(l, val) == lane(l, arg)); │ │ │ │ │ -752#undef DUNE_SIMD_OPNAME │ │ │ │ │ -753 } │ │ │ │ │ -754 │ │ │ │ │ -755 template │ │ │ │ │ -756 std::enable_if_t< │ │ │ │ │ -757 not IsCallable())))>::value> │ │ │ │ │ -758 checkUnaryOpV(Op op) │ │ │ │ │ -759 { │ │ │ │ │ -760 // log_ << "No " << className())))>() │ │ │ │ │ -761 // << std::endl │ │ │ │ │ -762 // << " ==> Not checking " << className() << std::endl; │ │ │ │ │ -763 } │ │ │ │ │ -764 │ │ │ │ │ -765 template │ │ │ │ │ -766 void checkUnaryOpsV(Op op) │ │ │ │ │ -767 { │ │ │ │ │ -768 checkUnaryOpV(op); │ │ │ │ │ -769 checkUnaryOpV(op); │ │ │ │ │ -770 checkUnaryOpV(op); │ │ │ │ │ -771 } │ │ │ │ │ -772 │ │ │ │ │ -774 // │ │ │ │ │ -775 // checks for binary operators │ │ │ │ │ -776 // │ │ │ │ │ -777 │ │ │ │ │ -778 // The operators contain an `operator()`, which will be invoked for both │ │ │ │ │ -779 // scalar and vector arguments. The function `scalar()` is used the │ │ │ │ │ -780 // test whether the scalar types support the operation (via │ │ │ │ │ -781 // `ScalarResult`). The difference is that `scalar()` should only ever │ │ │ │ │ -782 // receive `const`-ref-qualified version of `Scalar`, while the │ │ │ │ │ -783 // `operator()` may also be called with proxies representing scalars. │ │ │ │ │ -784#define DUNE_SIMD_INFIX_OP(NAME, SYMBOL) \ │ │ │ │ │ -785 struct OpInfix##NAME \ │ │ │ │ │ -786 { \ │ │ │ │ │ -787 template \ │ │ │ │ │ -788 decltype(auto) operator()(V1&& v1, V2&& v2) const \ │ │ │ │ │ -789 { \ │ │ │ │ │ -790 return std::forward(v1) SYMBOL std::forward(v2); \ │ │ │ │ │ -791 } \ │ │ │ │ │ -792 template \ │ │ │ │ │ -793 auto scalar(S1&& s1, S2&& s2) const \ │ │ │ │ │ -794 -> decltype(std::forward(s1) SYMBOL std::forward(s2)); \ │ │ │ │ │ -795 } │ │ │ │ │ -796 │ │ │ │ │ -797 // for assign ops, accept only non-const lvalue arguments for scalars. │ │ │ │ │ -798 // This is needed for class scalars (e.g. std::complex) because │ │ │ │ │ -799 // non-const class rvalues are actually usually assignable. Though that │ │ │ │ │ -800 // assignment happens to a temporary, and thus is lost. Except that the │ │ │ │ │ -801 // tests would bind the result of the assignment to a reference. And │ │ │ │ │ -802 // because that result is returned from a function by reference, even │ │ │ │ │ -803 // though it is a temporary passed as an argument to that function, │ │ │ │ │ -804 // accessing the result later is undefined behaviour. │ │ │ │ │ -805#define DUNE_SIMD_ASSIGN_OP(NAME, SYMBOL) \ │ │ │ │ │ -806 struct OpInfix##NAME \ │ │ │ │ │ -807 { \ │ │ │ │ │ -808 template \ │ │ │ │ │ -809 decltype(auto) operator()(V1&& v1, V2&& v2) const \ │ │ │ │ │ -810 { \ │ │ │ │ │ -811 return std::forward(v1) SYMBOL std::forward(v2); \ │ │ │ │ │ -812 } \ │ │ │ │ │ -813 template \ │ │ │ │ │ -814 auto scalar(S1& s1, S2&& s2) const \ │ │ │ │ │ -815 -> decltype(s1 SYMBOL std::forward(s2)); \ │ │ │ │ │ -816 } │ │ │ │ │ -817 │ │ │ │ │ -818#define DUNE_SIMD_REPL_OP(NAME, REPLFN, SYMBOL) \ │ │ │ │ │ -819 struct OpInfix##NAME \ │ │ │ │ │ -820 { \ │ │ │ │ │ -821 template \ │ │ │ │ │ -822 decltype(auto) operator()(V1&& v1, V2&& v2) const \ │ │ │ │ │ -823 { \ │ │ │ │ │ -824 return Simd::REPLFN(std::forward(v1), std::forward(v2)); \ │ │ │ │ │ -825 } \ │ │ │ │ │ -826 template \ │ │ │ │ │ -827 auto scalar(S1&& s1, S2&& s2) const \ │ │ │ │ │ -828 -> decltype(std::forward(s1) SYMBOL std::forward(s2)); \ │ │ │ │ │ -829 } │ │ │ │ │ -830 │ │ │ │ │ -831 DUNE_SIMD_INFIX_OP(Mul, * ); │ │ │ │ │ -832 DUNE_SIMD_INFIX_OP(Div, / ); │ │ │ │ │ -833 DUNE_SIMD_INFIX_OP(Remainder, % ); │ │ │ │ │ -834 │ │ │ │ │ -835 DUNE_SIMD_INFIX_OP(Plus, + ); │ │ │ │ │ -836 DUNE_SIMD_INFIX_OP(Minus, - ); │ │ │ │ │ -837 │ │ │ │ │ -838 DUNE_SIMD_INFIX_OP(LeftShift, << ); │ │ │ │ │ -839 DUNE_SIMD_INFIX_OP(RightShift, >> ); │ │ │ │ │ -840 │ │ │ │ │ -841 DUNE_SIMD_INFIX_OP(Less, < ); │ │ │ │ │ -842 DUNE_SIMD_INFIX_OP(Greater, > ); │ │ │ │ │ -843 DUNE_SIMD_INFIX_OP(LessEqual, <= ); │ │ │ │ │ -844 DUNE_SIMD_INFIX_OP(GreaterEqual, >= ); │ │ │ │ │ -845 │ │ │ │ │ -846 DUNE_SIMD_INFIX_OP(Equal, == ); │ │ │ │ │ -847 DUNE_SIMD_INFIX_OP(NotEqual, != ); │ │ │ │ │ -848 │ │ │ │ │ -849 DUNE_SIMD_INFIX_OP(BitAnd, & ); │ │ │ │ │ -850 DUNE_SIMD_INFIX_OP(BitXor, ^ ); │ │ │ │ │ -851 DUNE_SIMD_INFIX_OP(BitOr, | ); │ │ │ │ │ -852 │ │ │ │ │ -853 // Those are not supported in any meaningful way by vectorclass │ │ │ │ │ -854 // We need to test replacement functions maskAnd() and maskOr() instead. │ │ │ │ │ -855 DUNE_SIMD_REPL_OP(LogicAnd, maskAnd, && ); │ │ │ │ │ -856 DUNE_SIMD_REPL_OP(LogicOr, maskOr, || ); │ │ │ │ │ -857 │ │ │ │ │ -858 DUNE_SIMD_ASSIGN_OP(Assign, = ); │ │ │ │ │ -859 DUNE_SIMD_ASSIGN_OP(AssignMul, *= ); │ │ │ │ │ -860 DUNE_SIMD_ASSIGN_OP(AssignDiv, /= ); │ │ │ │ │ -861 DUNE_SIMD_ASSIGN_OP(AssignRemainder, %= ); │ │ │ │ │ -862 DUNE_SIMD_ASSIGN_OP(AssignPlus, += ); │ │ │ │ │ -863 DUNE_SIMD_ASSIGN_OP(AssignMinus, -= ); │ │ │ │ │ -864 DUNE_SIMD_ASSIGN_OP(AssignLeftShift, <<=); │ │ │ │ │ -865 DUNE_SIMD_ASSIGN_OP(AssignRightShift, >>=); │ │ │ │ │ -866 DUNE_SIMD_ASSIGN_OP(AssignAnd, &= ); │ │ │ │ │ -867 DUNE_SIMD_ASSIGN_OP(AssignXor, ^= ); │ │ │ │ │ -868 DUNE_SIMD_ASSIGN_OP(AssignOr, |= ); │ │ │ │ │ -869 │ │ │ │ │ -870#undef DUNE_SIMD_INFIX_OP │ │ │ │ │ -871#undef DUNE_SIMD_REPL_OP │ │ │ │ │ -872#undef DUNE_SIMD_ASSIGN_OP │ │ │ │ │ -873 │ │ │ │ │ -874 // just used as a tag │ │ │ │ │ -875 struct OpInfixComma {}; │ │ │ │ │ -876 │ │ │ │ │ -877 template │ │ │ │ │ -878 void checkCommaOp(const std::decay_t &val1, │ │ │ │ │ -879 const std::decay_t &val2) │ │ │ │ │ -880 { │ │ │ │ │ -881#define DUNE_SIMD_OPNAME (className()) │ │ │ │ │ -882 static_assert(std::is_same(), │ │ │ │ │ -883 std::declval())), T2>::value, │ │ │ │ │ -884 "Type and value category of the comma operator must " │ │ │ │ │ -885 "match that of the second operand"); │ │ │ │ │ -886 │ │ │ │ │ -887 // copy the arguments in case T1 or T2 are references │ │ │ │ │ -888 auto arg1 = val1; │ │ │ │ │ -889 auto arg2 = val2; │ │ │ │ │ -890 // Do not warn that the left side of the comma operator is unused. │ │ │ │ │ -891 // Seems to work for g++-4.9 and clang++-3.8. Appears to be harmless │ │ │ │ │ -892 // for icpc (14 and 17), and icpc does not seem to issue a warning │ │ │ │ │ -893 // anyway. │ │ │ │ │ -894#pragma GCC diagnostic push │ │ │ │ │ -895#pragma GCC diagnostic ignored "-Wunused-value" │ │ │ │ │ -896 auto &&result = (static_cast(arg1), │ │ │ │ │ -897 static_cast(arg2)); │ │ │ │ │ -898#pragma GCC diagnostic pop │ │ │ │ │ -899 if(std::is_reference::value) │ │ │ │ │ -900 { │ │ │ │ │ -901 // comma should return the same object as the second argument for │ │ │ │ │ -902 // lvalues and xvalues │ │ │ │ │ -903 DUNE_SIMD_CHECK_OP(&result == &arg2); │ │ │ │ │ -904 // it should not modify any arguments │ │ │ │ │ -905 DUNE_SIMD_CHECK_OP(allTrue(val1 == arg1)); │ │ │ │ │ -906 DUNE_SIMD_CHECK_OP(allTrue(val2 == arg2)); │ │ │ │ │ -907 } │ │ │ │ │ -908 else │ │ │ │ │ -909 { │ │ │ │ │ -910 // comma should return the same value as the second argument for │ │ │ │ │ -911 // prvalues │ │ │ │ │ -912 DUNE_SIMD_CHECK_OP(allTrue(result == arg2)); │ │ │ │ │ -913 // it should not modify any arguments │ │ │ │ │ -914 DUNE_SIMD_CHECK_OP(allTrue(val1 == arg1)); │ │ │ │ │ -915 // second argument is a prvalue, any modifications happen to a │ │ │ │ │ -916 // temporary and we can't detect them │ │ │ │ │ -917 } │ │ │ │ │ -918#undef DUNE_SIMD_OPNAME │ │ │ │ │ -919 } │ │ │ │ │ -920 │ │ │ │ │ -922 // │ │ │ │ │ -923 // checks for vector-vector binary operations │ │ │ │ │ -924 // │ │ │ │ │ -925 │ │ │ │ │ -926 // We check the following candidate operation │ │ │ │ │ -927 // │ │ │ │ │ -928 // vopres = vop1 @ vop2 │ │ │ │ │ -929 // │ │ │ │ │ -930 // against the reference operation │ │ │ │ │ -931 // │ │ │ │ │ -932 // arefres[l] = aref1[l] @ aref2[l] foreach l │ │ │ │ │ -933 // │ │ │ │ │ -934 // v... variables are simd-vectors and a... variables are arrays. The │ │ │ │ │ -935 // operation may modify the operands, but if is does the modification │ │ │ │ │ -936 // needs to happen in both the candidate and the reference. │ │ │ │ │ -937 // │ │ │ │ │ -938 // We do the following checks: │ │ │ │ │ -939 // 1. lanes(vopres) == lanes(vop1) │ │ │ │ │ -940 // 2. lane(l, vopres) == arefres[l] foreach l │ │ │ │ │ -941 // 3. lane(l, vop1) == aref1[l] foreach l │ │ │ │ │ -942 // 4. lane(l, vop2) == aref2[l] foreach l │ │ │ │ │ -943 template │ │ │ │ │ -944 std::enable_if_t > │ │ │ │ │ -945 checkBinaryOpVV(MetaType, MetaType, Op op) │ │ │ │ │ -946 { │ │ │ │ │ -947#define DUNE_SIMD_OPNAME (className()) │ │ │ │ │ -948 static_assert(std::is_same, std::decay_t >::value, │ │ │ │ │ -949 "Internal testsystem error: called with two types that " │ │ │ │ │ -950 "don't decay to the same thing"); │ │ │ │ │ -951 │ │ │ │ │ -952 // reference arguments │ │ │ │ │ -953 auto vref1 = leftVector>(); │ │ │ │ │ -954 auto vref2 = rightVector>(); │ │ │ │ │ -955 │ │ │ │ │ -956 // candidate arguments │ │ │ │ │ -957 auto vop1 = vref1; │ │ │ │ │ -958 auto vop2 = vref2; │ │ │ │ │ -959 │ │ │ │ │ -960 // candidate operation │ │ │ │ │ -961 auto &&vopres = op(static_cast(vop1), static_cast(vop2)); │ │ │ │ │ -962 using VR = decltype(vopres); │ │ │ │ │ -963 │ │ │ │ │ -964 // check 1. lanes(vopres) == lanes(vop1) │ │ │ │ │ -965 static_assert(lanes >() == lanes >(), │ │ │ │ │ -966 "The result must have the same number of lanes as the " │ │ │ │ │ -967 "operands."); │ │ │ │ │ -968 │ │ │ │ │ -969 // do the reference operation, and simultaneously │ │ │ │ │ -970 // check 2. lane(l, vopres) == arefres[l] foreach l │ │ │ │ │ -971 using T = Scalar >; │ │ │ │ │ -972 for(auto l : range(lanes(vopres))) │ │ │ │ │ -973 { │ │ │ │ │ -974 // see the lengthy comment in `checkUnaryOpV()` as to why the │ │ │ │ │ -975 // `static_cast` around the `op()` is necessary │ │ │ │ │ -976 DUNE_SIMD_CHECK_OP │ │ │ │ │ -977 (lane(l, vopres) │ │ │ │ │ -978 == static_cast(op(lane(l, static_cast(vref1)), │ │ │ │ │ -979 lane(l, static_cast(vref2))))); │ │ │ │ │ -980 } │ │ │ │ │ -981 │ │ │ │ │ -982 // check 3. lane(l, vop1) == aref1[l] foreach l │ │ │ │ │ -983 for(auto l : range(lanes(vop1))) │ │ │ │ │ -984 DUNE_SIMD_CHECK_OP(lane(l, vop1) == lane(l, vref1)); │ │ │ │ │ -985 │ │ │ │ │ -986 // check 4. lane(l, vop2) == aref2[l] foreach l │ │ │ │ │ -987 for(auto l : range(lanes(vop2))) │ │ │ │ │ -988 DUNE_SIMD_CHECK_OP(lane(l, vop2) == lane(l, vref2)); │ │ │ │ │ -989 │ │ │ │ │ -990#undef DUNE_SIMD_OPNAME │ │ │ │ │ -991 } │ │ │ │ │ -992 │ │ │ │ │ -993 template │ │ │ │ │ -994 std::enable_if_t > │ │ │ │ │ -995 checkBinaryOpVV(MetaType, MetaType, Op op) │ │ │ │ │ -996 { │ │ │ │ │ -997 // log_ << "No " << className())), │ │ │ │ │ -998 // decltype(lane(0, std::declval())))>() │ │ │ │ │ -999 // << std::endl │ │ │ │ │ -1000 // << " ==> Not checking " << className() << std::endl; │ │ │ │ │ -1001 } │ │ │ │ │ -1002 │ │ │ │ │ -1003 template │ │ │ │ │ -1004 void checkBinaryOpVV(MetaType, MetaType, OpInfixComma) │ │ │ │ │ -1005 { │ │ │ │ │ -1006 static_assert(std::is_same, std::decay_t >::value, │ │ │ │ │ -1007 "Internal testsystem error: called with two types that " │ │ │ │ │ -1008 "don't decay to the same thing"); │ │ │ │ │ -1009 │ │ │ │ │ -1010 checkCommaOp(leftVector>(), │ │ │ │ │ -1011 rightVector>()); │ │ │ │ │ -1012 } │ │ │ │ │ -1013 │ │ │ │ │ -1015 // │ │ │ │ │ -1016 // checks for vector-scalar binary operations │ │ │ │ │ -1017 // │ │ │ │ │ -1018 │ │ │ │ │ -1019 // We check the following candidate operation │ │ │ │ │ -1020 // │ │ │ │ │ -1021 // vopres = vop1 @ sop2 │ │ │ │ │ -1022 // │ │ │ │ │ -1023 // against the reference operation │ │ │ │ │ -1024 // │ │ │ │ │ -1025 // arefres[l] = aref1[l] @ sref2 foreach l │ │ │ │ │ -1026 // │ │ │ │ │ -1027 // v... variables are simd-vectors, a... variables are arrays, and │ │ │ │ │ -1028 // s... variables are scalars. The operation may modify the left │ │ │ │ │ -1029 // operand, but if is does the modifications needs to happen in both the │ │ │ │ │ -1030 // candidate and the reference. │ │ │ │ │ -1031 // │ │ │ │ │ -1032 // We do the following checks: │ │ │ │ │ -1033 // 1. lanes(vopres) == lanes(vop1) │ │ │ │ │ -1034 // 2. lane(l, vopres) == arefres[l] foreach l │ │ │ │ │ -1035 // 3. lane(l, vop1) == aref1[l] foreach l │ │ │ │ │ -1036 // 4. sop2 is never modified │ │ │ │ │ -1037 // 5. sref2 is never modified │ │ │ │ │ -1038 // │ │ │ │ │ -1039 // In fact, if the property "sref2 is never modified" is violated that │ │ │ │ │ -1040 // means the operation is unsuitable for an automatic broadcast of the │ │ │ │ │ -1041 // second operand and should not be checked. There are no operations in │ │ │ │ │ -1042 // the standard where the second operand is modified like this, but │ │ │ │ │ -1043 // there are operations where the first operand is modified -- and this │ │ │ │ │ -1044 // check is used for those ops as well by exchanging the first and second │ │ │ │ │ -1045 // argument below. │ │ │ │ │ -1046 │ │ │ │ │ -1047 template │ │ │ │ │ -1048 std::enable_if_t > │ │ │ │ │ -1049 checkBinaryOpVS(MetaType, MetaType, Op op) │ │ │ │ │ -1050 { │ │ │ │ │ -1051#define DUNE_SIMD_OPNAME (className()) │ │ │ │ │ -1052 static_assert(std::is_same >, │ │ │ │ │ -1053 std::decay_t >::value, │ │ │ │ │ -1054 "Internal testsystem error: called with a scalar that " │ │ │ │ │ -1055 "does not match the vector type."); │ │ │ │ │ -1056 │ │ │ │ │ -1057 // initial values │ │ │ │ │ -1058 auto sinit2 = rightScalar>(); │ │ │ │ │ -1059 │ │ │ │ │ -1060 // reference arguments │ │ │ │ │ -1061 auto vref1 = leftVector>(); │ │ │ │ │ -1062 auto sref2 = sinit2; │ │ │ │ │ -1063 │ │ │ │ │ -1064 // candidate arguments │ │ │ │ │ -1065 auto vop1 = vref1; │ │ │ │ │ -1066 auto sop2 = sref2; │ │ │ │ │ -1067 │ │ │ │ │ -1068 // candidate operation │ │ │ │ │ -1069 auto &&vopres = op(static_cast(vop1), static_cast(sop2)); │ │ │ │ │ -1070 using VR = decltype(vopres); │ │ │ │ │ -1071 │ │ │ │ │ -1072 // check 1. lanes(vopres) == lanes(vop1) │ │ │ │ │ -1073 static_assert(lanes >() == lanes >(), │ │ │ │ │ -1074 "The result must have the same number of lanes as the " │ │ │ │ │ -1075 "operands."); │ │ │ │ │ -1076 │ │ │ │ │ -1077 // check 4. sop2 is never modified │ │ │ │ │ -1078 DUNE_SIMD_CHECK_OP(sop2 == sinit2); │ │ │ │ │ -1079 │ │ │ │ │ -1080 // do the reference operation, and simultaneously check 2. and 5. │ │ │ │ │ -1081 using T = Scalar >; │ │ │ │ │ -1082 for(auto l : range(lanes(vopres))) │ │ │ │ │ -1083 { │ │ │ │ │ -1084 // check 2. lane(l, vopres) == arefres[l] foreach l │ │ │ │ │ -1085 // see the lengthy comment in `checkUnaryOpV()` as to why the │ │ │ │ │ -1086 // `static_cast` around the `op()` is necessary │ │ │ │ │ -1087 DUNE_SIMD_CHECK_OP │ │ │ │ │ -1088 (lane(l, vopres) │ │ │ │ │ -1089 == static_cast(op(lane(l, static_cast(vref1)), │ │ │ │ │ -1090 static_cast(sref2) ))); │ │ │ │ │ -1091 // check 5. sref2 is never modified │ │ │ │ │ -1092 DUNE_SIMD_CHECK_OP(sref2 == sinit2); │ │ │ │ │ -1093 } │ │ │ │ │ -1094 │ │ │ │ │ -1095 // check 3. lane(l, vop1) == aref1[l] foreach l │ │ │ │ │ -1096 for(auto l : range(lanes(vop1))) │ │ │ │ │ -1097 DUNE_SIMD_CHECK_OP(lane(l, vop1) == lane(l, vref1)); │ │ │ │ │ -1098 │ │ │ │ │ -1099#undef DUNE_SIMD_OPNAME │ │ │ │ │ -1100 } │ │ │ │ │ -1101 │ │ │ │ │ -1102 template │ │ │ │ │ -1103 std::enable_if_t > │ │ │ │ │ -1104 checkBinaryOpVS(MetaType, MetaType, Op op) │ │ │ │ │ -1105 { │ │ │ │ │ -1106 // log_ << "No " │ │ │ │ │ -1107 // << className())), T2)>() │ │ │ │ │ -1108 // << std::endl │ │ │ │ │ -1109 // << " ==> Not checking " << className() << std::endl; │ │ │ │ │ -1110 } │ │ │ │ │ -1111 │ │ │ │ │ -1112 template │ │ │ │ │ -1113 void checkBinaryOpVS(MetaType, MetaType, OpInfixComma) │ │ │ │ │ -1114 { │ │ │ │ │ -1115 static_assert(std::is_same >, │ │ │ │ │ -1116 std::decay_t >::value, │ │ │ │ │ -1117 "Internal testsystem error: called with a scalar that " │ │ │ │ │ -1118 "does not match the vector type."); │ │ │ │ │ -1119 │ │ │ │ │ -1120 checkCommaOp(leftVector>(), │ │ │ │ │ -1121 rightScalar>()); │ │ │ │ │ -1122 } │ │ │ │ │ -1123 │ │ │ │ │ -1125 // │ │ │ │ │ -1126 // cross-check scalar-vector binary operations against vector-vector │ │ │ │ │ -1127 // │ │ │ │ │ -1128 │ │ │ │ │ -1129 // We check the following candidate operation │ │ │ │ │ -1130 // │ │ │ │ │ -1131 // vopres = vop1 @ vop2, where vop2 = broadcast(sref2) │ │ │ │ │ -1132 // │ │ │ │ │ -1133 // against the reference operation │ │ │ │ │ -1134 // │ │ │ │ │ -1135 // vrefres = vref1 @ sref2 │ │ │ │ │ -1136 // │ │ │ │ │ -1137 // v... variables are simd-vectors, a... variables are arrays, and │ │ │ │ │ -1138 // s... variables are scalars. │ │ │ │ │ -1139 // │ │ │ │ │ -1140 // We could check the following properties │ │ │ │ │ -1141 // 1. lanes(vopres) == lanes(vop1) │ │ │ │ │ -1142 // 2. lane(l, vopres) == lane(l, vrefres) foreach l │ │ │ │ │ -1143 // 3. lane(l, vop1) == lane(l, vref1) foreach l │ │ │ │ │ -1144 // but these are given by checking the operation against the scalar │ │ │ │ │ -1145 // operation in the vector@vector and vector@scalar cases above. │ │ │ │ │ -1146 // │ │ │ │ │ -1147 // The only thing left to check is: │ │ │ │ │ -1148 // 4. lane(l, vop2) foreach l is never modified │ │ │ │ │ -1149 │ │ │ │ │ -1150 template │ │ │ │ │ -1151 std::enable_if_t > │ │ │ │ │ -1152 checkBinaryOpVVAgainstVS(MetaType, MetaType, Op op) │ │ │ │ │ -1153 { │ │ │ │ │ -1154#define DUNE_SIMD_OPNAME (className()) │ │ │ │ │ -1155 static_assert(std::is_same >, │ │ │ │ │ -1156 std::decay_t >::value, │ │ │ │ │ -1157 "Internal testsystem error: called with a scalar that " │ │ │ │ │ -1158 "does not match the vector type."); │ │ │ │ │ -1159 │ │ │ │ │ -1160 // initial values │ │ │ │ │ -1161 auto sinit2 = rightScalar>(); │ │ │ │ │ -1162 │ │ │ │ │ -1163 // reference arguments │ │ │ │ │ -1164 auto vop1 = leftVector>(); │ │ │ │ │ -1165 using V2 = CopyRefQual; │ │ │ │ │ -1166 std::decay_t vop2(sinit2); │ │ │ │ │ -1167 │ │ │ │ │ -1168 // candidate operation │ │ │ │ │ -1169 op(static_cast(vop1), static_cast(vop2)); │ │ │ │ │ -1170 │ │ │ │ │ -1171 // 4. lane(l, vop2) foreach l is never modified │ │ │ │ │ -1172 for(auto l : range(lanes(vop2))) │ │ │ │ │ -1173 DUNE_SIMD_CHECK_OP(lane(l, vop2) == sinit2); │ │ │ │ │ -1174 │ │ │ │ │ -1175#undef DUNE_SIMD_OPNAME │ │ │ │ │ -1176 } │ │ │ │ │ -1177 │ │ │ │ │ -1178 template │ │ │ │ │ -1179 std::enable_if_t > │ │ │ │ │ -1180 checkBinaryOpVVAgainstVS(MetaType, MetaType, Op op) │ │ │ │ │ -1181 { │ │ │ │ │ -1182 // log_ << "No " │ │ │ │ │ -1183 // << className())), T2)>() │ │ │ │ │ -1184 // << std::endl │ │ │ │ │ -1185 // << " ==> Not checking " << className() << std::endl; │ │ │ │ │ -1186 } │ │ │ │ │ -1187 │ │ │ │ │ -1188 template │ │ │ │ │ -1189 void checkBinaryOpVVAgainstVS(MetaType, MetaType, OpInfixComma) │ │ │ │ │ -1190 { } │ │ │ │ │ -1191 │ │ │ │ │ -1193 // │ │ │ │ │ -1194 // checks for vector-proxy binary operations │ │ │ │ │ -1195 // │ │ │ │ │ -1196 │ │ │ │ │ -1197 // We check the following candidate operation │ │ │ │ │ -1198 // │ │ │ │ │ -1199 // vopres = vop1 @ pop2 │ │ │ │ │ -1200 // │ │ │ │ │ -1201 // against the reference operation │ │ │ │ │ -1202 // │ │ │ │ │ -1203 // arefres[l] = aref1[l] @ sref2 foreach l │ │ │ │ │ -1204 // │ │ │ │ │ -1205 // v... variables are simd-vectors, a... variables are arrays, │ │ │ │ │ -1206 // p... variables are proxies of simd-vector entries and s... variables │ │ │ │ │ -1207 // are scalars. The operation may modify the left operand, but if is │ │ │ │ │ -1208 // does the modifications needs to happen in both the candidate and the │ │ │ │ │ -1209 // reference. │ │ │ │ │ -1210 // │ │ │ │ │ -1211 // We do the following checks: │ │ │ │ │ -1212 // 1. lanes(vopres) == lanes(vop1) │ │ │ │ │ -1213 // 2. lane(l, vopres) == arefres[l] foreach l │ │ │ │ │ -1214 // 3. lane(l, vop1) == aref1[l] foreach l │ │ │ │ │ -1215 // 4. pop2 is never modified │ │ │ │ │ -1216 // 5. sref2 is never modified │ │ │ │ │ -1217 // │ │ │ │ │ -1218 // In fact, if the property "sref2 is never modified" is violated that │ │ │ │ │ -1219 // means the operation is unsuitable for an automatic broadcast of the │ │ │ │ │ -1220 // second operand and should not be checked. There are no operations in │ │ │ │ │ -1221 // the standard where the second operand is modified like this, but │ │ │ │ │ -1222 // there are operations where the first operand is modified -- and this │ │ │ │ │ -1223 // check is used for those ops as well by exchanging the first and second │ │ │ │ │ -1224 // argument below. │ │ │ │ │ -1225 │ │ │ │ │ -1226 template │ │ │ │ │ -1227 std::enable_if_t > │ │ │ │ │ -1228 checkBinaryOpVP(MetaType, MetaType, Op op) │ │ │ │ │ -1229 { │ │ │ │ │ -1230 using P2 = decltype(lane(0, std::declval())); │ │ │ │ │ -1231 using T2 = CopyRefQual, V2>; │ │ │ │ │ -1232#define DUNE_SIMD_OPNAME (className()) │ │ │ │ │ -1233 static_assert(std::is_same, Scalar >::value, │ │ │ │ │ -1234 "Internal testsystem error: called with two vector " │ │ │ │ │ -1235 "types whose scalar types don't match."); │ │ │ │ │ -1236 │ │ │ │ │ -1237 // initial values │ │ │ │ │ -1238 auto sinit2 = rightScalar>(); │ │ │ │ │ -1239 │ │ │ │ │ -1240 // reference arguments │ │ │ │ │ -1241 auto vref1 = leftVector>(); │ │ │ │ │ -1242 auto sref2 = sinit2; │ │ │ │ │ -1243 │ │ │ │ │ -1244 // candidate arguments │ │ │ │ │ -1245 auto vop1 = vref1; │ │ │ │ │ -1246 auto vop2 = std::decay_t(Scalar(0)); │ │ │ │ │ -1247 lane(0, vop2) = sref2; // pop2 is just a name for `lane(0, vop2)` │ │ │ │ │ -1248 │ │ │ │ │ -1249 // candidate operation │ │ │ │ │ -1250 auto &&vopres = │ │ │ │ │ -1251 op(static_cast(vop1), lane(0, static_cast(vop2))); │ │ │ │ │ -1252 using VR = decltype(vopres); │ │ │ │ │ -1253 │ │ │ │ │ -1254 // check 1. lanes(vopres) == lanes(vop1) │ │ │ │ │ -1255 static_assert(lanes >() == lanes >(), │ │ │ │ │ -1256 "The result must have the same number of lanes as the " │ │ │ │ │ -1257 "operands."); │ │ │ │ │ -1258 │ │ │ │ │ -1259 // check 4. pop2 is never modified │ │ │ │ │ -1260 DUNE_SIMD_CHECK_OP(lane(0, vop2) == sinit2); │ │ │ │ │ -1261 │ │ │ │ │ -1262 // do the reference operation, and simultaneously check 2. and 5. │ │ │ │ │ -1263 using T = Scalar; │ │ │ │ │ -1264 for(auto l : range(lanes(vopres))) │ │ │ │ │ -1265 { │ │ │ │ │ -1266 // check 2. lane(l, vopres) == arefres[l] foreach l │ │ │ │ │ -1267 // see the lengthy comment in `checkUnaryOpV()` as to why the │ │ │ │ │ -1268 // `static_cast` around the `op()` is necessary │ │ │ │ │ -1269 DUNE_SIMD_CHECK_OP │ │ │ │ │ -1270 (lane(l, vopres) │ │ │ │ │ -1271 == static_cast(op(lane(l, static_cast(vref1)), │ │ │ │ │ -1272 static_cast(sref2) ))); │ │ │ │ │ -1273 // check 5. sref2 is never modified │ │ │ │ │ -1274 DUNE_SIMD_CHECK_OP(sref2 == sinit2); │ │ │ │ │ -1275 } │ │ │ │ │ -1276 │ │ │ │ │ -1277 // check 3. lane(l, vop1) == aref1[l] foreach l │ │ │ │ │ -1278 for(auto l : range(lanes(vop1))) │ │ │ │ │ -1279 DUNE_SIMD_CHECK_OP(lane(l, vop1) == lane(l, vref1)); │ │ │ │ │ -1280 │ │ │ │ │ -1281#undef DUNE_SIMD_OPNAME │ │ │ │ │ -1282 } │ │ │ │ │ -1283 │ │ │ │ │ -1284 template │ │ │ │ │ -1285 std::enable_if_t > │ │ │ │ │ -1286 checkBinaryOpVP(MetaType, MetaType, Op op) │ │ │ │ │ -1287 { │ │ │ │ │ -1288 // log_ << "No " │ │ │ │ │ -1289 // << className())), T2)>() │ │ │ │ │ -1290 // << std::endl │ │ │ │ │ -1291 // << " ==> Not checking " << className() << std::endl; │ │ │ │ │ -1292 } │ │ │ │ │ -1293 │ │ │ │ │ -1294 template │ │ │ │ │ -1295 void checkBinaryOpVP(MetaType, MetaType, OpInfixComma) │ │ │ │ │ -1296 { │ │ │ │ │ -1297 // Don't really know how to check comma operator for proxies │ │ │ │ │ -1298 } │ │ │ │ │ -1299 │ │ │ │ │ -1301 // │ │ │ │ │ -1302 // checks for (scalar/proxy)-vector binary operations │ │ │ │ │ -1303 // │ │ │ │ │ -1304 │ │ │ │ │ -1305 template │ │ │ │ │ -1306 struct OpInfixSwappedArgs │ │ │ │ │ -1307 { │ │ │ │ │ -1308 Op orig; │ │ │ │ │ -1309 │ │ │ │ │ -1310 template │ │ │ │ │ -1311 decltype(auto) operator()(V1&& v1, V2&& v2) const │ │ │ │ │ -1312 { │ │ │ │ │ -1313 return orig(std::forward(v2), std::forward(v1)); │ │ │ │ │ -1314 } │ │ │ │ │ -1315 template │ │ │ │ │ -1316 auto scalar(S1&& s1, S2&& s2) const │ │ │ │ │ -1317 -> decltype(orig.scalar(std::forward(s2), std::forward(s1))); │ │ │ │ │ -1318 }; │ │ │ │ │ -1319 │ │ │ │ │ -1320 template │ │ │ │ │ -1321 void checkBinaryOpSV(MetaType t1, MetaType v2, Op op) │ │ │ │ │ -1322 { │ │ │ │ │ -1323 checkBinaryOpVS(v2, t1, OpInfixSwappedArgs{op}); │ │ │ │ │ -1324 } │ │ │ │ │ -1325 │ │ │ │ │ -1326 template │ │ │ │ │ -1327 void checkBinaryOpSV(MetaType, MetaType, OpInfixComma) │ │ │ │ │ -1328 { │ │ │ │ │ -1329 static_assert(std::is_same, │ │ │ │ │ -1330 Scalar > >::value, │ │ │ │ │ -1331 "Internal testsystem error: called with a scalar that " │ │ │ │ │ -1332 "does not match the vector type."); │ │ │ │ │ -1333 │ │ │ │ │ -1334 checkCommaOp(leftScalar>(), │ │ │ │ │ -1335 rightVector>()); │ │ │ │ │ -1336 } │ │ │ │ │ -1337 │ │ │ │ │ -1338 template │ │ │ │ │ -1339 void checkBinaryOpPV(MetaType v1, MetaType v2, Op op) │ │ │ │ │ -1340 { │ │ │ │ │ -1341 checkBinaryOpVP(v2, v1, OpInfixSwappedArgs{op}); │ │ │ │ │ -1342 } │ │ │ │ │ -1343 │ │ │ │ │ -1344 template │ │ │ │ │ -1345 void checkBinaryOpPV(MetaType, MetaType, OpInfixComma) │ │ │ │ │ -1346 { │ │ │ │ │ -1347 // Don't really know how to check comma operator for proxies │ │ │ │ │ -1348 } │ │ │ │ │ -1349 │ │ │ │ │ -1351 // │ │ │ │ │ -1352 // cross-check scalar-vector binary operations against vector-vector │ │ │ │ │ -1353 // │ │ │ │ │ -1354 │ │ │ │ │ -1355 // We check the following candidate operation │ │ │ │ │ -1356 // │ │ │ │ │ -1357 // vopres = vop1 @ vop2, where vop2 = broadcast(sref2) │ │ │ │ │ -1358 // │ │ │ │ │ -1359 // against the reference operation │ │ │ │ │ -1360 // │ │ │ │ │ -1361 // vrefres = vref1 @ sref2 │ │ │ │ │ -1362 // │ │ │ │ │ -1363 // v... variables are simd-vectors, a... variables are arrays, and │ │ │ │ │ -1364 // s... variables are scalars. │ │ │ │ │ -1365 // │ │ │ │ │ -1366 // We could check the following properties │ │ │ │ │ -1367 // 1. lanes(vopres) == lanes(vop1) │ │ │ │ │ -1368 // 2. lane(l, vopres) == lane(l, vrefres) foreach l │ │ │ │ │ -1369 // 3. lane(l, vop1) == lane(l, vref1) foreach l │ │ │ │ │ -1370 // but these are given by checking the operation against the scalar │ │ │ │ │ -1371 // operation in the vector@vector and vector@scalar cases above. │ │ │ │ │ -1372 // │ │ │ │ │ -1373 // The only thing left to check is: │ │ │ │ │ -1374 // 4. lane(l, vop2) foreach l is never modified │ │ │ │ │ -1375 │ │ │ │ │ -1376 template │ │ │ │ │ -1377 void checkBinaryOpVVAgainstSV(MetaType t1, MetaType v2, Op op) │ │ │ │ │ -1378 { │ │ │ │ │ -1379 checkBinaryOpVVAgainstVS(v2, t1, OpInfixSwappedArgs{op}); │ │ │ │ │ -1380 } │ │ │ │ │ -1381 │ │ │ │ │ -1382 template │ │ │ │ │ -1383 void checkBinaryOpVVAgainstSV(MetaType, MetaType, OpInfixComma) │ │ │ │ │ -1384 { } │ │ │ │ │ -1385 │ │ │ │ │ -1387 // │ │ │ │ │ -1388 // Invoke the checks for all combinations │ │ │ │ │ -1389 // │ │ │ │ │ -1390 │ │ │ │ │ -1391 template │ │ │ │ │ -1392 void checkBinaryRefQual(Checker checker) │ │ │ │ │ -1393 { │ │ │ │ │ -1394 if constexpr (condition) { │ │ │ │ │ -1395 Hybrid::forEach(TypeList{}, [=] (auto t1) { │ │ │ │ │ -1396 Hybrid::forEach(TypeList{}, [=] (auto t2) { │ │ │ │ │ -1397 checker(t1, t2); │ │ │ │ │ -1398 }); │ │ │ │ │ -1399 }); │ │ │ │ │ -1400 } │ │ │ │ │ -1401 } │ │ │ │ │ -1402 │ │ │ │ │ -1403 template │ │ │ │ │ -1404 void checkBinaryOps(Checker checker) │ │ │ │ │ -1405 { │ │ │ │ │ -1406 using Std::bool_constant; │ │ │ │ │ -1407 │ │ │ │ │ -1408 constexpr bool isMask = std::is_same, bool>::value; │ │ │ │ │ -1409 │ │ │ │ │ -1410 constexpr bool do_ = false; │ │ │ │ │ -1411 constexpr bool do_SV = true; │ │ │ │ │ -1412 constexpr bool do_VV = true; │ │ │ │ │ -1413 constexpr bool do_VS = true; │ │ │ │ │ -1414 │ │ │ │ │ -1415#define DUNE_SIMD_DO(M1, M2, M3, V1, V2, V3, NAME) \ │ │ │ │ │ -1416 checker(bool_constant{}, \ │ │ │ │ │ -1417 bool_constant{}, \ │ │ │ │ │ -1418 bool_constant{}, \ │ │ │ │ │ -1419 Op##NAME{}) │ │ │ │ │ -1420 │ │ │ │ │ -1421 // (Mask , Vector , Name ); │ │ │ │ │ -1422 │ │ │ │ │ -1423 DUNE_SIMD_DO( , , , SV, VV, VS, InfixMul ); │ │ │ │ │ -1424 DUNE_SIMD_DO( , , , SV, VV, VS, InfixDiv ); │ │ │ │ │ -1425 DUNE_SIMD_DO( , , , SV, VV, VS, InfixRemainder ); │ │ │ │ │ -1426 │ │ │ │ │ -1427 DUNE_SIMD_DO( , , , SV, VV, VS, InfixPlus ); │ │ │ │ │ -1428 DUNE_SIMD_DO( , , , SV, VV, VS, InfixMinus ); │ │ │ │ │ -1429 │ │ │ │ │ -1430 DUNE_SIMD_DO( , , , , VV, VS, InfixLeftShift ); │ │ │ │ │ -1431 DUNE_SIMD_DO( , , , , VV, VS, InfixRightShift ); │ │ │ │ │ -1432 │ │ │ │ │ -1433 DUNE_SIMD_DO( , , , SV, VV, VS, InfixLess ); │ │ │ │ │ -1434 DUNE_SIMD_DO( , , , SV, VV, VS, InfixGreater ); │ │ │ │ │ -1435 DUNE_SIMD_DO( , , , SV, VV, VS, InfixLessEqual ); │ │ │ │ │ -1436 DUNE_SIMD_DO( , , , SV, VV, VS, InfixGreaterEqual ); │ │ │ │ │ -1437 │ │ │ │ │ -1438 DUNE_SIMD_DO( , , , SV, VV, VS, InfixEqual ); │ │ │ │ │ -1439 DUNE_SIMD_DO( , , , SV, VV, VS, InfixNotEqual ); │ │ │ │ │ -1440 │ │ │ │ │ -1441 DUNE_SIMD_DO( , VV, , SV, VV, VS, InfixBitAnd ); │ │ │ │ │ -1442 DUNE_SIMD_DO( , VV, , SV, VV, VS, InfixBitXor ); │ │ │ │ │ -1443 DUNE_SIMD_DO( , VV, , SV, VV, VS, InfixBitOr ); │ │ │ │ │ -1444 │ │ │ │ │ -1445 DUNE_SIMD_DO(SV, VV, VS, SV, VV, VS, InfixLogicAnd ); │ │ │ │ │ -1446 DUNE_SIMD_DO(SV, VV, VS, SV, VV, VS, InfixLogicOr ); │ │ │ │ │ -1447 │ │ │ │ │ -1448 DUNE_SIMD_DO( , VV, , , VV, VS, InfixAssign ); │ │ │ │ │ -1449 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignMul ); │ │ │ │ │ -1450 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignDiv ); │ │ │ │ │ -1451 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignRemainder ); │ │ │ │ │ -1452 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignPlus ); │ │ │ │ │ -1453 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignMinus ); │ │ │ │ │ -1454 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignLeftShift ); │ │ │ │ │ -1455 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignRightShift); │ │ │ │ │ -1456 DUNE_SIMD_DO( , VV, , , VV, VS, InfixAssignAnd ); │ │ │ │ │ -1457 DUNE_SIMD_DO( , VV, , , VV, VS, InfixAssignXor ); │ │ │ │ │ -1458 DUNE_SIMD_DO( , VV, , , VV, VS, InfixAssignOr ); │ │ │ │ │ -1459 │ │ │ │ │ -1460 DUNE_SIMD_DO(SV, VV, VS, SV, , VS, InfixComma ); │ │ │ │ │ -1461 │ │ │ │ │ -1462#undef DUNE_SIMD_DO │ │ │ │ │ -1463 } │ │ │ │ │ -1464 │ │ │ │ │ -1466 // │ │ │ │ │ -1467 // SIMD interface functions │ │ │ │ │ -1468 // │ │ │ │ │ -1469 │ │ │ │ │ -1470 template │ │ │ │ │ -1471 void checkAutoCopy() │ │ │ │ │ -1472 { │ │ │ │ │ -1473 using RValueResult = decltype(autoCopy(lane(0, std::declval()))); │ │ │ │ │ -1474 static_assert(std::is_same >::value, │ │ │ │ │ -1475 "Result of autoCopy() must always be Scalar"); │ │ │ │ │ -1476 │ │ │ │ │ -1477 using MutableLValueResult = │ │ │ │ │ -1478 decltype(autoCopy(lane(0, std::declval()))); │ │ │ │ │ -1479 static_assert(std::is_same >::value, │ │ │ │ │ -1480 "Result of autoCopy() must always be Scalar"); │ │ │ │ │ -1481 │ │ │ │ │ -1482 using ConstLValueResult = │ │ │ │ │ -1483 decltype(autoCopy(lane(0, std::declval()))); │ │ │ │ │ -1484 static_assert(std::is_same >::value, │ │ │ │ │ -1485 "Result of autoCopy() must always be Scalar"); │ │ │ │ │ -1486 │ │ │ │ │ -1487 V vec = make123(); │ │ │ │ │ -1488 for(std::size_t l = 0; l < lanes(vec); ++l) │ │ │ │ │ -1489 DUNE_SIMD_CHECK(autoCopy(lane(l, vec)) == Scalar(l+1)); │ │ │ │ │ -1490 } │ │ │ │ │ -1491 │ │ │ │ │ -1492 // may only be called for mask types │ │ │ │ │ -1493 template │ │ │ │ │ -1494 void checkBoolReductions() │ │ │ │ │ -1495 { │ │ │ │ │ -1496 M trueVec(true); │ │ │ │ │ -1497 │ │ │ │ │ -1498 // mutable lvalue │ │ │ │ │ -1499 DUNE_SIMD_CHECK(allTrue (static_cast(trueVec)) == true); │ │ │ │ │ -1500 DUNE_SIMD_CHECK(anyTrue (static_cast(trueVec)) == true); │ │ │ │ │ -1501 DUNE_SIMD_CHECK(allFalse(static_cast(trueVec)) == false); │ │ │ │ │ -1502 DUNE_SIMD_CHECK(anyFalse(static_cast(trueVec)) == false); │ │ │ │ │ -1503 │ │ │ │ │ -1504 // const lvalue │ │ │ │ │ -1505 DUNE_SIMD_CHECK(allTrue (static_cast(trueVec)) == true); │ │ │ │ │ -1506 DUNE_SIMD_CHECK(anyTrue (static_cast(trueVec)) == true); │ │ │ │ │ -1507 DUNE_SIMD_CHECK(allFalse(static_cast(trueVec)) == false); │ │ │ │ │ -1508 DUNE_SIMD_CHECK(anyFalse(static_cast(trueVec)) == false); │ │ │ │ │ -1509 │ │ │ │ │ -1510 // rvalue │ │ │ │ │ -1511 DUNE_SIMD_CHECK(allTrue (M(true)) == true); │ │ │ │ │ -1512 DUNE_SIMD_CHECK(anyTrue (M(true)) == true); │ │ │ │ │ -1513 DUNE_SIMD_CHECK(allFalse(M(true)) == false); │ │ │ │ │ -1514 DUNE_SIMD_CHECK(anyFalse(M(true)) == false); │ │ │ │ │ -1515 │ │ │ │ │ -1516 M falseVec(false); │ │ │ │ │ -1517 │ │ │ │ │ -1518 // mutable lvalue │ │ │ │ │ -1519 DUNE_SIMD_CHECK(allTrue (static_cast(falseVec)) == false); │ │ │ │ │ -1520 DUNE_SIMD_CHECK(anyTrue (static_cast(falseVec)) == false); │ │ │ │ │ -1521 DUNE_SIMD_CHECK(allFalse(static_cast(falseVec)) == true); │ │ │ │ │ -1522 DUNE_SIMD_CHECK(anyFalse(static_cast(falseVec)) == true); │ │ │ │ │ -1523 │ │ │ │ │ -1524 // const lvalue │ │ │ │ │ -1525 DUNE_SIMD_CHECK(allTrue (static_cast(falseVec)) == false); │ │ │ │ │ -1526 DUNE_SIMD_CHECK(anyTrue (static_cast(falseVec)) == false); │ │ │ │ │ -1527 DUNE_SIMD_CHECK(allFalse(static_cast(falseVec)) == true); │ │ │ │ │ -1528 DUNE_SIMD_CHECK(anyFalse(static_cast(falseVec)) == true); │ │ │ │ │ -1529 │ │ │ │ │ -1530 // rvalue │ │ │ │ │ -1531 DUNE_SIMD_CHECK(allTrue (M(false)) == false); │ │ │ │ │ -1532 DUNE_SIMD_CHECK(anyTrue (M(false)) == false); │ │ │ │ │ -1533 DUNE_SIMD_CHECK(allFalse(M(false)) == true); │ │ │ │ │ -1534 DUNE_SIMD_CHECK(anyFalse(M(false)) == true); │ │ │ │ │ -1535 │ │ │ │ │ -1536 auto mixedVec = broadcast(0); │ │ │ │ │ -1537 for(std::size_t l = 0; l < lanes(mixedVec); ++l) │ │ │ │ │ -1538 lane(l, mixedVec) = (l % 2); │ │ │ │ │ -1539 │ │ │ │ │ -1540 // mutable lvalue │ │ │ │ │ -1541 DUNE_SIMD_CHECK │ │ │ │ │ -1542 (allTrue (static_cast(mixedVec)) == false); │ │ │ │ │ -1543 DUNE_SIMD_CHECK │ │ │ │ │ -1544 (anyTrue (static_cast(mixedVec)) == (lanes() > 1)); │ │ │ │ │ -1545 DUNE_SIMD_CHECK │ │ │ │ │ -1546 (allFalse(static_cast(mixedVec)) == (lanes() == 1)); │ │ │ │ │ -1547 DUNE_SIMD_CHECK │ │ │ │ │ -1548 (anyFalse(static_cast(mixedVec)) == true); │ │ │ │ │ -1549 │ │ │ │ │ -1550 // const lvalue │ │ │ │ │ -1551 DUNE_SIMD_CHECK │ │ │ │ │ -1552 (allTrue (static_cast(mixedVec)) == false); │ │ │ │ │ -1553 DUNE_SIMD_CHECK │ │ │ │ │ -1554 (anyTrue (static_cast(mixedVec)) == (lanes() > 1)); │ │ │ │ │ -1555 DUNE_SIMD_CHECK │ │ │ │ │ -1556 (allFalse(static_cast(mixedVec)) == (lanes() == 1)); │ │ │ │ │ -1557 DUNE_SIMD_CHECK │ │ │ │ │ -1558 (anyFalse(static_cast(mixedVec)) == true); │ │ │ │ │ -1559 │ │ │ │ │ -1560 // rvalue │ │ │ │ │ -1561 DUNE_SIMD_CHECK(allTrue (M(mixedVec)) == false); │ │ │ │ │ -1562 DUNE_SIMD_CHECK(anyTrue (M(mixedVec)) == (lanes() > 1)); │ │ │ │ │ -1563 DUNE_SIMD_CHECK(allFalse(M(mixedVec)) == (lanes() == 1)); │ │ │ │ │ -1564 DUNE_SIMD_CHECK(anyFalse(M(mixedVec)) == true); │ │ │ │ │ -1565 } │ │ │ │ │ -1566 │ │ │ │ │ -1567 template │ │ │ │ │ -1568 void checkCond() │ │ │ │ │ -1569 { │ │ │ │ │ -1570 using M = Mask; │ │ │ │ │ -1571 │ │ │ │ │ -1572 static_assert │ │ │ │ │ -1573 (std::is_same(), std::declval(), │ │ │ │ │ -1574 std::declval())), V>::value, │ │ │ │ │ -1575 "The result of cond(M, V, V) should have exactly the type V"); │ │ │ │ │ -1576 │ │ │ │ │ -1577 static_assert │ │ │ │ │ -1578 (std::is_same(), │ │ │ │ │ -1579 std::declval(), │ │ │ │ │ -1580 std::declval())), V>::value, │ │ │ │ │ -1581 "The result of cond(const M&, const V&, const V&) should have " │ │ │ │ │ -1582 "exactly the type V"); │ │ │ │ │ -1583 │ │ │ │ │ -1584 static_assert │ │ │ │ │ -1585 (std::is_same(), std::declval(), │ │ │ │ │ -1586 std::declval())), V>::value, │ │ │ │ │ -1587 "The result of cond(M&, V&, V&) should have exactly the type V"); │ │ │ │ │ -1588 │ │ │ │ │ -1589 V vec1 = leftVector(); │ │ │ │ │ -1590 V vec2 = rightVector(); │ │ │ │ │ -1591 │ │ │ │ │ -1592 DUNE_SIMD_CHECK(allTrue(cond(M(true), vec1, vec2) == vec1)); │ │ │ │ │ -1593 DUNE_SIMD_CHECK(allTrue(cond(M(false), vec1, vec2) == vec2)); │ │ │ │ │ -1594 │ │ │ │ │ -1595 auto mixedResult = broadcast(0); │ │ │ │ │ -1596 auto mixedMask = broadcast(false); │ │ │ │ │ -1597 for(std::size_t l = 0; l < lanes(mixedMask); ++l) │ │ │ │ │ -1598 { │ │ │ │ │ -1599 lane(l, mixedMask ) = (l % 2); │ │ │ │ │ -1600 lane(l, mixedResult) = lane(l, (l % 2) ? vec1 : vec2); │ │ │ │ │ -1601 } │ │ │ │ │ -1602 │ │ │ │ │ -1603 DUNE_SIMD_CHECK(allTrue(cond(mixedMask, vec1, vec2) == mixedResult)); │ │ │ │ │ -1604 } │ │ │ │ │ -1605 │ │ │ │ │ -1606 template │ │ │ │ │ -1607 void checkBoolCond() │ │ │ │ │ -1608 { │ │ │ │ │ -1609 static_assert │ │ │ │ │ -1610 (std::is_same(), std::declval(), │ │ │ │ │ -1611 std::declval())), V>::value, │ │ │ │ │ -1612 "The result of cond(bool, V, V) should have exactly the type V"); │ │ │ │ │ -1613 │ │ │ │ │ -1614 static_assert │ │ │ │ │ -1615 (std::is_same(), │ │ │ │ │ -1616 std::declval(), │ │ │ │ │ -1617 std::declval())), V>::value, │ │ │ │ │ -1618 "The result of cond(const bool&, const V&, const V&) should have " │ │ │ │ │ -1619 "exactly the type V"); │ │ │ │ │ -1620 │ │ │ │ │ -1621 static_assert │ │ │ │ │ -1622 (std::is_same(), │ │ │ │ │ -1623 std::declval(), │ │ │ │ │ -1624 std::declval())), V>::value, │ │ │ │ │ -1625 "The result of cond(bool&, V&, V&) should have exactly the type V"); │ │ │ │ │ -1626 │ │ │ │ │ -1627 V vec1 = leftVector(); │ │ │ │ │ -1628 V vec2 = rightVector(); │ │ │ │ │ -1629 │ │ │ │ │ -1630 DUNE_SIMD_CHECK(allTrue(cond(true, vec1, vec2) == vec1)); │ │ │ │ │ -1631 DUNE_SIMD_CHECK(allTrue(cond(false, vec1, vec2) == vec2)); │ │ │ │ │ -1632 } │ │ │ │ │ -1633 │ │ │ │ │ -1634 template │ │ │ │ │ -1635 std::enable_if_t >::value> │ │ │ │ │ -1636 checkHorizontalMinMax() {} │ │ │ │ │ -1637 │ │ │ │ │ -1638 template │ │ │ │ │ -1639 std::enable_if_t >::value> │ │ │ │ │ -1640 checkHorizontalMinMax() │ │ │ │ │ -1641 { │ │ │ │ │ -1642 static_assert │ │ │ │ │ -1643 (std::is_same())), Scalar >::value, │ │ │ │ │ -1644 "The result of max(V) should be exactly Scalar"); │ │ │ │ │ -1645 │ │ │ │ │ -1646 static_assert │ │ │ │ │ -1647 (std::is_same())), Scalar >::value, │ │ │ │ │ -1648 "The result of min(V) should be exactly Scalar"); │ │ │ │ │ -1649 │ │ │ │ │ -1650 static_assert │ │ │ │ │ -1651 (std::is_same())), Scalar >::value, │ │ │ │ │ -1652 "The result of max(V) should be exactly Scalar"); │ │ │ │ │ -1653 │ │ │ │ │ -1654 static_assert │ │ │ │ │ -1655 (std::is_same())), Scalar >::value, │ │ │ │ │ -1656 "The result of min(V) should be exactly Scalar"); │ │ │ │ │ -1657 │ │ │ │ │ -1658 const V vec1 = leftVector(); │ │ │ │ │ -1659 │ │ │ │ │ -1660 DUNE_SIMD_CHECK(max(vec1) == Scalar(lanes(vec1))); │ │ │ │ │ -1661 DUNE_SIMD_CHECK(min(vec1) == Scalar(1)); │ │ │ │ │ -1662 } │ │ │ │ │ -1663 │ │ │ │ │ -1664 template │ │ │ │ │ -1665 std::enable_if_t >::value> │ │ │ │ │ -1666 checkBinaryMinMax() {} │ │ │ │ │ -1667 │ │ │ │ │ -1668 template │ │ │ │ │ -1669 std::enable_if_t >::value> │ │ │ │ │ -1670 checkBinaryMinMax() │ │ │ │ │ -1671 { │ │ │ │ │ -1672 using std::max; │ │ │ │ │ -1673 using std::min; │ │ │ │ │ -1674 │ │ │ │ │ -1675 static_assert │ │ │ │ │ -1676 (std::is_same(), │ │ │ │ │ -1677 std::declval())), V>::value, │ │ │ │ │ -1678 "The result of Simd::max(V, V) should be exactly V"); │ │ │ │ │ -1679 static_assert │ │ │ │ │ -1680 (std::is_same(), │ │ │ │ │ -1681 std::declval())), V>::value, │ │ │ │ │ -1682 "The result of Simd::min(V, V) should be exactly V"); │ │ │ │ │ -1683 │ │ │ │ │ -1684 static_assert │ │ │ │ │ -1685 (std::is_same(), │ │ │ │ │ -1686 std::declval())), V>::value, │ │ │ │ │ -1687 "The result of Simd::max(V&, V&) should be exactly V"); │ │ │ │ │ -1688 static_assert │ │ │ │ │ -1689 (std::is_same(), │ │ │ │ │ -1690 std::declval())), V>::value, │ │ │ │ │ -1691 "The result of Simd::min(V&, V&) should be exactly V"); │ │ │ │ │ -1692 │ │ │ │ │ -1693 const V arg1 = leftVector(); │ │ │ │ │ -1694 const V arg2 = rightVector(); │ │ │ │ │ -1695 │ │ │ │ │ -1696 V maxExp(Scalar(0)), minExp(Scalar(0)); │ │ │ │ │ -1697 for(auto l : range(lanes())) │ │ │ │ │ -1698 { │ │ │ │ │ -1699 lane(l, maxExp) = max(lane(l, arg1), lane(l, arg2)); │ │ │ │ │ -1700 lane(l, minExp) = min(lane(l, arg1), lane(l, arg2)); │ │ │ │ │ -1701 } │ │ │ │ │ -1702 │ │ │ │ │ -1703 DUNE_SIMD_CHECK(allTrue(maxExp == Simd::max(arg1, arg2))); │ │ │ │ │ -1704 DUNE_SIMD_CHECK(allTrue(minExp == Simd::min(arg1, arg2))); │ │ │ │ │ -1705 } │ │ │ │ │ -1706 │ │ │ │ │ -1707 template │ │ │ │ │ -1708 void checkIO() │ │ │ │ │ -1709 { │ │ │ │ │ -1710 const V vec1 = leftVector(); │ │ │ │ │ -1711 │ │ │ │ │ -1712 std::string reference; │ │ │ │ │ -1713 { │ │ │ │ │ -1714 const char *sep = ""; │ │ │ │ │ -1715 for(auto l : range(lanes(vec1))) │ │ │ │ │ -1716 { │ │ │ │ │ -1717 std::ostringstream stream; │ │ │ │ │ -1718 stream << lane(l, vec1); │ │ │ │ │ -1719 │ │ │ │ │ -1720 reference += sep; │ │ │ │ │ -1721 reference += stream.str(); │ │ │ │ │ -1722 sep = ", "; │ │ │ │ │ -1723 } │ │ │ │ │ -1724 } │ │ │ │ │ -1725 │ │ │ │ │ -1726 { │ │ │ │ │ -1727 std::ostringstream stream; │ │ │ │ │ -1728 stream << io(vec1); │ │ │ │ │ -1729 if(lanes(vec1) == 1) │ │ │ │ │ -1730 DUNE_SIMD_CHECK(stream.str() == reference); │ │ │ │ │ -1731 else │ │ │ │ │ -1732 DUNE_SIMD_CHECK(stream.str() == "<" + reference + ">"); │ │ │ │ │ -1733 } │ │ │ │ │ -1734 │ │ │ │ │ -1735 { │ │ │ │ │ -1736 std::ostringstream stream; │ │ │ │ │ -1737 stream << vio(vec1); │ │ │ │ │ -1738 DUNE_SIMD_CHECK(stream.str() == "<" + reference + ">"); │ │ │ │ │ -1739 } │ │ │ │ │ -1740 } │ │ │ │ │ -1741 │ │ │ │ │ -1742#undef DUNE_SIMD_CHECK │ │ │ │ │ -1743 │ │ │ │ │ -1744 public: │ │ │ │ │ -1807 template void checkType(); │ │ │ │ │ -1808 template void checkNonOps(); │ │ │ │ │ -1809 template void checkUnaryOps(); │ │ │ │ │ -1810 template void checkBinaryOps(); │ │ │ │ │ -1811 template void checkBinaryOpsVectorVector(); │ │ │ │ │ -1812 template void checkBinaryOpsScalarVector(); │ │ │ │ │ -1813 template void checkBinaryOpsVectorScalar(); │ │ │ │ │ -1814 template void checkBinaryOpsProxyVector(); │ │ │ │ │ -1815 template void checkBinaryOpsVectorProxy(); │ │ │ │ │ -1819 │ │ │ │ │ -1836 template class RebindPrune = IsLoop, │ │ │ │ │ -1838 template class RebindAccept = Dune::AlwaysTrue> │ │ │ │ │ -1839 void check() { │ │ │ │ │ -1840 // check whether the test for this type already started │ │ │ │ │ -1841 if(seen_.emplace(typeid (V)).second == false) │ │ │ │ │ -1842 { │ │ │ │ │ -1843 // type already seen, nothing to do │ │ │ │ │ -1844 return; │ │ │ │ │ -1845 } │ │ │ │ │ -1846 │ │ │ │ │ -1847 // do these first so everything that appears after "Checking SIMD type │ │ │ │ │ -1848 // ..." really pertains to that type │ │ │ │ │ -1849 auto recurse = [this](auto w) { │ │ │ │ │ -1850 using W = typename decltype(w)::type; │ │ │ │ │ -1851 this->template check(); │ │ │ │ │ -1852 }; │ │ │ │ │ -1853 checkRebindOf(recurse); │ │ │ │ │ -1854 │ │ │ │ │ -1855 checkType(); │ │ │ │ │ -1856 } │ │ │ │ │ -1857 │ │ │ │ │ -1859 bool good() const │ │ │ │ │ -1860 { │ │ │ │ │ -1861 return good_; │ │ │ │ │ -1862 } │ │ │ │ │ -1863 │ │ │ │ │ -1864 }; // class UnitTest │ │ │ │ │ -1865 │ │ │ │ │ -1866 template void UnitTest::checkType() │ │ │ │ │ -1867 { │ │ │ │ │ -1868 static_assert(std::is_same >::value, "Simd types " │ │ │ │ │ -1869 "must not be references, and must not include " │ │ │ │ │ -1870 "cv-qualifiers"); │ │ │ │ │ -1871 │ │ │ │ │ -1872 log_ << "Checking SIMD type " << className() << std::endl; │ │ │ │ │ -1873 │ │ │ │ │ -1874 checkNonOps(); │ │ │ │ │ -1875 checkUnaryOps(); │ │ │ │ │ -1876 checkBinaryOps(); │ │ │ │ │ -1877 } │ │ │ │ │ -1878 template void UnitTest::checkNonOps() │ │ │ │ │ -1879 { │ │ │ │ │ -1880 constexpr auto isMask = typename std::is_same, bool>::type{}; │ │ │ │ │ -1881 │ │ │ │ │ -1882 checkLanes(); │ │ │ │ │ -1883 checkScalar(); │ │ │ │ │ -1884 │ │ │ │ │ -1885 checkDefaultConstruct(); │ │ │ │ │ -1886 checkLane(); │ │ │ │ │ -1887 checkCopyMoveConstruct(); │ │ │ │ │ -1888 checkImplCast(); │ │ │ │ │ -1889 checkBroadcast(); │ │ │ │ │ -1890 if constexpr (isMask) │ │ │ │ │ -1891 this->template checkBroadcastMaskConstruct(); │ │ │ │ │ -1892 else │ │ │ │ │ -1893 this->template checkBroadcastVectorConstruct(); │ │ │ │ │ -1894 checkBracedAssign(); │ │ │ │ │ -1895 checkBracedBroadcastAssign(); │ │ │ │ │ -1896 │ │ │ │ │ -1897 checkAutoCopy(); │ │ │ │ │ -1898 checkCond(); │ │ │ │ │ -1899 checkBoolCond(); │ │ │ │ │ -1900 │ │ │ │ │ -1901 if constexpr (isMask) │ │ │ │ │ -1902 this->template checkBoolReductions(); │ │ │ │ │ -1903 // checkBoolReductions() is not applicable for non-masks │ │ │ │ │ -1904 │ │ │ │ │ -1905 checkHorizontalMinMax(); │ │ │ │ │ -1906 checkBinaryMinMax(); │ │ │ │ │ -1907 checkIO(); │ │ │ │ │ -1908 } │ │ │ │ │ -1909 template void UnitTest::checkUnaryOps() │ │ │ │ │ -1910 { │ │ │ │ │ -1911 if constexpr (std::is_same_v, bool>) { │ │ │ │ │ -1912 // check mask │ │ │ │ │ -1913 auto check = [this](auto op) { │ │ │ │ │ -1914 this->template checkUnaryOpsV(op); │ │ │ │ │ -1915 }; │ │ │ │ │ -1916 │ │ │ │ │ -1917 // postfix │ │ │ │ │ -1918 // check(OpPostfixDecrement{}); │ │ │ │ │ -1919 // clang deprecation warning if bool++ is tested │ │ │ │ │ -1920 // check(OpPostfixIncrement{}); │ │ │ │ │ -1921 │ │ │ │ │ -1922 // prefix │ │ │ │ │ -1923 // check(OpPrefixDecrement{}); │ │ │ │ │ -1924 // clang deprecation warning if ++bool is tested │ │ │ │ │ -1925 // check(OpPrefixIncrement{}); │ │ │ │ │ -1926 │ │ │ │ │ -1927 // check(OpPrefixPlus{}); │ │ │ │ │ -1928 // check(OpPrefixMinus{}); │ │ │ │ │ -1929 check(OpPrefixLogicNot{}); │ │ │ │ │ -1930 // check(OpPrefixBitNot{}); │ │ │ │ │ -1931 } │ │ │ │ │ -1932 else { │ │ │ │ │ -1933 // check vector │ │ │ │ │ -1934 auto check = [this](auto op) { │ │ │ │ │ -1935 this->template checkUnaryOpsV(op); │ │ │ │ │ -1936 }; │ │ │ │ │ -1937 │ │ │ │ │ -1938 // postfix │ │ │ │ │ -1939 // check(OpPostfixDecrement{}); │ │ │ │ │ -1940 // check(OpPostfixIncrement{}); │ │ │ │ │ -1941 │ │ │ │ │ -1942 // prefix │ │ │ │ │ -1943 // check(OpPrefixDecrement{}); │ │ │ │ │ -1944 // check(OpPrefixIncrement{}); │ │ │ │ │ -1945 │ │ │ │ │ -1946 // check(OpPrefixPlus{}); │ │ │ │ │ -1947 check(OpPrefixMinus{}); │ │ │ │ │ -1948 check(OpPrefixLogicNot{}); │ │ │ │ │ -1949 check(OpPrefixBitNot{}); │ │ │ │ │ -1950 } │ │ │ │ │ -1951 } │ │ │ │ │ -1952 template void UnitTest::checkBinaryOps() │ │ │ │ │ -1953 { │ │ │ │ │ -1954 checkBinaryOpsVectorVector(); │ │ │ │ │ -1955 checkBinaryOpsScalarVector(); │ │ │ │ │ -1956 checkBinaryOpsVectorScalar(); │ │ │ │ │ -1957 checkBinaryOpsProxyVector(); │ │ │ │ │ -1958 checkBinaryOpsVectorProxy(); │ │ │ │ │ -1959 } │ │ │ │ │ -1960 template void UnitTest::checkBinaryOpsVectorVector() │ │ │ │ │ -1961 { │ │ │ │ │ -1962 auto checker = [this](auto doSV, auto doVV, auto doVS, auto op) { │ │ │ │ │ -1963 auto check = [this,op](auto t1, auto t2) { │ │ │ │ │ -1964 this->checkBinaryOpVV(t1, t2, op); │ │ │ │ │ -1965 }; │ │ │ │ │ -1966 this->checkBinaryRefQual(check); │ │ │ │ │ -1967 }; │ │ │ │ │ -1968 checkBinaryOps(checker); │ │ │ │ │ -1969 } │ │ │ │ │ -1970 template void UnitTest::checkBinaryOpsScalarVector() │ │ │ │ │ -1971 { │ │ │ │ │ -1972 auto checker = [this](auto doSV, auto doVV, auto doVS, auto op) { │ │ │ │ │ -1973 auto check = [this,op](auto t1, auto t2) { │ │ │ │ │ -1974 this->checkBinaryOpSV(t1, t2, op); │ │ │ │ │ -1975 }; │ │ │ │ │ -1976 this->checkBinaryRefQual, V, doSV>(check); │ │ │ │ │ -1977 │ │ │ │ │ -1978 auto crossCheck = [this,op](auto t1, auto t2) { │ │ │ │ │ -1979 this->checkBinaryOpVVAgainstSV(t1, t2, op); │ │ │ │ │ -1980 }; │ │ │ │ │ -1981 this->checkBinaryRefQual, V, doSV && doVV>(crossCheck); │ │ │ │ │ -1982 }; │ │ │ │ │ -1983 checkBinaryOps(checker); │ │ │ │ │ -1984 } │ │ │ │ │ -1985 template void UnitTest::checkBinaryOpsVectorScalar() │ │ │ │ │ -1986 { │ │ │ │ │ -1987 auto checker = [this](auto doSV, auto doVV, auto doVS, auto op) { │ │ │ │ │ -1988 auto check = [this,op](auto t1, auto t2) { │ │ │ │ │ -1989 this->checkBinaryOpVS(t1, t2, op); │ │ │ │ │ -1990 }; │ │ │ │ │ -1991 this->checkBinaryRefQual, doVS>(check); │ │ │ │ │ -1992 │ │ │ │ │ -1993 auto crossCheck = [this,op](auto t1, auto t2) { │ │ │ │ │ -1994 this->checkBinaryOpVVAgainstVS(t1, t2, op); │ │ │ │ │ -1995 }; │ │ │ │ │ -1996 this->checkBinaryRefQual, doVV && doVS>(crossCheck); │ │ │ │ │ -1997 }; │ │ │ │ │ -1998 checkBinaryOps(checker); │ │ │ │ │ -1999 } │ │ │ │ │ -2000 template void UnitTest::checkBinaryOpsProxyVector() │ │ │ │ │ -2001 { │ │ │ │ │ -2002 auto checker = [this](auto doSV, auto doVV, auto doVS, auto op) { │ │ │ │ │ -2003 auto check = [this,op](auto t1, auto t2) { │ │ │ │ │ -2004 this->checkBinaryOpPV(t1, t2, op); │ │ │ │ │ -2005 }; │ │ │ │ │ -2006 this->checkBinaryRefQual(check); │ │ │ │ │ -2007 }; │ │ │ │ │ -2008 checkBinaryOps(checker); │ │ │ │ │ -2009 } │ │ │ │ │ -2010 template void UnitTest::checkBinaryOpsVectorProxy() │ │ │ │ │ -2011 { │ │ │ │ │ -2012 auto checker = [this](auto doSV, auto doVV, auto doVS, auto op) { │ │ │ │ │ -2013 auto check = [this,op](auto t1, auto t2) { │ │ │ │ │ -2014 this->checkBinaryOpVP(t1, t2, op); │ │ │ │ │ -2015 }; │ │ │ │ │ -2016 this->checkBinaryRefQual(check); │ │ │ │ │ -2017 }; │ │ │ │ │ -2018 checkBinaryOps(checker); │ │ │ │ │ -2019 } │ │ │ │ │ -2020 │ │ │ │ │ -2021 } // namespace Simd │ │ │ │ │ -2022} // namespace Dune │ │ │ │ │ -2023 │ │ │ │ │ -2024#endif // DUNE_COMMON_SIMD_TEST_HH │ │ │ │ │ -io.hh │ │ │ │ │ -IO interface of the SIMD abstraction. │ │ │ │ │ -loop.hh │ │ │ │ │ -DUNE_SIMD_POSTFIX_OP │ │ │ │ │ -#define DUNE_SIMD_POSTFIX_OP(NAME, SYMBOL) │ │ │ │ │ -Definition test.hh:670 │ │ │ │ │ -DUNE_SIMD_INFIX_OP │ │ │ │ │ -#define DUNE_SIMD_INFIX_OP(NAME, SYMBOL) │ │ │ │ │ -Definition test.hh:784 │ │ │ │ │ -DUNE_SIMD_CHECK_OP │ │ │ │ │ -#define DUNE_SIMD_CHECK_OP(expr) │ │ │ │ │ -Definition test.hh:191 │ │ │ │ │ -DUNE_SIMD_CHECK │ │ │ │ │ -#define DUNE_SIMD_CHECK(expr) │ │ │ │ │ -Definition test.hh:186 │ │ │ │ │ -DUNE_SIMD_REPL_OP │ │ │ │ │ -#define DUNE_SIMD_REPL_OP(NAME, REPLFN, SYMBOL) │ │ │ │ │ -Definition test.hh:818 │ │ │ │ │ -DUNE_SIMD_ASSIGN_OP │ │ │ │ │ -#define DUNE_SIMD_ASSIGN_OP(NAME, SYMBOL) │ │ │ │ │ -Definition test.hh:805 │ │ │ │ │ -DUNE_SIMD_PREFIX_OP │ │ │ │ │ -#define DUNE_SIMD_PREFIX_OP(NAME, SYMBOL) │ │ │ │ │ -Definition test.hh:681 │ │ │ │ │ -DUNE_SIMD_DO │ │ │ │ │ -#define DUNE_SIMD_DO(M1, M2, M3, V1, V2, V3, NAME) │ │ │ │ │ -typelist.hh │ │ │ │ │ -classname.hh │ │ │ │ │ -A free function to provide the demangled class name of a given object or type │ │ │ │ │ -as a string. │ │ │ │ │ -hybridutilities.hh │ │ │ │ │ -rangeutilities.hh │ │ │ │ │ -Utilities for reduction like operations on ranges. │ │ │ │ │ -type_traits.hh │ │ │ │ │ -typetraits.hh │ │ │ │ │ -Traits for type conversions and type information. │ │ │ │ │ -Dune::range │ │ │ │ │ -static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from │ │ │ │ │ ->, std::integral_constant< T, to >) noexcept │ │ │ │ │ -Definition rangeutilities.hh:312 │ │ │ │ │ -Dune::TypeList │ │ │ │ │ -std::tuple< MetaType< T >... > TypeList │ │ │ │ │ -A simple type list. │ │ │ │ │ -Definition typelist.hh:87 │ │ │ │ │ -Dune::Hybrid::forEach │ │ │ │ │ -constexpr void forEach(Range &&range, F &&f) │ │ │ │ │ -Range based for loop. │ │ │ │ │ -Definition hybridutilities.hh:256 │ │ │ │ │ -Dune::autoCopy │ │ │ │ │ -constexpr AutonomousValue< T > autoCopy(T &&v) │ │ │ │ │ -Autonomous copy of an expression's value for use in auto type deduction. │ │ │ │ │ -Definition typetraits.hh:672 │ │ │ │ │ -Dune::void_t │ │ │ │ │ -typename Impl::voider< Types... >::type void_t │ │ │ │ │ -Is void for all valid input types. The workhorse for C++11 SFINAE-techniques. │ │ │ │ │ -Definition typetraits.hh:40 │ │ │ │ │ -Dune::Simd::anyTrue │ │ │ │ │ -bool anyTrue(const Mask &mask) │ │ │ │ │ -Whether any entry is true │ │ │ │ │ -Definition simd/interface.hh:429 │ │ │ │ │ -Dune::Simd::maskOr │ │ │ │ │ -auto maskOr(const V1 &v1, const V2 &v2) │ │ │ │ │ -Logic or of masks. │ │ │ │ │ -Definition simd/interface.hh:499 │ │ │ │ │ -Dune::Simd::cond │ │ │ │ │ -V cond(M &&mask, const V &ifTrue, const V &ifFalse) │ │ │ │ │ -Like the ?: operator. │ │ │ │ │ -Definition simd/interface.hh:386 │ │ │ │ │ -Dune::Simd::io │ │ │ │ │ -auto io(const V &v) │ │ │ │ │ -construct a stream inserter │ │ │ │ │ -Definition io.hh:106 │ │ │ │ │ -Dune::Simd::allTrue │ │ │ │ │ -bool allTrue(const Mask &mask) │ │ │ │ │ -Whether all entries are true │ │ │ │ │ -Definition simd/interface.hh:439 │ │ │ │ │ -Dune::Simd::vio │ │ │ │ │ -auto vio(const V &v) │ │ │ │ │ -construct a stream inserter │ │ │ │ │ -Definition io.hh:90 │ │ │ │ │ -Dune::Simd::max │ │ │ │ │ -auto max(const V &v1, const V &v2) │ │ │ │ │ -The binary maximum value over two simd objects. │ │ │ │ │ -Definition simd/interface.hh:409 │ │ │ │ │ -Dune::Simd::anyFalse │ │ │ │ │ -bool anyFalse(const Mask &mask) │ │ │ │ │ -Whether any entry is false │ │ │ │ │ -Definition simd/interface.hh:449 │ │ │ │ │ -Dune::Simd::lanes │ │ │ │ │ -constexpr std::size_t lanes() │ │ │ │ │ -Number of lanes in a SIMD type. │ │ │ │ │ -Definition simd/interface.hh:305 │ │ │ │ │ -Dune::Simd::lane │ │ │ │ │ -decltype(auto) lane(std::size_t l, V &&v) │ │ │ │ │ -Extract an element of a SIMD type. │ │ │ │ │ -Definition simd/interface.hh:324 │ │ │ │ │ -Dune::Simd::allFalse │ │ │ │ │ -bool allFalse(const Mask &mask) │ │ │ │ │ -Whether all entries are false │ │ │ │ │ -Definition simd/interface.hh:459 │ │ │ │ │ -Dune::Simd::maskAnd │ │ │ │ │ -auto maskAnd(const V1 &v1, const V2 &v2) │ │ │ │ │ -Logic and of masks. │ │ │ │ │ -Definition simd/interface.hh:509 │ │ │ │ │ -Dune::Simd::Scalar │ │ │ │ │ -typename Overloads::ScalarType< std::decay_t< V > >::type Scalar │ │ │ │ │ -Element type of some SIMD type. │ │ │ │ │ -Definition simd/interface.hh:235 │ │ │ │ │ -Dune::Simd::min │ │ │ │ │ -auto min(const V &v1, const V &v2) │ │ │ │ │ -The binary minimum value over two simd objects. │ │ │ │ │ -Definition simd/interface.hh:419 │ │ │ │ │ -std │ │ │ │ │ -STL namespace. │ │ │ │ │ +101 const_reference back ([[maybe_unused]] int i) const │ │ │ │ │ +102 { │ │ │ │ │ +103 return _data.back().second; │ │ │ │ │ +104 } │ │ │ │ │ +105 │ │ │ │ │ +106 │ │ │ │ │ +110 void pop_front() │ │ │ │ │ +111 { │ │ │ │ │ +112 key_type k = _data.front().first; │ │ │ │ │ +113 _data.pop_front(); │ │ │ │ │ +114 _index.erase(k); │ │ │ │ │ +115 } │ │ │ │ │ +119 void pop_back() │ │ │ │ │ +120 { │ │ │ │ │ +121 key_type k = _data.back().first; │ │ │ │ │ +122 _data.pop_back(); │ │ │ │ │ +123 _index.erase(k); │ │ │ │ │ +124 } │ │ │ │ │ +125 │ │ │ │ │ +131 iterator find (const key_type & key) │ │ │ │ │ +132 { │ │ │ │ │ +133 const map_iterator it = _index.find(key); │ │ │ │ │ +134 if (it == _index.end()) return _data.end(); │ │ │ │ │ +135 return it->second; │ │ │ │ │ +136 } │ │ │ │ │ +137 │ │ │ │ │ +143 const_iterator find (const key_type & key) const │ │ │ │ │ +144 { │ │ │ │ │ +145 const map_iterator it = _index.find(key); │ │ │ │ │ +146 if (it == _index.end()) return _data.end(); │ │ │ │ │ +147 return it->second; │ │ │ │ │ +148 } │ │ │ │ │ +149 │ │ │ │ │ +161 reference insert (const key_type & key, const_reference data) │ │ │ │ │ +162 { │ │ │ │ │ +163 std::pair x(key, data); │ │ │ │ │ +164 /* insert item as mru */ │ │ │ │ │ +165 iterator it = _data.insert(_data.begin(), x); │ │ │ │ │ +166 /* store index */ │ │ │ │ │ +167 _index.insert(std::make_pair(key,it)); │ │ │ │ │ +168 │ │ │ │ │ +169 return it->second; │ │ │ │ │ +170 } │ │ │ │ │ +171 │ │ │ │ │ +175 reference insert (const key_type & key) │ │ │ │ │ +176 { │ │ │ │ │ +177 return touch (key); │ │ │ │ │ +178 } │ │ │ │ │ +179 │ │ │ │ │ +185 reference touch (const key_type & key) │ │ │ │ │ +186 { │ │ │ │ │ +187 /* query _index for iterator */ │ │ │ │ │ +188 map_iterator it = _index.find(key); │ │ │ │ │ +189 if (it == _index.end()) │ │ │ │ │ +190 DUNE_THROW(Dune::RangeError, │ │ │ │ │ +191 "Failed to touch key " << key << ", it is not in the lru container"); │ │ │ │ │ +192 /* update _data │ │ │ │ │ +193 move it to the front │ │ │ │ │ +194 */ │ │ │ │ │ +195 _data.splice(_data.begin(), _data, it->second); │ │ │ │ │ +196 return it->second->second; │ │ │ │ │ +197 } │ │ │ │ │ +198 │ │ │ │ │ +202 size_type size() const │ │ │ │ │ +203 { │ │ │ │ │ +204 return _data.size(); │ │ │ │ │ +205 } │ │ │ │ │ +206 │ │ │ │ │ +213 void resize(size_type new_size) │ │ │ │ │ +214 { │ │ │ │ │ +215 assert(new_size <= size()); │ │ │ │ │ +216 │ │ │ │ │ +217 while (new_size < size()) │ │ │ │ │ +218 pop_back(); │ │ │ │ │ +219 } │ │ │ │ │ +220 │ │ │ │ │ +224 void clear() │ │ │ │ │ +225 { │ │ │ │ │ +226 _data.clear(); │ │ │ │ │ +227 _index.clear(); │ │ │ │ │ +228 } │ │ │ │ │ +229 │ │ │ │ │ +230 private: │ │ │ │ │ +231 list_type _data; │ │ │ │ │ +232 map_type _index; │ │ │ │ │ +233 │ │ │ │ │ +234 }; │ │ │ │ │ +235 │ │ │ │ │ +236} // namespace Dune │ │ │ │ │ +237 │ │ │ │ │ +238#endif // DUNE_COMMON_LRU_HH │ │ │ │ │ +exceptions.hh │ │ │ │ │ +A few common exception classes. │ │ │ │ │ +DUNE_THROW │ │ │ │ │ +#define DUNE_THROW(E, m) │ │ │ │ │ +Definition exceptions.hh:218 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::size │ │ │ │ │ -constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std:: │ │ │ │ │ -integer_sequence< T, II... >) │ │ │ │ │ -Return the size of the sequence. │ │ │ │ │ -Definition integersequence.hh:75 │ │ │ │ │ -Dune::Simd::RebindList │ │ │ │ │ -typename Impl::RemoveEnd< EndMark, TypeList< Types... > >::type RebindList │ │ │ │ │ -A list of types with the final element removed. │ │ │ │ │ -Definition test.hh:158 │ │ │ │ │ -Dune::Simd::IsLoop │ │ │ │ │ -typename Impl::IsLoop< T >::type IsLoop │ │ │ │ │ -check whether a type is an instance of LoopSIMD │ │ │ │ │ -Definition test.hh:162 │ │ │ │ │ -Dune::LoopSIMD │ │ │ │ │ -Definition loop.hh:65 │ │ │ │ │ -Dune::Simd::EndMark │ │ │ │ │ -final element marker for RebindList │ │ │ │ │ -Definition test.hh:145 │ │ │ │ │ -Dune::Simd::UnitTest │ │ │ │ │ -Definition test.hh:164 │ │ │ │ │ -Dune::Simd::UnitTest::checkUnaryOps │ │ │ │ │ -void checkUnaryOps() │ │ │ │ │ -Definition test.hh:1909 │ │ │ │ │ -Dune::Simd::UnitTest::checkBinaryOps │ │ │ │ │ -void checkBinaryOps() │ │ │ │ │ -Definition test.hh:1952 │ │ │ │ │ -Dune::Simd::UnitTest::checkBinaryOpsScalarVector │ │ │ │ │ -void checkBinaryOpsScalarVector() │ │ │ │ │ -Definition test.hh:1970 │ │ │ │ │ -Dune::Simd::UnitTest::checkType │ │ │ │ │ -void checkType() │ │ │ │ │ -Definition test.hh:1866 │ │ │ │ │ -Dune::Simd::UnitTest::check │ │ │ │ │ -void check() │ │ │ │ │ -run unit tests for simd vector type V │ │ │ │ │ -Definition test.hh:1839 │ │ │ │ │ -Dune::Simd::UnitTest::checkBinaryOpsVectorScalar │ │ │ │ │ -void checkBinaryOpsVectorScalar() │ │ │ │ │ -Definition test.hh:1985 │ │ │ │ │ -Dune::Simd::UnitTest::good │ │ │ │ │ -bool good() const │ │ │ │ │ -whether all tests succeeded │ │ │ │ │ -Definition test.hh:1859 │ │ │ │ │ -Dune::Simd::UnitTest::checkBinaryOpsVectorVector │ │ │ │ │ -void checkBinaryOpsVectorVector() │ │ │ │ │ -Definition test.hh:1960 │ │ │ │ │ -Dune::Simd::UnitTest::checkNonOps │ │ │ │ │ -void checkNonOps() │ │ │ │ │ -Definition test.hh:1878 │ │ │ │ │ -Dune::Simd::UnitTest::checkBinaryOpsVectorProxy │ │ │ │ │ -void checkBinaryOpsVectorProxy() │ │ │ │ │ -Definition test.hh:2010 │ │ │ │ │ -Dune::Simd::UnitTest::checkBinaryOpsProxyVector │ │ │ │ │ -void checkBinaryOpsProxyVector() │ │ │ │ │ -Definition test.hh:2000 │ │ │ │ │ -Dune::AlwaysTrue │ │ │ │ │ -template which always yields a true value │ │ │ │ │ -Definition typetraits.hh:134 │ │ │ │ │ -simd.hh │ │ │ │ │ -Include file for users of the SIMD abstraction layer. │ │ │ │ │ +Dune::RangeError │ │ │ │ │ +Default exception class for range errors. │ │ │ │ │ +Definition exceptions.hh:254 │ │ │ │ │ +Dune::lru │ │ │ │ │ +LRU Cache Container. │ │ │ │ │ +Definition lru.hh:52 │ │ │ │ │ +Dune::lru::pop_back │ │ │ │ │ +void pop_back() │ │ │ │ │ +Removes the last element. │ │ │ │ │ +Definition lru.hh:119 │ │ │ │ │ +Dune::lru::find │ │ │ │ │ +iterator find(const key_type &key) │ │ │ │ │ +Finds the element whose key is k. │ │ │ │ │ +Definition lru.hh:131 │ │ │ │ │ +Dune::lru::insert │ │ │ │ │ +reference insert(const key_type &key) │ │ │ │ │ +mark data associated with key as most recent │ │ │ │ │ +Definition lru.hh:175 │ │ │ │ │ +Dune::lru::const_iterator │ │ │ │ │ +list_type::const_iterator const_iterator │ │ │ │ │ +Definition lru.hh:68 │ │ │ │ │ +Dune::lru::resize │ │ │ │ │ +void resize(size_type new_size) │ │ │ │ │ +ensure a maximum size of the container │ │ │ │ │ +Definition lru.hh:213 │ │ │ │ │ +Dune::lru::size_type │ │ │ │ │ +allocator::size_type size_type │ │ │ │ │ +Definition lru.hh:66 │ │ │ │ │ +Dune::lru::iterator │ │ │ │ │ +list_type::iterator iterator │ │ │ │ │ +Definition lru.hh:67 │ │ │ │ │ +Dune::lru::value_type │ │ │ │ │ +allocator::value_type value_type │ │ │ │ │ +Definition lru.hh:61 │ │ │ │ │ +Dune::lru::front │ │ │ │ │ +const_reference front() const │ │ │ │ │ +Definition lru.hh:83 │ │ │ │ │ +Dune::lru::const_pointer │ │ │ │ │ +typename allocator::value_type const * const_pointer │ │ │ │ │ +Definition lru.hh:63 │ │ │ │ │ +Dune::lru::size │ │ │ │ │ +size_type size() const │ │ │ │ │ +Retrieve number of entries in the container. │ │ │ │ │ +Definition lru.hh:202 │ │ │ │ │ +Dune::lru::reference │ │ │ │ │ +typename allocator::value_type & reference │ │ │ │ │ +Definition lru.hh:65 │ │ │ │ │ +Dune::lru::back │ │ │ │ │ +reference back() │ │ │ │ │ +Definition lru.hh:92 │ │ │ │ │ +Dune::lru::pop_front │ │ │ │ │ +void pop_front() │ │ │ │ │ +Removes the first element. │ │ │ │ │ +Definition lru.hh:110 │ │ │ │ │ +Dune::lru::front │ │ │ │ │ +reference front() │ │ │ │ │ +Definition lru.hh:74 │ │ │ │ │ +Dune::lru::clear │ │ │ │ │ +void clear() │ │ │ │ │ +Definition lru.hh:224 │ │ │ │ │ +Dune::lru::touch │ │ │ │ │ +reference touch(const key_type &key) │ │ │ │ │ +mark data associated with key as most recent │ │ │ │ │ +Definition lru.hh:185 │ │ │ │ │ +Dune::lru::insert │ │ │ │ │ +reference insert(const key_type &key, const_reference data) │ │ │ │ │ +Insert a value into the container. │ │ │ │ │ +Definition lru.hh:161 │ │ │ │ │ +Dune::lru::pointer │ │ │ │ │ +typename allocator::value_type * pointer │ │ │ │ │ +Definition lru.hh:62 │ │ │ │ │ +Dune::lru::find │ │ │ │ │ +const_iterator find(const key_type &key) const │ │ │ │ │ +Finds the element whose key is k. │ │ │ │ │ +Definition lru.hh:143 │ │ │ │ │ +Dune::lru::const_reference │ │ │ │ │ +typename allocator::value_type const & const_reference │ │ │ │ │ +Definition lru.hh:64 │ │ │ │ │ +Dune::lru::key_type │ │ │ │ │ +Traits::key_type key_type │ │ │ │ │ +Definition lru.hh:60 │ │ │ │ │ +Dune::lru::back │ │ │ │ │ +const_reference back(int i) const │ │ │ │ │ +Definition lru.hh:101 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00032.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: simd.hh File Reference │ │ │ │ +dune-common: debugalign.cc File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,96 +70,45 @@ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │ -Classes | │ │ │ │ Namespaces | │ │ │ │ -Typedefs | │ │ │ │ Functions
│ │ │ │ -
simd.hh File Reference
│ │ │ │ +
debugalign.cc File Reference
│ │ │ │
│ │ │ │
│ │ │ │ - │ │ │ │ -

Abstractions for support of dedicated SIMD data types. │ │ │ │ -More...

│ │ │ │ -
#include <cassert>
│ │ │ │ -#include <cstddef>
│ │ │ │ -#include <type_traits>
│ │ │ │ +
#include <cstddef>
│ │ │ │ +#include <cstdlib>
│ │ │ │ +#include <functional>
│ │ │ │ +#include <ios>
│ │ │ │ +#include <iostream>
│ │ │ │ #include <utility>
│ │ │ │ -#include <dune/common/conditional.hh>
│ │ │ │ -#include <dune/common/debugalign.hh>
│ │ │ │ -#include <dune/common/rangeutilities.hh>
│ │ │ │ -#include <dune/common/typetraits.hh>
│ │ │ │ -#include <dune/common/vc.hh>
│ │ │ │ -
│ │ │ │ -

Go to the source code of this file.

│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Classes

struct  Dune::SimdScalarTypeTraits< T >
 
struct  Dune::SimdScalarTypeTraits< AlignedNumber< T, align > >
 deduce the underlying scalar data type of an AlignedNumber More...
 
struct  Dune::SimdIndexTypeTraits< V, typename >
 
struct  Dune::SimdMaskTypeTraits< V, typename >
 
│ │ │ │ +#include <dune/common/debugalign.hh>
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Typedefs

template<typename T >
using Dune::SimdScalar = typename SimdScalarTypeTraits< T >::type
 
template<typename V >
using Dune::SimdIndex = typename SimdIndexTypeTraits< V >::type
 An simd vector of indices corresponding to a simd vector V.
 
template<typename V >
using Dune::SimdMask = typename SimdMaskTypeTraits< V >::type
 A simd vector of truth values corresponding to a simd vector V.
 
│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Functions

template<class T >
std::size_t Dune::lanes (const T &)
 get the number of lanes of a simd vector (scalar version)
 
template<class T >
Dune::lane (std::size_t l, const T &v)
 access a lane of a simd vector (scalar version)
 
template<class T >
T & Dune::lane (std::size_t l, T &v)
 access a lane of a simd vector (scalar version)
 
template<class T >
void Dune::assign (T &dst, const T &src, bool mask)
 masked Simd assignment (scalar version)
 
template<class T >
void Dune::swap (T &v1, T &v2, bool mask)
 
static void Dune::defaultViolatedAlignment (const char *className, std::size_t expectedAlignment, const void *address)
 default alignment violation handler
 
ViolatedAlignmentHandlerDune::violatedAlignmentHandler ()
 access the handler called by violatedAlignment()
 
void Dune::violatedAlignment (const char *className, std::size_t expectedAlignment, const void *address)
 called when an alignment violation is detected
 
│ │ │ │ -

Detailed Description

│ │ │ │ -

Abstractions for support of dedicated SIMD data types.

│ │ │ │ -

Libraries like Vc (https://github.com/VcDevel/Vc) add high-level data types for SIMD (or vectorization) support in C++. Most of these operations mimic the behavior of a numerical data type. Some boolean operations can not be implemented in a compatible way to trivial data types.

│ │ │ │ -

This header contains additional abstractions to help writing code that works with trivial numerical data types (like double) and Vc vectorization data types.

│ │ │ │ -

See also the conditional.hh and range_utils.hh headers.

│ │ │ │ -
Deprecated:
Use the newer simd architecture from dune/common/simd/simd.hh instead.
│ │ │ │ -
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,79 +1,34 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Typedefs | Functions │ │ │ │ │ -simd.hh File Reference │ │ │ │ │ -Abstractions for support of dedicated SIMD data types. More... │ │ │ │ │ -#include │ │ │ │ │ +Namespaces | Functions │ │ │ │ │ +debugalign.cc File Reference │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -Go_to_the_source_code_of_this_file. │ │ │ │ │ -Classes │ │ │ │ │ -struct   Dune::SimdScalarTypeTraits<_T_> │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::SimdScalarTypeTraits<_AlignedNumber<_T,_align_>_> │ │ │ │ │ -  deduce the underlying scalar data type of an AlignedNumber More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::SimdIndexTypeTraits<_V,_typename_> │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::SimdMaskTypeTraits<_V,_typename_> │ │ │ │ │ -  │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -Typedefs │ │ │ │ │ -template │ │ │ │ │ -using  Dune::SimdScalar = typename SimdScalarTypeTraits< T >::type │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -using  Dune::SimdIndex = typename SimdIndexTypeTraits< V >::type │ │ │ │ │ -  An simd vector of indices corresponding to a simd vector V. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -using  Dune::SimdMask = typename SimdMaskTypeTraits< V >::type │ │ │ │ │ -  A simd vector of truth values corresponding to a simd vector V. │ │ │ │ │ -  │ │ │ │ │ Functions │ │ │ │ │ -template │ │ │ │ │ -std::size_t  Dune::lanes (const T &) │ │ │ │ │ -  get the number of lanes of a simd vector (scalar version) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - T  Dune::lane (std::size_t l, const T &v) │ │ │ │ │ -  access a lane of a simd vector (scalar version) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - T &  Dune::lane (std::size_t l, T &v) │ │ │ │ │ -  access a lane of a simd vector (scalar version) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - void  Dune::assign (T &dst, const T &src, bool mask) │ │ │ │ │ -  masked Simd assignment (scalar version) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - void  Dune::swap (T &v1, T &v2, bool mask) │ │ │ │ │ + static void  Dune::defaultViolatedAlignment (const char │ │ │ │ │ + *className, std::size_t expectedAlignment, const │ │ │ │ │ + void *address) │ │ │ │ │ +  default alignment violation handler │ │ │ │ │ +  │ │ │ │ │ +ViolatedAlignmentHandler &  Dune::violatedAlignmentHandler () │ │ │ │ │ +  access the handler called by violatedAlignment() │ │ │ │ │ +  │ │ │ │ │ + void  Dune::violatedAlignment (const char *className, │ │ │ │ │ + std::size_t expectedAlignment, const void *address) │ │ │ │ │ +  called when an alignment violation is detected │ │ │ │ │   │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -Abstractions for support of dedicated SIMD data types. │ │ │ │ │ -Libraries like Vc (https://github.com/VcDevel/Vc) add high-level data types for │ │ │ │ │ -SIMD (or vectorization) support in C++. Most of these operations mimic the │ │ │ │ │ -behavior of a numerical data type. Some boolean operations can not be │ │ │ │ │ -implemented in a compatible way to trivial data types. │ │ │ │ │ -This header contains additional abstractions to help writing code that works │ │ │ │ │ -with trivial numerical data types (like double) and Vc vectorization data │ │ │ │ │ -types. │ │ │ │ │ -See also the conditional.hh and range_utils.hh headers. │ │ │ │ │ - Deprecated: │ │ │ │ │ - Use the newer simd architecture from dune/common/simd/simd.hh instead. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00038.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: overloadset.hh File Reference │ │ │ │ +dune-common: extents.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,46 +65,56 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ +Classes | │ │ │ │ Namespaces | │ │ │ │ -Functions
│ │ │ │ -
overloadset.hh File Reference
│ │ │ │ +Typedefs
│ │ │ │ +
extents.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ -
#include <utility>
│ │ │ │ +
#include <array>
│ │ │ │ +#include <cassert>
│ │ │ │ +#include <limits>
│ │ │ │ #include <type_traits>
│ │ │ │ -#include <dune/common/typetraits.hh>
│ │ │ │ +#include <dune/common/indices.hh>
│ │ │ │ +#include <dune/common/std/span.hh>
│ │ │ │ +#include <dune/common/std/impl/fwd_layouts.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Classes

class  Dune::Std::extents< IndexType, exts >
 Multidimensional index space with dynamic and static extents. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::Std
 Namespace for features backported from new C++ standards.
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ -Functions

template<class... F>
auto Dune::overload (F &&... f)
 Create an overload set.
 
template<class... F>
auto Dune::orderedOverload (F &&... f)
 Create an ordered overload set.
 

│ │ │ │ +Typedefs

template<class IndexType , std::size_t R>
using Dune::Std::dextents = typename Impl::DExtentsImpl< IndexType, std::make_integer_sequence< std::size_t, R > >::type
 Alias of extents of given rank R and purely dynamic extents. See [mdspan.extents.dextents].
 
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,27 +1,37 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Namespaces | Functions │ │ │ │ │ -overloadset.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ + * std │ │ │ │ │ +Classes | Namespaces | Typedefs │ │ │ │ │ +extents.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ +Classes │ │ │ │ │ +class   Dune::Std::extents<_IndexType,_exts_> │ │ │ │ │ +  Multidimensional index space with dynamic and static extents. More... │ │ │ │ │ +  │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -Functions │ │ │ │ │ -template │ │ │ │ │ -auto  Dune::overload (F &&... f) │ │ │ │ │ -  Create an overload set. │ │ │ │ │ +namespace   Dune::Std │ │ │ │ │ +  Namespace for features backported from new C++ standards. │ │ │ │ │   │ │ │ │ │ -template │ │ │ │ │ -auto  Dune::orderedOverload (F &&... f) │ │ │ │ │ -  Create an ordered overload set. │ │ │ │ │ +Typedefs │ │ │ │ │ +template │ │ │ │ │ +using  Dune::Std::dextents = typename Impl::DExtentsImpl< IndexType, std::make_ │ │ │ │ │ + integer_sequence< std::size_t, R > >::type │ │ │ │ │ +  Alias of extents of given rank R and purely dynamic extents. See │ │ │ │ │ + [mdspan.extents.dextents]. │ │ │ │ │   │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00038_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: overloadset.hh Source File │ │ │ │ +dune-common: extents.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,143 +70,289 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
overloadset.hh
│ │ │ │ +
extents.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_COMMON_OVERLOADSET_HH
│ │ │ │ -
6#define DUNE_COMMON_OVERLOADSET_HH
│ │ │ │ +
5#ifndef DUNE_COMMON_STD_EXTENTS_HH
│ │ │ │ +
6#define DUNE_COMMON_STD_EXTENTS_HH
│ │ │ │
7
│ │ │ │ -
8#include <utility>
│ │ │ │ -
9#include <type_traits>
│ │ │ │ - │ │ │ │ -
11
│ │ │ │ -
12namespace Dune {
│ │ │ │ -
13
│ │ │ │ -
14namespace Impl {
│ │ │ │ +
8#include <array>
│ │ │ │ +
9#include <cassert>
│ │ │ │ +
10#include <limits>
│ │ │ │ +
11#include <type_traits>
│ │ │ │ +
12#if __has_include(<version>)
│ │ │ │ +
13 #include <version>
│ │ │ │ +
14#endif
│ │ │ │
15
│ │ │ │ -
16 template<typename... F>
│ │ │ │ -
17 class OverloadSet
│ │ │ │ -
18 : public F...
│ │ │ │ -
19 {
│ │ │ │ -
20
│ │ │ │ -
21 public:
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
19
│ │ │ │ +
20namespace Dune::Std {
│ │ │ │ +
21namespace Impl {
│ │ │ │
22
│ │ │ │ -
23 template<typename... FF>
│ │ │ │ -
24 OverloadSet(FF&&... ff)
│ │ │ │ -
25 : F(std::forward<FF>(ff))...
│ │ │ │ -
26 {}
│ │ │ │ -
27
│ │ │ │ -
28 using F::operator()...;
│ │ │ │ -
29
│ │ │ │ -
30 };
│ │ │ │ -
31
│ │ │ │ -
32} // end namespace Impl
│ │ │ │ -
33
│ │ │ │ -
34
│ │ │ │ -
35
│ │ │ │ -
60template<class... F>
│ │ │ │ -
│ │ │ │ -
61auto overload(F&&... f)
│ │ │ │ -
62{
│ │ │ │ -
63 return Impl::OverloadSet<std::decay_t<F>...>(std::forward<F>(f)...);
│ │ │ │ -
64}
│ │ │ │ -
│ │ │ │ -
65
│ │ │ │ -
66
│ │ │ │ -
67
│ │ │ │ -
68namespace Impl {
│ │ │ │ -
69
│ │ │ │ -
70 template<class F0, class... F>
│ │ │ │ -
71 class OrderedOverloadSet: public OrderedOverloadSet<F...>, F0
│ │ │ │ -
72 {
│ │ │ │ -
73 using Base = OrderedOverloadSet<F...>;
│ │ │ │ -
74 public:
│ │ │ │ -
75
│ │ │ │ -
76 template<class FF0, class... FF>
│ │ │ │ -
77 OrderedOverloadSet(FF0&& f0, FF&&... ff) :
│ │ │ │ -
78 Base(std::forward<FF>(ff)...),
│ │ │ │ -
79 F0(std::forward<FF0>(f0))
│ │ │ │ -
80 {}
│ │ │ │ +
23template <class IndexType, std::size_t n>
│ │ │ │ +
24struct DynamicExtentsArray
│ │ │ │ +
25{
│ │ │ │ +
26 using type = std::array<IndexType,n>;
│ │ │ │ +
27};
│ │ │ │ +
28
│ │ │ │ +
29template <class IndexType>
│ │ │ │ +
30struct DynamicExtentsArray<IndexType,0>
│ │ │ │ +
31{
│ │ │ │ +
32 // empty type with minimal array-like interface
│ │ │ │ +
33 struct type {
│ │ │ │ +
34 IndexType operator[](std::size_t /*i*/) const { return 0; }
│ │ │ │ +
35 };
│ │ │ │ +
36};
│ │ │ │ +
37
│ │ │ │ +
38} // end namespace Impl
│ │ │ │ +
39
│ │ │ │ +
40
│ │ │ │ +
52template <class IndexType, std::size_t... exts>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
54{
│ │ │ │ +
55 static_assert(std::is_integral_v<IndexType>);
│ │ │ │ +
56
│ │ │ │ +
57private:
│ │ │ │ +
58 static constexpr std::size_t rank_ = sizeof...(exts);
│ │ │ │ +
59 static constexpr std::size_t rank_dynamic_ = ((exts == Std::dynamic_extent) + ... + 0);
│ │ │ │ +
60
│ │ │ │ +
61 // this type is used internally to extract the static extents by index
│ │ │ │ +
62 using array_type = std::array<std::size_t,rank_>;
│ │ │ │ +
63
│ │ │ │ +
64 // store at position i how many extents in {exts[0],...,exts[i]} are dynamic_extent
│ │ │ │ +
65 static constexpr std::array<std::size_t,rank_+1> make_dynamic_index()
│ │ │ │ +
66 {
│ │ │ │ +
67 std::array<std::size_t,rank_+1> di{{}};
│ │ │ │ +
68 for (std::size_t i = 0; i < rank_; ++i)
│ │ │ │ +
69 di[i+1] = di[i] + (array_type{exts...}[i] == Std::dynamic_extent);
│ │ │ │ +
70 return di;
│ │ │ │ +
71 }
│ │ │ │ +
72
│ │ │ │ +
73 // An index mapping computed by `make_dynamic_index()` to get the position of a dynamic
│ │ │ │ +
74 // extent in {exts...} within the array dynamic_extents.
│ │ │ │ +
75 static constexpr std::array<std::size_t,rank_+1> dynamic_index_{make_dynamic_index()};
│ │ │ │ +
76
│ │ │ │ +
77public:
│ │ │ │ +
78 using rank_type = std::size_t;
│ │ │ │ +
79 using index_type = IndexType;
│ │ │ │ +
80 using size_type = std::make_unsigned_t<index_type>;
│ │ │ │
81
│ │ │ │ -
82 // Forward to operator() of F0 if it can be called with the given arguments.
│ │ │ │ -
83 template<class... Args,
│ │ │ │ -
84 std::enable_if_t<IsCallable<F0(Args&&...)>::value, int> = 0>
│ │ │ │ -
85 decltype(auto) operator()(Args&&... args)
│ │ │ │ -
86 {
│ │ │ │ -
87 return F0::operator()(std::forward<Args>(args)...);
│ │ │ │ -
88 }
│ │ │ │ -
89
│ │ │ │ -
90 // Forward to operator() of base class if F0 cannot be called with the given
│ │ │ │ -
91 // arguments. In this case the base class will successively try operator()
│ │ │ │ -
92 // of all F... .
│ │ │ │ -
93 template<class... Args,
│ │ │ │ -
94 std::enable_if_t<not IsCallable<F0(Args&&...)>::value, int> = 0>
│ │ │ │ -
95 decltype(auto) operator()(Args&&... args)
│ │ │ │ -
96 {
│ │ │ │ -
97 return Base::operator()(std::forward<Args>(args)...);
│ │ │ │ -
98 }
│ │ │ │ -
99
│ │ │ │ -
100 };
│ │ │ │ -
101
│ │ │ │ -
102 template<class F0>
│ │ │ │ -
103 class OrderedOverloadSet<F0>: public F0
│ │ │ │ -
104 {
│ │ │ │ -
105 public:
│ │ │ │ -
106
│ │ │ │ -
107 template<class FF0>
│ │ │ │ -
108 OrderedOverloadSet(FF0&& f0) :
│ │ │ │ -
109 F0(std::forward<FF0>(f0))
│ │ │ │ -
110 {}
│ │ │ │ -
111
│ │ │ │ -
112 // Forward to operator() of F0. If it cannot be called with
│ │ │ │ -
113 // the given arguments a static assertion will fail.
│ │ │ │ -
114 template<class... Args>
│ │ │ │ -
115 decltype(auto) operator()(Args&&... args)
│ │ │ │ -
116 {
│ │ │ │ -
117 static_assert(IsCallable<F0(Args&&...)>::value,
│ │ │ │ -
118 "No matching overload found in OrderedOverloadSet");
│ │ │ │ -
119 return F0::operator()(std::forward<Args>(args)...);
│ │ │ │ -
120 }
│ │ │ │ -
121 };
│ │ │ │ -
122
│ │ │ │ -
123} // end namespace Impl
│ │ │ │ -
124
│ │ │ │ -
125
│ │ │ │ -
126
│ │ │ │ -
149template<class... F>
│ │ │ │ -
│ │ │ │ -
150auto orderedOverload(F&&... f)
│ │ │ │ -
151{
│ │ │ │ -
152 return Impl::OrderedOverloadSet<std::decay_t<F>...>(std::forward<F>(f)...);
│ │ │ │ -
153}
│ │ │ │ +
85
│ │ │ │ +
87 static constexpr rank_type rank () noexcept { return rank_; }
│ │ │ │ +
88
│ │ │ │ +
90 static constexpr rank_type rank_dynamic () noexcept { return rank_dynamic_; }
│ │ │ │ +
91
│ │ │ │ +
│ │ │ │ +
93 static constexpr std::size_t static_extent (rank_type r) noexcept
│ │ │ │ +
94 {
│ │ │ │ +
95 assert(rank() > 0 && r < rank());
│ │ │ │ +
96 return array_type{exts...}[r];
│ │ │ │ +
97 }
│ │ │ │ +
│ │ │ │ +
98
│ │ │ │ +
│ │ │ │ +
100 constexpr index_type extent (rank_type r) const noexcept
│ │ │ │ +
101 {
│ │ │ │ +
102 assert(rank() > 0 && r < rank());
│ │ │ │ +
103 if (std::size_t e = static_extent(r); e != Std::dynamic_extent)
│ │ │ │ +
104 return index_type(e);
│ │ │ │ +
105 else
│ │ │ │ +
106 return dynamic_extents_[dynamic_index_[r]];
│ │ │ │ +
107 }
│ │ │ │ +
│ │ │ │ +
108
│ │ │ │ +
110
│ │ │ │ +
111public:
│ │ │ │ +
114
│ │ │ │ +
116 constexpr extents () noexcept = default;
│ │ │ │ +
117
│ │ │ │ +
120 template <class... IndexTypes,
│ │ │ │ +
121 std::enable_if_t<(... && std::is_convertible_v<IndexTypes,index_type>), int> = 0,
│ │ │ │ +
122 std::enable_if_t<(sizeof...(IndexTypes) == rank() || sizeof...(IndexTypes) == rank_dynamic()), int> = 0,
│ │ │ │ +
123 std::enable_if_t<(... && std::is_nothrow_constructible_v<index_type, IndexTypes>), int> = 0>
│ │ │ │ +
│ │ │ │ +
124 constexpr explicit extents (IndexTypes... e) noexcept
│ │ │ │ +
125 {
│ │ │ │ +
126 init_dynamic_extents<sizeof...(e)>(std::array<index_type,sizeof...(e)>{index_type(e)...});
│ │ │ │ +
127 }
│ │ │ │ +
│ │ │ │ +
128
│ │ │ │ +
131 template <class I, std::size_t N,
│ │ │ │ +
132 std::enable_if_t<std::is_convertible_v<I, index_type>, int> = 0,
│ │ │ │ +
133 std::enable_if_t<(N == rank() || N == rank_dynamic()), int> = 0>
│ │ │ │ +
134 #if __cpp_conditional_explicit >= 201806L
│ │ │ │ +
135 explicit(N != rank_dynamic())
│ │ │ │ +
136 #endif
│ │ │ │ +
│ │ │ │ +
137 constexpr extents (const std::array<I,N>& e) noexcept
│ │ │ │ +
138 {
│ │ │ │ +
139 init_dynamic_extents<N>(e);
│ │ │ │ +
140 }
│ │ │ │ +
│ │ │ │ +
141
│ │ │ │ +
144 template <class I, std::size_t N,
│ │ │ │ +
145 std::enable_if_t<std::is_convertible_v<I, index_type>, int> = 0,
│ │ │ │ +
146 std::enable_if_t<(N == rank() || N == rank_dynamic()), int> = 0,
│ │ │ │ +
147 std::enable_if_t<std::is_nothrow_constructible_v<index_type, const I&>, int> = 0>
│ │ │ │ +
148 #if __cpp_conditional_explicit >= 201806L
│ │ │ │ +
149 explicit(N != rank_dynamic())
│ │ │ │ +
150 #endif
│ │ │ │ +
│ │ │ │ +
151 constexpr extents (Std::span<I,N> e) noexcept
│ │ │ │ +
152 {
│ │ │ │ +
153 init_dynamic_extents<N>(e);
│ │ │ │ +
154 }
│ │ │ │
│ │ │ │ -
154
│ │ │ │
155
│ │ │ │ -
156
│ │ │ │ -
157} // end namespace Dune
│ │ │ │ -
158
│ │ │ │ -
159#endif // DUNE_COMMON_OVERLOADSET_HH
│ │ │ │ -
Traits for type conversions and type information.
│ │ │ │ -
auto orderedOverload(F &&... f)
Create an ordered overload set.
Definition overloadset.hh:150
│ │ │ │ -
auto overload(F &&... f)
Create an overload set.
Definition overloadset.hh:61
│ │ │ │ +
156 template <class I, std::size_t... e,
│ │ │ │ +
157 std::enable_if_t<(sizeof...(e) == rank()), int> = 0,
│ │ │ │ +
158 std::enable_if_t<((e == Std::dynamic_extent || exts == Std::dynamic_extent || e == exts) &&...), int> = 0>
│ │ │ │ +
159 #if __cpp_conditional_explicit >= 201806L
│ │ │ │ +
160 explicit(
│ │ │ │ +
161 (( (exts != Std::dynamic_extent) && (e == Std::dynamic_extent)) || ... ) ||
│ │ │ │ +
162 (std::numeric_limits<index_type>::max() < std::numeric_limits<I>::max()))
│ │ │ │ +
163 #endif
│ │ │ │ +
│ │ │ │ +
164 constexpr extents (const extents<I,e...>& other) noexcept
│ │ │ │ +
165 {
│ │ │ │ +
166 init_dynamic_extents<sizeof...(e)>(as_array(other));
│ │ │ │ +
167 }
│ │ │ │ +
│ │ │ │ +
168
│ │ │ │ +
170
│ │ │ │ +
171
│ │ │ │ +
173 template <class OtherIndexType, std::size_t... otherExts>
│ │ │ │ +
│ │ │ │ +
174 friend constexpr bool operator== (const extents& a, const extents<OtherIndexType, otherExts...>& b) noexcept
│ │ │ │ +
175 {
│ │ │ │ +
176 if (a.rank() != b.rank())
│ │ │ │ +
177 return false;
│ │ │ │ +
178 using I = std::common_type_t<index_type, OtherIndexType>;
│ │ │ │ +
179 for (rank_type i = 0; i < rank(); ++i)
│ │ │ │ +
180 if (I(a.extent(i)) != I(b.extent(i)))
│ │ │ │ +
181 return false;
│ │ │ │ +
182 return true;
│ │ │ │ +
183 }
│ │ │ │ +
│ │ │ │ +
184
│ │ │ │ +
185private:
│ │ │ │ +
186#ifndef DOXYGEN
│ │ │ │ +
187 // The product of all extents
│ │ │ │ +
188 constexpr size_type product () const noexcept
│ │ │ │ +
189 {
│ │ │ │ +
190 size_type prod = 1;
│ │ │ │ +
191 for (rank_type i = 0; i < rank(); ++i)
│ │ │ │ +
192 prod *= extent(i);
│ │ │ │ +
193 return prod;
│ │ │ │ +
194 }
│ │ │ │ +
195
│ │ │ │ +
196 // A representation of all extents as an array
│ │ │ │ +
197 template <class OtherIndexType, std::size_t... otherExts>
│ │ │ │ +
198 static constexpr std::array<index_type,sizeof...(otherExts)>
│ │ │ │ +
199 as_array (const Std::extents<OtherIndexType,otherExts...>& e) noexcept
│ │ │ │ +
200 {
│ │ │ │ +
201 return unpackIntegerSequence([&](auto... ii) {
│ │ │ │ +
202 return std::array<index_type,sizeof...(otherExts)>{index_type(e.extent(ii))...}; },
│ │ │ │ +
203 std::make_index_sequence<sizeof...(otherExts)>{});
│ │ │ │ +
204 }
│ │ │ │ +
205
│ │ │ │ +
206 // Copy only the dynamic extents from the container `e` into the `dynamic_extents_` storage
│ │ │ │ +
207 template <std::size_t N, class Container>
│ │ │ │ +
208 constexpr void init_dynamic_extents (const Container& e) noexcept
│ │ │ │ +
209 {
│ │ │ │ +
210 if constexpr(rank_dynamic() > 0) {
│ │ │ │ +
211 if constexpr(N == rank_dynamic()) {
│ │ │ │ +
212 assert(e.size() == rank_dynamic());
│ │ │ │ +
213 for (rank_type i = 0; i < rank_dynamic(); ++i)
│ │ │ │ +
214 dynamic_extents_[i] = e[i];
│ │ │ │ +
215 } else {
│ │ │ │ +
216 assert(e.size() == rank());
│ │ │ │ +
217 for (rank_type i = 0, j = 0; i < rank(); ++i) {
│ │ │ │ + │ │ │ │ +
219 dynamic_extents_[j++] = e[i];
│ │ │ │ +
220 }
│ │ │ │ +
221 }
│ │ │ │ +
222 }
│ │ │ │ +
223 }
│ │ │ │ +
224#endif // DOXYGEN
│ │ │ │ +
225
│ │ │ │ +
226private:
│ │ │ │ +
227 using dynamic_extents_type = typename Impl::DynamicExtentsArray<index_type,rank_dynamic()>::type;
│ │ │ │ +
228 [[no_unique_address]] dynamic_extents_type dynamic_extents_;
│ │ │ │ +
229
│ │ │ │ +
230 template <class, std::size_t...> friend class extents;
│ │ │ │ +
231 friend struct layout_left;
│ │ │ │ +
232 friend struct layout_right;
│ │ │ │ +
233 friend struct layout_stride;
│ │ │ │ +
234};
│ │ │ │ +
│ │ │ │ +
235
│ │ │ │ +
236
│ │ │ │ +
237namespace Impl {
│ │ │ │ +
238
│ │ │ │ +
239template <class IndexType, class Seq>
│ │ │ │ +
240struct DExtentsImpl;
│ │ │ │ +
241
│ │ │ │ +
242template <class IndexType, std::size_t... I>
│ │ │ │ +
243struct DExtentsImpl<IndexType, std::integer_sequence<std::size_t,I...>>
│ │ │ │ +
244{
│ │ │ │ +
245 template <std::size_t>
│ │ │ │ +
246 using dynamic = std::integral_constant<std::size_t,Std::dynamic_extent>;
│ │ │ │ + │ │ │ │ +
248};
│ │ │ │ +
249
│ │ │ │ +
250} // end namespace Impl
│ │ │ │ +
251
│ │ │ │ +
252
│ │ │ │ +
258template <class IndexType, std::size_t R>
│ │ │ │ +
259using dextents = typename Impl::DExtentsImpl<IndexType, std::make_integer_sequence<std::size_t,R>>::type;
│ │ │ │ +
260
│ │ │ │ +
261} // end namespace Dune::Std
│ │ │ │ +
262
│ │ │ │ +
263#endif // DUNE_COMMON_STD_EXTENTS_HH
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
decltype(auto) constexpr unpackIntegerSequence(F &&f, std::integer_sequence< I, i... > sequence)
Unpack an std::integer_sequence<I,i...> to std::integral_constant<I,i>...
Definition indices.hh:124
│ │ │ │ +
typename Impl::DExtentsImpl< IndexType, std::make_integer_sequence< std::size_t, R > >::type dextents
Alias of extents of given rank R and purely dynamic extents. See [mdspan.extents.dextents].
Definition extents.hh:259
│ │ │ │
STL namespace.
│ │ │ │ -
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ +
Namespace for features backported from new C++ standards.
Definition default_accessor.hh:10
│ │ │ │ +
constexpr std::size_t dynamic_extent
A constant of type std::size_t that is used to differentiate std::span of static and dynamic extent.
Definition span.hh:26
│ │ │ │ +
Multidimensional index space with dynamic and static extents.
Definition extents.hh:54
│ │ │ │ +
static constexpr rank_type rank_dynamic() noexcept
The number of dimensions with dynamic extent.
Definition extents.hh:90
│ │ │ │ +
constexpr extents(const extents< I, e... > &other) noexcept
Definition extents.hh:164
│ │ │ │ +
std::size_t rank_type
Definition extents.hh:78
│ │ │ │ +
constexpr extents() noexcept=default
The default constructor requires that all exts are not Std::dynamic_extent.
│ │ │ │ +
static constexpr rank_type rank() noexcept
The total number of dimensions.
Definition extents.hh:87
│ │ │ │ +
friend struct layout_stride
Definition extents.hh:233
│ │ │ │ +
friend struct layout_left
Definition extents.hh:231
│ │ │ │ +
friend struct layout_right
Definition extents.hh:232
│ │ │ │ +
friend constexpr bool operator==(const extents &a, const extents< OtherIndexType, otherExts... > &b) noexcept
Compare two extents by their rank and all individual extents.
Definition extents.hh:174
│ │ │ │ +
std::make_unsigned_t< index_type > size_type
Definition extents.hh:80
│ │ │ │ +
static constexpr std::size_t static_extent(rank_type r) noexcept
Return the static extent of dimension r or Std::dynamic_extent
Definition extents.hh:93
│ │ │ │ +
friend class extents
Definition extents.hh:230
│ │ │ │ +
constexpr index_type extent(rank_type r) const noexcept
Return the extent of dimension i
Definition extents.hh:100
│ │ │ │ +
IndexType index_type
Definition extents.hh:79
│ │ │ │ +
A contiguous sequence of elements with static or dynamic extent.
Definition span.hh:126
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,139 +1,334 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -overloadset.hh │ │ │ │ │ + * std │ │ │ │ │ +extents.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_COMMON_OVERLOADSET_HH │ │ │ │ │ -6#define DUNE_COMMON_OVERLOADSET_HH │ │ │ │ │ +5#ifndef DUNE_COMMON_STD_EXTENTS_HH │ │ │ │ │ +6#define DUNE_COMMON_STD_EXTENTS_HH │ │ │ │ │ 7 │ │ │ │ │ -8#include │ │ │ │ │ -9#include │ │ │ │ │ -10#include │ │ │ │ │ -11 │ │ │ │ │ -12namespace Dune { │ │ │ │ │ -13 │ │ │ │ │ -14namespace Impl { │ │ │ │ │ +8#include │ │ │ │ │ +9#include │ │ │ │ │ +10#include │ │ │ │ │ +11#include │ │ │ │ │ +12#if __has_include() │ │ │ │ │ +13 #include │ │ │ │ │ +14#endif │ │ │ │ │ 15 │ │ │ │ │ -16 template │ │ │ │ │ -17 class OverloadSet │ │ │ │ │ -18 : public F... │ │ │ │ │ -19 { │ │ │ │ │ -20 │ │ │ │ │ -21 public: │ │ │ │ │ +16#include │ │ │ │ │ +17#include │ │ │ │ │ +18#include │ │ │ │ │ +19 │ │ │ │ │ +20namespace Dune::Std { │ │ │ │ │ +21namespace Impl { │ │ │ │ │ 22 │ │ │ │ │ -23 template │ │ │ │ │ -24 OverloadSet(FF&&... ff) │ │ │ │ │ -25 : F(std::forward(ff))... │ │ │ │ │ -26 {} │ │ │ │ │ -27 │ │ │ │ │ -28 using F::operator()...; │ │ │ │ │ -29 │ │ │ │ │ -30 }; │ │ │ │ │ -31 │ │ │ │ │ -32} // end namespace Impl │ │ │ │ │ -33 │ │ │ │ │ -34 │ │ │ │ │ -35 │ │ │ │ │ -60template │ │ │ │ │ -61auto overload(F&&... f) │ │ │ │ │ -62{ │ │ │ │ │ -63 return Impl::OverloadSet...>(std::forward(f)...); │ │ │ │ │ -64} │ │ │ │ │ -65 │ │ │ │ │ -66 │ │ │ │ │ -67 │ │ │ │ │ -68namespace Impl { │ │ │ │ │ -69 │ │ │ │ │ -70 template │ │ │ │ │ -71 class OrderedOverloadSet: public OrderedOverloadSet, F0 │ │ │ │ │ -72 { │ │ │ │ │ -73 using Base = OrderedOverloadSet; │ │ │ │ │ -74 public: │ │ │ │ │ -75 │ │ │ │ │ -76 template │ │ │ │ │ -77 OrderedOverloadSet(FF0&& f0, FF&&... ff) : │ │ │ │ │ -78 Base(std::forward(ff)...), │ │ │ │ │ -79 F0(std::forward(f0)) │ │ │ │ │ -80 {} │ │ │ │ │ +23template │ │ │ │ │ +24struct DynamicExtentsArray │ │ │ │ │ +25{ │ │ │ │ │ +26 using type = std::array; │ │ │ │ │ +27}; │ │ │ │ │ +28 │ │ │ │ │ +29template │ │ │ │ │ +30struct DynamicExtentsArray │ │ │ │ │ +31{ │ │ │ │ │ +32 // empty type with minimal array-like interface │ │ │ │ │ +33 struct type { │ │ │ │ │ +34 IndexType operator[](std::size_t /*i*/) const { return 0; } │ │ │ │ │ +35 }; │ │ │ │ │ +36}; │ │ │ │ │ +37 │ │ │ │ │ +38} // end namespace Impl │ │ │ │ │ +39 │ │ │ │ │ +40 │ │ │ │ │ +52template │ │ │ │ │ +53class extents │ │ │ │ │ +54{ │ │ │ │ │ +55 static_assert(std::is_integral_v); │ │ │ │ │ +56 │ │ │ │ │ +57private: │ │ │ │ │ +58 static constexpr std::size_t rank_ = sizeof...(exts); │ │ │ │ │ +59 static constexpr std::size_t rank_dynamic_ = ((exts == Std::dynamic_extent) │ │ │ │ │ ++ ... + 0); │ │ │ │ │ +60 │ │ │ │ │ +61 // this type is used internally to extract the static extents by index │ │ │ │ │ +62 using array_type = std::array; │ │ │ │ │ +63 │ │ │ │ │ +64 // store at position i how many extents in {exts[0],...,exts[i]} are │ │ │ │ │ +dynamic_extent │ │ │ │ │ +65 static constexpr std::array make_dynamic_index() │ │ │ │ │ +66 { │ │ │ │ │ +67 std::array di{{}}; │ │ │ │ │ +68 for (std::size_t i = 0; i < rank_; ++i) │ │ │ │ │ +69 di[i+1] = di[i] + (array_type{exts...}[i] == Std::dynamic_extent); │ │ │ │ │ +70 return di; │ │ │ │ │ +71 } │ │ │ │ │ +72 │ │ │ │ │ +73 // An index mapping computed by `make_dynamic_index()` to get the position │ │ │ │ │ +of a dynamic │ │ │ │ │ +74 // extent in {exts...} within the array dynamic_extents. │ │ │ │ │ +75 static constexpr std::array dynamic_index_{make_ │ │ │ │ │ +dynamic_index()}; │ │ │ │ │ +76 │ │ │ │ │ +77public: │ │ │ │ │ +78 using rank_type = std::size_t; │ │ │ │ │ +79 using index_type = IndexType; │ │ │ │ │ +80 using size_type = std::make_unsigned_t; │ │ │ │ │ 81 │ │ │ │ │ -82 // Forward to operator() of F0 if it can be called with the given arguments. │ │ │ │ │ -83 template::value, int> = 0> │ │ │ │ │ -85 decltype(auto) operator()(Args&&... args) │ │ │ │ │ -86 { │ │ │ │ │ -87 return F0::operator()(std::forward(args)...); │ │ │ │ │ -88 } │ │ │ │ │ -89 │ │ │ │ │ -90 // Forward to operator() of base class if F0 cannot be called with the given │ │ │ │ │ -91 // arguments. In this case the base class will successively try operator() │ │ │ │ │ -92 // of all F... . │ │ │ │ │ -93 template::value, int> = 0> │ │ │ │ │ -95 decltype(auto) operator()(Args&&... args) │ │ │ │ │ -96 { │ │ │ │ │ -97 return Base::operator()(std::forward(args)...); │ │ │ │ │ -98 } │ │ │ │ │ -99 │ │ │ │ │ -100 }; │ │ │ │ │ -101 │ │ │ │ │ -102 template │ │ │ │ │ -103 class OrderedOverloadSet: public F0 │ │ │ │ │ -104 { │ │ │ │ │ -105 public: │ │ │ │ │ -106 │ │ │ │ │ -107 template │ │ │ │ │ -108 OrderedOverloadSet(FF0&& f0) : │ │ │ │ │ -109 F0(std::forward(f0)) │ │ │ │ │ -110 {} │ │ │ │ │ -111 │ │ │ │ │ -112 // Forward to operator() of F0. If it cannot be called with │ │ │ │ │ -113 // the given arguments a static assertion will fail. │ │ │ │ │ -114 template │ │ │ │ │ -115 decltype(auto) operator()(Args&&... args) │ │ │ │ │ -116 { │ │ │ │ │ -117 static_assert(IsCallable::value, │ │ │ │ │ -118 "No matching overload found in OrderedOverloadSet"); │ │ │ │ │ -119 return F0::operator()(std::forward(args)...); │ │ │ │ │ -120 } │ │ │ │ │ -121 }; │ │ │ │ │ -122 │ │ │ │ │ -123} // end namespace Impl │ │ │ │ │ -124 │ │ │ │ │ -125 │ │ │ │ │ -126 │ │ │ │ │ -149template │ │ │ │ │ -150auto orderedOverload(F&&... f) │ │ │ │ │ -151{ │ │ │ │ │ -152 return Impl::OrderedOverloadSet...>(std::forward(f)...); │ │ │ │ │ -153} │ │ │ │ │ -154 │ │ │ │ │ +85 │ │ │ │ │ +87 static constexpr rank_type rank () noexcept { return rank_; } │ │ │ │ │ +88 │ │ │ │ │ +90 static constexpr rank_type rank_dynamic () noexcept { return rank_dynamic_; │ │ │ │ │ +} │ │ │ │ │ +91 │ │ │ │ │ +93 static constexpr std::size_t static_extent (rank_type r) noexcept │ │ │ │ │ +94 { │ │ │ │ │ +95 assert(rank() > 0 && r < rank()); │ │ │ │ │ +96 return array_type{exts...}[r]; │ │ │ │ │ +97 } │ │ │ │ │ +98 │ │ │ │ │ +100 constexpr index_type extent (rank_type r) const noexcept │ │ │ │ │ +101 { │ │ │ │ │ +102 assert(rank() > 0 && r < rank()); │ │ │ │ │ +103 if (std::size_t e = static_extent(r); e != Std::dynamic_extent) │ │ │ │ │ +104 return index_type(e); │ │ │ │ │ +105 else │ │ │ │ │ +106 return dynamic_extents_[dynamic_index_[r]]; │ │ │ │ │ +107 } │ │ │ │ │ +108 │ │ │ │ │ +110 │ │ │ │ │ +111public: │ │ │ │ │ +114 │ │ │ │ │ +116 constexpr extents () noexcept = default; │ │ │ │ │ +117 │ │ │ │ │ +120 template ), │ │ │ │ │ +int> = 0, │ │ │ │ │ +122 std::enable_if_t<(sizeof...(IndexTypes) == rank() || sizeof...(IndexTypes) │ │ │ │ │ +== rank_dynamic()), int> = 0, │ │ │ │ │ +123 std::enable_if_t<(... && std::is_nothrow_constructible_v), int> = 0> │ │ │ │ │ +124 constexpr explicit extents (IndexTypes... e) noexcept │ │ │ │ │ +125 { │ │ │ │ │ +126 init_dynamic_extents(std::array │ │ │ │ │ +{index_type(e)...}); │ │ │ │ │ +127 } │ │ │ │ │ +128 │ │ │ │ │ +131 template , int> = 0, │ │ │ │ │ +133 std::enable_if_t<(N == rank() || N == rank_dynamic()), int> = 0> │ │ │ │ │ +134 #if __cpp_conditional_explicit >= 201806L │ │ │ │ │ +135 explicit(N != rank_dynamic()) │ │ │ │ │ +136 #endif │ │ │ │ │ +137 constexpr extents (const std::array& e) noexcept │ │ │ │ │ +138 { │ │ │ │ │ +139 init_dynamic_extents(e); │ │ │ │ │ +140 } │ │ │ │ │ +141 │ │ │ │ │ +144 template , int> = 0, │ │ │ │ │ +146 std::enable_if_t<(N == rank() || N == rank_dynamic()), int> = 0, │ │ │ │ │ +147 std::enable_if_t, │ │ │ │ │ +int> = 0> │ │ │ │ │ +148 #if __cpp_conditional_explicit >= 201806L │ │ │ │ │ +149 explicit(N != rank_dynamic()) │ │ │ │ │ +150 #endif │ │ │ │ │ +151 constexpr extents (Std::span e) noexcept │ │ │ │ │ +152 { │ │ │ │ │ +153 init_dynamic_extents(e); │ │ │ │ │ +154 } │ │ │ │ │ 155 │ │ │ │ │ -156 │ │ │ │ │ -157} // end namespace Dune │ │ │ │ │ -158 │ │ │ │ │ -159#endif // DUNE_COMMON_OVERLOADSET_HH │ │ │ │ │ -typetraits.hh │ │ │ │ │ -Traits for type conversions and type information. │ │ │ │ │ -Dune::orderedOverload │ │ │ │ │ -auto orderedOverload(F &&... f) │ │ │ │ │ -Create an ordered overload set. │ │ │ │ │ -Definition overloadset.hh:150 │ │ │ │ │ -Dune::overload │ │ │ │ │ -auto overload(F &&... f) │ │ │ │ │ -Create an overload set. │ │ │ │ │ -Definition overloadset.hh:61 │ │ │ │ │ +156 template = 0, │ │ │ │ │ +158 std::enable_if_t<((e == Std::dynamic_extent || exts == Std::dynamic_extent │ │ │ │ │ +|| e == exts) &&...), int> = 0> │ │ │ │ │ +159 #if __cpp_conditional_explicit >= 201806L │ │ │ │ │ +160 explicit( │ │ │ │ │ +161 (( (exts != Std::dynamic_extent) && (e == Std::dynamic_extent)) || ... ) || │ │ │ │ │ +162 (std::numeric_limits::max() < std::numeric_limits::max())) │ │ │ │ │ +163 #endif │ │ │ │ │ +164 constexpr extents (const extents& other) noexcept │ │ │ │ │ +165 { │ │ │ │ │ +166 init_dynamic_extents(as_array(other)); │ │ │ │ │ +167 } │ │ │ │ │ +168 │ │ │ │ │ +170 │ │ │ │ │ +171 │ │ │ │ │ +173 template │ │ │ │ │ +174 friend constexpr bool operator==_(const extents& a, const │ │ │ │ │ +extents& b) noexcept │ │ │ │ │ +175 { │ │ │ │ │ +176 if (a.rank() != b.rank()) │ │ │ │ │ +177 return false; │ │ │ │ │ +178 using I = std::common_type_t; │ │ │ │ │ +179 for (rank_type i = 0; i < rank(); ++i) │ │ │ │ │ +180 if (I(a.extent(i)) != I(b.extent(i))) │ │ │ │ │ +181 return false; │ │ │ │ │ +182 return true; │ │ │ │ │ +183 } │ │ │ │ │ +184 │ │ │ │ │ +185private: │ │ │ │ │ +186#ifndef DOXYGEN │ │ │ │ │ +187 // The product of all extents │ │ │ │ │ +188 constexpr size_type product () const noexcept │ │ │ │ │ +189 { │ │ │ │ │ +190 size_type prod = 1; │ │ │ │ │ +191 for (rank_type i = 0; i < rank(); ++i) │ │ │ │ │ +192 prod *= extent(i); │ │ │ │ │ +193 return prod; │ │ │ │ │ +194 } │ │ │ │ │ +195 │ │ │ │ │ +196 // A representation of all extents as an array │ │ │ │ │ +197 template │ │ │ │ │ +198 static constexpr std::array │ │ │ │ │ +199 as_array (const Std::extents& e) noexcept │ │ │ │ │ +200 { │ │ │ │ │ +201 return unpackIntegerSequence([&](auto... ii) { │ │ │ │ │ +202 return std::array{index_type(e.extent │ │ │ │ │ +(ii))...}; }, │ │ │ │ │ +203 std::make_index_sequence{}); │ │ │ │ │ +204 } │ │ │ │ │ +205 │ │ │ │ │ +206 // Copy only the dynamic extents from the container `e` into the `dynamic_ │ │ │ │ │ +extents_` storage │ │ │ │ │ +207 template │ │ │ │ │ +208 constexpr void init_dynamic_extents (const Container& e) noexcept │ │ │ │ │ +209 { │ │ │ │ │ +210 if constexpr(rank_dynamic() > 0) { │ │ │ │ │ +211 if constexpr(N == rank_dynamic()) { │ │ │ │ │ +212 assert(e.size() == rank_dynamic()); │ │ │ │ │ +213 for (rank_type i = 0; i < rank_dynamic(); ++i) │ │ │ │ │ +214 dynamic_extents_[i] = e[i]; │ │ │ │ │ +215 } else { │ │ │ │ │ +216 assert(e.size() == rank()); │ │ │ │ │ +217 for (rank_type i = 0, j = 0; i < rank(); ++i) { │ │ │ │ │ +218 if (static_extent(i) == Std::dynamic_extent) │ │ │ │ │ +219 dynamic_extents_[j++] = e[i]; │ │ │ │ │ +220 } │ │ │ │ │ +221 } │ │ │ │ │ +222 } │ │ │ │ │ +223 } │ │ │ │ │ +224#endif // DOXYGEN │ │ │ │ │ +225 │ │ │ │ │ +226private: │ │ │ │ │ +227 using dynamic_extents_type = typename Impl::DynamicExtentsArray::type; │ │ │ │ │ +228 [[no_unique_address]] dynamic_extents_type dynamic_extents_; │ │ │ │ │ +229 │ │ │ │ │ +230 template friend class extents; │ │ │ │ │ +231 friend struct layout_left; │ │ │ │ │ +232 friend struct layout_right; │ │ │ │ │ +233 friend struct layout_stride; │ │ │ │ │ +234}; │ │ │ │ │ +235 │ │ │ │ │ +236 │ │ │ │ │ +237namespace Impl { │ │ │ │ │ +238 │ │ │ │ │ +239template │ │ │ │ │ +240struct DExtentsImpl; │ │ │ │ │ +241 │ │ │ │ │ +242template │ │ │ │ │ +243struct DExtentsImpl> │ │ │ │ │ +244{ │ │ │ │ │ +245 template │ │ │ │ │ +246 using dynamic = std::integral_constant; │ │ │ │ │ +247 using type = Std::extents::value...>; │ │ │ │ │ +248}; │ │ │ │ │ +249 │ │ │ │ │ +250} // end namespace Impl │ │ │ │ │ +251 │ │ │ │ │ +252 │ │ │ │ │ +258template │ │ │ │ │ +259using dextents = typename Impl::DExtentsImpl>::type; │ │ │ │ │ +260 │ │ │ │ │ +261} // end namespace Dune::Std │ │ │ │ │ +262 │ │ │ │ │ +263#endif // DUNE_COMMON_STD_EXTENTS_HH │ │ │ │ │ +indices.hh │ │ │ │ │ +span.hh │ │ │ │ │ +fwd_layouts.hh │ │ │ │ │ +Dune::unpackIntegerSequence │ │ │ │ │ +decltype(auto) constexpr unpackIntegerSequence(F &&f, std::integer_sequence< I, │ │ │ │ │ +i... > sequence) │ │ │ │ │ +Unpack an std::integer_sequence to std::integral_constant... │ │ │ │ │ +Definition indices.hh:124 │ │ │ │ │ +Dune::Std::dextents │ │ │ │ │ +typename Impl::DExtentsImpl< IndexType, std::make_integer_sequence< std::size_ │ │ │ │ │ +t, R > >::type dextents │ │ │ │ │ +Alias of extents of given rank R and purely dynamic extents. See │ │ │ │ │ +[mdspan.extents.dextents]. │ │ │ │ │ +Definition extents.hh:259 │ │ │ │ │ std │ │ │ │ │ STL namespace. │ │ │ │ │ -Dune │ │ │ │ │ -Dune namespace. │ │ │ │ │ -Definition alignedallocator.hh:13 │ │ │ │ │ +Dune::Std │ │ │ │ │ +Namespace for features backported from new C++ standards. │ │ │ │ │ +Definition default_accessor.hh:10 │ │ │ │ │ +Dune::Std::dynamic_extent │ │ │ │ │ +constexpr std::size_t dynamic_extent │ │ │ │ │ +A constant of type std::size_t that is used to differentiate std::span of │ │ │ │ │ +static and dynamic extent. │ │ │ │ │ +Definition span.hh:26 │ │ │ │ │ +Dune::Std::extents │ │ │ │ │ +Multidimensional index space with dynamic and static extents. │ │ │ │ │ +Definition extents.hh:54 │ │ │ │ │ +Dune::Std::extents::rank_dynamic │ │ │ │ │ +static constexpr rank_type rank_dynamic() noexcept │ │ │ │ │ +The number of dimensions with dynamic extent. │ │ │ │ │ +Definition extents.hh:90 │ │ │ │ │ +Dune::Std::extents::extents │ │ │ │ │ +constexpr extents(const extents< I, e... > &other) noexcept │ │ │ │ │ +Definition extents.hh:164 │ │ │ │ │ +Dune::Std::extents::rank_type │ │ │ │ │ +std::size_t rank_type │ │ │ │ │ +Definition extents.hh:78 │ │ │ │ │ +Dune::Std::extents::extents │ │ │ │ │ +constexpr extents() noexcept=default │ │ │ │ │ +The default constructor requires that all exts are not Std::dynamic_extent. │ │ │ │ │ +Dune::Std::extents::rank │ │ │ │ │ +static constexpr rank_type rank() noexcept │ │ │ │ │ +The total number of dimensions. │ │ │ │ │ +Definition extents.hh:87 │ │ │ │ │ +Dune::Std::extents::layout_stride │ │ │ │ │ +friend struct layout_stride │ │ │ │ │ +Definition extents.hh:233 │ │ │ │ │ +Dune::Std::extents::layout_left │ │ │ │ │ +friend struct layout_left │ │ │ │ │ +Definition extents.hh:231 │ │ │ │ │ +Dune::Std::extents::layout_right │ │ │ │ │ +friend struct layout_right │ │ │ │ │ +Definition extents.hh:232 │ │ │ │ │ +Dune::Std::extents::operator== │ │ │ │ │ +friend constexpr bool operator==(const extents &a, const extents< │ │ │ │ │ +OtherIndexType, otherExts... > &b) noexcept │ │ │ │ │ +Compare two extents by their rank and all individual extents. │ │ │ │ │ +Definition extents.hh:174 │ │ │ │ │ +Dune::Std::extents::size_type │ │ │ │ │ +std::make_unsigned_t< index_type > size_type │ │ │ │ │ +Definition extents.hh:80 │ │ │ │ │ +Dune::Std::extents::static_extent │ │ │ │ │ +static constexpr std::size_t static_extent(rank_type r) noexcept │ │ │ │ │ +Return the static extent of dimension r or Std::dynamic_extent │ │ │ │ │ +Definition extents.hh:93 │ │ │ │ │ +Dune::Std::extents::extents │ │ │ │ │ +friend class extents │ │ │ │ │ +Definition extents.hh:230 │ │ │ │ │ +Dune::Std::extents::extent │ │ │ │ │ +constexpr index_type extent(rank_type r) const noexcept │ │ │ │ │ +Return the extent of dimension i │ │ │ │ │ +Definition extents.hh:100 │ │ │ │ │ +Dune::Std::extents::index_type │ │ │ │ │ +IndexType index_type │ │ │ │ │ +Definition extents.hh:79 │ │ │ │ │ +Dune::Std::span │ │ │ │ │ +A contiguous sequence of elements with static or dynamic extent. │ │ │ │ │ +Definition span.hh:126 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00041.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: parameterizedobject.hh File Reference │ │ │ │ +dune-common: type_traits.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,42 +65,77 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces
│ │ │ │ -
parameterizedobject.hh File Reference
│ │ │ │ +Namespaces | │ │ │ │ +Typedefs
│ │ │ │ +
type_traits.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ -
#include <functional>
│ │ │ │ -#include <map>
│ │ │ │ -#include <memory>
│ │ │ │ -#include <dune/common/exceptions.hh>
│ │ │ │ -#include <dune/common/typeutilities.hh>
│ │ │ │ +
#include <type_traits>
│ │ │ │ +#include <dune-common-config.hh>
│ │ │ │ +#include <dune/common/typetraits.hh>
│ │ │ │ +#include <dune/common/typeutilities.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::ParameterizedObjectFactory< TypeT(Args...), KeyT >
struct  Dune::Std::nonesuch
 Type representing a lookup failure by std::detected_or and friends. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::Std
 Namespace for features backported from new C++ standards.
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ +Typedefs

template<typename Default , template< typename... > class Op, typename... Args>
using Dune::Std::detected_or = Impl::detector< Default, void, Op, Args... >
 Detects whether Op<Args...> is valid and makes the result available.
 
template<template< typename... > class Op, typename... Args>
using Dune::Std::is_detected = typename detected_or< nonesuch, Op, Args... >::value_t
 Detects whether Op<Args...> is valid.
 
template<template< typename... > class Op, typename... Args>
using Dune::Std::detected_t = typename detected_or< nonesuch, Op, Args... >::type
 Returns Op<Args...> if that is valid; otherwise returns nonesuch.
 
template<typename Default , template< typename... > class Op, typename... Args>
using Dune::Std::detected_or_t = typename detected_or< Default, Op, Args... >::type
 Returns Op<Args...> if that is valid; otherwise returns the fallback type Default.
 
template<typename Expected , template< typename... > class Op, typename... Args>
using Dune::Std::is_detected_exact = std::is_same< Expected, detected_t< Op, Args... > >
 Checks whether Op<Args...> is Expected without causing an error if Op<Args...> is invalid.
 
template<typename Target , template< typename... > class Op, typename... Args>
using Dune::Std::is_detected_convertible = std::is_convertible< Target, detected_t< Op, Args... > >
 Checks whether Op<Args...> is convertible to Target without causing an error if Op<Args...> is invalid.
 
template<template< typename... > class Fallback, template< typename... > class TargetType, typename... Args>
using Dune::detected_or_fallback_t = Std::detected_or_t< decltype(detail::warningIfNotDefined< Std::detected_t< Fallback, Args... > >(std::declval< const Std::detected_t< TargetType, Args... > * >())), TargetType, Args... >
 This type will be either TargetType<Args...> if it exists, or the Fallback<Args...> type.
 
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,23 +1,71 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -parameterizedobject.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ + * std │ │ │ │ │ +Classes | Namespaces | Typedefs │ │ │ │ │ +type_traits.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class   Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_> │ │ │ │ │ +struct   Dune::Std::nonesuch │ │ │ │ │ +  Type representing a lookup failure by std::detected_or and friends. │ │ │ │ │ + More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ +namespace   Dune::Std │ │ │ │ │ +  Namespace for features backported from new C++ standards. │ │ │ │ │ +  │ │ │ │ │ +Typedefs │ │ │ │ │ +template class Op, typename... Args> │ │ │ │ │ +using  Dune::Std::detected_or = Impl::detector< Default, void, Op, Args... > │ │ │ │ │ +  Detects whether Op is valid and makes the result available. │ │ │ │ │ +  │ │ │ │ │ +template class Op, typename... Args> │ │ │ │ │ +using  Dune::Std::is_detected = typename detected_or< nonesuch, Op, Args... >:: │ │ │ │ │ + value_t │ │ │ │ │ +  Detects whether Op is valid. │ │ │ │ │ +  │ │ │ │ │ +template class Op, typename... Args> │ │ │ │ │ +using  Dune::Std::detected_t = typename detected_or< nonesuch, Op, Args... >:: │ │ │ │ │ + type │ │ │ │ │ +  Returns Op if that is valid; otherwise returns nonesuch. │ │ │ │ │ +  │ │ │ │ │ +template class Op, typename... Args> │ │ │ │ │ +using  Dune::Std::detected_or_t = typename detected_or< Default, Op, Args... │ │ │ │ │ + >::type │ │ │ │ │ +  Returns Op if that is valid; otherwise returns the fallback │ │ │ │ │ + type Default. │ │ │ │ │ +  │ │ │ │ │ +template class Op, typename... │ │ │ │ │ +Args> │ │ │ │ │ +using  Dune::Std::is_detected_exact = std::is_same< Expected, detected_t< Op, │ │ │ │ │ + Args... > > │ │ │ │ │ +  Checks whether Op is Expected without causing an error if │ │ │ │ │ + Op is invalid. │ │ │ │ │ +  │ │ │ │ │ +template class Op, typename... Args> │ │ │ │ │ +using  Dune::Std::is_detected_convertible = std::is_convertible< Target, │ │ │ │ │ + detected_t< Op, Args... > > │ │ │ │ │ +  Checks whether Op is convertible to Target without causing an │ │ │ │ │ + error if Op is invalid. │ │ │ │ │ +  │ │ │ │ │ +template class Fallback, template< typename... > class │ │ │ │ │ +TargetType, typename... Args> │ │ │ │ │ +using  Dune::detected_or_fallback_t = Std::detected_or_t< decltype(detail:: │ │ │ │ │ + warningIfNotDefined< Std::detected_t< Fallback, Args... > >(std:: │ │ │ │ │ + declval< const Std::detected_t< TargetType, Args... > * >())), │ │ │ │ │ + TargetType, Args... > │ │ │ │ │ +  This type will be either TargetType if it exists, or the │ │ │ │ │ + Fallback type. │ │ │ │ │ +  │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00041_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: parameterizedobject.hh Source File │ │ │ │ +dune-common: type_traits.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,182 +70,184 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
parameterizedobject.hh
│ │ │ │ +
type_traits.hh
│ │ │ │
│ │ │ │
│ │ │ │ -Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
│ │ │ │ -
2// vi: set et ts=4 sw=4 sts=4:
│ │ │ │ +Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │ +
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_COMMON_PARAMETERIZEDOBJECT_HH
│ │ │ │ -
6#define DUNE_COMMON_PARAMETERIZEDOBJECT_HH
│ │ │ │ +
5#ifndef DUNE_COMMON_STD_TYPE_TRAITS_HH
│ │ │ │ +
6#define DUNE_COMMON_STD_TYPE_TRAITS_HH
│ │ │ │
7
│ │ │ │ -
8#include <functional>
│ │ │ │ -
9#include <map>
│ │ │ │ -
10#include <memory>
│ │ │ │ -
11
│ │ │ │ - │ │ │ │ - │ │ │ │ -
14
│ │ │ │ -
15namespace Dune {
│ │ │ │ +
8#include <type_traits>
│ │ │ │ +
9#include <dune-common-config.hh> // DUNE_HAVE_CXX_EXPERIMENTAL_IS_DETECTED
│ │ │ │ + │ │ │ │ + │ │ │ │ +
12
│ │ │ │ +
13#if DUNE_HAVE_CXX_EXPERIMENTAL_IS_DETECTED
│ │ │ │ +
14#include <experimental/type_traits>
│ │ │ │ +
15#endif
│ │ │ │
16
│ │ │ │ -
34template<typename Signature,
│ │ │ │ -
35 typename KeyT = std::string>
│ │ │ │ - │ │ │ │ -
37
│ │ │ │ -
38template<typename TypeT,
│ │ │ │ -
39 typename KeyT,
│ │ │ │ -
40 typename... Args>
│ │ │ │ -
│ │ │ │ -
41class ParameterizedObjectFactory<TypeT(Args...), KeyT>
│ │ │ │ -
42{
│ │ │ │ -
43 public:
│ │ │ │ -
44
│ │ │ │ -
46 typedef KeyT Key;
│ │ │ │ -
47
│ │ │ │ -
49 using Type = TypeT;
│ │ │ │ -
50
│ │ │ │ -
51 protected:
│ │ │ │ -
52
│ │ │ │ -
53 using Creator = std::function<Type(Args...)>;
│ │ │ │ +
17namespace Dune
│ │ │ │ +
18{
│ │ │ │ +
19
│ │ │ │ +
21
│ │ │ │ +
30namespace Std
│ │ │ │ +
31{
│ │ │ │ +
32
│ │ │ │ +
35 using std::bool_constant;
│ │ │ │ +
36
│ │ │ │ +
37#if DUNE_HAVE_CXX_EXPERIMENTAL_IS_DETECTED
│ │ │ │ +
38
│ │ │ │ +
39 using std::experimental::nonesuch;
│ │ │ │ +
40 using std::experimental::detected_or;
│ │ │ │ +
41 using std::experimental::is_detected;
│ │ │ │ +
42 using std::experimental::detected_t;
│ │ │ │ +
43 using std::experimental::is_detected_v;
│ │ │ │ +
44 using std::experimental::detected_or_t;
│ │ │ │ +
45 using std::experimental::is_detected_exact;
│ │ │ │ +
46 using std::experimental::is_detected_exact_v;
│ │ │ │ +
47 using std::experimental::is_detected_convertible;
│ │ │ │ +
48 using std::experimental::is_detected_convertible_v;
│ │ │ │ +
49
│ │ │ │ +
50#else // DUNE_HAVE_CXX_EXPERIMENTAL_IS_DETECTED
│ │ │ │ +
51
│ │ │ │ +
52 // fallback version of std::experimental::is_detected et al., heavily scribbled
│ │ │ │ +
53 // from cppreference.com (but there is actually not much implementation to the thing)
│ │ │ │
54
│ │ │ │ -
55 template<class F>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
57 -> decltype( std::declval<F>()(std::declval<Args>()...), std::true_type())
│ │ │ │ -
58 {
│ │ │ │ -
59 return {};
│ │ │ │ -
60 }
│ │ │ │ -
│ │ │ │ -
61
│ │ │ │ -
62 template<class F>
│ │ │ │ -
│ │ │ │ -
63 static constexpr std::false_type has_proper_signature(Dune::PriorityTag<0>)
│ │ │ │ -
64 {
│ │ │ │ -
65 return {};
│ │ │ │ -
66 }
│ │ │ │ -
│ │ │ │ -
67
│ │ │ │ -
68 public:
│ │ │ │ -
69
│ │ │ │ -
│ │ │ │ -
77 Type create(Key const& key, Args ... args) const {
│ │ │ │ -
78 typename Registry::const_iterator i = registry_.find(key);
│ │ │ │ -
79 if (i == registry_.end()) {
│ │ │ │ - │ │ │ │ -
81 "ParametrizedObjectFactory: key ``" <<
│ │ │ │ -
82 key << "'' not registered");
│ │ │ │ -
83 }
│ │ │ │ -
84 else return i->second(args...);
│ │ │ │ -
85 }
│ │ │ │ -
│ │ │ │ -
86
│ │ │ │ -
100 template<class Impl>
│ │ │ │ -
│ │ │ │ -
101 void define(Key const& key)
│ │ │ │ -
102 {
│ │ │ │ -
103 registry_[key] = DefaultCreator<Impl>();
│ │ │ │ -
104 }
│ │ │ │ -
│ │ │ │ -
105
│ │ │ │ -
119 template<class F,
│ │ │ │ -
120 typename std::enable_if<has_proper_signature<F>(PriorityTag<42>()), int>::type = 0>
│ │ │ │ -
│ │ │ │ -
121 void define(Key const& key, F&& f)
│ │ │ │ -
122 {
│ │ │ │ -
123 registry_[key] = f;
│ │ │ │ -
124 }
│ │ │ │ -
│ │ │ │ -
125
│ │ │ │ -
140 template<class Impl,
│ │ │ │ -
141 typename std::enable_if<
│ │ │ │ -
142 std::is_convertible<Impl, Type>::value
│ │ │ │ -
143 and not std::is_convertible<Impl, Creator>::value,
│ │ │ │ -
144 int>::type = 0>
│ │ │ │ -
│ │ │ │ -
145 void define(Key const& key, Impl&& t)
│ │ │ │ -
146 {
│ │ │ │ -
147 registry_[key] = [=](Args...) { return t;};
│ │ │ │ -
148 }
│ │ │ │ -
│ │ │ │ +
55#ifndef DOXYGEN
│ │ │ │ +
56
│ │ │ │ +
57 namespace Impl {
│ │ │ │ +
58
│ │ │ │ +
59 // default version of detector, this gets matched on failure
│ │ │ │ +
60 template<typename Default, typename Void, template<typename...> class Op, typename... Args>
│ │ │ │ +
61 struct detector
│ │ │ │ +
62 {
│ │ │ │ +
63 using value_t = std::false_type;
│ │ │ │ +
64 using type = Default;
│ │ │ │ +
65 };
│ │ │ │ +
66
│ │ │ │ +
67 // specialization of detector that matches if Op<Args...> can be instantiated
│ │ │ │ +
68 template<typename Default, template<typename...> class Op, typename... Args>
│ │ │ │ +
69 struct detector<Default, std::void_t<Op<Args...>>, Op, Args...>
│ │ │ │ +
70 {
│ │ │ │ +
71 using value_t = std::true_type;
│ │ │ │ +
72 using type = Op<Args...>;
│ │ │ │ +
73 };
│ │ │ │ +
74
│ │ │ │ +
75 }
│ │ │ │ +
76
│ │ │ │ +
77#endif // DOXYGEN
│ │ │ │ +
78
│ │ │ │ +
80
│ │ │ │ +
│ │ │ │ +
88 struct nonesuch
│ │ │ │ +
89 {
│ │ │ │ +
90 nonesuch() = delete;
│ │ │ │ +
91 ~nonesuch() = delete;
│ │ │ │ +
92 nonesuch(const nonesuch&) = delete;
│ │ │ │ +
93 void operator=(const nonesuch&) = delete;
│ │ │ │ +
94 };
│ │ │ │ +
│ │ │ │ +
95
│ │ │ │ +
97
│ │ │ │ +
131 template<typename Default, template<typename...> class Op, typename... Args>
│ │ │ │ +
132 using detected_or = Impl::detector<Default,void,Op,Args...>;
│ │ │ │ +
133
│ │ │ │ +
135
│ │ │ │ +
144 template<template<typename...> class Op, typename... Args>
│ │ │ │ +
145 using is_detected = typename detected_or<nonesuch,Op,Args...>::value_t;
│ │ │ │ +
146
│ │ │ │ +
147#ifdef __cpp_variable_templates
│ │ │ │
149
│ │ │ │ -
│ │ │ │ -
150 bool contains(Key const& key) const
│ │ │ │ -
151 {
│ │ │ │ -
152 return registry_.count(key);
│ │ │ │ -
153 }
│ │ │ │ -
│ │ │ │ -
154
│ │ │ │ -
155 private:
│ │ │ │ -
156
│ │ │ │ -
157 template<class T>
│ │ │ │ -
158 struct Tag{};
│ │ │ │ -
159
│ │ │ │ -
160 template<class Impl>
│ │ │ │ -
161 struct DefaultCreator
│ │ │ │ -
162 {
│ │ │ │ -
163 template<class... T>
│ │ │ │ -
164 Type operator()(T&&... args) const
│ │ │ │ -
165 {
│ │ │ │ -
166 return DefaultCreator::create(Tag<Type>(), PriorityTag<42>(), std::forward<T>(args)...);
│ │ │ │ -
167 }
│ │ │ │ -
168
│ │ │ │ -
169 template<class Target, class... T>
│ │ │ │ -
170 static Type create(Tag<Target>, PriorityTag<1>, T&& ... args) {
│ │ │ │ -
171 return Impl(std::forward<T>(args)...);
│ │ │ │ -
172 }
│ │ │ │ -
173
│ │ │ │ -
174 template<class Target, class... T>
│ │ │ │ -
175 static Type create(Tag<std::unique_ptr<Target>>, PriorityTag<2>, T&& ... args) {
│ │ │ │ -
176 return std::make_unique<Impl>(std::forward<T>(args)...);
│ │ │ │ -
177 }
│ │ │ │ +
158 template<template<typename...> class Op, typename... Args>
│ │ │ │ +
159 constexpr bool is_detected_v = is_detected<Op,Args...>::value;
│ │ │ │ +
160#endif // __cpp_variable_templates
│ │ │ │ +
161
│ │ │ │ +
163
│ │ │ │ +
173 template<template<typename...> class Op, typename... Args>
│ │ │ │ +
174 using detected_t = typename detected_or<nonesuch,Op,Args...>::type;
│ │ │ │ +
175
│ │ │ │ +
176
│ │ │ │
178
│ │ │ │ -
179 template<class Target, class... T>
│ │ │ │ -
180 static Type create(Tag<std::shared_ptr<Target>>, PriorityTag<3>, T&& ... args) {
│ │ │ │ -
181 return std::make_shared<Impl>(std::forward<T>(args)...);
│ │ │ │ -
182 }
│ │ │ │ -
183
│ │ │ │ -
184 };
│ │ │ │ -
185
│ │ │ │ -
186 typedef std::map<Key, Creator> Registry;
│ │ │ │ -
187 Registry registry_;
│ │ │ │ -
188};
│ │ │ │ -
│ │ │ │ -
189
│ │ │ │ +
188 template<typename Default, template<typename...> class Op, typename... Args>
│ │ │ │ +
189 using detected_or_t = typename detected_or<Default,Op,Args...>::type;
│ │ │ │
190
│ │ │ │ -
191
│ │ │ │ -
192} // end namespace Dune
│ │ │ │ -
193
│ │ │ │ -
194#endif // DUNE_COMMON_PARAMETERIZEDOBJECT_HH
│ │ │ │ -
A few common exception classes.
│ │ │ │ -
Utilities for type computations, constraining overloads, ...
│ │ │ │ -
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
│ │ │ │ +
192
│ │ │ │ +
198 template<typename Expected, template<typename...> class Op, typename... Args>
│ │ │ │ +
199 using is_detected_exact = std::is_same<Expected,detected_t<Op,Args...>>;
│ │ │ │ +
200
│ │ │ │ +
201#ifdef __cpp_variable_templates
│ │ │ │ +
203
│ │ │ │ +
209 template<typename Expected, template<typename...> class Op, typename... Args>
│ │ │ │ +
210 constexpr bool is_detected_exact_v = is_detected_exact<Expected,Op,Args...>::value;
│ │ │ │ +
211#endif // __cpp_variable_templates
│ │ │ │ +
212
│ │ │ │ +
214
│ │ │ │ +
220 template<typename Target, template<typename...> class Op, typename... Args>
│ │ │ │ +
221 using is_detected_convertible = std::is_convertible<Target,detected_t<Op,Args...>>;
│ │ │ │ +
222
│ │ │ │ +
223#ifdef __cpp_variable_templates
│ │ │ │ +
225
│ │ │ │ +
231 template<typename Target, template<typename...> class Op, typename... Args>
│ │ │ │ +
232 constexpr bool is_detected_convertible_v = is_detected_convertible<Target,Op,Args...>::value;
│ │ │ │ +
233#endif // __cpp_variable_templates
│ │ │ │ +
234
│ │ │ │ +
235#endif // DUNE_HAVE_CXX_EXPERIMENTAL_IS_DETECTED
│ │ │ │ +
236
│ │ │ │ +
237} // namespace Std
│ │ │ │ +
238
│ │ │ │ +
239
│ │ │ │ +
240namespace detail
│ │ │ │ +
241{
│ │ │ │ +
242 template <class Type>
│ │ │ │ +
243 [[deprecated("Type extraction of `TargetType` has failed. Inspect the code calling `detected_or_fallback_t` for getting the source of this warning!")]]
│ │ │ │ +
244 Type warningIfNotDefined(const Std::nonesuch*);
│ │ │ │ +
245
│ │ │ │ +
246 template <class Type, class T>
│ │ │ │ +
247 Type warningIfNotDefined(const T*);
│ │ │ │ +
248}
│ │ │ │ +
249
│ │ │ │ +
251template <template<typename...> class Fallback,
│ │ │ │ +
252 template<typename...> class TargetType, typename... Args>
│ │ │ │ + │ │ │ │ +
254 detail::warningIfNotDefined<Std::detected_t<Fallback, Args...> >(std::declval<const Std::detected_t<TargetType, Args...>*>())),
│ │ │ │ +
255 TargetType, Args...>;
│ │ │ │ +
256
│ │ │ │ +
257
│ │ │ │ +
258} // namespace Dune
│ │ │ │ +
259
│ │ │ │ +
260#endif // #ifndef DUNE_COMMON_STD_TYPE_TRAITS_HH
│ │ │ │ +
Traits for type conversions and type information.
│ │ │ │ +
Utilities for type computations, constraining overloads, ...
│ │ │ │ +
typename detected_or< Default, Op, Args... >::type detected_or_t
Returns Op<Args...> if that is valid; otherwise returns the fallback type Default.
Definition type_traits.hh:189
│ │ │ │ +
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
Checks whether Op<Args...> is Expected without causing an error if Op<Args...> is invalid.
Definition type_traits.hh:199
│ │ │ │ +
typename detected_or< nonesuch, Op, Args... >::type detected_t
Returns Op<Args...> if that is valid; otherwise returns nonesuch.
Definition type_traits.hh:174
│ │ │ │ +
typename Impl::voider< Types... >::type void_t
Is void for all valid input types. The workhorse for C++11 SFINAE-techniques.
Definition typetraits.hh:40
│ │ │ │ +
typename detected_or< nonesuch, Op, Args... >::value_t is_detected
Detects whether Op<Args...> is valid.
Definition type_traits.hh:145
│ │ │ │ +
Impl::detector< Default, void, Op, Args... > detected_or
Detects whether Op<Args...> is valid and makes the result available.
Definition type_traits.hh:132
│ │ │ │ +
std::is_convertible< Target, detected_t< Op, Args... > > is_detected_convertible
Checks whether Op<Args...> is convertible to Target without causing an error if Op<Args....
Definition type_traits.hh:221
│ │ │ │ +
STL namespace.
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
Default exception if a function was called while the object is not in a valid state for that function...
Definition exceptions.hh:281
│ │ │ │ -
A factory class for parameterized objects.
Definition parameterizedobject.hh:36
│ │ │ │ -
std::function< Type(Args...)> Creator
Definition parameterizedobject.hh:53
│ │ │ │ -
static constexpr auto has_proper_signature(Dune::PriorityTag< 1 >) -> decltype(std::declval< F >()(std::declval< Args >()...), std::true_type())
Definition parameterizedobject.hh:56
│ │ │ │ -
TypeT Type
The type of objects created by the factory.
Definition parameterizedobject.hh:49
│ │ │ │ -
void define(Key const &key, Impl &&t)
Registers a new type with a key.
Definition parameterizedobject.hh:145
│ │ │ │ -
KeyT Key
The typ of the keys.
Definition parameterizedobject.hh:46
│ │ │ │ -
Type create(Key const &key, Args ... args) const
Creates an object identified by a key from given parameters.
Definition parameterizedobject.hh:77
│ │ │ │ -
void define(Key const &key)
Registers a new type with a key.
Definition parameterizedobject.hh:101
│ │ │ │ -
void define(Key const &key, F &&f)
Registers a new creator with a key.
Definition parameterizedobject.hh:121
│ │ │ │ -
static constexpr std::false_type has_proper_signature(Dune::PriorityTag< 0 >)
Definition parameterizedobject.hh:63
│ │ │ │ -
bool contains(Key const &key) const
Definition parameterizedobject.hh:150
│ │ │ │ -
Helper class for tagging priorities.
Definition typeutilities.hh:73
│ │ │ │ +
Std::detected_or_t< decltype(detail::warningIfNotDefined< Std::detected_t< Fallback, Args... > >(std::declval< const Std::detected_t< TargetType, Args... > * >())), TargetType, Args... > detected_or_fallback_t
This type will be either TargetType<Args...> if it exists, or the Fallback<Args......
Definition type_traits.hh:255
│ │ │ │ +
Type representing a lookup failure by std::detected_or and friends.
Definition type_traits.hh:89
│ │ │ │ + │ │ │ │ +
nonesuch(const nonesuch &)=delete
│ │ │ │ +
void operator=(const nonesuch &)=delete
│ │ │ │ + │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,200 +1,228 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -parameterizedobject.hh │ │ │ │ │ + * std │ │ │ │ │ +type_traits.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ -1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- │ │ │ │ │ -2// vi: set et ts=4 sw=4 sts=4: │ │ │ │ │ +1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ +2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_COMMON_PARAMETERIZEDOBJECT_HH │ │ │ │ │ -6#define DUNE_COMMON_PARAMETERIZEDOBJECT_HH │ │ │ │ │ +5#ifndef DUNE_COMMON_STD_TYPE_TRAITS_HH │ │ │ │ │ +6#define DUNE_COMMON_STD_TYPE_TRAITS_HH │ │ │ │ │ 7 │ │ │ │ │ -8#include │ │ │ │ │ -9#include │ │ │ │ │ -10#include │ │ │ │ │ -11 │ │ │ │ │ -12#include │ │ │ │ │ -13#include │ │ │ │ │ -14 │ │ │ │ │ -15namespace Dune { │ │ │ │ │ +8#include │ │ │ │ │ +9#include // DUNE_HAVE_CXX_EXPERIMENTAL_IS_DETECTED │ │ │ │ │ +10#include │ │ │ │ │ +11#include │ │ │ │ │ +12 │ │ │ │ │ +13#if DUNE_HAVE_CXX_EXPERIMENTAL_IS_DETECTED │ │ │ │ │ +14#include │ │ │ │ │ +15#endif │ │ │ │ │ 16 │ │ │ │ │ -34template │ │ │ │ │ -36class ParameterizedObjectFactory; │ │ │ │ │ -37 │ │ │ │ │ -38template │ │ │ │ │ -41class ParameterizedObjectFactory │ │ │ │ │ -42{ │ │ │ │ │ -43 public: │ │ │ │ │ -44 │ │ │ │ │ -46 typedef KeyT Key; │ │ │ │ │ -47 │ │ │ │ │ -49 using Type = TypeT; │ │ │ │ │ -50 │ │ │ │ │ -51 protected: │ │ │ │ │ -52 │ │ │ │ │ -53 using Creator = std::function; │ │ │ │ │ +17namespace Dune │ │ │ │ │ +18{ │ │ │ │ │ +19 │ │ │ │ │ +21 │ │ │ │ │ +30namespace Std │ │ │ │ │ +31{ │ │ │ │ │ +32 │ │ │ │ │ +35 using std::bool_constant; │ │ │ │ │ +36 │ │ │ │ │ +37#if DUNE_HAVE_CXX_EXPERIMENTAL_IS_DETECTED │ │ │ │ │ +38 │ │ │ │ │ +39 using std::experimental::nonesuch; │ │ │ │ │ +40 using std::experimental::detected_or; │ │ │ │ │ +41 using std::experimental::is_detected; │ │ │ │ │ +42 using std::experimental::detected_t; │ │ │ │ │ +43 using std::experimental::is_detected_v; │ │ │ │ │ +44 using std::experimental::detected_or_t; │ │ │ │ │ +45 using std::experimental::is_detected_exact; │ │ │ │ │ +46 using std::experimental::is_detected_exact_v; │ │ │ │ │ +47 using std::experimental::is_detected_convertible; │ │ │ │ │ +48 using std::experimental::is_detected_convertible_v; │ │ │ │ │ +49 │ │ │ │ │ +50#else // DUNE_HAVE_CXX_EXPERIMENTAL_IS_DETECTED │ │ │ │ │ +51 │ │ │ │ │ +52 // fallback version of std::experimental::is_detected et al., heavily │ │ │ │ │ +scribbled │ │ │ │ │ +53 // from cppreference.com (but there is actually not much implementation to │ │ │ │ │ +the thing) │ │ │ │ │ 54 │ │ │ │ │ -55 template │ │ │ │ │ -56 static constexpr auto has_proper_signature(Dune::PriorityTag<1>) │ │ │ │ │ -57 -> decltype( std::declval()(std::declval()...), std::true_type()) │ │ │ │ │ -58 { │ │ │ │ │ -59 return {}; │ │ │ │ │ -60 } │ │ │ │ │ -61 │ │ │ │ │ -62 template │ │ │ │ │ -63 static constexpr std::false_type has_proper_signature(Dune::PriorityTag<0>) │ │ │ │ │ -64 { │ │ │ │ │ -65 return {}; │ │ │ │ │ -66 } │ │ │ │ │ -67 │ │ │ │ │ -68 public: │ │ │ │ │ -69 │ │ │ │ │ -77 Type create(Key const& key, Args ... args) const { │ │ │ │ │ -78 typename Registry::const_iterator i = registry_.find(key); │ │ │ │ │ -79 if (i == registry_.end()) { │ │ │ │ │ -80 DUNE_THROW(Dune::InvalidStateException, │ │ │ │ │ -81 "ParametrizedObjectFactory: key ``" << │ │ │ │ │ -82 key << "'' not registered"); │ │ │ │ │ -83 } │ │ │ │ │ -84 else return i->second(args...); │ │ │ │ │ -85 } │ │ │ │ │ -86 │ │ │ │ │ -100 template │ │ │ │ │ -101 void define(Key const& key) │ │ │ │ │ -102 { │ │ │ │ │ -103 registry_[key] = DefaultCreator(); │ │ │ │ │ -104 } │ │ │ │ │ -105 │ │ │ │ │ -119 template(PriorityTag<42>()), int>:: │ │ │ │ │ -type = 0> │ │ │ │ │ -121 void define(Key const& key, F&& f) │ │ │ │ │ -122 { │ │ │ │ │ -123 registry_[key] = f; │ │ │ │ │ -124 } │ │ │ │ │ -125 │ │ │ │ │ -140 template::value │ │ │ │ │ -143 and not std::is_convertible::value, │ │ │ │ │ -144 int>::type = 0> │ │ │ │ │ -145 void define(Key const& key, Impl&& t) │ │ │ │ │ -146 { │ │ │ │ │ -147 registry_[key] = [=](Args...) { return t;}; │ │ │ │ │ -148 } │ │ │ │ │ +55#ifndef DOXYGEN │ │ │ │ │ +56 │ │ │ │ │ +57 namespace Impl { │ │ │ │ │ +58 │ │ │ │ │ +59 // default version of detector, this gets matched on failure │ │ │ │ │ +60 template class Op, │ │ │ │ │ +typename... Args> │ │ │ │ │ +61 struct detector │ │ │ │ │ +62 { │ │ │ │ │ +63 using value_t = std::false_type; │ │ │ │ │ +64 using type = Default; │ │ │ │ │ +65 }; │ │ │ │ │ +66 │ │ │ │ │ +67 // specialization of detector that matches if Op can be │ │ │ │ │ +instantiated │ │ │ │ │ +68 template class Op, typename... Args> │ │ │ │ │ +69 struct detector>, Op, Args...> │ │ │ │ │ +70 { │ │ │ │ │ +71 using value_t = std::true_type; │ │ │ │ │ +72 using type = Op; │ │ │ │ │ +73 }; │ │ │ │ │ +74 │ │ │ │ │ +75 } │ │ │ │ │ +76 │ │ │ │ │ +77#endif // DOXYGEN │ │ │ │ │ +78 │ │ │ │ │ +80 │ │ │ │ │ +88 struct nonesuch │ │ │ │ │ +89 { │ │ │ │ │ +90 nonesuch() = delete; │ │ │ │ │ +91 ~nonesuch() = delete; │ │ │ │ │ +92 nonesuch(const nonesuch&) = delete; │ │ │ │ │ +93 void operator=(const nonesuch&) = delete; │ │ │ │ │ +94 }; │ │ │ │ │ +95 │ │ │ │ │ +97 │ │ │ │ │ +131 template class Op, typename... │ │ │ │ │ +Args> │ │ │ │ │ +132 using detected_or = Impl::detector; │ │ │ │ │ +133 │ │ │ │ │ +135 │ │ │ │ │ +144 template class Op, typename... Args> │ │ │ │ │ +145 using is_detected = typename detected_or::value_t; │ │ │ │ │ +146 │ │ │ │ │ +147#ifdef __cpp_variable_templates │ │ │ │ │ 149 │ │ │ │ │ -150 bool contains(Key const& key) const │ │ │ │ │ -151 { │ │ │ │ │ -152 return registry_.count(key); │ │ │ │ │ -153 } │ │ │ │ │ -154 │ │ │ │ │ -155 private: │ │ │ │ │ -156 │ │ │ │ │ -157 template │ │ │ │ │ -158 struct Tag{}; │ │ │ │ │ -159 │ │ │ │ │ -160 template │ │ │ │ │ -161 struct DefaultCreator │ │ │ │ │ -162 { │ │ │ │ │ -163 template │ │ │ │ │ -164 Type operator()(T&&... args) const │ │ │ │ │ -165 { │ │ │ │ │ -166 return DefaultCreator::create(Tag(), PriorityTag<42>(), std:: │ │ │ │ │ -forward(args)...); │ │ │ │ │ -167 } │ │ │ │ │ -168 │ │ │ │ │ -169 template │ │ │ │ │ -170 static Type create(Tag, PriorityTag<1>, T&& ... args) { │ │ │ │ │ -171 return Impl(std::forward(args)...); │ │ │ │ │ -172 } │ │ │ │ │ -173 │ │ │ │ │ -174 template │ │ │ │ │ -175 static Type create(Tag>, PriorityTag<2>, T&& ... │ │ │ │ │ -args) { │ │ │ │ │ -176 return std::make_unique(std::forward(args)...); │ │ │ │ │ -177 } │ │ │ │ │ +158 template class Op, typename... Args> │ │ │ │ │ +159 constexpr bool is_detected_v = is_detected::value; │ │ │ │ │ +160#endif // __cpp_variable_templates │ │ │ │ │ +161 │ │ │ │ │ +163 │ │ │ │ │ +173 template class Op, typename... Args> │ │ │ │ │ +174 using detected_t = typename detected_or::type; │ │ │ │ │ +175 │ │ │ │ │ +176 │ │ │ │ │ 178 │ │ │ │ │ -179 template │ │ │ │ │ -180 static Type create(Tag>, PriorityTag<3>, T&& ... │ │ │ │ │ -args) { │ │ │ │ │ -181 return std::make_shared(std::forward(args)...); │ │ │ │ │ -182 } │ │ │ │ │ -183 │ │ │ │ │ -184 }; │ │ │ │ │ -185 │ │ │ │ │ -186 typedef std::map Registry; │ │ │ │ │ -187 Registry registry_; │ │ │ │ │ -188}; │ │ │ │ │ -189 │ │ │ │ │ +188 template class Op, typename... │ │ │ │ │ +Args> │ │ │ │ │ +189 using detected_or_t = typename detected_or::type; │ │ │ │ │ 190 │ │ │ │ │ -191 │ │ │ │ │ -192} // end namespace Dune │ │ │ │ │ -193 │ │ │ │ │ -194#endif // DUNE_COMMON_PARAMETERIZEDOBJECT_HH │ │ │ │ │ -exceptions.hh │ │ │ │ │ -A few common exception classes. │ │ │ │ │ +192 │ │ │ │ │ +198 template class Op, typename... │ │ │ │ │ +Args> │ │ │ │ │ +199 using is_detected_exact = std::is_same>; │ │ │ │ │ +200 │ │ │ │ │ +201#ifdef __cpp_variable_templates │ │ │ │ │ +203 │ │ │ │ │ +209 template class Op, typename... │ │ │ │ │ +Args> │ │ │ │ │ +210 constexpr bool is_detected_exact_v = is_detected_ │ │ │ │ │ +exact::value; │ │ │ │ │ +211#endif // __cpp_variable_templates │ │ │ │ │ +212 │ │ │ │ │ +214 │ │ │ │ │ +220 template class Op, typename... Args> │ │ │ │ │ +221 using is_detected_convertible = std::is_convertible>; │ │ │ │ │ +222 │ │ │ │ │ +223#ifdef __cpp_variable_templates │ │ │ │ │ +225 │ │ │ │ │ +231 template class Op, typename... Args> │ │ │ │ │ +232 constexpr bool is_detected_convertible_v = is_detected_ │ │ │ │ │ +convertible::value; │ │ │ │ │ +233#endif // __cpp_variable_templates │ │ │ │ │ +234 │ │ │ │ │ +235#endif // DUNE_HAVE_CXX_EXPERIMENTAL_IS_DETECTED │ │ │ │ │ +236 │ │ │ │ │ +237} // namespace Std │ │ │ │ │ +238 │ │ │ │ │ +239 │ │ │ │ │ +240namespace detail │ │ │ │ │ +241{ │ │ │ │ │ +242 template │ │ │ │ │ +243 [[deprecated("Type extraction of `TargetType` has failed. Inspect the code │ │ │ │ │ +calling `detected_or_fallback_t` for getting the source of this warning!")]] │ │ │ │ │ +244 Type warningIfNotDefined(const Std::nonesuch*); │ │ │ │ │ +245 │ │ │ │ │ +246 template │ │ │ │ │ +247 Type warningIfNotDefined(const T*); │ │ │ │ │ +248} │ │ │ │ │ +249 │ │ │ │ │ +251template class Fallback, │ │ │ │ │ +252 template class TargetType, typename... Args> │ │ │ │ │ +253using detected_or_fallback_t = Std::detected_or_t >(std:: │ │ │ │ │ +declval*>())), │ │ │ │ │ +255 TargetType, Args...>; │ │ │ │ │ +256 │ │ │ │ │ +257 │ │ │ │ │ +258} // namespace Dune │ │ │ │ │ +259 │ │ │ │ │ +260#endif // #ifndef DUNE_COMMON_STD_TYPE_TRAITS_HH │ │ │ │ │ +typetraits.hh │ │ │ │ │ +Traits for type conversions and type information. │ │ │ │ │ typeutilities.hh │ │ │ │ │ Utilities for type computations, constraining overloads, ... │ │ │ │ │ -DUNE_THROW │ │ │ │ │ -#define DUNE_THROW(E, m) │ │ │ │ │ -Definition exceptions.hh:218 │ │ │ │ │ +Dune::Std::detected_or_t │ │ │ │ │ +typename detected_or< Default, Op, Args... >::type detected_or_t │ │ │ │ │ +Returns Op if that is valid; otherwise returns the fallback type │ │ │ │ │ +Default. │ │ │ │ │ +Definition type_traits.hh:189 │ │ │ │ │ +Dune::Std::is_detected_exact │ │ │ │ │ +std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact │ │ │ │ │ +Checks whether Op is Expected without causing an error if Op │ │ │ │ │ +is invalid. │ │ │ │ │ +Definition type_traits.hh:199 │ │ │ │ │ +Dune::Std::detected_t │ │ │ │ │ +typename detected_or< nonesuch, Op, Args... >::type detected_t │ │ │ │ │ +Returns Op if that is valid; otherwise returns nonesuch. │ │ │ │ │ +Definition type_traits.hh:174 │ │ │ │ │ +Dune::void_t │ │ │ │ │ +typename Impl::voider< Types... >::type void_t │ │ │ │ │ +Is void for all valid input types. The workhorse for C++11 SFINAE-techniques. │ │ │ │ │ +Definition typetraits.hh:40 │ │ │ │ │ +Dune::Std::is_detected │ │ │ │ │ +typename detected_or< nonesuch, Op, Args... >::value_t is_detected │ │ │ │ │ +Detects whether Op is valid. │ │ │ │ │ +Definition type_traits.hh:145 │ │ │ │ │ +Dune::Std::detected_or │ │ │ │ │ +Impl::detector< Default, void, Op, Args... > detected_or │ │ │ │ │ +Detects whether Op is valid and makes the result available. │ │ │ │ │ +Definition type_traits.hh:132 │ │ │ │ │ +Dune::Std::is_detected_convertible │ │ │ │ │ +std::is_convertible< Target, detected_t< Op, Args... > > is_detected_ │ │ │ │ │ +convertible │ │ │ │ │ +Checks whether Op is convertible to Target without causing an error if │ │ │ │ │ +Op::Creator │ │ │ │ │ -std::function< Type(Args...)> Creator │ │ │ │ │ -Definition parameterizedobject.hh:53 │ │ │ │ │ -Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::has_proper_signature │ │ │ │ │ -static constexpr auto has_proper_signature(Dune::PriorityTag< 1 >) -> decltype │ │ │ │ │ -(std::declval< F >()(std::declval< Args >()...), std::true_type()) │ │ │ │ │ -Definition parameterizedobject.hh:56 │ │ │ │ │ -Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::Type │ │ │ │ │ -TypeT Type │ │ │ │ │ -The type of objects created by the factory. │ │ │ │ │ -Definition parameterizedobject.hh:49 │ │ │ │ │ -Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::define │ │ │ │ │ -void define(Key const &key, Impl &&t) │ │ │ │ │ -Registers a new type with a key. │ │ │ │ │ -Definition parameterizedobject.hh:145 │ │ │ │ │ -Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::Key │ │ │ │ │ -KeyT Key │ │ │ │ │ -The typ of the keys. │ │ │ │ │ -Definition parameterizedobject.hh:46 │ │ │ │ │ -Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::create │ │ │ │ │ -Type create(Key const &key, Args ... args) const │ │ │ │ │ -Creates an object identified by a key from given parameters. │ │ │ │ │ -Definition parameterizedobject.hh:77 │ │ │ │ │ -Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::define │ │ │ │ │ -void define(Key const &key) │ │ │ │ │ -Registers a new type with a key. │ │ │ │ │ -Definition parameterizedobject.hh:101 │ │ │ │ │ -Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::define │ │ │ │ │ -void define(Key const &key, F &&f) │ │ │ │ │ -Registers a new creator with a key. │ │ │ │ │ -Definition parameterizedobject.hh:121 │ │ │ │ │ -Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::has_proper_signature │ │ │ │ │ -static constexpr std::false_type has_proper_signature(Dune::PriorityTag< 0 >) │ │ │ │ │ -Definition parameterizedobject.hh:63 │ │ │ │ │ -Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::contains │ │ │ │ │ -bool contains(Key const &key) const │ │ │ │ │ -Definition parameterizedobject.hh:150 │ │ │ │ │ -Dune::PriorityTag │ │ │ │ │ -Helper class for tagging priorities. │ │ │ │ │ -Definition typeutilities.hh:73 │ │ │ │ │ +Dune::detected_or_fallback_t │ │ │ │ │ +Std::detected_or_t< decltype(detail::warningIfNotDefined< Std::detected_t< │ │ │ │ │ +Fallback, Args... > >(std::declval< const Std::detected_t< TargetType, Args... │ │ │ │ │ +> * >())), TargetType, Args... > detected_or_fallback_t │ │ │ │ │ +This type will be either TargetType if it exists, or the │ │ │ │ │ +Fallback │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: classname.hh File Reference │ │ │ │ +dune-common: memory.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,54 +65,46 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Namespaces | │ │ │ │ Functions
│ │ │ │ -
classname.hh File Reference
│ │ │ │ +
memory.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ - │ │ │ │ -

A free function to provide the demangled class name of a given object or type as a string. │ │ │ │ -More...

│ │ │ │ -
#include <cstdlib>
│ │ │ │ -#include <memory>
│ │ │ │ -#include <string>
│ │ │ │ -#include <typeinfo>
│ │ │ │ +
#include <memory>
│ │ │ │ #include <type_traits>
│ │ │ │ +#include <dune/common/typeutilities.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::Std
 Namespace for features backported from new C++ standards.
 
│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Functions

template<class T >
std::string Dune::className ()
 Provide the demangled class name of a type T as a string.
 
template<class T >
std::string Dune::className (T &&v)
 Provide the demangled class name of a given object as a string.
 
template<class T >
constexpr auto Dune::Std::to_address (T &&p) noexcept
 Obtain the address represented by p without forming a reference to the object pointed to by p.
 
│ │ │ │ -

Detailed Description

│ │ │ │ -

A free function to provide the demangled class name of a given object or type as a string.

│ │ │ │ -
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,34 +1,28 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ + * std │ │ │ │ │ Namespaces | Functions │ │ │ │ │ -classname.hh File Reference │ │ │ │ │ -A free function to provide the demangled class name of a given object or type │ │ │ │ │ -as a string. More... │ │ │ │ │ -#include │ │ │ │ │ +memory.hh File Reference │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ #include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -Functions │ │ │ │ │ -template │ │ │ │ │ -std::string  Dune::className () │ │ │ │ │ -  Provide the demangled class name of a type T as a string. │ │ │ │ │ +namespace   Dune::Std │ │ │ │ │ +  Namespace for features backported from new C++ standards. │ │ │ │ │   │ │ │ │ │ +Functions │ │ │ │ │ template │ │ │ │ │ -std::string  Dune::className (T &&v) │ │ │ │ │ -  Provide the demangled class name of a given object as a string. │ │ │ │ │ +constexpr auto  Dune::Std::to_address (T &&p) noexcept │ │ │ │ │ +  Obtain the address represented by p without forming a reference │ │ │ │ │ + to the object pointed to by p. │ │ │ │ │   │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -A free function to provide the demangled class name of a given object or type │ │ │ │ │ -as a string. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00044_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: classname.hh Source File │ │ │ │ +dune-common: memory.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,99 +70,82 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
classname.hh
│ │ │ │ +
memory.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_CLASSNAME_HH
│ │ │ │ -
6#define DUNE_CLASSNAME_HH
│ │ │ │ +
5#ifndef DUNE_COMMON_STD_MEMORY_HH
│ │ │ │ +
6#define DUNE_COMMON_STD_MEMORY_HH
│ │ │ │
7
│ │ │ │ -
13#include <cstdlib>
│ │ │ │ -
14#include <memory>
│ │ │ │ -
15#include <string>
│ │ │ │ -
16#include <typeinfo>
│ │ │ │ -
17#include <type_traits>
│ │ │ │ +
8#include <memory>
│ │ │ │ +
9#include <type_traits>
│ │ │ │ +
10
│ │ │ │ + │ │ │ │ +
12
│ │ │ │ +
13namespace Dune::Std {
│ │ │ │ +
14
│ │ │ │ +
15#if __cpp_lib_to_address >= 201711L
│ │ │ │ +
16
│ │ │ │ +
17using std::to_address;
│ │ │ │
18
│ │ │ │ -
19#if __has_include(<cxxabi.h>) && !DISABLE_CXA_DEMANGLE
│ │ │ │ -
20#define HAVE_CXA_DEMANGLE 1
│ │ │ │ -
21#include <cxxabi.h>
│ │ │ │ -
22#endif // #if HAVE_CXA_DEMANGLE
│ │ │ │ -
23
│ │ │ │ -
24namespace Dune {
│ │ │ │ -
25
│ │ │ │ -
26 namespace Impl {
│ │ │ │ -
27
│ │ │ │ -
28 inline std::string demangle(std::string name)
│ │ │ │ -
29 {
│ │ │ │ -
30#if HAVE_CXA_DEMANGLE
│ │ │ │ -
31 int status;
│ │ │ │ -
32 std::unique_ptr<char, void(*)(void*)>
│ │ │ │ -
33 demangled(abi::__cxa_demangle(name.c_str(), nullptr, nullptr, &status),
│ │ │ │ -
34 std::free);
│ │ │ │ -
35 if( demangled )
│ │ │ │ -
36 name = demangled.get();
│ │ │ │ -
37#endif // #if HAVE_CXA_DEMANGLE
│ │ │ │ -
38 return name;
│ │ │ │ -
39 }
│ │ │ │ -
40 }
│ │ │ │ -
41
│ │ │ │ -
43 /*
│ │ │ │ -
44 * \ingroup CxxUtilities
│ │ │ │ -
45 */
│ │ │ │ -
46 template <class T>
│ │ │ │ +
19#else
│ │ │ │ +
20
│ │ │ │ +
21namespace Impl {
│ │ │ │ +
22
│ │ │ │ +
23template <class T>
│ │ │ │ +
24constexpr T* toAddressImpl (T* p, Dune::PriorityTag<2>) noexcept
│ │ │ │ +
25{
│ │ │ │ +
26 static_assert(!std::is_function_v<T>);
│ │ │ │ +
27 return p;
│ │ │ │ +
28}
│ │ │ │ +
29
│ │ │ │ +
30template <class T>
│ │ │ │ +
31constexpr auto toAddressImpl (const T& p, Dune::PriorityTag<1>) noexcept
│ │ │ │ +
32 -> decltype(std::pointer_traits<T>::to_address(p))
│ │ │ │ +
33{
│ │ │ │ +
34 return std::pointer_traits<T>::to_address(p);
│ │ │ │ +
35}
│ │ │ │ +
36
│ │ │ │ +
37template <class T>
│ │ │ │ +
38constexpr auto toAddressImpl (const T& p, Dune::PriorityTag<0>) noexcept
│ │ │ │ +
39{
│ │ │ │ +
40 return toAddressImpl(p.operator->(), Dune::PriorityTag<3>{});
│ │ │ │ +
41}
│ │ │ │ +
42
│ │ │ │ +
43} // end namespace Impl
│ │ │ │ +
44
│ │ │ │ +
46template <class T>
│ │ │ │
│ │ │ │ -
47 std::string className ()
│ │ │ │ -
48 {
│ │ │ │ -
49 typedef typename std::remove_reference<T>::type TR;
│ │ │ │ -
50 std::string className = Impl::demangle( typeid( TR ).name() );
│ │ │ │ -
51 if (std::is_const<TR>::value)
│ │ │ │ -
52 className += " const";
│ │ │ │ -
53 if (std::is_volatile<TR>::value)
│ │ │ │ -
54 className += " volatile";
│ │ │ │ -
55 if (std::is_lvalue_reference<T>::value)
│ │ │ │ -
56 className += "&";
│ │ │ │ -
57 else if (std::is_rvalue_reference<T>::value)
│ │ │ │ -
58 className += "&&";
│ │ │ │ -
59 return className;
│ │ │ │ -
60 }
│ │ │ │ -
│ │ │ │ -
61
│ │ │ │ -
63 /*
│ │ │ │ -
64 * \ingroup CxxUtilities
│ │ │ │ -
65 */
│ │ │ │ -
66 template <class T>
│ │ │ │ -
│ │ │ │ -
67 std::string className ( T&& v)
│ │ │ │ -
68 {
│ │ │ │ -
69 typedef typename std::remove_reference<T>::type TR;
│ │ │ │ -
70 std::string className = Impl::demangle( typeid(v).name() );
│ │ │ │ -
71 if (std::is_const<TR>::value)
│ │ │ │ -
72 className += " const";
│ │ │ │ -
73 if (std::is_volatile<TR>::value)
│ │ │ │ -
74 className += " volatile";
│ │ │ │ -
75 return className;
│ │ │ │ -
76 }
│ │ │ │ -
│ │ │ │ -
77} // namespace Dune
│ │ │ │ -
78
│ │ │ │ -
79#endif // DUNE_CLASSNAME_HH
│ │ │ │ -
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
std::string className()
Provide the demangled class name of a type T as a string.
Definition classname.hh:47
│ │ │ │ +
47constexpr auto to_address(T&& p) noexcept
│ │ │ │ +
48{
│ │ │ │ +
49 return Impl::toAddressImpl(std::forward<T>(p), Dune::PriorityTag<3>{});
│ │ │ │ +
50}
│ │ │ │ +
│ │ │ │ +
51
│ │ │ │ +
52#endif
│ │ │ │ +
53
│ │ │ │ +
54} // end namespace Dune::Std
│ │ │ │ +
55
│ │ │ │ +
56#endif // DUNE_COMMON_STD_MEMORY_HH
│ │ │ │ +
Utilities for type computations, constraining overloads, ...
│ │ │ │ +
Namespace for features backported from new C++ standards.
Definition default_accessor.hh:10
│ │ │ │ +
constexpr auto to_address(T &&p) noexcept
Obtain the address represented by p without forming a reference to the object pointed to by p.
Definition memory.hh:47
│ │ │ │ +
Helper class for tagging priorities.
Definition typeutilities.hh:73
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,90 +1,80 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -classname.hh │ │ │ │ │ + * std │ │ │ │ │ +memory.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_CLASSNAME_HH │ │ │ │ │ -6#define DUNE_CLASSNAME_HH │ │ │ │ │ +5#ifndef DUNE_COMMON_STD_MEMORY_HH │ │ │ │ │ +6#define DUNE_COMMON_STD_MEMORY_HH │ │ │ │ │ 7 │ │ │ │ │ -13#include │ │ │ │ │ -14#include │ │ │ │ │ -15#include │ │ │ │ │ -16#include │ │ │ │ │ -17#include │ │ │ │ │ +8#include │ │ │ │ │ +9#include │ │ │ │ │ +10 │ │ │ │ │ +11#include │ │ │ │ │ +12 │ │ │ │ │ +13namespace Dune::Std { │ │ │ │ │ +14 │ │ │ │ │ +15#if __cpp_lib_to_address >= 201711L │ │ │ │ │ +16 │ │ │ │ │ +17using std::to_address; │ │ │ │ │ 18 │ │ │ │ │ -19#if __has_include() && !DISABLE_CXA_DEMANGLE │ │ │ │ │ -20#define HAVE_CXA_DEMANGLE 1 │ │ │ │ │ -21#include │ │ │ │ │ -22#endif // #if HAVE_CXA_DEMANGLE │ │ │ │ │ -23 │ │ │ │ │ -24namespace Dune { │ │ │ │ │ -25 │ │ │ │ │ -26 namespace Impl { │ │ │ │ │ -27 │ │ │ │ │ -28 inline std::string demangle(std::string name) │ │ │ │ │ -29 { │ │ │ │ │ -30#if HAVE_CXA_DEMANGLE │ │ │ │ │ -31 int status; │ │ │ │ │ -32 std::unique_ptr │ │ │ │ │ -33 demangled(abi::__cxa_demangle(name.c_str(), nullptr, nullptr, &status), │ │ │ │ │ -34 std::free); │ │ │ │ │ -35 if( demangled ) │ │ │ │ │ -36 name = demangled.get(); │ │ │ │ │ -37#endif // #if HAVE_CXA_DEMANGLE │ │ │ │ │ -38 return name; │ │ │ │ │ -39 } │ │ │ │ │ -40 } │ │ │ │ │ -41 │ │ │ │ │ -43 /* │ │ │ │ │ -44 * \ingroup CxxUtilities │ │ │ │ │ -45 */ │ │ │ │ │ -46 template │ │ │ │ │ -47 std::string className () │ │ │ │ │ -48 { │ │ │ │ │ -49 typedef typename std::remove_reference::type TR; │ │ │ │ │ -50 std::string className = Impl::demangle( typeid( TR ).name() ); │ │ │ │ │ -51 if (std::is_const::value) │ │ │ │ │ -52 className += " const"; │ │ │ │ │ -53 if (std::is_volatile::value) │ │ │ │ │ -54 className += " volatile"; │ │ │ │ │ -55 if (std::is_lvalue_reference::value) │ │ │ │ │ -56 className += "&"; │ │ │ │ │ -57 else if (std::is_rvalue_reference::value) │ │ │ │ │ -58 className += "&&"; │ │ │ │ │ -59 return className; │ │ │ │ │ -60 } │ │ │ │ │ -61 │ │ │ │ │ -63 /* │ │ │ │ │ -64 * \ingroup CxxUtilities │ │ │ │ │ -65 */ │ │ │ │ │ -66 template │ │ │ │ │ -67 std::string className ( T&& v) │ │ │ │ │ -68 { │ │ │ │ │ -69 typedef typename std::remove_reference::type TR; │ │ │ │ │ -70 std::string className = Impl::demangle( typeid(v).name() ); │ │ │ │ │ -71 if (std::is_const::value) │ │ │ │ │ -72 className += " const"; │ │ │ │ │ -73 if (std::is_volatile::value) │ │ │ │ │ -74 className += " volatile"; │ │ │ │ │ -75 return className; │ │ │ │ │ -76 } │ │ │ │ │ -77} // namespace Dune │ │ │ │ │ -78 │ │ │ │ │ -79#endif // DUNE_CLASSNAME_HH │ │ │ │ │ -Dune │ │ │ │ │ -Dune namespace. │ │ │ │ │ -Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::className │ │ │ │ │ -std::string className() │ │ │ │ │ -Provide the demangled class name of a type T as a string. │ │ │ │ │ -Definition classname.hh:47 │ │ │ │ │ +19#else │ │ │ │ │ +20 │ │ │ │ │ +21namespace Impl { │ │ │ │ │ +22 │ │ │ │ │ +23template │ │ │ │ │ +24constexpr T* toAddressImpl (T* p, Dune::PriorityTag<2>) noexcept │ │ │ │ │ +25{ │ │ │ │ │ +26 static_assert(!std::is_function_v); │ │ │ │ │ +27 return p; │ │ │ │ │ +28} │ │ │ │ │ +29 │ │ │ │ │ +30template │ │ │ │ │ +31constexpr auto toAddressImpl (const T& p, Dune::PriorityTag<1>) noexcept │ │ │ │ │ +32 -> decltype(std::pointer_traits::to_address(p)) │ │ │ │ │ +33{ │ │ │ │ │ +34 return std::pointer_traits::to_address(p); │ │ │ │ │ +35} │ │ │ │ │ +36 │ │ │ │ │ +37template │ │ │ │ │ +38constexpr auto toAddressImpl (const T& p, Dune::PriorityTag<0>) noexcept │ │ │ │ │ +39{ │ │ │ │ │ +40 return toAddressImpl(p.operator->(), Dune::PriorityTag<3>{}); │ │ │ │ │ +41} │ │ │ │ │ +42 │ │ │ │ │ +43} // end namespace Impl │ │ │ │ │ +44 │ │ │ │ │ +46template │ │ │ │ │ +47constexpr auto to_address(T&& p) noexcept │ │ │ │ │ +48{ │ │ │ │ │ +49 return Impl::toAddressImpl(std::forward(p), Dune::PriorityTag<3>{}); │ │ │ │ │ +50} │ │ │ │ │ +51 │ │ │ │ │ +52#endif │ │ │ │ │ +53 │ │ │ │ │ +54} // end namespace Dune::Std │ │ │ │ │ +55 │ │ │ │ │ +56#endif // DUNE_COMMON_STD_MEMORY_HH │ │ │ │ │ +typeutilities.hh │ │ │ │ │ +Utilities for type computations, constraining overloads, ... │ │ │ │ │ +Dune::Std │ │ │ │ │ +Namespace for features backported from new C++ standards. │ │ │ │ │ +Definition default_accessor.hh:10 │ │ │ │ │ +Dune::Std::to_address │ │ │ │ │ +constexpr auto to_address(T &&p) noexcept │ │ │ │ │ +Obtain the address represented by p without forming a reference to the object │ │ │ │ │ +pointed to by p. │ │ │ │ │ +Definition memory.hh:47 │ │ │ │ │ +Dune::PriorityTag │ │ │ │ │ +Helper class for tagging priorities. │ │ │ │ │ +Definition typeutilities.hh:73 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00047.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: parametertreeparser.hh File Reference │ │ │ │ +dune-common: span.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,55 +65,84 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces
│ │ │ │ -
parametertreeparser.hh File Reference
│ │ │ │ +Namespaces | │ │ │ │ +Functions | │ │ │ │ +Variables
│ │ │ │ +
span.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ - │ │ │ │ -

Various parser methods to get data into a ParameterTree object. │ │ │ │ -More...

│ │ │ │ -
#include <istream>
│ │ │ │ +
#include <cassert>
│ │ │ │ +#include <cstddef>
│ │ │ │ +#include <exception>
│ │ │ │ +#include <iterator>
│ │ │ │ +#include <limits>
│ │ │ │ +#include <stdexcept>
│ │ │ │ #include <string>
│ │ │ │ -#include <vector>
│ │ │ │ -#include <dune/common/parametertree.hh>
│ │ │ │ -#include <dune/common/exceptions.hh>
│ │ │ │ +#include <type_traits>
│ │ │ │ +#include <dune/common/exceptions.hh>
│ │ │ │ +#include <dune/common/std/memory.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::ParameterTreeParserError
 report parser error while reading ParameterTree More...
 
class  Dune::HelpRequest
 exception thrown if the user wants to see help string More...
 
class  Dune::ParameterTreeParser
 Parsers to set up a ParameterTree from various input sources. More...
class  Dune::Std::span< Element, Extent >
 A contiguous sequence of elements with static or dynamic extent. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::Std
 Namespace for features backported from new C++ standards.
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Functions

template<class T , std::size_t N>
 Dune::Std::span (T(&)[N]) -> span< T, N >
 
template<class ElementType , class I , std::size_t Extent, std::enable_if_t< std::is_convertible_v< I, std::size_t >, int > = 0>
 Dune::Std::span (ElementType *, std::integral_constant< I, Extent >) -> span< ElementType, Extent >
 
template<class ElementType , class I , std::enable_if_t< std::is_integral_v< I >, int > = 0, std::enable_if_t< std::is_convertible_v< I, std::size_t >, int > = 0>
 Dune::Std::span (ElementType *, I) -> span< ElementType, Std::dynamic_extent >
 
template<class Iter , class Element = std::remove_reference_t<decltype(*std::declval<Iter>())>>
 Dune::Std::span (Iter, Iter) -> span< Element, Std::dynamic_extent >
 
template<class Range , class First = decltype(std::begin(std::declval<Range>())), class Last = decltype(std::end(std::declval<Range>())), class Element = std::remove_reference_t<decltype(*std::declval<First>())>>
 Dune::Std::span (Range &) -> span< Element, Std::dynamic_extent >
 
template<class T , size_t N>
 Dune::Std::span (std::array< T, N > &) -> span< T, N >
 
template<class T , size_t N>
 Dune::Std::span (const std::array< T, N > &) -> span< const T, N >
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ +Variables

constexpr std::size_t Dune::Std::dynamic_extent = std::numeric_limits<std::size_t>::max()
 A constant of type std::size_t that is used to differentiate std::span of static and dynamic extent.
 
│ │ │ │ -

Detailed Description

│ │ │ │ -

Various parser methods to get data into a ParameterTree object.

│ │ │ │ -
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,33 +1,70 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -parametertreeparser.hh File Reference │ │ │ │ │ -Various parser methods to get data into a ParameterTree object. More... │ │ │ │ │ -#include │ │ │ │ │ + * std │ │ │ │ │ +Classes | Namespaces | Functions | Variables │ │ │ │ │ +span.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class   Dune::ParameterTreeParserError │ │ │ │ │ -  report parser error while reading ParameterTree More... │ │ │ │ │ -  │ │ │ │ │ -class   Dune::HelpRequest │ │ │ │ │ -  exception thrown if the user wants to see help string More... │ │ │ │ │ -  │ │ │ │ │ -class   Dune::ParameterTreeParser │ │ │ │ │ -  Parsers to set up a ParameterTree from various input sources. More... │ │ │ │ │ +class   Dune::Std::span<_Element,_Extent_> │ │ │ │ │ +  A contiguous sequence of elements with static or dynamic extent. │ │ │ │ │ + More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -Various parser methods to get data into a ParameterTree object. │ │ │ │ │ +namespace   Dune::Std │ │ │ │ │ +  Namespace for features backported from new C++ standards. │ │ │ │ │ +  │ │ │ │ │ +Functions │ │ │ │ │ +template │ │ │ │ │ +  Dune::Std::span (T(&)[N]) -> span< T, N > │ │ │ │ │ +  │ │ │ │ │ +template, int > = 0> │ │ │ │ │ +  Dune::Std::span (ElementType *, std::integral_constant< I, Extent >) -> span< │ │ │ │ │ + ElementType, Extent > │ │ │ │ │ +  │ │ │ │ │ +template, int > = 0, std::enable_if_t< std::is_convertible_v< I, std::size_t >, int > │ │ │ │ │ += 0> │ │ │ │ │ +  Dune::Std::span (ElementType *, I) -> span< ElementType, Std::dynamic_extent │ │ │ │ │ + > │ │ │ │ │ +  │ │ │ │ │ +template())>> │ │ │ │ │ +  Dune::Std::span (Iter, Iter) -> span< Element, Std::dynamic_extent > │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +())), class Last = decltype(std::end(std::declval())), class Element = │ │ │ │ │ +std::remove_reference_t())>> │ │ │ │ │ +  Dune::Std::span (Range &) -> span< Element, Std::dynamic_extent > │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +  Dune::Std::span (std::array< T, N > &) -> span< T, N > │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +  Dune::Std::span (const std::array< T, N > &) -> span< const T, N > │ │ │ │ │ +  │ │ │ │ │ +Variables │ │ │ │ │ +constexpr std::size_t  Dune::Std::dynamic_extent = std::numeric_limits::max() │ │ │ │ │ +  A constant of type std::size_t that is used to │ │ │ │ │ + differentiate std::span of static and dynamic extent. │ │ │ │ │ +  │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00047_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: parametertreeparser.hh Source File │ │ │ │ +dune-common: span.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,96 +70,464 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
parametertreeparser.hh
│ │ │ │ +
span.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_PARAMETER_PARSER_HH
│ │ │ │ -
6#define DUNE_PARAMETER_PARSER_HH
│ │ │ │ +
5#ifndef DUNE_COMMON_STD_SPAN_HH
│ │ │ │ +
6#define DUNE_COMMON_STD_SPAN_HH
│ │ │ │
7
│ │ │ │ -
12#include <istream>
│ │ │ │ -
13#include <string>
│ │ │ │ -
14#include <vector>
│ │ │ │ -
15
│ │ │ │ - │ │ │ │ - │ │ │ │ -
18
│ │ │ │ -
19namespace Dune {
│ │ │ │ -
20
│ │ │ │ - │ │ │ │ -
28 class HelpRequest : public Exception {};
│ │ │ │ +
8#include <cassert>
│ │ │ │ +
9#include <cstddef>
│ │ │ │ +
10#include <exception>
│ │ │ │ +
11#include <iterator>
│ │ │ │ +
12#include <limits>
│ │ │ │ +
13#include <stdexcept>
│ │ │ │ +
14#include <string>
│ │ │ │ +
15#include <type_traits>
│ │ │ │ +
16#if __has_include(<version>)
│ │ │ │ +
17 #include <version>
│ │ │ │ +
18#endif
│ │ │ │ +
19
│ │ │ │ + │ │ │ │ + │ │ │ │ +
22
│ │ │ │ +
23namespace Dune::Std {
│ │ │ │ +
24
│ │ │ │ +
26inline constexpr std::size_t dynamic_extent = std::numeric_limits<std::size_t>::max();
│ │ │ │ +
27
│ │ │ │ +
28namespace Impl {
│ │ │ │
29
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
35 {
│ │ │ │ -
36
│ │ │ │ -
37 static std::string ltrim(const std::string& s);
│ │ │ │ -
38 static std::string rtrim(const std::string& s);
│ │ │ │ -
39
│ │ │ │ -
40 public:
│ │ │ │ -
41
│ │ │ │ -
85
│ │ │ │ -
96 static void readINITree(std::istream& in, ParameterTree& pt,
│ │ │ │ -
97 bool overwrite);
│ │ │ │ -
98
│ │ │ │ -
105 static Dune::ParameterTree readINITree(std::istream& in);
│ │ │ │ -
106
│ │ │ │ -
107
│ │ │ │ -
120 static void readINITree(std::istream& in, ParameterTree& pt,
│ │ │ │ -
121 const std::string srcname = "stream",
│ │ │ │ -
122 bool overwrite = true);
│ │ │ │ -
123
│ │ │ │ -
124
│ │ │ │ -
135 static void readINITree(std::string file, ParameterTree& pt, bool overwrite = true);
│ │ │ │ -
136
│ │ │ │ -
143 static Dune::ParameterTree readINITree(const std::string& file);
│ │ │ │ -
144
│ │ │ │ -
146
│ │ │ │ -
158 static void readOptions(int argc, char* argv [], ParameterTree& pt);
│ │ │ │ -
159
│ │ │ │ -
177 static void readNamedOptions(int argc, char* argv[],
│ │ │ │ -
178 ParameterTree& pt,
│ │ │ │ -
179 std::vector<std::string> keywords,
│ │ │ │ -
180 unsigned int required = std::numeric_limits<unsigned int>::max(),
│ │ │ │ -
181 bool allow_more = true,
│ │ │ │ -
182 bool overwrite = true,
│ │ │ │ -
183 std::vector<std::string> help = std::vector<std::string>());
│ │ │ │ -
184
│ │ │ │ -
185 private:
│ │ │ │ -
186 static std::string generateHelpString(std::string progname, std::vector<std::string> keywords, unsigned int required, std::vector<std::string> help);
│ │ │ │ -
187 };
│ │ │ │ -
│ │ │ │ -
188
│ │ │ │ -
189} // end namespace Dune
│ │ │ │ -
190
│ │ │ │ -
191#endif // DUNE_PARAMETER_PARSER_HH
│ │ │ │ -
A few common exception classes.
│ │ │ │ -
A hierarchical structure of string parameters.
│ │ │ │ -
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
Base class for Dune-Exceptions.
Definition exceptions.hh:96
│ │ │ │ -
Default exception class for range errors.
Definition exceptions.hh:254
│ │ │ │ -
Hierarchical structure of string parameters.
Definition parametertree.hh:37
│ │ │ │ -
report parser error while reading ParameterTree
Definition parametertreeparser.hh:22
│ │ │ │ -
exception thrown if the user wants to see help string
Definition parametertreeparser.hh:28
│ │ │ │ -
Parsers to set up a ParameterTree from various input sources.
Definition parametertreeparser.hh:35
│ │ │ │ -
static void readOptions(int argc, char *argv[], ParameterTree &pt)
parse command line options and build hierarchical ParameterTree structure
Definition parametertreeparser.cc:155
│ │ │ │ -
static void readINITree(std::istream &in, ParameterTree &pt, bool overwrite)
parse C++ stream
Definition parametertreeparser.cc:70
│ │ │ │ -
static void readNamedOptions(int argc, char *argv[], ParameterTree &pt, std::vector< std::string > keywords, unsigned int required=std::numeric_limits< unsigned int >::max(), bool allow_more=true, bool overwrite=true, std::vector< std::string > help=std::vector< std::string >())
read [named] command line options and build hierarchical ParameterTree structure
Definition parametertreeparser.cc:171
│ │ │ │ +
30template <std::size_t Extent>
│ │ │ │ +
31class SpanSize
│ │ │ │ +
32{
│ │ │ │ +
33public:
│ │ │ │ +
34 using size_type = std::size_t;
│ │ │ │ +
35
│ │ │ │ +
36public:
│ │ │ │ +
37 constexpr SpanSize () = default;
│ │ │ │ +
38
│ │ │ │ +
39 constexpr SpanSize ([[maybe_unused]] size_type size) noexcept
│ │ │ │ +
40 {
│ │ │ │ +
41 assert(Extent == Std::dynamic_extent || Extent == size);
│ │ │ │ +
42 }
│ │ │ │ +
43
│ │ │ │ +
44 template <class Iter>
│ │ │ │ +
45 constexpr SpanSize ([[maybe_unused]] Iter first, [[maybe_unused]] Iter last) noexcept
│ │ │ │ +
46 {
│ │ │ │ +
47 assert((std::distance(first,last) == Extent));
│ │ │ │ +
48 }
│ │ │ │ +
49
│ │ │ │ +
50 constexpr size_type size () const noexcept { return Extent; }
│ │ │ │ +
51};
│ │ │ │ +
52
│ │ │ │ +
53template <>
│ │ │ │ +
54class SpanSize<Std::dynamic_extent>
│ │ │ │ +
55{
│ │ │ │ +
56public:
│ │ │ │ +
57 using size_type = std::size_t;
│ │ │ │ +
58
│ │ │ │ +
59public:
│ │ │ │ +
60 constexpr SpanSize (size_type size = 0) noexcept
│ │ │ │ +
61 : size_(size)
│ │ │ │ +
62 {}
│ │ │ │ +
63
│ │ │ │ +
64 template <class Iter>
│ │ │ │ +
65 constexpr SpanSize (Iter first, Iter last) noexcept
│ │ │ │ +
66 : size_(std::distance(first,last))
│ │ │ │ +
67 {}
│ │ │ │ +
68
│ │ │ │ +
69 constexpr size_type size () const noexcept { return size_; }
│ │ │ │ +
70
│ │ │ │ +
71private:
│ │ │ │ +
72 size_type size_;
│ │ │ │ +
73};
│ │ │ │ +
74
│ │ │ │ +
75template <class T>
│ │ │ │ +
76struct TypeIdentity { using type = T; };
│ │ │ │ +
77
│ │ │ │ +
78template <class T>
│ │ │ │ +
79using TypeIdentity_t = typename TypeIdentity<T>::type;
│ │ │ │ +
80
│ │ │ │ +
81} // end namespace Impl
│ │ │ │ +
82
│ │ │ │ +
83
│ │ │ │ +
123template <class Element, std::size_t Extent = Std::dynamic_extent>
│ │ │ │ +
│ │ │ │ +
124class span
│ │ │ │ +
125 : public Impl::SpanSize<Extent>
│ │ │ │ +
126{
│ │ │ │ +
127 using base_type = Impl::SpanSize<Extent>; // base_type implements the member variable size()
│ │ │ │ +
128
│ │ │ │ +
129 static_assert(std::is_object_v<Element> && !std::is_abstract_v<Element>);
│ │ │ │ +
130
│ │ │ │ +
131public:
│ │ │ │ +
132 using element_type = Element;
│ │ │ │ +
133 using value_type = std::remove_cv_t<element_type>;
│ │ │ │ +
134 using size_type = std::size_t;
│ │ │ │ +
135 using difference_type = std::ptrdiff_t;
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
140 using reverse_iterator = std::reverse_iterator<iterator>;
│ │ │ │ +
141#if __cpp_lib_ranges_as_const >202311L
│ │ │ │ +
142 using const_iterator = std::const_iterator<iterator>;
│ │ │ │ +
143 using const_reverse_iterator = std::const_iterator<reverse_iterator>;
│ │ │ │ +
144#else
│ │ │ │ + │ │ │ │ +
146 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
│ │ │ │ +
147#endif
│ │ │ │ +
148
│ │ │ │ +
149
│ │ │ │ +
150 static constexpr size_type extent = Extent;
│ │ │ │ +
151
│ │ │ │ +
152public:
│ │ │ │ +
155
│ │ │ │ +
157 template <std::size_t e = extent,
│ │ │ │ +
158 std::enable_if_t<(e == dynamic_extent || e == 0), int> = 0>
│ │ │ │ +
│ │ │ │ +
159 constexpr span () noexcept
│ │ │ │ +
160 : base_type{}
│ │ │ │ +
161 , data_{}
│ │ │ │ +
162 {}
│ │ │ │ +
│ │ │ │ +
163
│ │ │ │ +
165 template <class Iter,
│ │ │ │ +
166 class U = std::remove_reference_t<decltype(*std::declval<Iter>())>,
│ │ │ │ +
167 std::enable_if_t<std::is_convertible_v<U(*)[], element_type(*)[]>, int> = 0>
│ │ │ │ +
168 #if __cpp_conditional_explicit >= 201806L
│ │ │ │ +
169 explicit(extent != Std::dynamic_extent)
│ │ │ │ +
170 #endif
│ │ │ │ +
│ │ │ │ +
171 constexpr span (Iter first, size_type size)
│ │ │ │ +
172 : base_type(size)
│ │ │ │ +
173 , data_(Std::to_address(first))
│ │ │ │ +
174 {}
│ │ │ │ +
│ │ │ │ +
175
│ │ │ │ +
177 template <class Iter,
│ │ │ │ +
178 class U = std::remove_reference_t<decltype(*std::declval<Iter>())>,
│ │ │ │ +
179 std::enable_if_t<std::is_convertible_v<U(*)[], element_type(*)[]>, int> = 0>
│ │ │ │ +
180 #if __cpp_conditional_explicit >= 201806L
│ │ │ │ +
181 explicit(extent != Std::dynamic_extent)
│ │ │ │ +
182 #endif
│ │ │ │ +
│ │ │ │ +
183 constexpr span (Iter first, Iter last)
│ │ │ │ +
184 : base_type(first,last)
│ │ │ │ +
185 , data_(Std::to_address(first))
│ │ │ │ +
186 {}
│ │ │ │ +
│ │ │ │ +
187
│ │ │ │ +
189 template <class Range,
│ │ │ │ +
190 decltype(std::begin(std::declval<Range>()), std::end(std::declval<Range>()), bool{}) = true,
│ │ │ │ +
191 std::enable_if_t<not std::is_array_v<Range>, int> = 0>
│ │ │ │ +
192 #if __cpp_conditional_explicit >= 201806L
│ │ │ │ +
193 explicit(extent != Std::dynamic_extent)
│ │ │ │ +
194 #endif
│ │ │ │ +
│ │ │ │ +
195 constexpr span (Range& range)
│ │ │ │ +
196 : span(std::begin(range), std::end(range))
│ │ │ │ +
197 {}
│ │ │ │ +
│ │ │ │ +
198
│ │ │ │ +
200 template <std::size_t N, std::size_t e = extent,
│ │ │ │ +
201 std::enable_if_t<(e == Std::dynamic_extent || e == N), int> = 0>
│ │ │ │ +
│ │ │ │ +
202 constexpr span (Impl::TypeIdentity_t<element_type> (&data)[N]) noexcept
│ │ │ │ +
203 : base_type(N)
│ │ │ │ +
204 , data_(data)
│ │ │ │ +
205 {}
│ │ │ │ +
│ │ │ │ +
206
│ │ │ │ +
208 template <class T, size_t N, std::size_t e = extent,
│ │ │ │ +
209 std::enable_if_t<(e == Std::dynamic_extent || e == N), int> = 0,
│ │ │ │ +
210 std::enable_if_t<std::is_convertible_v<T(*)[], element_type(*)[]>, int> = 0>
│ │ │ │ +
│ │ │ │ +
211 constexpr span (std::array<T, N>& arr) noexcept
│ │ │ │ +
212 : base_type(N)
│ │ │ │ +
213 , data_(arr.data())
│ │ │ │ +
214 {}
│ │ │ │ +
│ │ │ │ +
215
│ │ │ │ +
217 template <class T, size_t N, std::size_t e = extent,
│ │ │ │ +
218 std::enable_if_t<(e == Std::dynamic_extent || e == N), int> = 0,
│ │ │ │ +
219 std::enable_if_t<std::is_convertible_v<const T(*)[], element_type(*)[]>, int> = 0>
│ │ │ │ +
│ │ │ │ +
220 constexpr span (const std::array<T, N>& arr) noexcept
│ │ │ │ +
221 : base_type(N)
│ │ │ │ +
222 , data_(arr.data())
│ │ │ │ +
223 {}
│ │ │ │ +
│ │ │ │ +
224
│ │ │ │ +
226 template <class E = element_type,
│ │ │ │ +
227 std::enable_if_t<std::is_const_v<E>, int> = 0>
│ │ │ │ +
228 #if __cpp_conditional_explicit >= 201806L
│ │ │ │ +
229 explicit(extent != Std::dynamic_extent)
│ │ │ │ +
230 #endif
│ │ │ │ +
│ │ │ │ +
231 constexpr span (std::initializer_list<value_type> il)
│ │ │ │ +
232 : base_type(il.size())
│ │ │ │ +
233 , data_(il.begin())
│ │ │ │ +
234 {}
│ │ │ │ +
│ │ │ │ +
235
│ │ │ │ +
237 constexpr span (const span& other) noexcept = default;
│ │ │ │ +
238
│ │ │ │ +
240 template <class OtherElementType, std::size_t OtherExtent,
│ │ │ │ +
241 std::enable_if_t<(extent == Std::dynamic_extent || OtherExtent == Std::dynamic_extent || extent == OtherExtent), int> = 0,
│ │ │ │ +
242 std::enable_if_t<std::is_convertible_v<OtherElementType(*)[], element_type(*)[]>, int> = 0>
│ │ │ │ +
243 #if __cpp_conditional_explicit >= 201806L
│ │ │ │ +
244 explicit(extent != Std::dynamic_extent && OtherExtent == Std::dynamic_extent)
│ │ │ │ +
245 #endif
│ │ │ │ +
│ │ │ │ +
246 constexpr span (const span<OtherElementType, OtherExtent>& s) noexcept
│ │ │ │ +
247 : base_type(s.size())
│ │ │ │ +
248 , data_(s.data())
│ │ │ │ +
249 {}
│ │ │ │ +
│ │ │ │ +
250
│ │ │ │ +
252 constexpr span& operator= (const span& other) noexcept = default;
│ │ │ │ +
253
│ │ │ │ +
255
│ │ │ │ +
256
│ │ │ │ +
259
│ │ │ │ +
261 constexpr iterator begin () const noexcept { return data_; }
│ │ │ │ +
262
│ │ │ │ +
264 constexpr iterator end () const noexcept { return data_ + size(); }
│ │ │ │ +
265
│ │ │ │ +
267 constexpr const_iterator cbegin () const noexcept { return data_; }
│ │ │ │ +
268
│ │ │ │ +
270 constexpr const_iterator cend () const noexcept { return data_ + size(); }
│ │ │ │ +
271
│ │ │ │ +
273 constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator{end()}; }
│ │ │ │ +
274
│ │ │ │ +
276 constexpr reverse_iterator rend() const noexcept { return reverse_iterator{begin()}; }
│ │ │ │ +
277
│ │ │ │ +
279 constexpr const_reverse_iterator crbegin() const noexcept { return reverse_iterator{end()}; }
│ │ │ │ +
280
│ │ │ │ +
282 constexpr const_reverse_iterator crend() const noexcept { return reverse_iterator{begin()}; }
│ │ │ │ +
283
│ │ │ │ +
285
│ │ │ │ +
286
│ │ │ │ +
289
│ │ │ │ +
│ │ │ │ +
291 constexpr reference front () const
│ │ │ │ +
292 {
│ │ │ │ +
293 assert(not empty() && "front of empty span does not exist");
│ │ │ │ +
294 return data_[0];
│ │ │ │ +
295 }
│ │ │ │ +
│ │ │ │ +
296
│ │ │ │ +
│ │ │ │ +
298 constexpr reference back () const
│ │ │ │ +
299 {
│ │ │ │ +
300 assert(not empty() && "front of empty span does not exist");
│ │ │ │ +
301 return data_[size()-1];
│ │ │ │ +
302 }
│ │ │ │ +
│ │ │ │ +
303
│ │ │ │ +
│ │ │ │ +
305 constexpr reference at (size_type i) const
│ │ │ │ +
306 {
│ │ │ │ +
307 if (i >= size())
│ │ │ │ +
308 throw std::out_of_range("Index " + std::to_string(i) + " out of range.");
│ │ │ │ +
309 return data_[i];
│ │ │ │ +
310 }
│ │ │ │ +
│ │ │ │ +
311
│ │ │ │ +
313 constexpr reference operator[] (size_type i) const { return data_[i]; }
│ │ │ │ +
314
│ │ │ │ +
316 constexpr pointer data () const noexcept { return data_; }
│ │ │ │ +
317
│ │ │ │ +
319
│ │ │ │ +
320
│ │ │ │ +
323
│ │ │ │ +
325 template <std::size_t Count>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
327 {
│ │ │ │ +
328 static_assert(Count <= Extent);
│ │ │ │ +
329 assert(Count <= size());
│ │ │ │ +
330 return span<element_type, Count>{data(), Count};
│ │ │ │ +
331 }
│ │ │ │ +
│ │ │ │ +
332
│ │ │ │ +
334 template <std::size_t Count>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
336 {
│ │ │ │ +
337 static_assert(Count <= Extent);
│ │ │ │ +
338 assert(Count <= size());
│ │ │ │ +
339 return span<element_type, Count>{data()+ (size() - Count), Count};
│ │ │ │ +
340 }
│ │ │ │ +
│ │ │ │ +
341
│ │ │ │ +
342private:
│ │ │ │ +
343
│ │ │ │ +
344 static constexpr std::size_t subspan_extent (std::size_t O, std::size_t C) noexcept
│ │ │ │ +
345 {
│ │ │ │ +
346 return (C != Std::dynamic_extent) ? C :
│ │ │ │ +
347 (Extent != Std::dynamic_extent) ? Extent - O : Std::dynamic_extent;
│ │ │ │ +
348 }
│ │ │ │ +
349
│ │ │ │ +
350public:
│ │ │ │ +
351
│ │ │ │ +
353
│ │ │ │ +
357 template <std::size_t Offset, std::size_t Count = Std::dynamic_extent>
│ │ │ │ +
│ │ │ │ +
358 constexpr span<element_type, subspan_extent(Offset,Count)> subspan () const
│ │ │ │ +
359 {
│ │ │ │ +
360 static_assert(Offset <= Extent && (Count == Std::dynamic_extent || Count <= Extent - Offset));
│ │ │ │ +
361 assert(Offset <= size() && (Count == Std::dynamic_extent || Count <= size() - Offset));
│ │ │ │ +
362 return span<element_type, subspan_extent(Offset,Count)>{
│ │ │ │ +
363 data() + Offset, Count != Std::dynamic_extent ? Count : size() - Offset};
│ │ │ │ +
364 }
│ │ │ │ +
│ │ │ │ +
365
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
368 {
│ │ │ │ +
369 assert(count <= size());
│ │ │ │ + │ │ │ │ +
371 }
│ │ │ │ +
│ │ │ │ +
372
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
375 {
│ │ │ │ +
376 assert(count <= size());
│ │ │ │ +
377 return span<element_type, Std::dynamic_extent>{data()+ (size() - count), count};
│ │ │ │ +
378 }
│ │ │ │ +
│ │ │ │ +
379
│ │ │ │ +
381
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
386 {
│ │ │ │ +
387 assert(offset <= size() && (count == Std::dynamic_extent || count <= size() - offset));
│ │ │ │ + │ │ │ │ +
389 data() + offset, count == Std::dynamic_extent ? size() - offset : count};
│ │ │ │ +
390 }
│ │ │ │ +
│ │ │ │ +
391
│ │ │ │ +
393
│ │ │ │ +
394
│ │ │ │ +
397
│ │ │ │ +
399 using base_type::size;
│ │ │ │ +
400
│ │ │ │ +
402 constexpr size_type size_bytes () const noexcept { return size() * sizeof(element_type); }
│ │ │ │ +
403
│ │ │ │ +
405 [[nodiscard]] constexpr bool empty () const noexcept { return size() == 0; }
│ │ │ │ +
406
│ │ │ │ +
408
│ │ │ │ +
409private:
│ │ │ │ +
410 pointer data_;
│ │ │ │ +
411};
│ │ │ │ +
│ │ │ │ +
412
│ │ │ │ +
413// deduction guide
│ │ │ │ +
414// @{
│ │ │ │ +
415
│ │ │ │ +
416template <class T, std::size_t N>
│ │ │ │ +
417span (T (&)[N])
│ │ │ │ +
418 -> span<T, N>;
│ │ │ │ +
419
│ │ │ │ +
420template <class ElementType, class I, std::size_t Extent,
│ │ │ │ +
421 std::enable_if_t<std::is_convertible_v<I,std::size_t>, int> = 0>
│ │ │ │ +
422span (ElementType*, std::integral_constant<I,Extent>)
│ │ │ │ + │ │ │ │ +
424
│ │ │ │ +
425template <class ElementType, class I,
│ │ │ │ +
426 std::enable_if_t<std::is_integral_v<I>, int> = 0,
│ │ │ │ +
427 std::enable_if_t<std::is_convertible_v<I,std::size_t>, int> = 0>
│ │ │ │ +
428span (ElementType*, I)
│ │ │ │ + │ │ │ │ +
430
│ │ │ │ +
431template <class Iter,
│ │ │ │ +
432 class Element = std::remove_reference_t<decltype(*std::declval<Iter>())>>
│ │ │ │ +
433span (Iter,Iter)
│ │ │ │ + │ │ │ │ +
435
│ │ │ │ +
436template <class Range,
│ │ │ │ +
437 class First = decltype(std::begin(std::declval<Range>())),
│ │ │ │ +
438 class Last = decltype(std::end(std::declval<Range>())),
│ │ │ │ +
439 class Element = std::remove_reference_t<decltype(*std::declval<First>())>>
│ │ │ │ +
440span (Range&)
│ │ │ │ + │ │ │ │ +
442
│ │ │ │ +
443template <class T, size_t N>
│ │ │ │ +
444span (std::array<T, N>&) -> span<T, N>;
│ │ │ │ +
445
│ │ │ │ +
446template <class T, size_t N>
│ │ │ │ +
447span (const std::array<T, N>&) -> span<const T, N>;
│ │ │ │ +
448
│ │ │ │ +
449// @}
│ │ │ │ +
450
│ │ │ │ +
451} // end namespace Dune::Std
│ │ │ │ +
452
│ │ │ │ +
453#endif // DUNE_COMMON_STD_SPAN_HH
│ │ │ │ + │ │ │ │ +
A few common exception classes.
│ │ │ │ +
static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from >, std::integral_constant< T, to >) noexcept
Definition rangeutilities.hh:312
│ │ │ │ +
STL namespace.
│ │ │ │ +
Namespace for features backported from new C++ standards.
Definition default_accessor.hh:10
│ │ │ │ +
constexpr auto to_address(T &&p) noexcept
Obtain the address represented by p without forming a reference to the object pointed to by p.
Definition memory.hh:47
│ │ │ │ +
constexpr std::size_t dynamic_extent
A constant of type std::size_t that is used to differentiate std::span of static and dynamic extent.
Definition span.hh:26
│ │ │ │ +
A contiguous sequence of elements with static or dynamic extent.
Definition span.hh:126
│ │ │ │ +
std::ptrdiff_t difference_type
Definition span.hh:135
│ │ │ │ +
const element_type & const_reference
Definition span.hh:138
│ │ │ │ +
constexpr reference front() const
Access the first element.
Definition span.hh:291
│ │ │ │ +
element_type & reference
Definition span.hh:137
│ │ │ │ +
constexpr span(const span &other) noexcept=default
Copy constructor.
│ │ │ │ +
pointer iterator
Definition span.hh:139
│ │ │ │ +
static constexpr size_type extent
Definition span.hh:150
│ │ │ │ +
constexpr iterator begin() const noexcept
Returns an iterator to the beginning.
Definition span.hh:261
│ │ │ │ +
constexpr const_iterator cbegin() const noexcept
Returns an iterator to the beginning.
Definition span.hh:267
│ │ │ │ +
constexpr span(std::array< T, N > &arr) noexcept
Constructs a span that is a view over the array.
Definition span.hh:211
│ │ │ │ +
std::reverse_iterator< iterator > reverse_iterator
Definition span.hh:140
│ │ │ │ +
constexpr iterator end() const noexcept
Returns an iterator to the end.
Definition span.hh:264
│ │ │ │ +
constexpr span< element_type, Std::dynamic_extent > subspan(size_type offset, size_type count=Std::dynamic_extent) const
Obtains a subspan consisting of count elements of the sequence starting at offset.
Definition span.hh:385
│ │ │ │ +
constexpr span & operator=(const span &other) noexcept=default
Copy assignment operator.
│ │ │ │ +
std::size_t size_type
Definition span.hh:134
│ │ │ │ +
element_type * pointer
Definition span.hh:136
│ │ │ │ +
constexpr reference at(size_type i) const
Access specified element with bounds checking.
Definition span.hh:305
│ │ │ │ +
std::remove_cv_t< element_type > value_type
Definition span.hh:133
│ │ │ │ +
constexpr span< element_type, Std::dynamic_extent > first(size_type count) const
Obtains a subspan consisting of the first count elements of the sequence.
Definition span.hh:367
│ │ │ │ +
constexpr span< element_type, subspan_extent(Offset, Count)> subspan() const
Obtains a subspan consisting of Count elements of the sequence starting at Offset.
Definition span.hh:358
│ │ │ │ +
const iterator const_iterator
Definition span.hh:145
│ │ │ │ +
constexpr const_reverse_iterator crend() const noexcept
Returns a reverse iterator ending at the beginning.
Definition span.hh:282
│ │ │ │ +
constexpr reverse_iterator rend() const noexcept
Returns a reverse iterator ending at the beginning.
Definition span.hh:276
│ │ │ │ +
constexpr pointer data() const noexcept
Direct access to the underlying contiguous storage.
Definition span.hh:316
│ │ │ │ +
constexpr size_type size_bytes() const noexcept
Returns the size of the sequence in bytes.
Definition span.hh:402
│ │ │ │ +
constexpr const_reverse_iterator crbegin() const noexcept
Returns a reverse iterator starting at the end.
Definition span.hh:279
│ │ │ │ +
Element element_type
Definition span.hh:132
│ │ │ │ +
constexpr bool empty() const noexcept
Checks if the sequence is empty.
Definition span.hh:405
│ │ │ │ +
constexpr span< element_type, Count > last() const
Obtains a subspan consisting of the last Count elements of the sequence.
Definition span.hh:335
│ │ │ │ +
constexpr span(Range &range)
Constructs a span that is a view over the range [range.begin(), range.end())
Definition span.hh:195
│ │ │ │ +
constexpr reverse_iterator rbegin() const noexcept
Returns a reverse iterator starting at the end.
Definition span.hh:273
│ │ │ │ +
constexpr span< element_type, Std::dynamic_extent > last(size_type count) const
Obtains a subspan consisting of the last count elements of the sequence.
Definition span.hh:374
│ │ │ │ +
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition span.hh:146
│ │ │ │ +
constexpr const_iterator cend() const noexcept
Returns an iterator to the end.
Definition span.hh:270
│ │ │ │ +
constexpr span< element_type, Count > first() const
Obtains a subspan consisting of the first Count elements of the sequence.
Definition span.hh:326
│ │ │ │ +
constexpr reference back() const
Access the last element.
Definition span.hh:298
│ │ │ │ +
constexpr span(const std::array< T, N > &arr) noexcept
Constructs a span that is a view over the const array.
Definition span.hh:220
│ │ │ │ +
constexpr reference operator[](size_type i) const
Access specified element.
Definition span.hh:313
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,116 +1,563 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -parametertreeparser.hh │ │ │ │ │ + * std │ │ │ │ │ +span.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_PARAMETER_PARSER_HH │ │ │ │ │ -6#define DUNE_PARAMETER_PARSER_HH │ │ │ │ │ +5#ifndef DUNE_COMMON_STD_SPAN_HH │ │ │ │ │ +6#define DUNE_COMMON_STD_SPAN_HH │ │ │ │ │ 7 │ │ │ │ │ -12#include │ │ │ │ │ -13#include │ │ │ │ │ -14#include │ │ │ │ │ -15 │ │ │ │ │ -16#include │ │ │ │ │ -17#include │ │ │ │ │ -18 │ │ │ │ │ -19namespace Dune { │ │ │ │ │ -20 │ │ │ │ │ -22 class ParameterTreeParserError : public RangeError {}; │ │ │ │ │ -28 class HelpRequest : public Exception {}; │ │ │ │ │ +8#include │ │ │ │ │ +9#include │ │ │ │ │ +10#include │ │ │ │ │ +11#include │ │ │ │ │ +12#include │ │ │ │ │ +13#include │ │ │ │ │ +14#include │ │ │ │ │ +15#include │ │ │ │ │ +16#if __has_include() │ │ │ │ │ +17 #include │ │ │ │ │ +18#endif │ │ │ │ │ +19 │ │ │ │ │ +20#include │ │ │ │ │ +21#include │ │ │ │ │ +22 │ │ │ │ │ +23namespace Dune::Std { │ │ │ │ │ +24 │ │ │ │ │ +26inline constexpr std::size_t dynamic_extent = std::numeric_limits::max(); │ │ │ │ │ +27 │ │ │ │ │ +28namespace Impl { │ │ │ │ │ 29 │ │ │ │ │ -34 class ParameterTreeParser │ │ │ │ │ -35 { │ │ │ │ │ -36 │ │ │ │ │ -37 static std::string ltrim(const std::string& s); │ │ │ │ │ -38 static std::string rtrim(const std::string& s); │ │ │ │ │ -39 │ │ │ │ │ -40 public: │ │ │ │ │ -41 │ │ │ │ │ -85 │ │ │ │ │ -96 static void readINITree(std::istream& in, ParameterTree& pt, │ │ │ │ │ -97 bool overwrite); │ │ │ │ │ -98 │ │ │ │ │ -105 static Dune::ParameterTree readINITree(std::istream& in); │ │ │ │ │ -106 │ │ │ │ │ -107 │ │ │ │ │ -120 static void readINITree(std::istream& in, ParameterTree& pt, │ │ │ │ │ -121 const std::string srcname = "stream", │ │ │ │ │ -122 bool overwrite = true); │ │ │ │ │ -123 │ │ │ │ │ -124 │ │ │ │ │ -135 static void readINITree(std::string file, ParameterTree& pt, bool overwrite │ │ │ │ │ -= true); │ │ │ │ │ -136 │ │ │ │ │ -143 static Dune::ParameterTree readINITree(const std::string& file); │ │ │ │ │ -144 │ │ │ │ │ -146 │ │ │ │ │ -158 static void readOptions(int argc, char* argv [], ParameterTree& pt); │ │ │ │ │ -159 │ │ │ │ │ -177 static void readNamedOptions(int argc, char* argv[], │ │ │ │ │ -178 ParameterTree& pt, │ │ │ │ │ -179 std::vector keywords, │ │ │ │ │ -180 unsigned int required = std::numeric_limits::max(), │ │ │ │ │ -181 bool allow_more = true, │ │ │ │ │ -182 bool overwrite = true, │ │ │ │ │ -183 std::vector help = std::vector()); │ │ │ │ │ -184 │ │ │ │ │ -185 private: │ │ │ │ │ -186 static std::string generateHelpString(std::string progname, std:: │ │ │ │ │ -vector keywords, unsigned int required, std::vector │ │ │ │ │ -help); │ │ │ │ │ -187 }; │ │ │ │ │ -188 │ │ │ │ │ -189} // end namespace Dune │ │ │ │ │ -190 │ │ │ │ │ -191#endif // DUNE_PARAMETER_PARSER_HH │ │ │ │ │ +30template │ │ │ │ │ +31class SpanSize │ │ │ │ │ +32{ │ │ │ │ │ +33public: │ │ │ │ │ +34 using size_type = std::size_t; │ │ │ │ │ +35 │ │ │ │ │ +36public: │ │ │ │ │ +37 constexpr SpanSize () = default; │ │ │ │ │ +38 │ │ │ │ │ +39 constexpr SpanSize ([[maybe_unused]] size_type size) noexcept │ │ │ │ │ +40 { │ │ │ │ │ +41 assert(Extent == Std::dynamic_extent || Extent == size); │ │ │ │ │ +42 } │ │ │ │ │ +43 │ │ │ │ │ +44 template │ │ │ │ │ +45 constexpr SpanSize ([[maybe_unused]] Iter first, [[maybe_unused]] Iter last) │ │ │ │ │ +noexcept │ │ │ │ │ +46 { │ │ │ │ │ +47 assert((std::distance(first,last) == Extent)); │ │ │ │ │ +48 } │ │ │ │ │ +49 │ │ │ │ │ +50 constexpr size_type size () const noexcept { return Extent; } │ │ │ │ │ +51}; │ │ │ │ │ +52 │ │ │ │ │ +53template <> │ │ │ │ │ +54class SpanSize │ │ │ │ │ +55{ │ │ │ │ │ +56public: │ │ │ │ │ +57 using size_type = std::size_t; │ │ │ │ │ +58 │ │ │ │ │ +59public: │ │ │ │ │ +60 constexpr SpanSize (size_type size = 0) noexcept │ │ │ │ │ +61 : size_(size) │ │ │ │ │ +62 {} │ │ │ │ │ +63 │ │ │ │ │ +64 template │ │ │ │ │ +65 constexpr SpanSize (Iter first, Iter last) noexcept │ │ │ │ │ +66 : size_(std::distance(first,last)) │ │ │ │ │ +67 {} │ │ │ │ │ +68 │ │ │ │ │ +69 constexpr size_type size () const noexcept { return size_; } │ │ │ │ │ +70 │ │ │ │ │ +71private: │ │ │ │ │ +72 size_type size_; │ │ │ │ │ +73}; │ │ │ │ │ +74 │ │ │ │ │ +75template │ │ │ │ │ +76struct TypeIdentity { using type = T; }; │ │ │ │ │ +77 │ │ │ │ │ +78template │ │ │ │ │ +79using TypeIdentity_t = typename TypeIdentity::type; │ │ │ │ │ +80 │ │ │ │ │ +81} // end namespace Impl │ │ │ │ │ +82 │ │ │ │ │ +83 │ │ │ │ │ +123template │ │ │ │ │ +124class span │ │ │ │ │ +125 : public Impl::SpanSize │ │ │ │ │ +126{ │ │ │ │ │ +127 using base_type = Impl::SpanSize; // base_type implements the │ │ │ │ │ +member variable size() │ │ │ │ │ +128 │ │ │ │ │ +129 static_assert(std::is_object_v && !std::is_abstract_v); │ │ │ │ │ +130 │ │ │ │ │ +131public: │ │ │ │ │ +132 using element_type = Element; │ │ │ │ │ +133 using value_type = std::remove_cv_t; │ │ │ │ │ +134 using size_type = std::size_t; │ │ │ │ │ +135 using difference_type = std::ptrdiff_t; │ │ │ │ │ +136 using pointer = element_type*; │ │ │ │ │ +137 using reference = element_type&; │ │ │ │ │ +138 using const_reference = const element_type&; │ │ │ │ │ +139 using iterator = pointer; │ │ │ │ │ +140 using reverse_iterator = std::reverse_iterator; │ │ │ │ │ +141#if __cpp_lib_ranges_as_const >202311L │ │ │ │ │ +142 using const_iterator = std::const_iterator; │ │ │ │ │ +143 using const_reverse_iterator = std::const_iterator; │ │ │ │ │ +144#else │ │ │ │ │ +145 using const_iterator = const iterator; │ │ │ │ │ +146 using const_reverse_iterator = std::reverse_iterator; │ │ │ │ │ +147#endif │ │ │ │ │ +148 │ │ │ │ │ +149 │ │ │ │ │ +150 static constexpr size_type extent = Extent; │ │ │ │ │ +151 │ │ │ │ │ +152public: │ │ │ │ │ +155 │ │ │ │ │ +157 template = 0> │ │ │ │ │ +159 constexpr span () noexcept │ │ │ │ │ +160 : base_type{} │ │ │ │ │ +161 , data_{} │ │ │ │ │ +162 {} │ │ │ │ │ +163 │ │ │ │ │ +165 template ())>, │ │ │ │ │ +167 std::enable_if_t, int> = │ │ │ │ │ +0> │ │ │ │ │ +168 #if __cpp_conditional_explicit >= 201806L │ │ │ │ │ +169 explicit(extent != Std::dynamic_extent) │ │ │ │ │ +170 #endif │ │ │ │ │ +171 constexpr span (Iter first, size_type size) │ │ │ │ │ +172 : base_type(size) │ │ │ │ │ +173 , data_(Std::to_address(first)) │ │ │ │ │ +174 {} │ │ │ │ │ +175 │ │ │ │ │ +177 template ())>, │ │ │ │ │ +179 std::enable_if_t, int> = │ │ │ │ │ +0> │ │ │ │ │ +180 #if __cpp_conditional_explicit >= 201806L │ │ │ │ │ +181 explicit(extent != Std::dynamic_extent) │ │ │ │ │ +182 #endif │ │ │ │ │ +183 constexpr span (Iter first, Iter last) │ │ │ │ │ +184 : base_type(first,last) │ │ │ │ │ +185 , data_(Std::to_address(first)) │ │ │ │ │ +186 {} │ │ │ │ │ +187 │ │ │ │ │ +189 template ()), std::end(std::declval │ │ │ │ │ +()), bool{}) = true, │ │ │ │ │ +191 std::enable_if_t, int> = 0> │ │ │ │ │ +192 #if __cpp_conditional_explicit >= 201806L │ │ │ │ │ +193 explicit(extent != Std::dynamic_extent) │ │ │ │ │ +194 #endif │ │ │ │ │ +195 constexpr span (Range& range) │ │ │ │ │ +196 : span(std::begin(range), std::end(range)) │ │ │ │ │ +197 {} │ │ │ │ │ +198 │ │ │ │ │ +200 template = 0> │ │ │ │ │ +202 constexpr span (Impl::TypeIdentity_t (&data)[N]) noexcept │ │ │ │ │ +203 : base_type(N) │ │ │ │ │ +204 , data_(data) │ │ │ │ │ +205 {} │ │ │ │ │ +206 │ │ │ │ │ +208 template = 0, │ │ │ │ │ +210 std::enable_if_t, int> = │ │ │ │ │ +0> │ │ │ │ │ +211 constexpr span (std::array& arr) noexcept │ │ │ │ │ +212 : base_type(N) │ │ │ │ │ +213 , data_(arr.data()) │ │ │ │ │ +214 {} │ │ │ │ │ +215 │ │ │ │ │ +217 template = 0, │ │ │ │ │ +219 std::enable_if_t, │ │ │ │ │ +int> = 0> │ │ │ │ │ +220 constexpr span (const std::array& arr) noexcept │ │ │ │ │ +221 : base_type(N) │ │ │ │ │ +222 , data_(arr.data()) │ │ │ │ │ +223 {} │ │ │ │ │ +224 │ │ │ │ │ +226 template , int> = 0> │ │ │ │ │ +228 #if __cpp_conditional_explicit >= 201806L │ │ │ │ │ +229 explicit(extent != Std::dynamic_extent) │ │ │ │ │ +230 #endif │ │ │ │ │ +231 constexpr span (std::initializer_list il) │ │ │ │ │ +232 : base_type(il.size()) │ │ │ │ │ +233 , data_(il.begin()) │ │ │ │ │ +234 {} │ │ │ │ │ +235 │ │ │ │ │ +237 constexpr span (const span& other) noexcept = default; │ │ │ │ │ +238 │ │ │ │ │ +240 template = 0, │ │ │ │ │ +242 std::enable_if_t, int> = 0> │ │ │ │ │ +243 #if __cpp_conditional_explicit >= 201806L │ │ │ │ │ +244 explicit(extent != Std::dynamic_extent && OtherExtent == Std::dynamic_ │ │ │ │ │ +extent) │ │ │ │ │ +245 #endif │ │ │ │ │ +246 constexpr span (const span& s) noexcept │ │ │ │ │ +247 : base_type(s.size()) │ │ │ │ │ +248 , data_(s.data()) │ │ │ │ │ +249 {} │ │ │ │ │ +250 │ │ │ │ │ +252 constexpr span& operator=_(const span& other) noexcept = default; │ │ │ │ │ +253 │ │ │ │ │ +255 │ │ │ │ │ +256 │ │ │ │ │ +259 │ │ │ │ │ +261 constexpr iterator begin () const noexcept { return data_; } │ │ │ │ │ +262 │ │ │ │ │ +264 constexpr iterator end () const noexcept { return data_ + size(); } │ │ │ │ │ +265 │ │ │ │ │ +267 constexpr const_iterator cbegin () const noexcept { return data_; } │ │ │ │ │ +268 │ │ │ │ │ +270 constexpr const_iterator cend () const noexcept { return data_ + size(); } │ │ │ │ │ +271 │ │ │ │ │ +273 constexpr reverse_iterator rbegin() const noexcept { return reverse_ │ │ │ │ │ +iterator{end()}; } │ │ │ │ │ +274 │ │ │ │ │ +276 constexpr reverse_iterator rend() const noexcept { return reverse_iterator │ │ │ │ │ +{begin()}; } │ │ │ │ │ +277 │ │ │ │ │ +279 constexpr const_reverse_iterator crbegin() const noexcept { return reverse_ │ │ │ │ │ +iterator{end()}; } │ │ │ │ │ +280 │ │ │ │ │ +282 constexpr const_reverse_iterator crend() const noexcept { return reverse_ │ │ │ │ │ +iterator{begin()}; } │ │ │ │ │ +283 │ │ │ │ │ +285 │ │ │ │ │ +286 │ │ │ │ │ +289 │ │ │ │ │ +291 constexpr reference front () const │ │ │ │ │ +292 { │ │ │ │ │ +293 assert(not empty() && "front of empty span does not exist"); │ │ │ │ │ +294 return data_[0]; │ │ │ │ │ +295 } │ │ │ │ │ +296 │ │ │ │ │ +298 constexpr reference back () const │ │ │ │ │ +299 { │ │ │ │ │ +300 assert(not empty() && "front of empty span does not exist"); │ │ │ │ │ +301 return data_[size()-1]; │ │ │ │ │ +302 } │ │ │ │ │ +303 │ │ │ │ │ +305 constexpr reference at (size_type i) const │ │ │ │ │ +306 { │ │ │ │ │ +307 if (i >= size()) │ │ │ │ │ +308 throw std::out_of_range("Index " + std::to_string(i) + " out of range."); │ │ │ │ │ +309 return data_[i]; │ │ │ │ │ +310 } │ │ │ │ │ +311 │ │ │ │ │ +313 constexpr reference operator[]_(size_type i) const { return data_[i]; } │ │ │ │ │ +314 │ │ │ │ │ +316 constexpr pointer data () const noexcept { return data_; } │ │ │ │ │ +317 │ │ │ │ │ +319 │ │ │ │ │ +320 │ │ │ │ │ +323 │ │ │ │ │ +325 template │ │ │ │ │ +326 constexpr span first () const │ │ │ │ │ +327 { │ │ │ │ │ +328 static_assert(Count <= Extent); │ │ │ │ │ +329 assert(Count <= size()); │ │ │ │ │ +330 return span{data(), Count}; │ │ │ │ │ +331 } │ │ │ │ │ +332 │ │ │ │ │ +334 template │ │ │ │ │ +335 constexpr span last () const │ │ │ │ │ +336 { │ │ │ │ │ +337 static_assert(Count <= Extent); │ │ │ │ │ +338 assert(Count <= size()); │ │ │ │ │ +339 return span{data()+ (size() - Count), Count}; │ │ │ │ │ +340 } │ │ │ │ │ +341 │ │ │ │ │ +342private: │ │ │ │ │ +343 │ │ │ │ │ +344 static constexpr std::size_t subspan_extent (std::size_t O, std::size_t C) │ │ │ │ │ +noexcept │ │ │ │ │ +345 { │ │ │ │ │ +346 return (C != Std::dynamic_extent) ? C : │ │ │ │ │ +347 (Extent != Std::dynamic_extent) ? Extent - O : Std::dynamic_extent; │ │ │ │ │ +348 } │ │ │ │ │ +349 │ │ │ │ │ +350public: │ │ │ │ │ +351 │ │ │ │ │ +353 │ │ │ │ │ +357 template │ │ │ │ │ +358 constexpr span subspan () const │ │ │ │ │ +359 { │ │ │ │ │ +360 static_assert(Offset <= Extent && (Count == Std::dynamic_extent || Count <= │ │ │ │ │ +Extent - Offset)); │ │ │ │ │ +361 assert(Offset <= size() && (Count == Std::dynamic_extent || Count <= size() │ │ │ │ │ +- Offset)); │ │ │ │ │ +362 return span{ │ │ │ │ │ +363 data() + Offset, Count != Std::dynamic_extent ? Count : size() - Offset}; │ │ │ │ │ +364 } │ │ │ │ │ +365 │ │ │ │ │ +367 constexpr span first (size_type count) │ │ │ │ │ +const │ │ │ │ │ +368 { │ │ │ │ │ +369 assert(count <= size()); │ │ │ │ │ +370 return span{data(), count}; │ │ │ │ │ +371 } │ │ │ │ │ +372 │ │ │ │ │ +374 constexpr span last (size_type count) │ │ │ │ │ +const │ │ │ │ │ +375 { │ │ │ │ │ +376 assert(count <= size()); │ │ │ │ │ +377 return span{data()+ (size() - count), │ │ │ │ │ +count}; │ │ │ │ │ +378 } │ │ │ │ │ +379 │ │ │ │ │ +381 │ │ │ │ │ +385 constexpr span subspan (size_type │ │ │ │ │ +offset, size_type count = Std::dynamic_extent) const │ │ │ │ │ +386 { │ │ │ │ │ +387 assert(offset <= size() && (count == Std::dynamic_extent || count <= size() │ │ │ │ │ +- offset)); │ │ │ │ │ +388 return span{ │ │ │ │ │ +389 data() + offset, count == Std::dynamic_extent ? size() - offset : count}; │ │ │ │ │ +390 } │ │ │ │ │ +391 │ │ │ │ │ +393 │ │ │ │ │ +394 │ │ │ │ │ +397 │ │ │ │ │ +399 using base_type::size; │ │ │ │ │ +400 │ │ │ │ │ +402 constexpr size_type size_bytes () const noexcept { return size() * sizeof │ │ │ │ │ +(element_type); } │ │ │ │ │ +403 │ │ │ │ │ +405 [[nodiscard]] constexpr bool empty () const noexcept { return size() == 0; │ │ │ │ │ +} │ │ │ │ │ +406 │ │ │ │ │ +408 │ │ │ │ │ +409private: │ │ │ │ │ +410 pointer data_; │ │ │ │ │ +411}; │ │ │ │ │ +412 │ │ │ │ │ +413// deduction guide │ │ │ │ │ +414// @{ │ │ │ │ │ +415 │ │ │ │ │ +416template │ │ │ │ │ +417span (T (&)[N]) │ │ │ │ │ +418 -> span; │ │ │ │ │ +419 │ │ │ │ │ +420template , int> = 0> │ │ │ │ │ +422span (ElementType*, std::integral_constant) │ │ │ │ │ +423 -> span; │ │ │ │ │ +424 │ │ │ │ │ +425template , int> = 0, │ │ │ │ │ +427 std::enable_if_t, int> = 0> │ │ │ │ │ +428span (ElementType*, I) │ │ │ │ │ +429 -> span; │ │ │ │ │ +430 │ │ │ │ │ +431template ())>> │ │ │ │ │ +433span (Iter,Iter) │ │ │ │ │ +434 -> span; │ │ │ │ │ +435 │ │ │ │ │ +436template ())), │ │ │ │ │ +438 class Last = decltype(std::end(std::declval())), │ │ │ │ │ +439 class Element = std::remove_reference_t())>> │ │ │ │ │ +440span (Range&) │ │ │ │ │ +441 -> span; │ │ │ │ │ +442 │ │ │ │ │ +443template │ │ │ │ │ +444span (std::array&) -> span; │ │ │ │ │ +445 │ │ │ │ │ +446template │ │ │ │ │ +447span (const std::array&) -> span; │ │ │ │ │ +448 │ │ │ │ │ +449// @} │ │ │ │ │ +450 │ │ │ │ │ +451} // end namespace Dune::Std │ │ │ │ │ +452 │ │ │ │ │ +453#endif // DUNE_COMMON_STD_SPAN_HH │ │ │ │ │ +memory.hh │ │ │ │ │ exceptions.hh │ │ │ │ │ A few common exception classes. │ │ │ │ │ -parametertree.hh │ │ │ │ │ -A hierarchical structure of string parameters. │ │ │ │ │ -Dune │ │ │ │ │ -Dune namespace. │ │ │ │ │ -Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::Exception │ │ │ │ │ -Base class for Dune-Exceptions. │ │ │ │ │ -Definition exceptions.hh:96 │ │ │ │ │ -Dune::RangeError │ │ │ │ │ -Default exception class for range errors. │ │ │ │ │ -Definition exceptions.hh:254 │ │ │ │ │ -Dune::ParameterTree │ │ │ │ │ -Hierarchical structure of string parameters. │ │ │ │ │ -Definition parametertree.hh:37 │ │ │ │ │ -Dune::ParameterTreeParserError │ │ │ │ │ -report parser error while reading ParameterTree │ │ │ │ │ -Definition parametertreeparser.hh:22 │ │ │ │ │ -Dune::HelpRequest │ │ │ │ │ -exception thrown if the user wants to see help string │ │ │ │ │ -Definition parametertreeparser.hh:28 │ │ │ │ │ -Dune::ParameterTreeParser │ │ │ │ │ -Parsers to set up a ParameterTree from various input sources. │ │ │ │ │ -Definition parametertreeparser.hh:35 │ │ │ │ │ -Dune::ParameterTreeParser::readOptions │ │ │ │ │ -static void readOptions(int argc, char *argv[], ParameterTree &pt) │ │ │ │ │ -parse command line options and build hierarchical ParameterTree structure │ │ │ │ │ -Definition parametertreeparser.cc:155 │ │ │ │ │ -Dune::ParameterTreeParser::readINITree │ │ │ │ │ -static void readINITree(std::istream &in, ParameterTree &pt, bool overwrite) │ │ │ │ │ -parse C++ stream │ │ │ │ │ -Definition parametertreeparser.cc:70 │ │ │ │ │ -Dune::ParameterTreeParser::readNamedOptions │ │ │ │ │ -static void readNamedOptions(int argc, char *argv[], ParameterTree &pt, std:: │ │ │ │ │ -vector< std::string > keywords, unsigned int required=std::numeric_limits< │ │ │ │ │ -unsigned int >::max(), bool allow_more=true, bool overwrite=true, std::vector< │ │ │ │ │ -std::string > help=std::vector< std::string >()) │ │ │ │ │ -read [named] command line options and build hierarchical ParameterTree │ │ │ │ │ -structure │ │ │ │ │ -Definition parametertreeparser.cc:171 │ │ │ │ │ +Dune::range │ │ │ │ │ +static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from │ │ │ │ │ +>, std::integral_constant< T, to >) noexcept │ │ │ │ │ +Definition rangeutilities.hh:312 │ │ │ │ │ +std │ │ │ │ │ +STL namespace. │ │ │ │ │ +Dune::Std │ │ │ │ │ +Namespace for features backported from new C++ standards. │ │ │ │ │ +Definition default_accessor.hh:10 │ │ │ │ │ +Dune::Std::to_address │ │ │ │ │ +constexpr auto to_address(T &&p) noexcept │ │ │ │ │ +Obtain the address represented by p without forming a reference to the object │ │ │ │ │ +pointed to by p. │ │ │ │ │ +Definition memory.hh:47 │ │ │ │ │ +Dune::Std::dynamic_extent │ │ │ │ │ +constexpr std::size_t dynamic_extent │ │ │ │ │ +A constant of type std::size_t that is used to differentiate std::span of │ │ │ │ │ +static and dynamic extent. │ │ │ │ │ +Definition span.hh:26 │ │ │ │ │ +Dune::Std::span │ │ │ │ │ +A contiguous sequence of elements with static or dynamic extent. │ │ │ │ │ +Definition span.hh:126 │ │ │ │ │ +Dune::Std::span::difference_type │ │ │ │ │ +std::ptrdiff_t difference_type │ │ │ │ │ +Definition span.hh:135 │ │ │ │ │ +Dune::Std::span::const_reference │ │ │ │ │ +const element_type & const_reference │ │ │ │ │ +Definition span.hh:138 │ │ │ │ │ +Dune::Std::span::front │ │ │ │ │ +constexpr reference front() const │ │ │ │ │ +Access the first element. │ │ │ │ │ +Definition span.hh:291 │ │ │ │ │ +Dune::Std::span::reference │ │ │ │ │ +element_type & reference │ │ │ │ │ +Definition span.hh:137 │ │ │ │ │ +Dune::Std::span::span │ │ │ │ │ +constexpr span(const span &other) noexcept=default │ │ │ │ │ +Copy constructor. │ │ │ │ │ +Dune::Std::span::iterator │ │ │ │ │ +pointer iterator │ │ │ │ │ +Definition span.hh:139 │ │ │ │ │ +Dune::Std::span::extent │ │ │ │ │ +static constexpr size_type extent │ │ │ │ │ +Definition span.hh:150 │ │ │ │ │ +Dune::Std::span::begin │ │ │ │ │ +constexpr iterator begin() const noexcept │ │ │ │ │ +Returns an iterator to the beginning. │ │ │ │ │ +Definition span.hh:261 │ │ │ │ │ +Dune::Std::span::cbegin │ │ │ │ │ +constexpr const_iterator cbegin() const noexcept │ │ │ │ │ +Returns an iterator to the beginning. │ │ │ │ │ +Definition span.hh:267 │ │ │ │ │ +Dune::Std::span::span │ │ │ │ │ +constexpr span(std::array< T, N > &arr) noexcept │ │ │ │ │ +Constructs a span that is a view over the array. │ │ │ │ │ +Definition span.hh:211 │ │ │ │ │ +Dune::Std::span::reverse_iterator │ │ │ │ │ +std::reverse_iterator< iterator > reverse_iterator │ │ │ │ │ +Definition span.hh:140 │ │ │ │ │ +Dune::Std::span::end │ │ │ │ │ +constexpr iterator end() const noexcept │ │ │ │ │ +Returns an iterator to the end. │ │ │ │ │ +Definition span.hh:264 │ │ │ │ │ +Dune::Std::span::subspan │ │ │ │ │ +constexpr span< element_type, Std::dynamic_extent > subspan(size_type offset, │ │ │ │ │ +size_type count=Std::dynamic_extent) const │ │ │ │ │ +Obtains a subspan consisting of count elements of the sequence starting at │ │ │ │ │ +offset. │ │ │ │ │ +Definition span.hh:385 │ │ │ │ │ +Dune::Std::span::operator= │ │ │ │ │ +constexpr span & operator=(const span &other) noexcept=default │ │ │ │ │ +Copy assignment operator. │ │ │ │ │ +Dune::Std::span::size_type │ │ │ │ │ +std::size_t size_type │ │ │ │ │ +Definition span.hh:134 │ │ │ │ │ +Dune::Std::span::pointer │ │ │ │ │ +element_type * pointer │ │ │ │ │ +Definition span.hh:136 │ │ │ │ │ +Dune::Std::span::at │ │ │ │ │ +constexpr reference at(size_type i) const │ │ │ │ │ +Access specified element with bounds checking. │ │ │ │ │ +Definition span.hh:305 │ │ │ │ │ +Dune::Std::span::value_type │ │ │ │ │ +std::remove_cv_t< element_type > value_type │ │ │ │ │ +Definition span.hh:133 │ │ │ │ │ +Dune::Std::span::first │ │ │ │ │ +constexpr span< element_type, Std::dynamic_extent > first(size_type count) │ │ │ │ │ +const │ │ │ │ │ +Obtains a subspan consisting of the first count elements of the sequence. │ │ │ │ │ +Definition span.hh:367 │ │ │ │ │ +Dune::Std::span::subspan │ │ │ │ │ +constexpr span< element_type, subspan_extent(Offset, Count)> subspan() const │ │ │ │ │ +Obtains a subspan consisting of Count elements of the sequence starting at │ │ │ │ │ +Offset. │ │ │ │ │ +Definition span.hh:358 │ │ │ │ │ +Dune::Std::span::const_iterator │ │ │ │ │ +const iterator const_iterator │ │ │ │ │ +Definition span.hh:145 │ │ │ │ │ +Dune::Std::span::crend │ │ │ │ │ +constexpr const_reverse_iterator crend() const noexcept │ │ │ │ │ +Returns a reverse iterator ending at the beginning. │ │ │ │ │ +Definition span.hh:282 │ │ │ │ │ +Dune::Std::span::rend │ │ │ │ │ +constexpr reverse_iterator rend() const noexcept │ │ │ │ │ +Returns a reverse iterator ending at the beginning. │ │ │ │ │ +Definition span.hh:276 │ │ │ │ │ +Dune::Std::span::data │ │ │ │ │ +constexpr pointer data() const noexcept │ │ │ │ │ +Direct access to the underlying contiguous storage. │ │ │ │ │ +Definition span.hh:316 │ │ │ │ │ +Dune::Std::span::size_bytes │ │ │ │ │ +constexpr size_type size_bytes() const noexcept │ │ │ │ │ +Returns the size of the sequence in bytes. │ │ │ │ │ +Definition span.hh:402 │ │ │ │ │ +Dune::Std::span::crbegin │ │ │ │ │ +constexpr const_reverse_iterator crbegin() const noexcept │ │ │ │ │ +Returns a reverse iterator starting at the end. │ │ │ │ │ +Definition span.hh:279 │ │ │ │ │ +Dune::Std::span::element_type │ │ │ │ │ +Element element_type │ │ │ │ │ +Definition span.hh:132 │ │ │ │ │ +Dune::Std::span::empty │ │ │ │ │ +constexpr bool empty() const noexcept │ │ │ │ │ +Checks if the sequence is empty. │ │ │ │ │ +Definition span.hh:405 │ │ │ │ │ +Dune::Std::span::last │ │ │ │ │ +constexpr span< element_type, Count > last() const │ │ │ │ │ +Obtains a subspan consisting of the last Count elements of the sequence. │ │ │ │ │ +Definition span.hh:335 │ │ │ │ │ +Dune::Std::span::span │ │ │ │ │ +constexpr span(Range &range) │ │ │ │ │ +Constructs a span that is a view over the range [range.begin(), range.end()) │ │ │ │ │ +Definition span.hh:195 │ │ │ │ │ +Dune::Std::span::rbegin │ │ │ │ │ +constexpr reverse_iterator rbegin() const noexcept │ │ │ │ │ +Returns a reverse iterator starting at the end. │ │ │ │ │ +Definition span.hh:273 │ │ │ │ │ +Dune::Std::span::last │ │ │ │ │ +constexpr span< element_type, Std::dynamic_extent > last(size_type count) const │ │ │ │ │ +Obtains a subspan consisting of the last count elements of the sequence. │ │ │ │ │ +Definition span.hh:374 │ │ │ │ │ +Dune::Std::span::const_reverse_iterator │ │ │ │ │ +std::reverse_iterator< const_iterator > const_reverse_iterator │ │ │ │ │ +Definition span.hh:146 │ │ │ │ │ +Dune::Std::span::cend │ │ │ │ │ +constexpr const_iterator cend() const noexcept │ │ │ │ │ +Returns an iterator to the end. │ │ │ │ │ +Definition span.hh:270 │ │ │ │ │ +Dune::Std::span::first │ │ │ │ │ +constexpr span< element_type, Count > first() const │ │ │ │ │ +Obtains a subspan consisting of the first Count elements of the sequence. │ │ │ │ │ +Definition span.hh:326 │ │ │ │ │ +Dune::Std::span::back │ │ │ │ │ +constexpr reference back() const │ │ │ │ │ +Access the last element. │ │ │ │ │ +Definition span.hh:298 │ │ │ │ │ +Dune::Std::span::span │ │ │ │ │ +constexpr span(const std::array< T, N > &arr) noexcept │ │ │ │ │ +Constructs a span that is a view over the const array. │ │ │ │ │ +Definition span.hh:220 │ │ │ │ │ +Dune::Std::span::operator[] │ │ │ │ │ +constexpr reference operator[](size_type i) const │ │ │ │ │ +Access specified element. │ │ │ │ │ +Definition span.hh:313 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00050.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: copyableoptional.hh File Reference │ │ │ │ +dune-common: mdarray.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,44 +65,54 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ Namespaces
│ │ │ │ -
copyableoptional.hh File Reference
│ │ │ │ +
mdarray.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ -
#include <cassert>
│ │ │ │ -#include <iostream>
│ │ │ │ +
#include <algorithm>
│ │ │ │ +#include <array>
│ │ │ │ #include <memory>
│ │ │ │ -#include <optional>
│ │ │ │ +#include <vector>
│ │ │ │ +#include <tuple>
│ │ │ │ #include <type_traits>
│ │ │ │ -#include <dune/common/typeutilities.hh>
│ │ │ │ +#include <dune/common/indices.hh>
│ │ │ │ +#include <dune/common/rangeutilities.hh>
│ │ │ │ +#include <dune/common/std/default_accessor.hh>
│ │ │ │ +#include <dune/common/std/mdspan.hh>
│ │ │ │ +#include <dune/common/std/memory.hh>
│ │ │ │ +#include <dune/common/std/span.hh>
│ │ │ │ +#include <dune/common/std/impl/containerconstructiontraits.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::CopyableOptional< Type >
 A copyable type wrapper that provides copy/move assignment operations for types that are only copy/move constructible. More...
class  Dune::Std::mdarray< Element, Extents, LayoutPolicy, Container >
 An owning multi-dimensional array analog of mdspan. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::Std
 Namespace for features backported from new C++ standards.
 
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,26 +1,36 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ + * std │ │ │ │ │ Classes | Namespaces │ │ │ │ │ -copyableoptional.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +mdarray.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class   Dune::CopyableOptional<_Type_> │ │ │ │ │ -  A copyable type wrapper that provides copy/move assignment operations │ │ │ │ │ - for types that are only copy/move constructible. More... │ │ │ │ │ +class   Dune::Std::mdarray<_Element,_Extents,_LayoutPolicy,_Container_> │ │ │ │ │ +  An owning multi-dimensional array analog of mdspan. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ +namespace   Dune::Std │ │ │ │ │ +  Namespace for features backported from new C++ standards. │ │ │ │ │ +  │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00050_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: copyableoptional.hh Source File │ │ │ │ +dune-common: mdarray.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,173 +70,712 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
copyableoptional.hh
│ │ │ │ +
mdarray.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_COMMON_COPYABLE_OPTIONAL_HH
│ │ │ │ -
6#define DUNE_COMMON_COPYABLE_OPTIONAL_HH
│ │ │ │ +
5#ifndef DUNE_COMMON_STD_MDARRAY_HH
│ │ │ │ +
6#define DUNE_COMMON_STD_MDARRAY_HH
│ │ │ │
7
│ │ │ │ -
8#include <cassert>
│ │ │ │ -
9#include <iostream>
│ │ │ │ +
8#include <algorithm>
│ │ │ │ +
9#include <array>
│ │ │ │
10#include <memory>
│ │ │ │ -
11#include <optional>
│ │ │ │ -
12#include <type_traits>
│ │ │ │ -
13
│ │ │ │ - │ │ │ │ -
15
│ │ │ │ -
16namespace Dune {
│ │ │ │ +
11#include <vector>
│ │ │ │ +
12#include <tuple>
│ │ │ │ +
13#include <type_traits>
│ │ │ │ +
14#if __has_include(<version>)
│ │ │ │ +
15 #include <version>
│ │ │ │ +
16#endif
│ │ │ │
17
│ │ │ │ -
32template <class Type>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
34 : public std::optional<Type>
│ │ │ │ -
35{
│ │ │ │ -
36 static_assert(std::is_copy_constructible_v<Type>);
│ │ │ │ -
37 static_assert(std::is_object_v<Type>);
│ │ │ │ -
38
│ │ │ │ -
39 using Base = std::optional<Type>;
│ │ │ │ -
40
│ │ │ │ -
41public:
│ │ │ │ -
42
│ │ │ │ -
47 template <class T = Type,
│ │ │ │ -
48 std::enable_if_t<std::is_default_constructible_v<T>, int> = 0>
│ │ │ │ -
│ │ │ │ -
49 constexpr CopyableOptional ()
│ │ │ │ -
50 noexcept(std::is_nothrow_default_constructible_v<T>)
│ │ │ │ -
51 : Base{std::in_place}
│ │ │ │ -
52 {}
│ │ │ │ -
│ │ │ │ -
53
│ │ │ │ -
58 template <class T = Type,
│ │ │ │ -
59 disableCopyMove<CopyableOptional,T> = 0,
│ │ │ │ -
60 std::enable_if_t<std::is_constructible_v<Type,T&&>, int> = 0,
│ │ │ │ -
61 std::enable_if_t<std::is_convertible_v<T&&,Type>, int> = 0>
│ │ │ │ -
│ │ │ │ -
62 constexpr CopyableOptional (T&& value)
│ │ │ │ -
63 noexcept(std::is_nothrow_constructible_v<Type,T&&>)
│ │ │ │ -
64 : Base{std::in_place, std::forward<T>(value)}
│ │ │ │ -
65 {}
│ │ │ │ -
│ │ │ │ -
66
│ │ │ │ -
71 template <class T = Type,
│ │ │ │ - │ │ │ │ -
73 std::enable_if_t<std::is_constructible_v<Type,T&&>, int> = 0,
│ │ │ │ -
74 std::enable_if_t<not std::is_convertible_v<T&&,Type>, int> = 0>
│ │ │ │ -
│ │ │ │ -
75 explicit constexpr CopyableOptional (T&& value)
│ │ │ │ -
76 noexcept(std::is_nothrow_constructible_v<Type,T&&>)
│ │ │ │ -
77 : Base{std::in_place, std::forward<T>(value)}
│ │ │ │ -
78 {}
│ │ │ │ -
│ │ │ │ -
79
│ │ │ │ -
81 template <class... Args,
│ │ │ │ - │ │ │ │ -
83 std::enable_if_t<(sizeof...(Args) > 1), int> = 0,
│ │ │ │ -
84 std::enable_if_t<std::is_constructible_v<Type,Args&&...>, int> = 0>
│ │ │ │ -
│ │ │ │ -
85 constexpr CopyableOptional (Args&&... args)
│ │ │ │ -
86 noexcept(std::is_nothrow_constructible_v<Type,Args&&...>)
│ │ │ │ -
87 : Base{std::in_place, std::forward<Args>(args)...}
│ │ │ │ -
88 {}
│ │ │ │ -
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
25
│ │ │ │ +
26namespace Dune::Std {
│ │ │ │ +
27
│ │ │ │ +
66template <class Element, class Extents, class LayoutPolicy = Std::layout_right,
│ │ │ │ +
67 class Container = std::vector<Element>>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
69{
│ │ │ │ +
70 template <class,class,class,class> friend class mdarray;
│ │ │ │ +
71
│ │ │ │ +
72 static_assert(std::is_object_v<Element>);
│ │ │ │ +
73 static_assert(!std::is_abstract_v<Element>);
│ │ │ │ +
74 static_assert(!std::is_array_v<Element>);
│ │ │ │ +
75 static_assert(std::is_same_v<Element, typename Container::value_type>);
│ │ │ │ +
76
│ │ │ │ +
77public:
│ │ │ │ +
78 using element_type = Element;
│ │ │ │ +
79 using extents_type = Extents;
│ │ │ │ +
80 using layout_type = LayoutPolicy;
│ │ │ │ +
81 using container_type = Container;
│ │ │ │ +
82
│ │ │ │ + │ │ │ │ +
84 using mapping_type = typename layout_type::template mapping<extents_type>;
│ │ │ │ +
85
│ │ │ │ +
86 using index_type = typename extents_type::index_type;
│ │ │ │ +
87 using size_type = typename extents_type::size_type;
│ │ │ │ +
88 using rank_type = typename extents_type::rank_type;
│ │ │ │
89
│ │ │ │ -
91 constexpr CopyableOptional (const CopyableOptional&) = default;
│ │ │ │ + │ │ │ │ + │ │ │ │
92
│ │ │ │ -
94 constexpr CopyableOptional (CopyableOptional&&) = default;
│ │ │ │ -
95
│ │ │ │ -
97 ~CopyableOptional () = default;
│ │ │ │ -
98
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
101 noexcept(std::is_nothrow_copy_assignable_v<Type> ||
│ │ │ │ -
102 (!std::is_copy_assignable_v<Type> && std::is_nothrow_copy_constructible_v<Type>))
│ │ │ │ -
103 {
│ │ │ │ -
104 if constexpr(std::is_copy_assignable_v<Type>)
│ │ │ │ -
105 Base::operator=(that);
│ │ │ │ -
106 else {
│ │ │ │ -
107 // no self-assignment
│ │ │ │ -
108 if (this != std::addressof(that)) {
│ │ │ │ -
109 if (that)
│ │ │ │ -
110 Base::emplace(*that);
│ │ │ │ -
111 else
│ │ │ │ -
112 Base::reset();
│ │ │ │ -
113 }
│ │ │ │ -
114 }
│ │ │ │ -
115 return *this;
│ │ │ │ -
116 }
│ │ │ │ -
│ │ │ │ -
117
│ │ │ │ -
119 template <class T = Type,
│ │ │ │ -
120 std::enable_if_t<std::is_move_constructible_v<T>, int> = 0>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
122 noexcept(std::is_nothrow_move_assignable_v<Type> ||
│ │ │ │ -
123 (!std::is_move_assignable_v<Type> && std::is_nothrow_move_constructible_v<Type>))
│ │ │ │ -
124 {
│ │ │ │ -
125 if constexpr(std::is_move_assignable_v<Type>)
│ │ │ │ -
126 Base::operator=(std::move(that));
│ │ │ │ -
127 else {
│ │ │ │ -
128 // no self-assignment
│ │ │ │ -
129 if (this != std::addressof(that)) {
│ │ │ │ -
130 if (that)
│ │ │ │ -
131 Base::emplace(std::move(*that));
│ │ │ │ -
132 else
│ │ │ │ -
133 Base::reset();
│ │ │ │ -
134 }
│ │ │ │ -
135 }
│ │ │ │ -
136 return *this;
│ │ │ │ -
137 }
│ │ │ │ -
│ │ │ │ -
138
│ │ │ │ -
140 template <class T = Type,
│ │ │ │ -
141 std::enable_if_t<not std::is_same_v<std::decay_t<T>, CopyableOptional>, int> = 0,
│ │ │ │ -
142 std::enable_if_t<(std::is_assignable_v<Type&,T> || std::is_constructible_v<Type,T>), int> = 0>
│ │ │ │ -
│ │ │ │ -
143 constexpr CopyableOptional& operator= (T&& value)
│ │ │ │ -
144 noexcept(std::is_nothrow_assignable_v<Type&,T> ||
│ │ │ │ -
145 (!std::is_assignable_v<Type&,T> && std::is_nothrow_constructible_v<Type,T>))
│ │ │ │ -
146 {
│ │ │ │ -
147 if constexpr(std::is_assignable_v<Type&,T>)
│ │ │ │ -
148 Base::operator=(std::forward<T>(value));
│ │ │ │ -
149 else
│ │ │ │ -
150 Base::emplace(std::forward<T>(value));
│ │ │ │ -
151 return *this;
│ │ │ │ -
152 }
│ │ │ │ -
│ │ │ │ -
153};
│ │ │ │ -
│ │ │ │ -
154
│ │ │ │ -
155} // end namespace Dune
│ │ │ │ -
156
│ │ │ │ -
157#endif // DUNE_COMMON_COPYABLE_OPTIONAL_HH
│ │ │ │ -
Utilities for type computations, constraining overloads, ...
│ │ │ │ -
std::enable_if_t< not Impl::disableCopyMoveHelper< This, T... >::value, int > disableCopyMove
Helper to disable constructor as copy and move constructor.
Definition typeutilities.hh:45
│ │ │ │ +
93 using pointer = decltype(Std::to_address(std::declval<container_type>().begin()));
│ │ │ │ +
94 using reference = typename container_type::reference;
│ │ │ │ +
95 using const_pointer = decltype(Std::to_address(std::declval<container_type>().cbegin()));
│ │ │ │ +
96 using const_reference = typename container_type::const_reference;
│ │ │ │ +
97
│ │ │ │ +
98 static_assert(std::is_constructible_v<mapping_type, extents_type>);
│ │ │ │ +
99
│ │ │ │ +
100private:
│ │ │ │ +
101 // helper function to construct the container
│ │ │ │ +
102 template <class C, class... Args>
│ │ │ │ +
103 static constexpr auto construct_container (Args&&... args)
│ │ │ │ +
104 -> decltype(Impl::ContainerConstructionTraits<C>::construct(std::forward<Args>(args)...))
│ │ │ │ +
105 {
│ │ │ │ +
106 return Impl::ContainerConstructionTraits<C>::construct(std::forward<Args>(args)...);
│ │ │ │ +
107 }
│ │ │ │ +
108
│ │ │ │ +
109public:
│ │ │ │ +
112
│ │ │ │ +
114 template <class E = extents_type, class C = container_type, class M = mapping_type,
│ │ │ │ +
115 std::enable_if_t<(E::rank_dynamic() != 0), int> = 0,
│ │ │ │ +
116 std::enable_if_t<std::is_default_constructible_v<C>, int> = 0,
│ │ │ │ +
117 std::enable_if_t<std::is_default_constructible_v<M>, int> = 0>
│ │ │ │ +
│ │ │ │ +
118 constexpr mdarray ()
│ │ │ │ +
119 : container_{}
│ │ │ │ +
120 , mapping_{}
│ │ │ │ +
121 {}
│ │ │ │ +
│ │ │ │ +
122
│ │ │ │ +
123
│ │ │ │ +
124 // -------------------------------------
│ │ │ │ +
125 // constructors from extents or mappings
│ │ │ │ +
126
│ │ │ │ +
127
│ │ │ │ +
129 template <class... IndexTypes,
│ │ │ │ +
130 std::enable_if_t<(... && std::is_convertible_v<IndexTypes,index_type>), int> = 0,
│ │ │ │ +
131 std::enable_if_t<std::is_constructible_v<extents_type,IndexTypes...>, int> = 0,
│ │ │ │ +
132 std::enable_if_t<(... && std::is_nothrow_constructible_v<index_type,IndexTypes>), int> = 0>
│ │ │ │ +
│ │ │ │ +
133 explicit constexpr mdarray (IndexTypes... exts)
│ │ │ │ +
134 : mdarray(extents_type(index_type(std::move(exts))...))
│ │ │ │ +
135 {}
│ │ │ │ +
│ │ │ │ +
136
│ │ │ │ +
│ │ │ │ +
138 explicit constexpr mdarray (const extents_type& e)
│ │ │ │ + │ │ │ │ +
140 {}
│ │ │ │ +
│ │ │ │ +
141
│ │ │ │ +
143 template <class C = container_type,
│ │ │ │ +
144 decltype(construct_container<C>(std::declval<std::size_t>()), bool{}) = true>
│ │ │ │ +
│ │ │ │ +
145 explicit constexpr mdarray (const mapping_type& m)
│ │ │ │ +
146 : container_(construct_container<C>(m.required_span_size()))
│ │ │ │ +
147 , mapping_(m)
│ │ │ │ +
148 {}
│ │ │ │ +
│ │ │ │ +
149
│ │ │ │ +
150
│ │ │ │ +
151 // ---------------------------------------
│ │ │ │ +
152 // constructors with a given initial value
│ │ │ │ +
153
│ │ │ │ +
│ │ │ │ +
155 constexpr mdarray (const extents_type& e, const value_type& v)
│ │ │ │ +
156 : mdarray(mapping_type(e), v)
│ │ │ │ +
157 {}
│ │ │ │ +
│ │ │ │ +
158
│ │ │ │ +
160 template <class C = container_type,
│ │ │ │ +
161 decltype(construct_container<C>(std::declval<std::size_t>(),std::declval<const value_type&>()), bool{}) = true>
│ │ │ │ +
│ │ │ │ +
162 constexpr mdarray (const mapping_type& m, const value_type& v)
│ │ │ │ +
163 : container_(construct_container<C>(m.required_span_size(), v))
│ │ │ │ +
164 , mapping_(m)
│ │ │ │ +
165 {}
│ │ │ │ +
│ │ │ │ +
166
│ │ │ │ +
167
│ │ │ │ +
168 // -----------------------------------
│ │ │ │ +
169 // constructors with a given container
│ │ │ │ +
170
│ │ │ │ +
172 template <class E = extents_type,
│ │ │ │ +
173 std::enable_if_t<std::is_constructible_v<mapping_type,const E&>, int> = 0>
│ │ │ │ +
│ │ │ │ +
174 constexpr mdarray (const E& e, const container_type& c)
│ │ │ │ +
175 : container_(c)
│ │ │ │ +
176 , mapping_(e)
│ │ │ │ +
177 {}
│ │ │ │ +
│ │ │ │ +
178
│ │ │ │ +
180 template <class E = extents_type,
│ │ │ │ +
181 std::enable_if_t<std::is_constructible_v<mapping_type,const E&>, int> = 0>
│ │ │ │ +
│ │ │ │ +
182 constexpr mdarray (const E& e, container_type&& c)
│ │ │ │ +
183 : container_(std::move(c))
│ │ │ │ +
184 , mapping_(e)
│ │ │ │ +
185 {}
│ │ │ │ +
│ │ │ │ +
186
│ │ │ │ +
│ │ │ │ +
188 constexpr mdarray (const mapping_type& m, const container_type& c)
│ │ │ │ +
189 : container_(c)
│ │ │ │ +
190 , mapping_(m)
│ │ │ │ +
191 {}
│ │ │ │ +
│ │ │ │ +
192
│ │ │ │ +
│ │ │ │ +
194 constexpr mdarray (const mapping_type& m, container_type&& c)
│ │ │ │ +
195 : container_(std::move(c))
│ │ │ │ +
196 , mapping_(m)
│ │ │ │ +
197 {}
│ │ │ │ +
│ │ │ │ +
198
│ │ │ │ +
199
│ │ │ │ +
200 // -----------------------
│ │ │ │ +
201 // converting constructors
│ │ │ │ +
202
│ │ │ │ +
204 template <class OtherElementType, class OtherExtents, class OtherLayoutPolicy, class OtherContainer,
│ │ │ │ +
205 std::enable_if_t<std::is_constructible_v<Container,const OtherContainer&>, int> = 0,
│ │ │ │ +
206 std::enable_if_t<std::is_constructible_v<extents_type,OtherExtents>, int> = 0,
│ │ │ │ +
207 std::enable_if_t<std::is_constructible_v<mapping_type,const typename OtherLayoutPolicy::template mapping<OtherExtents>&>, int> = 0>
│ │ │ │ +
208 #if __cpp_conditional_explicit >= 201806L
│ │ │ │ +
209 explicit(
│ │ │ │ +
210 !std::is_convertible_v<const typename OtherLayoutPolicy::template mapping<OtherExtents>&, mapping_type> ||
│ │ │ │ +
211 !std::is_convertible_v<const OtherContainer&, container_type>)
│ │ │ │ +
212 #endif
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
214 : container_(other.container_)
│ │ │ │ +
215 , mapping_(other.mapping_)
│ │ │ │ +
216 {}
│ │ │ │ +
│ │ │ │ +
217
│ │ │ │ +
219 template <class OtherElementType, class OtherExtents, class OtherLayoutPolicy, class Accessor,
│ │ │ │ +
220 std::enable_if_t<std::is_constructible_v<value_type,typename Accessor::reference>, int> = 0,
│ │ │ │ +
221 std::enable_if_t<std::is_assignable_v<typename Accessor::reference, value_type>, int> = 0,
│ │ │ │ +
222 std::enable_if_t<std::is_constructible_v<mapping_type, const typename OtherLayoutPolicy::template mapping<OtherExtents>&>, int> = 0,
│ │ │ │ +
223 decltype(construct_container<container_type>(std::declval<std::size_t>()), bool{}) = true>
│ │ │ │ +
224 #if __cpp_conditional_explicit >= 201806L
│ │ │ │ +
225 explicit(
│ │ │ │ +
226 !std::is_convertible_v<const typename OtherLayoutPolicy::template mapping<OtherExtents>&, mapping_type> ||
│ │ │ │ +
227 !std::is_convertible_v<typename Accessor::reference, value_type>)
│ │ │ │ +
228 #endif
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
230 : container_(construct_container<container_type>(other.size()))
│ │ │ │ +
231 , mapping_(other.mapping())
│ │ │ │ +
232 {
│ │ │ │ +
233 init_from_mdspan(other);
│ │ │ │ +
234 }
│ │ │ │ +
│ │ │ │ +
235
│ │ │ │ +
236
│ │ │ │ +
237 // ----------------------------
│ │ │ │ +
238 // constructors with allocators
│ │ │ │ +
239
│ │ │ │ +
241 template <class Alloc,
│ │ │ │ +
242 std::enable_if_t<std::is_constructible_v<container_type, std::size_t, Alloc>, int> = 0>
│ │ │ │ +
│ │ │ │ +
243 constexpr mdarray (const extents_type& e, const Alloc& a)
│ │ │ │ +
244 : mdarray(mapping_type(e), a)
│ │ │ │ +
245 {}
│ │ │ │ +
│ │ │ │ +
246
│ │ │ │ +
248 template <class Alloc,
│ │ │ │ +
249 std::enable_if_t<std::is_constructible_v<container_type, std::size_t, Alloc>, int> = 0>
│ │ │ │ +
│ │ │ │ +
250 constexpr mdarray (const mapping_type& m, const Alloc& a)
│ │ │ │ +
251 : container_(m.required_span_size(), a)
│ │ │ │ +
252 , mapping_(m)
│ │ │ │ +
253 {}
│ │ │ │ +
│ │ │ │ +
254
│ │ │ │ +
256 template <class Alloc>
│ │ │ │ +
│ │ │ │ +
257 constexpr mdarray (const extents_type& e, const value_type& v, const Alloc& a)
│ │ │ │ +
258 : mdarray(mapping_type(e), v, a)
│ │ │ │ +
259 {}
│ │ │ │ +
│ │ │ │ +
260
│ │ │ │ +
262 template <class Alloc,
│ │ │ │ +
263 std::enable_if_t<std::is_constructible_v<container_type, std::size_t, value_type, Alloc>, int> = 0>
│ │ │ │ +
│ │ │ │ +
264 constexpr mdarray (const mapping_type& m, const value_type& v, const Alloc& a)
│ │ │ │ +
265 : container_(m.required_span_size(), v, a)
│ │ │ │ +
266 , mapping_(m)
│ │ │ │ +
267 {}
│ │ │ │ +
│ │ │ │ +
268
│ │ │ │ +
270 template <class Alloc,
│ │ │ │ +
271 std::enable_if_t<std::is_constructible_v<container_type, container_type, Alloc>, int> = 0>
│ │ │ │ +
│ │ │ │ +
272 constexpr mdarray (const extents_type& e, const container_type& c, const Alloc& a)
│ │ │ │ +
273 : container_(c, a)
│ │ │ │ +
274 , mapping_(e)
│ │ │ │ +
275 {}
│ │ │ │ +
│ │ │ │ +
276
│ │ │ │ +
278 template <class Alloc,
│ │ │ │ +
279 std::enable_if_t<std::is_constructible_v<container_type, container_type, Alloc>, int> = 0>
│ │ │ │ +
│ │ │ │ +
280 constexpr mdarray (const extents_type& e, container_type&& c, const Alloc& a)
│ │ │ │ +
281 : container_(std::move(c), a)
│ │ │ │ +
282 , mapping_(e)
│ │ │ │ +
283 {}
│ │ │ │ +
│ │ │ │ +
284
│ │ │ │ +
286 template <class Alloc,
│ │ │ │ +
287 std::enable_if_t<std::is_constructible_v<container_type, container_type, Alloc>, int> = 0>
│ │ │ │ +
│ │ │ │ +
288 constexpr mdarray (const mapping_type& m, const container_type& c, const Alloc& a)
│ │ │ │ +
289 : container_(c, a)
│ │ │ │ +
290 , mapping_(m)
│ │ │ │ +
291 {}
│ │ │ │ +
│ │ │ │ +
292
│ │ │ │ +
294 template <class Alloc,
│ │ │ │ +
295 std::enable_if_t<std::is_constructible_v<container_type, container_type, Alloc>, int> = 0>
│ │ │ │ +
│ │ │ │ +
296 constexpr mdarray (const mapping_type& m, container_type&& c, const Alloc& a)
│ │ │ │ +
297 : container_(std::move(c), a)
│ │ │ │ +
298 , mapping_(m)
│ │ │ │ +
299 {}
│ │ │ │ +
│ │ │ │ +
300
│ │ │ │ +
302 template <class V, class E, class L, class C, class Alloc,
│ │ │ │ +
303 std::enable_if_t<std::is_constructible_v<container_type, C, Alloc>, int> = 0>
│ │ │ │ +
304 #if __cpp_conditional_explicit >= 201806L
│ │ │ │ +
305 explicit(
│ │ │ │ +
306 !std::is_convertible_v<const typename L::template mapping<E>&, mapping_type> ||
│ │ │ │ +
307 !std::is_convertible_v<const C&, container_type>)
│ │ │ │ +
308 #endif
│ │ │ │ +
│ │ │ │ +
309 constexpr mdarray (const mdarray<V,E,L,C>& other, const Alloc& a) noexcept
│ │ │ │ +
310 : container_(other.container_, a)
│ │ │ │ +
311 , mapping_(other.mapping_)
│ │ │ │ +
312 {}
│ │ │ │ +
│ │ │ │ +
313
│ │ │ │ +
315 template <class V, class E, class L, class A, class Alloc,
│ │ │ │ +
316 class C = container_type,
│ │ │ │ +
317 class Al = typename C::allocator_type,
│ │ │ │ +
318 std::enable_if_t<std::is_constructible_v<C, std::size_t, Alloc>, int> = 0>
│ │ │ │ +
319 #if __cpp_conditional_explicit >= 201806L
│ │ │ │ +
320 explicit(
│ │ │ │ +
321 !std::is_convertible_v<const typename L::template mapping<E>&, mapping_type> ||
│ │ │ │ +
322 !std::is_convertible_v<typename A::reference, value_type> ||
│ │ │ │ +
323 !std::is_convertible_v<Alloc, Al>)
│ │ │ │ +
324 #endif
│ │ │ │ +
│ │ │ │ +
325 constexpr mdarray (const mdspan<V,E,L,A>& other, const Alloc& a)
│ │ │ │ +
326 : container_(other.size(), a)
│ │ │ │ +
327 , mapping_(other.mapping_)
│ │ │ │ +
328 {
│ │ │ │ +
329 init_from_mdspan(other);
│ │ │ │ +
330 }
│ │ │ │ +
│ │ │ │ +
331
│ │ │ │ +
333
│ │ │ │ +
334private:
│ │ │ │ +
335
│ │ │ │ +
336 template <class V, class E, class L, class A, class... Indices>
│ │ │ │ +
337 void init_from_mdspan (const mdspan<V,E,L,A>& other, Indices... ii)
│ │ │ │ +
338 {
│ │ │ │ +
339 constexpr rank_type pos = sizeof...(Indices);
│ │ │ │ +
340 if constexpr(pos < rank()) {
│ │ │ │ +
341 for (typename E::index_type i = 0; i < other.extent(pos); ++i)
│ │ │ │ +
342 init_from_mdspan(other,ii...,i);
│ │ │ │ +
343 } else {
│ │ │ │ +
344 using I = std::array<typename E::index_type,E::rank()>;
│ │ │ │ +
345 container_[mapping_(index_type(ii)...)] = other[I{ii...}];
│ │ │ │ +
346 }
│ │ │ │ +
347 }
│ │ │ │ +
348
│ │ │ │ +
349public:
│ │ │ │ +
350
│ │ │ │ +
353
│ │ │ │ +
360 template <class... Indices,
│ │ │ │ +
361 std::enable_if_t<(sizeof...(Indices) == extents_type::rank()), int> = 0,
│ │ │ │ +
362 std::enable_if_t<(... && std::is_convertible_v<Indices,index_type>), int> = 0>
│ │ │ │ +
│ │ │ │ +
363 constexpr reference operator() (Indices... indices)
│ │ │ │ +
364 {
│ │ │ │ +
365 return container_[mapping_(index_type(std::move(indices))...)];
│ │ │ │ +
366 }
│ │ │ │ +
│ │ │ │ +
367
│ │ │ │ +
372 template <class... Indices,
│ │ │ │ +
373 std::enable_if_t<(sizeof...(Indices) == extents_type::rank()), int> = 0,
│ │ │ │ +
374 std::enable_if_t<(... && std::is_convertible_v<Indices,index_type>), int> = 0>
│ │ │ │ +
│ │ │ │ +
375 constexpr const_reference operator() (Indices... indices) const
│ │ │ │ +
376 {
│ │ │ │ +
377 return container_[mapping_(index_type(std::move(indices))...)];
│ │ │ │ +
378 }
│ │ │ │ +
│ │ │ │ +
379
│ │ │ │ +
380
│ │ │ │ +
381#if __cpp_multidimensional_subscript >= 202110L
│ │ │ │ +
382
│ │ │ │ +
384 template <class... Indices,
│ │ │ │ +
385 std::enable_if_t<(sizeof...(Indices) == extents_type::rank()), int> = 0,
│ │ │ │ +
386 std::enable_if_t<(... && std::is_convertible_v<Indices,index_type>), int> = 0>
│ │ │ │ +
387 constexpr reference operator[] (Indices... indices)
│ │ │ │ +
388 {
│ │ │ │ +
389 return container_[mapping_(index_type(std::move(indices))...)];
│ │ │ │ +
390 }
│ │ │ │ +
391
│ │ │ │ +
393 template <class... Indices,
│ │ │ │ +
394 std::enable_if_t<(sizeof...(Indices) == extents_type::rank()), int> = 0,
│ │ │ │ +
395 std::enable_if_t<(... && std::is_convertible_v<Indices,index_type>), int> = 0>
│ │ │ │ +
396 constexpr const_reference operator[] (Indices... indices) const
│ │ │ │ +
397 {
│ │ │ │ +
398 return container_[mapping_(index_type(std::move(indices))...)];
│ │ │ │ +
399 }
│ │ │ │ +
400
│ │ │ │ +
401#else
│ │ │ │ +
402
│ │ │ │ +
405 template <class Index, class E = extents_type,
│ │ │ │ +
406 std::enable_if_t<std::is_convertible_v<Index,index_type>, int> = 0,
│ │ │ │ +
407 std::enable_if_t<(E::rank() == 1), int> = 0>
│ │ │ │ +
│ │ │ │ +
408 constexpr reference operator[] (Index index)
│ │ │ │ +
409 {
│ │ │ │ +
410 return container_[mapping_(index_type(std::move(index)))];
│ │ │ │ +
411 }
│ │ │ │ +
│ │ │ │ +
412
│ │ │ │ +
415 template <class Index, class E = extents_type,
│ │ │ │ +
416 std::enable_if_t<std::is_convertible_v<Index,index_type>, int> = 0,
│ │ │ │ +
417 std::enable_if_t<(E::rank() == 1), int> = 0>
│ │ │ │ +
│ │ │ │ +
418 constexpr const_reference operator[] (Index index) const
│ │ │ │ +
419 {
│ │ │ │ +
420 return container_[mapping_(index_type(std::move(index)))];
│ │ │ │ +
421 }
│ │ │ │ +
│ │ │ │ +
422
│ │ │ │ +
423#endif
│ │ │ │ +
424
│ │ │ │ +
425
│ │ │ │ +
427 template <class Index,
│ │ │ │ +
428 std::enable_if_t<std::is_convertible_v<const Index&, index_type>, int> = 0>
│ │ │ │ +
│ │ │ │ +
429 constexpr reference operator[] (Std::span<Index,extents_type::rank()> indices)
│ │ │ │ +
430 {
│ │ │ │ +
431 return unpackIntegerSequence([&](auto... ii) -> reference {
│ │ │ │ +
432 return container_[mapping_(index_type(indices[ii])...)]; },
│ │ │ │ +
433 std::make_index_sequence<extents_type::rank()>{});
│ │ │ │ +
434 }
│ │ │ │ +
│ │ │ │ +
435
│ │ │ │ +
437 template <class Index,
│ │ │ │ +
438 std::enable_if_t<std::is_convertible_v<const Index&, index_type>, int> = 0>
│ │ │ │ +
│ │ │ │ +
439 constexpr const_reference operator[] (Std::span<Index,extents_type::rank()> indices) const
│ │ │ │ +
440 {
│ │ │ │ +
441 return unpackIntegerSequence([&](auto... ii) -> const_reference {
│ │ │ │ +
442 return container_[mapping_(index_type(indices[ii])...)]; },
│ │ │ │ +
443 std::make_index_sequence<extents_type::rank()>{});
│ │ │ │ +
444 }
│ │ │ │ +
│ │ │ │ +
445
│ │ │ │ +
447 template <class Index,
│ │ │ │ +
448 std::enable_if_t<std::is_convertible_v<const Index&, index_type>, int> = 0>
│ │ │ │ +
│ │ │ │ +
449 constexpr reference operator[] (const std::array<Index,extents_type::rank()>& indices)
│ │ │ │ +
450 {
│ │ │ │ +
451 return std::apply([&](auto... ii) -> reference {
│ │ │ │ +
452 return container_[mapping_(index_type(ii)...)]; }, indices);
│ │ │ │ +
453 }
│ │ │ │ +
│ │ │ │ +
454
│ │ │ │ +
456 template <class Index,
│ │ │ │ +
457 std::enable_if_t<std::is_convertible_v<const Index&, index_type>, int> = 0>
│ │ │ │ +
│ │ │ │ +
458 constexpr const_reference operator[] (const std::array<Index,extents_type::rank()>& indices) const
│ │ │ │ +
459 {
│ │ │ │ +
460 return std::apply([&](auto... ii) -> const_reference {
│ │ │ │ +
461 return container_[mapping_(index_type(ii)...)]; }, indices);
│ │ │ │ +
462 }
│ │ │ │ +
│ │ │ │ +
463
│ │ │ │ +
465
│ │ │ │ +
466
│ │ │ │ +
468 constexpr const extents_type& extents () const noexcept { return mapping_.extents(); }
│ │ │ │ +
469
│ │ │ │ +
471 constexpr const mapping_type& mapping () const noexcept { return mapping_; }
│ │ │ │ +
472
│ │ │ │ +
474 constexpr const container_type& container () const noexcept { return container_; }
│ │ │ │ +
475
│ │ │ │ +
482 constexpr container_type&& extract_container () && noexcept { return std::move(container_); }
│ │ │ │ +
483
│ │ │ │ +
484
│ │ │ │ +
487
│ │ │ │ +
489 static constexpr rank_type rank () noexcept { return extents_type::rank(); }
│ │ │ │ +
490
│ │ │ │ +
492 static constexpr rank_type rank_dynamic () noexcept { return extents_type::rank_dynamic(); }
│ │ │ │ +
493
│ │ │ │ +
495 static constexpr std::size_t static_extent (rank_type r) noexcept { return extents_type::static_extent(r); }
│ │ │ │ +
496
│ │ │ │ +
498 constexpr index_type extent (rank_type r) const noexcept { return extents().extent(r); }
│ │ │ │ +
499
│ │ │ │ +
│ │ │ │ +
501 constexpr size_type size () const noexcept
│ │ │ │ +
502 {
│ │ │ │ +
503 size_type s = 1;
│ │ │ │ +
504 for (rank_type r = 0; r < rank(); ++r)
│ │ │ │ +
505 s *= extent(r);
│ │ │ │ +
506 return s;
│ │ │ │ +
507 }
│ │ │ │ +
│ │ │ │ +
508
│ │ │ │ +
510 constexpr std::size_t container_size () const { return container_.size(); }
│ │ │ │ +
511
│ │ │ │ +
513 [[nodiscard]] constexpr bool empty () const noexcept { return size() == 0; }
│ │ │ │ +
514
│ │ │ │ +
516 constexpr index_type stride (rank_type r) const { return mapping().stride(r); };
│ │ │ │ +
517
│ │ │ │ +
519
│ │ │ │ +
520
│ │ │ │ +
521 static constexpr bool is_always_unique () noexcept { return mapping_type::is_always_unique(); }
│ │ │ │ +
522 static constexpr bool is_always_exhaustive () noexcept { return mapping_type::is_always_exhaustive(); }
│ │ │ │ +
523 static constexpr bool is_always_strided () noexcept { return mapping_type::is_always_strided(); }
│ │ │ │ +
524
│ │ │ │ +
525 constexpr bool is_unique () const noexcept { return mapping_.is_unique(); }
│ │ │ │ +
526 constexpr bool is_exhaustive () const noexcept { return mapping_.is_exhaustive(); }
│ │ │ │ +
527 constexpr bool is_strided () const noexcept { return mapping_.is_strided(); }
│ │ │ │ +
528
│ │ │ │ +
529
│ │ │ │ +
532
│ │ │ │ +
534 constexpr pointer container_data () noexcept { return Std::to_address(container_.begin()); }
│ │ │ │ +
535
│ │ │ │ +
537 constexpr const_pointer container_data () const noexcept { return Std::to_address(container_.begin()); }
│ │ │ │ +
538
│ │ │ │ +
540
│ │ │ │ +
541
│ │ │ │ +
│ │ │ │ +
542 friend constexpr void swap (mdarray& x, mdarray& y) noexcept
│ │ │ │ +
543 {
│ │ │ │ +
544 using std::swap;
│ │ │ │ +
545 swap(x.container_, y.container_);
│ │ │ │ +
546 swap(x.mapping_, y.mapping_);
│ │ │ │ +
547 }
│ │ │ │ +
│ │ │ │ +
548
│ │ │ │ +
549
│ │ │ │ +
552
│ │ │ │ +
│ │ │ │ +
553 friend constexpr bool operator== (const mdarray& lhs, const mdarray& rhs) noexcept
│ │ │ │ +
554 {
│ │ │ │ +
555 return lhs.mapping() == rhs.mapping() && lhs.container() == rhs.container();
│ │ │ │ +
556 }
│ │ │ │ +
│ │ │ │ +
557
│ │ │ │ +
559
│ │ │ │ +
562
│ │ │ │ +
564 template <class V, class E, class L, class A,
│ │ │ │ +
565 std::enable_if_t<std::is_assignable_v<mdspan<V,E,L,A>, mdspan_type>, int> = 0>
│ │ │ │ +
│ │ │ │ +
566 constexpr operator mdspan<V,E,L,A> ()
│ │ │ │ +
567 {
│ │ │ │ + │ │ │ │ +
569 }
│ │ │ │ +
│ │ │ │ +
570
│ │ │ │ +
572 template <class V, class E, class L, class A,
│ │ │ │ +
573 std::enable_if_t<std::is_assignable_v<mdspan<V,E,L,A>, const_mdspan_type>, int> = 0>
│ │ │ │ +
│ │ │ │ +
574 constexpr operator mdspan<V,E,L,A> () const
│ │ │ │ +
575 {
│ │ │ │ + │ │ │ │ +
577 }
│ │ │ │ +
│ │ │ │ +
578
│ │ │ │ +
580 template <class AccessorPolicy = Std::default_accessor<element_type>,
│ │ │ │ +
581 std::enable_if_t<
│ │ │ │ +
582 std::is_assignable_v<mdspan_type, mdspan<element_type,extents_type,layout_type,AccessorPolicy>>, int> = 0>
│ │ │ │ + │ │ │ │ +
│ │ │ │ +
584 to_mdspan (const AccessorPolicy& a = AccessorPolicy{})
│ │ │ │ +
585 {
│ │ │ │ + │ │ │ │ +
587 }
│ │ │ │ +
│ │ │ │ +
588
│ │ │ │ +
590 template <class AccessorPolicy = Std::default_accessor<const element_type>,
│ │ │ │ +
591 std::enable_if_t<
│ │ │ │ +
592 std::is_assignable_v<const_mdspan_type, mdspan<const element_type,extents_type,layout_type,AccessorPolicy>>, int> = 0>
│ │ │ │ +
593 constexpr mdspan<const element_type,extents_type,layout_type,AccessorPolicy>
│ │ │ │ +
│ │ │ │ +
594 to_mdspan (const AccessorPolicy& a = AccessorPolicy{}) const
│ │ │ │ +
595 {
│ │ │ │ + │ │ │ │ +
597 }
│ │ │ │ +
│ │ │ │ +
598
│ │ │ │ +
599protected:
│ │ │ │ + │ │ │ │ +
601 [[no_unique_address]] mapping_type mapping_;
│ │ │ │ +
602};
│ │ │ │ +
│ │ │ │ +
603
│ │ │ │ +
607
│ │ │ │ +
608template <class IndexType, std::size_t... exts, class Container>
│ │ │ │ +
609mdarray (const Std::extents<IndexType, exts...>&, const Container&)
│ │ │ │ +
610 -> mdarray<typename Container::value_type, Std::extents<IndexType, exts...>, layout_right, Container>;
│ │ │ │ +
611
│ │ │ │ +
612template <class Mapping, class Container>
│ │ │ │ +
613mdarray (const Mapping&, const Container&)
│ │ │ │ + │ │ │ │ +
615
│ │ │ │ +
616template <class IndexType, std::size_t... exts, class Container>
│ │ │ │ +
617mdarray (const Std::extents<IndexType, exts...>&, Container&&)
│ │ │ │ +
618 -> mdarray<typename Container::value_type, Std::extents<IndexType, exts...>, layout_right, Container>;
│ │ │ │ +
619
│ │ │ │ +
620template <class Mapping, class Container>
│ │ │ │ +
621mdarray (const Mapping&, Container&&)
│ │ │ │ + │ │ │ │ +
623
│ │ │ │ +
624template <class Element, class Extents, class Layout, class Accessor>
│ │ │ │ + │ │ │ │ +
626 -> mdarray<std::remove_cv_t<Element>, Extents, Layout>;
│ │ │ │ +
627
│ │ │ │ +
628template <class IndexType, std::size_t... exts, class Container, class Alloc>
│ │ │ │ +
629mdarray (const Std::extents<IndexType, exts...>&, const Container&, const Alloc&)
│ │ │ │ +
630 -> mdarray<typename Container::value_type, Std::extents<IndexType, exts...>, layout_right, Container>;
│ │ │ │ +
631
│ │ │ │ +
632template <class Mapping, class Container, class Alloc>
│ │ │ │ +
633mdarray (const Mapping&, const Container&, const Alloc&)
│ │ │ │ + │ │ │ │ +
635
│ │ │ │ +
636template <class IndexType, std::size_t... exts, class Container, class Alloc>
│ │ │ │ +
637mdarray (const Std::extents<IndexType, exts...>&, Container&&, const Alloc&)
│ │ │ │ +
638 -> mdarray<typename Container::value_type, Std::extents<IndexType, exts...>, layout_right, Container>;
│ │ │ │ +
639
│ │ │ │ +
640template <class Mapping, class Container, class Alloc>
│ │ │ │ +
641mdarray (const Mapping&, Container&&, const Alloc&)
│ │ │ │ + │ │ │ │ +
643
│ │ │ │ +
644template <class Element, class Extents, class Layout, class Accessor, class Alloc>
│ │ │ │ + │ │ │ │ +
646 -> mdarray<std::remove_cv_t<Element>, Extents, Layout>;
│ │ │ │ +
647
│ │ │ │ +
649
│ │ │ │ +
653
│ │ │ │ +
654template <class Element, class Extents, class Layout, class Container>
│ │ │ │ + │ │ │ │ +
656 typename decltype(std::declval<mdarray<Element, Extents, Layout, Container>>().to_mdspan())::element_type,
│ │ │ │ +
657 typename decltype(std::declval<mdarray<Element, Extents, Layout, Container>>().to_mdspan())::extents_type,
│ │ │ │ +
658 typename decltype(std::declval<mdarray<Element, Extents, Layout, Container>>().to_mdspan())::layout_type,
│ │ │ │ +
659 typename decltype(std::declval<mdarray<Element, Extents, Layout, Container>>().to_mdspan())::accessor_type>;
│ │ │ │ +
660
│ │ │ │ +
662
│ │ │ │ +
663} // end namespace Dune::Std
│ │ │ │ +
664
│ │ │ │ +
665#endif // DUNE_COMMON_STD_MDARRAY_HH
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
Utilities for reduction like operations on ranges.
│ │ │ │ +
decltype(auto) constexpr unpackIntegerSequence(F &&f, std::integer_sequence< I, i... > sequence)
Unpack an std::integer_sequence<I,i...> to std::integral_constant<I,i>...
Definition indices.hh:124
│ │ │ │
STL namespace.
│ │ │ │ -
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
A copyable type wrapper that provides copy/move assignment operations for types that are only copy/mo...
Definition copyableoptional.hh:35
│ │ │ │ -
constexpr CopyableOptional(CopyableOptional &&)=default
Move construct the contained value.
│ │ │ │ -
constexpr CopyableOptional(T &&value) noexcept(std::is_nothrow_constructible_v< Type, T && >)
Construct the internal data from perfect forwarding of the passed arguments. Participates in overload...
Definition copyableoptional.hh:62
│ │ │ │ -
constexpr CopyableOptional & operator=(const CopyableOptional &that) noexcept(std::is_nothrow_copy_assignable_v< Type >||(!std::is_copy_assignable_v< Type > &&std::is_nothrow_copy_constructible_v< Type >))
Copy assignment in terms of copy constructor.
Definition copyableoptional.hh:100
│ │ │ │ -
constexpr CopyableOptional() noexcept(std::is_nothrow_default_constructible_v< T >)
Implementation of a default constructor, if the Type is itself default constructible....
Definition copyableoptional.hh:49
│ │ │ │ -
constexpr CopyableOptional(const CopyableOptional &)=default
Copy construct the contained value.
│ │ │ │ -
constexpr CopyableOptional(Args &&... args) noexcept(std::is_nothrow_constructible_v< Type, Args &&... >)
Construct the internal data from perfect forwarding of the passed arguments.
Definition copyableoptional.hh:85
│ │ │ │ -
~CopyableOptional()=default
Default destructor.
│ │ │ │ +
Namespace for features backported from new C++ standards.
Definition default_accessor.hh:10
│ │ │ │ +
constexpr auto to_address(T &&p) noexcept
Obtain the address represented by p without forming a reference to the object pointed to by p.
Definition memory.hh:47
│ │ │ │ +
Get the 'const' version of a reference to a mutable object.
Definition genericiterator.hh:87
│ │ │ │ +
Multidimensional index space with dynamic and static extents.
Definition extents.hh:54
│ │ │ │ +
A layout where the rightmost extent has stride 1, and strides increase right-to-left as the product o...
Definition fwd_layouts.hh:30
│ │ │ │ +
An owning multi-dimensional array analog of mdspan.
Definition mdarray.hh:69
│ │ │ │ +
mdspan< const element_type, extents_type, layout_type > const_mdspan_type
Definition mdarray.hh:91
│ │ │ │ +
constexpr mdarray(const mapping_type &m, const container_type &c, const Alloc &a)
Construct from layout mapping, container and allocator.
Definition mdarray.hh:288
│ │ │ │ +
typename container_type::const_reference const_reference
Definition mdarray.hh:96
│ │ │ │ +
constexpr mdarray(const mapping_type &m, container_type &&c)
Construct from layout mapping and the storage container.
Definition mdarray.hh:194
│ │ │ │ +
Container container_type
Definition mdarray.hh:81
│ │ │ │ +
Extents extents_type
Definition mdarray.hh:79
│ │ │ │ +
constexpr mdarray(const E &e, const container_type &c)
Construct from extents and the storage container.
Definition mdarray.hh:174
│ │ │ │ +
static constexpr bool is_always_exhaustive() noexcept
Definition mdarray.hh:522
│ │ │ │ +
constexpr mdspan< const element_type, extents_type, layout_type, AccessorPolicy > to_mdspan(const AccessorPolicy &a=AccessorPolicy{}) const
Conversion function to mdspan.
Definition mdarray.hh:594
│ │ │ │ +
constexpr index_type stride(rank_type r) const
The stride along the specified dimension.
Definition mdarray.hh:516
│ │ │ │ +
constexpr bool is_unique() const noexcept
Definition mdarray.hh:525
│ │ │ │ +
constexpr index_type extent(rank_type r) const noexcept
Number of elements in the r'th dimension of the tensor.
Definition mdarray.hh:498
│ │ │ │ +
constexpr mdarray(const extents_type &e, const Alloc &a)
Construct from the extents of the array and allocator.
Definition mdarray.hh:243
│ │ │ │ +
static constexpr std::size_t static_extent(rank_type r) noexcept
Number of elements in the r'th dimension of the tensor.
Definition mdarray.hh:495
│ │ │ │ +
mapping_type mapping_
Definition mdarray.hh:601
│ │ │ │ +
constexpr mdarray(const mdspan< OtherElementType, OtherExtents, OtherLayoutPolicy, Accessor > &other)
Converting constructor from mdspan.
Definition mdarray.hh:229
│ │ │ │ +
typename layout_type::template mapping< extents_type > mapping_type
Definition mdarray.hh:84
│ │ │ │ +
constexpr const_pointer container_data() const noexcept
Direct access to the underlying const data in the container.
Definition mdarray.hh:537
│ │ │ │ +
constexpr mdarray(const extents_type &e, const value_type &v)
Construct from extents and initial value.
Definition mdarray.hh:155
│ │ │ │ +
constexpr mdarray(const mapping_type &m, const Alloc &a)
Construct from the layout mapping of the array and allocator.
Definition mdarray.hh:250
│ │ │ │ +
constexpr pointer container_data() noexcept
Direct access to the underlying data in the container.
Definition mdarray.hh:534
│ │ │ │ +
constexpr bool is_exhaustive() const noexcept
Definition mdarray.hh:526
│ │ │ │ +
decltype(Std::to_address(std::declval< container_type >().begin())) pointer
Definition mdarray.hh:93
│ │ │ │ +
constexpr reference operator[](Index index)
Access specified element at position [i0] For a rank one mdarray, the operator[i] is added to support...
Definition mdarray.hh:408
│ │ │ │ +
constexpr const extents_type & extents() const noexcept
Number of elements in all dimensions of the array,.
Definition mdarray.hh:468
│ │ │ │ +
constexpr bool is_strided() const noexcept
Definition mdarray.hh:527
│ │ │ │ +
constexpr mdarray(const mapping_type &m, const container_type &c)
Construct from layout mapping and the storage container.
Definition mdarray.hh:188
│ │ │ │ +
static constexpr bool is_always_unique() noexcept
Definition mdarray.hh:521
│ │ │ │ +
constexpr mdarray(const mapping_type &m, container_type &&c, const Alloc &a)
Construct from layout mapping, container and allocator.
Definition mdarray.hh:296
│ │ │ │ +
constexpr mdarray(const E &e, container_type &&c)
Construct from extents and the storage container.
Definition mdarray.hh:182
│ │ │ │ +
constexpr const container_type & container() const noexcept
The underlying storage container.
Definition mdarray.hh:474
│ │ │ │ +
constexpr std::size_t container_size() const
Size of the underlying container.
Definition mdarray.hh:510
│ │ │ │ +
typename extents_type::size_type size_type
Definition mdarray.hh:87
│ │ │ │ +
static constexpr rank_type rank() noexcept
Number of dimensions of the array.
Definition mdarray.hh:489
│ │ │ │ +
constexpr bool empty() const noexcept
Check whether the index space is empty.
Definition mdarray.hh:513
│ │ │ │ +
constexpr mdarray(const extents_type &e, container_type &&c, const Alloc &a)
Construct from extents, container and allocator.
Definition mdarray.hh:280
│ │ │ │ +
mdspan< element_type, extents_type, layout_type > mdspan_type
Definition mdarray.hh:90
│ │ │ │ +
constexpr size_type size() const noexcept
Size of the multi-dimensional index space.
Definition mdarray.hh:501
│ │ │ │ +
friend constexpr bool operator==(const mdarray &lhs, const mdarray &rhs) noexcept
Definition mdarray.hh:553
│ │ │ │ +
friend constexpr void swap(mdarray &x, mdarray &y) noexcept
Definition mdarray.hh:542
│ │ │ │ +
constexpr const mapping_type & mapping() const noexcept
Index mapping of a layout policy.
Definition mdarray.hh:471
│ │ │ │ +
Element element_type
Definition mdarray.hh:78
│ │ │ │ +
constexpr mdarray(const mapping_type &m, const value_type &v, const Alloc &a)
Construct from layout mapping, initial value and allocator.
Definition mdarray.hh:264
│ │ │ │ +
constexpr mdarray(const extents_type &e, const value_type &v, const Alloc &a)
Construct from extents, initial value and allocator.
Definition mdarray.hh:257
│ │ │ │ +
decltype(Std::to_address(std::declval< container_type >().cbegin())) const_pointer
Definition mdarray.hh:95
│ │ │ │ +
typename container_type::reference reference
Definition mdarray.hh:94
│ │ │ │ +
constexpr mdspan< element_type, extents_type, layout_type, AccessorPolicy > to_mdspan(const AccessorPolicy &a=AccessorPolicy{})
Conversion function to mdspan.
Definition mdarray.hh:584
│ │ │ │ +
element_type value_type
Definition mdarray.hh:83
│ │ │ │ +
LayoutPolicy layout_type
Definition mdarray.hh:80
│ │ │ │ +
constexpr container_type && extract_container() &&noexcept
Move the container out of the mdarray.
Definition mdarray.hh:482
│ │ │ │ +
constexpr mdarray(const extents_type &e, const container_type &c, const Alloc &a)
Construct from extents, container and allocator.
Definition mdarray.hh:272
│ │ │ │ +
typename extents_type::rank_type rank_type
Definition mdarray.hh:88
│ │ │ │ +
static constexpr rank_type rank_dynamic() noexcept
Number of dimension with dynamic size.
Definition mdarray.hh:492
│ │ │ │ +
constexpr reference operator()(Indices... indices)
Access element at position (i0,i1,...)
Definition mdarray.hh:363
│ │ │ │ +
constexpr mdarray(const extents_type &e)
Construct from the extents of the array.
Definition mdarray.hh:138
│ │ │ │ +
container_type container_
Definition mdarray.hh:600
│ │ │ │ +
typename extents_type::index_type index_type
Definition mdarray.hh:86
│ │ │ │ +
constexpr mdarray(IndexTypes... exts)
Construct from the dynamic extents.
Definition mdarray.hh:133
│ │ │ │ +
static constexpr bool is_always_strided() noexcept
Definition mdarray.hh:523
│ │ │ │ +
A multi-dimensional non-owning array view.
Definition mdspan.hh:64
│ │ │ │ +
constexpr index_type extent(rank_type r) const noexcept
Number of elements in the r'th dimension of the tensor.
Definition mdspan.hh:275
│ │ │ │ +
constexpr size_type size() const noexcept
The number of elements accessible by this multi-dimensional span.
Definition mdspan.hh:278
│ │ │ │ +
A contiguous sequence of elements with static or dynamic extent.
Definition span.hh:126
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,188 +1,909 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -copyableoptional.hh │ │ │ │ │ + * std │ │ │ │ │ +mdarray.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_COMMON_COPYABLE_OPTIONAL_HH │ │ │ │ │ -6#define DUNE_COMMON_COPYABLE_OPTIONAL_HH │ │ │ │ │ +5#ifndef DUNE_COMMON_STD_MDARRAY_HH │ │ │ │ │ +6#define DUNE_COMMON_STD_MDARRAY_HH │ │ │ │ │ 7 │ │ │ │ │ -8#include │ │ │ │ │ -9#include │ │ │ │ │ +8#include │ │ │ │ │ +9#include │ │ │ │ │ 10#include │ │ │ │ │ -11#include │ │ │ │ │ -12#include │ │ │ │ │ -13 │ │ │ │ │ -14#include │ │ │ │ │ -15 │ │ │ │ │ -16namespace Dune { │ │ │ │ │ +11#include │ │ │ │ │ +12#include │ │ │ │ │ +13#include │ │ │ │ │ +14#if __has_include() │ │ │ │ │ +15 #include │ │ │ │ │ +16#endif │ │ │ │ │ 17 │ │ │ │ │ -32template │ │ │ │ │ -33class CopyableOptional │ │ │ │ │ -34 : public std::optional │ │ │ │ │ -35{ │ │ │ │ │ -36 static_assert(std::is_copy_constructible_v); │ │ │ │ │ -37 static_assert(std::is_object_v); │ │ │ │ │ -38 │ │ │ │ │ -39 using Base = std::optional; │ │ │ │ │ -40 │ │ │ │ │ -41public: │ │ │ │ │ -42 │ │ │ │ │ -47 template , int> = 0> │ │ │ │ │ -49 constexpr CopyableOptional () │ │ │ │ │ -50 noexcept(std::is_nothrow_default_constructible_v) │ │ │ │ │ -51 : Base{std::in_place} │ │ │ │ │ -52 {} │ │ │ │ │ -53 │ │ │ │ │ -58 template = 0, │ │ │ │ │ -60 std::enable_if_t, int> = 0, │ │ │ │ │ -61 std::enable_if_t, int> = 0> │ │ │ │ │ -62 constexpr CopyableOptional (T&& value) │ │ │ │ │ -63 noexcept(std::is_nothrow_constructible_v) │ │ │ │ │ -64 : Base{std::in_place, std::forward(value)} │ │ │ │ │ -65 {} │ │ │ │ │ -66 │ │ │ │ │ -71 template = 0, │ │ │ │ │ -73 std::enable_if_t, int> = 0, │ │ │ │ │ -74 std::enable_if_t, int> = 0> │ │ │ │ │ -75 explicit constexpr CopyableOptional (T&& value) │ │ │ │ │ -76 noexcept(std::is_nothrow_constructible_v) │ │ │ │ │ -77 : Base{std::in_place, std::forward(value)} │ │ │ │ │ -78 {} │ │ │ │ │ -79 │ │ │ │ │ -81 template = 0, │ │ │ │ │ -83 std::enable_if_t<(sizeof...(Args) > 1), int> = 0, │ │ │ │ │ -84 std::enable_if_t, int> = 0> │ │ │ │ │ -85 constexpr CopyableOptional (Args&&... args) │ │ │ │ │ -86 noexcept(std::is_nothrow_constructible_v) │ │ │ │ │ -87 : Base{std::in_place, std::forward(args)...} │ │ │ │ │ -88 {} │ │ │ │ │ +18#include │ │ │ │ │ +19#include │ │ │ │ │ +20#include │ │ │ │ │ +21#include │ │ │ │ │ +22#include │ │ │ │ │ +23#include │ │ │ │ │ +24#include │ │ │ │ │ +25 │ │ │ │ │ +26namespace Dune::Std { │ │ │ │ │ +27 │ │ │ │ │ +66template > │ │ │ │ │ +68class mdarray │ │ │ │ │ +69{ │ │ │ │ │ +70 template friend class mdarray; │ │ │ │ │ +71 │ │ │ │ │ +72 static_assert(std::is_object_v); │ │ │ │ │ +73 static_assert(!std::is_abstract_v); │ │ │ │ │ +74 static_assert(!std::is_array_v); │ │ │ │ │ +75 static_assert(std::is_same_v); │ │ │ │ │ +76 │ │ │ │ │ +77public: │ │ │ │ │ +78 using element_type = Element; │ │ │ │ │ +79 using extents_type = Extents; │ │ │ │ │ +80 using layout_type = LayoutPolicy; │ │ │ │ │ +81 using container_type = Container; │ │ │ │ │ +82 │ │ │ │ │ +83 using value_type = element_type; │ │ │ │ │ +84 using mapping_type = typename layout_type::template mapping; │ │ │ │ │ +85 │ │ │ │ │ +86 using index_type = typename extents_type::index_type; │ │ │ │ │ +87 using size_type = typename extents_type::size_type; │ │ │ │ │ +88 using rank_type = typename extents_type::rank_type; │ │ │ │ │ 89 │ │ │ │ │ -91 constexpr CopyableOptional (const CopyableOptional&) = default; │ │ │ │ │ +90 using mdspan_type = mdspan; │ │ │ │ │ +91 using const_mdspan_type = mdspan; │ │ │ │ │ 92 │ │ │ │ │ -94 constexpr CopyableOptional (CopyableOptional&&) = default; │ │ │ │ │ -95 │ │ │ │ │ -97 ~CopyableOptional () = default; │ │ │ │ │ -98 │ │ │ │ │ -100 constexpr CopyableOptional& operator=_(const CopyableOptional& that) │ │ │ │ │ -101 noexcept(std::is_nothrow_copy_assignable_v || │ │ │ │ │ -102 (!std::is_copy_assignable_v && std::is_nothrow_copy_constructible_ │ │ │ │ │ -v)) │ │ │ │ │ -103 { │ │ │ │ │ -104 if constexpr(std::is_copy_assignable_v) │ │ │ │ │ -105 Base::operator=(that); │ │ │ │ │ -106 else { │ │ │ │ │ -107 // no self-assignment │ │ │ │ │ -108 if (this != std::addressof(that)) { │ │ │ │ │ -109 if (that) │ │ │ │ │ -110 Base::emplace(*that); │ │ │ │ │ -111 else │ │ │ │ │ -112 Base::reset(); │ │ │ │ │ -113 } │ │ │ │ │ -114 } │ │ │ │ │ -115 return *this; │ │ │ │ │ -116 } │ │ │ │ │ -117 │ │ │ │ │ -119 template , int> = 0> │ │ │ │ │ -121 constexpr CopyableOptional& operator=_(CopyableOptional&& that) │ │ │ │ │ -122 noexcept(std::is_nothrow_move_assignable_v || │ │ │ │ │ -123 (!std::is_move_assignable_v && std::is_nothrow_move_constructible_ │ │ │ │ │ -v)) │ │ │ │ │ -124 { │ │ │ │ │ -125 if constexpr(std::is_move_assignable_v) │ │ │ │ │ -126 Base::operator=(std::move(that)); │ │ │ │ │ -127 else { │ │ │ │ │ -128 // no self-assignment │ │ │ │ │ -129 if (this != std::addressof(that)) { │ │ │ │ │ -130 if (that) │ │ │ │ │ -131 Base::emplace(std::move(*that)); │ │ │ │ │ -132 else │ │ │ │ │ -133 Base::reset(); │ │ │ │ │ -134 } │ │ │ │ │ -135 } │ │ │ │ │ -136 return *this; │ │ │ │ │ -137 } │ │ │ │ │ -138 │ │ │ │ │ -140 template , CopyableOptional>, │ │ │ │ │ +93 using pointer = decltype(Std::to_address(std::declval │ │ │ │ │ +().begin())); │ │ │ │ │ +94 using reference = typename container_type::reference; │ │ │ │ │ +95 using const_pointer = decltype(Std::to_address(std::declval │ │ │ │ │ +().cbegin())); │ │ │ │ │ +96 using const_reference = typename container_type::const_reference; │ │ │ │ │ +97 │ │ │ │ │ +98 static_assert(std::is_constructible_v); │ │ │ │ │ +99 │ │ │ │ │ +100private: │ │ │ │ │ +101 // helper function to construct the container │ │ │ │ │ +102 template │ │ │ │ │ +103 static constexpr auto construct_container (Args&&... args) │ │ │ │ │ +104 -> decltype(Impl::ContainerConstructionTraits::construct(std:: │ │ │ │ │ +forward(args)...)) │ │ │ │ │ +105 { │ │ │ │ │ +106 return Impl::ContainerConstructionTraits::construct(std::forward │ │ │ │ │ +(args)...); │ │ │ │ │ +107 } │ │ │ │ │ +108 │ │ │ │ │ +109public: │ │ │ │ │ +112 │ │ │ │ │ +114 template = 0, │ │ │ │ │ +116 std::enable_if_t, int> = 0, │ │ │ │ │ +117 std::enable_if_t, int> = 0> │ │ │ │ │ +118 constexpr mdarray () │ │ │ │ │ +119 : container_{} │ │ │ │ │ +120 , mapping_{} │ │ │ │ │ +121 {} │ │ │ │ │ +122 │ │ │ │ │ +123 │ │ │ │ │ +124 // ------------------------------------- │ │ │ │ │ +125 // constructors from extents or mappings │ │ │ │ │ +126 │ │ │ │ │ +127 │ │ │ │ │ +129 template ), │ │ │ │ │ int> = 0, │ │ │ │ │ -142 std::enable_if_t<(std::is_assignable_v || std::is_constructible_ │ │ │ │ │ -v), int> = 0> │ │ │ │ │ -143 constexpr CopyableOptional& operator= (T&& value) │ │ │ │ │ -144 noexcept(std::is_nothrow_assignable_v || │ │ │ │ │ -145 (!std::is_assignable_v && std::is_nothrow_constructible_ │ │ │ │ │ -v)) │ │ │ │ │ -146 { │ │ │ │ │ -147 if constexpr(std::is_assignable_v) │ │ │ │ │ -148 Base::operator=(std::forward(value)); │ │ │ │ │ -149 else │ │ │ │ │ -150 Base::emplace(std::forward(value)); │ │ │ │ │ -151 return *this; │ │ │ │ │ -152 } │ │ │ │ │ -153}; │ │ │ │ │ -154 │ │ │ │ │ -155} // end namespace Dune │ │ │ │ │ -156 │ │ │ │ │ -157#endif // DUNE_COMMON_COPYABLE_OPTIONAL_HH │ │ │ │ │ -typeutilities.hh │ │ │ │ │ -Utilities for type computations, constraining overloads, ... │ │ │ │ │ -Dune::disableCopyMove │ │ │ │ │ -std::enable_if_t< not Impl::disableCopyMoveHelper< This, T... >::value, int > │ │ │ │ │ -disableCopyMove │ │ │ │ │ -Helper to disable constructor as copy and move constructor. │ │ │ │ │ -Definition typeutilities.hh:45 │ │ │ │ │ +131 std::enable_if_t, int> │ │ │ │ │ += 0, │ │ │ │ │ +132 std::enable_if_t<(... && std::is_nothrow_constructible_v), int> = 0> │ │ │ │ │ +133 explicit constexpr mdarray (IndexTypes... exts) │ │ │ │ │ +134 : mdarray(extents_type(index_type(std::move(exts))...)) │ │ │ │ │ +135 {} │ │ │ │ │ +136 │ │ │ │ │ +138 explicit constexpr mdarray (const extents_type& e) │ │ │ │ │ +139 : mdarray(mapping_type(e)) │ │ │ │ │ +140 {} │ │ │ │ │ +141 │ │ │ │ │ +143 template (std::declval()), bool{}) = │ │ │ │ │ +true> │ │ │ │ │ +145 explicit constexpr mdarray (const mapping_type& m) │ │ │ │ │ +146 : container_(construct_container(m.required_span_size())) │ │ │ │ │ +147 , mapping_(m) │ │ │ │ │ +148 {} │ │ │ │ │ +149 │ │ │ │ │ +150 │ │ │ │ │ +151 // --------------------------------------- │ │ │ │ │ +152 // constructors with a given initial value │ │ │ │ │ +153 │ │ │ │ │ +155 constexpr mdarray (const extents_type& e, const value_type& v) │ │ │ │ │ +156 : mdarray(mapping_type(e), v) │ │ │ │ │ +157 {} │ │ │ │ │ +158 │ │ │ │ │ +160 template (std::declval(),std:: │ │ │ │ │ +declval()), bool{}) = true> │ │ │ │ │ +162 constexpr mdarray (const mapping_type& m, const value_type& v) │ │ │ │ │ +163 : container_(construct_container(m.required_span_size(), v)) │ │ │ │ │ +164 , mapping_(m) │ │ │ │ │ +165 {} │ │ │ │ │ +166 │ │ │ │ │ +167 │ │ │ │ │ +168 // ----------------------------------- │ │ │ │ │ +169 // constructors with a given container │ │ │ │ │ +170 │ │ │ │ │ +172 template , int> = 0> │ │ │ │ │ +174 constexpr mdarray (const E& e, const container_type& c) │ │ │ │ │ +175 : container_(c) │ │ │ │ │ +176 , mapping_(e) │ │ │ │ │ +177 {} │ │ │ │ │ +178 │ │ │ │ │ +180 template , int> = 0> │ │ │ │ │ +182 constexpr mdarray (const E& e, container_type&& c) │ │ │ │ │ +183 : container_(std::move(c)) │ │ │ │ │ +184 , mapping_(e) │ │ │ │ │ +185 {} │ │ │ │ │ +186 │ │ │ │ │ +188 constexpr mdarray (const mapping_type& m, const container_type& c) │ │ │ │ │ +189 : container_(c) │ │ │ │ │ +190 , mapping_(m) │ │ │ │ │ +191 {} │ │ │ │ │ +192 │ │ │ │ │ +194 constexpr mdarray (const mapping_type& m, container_type&& c) │ │ │ │ │ +195 : container_(std::move(c)) │ │ │ │ │ +196 , mapping_(m) │ │ │ │ │ +197 {} │ │ │ │ │ +198 │ │ │ │ │ +199 │ │ │ │ │ +200 // ----------------------- │ │ │ │ │ +201 // converting constructors │ │ │ │ │ +202 │ │ │ │ │ +204 template , │ │ │ │ │ +int> = 0, │ │ │ │ │ +206 std::enable_if_t, int> = │ │ │ │ │ +0, │ │ │ │ │ +207 std::enable_if_t&>, int> = 0> │ │ │ │ │ +208 #if __cpp_conditional_explicit >= 201806L │ │ │ │ │ +209 explicit( │ │ │ │ │ +210 !std::is_convertible_v&, mapping_type> || │ │ │ │ │ +211 !std::is_convertible_v) │ │ │ │ │ +212 #endif │ │ │ │ │ +213 constexpr mdarray (const │ │ │ │ │ +mdarray& other) │ │ │ │ │ +214 : container_(other.container_) │ │ │ │ │ +215 , mapping_(other.mapping_) │ │ │ │ │ +216 {} │ │ │ │ │ +217 │ │ │ │ │ +219 template , int> = 0, │ │ │ │ │ +221 std::enable_if_t, int> = 0, │ │ │ │ │ +222 std::enable_if_t&>, int> = 0, │ │ │ │ │ +223 decltype(construct_container(std::declval()), │ │ │ │ │ +bool{}) = true> │ │ │ │ │ +224 #if __cpp_conditional_explicit >= 201806L │ │ │ │ │ +225 explicit( │ │ │ │ │ +226 !std::is_convertible_v&, mapping_type> || │ │ │ │ │ +227 !std::is_convertible_v) │ │ │ │ │ +228 #endif │ │ │ │ │ +229 constexpr mdarray (const │ │ │ │ │ +mdspan& other) │ │ │ │ │ +230 : container_(construct_container(other.size())) │ │ │ │ │ +231 , mapping_(other.mapping()) │ │ │ │ │ +232 { │ │ │ │ │ +233 init_from_mdspan(other); │ │ │ │ │ +234 } │ │ │ │ │ +235 │ │ │ │ │ +236 │ │ │ │ │ +237 // ---------------------------- │ │ │ │ │ +238 // constructors with allocators │ │ │ │ │ +239 │ │ │ │ │ +241 template , int> = 0> │ │ │ │ │ +243 constexpr mdarray (const extents_type& e, const Alloc& a) │ │ │ │ │ +244 : mdarray(mapping_type(e), a) │ │ │ │ │ +245 {} │ │ │ │ │ +246 │ │ │ │ │ +248 template , int> = 0> │ │ │ │ │ +250 constexpr mdarray (const mapping_type& m, const Alloc& a) │ │ │ │ │ +251 : container_(m.required_span_size(), a) │ │ │ │ │ +252 , mapping_(m) │ │ │ │ │ +253 {} │ │ │ │ │ +254 │ │ │ │ │ +256 template │ │ │ │ │ +257 constexpr mdarray (const extents_type& e, const value_type& v, const Alloc& │ │ │ │ │ +a) │ │ │ │ │ +258 : mdarray(mapping_type(e), v, a) │ │ │ │ │ +259 {} │ │ │ │ │ +260 │ │ │ │ │ +262 template , int> = 0> │ │ │ │ │ +264 constexpr mdarray (const mapping_type& m, const value_type& v, const Alloc& │ │ │ │ │ +a) │ │ │ │ │ +265 : container_(m.required_span_size(), v, a) │ │ │ │ │ +266 , mapping_(m) │ │ │ │ │ +267 {} │ │ │ │ │ +268 │ │ │ │ │ +270 template , int> = 0> │ │ │ │ │ +272 constexpr mdarray (const extents_type& e, const container_type& c, const │ │ │ │ │ +Alloc& a) │ │ │ │ │ +273 : container_(c, a) │ │ │ │ │ +274 , mapping_(e) │ │ │ │ │ +275 {} │ │ │ │ │ +276 │ │ │ │ │ +278 template , int> = 0> │ │ │ │ │ +280 constexpr mdarray (const extents_type& e, container_type&& c, const Alloc& │ │ │ │ │ +a) │ │ │ │ │ +281 : container_(std::move(c), a) │ │ │ │ │ +282 , mapping_(e) │ │ │ │ │ +283 {} │ │ │ │ │ +284 │ │ │ │ │ +286 template , int> = 0> │ │ │ │ │ +288 constexpr mdarray (const mapping_type& m, const container_type& c, const │ │ │ │ │ +Alloc& a) │ │ │ │ │ +289 : container_(c, a) │ │ │ │ │ +290 , mapping_(m) │ │ │ │ │ +291 {} │ │ │ │ │ +292 │ │ │ │ │ +294 template , int> = 0> │ │ │ │ │ +296 constexpr mdarray (const mapping_type& m, container_type&& c, const Alloc& │ │ │ │ │ +a) │ │ │ │ │ +297 : container_(std::move(c), a) │ │ │ │ │ +298 , mapping_(m) │ │ │ │ │ +299 {} │ │ │ │ │ +300 │ │ │ │ │ +302 template , int> = │ │ │ │ │ +0> │ │ │ │ │ +304 #if __cpp_conditional_explicit >= 201806L │ │ │ │ │ +305 explicit( │ │ │ │ │ +306 !std::is_convertible_v&, mapping_ │ │ │ │ │ +type> || │ │ │ │ │ +307 !std::is_convertible_v) │ │ │ │ │ +308 #endif │ │ │ │ │ +309 constexpr mdarray (const mdarray& other, const Alloc& a) noexcept │ │ │ │ │ +310 : container_(other.container_, a) │ │ │ │ │ +311 , mapping_(other.mapping_) │ │ │ │ │ +312 {} │ │ │ │ │ +313 │ │ │ │ │ +315 template , int> = 0> │ │ │ │ │ +319 #if __cpp_conditional_explicit >= 201806L │ │ │ │ │ +320 explicit( │ │ │ │ │ +321 !std::is_convertible_v&, mapping_ │ │ │ │ │ +type> || │ │ │ │ │ +322 !std::is_convertible_v || │ │ │ │ │ +323 !std::is_convertible_v) │ │ │ │ │ +324 #endif │ │ │ │ │ +325 constexpr mdarray (const mdspan& other, const Alloc& a) │ │ │ │ │ +326 : container_(other.size(), a) │ │ │ │ │ +327 , mapping_(other.mapping_) │ │ │ │ │ +328 { │ │ │ │ │ +329 init_from_mdspan(other); │ │ │ │ │ +330 } │ │ │ │ │ +331 │ │ │ │ │ +333 │ │ │ │ │ +334private: │ │ │ │ │ +335 │ │ │ │ │ +336 template │ │ │ │ │ +337 void init_from_mdspan (const mdspan& other, Indices... ii) │ │ │ │ │ +338 { │ │ │ │ │ +339 constexpr rank_type pos = sizeof...(Indices); │ │ │ │ │ +340 if constexpr(pos < rank()) { │ │ │ │ │ +341 for (typename E::index_type i = 0; i < other.extent(pos); ++i) │ │ │ │ │ +342 init_from_mdspan(other,ii...,i); │ │ │ │ │ +343 } else { │ │ │ │ │ +344 using I = std::array; │ │ │ │ │ +345 container_[mapping_(index_type(ii)...)] = other[I{ii...}]; │ │ │ │ │ +346 } │ │ │ │ │ +347 } │ │ │ │ │ +348 │ │ │ │ │ +349public: │ │ │ │ │ +350 │ │ │ │ │ +353 │ │ │ │ │ +360 template = 0, │ │ │ │ │ +362 std::enable_if_t<(... && std::is_convertible_v), int> = │ │ │ │ │ +0> │ │ │ │ │ +363 constexpr reference operator()_(Indices... indices) │ │ │ │ │ +364 { │ │ │ │ │ +365 return container_[mapping_(index_type(std::move(indices))...)]; │ │ │ │ │ +366 } │ │ │ │ │ +367 │ │ │ │ │ +372 template = 0, │ │ │ │ │ +374 std::enable_if_t<(... && std::is_convertible_v), int> = │ │ │ │ │ +0> │ │ │ │ │ +375 constexpr const_reference operator()_(Indices... indices) const │ │ │ │ │ +376 { │ │ │ │ │ +377 return container_[mapping_(index_type(std::move(indices))...)]; │ │ │ │ │ +378 } │ │ │ │ │ +379 │ │ │ │ │ +380 │ │ │ │ │ +381#if __cpp_multidimensional_subscript >= 202110L │ │ │ │ │ +382 │ │ │ │ │ +384 template = 0, │ │ │ │ │ +386 std::enable_if_t<(... && std::is_convertible_v), int> = │ │ │ │ │ +0> │ │ │ │ │ +387 constexpr reference operator[]_(Indices... indices) │ │ │ │ │ +388 { │ │ │ │ │ +389 return container_[mapping_(index_type(std::move(indices))...)]; │ │ │ │ │ +390 } │ │ │ │ │ +391 │ │ │ │ │ +393 template = 0, │ │ │ │ │ +395 std::enable_if_t<(... && std::is_convertible_v), int> = │ │ │ │ │ +0> │ │ │ │ │ +396 constexpr const_reference operator[]_(Indices... indices) const │ │ │ │ │ +397 { │ │ │ │ │ +398 return container_[mapping_(index_type(std::move(indices))...)]; │ │ │ │ │ +399 } │ │ │ │ │ +400 │ │ │ │ │ +401#else │ │ │ │ │ +402 │ │ │ │ │ +405 template , int> = 0, │ │ │ │ │ +407 std::enable_if_t<(E::rank() == 1), int> = 0> │ │ │ │ │ +408 constexpr reference operator[] (Index index) │ │ │ │ │ +409 { │ │ │ │ │ +410 return container_[mapping_(index_type(std::move(index)))]; │ │ │ │ │ +411 } │ │ │ │ │ +412 │ │ │ │ │ +415 template , int> = 0, │ │ │ │ │ +417 std::enable_if_t<(E::rank() == 1), int> = 0> │ │ │ │ │ +418 constexpr const_reference operator[] (Index index) const │ │ │ │ │ +419 { │ │ │ │ │ +420 return container_[mapping_(index_type(std::move(index)))]; │ │ │ │ │ +421 } │ │ │ │ │ +422 │ │ │ │ │ +423#endif │ │ │ │ │ +424 │ │ │ │ │ +425 │ │ │ │ │ +427 template , int> = 0> │ │ │ │ │ +429 constexpr reference operator[]_(Std::span │ │ │ │ │ +indices) │ │ │ │ │ +430 { │ │ │ │ │ +431 return unpackIntegerSequence([&](auto... ii) -> reference { │ │ │ │ │ +432 return container_[mapping_(index_type(indices[ii])...)]; }, │ │ │ │ │ +433 std::make_index_sequence{}); │ │ │ │ │ +434 } │ │ │ │ │ +435 │ │ │ │ │ +437 template , int> = 0> │ │ │ │ │ +439 constexpr const_reference operator[]_(Std::span │ │ │ │ │ +indices) const │ │ │ │ │ +440 { │ │ │ │ │ +441 return unpackIntegerSequence([&](auto... ii) -> const_reference { │ │ │ │ │ +442 return container_[mapping_(index_type(indices[ii])...)]; }, │ │ │ │ │ +443 std::make_index_sequence{}); │ │ │ │ │ +444 } │ │ │ │ │ +445 │ │ │ │ │ +447 template , int> = 0> │ │ │ │ │ +449 constexpr reference operator[]_(const std::array& indices) │ │ │ │ │ +450 { │ │ │ │ │ +451 return std::apply([&](auto... ii) -> reference { │ │ │ │ │ +452 return container_[mapping_(index_type(ii)...)]; }, indices); │ │ │ │ │ +453 } │ │ │ │ │ +454 │ │ │ │ │ +456 template , int> = 0> │ │ │ │ │ +458 constexpr const_reference operator[]_(const std::array& indices) const │ │ │ │ │ +459 { │ │ │ │ │ +460 return std::apply([&](auto... ii) -> const_reference { │ │ │ │ │ +461 return container_[mapping_(index_type(ii)...)]; }, indices); │ │ │ │ │ +462 } │ │ │ │ │ +463 │ │ │ │ │ +465 │ │ │ │ │ +466 │ │ │ │ │ +468 constexpr const extents_type& extents () const noexcept { return │ │ │ │ │ +mapping_.extents(); } │ │ │ │ │ +469 │ │ │ │ │ +471 constexpr const mapping_type& mapping () const noexcept { return mapping_; │ │ │ │ │ +} │ │ │ │ │ +472 │ │ │ │ │ +474 constexpr const container_type& container () const noexcept { return │ │ │ │ │ +container_; } │ │ │ │ │ +475 │ │ │ │ │ +482 constexpr container_type&& extract_container () && noexcept { return std:: │ │ │ │ │ +move(container_); } │ │ │ │ │ +483 │ │ │ │ │ +484 │ │ │ │ │ +487 │ │ │ │ │ +489 static constexpr rank_type rank () noexcept { return extents_type::rank(); │ │ │ │ │ +} │ │ │ │ │ +490 │ │ │ │ │ +492 static constexpr rank_type rank_dynamic () noexcept { return extents_type:: │ │ │ │ │ +rank_dynamic(); } │ │ │ │ │ +493 │ │ │ │ │ +495 static constexpr std::size_t static_extent (rank_type r) noexcept { return │ │ │ │ │ +extents_type::static_extent(r); } │ │ │ │ │ +496 │ │ │ │ │ +498 constexpr index_type extent (rank_type r) const noexcept { return extents │ │ │ │ │ +().extent(r); } │ │ │ │ │ +499 │ │ │ │ │ +501 constexpr size_type size () const noexcept │ │ │ │ │ +502 { │ │ │ │ │ +503 size_type s = 1; │ │ │ │ │ +504 for (rank_type r = 0; r < rank(); ++r) │ │ │ │ │ +505 s *= extent(r); │ │ │ │ │ +506 return s; │ │ │ │ │ +507 } │ │ │ │ │ +508 │ │ │ │ │ +510 constexpr std::size_t container_size () const { return container_.size(); } │ │ │ │ │ +511 │ │ │ │ │ +513 [[nodiscard]] constexpr bool empty () const noexcept { return size() == 0; │ │ │ │ │ +} │ │ │ │ │ +514 │ │ │ │ │ +516 constexpr index_type stride (rank_type r) const { return mapping().stride │ │ │ │ │ +(r); }; │ │ │ │ │ +517 │ │ │ │ │ +519 │ │ │ │ │ +520 │ │ │ │ │ +521 static constexpr bool is_always_unique () noexcept { return mapping_type:: │ │ │ │ │ +is_always_unique(); } │ │ │ │ │ +522 static constexpr bool is_always_exhaustive () noexcept { return mapping_ │ │ │ │ │ +type::is_always_exhaustive(); } │ │ │ │ │ +523 static constexpr bool is_always_strided () noexcept { return mapping_type:: │ │ │ │ │ +is_always_strided(); } │ │ │ │ │ +524 │ │ │ │ │ +525 constexpr bool is_unique () const noexcept { return mapping_.is_unique(); } │ │ │ │ │ +526 constexpr bool is_exhaustive () const noexcept { return mapping_.is_ │ │ │ │ │ +exhaustive(); } │ │ │ │ │ +527 constexpr bool is_strided () const noexcept { return mapping_.is_strided(); │ │ │ │ │ +} │ │ │ │ │ +528 │ │ │ │ │ +529 │ │ │ │ │ +532 │ │ │ │ │ +534 constexpr pointer container_data () noexcept { return Std::to_address │ │ │ │ │ +(container_.begin()); } │ │ │ │ │ +535 │ │ │ │ │ +537 constexpr const_pointer container_data () const noexcept { return Std::to_ │ │ │ │ │ +address(container_.begin()); } │ │ │ │ │ +538 │ │ │ │ │ +540 │ │ │ │ │ +541 │ │ │ │ │ +542 friend constexpr void swap (mdarray& x, mdarray& y) noexcept │ │ │ │ │ +543 { │ │ │ │ │ +544 using std::swap; │ │ │ │ │ +545 swap(x.container_, y.container_); │ │ │ │ │ +546 swap(x.mapping_, y.mapping_); │ │ │ │ │ +547 } │ │ │ │ │ +548 │ │ │ │ │ +549 │ │ │ │ │ +552 │ │ │ │ │ +553 friend constexpr bool operator==_(const mdarray& lhs, const mdarray& rhs) │ │ │ │ │ +noexcept │ │ │ │ │ +554 { │ │ │ │ │ +555 return lhs.mapping() == rhs.mapping() && lhs.container() == rhs.container │ │ │ │ │ +(); │ │ │ │ │ +556 } │ │ │ │ │ +557 │ │ │ │ │ +559 │ │ │ │ │ +562 │ │ │ │ │ +564 template , mdspan_type>, int> = │ │ │ │ │ +0> │ │ │ │ │ +566 constexpr operator mdspan () │ │ │ │ │ +567 { │ │ │ │ │ +568 return mdspan_type(container_data(), mapping()); │ │ │ │ │ +569 } │ │ │ │ │ +570 │ │ │ │ │ +572 template , const_mdspan_type>, │ │ │ │ │ +int> = 0> │ │ │ │ │ +574 constexpr operator mdspan () const │ │ │ │ │ +575 { │ │ │ │ │ +576 return const_mdspan_type(container_data(), mapping()); │ │ │ │ │ +577 } │ │ │ │ │ +578 │ │ │ │ │ +580 template , │ │ │ │ │ +581 std::enable_if_t< │ │ │ │ │ +582 std::is_assignable_v>, int> = 0> │ │ │ │ │ +583 constexpr mdspan │ │ │ │ │ +584 to_mdspan (const AccessorPolicy& a = AccessorPolicy{}) │ │ │ │ │ +585 { │ │ │ │ │ +586 return mdspan │ │ │ │ │ +(container_data(), mapping(), a); │ │ │ │ │ +587 } │ │ │ │ │ +588 │ │ │ │ │ +590 template , │ │ │ │ │ +591 std::enable_if_t< │ │ │ │ │ +592 std::is_assignable_v>, int> = 0> │ │ │ │ │ +593 constexpr mdspan │ │ │ │ │ +594 to_mdspan (const AccessorPolicy& a = AccessorPolicy{}) const │ │ │ │ │ +595 { │ │ │ │ │ +596 return mdspan │ │ │ │ │ +(container_data(), mapping(), a); │ │ │ │ │ +597 } │ │ │ │ │ +598 │ │ │ │ │ +599protected: │ │ │ │ │ +600 container_type container_; │ │ │ │ │ +601 [[no_unique_address]] mapping_type mapping_; │ │ │ │ │ +602}; │ │ │ │ │ +603 │ │ │ │ │ +607 │ │ │ │ │ +608template │ │ │ │ │ +609mdarray (const Std::extents&, const Container&) │ │ │ │ │ +610 -> mdarray, layout_right, Container>; │ │ │ │ │ +611 │ │ │ │ │ +612template │ │ │ │ │ +613mdarray (const Mapping&, const Container&) │ │ │ │ │ +614 -> mdarray; │ │ │ │ │ +615 │ │ │ │ │ +616template │ │ │ │ │ +617mdarray (const Std::extents&, Container&&) │ │ │ │ │ +618 -> mdarray, layout_right, Container>; │ │ │ │ │ +619 │ │ │ │ │ +620template │ │ │ │ │ +621mdarray (const Mapping&, Container&&) │ │ │ │ │ +622 -> mdarray; │ │ │ │ │ +623 │ │ │ │ │ +624template │ │ │ │ │ +625mdarray (const mdspan&) │ │ │ │ │ +626 -> mdarray, Extents, Layout>; │ │ │ │ │ +627 │ │ │ │ │ +628template │ │ │ │ │ +629mdarray (const Std::extents&, const Container&, const │ │ │ │ │ +Alloc&) │ │ │ │ │ +630 -> mdarray, layout_right, Container>; │ │ │ │ │ +631 │ │ │ │ │ +632template │ │ │ │ │ +633mdarray (const Mapping&, const Container&, const Alloc&) │ │ │ │ │ +634 -> mdarray; │ │ │ │ │ +635 │ │ │ │ │ +636template │ │ │ │ │ +637mdarray (const Std::extents&, Container&&, const Alloc&) │ │ │ │ │ +638 -> mdarray, layout_right, Container>; │ │ │ │ │ +639 │ │ │ │ │ +640template │ │ │ │ │ +641mdarray (const Mapping&, Container&&, const Alloc&) │ │ │ │ │ +642 -> mdarray; │ │ │ │ │ +643 │ │ │ │ │ +644template │ │ │ │ │ +645mdarray (const mdspan&, const Alloc&) │ │ │ │ │ +646 -> mdarray, Extents, Layout>; │ │ │ │ │ +647 │ │ │ │ │ +649 │ │ │ │ │ +653 │ │ │ │ │ +654template │ │ │ │ │ +655mdspan (mdarray) -> mdspan< │ │ │ │ │ +656 typename decltype(std::declval>().to_mdspan())::element_type, │ │ │ │ │ +657 typename decltype(std::declval>().to_mdspan())::extents_type, │ │ │ │ │ +658 typename decltype(std::declval>().to_mdspan())::layout_type, │ │ │ │ │ +659 typename decltype(std::declval>().to_mdspan())::accessor_type>; │ │ │ │ │ +660 │ │ │ │ │ +662 │ │ │ │ │ +663} // end namespace Dune::Std │ │ │ │ │ +664 │ │ │ │ │ +665#endif // DUNE_COMMON_STD_MDARRAY_HH │ │ │ │ │ +indices.hh │ │ │ │ │ +memory.hh │ │ │ │ │ +span.hh │ │ │ │ │ +containerconstructiontraits.hh │ │ │ │ │ +default_accessor.hh │ │ │ │ │ +mdspan.hh │ │ │ │ │ +rangeutilities.hh │ │ │ │ │ +Utilities for reduction like operations on ranges. │ │ │ │ │ +Dune::unpackIntegerSequence │ │ │ │ │ +decltype(auto) constexpr unpackIntegerSequence(F &&f, std::integer_sequence< I, │ │ │ │ │ +i... > sequence) │ │ │ │ │ +Unpack an std::integer_sequence to std::integral_constant... │ │ │ │ │ +Definition indices.hh:124 │ │ │ │ │ std │ │ │ │ │ STL namespace. │ │ │ │ │ -Dune │ │ │ │ │ -Dune namespace. │ │ │ │ │ -Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::CopyableOptional │ │ │ │ │ -A copyable type wrapper that provides copy/move assignment operations for types │ │ │ │ │ -that are only copy/mo... │ │ │ │ │ -Definition copyableoptional.hh:35 │ │ │ │ │ -Dune::CopyableOptional::CopyableOptional │ │ │ │ │ -constexpr CopyableOptional(CopyableOptional &&)=default │ │ │ │ │ -Move construct the contained value. │ │ │ │ │ -Dune::CopyableOptional::CopyableOptional │ │ │ │ │ -constexpr CopyableOptional(T &&value) noexcept(std::is_nothrow_constructible_v< │ │ │ │ │ -Type, T && >) │ │ │ │ │ -Construct the internal data from perfect forwarding of the passed arguments. │ │ │ │ │ -Participates in overload... │ │ │ │ │ -Definition copyableoptional.hh:62 │ │ │ │ │ -Dune::CopyableOptional::operator= │ │ │ │ │ -constexpr CopyableOptional & operator=(const CopyableOptional &that) noexcept │ │ │ │ │ -(std::is_nothrow_copy_assignable_v< Type >||(!std::is_copy_assignable_v< Type > │ │ │ │ │ -&&std::is_nothrow_copy_constructible_v< Type >)) │ │ │ │ │ -Copy assignment in terms of copy constructor. │ │ │ │ │ -Definition copyableoptional.hh:100 │ │ │ │ │ -Dune::CopyableOptional::CopyableOptional │ │ │ │ │ -constexpr CopyableOptional() noexcept(std::is_nothrow_default_constructible_v< │ │ │ │ │ -T >) │ │ │ │ │ -Implementation of a default constructor, if the Type is itself default │ │ │ │ │ -constructible.... │ │ │ │ │ -Definition copyableoptional.hh:49 │ │ │ │ │ -Dune::CopyableOptional::CopyableOptional │ │ │ │ │ -constexpr CopyableOptional(const CopyableOptional &)=default │ │ │ │ │ -Copy construct the contained value. │ │ │ │ │ -Dune::CopyableOptional::CopyableOptional │ │ │ │ │ -constexpr CopyableOptional(Args &&... args) noexcept(std::is_nothrow_ │ │ │ │ │ -constructible_v< Type, Args &&... >) │ │ │ │ │ -Construct the internal data from perfect forwarding of the passed arguments. │ │ │ │ │ -Definition copyableoptional.hh:85 │ │ │ │ │ -Dune::CopyableOptional::~CopyableOptional │ │ │ │ │ -~CopyableOptional()=default │ │ │ │ │ -Default destructor. │ │ │ │ │ +Dune::Std │ │ │ │ │ +Namespace for features backported from new C++ standards. │ │ │ │ │ +Definition default_accessor.hh:10 │ │ │ │ │ +Dune::Std::to_address │ │ │ │ │ +constexpr auto to_address(T &&p) noexcept │ │ │ │ │ +Obtain the address represented by p without forming a reference to the object │ │ │ │ │ +pointed to by p. │ │ │ │ │ +Definition memory.hh:47 │ │ │ │ │ +Dune::const_reference │ │ │ │ │ +Get the 'const' version of a reference to a mutable object. │ │ │ │ │ +Definition genericiterator.hh:87 │ │ │ │ │ +Dune::Std::extents │ │ │ │ │ +Multidimensional index space with dynamic and static extents. │ │ │ │ │ +Definition extents.hh:54 │ │ │ │ │ +Dune::Std::layout_right │ │ │ │ │ +A layout where the rightmost extent has stride 1, and strides increase right- │ │ │ │ │ +to-left as the product o... │ │ │ │ │ +Definition fwd_layouts.hh:30 │ │ │ │ │ +Dune::Std::mdarray │ │ │ │ │ +An owning multi-dimensional array analog of mdspan. │ │ │ │ │ +Definition mdarray.hh:69 │ │ │ │ │ +Dune::Std::mdarray::const_mdspan_type │ │ │ │ │ +mdspan< const element_type, extents_type, layout_type > const_mdspan_type │ │ │ │ │ +Definition mdarray.hh:91 │ │ │ │ │ +Dune::Std::mdarray::mdarray │ │ │ │ │ +constexpr mdarray(const mapping_type &m, const container_type &c, const Alloc │ │ │ │ │ +&a) │ │ │ │ │ +Construct from layout mapping, container and allocator. │ │ │ │ │ +Definition mdarray.hh:288 │ │ │ │ │ +Dune::Std::mdarray::const_reference │ │ │ │ │ +typename container_type::const_reference const_reference │ │ │ │ │ +Definition mdarray.hh:96 │ │ │ │ │ +Dune::Std::mdarray::mdarray │ │ │ │ │ +constexpr mdarray(const mapping_type &m, container_type &&c) │ │ │ │ │ +Construct from layout mapping and the storage container. │ │ │ │ │ +Definition mdarray.hh:194 │ │ │ │ │ +Dune::Std::mdarray::container_type │ │ │ │ │ +Container container_type │ │ │ │ │ +Definition mdarray.hh:81 │ │ │ │ │ +Dune::Std::mdarray::extents_type │ │ │ │ │ +Extents extents_type │ │ │ │ │ +Definition mdarray.hh:79 │ │ │ │ │ +Dune::Std::mdarray::mdarray │ │ │ │ │ +constexpr mdarray(const E &e, const container_type &c) │ │ │ │ │ +Construct from extents and the storage container. │ │ │ │ │ +Definition mdarray.hh:174 │ │ │ │ │ +Dune::Std::mdarray::is_always_exhaustive │ │ │ │ │ +static constexpr bool is_always_exhaustive() noexcept │ │ │ │ │ +Definition mdarray.hh:522 │ │ │ │ │ +Dune::Std::mdarray::to_mdspan │ │ │ │ │ +constexpr mdspan< const element_type, extents_type, layout_type, AccessorPolicy │ │ │ │ │ +> to_mdspan(const AccessorPolicy &a=AccessorPolicy{}) const │ │ │ │ │ +Conversion function to mdspan. │ │ │ │ │ +Definition mdarray.hh:594 │ │ │ │ │ +Dune::Std::mdarray::stride │ │ │ │ │ +constexpr index_type stride(rank_type r) const │ │ │ │ │ +The stride along the specified dimension. │ │ │ │ │ +Definition mdarray.hh:516 │ │ │ │ │ +Dune::Std::mdarray::is_unique │ │ │ │ │ +constexpr bool is_unique() const noexcept │ │ │ │ │ +Definition mdarray.hh:525 │ │ │ │ │ +Dune::Std::mdarray::extent │ │ │ │ │ +constexpr index_type extent(rank_type r) const noexcept │ │ │ │ │ +Number of elements in the r'th dimension of the tensor. │ │ │ │ │ +Definition mdarray.hh:498 │ │ │ │ │ +Dune::Std::mdarray::mdarray │ │ │ │ │ +constexpr mdarray(const extents_type &e, const Alloc &a) │ │ │ │ │ +Construct from the extents of the array and allocator. │ │ │ │ │ +Definition mdarray.hh:243 │ │ │ │ │ +Dune::Std::mdarray::static_extent │ │ │ │ │ +static constexpr std::size_t static_extent(rank_type r) noexcept │ │ │ │ │ +Number of elements in the r'th dimension of the tensor. │ │ │ │ │ +Definition mdarray.hh:495 │ │ │ │ │ +Dune::Std::mdarray::mapping_ │ │ │ │ │ +mapping_type mapping_ │ │ │ │ │ +Definition mdarray.hh:601 │ │ │ │ │ +Dune::Std::mdarray::mdarray │ │ │ │ │ +constexpr mdarray(const mdspan< OtherElementType, OtherExtents, │ │ │ │ │ +OtherLayoutPolicy, Accessor > &other) │ │ │ │ │ +Converting constructor from mdspan. │ │ │ │ │ +Definition mdarray.hh:229 │ │ │ │ │ +Dune::Std::mdarray::mapping_type │ │ │ │ │ +typename layout_type::template mapping< extents_type > mapping_type │ │ │ │ │ +Definition mdarray.hh:84 │ │ │ │ │ +Dune::Std::mdarray::container_data │ │ │ │ │ +constexpr const_pointer container_data() const noexcept │ │ │ │ │ +Direct access to the underlying const data in the container. │ │ │ │ │ +Definition mdarray.hh:537 │ │ │ │ │ +Dune::Std::mdarray::mdarray │ │ │ │ │ +constexpr mdarray(const extents_type &e, const value_type &v) │ │ │ │ │ +Construct from extents and initial value. │ │ │ │ │ +Definition mdarray.hh:155 │ │ │ │ │ +Dune::Std::mdarray::mdarray │ │ │ │ │ +constexpr mdarray(const mapping_type &m, const Alloc &a) │ │ │ │ │ +Construct from the layout mapping of the array and allocator. │ │ │ │ │ +Definition mdarray.hh:250 │ │ │ │ │ +Dune::Std::mdarray::container_data │ │ │ │ │ +constexpr pointer container_data() noexcept │ │ │ │ │ +Direct access to the underlying data in the container. │ │ │ │ │ +Definition mdarray.hh:534 │ │ │ │ │ +Dune::Std::mdarray::is_exhaustive │ │ │ │ │ +constexpr bool is_exhaustive() const noexcept │ │ │ │ │ +Definition mdarray.hh:526 │ │ │ │ │ +Dune::Std::mdarray::pointer │ │ │ │ │ +decltype(Std::to_address(std::declval< container_type >().begin())) pointer │ │ │ │ │ +Definition mdarray.hh:93 │ │ │ │ │ +Dune::Std::mdarray::operator[] │ │ │ │ │ +constexpr reference operator[](Index index) │ │ │ │ │ +Access specified element at position [i0] For a rank one mdarray, the operator │ │ │ │ │ +[i] is added to support... │ │ │ │ │ +Definition mdarray.hh:408 │ │ │ │ │ +Dune::Std::mdarray::extents │ │ │ │ │ +constexpr const extents_type & extents() const noexcept │ │ │ │ │ +Number of elements in all dimensions of the array,. │ │ │ │ │ +Definition mdarray.hh:468 │ │ │ │ │ +Dune::Std::mdarray::is_strided │ │ │ │ │ +constexpr bool is_strided() const noexcept │ │ │ │ │ +Definition mdarray.hh:527 │ │ │ │ │ +Dune::Std::mdarray::mdarray │ │ │ │ │ +constexpr mdarray(const mapping_type &m, const container_type &c) │ │ │ │ │ +Construct from layout mapping and the storage container. │ │ │ │ │ +Definition mdarray.hh:188 │ │ │ │ │ +Dune::Std::mdarray::is_always_unique │ │ │ │ │ +static constexpr bool is_always_unique() noexcept │ │ │ │ │ +Definition mdarray.hh:521 │ │ │ │ │ +Dune::Std::mdarray::mdarray │ │ │ │ │ +constexpr mdarray(const mapping_type &m, container_type &&c, const Alloc &a) │ │ │ │ │ +Construct from layout mapping, container and allocator. │ │ │ │ │ +Definition mdarray.hh:296 │ │ │ │ │ +Dune::Std::mdarray::mdarray │ │ │ │ │ +constexpr mdarray(const E &e, container_type &&c) │ │ │ │ │ +Construct from extents and the storage container. │ │ │ │ │ +Definition mdarray.hh:182 │ │ │ │ │ +Dune::Std::mdarray::container │ │ │ │ │ +constexpr const container_type & container() const noexcept │ │ │ │ │ +The underlying storage container. │ │ │ │ │ +Definition mdarray.hh:474 │ │ │ │ │ +Dune::Std::mdarray::container_size │ │ │ │ │ +constexpr std::size_t container_size() const │ │ │ │ │ +Size of the underlying container. │ │ │ │ │ +Definition mdarray.hh:510 │ │ │ │ │ +Dune::Std::mdarray::size_type │ │ │ │ │ +typename extents_type::size_type size_type │ │ │ │ │ +Definition mdarray.hh:87 │ │ │ │ │ +Dune::Std::mdarray::rank │ │ │ │ │ +static constexpr rank_type rank() noexcept │ │ │ │ │ +Number of dimensions of the array. │ │ │ │ │ +Definition mdarray.hh:489 │ │ │ │ │ +Dune::Std::mdarray::empty │ │ │ │ │ +constexpr bool empty() const noexcept │ │ │ │ │ +Check whether the index space is empty. │ │ │ │ │ +Definition mdarray.hh:513 │ │ │ │ │ +Dune::Std::mdarray::mdarray │ │ │ │ │ +constexpr mdarray(const extents_type &e, container_type &&c, const Alloc &a) │ │ │ │ │ +Construct from extents, container and allocator. │ │ │ │ │ +Definition mdarray.hh:280 │ │ │ │ │ +Dune::Std::mdarray::mdspan_type │ │ │ │ │ +mdspan< element_type, extents_type, layout_type > mdspan_type │ │ │ │ │ +Definition mdarray.hh:90 │ │ │ │ │ +Dune::Std::mdarray::size │ │ │ │ │ +constexpr size_type size() const noexcept │ │ │ │ │ +Size of the multi-dimensional index space. │ │ │ │ │ +Definition mdarray.hh:501 │ │ │ │ │ +Dune::Std::mdarray::operator== │ │ │ │ │ +friend constexpr bool operator==(const mdarray &lhs, const mdarray &rhs) │ │ │ │ │ +noexcept │ │ │ │ │ +Definition mdarray.hh:553 │ │ │ │ │ +Dune::Std::mdarray::swap │ │ │ │ │ +friend constexpr void swap(mdarray &x, mdarray &y) noexcept │ │ │ │ │ +Definition mdarray.hh:542 │ │ │ │ │ +Dune::Std::mdarray::mapping │ │ │ │ │ +constexpr const mapping_type & mapping() const noexcept │ │ │ │ │ +Index mapping of a layout policy. │ │ │ │ │ +Definition mdarray.hh:471 │ │ │ │ │ +Dune::Std::mdarray::element_type │ │ │ │ │ +Element element_type │ │ │ │ │ +Definition mdarray.hh:78 │ │ │ │ │ +Dune::Std::mdarray::mdarray │ │ │ │ │ +constexpr mdarray(const mapping_type &m, const value_type &v, const Alloc &a) │ │ │ │ │ +Construct from layout mapping, initial value and allocator. │ │ │ │ │ +Definition mdarray.hh:264 │ │ │ │ │ +Dune::Std::mdarray::mdarray │ │ │ │ │ +constexpr mdarray(const extents_type &e, const value_type &v, const Alloc &a) │ │ │ │ │ +Construct from extents, initial value and allocator. │ │ │ │ │ +Definition mdarray.hh:257 │ │ │ │ │ +Dune::Std::mdarray::const_pointer │ │ │ │ │ +decltype(Std::to_address(std::declval< container_type >().cbegin())) const_ │ │ │ │ │ +pointer │ │ │ │ │ +Definition mdarray.hh:95 │ │ │ │ │ +Dune::Std::mdarray::reference │ │ │ │ │ +typename container_type::reference reference │ │ │ │ │ +Definition mdarray.hh:94 │ │ │ │ │ +Dune::Std::mdarray::to_mdspan │ │ │ │ │ +constexpr mdspan< element_type, extents_type, layout_type, AccessorPolicy > to_ │ │ │ │ │ +mdspan(const AccessorPolicy &a=AccessorPolicy{}) │ │ │ │ │ +Conversion function to mdspan. │ │ │ │ │ +Definition mdarray.hh:584 │ │ │ │ │ +Dune::Std::mdarray::value_type │ │ │ │ │ +element_type value_type │ │ │ │ │ +Definition mdarray.hh:83 │ │ │ │ │ +Dune::Std::mdarray::layout_type │ │ │ │ │ +LayoutPolicy layout_type │ │ │ │ │ +Definition mdarray.hh:80 │ │ │ │ │ +Dune::Std::mdarray::extract_container │ │ │ │ │ +constexpr container_type && extract_container() &&noexcept │ │ │ │ │ +Move the container out of the mdarray. │ │ │ │ │ +Definition mdarray.hh:482 │ │ │ │ │ +Dune::Std::mdarray::mdarray │ │ │ │ │ +constexpr mdarray(const extents_type &e, const container_type &c, const Alloc │ │ │ │ │ +&a) │ │ │ │ │ +Construct from extents, container and allocator. │ │ │ │ │ +Definition mdarray.hh:272 │ │ │ │ │ +Dune::Std::mdarray::rank_type │ │ │ │ │ +typename extents_type::rank_type rank_type │ │ │ │ │ +Definition mdarray.hh:88 │ │ │ │ │ +Dune::Std::mdarray::rank_dynamic │ │ │ │ │ +static constexpr rank_type rank_dynamic() noexcept │ │ │ │ │ +Number of dimension with dynamic size. │ │ │ │ │ +Definition mdarray.hh:492 │ │ │ │ │ +Dune::Std::mdarray::operator() │ │ │ │ │ +constexpr reference operator()(Indices... indices) │ │ │ │ │ +Access element at position (i0,i1,...) │ │ │ │ │ +Definition mdarray.hh:363 │ │ │ │ │ +Dune::Std::mdarray::mdarray │ │ │ │ │ +constexpr mdarray(const extents_type &e) │ │ │ │ │ +Construct from the extents of the array. │ │ │ │ │ +Definition mdarray.hh:138 │ │ │ │ │ +Dune::Std::mdarray::container_ │ │ │ │ │ +container_type container_ │ │ │ │ │ +Definition mdarray.hh:600 │ │ │ │ │ +Dune::Std::mdarray::index_type │ │ │ │ │ +typename extents_type::index_type index_type │ │ │ │ │ +Definition mdarray.hh:86 │ │ │ │ │ +Dune::Std::mdarray::mdarray │ │ │ │ │ +constexpr mdarray(IndexTypes... exts) │ │ │ │ │ +Construct from the dynamic extents. │ │ │ │ │ +Definition mdarray.hh:133 │ │ │ │ │ +Dune::Std::mdarray::is_always_strided │ │ │ │ │ +static constexpr bool is_always_strided() noexcept │ │ │ │ │ +Definition mdarray.hh:523 │ │ │ │ │ +Dune::Std::mdspan │ │ │ │ │ +A multi-dimensional non-owning array view. │ │ │ │ │ +Definition mdspan.hh:64 │ │ │ │ │ +Dune::Std::mdspan::extent │ │ │ │ │ +constexpr index_type extent(rank_type r) const noexcept │ │ │ │ │ +Number of elements in the r'th dimension of the tensor. │ │ │ │ │ +Definition mdspan.hh:275 │ │ │ │ │ +Dune::Std::mdspan::size │ │ │ │ │ +constexpr size_type size() const noexcept │ │ │ │ │ +The number of elements accessible by this multi-dimensional span. │ │ │ │ │ +Definition mdspan.hh:278 │ │ │ │ │ +Dune::Std::span │ │ │ │ │ +A contiguous sequence of elements with static or dynamic extent. │ │ │ │ │ +Definition span.hh:126 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00053.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: precision.hh File Reference │ │ │ │ +dune-common: fwd_layouts.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,45 +65,48 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ Namespaces
│ │ │ │ -
precision.hh File Reference
│ │ │ │ +
fwd_layouts.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ -

Various precision settings for calculations with FieldMatrix and FieldVector. │ │ │ │ -More...

│ │ │ │ -
#include <stdlib.h>
│ │ │ │ -
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::FMatrixPrecision< ctype >
 Precisions for calculations with FieldMatrix and FieldVector. More...
struct  Dune::Std::layout_left
 A layout where the leftmost extent has stride 1. More...
 
struct  Dune::Std::layout_right
 A layout where the rightmost extent has stride 1, and strides increase right-to-left as the product of extents. More...
 
struct  Dune::Std::layout_stride
 A layout mapping where the strides are user-defined. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::Std
 Namespace for features backported from new C++ standards.
 
│ │ │ │ -

Detailed Description

│ │ │ │ -

Various precision settings for calculations with FieldMatrix and FieldVector.

│ │ │ │ -
│ │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,24 +1,31 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ + * std │ │ │ │ │ + * impl │ │ │ │ │ Classes | Namespaces │ │ │ │ │ -precision.hh File Reference │ │ │ │ │ -Various precision settings for calculations with FieldMatrix and FieldVector. │ │ │ │ │ -More... │ │ │ │ │ -#include │ │ │ │ │ +fwd_layouts.hh File Reference │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class   Dune::FMatrixPrecision<_ctype_> │ │ │ │ │ -  Precisions for calculations with FieldMatrix and FieldVector. More... │ │ │ │ │ +struct   Dune::Std::layout_left │ │ │ │ │ +  A layout where the leftmost extent has stride 1. More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::Std::layout_right │ │ │ │ │ +  A layout where the rightmost extent has stride 1, and strides increase │ │ │ │ │ + right-to-left as the product of extents. More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::Std::layout_stride │ │ │ │ │ +  A layout mapping where the strides are user-defined. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -Various precision settings for calculations with FieldMatrix and FieldVector. │ │ │ │ │ +namespace   Dune::Std │ │ │ │ │ +  Namespace for features backported from new C++ standards. │ │ │ │ │ +  │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00053_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: precision.hh Source File │ │ │ │ +dune-common: fwd_layouts.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,66 +70,64 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
precision.hh
│ │ │ │ +
fwd_layouts.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_PRECISION_HH
│ │ │ │ -
6#define DUNE_PRECISION_HH
│ │ │ │ +
5#ifndef DUNE_COMMON_STD_IMPL_FWD_LAYOUTS_HH
│ │ │ │ +
6#define DUNE_COMMON_STD_IMPL_FWD_LAYOUTS_HH
│ │ │ │
7
│ │ │ │ -
12#include <stdlib.h>
│ │ │ │ -
13
│ │ │ │ -
14namespace Dune {
│ │ │ │ -
15
│ │ │ │ -
24 template <class ctype = double>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
26 public:
│ │ │ │ -
│ │ │ │ -
28 static ctype absolute_limit ()
│ │ │ │ -
29 {
│ │ │ │ -
30 return _absolute;
│ │ │ │ -
31 }
│ │ │ │ -
│ │ │ │ -
32
│ │ │ │ -
│ │ │ │ -
34 static void set_absolute_limit (ctype absthres)
│ │ │ │ -
35 {
│ │ │ │ -
36 _absolute = absthres;
│ │ │ │ -
37 }
│ │ │ │ -
│ │ │ │ -
38
│ │ │ │ -
39 private:
│ │ │ │ -
40 // just to demonstrate some state information
│ │ │ │ -
41 static ctype _absolute;
│ │ │ │ -
42 };
│ │ │ │ -
│ │ │ │ -
43
│ │ │ │ -
44 template <class ctype>
│ │ │ │ -
45 ctype FMatrixPrecision<ctype>::_absolute = 1E-80;
│ │ │ │ +
8namespace Dune::Std {
│ │ │ │ +
9
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
17{
│ │ │ │ +
18 template <class Extents>
│ │ │ │ +
19 class mapping;
│ │ │ │ +
20};
│ │ │ │ +
│ │ │ │ +
21
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
30{
│ │ │ │ +
31 template <class Extents>
│ │ │ │ +
32 class mapping;
│ │ │ │ +
33};
│ │ │ │ +
│ │ │ │ +
34
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
40{
│ │ │ │ +
41 template <class Extents>
│ │ │ │ +
42 class mapping;
│ │ │ │ +
43};
│ │ │ │ +
│ │ │ │ +
44
│ │ │ │ +
45} // end namespace Dune::Std
│ │ │ │
46
│ │ │ │ -
49} // end namespace
│ │ │ │ -
50
│ │ │ │ -
51#endif
│ │ │ │ -
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
Precisions for calculations with FieldMatrix and FieldVector.
Definition precision.hh:25
│ │ │ │ -
static ctype absolute_limit()
return threshold to declare matrix singular
Definition precision.hh:28
│ │ │ │ -
static void set_absolute_limit(ctype absthres)
set singular threshold
Definition precision.hh:34
│ │ │ │ +
47#endif // DUNE_COMMON_STD_IMPL_FWD_LAYOUTS_HH
│ │ │ │ +
Namespace for features backported from new C++ standards.
Definition default_accessor.hh:10
│ │ │ │ +
A layout where the leftmost extent has stride 1.
Definition fwd_layouts.hh:17
│ │ │ │ +
A layout mapping where the leftmost extent has stride 1.
Definition layout_left.hh:19
│ │ │ │ +
A layout where the rightmost extent has stride 1, and strides increase right-to-left as the product o...
Definition fwd_layouts.hh:30
│ │ │ │ +
A layout mapping where the rightmost extent has stride 1.
Definition layout_right.hh:19
│ │ │ │ +
A layout mapping where the strides are user-defined.
Definition fwd_layouts.hh:40
│ │ │ │ +
A layout mapping where the strides are user-defined.
Definition layout_stride.hh:19
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,60 +1,65 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -precision.hh │ │ │ │ │ + * std │ │ │ │ │ + * impl │ │ │ │ │ +fwd_layouts.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_PRECISION_HH │ │ │ │ │ -6#define DUNE_PRECISION_HH │ │ │ │ │ +5#ifndef DUNE_COMMON_STD_IMPL_FWD_LAYOUTS_HH │ │ │ │ │ +6#define DUNE_COMMON_STD_IMPL_FWD_LAYOUTS_HH │ │ │ │ │ 7 │ │ │ │ │ -12#include │ │ │ │ │ -13 │ │ │ │ │ -14namespace Dune { │ │ │ │ │ -15 │ │ │ │ │ -24 template │ │ │ │ │ -25 class FMatrixPrecision { │ │ │ │ │ -26 public: │ │ │ │ │ -28 static ctype absolute_limit () │ │ │ │ │ -29 { │ │ │ │ │ -30 return _absolute; │ │ │ │ │ -31 } │ │ │ │ │ -32 │ │ │ │ │ -34 static void set_absolute_limit (ctype absthres) │ │ │ │ │ -35 { │ │ │ │ │ -36 _absolute = absthres; │ │ │ │ │ -37 } │ │ │ │ │ -38 │ │ │ │ │ -39 private: │ │ │ │ │ -40 // just to demonstrate some state information │ │ │ │ │ -41 static ctype _absolute; │ │ │ │ │ -42 }; │ │ │ │ │ -43 │ │ │ │ │ -44 template │ │ │ │ │ -45 ctype FMatrixPrecision::_absolute = 1E-80; │ │ │ │ │ +8namespace Dune::Std { │ │ │ │ │ +9 │ │ │ │ │ +16struct layout_left │ │ │ │ │ +17{ │ │ │ │ │ +18 template │ │ │ │ │ +19 class mapping; │ │ │ │ │ +20}; │ │ │ │ │ +21 │ │ │ │ │ +29struct layout_right │ │ │ │ │ +30{ │ │ │ │ │ +31 template │ │ │ │ │ +32 class mapping; │ │ │ │ │ +33}; │ │ │ │ │ +34 │ │ │ │ │ +39struct layout_stride │ │ │ │ │ +40{ │ │ │ │ │ +41 template │ │ │ │ │ +42 class mapping; │ │ │ │ │ +43}; │ │ │ │ │ +44 │ │ │ │ │ +45} // end namespace Dune::Std │ │ │ │ │ 46 │ │ │ │ │ -49} // end namespace │ │ │ │ │ -50 │ │ │ │ │ -51#endif │ │ │ │ │ -Dune │ │ │ │ │ -Dune namespace. │ │ │ │ │ -Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::FMatrixPrecision │ │ │ │ │ -Precisions for calculations with FieldMatrix and FieldVector. │ │ │ │ │ -Definition precision.hh:25 │ │ │ │ │ -Dune::FMatrixPrecision::absolute_limit │ │ │ │ │ -static ctype absolute_limit() │ │ │ │ │ -return threshold to declare matrix singular │ │ │ │ │ -Definition precision.hh:28 │ │ │ │ │ -Dune::FMatrixPrecision::set_absolute_limit │ │ │ │ │ -static void set_absolute_limit(ctype absthres) │ │ │ │ │ -set singular threshold │ │ │ │ │ -Definition precision.hh:34 │ │ │ │ │ +47#endif // DUNE_COMMON_STD_IMPL_FWD_LAYOUTS_HH │ │ │ │ │ +Dune::Std │ │ │ │ │ +Namespace for features backported from new C++ standards. │ │ │ │ │ +Definition default_accessor.hh:10 │ │ │ │ │ +Dune::Std::layout_left │ │ │ │ │ +A layout where the leftmost extent has stride 1. │ │ │ │ │ +Definition fwd_layouts.hh:17 │ │ │ │ │ +Dune::Std::layout_left::mapping │ │ │ │ │ +A layout mapping where the leftmost extent has stride 1. │ │ │ │ │ +Definition layout_left.hh:19 │ │ │ │ │ +Dune::Std::layout_right │ │ │ │ │ +A layout where the rightmost extent has stride 1, and strides increase right- │ │ │ │ │ +to-left as the product o... │ │ │ │ │ +Definition fwd_layouts.hh:30 │ │ │ │ │ +Dune::Std::layout_right::mapping │ │ │ │ │ +A layout mapping where the rightmost extent has stride 1. │ │ │ │ │ +Definition layout_right.hh:19 │ │ │ │ │ +Dune::Std::layout_stride │ │ │ │ │ +A layout mapping where the strides are user-defined. │ │ │ │ │ +Definition fwd_layouts.hh:40 │ │ │ │ │ +Dune::Std::layout_stride::mapping │ │ │ │ │ +A layout mapping where the strides are user-defined. │ │ │ │ │ +Definition layout_stride.hh:19 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00056.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: matvectraits.hh File Reference │ │ │ │ +dune-common: containerconstructiontraits.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,43 +65,38 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Classes | │ │ │ │ Namespaces
│ │ │ │ -
matvectraits.hh File Reference
│ │ │ │ +
containerconstructiontraits.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ - │ │ │ │ -

Documentation of the traits classes you need to write for each implementation of DenseVector or DenseMatrix. │ │ │ │ -More...

│ │ │ │ - │ │ │ │ +
#include <array>
│ │ │ │ +#include <cassert>
│ │ │ │ +#include <cstddef>
│ │ │ │ +
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Classes

struct  Dune::DenseMatVecTraits< T >
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::Std
 Namespace for features backported from new C++ standards.
 
│ │ │ │ -

Detailed Description

│ │ │ │ -

Documentation of the traits classes you need to write for each implementation of DenseVector or DenseMatrix.

│ │ │ │ -
│ │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,23 +1,23 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -matvectraits.hh File Reference │ │ │ │ │ -Documentation of the traits classes you need to write for each implementation │ │ │ │ │ -of DenseVector or DenseMatrix. More... │ │ │ │ │ + * std │ │ │ │ │ + * impl │ │ │ │ │ +Namespaces │ │ │ │ │ +containerconstructiontraits.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ -Classes │ │ │ │ │ -struct   Dune::DenseMatVecTraits<_T_> │ │ │ │ │ -  │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -Documentation of the traits classes you need to write for each implementation │ │ │ │ │ -of DenseVector or DenseMatrix. │ │ │ │ │ +namespace   Dune::Std │ │ │ │ │ +  Namespace for features backported from new C++ standards. │ │ │ │ │ +  │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00056_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: matvectraits.hh Source File │ │ │ │ +dune-common: containerconstructiontraits.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,41 +70,81 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
matvectraits.hh
│ │ │ │ +
containerconstructiontraits.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_MATVECTRAITS_HH
│ │ │ │ -
6#define DUNE_MATVECTRAITS_HH
│ │ │ │ +
5#ifndef DUNE_COMMON_STD_IMPL_CONTAINER_CONSTRUCTION_TRAITS_HH
│ │ │ │ +
6#define DUNE_COMMON_STD_IMPL_CONTAINER_CONSTRUCTION_TRAITS_HH
│ │ │ │
7
│ │ │ │ -
12namespace Dune {
│ │ │ │ -
13
│ │ │ │ -
22
│ │ │ │ -
24
│ │ │ │ -
26
│ │ │ │ -
30 template<class T>
│ │ │ │ - │ │ │ │ -
32
│ │ │ │ -
33} // end namespace Dune
│ │ │ │ -
34
│ │ │ │ -
35#endif // DUNE_FTRAITS_HH
│ │ │ │ -
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
Definition matvectraits.hh:31
│ │ │ │ +
8#include <array>
│ │ │ │ +
9#include <cassert>
│ │ │ │ +
10#include <cstddef>
│ │ │ │ +
11
│ │ │ │ +
12namespace Dune::Std {
│ │ │ │ +
13namespace Impl {
│ │ │ │ +
14
│ │ │ │ +
20template <class Container>
│ │ │ │ +
21struct ContainerConstructionTraits
│ │ │ │ +
22{
│ │ │ │ +
23 using container_type = Container;
│ │ │ │ +
24 using value_type = typename container_type::value_type;
│ │ │ │ +
25
│ │ │ │ +
26 static constexpr container_type construct (std::size_t size)
│ │ │ │ +
27 {
│ │ │ │ +
28 return container_type(size);
│ │ │ │ +
29 }
│ │ │ │ +
30
│ │ │ │ +
31 static constexpr container_type construct (std::size_t size, value_type value)
│ │ │ │ +
32 {
│ │ │ │ +
33 return container_type(size, value);
│ │ │ │ +
34 }
│ │ │ │ +
35};
│ │ │ │ +
36
│ │ │ │ +
37template <class Value, std::size_t N>
│ │ │ │ +
38struct ContainerConstructionTraits<std::array<Value,N>>
│ │ │ │ +
39{
│ │ │ │ +
40 using container_type = std::array<Value,N>;
│ │ │ │ +
41 using value_type = typename container_type::value_type;
│ │ │ │ +
42
│ │ │ │ +
43 static constexpr container_type construct ([[maybe_unused]] std::size_t size)
│ │ │ │ +
44 {
│ │ │ │ +
45 assert(size <= N);
│ │ │ │ +
46 return container_type{};
│ │ │ │ +
47 }
│ │ │ │ +
48
│ │ │ │ +
49 static constexpr container_type construct ([[maybe_unused]] std::size_t size, value_type value)
│ │ │ │ +
50 {
│ │ │ │ +
51 assert(size <= N);
│ │ │ │ +
52 container_type c{};
│ │ │ │ +
53 for (auto& c_i : c)
│ │ │ │ +
54 c_i = value;
│ │ │ │ +
55 return c;
│ │ │ │ +
56 }
│ │ │ │ +
57};
│ │ │ │ +
58
│ │ │ │ +
59} // end namespace Impl
│ │ │ │ +
60} // end namespace Dune::Std
│ │ │ │ +
61
│ │ │ │ +
62#endif // DUNE_COMMON_STD_IMPL_CONTAINER_CONSTRUCTION_TRAITS_HH
│ │ │ │ +
STL namespace.
│ │ │ │ +
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition integersequence.hh:75
│ │ │ │ +
Namespace for features backported from new C++ standards.
Definition default_accessor.hh:10
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,34 +1,83 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -matvectraits.hh │ │ │ │ │ + * std │ │ │ │ │ + * impl │ │ │ │ │ +containerconstructiontraits.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_MATVECTRAITS_HH │ │ │ │ │ -6#define DUNE_MATVECTRAITS_HH │ │ │ │ │ +5#ifndef DUNE_COMMON_STD_IMPL_CONTAINER_CONSTRUCTION_TRAITS_HH │ │ │ │ │ +6#define DUNE_COMMON_STD_IMPL_CONTAINER_CONSTRUCTION_TRAITS_HH │ │ │ │ │ 7 │ │ │ │ │ -12namespace Dune { │ │ │ │ │ -13 │ │ │ │ │ -22 │ │ │ │ │ -24 │ │ │ │ │ -26 │ │ │ │ │ -30 template │ │ │ │ │ -31 struct DenseMatVecTraits {}; │ │ │ │ │ -32 │ │ │ │ │ -33} // end namespace Dune │ │ │ │ │ -34 │ │ │ │ │ -35#endif // DUNE_FTRAITS_HH │ │ │ │ │ -Dune │ │ │ │ │ -Dune namespace. │ │ │ │ │ -Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::DenseMatVecTraits │ │ │ │ │ -Definition matvectraits.hh:31 │ │ │ │ │ +8#include │ │ │ │ │ +9#include │ │ │ │ │ +10#include │ │ │ │ │ +11 │ │ │ │ │ +12namespace Dune::Std { │ │ │ │ │ +13namespace Impl { │ │ │ │ │ +14 │ │ │ │ │ +20template │ │ │ │ │ +21struct ContainerConstructionTraits │ │ │ │ │ +22{ │ │ │ │ │ +23 using container_type = Container; │ │ │ │ │ +24 using value_type = typename container_type::value_type; │ │ │ │ │ +25 │ │ │ │ │ +26 static constexpr container_type construct (std::size_t size) │ │ │ │ │ +27 { │ │ │ │ │ +28 return container_type(size); │ │ │ │ │ +29 } │ │ │ │ │ +30 │ │ │ │ │ +31 static constexpr container_type construct (std::size_t size, value_type │ │ │ │ │ +value) │ │ │ │ │ +32 { │ │ │ │ │ +33 return container_type(size, value); │ │ │ │ │ +34 } │ │ │ │ │ +35}; │ │ │ │ │ +36 │ │ │ │ │ +37template │ │ │ │ │ +38struct ContainerConstructionTraits> │ │ │ │ │ +39{ │ │ │ │ │ +40 using container_type = std::array; │ │ │ │ │ +41 using value_type = typename container_type::value_type; │ │ │ │ │ +42 │ │ │ │ │ +43 static constexpr container_type construct ([[maybe_unused]] std::size_ │ │ │ │ │ +t size) │ │ │ │ │ +44 { │ │ │ │ │ +45 assert(size <= N); │ │ │ │ │ +46 return container_type{}; │ │ │ │ │ +47 } │ │ │ │ │ +48 │ │ │ │ │ +49 static constexpr container_type construct ([[maybe_unused]] std::size_ │ │ │ │ │ +t size, value_type value) │ │ │ │ │ +50 { │ │ │ │ │ +51 assert(size <= N); │ │ │ │ │ +52 container_type c{}; │ │ │ │ │ +53 for (auto& c_i : c) │ │ │ │ │ +54 c_i = value; │ │ │ │ │ +55 return c; │ │ │ │ │ +56 } │ │ │ │ │ +57}; │ │ │ │ │ +58 │ │ │ │ │ +59} // end namespace Impl │ │ │ │ │ +60} // end namespace Dune::Std │ │ │ │ │ +61 │ │ │ │ │ +62#endif // DUNE_COMMON_STD_IMPL_CONTAINER_CONSTRUCTION_TRAITS_HH │ │ │ │ │ +std │ │ │ │ │ +STL namespace. │ │ │ │ │ +Dune::size │ │ │ │ │ +constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std:: │ │ │ │ │ +integer_sequence< T, II... >) │ │ │ │ │ +Return the size of the sequence. │ │ │ │ │ +Definition integersequence.hh:75 │ │ │ │ │ +Dune::Std │ │ │ │ │ +Namespace for features backported from new C++ standards. │ │ │ │ │ +Definition default_accessor.hh:10 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00059.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: enumset.hh File Reference │ │ │ │ +dune-common: layout_stride.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,77 +65,46 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces | │ │ │ │ -Functions
│ │ │ │ -
enumset.hh File Reference
│ │ │ │ +Namespaces
│ │ │ │ +
layout_stride.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ - │ │ │ │ -

Classes for building sets out of enumeration values. │ │ │ │ -More...

│ │ │ │ -
#include <iostream>
│ │ │ │ +
#include <array>
│ │ │ │ +#include <type_traits>
│ │ │ │ +#include <dune/common/indices.hh>
│ │ │ │ +#include <dune/common/std/impl/fwd_layouts.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::EmptySet< TA >
 An empty set. More...
 
class  Dune::AllSet< TA >
 A set containing everything. More...
 
class  Dune::EnumItem< TA, item >
 A set consisting only of one item. More...
 
class  Dune::EnumRange< TA, from, end >
 A set representing a range including the borders. More...
 
class  Dune::NegateSet< S >
 The negation of a set. An item is contained in the set if and only if it is not contained in the negated set. More...
 
class  Dune::Combine< TI1, TI2, TA >
 A set combining two other sets. More...
class  Dune::Std::layout_stride::mapping< Extents >
 A layout mapping where the strides are user-defined. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ -Functions

template<typename TA , int i>
std::ostream & Dune::operator<< (std::ostream &os, const EnumItem< TA, i > &)
 
template<typename TA , int from, int to>
std::ostream & Dune::operator<< (std::ostream &os, const EnumRange< TA, from, to > &)
 
template<class TI1 , class TI2 >
Combine< TI1, TI2, typename TI1::Type > Dune::combine (const TI1 &set1, const TI2 &set2)
 
template<class TI1 , class TI2 , class T >
std::ostream & Dune::operator<< (std::ostream &os, const Combine< TI1, TI2, T > &)
 
namespace  Dune::Std
 Namespace for features backported from new C++ standards.
 
│ │ │ │ -

Detailed Description

│ │ │ │ -

Classes for building sets out of enumeration values.

│ │ │ │ -
Author
Markus Blatt
│ │ │ │ -
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,58 +1,27 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Functions │ │ │ │ │ -enumset.hh File Reference │ │ │ │ │ -Classes for building sets out of enumeration values. More... │ │ │ │ │ -#include │ │ │ │ │ + * std │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +layout_stride.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class   Dune::EmptySet<_TA_> │ │ │ │ │ -  An empty set. More... │ │ │ │ │ -  │ │ │ │ │ -class   Dune::AllSet<_TA_> │ │ │ │ │ -  A set containing everything. More... │ │ │ │ │ -  │ │ │ │ │ -class   Dune::EnumItem<_TA,_item_> │ │ │ │ │ -  A set consisting only of one item. More... │ │ │ │ │ -  │ │ │ │ │ -class   Dune::EnumRange<_TA,_from,_end_> │ │ │ │ │ -  A set representing a range including the borders. More... │ │ │ │ │ -  │ │ │ │ │ -class   Dune::NegateSet<_S_> │ │ │ │ │ -  The negation of a set. An item is contained in the set if and only if │ │ │ │ │ - it is not contained in the negated set. More... │ │ │ │ │ -  │ │ │ │ │ -class   Dune::Combine<_TI1,_TI2,_TA_> │ │ │ │ │ -  A set combining two other sets. More... │ │ │ │ │ +class   Dune::Std::layout_stride::mapping<_Extents_> │ │ │ │ │ +  A layout mapping where the strides are user-defined. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -Functions │ │ │ │ │ -template │ │ │ │ │ - std::ostream &  Dune::operator<< (std::ostream &os, const │ │ │ │ │ - EnumItem< TA, i > &) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - std::ostream &  Dune::operator<< (std::ostream &os, const │ │ │ │ │ - EnumRange< TA, from, to > &) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -Combine< TI1, TI2, typename TI1::Type Dune::combine (const TI1 &set1, const TI2 │ │ │ │ │ - >  &set2) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - std::ostream &  Dune::operator<< (std::ostream &os, const │ │ │ │ │ - Combine< TI1, TI2, T > &) │ │ │ │ │ +namespace   Dune::Std │ │ │ │ │ +  Namespace for features backported from new C++ standards. │ │ │ │ │   │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -Classes for building sets out of enumeration values. │ │ │ │ │ - Author │ │ │ │ │ - Markus Blatt │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00059_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: enumset.hh Source File │ │ │ │ +dune-common: layout_stride.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,194 +70,256 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
enumset.hh
│ │ │ │ +
layout_stride.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_ENUMSET_HH
│ │ │ │ -
6#define DUNE_ENUMSET_HH
│ │ │ │ +
5#ifndef DUNE_COMMON_STD_LAYOUT_STRIDE_HH
│ │ │ │ +
6#define DUNE_COMMON_STD_LAYOUT_STRIDE_HH
│ │ │ │
7
│ │ │ │ -
8#include <iostream>
│ │ │ │ -
9
│ │ │ │ -
10namespace Dune
│ │ │ │ -
11{
│ │ │ │ -
25 template<typename TA>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
27 {
│ │ │ │ -
28 public:
│ │ │ │ -
32 typedef TA Type;
│ │ │ │ -
36 static bool contains(const Type& attribute);
│ │ │ │ -
37 };
│ │ │ │ -
│ │ │ │ -
38
│ │ │ │ -
42 template<typename TA>
│ │ │ │ -
│ │ │ │ -
43 class AllSet
│ │ │ │ -
44 {
│ │ │ │ -
45 public:
│ │ │ │ -
49 typedef TA Type;
│ │ │ │ -
53 static bool contains(const Type& attribute);
│ │ │ │ -
54 };
│ │ │ │ -
│ │ │ │ -
55
│ │ │ │ -
59 template<typename TA, int item>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
61 {
│ │ │ │ -
62 public:
│ │ │ │ -
66 typedef TA Type;
│ │ │ │ -
67
│ │ │ │ -
72 static bool contains(const Type& attribute);
│ │ │ │ -
73 };
│ │ │ │ -
│ │ │ │ -
74
│ │ │ │ -
78 template<typename TA,int from, int end>
│ │ │ │ -
│ │ │ │ -
79 class EnumRange //: public PODSet<EnumRange<T,from,end>,T>
│ │ │ │ -
80 {
│ │ │ │ -
81 public:
│ │ │ │ -
85 typedef TA Type;
│ │ │ │ -
86 static bool contains(const Type& item);
│ │ │ │ -
87 };
│ │ │ │ -
│ │ │ │ -
88
│ │ │ │ -
94 template<typename S>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
96 {
│ │ │ │ -
97 public:
│ │ │ │ -
98 typedef typename S::Type Type;
│ │ │ │ -
99
│ │ │ │ -
│ │ │ │ -
100 static bool contains(const Type& item)
│ │ │ │ -
101 {
│ │ │ │ -
102 return !S::contains(item);
│ │ │ │ -
103 }
│ │ │ │ -
│ │ │ │ -
104 };
│ │ │ │ -
│ │ │ │ -
105
│ │ │ │ -
109 template<class TI1, class TI2, typename TA=typename TI1::Type>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
111 {
│ │ │ │ -
112 public:
│ │ │ │ -
113 static bool contains(const TA& item);
│ │ │ │ -
114 };
│ │ │ │ -
│ │ │ │ -
115
│ │ │ │ -
116 template<typename TA>
│ │ │ │ -
│ │ │ │ -
117 inline bool EmptySet<TA>::contains([[maybe_unused]] const Type& attribute)
│ │ │ │ -
118 {
│ │ │ │ -
119 return false;
│ │ │ │ -
120 }
│ │ │ │ -
│ │ │ │ -
121
│ │ │ │ -
122 template<typename TA>
│ │ │ │ -
│ │ │ │ -
123 inline bool AllSet<TA>::contains([[maybe_unused]] const Type& attribute)
│ │ │ │ -
124 {
│ │ │ │ -
125 return true;
│ │ │ │ -
126 }
│ │ │ │ -
│ │ │ │ -
127
│ │ │ │ -
128 template<typename TA,int i>
│ │ │ │ -
│ │ │ │ -
129 inline bool EnumItem<TA,i>::contains(const Type& item)
│ │ │ │ -
130 {
│ │ │ │ -
131 return item==i;
│ │ │ │ -
132 }
│ │ │ │ -
│ │ │ │ -
133
│ │ │ │ -
134 template<typename TA,int i>
│ │ │ │ +
8#include <array>
│ │ │ │ +
9#include <type_traits>
│ │ │ │ +
10
│ │ │ │ + │ │ │ │ + │ │ │ │ +
13
│ │ │ │ +
14namespace Dune::Std {
│ │ │ │ +
15
│ │ │ │ +
17template <class Extents>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
19{
│ │ │ │ +
20 template <class> friend class mapping;
│ │ │ │ +
21 static constexpr typename Extents::rank_type rank_ = Extents::rank();
│ │ │ │ +
22
│ │ │ │ +
23public:
│ │ │ │ +
24 using extents_type = Extents;
│ │ │ │ +
25 using index_type = typename extents_type::index_type;
│ │ │ │ +
26 using size_type = typename extents_type::size_type;
│ │ │ │ +
27 using rank_type = typename extents_type::rank_type;
│ │ │ │ + │ │ │ │ +
29
│ │ │ │ +
30private:
│ │ │ │ +
31 using strides_type = std::array<index_type,rank_>;
│ │ │ │ +
32
│ │ │ │ +
33public:
│ │ │ │ +
34
│ │ │ │ +
│ │ │ │ +
36 constexpr mapping () noexcept
│ │ │ │ + │ │ │ │ +
38 {}
│ │ │ │ +
│ │ │ │ +
39
│ │ │ │ +
41 constexpr mapping (const mapping&) noexcept = default;
│ │ │ │ +
42
│ │ │ │ +
44 template <class OtherIndexType,
│ │ │ │ +
45 std::enable_if_t<std::is_convertible_v<const OtherIndexType&, index_type>, int> = 0,
│ │ │ │ +
46 std::enable_if_t<std::is_nothrow_constructible_v<index_type, const OtherIndexType&>, int> = 0>
│ │ │ │ +
│ │ │ │ +
47 constexpr mapping (const extents_type& e, const std::array<OtherIndexType,rank_>& s) noexcept
│ │ │ │ +
48 : extents_(e)
│ │ │ │ +
49 , strides_{}
│ │ │ │ +
50 {
│ │ │ │ +
51 for (rank_type r = 0; r < rank_; ++r)
│ │ │ │ +
52 strides_[r] = s[r];
│ │ │ │ +
53 }
│ │ │ │ +
│ │ │ │ +
54
│ │ │ │ +
56 template <class OtherIndexType,
│ │ │ │ +
57 std::enable_if_t<std::is_convertible_v<const OtherIndexType&, index_type>, int> = 0,
│ │ │ │ +
58 std::enable_if_t<std::is_nothrow_constructible_v<index_type, const OtherIndexType&>, int> = 0>
│ │ │ │ +
│ │ │ │ +
59 constexpr mapping (const extents_type& e, const span<OtherIndexType,rank_>& s) noexcept
│ │ │ │ +
60 : extents_(e)
│ │ │ │ +
61 , strides_{}
│ │ │ │ +
62 {
│ │ │ │ +
63 for (rank_type r = 0; r < rank_; ++r)
│ │ │ │ +
64 strides_[r] = s[r];
│ │ │ │ +
65 }
│ │ │ │ +
│ │ │ │ +
66
│ │ │ │ +
68 template <class M,
│ │ │ │ +
69 std::enable_if_t<(M::extents_type::rank() == extents_type::rank()), int> = 0,
│ │ │ │ +
70 std::enable_if_t<(M::is_always_unique()), int> = 0,
│ │ │ │ +
71 std::enable_if_t<(M::is_always_strided()), int> = 0,
│ │ │ │ +
72 decltype(std::declval<M>().extents(), bool{}) = true,
│ │ │ │ +
73 decltype(std::declval<M>().stride(std::declval<rank_type>()), bool{}) = true>
│ │ │ │ +
│ │ │ │ +
74 constexpr mapping (const M& m) noexcept
│ │ │ │ +
75 : extents_(m.extents())
│ │ │ │ +
76 , strides_{}
│ │ │ │ +
77 {
│ │ │ │ +
78 for (rank_type r = 0; r < rank_; ++r)
│ │ │ │ +
79 strides_[r] = m.stride(r);
│ │ │ │ +
80 }
│ │ │ │ +
│ │ │ │ +
81
│ │ │ │ +
83 constexpr mapping& operator= (const mapping&) noexcept = default;
│ │ │ │ +
84
│ │ │ │ +
85 constexpr const extents_type& extents () const noexcept { return extents_; }
│ │ │ │ +
86
│ │ │ │ +
│ │ │ │ +
88 constexpr index_type required_span_size () const noexcept
│ │ │ │ +
89 {
│ │ │ │ +
90 return size(extents_,strides_);
│ │ │ │ +
91 }
│ │ │ │ +
│ │ │ │ +
92
│ │ │ │ +
94 template <class... Indices,
│ │ │ │ +
95 std::enable_if_t<(sizeof...(Indices) == rank_), int> = 0,
│ │ │ │ +
96 std::enable_if_t<(std::is_convertible_v<Indices, index_type> && ...), int> = 0,
│ │ │ │ +
97 std::enable_if_t<(std::is_nothrow_constructible_v<index_type, Indices> && ...), int> = 0>
│ │ │ │ +
│ │ │ │ +
98 constexpr index_type operator() (Indices... ii) const noexcept
│ │ │ │ +
99 {
│ │ │ │ +
100 return unpackIntegerSequence([&](auto... r) {
│ │ │ │ +
101 return ((static_cast<index_type>(ii)*strides_[r]) + ... + 0); },
│ │ │ │ +
102 std::make_index_sequence<rank_>{});
│ │ │ │ +
103 }
│ │ │ │ +
│ │ │ │ +
104
│ │ │ │ +
│ │ │ │ +
106 constexpr index_type operator() () const noexcept
│ │ │ │ +
107 {
│ │ │ │ +
108 return 0;
│ │ │ │ +
109 }
│ │ │ │ +
│ │ │ │ +
110
│ │ │ │ +
111 static constexpr bool is_always_unique () noexcept { return true; }
│ │ │ │ +
112 static constexpr bool is_always_exhaustive () noexcept { return false; }
│ │ │ │ +
113 static constexpr bool is_always_strided () noexcept { return true; }
│ │ │ │ +
114
│ │ │ │ +
115 static constexpr bool is_unique () noexcept { return true; }
│ │ │ │ +
116 static constexpr bool is_strided () noexcept { return true; }
│ │ │ │ +
117
│ │ │ │ +
│ │ │ │ +
118 constexpr bool is_exhaustive () const noexcept
│ │ │ │ +
119 {
│ │ │ │ +
120 // Actually this could be improved. A strided layout can still be exhaustive.
│ │ │ │ +
121 // This test is more complicated to implement, though. See §24.7.3.4.7.4 line (5.2)
│ │ │ │ +
122 // in the C++ standard document N4971
│ │ │ │ +
123 return extents_type::rank() == 0 || (required_span_size() > 0 && required_span_size() == extents().product());
│ │ │ │ +
124 }
│ │ │ │ +
│ │ │ │ +
125
│ │ │ │ +
│ │ │ │ +
127 constexpr const strides_type& strides () const noexcept
│ │ │ │ +
128 {
│ │ │ │ +
129 return strides_;
│ │ │ │ +
130 }
│ │ │ │ +
│ │ │ │ +
131
│ │ │ │ +
133 template <class E = extents_type,
│ │ │ │ +
134 std::enable_if_t<(E::rank() > 0), int> = 0>
│ │ │ │
│ │ │ │ -
135 inline std::ostream& operator<<(std::ostream& os, const EnumItem<TA,i>&)
│ │ │ │ +
135 constexpr index_type stride (rank_type i) const noexcept
│ │ │ │
136 {
│ │ │ │ -
137 return os<<i;
│ │ │ │ +
137 return strides_[i];
│ │ │ │
138 }
│ │ │ │
│ │ │ │
139
│ │ │ │ -
140 template<typename TA, int from, int to>
│ │ │ │ -
│ │ │ │ -
141 inline bool EnumRange<TA,from,to>::contains(const Type& item)
│ │ │ │ -
142 {
│ │ │ │ -
143 return from<=item && item<=to;
│ │ │ │ -
144 }
│ │ │ │ -
│ │ │ │ -
145
│ │ │ │ -
146 template<typename TA, int from, int to>
│ │ │ │ -
│ │ │ │ -
147 inline std::ostream& operator<<(std::ostream& os, const EnumRange<TA,from,to>&)
│ │ │ │ -
148 {
│ │ │ │ -
149 return os<<"["<<from<<" - "<<to<<"]";
│ │ │ │ +
140 template <class OtherMapping,
│ │ │ │ +
141 std::enable_if_t<(OtherMapping::extents_type::rank() == extents_type::rank()), int> = 0,
│ │ │ │ +
142 std::enable_if_t<(OtherMapping::is_always_strided()), int> = 0>
│ │ │ │ +
│ │ │ │ +
143 friend constexpr bool operator== (const mapping& a, const OtherMapping& b) noexcept
│ │ │ │ +
144 {
│ │ │ │ +
145 if (offset(b))
│ │ │ │ +
146 return false;
│ │ │ │ +
147 if constexpr(extents_type::rank() == 0)
│ │ │ │ +
148 return true;
│ │ │ │ +
149 return a.extents_ == b.extents_ && a.strides_ == b.strides_;
│ │ │ │
150 }
│ │ │ │
│ │ │ │
151
│ │ │ │ -
152 template<class TI1, class TI2, typename TA>
│ │ │ │ -
│ │ │ │ -
153 inline bool Combine<TI1,TI2,TA>::contains(const TA& item)
│ │ │ │ -
154 {
│ │ │ │ -
155 return TI1::contains(item) ||
│ │ │ │ -
156 TI2::contains(item);
│ │ │ │ -
157 }
│ │ │ │ -
│ │ │ │ -
158
│ │ │ │ -
159 template<class TI1, class TI2>
│ │ │ │ -
│ │ │ │ -
160 inline Combine<TI1,TI2,typename TI1::Type> combine([[maybe_unused]] const TI1& set1,
│ │ │ │ -
161 [[maybe_unused]] const TI2& set2)
│ │ │ │ -
162 {
│ │ │ │ - │ │ │ │ -
164 }
│ │ │ │ -
│ │ │ │ -
165
│ │ │ │ -
166 template<class TI1, class TI2, class T>
│ │ │ │ -
│ │ │ │ -
167 inline std::ostream& operator<<(std::ostream& os, const Combine<TI1,TI2,T>&)
│ │ │ │ -
168 {
│ │ │ │ -
169 return os << TI1()<<" "<<TI2();
│ │ │ │ -
170 }
│ │ │ │ -
│ │ │ │ -
172}
│ │ │ │ -
173
│ │ │ │ -
174#endif
│ │ │ │ -
static bool contains(const Type &attribute)
Always returns true.
Definition enumset.hh:123
│ │ │ │ -
static bool contains(const Type &item)
Definition enumset.hh:141
│ │ │ │ -
static bool contains(const TA &item)
Definition enumset.hh:153
│ │ │ │ -
static bool contains(const Type &attribute)
Always returns false.
Definition enumset.hh:117
│ │ │ │ -
static bool contains(const Type &attribute)
Tests whether an item is in the set.
Definition enumset.hh:129
│ │ │ │ -
Combine< TI1, TI2, typename TI1::Type > combine(const TI1 &set1, const TI2 &set2)
Definition enumset.hh:160
│ │ │ │ -
std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x)
Definition bigunsignedint.hh:278
│ │ │ │ -
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
An empty set.
Definition enumset.hh:27
│ │ │ │ -
TA Type
The POD type the set holds.
Definition enumset.hh:32
│ │ │ │ -
A set containing everything.
Definition enumset.hh:44
│ │ │ │ -
TA Type
The POD type the set holds.
Definition enumset.hh:49
│ │ │ │ -
A set consisting only of one item.
Definition enumset.hh:61
│ │ │ │ -
TA Type
The type the set holds.
Definition enumset.hh:66
│ │ │ │ -
A set representing a range including the borders.
Definition enumset.hh:80
│ │ │ │ -
TA Type
The type the set holds.
Definition enumset.hh:85
│ │ │ │ -
The negation of a set. An item is contained in the set if and only if it is not contained in the nega...
Definition enumset.hh:96
│ │ │ │ -
S::Type Type
Definition enumset.hh:98
│ │ │ │ -
static bool contains(const Type &item)
Definition enumset.hh:100
│ │ │ │ -
A set combining two other sets.
Definition enumset.hh:111
│ │ │ │ +
152private:
│ │ │ │ +
153 template <class E, class S>
│ │ │ │ +
154 static constexpr index_type size (const E& extents, const S& strides) noexcept
│ │ │ │ +
155 {
│ │ │ │ +
156 if constexpr (E::rank() == 0)
│ │ │ │ +
157 return 1;
│ │ │ │ +
158 else {
│ │ │ │ +
159 if (extents.product() == 0)
│ │ │ │ +
160 return 0;
│ │ │ │ +
161 else {
│ │ │ │ +
162 index_type result = 1;
│ │ │ │ +
163 for (rank_type r = 0; r < E::rank(); ++r)
│ │ │ │ +
164 result += (extents.extent(r)-1) * strides[r];
│ │ │ │ +
165 return result;
│ │ │ │ +
166 }
│ │ │ │ +
167 }
│ │ │ │ +
168 }
│ │ │ │ +
169
│ │ │ │ +
170 template <class M>
│ │ │ │ +
171 static constexpr size_type offset (const M& m) noexcept
│ │ │ │ +
172 {
│ │ │ │ +
173 if constexpr (M::extents_type::rank() == 0)
│ │ │ │ +
174 return m();
│ │ │ │ +
175 else {
│ │ │ │ +
176 if (m.required_span_size() == 0)
│ │ │ │ +
177 return 0;
│ │ │ │ +
178 else {
│ │ │ │ +
179 return unpackIntegerSequence([&](auto... r) {
│ │ │ │ +
180 return m((r,0)...); }, // map the index tuple (0,0...)
│ │ │ │ +
181 std::make_index_sequence<M::extents_type::rank()>{});
│ │ │ │ +
182 }
│ │ │ │ +
183 }
│ │ │ │ +
184 }
│ │ │ │ +
185
│ │ │ │ +
186private:
│ │ │ │ +
187 [[no_unique_address]] extents_type extents_;
│ │ │ │ +
188 strides_type strides_;
│ │ │ │ +
189};
│ │ │ │ +
│ │ │ │ +
190
│ │ │ │ +
191} // end namespace Dune::Std
│ │ │ │ +
192
│ │ │ │ +
193#endif // DUNE_COMMON_STD_LAYOUT_STRIDE_HH
│ │ │ │ + │ │ │ │ + │ │ │ │ +
decltype(auto) constexpr unpackIntegerSequence(F &&f, std::integer_sequence< I, i... > sequence)
Unpack an std::integer_sequence<I,i...> to std::integral_constant<I,i>...
Definition indices.hh:124
│ │ │ │ +
Namespace for features backported from new C++ standards.
Definition default_accessor.hh:10
│ │ │ │ +
Multidimensional index space with dynamic and static extents.
Definition extents.hh:54
│ │ │ │ +
constexpr index_type extent(rank_type r) const noexcept
Return the extent of dimension i
Definition extents.hh:100
│ │ │ │ +
A layout where the rightmost extent has stride 1, and strides increase right-to-left as the product o...
Definition fwd_layouts.hh:30
│ │ │ │ +
A layout mapping where the strides are user-defined.
Definition fwd_layouts.hh:40
│ │ │ │ +
A layout mapping where the strides are user-defined.
Definition layout_stride.hh:19
│ │ │ │ +
constexpr mapping(const extents_type &e, const span< OtherIndexType, rank_ > &s) noexcept
Construct the mapping from given extents and strides.
Definition layout_stride.hh:59
│ │ │ │ +
Extents extents_type
Definition layout_stride.hh:24
│ │ │ │ +
constexpr mapping & operator=(const mapping &) noexcept=default
Copy-assignment for the mapping.
│ │ │ │ +
constexpr bool is_exhaustive() const noexcept
Definition layout_stride.hh:118
│ │ │ │ +
constexpr mapping() noexcept
The default construction initializes the strides from layout_right.
Definition layout_stride.hh:36
│ │ │ │ +
constexpr mapping(const extents_type &e, const std::array< OtherIndexType, rank_ > &s) noexcept
Construct the mapping from given extents and strides.
Definition layout_stride.hh:47
│ │ │ │ +
constexpr index_type stride(rank_type i) const noexcept
Get the single stride i
Definition layout_stride.hh:135
│ │ │ │ +
typename extents_type::index_type index_type
Definition layout_stride.hh:25
│ │ │ │ +
static constexpr bool is_always_exhaustive() noexcept
Definition layout_stride.hh:112
│ │ │ │ +
constexpr const extents_type & extents() const noexcept
Definition layout_stride.hh:85
│ │ │ │ +
static constexpr bool is_strided() noexcept
Definition layout_stride.hh:116
│ │ │ │ +
static constexpr bool is_always_strided() noexcept
Definition layout_stride.hh:113
│ │ │ │ +
constexpr index_type required_span_size() const noexcept
Return the sum 1 + (E(0)-1)*S(0) + (E(1)-1)*S(1) + ...
Definition layout_stride.hh:88
│ │ │ │ +
constexpr const strides_type & strides() const noexcept
Get the array of all strides.
Definition layout_stride.hh:127
│ │ │ │ +
constexpr mapping(const mapping &) noexcept=default
Copy constructor for the mapping.
│ │ │ │ +
typename extents_type::rank_type rank_type
Definition layout_stride.hh:27
│ │ │ │ +
static constexpr bool is_unique() noexcept
Definition layout_stride.hh:115
│ │ │ │ +
constexpr index_type operator()() const noexcept
The default offset for rank-0 tensors is 0.
Definition layout_stride.hh:106
│ │ │ │ +
typename extents_type::size_type size_type
Definition layout_stride.hh:26
│ │ │ │ +
static constexpr bool is_always_unique() noexcept
Definition layout_stride.hh:111
│ │ │ │ +
A contiguous sequence of elements with static or dynamic extent.
Definition span.hh:126
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,204 +1,308 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -enumset.hh │ │ │ │ │ + * std │ │ │ │ │ +layout_stride.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_ENUMSET_HH │ │ │ │ │ -6#define DUNE_ENUMSET_HH │ │ │ │ │ +5#ifndef DUNE_COMMON_STD_LAYOUT_STRIDE_HH │ │ │ │ │ +6#define DUNE_COMMON_STD_LAYOUT_STRIDE_HH │ │ │ │ │ 7 │ │ │ │ │ -8#include │ │ │ │ │ -9 │ │ │ │ │ -10namespace Dune │ │ │ │ │ -11{ │ │ │ │ │ -25 template │ │ │ │ │ -26 class EmptySet │ │ │ │ │ -27 { │ │ │ │ │ -28 public: │ │ │ │ │ -32 typedef TA Type; │ │ │ │ │ -36 static bool contains(const Type& attribute); │ │ │ │ │ -37 }; │ │ │ │ │ -38 │ │ │ │ │ -42 template │ │ │ │ │ -43 class AllSet │ │ │ │ │ -44 { │ │ │ │ │ -45 public: │ │ │ │ │ -49 typedef TA Type; │ │ │ │ │ -53 static bool contains(const Type& attribute); │ │ │ │ │ -54 }; │ │ │ │ │ -55 │ │ │ │ │ -59 template │ │ │ │ │ -60 class EnumItem │ │ │ │ │ -61 { │ │ │ │ │ -62 public: │ │ │ │ │ -66 typedef TA Type; │ │ │ │ │ -67 │ │ │ │ │ -72 static bool contains(const Type& attribute); │ │ │ │ │ -73 }; │ │ │ │ │ -74 │ │ │ │ │ -78 template │ │ │ │ │ -79 class EnumRange //: public PODSet,T> │ │ │ │ │ -80 { │ │ │ │ │ -81 public: │ │ │ │ │ -85 typedef TA Type; │ │ │ │ │ -86 static bool contains(const Type& item); │ │ │ │ │ -87 }; │ │ │ │ │ -88 │ │ │ │ │ -94 template │ │ │ │ │ -95 class NegateSet │ │ │ │ │ -96 { │ │ │ │ │ -97 public: │ │ │ │ │ -98 typedef typename S::Type Type; │ │ │ │ │ -99 │ │ │ │ │ -100 static bool contains(const Type& item) │ │ │ │ │ -101 { │ │ │ │ │ -102 return !S::contains(item); │ │ │ │ │ +8#include │ │ │ │ │ +9#include │ │ │ │ │ +10 │ │ │ │ │ +11#include │ │ │ │ │ +12#include │ │ │ │ │ +13 │ │ │ │ │ +14namespace Dune::Std { │ │ │ │ │ +15 │ │ │ │ │ +17template │ │ │ │ │ +18class layout_stride::mapping │ │ │ │ │ +19{ │ │ │ │ │ +20 template friend class mapping; │ │ │ │ │ +21 static constexpr typename Extents::rank_type rank_ = Extents::rank(); │ │ │ │ │ +22 │ │ │ │ │ +23public: │ │ │ │ │ +24 using extents_type = Extents; │ │ │ │ │ +25 using index_type = typename extents_type::index_type; │ │ │ │ │ +26 using size_type = typename extents_type::size_type; │ │ │ │ │ +27 using rank_type = typename extents_type::rank_type; │ │ │ │ │ +28 using layout_type = layout_stride; │ │ │ │ │ +29 │ │ │ │ │ +30private: │ │ │ │ │ +31 using strides_type = std::array; │ │ │ │ │ +32 │ │ │ │ │ +33public: │ │ │ │ │ +34 │ │ │ │ │ +36 constexpr mapping () noexcept │ │ │ │ │ +37 : mapping(layout_right::template mapping{}) │ │ │ │ │ +38 {} │ │ │ │ │ +39 │ │ │ │ │ +41 constexpr mapping (const mapping&) noexcept = default; │ │ │ │ │ +42 │ │ │ │ │ +44 template , │ │ │ │ │ +int> = 0, │ │ │ │ │ +46 std::enable_if_t, int> = 0> │ │ │ │ │ +47 constexpr mapping (const extents_type& e, const std:: │ │ │ │ │ +array& s) noexcept │ │ │ │ │ +48 : extents_(e) │ │ │ │ │ +49 , strides_{} │ │ │ │ │ +50 { │ │ │ │ │ +51 for (rank_type r = 0; r < rank_; ++r) │ │ │ │ │ +52 strides_[r] = s[r]; │ │ │ │ │ +53 } │ │ │ │ │ +54 │ │ │ │ │ +56 template , │ │ │ │ │ +int> = 0, │ │ │ │ │ +58 std::enable_if_t, int> = 0> │ │ │ │ │ +59 constexpr mapping (const extents_type& e, const span& │ │ │ │ │ +s) noexcept │ │ │ │ │ +60 : extents_(e) │ │ │ │ │ +61 , strides_{} │ │ │ │ │ +62 { │ │ │ │ │ +63 for (rank_type r = 0; r < rank_; ++r) │ │ │ │ │ +64 strides_[r] = s[r]; │ │ │ │ │ +65 } │ │ │ │ │ +66 │ │ │ │ │ +68 template = │ │ │ │ │ +0, │ │ │ │ │ +70 std::enable_if_t<(M::is_always_unique()), int> = 0, │ │ │ │ │ +71 std::enable_if_t<(M::is_always_strided()), int> = 0, │ │ │ │ │ +72 decltype(std::declval().extents(), bool{}) = true, │ │ │ │ │ +73 decltype(std::declval().stride(std::declval()), bool{}) = │ │ │ │ │ +true> │ │ │ │ │ +74 constexpr mapping (const M& m) noexcept │ │ │ │ │ +75 : extents_(m.extents()) │ │ │ │ │ +76 , strides_{} │ │ │ │ │ +77 { │ │ │ │ │ +78 for (rank_type r = 0; r < rank_; ++r) │ │ │ │ │ +79 strides_[r] = m.stride(r); │ │ │ │ │ +80 } │ │ │ │ │ +81 │ │ │ │ │ +83 constexpr mapping& operator=_(const mapping&) noexcept = default; │ │ │ │ │ +84 │ │ │ │ │ +85 constexpr const extents_type& extents () const noexcept { return extents_; } │ │ │ │ │ +86 │ │ │ │ │ +88 constexpr index_type required_span_size () const noexcept │ │ │ │ │ +89 { │ │ │ │ │ +90 return size(extents_,strides_); │ │ │ │ │ +91 } │ │ │ │ │ +92 │ │ │ │ │ +94 template = 0, │ │ │ │ │ +96 std::enable_if_t<(std::is_convertible_v && ...), int> = │ │ │ │ │ +0, │ │ │ │ │ +97 std::enable_if_t<(std::is_nothrow_constructible_v && │ │ │ │ │ +...), int> = 0> │ │ │ │ │ +98 constexpr index_type operator()_(Indices... ii) const noexcept │ │ │ │ │ +99 { │ │ │ │ │ +100 return unpackIntegerSequence([&](auto... r) { │ │ │ │ │ +101 return ((static_cast(ii)*strides_[r]) + ... + 0); }, │ │ │ │ │ +102 std::make_index_sequence{}); │ │ │ │ │ 103 } │ │ │ │ │ -104 }; │ │ │ │ │ -105 │ │ │ │ │ -109 template │ │ │ │ │ -110 class Combine │ │ │ │ │ -111 { │ │ │ │ │ -112 public: │ │ │ │ │ -113 static bool contains(const TA& item); │ │ │ │ │ -114 }; │ │ │ │ │ -115 │ │ │ │ │ -116 template │ │ │ │ │ -117 inline bool EmptySet::contains([[maybe_unused]] const Type& attribute) │ │ │ │ │ -118 { │ │ │ │ │ -119 return false; │ │ │ │ │ -120 } │ │ │ │ │ -121 │ │ │ │ │ -122 template │ │ │ │ │ -123 inline bool AllSet::contains([[maybe_unused]] const Type& attribute) │ │ │ │ │ -124 { │ │ │ │ │ -125 return true; │ │ │ │ │ -126 } │ │ │ │ │ -127 │ │ │ │ │ -128 template │ │ │ │ │ -129 inline bool EnumItem::contains(const Type& item) │ │ │ │ │ -130 { │ │ │ │ │ -131 return item==i; │ │ │ │ │ -132 } │ │ │ │ │ -133 │ │ │ │ │ -134 template │ │ │ │ │ -135 inline std::ostream& operator<<(std::ostream& os, const EnumItem&) │ │ │ │ │ +104 │ │ │ │ │ +106 constexpr index_type operator()_() const noexcept │ │ │ │ │ +107 { │ │ │ │ │ +108 return 0; │ │ │ │ │ +109 } │ │ │ │ │ +110 │ │ │ │ │ +111 static constexpr bool is_always_unique () noexcept { return true; } │ │ │ │ │ +112 static constexpr bool is_always_exhaustive () noexcept { return false; } │ │ │ │ │ +113 static constexpr bool is_always_strided () noexcept { return true; } │ │ │ │ │ +114 │ │ │ │ │ +115 static constexpr bool is_unique () noexcept { return true; } │ │ │ │ │ +116 static constexpr bool is_strided () noexcept { return true; } │ │ │ │ │ +117 │ │ │ │ │ +118 constexpr bool is_exhaustive () const noexcept │ │ │ │ │ +119 { │ │ │ │ │ +120 // Actually this could be improved. A strided layout can still be │ │ │ │ │ +exhaustive. │ │ │ │ │ +121 // This test is more complicated to implement, though. See §24.7.3.4.7.4 │ │ │ │ │ +line (5.2) │ │ │ │ │ +122 // in the C++ standard document N4971 │ │ │ │ │ +123 return extents_type::rank() == 0 || (required_span_size() > 0 && required_ │ │ │ │ │ +span_size() == extents().product()); │ │ │ │ │ +124 } │ │ │ │ │ +125 │ │ │ │ │ +127 constexpr const strides_type& strides () const noexcept │ │ │ │ │ +128 { │ │ │ │ │ +129 return strides_; │ │ │ │ │ +130 } │ │ │ │ │ +131 │ │ │ │ │ +133 template 0), int> = 0> │ │ │ │ │ +135 constexpr index_type stride (rank_type i) const noexcept │ │ │ │ │ 136 { │ │ │ │ │ -137 return os< │ │ │ │ │ -141 inline bool EnumRange::contains(const Type& item) │ │ │ │ │ -142 { │ │ │ │ │ -143 return from<=item && item<=to; │ │ │ │ │ -144 } │ │ │ │ │ -145 │ │ │ │ │ -146 template │ │ │ │ │ -147 inline std::ostream& operator<<(std::ostream& os, const │ │ │ │ │ -EnumRange&) │ │ │ │ │ -148 { │ │ │ │ │ -149 return os<<"["< = 0, │ │ │ │ │ +142 std::enable_if_t<(OtherMapping::is_always_strided()), int> = 0> │ │ │ │ │ +143 friend constexpr bool operator== (const mapping& a, const OtherMapping& b) │ │ │ │ │ +noexcept │ │ │ │ │ +144 { │ │ │ │ │ +145 if (offset(b)) │ │ │ │ │ +146 return false; │ │ │ │ │ +147 if constexpr(extents_type::rank() == 0) │ │ │ │ │ +148 return true; │ │ │ │ │ +149 return a.extents_ == b.extents_ && a.strides_ == b.strides_; │ │ │ │ │ 150 } │ │ │ │ │ 151 │ │ │ │ │ -152 template │ │ │ │ │ -153 inline bool Combine::contains(const TA& item) │ │ │ │ │ -154 { │ │ │ │ │ -155 return TI1::contains(item) || │ │ │ │ │ -156 TI2::contains(item); │ │ │ │ │ -157 } │ │ │ │ │ -158 │ │ │ │ │ -159 template │ │ │ │ │ -160 inline Combine combine([[maybe_unused]] const │ │ │ │ │ -TI1& set1, │ │ │ │ │ -161 [[maybe_unused]] const TI2& set2) │ │ │ │ │ -162 { │ │ │ │ │ -163 return Combine(); │ │ │ │ │ -164 } │ │ │ │ │ -165 │ │ │ │ │ -166 template │ │ │ │ │ -167 inline std::ostream& operator<<(std::ostream& os, const │ │ │ │ │ -Combine&) │ │ │ │ │ -168 { │ │ │ │ │ -169 return os << TI1()<<" "< combine(const TI1 &set1, const TI2 │ │ │ │ │ -&set2) │ │ │ │ │ -Definition enumset.hh:160 │ │ │ │ │ -Dune::operator<< │ │ │ │ │ -std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x) │ │ │ │ │ -Definition bigunsignedint.hh:278 │ │ │ │ │ -Dune │ │ │ │ │ -Dune namespace. │ │ │ │ │ -Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::EmptySet │ │ │ │ │ -An empty set. │ │ │ │ │ -Definition enumset.hh:27 │ │ │ │ │ -Dune::EmptySet::Type │ │ │ │ │ -TA Type │ │ │ │ │ -The POD type the set holds. │ │ │ │ │ -Definition enumset.hh:32 │ │ │ │ │ -Dune::AllSet │ │ │ │ │ -A set containing everything. │ │ │ │ │ -Definition enumset.hh:44 │ │ │ │ │ -Dune::AllSet::Type │ │ │ │ │ -TA Type │ │ │ │ │ -The POD type the set holds. │ │ │ │ │ -Definition enumset.hh:49 │ │ │ │ │ -Dune::EnumItem │ │ │ │ │ -A set consisting only of one item. │ │ │ │ │ -Definition enumset.hh:61 │ │ │ │ │ -Dune::EnumItem::Type │ │ │ │ │ -TA Type │ │ │ │ │ -The type the set holds. │ │ │ │ │ -Definition enumset.hh:66 │ │ │ │ │ -Dune::EnumRange │ │ │ │ │ -A set representing a range including the borders. │ │ │ │ │ -Definition enumset.hh:80 │ │ │ │ │ -Dune::EnumRange::Type │ │ │ │ │ -TA Type │ │ │ │ │ -The type the set holds. │ │ │ │ │ -Definition enumset.hh:85 │ │ │ │ │ -Dune::NegateSet │ │ │ │ │ -The negation of a set. An item is contained in the set if and only if it is not │ │ │ │ │ -contained in the nega... │ │ │ │ │ -Definition enumset.hh:96 │ │ │ │ │ -Dune::NegateSet::Type │ │ │ │ │ -S::Type Type │ │ │ │ │ -Definition enumset.hh:98 │ │ │ │ │ -Dune::NegateSet::contains │ │ │ │ │ -static bool contains(const Type &item) │ │ │ │ │ -Definition enumset.hh:100 │ │ │ │ │ -Dune::Combine │ │ │ │ │ -A set combining two other sets. │ │ │ │ │ -Definition enumset.hh:111 │ │ │ │ │ +152private: │ │ │ │ │ +153 template │ │ │ │ │ +154 static constexpr index_type size (const E& extents, const S& strides) │ │ │ │ │ +noexcept │ │ │ │ │ +155 { │ │ │ │ │ +156 if constexpr (E::rank() == 0) │ │ │ │ │ +157 return 1; │ │ │ │ │ +158 else { │ │ │ │ │ +159 if (extents.product() == 0) │ │ │ │ │ +160 return 0; │ │ │ │ │ +161 else { │ │ │ │ │ +162 index_type result = 1; │ │ │ │ │ +163 for (rank_type r = 0; r < E::rank(); ++r) │ │ │ │ │ +164 result += (extents.extent(r)-1) * strides[r]; │ │ │ │ │ +165 return result; │ │ │ │ │ +166 } │ │ │ │ │ +167 } │ │ │ │ │ +168 } │ │ │ │ │ +169 │ │ │ │ │ +170 template │ │ │ │ │ +171 static constexpr size_type offset (const M& m) noexcept │ │ │ │ │ +172 { │ │ │ │ │ +173 if constexpr (M::extents_type::rank() == 0) │ │ │ │ │ +174 return m(); │ │ │ │ │ +175 else { │ │ │ │ │ +176 if (m.required_span_size() == 0) │ │ │ │ │ +177 return 0; │ │ │ │ │ +178 else { │ │ │ │ │ +179 return unpackIntegerSequence([&](auto... r) { │ │ │ │ │ +180 return m((r,0)...); }, // map the index tuple (0,0...) │ │ │ │ │ +181 std::make_index_sequence{}); │ │ │ │ │ +182 } │ │ │ │ │ +183 } │ │ │ │ │ +184 } │ │ │ │ │ +185 │ │ │ │ │ +186private: │ │ │ │ │ +187 [[no_unique_address]] extents_type extents_; │ │ │ │ │ +188 strides_type strides_; │ │ │ │ │ +189}; │ │ │ │ │ +190 │ │ │ │ │ +191} // end namespace Dune::Std │ │ │ │ │ +192 │ │ │ │ │ +193#endif // DUNE_COMMON_STD_LAYOUT_STRIDE_HH │ │ │ │ │ +indices.hh │ │ │ │ │ +fwd_layouts.hh │ │ │ │ │ +Dune::unpackIntegerSequence │ │ │ │ │ +decltype(auto) constexpr unpackIntegerSequence(F &&f, std::integer_sequence< I, │ │ │ │ │ +i... > sequence) │ │ │ │ │ +Unpack an std::integer_sequence to std::integral_constant... │ │ │ │ │ +Definition indices.hh:124 │ │ │ │ │ +Dune::Std │ │ │ │ │ +Namespace for features backported from new C++ standards. │ │ │ │ │ +Definition default_accessor.hh:10 │ │ │ │ │ +Dune::Std::extents │ │ │ │ │ +Multidimensional index space with dynamic and static extents. │ │ │ │ │ +Definition extents.hh:54 │ │ │ │ │ +Dune::Std::extents::extent │ │ │ │ │ +constexpr index_type extent(rank_type r) const noexcept │ │ │ │ │ +Return the extent of dimension i │ │ │ │ │ +Definition extents.hh:100 │ │ │ │ │ +Dune::Std::layout_right │ │ │ │ │ +A layout where the rightmost extent has stride 1, and strides increase right- │ │ │ │ │ +to-left as the product o... │ │ │ │ │ +Definition fwd_layouts.hh:30 │ │ │ │ │ +Dune::Std::layout_stride │ │ │ │ │ +A layout mapping where the strides are user-defined. │ │ │ │ │ +Definition fwd_layouts.hh:40 │ │ │ │ │ +Dune::Std::layout_stride::mapping │ │ │ │ │ +A layout mapping where the strides are user-defined. │ │ │ │ │ +Definition layout_stride.hh:19 │ │ │ │ │ +Dune::Std::layout_stride::mapping::mapping │ │ │ │ │ +constexpr mapping(const extents_type &e, const span< OtherIndexType, rank_ > │ │ │ │ │ +&s) noexcept │ │ │ │ │ +Construct the mapping from given extents and strides. │ │ │ │ │ +Definition layout_stride.hh:59 │ │ │ │ │ +Dune::Std::layout_stride::mapping::extents_type │ │ │ │ │ +Extents extents_type │ │ │ │ │ +Definition layout_stride.hh:24 │ │ │ │ │ +Dune::Std::layout_stride::mapping::operator= │ │ │ │ │ +constexpr mapping & operator=(const mapping &) noexcept=default │ │ │ │ │ +Copy-assignment for the mapping. │ │ │ │ │ +Dune::Std::layout_stride::mapping::is_exhaustive │ │ │ │ │ +constexpr bool is_exhaustive() const noexcept │ │ │ │ │ +Definition layout_stride.hh:118 │ │ │ │ │ +Dune::Std::layout_stride::mapping::mapping │ │ │ │ │ +constexpr mapping() noexcept │ │ │ │ │ +The default construction initializes the strides from layout_right. │ │ │ │ │ +Definition layout_stride.hh:36 │ │ │ │ │ +Dune::Std::layout_stride::mapping::mapping │ │ │ │ │ +constexpr mapping(const extents_type &e, const std::array< OtherIndexType, │ │ │ │ │ +rank_ > &s) noexcept │ │ │ │ │ +Construct the mapping from given extents and strides. │ │ │ │ │ +Definition layout_stride.hh:47 │ │ │ │ │ +Dune::Std::layout_stride::mapping::stride │ │ │ │ │ +constexpr index_type stride(rank_type i) const noexcept │ │ │ │ │ +Get the single stride i │ │ │ │ │ +Definition layout_stride.hh:135 │ │ │ │ │ +Dune::Std::layout_stride::mapping::index_type │ │ │ │ │ +typename extents_type::index_type index_type │ │ │ │ │ +Definition layout_stride.hh:25 │ │ │ │ │ +Dune::Std::layout_stride::mapping::is_always_exhaustive │ │ │ │ │ +static constexpr bool is_always_exhaustive() noexcept │ │ │ │ │ +Definition layout_stride.hh:112 │ │ │ │ │ +Dune::Std::layout_stride::mapping::extents │ │ │ │ │ +constexpr const extents_type & extents() const noexcept │ │ │ │ │ +Definition layout_stride.hh:85 │ │ │ │ │ +Dune::Std::layout_stride::mapping::is_strided │ │ │ │ │ +static constexpr bool is_strided() noexcept │ │ │ │ │ +Definition layout_stride.hh:116 │ │ │ │ │ +Dune::Std::layout_stride::mapping::is_always_strided │ │ │ │ │ +static constexpr bool is_always_strided() noexcept │ │ │ │ │ +Definition layout_stride.hh:113 │ │ │ │ │ +Dune::Std::layout_stride::mapping::required_span_size │ │ │ │ │ +constexpr index_type required_span_size() const noexcept │ │ │ │ │ +Return the sum 1 + (E(0)-1)*S(0) + (E(1)-1)*S(1) + ... │ │ │ │ │ +Definition layout_stride.hh:88 │ │ │ │ │ +Dune::Std::layout_stride::mapping::strides │ │ │ │ │ +constexpr const strides_type & strides() const noexcept │ │ │ │ │ +Get the array of all strides. │ │ │ │ │ +Definition layout_stride.hh:127 │ │ │ │ │ +Dune::Std::layout_stride::mapping::mapping │ │ │ │ │ +constexpr mapping(const mapping &) noexcept=default │ │ │ │ │ +Copy constructor for the mapping. │ │ │ │ │ +Dune::Std::layout_stride::mapping::rank_type │ │ │ │ │ +typename extents_type::rank_type rank_type │ │ │ │ │ +Definition layout_stride.hh:27 │ │ │ │ │ +Dune::Std::layout_stride::mapping::is_unique │ │ │ │ │ +static constexpr bool is_unique() noexcept │ │ │ │ │ +Definition layout_stride.hh:115 │ │ │ │ │ +Dune::Std::layout_stride::mapping::operator() │ │ │ │ │ +constexpr index_type operator()() const noexcept │ │ │ │ │ +The default offset for rank-0 tensors is 0. │ │ │ │ │ +Definition layout_stride.hh:106 │ │ │ │ │ +Dune::Std::layout_stride::mapping::size_type │ │ │ │ │ +typename extents_type::size_type size_type │ │ │ │ │ +Definition layout_stride.hh:26 │ │ │ │ │ +Dune::Std::layout_stride::mapping::is_always_unique │ │ │ │ │ +static constexpr bool is_always_unique() noexcept │ │ │ │ │ +Definition layout_stride.hh:111 │ │ │ │ │ +Dune::Std::span │ │ │ │ │ +A contiguous sequence of elements with static or dynamic extent. │ │ │ │ │ +Definition span.hh:126 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00062.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: singleton.hh File Reference │ │ │ │ +dune-common: default_accessor.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,46 +65,43 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ Namespaces
│ │ │ │ -
singleton.hh File Reference
│ │ │ │ +
default_accessor.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ - │ │ │ │ -

Useful wrapper for creating singletons. │ │ │ │ -More...

│ │ │ │ -
#include <dune/common/visibility.hh>
│ │ │ │ +
#include <type_traits>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::Singleton< T >
 An adapter to turn a class into a singleton. More...
class  Dune::Std::default_accessor< Element >
 A type for indexed access to elements of mdspan. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::Std
 Namespace for features backported from new C++ standards.
 
│ │ │ │ -

Detailed Description

│ │ │ │ -

Useful wrapper for creating singletons.

│ │ │ │ -

Inspired by the article CodeGuru: A Leak-Free Singleton class

│ │ │ │ -
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,24 +1,24 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ + * std │ │ │ │ │ Classes | Namespaces │ │ │ │ │ -singleton.hh File Reference │ │ │ │ │ -Useful wrapper for creating singletons. More... │ │ │ │ │ -#include │ │ │ │ │ +default_accessor.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class   Dune::Singleton<_T_> │ │ │ │ │ -  An adapter to turn a class into a singleton. More... │ │ │ │ │ +class   Dune::Std::default_accessor<_Element_> │ │ │ │ │ +  A type for indexed access to elements of mdspan. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -Useful wrapper for creating singletons. │ │ │ │ │ -Inspired by the article CodeGuru:_A_Leak-Free_Singleton_class │ │ │ │ │ +namespace   Dune::Std │ │ │ │ │ +  Namespace for features backported from new C++ standards. │ │ │ │ │ +  │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00062_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: singleton.hh Source File │ │ │ │ +dune-common: default_accessor.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,66 +70,80 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
singleton.hh
│ │ │ │ +
default_accessor.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_SINGLETON_HH
│ │ │ │ -
6#define DUNE_SINGLETON_HH
│ │ │ │ +
5#ifndef DUNE_COMMON_STD_DEFAULT_ACCESSOR_HH
│ │ │ │ +
6#define DUNE_COMMON_STD_DEFAULT_ACCESSOR_HH
│ │ │ │
7
│ │ │ │ - │ │ │ │ +
8#include <type_traits>
│ │ │ │
9
│ │ │ │ -
17namespace Dune
│ │ │ │ -
18{
│ │ │ │ -
54 template<class T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
56 {
│ │ │ │ -
57 protected:
│ │ │ │ -
58 /* @brief Protected constructor. */
│ │ │ │ -
59 Singleton() = default;
│ │ │ │ -
60
│ │ │ │ -
61 public:
│ │ │ │ -
62
│ │ │ │ -
63 Singleton(const Singleton&) = delete;
│ │ │ │ -
64 void operator=(const Singleton&) = delete;
│ │ │ │ -
65
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
71 {
│ │ │ │ -
72 static T instance_;
│ │ │ │ -
73 return instance_;
│ │ │ │ -
74 }
│ │ │ │ -
│ │ │ │ -
75 };
│ │ │ │ -
│ │ │ │ -
76
│ │ │ │ -
77} // namespace Dune
│ │ │ │ -
78
│ │ │ │ -
79#endif
│ │ │ │ -
Definition of macros controlling symbol visibility at the ABI level.
│ │ │ │ -
#define DUNE_EXPORT
Export a symbol as part of the public ABI.
Definition visibility.hh:20
│ │ │ │ -
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
An adapter to turn a class into a singleton.
Definition singleton.hh:56
│ │ │ │ -
Singleton()=default
│ │ │ │ -
Singleton(const Singleton &)=delete
│ │ │ │ -
void operator=(const Singleton &)=delete
│ │ │ │ -
static DUNE_EXPORT T & instance()
Get the instance of the singleton.
Definition singleton.hh:70
│ │ │ │ +
│ │ │ │ +
10namespace Dune::Std {
│ │ │ │ +
11
│ │ │ │ +
22template <class Element>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
24{
│ │ │ │ +
25public:
│ │ │ │ +
26 using element_type = Element;
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
30
│ │ │ │ +
31public:
│ │ │ │ +
32 // [mdspan.accessor.default.overview]
│ │ │ │ +
34 constexpr default_accessor () noexcept = default;
│ │ │ │ +
35
│ │ │ │ +
37 template <class OtherElement,
│ │ │ │ +
38 std::enable_if_t<std::is_convertible_v<OtherElement(*)[], Element(*)[]>, int> = 0>
│ │ │ │ +
39 constexpr default_accessor (default_accessor<OtherElement>) noexcept {}
│ │ │ │ +
40
│ │ │ │ +
│ │ │ │ +
42 constexpr reference access (data_handle_type p, std::size_t i) const noexcept
│ │ │ │ +
43 {
│ │ │ │ +
44 return p[i];
│ │ │ │ +
45 }
│ │ │ │ +
│ │ │ │ +
46
│ │ │ │ +
│ │ │ │ +
48 constexpr data_handle_type offset (data_handle_type p, std::size_t i) const noexcept
│ │ │ │ +
49 {
│ │ │ │ +
50 return p + i;
│ │ │ │ +
51 }
│ │ │ │ +
│ │ │ │ +
52};
│ │ │ │ +
│ │ │ │ +
53
│ │ │ │ +
54} // end namespace Dune::Std
│ │ │ │ +
│ │ │ │ +
55
│ │ │ │ +
56#endif // DUNE_COMMON_STD_DEFAULT_ACCESSOR_HH
│ │ │ │ +
STL namespace.
│ │ │ │ +
Namespace for features backported from new C++ standards.
Definition default_accessor.hh:10
│ │ │ │ +
A type for indexed access to elements of mdspan.
Definition default_accessor.hh:24
│ │ │ │ +
element_type * data_handle_type
Definition default_accessor.hh:27
│ │ │ │ +
element_type & reference
Definition default_accessor.hh:28
│ │ │ │ +
Element element_type
Definition default_accessor.hh:26
│ │ │ │ +
constexpr default_accessor() noexcept=default
Default constructor.
│ │ │ │ +
constexpr reference access(data_handle_type p, std::size_t i) const noexcept
Return a reference to the i'th element in the data range starting at p
Definition default_accessor.hh:42
│ │ │ │ +
constexpr data_handle_type offset(data_handle_type p, std::size_t i) const noexcept
Return a data handle to the i'th element in the data range starting at p
Definition default_accessor.hh:48
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,66 +1,86 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -singleton.hh │ │ │ │ │ + * std │ │ │ │ │ +default_accessor.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_SINGLETON_HH │ │ │ │ │ -6#define DUNE_SINGLETON_HH │ │ │ │ │ +5#ifndef DUNE_COMMON_STD_DEFAULT_ACCESSOR_HH │ │ │ │ │ +6#define DUNE_COMMON_STD_DEFAULT_ACCESSOR_HH │ │ │ │ │ 7 │ │ │ │ │ -8#include │ │ │ │ │ +8#include │ │ │ │ │ 9 │ │ │ │ │ -17namespace Dune │ │ │ │ │ -18{ │ │ │ │ │ -54 template │ │ │ │ │ -55 class Singleton │ │ │ │ │ -56 { │ │ │ │ │ -57 protected: │ │ │ │ │ -58 /* @brief Protected constructor. */ │ │ │ │ │ -59 Singleton() = default; │ │ │ │ │ -60 │ │ │ │ │ -61 public: │ │ │ │ │ -62 │ │ │ │ │ -63 Singleton(const Singleton&) = delete; │ │ │ │ │ -64 void operator=(const Singleton&) = delete; │ │ │ │ │ -65 │ │ │ │ │ -70 DUNE_EXPORT static T& instance() │ │ │ │ │ -71 { │ │ │ │ │ -72 static T instance_; │ │ │ │ │ -73 return instance_; │ │ │ │ │ -74 } │ │ │ │ │ -75 }; │ │ │ │ │ -76 │ │ │ │ │ -77} // namespace Dune │ │ │ │ │ -78 │ │ │ │ │ -79#endif │ │ │ │ │ -visibility.hh │ │ │ │ │ -Definition of macros controlling symbol visibility at the ABI level. │ │ │ │ │ -DUNE_EXPORT │ │ │ │ │ -#define DUNE_EXPORT │ │ │ │ │ -Export a symbol as part of the public ABI. │ │ │ │ │ -Definition visibility.hh:20 │ │ │ │ │ -Dune │ │ │ │ │ -Dune namespace. │ │ │ │ │ -Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::Singleton │ │ │ │ │ -An adapter to turn a class into a singleton. │ │ │ │ │ -Definition singleton.hh:56 │ │ │ │ │ -Dune::Singleton::Singleton │ │ │ │ │ -Singleton()=default │ │ │ │ │ -Dune::Singleton::Singleton │ │ │ │ │ -Singleton(const Singleton &)=delete │ │ │ │ │ -Dune::Singleton::operator= │ │ │ │ │ -void operator=(const Singleton &)=delete │ │ │ │ │ -Dune::Singleton::instance │ │ │ │ │ -static DUNE_EXPORT T & instance() │ │ │ │ │ -Get the instance of the singleton. │ │ │ │ │ -Definition singleton.hh:70 │ │ │ │ │ +10namespace Dune::Std { │ │ │ │ │ +11 │ │ │ │ │ +22template │ │ │ │ │ +23class default_accessor │ │ │ │ │ +24{ │ │ │ │ │ +25public: │ │ │ │ │ +26 using element_type = Element; │ │ │ │ │ +27 using data_handle_type = element_type*; │ │ │ │ │ +28 using reference = element_type&; │ │ │ │ │ +29 using offset_policy = default_accessor; │ │ │ │ │ +30 │ │ │ │ │ +31public: │ │ │ │ │ +32 // [mdspan.accessor.default.overview] │ │ │ │ │ +34 constexpr default_accessor () noexcept = default; │ │ │ │ │ +35 │ │ │ │ │ +37 template , │ │ │ │ │ +int> = 0> │ │ │ │ │ +39 constexpr default_accessor (default_accessor) noexcept {} │ │ │ │ │ +40 │ │ │ │ │ +42 constexpr reference access (data_handle_type p, std::size_t i) const │ │ │ │ │ +noexcept │ │ │ │ │ +43 { │ │ │ │ │ +44 return p[i]; │ │ │ │ │ +45 } │ │ │ │ │ +46 │ │ │ │ │ +48 constexpr data_handle_type offset (data_handle_type p, std::size_t i) const │ │ │ │ │ +noexcept │ │ │ │ │ +49 { │ │ │ │ │ +50 return p + i; │ │ │ │ │ +51 } │ │ │ │ │ +52}; │ │ │ │ │ +53 │ │ │ │ │ +54} // end namespace Dune::Std │ │ │ │ │ +55 │ │ │ │ │ +56#endif // DUNE_COMMON_STD_DEFAULT_ACCESSOR_HH │ │ │ │ │ +std │ │ │ │ │ +STL namespace. │ │ │ │ │ +Dune::Std │ │ │ │ │ +Namespace for features backported from new C++ standards. │ │ │ │ │ +Definition default_accessor.hh:10 │ │ │ │ │ +Dune::Std::default_accessor │ │ │ │ │ +A type for indexed access to elements of mdspan. │ │ │ │ │ +Definition default_accessor.hh:24 │ │ │ │ │ +Dune::Std::default_accessor::data_handle_type │ │ │ │ │ +element_type * data_handle_type │ │ │ │ │ +Definition default_accessor.hh:27 │ │ │ │ │ +Dune::Std::default_accessor::reference │ │ │ │ │ +element_type & reference │ │ │ │ │ +Definition default_accessor.hh:28 │ │ │ │ │ +Dune::Std::default_accessor::element_type │ │ │ │ │ +Element element_type │ │ │ │ │ +Definition default_accessor.hh:26 │ │ │ │ │ +Dune::Std::default_accessor::default_accessor │ │ │ │ │ +constexpr default_accessor() noexcept=default │ │ │ │ │ +Default constructor. │ │ │ │ │ +Dune::Std::default_accessor::access │ │ │ │ │ +constexpr reference access(data_handle_type p, std::size_t i) const noexcept │ │ │ │ │ +Return a reference to the i'th element in the data range starting at p │ │ │ │ │ +Definition default_accessor.hh:42 │ │ │ │ │ +Dune::Std::default_accessor::offset │ │ │ │ │ +constexpr data_handle_type offset(data_handle_type p, std::size_t i) const │ │ │ │ │ +noexcept │ │ │ │ │ +Return a data handle to the i'th element in the data range starting at p │ │ │ │ │ +Definition default_accessor.hh:48 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00065.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: path.hh File Reference │ │ │ │ +dune-common: layout_left.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,61 +65,46 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Namespaces | │ │ │ │ -Functions
│ │ │ │ -
path.hh File Reference
│ │ │ │ +Classes | │ │ │ │ +Namespaces
│ │ │ │ +
layout_left.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ - │ │ │ │ -

Utilities for handling filesystem paths. │ │ │ │ -More...

│ │ │ │ -
#include <string>
│ │ │ │ +
#include <array>
│ │ │ │ +#include <type_traits>
│ │ │ │ +#include <dune/common/indices.hh>
│ │ │ │ +#include <dune/common/std/impl/fwd_layouts.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Classes

class  Dune::Std::layout_left::mapping< Extents >
 A layout mapping where the leftmost extent has stride 1. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ -Functions

std::string Dune::concatPaths (const std::string &base, const std::string &p)
 concatenate two paths
 
std::string Dune::processPath (const std::string &p)
 sanitize a path for further processing
 
bool Dune::pathIndicatesDirectory (const std::string &p)
 check whether the given path indicates that it is a directory
 
std::string Dune::prettyPath (const std::string &p, bool isDirectory)
 pretty print path
 
std::string Dune::prettyPath (const std::string &p)
 pretty print path
 
std::string Dune::relativePath (const std::string &newbase, const std::string &p)
 compute a relative path between two paths
 
namespace  Dune::Std
 Namespace for features backported from new C++ standards.
 
│ │ │ │ -

Detailed Description

│ │ │ │ -

Utilities for handling filesystem paths.

│ │ │ │ -
Author
Jö Fahlke jorri.nosp@m.t@jo.nosp@m.rrit..nosp@m.de
│ │ │ │ -
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── encoding │ │ │ │ │ @@ -1 +1 @@ │ │ │ │ │ -utf-8 │ │ │ │ │ +us-ascii │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,42 +1,27 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Namespaces | Functions │ │ │ │ │ -path.hh File Reference │ │ │ │ │ -Common » Utilities » Filesystem_Paths │ │ │ │ │ -Utilities for handling filesystem paths. More... │ │ │ │ │ -#include │ │ │ │ │ + * std │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +layout_left.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ +Classes │ │ │ │ │ +class   Dune::Std::layout_left::mapping<_Extents_> │ │ │ │ │ +  A layout mapping where the leftmost extent has stride 1. More... │ │ │ │ │ +  │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -Functions │ │ │ │ │ -std::string  Dune::concatPaths (const std::string &base, const std::string &p) │ │ │ │ │ -  concatenate two paths │ │ │ │ │ -  │ │ │ │ │ -std::string  Dune::processPath (const std::string &p) │ │ │ │ │ -  sanitize a path for further processing │ │ │ │ │ -  │ │ │ │ │ - bool  Dune::pathIndicatesDirectory (const std::string &p) │ │ │ │ │ -  check whether the given path indicates that it is a directory │ │ │ │ │ -  │ │ │ │ │ -std::string  Dune::prettyPath (const std::string &p, bool isDirectory) │ │ │ │ │ -  pretty print path │ │ │ │ │ -  │ │ │ │ │ -std::string  Dune::prettyPath (const std::string &p) │ │ │ │ │ -  pretty print path │ │ │ │ │ -  │ │ │ │ │ -std::string  Dune::relativePath (const std::string &newbase, const std::string │ │ │ │ │ - &p) │ │ │ │ │ -  compute a relative path between two paths │ │ │ │ │ +namespace   Dune::Std │ │ │ │ │ +  Namespace for features backported from new C++ standards. │ │ │ │ │   │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -Utilities for handling filesystem paths. │ │ │ │ │ - Author │ │ │ │ │ - Jö Fahlke jorri.nosp@m.t@jo.nosp@m.rrit..nosp@m.de │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00065_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: path.hh Source File │ │ │ │ +dune-common: layout_left.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,58 +70,197 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
path.hh
│ │ │ │ +
layout_left.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_COMMON_PATH_HH
│ │ │ │ -
6#define DUNE_COMMON_PATH_HH
│ │ │ │ +
5#ifndef DUNE_COMMON_STD_LAYOUT_LEFT_HH
│ │ │ │ +
6#define DUNE_COMMON_STD_LAYOUT_LEFT_HH
│ │ │ │
7
│ │ │ │ -
8#include <string>
│ │ │ │ -
9
│ │ │ │ -
10namespace Dune {
│ │ │ │ -
23
│ │ │ │ -
51 std::string concatPaths(const std::string& base, const std::string& p);
│ │ │ │ -
52
│ │ │ │ -
54
│ │ │ │ -
98 std::string processPath(const std::string& p);
│ │ │ │ -
99
│ │ │ │ -
101
│ │ │ │ -
109 bool pathIndicatesDirectory(const std::string& p);
│ │ │ │ -
110
│ │ │ │ -
112
│ │ │ │ -
151 std::string prettyPath(const std::string& p, bool isDirectory);
│ │ │ │ -
152
│ │ │ │ -
154
│ │ │ │ -
160 std::string prettyPath(const std::string& p);
│ │ │ │ -
161
│ │ │ │ -
163
│ │ │ │ -
179 std::string relativePath(const std::string& newbase, const std::string& p);
│ │ │ │ -
180
│ │ │ │ -
182}
│ │ │ │ -
183
│ │ │ │ -
184#endif // DUNE_COMMON_PATH_HH
│ │ │ │ -
std::string processPath(const std::string &p)
sanitize a path for further processing
Definition path.cc:37
│ │ │ │ -
bool pathIndicatesDirectory(const std::string &p)
check whether the given path indicates that it is a directory
Definition path.cc:111
│ │ │ │ -
std::string prettyPath(const std::string &p, bool isDirectory)
pretty print path
Definition path.cc:122
│ │ │ │ -
std::string relativePath(const std::string &newbase, const std::string &p)
compute a relative path between two paths
Definition path.cc:149
│ │ │ │ -
std::string concatPaths(const std::string &base, const std::string &p)
concatenate two paths
Definition path.cc:28
│ │ │ │ -
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ +
8#include <array>
│ │ │ │ +
9#include <type_traits>
│ │ │ │ +
10
│ │ │ │ + │ │ │ │ + │ │ │ │ +
13
│ │ │ │ +
14namespace Dune::Std {
│ │ │ │ +
15
│ │ │ │ +
17template <class Extents>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
19{
│ │ │ │ +
20 template <class> friend class mapping;
│ │ │ │ +
21
│ │ │ │ +
22public:
│ │ │ │ +
23 using extents_type = Extents;
│ │ │ │ +
24 using size_type = typename extents_type::size_type;
│ │ │ │ +
25 using rank_type = typename extents_type::rank_type;
│ │ │ │ +
26 using index_type = typename extents_type::index_type;
│ │ │ │ + │ │ │ │ +
28
│ │ │ │ +
30 constexpr mapping () noexcept = default;
│ │ │ │ +
31
│ │ │ │ +
33 constexpr mapping (const mapping&) noexcept = default;
│ │ │ │ +
34
│ │ │ │ +
│ │ │ │ +
36 constexpr mapping (const extents_type& e) noexcept
│ │ │ │ +
37 : extents_(e)
│ │ │ │ +
38 {}
│ │ │ │ +
│ │ │ │ +
39
│ │ │ │ +
41 template <class OtherExtents,
│ │ │ │ +
42 std::enable_if_t<std::is_constructible_v<extents_type, OtherExtents>, int> = 0>
│ │ │ │ +
43 #if __cpp_conditional_explicit >= 201806L
│ │ │ │ +
44 explicit(!std::is_convertible_v<OtherExtents, extents_type>)
│ │ │ │ +
45 #endif
│ │ │ │ +
│ │ │ │ +
46 constexpr mapping (const mapping<OtherExtents>& m) noexcept
│ │ │ │ +
47 : extents_(m.extents())
│ │ │ │ +
48 {}
│ │ │ │ +
│ │ │ │ +
49
│ │ │ │ +
51 template <class OtherExtents, class E = extents_type,
│ │ │ │ +
52 std::enable_if_t<(E::rank() <= 1), int> = 0,
│ │ │ │ +
53 std::enable_if_t<std::is_constructible_v<extents_type, OtherExtents>, int> = 0>
│ │ │ │ +
54 #if __cpp_conditional_explicit >= 201806L
│ │ │ │ +
55 explicit(!std::is_convertible_v<OtherExtents, extents_type>)
│ │ │ │ +
56 #endif
│ │ │ │ +
│ │ │ │ +
57 constexpr mapping (const layout_right::mapping<OtherExtents>& m) noexcept
│ │ │ │ +
58 : extents_(m.extents())
│ │ │ │ +
59 {}
│ │ │ │ +
│ │ │ │ +
60
│ │ │ │ +
62 template <class OtherExtents,
│ │ │ │ +
63 std::enable_if_t<std::is_constructible_v<extents_type, OtherExtents>, int> = 0>
│ │ │ │ +
64 #if __cpp_conditional_explicit >= 201806L
│ │ │ │ +
65 explicit(extents_type::rank() > 0)
│ │ │ │ +
66 #endif
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
68 : extents_(m.extents())
│ │ │ │ +
69 {
│ │ │ │ +
70#ifndef NDEBUG
│ │ │ │ +
71 if constexpr(extents_type::rank() > 0) {
│ │ │ │ +
72 index_type prod = 1;
│ │ │ │ +
73 for (rank_type r = 0; r < extents_type::rank()-1; ++r) {
│ │ │ │ +
74 assert(m.strides(r) == prod);
│ │ │ │ +
75 prod *= m.extents().extent(r);
│ │ │ │ +
76 }
│ │ │ │ +
77 assert(m.strides(extents_type::rank()-1) == prod);
│ │ │ │ +
78 }
│ │ │ │ +
79#endif
│ │ │ │ +
80 }
│ │ │ │ +
│ │ │ │ +
81
│ │ │ │ +
83 constexpr mapping& operator= (const mapping&) noexcept = default;
│ │ │ │ +
84
│ │ │ │ +
85 constexpr const extents_type& extents () const noexcept { return extents_; }
│ │ │ │ +
86 constexpr index_type required_span_size () const noexcept { return extents_.product(); }
│ │ │ │ +
87
│ │ │ │ +
89 template <class... Indices,
│ │ │ │ +
90 std::enable_if_t<(sizeof...(Indices) == extents_type::rank()), int> = 0,
│ │ │ │ +
91 std::enable_if_t<(... && std::is_convertible_v<Indices, index_type>), int> = 0,
│ │ │ │ +
92 std::enable_if_t<(... && std::is_nothrow_constructible_v<Indices, index_type>), int> = 0>
│ │ │ │ +
│ │ │ │ +
93 constexpr index_type operator() (Indices... ii) const noexcept
│ │ │ │ +
94 {
│ │ │ │ +
95 const std::array indices{index_type(std::move(ii))...};
│ │ │ │ +
96 index_type value = indices.back();
│ │ │ │ +
97 for (rank_type r = 1; r < extents_type::rank(); ++r) {
│ │ │ │ +
98 const rank_type j = extents_type::rank()-r;
│ │ │ │ +
99 value = indices[j-1] + extents_.extent(j-1) * value;
│ │ │ │ +
100 }
│ │ │ │ +
101 return value;
│ │ │ │ +
102 }
│ │ │ │ +
│ │ │ │ +
103
│ │ │ │ +
│ │ │ │ +
105 constexpr index_type operator() () const noexcept
│ │ │ │ +
106 {
│ │ │ │ +
107 return 0;
│ │ │ │ +
108 }
│ │ │ │ +
│ │ │ │ +
109
│ │ │ │ +
110 static constexpr bool is_always_unique () noexcept { return true; }
│ │ │ │ +
111 static constexpr bool is_always_exhaustive () noexcept { return true; }
│ │ │ │ +
112 static constexpr bool is_always_strided () noexcept { return true; }
│ │ │ │ +
113
│ │ │ │ +
114 static constexpr bool is_unique () noexcept { return true; }
│ │ │ │ +
115 static constexpr bool is_exhaustive () noexcept { return true; }
│ │ │ │ +
116 static constexpr bool is_strided () noexcept { return true; }
│ │ │ │ +
117
│ │ │ │ +
119 template <class E = extents_type,
│ │ │ │ +
120 std::enable_if_t<(E::rank() > 0), int> = 0>
│ │ │ │ +
│ │ │ │ +
121 constexpr index_type stride (rank_type i) const noexcept
│ │ │ │ +
122 {
│ │ │ │ +
123 assert(i < extents_type::rank());
│ │ │ │ +
124 index_type prod = 1;
│ │ │ │ +
125 for (rank_type r = 0; r < i; ++r)
│ │ │ │ +
126 prod *= extents().extent(r);
│ │ │ │ +
127 return prod;
│ │ │ │ +
128 }
│ │ │ │ +
│ │ │ │ +
129
│ │ │ │ +
130 template <class OtherExtents,
│ │ │ │ +
131 std::enable_if_t<(Extents::rank() == OtherExtents::rank()), int> = 0>
│ │ │ │ +
│ │ │ │ +
132 friend constexpr bool operator== (const mapping& a, const mapping<OtherExtents>& b) noexcept
│ │ │ │ +
133 {
│ │ │ │ +
134 return a.extents_ == b.extents_;
│ │ │ │ +
135 }
│ │ │ │ +
│ │ │ │ +
136
│ │ │ │ +
137private:
│ │ │ │ +
138 [[no_unique_address]] extents_type extents_;
│ │ │ │ +
139};
│ │ │ │ +
│ │ │ │ +
140
│ │ │ │ +
141} // end namespace Dune::Std
│ │ │ │ +
142
│ │ │ │ +
143#endif // DUNE_COMMON_STD_LAYOUT_LEFT_HH
│ │ │ │ + │ │ │ │ + │ │ │ │ +
Namespace for features backported from new C++ standards.
Definition default_accessor.hh:10
│ │ │ │ +
A layout where the leftmost extent has stride 1.
Definition fwd_layouts.hh:17
│ │ │ │ +
A layout mapping where the leftmost extent has stride 1.
Definition layout_left.hh:19
│ │ │ │ +
constexpr index_type stride(rank_type i) const noexcept
The stride is the product of the extents E(0)*E(1)*...*E(i-1)
Definition layout_left.hh:121
│ │ │ │ +
typename extents_type::index_type index_type
Definition layout_left.hh:26
│ │ │ │ +
constexpr index_type required_span_size() const noexcept
Definition layout_left.hh:86
│ │ │ │ +
constexpr mapping & operator=(const mapping &) noexcept=default
Copy-assignment for the mapping.
│ │ │ │ +
Extents extents_type
Definition layout_left.hh:23
│ │ │ │ +
static constexpr bool is_always_unique() noexcept
Definition layout_left.hh:110
│ │ │ │ +
constexpr mapping() noexcept=default
The default construction is possible for default constructible extents.
│ │ │ │ +
static constexpr bool is_strided() noexcept
Definition layout_left.hh:116
│ │ │ │ +
static constexpr bool is_always_strided() noexcept
Definition layout_left.hh:112
│ │ │ │ +
constexpr index_type operator()() const noexcept
The default offset for rank-0 tensors is 0.
Definition layout_left.hh:105
│ │ │ │ +
typename extents_type::size_type size_type
Definition layout_left.hh:24
│ │ │ │ +
static constexpr bool is_unique() noexcept
Definition layout_left.hh:114
│ │ │ │ +
constexpr mapping(const layout_right::mapping< OtherExtents > &m) noexcept
Construct the mapping from a layout_right.
Definition layout_left.hh:57
│ │ │ │ +
constexpr const extents_type & extents() const noexcept
Definition layout_left.hh:85
│ │ │ │ +
static constexpr bool is_always_exhaustive() noexcept
Definition layout_left.hh:111
│ │ │ │ +
typename extents_type::rank_type rank_type
Definition layout_left.hh:25
│ │ │ │ +
static constexpr bool is_exhaustive() noexcept
Definition layout_left.hh:115
│ │ │ │ +
A layout mapping where the rightmost extent has stride 1.
Definition layout_right.hh:19
│ │ │ │ +
A layout mapping where the strides are user-defined.
Definition layout_stride.hh:19
│ │ │ │ +
constexpr const extents_type & extents() const noexcept
Definition layout_stride.hh:85
│ │ │ │ +
constexpr const strides_type & strides() const noexcept
Get the array of all strides.
Definition layout_stride.hh:127
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,65 +1,229 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -path.hh │ │ │ │ │ + * std │ │ │ │ │ +layout_left.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_COMMON_PATH_HH │ │ │ │ │ -6#define DUNE_COMMON_PATH_HH │ │ │ │ │ +5#ifndef DUNE_COMMON_STD_LAYOUT_LEFT_HH │ │ │ │ │ +6#define DUNE_COMMON_STD_LAYOUT_LEFT_HH │ │ │ │ │ 7 │ │ │ │ │ -8#include │ │ │ │ │ -9 │ │ │ │ │ -10namespace Dune { │ │ │ │ │ -23 │ │ │ │ │ -51 std::string concatPaths(const std::string& base, const std::string& p); │ │ │ │ │ -52 │ │ │ │ │ -54 │ │ │ │ │ -98 std::string processPath(const std::string& p); │ │ │ │ │ -99 │ │ │ │ │ -101 │ │ │ │ │ -109 bool pathIndicatesDirectory(const std::string& p); │ │ │ │ │ -110 │ │ │ │ │ -112 │ │ │ │ │ -151 std::string prettyPath(const std::string& p, bool isDirectory); │ │ │ │ │ -152 │ │ │ │ │ -154 │ │ │ │ │ -160 std::string prettyPath(const std::string& p); │ │ │ │ │ -161 │ │ │ │ │ -163 │ │ │ │ │ -179 std::string relativePath(const std::string& newbase, const std::string& p); │ │ │ │ │ -180 │ │ │ │ │ -182} │ │ │ │ │ -183 │ │ │ │ │ -184#endif // DUNE_COMMON_PATH_HH │ │ │ │ │ -Dune::processPath │ │ │ │ │ -std::string processPath(const std::string &p) │ │ │ │ │ -sanitize a path for further processing │ │ │ │ │ -Definition path.cc:37 │ │ │ │ │ -Dune::pathIndicatesDirectory │ │ │ │ │ -bool pathIndicatesDirectory(const std::string &p) │ │ │ │ │ -check whether the given path indicates that it is a directory │ │ │ │ │ -Definition path.cc:111 │ │ │ │ │ -Dune::prettyPath │ │ │ │ │ -std::string prettyPath(const std::string &p, bool isDirectory) │ │ │ │ │ -pretty print path │ │ │ │ │ -Definition path.cc:122 │ │ │ │ │ -Dune::relativePath │ │ │ │ │ -std::string relativePath(const std::string &newbase, const std::string &p) │ │ │ │ │ -compute a relative path between two paths │ │ │ │ │ -Definition path.cc:149 │ │ │ │ │ -Dune::concatPaths │ │ │ │ │ -std::string concatPaths(const std::string &base, const std::string &p) │ │ │ │ │ -concatenate two paths │ │ │ │ │ -Definition path.cc:28 │ │ │ │ │ -Dune │ │ │ │ │ -Dune namespace. │ │ │ │ │ -Definition alignedallocator.hh:13 │ │ │ │ │ +8#include │ │ │ │ │ +9#include │ │ │ │ │ +10 │ │ │ │ │ +11#include │ │ │ │ │ +12#include │ │ │ │ │ +13 │ │ │ │ │ +14namespace Dune::Std { │ │ │ │ │ +15 │ │ │ │ │ +17template │ │ │ │ │ +18class layout_left::mapping │ │ │ │ │ +19{ │ │ │ │ │ +20 template friend class mapping; │ │ │ │ │ +21 │ │ │ │ │ +22public: │ │ │ │ │ +23 using extents_type = Extents; │ │ │ │ │ +24 using size_type = typename extents_type::size_type; │ │ │ │ │ +25 using rank_type = typename extents_type::rank_type; │ │ │ │ │ +26 using index_type = typename extents_type::index_type; │ │ │ │ │ +27 using layout_type = layout_left; │ │ │ │ │ +28 │ │ │ │ │ +30 constexpr mapping () noexcept = default; │ │ │ │ │ +31 │ │ │ │ │ +33 constexpr mapping (const mapping&) noexcept = default; │ │ │ │ │ +34 │ │ │ │ │ +36 constexpr mapping (const extents_type& e) noexcept │ │ │ │ │ +37 : extents_(e) │ │ │ │ │ +38 {} │ │ │ │ │ +39 │ │ │ │ │ +41 template , int> = │ │ │ │ │ +0> │ │ │ │ │ +43 #if __cpp_conditional_explicit >= 201806L │ │ │ │ │ +44 explicit(!std::is_convertible_v) │ │ │ │ │ +45 #endif │ │ │ │ │ +46 constexpr mapping (const mapping& m) noexcept │ │ │ │ │ +47 : extents_(m.extents()) │ │ │ │ │ +48 {} │ │ │ │ │ +49 │ │ │ │ │ +51 template = 0, │ │ │ │ │ +53 std::enable_if_t, int> = │ │ │ │ │ +0> │ │ │ │ │ +54 #if __cpp_conditional_explicit >= 201806L │ │ │ │ │ +55 explicit(!std::is_convertible_v) │ │ │ │ │ +56 #endif │ │ │ │ │ +57 constexpr mapping (const layout_right::mapping& m) noexcept │ │ │ │ │ +58 : extents_(m.extents()) │ │ │ │ │ +59 {} │ │ │ │ │ +60 │ │ │ │ │ +62 template , int> = │ │ │ │ │ +0> │ │ │ │ │ +64 #if __cpp_conditional_explicit >= 201806L │ │ │ │ │ +65 explicit(extents_type::rank() > 0) │ │ │ │ │ +66 #endif │ │ │ │ │ +67 constexpr mapping (const layout_stride::mapping& m) │ │ │ │ │ +68 : extents_(m.extents()) │ │ │ │ │ +69 { │ │ │ │ │ +70#ifndef NDEBUG │ │ │ │ │ +71 if constexpr(extents_type::rank() > 0) { │ │ │ │ │ +72 index_type prod = 1; │ │ │ │ │ +73 for (rank_type r = 0; r < extents_type::rank()-1; ++r) { │ │ │ │ │ +74 assert(m.strides(r) == prod); │ │ │ │ │ +75 prod *= m.extents().extent(r); │ │ │ │ │ +76 } │ │ │ │ │ +77 assert(m.strides(extents_type::rank()-1) == prod); │ │ │ │ │ +78 } │ │ │ │ │ +79#endif │ │ │ │ │ +80 } │ │ │ │ │ +81 │ │ │ │ │ +83 constexpr mapping& operator=_(const mapping&) noexcept = default; │ │ │ │ │ +84 │ │ │ │ │ +85 constexpr const extents_type& extents () const noexcept { return extents_; } │ │ │ │ │ +86 constexpr index_type required_span_size () const noexcept { return │ │ │ │ │ +extents_.product(); } │ │ │ │ │ +87 │ │ │ │ │ +89 template = 0, │ │ │ │ │ +91 std::enable_if_t<(... && std::is_convertible_v), int> = │ │ │ │ │ +0, │ │ │ │ │ +92 std::enable_if_t<(... && std::is_nothrow_constructible_v), int> = 0> │ │ │ │ │ +93 constexpr index_type operator() (Indices... ii) const noexcept │ │ │ │ │ +94 { │ │ │ │ │ +95 const std::array indices{index_type(std::move(ii))...}; │ │ │ │ │ +96 index_type value = indices.back(); │ │ │ │ │ +97 for (rank_type r = 1; r < extents_type::rank(); ++r) { │ │ │ │ │ +98 const rank_type j = extents_type::rank()-r; │ │ │ │ │ +99 value = indices[j-1] + extents_.extent(j-1) * value; │ │ │ │ │ +100 } │ │ │ │ │ +101 return value; │ │ │ │ │ +102 } │ │ │ │ │ +103 │ │ │ │ │ +105 constexpr index_type operator()_() const noexcept │ │ │ │ │ +106 { │ │ │ │ │ +107 return 0; │ │ │ │ │ +108 } │ │ │ │ │ +109 │ │ │ │ │ +110 static constexpr bool is_always_unique () noexcept { return true; } │ │ │ │ │ +111 static constexpr bool is_always_exhaustive () noexcept { return true; } │ │ │ │ │ +112 static constexpr bool is_always_strided () noexcept { return true; } │ │ │ │ │ +113 │ │ │ │ │ +114 static constexpr bool is_unique () noexcept { return true; } │ │ │ │ │ +115 static constexpr bool is_exhaustive () noexcept { return true; } │ │ │ │ │ +116 static constexpr bool is_strided () noexcept { return true; } │ │ │ │ │ +117 │ │ │ │ │ +119 template 0), int> = 0> │ │ │ │ │ +121 constexpr index_type stride (rank_type i) const noexcept │ │ │ │ │ +122 { │ │ │ │ │ +123 assert(i < extents_type::rank()); │ │ │ │ │ +124 index_type prod = 1; │ │ │ │ │ +125 for (rank_type r = 0; r < i; ++r) │ │ │ │ │ +126 prod *= extents().extent(r); │ │ │ │ │ +127 return prod; │ │ │ │ │ +128 } │ │ │ │ │ +129 │ │ │ │ │ +130 template = 0> │ │ │ │ │ +132 friend constexpr bool operator== (const mapping& a, const │ │ │ │ │ +mapping& b) noexcept │ │ │ │ │ +133 { │ │ │ │ │ +134 return a.extents_ == b.extents_; │ │ │ │ │ +135 } │ │ │ │ │ +136 │ │ │ │ │ +137private: │ │ │ │ │ +138 [[no_unique_address]] extents_type extents_; │ │ │ │ │ +139}; │ │ │ │ │ +140 │ │ │ │ │ +141} // end namespace Dune::Std │ │ │ │ │ +142 │ │ │ │ │ +143#endif // DUNE_COMMON_STD_LAYOUT_LEFT_HH │ │ │ │ │ +indices.hh │ │ │ │ │ +fwd_layouts.hh │ │ │ │ │ +Dune::Std │ │ │ │ │ +Namespace for features backported from new C++ standards. │ │ │ │ │ +Definition default_accessor.hh:10 │ │ │ │ │ +Dune::Std::layout_left │ │ │ │ │ +A layout where the leftmost extent has stride 1. │ │ │ │ │ +Definition fwd_layouts.hh:17 │ │ │ │ │ +Dune::Std::layout_left::mapping │ │ │ │ │ +A layout mapping where the leftmost extent has stride 1. │ │ │ │ │ +Definition layout_left.hh:19 │ │ │ │ │ +Dune::Std::layout_left::mapping::stride │ │ │ │ │ +constexpr index_type stride(rank_type i) const noexcept │ │ │ │ │ +The stride is the product of the extents E(0)*E(1)*...*E(i-1) │ │ │ │ │ +Definition layout_left.hh:121 │ │ │ │ │ +Dune::Std::layout_left::mapping::index_type │ │ │ │ │ +typename extents_type::index_type index_type │ │ │ │ │ +Definition layout_left.hh:26 │ │ │ │ │ +Dune::Std::layout_left::mapping::required_span_size │ │ │ │ │ +constexpr index_type required_span_size() const noexcept │ │ │ │ │ +Definition layout_left.hh:86 │ │ │ │ │ +Dune::Std::layout_left::mapping::operator= │ │ │ │ │ +constexpr mapping & operator=(const mapping &) noexcept=default │ │ │ │ │ +Copy-assignment for the mapping. │ │ │ │ │ +Dune::Std::layout_left::mapping::extents_type │ │ │ │ │ +Extents extents_type │ │ │ │ │ +Definition layout_left.hh:23 │ │ │ │ │ +Dune::Std::layout_left::mapping::is_always_unique │ │ │ │ │ +static constexpr bool is_always_unique() noexcept │ │ │ │ │ +Definition layout_left.hh:110 │ │ │ │ │ +Dune::Std::layout_left::mapping::mapping │ │ │ │ │ +constexpr mapping() noexcept=default │ │ │ │ │ +The default construction is possible for default constructible extents. │ │ │ │ │ +Dune::Std::layout_left::mapping::is_strided │ │ │ │ │ +static constexpr bool is_strided() noexcept │ │ │ │ │ +Definition layout_left.hh:116 │ │ │ │ │ +Dune::Std::layout_left::mapping::is_always_strided │ │ │ │ │ +static constexpr bool is_always_strided() noexcept │ │ │ │ │ +Definition layout_left.hh:112 │ │ │ │ │ +Dune::Std::layout_left::mapping::operator() │ │ │ │ │ +constexpr index_type operator()() const noexcept │ │ │ │ │ +The default offset for rank-0 tensors is 0. │ │ │ │ │ +Definition layout_left.hh:105 │ │ │ │ │ +Dune::Std::layout_left::mapping::size_type │ │ │ │ │ +typename extents_type::size_type size_type │ │ │ │ │ +Definition layout_left.hh:24 │ │ │ │ │ +Dune::Std::layout_left::mapping::is_unique │ │ │ │ │ +static constexpr bool is_unique() noexcept │ │ │ │ │ +Definition layout_left.hh:114 │ │ │ │ │ +Dune::Std::layout_left::mapping::mapping │ │ │ │ │ +constexpr mapping(const layout_right::mapping< OtherExtents > &m) noexcept │ │ │ │ │ +Construct the mapping from a layout_right. │ │ │ │ │ +Definition layout_left.hh:57 │ │ │ │ │ +Dune::Std::layout_left::mapping::extents │ │ │ │ │ +constexpr const extents_type & extents() const noexcept │ │ │ │ │ +Definition layout_left.hh:85 │ │ │ │ │ +Dune::Std::layout_left::mapping::is_always_exhaustive │ │ │ │ │ +static constexpr bool is_always_exhaustive() noexcept │ │ │ │ │ +Definition layout_left.hh:111 │ │ │ │ │ +Dune::Std::layout_left::mapping::rank_type │ │ │ │ │ +typename extents_type::rank_type rank_type │ │ │ │ │ +Definition layout_left.hh:25 │ │ │ │ │ +Dune::Std::layout_left::mapping::is_exhaustive │ │ │ │ │ +static constexpr bool is_exhaustive() noexcept │ │ │ │ │ +Definition layout_left.hh:115 │ │ │ │ │ +Dune::Std::layout_right::mapping │ │ │ │ │ +A layout mapping where the rightmost extent has stride 1. │ │ │ │ │ +Definition layout_right.hh:19 │ │ │ │ │ +Dune::Std::layout_stride::mapping │ │ │ │ │ +A layout mapping where the strides are user-defined. │ │ │ │ │ +Definition layout_stride.hh:19 │ │ │ │ │ +Dune::Std::layout_stride::mapping::extents │ │ │ │ │ +constexpr const extents_type & extents() const noexcept │ │ │ │ │ +Definition layout_stride.hh:85 │ │ │ │ │ +Dune::Std::layout_stride::mapping::strides │ │ │ │ │ +constexpr const strides_type & strides() const noexcept │ │ │ │ │ +Get the array of all strides. │ │ │ │ │ +Definition layout_stride.hh:127 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00068.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: stdthread.hh File Reference │ │ │ │ +dune-common: functional.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,69 +65,44 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Namespaces | │ │ │ │ -Macros | │ │ │ │ -Functions
│ │ │ │ -
stdthread.hh File Reference
│ │ │ │ +Classes | │ │ │ │ +Namespaces
│ │ │ │ +
functional.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ - │ │ │ │ +
#include <functional>
│ │ │ │ +#include <dune-common-config.hh>
│ │ │ │ +
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Classes

struct  Dune::Std::identity
 A function object type whose operator() returns its argument unchanged. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Macros

#define DUNE_ASSERT_CALL_ONCE()    ::Dune::assertCallOnce(__FILE__, __LINE__, __func__)
 Make sure call_once() works and provide a helpful error message otherwise.
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ -Functions

void Dune::doAssertCallOnce (const char *file, int line, const char *function)
 
void Dune::assertCallOnce (const char *file=nullptr, int line=-1, const char *function=nullptr)
 Make sure call_once() works and provide a helpful error message otherwise.
 
namespace  Dune::Std
 Namespace for features backported from new C++ standards.
 
│ │ │ │ -

Macro Definition Documentation

│ │ │ │ - │ │ │ │ -

◆ DUNE_ASSERT_CALL_ONCE

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_ASSERT_CALL_ONCE()    ::Dune::assertCallOnce(__FILE__, __LINE__, __func__)
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

Make sure call_once() works and provide a helpful error message otherwise.

│ │ │ │ -

This calls assertCallOnce() and automatically provides information about the caller in the error message.

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,36 +1,26 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Namespaces | Macros | Functions │ │ │ │ │ -stdthread.hh File Reference │ │ │ │ │ + * std │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +functional.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ +Classes │ │ │ │ │ +struct   Dune::Std::identity │ │ │ │ │ +  A function object type whose operator() returns its argument │ │ │ │ │ + unchanged. More... │ │ │ │ │ +  │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -Macros │ │ │ │ │ -#define  DUNE_ASSERT_CALL_ONCE()    ::Dune::assertCallOnce(__FILE__, __LINE__, │ │ │ │ │ - __func__) │ │ │ │ │ -  Make sure call_once() works and provide a helpful error message │ │ │ │ │ - otherwise. │ │ │ │ │ -  │ │ │ │ │ -Functions │ │ │ │ │ -void  Dune::doAssertCallOnce (const char *file, int line, const char *function) │ │ │ │ │ -  │ │ │ │ │ -void  Dune::assertCallOnce (const char *file=nullptr, int line=-1, const char │ │ │ │ │ - *function=nullptr) │ │ │ │ │ -  Make sure call_once() works and provide a helpful error message │ │ │ │ │ - otherwise. │ │ │ │ │ +namespace   Dune::Std │ │ │ │ │ +  Namespace for features backported from new C++ standards. │ │ │ │ │   │ │ │ │ │ -***** Macro Definition Documentation ***** │ │ │ │ │ -***** ◆ DUNE_ASSERT_CALL_ONCE ***** │ │ │ │ │ -#define DUNE_ASSERT_CALL_ONCE ( )     ::Dune::assertCallOnce(__FILE__, __LINE_ │ │ │ │ │ - _, __func__) │ │ │ │ │ -Make sure call_once() works and provide a helpful error message otherwise. │ │ │ │ │ -This calls assertCallOnce() and automatically provides information about the │ │ │ │ │ -caller in the error message. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00068_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: stdthread.hh Source File │ │ │ │ +dune-common: functional.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,58 +70,56 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
stdthread.hh
│ │ │ │ +
functional.hh
│ │ │ │
│ │ │ │
│ │ │ │ -Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │ -
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │ +Go to the documentation of this file.
1// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │ +
2// vi: set ts=8 sw=2 et sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5
│ │ │ │ -
6#ifndef DUNE_COMMON_STDTHREAD_HH
│ │ │ │ -
7#define DUNE_COMMON_STDTHREAD_HH
│ │ │ │ -
8
│ │ │ │ -
9namespace Dune
│ │ │ │ -
10{
│ │ │ │ +
5#ifndef DUNE_COMMON_STD_FUNCTIONAL_HH
│ │ │ │ +
6#define DUNE_COMMON_STD_FUNCTIONAL_HH
│ │ │ │ +
7
│ │ │ │ +
8#include <functional>
│ │ │ │ +
9
│ │ │ │ +
10#include <dune-common-config.hh> // DUNE_HAVE_CXX_STD_IDENTITY
│ │ │ │
11
│ │ │ │ -
12 // used internally by assertCallOnce for the actual check
│ │ │ │ -
13 void doAssertCallOnce(const char *file, int line, const char *function);
│ │ │ │ +
12namespace Dune
│ │ │ │ +
13{
│ │ │ │
14
│ │ │ │ +
15 namespace Std
│ │ │ │ +
16 {
│ │ │ │
17
│ │ │ │ -
│ │ │ │ -
35 inline void assertCallOnce(const char *file = nullptr, int line = -1,
│ │ │ │ -
36 const char *function = nullptr)
│ │ │ │ -
37 {
│ │ │ │ -
38 // make sure to call this only the first time this function is invoked
│ │ │ │ -
39 [[maybe_unused]] static const bool works
│ │ │ │ -
40 = (doAssertCallOnce(file, line, function), true);
│ │ │ │ -
41 }
│ │ │ │ -
│ │ │ │ -
42
│ │ │ │ -
45
│ │ │ │ -
│ │ │ │ -
49#define DUNE_ASSERT_CALL_ONCE() \
│ │ │ │ -
50 ::Dune::assertCallOnce(__FILE__, __LINE__, __func__)
│ │ │ │ -
│ │ │ │ -
51
│ │ │ │ -
52} // namespace Dune
│ │ │ │ -
53
│ │ │ │ -
54#endif // DUNE_COMMON_STDTHREAD_HH
│ │ │ │ +
24#if DUNE_HAVE_CXX_STD_IDENTITY
│ │ │ │ +
25 using std::identity;
│ │ │ │ +
26#else //DUNE_HAVE_CXX_STD_IDENTITY
│ │ │ │ +
│ │ │ │ +
27 struct identity {
│ │ │ │ +
28 template<class T>
│ │ │ │ +
29 constexpr T&& operator()(T&& t ) const noexcept {return std::forward<T>(t);}
│ │ │ │ +
30 };
│ │ │ │ +
│ │ │ │ +
31#endif
│ │ │ │ +
32 } // namespace Std
│ │ │ │ +
33
│ │ │ │ +
34} // namespace Dune
│ │ │ │ +
35
│ │ │ │ +
36#endif // #ifndef DUNE_COMMON_STD_FUNCTIONAL_HH
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
void assertCallOnce(const char *file=nullptr, int line=-1, const char *function=nullptr)
Make sure call_once() works and provide a helpful error message otherwise.
Definition stdthread.hh:35
│ │ │ │ -
void doAssertCallOnce(const char *file, int line, const char *function)
Definition stdthread.cc:38
│ │ │ │ +
A function object type whose operator() returns its argument unchanged.
Definition functional.hh:27
│ │ │ │ +
constexpr T && operator()(T &&t) const noexcept
Definition functional.hh:29
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,52 +1,51 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -stdthread.hh │ │ │ │ │ + * std │ │ │ │ │ +functional.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ -1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ -2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ +1// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ +2// vi: set ts=8 sw=2 et sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5 │ │ │ │ │ -6#ifndef DUNE_COMMON_STDTHREAD_HH │ │ │ │ │ -7#define DUNE_COMMON_STDTHREAD_HH │ │ │ │ │ -8 │ │ │ │ │ -9namespace Dune │ │ │ │ │ -10{ │ │ │ │ │ +5#ifndef DUNE_COMMON_STD_FUNCTIONAL_HH │ │ │ │ │ +6#define DUNE_COMMON_STD_FUNCTIONAL_HH │ │ │ │ │ +7 │ │ │ │ │ +8#include │ │ │ │ │ +9 │ │ │ │ │ +10#include // DUNE_HAVE_CXX_STD_IDENTITY │ │ │ │ │ 11 │ │ │ │ │ -12 // used internally by assertCallOnce for the actual check │ │ │ │ │ -13 void doAssertCallOnce(const char *file, int line, const char *function); │ │ │ │ │ +12namespace Dune │ │ │ │ │ +13{ │ │ │ │ │ 14 │ │ │ │ │ +15 namespace Std │ │ │ │ │ +16 { │ │ │ │ │ 17 │ │ │ │ │ -35 inline void assertCallOnce(const char *file = nullptr, int line = -1, │ │ │ │ │ -36 const char *function = nullptr) │ │ │ │ │ -37 { │ │ │ │ │ -38 // make sure to call this only the first time this function is invoked │ │ │ │ │ -39 [[maybe_unused]] static const bool works │ │ │ │ │ -40 = (doAssertCallOnce(file, line, function), true); │ │ │ │ │ -41 } │ │ │ │ │ -42 │ │ │ │ │ -45 │ │ │ │ │ -49#define DUNE_ASSERT_CALL_ONCE() \ │ │ │ │ │ -50 ::Dune::assertCallOnce(__FILE__, __LINE__, __func__) │ │ │ │ │ -51 │ │ │ │ │ -52} // namespace Dune │ │ │ │ │ -53 │ │ │ │ │ -54#endif // DUNE_COMMON_STDTHREAD_HH │ │ │ │ │ +24#if DUNE_HAVE_CXX_STD_IDENTITY │ │ │ │ │ +25 using std::identity; │ │ │ │ │ +26#else //DUNE_HAVE_CXX_STD_IDENTITY │ │ │ │ │ +27 struct identity { │ │ │ │ │ +28 template │ │ │ │ │ +29 constexpr T&& operator()(T&& t ) const noexcept {return std::forward(t);} │ │ │ │ │ +30 }; │ │ │ │ │ +31#endif │ │ │ │ │ +32 } // namespace Std │ │ │ │ │ +33 │ │ │ │ │ +34} // namespace Dune │ │ │ │ │ +35 │ │ │ │ │ +36#endif // #ifndef DUNE_COMMON_STD_FUNCTIONAL_HH │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::assertCallOnce │ │ │ │ │ -void assertCallOnce(const char *file=nullptr, int line=-1, const char │ │ │ │ │ -*function=nullptr) │ │ │ │ │ -Make sure call_once() works and provide a helpful error message otherwise. │ │ │ │ │ -Definition stdthread.hh:35 │ │ │ │ │ -Dune::doAssertCallOnce │ │ │ │ │ -void doAssertCallOnce(const char *file, int line, const char *function) │ │ │ │ │ -Definition stdthread.cc:38 │ │ │ │ │ +Dune::Std::identity │ │ │ │ │ +A function object type whose operator() returns its argument unchanged. │ │ │ │ │ +Definition functional.hh:27 │ │ │ │ │ +Dune::Std::identity::operator() │ │ │ │ │ +constexpr T && operator()(T &&t) const noexcept │ │ │ │ │ +Definition functional.hh:29 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00071.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: fmatrixev.hh File Reference │ │ │ │ +dune-common: layout_right.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,72 +65,46 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Namespaces | │ │ │ │ -Functions
│ │ │ │ -
fmatrixev.hh File Reference
│ │ │ │ +Classes | │ │ │ │ +Namespaces
│ │ │ │ +
layout_right.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ - │ │ │ │ -

Eigenvalue computations for the FieldMatrix class. │ │ │ │ -More...

│ │ │ │ -
#include <algorithm>
│ │ │ │ -#include <iostream>
│ │ │ │ -#include <cmath>
│ │ │ │ -#include <cassert>
│ │ │ │ -#include <dune-common-config.hh>
│ │ │ │ -#include <dune/common/exceptions.hh>
│ │ │ │ -#include <dune/common/fvector.hh>
│ │ │ │ -#include <dune/common/fmatrix.hh>
│ │ │ │ -#include <dune/common/math.hh>
│ │ │ │ +
#include <array>
│ │ │ │ +#include <type_traits>
│ │ │ │ +#include <dune/common/indices.hh>
│ │ │ │ +#include <dune/common/std/impl/fwd_layouts.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Classes

class  Dune::Std::layout_right::mapping< Extents >
 A layout mapping where the rightmost extent has stride 1. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ -

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::FMatrixHelp
namespace  Dune::Std
 Namespace for features backported from new C++ standards.
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │

│ │ │ │ -Functions

template<int dim, typename K >
static void Dune::FMatrixHelp::eigenValues (const FieldMatrix< K, dim, dim > &matrix, FieldVector< K, dim > &eigenValues)
 calculates the eigenvalues of a symmetric field matrix
 
template<int dim, typename K >
static void Dune::FMatrixHelp::eigenValuesVectors (const FieldMatrix< K, dim, dim > &matrix, FieldVector< K, dim > &eigenValues, FieldMatrix< K, dim, dim > &eigenVectors)
 calculates the eigenvalues and eigenvectors of a symmetric field matrix
 
template<int dim, typename K >
static void Dune::FMatrixHelp::eigenValuesLapack (const FieldMatrix< K, dim, dim > &matrix, FieldVector< K, dim > &eigenValues)
 calculates the eigenvalues of a symmetric field matrix
 
template<int dim, typename K >
static void Dune::FMatrixHelp::eigenValuesVectorsLapack (const FieldMatrix< K, dim, dim > &matrix, FieldVector< K, dim > &eigenValues, FieldMatrix< K, dim, dim > &eigenVectors)
 calculates the eigenvalues and -vectors of a symmetric field matrix
 
template<int dim, typename K , class C >
static void Dune::FMatrixHelp::eigenValuesNonSym (const FieldMatrix< K, dim, dim > &matrix, FieldVector< C, dim > &eigenValues)
 calculates the eigenvalues of a non-symmetric field matrix
 
│ │ │ │ -

Detailed Description

│ │ │ │ -

Eigenvalue computations for the FieldMatrix class.

│ │ │ │ -
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,59 +1,27 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Namespaces | Functions │ │ │ │ │ -fmatrixev.hh File Reference │ │ │ │ │ -Eigenvalue computations for the FieldMatrix class. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ + * std │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +layout_right.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ +Classes │ │ │ │ │ +class   Dune::Std::layout_right::mapping<_Extents_> │ │ │ │ │ +  A layout mapping where the rightmost extent has stride 1. More... │ │ │ │ │ +  │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -namespace   Dune::FMatrixHelp │ │ │ │ │ -  │ │ │ │ │ -Functions │ │ │ │ │ -template │ │ │ │ │ -static void  Dune::FMatrixHelp::eigenValues (const FieldMatrix< K, dim, dim > │ │ │ │ │ - &matrix, FieldVector< K, dim > &eigenValues) │ │ │ │ │ -  calculates the eigenvalues of a symmetric field matrix │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -static void  Dune::FMatrixHelp::eigenValuesVectors (const FieldMatrix< K, dim, │ │ │ │ │ - dim > &matrix, FieldVector< K, dim > &eigenValues, FieldMatrix< K, │ │ │ │ │ - dim, dim > &eigenVectors) │ │ │ │ │ -  calculates the eigenvalues and eigenvectors of a symmetric field │ │ │ │ │ - matrix │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -static void  Dune::FMatrixHelp::eigenValuesLapack (const FieldMatrix< K, dim, │ │ │ │ │ - dim > &matrix, FieldVector< K, dim > &eigenValues) │ │ │ │ │ -  calculates the eigenvalues of a symmetric field matrix │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -static void  Dune::FMatrixHelp::eigenValuesVectorsLapack (const FieldMatrix< K, │ │ │ │ │ - dim, dim > &matrix, FieldVector< K, dim > &eigenValues, │ │ │ │ │ - FieldMatrix< K, dim, dim > &eigenVectors) │ │ │ │ │ -  calculates the eigenvalues and -vectors of a symmetric field │ │ │ │ │ - matrix │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -static void  Dune::FMatrixHelp::eigenValuesNonSym (const FieldMatrix< K, dim, │ │ │ │ │ - dim > &matrix, FieldVector< C, dim > &eigenValues) │ │ │ │ │ -  calculates the eigenvalues of a non-symmetric field matrix │ │ │ │ │ +namespace   Dune::Std │ │ │ │ │ +  Namespace for features backported from new C++ standards. │ │ │ │ │   │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -Eigenvalue computations for the FieldMatrix class. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00071_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: fmatrixev.hh Source File │ │ │ │ +dune-common: layout_right.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,645 +70,196 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
fmatrixev.hh
│ │ │ │ +
layout_right.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_FMATRIXEIGENVALUES_HH
│ │ │ │ -
6#define DUNE_FMATRIXEIGENVALUES_HH
│ │ │ │ +
5#ifndef DUNE_COMMON_STD_LAYOUT_RIGHT_HH
│ │ │ │ +
6#define DUNE_COMMON_STD_LAYOUT_RIGHT_HH
│ │ │ │
7
│ │ │ │ -
12#include <algorithm>
│ │ │ │ -
13#include <iostream>
│ │ │ │ -
14#include <cmath>
│ │ │ │ -
15#include <cassert>
│ │ │ │ -
16
│ │ │ │ -
17#include <dune-common-config.hh> // HAVE_LAPACK
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
21#include <dune/common/math.hh>
│ │ │ │ -
22
│ │ │ │ -
23namespace Dune {
│ │ │ │ -
24
│ │ │ │ -
30 namespace FMatrixHelp {
│ │ │ │ +
8#include <array>
│ │ │ │ +
9#include <type_traits>
│ │ │ │ +
10
│ │ │ │ + │ │ │ │ + │ │ │ │ +
13
│ │ │ │ +
14namespace Dune::Std {
│ │ │ │ +
15
│ │ │ │ +
17template <class Extents>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
19{
│ │ │ │ +
20 template <class> friend class mapping;
│ │ │ │ +
21
│ │ │ │ +
22public:
│ │ │ │ +
23 using extents_type = Extents;
│ │ │ │ +
24 using size_type = typename extents_type::size_type;
│ │ │ │ +
25 using rank_type = typename extents_type::rank_type;
│ │ │ │ +
26 using index_type = typename extents_type::index_type;
│ │ │ │ + │ │ │ │ +
28
│ │ │ │ +
30 constexpr mapping () noexcept = default;
│ │ │ │
31
│ │ │ │ -
32#if HAVE_LAPACK
│ │ │ │ -
33 // defined in fmatrixev.cc
│ │ │ │ -
34 extern void eigenValuesLapackCall(
│ │ │ │ -
35 const char* jobz, const char* uplo, const long
│ │ │ │ -
36 int* n, double* a, const long int* lda, double* w,
│ │ │ │ -
37 double* work, const long int* lwork, long int* info);
│ │ │ │ -
38
│ │ │ │ -
39 extern void eigenValuesNonsymLapackCall(
│ │ │ │ -
40 const char* jobvl, const char* jobvr, const long
│ │ │ │ -
41 int* n, double* a, const long int* lda, double* wr, double* wi, double* vl,
│ │ │ │ -
42 const long int* ldvl, double* vr, const long int* ldvr, double* work,
│ │ │ │ -
43 const long int* lwork, long int* info);
│ │ │ │ -
44
│ │ │ │ -
45 extern void eigenValuesLapackCall(
│ │ │ │ -
46 const char* jobz, const char* uplo, const long
│ │ │ │ -
47 int* n, float* a, const long int* lda, float* w,
│ │ │ │ -
48 float* work, const long int* lwork, long int* info);
│ │ │ │ +
33 constexpr mapping (const mapping&) noexcept = default;
│ │ │ │ +
34
│ │ │ │ +
│ │ │ │ +
36 constexpr mapping (const extents_type& e) noexcept
│ │ │ │ +
37 : extents_(e)
│ │ │ │ +
38 {}
│ │ │ │ +
│ │ │ │ +
39
│ │ │ │ +
41 template <class OtherExtents,
│ │ │ │ +
42 std::enable_if_t<std::is_constructible_v<extents_type, OtherExtents>, int> = 0>
│ │ │ │ +
43 #if __cpp_conditional_explicit >= 201806L
│ │ │ │ +
44 explicit(!std::is_convertible_v<OtherExtents, extents_type>)
│ │ │ │ +
45 #endif
│ │ │ │ +
│ │ │ │ +
46 constexpr mapping (const mapping<OtherExtents>& m) noexcept
│ │ │ │ +
47 : extents_(m.extents())
│ │ │ │ +
48 {}
│ │ │ │ +
│ │ │ │
49
│ │ │ │ -
50 extern void eigenValuesNonsymLapackCall(
│ │ │ │ -
51 const char* jobvl, const char* jobvr, const long
│ │ │ │ -
52 int* n, float* a, const long int* lda, float* wr, float* wi, float* vl,
│ │ │ │ -
53 const long int* ldvl, float* vr, const long int* ldvr, float* work,
│ │ │ │ -
54 const long int* lwork, long int* info);
│ │ │ │ -
55
│ │ │ │ -
56#endif
│ │ │ │ -
57
│ │ │ │ -
58 namespace Impl {
│ │ │ │ -
59 //internal tag to activate/disable code for eigenvector calculation at compile time
│ │ │ │ -
60 enum Jobs { OnlyEigenvalues=0, EigenvaluesEigenvectors=1 };
│ │ │ │ -
61
│ │ │ │ -
62 //internal dummy used if only eigenvalues are to be calculated
│ │ │ │ -
63 template<typename K, int dim>
│ │ │ │ -
64 using EVDummy = FieldMatrix<K, dim, dim>;
│ │ │ │ -
65
│ │ │ │ -
66 //compute the cross-product of two vectors
│ │ │ │ -
67 template<typename K>
│ │ │ │ -
68 inline FieldVector<K,3> crossProduct(const FieldVector<K,3>& vec0, const FieldVector<K,3>& vec1) {
│ │ │ │ -
69 return {vec0[1]*vec1[2] - vec0[2]*vec1[1], vec0[2]*vec1[0] - vec0[0]*vec1[2], vec0[0]*vec1[1] - vec0[1]*vec1[0]};
│ │ │ │ -
70 }
│ │ │ │ -
71
│ │ │ │ -
72 template <typename K>
│ │ │ │ -
73 static void eigenValues2dImpl(const FieldMatrix<K, 2, 2>& matrix,
│ │ │ │ -
74 FieldVector<K, 2>& eigenvalues)
│ │ │ │ -
75 {
│ │ │ │ -
76 using std::sqrt;
│ │ │ │ -
77 const K p = 0.5 * (matrix[0][0] + matrix [1][1]);
│ │ │ │ -
78 const K p2 = p - matrix[1][1];
│ │ │ │ -
79 K q = p2 * p2 + matrix[1][0] * matrix[0][1];
│ │ │ │ -
80 if( q < 0 && q > -1e-14 ) q = 0;
│ │ │ │ -
81 if (q < 0)
│ │ │ │ -
82 {
│ │ │ │ -
83 std::cout << matrix << std::endl;
│ │ │ │ -
84 // Complex eigenvalues are either caused by non-symmetric matrices or by round-off errors
│ │ │ │ -
85 DUNE_THROW(MathError, "Complex eigenvalue detected (which this implementation cannot handle).");
│ │ │ │ -
86 }
│ │ │ │ +
51 template <class OtherExtents, class E = extents_type,
│ │ │ │ +
52 std::enable_if_t<(E::rank() <= 1), int> = 0,
│ │ │ │ +
53 std::enable_if_t<std::is_constructible_v<extents_type, OtherExtents>, int> = 0>
│ │ │ │ +
54 #if __cpp_conditional_explicit >= 201806L
│ │ │ │ +
55 explicit(!std::is_convertible_v<OtherExtents, extents_type>)
│ │ │ │ +
56 #endif
│ │ │ │ +
│ │ │ │ +
57 constexpr mapping (const layout_left::mapping<OtherExtents>& m) noexcept
│ │ │ │ +
58 : extents_(m.extents())
│ │ │ │ +
59 {}
│ │ │ │ +
│ │ │ │ +
60
│ │ │ │ +
62 template <class OtherExtents,
│ │ │ │ +
63 std::enable_if_t<std::is_constructible_v<extents_type, OtherExtents>, int> = 0>
│ │ │ │ +
64 #if __cpp_conditional_explicit >= 201806L
│ │ │ │ +
65 explicit(extents_type::rank() > 0)
│ │ │ │ +
66 #endif
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
68 : extents_(m.extents())
│ │ │ │ +
69 {
│ │ │ │ +
70#ifndef NDEBUG
│ │ │ │ +
71 if constexpr(extents_type::rank() > 0) {
│ │ │ │ +
72 index_type prod = 1;
│ │ │ │ +
73 for (rank_type r = extents_type::rank()-1; r > 0; --r) {
│ │ │ │ +
74 assert(m.strides(r) == prod);
│ │ │ │ +
75 prod *= m.extents().extent(r);
│ │ │ │ +
76 }
│ │ │ │ +
77 assert(m.strides(0) == prod);
│ │ │ │ +
78 }
│ │ │ │ +
79#endif
│ │ │ │ +
80 }
│ │ │ │ +
│ │ │ │ +
81
│ │ │ │ +
83 constexpr mapping& operator= (const mapping&) noexcept = default;
│ │ │ │ +
84
│ │ │ │ +
85 constexpr const extents_type& extents () const noexcept { return extents_; }
│ │ │ │ +
86 constexpr index_type required_span_size () const noexcept { return extents_.product(); }
│ │ │ │
87
│ │ │ │ -
88 // get square root
│ │ │ │ -
89 q = sqrt(q);
│ │ │ │ -
90
│ │ │ │ -
91 // store eigenvalues in ascending order
│ │ │ │ -
92 eigenvalues[0] = p - q;
│ │ │ │ -
93 eigenvalues[1] = p + q;
│ │ │ │ -
94 }
│ │ │ │ -
95
│ │ │ │ -
96 /*
│ │ │ │ -
97 This implementation was adapted from the pseudo-code (Python?) implementation found on
│ │ │ │ -
98 http://en.wikipedia.org/wiki/Eigenvalue_algorithm (retrieved late August 2014).
│ │ │ │ -
99 Wikipedia claims to have taken it from
│ │ │ │ -
100 Smith, Oliver K. (April 1961), Eigenvalues of a symmetric 3 × 3 matrix.,
│ │ │ │ -
101 Communications of the ACM 4 (4): 168, doi:10.1145/355578.366316
│ │ │ │ -
102 */
│ │ │ │ -
103 template <typename K>
│ │ │ │ -
104 static K eigenValues3dImpl(const FieldMatrix<K, 3, 3>& matrix,
│ │ │ │ -
105 FieldVector<K, 3>& eigenvalues)
│ │ │ │ -
106 {
│ │ │ │ -
107 using std::sqrt;
│ │ │ │ -
108 using std::acos;
│ │ │ │ -
109 using real_type = typename FieldTraits<K>::real_type;
│ │ │ │ -
110 const K pi = MathematicalConstants<K>::pi();
│ │ │ │ -
111 K p1 = matrix[0][1]*matrix[0][1] + matrix[0][2]*matrix[0][2] + matrix[1][2]*matrix[1][2];
│ │ │ │ +
89 template <class... Indices,
│ │ │ │ +
90 std::enable_if_t<(sizeof...(Indices) == extents_type::rank()), int> = 0,
│ │ │ │ +
91 std::enable_if_t<(std::is_convertible_v<Indices, index_type> && ...), int> = 0,
│ │ │ │ +
92 std::enable_if_t<(std::is_nothrow_constructible_v<Indices, index_type> && ...), int> = 0>
│ │ │ │ +
│ │ │ │ +
93 constexpr index_type operator() (Indices... ii) const noexcept
│ │ │ │ +
94 {
│ │ │ │ +
95 const std::array indices{index_type(std::move(ii))...};
│ │ │ │ +
96 index_type value = indices.front();
│ │ │ │ +
97 for (rank_type j = 0; j < extents_type::rank()-1; ++j) {
│ │ │ │ +
98 value = indices[j+1] + extents_.extent(j+1) * value;
│ │ │ │ +
99 }
│ │ │ │ +
100 return value;
│ │ │ │ +
101 }
│ │ │ │ +
│ │ │ │ +
102
│ │ │ │ +
│ │ │ │ +
104 constexpr index_type operator() () const noexcept
│ │ │ │ +
105 {
│ │ │ │ +
106 return 0;
│ │ │ │ +
107 }
│ │ │ │ +
│ │ │ │ +
108
│ │ │ │ +
109 static constexpr bool is_always_unique () noexcept { return true; }
│ │ │ │ +
110 static constexpr bool is_always_exhaustive () noexcept { return true; }
│ │ │ │ +
111 static constexpr bool is_always_strided () noexcept { return true; }
│ │ │ │
112
│ │ │ │ -
113 if (p1 <= std::numeric_limits<K>::epsilon()) {
│ │ │ │ -
114 // A is diagonal.
│ │ │ │ -
115 eigenvalues[0] = matrix[0][0];
│ │ │ │ -
116 eigenvalues[1] = matrix[1][1];
│ │ │ │ -
117 eigenvalues[2] = matrix[2][2];
│ │ │ │ -
118 std::sort(eigenvalues.begin(), eigenvalues.end());
│ │ │ │ -
119
│ │ │ │ -
120 return 0.0;
│ │ │ │ -
121 }
│ │ │ │ -
122 else
│ │ │ │ -
123 {
│ │ │ │ -
124 // q = trace(A)/3
│ │ │ │ -
125 K q = 0;
│ │ │ │ -
126 for (int i=0; i<3; i++)
│ │ │ │ -
127 q += matrix[i][i] / 3.0;
│ │ │ │ +
113 static constexpr bool is_unique () noexcept { return true; }
│ │ │ │ +
114 static constexpr bool is_exhaustive () noexcept { return true; }
│ │ │ │ +
115 static constexpr bool is_strided () noexcept { return true; }
│ │ │ │ +
116
│ │ │ │ +
118 template <class E = extents_type,
│ │ │ │ +
119 std::enable_if_t<(E::rank() > 0), int> = 0>
│ │ │ │ +
│ │ │ │ +
120 constexpr index_type stride (rank_type i) const noexcept
│ │ │ │ +
121 {
│ │ │ │ +
122 assert(i < extents_type::rank());
│ │ │ │ +
123 index_type prod = 1;
│ │ │ │ +
124 for (rank_type r = i+1; r < extents_type::rank(); ++r)
│ │ │ │ +
125 prod *= extents().extent(r);
│ │ │ │ +
126 return prod;
│ │ │ │ +
127 }
│ │ │ │ +
│ │ │ │
128
│ │ │ │ -
129 K p2 = (matrix[0][0] - q)*(matrix[0][0] - q) + (matrix[1][1] - q)*(matrix[1][1] - q) + (matrix[2][2] - q)*(matrix[2][2] - q) + 2.0 * p1;
│ │ │ │ -
130 K p = sqrt(p2 / 6);
│ │ │ │ -
131 // B = (1 / p) * (A - q * I); // I is the identity matrix
│ │ │ │ -
132 FieldMatrix<K,3,3> B;
│ │ │ │ -
133 for (int i=0; i<3; i++)
│ │ │ │ -
134 for (int j=0; j<3; j++)
│ │ │ │ -
135 B[i][j] = (real_type(1.0)/p) * (matrix[i][j] - q*(i==j));
│ │ │ │ -
136
│ │ │ │ -
137 K r = B.determinant() / 2.0;
│ │ │ │ +
129 template <class OtherExtents>
│ │ │ │ +
│ │ │ │ +
130 friend constexpr bool operator== (const mapping& a, const mapping<OtherExtents>& b) noexcept
│ │ │ │ +
131 {
│ │ │ │ +
132 return a.extents_ == b.extents_;
│ │ │ │ +
133 }
│ │ │ │ +
│ │ │ │ +
134
│ │ │ │ +
135private:
│ │ │ │ +
136 [[no_unique_address]] extents_type extents_;
│ │ │ │ +
137};
│ │ │ │ +
│ │ │ │
138
│ │ │ │ -
139 /*In exact arithmetic for a symmetric matrix -1 <= r <= 1
│ │ │ │ -
140 but computation error can leave it slightly outside this range.
│ │ │ │ -
141 acos(z) function requires |z| <= 1, but will fail silently
│ │ │ │ -
142 and return NaN if the input is larger than 1 in magnitude.
│ │ │ │ -
143 Thus r is clamped to [-1,1].*/
│ │ │ │ -
144 using std::clamp;
│ │ │ │ -
145 r = clamp<K>(r, -1.0, 1.0);
│ │ │ │ -
146 K phi = acos(r) / 3.0;
│ │ │ │ -
147
│ │ │ │ -
148 // the eigenvalues satisfy eig[2] <= eig[1] <= eig[0]
│ │ │ │ -
149 eigenvalues[2] = q + 2 * p * cos(phi);
│ │ │ │ -
150 eigenvalues[0] = q + 2 * p * cos(phi + (2*pi/3));
│ │ │ │ -
151 eigenvalues[1] = 3 * q - eigenvalues[0] - eigenvalues[2]; // since trace(matrix) = eig1 + eig2 + eig3
│ │ │ │ -
152
│ │ │ │ -
153 return r;
│ │ │ │ -
154 }
│ │ │ │ -
155 }
│ │ │ │ -
156
│ │ │ │ -
157 //see https://www.geometrictools.com/Documentation/RobustEigenSymmetric3x3.pdf
│ │ │ │ -
158 //Robustly compute a right-handed orthonormal set {u, v, evec0}.
│ │ │ │ -
159 template<typename K>
│ │ │ │ -
160 void orthoComp(const FieldVector<K,3>& evec0, FieldVector<K,3>& u, FieldVector<K,3>& v) {
│ │ │ │ -
161 using std::abs;
│ │ │ │ -
162 if(abs(evec0[0]) > abs(evec0[1])) {
│ │ │ │ -
163 //The component of maximum absolute value is either evec0[0] or evec0[2].
│ │ │ │ -
164 FieldVector<K,2> temp = {evec0[0], evec0[2]};
│ │ │ │ -
165 auto L = 1.0 / temp.two_norm();
│ │ │ │ -
166 u = L * FieldVector<K,3>({-evec0[2], 0.0, evec0[0]});
│ │ │ │ -
167 }
│ │ │ │ -
168 else {
│ │ │ │ -
169 //The component of maximum absolute value is either evec0[1] or evec0[2].
│ │ │ │ -
170 FieldVector<K,2> temp = {evec0[1], evec0[2]};
│ │ │ │ -
171 auto L = 1.0 / temp.two_norm();
│ │ │ │ -
172 u = L * FieldVector<K,3>({0.0, evec0[2], -evec0[1]});
│ │ │ │ -
173 }
│ │ │ │ -
174 v = crossProduct(evec0, u);
│ │ │ │ -
175 }
│ │ │ │ -
176
│ │ │ │ -
177 //see https://www.geometrictools.com/Documentation/RobustEigenSymmetric3x3.pdf
│ │ │ │ -
178 template<typename K>
│ │ │ │ -
179 void eig0(const FieldMatrix<K,3,3>& matrix, K eval0, FieldVector<K,3>& evec0) {
│ │ │ │ -
180 /* Compute a unit-length eigenvector for eigenvalue[i0]. The
│ │ │ │ -
181 matrix is rank 2, so two of the rows are linearly independent.
│ │ │ │ -
182 For a robust computation of the eigenvector, select the two
│ │ │ │ -
183 rows whose cross product has largest length of all pairs of
│ │ │ │ -
184 rows. */
│ │ │ │ -
185 using Vector = FieldVector<K,3>;
│ │ │ │ -
186 Vector row0 = {matrix[0][0]-eval0, matrix[0][1], matrix[0][2]};
│ │ │ │ -
187 Vector row1 = {matrix[1][0], matrix[1][1]-eval0, matrix[1][2]};
│ │ │ │ -
188 Vector row2 = {matrix[2][0], matrix[2][1], matrix[2][2]-eval0};
│ │ │ │ -
189
│ │ │ │ -
190 Vector r0xr1 = crossProduct(row0, row1);
│ │ │ │ -
191 Vector r0xr2 = crossProduct(row0, row2);
│ │ │ │ -
192 Vector r1xr2 = crossProduct(row1, row2);
│ │ │ │ -
193 auto d0 = r0xr1.two_norm();
│ │ │ │ -
194 auto d1 = r0xr2.two_norm();
│ │ │ │ -
195 auto d2 = r1xr2.two_norm();
│ │ │ │ -
196
│ │ │ │ -
197 auto dmax = d0 ;
│ │ │ │ -
198 int imax = 0;
│ │ │ │ -
199 if(d1>dmax) {
│ │ │ │ -
200 dmax = d1;
│ │ │ │ -
201 imax = 1;
│ │ │ │ -
202 }
│ │ │ │ -
203 if(d2>dmax)
│ │ │ │ -
204 imax = 2;
│ │ │ │ -
205
│ │ │ │ -
206 if(imax == 0)
│ │ │ │ -
207 evec0 = r0xr1 / d0;
│ │ │ │ -
208 else if(imax == 1)
│ │ │ │ -
209 evec0 = r0xr2 / d1;
│ │ │ │ -
210 else
│ │ │ │ -
211 evec0 = r1xr2 / d2;
│ │ │ │ -
212 }
│ │ │ │ -
213
│ │ │ │ -
214 //see https://www.geometrictools.com/Documentation/RobustEigenSymmetric3x3.pdf
│ │ │ │ -
215 template<typename K>
│ │ │ │ -
216 void eig1(const FieldMatrix<K,3,3>& matrix, const FieldVector<K,3>& evec0, FieldVector<K,3>& evec1, K eval1) {
│ │ │ │ -
217 using Vector = FieldVector<K,3>;
│ │ │ │ -
218
│ │ │ │ -
219 //Robustly compute a right-handed orthonormal set {u, v, evec0}.
│ │ │ │ -
220 Vector u,v;
│ │ │ │ -
221 orthoComp(evec0, u, v);
│ │ │ │ -
222
│ │ │ │ -
223 /* Let e be eval1 and let E be a corresponding eigenvector which
│ │ │ │ -
224 is a solution to the linear system (A - e*I)*E = 0. The matrix
│ │ │ │ -
225 (A - e*I) is 3x3, not invertible (so infinitely many
│ │ │ │ -
226 solutions), and has rank 2 when eval1 and eval are different.
│ │ │ │ -
227 It has rank 1 when eval1 and eval2 are equal. Numerically, it
│ │ │ │ -
228 is difficult to compute robustly the rank of a matrix. Instead,
│ │ │ │ -
229 the 3x3 linear system is reduced to a 2x2 system as follows.
│ │ │ │ -
230 Define the 3x2 matrix J = [u,v] whose columns are the u and v
│ │ │ │ -
231 computed previously. Define the 2x1 vector X = J*E. The 2x2
│ │ │ │ -
232 system is 0 = M * X = (J^T * (A - e*I) * J) * X where J^T is
│ │ │ │ -
233 the transpose of J and M = J^T * (A - e*I) * J is a 2x2 matrix.
│ │ │ │ -
234 The system may be written as
│ │ │ │ -
235 +- -++- -+ +- -+
│ │ │ │ -
236 | U^T*A*U - e U^T*A*V || x0 | = e * | x0 |
│ │ │ │ -
237 | V^T*A*U V^T*A*V - e || x1 | | x1 |
│ │ │ │ -
238 +- -++ -+ +- -+
│ │ │ │ -
239 where X has row entries x0 and x1. */
│ │ │ │ -
240
│ │ │ │ -
241 Vector Au, Av;
│ │ │ │ -
242 matrix.mv(u, Au);
│ │ │ │ -
243 matrix.mv(v, Av);
│ │ │ │ -
244
│ │ │ │ -
245 auto m00 = u.dot(Au) - eval1;
│ │ │ │ -
246 auto m01 = u.dot(Av);
│ │ │ │ -
247 auto m11 = v.dot(Av) - eval1;
│ │ │ │ -
248
│ │ │ │ -
249 /* For robustness, choose the largest-length row of M to compute
│ │ │ │ -
250 the eigenvector. The 2-tuple of coefficients of U and V in the
│ │ │ │ -
251 assignments to eigenvector[1] lies on a circle, and U and V are
│ │ │ │ -
252 unit length and perpendicular, so eigenvector[1] is unit length
│ │ │ │ -
253 (within numerical tolerance). */
│ │ │ │ -
254 using std::abs, std::sqrt, std::max;
│ │ │ │ -
255 auto absM00 = abs(m00);
│ │ │ │ -
256 auto absM01 = abs(m01);
│ │ │ │ -
257 auto absM11 = abs(m11);
│ │ │ │ -
258 if(absM00 >= absM11) {
│ │ │ │ -
259 auto maxAbsComp = max(absM00, absM01);
│ │ │ │ -
260 if(maxAbsComp > 0.0) {
│ │ │ │ -
261 if(absM00 >= absM01) {
│ │ │ │ -
262 m01 /= m00;
│ │ │ │ -
263 m00 = 1.0 / sqrt(1.0 + m01*m01);
│ │ │ │ -
264 m01 *= m00;
│ │ │ │ -
265 }
│ │ │ │ -
266 else {
│ │ │ │ -
267 m00 /= m01;
│ │ │ │ -
268 m01 = 1.0 / sqrt(1.0 + m00*m00);
│ │ │ │ -
269 m00 *= m01;
│ │ │ │ -
270 }
│ │ │ │ -
271 evec1 = m01*u - m00*v;
│ │ │ │ -
272 }
│ │ │ │ -
273 else
│ │ │ │ -
274 evec1 = u;
│ │ │ │ -
275 }
│ │ │ │ -
276 else {
│ │ │ │ -
277 auto maxAbsComp = max(absM11, absM01);
│ │ │ │ -
278 if(maxAbsComp > 0.0) {
│ │ │ │ -
279 if(absM11 >= absM01) {
│ │ │ │ -
280 m01 /= m11;
│ │ │ │ -
281 m11 = 1.0 / sqrt(1.0 + m01*m01);
│ │ │ │ -
282 m01 *= m11;
│ │ │ │ -
283 }
│ │ │ │ -
284 else {
│ │ │ │ -
285 m11 /= m01;
│ │ │ │ -
286 m01 = 1.0 / sqrt(1.0 + m11*m11);
│ │ │ │ -
287 m11 *= m01;
│ │ │ │ -
288 }
│ │ │ │ -
289 evec1 = m11*u - m01*v;
│ │ │ │ -
290 }
│ │ │ │ -
291 else
│ │ │ │ -
292 evec1 = u;
│ │ │ │ -
293 }
│ │ │ │ -
294 }
│ │ │ │ -
295
│ │ │ │ -
296 // 1d specialization
│ │ │ │ -
297 template<Jobs Tag, typename K>
│ │ │ │ -
298 static void eigenValuesVectorsImpl(const FieldMatrix<K, 1, 1>& matrix,
│ │ │ │ -
299 FieldVector<K, 1>& eigenValues,
│ │ │ │ -
300 FieldMatrix<K, 1, 1>& eigenVectors)
│ │ │ │ -
301 {
│ │ │ │ -
302 eigenValues[0] = matrix[0][0];
│ │ │ │ -
303 if constexpr(Tag==EigenvaluesEigenvectors)
│ │ │ │ -
304 eigenVectors[0] = {1.0};
│ │ │ │ -
305 }
│ │ │ │ -
306
│ │ │ │ -
307
│ │ │ │ -
308 // 2d specialization
│ │ │ │ -
309 template <Jobs Tag, typename K>
│ │ │ │ -
310 static void eigenValuesVectorsImpl(const FieldMatrix<K, 2, 2>& matrix,
│ │ │ │ -
311 FieldVector<K, 2>& eigenValues,
│ │ │ │ -
312 FieldMatrix<K, 2, 2>& eigenVectors)
│ │ │ │ -
313 {
│ │ │ │ -
314 // Compute eigen values
│ │ │ │ -
315 Impl::eigenValues2dImpl(matrix, eigenValues);
│ │ │ │ -
316
│ │ │ │ -
317 // Compute eigenvectors by exploiting the Cayley–Hamilton theorem.
│ │ │ │ -
318 // If λ_1, λ_2 are the eigenvalues, then (A - λ_1I )(A - λ_2I ) = (A - λ_2I )(A - λ_1I ) = 0,
│ │ │ │ -
319 // so the columns of (A - λ_2I ) are annihilated by (A - λ_1I ) and vice versa.
│ │ │ │ -
320 // Assuming neither matrix is zero, the columns of each must include eigenvectors
│ │ │ │ -
321 // for the other eigenvalue. (If either matrix is zero, then A is a multiple of the
│ │ │ │ -
322 // identity and any non-zero vector is an eigenvector.)
│ │ │ │ -
323 // From: https://en.wikipedia.org/wiki/Eigenvalue_algorithm#2x2_matrices
│ │ │ │ -
324 if constexpr(Tag==EigenvaluesEigenvectors) {
│ │ │ │ -
325
│ │ │ │ -
326 // Special casing for multiples of the identity
│ │ │ │ -
327 FieldMatrix<K,2,2> temp = matrix;
│ │ │ │ -
328 temp[0][0] -= eigenValues[0];
│ │ │ │ -
329 temp[1][1] -= eigenValues[0];
│ │ │ │ -
330 if(temp.infinity_norm() <= 1e-14) {
│ │ │ │ -
331 eigenVectors[0] = {1.0, 0.0};
│ │ │ │ -
332 eigenVectors[1] = {0.0, 1.0};
│ │ │ │ -
333 }
│ │ │ │ -
334 else {
│ │ │ │ -
335 // The columns of A - λ_2I are eigenvectors for λ_1, or zero.
│ │ │ │ -
336 // Take the column with the larger norm to avoid zero columns.
│ │ │ │ -
337 FieldVector<K,2> ev0 = {matrix[0][0]-eigenValues[1], matrix[1][0]};
│ │ │ │ -
338 FieldVector<K,2> ev1 = {matrix[0][1], matrix[1][1]-eigenValues[1]};
│ │ │ │ -
339 eigenVectors[0] = (ev0.two_norm2() >= ev1.two_norm2()) ? ev0/ev0.two_norm() : ev1/ev1.two_norm();
│ │ │ │ -
340
│ │ │ │ -
341 // The columns of A - λ_1I are eigenvectors for λ_2, or zero.
│ │ │ │ -
342 // Take the column with the larger norm to avoid zero columns.
│ │ │ │ -
343 ev0 = {matrix[0][0]-eigenValues[0], matrix[1][0]};
│ │ │ │ -
344 ev1 = {matrix[0][1], matrix[1][1]-eigenValues[0]};
│ │ │ │ -
345 eigenVectors[1] = (ev0.two_norm2() >= ev1.two_norm2()) ? ev0/ev0.two_norm() : ev1/ev1.two_norm();
│ │ │ │ -
346 }
│ │ │ │ -
347 }
│ │ │ │ -
348 }
│ │ │ │ -
349
│ │ │ │ -
350 // 3d specialization
│ │ │ │ -
351 template <Jobs Tag, typename K>
│ │ │ │ -
352 static void eigenValuesVectorsImpl(const FieldMatrix<K, 3, 3>& matrix,
│ │ │ │ -
353 FieldVector<K, 3>& eigenValues,
│ │ │ │ -
354 FieldMatrix<K, 3, 3>& eigenVectors)
│ │ │ │ -
355 {
│ │ │ │ -
356 using Vector = FieldVector<K,3>;
│ │ │ │ -
357 using Matrix = FieldMatrix<K,3,3>;
│ │ │ │ -
358
│ │ │ │ -
359 //compute eigenvalues
│ │ │ │ -
360 /* Precondition the matrix by factoring out the maximum absolute
│ │ │ │ -
361 value of the components. This guards against floating-point
│ │ │ │ -
362 overflow when computing the eigenvalues.*/
│ │ │ │ -
363 using std::isnormal;
│ │ │ │ -
364 K maxAbsElement = (isnormal(matrix.infinity_norm())) ? matrix.infinity_norm() : K(1.0);
│ │ │ │ -
365 Matrix scaledMatrix = matrix / maxAbsElement;
│ │ │ │ -
366 K r = Impl::eigenValues3dImpl(scaledMatrix, eigenValues);
│ │ │ │ -
367
│ │ │ │ -
368 if constexpr(Tag==EigenvaluesEigenvectors) {
│ │ │ │ -
369 K offDiagNorm = Vector{scaledMatrix[0][1],scaledMatrix[0][2],scaledMatrix[1][2]}.two_norm2();
│ │ │ │ -
370 if (offDiagNorm <= std::numeric_limits<K>::epsilon())
│ │ │ │ -
371 {
│ │ │ │ -
372 eigenValues = {scaledMatrix[0][0], scaledMatrix[1][1], scaledMatrix[2][2]};
│ │ │ │ -
373 eigenVectors = {{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}};
│ │ │ │ -
374
│ │ │ │ -
375 // Use bubble sort to jointly sort eigenvalues and eigenvectors
│ │ │ │ -
376 // such that eigenvalues are ascending
│ │ │ │ -
377 if (eigenValues[0] > eigenValues[1])
│ │ │ │ -
378 {
│ │ │ │ -
379 std::swap(eigenValues[0], eigenValues[1]);
│ │ │ │ -
380 std::swap(eigenVectors[0], eigenVectors[1]);
│ │ │ │ -
381 }
│ │ │ │ -
382 if (eigenValues[1] > eigenValues[2])
│ │ │ │ -
383 {
│ │ │ │ -
384 std::swap(eigenValues[1], eigenValues[2]);
│ │ │ │ -
385 std::swap(eigenVectors[1], eigenVectors[2]);
│ │ │ │ -
386 }
│ │ │ │ -
387 if (eigenValues[0] > eigenValues[1])
│ │ │ │ -
388 {
│ │ │ │ -
389 std::swap(eigenValues[0], eigenValues[1]);
│ │ │ │ -
390 std::swap(eigenVectors[0], eigenVectors[1]);
│ │ │ │ -
391 }
│ │ │ │ -
392 }
│ │ │ │ -
393 else {
│ │ │ │ -
394 /*Compute the eigenvectors so that the set
│ │ │ │ -
395 [evec[0], evec[1], evec[2]] is right handed and
│ │ │ │ -
396 orthonormal. */
│ │ │ │ -
397
│ │ │ │ -
398 Matrix evec(0.0);
│ │ │ │ -
399 Vector eval(eigenValues);
│ │ │ │ -
400 if(r >= 0) {
│ │ │ │ -
401 Impl::eig0(scaledMatrix, eval[2], evec[2]);
│ │ │ │ -
402 Impl::eig1(scaledMatrix, evec[2], evec[1], eval[1]);
│ │ │ │ -
403 evec[0] = Impl::crossProduct(evec[1], evec[2]);
│ │ │ │ -
404 }
│ │ │ │ -
405 else {
│ │ │ │ -
406 Impl::eig0(scaledMatrix, eval[0], evec[0]);
│ │ │ │ -
407 Impl::eig1(scaledMatrix, evec[0], evec[1], eval[1]);
│ │ │ │ -
408 evec[2] = Impl::crossProduct(evec[0], evec[1]);
│ │ │ │ -
409 }
│ │ │ │ -
410 //sort eval/evec-pairs in ascending order
│ │ │ │ -
411 using EVPair = std::pair<K, Vector>;
│ │ │ │ -
412 std::vector<EVPair> pairs;
│ │ │ │ -
413 for(std::size_t i=0; i<=2; ++i)
│ │ │ │ -
414 pairs.push_back(EVPair(eval[i], evec[i]));
│ │ │ │ -
415 auto comp = [](EVPair x, EVPair y){ return x.first < y.first; };
│ │ │ │ -
416 std::sort(pairs.begin(), pairs.end(), comp);
│ │ │ │ -
417 for(std::size_t i=0; i<=2; ++i){
│ │ │ │ -
418 eigenValues[i] = pairs[i].first;
│ │ │ │ -
419 eigenVectors[i] = pairs[i].second;
│ │ │ │ -
420 }
│ │ │ │ -
421 }
│ │ │ │ -
422 }
│ │ │ │ -
423 //The preconditioning scaled the matrix, which scales the eigenvalues. Revert the scaling.
│ │ │ │ -
424 eigenValues *= maxAbsElement;
│ │ │ │ -
425 }
│ │ │ │ -
426
│ │ │ │ -
427 // forwarding to LAPACK with corresponding tag
│ │ │ │ -
428 template <Jobs Tag, int dim, typename K>
│ │ │ │ -
429 static void eigenValuesVectorsLapackImpl(const FieldMatrix<K, dim, dim>& matrix,
│ │ │ │ -
430 FieldVector<K, dim>& eigenValues,
│ │ │ │ -
431 FieldMatrix<K, dim, dim>& eigenVectors)
│ │ │ │ -
432 {
│ │ │ │ -
433 {
│ │ │ │ -
434#if HAVE_LAPACK
│ │ │ │ -
435 /*Lapack uses a proprietary tag to determine whether both eigenvalues and
│ │ │ │ -
436 -vectors ('v') or only eigenvalues ('n') should be calculated */
│ │ │ │ -
437 const char jobz = "nv"[Tag];
│ │ │ │ -
438
│ │ │ │ -
439 const long int N = dim ;
│ │ │ │ -
440 const char uplo = 'u'; // use upper triangular matrix
│ │ │ │ -
441
│ │ │ │ -
442 // length of matrix vector, LWORK >= max(1,3*N-1)
│ │ │ │ -
443 const long int lwork = 3*N -1 ;
│ │ │ │ -
444
│ │ │ │ -
445 constexpr bool isKLapackType = std::is_same_v<K,double> || std::is_same_v<K,float>;
│ │ │ │ -
446 using LapackNumType = std::conditional_t<isKLapackType, K, double>;
│ │ │ │ -
447
│ │ │ │ -
448 // matrix to put into dsyev
│ │ │ │ -
449 LapackNumType matrixVector[dim * dim];
│ │ │ │ -
450
│ │ │ │ -
451 // copy matrix
│ │ │ │ -
452 int row = 0;
│ │ │ │ -
453 for(int i=0; i<dim; ++i)
│ │ │ │ -
454 {
│ │ │ │ -
455 for(int j=0; j<dim; ++j, ++row)
│ │ │ │ -
456 {
│ │ │ │ -
457 matrixVector[ row ] = matrix[ i ][ j ];
│ │ │ │ -
458 }
│ │ │ │ -
459 }
│ │ │ │ -
460
│ │ │ │ -
461 // working memory
│ │ │ │ -
462 LapackNumType workSpace[lwork];
│ │ │ │ -
463
│ │ │ │ -
464 // return value information
│ │ │ │ -
465 long int info = 0;
│ │ │ │ -
466 LapackNumType* ev;
│ │ │ │ -
467 if constexpr (isKLapackType){
│ │ │ │ -
468 ev = &eigenValues[0];
│ │ │ │ -
469 }else{
│ │ │ │ -
470 ev = new LapackNumType[dim];
│ │ │ │ -
471 }
│ │ │ │ -
472
│ │ │ │ -
473 // call LAPACK routine (see fmatrixev.cc)
│ │ │ │ -
474 eigenValuesLapackCall(&jobz, &uplo, &N, &matrixVector[0], &N,
│ │ │ │ -
475 ev, &workSpace[0], &lwork, &info);
│ │ │ │ -
476
│ │ │ │ -
477 if constexpr (!isKLapackType){
│ │ │ │ -
478 for(size_t i=0;i<dim;++i)
│ │ │ │ -
479 eigenValues[i] = ev[i];
│ │ │ │ -
480 delete[] ev;
│ │ │ │ -
481 }
│ │ │ │ -
482
│ │ │ │ -
483 // restore eigenvectors matrix
│ │ │ │ -
484 if (Tag==Jobs::EigenvaluesEigenvectors){
│ │ │ │ -
485 row = 0;
│ │ │ │ -
486 for(int i=0; i<dim; ++i)
│ │ │ │ -
487 {
│ │ │ │ -
488 for(int j=0; j<dim; ++j, ++row)
│ │ │ │ -
489 {
│ │ │ │ -
490 eigenVectors[ i ][ j ] = matrixVector[ row ];
│ │ │ │ -
491 }
│ │ │ │ -
492 }
│ │ │ │ -
493 }
│ │ │ │ -
494
│ │ │ │ -
495 if( info != 0 )
│ │ │ │ -
496 {
│ │ │ │ -
497 std::cerr << "For matrix " << matrix << " eigenvalue calculation failed! " << std::endl;
│ │ │ │ -
498 DUNE_THROW(InvalidStateException,"eigenValues: Eigenvalue calculation failed!");
│ │ │ │ -
499 }
│ │ │ │ -
500#else
│ │ │ │ -
501 DUNE_THROW(NotImplemented,"LAPACK not found!");
│ │ │ │ -
502#endif
│ │ │ │ -
503 }
│ │ │ │ -
504 }
│ │ │ │ -
505
│ │ │ │ -
506 // generic specialization
│ │ │ │ -
507 template <Jobs Tag, int dim, typename K>
│ │ │ │ -
508 static void eigenValuesVectorsImpl(const FieldMatrix<K, dim, dim>& matrix,
│ │ │ │ -
509 FieldVector<K, dim>& eigenValues,
│ │ │ │ -
510 FieldMatrix<K, dim, dim>& eigenVectors)
│ │ │ │ -
511 {
│ │ │ │ -
512 eigenValuesVectorsLapackImpl<Tag>(matrix,eigenValues,eigenVectors);
│ │ │ │ -
513 }
│ │ │ │ -
514 } //namespace Impl
│ │ │ │ -
515
│ │ │ │ -
523 template <int dim, typename K>
│ │ │ │ -
│ │ │ │ -
524 static void eigenValues(const FieldMatrix<K, dim, dim>& matrix,
│ │ │ │ - │ │ │ │ -
526 {
│ │ │ │ - │ │ │ │ -
528 Impl::eigenValuesVectorsImpl<Impl::Jobs::OnlyEigenvalues>(matrix, eigenValues, dummy);
│ │ │ │ -
529 }
│ │ │ │ -
│ │ │ │ -
530
│ │ │ │ -
539 template <int dim, typename K>
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ -
542 FieldMatrix<K, dim, dim>& eigenVectors)
│ │ │ │ -
543 {
│ │ │ │ -
544 Impl::eigenValuesVectorsImpl<Impl::Jobs::EigenvaluesEigenvectors>(matrix, eigenValues, eigenVectors);
│ │ │ │ -
545 }
│ │ │ │ -
│ │ │ │ -
546
│ │ │ │ -
554 template <int dim, typename K>
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ -
557 {
│ │ │ │ - │ │ │ │ -
559 Impl::eigenValuesVectorsLapackImpl<Impl::Jobs::EigenvaluesEigenvectors>(matrix, eigenValues, dummy);
│ │ │ │ -
560 }
│ │ │ │ -
│ │ │ │ -
561
│ │ │ │ -
570 template <int dim, typename K>
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ -
573 FieldMatrix<K, dim, dim>& eigenVectors)
│ │ │ │ -
574 {
│ │ │ │ -
575 Impl::eigenValuesVectorsLapackImpl<Impl::Jobs::EigenvaluesEigenvectors>(matrix, eigenValues, eigenVectors);
│ │ │ │ -
576 }
│ │ │ │ -
│ │ │ │ -
577
│ │ │ │ -
585 template <int dim, typename K, class C>
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ -
588 {
│ │ │ │ -
589#if HAVE_LAPACK
│ │ │ │ -
590 {
│ │ │ │ -
591 const long int N = dim ;
│ │ │ │ -
592 const char jobvl = 'n';
│ │ │ │ -
593 const char jobvr = 'n';
│ │ │ │ -
594
│ │ │ │ -
595 constexpr bool isKLapackType = std::is_same_v<K,double> || std::is_same_v<K,float>;
│ │ │ │ -
596 using LapackNumType = std::conditional_t<isKLapackType, K, double>;
│ │ │ │ -
597
│ │ │ │ -
598 // matrix to put into dgeev
│ │ │ │ -
599 LapackNumType matrixVector[dim * dim];
│ │ │ │ -
600
│ │ │ │ -
601 // copy matrix
│ │ │ │ -
602 int row = 0;
│ │ │ │ -
603 for(int i=0; i<dim; ++i)
│ │ │ │ -
604 {
│ │ │ │ -
605 for(int j=0; j<dim; ++j, ++row)
│ │ │ │ -
606 {
│ │ │ │ -
607 matrixVector[ row ] = matrix[ i ][ j ];
│ │ │ │ -
608 }
│ │ │ │ -
609 }
│ │ │ │ -
610
│ │ │ │ -
611 // working memory
│ │ │ │ -
612 LapackNumType eigenR[dim];
│ │ │ │ -
613 LapackNumType eigenI[dim];
│ │ │ │ -
614 LapackNumType work[3*dim];
│ │ │ │ -
615
│ │ │ │ -
616 // return value information
│ │ │ │ -
617 long int info = 0;
│ │ │ │ -
618 const long int lwork = 3*dim;
│ │ │ │ -
619
│ │ │ │ -
620 // call LAPACK routine (see fmatrixev_ext.cc)
│ │ │ │ -
621 eigenValuesNonsymLapackCall(&jobvl, &jobvr, &N, &matrixVector[0], &N,
│ │ │ │ -
622 &eigenR[0], &eigenI[0], nullptr, &N, nullptr, &N, &work[0],
│ │ │ │ -
623 &lwork, &info);
│ │ │ │ -
624
│ │ │ │ -
625 if( info != 0 )
│ │ │ │ -
626 {
│ │ │ │ -
627 std::cerr << "For matrix " << matrix << " eigenvalue calculation failed! " << std::endl;
│ │ │ │ -
628 DUNE_THROW(InvalidStateException,"eigenValues: Eigenvalue calculation failed!");
│ │ │ │ -
629 }
│ │ │ │ -
630 for (int i=0; i<N; ++i) {
│ │ │ │ -
631 eigenValues[i].real = eigenR[i];
│ │ │ │ -
632 eigenValues[i].imag = eigenI[i];
│ │ │ │ -
633 }
│ │ │ │ -
634 }
│ │ │ │ -
635#else
│ │ │ │ -
636 DUNE_THROW(NotImplemented,"LAPACK not found!");
│ │ │ │ -
637#endif
│ │ │ │ -
638 }
│ │ │ │ -
│ │ │ │ -
639 } // end namespace FMatrixHelp
│ │ │ │ -
640
│ │ │ │ -
643} // end namespace Dune
│ │ │ │ -
644#endif
│ │ │ │ -
A few common exception classes.
│ │ │ │ -
Implements a matrix constructed from a given type representing a field and compile-time given number ...
│ │ │ │ -
Some useful basic math stuff.
│ │ │ │ -
Implements a vector constructed from a given type representing a field and a compile-time given size.
│ │ │ │ -
constexpr auto max
Function object that returns the greater of the given values.
Definition hybridutilities.hh:484
│ │ │ │ -
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
│ │ │ │ -
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
static void eigenValuesNonSym(const FieldMatrix< K, dim, dim > &matrix, FieldVector< C, dim > &eigenValues)
calculates the eigenvalues of a non-symmetric field matrix
Definition fmatrixev.hh:586
│ │ │ │ -
static void eigenValues(const FieldMatrix< K, dim, dim > &matrix, FieldVector< K, dim > &eigenValues)
calculates the eigenvalues of a symmetric field matrix
Definition fmatrixev.hh:524
│ │ │ │ -
static void eigenValuesLapack(const FieldMatrix< K, dim, dim > &matrix, FieldVector< K, dim > &eigenValues)
calculates the eigenvalues of a symmetric field matrix
Definition fmatrixev.hh:555
│ │ │ │ -
static void eigenValuesVectors(const FieldMatrix< K, dim, dim > &matrix, FieldVector< K, dim > &eigenValues, FieldMatrix< K, dim, dim > &eigenVectors)
calculates the eigenvalues and eigenvectors of a symmetric field matrix
Definition fmatrixev.hh:540
│ │ │ │ -
static void eigenValuesVectorsLapack(const FieldMatrix< K, dim, dim > &matrix, FieldVector< K, dim > &eigenValues, FieldMatrix< K, dim, dim > &eigenVectors)
calculates the eigenvalues and -vectors of a symmetric field matrix
Definition fmatrixev.hh:571
│ │ │ │ -
A dense n x m matrix.
Definition fmatrix.hh:117
│ │ │ │ -
vector space out of a tensor product of fields.
Definition fvector.hh:91
│ │ │ │ -
Default exception for dummy implementations.
Definition exceptions.hh:263
│ │ │ │ -
Default exception if a function was called while the object is not in a valid state for that function...
Definition exceptions.hh:281
│ │ │ │ -
T real_type
export the type representing the real type of the field
Definition ftraits.hh:30
│ │ │ │ -
static const Field pi()
Archimedes' constant.
Definition math.hh:48
│ │ │ │ +
139} // end namespace Dune::Std
│ │ │ │ +
140
│ │ │ │ +
141#endif // DUNE_COMMON_STD_LAYOUT_RIGHT_HH
│ │ │ │ + │ │ │ │ + │ │ │ │ +
Namespace for features backported from new C++ standards.
Definition default_accessor.hh:10
│ │ │ │ +
A layout mapping where the leftmost extent has stride 1.
Definition layout_left.hh:19
│ │ │ │ +
A layout where the rightmost extent has stride 1, and strides increase right-to-left as the product o...
Definition fwd_layouts.hh:30
│ │ │ │ +
A layout mapping where the rightmost extent has stride 1.
Definition layout_right.hh:19
│ │ │ │ +
constexpr const extents_type & extents() const noexcept
Definition layout_right.hh:85
│ │ │ │ +
constexpr index_type operator()() const noexcept
The default offset for rank-0 tensors is 0.
Definition layout_right.hh:104
│ │ │ │ +
constexpr mapping & operator=(const mapping &) noexcept=default
Copy-assignment for the mapping.
│ │ │ │ +
constexpr index_type required_span_size() const noexcept
Definition layout_right.hh:86
│ │ │ │ +
constexpr mapping() noexcept=default
The default construction is possible for default constructible extents.
│ │ │ │ +
typename extents_type::size_type size_type
Definition layout_right.hh:24
│ │ │ │ +
Extents extents_type
Definition layout_right.hh:23
│ │ │ │ +
static constexpr bool is_always_unique() noexcept
Definition layout_right.hh:109
│ │ │ │ +
constexpr index_type stride(rank_type i) const noexcept
The stride is the product of the extents E(n)*E(n-1)*...*E(i+1)
Definition layout_right.hh:120
│ │ │ │ +
static constexpr bool is_exhaustive() noexcept
Definition layout_right.hh:114
│ │ │ │ +
constexpr mapping(const layout_left::mapping< OtherExtents > &m) noexcept
Construct the mapping from a layout_left.
Definition layout_right.hh:57
│ │ │ │ +
static constexpr bool is_strided() noexcept
Definition layout_right.hh:115
│ │ │ │ +
typename extents_type::rank_type rank_type
Definition layout_right.hh:25
│ │ │ │ +
static constexpr bool is_always_strided() noexcept
Definition layout_right.hh:111
│ │ │ │ +
static constexpr bool is_unique() noexcept
Definition layout_right.hh:113
│ │ │ │ +
friend constexpr bool operator==(const mapping &a, const mapping< OtherExtents > &b) noexcept
Definition layout_right.hh:130
│ │ │ │ +
static constexpr bool is_always_exhaustive() noexcept
Definition layout_right.hh:110
│ │ │ │ +
typename extents_type::index_type index_type
Definition layout_right.hh:26
│ │ │ │ +
A layout mapping where the strides are user-defined.
Definition layout_stride.hh:19
│ │ │ │ +
constexpr const extents_type & extents() const noexcept
Definition layout_stride.hh:85
│ │ │ │ +
constexpr const strides_type & strides() const noexcept
Get the array of all strides.
Definition layout_stride.hh:127
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,710 +1,232 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -fmatrixev.hh │ │ │ │ │ + * std │ │ │ │ │ +layout_right.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_FMATRIXEIGENVALUES_HH │ │ │ │ │ -6#define DUNE_FMATRIXEIGENVALUES_HH │ │ │ │ │ +5#ifndef DUNE_COMMON_STD_LAYOUT_RIGHT_HH │ │ │ │ │ +6#define DUNE_COMMON_STD_LAYOUT_RIGHT_HH │ │ │ │ │ 7 │ │ │ │ │ -12#include │ │ │ │ │ -13#include │ │ │ │ │ -14#include │ │ │ │ │ -15#include │ │ │ │ │ -16 │ │ │ │ │ -17#include // HAVE_LAPACK │ │ │ │ │ -18#include │ │ │ │ │ -19#include │ │ │ │ │ -20#include │ │ │ │ │ -21#include │ │ │ │ │ -22 │ │ │ │ │ -23namespace Dune { │ │ │ │ │ -24 │ │ │ │ │ -30 namespace FMatrixHelp { │ │ │ │ │ +8#include │ │ │ │ │ +9#include │ │ │ │ │ +10 │ │ │ │ │ +11#include │ │ │ │ │ +12#include │ │ │ │ │ +13 │ │ │ │ │ +14namespace Dune::Std { │ │ │ │ │ +15 │ │ │ │ │ +17template │ │ │ │ │ +18class layout_right::mapping │ │ │ │ │ +19{ │ │ │ │ │ +20 template friend class mapping; │ │ │ │ │ +21 │ │ │ │ │ +22public: │ │ │ │ │ +23 using extents_type = Extents; │ │ │ │ │ +24 using size_type = typename extents_type::size_type; │ │ │ │ │ +25 using rank_type = typename extents_type::rank_type; │ │ │ │ │ +26 using index_type = typename extents_type::index_type; │ │ │ │ │ +27 using layout_type = layout_right; │ │ │ │ │ +28 │ │ │ │ │ +30 constexpr mapping () noexcept = default; │ │ │ │ │ 31 │ │ │ │ │ -32#if HAVE_LAPACK │ │ │ │ │ -33 // defined in fmatrixev.cc │ │ │ │ │ -34 extern void eigenValuesLapackCall( │ │ │ │ │ -35 const char* jobz, const char* uplo, const long │ │ │ │ │ -36 int* n, double* a, const long int* lda, double* w, │ │ │ │ │ -37 double* work, const long int* lwork, long int* info); │ │ │ │ │ -38 │ │ │ │ │ -39 extern void eigenValuesNonsymLapackCall( │ │ │ │ │ -40 const char* jobvl, const char* jobvr, const long │ │ │ │ │ -41 int* n, double* a, const long int* lda, double* wr, double* wi, double* vl, │ │ │ │ │ -42 const long int* ldvl, double* vr, const long int* ldvr, double* work, │ │ │ │ │ -43 const long int* lwork, long int* info); │ │ │ │ │ -44 │ │ │ │ │ -45 extern void eigenValuesLapackCall( │ │ │ │ │ -46 const char* jobz, const char* uplo, const long │ │ │ │ │ -47 int* n, float* a, const long int* lda, float* w, │ │ │ │ │ -48 float* work, const long int* lwork, long int* info); │ │ │ │ │ +33 constexpr mapping (const mapping&) noexcept = default; │ │ │ │ │ +34 │ │ │ │ │ +36 constexpr mapping (const extents_type& e) noexcept │ │ │ │ │ +37 : extents_(e) │ │ │ │ │ +38 {} │ │ │ │ │ +39 │ │ │ │ │ +41 template , int> = │ │ │ │ │ +0> │ │ │ │ │ +43 #if __cpp_conditional_explicit >= 201806L │ │ │ │ │ +44 explicit(!std::is_convertible_v) │ │ │ │ │ +45 #endif │ │ │ │ │ +46 constexpr mapping (const mapping& m) noexcept │ │ │ │ │ +47 : extents_(m.extents()) │ │ │ │ │ +48 {} │ │ │ │ │ 49 │ │ │ │ │ -50 extern void eigenValuesNonsymLapackCall( │ │ │ │ │ -51 const char* jobvl, const char* jobvr, const long │ │ │ │ │ -52 int* n, float* a, const long int* lda, float* wr, float* wi, float* vl, │ │ │ │ │ -53 const long int* ldvl, float* vr, const long int* ldvr, float* work, │ │ │ │ │ -54 const long int* lwork, long int* info); │ │ │ │ │ -55 │ │ │ │ │ -56#endif │ │ │ │ │ -57 │ │ │ │ │ -58 namespace Impl { │ │ │ │ │ -59 //internal tag to activate/disable code for eigenvector calculation at │ │ │ │ │ -compile time │ │ │ │ │ -60 enum Jobs { OnlyEigenvalues=0, EigenvaluesEigenvectors=1 }; │ │ │ │ │ -61 │ │ │ │ │ -62 //internal dummy used if only eigenvalues are to be calculated │ │ │ │ │ -63 template │ │ │ │ │ -64 using EVDummy = FieldMatrix; │ │ │ │ │ -65 │ │ │ │ │ -66 //compute the cross-product of two vectors │ │ │ │ │ -67 template │ │ │ │ │ -68 inline FieldVector crossProduct(const FieldVector& vec0, const │ │ │ │ │ -FieldVector& vec1) { │ │ │ │ │ -69 return {vec0[1]*vec1[2] - vec0[2]*vec1[1], vec0[2]*vec1[0] - vec0[0]*vec1 │ │ │ │ │ -[2], vec0[0]*vec1[1] - vec0[1]*vec1[0]}; │ │ │ │ │ -70 } │ │ │ │ │ -71 │ │ │ │ │ -72 template │ │ │ │ │ -73 static void eigenValues2dImpl(const FieldMatrix& matrix, │ │ │ │ │ -74 FieldVector& eigenvalues) │ │ │ │ │ -75 { │ │ │ │ │ -76 using std::sqrt; │ │ │ │ │ -77 const K p = 0.5 * (matrix[0][0] + matrix [1][1]); │ │ │ │ │ -78 const K p2 = p - matrix[1][1]; │ │ │ │ │ -79 K q = p2 * p2 + matrix[1][0] * matrix[0][1]; │ │ │ │ │ -80 if( q < 0 && q > -1e-14 ) q = 0; │ │ │ │ │ -81 if (q < 0) │ │ │ │ │ -82 { │ │ │ │ │ -83 std::cout << matrix << std::endl; │ │ │ │ │ -84 // Complex eigenvalues are either caused by non-symmetric matrices or by │ │ │ │ │ -round-off errors │ │ │ │ │ -85 DUNE_THROW(MathError, "Complex eigenvalue detected (which this │ │ │ │ │ -implementation cannot handle)."); │ │ │ │ │ -86 } │ │ │ │ │ +51 template = 0, │ │ │ │ │ +53 std::enable_if_t, int> = │ │ │ │ │ +0> │ │ │ │ │ +54 #if __cpp_conditional_explicit >= 201806L │ │ │ │ │ +55 explicit(!std::is_convertible_v) │ │ │ │ │ +56 #endif │ │ │ │ │ +57 constexpr mapping (const layout_left::mapping& m) noexcept │ │ │ │ │ +58 : extents_(m.extents()) │ │ │ │ │ +59 {} │ │ │ │ │ +60 │ │ │ │ │ +62 template , int> = │ │ │ │ │ +0> │ │ │ │ │ +64 #if __cpp_conditional_explicit >= 201806L │ │ │ │ │ +65 explicit(extents_type::rank() > 0) │ │ │ │ │ +66 #endif │ │ │ │ │ +67 constexpr mapping (const layout_stride::mapping& m) │ │ │ │ │ +68 : extents_(m.extents()) │ │ │ │ │ +69 { │ │ │ │ │ +70#ifndef NDEBUG │ │ │ │ │ +71 if constexpr(extents_type::rank() > 0) { │ │ │ │ │ +72 index_type prod = 1; │ │ │ │ │ +73 for (rank_type r = extents_type::rank()-1; r > 0; --r) { │ │ │ │ │ +74 assert(m.strides(r) == prod); │ │ │ │ │ +75 prod *= m.extents().extent(r); │ │ │ │ │ +76 } │ │ │ │ │ +77 assert(m.strides(0) == prod); │ │ │ │ │ +78 } │ │ │ │ │ +79#endif │ │ │ │ │ +80 } │ │ │ │ │ +81 │ │ │ │ │ +83 constexpr mapping& operator=_(const mapping&) noexcept = default; │ │ │ │ │ +84 │ │ │ │ │ +85 constexpr const extents_type& extents () const noexcept { return extents_; } │ │ │ │ │ +86 constexpr index_type required_span_size () const noexcept { return │ │ │ │ │ +extents_.product(); } │ │ │ │ │ 87 │ │ │ │ │ -88 // get square root │ │ │ │ │ -89 q = sqrt(q); │ │ │ │ │ -90 │ │ │ │ │ -91 // store eigenvalues in ascending order │ │ │ │ │ -92 eigenvalues[0] = p - q; │ │ │ │ │ -93 eigenvalues[1] = p + q; │ │ │ │ │ -94 } │ │ │ │ │ -95 │ │ │ │ │ -96 /* │ │ │ │ │ -97 This implementation was adapted from the pseudo-code (Python?) │ │ │ │ │ -implementation found on │ │ │ │ │ -98 http://en.wikipedia.org/wiki/Eigenvalue_algorithm (retrieved late August │ │ │ │ │ -2014). │ │ │ │ │ -99 Wikipedia claims to have taken it from │ │ │ │ │ -100 Smith, Oliver K. (April 1961), Eigenvalues of a symmetric 3 × 3 matrix., │ │ │ │ │ -101 Communications of the ACM 4 (4): 168, doi:10.1145/355578.366316 │ │ │ │ │ -102 */ │ │ │ │ │ -103 template │ │ │ │ │ -104 static K eigenValues3dImpl(const FieldMatrix& matrix, │ │ │ │ │ -105 FieldVector& eigenvalues) │ │ │ │ │ -106 { │ │ │ │ │ -107 using std::sqrt; │ │ │ │ │ -108 using std::acos; │ │ │ │ │ -109 using real_type = typename FieldTraits::real_type; │ │ │ │ │ -110 const K pi = MathematicalConstants::pi(); │ │ │ │ │ -111 K p1 = matrix[0][1]*matrix[0][1] + matrix[0][2]*matrix[0][2] + matrix[1] │ │ │ │ │ -[2]*matrix[1][2]; │ │ │ │ │ +89 template = 0, │ │ │ │ │ +91 std::enable_if_t<(std::is_convertible_v && ...), int> = │ │ │ │ │ +0, │ │ │ │ │ +92 std::enable_if_t<(std::is_nothrow_constructible_v && │ │ │ │ │ +...), int> = 0> │ │ │ │ │ +93 constexpr index_type operator()_(Indices... ii) const noexcept │ │ │ │ │ +94 { │ │ │ │ │ +95 const std::array indices{index_type(std::move(ii))...}; │ │ │ │ │ +96 index_type value = indices.front(); │ │ │ │ │ +97 for (rank_type j = 0; j < extents_type::rank()-1; ++j) { │ │ │ │ │ +98 value = indices[j+1] + extents_.extent(j+1) * value; │ │ │ │ │ +99 } │ │ │ │ │ +100 return value; │ │ │ │ │ +101 } │ │ │ │ │ +102 │ │ │ │ │ +104 constexpr index_type operator()_() const noexcept │ │ │ │ │ +105 { │ │ │ │ │ +106 return 0; │ │ │ │ │ +107 } │ │ │ │ │ +108 │ │ │ │ │ +109 static constexpr bool is_always_unique () noexcept { return true; } │ │ │ │ │ +110 static constexpr bool is_always_exhaustive () noexcept { return true; } │ │ │ │ │ +111 static constexpr bool is_always_strided () noexcept { return true; } │ │ │ │ │ 112 │ │ │ │ │ -113 if (p1 <= std::numeric_limits::epsilon()) { │ │ │ │ │ -114 // A is diagonal. │ │ │ │ │ -115 eigenvalues[0] = matrix[0][0]; │ │ │ │ │ -116 eigenvalues[1] = matrix[1][1]; │ │ │ │ │ -117 eigenvalues[2] = matrix[2][2]; │ │ │ │ │ -118 std::sort(eigenvalues.begin(), eigenvalues.end()); │ │ │ │ │ -119 │ │ │ │ │ -120 return 0.0; │ │ │ │ │ -121 } │ │ │ │ │ -122 else │ │ │ │ │ -123 { │ │ │ │ │ -124 // q = trace(A)/3 │ │ │ │ │ -125 K q = 0; │ │ │ │ │ -126 for (int i=0; i<3; i++) │ │ │ │ │ -127 q += matrix[i][i] / 3.0; │ │ │ │ │ +113 static constexpr bool is_unique () noexcept { return true; } │ │ │ │ │ +114 static constexpr bool is_exhaustive () noexcept { return true; } │ │ │ │ │ +115 static constexpr bool is_strided () noexcept { return true; } │ │ │ │ │ +116 │ │ │ │ │ +118 template 0), int> = 0> │ │ │ │ │ +120 constexpr index_type stride (rank_type i) const noexcept │ │ │ │ │ +121 { │ │ │ │ │ +122 assert(i < extents_type::rank()); │ │ │ │ │ +123 index_type prod = 1; │ │ │ │ │ +124 for (rank_type r = i+1; r < extents_type::rank(); ++r) │ │ │ │ │ +125 prod *= extents().extent(r); │ │ │ │ │ +126 return prod; │ │ │ │ │ +127 } │ │ │ │ │ 128 │ │ │ │ │ -129 K p2 = (matrix[0][0] - q)*(matrix[0][0] - q) + (matrix[1][1] - q)*(matrix │ │ │ │ │ -[1][1] - q) + (matrix[2][2] - q)*(matrix[2][2] - q) + 2.0 * p1; │ │ │ │ │ -130 K p = sqrt(p2 / 6); │ │ │ │ │ -131 // B = (1 / p) * (A - q * I); // I is the identity matrix │ │ │ │ │ -132 FieldMatrix B; │ │ │ │ │ -133 for (int i=0; i<3; i++) │ │ │ │ │ -134 for (int j=0; j<3; j++) │ │ │ │ │ -135 B[i][j] = (real_type(1.0)/p) * (matrix[i][j] - q*(i==j)); │ │ │ │ │ -136 │ │ │ │ │ -137 K r = B.determinant() / 2.0; │ │ │ │ │ +129 template │ │ │ │ │ +130 friend constexpr bool operator==_(const mapping& a, const │ │ │ │ │ +mapping& b) noexcept │ │ │ │ │ +131 { │ │ │ │ │ +132 return a.extents_ == b.extents_; │ │ │ │ │ +133 } │ │ │ │ │ +134 │ │ │ │ │ +135private: │ │ │ │ │ +136 [[no_unique_address]] extents_type extents_; │ │ │ │ │ +137}; │ │ │ │ │ 138 │ │ │ │ │ -139 /*In exact arithmetic for a symmetric matrix -1 <= r <= 1 │ │ │ │ │ -140 but computation error can leave it slightly outside this range. │ │ │ │ │ -141 acos(z) function requires |z| <= 1, but will fail silently │ │ │ │ │ -142 and return NaN if the input is larger than 1 in magnitude. │ │ │ │ │ -143 Thus r is clamped to [-1,1].*/ │ │ │ │ │ -144 using std::clamp; │ │ │ │ │ -145 r = clamp(r, -1.0, 1.0); │ │ │ │ │ -146 K phi = acos(r) / 3.0; │ │ │ │ │ -147 │ │ │ │ │ -148 // the eigenvalues satisfy eig[2] <= eig[1] <= eig[0] │ │ │ │ │ -149 eigenvalues[2] = q + 2 * p * cos(phi); │ │ │ │ │ -150 eigenvalues[0] = q + 2 * p * cos(phi + (2*pi/3)); │ │ │ │ │ -151 eigenvalues[1] = 3 * q - eigenvalues[0] - eigenvalues[2]; // since trace │ │ │ │ │ -(matrix) = eig1 + eig2 + eig3 │ │ │ │ │ -152 │ │ │ │ │ -153 return r; │ │ │ │ │ -154 } │ │ │ │ │ -155 } │ │ │ │ │ -156 │ │ │ │ │ -157 //see https://www.geometrictools.com/Documentation/ │ │ │ │ │ -RobustEigenSymmetric3x3.pdf │ │ │ │ │ -158 //Robustly compute a right-handed orthonormal set {u, v, evec0}. │ │ │ │ │ -159 template │ │ │ │ │ -160 void orthoComp(const FieldVector& evec0, FieldVector& u, │ │ │ │ │ -FieldVector& v) { │ │ │ │ │ -161 using std::abs; │ │ │ │ │ -162 if(abs(evec0[0]) > abs(evec0[1])) { │ │ │ │ │ -163 //The component of maximum absolute value is either evec0[0] or evec0[2]. │ │ │ │ │ -164 FieldVector temp = {evec0[0], evec0[2]}; │ │ │ │ │ -165 auto L = 1.0 / temp.two_norm(); │ │ │ │ │ -166 u = L * FieldVector({-evec0[2], 0.0, evec0[0]}); │ │ │ │ │ -167 } │ │ │ │ │ -168 else { │ │ │ │ │ -169 //The component of maximum absolute value is either evec0[1] or evec0[2]. │ │ │ │ │ -170 FieldVector temp = {evec0[1], evec0[2]}; │ │ │ │ │ -171 auto L = 1.0 / temp.two_norm(); │ │ │ │ │ -172 u = L * FieldVector({0.0, evec0[2], -evec0[1]}); │ │ │ │ │ -173 } │ │ │ │ │ -174 v = crossProduct(evec0, u); │ │ │ │ │ -175 } │ │ │ │ │ -176 │ │ │ │ │ -177 //see https://www.geometrictools.com/Documentation/ │ │ │ │ │ -RobustEigenSymmetric3x3.pdf │ │ │ │ │ -178 template │ │ │ │ │ -179 void eig0(const FieldMatrix& matrix, K eval0, FieldVector& │ │ │ │ │ -evec0) { │ │ │ │ │ -180 /* Compute a unit-length eigenvector for eigenvalue[i0]. The │ │ │ │ │ -181 matrix is rank 2, so two of the rows are linearly independent. │ │ │ │ │ -182 For a robust computation of the eigenvector, select the two │ │ │ │ │ -183 rows whose cross product has largest length of all pairs of │ │ │ │ │ -184 rows. */ │ │ │ │ │ -185 using Vector = FieldVector; │ │ │ │ │ -186 Vector row0 = {matrix[0][0]-eval0, matrix[0][1], matrix[0][2]}; │ │ │ │ │ -187 Vector row1 = {matrix[1][0], matrix[1][1]-eval0, matrix[1][2]}; │ │ │ │ │ -188 Vector row2 = {matrix[2][0], matrix[2][1], matrix[2][2]-eval0}; │ │ │ │ │ -189 │ │ │ │ │ -190 Vector r0xr1 = crossProduct(row0, row1); │ │ │ │ │ -191 Vector r0xr2 = crossProduct(row0, row2); │ │ │ │ │ -192 Vector r1xr2 = crossProduct(row1, row2); │ │ │ │ │ -193 auto d0 = r0xr1.two_norm(); │ │ │ │ │ -194 auto d1 = r0xr2.two_norm(); │ │ │ │ │ -195 auto d2 = r1xr2.two_norm(); │ │ │ │ │ -196 │ │ │ │ │ -197 auto dmax = d0 ; │ │ │ │ │ -198 int imax = 0; │ │ │ │ │ -199 if(d1>dmax) { │ │ │ │ │ -200 dmax = d1; │ │ │ │ │ -201 imax = 1; │ │ │ │ │ -202 } │ │ │ │ │ -203 if(d2>dmax) │ │ │ │ │ -204 imax = 2; │ │ │ │ │ -205 │ │ │ │ │ -206 if(imax == 0) │ │ │ │ │ -207 evec0 = r0xr1 / d0; │ │ │ │ │ -208 else if(imax == 1) │ │ │ │ │ -209 evec0 = r0xr2 / d1; │ │ │ │ │ -210 else │ │ │ │ │ -211 evec0 = r1xr2 / d2; │ │ │ │ │ -212 } │ │ │ │ │ -213 │ │ │ │ │ -214 //see https://www.geometrictools.com/Documentation/ │ │ │ │ │ -RobustEigenSymmetric3x3.pdf │ │ │ │ │ -215 template │ │ │ │ │ -216 void eig1(const FieldMatrix& matrix, const FieldVector& evec0, │ │ │ │ │ -FieldVector& evec1, K eval1) { │ │ │ │ │ -217 using Vector = FieldVector; │ │ │ │ │ -218 │ │ │ │ │ -219 //Robustly compute a right-handed orthonormal set {u, v, evec0}. │ │ │ │ │ -220 Vector u,v; │ │ │ │ │ -221 orthoComp(evec0, u, v); │ │ │ │ │ -222 │ │ │ │ │ -223 /* Let e be eval1 and let E be a corresponding eigenvector which │ │ │ │ │ -224 is a solution to the linear system (A - e*I)*E = 0. The matrix │ │ │ │ │ -225 (A - e*I) is 3x3, not invertible (so infinitely many │ │ │ │ │ -226 solutions), and has rank 2 when eval1 and eval are different. │ │ │ │ │ -227 It has rank 1 when eval1 and eval2 are equal. Numerically, it │ │ │ │ │ -228 is difficult to compute robustly the rank of a matrix. Instead, │ │ │ │ │ -229 the 3x3 linear system is reduced to a 2x2 system as follows. │ │ │ │ │ -230 Define the 3x2 matrix J = [u,v] whose columns are the u and v │ │ │ │ │ -231 computed previously. Define the 2x1 vector X = J*E. The 2x2 │ │ │ │ │ -232 system is 0 = M * X = (J^T * (A - e*I) * J) * X where J^T is │ │ │ │ │ -233 the transpose of J and M = J^T * (A - e*I) * J is a 2x2 matrix. │ │ │ │ │ -234 The system may be written as │ │ │ │ │ -235 +- -++- -+ +- -+ │ │ │ │ │ -236 | U^T*A*U - e U^T*A*V || x0 | = e * | x0 | │ │ │ │ │ -237 | V^T*A*U V^T*A*V - e || x1 | | x1 | │ │ │ │ │ -238 +- -++ -+ +- -+ │ │ │ │ │ -239 where X has row entries x0 and x1. */ │ │ │ │ │ -240 │ │ │ │ │ -241 Vector Au, Av; │ │ │ │ │ -242 matrix.mv(u, Au); │ │ │ │ │ -243 matrix.mv(v, Av); │ │ │ │ │ -244 │ │ │ │ │ -245 auto m00 = u.dot(Au) - eval1; │ │ │ │ │ -246 auto m01 = u.dot(Av); │ │ │ │ │ -247 auto m11 = v.dot(Av) - eval1; │ │ │ │ │ -248 │ │ │ │ │ -249 /* For robustness, choose the largest-length row of M to compute │ │ │ │ │ -250 the eigenvector. The 2-tuple of coefficients of U and V in the │ │ │ │ │ -251 assignments to eigenvector[1] lies on a circle, and U and V are │ │ │ │ │ -252 unit length and perpendicular, so eigenvector[1] is unit length │ │ │ │ │ -253 (within numerical tolerance). */ │ │ │ │ │ -254 using std::abs, std::sqrt, std::max; │ │ │ │ │ -255 auto absM00 = abs(m00); │ │ │ │ │ -256 auto absM01 = abs(m01); │ │ │ │ │ -257 auto absM11 = abs(m11); │ │ │ │ │ -258 if(absM00 >= absM11) { │ │ │ │ │ -259 auto maxAbsComp = max(absM00, absM01); │ │ │ │ │ -260 if(maxAbsComp > 0.0) { │ │ │ │ │ -261 if(absM00 >= absM01) { │ │ │ │ │ -262 m01 /= m00; │ │ │ │ │ -263 m00 = 1.0 / sqrt(1.0 + m01*m01); │ │ │ │ │ -264 m01 *= m00; │ │ │ │ │ -265 } │ │ │ │ │ -266 else { │ │ │ │ │ -267 m00 /= m01; │ │ │ │ │ -268 m01 = 1.0 / sqrt(1.0 + m00*m00); │ │ │ │ │ -269 m00 *= m01; │ │ │ │ │ -270 } │ │ │ │ │ -271 evec1 = m01*u - m00*v; │ │ │ │ │ -272 } │ │ │ │ │ -273 else │ │ │ │ │ -274 evec1 = u; │ │ │ │ │ -275 } │ │ │ │ │ -276 else { │ │ │ │ │ -277 auto maxAbsComp = max(absM11, absM01); │ │ │ │ │ -278 if(maxAbsComp > 0.0) { │ │ │ │ │ -279 if(absM11 >= absM01) { │ │ │ │ │ -280 m01 /= m11; │ │ │ │ │ -281 m11 = 1.0 / sqrt(1.0 + m01*m01); │ │ │ │ │ -282 m01 *= m11; │ │ │ │ │ -283 } │ │ │ │ │ -284 else { │ │ │ │ │ -285 m11 /= m01; │ │ │ │ │ -286 m01 = 1.0 / sqrt(1.0 + m11*m11); │ │ │ │ │ -287 m11 *= m01; │ │ │ │ │ -288 } │ │ │ │ │ -289 evec1 = m11*u - m01*v; │ │ │ │ │ -290 } │ │ │ │ │ -291 else │ │ │ │ │ -292 evec1 = u; │ │ │ │ │ -293 } │ │ │ │ │ -294 } │ │ │ │ │ -295 │ │ │ │ │ -296 // 1d specialization │ │ │ │ │ -297 template │ │ │ │ │ -298 static void eigenValuesVectorsImpl(const FieldMatrix& matrix, │ │ │ │ │ -299 FieldVector& eigenValues, │ │ │ │ │ -300 FieldMatrix& eigenVectors) │ │ │ │ │ -301 { │ │ │ │ │ -302 eigenValues[0] = matrix[0][0]; │ │ │ │ │ -303 if constexpr(Tag==EigenvaluesEigenvectors) │ │ │ │ │ -304 eigenVectors[0] = {1.0}; │ │ │ │ │ -305 } │ │ │ │ │ -306 │ │ │ │ │ -307 │ │ │ │ │ -308 // 2d specialization │ │ │ │ │ -309 template │ │ │ │ │ -310 static void eigenValuesVectorsImpl(const FieldMatrix& matrix, │ │ │ │ │ -311 FieldVector& eigenValues, │ │ │ │ │ -312 FieldMatrix& eigenVectors) │ │ │ │ │ -313 { │ │ │ │ │ -314 // Compute eigen values │ │ │ │ │ -315 Impl::eigenValues2dImpl(matrix, eigenValues); │ │ │ │ │ -316 │ │ │ │ │ -317 // Compute eigenvectors by exploiting the Cayley–Hamilton theorem. │ │ │ │ │ -318 // If λ_1, λ_2 are the eigenvalues, then (A - λ_1I )(A - λ_2I ) = (A - │ │ │ │ │ -λ_2I )(A - λ_1I ) = 0, │ │ │ │ │ -319 // so the columns of (A - λ_2I ) are annihilated by (A - λ_1I ) and vice │ │ │ │ │ -versa. │ │ │ │ │ -320 // Assuming neither matrix is zero, the columns of each must include │ │ │ │ │ -eigenvectors │ │ │ │ │ -321 // for the other eigenvalue. (If either matrix is zero, then A is a │ │ │ │ │ -multiple of the │ │ │ │ │ -322 // identity and any non-zero vector is an eigenvector.) │ │ │ │ │ -323 // From: https://en.wikipedia.org/wiki/Eigenvalue_algorithm#2x2_matrices │ │ │ │ │ -324 if constexpr(Tag==EigenvaluesEigenvectors) { │ │ │ │ │ -325 │ │ │ │ │ -326 // Special casing for multiples of the identity │ │ │ │ │ -327 FieldMatrix temp = matrix; │ │ │ │ │ -328 temp[0][0] -= eigenValues[0]; │ │ │ │ │ -329 temp[1][1] -= eigenValues[0]; │ │ │ │ │ -330 if(temp.infinity_norm() <= 1e-14) { │ │ │ │ │ -331 eigenVectors[0] = {1.0, 0.0}; │ │ │ │ │ -332 eigenVectors[1] = {0.0, 1.0}; │ │ │ │ │ -333 } │ │ │ │ │ -334 else { │ │ │ │ │ -335 // The columns of A - λ_2I are eigenvectors for λ_1, or zero. │ │ │ │ │ -336 // Take the column with the larger norm to avoid zero columns. │ │ │ │ │ -337 FieldVector ev0 = {matrix[0][0]-eigenValues[1], matrix[1][0]}; │ │ │ │ │ -338 FieldVector ev1 = {matrix[0][1], matrix[1][1]-eigenValues[1]}; │ │ │ │ │ -339 eigenVectors[0] = (ev0.two_norm2() >= ev1.two_norm2()) ? ev0/ev0.two_norm() │ │ │ │ │ -: ev1/ev1.two_norm(); │ │ │ │ │ -340 │ │ │ │ │ -341 // The columns of A - λ_1I are eigenvectors for λ_2, or zero. │ │ │ │ │ -342 // Take the column with the larger norm to avoid zero columns. │ │ │ │ │ -343 ev0 = {matrix[0][0]-eigenValues[0], matrix[1][0]}; │ │ │ │ │ -344 ev1 = {matrix[0][1], matrix[1][1]-eigenValues[0]}; │ │ │ │ │ -345 eigenVectors[1] = (ev0.two_norm2() >= ev1.two_norm2()) ? ev0/ev0.two_norm() │ │ │ │ │ -: ev1/ev1.two_norm(); │ │ │ │ │ -346 } │ │ │ │ │ -347 } │ │ │ │ │ -348 } │ │ │ │ │ -349 │ │ │ │ │ -350 // 3d specialization │ │ │ │ │ -351 template │ │ │ │ │ -352 static void eigenValuesVectorsImpl(const FieldMatrix& matrix, │ │ │ │ │ -353 FieldVector& eigenValues, │ │ │ │ │ -354 FieldMatrix& eigenVectors) │ │ │ │ │ -355 { │ │ │ │ │ -356 using Vector = FieldVector; │ │ │ │ │ -357 using Matrix = FieldMatrix; │ │ │ │ │ -358 │ │ │ │ │ -359 //compute eigenvalues │ │ │ │ │ -360 /* Precondition the matrix by factoring out the maximum absolute │ │ │ │ │ -361 value of the components. This guards against floating-point │ │ │ │ │ -362 overflow when computing the eigenvalues.*/ │ │ │ │ │ -363 using std::isnormal; │ │ │ │ │ -364 K maxAbsElement = (isnormal(matrix.infinity_norm())) ? matrix.infinity_norm │ │ │ │ │ -() : K(1.0); │ │ │ │ │ -365 Matrix scaledMatrix = matrix / maxAbsElement; │ │ │ │ │ -366 K r = Impl::eigenValues3dImpl(scaledMatrix, eigenValues); │ │ │ │ │ -367 │ │ │ │ │ -368 if constexpr(Tag==EigenvaluesEigenvectors) { │ │ │ │ │ -369 K offDiagNorm = Vector{scaledMatrix[0][1],scaledMatrix[0][2],scaledMatrix │ │ │ │ │ -[1][2]}.two_norm2(); │ │ │ │ │ -370 if (offDiagNorm <= std::numeric_limits::epsilon()) │ │ │ │ │ -371 { │ │ │ │ │ -372 eigenValues = {scaledMatrix[0][0], scaledMatrix[1][1], scaledMatrix[2][2]}; │ │ │ │ │ -373 eigenVectors = {{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}}; │ │ │ │ │ -374 │ │ │ │ │ -375 // Use bubble sort to jointly sort eigenvalues and eigenvectors │ │ │ │ │ -376 // such that eigenvalues are ascending │ │ │ │ │ -377 if (eigenValues[0] > eigenValues[1]) │ │ │ │ │ -378 { │ │ │ │ │ -379 std::swap(eigenValues[0], eigenValues[1]); │ │ │ │ │ -380 std::swap(eigenVectors[0], eigenVectors[1]); │ │ │ │ │ -381 } │ │ │ │ │ -382 if (eigenValues[1] > eigenValues[2]) │ │ │ │ │ -383 { │ │ │ │ │ -384 std::swap(eigenValues[1], eigenValues[2]); │ │ │ │ │ -385 std::swap(eigenVectors[1], eigenVectors[2]); │ │ │ │ │ -386 } │ │ │ │ │ -387 if (eigenValues[0] > eigenValues[1]) │ │ │ │ │ -388 { │ │ │ │ │ -389 std::swap(eigenValues[0], eigenValues[1]); │ │ │ │ │ -390 std::swap(eigenVectors[0], eigenVectors[1]); │ │ │ │ │ -391 } │ │ │ │ │ -392 } │ │ │ │ │ -393 else { │ │ │ │ │ -394 /*Compute the eigenvectors so that the set │ │ │ │ │ -395 [evec[0], evec[1], evec[2]] is right handed and │ │ │ │ │ -396 orthonormal. */ │ │ │ │ │ -397 │ │ │ │ │ -398 Matrix evec(0.0); │ │ │ │ │ -399 Vector eval(eigenValues); │ │ │ │ │ -400 if(r >= 0) { │ │ │ │ │ -401 Impl::eig0(scaledMatrix, eval[2], evec[2]); │ │ │ │ │ -402 Impl::eig1(scaledMatrix, evec[2], evec[1], eval[1]); │ │ │ │ │ -403 evec[0] = Impl::crossProduct(evec[1], evec[2]); │ │ │ │ │ -404 } │ │ │ │ │ -405 else { │ │ │ │ │ -406 Impl::eig0(scaledMatrix, eval[0], evec[0]); │ │ │ │ │ -407 Impl::eig1(scaledMatrix, evec[0], evec[1], eval[1]); │ │ │ │ │ -408 evec[2] = Impl::crossProduct(evec[0], evec[1]); │ │ │ │ │ -409 } │ │ │ │ │ -410 //sort eval/evec-pairs in ascending order │ │ │ │ │ -411 using EVPair = std::pair; │ │ │ │ │ -412 std::vector pairs; │ │ │ │ │ -413 for(std::size_t i=0; i<=2; ++i) │ │ │ │ │ -414 pairs.push_back(EVPair(eval[i], evec[i])); │ │ │ │ │ -415 auto comp = [](EVPair x, EVPair y){ return x.first < y.first; }; │ │ │ │ │ -416 std::sort(pairs.begin(), pairs.end(), comp); │ │ │ │ │ -417 for(std::size_t i=0; i<=2; ++i){ │ │ │ │ │ -418 eigenValues[i] = pairs[i].first; │ │ │ │ │ -419 eigenVectors[i] = pairs[i].second; │ │ │ │ │ -420 } │ │ │ │ │ -421 } │ │ │ │ │ -422 } │ │ │ │ │ -423 //The preconditioning scaled the matrix, which scales the eigenvalues. │ │ │ │ │ -Revert the scaling. │ │ │ │ │ -424 eigenValues *= maxAbsElement; │ │ │ │ │ -425 } │ │ │ │ │ -426 │ │ │ │ │ -427 // forwarding to LAPACK with corresponding tag │ │ │ │ │ -428 template │ │ │ │ │ -429 static void eigenValuesVectorsLapackImpl(const FieldMatrix& │ │ │ │ │ -matrix, │ │ │ │ │ -430 FieldVector& eigenValues, │ │ │ │ │ -431 FieldMatrix& eigenVectors) │ │ │ │ │ -432 { │ │ │ │ │ -433 { │ │ │ │ │ -434#if HAVE_LAPACK │ │ │ │ │ -435 /*Lapack uses a proprietary tag to determine whether both eigenvalues and │ │ │ │ │ -436 -vectors ('v') or only eigenvalues ('n') should be calculated */ │ │ │ │ │ -437 const char jobz = "nv"[Tag]; │ │ │ │ │ -438 │ │ │ │ │ -439 const long int N = dim ; │ │ │ │ │ -440 const char uplo = 'u'; // use upper triangular matrix │ │ │ │ │ -441 │ │ │ │ │ -442 // length of matrix vector, LWORK >= max(1,3*N-1) │ │ │ │ │ -443 const long int lwork = 3*N -1 ; │ │ │ │ │ -444 │ │ │ │ │ -445 constexpr bool isKLapackType = std::is_same_v || std::is_same_ │ │ │ │ │ -v; │ │ │ │ │ -446 using LapackNumType = std::conditional_t; │ │ │ │ │ -447 │ │ │ │ │ -448 // matrix to put into dsyev │ │ │ │ │ -449 LapackNumType matrixVector[dim * dim]; │ │ │ │ │ -450 │ │ │ │ │ -451 // copy matrix │ │ │ │ │ -452 int row = 0; │ │ │ │ │ -453 for(int i=0; i │ │ │ │ │ -508 static void eigenValuesVectorsImpl(const FieldMatrix& matrix, │ │ │ │ │ -509 FieldVector& eigenValues, │ │ │ │ │ -510 FieldMatrix& eigenVectors) │ │ │ │ │ -511 { │ │ │ │ │ -512 eigenValuesVectorsLapackImpl(matrix,eigenValues,eigenVectors); │ │ │ │ │ -513 } │ │ │ │ │ -514 } //namespace Impl │ │ │ │ │ -515 │ │ │ │ │ -523 template │ │ │ │ │ -524 static void eigenValues(const FieldMatrix& matrix, │ │ │ │ │ -525 FieldVector& eigenValues) │ │ │ │ │ -526 { │ │ │ │ │ -527 Impl::EVDummy dummy; │ │ │ │ │ -528 Impl::eigenValuesVectorsImpl(matrix, │ │ │ │ │ -eigenValues, dummy); │ │ │ │ │ -529 } │ │ │ │ │ -530 │ │ │ │ │ -539 template │ │ │ │ │ -540 static void eigenValuesVectors(const FieldMatrix& matrix, │ │ │ │ │ -541 FieldVector& eigenValues, │ │ │ │ │ -542 FieldMatrix& eigenVectors) │ │ │ │ │ -543 { │ │ │ │ │ -544 Impl::eigenValuesVectorsImpl(matrix, │ │ │ │ │ -eigenValues, eigenVectors); │ │ │ │ │ -545 } │ │ │ │ │ -546 │ │ │ │ │ -554 template │ │ │ │ │ -555 static void eigenValuesLapack(const FieldMatrix& matrix, │ │ │ │ │ -556 FieldVector& eigenValues) │ │ │ │ │ -557 { │ │ │ │ │ -558 Impl::EVDummy dummy; │ │ │ │ │ -559 Impl::eigenValuesVectorsLapackImpl │ │ │ │ │ -(matrix, eigenValues, dummy); │ │ │ │ │ -560 } │ │ │ │ │ -561 │ │ │ │ │ -570 template │ │ │ │ │ -571 static void eigenValuesVectorsLapack(const FieldMatrix& │ │ │ │ │ -matrix, │ │ │ │ │ -572 FieldVector& eigenValues, │ │ │ │ │ -573 FieldMatrix& eigenVectors) │ │ │ │ │ -574 { │ │ │ │ │ -575 Impl::eigenValuesVectorsLapackImpl │ │ │ │ │ -(matrix, eigenValues, eigenVectors); │ │ │ │ │ -576 } │ │ │ │ │ -577 │ │ │ │ │ -585 template │ │ │ │ │ -586 static void eigenValuesNonSym(const FieldMatrix& matrix, │ │ │ │ │ -587 FieldVector& eigenValues) │ │ │ │ │ -588 { │ │ │ │ │ -589#if HAVE_LAPACK │ │ │ │ │ -590 { │ │ │ │ │ -591 const long int N = dim ; │ │ │ │ │ -592 const char jobvl = 'n'; │ │ │ │ │ -593 const char jobvr = 'n'; │ │ │ │ │ -594 │ │ │ │ │ -595 constexpr bool isKLapackType = std::is_same_v || std::is_same_ │ │ │ │ │ -v; │ │ │ │ │ -596 using LapackNumType = std::conditional_t; │ │ │ │ │ -597 │ │ │ │ │ -598 // matrix to put into dgeev │ │ │ │ │ -599 LapackNumType matrixVector[dim * dim]; │ │ │ │ │ -600 │ │ │ │ │ -601 // copy matrix │ │ │ │ │ -602 int row = 0; │ │ │ │ │ -603 for(int i=0; i &matrix, │ │ │ │ │ -FieldVector< C, dim > &eigenValues) │ │ │ │ │ -calculates the eigenvalues of a non-symmetric field matrix │ │ │ │ │ -Definition fmatrixev.hh:586 │ │ │ │ │ -Dune::FMatrixHelp::eigenValues │ │ │ │ │ -static void eigenValues(const FieldMatrix< K, dim, dim > &matrix, FieldVector< │ │ │ │ │ -K, dim > &eigenValues) │ │ │ │ │ -calculates the eigenvalues of a symmetric field matrix │ │ │ │ │ -Definition fmatrixev.hh:524 │ │ │ │ │ -Dune::FMatrixHelp::eigenValuesLapack │ │ │ │ │ -static void eigenValuesLapack(const FieldMatrix< K, dim, dim > &matrix, │ │ │ │ │ -FieldVector< K, dim > &eigenValues) │ │ │ │ │ -calculates the eigenvalues of a symmetric field matrix │ │ │ │ │ -Definition fmatrixev.hh:555 │ │ │ │ │ -Dune::FMatrixHelp::eigenValuesVectors │ │ │ │ │ -static void eigenValuesVectors(const FieldMatrix< K, dim, dim > &matrix, │ │ │ │ │ -FieldVector< K, dim > &eigenValues, FieldMatrix< K, dim, dim > &eigenVectors) │ │ │ │ │ -calculates the eigenvalues and eigenvectors of a symmetric field matrix │ │ │ │ │ -Definition fmatrixev.hh:540 │ │ │ │ │ -Dune::FMatrixHelp::eigenValuesVectorsLapack │ │ │ │ │ -static void eigenValuesVectorsLapack(const FieldMatrix< K, dim, dim > &matrix, │ │ │ │ │ -FieldVector< K, dim > &eigenValues, FieldMatrix< K, dim, dim > &eigenVectors) │ │ │ │ │ -calculates the eigenvalues and -vectors of a symmetric field matrix │ │ │ │ │ -Definition fmatrixev.hh:571 │ │ │ │ │ -Dune::FieldMatrix │ │ │ │ │ -A dense n x m matrix. │ │ │ │ │ -Definition fmatrix.hh:117 │ │ │ │ │ -Dune::FieldVector │ │ │ │ │ -vector space out of a tensor product of fields. │ │ │ │ │ -Definition fvector.hh:91 │ │ │ │ │ -Dune::NotImplemented │ │ │ │ │ -Default exception for dummy implementations. │ │ │ │ │ -Definition exceptions.hh:263 │ │ │ │ │ -Dune::InvalidStateException │ │ │ │ │ -Default exception if a function was called while the object is not in a valid │ │ │ │ │ -state for that function... │ │ │ │ │ -Definition exceptions.hh:281 │ │ │ │ │ -Dune::FieldTraits::real_type │ │ │ │ │ -T real_type │ │ │ │ │ -export the type representing the real type of the field │ │ │ │ │ -Definition ftraits.hh:30 │ │ │ │ │ -Dune::StandardMathematicalConstants<_Field_>::pi │ │ │ │ │ -static const Field pi() │ │ │ │ │ -Archimedes' constant. │ │ │ │ │ -Definition math.hh:48 │ │ │ │ │ +139} // end namespace Dune::Std │ │ │ │ │ +140 │ │ │ │ │ +141#endif // DUNE_COMMON_STD_LAYOUT_RIGHT_HH │ │ │ │ │ +indices.hh │ │ │ │ │ +fwd_layouts.hh │ │ │ │ │ +Dune::Std │ │ │ │ │ +Namespace for features backported from new C++ standards. │ │ │ │ │ +Definition default_accessor.hh:10 │ │ │ │ │ +Dune::Std::layout_left::mapping │ │ │ │ │ +A layout mapping where the leftmost extent has stride 1. │ │ │ │ │ +Definition layout_left.hh:19 │ │ │ │ │ +Dune::Std::layout_right │ │ │ │ │ +A layout where the rightmost extent has stride 1, and strides increase right- │ │ │ │ │ +to-left as the product o... │ │ │ │ │ +Definition fwd_layouts.hh:30 │ │ │ │ │ +Dune::Std::layout_right::mapping │ │ │ │ │ +A layout mapping where the rightmost extent has stride 1. │ │ │ │ │ +Definition layout_right.hh:19 │ │ │ │ │ +Dune::Std::layout_right::mapping::extents │ │ │ │ │ +constexpr const extents_type & extents() const noexcept │ │ │ │ │ +Definition layout_right.hh:85 │ │ │ │ │ +Dune::Std::layout_right::mapping::operator() │ │ │ │ │ +constexpr index_type operator()() const noexcept │ │ │ │ │ +The default offset for rank-0 tensors is 0. │ │ │ │ │ +Definition layout_right.hh:104 │ │ │ │ │ +Dune::Std::layout_right::mapping::operator= │ │ │ │ │ +constexpr mapping & operator=(const mapping &) noexcept=default │ │ │ │ │ +Copy-assignment for the mapping. │ │ │ │ │ +Dune::Std::layout_right::mapping::required_span_size │ │ │ │ │ +constexpr index_type required_span_size() const noexcept │ │ │ │ │ +Definition layout_right.hh:86 │ │ │ │ │ +Dune::Std::layout_right::mapping::mapping │ │ │ │ │ +constexpr mapping() noexcept=default │ │ │ │ │ +The default construction is possible for default constructible extents. │ │ │ │ │ +Dune::Std::layout_right::mapping::size_type │ │ │ │ │ +typename extents_type::size_type size_type │ │ │ │ │ +Definition layout_right.hh:24 │ │ │ │ │ +Dune::Std::layout_right::mapping::extents_type │ │ │ │ │ +Extents extents_type │ │ │ │ │ +Definition layout_right.hh:23 │ │ │ │ │ +Dune::Std::layout_right::mapping::is_always_unique │ │ │ │ │ +static constexpr bool is_always_unique() noexcept │ │ │ │ │ +Definition layout_right.hh:109 │ │ │ │ │ +Dune::Std::layout_right::mapping::stride │ │ │ │ │ +constexpr index_type stride(rank_type i) const noexcept │ │ │ │ │ +The stride is the product of the extents E(n)*E(n-1)*...*E(i+1) │ │ │ │ │ +Definition layout_right.hh:120 │ │ │ │ │ +Dune::Std::layout_right::mapping::is_exhaustive │ │ │ │ │ +static constexpr bool is_exhaustive() noexcept │ │ │ │ │ +Definition layout_right.hh:114 │ │ │ │ │ +Dune::Std::layout_right::mapping::mapping │ │ │ │ │ +constexpr mapping(const layout_left::mapping< OtherExtents > &m) noexcept │ │ │ │ │ +Construct the mapping from a layout_left. │ │ │ │ │ +Definition layout_right.hh:57 │ │ │ │ │ +Dune::Std::layout_right::mapping::is_strided │ │ │ │ │ +static constexpr bool is_strided() noexcept │ │ │ │ │ +Definition layout_right.hh:115 │ │ │ │ │ +Dune::Std::layout_right::mapping::rank_type │ │ │ │ │ +typename extents_type::rank_type rank_type │ │ │ │ │ +Definition layout_right.hh:25 │ │ │ │ │ +Dune::Std::layout_right::mapping::is_always_strided │ │ │ │ │ +static constexpr bool is_always_strided() noexcept │ │ │ │ │ +Definition layout_right.hh:111 │ │ │ │ │ +Dune::Std::layout_right::mapping::is_unique │ │ │ │ │ +static constexpr bool is_unique() noexcept │ │ │ │ │ +Definition layout_right.hh:113 │ │ │ │ │ +Dune::Std::layout_right::mapping::operator== │ │ │ │ │ +friend constexpr bool operator==(const mapping &a, const mapping< OtherExtents │ │ │ │ │ +> &b) noexcept │ │ │ │ │ +Definition layout_right.hh:130 │ │ │ │ │ +Dune::Std::layout_right::mapping::is_always_exhaustive │ │ │ │ │ +static constexpr bool is_always_exhaustive() noexcept │ │ │ │ │ +Definition layout_right.hh:110 │ │ │ │ │ +Dune::Std::layout_right::mapping::index_type │ │ │ │ │ +typename extents_type::index_type index_type │ │ │ │ │ +Definition layout_right.hh:26 │ │ │ │ │ +Dune::Std::layout_stride::mapping │ │ │ │ │ +A layout mapping where the strides are user-defined. │ │ │ │ │ +Definition layout_stride.hh:19 │ │ │ │ │ +Dune::Std::layout_stride::mapping::extents │ │ │ │ │ +constexpr const extents_type & extents() const noexcept │ │ │ │ │ +Definition layout_stride.hh:85 │ │ │ │ │ +Dune::Std::layout_stride::mapping::strides │ │ │ │ │ +constexpr const strides_type & strides() const noexcept │ │ │ │ │ +Get the array of all strides. │ │ │ │ │ +Definition layout_stride.hh:127 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00074.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: hybridutilities.hh File Reference │ │ │ │ +dune-common: mdspan.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,122 +65,77 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ Namespaces | │ │ │ │ -Functions | │ │ │ │ -Variables
│ │ │ │ -
hybridutilities.hh File Reference
│ │ │ │ +Functions
│ │ │ │ +
mdspan.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ -
#include <tuple>
│ │ │ │ +
#include <array>
│ │ │ │ +#include <type_traits>
│ │ │ │ #include <utility>
│ │ │ │ -#include <dune/common/typetraits.hh>
│ │ │ │ -#include <dune/common/typeutilities.hh>
│ │ │ │ -#include <dune/common/fvector.hh>
│ │ │ │ -#include <dune/common/indices.hh>
│ │ │ │ -#include <dune/common/rangeutilities.hh>
│ │ │ │ +#include <dune/common/indices.hh>
│ │ │ │ +#include <dune/common/std/default_accessor.hh>
│ │ │ │ +#include <dune/common/std/extents.hh>
│ │ │ │ +#include <dune/common/std/layout_right.hh>
│ │ │ │ +#include <dune/common/std/span.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::Hybrid::HybridFunctor< Functor >
 Adapter of a hybrid functor that maintains results hybrid. More...
class  Dune::Std::mdspan< Element, Extents, LayoutPolicy, AccessorPolicy >
 A multi-dimensional non-owning array view. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::Hybrid
namespace  Dune::Std
 Namespace for features backported from new C++ standards.
 
│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ Functions

template<class T >
constexpr auto Dune::Hybrid::size (const T &t)
 Size query.
 
template<class Container , class Index >
constexpr decltype(auto) Dune::Hybrid::elementAt (Container &&c, Index &&i)
 Get element at given position from container.
 
template<class Begin , class End >
constexpr auto Dune::Hybrid::integralRange (const Begin &begin, const End &end)
 Create an integral range.
 
template<class End >
constexpr auto Dune::Hybrid::integralRange (const End &end)
 Create an integral range starting from 0.
 
template<class Range , class F >
constexpr void Dune::Hybrid::forEach (Range &&range, F &&f)
 Range based for loop.
 
template<class Range , class T , class F >
constexpr T Dune::Hybrid::accumulate (Range &&range, T value, F &&f)
 Accumulate values.
 
template<class Condition , class IfFunc , class ElseFunc >
decltype(auto) Dune::Hybrid::ifElse (const Condition &condition, IfFunc &&ifFunc, ElseFunc &&elseFunc)
 A conditional expression.
 
template<class Condition , class IfFunc >
void Dune::Hybrid::ifElse (const Condition &condition, IfFunc &&ifFunc)
 A conditional expression.
 
template<class Functor >
constexpr HybridFunctor< Functor > Dune::Hybrid::hybridFunctor (const Functor &)
 Returns an HybridFunctor adaptor.
 
template<class T1 , class T2 >
constexpr auto Dune::Hybrid::equals (T1 &&t1, T2 &&t2)
 Equality comparison.
 
template<class Cases , class Value , class Branches , class ElseBranch >
constexpr decltype(auto) Dune::Hybrid::switchCases (const Cases &cases, const Value &value, Branches &&branches, ElseBranch &&elseBranch)
 Switch statement.
 
template<class Cases , class Value , class Branches >
constexpr void Dune::Hybrid::switchCases (const Cases &cases, const Value &value, Branches &&branches)
 Switch statement.
 
template<class T , class Value , class Branches >
constexpr void Dune::Hybrid::switchCases (IntegralRange< T > range, const Value &value, Branches &&branches)
 Switch statement.
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ -Variables

constexpr auto Dune::Hybrid::max = hybridFunctor(Impl::Max{})
 Function object that returns the greater of the given values.
 
constexpr auto Dune::Hybrid::min = hybridFunctor(Impl::Min{})
 Function object that returns the smaller of the given values.
 
constexpr auto Dune::Hybrid::plus = hybridFunctor(std::plus<>{})
 Function object for performing addition.
 
constexpr auto Dune::Hybrid::minus = hybridFunctor(std::minus<>{})
 Function object for performing subtraction.
 
constexpr auto Dune::Hybrid::equal_to = hybridFunctor(std::equal_to<>{})
 Function object for performing equality comparison.
 
template<class CArray , std::enable_if_t< std::is_array_v< CArray >, int > = 0, std::enable_if_t<(std::rank_v< CArray >==1), int > = 0>
 Dune::Std::mdspan (CArray &) -> mdspan< std::remove_all_extents_t< CArray >, Std::extents< std::size_t, std::extent_v< CArray, 0 > > >
 
template<class Pointer , std::enable_if_t< std::is_pointer_v< std::remove_reference_t< Pointer > >, int > = 0>
 Dune::Std::mdspan (Pointer &&) -> mdspan< std::remove_pointer_t< std::remove_reference_t< Pointer > >, Std::extents< std::size_t > >
 
template<class ElementType , class... II, std::enable_if_t<(... &&std::is_convertible_v< II, std::size_t >), int > = 0, std::enable_if_t<(sizeof...(II) > 0), int > = 0>
 Dune::Std::mdspan (ElementType *, II...) -> mdspan< ElementType, Std::dextents< std::size_t, sizeof...(II)> >
 
template<class ElementType , class SizeType , std::size_t N>
 Dune::Std::mdspan (ElementType *, Std::span< SizeType, N > &) -> mdspan< ElementType, Std::dextents< std::size_t, N > >
 
template<class ElementType , class SizeType , std::size_t N>
 Dune::Std::mdspan (ElementType *, const std::array< SizeType, N > &) -> mdspan< ElementType, Std::dextents< std::size_t, N > >
 
template<class ElementType , class IndexType , std::size_t... exts>
 Dune::Std::mdspan (ElementType *, const Std::extents< IndexType, exts... > &) -> mdspan< ElementType, Std::extents< IndexType, exts... > >
 
template<class ElementType , class Mapping , class Extents = typename Mapping::extents_type, class Layout = typename Mapping::layout_type>
 Dune::Std::mdspan (ElementType *, const Mapping &) -> mdspan< ElementType, Extents, Layout >
 
template<class Mapping , class Accessor , class DataHandle = typename Accessor::data_handle_type, class Element = typename Accessor::element_type, class Extents = typename Mapping::extents_type, class Layout = typename Mapping::layout_type>
 Dune::Std::mdspan (const DataHandle &, const Mapping &, const Accessor &) -> mdspan< Element, Extents, Layout, Accessor >
 
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,113 +1,72 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Functions | Variables │ │ │ │ │ -hybridutilities.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ + * std │ │ │ │ │ +Classes | Namespaces | Functions │ │ │ │ │ +mdspan.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class   Dune::Hybrid::HybridFunctor<_Functor_> │ │ │ │ │ -  Adapter of a hybrid functor that maintains results hybrid. More... │ │ │ │ │ +class   Dune::Std::mdspan<_Element,_Extents,_LayoutPolicy,_AccessorPolicy_> │ │ │ │ │ +  A multi-dimensional non-owning array view. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -namespace   Dune::Hybrid │ │ │ │ │ +namespace   Dune::Std │ │ │ │ │ +  Namespace for features backported from new C++ standards. │ │ │ │ │   │ │ │ │ │ Functions │ │ │ │ │ -template │ │ │ │ │ - constexpr auto  Dune::Hybrid::size (const T &t) │ │ │ │ │ -  Size query. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - constexpr decltype(auto)  Dune::Hybrid::elementAt (Container &&c, │ │ │ │ │ - Index &&i) │ │ │ │ │ -  Get element at given position from │ │ │ │ │ - container. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - constexpr auto  Dune::Hybrid::integralRange (const Begin │ │ │ │ │ - &begin, const End &end) │ │ │ │ │ -  Create an integral range. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - constexpr auto  Dune::Hybrid::integralRange (const End │ │ │ │ │ - &end) │ │ │ │ │ -  Create an integral range starting from 0. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - constexpr void  Dune::Hybrid::forEach (Range &&range, F │ │ │ │ │ - &&f) │ │ │ │ │ -  Range based for loop. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - constexpr T  Dune::Hybrid::accumulate (Range &&range, T │ │ │ │ │ - value, F &&f) │ │ │ │ │ -  Accumulate values. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - decltype(auto)  Dune::Hybrid::ifElse (const Condition │ │ │ │ │ - &condition, IfFunc &&ifFunc, ElseFunc │ │ │ │ │ - &&elseFunc) │ │ │ │ │ -  A conditional expression. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - void  Dune::Hybrid::ifElse (const Condition │ │ │ │ │ - &condition, IfFunc &&ifFunc) │ │ │ │ │ -  A conditional expression. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -constexpr HybridFunctor< Functor >  Dune::Hybrid::hybridFunctor (const Functor │ │ │ │ │ - &) │ │ │ │ │ -  Returns an HybridFunctor adaptor. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - constexpr auto  Dune::Hybrid::equals (T1 &&t1, T2 &&t2) │ │ │ │ │ -  Equality comparison. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - constexpr decltype(auto)  Dune::Hybrid::switchCases (const Cases │ │ │ │ │ - &cases, const Value &value, Branches │ │ │ │ │ - &&branches, ElseBranch &&elseBranch) │ │ │ │ │ -  Switch statement. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - constexpr void  Dune::Hybrid::switchCases (const Cases │ │ │ │ │ - &cases, const Value &value, Branches │ │ │ │ │ - &&branches) │ │ │ │ │ -  Switch statement. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - constexpr void  Dune::Hybrid::switchCases (IntegralRange< T │ │ │ │ │ - > range, const Value &value, Branches │ │ │ │ │ - &&branches) │ │ │ │ │ -  Switch statement. │ │ │ │ │ -  │ │ │ │ │ -Variables │ │ │ │ │ -constexpr auto  Dune::Hybrid::max = hybridFunctor(Impl::Max{}) │ │ │ │ │ -  Function object that returns the greater of the given values. │ │ │ │ │ -  │ │ │ │ │ -constexpr auto  Dune::Hybrid::min = hybridFunctor(Impl::Min{}) │ │ │ │ │ -  Function object that returns the smaller of the given values. │ │ │ │ │ -  │ │ │ │ │ -constexpr auto  Dune::Hybrid::plus = hybridFunctor(std::plus<>{}) │ │ │ │ │ -  Function object for performing addition. │ │ │ │ │ -  │ │ │ │ │ -constexpr auto  Dune::Hybrid::minus = hybridFunctor(std::minus<>{}) │ │ │ │ │ -  Function object for performing subtraction. │ │ │ │ │ -  │ │ │ │ │ -constexpr auto  Dune::Hybrid::equal_to = hybridFunctor(std::equal_to<>{}) │ │ │ │ │ -  Function object for performing equality comparison. │ │ │ │ │ +template, int > = 0, │ │ │ │ │ +std::enable_if_t<(std::rank_v< CArray >==1), int > = 0> │ │ │ │ │ +  Dune::Std::mdspan (CArray &) -> mdspan< std::remove_all_extents_t< CArray >, │ │ │ │ │ + Std::extents< std::size_t, std::extent_v< CArray, 0 > > > │ │ │ │ │ +  │ │ │ │ │ +template >, int > = 0> │ │ │ │ │ +  Dune::Std::mdspan (Pointer &&) -> mdspan< std::remove_pointer_t< std::remove_ │ │ │ │ │ + reference_t< Pointer > >, Std::extents< std::size_t > > │ │ │ │ │ +  │ │ │ │ │ +template), int > = 0, std::enable_if_t<(sizeof...(II) > │ │ │ │ │ +0), int > = 0> │ │ │ │ │ +  Dune::Std::mdspan (ElementType *, II...) -> mdspan< ElementType, Std:: │ │ │ │ │ + dextents< std::size_t, sizeof...(II)> > │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +  Dune::Std::mdspan (ElementType *, Std::span< SizeType, N > &) -> mdspan< │ │ │ │ │ + ElementType, Std::dextents< std::size_t, N > > │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +  Dune::Std::mdspan (ElementType *, const std::array< SizeType, N > &) - │ │ │ │ │ + > mdspan< ElementType, Std::dextents< std::size_t, N > > │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +  Dune::Std::mdspan (ElementType *, const Std::extents< IndexType, exts... > &) │ │ │ │ │ + -> mdspan< ElementType, Std::extents< IndexType, exts... > > │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +  Dune::Std::mdspan (ElementType *, const Mapping &) -> mdspan< ElementType, │ │ │ │ │ + Extents, Layout > │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +  Dune::Std::mdspan (const DataHandle &, const Mapping &, const Accessor &) - │ │ │ │ │ + > mdspan< Element, Extents, Layout, Accessor > │ │ │ │ │   │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00074_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: hybridutilities.hh Source File │ │ │ │ +dune-common: mdspan.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,466 +70,395 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
hybridutilities.hh
│ │ │ │ +
mdspan.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_COMMON_HYBRIDUTILITIES_HH
│ │ │ │ -
6#define DUNE_COMMON_HYBRIDUTILITIES_HH
│ │ │ │ +
5#ifndef DUNE_COMMON_STD_MDSPAN_HH
│ │ │ │ +
6#define DUNE_COMMON_STD_MDSPAN_HH
│ │ │ │
7
│ │ │ │ -
8#include <tuple>
│ │ │ │ -
9#include <utility>
│ │ │ │ -
10
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
16
│ │ │ │ -
17
│ │ │ │ -
18
│ │ │ │ -
19namespace Dune {
│ │ │ │ -
│ │ │ │ -
20namespace Hybrid {
│ │ │ │ -
21
│ │ │ │ -
22namespace Impl {
│ │ │ │ -
23
│ │ │ │ -
24 // Try if std::tuple_size is implemented for class
│ │ │ │ -
25 template<class T>
│ │ │ │ -
26 constexpr auto size(const T&, const PriorityTag<2>&)
│ │ │ │ -
27 -> decltype(std::integral_constant<std::size_t,std::tuple_size<T>::value>())
│ │ │ │ -
28 {
│ │ │ │ -
29 return {};
│ │ │ │ -
30 }
│ │ │ │ -
31
│ │ │ │ -
32 // Try if there's a static constexpr size() method
│ │ │ │ -
33 template<class T>
│ │ │ │ -
34 constexpr auto size(const T&, const PriorityTag<1>&)
│ │ │ │ -
35 -> decltype(std::integral_constant<std::size_t,T::size()>())
│ │ │ │ -
36 {
│ │ │ │ -
37 return {};
│ │ │ │ -
38 }
│ │ │ │ -
39
│ │ │ │ -
40 // As a last resort try if there's a non-static size()
│ │ │ │ -
41 template<class T>
│ │ │ │ -
42 constexpr auto size(const T& t, const PriorityTag<0>&)
│ │ │ │ -
43 {
│ │ │ │ -
44 return t.size();
│ │ │ │ -
45 }
│ │ │ │ -
46
│ │ │ │ -
47} // namespace Impl
│ │ │ │ -
48
│ │ │ │ -
49
│ │ │ │ -
50
│ │ │ │ -
72template<class T>
│ │ │ │ -
│ │ │ │ -
73constexpr auto size(const T& t)
│ │ │ │ -
74{
│ │ │ │ -
75 return Impl::size(t, PriorityTag<42>());
│ │ │ │ -
76}
│ │ │ │ -
│ │ │ │ -
77
│ │ │ │ -
78
│ │ │ │ -
79
│ │ │ │ -
80namespace Impl {
│ │ │ │ -
81
│ │ │ │ -
82 template<class Container, class Index,
│ │ │ │ -
83 std::enable_if_t<IsTuple<std::decay_t<Container>>::value, int> = 0>
│ │ │ │ -
84 constexpr decltype(auto) elementAt(Container&& c, Index&&, PriorityTag<2>)
│ │ │ │ -
85 {
│ │ │ │ -
86 return std::get<std::decay_t<Index>::value>(c);
│ │ │ │ -
87 }
│ │ │ │ -
88
│ │ │ │ -
89 template<class T, T... t, class Index>
│ │ │ │ -
90 constexpr decltype(auto) elementAt(std::integer_sequence<T, t...> c, Index, PriorityTag<1>)
│ │ │ │ -
91 {
│ │ │ │ -
92 return Dune::integerSequenceEntry(c, std::integral_constant<std::size_t, Index::value>());
│ │ │ │ -
93 }
│ │ │ │ +
8#include <array>
│ │ │ │ +
9#include <type_traits>
│ │ │ │ +
10#include <utility>
│ │ │ │ +
11#if __has_include(<version>)
│ │ │ │ +
12 #include <version>
│ │ │ │ +
13#endif
│ │ │ │ +
14
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
20
│ │ │ │ +
21namespace Dune::Std {
│ │ │ │ +
22
│ │ │ │ +
61template <class Element, class Extents, class LayoutPolicy = Std::layout_right,
│ │ │ │ +
62 class AccessorPolicy = Std::default_accessor<Element>>
│ │ │ │ +
│ │ │ │ +
63class mdspan
│ │ │ │ +
64{
│ │ │ │ +
65 static_assert(std::is_object_v<Element>);
│ │ │ │ +
66 static_assert(!std::is_abstract_v<Element>);
│ │ │ │ +
67 static_assert(!std::is_array_v<Element>);
│ │ │ │ +
68 static_assert(std::is_same_v<Element, typename AccessorPolicy::element_type>);
│ │ │ │ +
69
│ │ │ │ +
70public:
│ │ │ │ +
71 using element_type = Element;
│ │ │ │ +
72 using extents_type = Extents;
│ │ │ │ +
73 using layout_type = LayoutPolicy;
│ │ │ │ +
74 using accessor_type = AccessorPolicy;
│ │ │ │ +
75
│ │ │ │ +
76 using value_type = std::remove_cv_t<Element>;
│ │ │ │ +
77 using mapping_type = typename layout_type::template mapping<extents_type>;
│ │ │ │ +
78 using index_type = typename extents_type::index_type;
│ │ │ │ +
79 using size_type = typename extents_type::size_type;
│ │ │ │ +
80 using rank_type = typename extents_type::rank_type;
│ │ │ │ +
81 using data_handle_type = typename accessor_type::data_handle_type;
│ │ │ │ +
82 using reference = typename accessor_type::reference;
│ │ │ │ +
83
│ │ │ │ +
84private:
│ │ │ │ +
85 // [mdspan.layout.reqmts]
│ │ │ │ +
86 static_assert(std::is_nothrow_move_constructible_v<mapping_type>);
│ │ │ │ +
87 static_assert(std::is_nothrow_move_assignable_v<mapping_type>);
│ │ │ │ +
88 static_assert(std::is_nothrow_swappable_v<mapping_type>);
│ │ │ │ +
89
│ │ │ │ +
90 // [mdspan.accessor.reqmts]
│ │ │ │ +
91 static_assert(std::is_nothrow_move_constructible_v<accessor_type>);
│ │ │ │ +
92 static_assert(std::is_nothrow_move_assignable_v<accessor_type>);
│ │ │ │ +
93 static_assert(std::is_nothrow_swappable_v<accessor_type>);
│ │ │ │
94
│ │ │ │ -
95 template<class Container, class Index>
│ │ │ │ -
96 constexpr decltype(auto) elementAt(Container&& c, Index&& i, PriorityTag<0>)
│ │ │ │ -
97 {
│ │ │ │ -
98 return c[i];
│ │ │ │ -
99 }
│ │ │ │ -
100
│ │ │ │ -
101} // namespace Impl
│ │ │ │ -
102
│ │ │ │ -
103
│ │ │ │ -
104
│ │ │ │ -
125template<class Container, class Index>
│ │ │ │ -
│ │ │ │ -
126constexpr decltype(auto) elementAt(Container&& c, Index&& i)
│ │ │ │ -
127{
│ │ │ │ -
128 return Impl::elementAt(std::forward<Container>(c), std::forward<Index>(i), PriorityTag<42>());
│ │ │ │ -
129}
│ │ │ │ -
│ │ │ │ -
130
│ │ │ │ -
131
│ │ │ │ -
132
│ │ │ │ -
133namespace Impl {
│ │ │ │ +
95public:
│ │ │ │ +
98
│ │ │ │ +
100 template <class E = extents_type, class D = data_handle_type, class M = mapping_type, class A = accessor_type,
│ │ │ │ +
101 std::enable_if_t<(E::rank_dynamic() > 0), int> = 0,
│ │ │ │ +
102 std::enable_if_t<std::is_default_constructible_v<D>, int> = 0,
│ │ │ │ +
103 std::enable_if_t<std::is_default_constructible_v<M>, int> = 0,
│ │ │ │ +
104 std::enable_if_t<std::is_default_constructible_v<A>, int> = 0>
│ │ │ │ +
│ │ │ │ +
105 constexpr mdspan ()
│ │ │ │ +
106 : data_handle_{}
│ │ │ │ +
107 , mapping_{}
│ │ │ │ +
108 , accessor_{}
│ │ │ │ +
109 {}
│ │ │ │ +
│ │ │ │ +
110
│ │ │ │ +
112 template <class... IndexTypes,
│ │ │ │ +
113 class E = extents_type, class M = mapping_type, class A = accessor_type,
│ │ │ │ +
114 std::enable_if_t<(sizeof...(IndexTypes) == E::rank() || sizeof...(IndexTypes) == E::rank_dynamic()), int> = 0,
│ │ │ │ +
115 std::enable_if_t<(... && std::is_convertible_v<IndexTypes, index_type>), int> = 0,
│ │ │ │ +
116 std::enable_if_t<(... && std::is_nothrow_constructible_v<index_type, IndexTypes>), int> = 0,
│ │ │ │ +
117 std::enable_if_t<std::is_constructible_v<M, E>, int> = 0,
│ │ │ │ +
118 std::enable_if_t<std::is_default_constructible_v<A>, int> = 0>
│ │ │ │ +
│ │ │ │ +
119 explicit constexpr mdspan (data_handle_type p, IndexTypes... exts)
│ │ │ │ +
120 : mdspan(std::move(p), extents_type(index_type(std::move(exts))...))
│ │ │ │ +
121 {}
│ │ │ │ +
│ │ │ │ +
122
│ │ │ │ +
124 template <class IndexType, std::size_t N,
│ │ │ │ +
125 std::enable_if_t<std::is_convertible_v<const IndexType&, index_type>, int> = 0,
│ │ │ │ +
126 std::enable_if_t<std::is_nothrow_constructible_v<index_type,const IndexType&>, int> = 0,
│ │ │ │ +
127 std::enable_if_t<(N == extents_type::rank_dynamic() || N == extents_type::rank()), int> = 0>
│ │ │ │ +
128 #if __cpp_conditional_explicit >= 201806L
│ │ │ │ +
129 explicit(N != extents_type::rank_dynamic())
│ │ │ │ +
130 #endif
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
132 : mdspan(std::move(p), extents_type(exts))
│ │ │ │ +
133 {}
│ │ │ │ +
│ │ │ │
134
│ │ │ │ -
135 template<class Begin, class End,
│ │ │ │ -
136 std::enable_if_t<IsIntegralConstant<Begin>::value and IsIntegralConstant<End>::value, int> = 0>
│ │ │ │ -
137 constexpr auto integralRange(const Begin& /*begin*/, const End& /*end*/, const PriorityTag<1>&)
│ │ │ │ -
138 {
│ │ │ │ -
139 static_assert(Begin::value <= End::value, "You cannot create an integralRange where end<begin");
│ │ │ │ - │ │ │ │ -
141 }
│ │ │ │ -
142
│ │ │ │ -
143 template<class Begin, class End>
│ │ │ │ -
144 constexpr auto integralRange(const Begin& begin, const End& end, const PriorityTag<0>&)
│ │ │ │ -
145 {
│ │ │ │ -
146 assert(begin<=end && "You cannot create an integralRange where end<begin");
│ │ │ │ -
147 return Dune::IntegralRange<End>(begin, end);
│ │ │ │ -
148 }
│ │ │ │ -
149
│ │ │ │ -
150} // namespace Impl
│ │ │ │ -
151
│ │ │ │ +
136 template <class IndexType, std::size_t N,
│ │ │ │ +
137 std::enable_if_t<std::is_convertible_v<IndexType, index_type>, int> = 0,
│ │ │ │ +
138 std::enable_if_t<(N == extents_type::rank_dynamic() || N == extents_type::rank()), int> = 0>
│ │ │ │ +
139 #if __cpp_conditional_explicit >= 201806L
│ │ │ │ +
140 explicit(N != extents_type::rank_dynamic())
│ │ │ │ +
141 #endif
│ │ │ │ +
│ │ │ │ +
142 constexpr mdspan (data_handle_type p, const std::array<IndexType,N>& exts)
│ │ │ │ +
143 : mdspan(std::move(p), extents_type(exts))
│ │ │ │ +
144 {}
│ │ │ │ +
│ │ │ │ +
145
│ │ │ │ +
147 template <class M = mapping_type,
│ │ │ │ +
148 std::enable_if_t<std::is_constructible_v<M, const extents_type&>, int> = 0>
│ │ │ │ +
│ │ │ │ +
149 constexpr mdspan (data_handle_type p, const extents_type& e)
│ │ │ │ +
150 : mdspan(std::move(p), mapping_type(e))
│ │ │ │ +
151 {}
│ │ │ │ +
│ │ │ │
152
│ │ │ │ -
153
│ │ │ │ -
171template<class Begin, class End>
│ │ │ │ -
│ │ │ │ -
172constexpr auto integralRange(const Begin& begin, const End& end)
│ │ │ │ -
173{
│ │ │ │ -
174 return Impl::integralRange(begin, end, PriorityTag<42>());
│ │ │ │ -
175}
│ │ │ │ -
│ │ │ │ -
176
│ │ │ │ -
190template<class End>
│ │ │ │ -
│ │ │ │ -
191constexpr auto integralRange(const End& end)
│ │ │ │ -
192{
│ │ │ │ -
193 return Impl::integralRange(Dune::Indices::_0, end, PriorityTag<42>());
│ │ │ │ -
194}
│ │ │ │ -
│ │ │ │ -
195
│ │ │ │ -
196
│ │ │ │ -
197
│ │ │ │ -
198namespace Impl {
│ │ │ │ +
154 template <class A = accessor_type,
│ │ │ │ +
155 std::enable_if_t<std::is_default_constructible_v<A>, int> = 0>
│ │ │ │ +
│ │ │ │ +
156 constexpr mdspan (data_handle_type p, const mapping_type& m)
│ │ │ │ +
157 : mdspan(std::move(p), m, accessor_type{})
│ │ │ │ +
158 {}
│ │ │ │ +
│ │ │ │ +
159
│ │ │ │ +
│ │ │ │ +
161 constexpr mdspan (data_handle_type p, const mapping_type& m, const accessor_type& a)
│ │ │ │ +
162 : data_handle_(std::move(p))
│ │ │ │ +
163 , mapping_(m)
│ │ │ │ +
164 , accessor_(a)
│ │ │ │ +
165 {}
│ │ │ │ +
│ │ │ │ +
166
│ │ │ │ +
167
│ │ │ │ +
169 template <class OtherElementType, class OtherExtends, class OtherLayoutPolicy, class OtherAccessor,
│ │ │ │ +
170 std::enable_if_t<std::is_constructible_v<mapping_type, const typename OtherElementType::template mapping<OtherExtends>&>, int> = 0,
│ │ │ │ +
171 std::enable_if_t<std::is_constructible_v<accessor_type, const OtherAccessor&>, int> = 0>
│ │ │ │ +
172 #if __cpp_conditional_explicit >= 201806L
│ │ │ │ +
173 explicit(!std::is_convertible_v<const typename OtherElementType::template mapping<OtherExtends>&, mapping_type>
│ │ │ │ +
174 || !std::is_convertible_v<const OtherAccessor&, accessor_type>)
│ │ │ │ +
175 #endif
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ +
178 accessor_type(other.accessor()))
│ │ │ │ +
179 {}
│ │ │ │ +
│ │ │ │ +
180
│ │ │ │ +
182
│ │ │ │ +
183
│ │ │ │ +
186
│ │ │ │ +
191 template <class... Indices,
│ │ │ │ +
192 std::enable_if_t<(sizeof...(Indices) == extents_type::rank()), int> = 0,
│ │ │ │ +
193 std::enable_if_t<(... && std::is_convertible_v<Indices, index_type>), int> = 0,
│ │ │ │ +
194 std::enable_if_t<(... && std::is_nothrow_constructible_v<index_type,Indices>), int> = 0>
│ │ │ │ +
│ │ │ │ +
195 constexpr reference operator() (Indices... indices) const
│ │ │ │ +
196 {
│ │ │ │ +
197 return accessor_.access(data_handle_, mapping_(index_type(std::move(indices))...));
│ │ │ │ +
198 }
│ │ │ │ +
│ │ │ │
199
│ │ │ │ -
200 template<class T>
│ │ │ │ -
201 constexpr void evaluateFoldExpression(std::initializer_list<T>&&)
│ │ │ │ -
202 {}
│ │ │ │ -
203
│ │ │ │ -
204 template<class Range, class F, class Index, Index... i>
│ │ │ │ -
205 constexpr void forEachIndex(Range&& range, F&& f, std::integer_sequence<Index, i...>)
│ │ │ │ -
206 {
│ │ │ │ -
207 evaluateFoldExpression<int>({(f(Hybrid::elementAt(range, std::integral_constant<Index,i>())), 0)...});
│ │ │ │ -
208 }
│ │ │ │ -
209
│ │ │ │ -
210 template<class F, class Index, Index... i>
│ │ │ │ -
211 constexpr void forEach(std::integer_sequence<Index, i...> /*range*/, F&& f, PriorityTag<2>)
│ │ │ │ -
212 {
│ │ │ │ -
213 evaluateFoldExpression<int>({(f(std::integral_constant<Index,i>()), 0)...});
│ │ │ │ -
214 }
│ │ │ │ -
215
│ │ │ │ -
216
│ │ │ │ -
217 template<class Range, class F,
│ │ │ │ -
218 std::enable_if_t<IsIntegralConstant<decltype(Hybrid::size(std::declval<Range>()))>::value, int> = 0>
│ │ │ │ -
219 constexpr void forEach(Range&& range, F&& f, PriorityTag<1>)
│ │ │ │ +
200#if __cpp_multidimensional_subscript >= 202110L
│ │ │ │ +
201
│ │ │ │ +
203 template <class... Indices,
│ │ │ │ +
204 std::enable_if_t<(sizeof...(Indices) == extents_type::rank()), int> = 0,
│ │ │ │ +
205 std::enable_if_t<(... && std::is_convertible_v<Indices, index_type>), int> = 0,
│ │ │ │ +
206 std::enable_if_t<(... && std::is_nothrow_constructible_v<index_type,Indices>), int> = 0>
│ │ │ │ +
207 constexpr reference operator[] (Indices... indices) const
│ │ │ │ +
208 {
│ │ │ │ +
209 return accessor_.access(data_handle_, mapping_(index_type(std::move(indices))...));
│ │ │ │ +
210 }
│ │ │ │ +
211
│ │ │ │ +
212#else // __cpp_multidimensional_subscript
│ │ │ │ +
213
│ │ │ │ +
216 template <class Index, class E = extents_type,
│ │ │ │ +
217 std::enable_if_t<std::is_convertible_v<Index,index_type>, int> = 0,
│ │ │ │ +
218 std::enable_if_t<(E::rank() == 1), int> = 0>
│ │ │ │ +
│ │ │ │ +
219 constexpr reference operator[] (Index index) const
│ │ │ │
220 {
│ │ │ │ -
221 auto size = Hybrid::size(range);
│ │ │ │ -
222 auto indices = std::make_index_sequence<size>();
│ │ │ │ -
223 (forEachIndex)(std::forward<Range>(range), std::forward<F>(f), indices);
│ │ │ │ -
224 }
│ │ │ │ +
221 return accessor_.access(data_handle_, mapping_(index_type(std::move(index))));
│ │ │ │ +
222 }
│ │ │ │ +
│ │ │ │ +
223
│ │ │ │ +
224#endif // __cpp_multidimensional_subscript
│ │ │ │
225
│ │ │ │ -
226 template<class Range, class F>
│ │ │ │ -
227 constexpr void forEach(Range&& range, F&& f, PriorityTag<0>)
│ │ │ │ -
228 {
│ │ │ │ -
229 for(auto&& e : range)
│ │ │ │ -
230 f(e);
│ │ │ │ -
231 }
│ │ │ │ -
232
│ │ │ │ -
233} // namespace Impl
│ │ │ │ -
234
│ │ │ │ -
235
│ │ │ │ -
236
│ │ │ │ -
255template<class Range, class F>
│ │ │ │ -
│ │ │ │ -
256constexpr void forEach(Range&& range, F&& f)
│ │ │ │ -
257{
│ │ │ │ -
258 Impl::forEach(std::forward<Range>(range), std::forward<F>(f), PriorityTag<42>());
│ │ │ │ -
259}
│ │ │ │ +
227 template <class Index,
│ │ │ │ +
228 std::enable_if_t<std::is_convertible_v<const Index&, index_type>, int> = 0,
│ │ │ │ +
229 std::enable_if_t<std::is_nothrow_constructible_v<index_type, const Index&>, int> = 0>
│ │ │ │ +
│ │ │ │ +
230 constexpr reference operator[] (Std::span<Index,extents_type::rank()> indices) const
│ │ │ │ +
231 {
│ │ │ │ +
232 return unpackIntegerSequence([&](auto... ii) -> reference {
│ │ │ │ +
233 return accessor_.access(data_handle_, mapping_(index_type(indices[ii])...)); },
│ │ │ │ +
234 std::make_index_sequence<extents_type::rank()>{});
│ │ │ │ +
235 }
│ │ │ │
│ │ │ │ +
236
│ │ │ │ +
238 template <class Index,
│ │ │ │ +
239 std::enable_if_t<std::is_convertible_v<const Index&, index_type>, int> = 0,
│ │ │ │ +
240 std::enable_if_t<std::is_nothrow_constructible_v<index_type, const Index&>, int> = 0>
│ │ │ │ +
│ │ │ │ +
241 constexpr reference operator[] (const std::array<Index,extents_type::rank()>& indices) const
│ │ │ │ +
242 {
│ │ │ │ +
243 return std::apply([&](auto... ii) -> reference {
│ │ │ │ +
244 return accessor_.access(data_handle_, mapping_(index_type(ii)...)); }, indices);
│ │ │ │ +
245 }
│ │ │ │ +
│ │ │ │ +
246
│ │ │ │ +
248
│ │ │ │ +
250 constexpr const extents_type& extents () const noexcept { return mapping_.extents(); }
│ │ │ │ +
251
│ │ │ │ +
253 constexpr const mapping_type& mapping () const noexcept { return mapping_; }
│ │ │ │ +
254
│ │ │ │ +
256 constexpr const accessor_type& accessor () const noexcept { return accessor_; }
│ │ │ │ +
257
│ │ │ │ +
259 constexpr const data_handle_type& data_handle () const noexcept { return data_handle_; };
│ │ │ │
260
│ │ │ │
261
│ │ │ │ -
262
│ │ │ │ -
278template<class Range, class T, class F>
│ │ │ │ -
│ │ │ │ -
279constexpr T accumulate(Range&& range, T value, F&& f)
│ │ │ │ -
280{
│ │ │ │ -
281 forEach(std::forward<Range>(range), [&](auto&& entry) {
│ │ │ │ -
282 value = f(value, entry);
│ │ │ │ -
283 });
│ │ │ │ -
284 return value;
│ │ │ │ -
285}
│ │ │ │ +
264
│ │ │ │ +
266 static constexpr rank_type rank () noexcept { return extents_type::rank(); }
│ │ │ │ +
267
│ │ │ │ +
269 static constexpr rank_type rank_dynamic () noexcept { return extents_type::rank_dynamic(); }
│ │ │ │ +
270
│ │ │ │ +
272 static constexpr std::size_t static_extent (rank_type r) noexcept { return extents_type::static_extent(r); }
│ │ │ │ +
273
│ │ │ │ +
275 constexpr index_type extent (rank_type r) const noexcept { return extents().extent(r); }
│ │ │ │ +
276
│ │ │ │ +
│ │ │ │ +
278 constexpr size_type size () const noexcept
│ │ │ │ +
279 {
│ │ │ │ +
280 size_type s = 1;
│ │ │ │ +
281 for (rank_type r = 0; r < rank(); ++r)
│ │ │ │ +
282 s *= extent(r);
│ │ │ │ +
283 return s;
│ │ │ │ +
284 }
│ │ │ │
│ │ │ │ -
286
│ │ │ │ -
287
│ │ │ │ +
285
│ │ │ │ +
287 [[nodiscard]] constexpr bool empty () const noexcept { return size() == 0; }
│ │ │ │
288
│ │ │ │ -
289namespace Impl {
│ │ │ │
290
│ │ │ │ -
291 struct Id {
│ │ │ │ -
292 template<class T>
│ │ │ │ -
293 constexpr T operator()(T&& x) const {
│ │ │ │ -
294 return std::forward<T>(x);
│ │ │ │ -
295 }
│ │ │ │ -
296 };
│ │ │ │ +
291
│ │ │ │ +
293 static constexpr bool is_always_unique () { return mapping_type::is_always_unique(); }
│ │ │ │ +
294
│ │ │ │ +
296 static constexpr bool is_always_exhaustive () { return mapping_type::is_always_exhaustive(); }
│ │ │ │
297
│ │ │ │ -
298 template<class IfFunc, class ElseFunc>
│ │ │ │ -
299 constexpr decltype(auto) ifElse(std::true_type, IfFunc&& ifFunc, ElseFunc&& /*elseFunc*/)
│ │ │ │ -
300 {
│ │ │ │ -
301 return ifFunc(Id{});
│ │ │ │ -
302 }
│ │ │ │ +
299 static constexpr bool is_always_strided () { return mapping_type::is_always_strided(); }
│ │ │ │ +
300
│ │ │ │ +
302 constexpr bool is_unique () const { return mapping_.is_unique(); }
│ │ │ │
303
│ │ │ │ -
304 template<class IfFunc, class ElseFunc>
│ │ │ │ -
305 constexpr decltype(auto) ifElse(std::false_type, IfFunc&& /*ifFunc*/, ElseFunc&& elseFunc)
│ │ │ │ -
306 {
│ │ │ │ -
307 return elseFunc(Id{});
│ │ │ │ -
308 }
│ │ │ │ -
309
│ │ │ │ -
310 template<class IfFunc, class ElseFunc>
│ │ │ │ -
311 decltype(auto) ifElse(const bool& condition, IfFunc&& ifFunc, ElseFunc&& elseFunc)
│ │ │ │ -
312 {
│ │ │ │ -
313 if (condition)
│ │ │ │ -
314 return ifFunc(Id{});
│ │ │ │ -
315 else
│ │ │ │ -
316 return elseFunc(Id{});
│ │ │ │ -
317 }
│ │ │ │ +
306 constexpr bool is_exhaustive () const { return mapping_.is_exhaustive(); }
│ │ │ │ +
307
│ │ │ │ +
313 constexpr bool is_strided () const { return mapping_.is_strided(); }
│ │ │ │ +
314
│ │ │ │ +
316 constexpr index_type stride (rank_type r) const { return mapping_.stride(r); }
│ │ │ │ +
317
│ │ │ │
318
│ │ │ │ -
319} // namespace Impl
│ │ │ │ -
320
│ │ │ │ -
321
│ │ │ │ -
322
│ │ │ │ -
343template<class Condition, class IfFunc, class ElseFunc>
│ │ │ │ -
│ │ │ │ -
344decltype(auto) ifElse(const Condition& condition, IfFunc&& ifFunc, ElseFunc&& elseFunc)
│ │ │ │ -
345{
│ │ │ │ -
346 return Impl::ifElse(condition, std::forward<IfFunc>(ifFunc), std::forward<ElseFunc>(elseFunc));
│ │ │ │ -
347}
│ │ │ │ -
│ │ │ │ +
│ │ │ │ +
320 friend constexpr void swap (mdspan& x, mdspan& y) noexcept
│ │ │ │ +
321 {
│ │ │ │ +
322 using std::swap;
│ │ │ │ +
323 swap(x.data_handle_, y.data_handle_);
│ │ │ │ +
324 swap(x.mapping_, y.mapping_);
│ │ │ │ +
325 swap(x.accessor_, y.accessor_);
│ │ │ │ +
326 }
│ │ │ │ +
│ │ │ │ +
327
│ │ │ │ +
328
│ │ │ │ +
329private:
│ │ │ │ +
330 data_handle_type data_handle_;
│ │ │ │ +
331 [[no_unique_address]] mapping_type mapping_;
│ │ │ │ +
332 [[no_unique_address]] accessor_type accessor_;
│ │ │ │ +
333};
│ │ │ │ +
│ │ │ │ +
334
│ │ │ │ +
335// deduction guides
│ │ │ │ +
336// @{
│ │ │ │ +
337
│ │ │ │ +
338template <class CArray,
│ │ │ │ +
339 std::enable_if_t<std::is_array_v<CArray>, int> = 0,
│ │ │ │ +
340 std::enable_if_t<(std::rank_v<CArray> == 1), int> = 0>
│ │ │ │ +
341mdspan (CArray&)
│ │ │ │ + │ │ │ │ +
343
│ │ │ │ +
344template <class Pointer,
│ │ │ │ +
345 std::enable_if_t<std::is_pointer_v<std::remove_reference_t<Pointer>>, int> = 0>
│ │ │ │ +
346mdspan (Pointer&&)
│ │ │ │ + │ │ │ │
348
│ │ │ │ -
356template<class Condition, class IfFunc>
│ │ │ │ -
│ │ │ │ -
357void ifElse(const Condition& condition, IfFunc&& ifFunc)
│ │ │ │ -
358{
│ │ │ │ -
359 ifElse(condition, std::forward<IfFunc>(ifFunc), [](auto&&) {});
│ │ │ │ -
360}
│ │ │ │ -
│ │ │ │ -
361
│ │ │ │ +
349template <class ElementType, class... II,
│ │ │ │ +
350 std::enable_if_t<(... && std::is_convertible_v<II,std::size_t>), int> = 0,
│ │ │ │ +
351 std::enable_if_t<(sizeof...(II) > 0), int> = 0>
│ │ │ │ +
352mdspan (ElementType*, II...)
│ │ │ │ +
353 -> mdspan<ElementType, Std::dextents<std::size_t, sizeof...(II)>>;
│ │ │ │ +
354
│ │ │ │ +
355template <class ElementType, class SizeType, std::size_t N>
│ │ │ │ + │ │ │ │ + │ │ │ │ +
358
│ │ │ │ +
359template <class ElementType, class SizeType, std::size_t N>
│ │ │ │ +
360mdspan (ElementType*, const std::array<SizeType,N>&)
│ │ │ │ + │ │ │ │
362
│ │ │ │ -
363
│ │ │ │ -
364namespace Impl {
│ │ │ │ -
365
│ │ │ │ -
366 struct Max {
│ │ │ │ -
367 template<class... Args>
│ │ │ │ -
368 constexpr decltype(auto) operator()(Args&&... args) const
│ │ │ │ -
369 {
│ │ │ │ -
370 using T = std::common_type_t<Args...>;
│ │ │ │ -
371 return std::max({T(args)...});
│ │ │ │ -
372 }
│ │ │ │ -
373 };
│ │ │ │ -
374
│ │ │ │ -
375 struct Min {
│ │ │ │ -
376 template<class... Args>
│ │ │ │ -
377 constexpr decltype(auto) operator()(Args&&... args) const
│ │ │ │ -
378 {
│ │ │ │ -
379 using T = std::common_type_t<Args...>;
│ │ │ │ -
380 return std::min({T(args)...});
│ │ │ │ -
381 }
│ │ │ │ -
382 };
│ │ │ │ -
383
│ │ │ │ -
384} // namespace Impl
│ │ │ │ -
385
│ │ │ │ -
386
│ │ │ │ -
417template<class Functor>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
419
│ │ │ │ -
420 static_assert(std::is_default_constructible_v<Functor>,
│ │ │ │ -
421 "Operator in integral expressions shall be constexpr default constructible");
│ │ │ │ -
422
│ │ │ │ -
423 inline static constexpr Functor _functor = Functor{};
│ │ │ │ -
424
│ │ │ │ -
425public:
│ │ │ │ -
426
│ │ │ │ -
436 template<class... Args>
│ │ │ │ -
│ │ │ │ -
437 constexpr decltype(auto) operator()(const Args&... args) const
│ │ │ │ -
438 {
│ │ │ │ -
439 if constexpr (std::conjunction_v<IsCompileTimeConstant<Args>...>)
│ │ │ │ -
440 {
│ │ │ │ -
441 constexpr auto result = _functor(Args::value...);
│ │ │ │ -
442 // apply functor on integral constant arguments and return an integral constant of the result
│ │ │ │ -
443 // this is guaranteed to be evaluated at compile-time
│ │ │ │ -
444 return std::integral_constant<std::remove_cv_t<decltype(result)>,result>{};
│ │ │ │ -
445 } else {
│ │ │ │ -
446 // apply functor directly on arguments and return the result of the functor
│ │ │ │ -
447 // (integral constants are likely to be casted to underlying type)
│ │ │ │ -
448 // this not is guaranteed to be evaluated at compile-time although is possible if expression is constexpr
│ │ │ │ -
449 return _functor(args...);
│ │ │ │ -
450 }
│ │ │ │ -
451 }
│ │ │ │ -
│ │ │ │ -
452};
│ │ │ │ -
│ │ │ │ -
453
│ │ │ │ -
458template<class Functor>
│ │ │ │ -
│ │ │ │ -
459constexpr HybridFunctor<Functor> hybridFunctor(const Functor&)
│ │ │ │ -
460{
│ │ │ │ -
461 return {};
│ │ │ │ -
462}
│ │ │ │ -
│ │ │ │ -
463
│ │ │ │ -
484inline constexpr auto max = hybridFunctor(Impl::Max{});
│ │ │ │ -
485
│ │ │ │ -
506inline constexpr auto min = hybridFunctor(Impl::Min{});
│ │ │ │ -
507
│ │ │ │ -
528inline constexpr auto plus = hybridFunctor(std::plus<>{});
│ │ │ │ -
529
│ │ │ │ -
550inline constexpr auto minus = hybridFunctor(std::minus<>{});
│ │ │ │ -
551
│ │ │ │ -
572inline constexpr auto equal_to = hybridFunctor(std::equal_to<>{});
│ │ │ │ -
573
│ │ │ │ -
574
│ │ │ │ -
586template<class T1, class T2>
│ │ │ │ -
│ │ │ │ -
587[[deprecated("Use Hybrid::equal_to instead!")]] constexpr auto equals(T1&& t1, T2&& t2){
│ │ │ │ -
588 return equal_to(std::forward<T1>(t1), std::forward<T2>(t2));
│ │ │ │ -
589}
│ │ │ │ -
│ │ │ │ -
590
│ │ │ │ -
591
│ │ │ │ -
592namespace Impl {
│ │ │ │ -
593
│ │ │ │ -
594 // This overload is selected if the passed value is already a compile time constant.
│ │ │ │ -
595 template<class Result, class T, T t0, T... tt, class ValueType, ValueType value, class Branches, class ElseBranch>
│ │ │ │ -
596 constexpr Result switchCases(std::integer_sequence<T, t0, tt...>, const std::integral_constant<ValueType, value>& /*value*/, Branches&& branches, ElseBranch&& elseBranch)
│ │ │ │ -
597 {
│ │ │ │ -
598 // In case we pass a value known at compile time, we no longer have to do
│ │ │ │ -
599 // a dynamic to static dispatch via recursion. The only thing that's left
│ │ │ │ -
600 // is to check if the value is contained in the passed range.
│ │ │ │ -
601 // If this is true, we have to pass it to the branches callback
│ │ │ │ -
602 // as an appropriate integral_constant type. Otherwise we have to
│ │ │ │ -
603 // execute the else callback.
│ │ │ │ -
604 if constexpr (((t0 == value) || ... || (tt == value)))
│ │ │ │ -
605 return branches(std::integral_constant<T, value>{});
│ │ │ │ -
606 else
│ │ │ │ -
607 return elseBranch();
│ │ │ │ -
608 }
│ │ │ │ -
609
│ │ │ │ -
610 // This overload is selected if the passed value is dynamic.
│ │ │ │ -
611 template<class Result, class T, class Value, class Branches, class ElseBranch>
│ │ │ │ -
612 constexpr Result switchCases(std::integer_sequence<T>, const Value& /*value*/, Branches&& /*branches*/, ElseBranch&& elseBranch)
│ │ │ │ -
613 {
│ │ │ │ -
614 return elseBranch();
│ │ │ │ -
615 }
│ │ │ │ -
616
│ │ │ │ -
617 template<class Result, class T, T t0, T... tt, class Value, class Branches, class ElseBranch>
│ │ │ │ -
618 constexpr Result switchCases(std::integer_sequence<T, t0, tt...>, const Value& value, Branches&& branches, ElseBranch&& elseBranch)
│ │ │ │ -
619 {
│ │ │ │ -
620 if (t0 == value)
│ │ │ │ -
621 return branches(std::integral_constant<T, t0>());
│ │ │ │ -
622 else
│ │ │ │ -
623 return Impl::switchCases<Result>(std::integer_sequence<T, tt...>(), value, branches, elseBranch);
│ │ │ │ -
624 }
│ │ │ │ -
625
│ │ │ │ -
626 // This overload is selected if the range of cases is an IntegralRange
│ │ │ │ -
627 template <class Result, class T, class Value, class Branches, class ElseBranch>
│ │ │ │ -
628 constexpr Result switchCases(IntegralRange<T> range, const Value& value, Branches&& branches, ElseBranch&& elseBranch)
│ │ │ │ -
629 {
│ │ │ │ -
630 return range.contains(value) ? branches(T(value)) : elseBranch();
│ │ │ │ -
631 }
│ │ │ │ -
632
│ │ │ │ -
633 // This overload is selected if the range of cases is a StaticIntegralRange
│ │ │ │ -
634 template <class Result, class T, T to, T from, class Value, class Branches, class ElseBranch>
│ │ │ │ -
635 constexpr Result switchCases(StaticIntegralRange<T, to, from> range, const Value& value, Branches&& branches, ElseBranch&& elseBranch)
│ │ │ │ -
636 {
│ │ │ │ -
637 using seq = typename decltype(range)::integer_sequence;
│ │ │ │ -
638 return Impl::switchCases<Result>(seq{}, value, branches, elseBranch);
│ │ │ │ -
639 }
│ │ │ │ -
640
│ │ │ │ -
641} // namespace Impl
│ │ │ │ -
642
│ │ │ │ -
643
│ │ │ │ -
644
│ │ │ │ -
672template<class Cases, class Value, class Branches, class ElseBranch>
│ │ │ │ -
│ │ │ │ -
673constexpr decltype(auto) switchCases(const Cases& cases, const Value& value, Branches&& branches, ElseBranch&& elseBranch)
│ │ │ │ -
674{
│ │ │ │ -
675 return Impl::switchCases<decltype(elseBranch())>(cases, value, std::forward<Branches>(branches), std::forward<ElseBranch>(elseBranch));
│ │ │ │ -
676}
│ │ │ │ -
│ │ │ │ -
677
│ │ │ │ -
697template<class Cases, class Value, class Branches>
│ │ │ │ -
│ │ │ │ -
698constexpr void switchCases(const Cases& cases, const Value& value, Branches&& branches)
│ │ │ │ -
699{
│ │ │ │ -
700 Impl::switchCases<void>(cases, value, std::forward<Branches>(branches),
│ │ │ │ -
701 []{ assert(false && "value not found in range"); });
│ │ │ │ -
702}
│ │ │ │ -
│ │ │ │ -
703
│ │ │ │ -
722template <class T, class Value, class Branches>
│ │ │ │ -
│ │ │ │ -
723constexpr void switchCases(IntegralRange<T> range, const Value& value, Branches&& branches)
│ │ │ │ -
724{
│ │ │ │ -
725 assert(range.contains(value) && "value not found in range");
│ │ │ │ -
726 branches(T(value));
│ │ │ │ -
727}
│ │ │ │ -
│ │ │ │ -
728
│ │ │ │ -
729} // namespace Hybrid
│ │ │ │ -
│ │ │ │ -
730} // namespace Dune
│ │ │ │ -
731
│ │ │ │ -
732
│ │ │ │ -
733#endif // #ifndef DUNE_COMMON_HYBRIDUTILITIES_HH
│ │ │ │ -
Utilities for reduction like operations on ranges.
│ │ │ │ -
Utilities for type computations, constraining overloads, ...
│ │ │ │ -
Implements a vector constructed from a given type representing a field and a compile-time given size.
│ │ │ │ - │ │ │ │ -
Traits for type conversions and type information.
│ │ │ │ -
constexpr index_constant< 0 > _0
Compile time index with value 0.
Definition indices.hh:52
│ │ │ │ -
static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from >, std::integral_constant< T, to >) noexcept
Definition rangeutilities.hh:312
│ │ │ │ -
constexpr auto size(const T &t)
Size query.
Definition hybridutilities.hh:73
│ │ │ │ -
constexpr auto minus
Function object for performing subtraction.
Definition hybridutilities.hh:550
│ │ │ │ -
constexpr auto equals(T1 &&t1, T2 &&t2)
Equality comparison.
Definition hybridutilities.hh:587
│ │ │ │ -
constexpr void forEach(Range &&range, F &&f)
Range based for loop.
Definition hybridutilities.hh:256
│ │ │ │ -
constexpr auto equal_to
Function object for performing equality comparison.
Definition hybridutilities.hh:572
│ │ │ │ -
constexpr decltype(auto) switchCases(const Cases &cases, const Value &value, Branches &&branches, ElseBranch &&elseBranch)
Switch statement.
Definition hybridutilities.hh:673
│ │ │ │ -
constexpr auto max
Function object that returns the greater of the given values.
Definition hybridutilities.hh:484
│ │ │ │ -
constexpr auto plus
Function object for performing addition.
Definition hybridutilities.hh:528
│ │ │ │ -
constexpr auto min
Function object that returns the smaller of the given values.
Definition hybridutilities.hh:506
│ │ │ │ -
decltype(auto) ifElse(const Condition &condition, IfFunc &&ifFunc, ElseFunc &&elseFunc)
A conditional expression.
Definition hybridutilities.hh:344
│ │ │ │ -
constexpr auto integralRange(const Begin &begin, const End &end)
Create an integral range.
Definition hybridutilities.hh:172
│ │ │ │ -
constexpr decltype(auto) elementAt(Container &&c, Index &&i)
Get element at given position from container.
Definition hybridutilities.hh:126
│ │ │ │ -
constexpr T accumulate(Range &&range, T value, F &&f)
Accumulate values.
Definition hybridutilities.hh:279
│ │ │ │ -
constexpr auto integerSequenceEntry(std::integer_sequence< T, t... >, std::integral_constant< std::size_t, index > i)
Get entry of std::integer_sequence.
Definition typetraits.hh:492
│ │ │ │ -
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
constexpr HybridFunctor< Functor > hybridFunctor(const Functor &)
Returns an HybridFunctor adaptor.
Definition hybridutilities.hh:459
│ │ │ │ -
Definition binaryfunctions.hh:34
│ │ │ │ -
Adapter of a hybrid functor that maintains results hybrid.
Definition hybridutilities.hh:418
│ │ │ │ -
dynamic integer range for use in range-based for loops
Definition rangeutilities.hh:177
│ │ │ │ -
static integer range for use in range-based for loops
Definition rangeutilities.hh:230
│ │ │ │ -
Check if T is an std::integral_constant<I, i>
Definition typetraits.hh:384
│ │ │ │ -
Helper class for tagging priorities.
Definition typeutilities.hh:73
│ │ │ │ +
363template <class ElementType, class IndexType, std::size_t... exts>
│ │ │ │ + │ │ │ │ +
365 -> mdspan<ElementType, Std::extents<IndexType,exts...>>;
│ │ │ │ +
366
│ │ │ │ +
367template <class ElementType, class Mapping,
│ │ │ │ +
368 class Extents = typename Mapping::extents_type,
│ │ │ │ +
369 class Layout = typename Mapping::layout_type>
│ │ │ │ +
370mdspan (ElementType*, const Mapping&)
│ │ │ │ + │ │ │ │ +
372
│ │ │ │ +
373template <class Mapping, class Accessor,
│ │ │ │ +
374 class DataHandle = typename Accessor::data_handle_type,
│ │ │ │ +
375 class Element = typename Accessor::element_type,
│ │ │ │ +
376 class Extents = typename Mapping::extents_type,
│ │ │ │ +
377 class Layout = typename Mapping::layout_type>
│ │ │ │ +
378mdspan (const DataHandle&, const Mapping&, const Accessor&)
│ │ │ │ + │ │ │ │ +
380
│ │ │ │ +
381// @}
│ │ │ │ +
382
│ │ │ │ +
383} // end namespace Dune::Std
│ │ │ │ +
384
│ │ │ │ +
385#endif // DUNE_COMMON_STD_MDSPAN_HH
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
decltype(auto) constexpr unpackIntegerSequence(F &&f, std::integer_sequence< I, i... > sequence)
Unpack an std::integer_sequence<I,i...> to std::integral_constant<I,i>...
Definition indices.hh:124
│ │ │ │ +
typename Impl::DExtentsImpl< IndexType, std::make_integer_sequence< std::size_t, R > >::type dextents
Alias of extents of given rank R and purely dynamic extents. See [mdspan.extents.dextents].
Definition extents.hh:259
│ │ │ │ +
STL namespace.
│ │ │ │ +
Namespace for features backported from new C++ standards.
Definition default_accessor.hh:10
│ │ │ │ +
Multidimensional index space with dynamic and static extents.
Definition extents.hh:54
│ │ │ │ +
A multi-dimensional non-owning array view.
Definition mdspan.hh:64
│ │ │ │ +
typename accessor_type::reference reference
Definition mdspan.hh:82
│ │ │ │ +
Element element_type
Definition mdspan.hh:71
│ │ │ │ +
constexpr mdspan(data_handle_type p, const mapping_type &m, const accessor_type &a)
Construct from the pointer to the data of the tensor, an index mapping, and an accessor.
Definition mdspan.hh:161
│ │ │ │ +
Extents extents_type
Definition mdspan.hh:72
│ │ │ │ +
static constexpr rank_type rank_dynamic() noexcept
Number of dimensions of the tensor.
Definition mdspan.hh:269
│ │ │ │ +
static constexpr bool is_always_unique()
Return true only if for every i and j where (i != j || ...) => mapping(i...) != mapping(j....
Definition mdspan.hh:293
│ │ │ │ +
typename extents_type::index_type index_type
Definition mdspan.hh:78
│ │ │ │ +
LayoutPolicy layout_type
Definition mdspan.hh:73
│ │ │ │ +
constexpr bool is_strided() const
Return true only if for every rank index r of extents there exists an integer sr such that,...
Definition mdspan.hh:313
│ │ │ │ +
constexpr mdspan(data_handle_type p, const mapping_type &m)
Construct from the pointer to the data of the tensor and an index mapping.
Definition mdspan.hh:156
│ │ │ │ +
typename extents_type::rank_type rank_type
Definition mdspan.hh:80
│ │ │ │ +
constexpr mdspan(data_handle_type p, const extents_type &e)
Construct from the pointer to the data of the tensor and its extents.
Definition mdspan.hh:149
│ │ │ │ +
std::remove_cv_t< Element > value_type
Definition mdspan.hh:76
│ │ │ │ +
static constexpr bool is_always_exhaustive()
Return true only if for all k in the range [0, mapping.required_span_size() ) there exists an i such ...
Definition mdspan.hh:296
│ │ │ │ +
constexpr reference operator[](Index index) const
Access specified element at position [i0] For a rank one mdspan, the operator[i] is added to support ...
Definition mdspan.hh:219
│ │ │ │ +
constexpr const extents_type & extents() const noexcept
Number of elements in all dimensions of the tensor,.
Definition mdspan.hh:250
│ │ │ │ +
constexpr index_type extent(rank_type r) const noexcept
Number of elements in the r'th dimension of the tensor.
Definition mdspan.hh:275
│ │ │ │ +
friend constexpr void swap(mdspan &x, mdspan &y) noexcept
Overloads the std::swap algorithm for std::mdspan. Exchanges the state of x with that of y.
Definition mdspan.hh:320
│ │ │ │ +
static constexpr bool is_always_strided()
Return true only if for every rank index r of extents there exists an integer sr such that,...
Definition mdspan.hh:299
│ │ │ │ +
constexpr size_type size() const noexcept
The number of elements accessible by this multi-dimensional span.
Definition mdspan.hh:278
│ │ │ │ +
typename accessor_type::data_handle_type data_handle_type
Definition mdspan.hh:81
│ │ │ │ +
constexpr bool empty() const noexcept
Checks if the size of the index space is zero.
Definition mdspan.hh:287
│ │ │ │ +
constexpr const accessor_type & accessor() const noexcept
The accessor policy object.
Definition mdspan.hh:256
│ │ │ │ +
AccessorPolicy accessor_type
Definition mdspan.hh:74
│ │ │ │ +
constexpr bool is_exhaustive() const
Return true only if for all k in the range [0, mapping.required_span_size() ) there exists an i such ...
Definition mdspan.hh:306
│ │ │ │ +
static constexpr rank_type rank() noexcept
Number of dimensions of the tensor.
Definition mdspan.hh:266
│ │ │ │ +
static constexpr std::size_t static_extent(rank_type r) noexcept
Number of elements in the r'th dimension of the tensor.
Definition mdspan.hh:272
│ │ │ │ +
constexpr const mapping_type & mapping() const noexcept
Index mapping of a layout policy.
Definition mdspan.hh:253
│ │ │ │ +
constexpr const data_handle_type & data_handle() const noexcept
The pointer to the underlying flat sequence.
Definition mdspan.hh:259
│ │ │ │ +
constexpr index_type stride(rank_type r) const
The stride along the specified dimension.
Definition mdspan.hh:316
│ │ │ │ +
constexpr bool is_unique() const
Return true only if for every i and j where (i != j || ...) => mapping(i...) != mapping(j....
Definition mdspan.hh:302
│ │ │ │ +
constexpr mdspan()
Default constructor value-initializes all members.
Definition mdspan.hh:105
│ │ │ │ +
typename extents_type::size_type size_type
Definition mdspan.hh:79
│ │ │ │ +
typename layout_type::template mapping< extents_type > mapping_type
Definition mdspan.hh:77
│ │ │ │ +
A contiguous sequence of elements with static or dynamic extent.
Definition span.hh:126
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,535 +1,522 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -hybridutilities.hh │ │ │ │ │ + * std │ │ │ │ │ +mdspan.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_COMMON_HYBRIDUTILITIES_HH │ │ │ │ │ -6#define DUNE_COMMON_HYBRIDUTILITIES_HH │ │ │ │ │ +5#ifndef DUNE_COMMON_STD_MDSPAN_HH │ │ │ │ │ +6#define DUNE_COMMON_STD_MDSPAN_HH │ │ │ │ │ 7 │ │ │ │ │ -8#include │ │ │ │ │ -9#include │ │ │ │ │ -10 │ │ │ │ │ -11#include │ │ │ │ │ -12#include │ │ │ │ │ -13#include │ │ │ │ │ -14#include │ │ │ │ │ -15#include │ │ │ │ │ -16 │ │ │ │ │ -17 │ │ │ │ │ -18 │ │ │ │ │ -19namespace Dune { │ │ │ │ │ -20namespace Hybrid { │ │ │ │ │ -21 │ │ │ │ │ -22namespace Impl { │ │ │ │ │ -23 │ │ │ │ │ -24 // Try if std::tuple_size is implemented for class │ │ │ │ │ -25 template │ │ │ │ │ -26 constexpr auto size(const T&, const PriorityTag<2>&) │ │ │ │ │ -27 -> decltype(std::integral_constant::value>()) │ │ │ │ │ -28 { │ │ │ │ │ -29 return {}; │ │ │ │ │ -30 } │ │ │ │ │ -31 │ │ │ │ │ -32 // Try if there's a static constexpr size() method │ │ │ │ │ -33 template │ │ │ │ │ -34 constexpr auto size(const T&, const PriorityTag<1>&) │ │ │ │ │ -35 -> decltype(std::integral_constant()) │ │ │ │ │ -36 { │ │ │ │ │ -37 return {}; │ │ │ │ │ -38 } │ │ │ │ │ -39 │ │ │ │ │ -40 // As a last resort try if there's a non-static size() │ │ │ │ │ -41 template │ │ │ │ │ -42 constexpr auto size(const T& t, const PriorityTag<0>&) │ │ │ │ │ -43 { │ │ │ │ │ -44 return t.size(); │ │ │ │ │ -45 } │ │ │ │ │ -46 │ │ │ │ │ -47} // namespace Impl │ │ │ │ │ -48 │ │ │ │ │ -49 │ │ │ │ │ -50 │ │ │ │ │ -72template │ │ │ │ │ -73constexpr auto size(const T& t) │ │ │ │ │ -74{ │ │ │ │ │ -75 return Impl::size(t, PriorityTag<42>()); │ │ │ │ │ -76} │ │ │ │ │ -77 │ │ │ │ │ -78 │ │ │ │ │ -79 │ │ │ │ │ -80namespace Impl { │ │ │ │ │ -81 │ │ │ │ │ -82 template>::value, int> = 0> │ │ │ │ │ -84 constexpr decltype(auto) elementAt(Container&& c, Index&&, PriorityTag<2>) │ │ │ │ │ -85 { │ │ │ │ │ -86 return std::get::value>(c); │ │ │ │ │ -87 } │ │ │ │ │ -88 │ │ │ │ │ -89 template │ │ │ │ │ -90 constexpr decltype(auto) elementAt(std::integer_sequence c, Index, │ │ │ │ │ -PriorityTag<1>) │ │ │ │ │ -91 { │ │ │ │ │ -92 return Dune::integerSequenceEntry(c, std::integral_constant()); │ │ │ │ │ -93 } │ │ │ │ │ +8#include │ │ │ │ │ +9#include │ │ │ │ │ +10#include │ │ │ │ │ +11#if __has_include() │ │ │ │ │ +12 #include │ │ │ │ │ +13#endif │ │ │ │ │ +14 │ │ │ │ │ +15#include │ │ │ │ │ +16#include │ │ │ │ │ +17#include │ │ │ │ │ +18#include │ │ │ │ │ +19#include │ │ │ │ │ +20 │ │ │ │ │ +21namespace Dune::Std { │ │ │ │ │ +22 │ │ │ │ │ +61template > │ │ │ │ │ +63class mdspan │ │ │ │ │ +64{ │ │ │ │ │ +65 static_assert(std::is_object_v); │ │ │ │ │ +66 static_assert(!std::is_abstract_v); │ │ │ │ │ +67 static_assert(!std::is_array_v); │ │ │ │ │ +68 static_assert(std::is_same_v); │ │ │ │ │ +69 │ │ │ │ │ +70public: │ │ │ │ │ +71 using element_type = Element; │ │ │ │ │ +72 using extents_type = Extents; │ │ │ │ │ +73 using layout_type = LayoutPolicy; │ │ │ │ │ +74 using accessor_type = AccessorPolicy; │ │ │ │ │ +75 │ │ │ │ │ +76 using value_type = std::remove_cv_t; │ │ │ │ │ +77 using mapping_type = typename layout_type::template mapping; │ │ │ │ │ +78 using index_type = typename extents_type::index_type; │ │ │ │ │ +79 using size_type = typename extents_type::size_type; │ │ │ │ │ +80 using rank_type = typename extents_type::rank_type; │ │ │ │ │ +81 using data_handle_type = typename accessor_type::data_handle_type; │ │ │ │ │ +82 using reference = typename accessor_type::reference; │ │ │ │ │ +83 │ │ │ │ │ +84private: │ │ │ │ │ +85 // [mdspan.layout.reqmts] │ │ │ │ │ +86 static_assert(std::is_nothrow_move_constructible_v); │ │ │ │ │ +87 static_assert(std::is_nothrow_move_assignable_v); │ │ │ │ │ +88 static_assert(std::is_nothrow_swappable_v); │ │ │ │ │ +89 │ │ │ │ │ +90 // [mdspan.accessor.reqmts] │ │ │ │ │ +91 static_assert(std::is_nothrow_move_constructible_v); │ │ │ │ │ +92 static_assert(std::is_nothrow_move_assignable_v); │ │ │ │ │ +93 static_assert(std::is_nothrow_swappable_v); │ │ │ │ │ 94 │ │ │ │ │ -95 template │ │ │ │ │ -96 constexpr decltype(auto) elementAt(Container&& c, Index&& i, PriorityTag<0>) │ │ │ │ │ -97 { │ │ │ │ │ -98 return c[i]; │ │ │ │ │ -99 } │ │ │ │ │ -100 │ │ │ │ │ -101} // namespace Impl │ │ │ │ │ -102 │ │ │ │ │ -103 │ │ │ │ │ -104 │ │ │ │ │ -125template │ │ │ │ │ -126constexpr decltype(auto) elementAt(Container&& c, Index&& i) │ │ │ │ │ -127{ │ │ │ │ │ -128 return Impl::elementAt(std::forward(c), std::forward(i), │ │ │ │ │ -PriorityTag<42>()); │ │ │ │ │ -129} │ │ │ │ │ -130 │ │ │ │ │ -131 │ │ │ │ │ -132 │ │ │ │ │ -133namespace Impl { │ │ │ │ │ +95public: │ │ │ │ │ +98 │ │ │ │ │ +100 template 0), int> = 0, │ │ │ │ │ +102 std::enable_if_t, int> = 0, │ │ │ │ │ +103 std::enable_if_t, int> = 0, │ │ │ │ │ +104 std::enable_if_t, int> = 0> │ │ │ │ │ +105 constexpr mdspan () │ │ │ │ │ +106 : data_handle_{} │ │ │ │ │ +107 , mapping_{} │ │ │ │ │ +108 , accessor_{} │ │ │ │ │ +109 {} │ │ │ │ │ +110 │ │ │ │ │ +112 template = 0, │ │ │ │ │ +115 std::enable_if_t<(... && std::is_convertible_v), │ │ │ │ │ +int> = 0, │ │ │ │ │ +116 std::enable_if_t<(... && std::is_nothrow_constructible_v), int> = 0, │ │ │ │ │ +117 std::enable_if_t, int> = 0, │ │ │ │ │ +118 std::enable_if_t, int> = 0> │ │ │ │ │ +119 explicit constexpr mdspan (data_handle_type p, IndexTypes... exts) │ │ │ │ │ +120 : mdspan(std::move(p), extents_type(index_type(std::move(exts))...)) │ │ │ │ │ +121 {} │ │ │ │ │ +122 │ │ │ │ │ +124 template , int> │ │ │ │ │ += 0, │ │ │ │ │ +126 std::enable_if_t, int> = 0, │ │ │ │ │ +127 std::enable_if_t<(N == extents_type::rank_dynamic() || N == extents_type:: │ │ │ │ │ +rank()), int> = 0> │ │ │ │ │ +128 #if __cpp_conditional_explicit >= 201806L │ │ │ │ │ +129 explicit(N != extents_type::rank_dynamic()) │ │ │ │ │ +130 #endif │ │ │ │ │ +131 constexpr mdspan (data_handle_type p, Std::span exts) │ │ │ │ │ +132 : mdspan(std::move(p), extents_type(exts)) │ │ │ │ │ +133 {} │ │ │ │ │ 134 │ │ │ │ │ -135 template::value and │ │ │ │ │ -IsIntegralConstant::value, int> = 0> │ │ │ │ │ -137 constexpr auto integralRange(const Begin& /*begin*/, const End& /*end*/, │ │ │ │ │ -const PriorityTag<1>&) │ │ │ │ │ -138 { │ │ │ │ │ -139 static_assert(Begin::value <= End::value, "You cannot create an │ │ │ │ │ -integralRange where end(); │ │ │ │ │ -141 } │ │ │ │ │ -142 │ │ │ │ │ -143 template │ │ │ │ │ -144 constexpr auto integralRange(const Begin& begin, const End& end, const │ │ │ │ │ -PriorityTag<0>&) │ │ │ │ │ -145 { │ │ │ │ │ -146 assert(begin<=end && "You cannot create an integralRange where end(begin, end); │ │ │ │ │ -148 } │ │ │ │ │ -149 │ │ │ │ │ -150} // namespace Impl │ │ │ │ │ -151 │ │ │ │ │ +136 template , int> = 0, │ │ │ │ │ +138 std::enable_if_t<(N == extents_type::rank_dynamic() || N == extents_type:: │ │ │ │ │ +rank()), int> = 0> │ │ │ │ │ +139 #if __cpp_conditional_explicit >= 201806L │ │ │ │ │ +140 explicit(N != extents_type::rank_dynamic()) │ │ │ │ │ +141 #endif │ │ │ │ │ +142 constexpr mdspan (data_handle_type p, const std::array& exts) │ │ │ │ │ +143 : mdspan(std::move(p), extents_type(exts)) │ │ │ │ │ +144 {} │ │ │ │ │ +145 │ │ │ │ │ +147 template , int> = 0> │ │ │ │ │ +149 constexpr mdspan (data_handle_type p, const extents_type& e) │ │ │ │ │ +150 : mdspan(std::move(p), mapping_type(e)) │ │ │ │ │ +151 {} │ │ │ │ │ 152 │ │ │ │ │ -153 │ │ │ │ │ -171template │ │ │ │ │ -172constexpr auto integralRange(const Begin& begin, const End& end) │ │ │ │ │ -173{ │ │ │ │ │ -174 return Impl::integralRange(begin, end, PriorityTag<42>()); │ │ │ │ │ -175} │ │ │ │ │ -176 │ │ │ │ │ -190template │ │ │ │ │ -191constexpr auto integralRange(const End& end) │ │ │ │ │ -192{ │ │ │ │ │ -193 return Impl::integralRange(Dune::Indices::_0, end, PriorityTag<42>()); │ │ │ │ │ -194} │ │ │ │ │ -195 │ │ │ │ │ -196 │ │ │ │ │ -197 │ │ │ │ │ -198namespace Impl { │ │ │ │ │ +154 template , int> = 0> │ │ │ │ │ +156 constexpr mdspan (data_handle_type p, const mapping_type& m) │ │ │ │ │ +157 : mdspan(std::move(p), m, accessor_type{}) │ │ │ │ │ +158 {} │ │ │ │ │ +159 │ │ │ │ │ +161 constexpr mdspan (data_handle_type p, const mapping_type& m, const │ │ │ │ │ +accessor_type& a) │ │ │ │ │ +162 : data_handle_(std::move(p)) │ │ │ │ │ +163 , mapping_(m) │ │ │ │ │ +164 , accessor_(a) │ │ │ │ │ +165 {} │ │ │ │ │ +166 │ │ │ │ │ +167 │ │ │ │ │ +169 template &>, int> = 0, │ │ │ │ │ +171 std::enable_if_t, int> = 0> │ │ │ │ │ +172 #if __cpp_conditional_explicit >= 201806L │ │ │ │ │ +173 explicit(!std::is_convertible_v&, mapping_type> │ │ │ │ │ +174 || !std::is_convertible_v) │ │ │ │ │ +175 #endif │ │ │ │ │ +176 constexpr mdspan (const │ │ │ │ │ +mdspan& other) │ │ │ │ │ +noexcept │ │ │ │ │ +177 : mdspan(data_handle_type(other.data_handle()), mapping_type(other.mapping │ │ │ │ │ +()), │ │ │ │ │ +178 accessor_type(other.accessor())) │ │ │ │ │ +179 {} │ │ │ │ │ +180 │ │ │ │ │ +182 │ │ │ │ │ +183 │ │ │ │ │ +186 │ │ │ │ │ +191 template = 0, │ │ │ │ │ +193 std::enable_if_t<(... && std::is_convertible_v), int> │ │ │ │ │ += 0, │ │ │ │ │ +194 std::enable_if_t<(... && std::is_nothrow_constructible_v), int> = 0> │ │ │ │ │ +195 constexpr reference operator() (Indices... indices) const │ │ │ │ │ +196 { │ │ │ │ │ +197 return accessor_.access(data_handle_, mapping_(index_type(std::move │ │ │ │ │ +(indices))...)); │ │ │ │ │ +198 } │ │ │ │ │ 199 │ │ │ │ │ -200 template │ │ │ │ │ -201 constexpr void evaluateFoldExpression(std::initializer_list&&) │ │ │ │ │ -202 {} │ │ │ │ │ -203 │ │ │ │ │ -204 template │ │ │ │ │ -205 constexpr void forEachIndex(Range&& range, F&& f, std::integer_ │ │ │ │ │ -sequence) │ │ │ │ │ -206 { │ │ │ │ │ -207 evaluateFoldExpression({(f(Hybrid::elementAt(range, std::integral_ │ │ │ │ │ -constant())), 0)...}); │ │ │ │ │ -208 } │ │ │ │ │ -209 │ │ │ │ │ -210 template │ │ │ │ │ -211 constexpr void forEach(std::integer_sequence /*range*/, F&& f, │ │ │ │ │ -PriorityTag<2>) │ │ │ │ │ -212 { │ │ │ │ │ -213 evaluateFoldExpression({(f(std::integral_constant()), │ │ │ │ │ -0)...}); │ │ │ │ │ -214 } │ │ │ │ │ -215 │ │ │ │ │ -216 │ │ │ │ │ -217 template()))>::value, int> = 0> │ │ │ │ │ -219 constexpr void forEach(Range&& range, F&& f, PriorityTag<1>) │ │ │ │ │ +200#if __cpp_multidimensional_subscript >= 202110L │ │ │ │ │ +201 │ │ │ │ │ +203 template = 0, │ │ │ │ │ +205 std::enable_if_t<(... && std::is_convertible_v), int> │ │ │ │ │ += 0, │ │ │ │ │ +206 std::enable_if_t<(... && std::is_nothrow_constructible_v), int> = 0> │ │ │ │ │ +207 constexpr reference operator[] (Indices... indices) const │ │ │ │ │ +208 { │ │ │ │ │ +209 return accessor_.access(data_handle_, mapping_(index_type(std::move │ │ │ │ │ +(indices))...)); │ │ │ │ │ +210 } │ │ │ │ │ +211 │ │ │ │ │ +212#else // __cpp_multidimensional_subscript │ │ │ │ │ +213 │ │ │ │ │ +216 template , int> = 0, │ │ │ │ │ +218 std::enable_if_t<(E::rank() == 1), int> = 0> │ │ │ │ │ +219 constexpr reference operator[] (Index index) const │ │ │ │ │ 220 { │ │ │ │ │ -221 auto size = Hybrid::size(range); │ │ │ │ │ -222 auto indices = std::make_index_sequence(); │ │ │ │ │ -223 (forEachIndex)(std::forward(range), std::forward(f), indices); │ │ │ │ │ -224 } │ │ │ │ │ +221 return accessor_.access(data_handle_, mapping_(index_type(std::move │ │ │ │ │ +(index)))); │ │ │ │ │ +222 } │ │ │ │ │ +223 │ │ │ │ │ +224#endif // __cpp_multidimensional_subscript │ │ │ │ │ 225 │ │ │ │ │ -226 template │ │ │ │ │ -227 constexpr void forEach(Range&& range, F&& f, PriorityTag<0>) │ │ │ │ │ -228 { │ │ │ │ │ -229 for(auto&& e : range) │ │ │ │ │ -230 f(e); │ │ │ │ │ -231 } │ │ │ │ │ -232 │ │ │ │ │ -233} // namespace Impl │ │ │ │ │ -234 │ │ │ │ │ -235 │ │ │ │ │ +227 template , int> = 0, │ │ │ │ │ +229 std::enable_if_t, │ │ │ │ │ +int> = 0> │ │ │ │ │ +230 constexpr reference operator[]_(Std::span │ │ │ │ │ +indices) const │ │ │ │ │ +231 { │ │ │ │ │ +232 return unpackIntegerSequence([&](auto... ii) -> reference { │ │ │ │ │ +233 return accessor_.access(data_handle_, mapping_(index_type(indices │ │ │ │ │ +[ii])...)); }, │ │ │ │ │ +234 std::make_index_sequence{}); │ │ │ │ │ +235 } │ │ │ │ │ 236 │ │ │ │ │ -255template │ │ │ │ │ -256constexpr void forEach(Range&& range, F&& f) │ │ │ │ │ -257{ │ │ │ │ │ -258 Impl::forEach(std::forward(range), std::forward(f), │ │ │ │ │ -PriorityTag<42>()); │ │ │ │ │ -259} │ │ │ │ │ +238 template , int> = 0, │ │ │ │ │ +240 std::enable_if_t, │ │ │ │ │ +int> = 0> │ │ │ │ │ +241 constexpr reference operator[]_(const std::array& indices) const │ │ │ │ │ +242 { │ │ │ │ │ +243 return std::apply([&](auto... ii) -> reference { │ │ │ │ │ +244 return accessor_.access(data_handle_, mapping_(index_type(ii)...)); }, │ │ │ │ │ +indices); │ │ │ │ │ +245 } │ │ │ │ │ +246 │ │ │ │ │ +248 │ │ │ │ │ +250 constexpr const extents_type& extents () const noexcept { return │ │ │ │ │ +mapping_.extents(); } │ │ │ │ │ +251 │ │ │ │ │ +253 constexpr const mapping_type& mapping () const noexcept { return mapping_; │ │ │ │ │ +} │ │ │ │ │ +254 │ │ │ │ │ +256 constexpr const accessor_type& accessor () const noexcept { return │ │ │ │ │ +accessor_; } │ │ │ │ │ +257 │ │ │ │ │ +259 constexpr const data_handle_type& data_handle () const noexcept { return │ │ │ │ │ +data_handle_; }; │ │ │ │ │ 260 │ │ │ │ │ 261 │ │ │ │ │ -262 │ │ │ │ │ -278template │ │ │ │ │ -279constexpr T accumulate(Range&& range, T value, F&& f) │ │ │ │ │ -280{ │ │ │ │ │ -281 forEach(std::forward(range), [&](auto&& entry) { │ │ │ │ │ -282 value = f(value, entry); │ │ │ │ │ -283 }); │ │ │ │ │ -284 return value; │ │ │ │ │ -285} │ │ │ │ │ -286 │ │ │ │ │ -287 │ │ │ │ │ +264 │ │ │ │ │ +266 static constexpr rank_type rank () noexcept { return extents_type::rank(); │ │ │ │ │ +} │ │ │ │ │ +267 │ │ │ │ │ +269 static constexpr rank_type rank_dynamic () noexcept { return extents_type:: │ │ │ │ │ +rank_dynamic(); } │ │ │ │ │ +270 │ │ │ │ │ +272 static constexpr std::size_t static_extent (rank_type r) noexcept { return │ │ │ │ │ +extents_type::static_extent(r); } │ │ │ │ │ +273 │ │ │ │ │ +275 constexpr index_type extent (rank_type r) const noexcept { return extents │ │ │ │ │ +().extent(r); } │ │ │ │ │ +276 │ │ │ │ │ +278 constexpr size_type size () const noexcept │ │ │ │ │ +279 { │ │ │ │ │ +280 size_type s = 1; │ │ │ │ │ +281 for (rank_type r = 0; r < rank(); ++r) │ │ │ │ │ +282 s *= extent(r); │ │ │ │ │ +283 return s; │ │ │ │ │ +284 } │ │ │ │ │ +285 │ │ │ │ │ +287 [[nodiscard]] constexpr bool empty () const noexcept { return size() == 0; │ │ │ │ │ +} │ │ │ │ │ 288 │ │ │ │ │ -289namespace Impl { │ │ │ │ │ 290 │ │ │ │ │ -291 struct Id { │ │ │ │ │ -292 template │ │ │ │ │ -293 constexpr T operator()(T&& x) const { │ │ │ │ │ -294 return std::forward(x); │ │ │ │ │ -295 } │ │ │ │ │ -296 }; │ │ │ │ │ +291 │ │ │ │ │ +293 static constexpr bool is_always_unique () { return mapping_type::is_always_ │ │ │ │ │ +unique(); } │ │ │ │ │ +294 │ │ │ │ │ +296 static constexpr bool is_always_exhaustive () { return mapping_type::is_ │ │ │ │ │ +always_exhaustive(); } │ │ │ │ │ 297 │ │ │ │ │ -298 template │ │ │ │ │ -299 constexpr decltype(auto) ifElse(std::true_type, IfFunc&& ifFunc, ElseFunc&& │ │ │ │ │ -/*elseFunc*/) │ │ │ │ │ -300 { │ │ │ │ │ -301 return ifFunc(Id{}); │ │ │ │ │ -302 } │ │ │ │ │ +299 static constexpr bool is_always_strided () { return mapping_type::is_ │ │ │ │ │ +always_strided(); } │ │ │ │ │ +300 │ │ │ │ │ +302 constexpr bool is_unique () const { return mapping_.is_unique(); } │ │ │ │ │ 303 │ │ │ │ │ -304 template │ │ │ │ │ -305 constexpr decltype(auto) ifElse(std::false_type, IfFunc&& /*ifFunc*/, │ │ │ │ │ -ElseFunc&& elseFunc) │ │ │ │ │ -306 { │ │ │ │ │ -307 return elseFunc(Id{}); │ │ │ │ │ -308 } │ │ │ │ │ -309 │ │ │ │ │ -310 template │ │ │ │ │ -311 decltype(auto) ifElse(const bool& condition, IfFunc&& ifFunc, ElseFunc&& │ │ │ │ │ -elseFunc) │ │ │ │ │ -312 { │ │ │ │ │ -313 if (condition) │ │ │ │ │ -314 return ifFunc(Id{}); │ │ │ │ │ -315 else │ │ │ │ │ -316 return elseFunc(Id{}); │ │ │ │ │ -317 } │ │ │ │ │ +306 constexpr bool is_exhaustive () const { return mapping_.is_exhaustive(); } │ │ │ │ │ +307 │ │ │ │ │ +313 constexpr bool is_strided () const { return mapping_.is_strided(); } │ │ │ │ │ +314 │ │ │ │ │ +316 constexpr index_type stride (rank_type r) const { return mapping_.stride │ │ │ │ │ +(r); } │ │ │ │ │ +317 │ │ │ │ │ 318 │ │ │ │ │ -319} // namespace Impl │ │ │ │ │ -320 │ │ │ │ │ -321 │ │ │ │ │ -322 │ │ │ │ │ -343template │ │ │ │ │ -344decltype(auto) ifElse(const Condition& condition, IfFunc&& ifFunc, │ │ │ │ │ -ElseFunc&& elseFunc) │ │ │ │ │ -345{ │ │ │ │ │ -346 return Impl::ifElse(condition, std::forward(ifFunc), std:: │ │ │ │ │ -forward(elseFunc)); │ │ │ │ │ -347} │ │ │ │ │ +320 friend constexpr void swap (mdspan& x, mdspan& y) noexcept │ │ │ │ │ +321 { │ │ │ │ │ +322 using std::swap; │ │ │ │ │ +323 swap(x.data_handle_, y.data_handle_); │ │ │ │ │ +324 swap(x.mapping_, y.mapping_); │ │ │ │ │ +325 swap(x.accessor_, y.accessor_); │ │ │ │ │ +326 } │ │ │ │ │ +327 │ │ │ │ │ +328 │ │ │ │ │ +329private: │ │ │ │ │ +330 data_handle_type data_handle_; │ │ │ │ │ +331 [[no_unique_address]] mapping_type mapping_; │ │ │ │ │ +332 [[no_unique_address]] accessor_type accessor_; │ │ │ │ │ +333}; │ │ │ │ │ +334 │ │ │ │ │ +335// deduction guides │ │ │ │ │ +336// @{ │ │ │ │ │ +337 │ │ │ │ │ +338template , int> = 0, │ │ │ │ │ +340 std::enable_if_t<(std::rank_v == 1), int> = 0> │ │ │ │ │ +341mdspan (CArray&) │ │ │ │ │ +342 -> mdspan, Std::extents>>; │ │ │ │ │ +343 │ │ │ │ │ +344template >, int> │ │ │ │ │ += 0> │ │ │ │ │ +346mdspan (Pointer&&) │ │ │ │ │ +347 -> mdspan>, Std:: │ │ │ │ │ +extents>; │ │ │ │ │ 348 │ │ │ │ │ -356template │ │ │ │ │ -357void ifElse(const Condition& condition, IfFunc&& ifFunc) │ │ │ │ │ -358{ │ │ │ │ │ -359 ifElse(condition, std::forward(ifFunc), [](auto&&) {}); │ │ │ │ │ -360} │ │ │ │ │ -361 │ │ │ │ │ +349template ), int> = 0, │ │ │ │ │ +351 std::enable_if_t<(sizeof...(II) > 0), int> = 0> │ │ │ │ │ +352mdspan (ElementType*, II...) │ │ │ │ │ +353 -> mdspan>; │ │ │ │ │ +354 │ │ │ │ │ +355template │ │ │ │ │ +356mdspan (ElementType*, Std::span&) │ │ │ │ │ +357 -> mdspan>; │ │ │ │ │ +358 │ │ │ │ │ +359template │ │ │ │ │ +360mdspan (ElementType*, const std::array&) │ │ │ │ │ +361 -> mdspan>; │ │ │ │ │ 362 │ │ │ │ │ -363 │ │ │ │ │ -364namespace Impl { │ │ │ │ │ -365 │ │ │ │ │ -366 struct Max { │ │ │ │ │ -367 template │ │ │ │ │ -368 constexpr decltype(auto) operator()(Args&&... args) const │ │ │ │ │ -369 { │ │ │ │ │ -370 using T = std::common_type_t; │ │ │ │ │ -371 return std::max({T(args)...}); │ │ │ │ │ -372 } │ │ │ │ │ -373 }; │ │ │ │ │ -374 │ │ │ │ │ -375 struct Min { │ │ │ │ │ -376 template │ │ │ │ │ -377 constexpr decltype(auto) operator()(Args&&... args) const │ │ │ │ │ -378 { │ │ │ │ │ -379 using T = std::common_type_t; │ │ │ │ │ -380 return std::min({T(args)...}); │ │ │ │ │ -381 } │ │ │ │ │ -382 }; │ │ │ │ │ -383 │ │ │ │ │ -384} // namespace Impl │ │ │ │ │ -385 │ │ │ │ │ -386 │ │ │ │ │ -417template │ │ │ │ │ -418class HybridFunctor { │ │ │ │ │ -419 │ │ │ │ │ -420 static_assert(std::is_default_constructible_v, │ │ │ │ │ -421 "Operator in integral expressions shall be constexpr default │ │ │ │ │ -constructible"); │ │ │ │ │ -422 │ │ │ │ │ -423 inline static constexpr Functor _functor = Functor{}; │ │ │ │ │ -424 │ │ │ │ │ -425public: │ │ │ │ │ -426 │ │ │ │ │ -436 template │ │ │ │ │ -437 constexpr decltype(auto) operator()(const Args&... args) const │ │ │ │ │ -438 { │ │ │ │ │ -439 if constexpr (std::conjunction_v...>) │ │ │ │ │ -440 { │ │ │ │ │ -441 constexpr auto result = _functor(Args::value...); │ │ │ │ │ -442 // apply functor on integral constant arguments and return an integral │ │ │ │ │ -constant of the result │ │ │ │ │ -443 // this is guaranteed to be evaluated at compile-time │ │ │ │ │ -444 return std::integral_constant,result>{}; │ │ │ │ │ -445 } else { │ │ │ │ │ -446 // apply functor directly on arguments and return the result of the functor │ │ │ │ │ -447 // (integral constants are likely to be casted to underlying type) │ │ │ │ │ -448 // this not is guaranteed to be evaluated at compile-time although is │ │ │ │ │ -possible if expression is constexpr │ │ │ │ │ -449 return _functor(args...); │ │ │ │ │ -450 } │ │ │ │ │ -451 } │ │ │ │ │ -452}; │ │ │ │ │ -453 │ │ │ │ │ -458template │ │ │ │ │ -459constexpr HybridFunctor hybridFunctor(const Functor&) │ │ │ │ │ -460{ │ │ │ │ │ -461 return {}; │ │ │ │ │ -462} │ │ │ │ │ -463 │ │ │ │ │ -484inline constexpr auto max = hybridFunctor(Impl::Max{}); │ │ │ │ │ -485 │ │ │ │ │ -506inline constexpr auto min = hybridFunctor(Impl::Min{}); │ │ │ │ │ -507 │ │ │ │ │ -528inline constexpr auto plus = hybridFunctor(std::plus<>{}); │ │ │ │ │ -529 │ │ │ │ │ -550inline constexpr auto minus = hybridFunctor(std::minus<>{}); │ │ │ │ │ -551 │ │ │ │ │ -572inline constexpr auto equal_to = hybridFunctor(std::equal_to<>{}); │ │ │ │ │ -573 │ │ │ │ │ -574 │ │ │ │ │ -586template │ │ │ │ │ -587[[deprecated("Use Hybrid::equal_to instead!")]] constexpr auto equals(T1&& │ │ │ │ │ -t1, T2&& t2){ │ │ │ │ │ -588 return equal_to(std::forward(t1), std::forward(t2)); │ │ │ │ │ -589} │ │ │ │ │ -590 │ │ │ │ │ -591 │ │ │ │ │ -592namespace Impl { │ │ │ │ │ -593 │ │ │ │ │ -594 // This overload is selected if the passed value is already a compile time │ │ │ │ │ -constant. │ │ │ │ │ -595 template │ │ │ │ │ -596 constexpr Result switchCases(std::integer_sequence, const │ │ │ │ │ -std::integral_constant& /*value*/, Branches&& branches, │ │ │ │ │ -ElseBranch&& elseBranch) │ │ │ │ │ -597 { │ │ │ │ │ -598 // In case we pass a value known at compile time, we no longer have to do │ │ │ │ │ -599 // a dynamic to static dispatch via recursion. The only thing that's left │ │ │ │ │ -600 // is to check if the value is contained in the passed range. │ │ │ │ │ -601 // If this is true, we have to pass it to the branches callback │ │ │ │ │ -602 // as an appropriate integral_constant type. Otherwise we have to │ │ │ │ │ -603 // execute the else callback. │ │ │ │ │ -604 if constexpr (((t0 == value) || ... || (tt == value))) │ │ │ │ │ -605 return branches(std::integral_constant{}); │ │ │ │ │ -606 else │ │ │ │ │ -607 return elseBranch(); │ │ │ │ │ -608 } │ │ │ │ │ -609 │ │ │ │ │ -610 // This overload is selected if the passed value is dynamic. │ │ │ │ │ -611 template │ │ │ │ │ -612 constexpr Result switchCases(std::integer_sequence, const Value& / │ │ │ │ │ -*value*/, Branches&& /*branches*/, ElseBranch&& elseBranch) │ │ │ │ │ -613 { │ │ │ │ │ -614 return elseBranch(); │ │ │ │ │ -615 } │ │ │ │ │ -616 │ │ │ │ │ -617 template │ │ │ │ │ -618 constexpr Result switchCases(std::integer_sequence, const │ │ │ │ │ -Value& value, Branches&& branches, ElseBranch&& elseBranch) │ │ │ │ │ -619 { │ │ │ │ │ -620 if (t0 == value) │ │ │ │ │ -621 return branches(std::integral_constant()); │ │ │ │ │ -622 else │ │ │ │ │ -623 return Impl::switchCases(std::integer_sequence(), value, │ │ │ │ │ -branches, elseBranch); │ │ │ │ │ -624 } │ │ │ │ │ -625 │ │ │ │ │ -626 // This overload is selected if the range of cases is an IntegralRange │ │ │ │ │ -627 template │ │ │ │ │ -628 constexpr Result switchCases(IntegralRange range, const Value& value, │ │ │ │ │ -Branches&& branches, ElseBranch&& elseBranch) │ │ │ │ │ -629 { │ │ │ │ │ -630 return range.contains(value) ? branches(T(value)) : elseBranch(); │ │ │ │ │ -631 } │ │ │ │ │ -632 │ │ │ │ │ -633 // This overload is selected if the range of cases is a StaticIntegralRange │ │ │ │ │ -634 template │ │ │ │ │ -635 constexpr Result switchCases(StaticIntegralRange range, const │ │ │ │ │ -Value& value, Branches&& branches, ElseBranch&& elseBranch) │ │ │ │ │ -636 { │ │ │ │ │ -637 using seq = typename decltype(range)::integer_sequence; │ │ │ │ │ -638 return Impl::switchCases(seq{}, value, branches, elseBranch); │ │ │ │ │ -639 } │ │ │ │ │ -640 │ │ │ │ │ -641} // namespace Impl │ │ │ │ │ -642 │ │ │ │ │ -643 │ │ │ │ │ -644 │ │ │ │ │ -672template │ │ │ │ │ -673constexpr decltype(auto) switchCases(const Cases& cases, const Value& value, │ │ │ │ │ -Branches&& branches, ElseBranch&& elseBranch) │ │ │ │ │ -674{ │ │ │ │ │ -675 return Impl::switchCases(cases, value, std:: │ │ │ │ │ -forward(branches), std::forward(elseBranch)); │ │ │ │ │ -676} │ │ │ │ │ -677 │ │ │ │ │ -697template │ │ │ │ │ -698constexpr void switchCases(const Cases& cases, const Value& value, │ │ │ │ │ -Branches&& branches) │ │ │ │ │ -699{ │ │ │ │ │ -700 Impl::switchCases(cases, value, std::forward(branches), │ │ │ │ │ -701 []{ assert(false && "value not found in range"); }); │ │ │ │ │ -702} │ │ │ │ │ -703 │ │ │ │ │ -722template │ │ │ │ │ -723constexpr void switchCases(IntegralRange range, const Value& value, │ │ │ │ │ -Branches&& branches) │ │ │ │ │ -724{ │ │ │ │ │ -725 assert(range.contains(value) && "value not found in range"); │ │ │ │ │ -726 branches(T(value)); │ │ │ │ │ -727} │ │ │ │ │ -728 │ │ │ │ │ -729} // namespace Hybrid │ │ │ │ │ -730} // namespace Dune │ │ │ │ │ -731 │ │ │ │ │ -732 │ │ │ │ │ -733#endif // #ifndef DUNE_COMMON_HYBRIDUTILITIES_HH │ │ │ │ │ -rangeutilities.hh │ │ │ │ │ -Utilities for reduction like operations on ranges. │ │ │ │ │ -typeutilities.hh │ │ │ │ │ -Utilities for type computations, constraining overloads, ... │ │ │ │ │ -fvector.hh │ │ │ │ │ -Implements a vector constructed from a given type representing a field and a │ │ │ │ │ -compile-time given size. │ │ │ │ │ +363template │ │ │ │ │ +364mdspan (ElementType*, const Std::extents&) │ │ │ │ │ +365 -> mdspan>; │ │ │ │ │ +366 │ │ │ │ │ +367template │ │ │ │ │ +370mdspan (ElementType*, const Mapping&) │ │ │ │ │ +371 -> mdspan; │ │ │ │ │ +372 │ │ │ │ │ +373template │ │ │ │ │ +378mdspan (const DataHandle&, const Mapping&, const Accessor&) │ │ │ │ │ +379 -> mdspan; │ │ │ │ │ +380 │ │ │ │ │ +381// @} │ │ │ │ │ +382 │ │ │ │ │ +383} // end namespace Dune::Std │ │ │ │ │ +384 │ │ │ │ │ +385#endif // DUNE_COMMON_STD_MDSPAN_HH │ │ │ │ │ indices.hh │ │ │ │ │ -typetraits.hh │ │ │ │ │ -Traits for type conversions and type information. │ │ │ │ │ -Dune::Indices::_0 │ │ │ │ │ -constexpr index_constant< 0 > _0 │ │ │ │ │ -Compile time index with value 0. │ │ │ │ │ -Definition indices.hh:52 │ │ │ │ │ -Dune::range │ │ │ │ │ -static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from │ │ │ │ │ ->, std::integral_constant< T, to >) noexcept │ │ │ │ │ -Definition rangeutilities.hh:312 │ │ │ │ │ -Dune::Hybrid::size │ │ │ │ │ -constexpr auto size(const T &t) │ │ │ │ │ -Size query. │ │ │ │ │ -Definition hybridutilities.hh:73 │ │ │ │ │ -Dune::Hybrid::minus │ │ │ │ │ -constexpr auto minus │ │ │ │ │ -Function object for performing subtraction. │ │ │ │ │ -Definition hybridutilities.hh:550 │ │ │ │ │ -Dune::Hybrid::equals │ │ │ │ │ -constexpr auto equals(T1 &&t1, T2 &&t2) │ │ │ │ │ -Equality comparison. │ │ │ │ │ -Definition hybridutilities.hh:587 │ │ │ │ │ -Dune::Hybrid::forEach │ │ │ │ │ -constexpr void forEach(Range &&range, F &&f) │ │ │ │ │ -Range based for loop. │ │ │ │ │ -Definition hybridutilities.hh:256 │ │ │ │ │ -Dune::Hybrid::equal_to │ │ │ │ │ -constexpr auto equal_to │ │ │ │ │ -Function object for performing equality comparison. │ │ │ │ │ -Definition hybridutilities.hh:572 │ │ │ │ │ -Dune::Hybrid::switchCases │ │ │ │ │ -constexpr decltype(auto) switchCases(const Cases &cases, const Value &value, │ │ │ │ │ -Branches &&branches, ElseBranch &&elseBranch) │ │ │ │ │ -Switch statement. │ │ │ │ │ -Definition hybridutilities.hh:673 │ │ │ │ │ -Dune::Hybrid::max │ │ │ │ │ -constexpr auto max │ │ │ │ │ -Function object that returns the greater of the given values. │ │ │ │ │ -Definition hybridutilities.hh:484 │ │ │ │ │ -Dune::Hybrid::plus │ │ │ │ │ -constexpr auto plus │ │ │ │ │ -Function object for performing addition. │ │ │ │ │ -Definition hybridutilities.hh:528 │ │ │ │ │ -Dune::Hybrid::min │ │ │ │ │ -constexpr auto min │ │ │ │ │ -Function object that returns the smaller of the given values. │ │ │ │ │ -Definition hybridutilities.hh:506 │ │ │ │ │ -Dune::Hybrid::ifElse │ │ │ │ │ -decltype(auto) ifElse(const Condition &condition, IfFunc &&ifFunc, ElseFunc │ │ │ │ │ -&&elseFunc) │ │ │ │ │ -A conditional expression. │ │ │ │ │ -Definition hybridutilities.hh:344 │ │ │ │ │ -Dune::Hybrid::integralRange │ │ │ │ │ -constexpr auto integralRange(const Begin &begin, const End &end) │ │ │ │ │ -Create an integral range. │ │ │ │ │ -Definition hybridutilities.hh:172 │ │ │ │ │ -Dune::Hybrid::elementAt │ │ │ │ │ -constexpr decltype(auto) elementAt(Container &&c, Index &&i) │ │ │ │ │ -Get element at given position from container. │ │ │ │ │ -Definition hybridutilities.hh:126 │ │ │ │ │ -Dune::Hybrid::accumulate │ │ │ │ │ -constexpr T accumulate(Range &&range, T value, F &&f) │ │ │ │ │ -Accumulate values. │ │ │ │ │ -Definition hybridutilities.hh:279 │ │ │ │ │ -Dune::integerSequenceEntry │ │ │ │ │ -constexpr auto integerSequenceEntry(std::integer_sequence< T, t... >, std:: │ │ │ │ │ -integral_constant< std::size_t, index > i) │ │ │ │ │ -Get entry of std::integer_sequence. │ │ │ │ │ -Definition typetraits.hh:492 │ │ │ │ │ -Dune │ │ │ │ │ -Dune namespace. │ │ │ │ │ -Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::Hybrid::hybridFunctor │ │ │ │ │ -constexpr HybridFunctor< Functor > hybridFunctor(const Functor &) │ │ │ │ │ -Returns an HybridFunctor adaptor. │ │ │ │ │ -Definition hybridutilities.hh:459 │ │ │ │ │ -Dune::Max │ │ │ │ │ -Definition binaryfunctions.hh:34 │ │ │ │ │ -Dune::Hybrid::HybridFunctor │ │ │ │ │ -Adapter of a hybrid functor that maintains results hybrid. │ │ │ │ │ -Definition hybridutilities.hh:418 │ │ │ │ │ -Dune::IntegralRange │ │ │ │ │ -dynamic integer range for use in range-based for loops │ │ │ │ │ -Definition rangeutilities.hh:177 │ │ │ │ │ -Dune::StaticIntegralRange │ │ │ │ │ -static integer range for use in range-based for loops │ │ │ │ │ -Definition rangeutilities.hh:230 │ │ │ │ │ -Dune::IsIntegralConstant │ │ │ │ │ -Check if T is an std::integral_constant │ │ │ │ │ -Definition typetraits.hh:384 │ │ │ │ │ -Dune::PriorityTag │ │ │ │ │ -Helper class for tagging priorities. │ │ │ │ │ -Definition typeutilities.hh:73 │ │ │ │ │ +extents.hh │ │ │ │ │ +span.hh │ │ │ │ │ +default_accessor.hh │ │ │ │ │ +layout_right.hh │ │ │ │ │ +Dune::unpackIntegerSequence │ │ │ │ │ +decltype(auto) constexpr unpackIntegerSequence(F &&f, std::integer_sequence< I, │ │ │ │ │ +i... > sequence) │ │ │ │ │ +Unpack an std::integer_sequence to std::integral_constant... │ │ │ │ │ +Definition indices.hh:124 │ │ │ │ │ +Dune::Std::dextents │ │ │ │ │ +typename Impl::DExtentsImpl< IndexType, std::make_integer_sequence< std::size_ │ │ │ │ │ +t, R > >::type dextents │ │ │ │ │ +Alias of extents of given rank R and purely dynamic extents. See │ │ │ │ │ +[mdspan.extents.dextents]. │ │ │ │ │ +Definition extents.hh:259 │ │ │ │ │ +std │ │ │ │ │ +STL namespace. │ │ │ │ │ +Dune::Std │ │ │ │ │ +Namespace for features backported from new C++ standards. │ │ │ │ │ +Definition default_accessor.hh:10 │ │ │ │ │ +Dune::Std::extents │ │ │ │ │ +Multidimensional index space with dynamic and static extents. │ │ │ │ │ +Definition extents.hh:54 │ │ │ │ │ +Dune::Std::mdspan │ │ │ │ │ +A multi-dimensional non-owning array view. │ │ │ │ │ +Definition mdspan.hh:64 │ │ │ │ │ +Dune::Std::mdspan::reference │ │ │ │ │ +typename accessor_type::reference reference │ │ │ │ │ +Definition mdspan.hh:82 │ │ │ │ │ +Dune::Std::mdspan::element_type │ │ │ │ │ +Element element_type │ │ │ │ │ +Definition mdspan.hh:71 │ │ │ │ │ +Dune::Std::mdspan::mdspan │ │ │ │ │ +constexpr mdspan(data_handle_type p, const mapping_type &m, const accessor_type │ │ │ │ │ +&a) │ │ │ │ │ +Construct from the pointer to the data of the tensor, an index mapping, and an │ │ │ │ │ +accessor. │ │ │ │ │ +Definition mdspan.hh:161 │ │ │ │ │ +Dune::Std::mdspan::extents_type │ │ │ │ │ +Extents extents_type │ │ │ │ │ +Definition mdspan.hh:72 │ │ │ │ │ +Dune::Std::mdspan::rank_dynamic │ │ │ │ │ +static constexpr rank_type rank_dynamic() noexcept │ │ │ │ │ +Number of dimensions of the tensor. │ │ │ │ │ +Definition mdspan.hh:269 │ │ │ │ │ +Dune::Std::mdspan::is_always_unique │ │ │ │ │ +static constexpr bool is_always_unique() │ │ │ │ │ +Return true only if for every i and j where (i != j || ...) => mapping(i...) != │ │ │ │ │ +mapping(j.... │ │ │ │ │ +Definition mdspan.hh:293 │ │ │ │ │ +Dune::Std::mdspan::index_type │ │ │ │ │ +typename extents_type::index_type index_type │ │ │ │ │ +Definition mdspan.hh:78 │ │ │ │ │ +Dune::Std::mdspan::layout_type │ │ │ │ │ +LayoutPolicy layout_type │ │ │ │ │ +Definition mdspan.hh:73 │ │ │ │ │ +Dune::Std::mdspan::is_strided │ │ │ │ │ +constexpr bool is_strided() const │ │ │ │ │ +Return true only if for every rank index r of extents there exists an integer │ │ │ │ │ +sr such that,... │ │ │ │ │ +Definition mdspan.hh:313 │ │ │ │ │ +Dune::Std::mdspan::mdspan │ │ │ │ │ +constexpr mdspan(data_handle_type p, const mapping_type &m) │ │ │ │ │ +Construct from the pointer to the data of the tensor and an index mapping. │ │ │ │ │ +Definition mdspan.hh:156 │ │ │ │ │ +Dune::Std::mdspan::rank_type │ │ │ │ │ +typename extents_type::rank_type rank_type │ │ │ │ │ +Definition mdspan.hh:80 │ │ │ │ │ +Dune::Std::mdspan::mdspan │ │ │ │ │ +constexpr mdspan(data_handle_type p, const extents_type &e) │ │ │ │ │ +Construct from the pointer to the data of the tensor and its extents. │ │ │ │ │ +Definition mdspan.hh:149 │ │ │ │ │ +Dune::Std::mdspan::value_type │ │ │ │ │ +std::remove_cv_t< Element > value_type │ │ │ │ │ +Definition mdspan.hh:76 │ │ │ │ │ +Dune::Std::mdspan::is_always_exhaustive │ │ │ │ │ +static constexpr bool is_always_exhaustive() │ │ │ │ │ +Return true only if for all k in the range [0, mapping.required_span_size() ) │ │ │ │ │ +there exists an i such ... │ │ │ │ │ +Definition mdspan.hh:296 │ │ │ │ │ +Dune::Std::mdspan::operator[] │ │ │ │ │ +constexpr reference operator[](Index index) const │ │ │ │ │ +Access specified element at position [i0] For a rank one mdspan, the operator │ │ │ │ │ +[i] is added to support ... │ │ │ │ │ +Definition mdspan.hh:219 │ │ │ │ │ +Dune::Std::mdspan::extents │ │ │ │ │ +constexpr const extents_type & extents() const noexcept │ │ │ │ │ +Number of elements in all dimensions of the tensor,. │ │ │ │ │ +Definition mdspan.hh:250 │ │ │ │ │ +Dune::Std::mdspan::extent │ │ │ │ │ +constexpr index_type extent(rank_type r) const noexcept │ │ │ │ │ +Number of elements in the r'th dimension of the tensor. │ │ │ │ │ +Definition mdspan.hh:275 │ │ │ │ │ +Dune::Std::mdspan::swap │ │ │ │ │ +friend constexpr void swap(mdspan &x, mdspan &y) noexcept │ │ │ │ │ +Overloads the std::swap algorithm for std::mdspan. Exchanges the state of x │ │ │ │ │ +with that of y. │ │ │ │ │ +Definition mdspan.hh:320 │ │ │ │ │ +Dune::Std::mdspan::is_always_strided │ │ │ │ │ +static constexpr bool is_always_strided() │ │ │ │ │ +Return true only if for every rank index r of extents there exists an integer │ │ │ │ │ +sr such that,... │ │ │ │ │ +Definition mdspan.hh:299 │ │ │ │ │ +Dune::Std::mdspan::size │ │ │ │ │ +constexpr size_type size() const noexcept │ │ │ │ │ +The number of elements accessible by this multi-dimensional span. │ │ │ │ │ +Definition mdspan.hh:278 │ │ │ │ │ +Dune::Std::mdspan::data_handle_type │ │ │ │ │ +typename accessor_type::data_handle_type data_handle_type │ │ │ │ │ +Definition mdspan.hh:81 │ │ │ │ │ +Dune::Std::mdspan::empty │ │ │ │ │ +constexpr bool empty() const noexcept │ │ │ │ │ +Checks if the size of the index space is zero. │ │ │ │ │ +Definition mdspan.hh:287 │ │ │ │ │ +Dune::Std::mdspan::accessor │ │ │ │ │ +constexpr const accessor_type & accessor() const noexcept │ │ │ │ │ +The accessor policy object. │ │ │ │ │ +Definition mdspan.hh:256 │ │ │ │ │ +Dune::Std::mdspan::accessor_type │ │ │ │ │ +AccessorPolicy accessor_type │ │ │ │ │ +Definition mdspan.hh:74 │ │ │ │ │ +Dune::Std::mdspan::is_exhaustive │ │ │ │ │ +constexpr bool is_exhaustive() const │ │ │ │ │ +Return true only if for all k in the range [0, mapping.required_span_size() ) │ │ │ │ │ +there exists an i such ... │ │ │ │ │ +Definition mdspan.hh:306 │ │ │ │ │ +Dune::Std::mdspan::rank │ │ │ │ │ +static constexpr rank_type rank() noexcept │ │ │ │ │ +Number of dimensions of the tensor. │ │ │ │ │ +Definition mdspan.hh:266 │ │ │ │ │ +Dune::Std::mdspan::static_extent │ │ │ │ │ +static constexpr std::size_t static_extent(rank_type r) noexcept │ │ │ │ │ +Number of elements in the r'th dimension of the tensor. │ │ │ │ │ +Definition mdspan.hh:272 │ │ │ │ │ +Dune::Std::mdspan::mapping │ │ │ │ │ +constexpr const mapping_type & mapping() const noexcept │ │ │ │ │ +Index mapping of a layout policy. │ │ │ │ │ +Definition mdspan.hh:253 │ │ │ │ │ +Dune::Std::mdspan::data_handle │ │ │ │ │ +constexpr const data_handle_type & data_handle() const noexcept │ │ │ │ │ +The pointer to the underlying flat sequence. │ │ │ │ │ +Definition mdspan.hh:259 │ │ │ │ │ +Dune::Std::mdspan::stride │ │ │ │ │ +constexpr index_type stride(rank_type r) const │ │ │ │ │ +The stride along the specified dimension. │ │ │ │ │ +Definition mdspan.hh:316 │ │ │ │ │ +Dune::Std::mdspan::is_unique │ │ │ │ │ +constexpr bool is_unique() const │ │ │ │ │ +Return true only if for every i and j where (i != j || ...) => mapping(i...) != │ │ │ │ │ +mapping(j.... │ │ │ │ │ +Definition mdspan.hh:302 │ │ │ │ │ +Dune::Std::mdspan::mdspan │ │ │ │ │ +constexpr mdspan() │ │ │ │ │ +Default constructor value-initializes all members. │ │ │ │ │ +Definition mdspan.hh:105 │ │ │ │ │ +Dune::Std::mdspan::size_type │ │ │ │ │ +typename extents_type::size_type size_type │ │ │ │ │ +Definition mdspan.hh:79 │ │ │ │ │ +Dune::Std::mdspan::mapping_type │ │ │ │ │ +typename layout_type::template mapping< extents_type > mapping_type │ │ │ │ │ +Definition mdspan.hh:77 │ │ │ │ │ +Dune::Std::span │ │ │ │ │ +A contiguous sequence of elements with static or dynamic extent. │ │ │ │ │ +Definition span.hh:126 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00077.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: scalarmatrixview.hh File Reference │ │ │ │ +dune-common: concept.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,41 +70,90 @@ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │ -Namespaces
│ │ │ │ -
scalarmatrixview.hh File Reference
│ │ │ │ +Classes | │ │ │ │ +Namespaces | │ │ │ │ +Functions
│ │ │ │ +
concept.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ -

Implements a scalar matrix view wrapper around an existing scalar. │ │ │ │ +

Infrastructure for concepts. │ │ │ │ More...

│ │ │ │ -
#include <cstddef>
│ │ │ │ -#include <type_traits>
│ │ │ │ -#include <ostream>
│ │ │ │ -#include <dune/common/boundschecking.hh>
│ │ │ │ -#include <dune/common/typetraits.hh>
│ │ │ │ -#include <dune/common/matvectraits.hh>
│ │ │ │ -#include <dune/common/densematrix.hh>
│ │ │ │ -#include <dune/common/fmatrix.hh>
│ │ │ │ -#include <dune/common/scalarvectorview.hh>
│ │ │ │ +
#include <type_traits>
│ │ │ │ +#include <utility>
│ │ │ │ +#include <tuple>
│ │ │ │ +#include <dune/common/typeutilities.hh>
│ │ │ │ +#include <dune/common/typelist.hh>
│ │ │ │ +#include <dune/common/indices.hh>
│ │ │ │ +#include <dune/common/std/type_traits.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Classes

struct  Dune::Concept::Refines< BaseConcepts >
 Base class for refined concepts. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::Concept
 Namespace for concepts.
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ +Functions

template<class C , class... T>
constexpr auto Dune::models ()
 Check if concept is modeled by given types.
 
template<class C , class Tuple >
constexpr auto Dune::Concept::tupleEntriesModel ()
 
template<bool b, typename std::enable_if< b, int >::type = 0>
constexpr bool Dune::Concept::requireTrue ()
 
template<class C , class... T, typename std::enable_if< models< C, T... >(), int >::type = 0>
constexpr bool Dune::Concept::requireConcept ()
 
template<class C , class... T, typename std::enable_if< models< C, T... >(), int >::type = 0>
constexpr bool Dune::Concept::requireConcept (T &&...)
 
template<class C , class Tuple , typename std::enable_if< tupleEntriesModel< C, Tuple >(), int >::type = 0>
constexpr bool Dune::Concept::requireConceptForTupleEntries ()
 
template<class From , class To , typename std::enable_if< std::is_convertible< From, To >::value, int >::type = 0>
constexpr bool Dune::Concept::requireConvertible ()
 
template<class To , class From , typename std::enable_if< std::is_convertible< From, To >::value, int >::type = 0>
constexpr bool Dune::Concept::requireConvertible (const From &)
 
template<typename T >
constexpr bool Dune::Concept::requireType ()
 
template<class Base , class Derived , typename std::enable_if< std::is_base_of< Base, Derived >::value, int >::type = 0>
constexpr bool Dune::Concept::requireBaseOf ()
 
template<class Base , class Derived , typename std::enable_if< std::is_base_of< Base, Derived >::value, int >::type = 0>
constexpr bool Dune::Concept::requireBaseOf (const Derived &)
 
template<class A , class B , typename std::enable_if< std::is_same< A, B >::value, int >::type = 0>
constexpr bool Dune::Concept::requireSameType ()
 
│ │ │ │

Detailed Description

│ │ │ │ -

Implements a scalar matrix view wrapper around an existing scalar.

│ │ │ │ +

Infrastructure for concepts.

│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,28 +1,78 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Namespaces │ │ │ │ │ -scalarmatrixview.hh File Reference │ │ │ │ │ -Common » Dense_Matrix_and_Vector_Template_Library │ │ │ │ │ -Implements a scalar matrix view wrapper around an existing scalar. More... │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces | Functions │ │ │ │ │ +concept.hh File Reference │ │ │ │ │ +Infrastructure for concepts. More... │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ +Classes │ │ │ │ │ +struct   Dune::Concept::Refines<_BaseConcepts_> │ │ │ │ │ +  Base class for refined concepts. More... │ │ │ │ │ +  │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ +namespace   Dune::Concept │ │ │ │ │ +  Namespace for concepts. │ │ │ │ │ +  │ │ │ │ │ +Functions │ │ │ │ │ +template │ │ │ │ │ +constexpr auto  Dune::models () │ │ │ │ │ +  Check if concept is modeled by given types. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +constexpr auto  Dune::Concept::tupleEntriesModel () │ │ │ │ │ +  │ │ │ │ │ +template::type = 0> │ │ │ │ │ +constexpr bool  Dune::Concept::requireTrue () │ │ │ │ │ +  │ │ │ │ │ +template(), │ │ │ │ │ +int >::type = 0> │ │ │ │ │ +constexpr bool  Dune::Concept::requireConcept () │ │ │ │ │ +  │ │ │ │ │ +template(), │ │ │ │ │ +int >::type = 0> │ │ │ │ │ +constexpr bool  Dune::Concept::requireConcept (T &&...) │ │ │ │ │ +  │ │ │ │ │ +template(), int >::type = 0> │ │ │ │ │ +constexpr bool  Dune::Concept::requireConceptForTupleEntries () │ │ │ │ │ +  │ │ │ │ │ +template::value, int >::type = 0> │ │ │ │ │ +constexpr bool  Dune::Concept::requireConvertible () │ │ │ │ │ +  │ │ │ │ │ +template::value, int >::type = 0> │ │ │ │ │ +constexpr bool  Dune::Concept::requireConvertible (const From &) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +constexpr bool  Dune::Concept::requireType () │ │ │ │ │ +  │ │ │ │ │ +template::value, int >::type = 0> │ │ │ │ │ +constexpr bool  Dune::Concept::requireBaseOf () │ │ │ │ │ +  │ │ │ │ │ +template::value, int >::type = 0> │ │ │ │ │ +constexpr bool  Dune::Concept::requireBaseOf (const Derived &) │ │ │ │ │ +  │ │ │ │ │ +template:: │ │ │ │ │ +value, int >::type = 0> │ │ │ │ │ +constexpr bool  Dune::Concept::requireSameType () │ │ │ │ │ +  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Implements a scalar matrix view wrapper around an existing scalar. │ │ │ │ │ +Infrastructure for concepts. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00077_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: scalarmatrixview.hh Source File │ │ │ │ +dune-common: concept.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,198 +74,313 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
scalarmatrixview.hh
│ │ │ │ +
concept.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_COMMON_SCALARMATRIXVIEW_HH
│ │ │ │ -
6#define DUNE_COMMON_SCALARMATRIXVIEW_HH
│ │ │ │ +
5#ifndef DUNE_COMMON_CONCEPT_HH
│ │ │ │ +
6#define DUNE_COMMON_CONCEPT_HH
│ │ │ │
7
│ │ │ │ -
8#include <cstddef>
│ │ │ │ -
9#include <type_traits>
│ │ │ │ -
10#include <ostream>
│ │ │ │ +
8#include <type_traits>
│ │ │ │ +
9#include <utility>
│ │ │ │ +
10#include <tuple>
│ │ │ │
11
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
18
│ │ │ │ -
19
│ │ │ │ -
20namespace Dune {
│ │ │ │ -
21
│ │ │ │ -
22namespace Impl {
│ │ │ │ -
23
│ │ │ │ -
39 template<class K>
│ │ │ │ -
40 class ScalarMatrixView :
│ │ │ │ -
41 public DenseMatrix<ScalarMatrixView<K>>
│ │ │ │ -
42 {
│ │ │ │ -
43 ScalarVectorView<K> data_;
│ │ │ │ -
44 using Base = DenseMatrix<ScalarMatrixView<K>>;
│ │ │ │ -
45
│ │ │ │ -
46 template <class>
│ │ │ │ -
47 friend class ScalarMatrixView;
│ │ │ │ -
48 public:
│ │ │ │ -
49
│ │ │ │ -
50 //===== type definitions and constants
│ │ │ │ -
51
│ │ │ │ -
54 constexpr static int blocklevel = 1;
│ │ │ │ -
55
│ │ │ │ -
56 using size_type = typename Base::size_type;
│ │ │ │ -
57 using row_type = typename Base::row_type;
│ │ │ │ -
58 using row_reference = typename Base::row_reference;
│ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
16
│ │ │ │ +
23namespace Dune {
│ │ │ │ +
24
│ │ │ │ +
│ │ │ │ +
34namespace Concept {
│ │ │ │ +
35
│ │ │ │ +
36
│ │ │ │ +
37
│ │ │ │ +
52template<class... BaseConcepts>
│ │ │ │ +
│ │ │ │ +
53struct Refines
│ │ │ │ +
54{
│ │ │ │ +
55 typedef TypeList<BaseConcepts...> BaseConceptList;
│ │ │ │ +
56};
│ │ │ │ +
│ │ │ │ +
57
│ │ │ │ +
58
│ │ │ │ +
59#ifndef DOXYGEN
│ │ │ │
60
│ │ │ │ -
63 constexpr static int rows = 1;
│ │ │ │ -
66 constexpr static int cols = 1;
│ │ │ │ +
61namespace Impl {
│ │ │ │ +
62
│ │ │ │ +
63 // #############################################################################
│ │ │ │ +
64 // # All functions following here are implementation details
│ │ │ │ +
65 // # for the models() function below.
│ │ │ │ +
66 // #############################################################################
│ │ │ │
67
│ │ │ │ -
68 //===== constructors
│ │ │ │ -
71 constexpr ScalarMatrixView ()
│ │ │ │ -
72 : data_()
│ │ │ │ -
73 {}
│ │ │ │ -
74
│ │ │ │ -
76 ScalarMatrixView (K* p) :
│ │ │ │ -
77 data_(p)
│ │ │ │ -
78 {}
│ │ │ │ +
68 // Forward declaration
│ │ │ │ +
69 template<class C, class... T>
│ │ │ │ +
70 constexpr bool models();
│ │ │ │ +
71
│ │ │ │ +
72
│ │ │ │ +
73
│ │ │ │ +
74 // Here is the implementation of the concept checking.
│ │ │ │ +
75 // The first two overloads do the magic for checking
│ │ │ │ +
76 // if the requirements of a concept are satisfied.
│ │ │ │ +
77 // The rest is just for checking base concepts in case
│ │ │ │ +
78 // of refinement.
│ │ │ │
79
│ │ │ │ -
81 ScalarMatrixView (const ScalarMatrixView &other) :
│ │ │ │ -
82 Base(),
│ │ │ │ -
83 data_(other.data_)
│ │ │ │ -
84 {}
│ │ │ │ -
85
│ │ │ │ -
87 ScalarMatrixView (ScalarMatrixView &&other) :
│ │ │ │ -
88 Base(),
│ │ │ │ -
89 data_( other.data_ )
│ │ │ │ -
90 {}
│ │ │ │ -
91
│ │ │ │ -
93 ScalarMatrixView& operator= (const ScalarMatrixView& other)
│ │ │ │ -
94 {
│ │ │ │ -
95 data_ = other.data_;
│ │ │ │ -
96 return *this;
│ │ │ │ -
97 }
│ │ │ │ +
80 // This overload is present if type substitution for
│ │ │ │ +
81 // C::require(T...) is successful, i.e., if the T...
│ │ │ │ +
82 // matches the requirement of C. In this case this
│ │ │ │ +
83 // overload is selected because PriorityTag<1>
│ │ │ │ +
84 // is a better match for PrioriryTag<42> than
│ │ │ │ +
85 // PriorityTag<0> in the default overload.
│ │ │ │ +
86 template<class C, class... T,
│ │ │ │ +
87 decltype(std::declval<C>().require(std::declval<T>()...), 0) =0>
│ │ │ │ +
88 constexpr std::true_type matchesRequirement(PriorityTag<1>)
│ │ │ │ +
89 { return {}; }
│ │ │ │ +
90
│ │ │ │ +
91 // If the above overload is ruled out by SFINAE because
│ │ │ │ +
92 // the T... does not match the requirements of C, then
│ │ │ │ +
93 // this default overload drops in.
│ │ │ │ +
94 template<class C, class... T>
│ │ │ │ +
95 constexpr std::false_type matchesRequirement(PriorityTag<0>)
│ │ │ │ +
96 { return {}; }
│ │ │ │ +
97
│ │ │ │
98
│ │ │ │ -
99 template<class KK>
│ │ │ │ -
100 ScalarMatrixView& operator= (const ScalarMatrixView<KK>& other)
│ │ │ │ -
101 {
│ │ │ │ -
102 data_ = other.data_;
│ │ │ │ -
103 return *this;
│ │ │ │ -
104 }
│ │ │ │ -
105
│ │ │ │ -
107 template<typename T,
│ │ │ │ -
108 std::enable_if_t<std::is_convertible<T, K>::value, int> = 0>
│ │ │ │ -
109 inline ScalarMatrixView& operator= (const T& k)
│ │ │ │ -
110 {
│ │ │ │ -
111 data_ = k;
│ │ │ │ -
112 return *this;
│ │ │ │ -
113 }
│ │ │ │ -
114
│ │ │ │ -
115 // make this thing a matrix
│ │ │ │ -
116 static constexpr size_type mat_rows() { return 1; }
│ │ │ │ -
117 static constexpr size_type mat_cols() { return 1; }
│ │ │ │ -
118
│ │ │ │ -
119 row_reference mat_access ([[maybe_unused]] size_type i)
│ │ │ │ -
120 {
│ │ │ │ -
121 DUNE_ASSERT_BOUNDS(i == 0);
│ │ │ │ -
122 return data_;
│ │ │ │ -
123 }
│ │ │ │ -
124
│ │ │ │ -
125 const_row_reference mat_access ([[maybe_unused]] size_type i) const
│ │ │ │ -
126 {
│ │ │ │ -
127 DUNE_ASSERT_BOUNDS(i == 0);
│ │ │ │ -
128 return data_;
│ │ │ │ -
129 }
│ │ │ │ -
130 }; // class ScalarMatrixView
│ │ │ │ -
131
│ │ │ │ -
133 template<typename K>
│ │ │ │ -
134 std::ostream& operator<< (std::ostream& s, const ScalarMatrixView<K>& a)
│ │ │ │ -
135 {
│ │ │ │ -
136 s << a[0][0];
│ │ │ │ -
137 return s;
│ │ │ │ -
138 }
│ │ │ │ -
139
│ │ │ │ -
141 template<class T,
│ │ │ │ -
142 std::enable_if_t<IsNumber<T>::value, int> = 0>
│ │ │ │ -
143 auto asMatrix(T& t)
│ │ │ │ -
144 {
│ │ │ │ -
145 return ScalarMatrixView<T>{&t};
│ │ │ │ -
146 }
│ │ │ │ +
99
│ │ │ │ +
100 // An empty list C of concepts is always matched by T...
│ │ │ │ +
101 template<class...T>
│ │ │ │ +
102 constexpr bool modelsConceptList(TypeList<>)
│ │ │ │ +
103 { return true; }
│ │ │ │ +
104
│ │ │ │ +
105 // A nonempty list C0,..,CN of concepts is modeled
│ │ │ │ +
106 // by T... if it models the concept C0
│ │ │ │ +
107 // and all concepts in the list C1,..,CN.
│ │ │ │ +
108 template<class...T, class C0, class... CC>
│ │ │ │ +
109 constexpr bool modelsConceptList(TypeList<C0, CC...>)
│ │ │ │ +
110 { return models<C0, T...>() and modelsConceptList<T...>(TypeList<CC...>()); }
│ │ │ │ +
111
│ │ │ │ +
112
│ │ │ │ +
113
│ │ │ │ +
114 // If C is an unrefined concept, then T... models C
│ │ │ │ +
115 // if it matches the requirement of C.
│ │ │ │ +
116 template<class C, class... T>
│ │ │ │ +
117 constexpr bool modelsConcept(PriorityTag<0>)
│ │ │ │ +
118 { return matchesRequirement<C, T...>(PriorityTag<42>()); }
│ │ │ │ +
119
│ │ │ │ +
120 // If C is a refined concept, then T... models C
│ │ │ │ +
121 // if it matches the requirement of C and of
│ │ │ │ +
122 // all base concepts.
│ │ │ │ +
123 //
│ │ │ │ +
124 // This overload is used if C::BaseConceptList exists
│ │ │ │ +
125 // due to its higher priority.
│ │ │ │ +
126 template<class C, class... T,
│ │ │ │ +
127 decltype(typename C::BaseConceptList(), 0) = 0>
│ │ │ │ +
128 constexpr bool modelsConcept(PriorityTag<1>)
│ │ │ │ +
129 { return matchesRequirement<C, T...>(PriorityTag<42>()) and modelsConceptList<T...>(typename C::BaseConceptList()); }
│ │ │ │ +
130
│ │ │ │ +
131 // This is the full concept check. It's defined here in the
│ │ │ │ +
132 // implementation namespace with 'constexpr bool' return type
│ │ │ │ +
133 // because we need a forward declaration in order to use it
│ │ │ │ +
134 // internally above.
│ │ │ │ +
135 //
│ │ │ │ +
136 // The actual interface function can then call this one and
│ │ │ │ +
137 // return the result as std::integral_constant<bool,*> which
│ │ │ │ +
138 // does not allow for a forward declaration because the return
│ │ │ │ +
139 // type is deduced.
│ │ │ │ +
140 template<class C, class... T>
│ │ │ │ +
141 constexpr bool models()
│ │ │ │ +
142 {
│ │ │ │ +
143 return modelsConcept<C, T...>(PriorityTag<42>());
│ │ │ │ +
144 }
│ │ │ │ +
145
│ │ │ │ +
146} // namespace Dune::Concept::Impl
│ │ │ │
147
│ │ │ │ -
149 template<class T,
│ │ │ │ -
150 std::enable_if_t<IsNumber<T>::value, int> = 0>
│ │ │ │ -
151 auto asMatrix(const T& t)
│ │ │ │ -
152 {
│ │ │ │ -
153 return ScalarMatrixView<const T>{&t};
│ │ │ │ -
154 }
│ │ │ │ -
155
│ │ │ │ -
157 template<class T,
│ │ │ │ -
158 std::enable_if_t<not IsNumber<T>::value, int> = 0>
│ │ │ │ -
159 T& asMatrix(T& t)
│ │ │ │ -
160 {
│ │ │ │ -
161 return t;
│ │ │ │ -
162 }
│ │ │ │ -
163
│ │ │ │ -
165 template<class T,
│ │ │ │ -
166 std::enable_if_t<not IsNumber<T>::value, int> = 0>
│ │ │ │ -
167 const T& asMatrix(const T& t)
│ │ │ │ -
168 {
│ │ │ │ -
169 return t;
│ │ │ │ -
170 }
│ │ │ │ -
171
│ │ │ │ -
174} // end namespace Impl
│ │ │ │ -
175
│ │ │ │ -
176 template<class K>
│ │ │ │ -
177 struct FieldTraits<Impl::ScalarMatrixView<K>> : public FieldTraits<std::remove_const_t<K>> {};
│ │ │ │ -
178
│ │ │ │ -
179 template<class K>
│ │ │ │ -
180 struct DenseMatVecTraits<Impl::ScalarMatrixView<K>>
│ │ │ │ -
181 {
│ │ │ │ -
182 using derived_type = Impl::ScalarMatrixView<K>;
│ │ │ │ -
183 using row_type = Impl::ScalarVectorView<K>;
│ │ │ │ -
184 using row_reference = row_type&;
│ │ │ │ -
185 using const_row_reference = const row_type&;
│ │ │ │ -
186 using value_type = std::remove_const_t<K>;
│ │ │ │ -
187 using size_type = std::size_t;
│ │ │ │ -
188 };
│ │ │ │ +
148#endif // DOXYGEN
│ │ │ │ +
149
│ │ │ │ +
150} // namespace Dune::Concept
│ │ │ │ +
│ │ │ │ +
151
│ │ │ │ +
152
│ │ │ │ +
153
│ │ │ │ +
183template<class C, class... T>
│ │ │ │ +
│ │ │ │ +
184constexpr auto models()
│ │ │ │ +
185{
│ │ │ │ +
186 return Std::bool_constant<Concept::Impl::models<C, T...>()>();
│ │ │ │ +
187}
│ │ │ │ +
│ │ │ │ +
188
│ │ │ │
189
│ │ │ │
190
│ │ │ │ -
191 template<class K>
│ │ │ │ -
192 struct AutonomousValueType<Impl::ScalarMatrixView<K>>
│ │ │ │ -
193 {
│ │ │ │ -
194 using type = FieldMatrix<std::remove_const_t<K>,1,1>;
│ │ │ │ -
195 };
│ │ │ │ -
196
│ │ │ │ +
191namespace Concept {
│ │ │ │ +
192
│ │ │ │ +
193// #############################################################################
│ │ │ │ +
194// # The method tupleEntriesModel() does the actual check if the types in a tuple
│ │ │ │ +
195// # model a concept using the implementation details above.
│ │ │ │ +
196// #############################################################################
│ │ │ │
197
│ │ │ │ -
198} // end namespace Dune
│ │ │ │ -
199
│ │ │ │ -
200#endif // DUNE_COMMON_SCALARMATRIXVIEW_HH
│ │ │ │ -
Documentation of the traits classes you need to write for each implementation of DenseVector or Dense...
│ │ │ │ -
Implements a matrix constructed from a given type representing a field and compile-time given number ...
│ │ │ │ -
Implements a matrix constructed from a given type representing a field and a compile-time given numbe...
│ │ │ │ -
Macro for wrapping boundary checks.
│ │ │ │ -
Traits for type conversions and type information.
│ │ │ │ -
Implements a scalar vector view wrapper around an existing scalar.
│ │ │ │ -
#define DUNE_ASSERT_BOUNDS(cond)
If DUNE_CHECK_BOUNDS is defined: check if condition cond holds; otherwise, do nothing.
Definition boundschecking.hh:30
│ │ │ │ +
198template<class C, class Tuple>
│ │ │ │ +
│ │ │ │ +
199constexpr auto tupleEntriesModel()
│ │ │ │ +
200{
│ │ │ │ +
201 return Dune::unpackIntegerSequence([&](auto... i) {
│ │ │ │ +
202 return std::conjunction<decltype(Dune::models<C, std::tuple_element_t<decltype(i)::value, Tuple>>())...>();
│ │ │ │ +
203 }, std::make_index_sequence<std::tuple_size_v<Tuple>>());
│ │ │ │ +
204}
│ │ │ │ +
│ │ │ │ +
205
│ │ │ │ +
206// #############################################################################
│ │ │ │ +
207// # The following require*() functions are just helpers that allow to
│ │ │ │ +
208// # propagate a failed check as substitution failure. This is useful
│ │ │ │ +
209// # inside of a concept definition.
│ │ │ │ +
210// #############################################################################
│ │ │ │ +
211
│ │ │ │ +
212// Helper function for use in concept definitions.
│ │ │ │ +
213// If the passed value b is not true, the concept will to be satisfied.
│ │ │ │ +
214template<bool b, typename std::enable_if<b, int>::type = 0>
│ │ │ │ +
│ │ │ │ +
215constexpr bool requireTrue()
│ │ │ │ +
216{
│ │ │ │ +
217 return true;
│ │ │ │ +
218}
│ │ │ │ +
│ │ │ │ +
219
│ │ │ │ +
220// Helper function for use in concept definitions.
│ │ │ │ +
221template<class C, class... T, typename std::enable_if<models<C, T...>(), int>::type = 0>
│ │ │ │ +
│ │ │ │ +
222constexpr bool requireConcept()
│ │ │ │ +
223{
│ │ │ │ +
224 return true;
│ │ │ │ +
225}
│ │ │ │ +
│ │ │ │ +
226
│ │ │ │ +
227// Helper function for use in concept definitions.
│ │ │ │ +
228// This allows to avoid using decltype
│ │ │ │ +
229template<class C, class... T, typename std::enable_if<models<C, T...>(), int>::type = 0>
│ │ │ │ +
│ │ │ │ +
230constexpr bool requireConcept(T&&... /*t*/)
│ │ │ │ +
231{
│ │ │ │ +
232 return true;
│ │ │ │ +
233}
│ │ │ │ +
│ │ │ │ +
234
│ │ │ │ +
235// Helper function for use in concept definitions.
│ │ │ │ +
236// This checks if the concept given as first type is modelled by all types in the tuple passed as argument
│ │ │ │ +
237template<class C, class Tuple, typename std::enable_if<tupleEntriesModel<C, Tuple>(), int>::type = 0>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
239{
│ │ │ │ +
240 return true;
│ │ │ │ +
241}
│ │ │ │ +
│ │ │ │ +
242
│ │ │ │ +
243// Helper function for use in concept definitions.
│ │ │ │ +
244// If the first passed type is not convertible to the second, the concept will not be satisfied.
│ │ │ │ +
245template<class From, class To,
│ │ │ │ +
246 typename std::enable_if< std::is_convertible<From, To>::value, int>::type = 0>
│ │ │ │ +
│ │ │ │ +
247constexpr bool requireConvertible()
│ │ │ │ +
248{
│ │ │ │ +
249 return true;
│ │ │ │ +
250}
│ │ │ │ +
│ │ │ │ +
251
│ │ │ │ +
252// Helper function for use in concept definitions.
│ │ │ │ +
253// If passed argument is not convertible to the first passed type, the concept will not be satisfied.
│ │ │ │ +
254template<class To, class From,
│ │ │ │ +
255 typename std::enable_if< std::is_convertible<From, To>::value, int>::type = 0>
│ │ │ │ +
│ │ │ │ +
256constexpr bool requireConvertible(const From&)
│ │ │ │ +
257{
│ │ │ │ +
258 return true;
│ │ │ │ +
259}
│ │ │ │ +
│ │ │ │ +
260
│ │ │ │ +
261// Helper function for use in concept definitions.
│ │ │ │ +
262// This will always evaluate to true. If just allow
│ │ │ │ +
263// to turn a type into an expression. The failure happens
│ │ │ │ +
264// already during substitution for the type argument.
│ │ │ │ +
265template<typename T>
│ │ │ │ +
│ │ │ │ +
266constexpr bool requireType()
│ │ │ │ +
267{
│ │ │ │ +
268 return true;
│ │ │ │ +
269}
│ │ │ │ +
│ │ │ │ +
270
│ │ │ │ +
271// Helper function for use in concept definitions.
│ │ │ │ +
272// If first passed type is not a base class of second type, the concept will not be satisfied.
│ │ │ │ +
273template<class Base, class Derived,
│ │ │ │ +
274 typename std::enable_if< std::is_base_of<Base, Derived>::value, int>::type = 0>
│ │ │ │ +
│ │ │ │ +
275constexpr bool requireBaseOf()
│ │ │ │ +
276{
│ │ │ │ +
277 return true;
│ │ │ │ +
278}
│ │ │ │ +
│ │ │ │ +
279
│ │ │ │ +
280// Helper function for use in concept definitions.
│ │ │ │ +
281// If first passed type is not a base class of first arguments type, the concept will not be satisfied.
│ │ │ │ +
282template<class Base, class Derived,
│ │ │ │ +
283 typename std::enable_if< std::is_base_of<Base, Derived>::value, int>::type = 0>
│ │ │ │ +
│ │ │ │ +
284constexpr bool requireBaseOf(const Derived&)
│ │ │ │ +
285{
│ │ │ │ +
286 return true;
│ │ │ │ +
287}
│ │ │ │ +
│ │ │ │ +
288
│ │ │ │ +
289// Helper function for use in concept definitions.
│ │ │ │ +
290// If the passed types are not the same, the concept will not be satisfied.
│ │ │ │ +
291template<class A, class B,
│ │ │ │ +
292 typename std::enable_if< std::is_same<A, B>::value, int>::type = 0>
│ │ │ │ +
│ │ │ │ +
293constexpr bool requireSameType()
│ │ │ │ +
294{
│ │ │ │ +
295 return true;
│ │ │ │ +
296}
│ │ │ │ +
│ │ │ │ +
297
│ │ │ │ +
298
│ │ │ │ +
299
│ │ │ │ +
300} // namespace Dune::Concept
│ │ │ │ +
301
│ │ │ │ +
302} // namespace Dune
│ │ │ │ +
303
│ │ │ │ +
304
│ │ │ │ +
305
│ │ │ │ +
306
│ │ │ │ +
307#endif // DUNE_COMMON_CONCEPT_HH
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
Utilities for type computations, constraining overloads, ...
│ │ │ │ +
decltype(auto) constexpr unpackIntegerSequence(F &&f, std::integer_sequence< I, i... > sequence)
Unpack an std::integer_sequence<I,i...> to std::integral_constant<I,i>...
Definition indices.hh:124
│ │ │ │ +
std::tuple< MetaType< T >... > TypeList
A simple type list.
Definition typelist.hh:87
│ │ │ │ +
constexpr auto models()
Check if concept is modeled by given types.
Definition concept.hh:184
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
constexpr size_type cols() const
number of columns
Definition densematrix.hh:715
│ │ │ │ -
constexpr size_type rows() const
number of rows
Definition densematrix.hh:709
│ │ │ │ -
static constexpr int blocklevel
The number of block levels we contain. This is the leaf, that is, 1.
Definition densematrix.hh:178
│ │ │ │ -
Traits::row_type row_type
The type used to represent a row (must fulfill the Dune::DenseVector interface)
Definition densematrix.hh:169
│ │ │ │ -
Traits::size_type size_type
The type used for the index access and size operation.
Definition densematrix.hh:166
│ │ │ │ -
Traits::const_row_reference const_row_reference
The type used to represent a reference to a constant row (usually const row_type &)
Definition densematrix.hh:175
│ │ │ │ -
Traits::row_reference row_reference
The type used to represent a reference to a row (usually row_type &)
Definition densematrix.hh:172
│ │ │ │ -
T type
Definition typetraits.hh:531
│ │ │ │ +
constexpr bool requireConcept()
Definition concept.hh:222
│ │ │ │ +
constexpr bool requireTrue()
Definition concept.hh:215
│ │ │ │ +
constexpr bool requireSameType()
Definition concept.hh:293
│ │ │ │ +
constexpr bool requireConceptForTupleEntries()
Definition concept.hh:238
│ │ │ │ +
constexpr bool requireBaseOf()
Definition concept.hh:275
│ │ │ │ +
constexpr bool requireConvertible()
Definition concept.hh:247
│ │ │ │ +
constexpr auto tupleEntriesModel()
Definition concept.hh:199
│ │ │ │ +
constexpr bool requireType()
Definition concept.hh:266
│ │ │ │ +
Base class for refined concepts.
Definition concept.hh:54
│ │ │ │ +
TypeList< BaseConcepts... > BaseConceptList
Definition concept.hh:55
│ │ │ │ +
Helper class for tagging priorities.
Definition typeutilities.hh:73
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,232 +1,336 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -scalarmatrixview.hh │ │ │ │ │ +concept.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_COMMON_SCALARMATRIXVIEW_HH │ │ │ │ │ -6#define DUNE_COMMON_SCALARMATRIXVIEW_HH │ │ │ │ │ +5#ifndef DUNE_COMMON_CONCEPT_HH │ │ │ │ │ +6#define DUNE_COMMON_CONCEPT_HH │ │ │ │ │ 7 │ │ │ │ │ -8#include │ │ │ │ │ -9#include │ │ │ │ │ -10#include │ │ │ │ │ +8#include │ │ │ │ │ +9#include │ │ │ │ │ +10#include │ │ │ │ │ 11 │ │ │ │ │ -12#include │ │ │ │ │ -13#include │ │ │ │ │ -14#include │ │ │ │ │ -15#include │ │ │ │ │ -16#include │ │ │ │ │ -17#include │ │ │ │ │ -18 │ │ │ │ │ -19 │ │ │ │ │ -20namespace Dune { │ │ │ │ │ -21 │ │ │ │ │ -22namespace Impl { │ │ │ │ │ -23 │ │ │ │ │ -39 template │ │ │ │ │ -40 class ScalarMatrixView : │ │ │ │ │ -41 public DenseMatrix> │ │ │ │ │ -42 { │ │ │ │ │ -43 ScalarVectorView data_; │ │ │ │ │ -44 using Base = DenseMatrix>; │ │ │ │ │ -45 │ │ │ │ │ -46 template │ │ │ │ │ -47 friend class ScalarMatrixView; │ │ │ │ │ -48 public: │ │ │ │ │ -49 │ │ │ │ │ -50 //===== type definitions and constants │ │ │ │ │ -51 │ │ │ │ │ -54 constexpr static int blocklevel = 1; │ │ │ │ │ -55 │ │ │ │ │ -56 using size_type = typename Base::size_type; │ │ │ │ │ -57 using row_type = typename Base::row_type; │ │ │ │ │ -58 using row_reference = typename Base::row_reference; │ │ │ │ │ -59 using const_row_reference = typename Base::const_row_reference; │ │ │ │ │ +12#include │ │ │ │ │ +13#include │ │ │ │ │ +14#include │ │ │ │ │ +15#include │ │ │ │ │ +16 │ │ │ │ │ +23namespace Dune { │ │ │ │ │ +24 │ │ │ │ │ +34namespace Concept { │ │ │ │ │ +35 │ │ │ │ │ +36 │ │ │ │ │ +37 │ │ │ │ │ +52template │ │ │ │ │ +53struct Refines │ │ │ │ │ +54{ │ │ │ │ │ +55 typedef TypeList BaseConceptList; │ │ │ │ │ +56}; │ │ │ │ │ +57 │ │ │ │ │ +58 │ │ │ │ │ +59#ifndef DOXYGEN │ │ │ │ │ 60 │ │ │ │ │ -63 constexpr static int rows = 1; │ │ │ │ │ -66 constexpr static int cols = 1; │ │ │ │ │ +61namespace Impl { │ │ │ │ │ +62 │ │ │ │ │ +63 / │ │ │ │ │ +/ ############################################################################# │ │ │ │ │ +64 // # All functions following here are implementation details │ │ │ │ │ +65 // # for the models() function below. │ │ │ │ │ +66 / │ │ │ │ │ +/ ############################################################################# │ │ │ │ │ 67 │ │ │ │ │ -68 //===== constructors │ │ │ │ │ -71 constexpr ScalarMatrixView () │ │ │ │ │ -72 : data_() │ │ │ │ │ -73 {} │ │ │ │ │ -74 │ │ │ │ │ -76 ScalarMatrixView (K* p) : │ │ │ │ │ -77 data_(p) │ │ │ │ │ -78 {} │ │ │ │ │ +68 // Forward declaration │ │ │ │ │ +69 template │ │ │ │ │ +70 constexpr bool models(); │ │ │ │ │ +71 │ │ │ │ │ +72 │ │ │ │ │ +73 │ │ │ │ │ +74 // Here is the implementation of the concept checking. │ │ │ │ │ +75 // The first two overloads do the magic for checking │ │ │ │ │ +76 // if the requirements of a concept are satisfied. │ │ │ │ │ +77 // The rest is just for checking base concepts in case │ │ │ │ │ +78 // of refinement. │ │ │ │ │ 79 │ │ │ │ │ -81 ScalarMatrixView (const ScalarMatrixView &other) : │ │ │ │ │ -82 Base(), │ │ │ │ │ -83 data_(other.data_) │ │ │ │ │ -84 {} │ │ │ │ │ -85 │ │ │ │ │ -87 ScalarMatrixView (ScalarMatrixView &&other) : │ │ │ │ │ -88 Base(), │ │ │ │ │ -89 data_( other.data_ ) │ │ │ │ │ -90 {} │ │ │ │ │ -91 │ │ │ │ │ -93 ScalarMatrixView& operator= (const ScalarMatrixView& other) │ │ │ │ │ -94 { │ │ │ │ │ -95 data_ = other.data_; │ │ │ │ │ -96 return *this; │ │ │ │ │ -97 } │ │ │ │ │ +80 // This overload is present if type substitution for │ │ │ │ │ +81 // C::require(T...) is successful, i.e., if the T... │ │ │ │ │ +82 // matches the requirement of C. In this case this │ │ │ │ │ +83 // overload is selected because PriorityTag<1> │ │ │ │ │ +84 // is a better match for PrioriryTag<42> than │ │ │ │ │ +85 // PriorityTag<0> in the default overload. │ │ │ │ │ +86 template().require(std::declval()...), 0) =0> │ │ │ │ │ +88 constexpr std::true_type matchesRequirement(PriorityTag<1>) │ │ │ │ │ +89 { return {}; } │ │ │ │ │ +90 │ │ │ │ │ +91 // If the above overload is ruled out by SFINAE because │ │ │ │ │ +92 // the T... does not match the requirements of C, then │ │ │ │ │ +93 // this default overload drops in. │ │ │ │ │ +94 template │ │ │ │ │ +95 constexpr std::false_type matchesRequirement(PriorityTag<0>) │ │ │ │ │ +96 { return {}; } │ │ │ │ │ +97 │ │ │ │ │ 98 │ │ │ │ │ -99 template │ │ │ │ │ -100 ScalarMatrixView& operator= (const ScalarMatrixView& other) │ │ │ │ │ -101 { │ │ │ │ │ -102 data_ = other.data_; │ │ │ │ │ -103 return *this; │ │ │ │ │ -104 } │ │ │ │ │ -105 │ │ │ │ │ -107 template::value, int> = 0> │ │ │ │ │ -109 inline ScalarMatrixView& operator= (const T& k) │ │ │ │ │ -110 { │ │ │ │ │ -111 data_ = k; │ │ │ │ │ -112 return *this; │ │ │ │ │ -113 } │ │ │ │ │ -114 │ │ │ │ │ -115 // make this thing a matrix │ │ │ │ │ -116 static constexpr size_type mat_rows() { return 1; } │ │ │ │ │ -117 static constexpr size_type mat_cols() { return 1; } │ │ │ │ │ -118 │ │ │ │ │ -119 row_reference mat_access ([[maybe_unused]] size_type i) │ │ │ │ │ -120 { │ │ │ │ │ -121 DUNE_ASSERT_BOUNDS(i == 0); │ │ │ │ │ -122 return data_; │ │ │ │ │ -123 } │ │ │ │ │ -124 │ │ │ │ │ -125 const_row_reference mat_access ([[maybe_unused]] size_type i) const │ │ │ │ │ -126 { │ │ │ │ │ -127 DUNE_ASSERT_BOUNDS(i == 0); │ │ │ │ │ -128 return data_; │ │ │ │ │ -129 } │ │ │ │ │ -130 }; // class ScalarMatrixView │ │ │ │ │ -131 │ │ │ │ │ -133 template │ │ │ │ │ -134 std::ostream& operator<< (std::ostream& s, const ScalarMatrixView& a) │ │ │ │ │ -135 { │ │ │ │ │ -136 s << a[0][0]; │ │ │ │ │ -137 return s; │ │ │ │ │ -138 } │ │ │ │ │ -139 │ │ │ │ │ -141 template::value, int> = 0> │ │ │ │ │ -143 auto asMatrix(T& t) │ │ │ │ │ -144 { │ │ │ │ │ -145 return ScalarMatrixView{&t}; │ │ │ │ │ -146 } │ │ │ │ │ +99 │ │ │ │ │ +100 // An empty list C of concepts is always matched by T... │ │ │ │ │ +101 template │ │ │ │ │ +102 constexpr bool modelsConceptList(TypeList<>) │ │ │ │ │ +103 { return true; } │ │ │ │ │ +104 │ │ │ │ │ +105 // A nonempty list C0,..,CN of concepts is modeled │ │ │ │ │ +106 // by T... if it models the concept C0 │ │ │ │ │ +107 // and all concepts in the list C1,..,CN. │ │ │ │ │ +108 template │ │ │ │ │ +109 constexpr bool modelsConceptList(TypeList) │ │ │ │ │ +110 { return models() and modelsConceptList(TypeList()); │ │ │ │ │ +} │ │ │ │ │ +111 │ │ │ │ │ +112 │ │ │ │ │ +113 │ │ │ │ │ +114 // If C is an unrefined concept, then T... models C │ │ │ │ │ +115 // if it matches the requirement of C. │ │ │ │ │ +116 template │ │ │ │ │ +117 constexpr bool modelsConcept(PriorityTag<0>) │ │ │ │ │ +118 { return matchesRequirement(PriorityTag<42>()); } │ │ │ │ │ +119 │ │ │ │ │ +120 // If C is a refined concept, then T... models C │ │ │ │ │ +121 // if it matches the requirement of C and of │ │ │ │ │ +122 // all base concepts. │ │ │ │ │ +123 // │ │ │ │ │ +124 // This overload is used if C::BaseConceptList exists │ │ │ │ │ +125 // due to its higher priority. │ │ │ │ │ +126 template │ │ │ │ │ +128 constexpr bool modelsConcept(PriorityTag<1>) │ │ │ │ │ +129 { return matchesRequirement(PriorityTag<42>()) and │ │ │ │ │ +modelsConceptList(typename C::BaseConceptList()); } │ │ │ │ │ +130 │ │ │ │ │ +131 // This is the full concept check. It's defined here in the │ │ │ │ │ +132 // implementation namespace with 'constexpr bool' return type │ │ │ │ │ +133 // because we need a forward declaration in order to use it │ │ │ │ │ +134 // internally above. │ │ │ │ │ +135 // │ │ │ │ │ +136 // The actual interface function can then call this one and │ │ │ │ │ +137 // return the result as std::integral_constant which │ │ │ │ │ +138 // does not allow for a forward declaration because the return │ │ │ │ │ +139 // type is deduced. │ │ │ │ │ +140 template │ │ │ │ │ +141 constexpr bool models() │ │ │ │ │ +142 { │ │ │ │ │ +143 return modelsConcept(PriorityTag<42>()); │ │ │ │ │ +144 } │ │ │ │ │ +145 │ │ │ │ │ +146} // namespace Dune::Concept::Impl │ │ │ │ │ 147 │ │ │ │ │ -149 template::value, int> = 0> │ │ │ │ │ -151 auto asMatrix(const T& t) │ │ │ │ │ -152 { │ │ │ │ │ -153 return ScalarMatrixView{&t}; │ │ │ │ │ -154 } │ │ │ │ │ -155 │ │ │ │ │ -157 template::value, int> = 0> │ │ │ │ │ -159 T& asMatrix(T& t) │ │ │ │ │ -160 { │ │ │ │ │ -161 return t; │ │ │ │ │ -162 } │ │ │ │ │ -163 │ │ │ │ │ -165 template::value, int> = 0> │ │ │ │ │ -167 const T& asMatrix(const T& t) │ │ │ │ │ -168 { │ │ │ │ │ -169 return t; │ │ │ │ │ -170 } │ │ │ │ │ -171 │ │ │ │ │ -174} // end namespace Impl │ │ │ │ │ -175 │ │ │ │ │ -176 template │ │ │ │ │ -177 struct FieldTraits> : public FieldTraits> {}; │ │ │ │ │ -178 │ │ │ │ │ -179 template │ │ │ │ │ -180 struct DenseMatVecTraits> │ │ │ │ │ -181 { │ │ │ │ │ -182 using derived_type = Impl::ScalarMatrixView; │ │ │ │ │ -183 using row_type = Impl::ScalarVectorView; │ │ │ │ │ -184 using row_reference = row_type&; │ │ │ │ │ -185 using const_row_reference = const row_type&; │ │ │ │ │ -186 using value_type = std::remove_const_t; │ │ │ │ │ -187 using size_type = std::size_t; │ │ │ │ │ -188 }; │ │ │ │ │ +148#endif // DOXYGEN │ │ │ │ │ +149 │ │ │ │ │ +150} // namespace Dune::Concept │ │ │ │ │ +151 │ │ │ │ │ +152 │ │ │ │ │ +153 │ │ │ │ │ +183template │ │ │ │ │ +184constexpr auto models() │ │ │ │ │ +185{ │ │ │ │ │ +186 return Std::bool_constant()>(); │ │ │ │ │ +187} │ │ │ │ │ +188 │ │ │ │ │ 189 │ │ │ │ │ 190 │ │ │ │ │ -191 template │ │ │ │ │ -192 struct AutonomousValueType> │ │ │ │ │ -193 { │ │ │ │ │ -194 using type = FieldMatrix,1,1>; │ │ │ │ │ -195 }; │ │ │ │ │ -196 │ │ │ │ │ +191namespace Concept { │ │ │ │ │ +192 │ │ │ │ │ +193/ │ │ │ │ │ +/ ############################################################################# │ │ │ │ │ +194// # The method tupleEntriesModel() does the actual check if the types in a │ │ │ │ │ +tuple │ │ │ │ │ +195// # model a concept using the implementation details above. │ │ │ │ │ +196/ │ │ │ │ │ +/ ############################################################################# │ │ │ │ │ 197 │ │ │ │ │ -198} // end namespace Dune │ │ │ │ │ -199 │ │ │ │ │ -200#endif // DUNE_COMMON_SCALARMATRIXVIEW_HH │ │ │ │ │ -matvectraits.hh │ │ │ │ │ -Documentation of the traits classes you need to write for each implementation │ │ │ │ │ -of DenseVector or Dense... │ │ │ │ │ -fmatrix.hh │ │ │ │ │ -Implements a matrix constructed from a given type representing a field and │ │ │ │ │ -compile-time given number ... │ │ │ │ │ -densematrix.hh │ │ │ │ │ -Implements a matrix constructed from a given type representing a field and a │ │ │ │ │ -compile-time given numbe... │ │ │ │ │ -boundschecking.hh │ │ │ │ │ -Macro for wrapping boundary checks. │ │ │ │ │ -typetraits.hh │ │ │ │ │ -Traits for type conversions and type information. │ │ │ │ │ -scalarvectorview.hh │ │ │ │ │ -Implements a scalar vector view wrapper around an existing scalar. │ │ │ │ │ -DUNE_ASSERT_BOUNDS │ │ │ │ │ -#define DUNE_ASSERT_BOUNDS(cond) │ │ │ │ │ -If DUNE_CHECK_BOUNDS is defined: check if condition cond holds; otherwise, do │ │ │ │ │ -nothing. │ │ │ │ │ -Definition boundschecking.hh:30 │ │ │ │ │ +198template │ │ │ │ │ +199constexpr auto tupleEntriesModel() │ │ │ │ │ +200{ │ │ │ │ │ +201 return Dune::unpackIntegerSequence([&](auto... i) { │ │ │ │ │ +202 return std::conjunction>())...>(); │ │ │ │ │ +203 }, std::make_index_sequence>()); │ │ │ │ │ +204} │ │ │ │ │ +205 │ │ │ │ │ +206/ │ │ │ │ │ +/ ############################################################################# │ │ │ │ │ +207// # The following require*() functions are just helpers that allow to │ │ │ │ │ +208// # propagate a failed check as substitution failure. This is useful │ │ │ │ │ +209// # inside of a concept definition. │ │ │ │ │ +210/ │ │ │ │ │ +/ ############################################################################# │ │ │ │ │ +211 │ │ │ │ │ +212// Helper function for use in concept definitions. │ │ │ │ │ +213// If the passed value b is not true, the concept will to be satisfied. │ │ │ │ │ +214template::type = 0> │ │ │ │ │ +215constexpr bool requireTrue() │ │ │ │ │ +216{ │ │ │ │ │ +217 return true; │ │ │ │ │ +218} │ │ │ │ │ +219 │ │ │ │ │ +220// Helper function for use in concept definitions. │ │ │ │ │ +221template(), │ │ │ │ │ +int>::type = 0> │ │ │ │ │ +222constexpr bool requireConcept() │ │ │ │ │ +223{ │ │ │ │ │ +224 return true; │ │ │ │ │ +225} │ │ │ │ │ +226 │ │ │ │ │ +227// Helper function for use in concept definitions. │ │ │ │ │ +228// This allows to avoid using decltype │ │ │ │ │ +229template(), │ │ │ │ │ +int>::type = 0> │ │ │ │ │ +230constexpr bool requireConcept(T&&... /*t*/) │ │ │ │ │ +231{ │ │ │ │ │ +232 return true; │ │ │ │ │ +233} │ │ │ │ │ +234 │ │ │ │ │ +235// Helper function for use in concept definitions. │ │ │ │ │ +236// This checks if the concept given as first type is modelled by all types │ │ │ │ │ +in the tuple passed as argument │ │ │ │ │ +237template(), int>::type = 0> │ │ │ │ │ +238constexpr bool requireConceptForTupleEntries() │ │ │ │ │ +239{ │ │ │ │ │ +240 return true; │ │ │ │ │ +241} │ │ │ │ │ +242 │ │ │ │ │ +243// Helper function for use in concept definitions. │ │ │ │ │ +244// If the first passed type is not convertible to the second, the concept │ │ │ │ │ +will not be satisfied. │ │ │ │ │ +245template::value, int>::type = │ │ │ │ │ +0> │ │ │ │ │ +247constexpr bool requireConvertible() │ │ │ │ │ +248{ │ │ │ │ │ +249 return true; │ │ │ │ │ +250} │ │ │ │ │ +251 │ │ │ │ │ +252// Helper function for use in concept definitions. │ │ │ │ │ +253// If passed argument is not convertible to the first passed type, the │ │ │ │ │ +concept will not be satisfied. │ │ │ │ │ +254template::value, int>::type = │ │ │ │ │ +0> │ │ │ │ │ +256constexpr bool requireConvertible(const From&) │ │ │ │ │ +257{ │ │ │ │ │ +258 return true; │ │ │ │ │ +259} │ │ │ │ │ +260 │ │ │ │ │ +261// Helper function for use in concept definitions. │ │ │ │ │ +262// This will always evaluate to true. If just allow │ │ │ │ │ +263// to turn a type into an expression. The failure happens │ │ │ │ │ +264// already during substitution for the type argument. │ │ │ │ │ +265template │ │ │ │ │ +266constexpr bool requireType() │ │ │ │ │ +267{ │ │ │ │ │ +268 return true; │ │ │ │ │ +269} │ │ │ │ │ +270 │ │ │ │ │ +271// Helper function for use in concept definitions. │ │ │ │ │ +272// If first passed type is not a base class of second type, the concept will │ │ │ │ │ +not be satisfied. │ │ │ │ │ +273template::value, int>::type │ │ │ │ │ += 0> │ │ │ │ │ +275constexpr bool requireBaseOf() │ │ │ │ │ +276{ │ │ │ │ │ +277 return true; │ │ │ │ │ +278} │ │ │ │ │ +279 │ │ │ │ │ +280// Helper function for use in concept definitions. │ │ │ │ │ +281// If first passed type is not a base class of first arguments type, the │ │ │ │ │ +concept will not be satisfied. │ │ │ │ │ +282template::value, int>::type │ │ │ │ │ += 0> │ │ │ │ │ +284constexpr bool requireBaseOf(const Derived&) │ │ │ │ │ +285{ │ │ │ │ │ +286 return true; │ │ │ │ │ +287} │ │ │ │ │ +288 │ │ │ │ │ +289// Helper function for use in concept definitions. │ │ │ │ │ +290// If the passed types are not the same, the concept will not be satisfied. │ │ │ │ │ +291template::value, int>::type = 0> │ │ │ │ │ +293constexpr bool requireSameType() │ │ │ │ │ +294{ │ │ │ │ │ +295 return true; │ │ │ │ │ +296} │ │ │ │ │ +297 │ │ │ │ │ +298 │ │ │ │ │ +299 │ │ │ │ │ +300} // namespace Dune::Concept │ │ │ │ │ +301 │ │ │ │ │ +302} // namespace Dune │ │ │ │ │ +303 │ │ │ │ │ +304 │ │ │ │ │ +305 │ │ │ │ │ +306 │ │ │ │ │ +307#endif // DUNE_COMMON_CONCEPT_HH │ │ │ │ │ +indices.hh │ │ │ │ │ +typelist.hh │ │ │ │ │ +type_traits.hh │ │ │ │ │ +typeutilities.hh │ │ │ │ │ +Utilities for type computations, constraining overloads, ... │ │ │ │ │ +Dune::unpackIntegerSequence │ │ │ │ │ +decltype(auto) constexpr unpackIntegerSequence(F &&f, std::integer_sequence< I, │ │ │ │ │ +i... > sequence) │ │ │ │ │ +Unpack an std::integer_sequence to std::integral_constant... │ │ │ │ │ +Definition indices.hh:124 │ │ │ │ │ +Dune::TypeList │ │ │ │ │ +std::tuple< MetaType< T >... > TypeList │ │ │ │ │ +A simple type list. │ │ │ │ │ +Definition typelist.hh:87 │ │ │ │ │ +Dune::models │ │ │ │ │ +constexpr auto models() │ │ │ │ │ +Check if concept is modeled by given types. │ │ │ │ │ +Definition concept.hh:184 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::DenseMatrix<_ScalarMatrixView<_K_>_>::cols │ │ │ │ │ -constexpr size_type cols() const │ │ │ │ │ -number of columns │ │ │ │ │ -Definition densematrix.hh:715 │ │ │ │ │ -Dune::DenseMatrix<_ScalarMatrixView<_K_>_>::rows │ │ │ │ │ -constexpr size_type rows() const │ │ │ │ │ -number of rows │ │ │ │ │ -Definition densematrix.hh:709 │ │ │ │ │ -Dune::DenseMatrix<_ScalarMatrixView<_K_>_>::blocklevel │ │ │ │ │ -static constexpr int blocklevel │ │ │ │ │ -The number of block levels we contain. This is the leaf, that is, 1. │ │ │ │ │ -Definition densematrix.hh:178 │ │ │ │ │ -Dune::DenseMatrix<_ScalarMatrixView<_K_>_>::row_type │ │ │ │ │ -Traits::row_type row_type │ │ │ │ │ -The type used to represent a row (must fulfill the Dune::DenseVector interface) │ │ │ │ │ -Definition densematrix.hh:169 │ │ │ │ │ -Dune::DenseMatrix<_ScalarMatrixView<_K_>_>::size_type │ │ │ │ │ -Traits::size_type size_type │ │ │ │ │ -The type used for the index access and size operation. │ │ │ │ │ -Definition densematrix.hh:166 │ │ │ │ │ -Dune::DenseMatrix<_ScalarMatrixView<_K_>_>::const_row_reference │ │ │ │ │ -Traits::const_row_reference const_row_reference │ │ │ │ │ -The type used to represent a reference to a constant row (usually const row_ │ │ │ │ │ -type &) │ │ │ │ │ -Definition densematrix.hh:175 │ │ │ │ │ -Dune::DenseMatrix<_ScalarMatrixView<_K_>_>::row_reference │ │ │ │ │ -Traits::row_reference row_reference │ │ │ │ │ -The type used to represent a reference to a row (usually row_type &) │ │ │ │ │ -Definition densematrix.hh:172 │ │ │ │ │ -Dune::AutonomousValueType::type │ │ │ │ │ -T type │ │ │ │ │ -Definition typetraits.hh:531 │ │ │ │ │ +Dune::Concept::requireConcept │ │ │ │ │ +constexpr bool requireConcept() │ │ │ │ │ +Definition concept.hh:222 │ │ │ │ │ +Dune::Concept::requireTrue │ │ │ │ │ +constexpr bool requireTrue() │ │ │ │ │ +Definition concept.hh:215 │ │ │ │ │ +Dune::Concept::requireSameType │ │ │ │ │ +constexpr bool requireSameType() │ │ │ │ │ +Definition concept.hh:293 │ │ │ │ │ +Dune::Concept::requireConceptForTupleEntries │ │ │ │ │ +constexpr bool requireConceptForTupleEntries() │ │ │ │ │ +Definition concept.hh:238 │ │ │ │ │ +Dune::Concept::requireBaseOf │ │ │ │ │ +constexpr bool requireBaseOf() │ │ │ │ │ +Definition concept.hh:275 │ │ │ │ │ +Dune::Concept::requireConvertible │ │ │ │ │ +constexpr bool requireConvertible() │ │ │ │ │ +Definition concept.hh:247 │ │ │ │ │ +Dune::Concept::tupleEntriesModel │ │ │ │ │ +constexpr auto tupleEntriesModel() │ │ │ │ │ +Definition concept.hh:199 │ │ │ │ │ +Dune::Concept::requireType │ │ │ │ │ +constexpr bool requireType() │ │ │ │ │ +Definition concept.hh:266 │ │ │ │ │ +Dune::Concept::Refines │ │ │ │ │ +Base class for refined concepts. │ │ │ │ │ +Definition concept.hh:54 │ │ │ │ │ +Dune::Concept::Refines::BaseConceptList │ │ │ │ │ +TypeList< BaseConcepts... > BaseConceptList │ │ │ │ │ +Definition concept.hh:55 │ │ │ │ │ +Dune::PriorityTag │ │ │ │ │ +Helper class for tagging priorities. │ │ │ │ │ +Definition typeutilities.hh:73 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00080.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: rangeutilities.hh File Reference │ │ │ │ +dune-common: arraylist.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -71,121 +71,50 @@ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces | │ │ │ │ -Functions | │ │ │ │ -Variables
│ │ │ │ -
rangeutilities.hh File Reference
│ │ │ │ +Namespaces
│ │ │ │ +
arraylist.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

Utilities for reduction like operations on ranges. │ │ │ │ +

Implements a random-access container that can efficiently change size (similar to std::deque) │ │ │ │ More...

│ │ │ │ -
#include <algorithm>
│ │ │ │ -#include <utility>
│ │ │ │ -#include <type_traits>
│ │ │ │ -#include <bitset>
│ │ │ │ -#include <dune/common/typetraits.hh>
│ │ │ │ -#include <dune/common/iteratorfacades.hh>
│ │ │ │ +
#include <array>
│ │ │ │ +#include <cassert>
│ │ │ │ +#include <memory>
│ │ │ │ +#include <vector>
│ │ │ │ +#include "iteratorfacades.hh"
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::IntegralRange< T >
 dynamic integer range for use in range-based for loops More...
class  Dune::ArrayList< T, N, A >
 A dynamically growing random access list. More...
 
class  Dune::StaticIntegralRange< T, to, from >
 static integer range for use in range-based for loops More...
class  Dune::ArrayListIterator< T, N, A >
 A random access iterator for the Dune::ArrayList class. More...
 
struct  Dune::ValueTransformationTag
 Tag to enable value based transformations in TransformedRangeView. More...
 
struct  Dune::IteratorTransformationTag
 Tag to enable iterator based transformations in TransformedRangeView. More...
 
class  Dune::TransformedRangeView< R, F, T >
 A range transforming the values of another range on-the-fly. More...
class  Dune::ConstArrayListIterator< T, N, A >
 A constant random access iterator for the Dune::ArrayList class. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Functions

template<typename T , typename std::enable_if< IsIterable< T >::value, int >::type = 0>
T::value_type Dune::max_value (const T &v)
 compute the maximum value over a range
 
template<typename T , typename std::enable_if<!IsIterable< T >::value, int >::type = 0>
const T & Dune::max_value (const T &v)
 
template<typename T , typename std::enable_if< IsIterable< T >::value, int >::type = 0>
T::value_type Dune::min_value (const T &v)
 compute the minimum value over a range
 
template<typename T , typename std::enable_if<!IsIterable< T >::value, int >::type = 0>
const T & Dune::min_value (const T &v)
 
template<typename T , typename std::enable_if< IsIterable< T >::value, int >::type = 0>
bool Dune::any_true (const T &v)
 similar to std::bitset<N>::any() return true, if any entries is true
 
template<std::size_t N>
bool Dune::any_true (const std::bitset< N > &b)
 
template<typename T , typename std::enable_if< IsIterable< T >::value, int >::type = 0>
bool Dune::all_true (const T &v)
 similar to std::bitset<N>::all() return true, if any entries is true
 
template<std::size_t N>
bool Dune::all_true (const std::bitset< N > &b)
 
template<class T , class U , std::enable_if_t< std::is_same< std::decay_t< T >, std::decay_t< U > >::value, int > = 0, std::enable_if_t< std::is_integral< std::decay_t< T > >::value, int > = 0>
static IntegralRange< std::decay_t< T > > Dune::range (T &&from, U &&to) noexcept
 free standing function for setting up a range based for loop over an integer range for (auto i: range(0,10)) // 0,1,2,3,4,5,6,7,8,9 or for (auto i: range(-10,10)) // -10,-9,..,8,9 or for (auto i: range(10)) // 0,1,2,3,4,5,6,7,8,9
 
template<class T , std::enable_if_t< std::is_integral< std::decay_t< T > >::value, int > = 0>
static IntegralRange< std::decay_t< T > > Dune::range (T &&to) noexcept
 
template<class T , std::enable_if_t< std::is_enum< std::decay_t< T > >::value, int > = 0>
static IntegralRange< std::underlying_type_t< std::decay_t< T > > > Dune::range (T &&to) noexcept
 
template<class T , T to>
static StaticIntegralRange< T, to > Dune::range (std::integral_constant< T, to >) noexcept
 
template<class R , class F >
auto Dune::transformedRangeView (R &&range, F &&f)
 Create a TransformedRangeView.
 
template<class R , class F >
auto Dune::iteratorTransformedRangeView (R &&range, F &&f)
 Create a TransformedRangeView using an iterator transformation.
 
template<class Range >
auto Dune::sparseRange (Range &&range)
 Allow structured-binding for-loops for sparse iterators.
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │

│ │ │ │ -Variables

template<class T , T from, T to>
static StaticIntegralRange< T, to, from > Dune::range (std::integral_constant< T, from >, std::integral_constant< T, to >) noexcept
 
│ │ │ │

Detailed Description

│ │ │ │ -

Utilities for reduction like operations on ranges.

│ │ │ │ -
Author
Christian Engwer
│ │ │ │ +

Implements a random-access container that can efficiently change size (similar to std::deque)

│ │ │ │ +

This file implements the class ArrayList which behaves like dynamically growing array together with the class ArrayListIterator which is random access iterator as needed by the stl for sorting and other algorithms.

Author
Markus Blatt
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,130 +1,41 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Functions | Variables │ │ │ │ │ -rangeutilities.hh File Reference │ │ │ │ │ -Utilities for reduction like operations on ranges. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +arraylist.hh File Reference │ │ │ │ │ +Implements a random-access container that can efficiently change size (similar │ │ │ │ │ +to std::deque) More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include "iteratorfacades.hh" │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ - class   Dune::IntegralRange<_T_> │ │ │ │ │ -  dynamic integer range for use in range-based for loops More... │ │ │ │ │ +class   Dune::ArrayList<_T,_N,_A_> │ │ │ │ │ +  A dynamically growing random access list. More... │ │ │ │ │   │ │ │ │ │ - class   Dune::StaticIntegralRange<_T,_to,_from_> │ │ │ │ │ -  static integer range for use in range-based for loops More... │ │ │ │ │ +class   Dune::ArrayListIterator<_T,_N,_A_> │ │ │ │ │ +  A random access iterator for the Dune::ArrayList class. More... │ │ │ │ │   │ │ │ │ │ -struct   Dune::ValueTransformationTag │ │ │ │ │ -  Tag to enable value based transformations in TransformedRangeView. │ │ │ │ │ - More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::IteratorTransformationTag │ │ │ │ │ -  Tag to enable iterator based transformations in TransformedRangeView. │ │ │ │ │ - More... │ │ │ │ │ -  │ │ │ │ │ - class   Dune::TransformedRangeView<_R,_F,_T_> │ │ │ │ │ -  A range transforming the values of another range on-the-fly. More... │ │ │ │ │ +class   Dune::ConstArrayListIterator<_T,_N,_A_> │ │ │ │ │ +  A constant random access iterator for the Dune::ArrayList class. │ │ │ │ │ + More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -Functions │ │ │ │ │ -template::value, int >:: │ │ │ │ │ -type = 0> │ │ │ │ │ - T::value_type  Dune::max_value (const T &v) │ │ │ │ │ -  compute the maximum value over a range │ │ │ │ │ -  │ │ │ │ │ -template::value, int >:: │ │ │ │ │ -type = 0> │ │ │ │ │ - const T &  Dune::max_value (const T &v) │ │ │ │ │ -  │ │ │ │ │ -template::value, int >:: │ │ │ │ │ -type = 0> │ │ │ │ │ - T::value_type  Dune::min_value (const T &v) │ │ │ │ │ -  compute the minimum value over a range │ │ │ │ │ -  │ │ │ │ │ -template::value, int >:: │ │ │ │ │ -type = 0> │ │ │ │ │ - const T &  Dune::min_value (const T &v) │ │ │ │ │ -  │ │ │ │ │ -template::value, int >:: │ │ │ │ │ -type = 0> │ │ │ │ │ - bool  Dune::any_true (const T &v) │ │ │ │ │ -  similar to std::bitset::any() return │ │ │ │ │ - true, if any entries is true │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - bool  Dune::any_true (const std::bitset< N > &b) │ │ │ │ │ -  │ │ │ │ │ -template::value, int >:: │ │ │ │ │ -type = 0> │ │ │ │ │ - bool  Dune::all_true (const T &v) │ │ │ │ │ -  similar to std::bitset::all() return │ │ │ │ │ - true, if any entries is true │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - bool  Dune::all_true (const std::bitset< N > &b) │ │ │ │ │ -  │ │ │ │ │ -template, │ │ │ │ │ -std::decay_t< U > >::value, int > = 0, std::enable_if_t< std::is_integral< │ │ │ │ │ -std::decay_t< T > >::value, int > = 0> │ │ │ │ │ -static IntegralRange< std::decay_t< │ │ │ │ │ - T > >  Dune::range (T &&from, U &&to) noexcept │ │ │ │ │ - free standing function for setting up a │ │ │ │ │ - range based for loop over an integer range │ │ │ │ │ -  for (auto i: range(0,10)) / │ │ │ │ │ - / 0,1,2,3,4,5,6,7,8,9 or for (auto i: range │ │ │ │ │ - (-10,10)) // -10,-9,..,8,9 or for (auto i: │ │ │ │ │ - range(10)) // 0,1,2,3,4,5,6,7,8,9 │ │ │ │ │ -  │ │ │ │ │ -template >:: │ │ │ │ │ -value, int > = 0> │ │ │ │ │ -static IntegralRange< std::decay_t< │ │ │ │ │ - T > >  Dune::range (T &&to) noexcept │ │ │ │ │ -  │ │ │ │ │ -template >::value, │ │ │ │ │ -int > = 0> │ │ │ │ │ - static IntegralRange< std:: │ │ │ │ │ - underlying_type_t< std::decay_t< T │ │ │ │ │ - > > >  Dune::range (T &&to) noexcept │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - static StaticIntegralRange< T, to Dune::range (std::integral_constant< T, to │ │ │ │ │ - >  >) noexcept │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::transformedRangeView (R &&range, F │ │ │ │ │ - &&f) │ │ │ │ │ -  Create a TransformedRangeView. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::iteratorTransformedRangeView (R │ │ │ │ │ - &&range, F &&f) │ │ │ │ │ -  Create a TransformedRangeView using an │ │ │ │ │ - iterator transformation. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::sparseRange (Range &&range) │ │ │ │ │ -  Allow structured-binding for-loops for │ │ │ │ │ - sparse iterators. │ │ │ │ │ -  │ │ │ │ │ -Variables │ │ │ │ │ -template │ │ │ │ │ -static StaticIntegralRange< T, to, from >  Dune::range (std::integral_constant< │ │ │ │ │ - T, from >, std::integral_constant< │ │ │ │ │ - T, to >) noexcept │ │ │ │ │ -  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Utilities for reduction like operations on ranges. │ │ │ │ │ +Implements a random-access container that can efficiently change size (similar │ │ │ │ │ +to std::deque) │ │ │ │ │ +This file implements the class ArrayList which behaves like dynamically growing │ │ │ │ │ +array together with the class ArrayListIterator which is random access iterator │ │ │ │ │ +as needed by the stl for sorting and other algorithms. │ │ │ │ │ Author │ │ │ │ │ - Christian Engwer │ │ │ │ │ + Markus Blatt │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00080_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: rangeutilities.hh Source File │ │ │ │ +dune-common: arraylist.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,611 +74,623 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
rangeutilities.hh
│ │ │ │ +
arraylist.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_COMMON_RANGE_UTILITIES_HH
│ │ │ │ -
6#define DUNE_COMMON_RANGE_UTILITIES_HH
│ │ │ │ -
7
│ │ │ │ -
8#include <algorithm>
│ │ │ │ -
9#include <utility>
│ │ │ │ -
10#include <type_traits>
│ │ │ │ -
11#include <bitset>
│ │ │ │ -
12
│ │ │ │ - │ │ │ │ - │ │ │ │ -
15
│ │ │ │ -
23namespace Dune
│ │ │ │ -
24{
│ │ │ │ -
25
│ │ │ │ -
36 template <typename T,
│ │ │ │ -
37 typename std::enable_if<IsIterable<T>::value, int>::type = 0>
│ │ │ │ -
38 typename T::value_type
│ │ │ │ -
│ │ │ │ -
39 max_value(const T & v) {
│ │ │ │ -
40 using std::max_element;
│ │ │ │ -
41 return *max_element(v.begin(), v.end());
│ │ │ │ -
42 }
│ │ │ │ -
│ │ │ │ -
43
│ │ │ │ -
44 template <typename T,
│ │ │ │ -
45 typename std::enable_if<!IsIterable<T>::value, int>::type = 0>
│ │ │ │ -
46 const T & max_value(const T & v) { return v; }
│ │ │ │ -
47
│ │ │ │ -
53 template <typename T,
│ │ │ │ -
54 typename std::enable_if<IsIterable<T>::value, int>::type = 0>
│ │ │ │ -
55 typename T::value_type
│ │ │ │ -
│ │ │ │ -
56 min_value(const T & v) {
│ │ │ │ -
57 using std::min_element;
│ │ │ │ -
58 return *min_element(v.begin(), v.end());
│ │ │ │ -
59 }
│ │ │ │ -
│ │ │ │ -
60
│ │ │ │ -
61 template <typename T,
│ │ │ │ -
62 typename std::enable_if<!IsIterable<T>::value, int>::type = 0>
│ │ │ │ -
63 const T & min_value(const T & v) { return v; }
│ │ │ │ -
64
│ │ │ │ -
70 template <typename T,
│ │ │ │ -
71 typename std::enable_if<IsIterable<T>::value, int>::type = 0>
│ │ │ │ -
│ │ │ │ -
72 bool any_true(const T & v) {
│ │ │ │ -
73 bool b = false;
│ │ │ │ -
74 for (const auto & e : v)
│ │ │ │ -
75 b = b or bool(e);
│ │ │ │ -
76 return b;
│ │ │ │ -
77 }
│ │ │ │ -
│ │ │ │ -
78
│ │ │ │ -
79 template <typename T,
│ │ │ │ -
80 typename std::enable_if<!IsIterable<T>::value, int>::type = 0>
│ │ │ │ -
81 bool any_true(const T & v) { return v; }
│ │ │ │ -
82
│ │ │ │ -
83 template<std::size_t N>
│ │ │ │ -
│ │ │ │ -
84 bool any_true(const std::bitset<N> & b)
│ │ │ │ -
85 {
│ │ │ │ -
86 return b.any();
│ │ │ │ -
87 }
│ │ │ │ -
│ │ │ │ -
88
│ │ │ │ -
94 template <typename T,
│ │ │ │ -
95 typename std::enable_if<IsIterable<T>::value, int>::type = 0>
│ │ │ │ -
│ │ │ │ -
96 bool all_true(const T & v) {
│ │ │ │ -
97 bool b = true;
│ │ │ │ -
98 for (const auto & e : v)
│ │ │ │ -
99 b = b and bool(e);
│ │ │ │ -
100 return b;
│ │ │ │ -
101 }
│ │ │ │ -
│ │ │ │ -
102
│ │ │ │ -
103 template <typename T,
│ │ │ │ -
104 typename std::enable_if<!IsIterable<T>::value, int>::type = 0>
│ │ │ │ -
105 bool all_true(const T & v) { return v; }
│ │ │ │ +
5
│ │ │ │ +
6#ifndef DUNE_COMMON_ARRAYLIST_HH
│ │ │ │ +
7#define DUNE_COMMON_ARRAYLIST_HH
│ │ │ │ +
8
│ │ │ │ +
9#include <array>
│ │ │ │ +
10#include <cassert>
│ │ │ │ +
11#include <memory>
│ │ │ │ +
12#include <vector>
│ │ │ │ +
13#include "iteratorfacades.hh"
│ │ │ │ +
14
│ │ │ │ +
15namespace Dune
│ │ │ │ +
16{
│ │ │ │ +
17 // forward declaration
│ │ │ │ +
18 template<class T, int N, class A>
│ │ │ │ +
19 class ArrayListIterator;
│ │ │ │ +
20
│ │ │ │ +
21 template<class T, int N, class A>
│ │ │ │ +
22 class ConstArrayListIterator;
│ │ │ │ +
23
│ │ │ │ +
60 template<class T, int N=100, class A=std::allocator<T> >
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
62 {
│ │ │ │ +
63 public:
│ │ │ │ +
69 typedef T MemberType;
│ │ │ │ +
70
│ │ │ │ +
74 typedef T value_type;
│ │ │ │ +
75
│ │ │ │ +
79 typedef T& reference;
│ │ │ │ +
80
│ │ │ │ +
84 typedef const T& const_reference;
│ │ │ │ +
85
│ │ │ │ +
89 typedef T* pointer;
│ │ │ │ +
90
│ │ │ │ +
94 typedef const T* const_pointer;
│ │ │ │ +
95
│ │ │ │ +
100 constexpr static int chunkSize_ = (N > 0) ? N : 1;
│ │ │ │ +
101
│ │ │ │ + │ │ │ │
106
│ │ │ │ -
107 template<std::size_t N>
│ │ │ │ -
│ │ │ │ -
108 bool all_true(const std::bitset<N> & b)
│ │ │ │ -
109 {
│ │ │ │ -
110 return b.all();
│ │ │ │ -
111 }
│ │ │ │ -
│ │ │ │ -
112
│ │ │ │ -
113
│ │ │ │ -
114
│ │ │ │ -
115 namespace Impl
│ │ │ │ -
116 {
│ │ │ │ -
117
│ │ │ │ -
118 template <class T>
│ │ │ │ -
119 class IntegralRangeIterator
│ │ │ │ -
120 {
│ │ │ │ -
121 public:
│ │ │ │ -
122 typedef std::random_access_iterator_tag iterator_category;
│ │ │ │ -
123 typedef T value_type;
│ │ │ │ -
124 typedef std::make_signed_t<T> difference_type;
│ │ │ │ -
125 typedef const T *pointer;
│ │ │ │ -
126 typedef T reference;
│ │ │ │ + │ │ │ │ +
111
│ │ │ │ +
115 typedef std::size_t size_type;
│ │ │ │ +
116
│ │ │ │ +
120 typedef std::ptrdiff_t difference_type;
│ │ │ │ +
121
│ │ │ │ +
│ │ │ │ + │ │ │ │
127
│ │ │ │ -
128 constexpr IntegralRangeIterator() noexcept : value_(0) {}
│ │ │ │ -
129 constexpr explicit IntegralRangeIterator(value_type value) noexcept : value_(value) {}
│ │ │ │ -
130
│ │ │ │ -
131 pointer operator->() const noexcept { return &value_; }
│ │ │ │ -
132 constexpr reference operator*() const noexcept { return value_; }
│ │ │ │ -
133
│ │ │ │ -
134 constexpr reference operator[]( difference_type n ) const noexcept { return (value_ + n); }
│ │ │ │ -
135
│ │ │ │ -
136 constexpr bool operator==(const IntegralRangeIterator & other) const noexcept { return (value_ == other.value_); }
│ │ │ │ -
137 constexpr bool operator!=(const IntegralRangeIterator & other) const noexcept { return (value_ != other.value_); }
│ │ │ │ -
138
│ │ │ │ -
139 constexpr bool operator<(const IntegralRangeIterator & other) const noexcept { return (value_ <= other.value_); }
│ │ │ │ -
140 constexpr bool operator<=(const IntegralRangeIterator & other) const noexcept { return (value_ <= other.value_); }
│ │ │ │ -
141 constexpr bool operator>(const IntegralRangeIterator & other) const noexcept { return (value_ >= other.value_); }
│ │ │ │ -
142 constexpr bool operator>=(const IntegralRangeIterator & other) const noexcept { return (value_ >= other.value_); }
│ │ │ │ -
143
│ │ │ │ -
144 IntegralRangeIterator& operator++() noexcept { ++value_; return *this; }
│ │ │ │ -
145 IntegralRangeIterator operator++(int) noexcept { IntegralRangeIterator copy( *this ); ++(*this); return copy; }
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
134
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
140
│ │ │ │ +
│ │ │ │ + │ │ │ │
146
│ │ │ │ -
147 IntegralRangeIterator& operator--() noexcept { --value_; return *this; }
│ │ │ │ -
148 IntegralRangeIterator operator--(int) noexcept { IntegralRangeIterator copy( *this ); --(*this); return copy; }
│ │ │ │ -
149
│ │ │ │ -
150 IntegralRangeIterator& operator+=(difference_type n) noexcept { value_ += n; return *this; }
│ │ │ │ -
151 IntegralRangeIterator& operator-=(difference_type n) noexcept { value_ -= n; return *this; }
│ │ │ │ +
│ │ │ │ +
151 inline void push_back(const_reference entry);
│ │ │ │
152
│ │ │ │ -
153 friend constexpr IntegralRangeIterator operator+(const IntegralRangeIterator &a, difference_type n) noexcept { return IntegralRangeIterator(a.value_ + n); }
│ │ │ │ -
154 friend constexpr IntegralRangeIterator operator+(difference_type n, const IntegralRangeIterator &a) noexcept { return IntegralRangeIterator(a.value_ + n); }
│ │ │ │ -
155 friend constexpr IntegralRangeIterator operator-(const IntegralRangeIterator &a, difference_type n) noexcept { return IntegralRangeIterator(a.value_ - n); }
│ │ │ │ -
156
│ │ │ │ -
157 constexpr difference_type operator-(const IntegralRangeIterator &other) const noexcept { return (static_cast<difference_type>(value_) - static_cast<difference_type>(other.value_)); }
│ │ │ │ -
158
│ │ │ │ -
159 private:
│ │ │ │ -
160 value_type value_;
│ │ │ │ -
161 };
│ │ │ │ -
162
│ │ │ │ -
163 } // namespace Impl
│ │ │ │ -
164
│ │ │ │ -
165
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
159
│ │ │ │ +
│ │ │ │ + │ │ │ │
166
│ │ │ │ -
175 template <class T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
177 {
│ │ │ │ -
178 public:
│ │ │ │ -
180 typedef T value_type;
│ │ │ │ -
182 typedef Impl::IntegralRangeIterator<T> iterator;
│ │ │ │ -
184 typedef std::make_unsigned_t<T> size_type;
│ │ │ │ -
185
│ │ │ │ -
187 constexpr IntegralRange(value_type from, value_type to) noexcept : from_(from), to_(to) {}
│ │ │ │ -
189 constexpr explicit IntegralRange(value_type to) noexcept : from_(0), to_(to) {}
│ │ │ │ -
191 constexpr IntegralRange(std::pair<value_type, value_type> range) noexcept : from_(range.first), to_(range.second) {}
│ │ │ │ +
│ │ │ │ +
171 inline size_type size() const;
│ │ │ │ +
172
│ │ │ │ +
│ │ │ │ +
180 inline void purge();
│ │ │ │ +
181
│ │ │ │ +
│ │ │ │ +
185 inline void clear();
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
190
│ │ │ │ +
191 private:
│ │ │ │
192
│ │ │ │ -
194 constexpr iterator begin() const noexcept { return iterator(from_); }
│ │ │ │ -
196 constexpr iterator end() const noexcept { return iterator(to_); }
│ │ │ │ +
196 using SmartPointerAllocator = typename std::allocator_traits<A>::template rebind_alloc< std::shared_ptr< std::array<MemberType,chunkSize_> > >;
│ │ │ │
197
│ │ │ │ -
199 constexpr value_type operator[](const value_type &i) const noexcept { return (from_ + i); }
│ │ │ │ -
200
│ │ │ │ -
202 constexpr bool empty() const noexcept { return (from_ == to_); }
│ │ │ │ -
204 constexpr size_type size() const noexcept { return (static_cast<size_type>(to_) - static_cast<size_type>(from_)); }
│ │ │ │ -
205
│ │ │ │ -
207 constexpr bool contains(value_type index) const noexcept { return from_ <= index && index < to_; }
│ │ │ │ +
201 using ArrayAllocator = typename std::allocator_traits<A>::template rebind_alloc< std::array<MemberType,chunkSize_> >;
│ │ │ │ +
202
│ │ │ │ +
206 friend class ArrayListIterator<T,N,A>;
│ │ │ │ +
207 friend class ConstArrayListIterator<T,N,A>;
│ │ │ │
208
│ │ │ │ -
209 private:
│ │ │ │ -
210 value_type from_, to_;
│ │ │ │ -
211 };
│ │ │ │ -
│ │ │ │ -
212
│ │ │ │ -
213
│ │ │ │ -
228 template <class T, T to, T from = 0>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
230 {
│ │ │ │ -
231 template <T ofs, T... i>
│ │ │ │ -
232 static std::integer_sequence<T, (i+ofs)...> shift_integer_sequence(std::integer_sequence<T, i...>);
│ │ │ │ -
233
│ │ │ │ -
234 public:
│ │ │ │ -
236 typedef T value_type;
│ │ │ │ -
238 typedef Impl::IntegralRangeIterator<T> iterator;
│ │ │ │ -
240 typedef std::make_unsigned_t<T> size_type;
│ │ │ │ -
241
│ │ │ │ -
243 typedef decltype(shift_integer_sequence<from>(std::make_integer_sequence<T, to-from>())) integer_sequence;
│ │ │ │ -
244
│ │ │ │ -
246 constexpr StaticIntegralRange() noexcept = default;
│ │ │ │ -
247
│ │ │ │ -
249 constexpr operator IntegralRange<T>() const noexcept { return {from, to}; }
│ │ │ │ -
251 constexpr operator integer_sequence() const noexcept { return {}; }
│ │ │ │ -
252
│ │ │ │ -
254 static constexpr integer_sequence to_integer_sequence() noexcept { return {}; }
│ │ │ │ -
255
│ │ │ │ -
257 static constexpr iterator begin() noexcept { return iterator(from); }
│ │ │ │ -
259 static constexpr iterator end() noexcept { return iterator(to); }
│ │ │ │ -
260
│ │ │ │ -
262 template <class U, U i>
│ │ │ │ -
│ │ │ │ -
263 constexpr auto operator[](const std::integral_constant<U, i> &) const noexcept
│ │ │ │ -
264 -> std::integral_constant<value_type, from + static_cast<value_type>(i)>
│ │ │ │ -
265 {
│ │ │ │ -
266 return {};
│ │ │ │ -
267 }
│ │ │ │ -
│ │ │ │ +
210 std::vector<std::shared_ptr<std::array<MemberType,chunkSize_> >,
│ │ │ │ +
211 SmartPointerAllocator> chunks_;
│ │ │ │ +
220 size_type capacity_;
│ │ │ │ +
222 size_type size_;
│ │ │ │ +
224 size_type start_;
│ │ │ │ +
233 inline reference elementAt(size_type i);
│ │ │ │ +
234
│ │ │ │ +
243 inline const_reference elementAt(size_type i) const;
│ │ │ │ +
244 };
│ │ │ │ +
245
│ │ │ │ +
246
│ │ │ │ +
250 template<class T, int N, class A>
│ │ │ │ +
│ │ │ │ +
251 class ArrayListIterator : public RandomAccessIteratorFacade<ArrayListIterator<T,N,A>,
│ │ │ │ +
252 typename A::value_type,
│ │ │ │ +
253 typename A::value_type &,
│ │ │ │ +
254 typename A::difference_type>
│ │ │ │ +
255 {
│ │ │ │ +
256
│ │ │ │ +
257 friend class ArrayList<T,N,A>;
│ │ │ │ +
258 friend class ConstArrayListIterator<T,N,A>;
│ │ │ │ +
259 public:
│ │ │ │ +
263 typedef typename A::value_type MemberType;
│ │ │ │ +
264
│ │ │ │ +
265 typedef typename A::difference_type difference_type;
│ │ │ │ +
266
│ │ │ │ +
267 typedef typename A::size_type size_type;
│ │ │ │
268
│ │ │ │ -
270 constexpr value_type operator[](const size_type &i) const noexcept { return (from + static_cast<value_type>(i)); }
│ │ │ │ -
271
│ │ │ │ -
273 static constexpr std::integral_constant<bool, from == to> empty() noexcept { return {}; }
│ │ │ │ -
275 static constexpr std::integral_constant<size_type, static_cast<size_type>(to) - static_cast<size_type>(from) > size() noexcept { return {}; }
│ │ │ │ -
276
│ │ │ │ -
278 static constexpr bool contains(value_type index) noexcept { return from <= index && index < to; }
│ │ │ │ +
269 using reference = typename A::value_type &;
│ │ │ │ +
270
│ │ │ │ +
271 using const_reference = typename A::value_type const&;
│ │ │ │ +
272
│ │ │ │ +
278 constexpr static int chunkSize_ = (N > 0) ? N : 1;
│ │ │ │
279
│ │ │ │ -
280 };
│ │ │ │ -
│ │ │ │ -
281
│ │ │ │ -
291 template<class T, class U,
│ │ │ │ -
292 std::enable_if_t<std::is_same<std::decay_t<T>, std::decay_t<U>>::value, int> = 0,
│ │ │ │ -
293 std::enable_if_t<std::is_integral<std::decay_t<T>>::value, int> = 0>
│ │ │ │ -
│ │ │ │ -
294 inline static IntegralRange<std::decay_t<T>> range(T &&from, U &&to) noexcept
│ │ │ │ -
295 {
│ │ │ │ -
296 return IntegralRange<std::decay_t<T>>(std::forward<T>(from), std::forward<U>(to));
│ │ │ │ -
297 }
│ │ │ │ -
│ │ │ │ -
298
│ │ │ │ -
299 template<class T, std::enable_if_t<std::is_integral<std::decay_t<T>>::value, int> = 0>
│ │ │ │ -
│ │ │ │ -
300 inline static IntegralRange<std::decay_t<T>> range(T &&to) noexcept
│ │ │ │ -
301 {
│ │ │ │ -
302 return IntegralRange<std::decay_t<T>>(std::forward<T>(to));
│ │ │ │ -
303 }
│ │ │ │ -
│ │ │ │ +
280
│ │ │ │ +
286 inline bool equals(const ArrayListIterator<MemberType,N,A>& other) const;
│ │ │ │ +
287
│ │ │ │ +
293 inline bool equals(const ConstArrayListIterator<MemberType,N,A>& other) const;
│ │ │ │ +
294
│ │ │ │ +
298 inline void increment();
│ │ │ │ +
299
│ │ │ │ +
303 inline void decrement();
│ │ │ │
304
│ │ │ │ -
305 template<class T, std::enable_if_t<std::is_enum<std::decay_t<T>>::value, int> = 0>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
307 {
│ │ │ │ -
308 return IntegralRange<std::underlying_type_t<std::decay_t<T>>>(std::forward<T>(to));
│ │ │ │ -
309 }
│ │ │ │ -
│ │ │ │ +
309 inline reference elementAt(size_type i) const;
│ │ │ │
310
│ │ │ │ -
311 template<class T, T from, T to>
│ │ │ │ -
│ │ │ │ -
312 inline static StaticIntegralRange<T, to, from> range(std::integral_constant<T, from>, std::integral_constant<T, to>) noexcept
│ │ │ │ -
313 {
│ │ │ │ -
314 return {};
│ │ │ │ -
315 }
│ │ │ │ -
│ │ │ │ +
315 inline reference dereference() const;
│ │ │ │
316
│ │ │ │ -
317 template<class T, T to>
│ │ │ │ -
│ │ │ │ -
318 inline static StaticIntegralRange<T, to> range(std::integral_constant<T, to>) noexcept
│ │ │ │ -
319 {
│ │ │ │ -
320 return {};
│ │ │ │ -
321 }
│ │ │ │ -
│ │ │ │ -
322
│ │ │ │ -
323
│ │ │ │ -
324
│ │ │ │ - │ │ │ │ -
329
│ │ │ │ - │ │ │ │ -
334
│ │ │ │ -
335 namespace Impl
│ │ │ │ -
336 {
│ │ │ │ -
337
│ │ │ │ -
338
│ │ │ │ -
339
│ │ │ │ -
340 // An iterator transforming a wrapped iterator using
│ │ │ │ -
341 // an unary function. It inherits the iterator-category
│ │ │ │ -
342 // of the underlying iterator.
│ │ │ │ -
343 //
│ │ │ │ -
344 // \tparam I Type of the underlying iterator
│ │ │ │ -
345 // \tparam F Type of transformation function that can either be applied directly or after dereferencing
│ │ │ │ -
346 // \tparam TT Type of transformation (ValueTransformationTag or IteratorTransformationTag)
│ │ │ │ -
347 // \tparam C An iterator category tag, defaults to the one of I
│ │ │ │ -
348 template <class I, class F, class TT, class C = typename std::iterator_traits<I>::iterator_category>
│ │ │ │ -
349 class TransformedRangeIterator;
│ │ │ │ -
350
│ │ │ │ -
351 template<class I, class F, class TT, class C>
│ │ │ │ -
352 struct TransformationRangeIteratorTraits
│ │ │ │ -
353 {
│ │ │ │ -
354 template<class FF>
│ │ │ │ -
355 static decltype(auto) transform(FF&& f, const I& it) {
│ │ │ │ -
356 if constexpr (std::is_same_v<TT,IteratorTransformationTag>)
│ │ │ │ -
357 {
│ │ │ │ -
358 if constexpr (Dune::IsCallable<FF(const I&)>::value)
│ │ │ │ -
359 return f(it);
│ │ │ │ -
360 else
│ │ │ │ -
361 return (*f)(it);
│ │ │ │ -
362 }
│ │ │ │ -
363 else
│ │ │ │ -
364 {
│ │ │ │ -
365 if constexpr (Dune::IsCallable<FF(decltype(*it))>::value)
│ │ │ │ -
366 return f(*it);
│ │ │ │ -
367 else
│ │ │ │ -
368 return (*f)(*it);
│ │ │ │ -
369 }
│ │ │ │ -
370 }
│ │ │ │ -
371
│ │ │ │ -
372 using reference = decltype(transform(std::declval<F>(), std::declval<I>()));
│ │ │ │ -
373 using value_type = Dune::AutonomousValue<reference>;
│ │ │ │ -
374 using pointer = std::conditional_t<std::is_lvalue_reference_v<reference>, value_type*, ProxyArrowResult<reference>>;
│ │ │ │ -
375 using difference_type = typename std::iterator_traits<I>::difference_type;
│ │ │ │ -
376 using Facade = Dune::IteratorFacade<TransformedRangeIterator<I,F,TT,C>, C, value_type, reference, pointer, difference_type>;
│ │ │ │ -
377 };
│ │ │ │ +
326 inline void eraseToHere();
│ │ │ │ +
327
│ │ │ │ +
329 inline size_type position(){return position_;}
│ │ │ │ +
330
│ │ │ │ +
332 inline void advance(difference_type n);
│ │ │ │ +
333
│ │ │ │ +
335 inline difference_type distanceTo(const ArrayListIterator<T,N,A>& other) const;
│ │ │ │ +
336
│ │ │ │ +
│ │ │ │ +
338 inline ArrayListIterator() : position_(0), list_(nullptr)
│ │ │ │ +
339 {}
│ │ │ │ +
│ │ │ │ +
340
│ │ │ │ +
341 private:
│ │ │ │ + │ │ │ │ +
348
│ │ │ │ +
352 size_type position_;
│ │ │ │ + │ │ │ │ +
357 };
│ │ │ │ +
│ │ │ │ +
358
│ │ │ │ +
362 template<class T, int N, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
364 : public RandomAccessIteratorFacade<ConstArrayListIterator<T,N,A>,
│ │ │ │ +
365 const typename A::value_type,
│ │ │ │ +
366 typename A::value_type const&,
│ │ │ │ +
367 typename A::difference_type>
│ │ │ │ +
368 {
│ │ │ │ +
369
│ │ │ │ +
370 friend class ArrayList<T,N,A>;
│ │ │ │ +
371 friend class ArrayListIterator<T,N,A>;
│ │ │ │ +
372
│ │ │ │ +
373 public:
│ │ │ │ +
377 typedef typename A::value_type MemberType;
│ │ │ │
378
│ │ │ │ -
379
│ │ │ │ -
380 template <class I, class F, class TT, class C>
│ │ │ │ -
381 class TransformedRangeIterator :
│ │ │ │ -
382 public TransformationRangeIteratorTraits<I,F, TT, C>::Facade
│ │ │ │ -
383 {
│ │ │ │ -
384 using Traits = TransformationRangeIteratorTraits<I,F, TT, C>;
│ │ │ │ -
385 using Facade = typename Traits::Facade;
│ │ │ │ +
379 typedef typename A::difference_type difference_type;
│ │ │ │ +
380
│ │ │ │ +
381 typedef typename A::size_type size_type;
│ │ │ │ +
382
│ │ │ │ +
383 using reference = typename A::value_type const&;
│ │ │ │ +
384
│ │ │ │ +
385 using const_reference = typename A::value_type const&;
│ │ │ │
386
│ │ │ │ -
387 static constexpr bool isBidirectional = std::is_convertible_v<C, std::bidirectional_iterator_tag>;
│ │ │ │ -
388 static constexpr bool isRandomAccess = std::is_convertible_v<C, std::random_access_iterator_tag>;
│ │ │ │ -
389
│ │ │ │ -
390 public:
│ │ │ │ -
391
│ │ │ │ -
392 using Function = F;
│ │ │ │ -
393 using reference = typename Facade::reference;
│ │ │ │ -
394 using difference_type = typename Facade::difference_type;
│ │ │ │ -
395
│ │ │ │ -
396 template<class II, class FF>
│ │ │ │ -
397 constexpr TransformedRangeIterator(II&& it, FF&& f) noexcept :
│ │ │ │ -
398 it_(std::forward<II>(it)),
│ │ │ │ -
399 f_(std::forward<FF>(f))
│ │ │ │ -
400 {}
│ │ │ │ -
401
│ │ │ │ -
402 template<class II,
│ │ │ │ -
403 disableCopyMove<TransformedRangeIterator,II> =0,
│ │ │ │ -
404 std::enable_if_t<std::is_convertible_v<II, I> and std::is_default_constructible_v<F>, int> =0>
│ │ │ │ -
405 constexpr TransformedRangeIterator(II&& it) noexcept :
│ │ │ │ -
406 it_(std::forward<II>(it)),
│ │ │ │ -
407 f_()
│ │ │ │ -
408 {}
│ │ │ │ -
409
│ │ │ │ -
410 template<class FF,
│ │ │ │ -
411 disableCopyMove<TransformedRangeIterator,FF> =0,
│ │ │ │ -
412 std::enable_if_t<std::is_convertible_v<FF, F> and std::is_default_constructible_v<I>, int> =0>
│ │ │ │ -
413 constexpr TransformedRangeIterator(FF&& f) noexcept :
│ │ │ │ -
414 it_(),
│ │ │ │ -
415 f_(std::forward<FF>(f))
│ │ │ │ -
416 {}
│ │ │ │ -
417
│ │ │ │ -
418 // Explicitly initialize members. Using a plain
│ │ │ │ -
419 //
│ │ │ │ -
420 // constexpr TransformedRangeIterator() noexcept {}
│ │ │ │ -
421 //
│ │ │ │ -
422 // would default-initialize the members while
│ │ │ │ -
423 //
│ │ │ │ -
424 // constexpr TransformedRangeIterator() noexcept : it_(), f_() {}
│ │ │ │ -
425 //
│ │ │ │ -
426 // leads to value-initialization. This is a case where
│ │ │ │ -
427 // both are really different. If it_ is a raw pointer (i.e. POD)
│ │ │ │ -
428 // then default-initialization leaves it uninitialized while
│ │ │ │ -
429 // value-initialization zero-initializes it.
│ │ │ │ -
430 constexpr TransformedRangeIterator() noexcept :
│ │ │ │ -
431 it_(),
│ │ │ │ -
432 f_()
│ │ │ │ -
433 {}
│ │ │ │ -
434
│ │ │ │ -
435 // Dereferencing returns a value created by the function
│ │ │ │ -
436 constexpr reference operator*() const noexcept {
│ │ │ │ -
437 return Traits::transform(f_, it_);
│ │ │ │ -
438 }
│ │ │ │ -
439
│ │ │ │ -
440 protected:
│ │ │ │ -
441
│ │ │ │ - │ │ │ │ -
443
│ │ │ │ -
444 // Export base iterator, such that equalilty comparison,
│ │ │ │ -
445 // differences, and inequality comparisons are automatically
│ │ │ │ -
446 // forwarded to the base iterator by the facade.
│ │ │ │ -
447 const I& baseIterator() const noexcept {
│ │ │ │ -
448 return it_;
│ │ │ │ -
449 }
│ │ │ │ -
450
│ │ │ │ -
451 I& baseIterator() noexcept {
│ │ │ │ -
452 return it_;
│ │ │ │ -
453 }
│ │ │ │ -
454
│ │ │ │ -
455 I it_;
│ │ │ │ -
456 Function f_;
│ │ │ │ -
457 };
│ │ │ │ -
458
│ │ │ │ -
459 } // namespace Impl
│ │ │ │ +
392 constexpr static int chunkSize_ = (N > 0) ? N : 1;
│ │ │ │ +
393
│ │ │ │ +
│ │ │ │ +
399 inline bool equals(const ConstArrayListIterator<MemberType,N,A>& other) const;
│ │ │ │ +
400
│ │ │ │ +
│ │ │ │ +
404 inline void increment();
│ │ │ │ +
405
│ │ │ │ +
│ │ │ │ +
409 inline void decrement();
│ │ │ │ +
410
│ │ │ │ +
│ │ │ │ +
412 inline void advance(difference_type n);
│ │ │ │ +
413
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
416
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
422
│ │ │ │ +
│ │ │ │ +
427 inline reference dereference() const;
│ │ │ │ +
428
│ │ │ │ +
│ │ │ │ +
429 inline ConstArrayListIterator() : position_(0), list_(nullptr)
│ │ │ │ +
430 {}
│ │ │ │ +
│ │ │ │ +
431
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
433
│ │ │ │ +
434 private:
│ │ │ │ +
435
│ │ │ │ +
441 inline ConstArrayListIterator(const ArrayList<T,N,A>& arrayList, size_type position);
│ │ │ │ +
442
│ │ │ │ +
446 size_type position_;
│ │ │ │ +
450 const ArrayList<T,N,A>* list_;
│ │ │ │ +
451 };
│ │ │ │ +
452
│ │ │ │ +
453
│ │ │ │ +
454 template<class T, int N, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
456 : capacity_(0), size_(0), start_(0)
│ │ │ │ +
457 {
│ │ │ │ +
458 chunks_.reserve(100);
│ │ │ │ +
459 }
│ │ │ │ +
│ │ │ │
460
│ │ │ │ -
461
│ │ │ │ -
462
│ │ │ │ -
499 template <class R, class F, class T=ValueTransformationTag>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
501 {
│ │ │ │ -
502 using RawConstIterator = std::decay_t<decltype(std::declval<const R>().begin())>;
│ │ │ │ -
503 using RawIterator = std::decay_t<decltype(std::declval<R>().begin())>;
│ │ │ │ -
504
│ │ │ │ -
505 public:
│ │ │ │ +
461 template<class T, int N, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
463 capacity_=0;
│ │ │ │ +
464 size_=0;
│ │ │ │ +
465 start_=0;
│ │ │ │ +
466 chunks_.clear();
│ │ │ │ +
467 }
│ │ │ │ +
│ │ │ │ +
468
│ │ │ │ +
469 template<class T, int N, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
471 {
│ │ │ │ +
472 return size_;
│ │ │ │ +
473 }
│ │ │ │ +
│ │ │ │ +
474
│ │ │ │ +
475 template<class T, int N, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
477 {
│ │ │ │ +
478 size_t index=start_+size_;
│ │ │ │ +
479 if(index==capacity_)
│ │ │ │ +
480 {
│ │ │ │ +
481 chunks_.push_back(std::make_shared<std::array<MemberType,chunkSize_> >());
│ │ │ │ +
482 capacity_ += chunkSize_;
│ │ │ │ +
483 }
│ │ │ │ +
484 elementAt(index)=entry;
│ │ │ │ +
485 ++size_;
│ │ │ │ +
486 }
│ │ │ │ +
│ │ │ │ +
487
│ │ │ │ +
488 template<class T, int N, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
490 {
│ │ │ │ +
491 return elementAt(start_+i);
│ │ │ │ +
492 }
│ │ │ │ +
│ │ │ │ +
493
│ │ │ │ +
494
│ │ │ │ +
495 template<class T, int N, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
497 {
│ │ │ │ +
498 return elementAt(start_+i);
│ │ │ │ +
499 }
│ │ │ │ +
│ │ │ │ +
500
│ │ │ │ +
501 template<class T, int N, class A>
│ │ │ │ + │ │ │ │ +
503 {
│ │ │ │ +
504 return chunks_[i/chunkSize_]->operator[](i%chunkSize_);
│ │ │ │ +
505 }
│ │ │ │
506
│ │ │ │ -
513 using const_iterator = Impl::TransformedRangeIterator<RawConstIterator, const F*, T>;
│ │ │ │ -
514
│ │ │ │ -
521 using iterator = Impl::TransformedRangeIterator<RawIterator, F*, T>;
│ │ │ │ -
522
│ │ │ │ -
529 using RawRange = std::remove_reference_t<R>;
│ │ │ │ -
530
│ │ │ │ -
534 template<class RR, class FF>
│ │ │ │ -
│ │ │ │ -
535 constexpr TransformedRangeView(RR&& rawRange, FF&& f) noexcept :
│ │ │ │ -
536 rawRange_(std::forward<RR>(rawRange)),
│ │ │ │ -
537 f_(std::forward<FF>(f))
│ │ │ │ -
538 {
│ │ │ │ -
539 static_assert(std::is_same_v<T, ValueTransformationTag> or std::is_same_v<T, IteratorTransformationTag>,
│ │ │ │ -
540 "The TransformationType passed to TransformedRangeView has to be either ValueTransformationTag or IteratorTransformationTag.");
│ │ │ │ -
541 }
│ │ │ │ -
│ │ │ │ -
542
│ │ │ │ -
│ │ │ │ -
551 constexpr const_iterator begin() const noexcept {
│ │ │ │ -
552 return const_iterator(rawRange_.begin(), &f_);
│ │ │ │ -
553 }
│ │ │ │ -
│ │ │ │ -
554
│ │ │ │ -
│ │ │ │ -
555 constexpr iterator begin() noexcept {
│ │ │ │ -
556 return iterator(rawRange_.begin(), &f_);
│ │ │ │ -
557 }
│ │ │ │ -
│ │ │ │ -
558
│ │ │ │ -
│ │ │ │ -
567 constexpr const_iterator end() const noexcept {
│ │ │ │ -
568 return const_iterator(rawRange_.end(), &f_);
│ │ │ │ -
569 }
│ │ │ │ -
│ │ │ │ -
570
│ │ │ │ +
507
│ │ │ │ +
508 template<class T, int N, class A>
│ │ │ │ +
509 typename ArrayList<T,N,A>::const_reference ArrayList<T,N,A>::elementAt(size_type i) const
│ │ │ │ +
510 {
│ │ │ │ +
511 return chunks_[i/chunkSize_]->operator[](i%chunkSize_);
│ │ │ │ +
512 }
│ │ │ │ +
513
│ │ │ │ +
514 template<class T, int N, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
516 {
│ │ │ │ +
517 return ArrayListIterator<T,N,A>(*this, start_);
│ │ │ │ +
518 }
│ │ │ │ +
│ │ │ │ +
519
│ │ │ │ +
520 template<class T, int N, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
522 {
│ │ │ │ +
523 return ConstArrayListIterator<T,N,A>(*this, start_);
│ │ │ │ +
524 }
│ │ │ │ +
│ │ │ │ +
525
│ │ │ │ +
526 template<class T, int N, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
528 {
│ │ │ │ +
529 return ArrayListIterator<T,N,A>(*this, start_+size_);
│ │ │ │ +
530 }
│ │ │ │ +
│ │ │ │ +
531
│ │ │ │ +
532 template<class T, int N, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
534 {
│ │ │ │ +
535 return ConstArrayListIterator<T,N,A>(*this, start_+size_);
│ │ │ │ +
536 }
│ │ │ │ +
│ │ │ │ +
537
│ │ │ │ +
538 template<class T, int N, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
540 {
│ │ │ │ +
541 // Distance to copy to the left.
│ │ │ │ +
542 size_t distance = start_/chunkSize_;
│ │ │ │ +
543 if(distance>0) {
│ │ │ │ +
544 // Number of chunks with entries in it;
│ │ │ │ +
545 size_t chunks = ((start_%chunkSize_ + size_)/chunkSize_ );
│ │ │ │ +
546
│ │ │ │ +
547 // Copy chunks to the left.
│ │ │ │ +
548 std::copy(chunks_.begin()+distance,
│ │ │ │ +
549 chunks_.begin()+(distance+chunks), chunks_.begin());
│ │ │ │ +
550
│ │ │ │ +
551 // Calculate new parameters
│ │ │ │ +
552 start_ = start_ % chunkSize_;
│ │ │ │ +
553 //capacity += distance * chunkSize_;
│ │ │ │ +
554 }
│ │ │ │ +
555 }
│ │ │ │ +
│ │ │ │ +
556
│ │ │ │ +
557 template<class T, int N, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
559 {
│ │ │ │ +
560 position_+=i;
│ │ │ │ +
561 }
│ │ │ │ +
│ │ │ │ +
562
│ │ │ │ +
563 template<class T, int N, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
565 {
│ │ │ │ +
566 position_+=i;
│ │ │ │ +
567 }
│ │ │ │ +
│ │ │ │ +
568
│ │ │ │ +
569
│ │ │ │ +
570 template<class T, int N, class A>
│ │ │ │
│ │ │ │ -
571 constexpr iterator end() noexcept {
│ │ │ │ -
572 return iterator(rawRange_.end(), &f_);
│ │ │ │ -
573 }
│ │ │ │ -
│ │ │ │ -
574
│ │ │ │ -
578 template<class It=const_iterator,
│ │ │ │ -
579 std::enable_if_t<std::is_same_v<typename It::iterator_category,std::random_access_iterator_tag>, int> = 0>
│ │ │ │ + │ │ │ │ +
572 {
│ │ │ │ +
573 // Makes only sense if we reference a common list
│ │ │ │ +
574 assert(list_==(other.list_));
│ │ │ │ +
575 return position_==other.position_ ;
│ │ │ │ +
576 }
│ │ │ │ +
│ │ │ │ +
577
│ │ │ │ +
578
│ │ │ │ +
579 template<class T, int N, class A>
│ │ │ │
│ │ │ │ -
580 constexpr decltype(auto) operator[](std::size_t i) const noexcept
│ │ │ │ -
581 {
│ │ │ │ -
582 return this->begin()[i];
│ │ │ │ -
583 }
│ │ │ │ -
│ │ │ │ -
584
│ │ │ │ -
588 template<class It=iterator,
│ │ │ │ -
589 std::enable_if_t<std::is_same_v<typename It::iterator_category,std::random_access_iterator_tag>, int> = 0>
│ │ │ │ -
│ │ │ │ -
590 constexpr decltype(auto) operator[](std::size_t i) noexcept
│ │ │ │ -
591 {
│ │ │ │ -
592 return this->begin()[i];
│ │ │ │ -
593 }
│ │ │ │ -
│ │ │ │ -
594
│ │ │ │ -
605 template<class Range=R,
│ │ │ │ -
606 class = std::void_t<decltype(std::declval<const Range>().size())>>
│ │ │ │ -
│ │ │ │ -
607 auto size() const noexcept
│ │ │ │ -
608 {
│ │ │ │ -
609 return rawRange_.size();
│ │ │ │ -
610 }
│ │ │ │ + │ │ │ │ +
581 {
│ │ │ │ +
582 // Makes only sense if we reference a common list
│ │ │ │ +
583 assert(list_==(other.list_));
│ │ │ │ +
584 return position_==other.position_ ;
│ │ │ │ +
585 }
│ │ │ │ +
│ │ │ │ +
586
│ │ │ │ +
587
│ │ │ │ +
588 template<class T, int N, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
590 {
│ │ │ │ +
591 // Makes only sense if we reference a common list
│ │ │ │ +
592 assert(list_==(other.list_));
│ │ │ │ +
593 return position_==other.position_ ;
│ │ │ │ +
594 }
│ │ │ │ +
│ │ │ │ +
595
│ │ │ │ +
596 template<class T, int N, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
598 {
│ │ │ │ +
599 ++position_;
│ │ │ │ +
600 }
│ │ │ │ +
│ │ │ │ +
601
│ │ │ │ +
602 template<class T, int N, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
604 {
│ │ │ │ +
605 ++position_;
│ │ │ │ +
606 }
│ │ │ │ +
│ │ │ │ +
607
│ │ │ │ +
608 template<class T, int N, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
610 {
│ │ │ │ +
611 --position_;
│ │ │ │ +
612 }
│ │ │ │
│ │ │ │ -
611
│ │ │ │ +
613
│ │ │ │ +
614 template<class T, int N, class A>
│ │ │ │
│ │ │ │ -
615 constexpr bool empty() const noexcept
│ │ │ │ -
616 {
│ │ │ │ -
617 return rawRange_.begin() == rawRange_.end();
│ │ │ │ -
618 }
│ │ │ │ + │ │ │ │ +
616 {
│ │ │ │ +
617 --position_;
│ │ │ │ +
618 }
│ │ │ │
│ │ │ │
619
│ │ │ │ -
│ │ │ │ -
623 const RawRange& rawRange() const noexcept
│ │ │ │ -
624 {
│ │ │ │ -
625 return rawRange_;
│ │ │ │ -
626 }
│ │ │ │ -
│ │ │ │ -
627
│ │ │ │ -
│ │ │ │ -
631 RawRange& rawRange() noexcept
│ │ │ │ -
632 {
│ │ │ │ -
633 return rawRange_;
│ │ │ │ -
634 }
│ │ │ │ -
│ │ │ │ -
635
│ │ │ │ -
636 private:
│ │ │ │ -
637 R rawRange_;
│ │ │ │ -
638 F f_;
│ │ │ │ -
639 };
│ │ │ │ -
│ │ │ │ -
640
│ │ │ │ -
669 template <class R, class F>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
671 {
│ │ │ │ -
672 return TransformedRangeView<R, std::decay_t<F>, ValueTransformationTag>(std::forward<R>(range), std::forward<F>(f));
│ │ │ │ -
673 }
│ │ │ │ -
│ │ │ │ -
674
│ │ │ │ -
702 template <class R, class F>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
704 {
│ │ │ │ -
705 return TransformedRangeView<R, std::decay_t<F>, IteratorTransformationTag>(std::forward<R>(range), std::forward<F>(f));
│ │ │ │ -
706 }
│ │ │ │ -
│ │ │ │ -
707
│ │ │ │ -
708
│ │ │ │ -
721 template<class Range>
│ │ │ │ -
│ │ │ │ -
722 auto sparseRange(Range&& range) {
│ │ │ │ -
723 return Dune::iteratorTransformedRangeView(std::forward<Range>(range), [](auto&& it) {
│ │ │ │ -
724 return std::tuple<decltype(*it), decltype(it.index())>(*it, it.index());
│ │ │ │ -
725 });
│ │ │ │ -
726 }
│ │ │ │ -
│ │ │ │ -
727
│ │ │ │ -
732}
│ │ │ │ -
733
│ │ │ │ -
734#endif // DUNE_COMMON_RANGE_UTILITIES_HH
│ │ │ │ -
This file implements iterator facade classes for writing stl conformant iterators.
│ │ │ │ -
Traits for type conversions and type information.
│ │ │ │ -
auto iteratorTransformedRangeView(R &&range, F &&f)
Create a TransformedRangeView using an iterator transformation.
Definition rangeutilities.hh:703
│ │ │ │ -
auto transformedRangeView(R &&range, F &&f)
Create a TransformedRangeView.
Definition rangeutilities.hh:670
│ │ │ │ -
auto sparseRange(Range &&range)
Allow structured-binding for-loops for sparse iterators.
Definition rangeutilities.hh:722
│ │ │ │ -
static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from >, std::integral_constant< T, to >) noexcept
Definition rangeutilities.hh:312
│ │ │ │ -
typename AutonomousValueType< T >::type AutonomousValue
Type free of internal references that T can be converted to.
Definition typetraits.hh:588
│ │ │ │ -
bigunsignedint< k > operator*(const bigunsignedint< k > &x, std::uintmax_t y)
Definition bigunsignedint.hh:549
│ │ │ │ -
bigunsignedint< k > operator-(const bigunsignedint< k > &x, std::uintmax_t y)
Definition bigunsignedint.hh:542
│ │ │ │ -
bigunsignedint< k > operator+(const bigunsignedint< k > &x, std::uintmax_t y)
Definition bigunsignedint.hh:535
│ │ │ │ -
EnableIfInterOperable< T1, T2, bool >::type operator<(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition iteratorfacades.hh:638
│ │ │ │ -
EnableIfInterOperable< T1, T2, bool >::type operator>(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition iteratorfacades.hh:684
│ │ │ │ -
EnableIfInterOperable< T1, T2, bool >::type operator<=(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition iteratorfacades.hh:661
│ │ │ │ -
EnableIfInterOperable< T1, T2, bool >::type operator==(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for equality.
Definition iteratorfacades.hh:238
│ │ │ │ -
EnableIfInterOperable< T1, T2, bool >::type operator>=(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition iteratorfacades.hh:706
│ │ │ │ -
EnableIfInterOperable< T1, T2, bool >::type operator!=(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for inequality.
Definition iteratorfacades.hh:260
│ │ │ │ +
620 template<class T, int N, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
622 {
│ │ │ │ +
623 return list_->elementAt(i+position_);
│ │ │ │ +
624 }
│ │ │ │ +
│ │ │ │ +
625
│ │ │ │ +
626 template<class T, int N, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
628 {
│ │ │ │ +
629 return list_->elementAt(i+position_);
│ │ │ │ +
630 }
│ │ │ │ +
│ │ │ │ +
631
│ │ │ │ +
632 template<class T, int N, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
634 {
│ │ │ │ +
635 return list_->elementAt(position_);
│ │ │ │ +
636 }
│ │ │ │ +
│ │ │ │ +
637
│ │ │ │ +
638 template<class T, int N, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
640 {
│ │ │ │ +
641 return list_->elementAt(position_);
│ │ │ │ +
642 }
│ │ │ │ +
│ │ │ │ +
643
│ │ │ │ +
644 template<class T, int N, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
646 {
│ │ │ │ +
647 // Makes only sense if we reference a common list
│ │ │ │ +
648 assert(list_==(other.list_));
│ │ │ │ +
649 return other.position_ - position_;
│ │ │ │ +
650 }
│ │ │ │ +
│ │ │ │ +
651
│ │ │ │ +
652 template<class T, int N, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
654 {
│ │ │ │ +
655 // Makes only sense if we reference a common list
│ │ │ │ +
656 assert(list_==(other.list_));
│ │ │ │ +
657 return other.position_ - position_;
│ │ │ │ +
658 }
│ │ │ │ +
│ │ │ │ +
659
│ │ │ │ +
660 template<class T, int N, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
662 {
│ │ │ │ +
663 list_->size_ -= ++position_ - list_->start_;
│ │ │ │ +
664 // chunk number of the new position.
│ │ │ │ +
665 size_t posChunkStart = position_ / chunkSize_;
│ │ │ │ +
666 // number of chunks to deallocate
│ │ │ │ +
667 size_t chunks = (position_ - list_->start_ + list_->start_ % chunkSize_)
│ │ │ │ +
668 / chunkSize_;
│ │ │ │ +
669 list_->start_ = position_;
│ │ │ │ +
670
│ │ │ │ +
671 // Deallocate memory not needed any more.
│ │ │ │ +
672 for(size_t chunk=0; chunk<chunks; chunk++) {
│ │ │ │ +
673 --posChunkStart;
│ │ │ │ +
674 list_->chunks_[posChunkStart].reset();
│ │ │ │ +
675 }
│ │ │ │ +
676
│ │ │ │ +
677 // Capacity stays the same as the chunks before us
│ │ │ │ +
678 // are still there. They null pointers.
│ │ │ │ +
679 assert(list_->start_+list_->size_<=list_->capacity_);
│ │ │ │ +
680 }
│ │ │ │ +
│ │ │ │ +
681
│ │ │ │ +
682 template<class T, int N, class A>
│ │ │ │ + │ │ │ │ +
684 : position_(position), list_(&arrayList)
│ │ │ │ +
685 {}
│ │ │ │ +
686
│ │ │ │ +
687
│ │ │ │ +
688 template<class T, int N, class A>
│ │ │ │ +
689 ConstArrayListIterator<T,N,A>::ConstArrayListIterator(const ArrayList<T,N,A>& arrayList,
│ │ │ │ +
690 size_type position)
│ │ │ │ +
691 : position_(position), list_(&arrayList)
│ │ │ │ +
692 {}
│ │ │ │ +
693
│ │ │ │ +
694 template<class T, int N, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
696 : position_(other.position_), list_(other.list_)
│ │ │ │ +
697 {}
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
698
│ │ │ │ +
699
│ │ │ │ +
701}
│ │ │ │ +
702#endif
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
This file implements iterator facade classes for writing stl conformant iterators.
│ │ │ │ +
reference operator[](size_type i)
Get the element at specific position.
Definition arraylist.hh:489
│ │ │ │ +
iterator begin()
Get an iterator that is positioned at the first element.
Definition arraylist.hh:515
│ │ │ │ +
bool equals(const ArrayListIterator< MemberType, N, A > &other) const
Compares two iterators.
Definition arraylist.hh:571
│ │ │ │ +
void increment()
Increment the iterator.
Definition arraylist.hh:597
│ │ │ │ +
size_type size() const
Get the number of elements in the list.
Definition arraylist.hh:470
│ │ │ │ +
ConstArrayListIterator(const ArrayListIterator< T, N, A > &other)
Definition arraylist.hh:695
│ │ │ │ +
void purge()
Purge the list.
Definition arraylist.hh:539
│ │ │ │ +
void decrement()
decrement the iterator.
Definition arraylist.hh:609
│ │ │ │ +
void eraseToHere()
Erase all entries before the current position and the one at the current position.
Definition arraylist.hh:661
│ │ │ │ +
ArrayList()
Constructs an Array list with one chunk.
Definition arraylist.hh:455
│ │ │ │ +
const_iterator begin() const
Get a random access iterator that is positioned at the first element.
Definition arraylist.hh:521
│ │ │ │ +
void increment()
Increment the iterator.
Definition arraylist.hh:603
│ │ │ │ +
reference elementAt(size_type i) const
Get the value of the list at an arbitrary position.
Definition arraylist.hh:627
│ │ │ │ +
iterator end()
Get a random access iterator positioned after the last element.
Definition arraylist.hh:527
│ │ │ │ +
reference dereference() const
Access the element at the current position.
Definition arraylist.hh:639
│ │ │ │ +
const_reference operator[](size_type i) const
Get the element at specific position.
Definition arraylist.hh:496
│ │ │ │ +
void decrement()
decrement the iterator.
Definition arraylist.hh:615
│ │ │ │ +
void advance(difference_type n)
Definition arraylist.hh:564
│ │ │ │ +
const_iterator end() const
Get a random access iterator positioned after the last element.
Definition arraylist.hh:533
│ │ │ │ +
void clear()
Delete all entries from the list.
Definition arraylist.hh:462
│ │ │ │ +
reference elementAt(size_type i) const
Get the value of the list at an arbitrary position.
Definition arraylist.hh:621
│ │ │ │ +
bool equals(const ConstArrayListIterator< MemberType, N, A > &other) const
Compares to iterators.
Definition arraylist.hh:589
│ │ │ │ +
void advance(difference_type n)
Definition arraylist.hh:558
│ │ │ │ +
difference_type distanceTo(const ConstArrayListIterator< T, N, A > &other) const
Definition arraylist.hh:653
│ │ │ │ +
reference dereference() const
Access the element at the current position.
Definition arraylist.hh:633
│ │ │ │ +
void push_back(const_reference entry)
Append an entry to the list.
Definition arraylist.hh:476
│ │ │ │ +
difference_type distanceTo(const ArrayListIterator< T, N, A > &other) const
Definition arraylist.hh:645
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
bool any_true(const AlignedNumber< bool, align > &val)
Definition debugalign.hh:506
│ │ │ │ -
bool all_true(const AlignedNumber< bool, align > &val)
Definition debugalign.hh:512
│ │ │ │ -
T max_value(const AlignedNumber< T, align > &val)
Definition debugalign.hh:494
│ │ │ │ -
T min_value(const AlignedNumber< T, align > &val)
Definition debugalign.hh:500
│ │ │ │ -
This class encapsulates access of IteratorFacade.
Definition iteratorfacades.hh:786
│ │ │ │ -
CRTP-Mixing class for stl conformant iterators of given iterator category.
Definition iteratorfacades.hh:1053
│ │ │ │ -
constexpr decltype(auto) operator*() const
Dereferencing operator.
Definition iteratorfacades.hh:1119
│ │ │ │ -
dynamic integer range for use in range-based for loops
Definition rangeutilities.hh:177
│ │ │ │ -
constexpr iterator begin() const noexcept
obtain a random-access iterator to the first element
Definition rangeutilities.hh:194
│ │ │ │ -
constexpr iterator end() const noexcept
obtain a random-access iterator past the last element
Definition rangeutilities.hh:196
│ │ │ │ -
std::make_unsigned_t< T > size_type
unsigned integer type corresponding to value_type
Definition rangeutilities.hh:184
│ │ │ │ -
Impl::IntegralRangeIterator< T > iterator
type of iterator
Definition rangeutilities.hh:182
│ │ │ │ -
constexpr value_type operator[](const value_type &i) const noexcept
access specified element
Definition rangeutilities.hh:199
│ │ │ │ -
constexpr bool contains(value_type index) const noexcept
check whether given index is within range [from, to)
Definition rangeutilities.hh:207
│ │ │ │ -
constexpr bool empty() const noexcept
check whether the range is empty
Definition rangeutilities.hh:202
│ │ │ │ -
constexpr IntegralRange(std::pair< value_type, value_type > range) noexcept
construct integer range std::pair
Definition rangeutilities.hh:191
│ │ │ │ -
constexpr IntegralRange(value_type from, value_type to) noexcept
construct integer range [from, to)
Definition rangeutilities.hh:187
│ │ │ │ -
constexpr size_type size() const noexcept
obtain number of elements in the range
Definition rangeutilities.hh:204
│ │ │ │ -
constexpr IntegralRange(value_type to) noexcept
construct integer range [0, to)
Definition rangeutilities.hh:189
│ │ │ │ -
T value_type
type of integers contained in the range
Definition rangeutilities.hh:180
│ │ │ │ -
static integer range for use in range-based for loops
Definition rangeutilities.hh:230
│ │ │ │ -
static constexpr iterator end() noexcept
obtain a random-access iterator past the last element
Definition rangeutilities.hh:259
│ │ │ │ -
decltype(shift_integer_sequence< from >(std::make_integer_sequence< T, to-from >())) integer_sequence
type of corresponding std::integer_sequence
Definition rangeutilities.hh:243
│ │ │ │ -
static constexpr bool contains(value_type index) noexcept
check whether given index is within range [from, to)
Definition rangeutilities.hh:278
│ │ │ │ -
constexpr StaticIntegralRange() noexcept=default
default constructor
│ │ │ │ -
std::make_unsigned_t< T > size_type
unsigned integer type corresponding to value_type
Definition rangeutilities.hh:240
│ │ │ │ -
T value_type
type of integers contained in the range
Definition rangeutilities.hh:236
│ │ │ │ -
constexpr auto operator[](const std::integral_constant< U, i > &) const noexcept -> std::integral_constant< value_type, from+static_cast< value_type >(i)>
access specified element (static version)
Definition rangeutilities.hh:263
│ │ │ │ -
static constexpr std::integral_constant< bool, from==to > empty() noexcept
check whether the range is empty
Definition rangeutilities.hh:273
│ │ │ │ -
static constexpr iterator begin() noexcept
obtain a random-access iterator to the first element
Definition rangeutilities.hh:257
│ │ │ │ -
static constexpr integer_sequence to_integer_sequence() noexcept
return corresponding std::integer_sequence
Definition rangeutilities.hh:254
│ │ │ │ -
constexpr value_type operator[](const size_type &i) const noexcept
access specified element (dynamic version)
Definition rangeutilities.hh:270
│ │ │ │ -
Impl::IntegralRangeIterator< T > iterator
type of iterator
Definition rangeutilities.hh:238
│ │ │ │ -
static constexpr std::integral_constant< size_type, static_cast< size_type >(to) - static_cast< size_type >(from) > size() noexcept
obtain number of elements in the range
Definition rangeutilities.hh:275
│ │ │ │ -
Tag to enable value based transformations in TransformedRangeView.
Definition rangeutilities.hh:328
│ │ │ │ -
Tag to enable iterator based transformations in TransformedRangeView.
Definition rangeutilities.hh:333
│ │ │ │ -
A range transforming the values of another range on-the-fly.
Definition rangeutilities.hh:501
│ │ │ │ -
Impl::TransformedRangeIterator< RawIterator, F *, T > iterator
Iterator type.
Definition rangeutilities.hh:521
│ │ │ │ -
constexpr TransformedRangeView(RR &&rawRange, FF &&f) noexcept
Construct from range and function.
Definition rangeutilities.hh:535
│ │ │ │ -
constexpr iterator end() noexcept
Definition rangeutilities.hh:571
│ │ │ │ -
Impl::TransformedRangeIterator< RawConstIterator, const F *, T > const_iterator
Const iterator type.
Definition rangeutilities.hh:513
│ │ │ │ -
std::remove_reference_t< R > RawRange
Export type of the wrapped untransformed range.
Definition rangeutilities.hh:529
│ │ │ │ -
constexpr iterator begin() noexcept
Definition rangeutilities.hh:555
│ │ │ │ -
RawRange & rawRange() noexcept
Export the wrapped untransformed range.
Definition rangeutilities.hh:631
│ │ │ │ -
const RawRange & rawRange() const noexcept
Export the wrapped untransformed range.
Definition rangeutilities.hh:623
│ │ │ │ -
constexpr const_iterator begin() const noexcept
Obtain a iterator to the first element.
Definition rangeutilities.hh:551
│ │ │ │ -
auto size() const noexcept
Obtain the size of the range.
Definition rangeutilities.hh:607
│ │ │ │ -
constexpr const_iterator end() const noexcept
Obtain a iterator past the last element.
Definition rangeutilities.hh:567
│ │ │ │ -
constexpr bool empty() const noexcept
Checks whether the range is empty.
Definition rangeutilities.hh:615
│ │ │ │ -
Check if a type is callable with ()-operator and given arguments.
Definition typetraits.hh:162
│ │ │ │ +
A random access iterator for the Dune::ArrayList class.
Definition arraylist.hh:255
│ │ │ │ +
size_type position()
Definition arraylist.hh:329
│ │ │ │ +
A::value_type MemberType
The member type.
Definition arraylist.hh:263
│ │ │ │ +
ArrayListIterator()
Standard constructor.
Definition arraylist.hh:338
│ │ │ │ +
A::difference_type difference_type
Definition arraylist.hh:265
│ │ │ │ +
static constexpr int chunkSize_
The number of elements in one chunk of the list.
Definition arraylist.hh:278
│ │ │ │ +
A::size_type size_type
Definition arraylist.hh:267
│ │ │ │ +
typename A::value_type const & const_reference
Definition arraylist.hh:271
│ │ │ │ +
typename A::value_type & reference
Definition arraylist.hh:269
│ │ │ │ +
A constant random access iterator for the Dune::ArrayList class.
Definition arraylist.hh:368
│ │ │ │ +
static constexpr int chunkSize_
The number of elements in one chunk of the list.
Definition arraylist.hh:392
│ │ │ │ +
ConstArrayListIterator()
Definition arraylist.hh:429
│ │ │ │ +
typename A::value_type const & reference
Definition arraylist.hh:383
│ │ │ │ +
A::value_type MemberType
The member type.
Definition arraylist.hh:377
│ │ │ │ +
A::difference_type difference_type
Definition arraylist.hh:379
│ │ │ │ +
typename A::value_type const & const_reference
Definition arraylist.hh:385
│ │ │ │ +
A::size_type size_type
Definition arraylist.hh:381
│ │ │ │ +
A dynamically growing random access list.
Definition arraylist.hh:62
│ │ │ │ +
T value_type
Value type for stl compliance.
Definition arraylist.hh:74
│ │ │ │ +
static constexpr int chunkSize_
The number of elements in one chunk of the list. This has to be at least one. The default is 100.
Definition arraylist.hh:100
│ │ │ │ +
const T * const_pointer
The type of a const pointer to the type we store.
Definition arraylist.hh:94
│ │ │ │ +
ArrayListIterator< MemberType, N, A > iterator
A random access iterator.
Definition arraylist.hh:105
│ │ │ │ +
const T & const_reference
The type of a const reference to the type we store.
Definition arraylist.hh:84
│ │ │ │ +
T & reference
The type of a reference to the type we store.
Definition arraylist.hh:79
│ │ │ │ +
std::size_t size_type
The size type.
Definition arraylist.hh:115
│ │ │ │ +
T MemberType
The member type that is stored.
Definition arraylist.hh:69
│ │ │ │ +
T * pointer
The type of a pointer to the type we store.
Definition arraylist.hh:89
│ │ │ │ +
ConstArrayListIterator< MemberType, N, A > const_iterator
A constant random access iterator.
Definition arraylist.hh:110
│ │ │ │ +
std::ptrdiff_t difference_type
The difference type.
Definition arraylist.hh:120
│ │ │ │ +
Base class for stl conformant forward iterators.
Definition iteratorfacades.hh:435
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,804 +1,698 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -rangeutilities.hh │ │ │ │ │ +arraylist.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_COMMON_RANGE_UTILITIES_HH │ │ │ │ │ -6#define DUNE_COMMON_RANGE_UTILITIES_HH │ │ │ │ │ -7 │ │ │ │ │ -8#include │ │ │ │ │ -9#include │ │ │ │ │ -10#include │ │ │ │ │ -11#include │ │ │ │ │ -12 │ │ │ │ │ -13#include │ │ │ │ │ -14#include │ │ │ │ │ -15 │ │ │ │ │ -23namespace Dune │ │ │ │ │ -24{ │ │ │ │ │ -25 │ │ │ │ │ -36 template ::value, int>::type = 0> │ │ │ │ │ -38 typename T::value_type │ │ │ │ │ -39 max_value(const T & v) { │ │ │ │ │ -40 using std::max_element; │ │ │ │ │ -41 return *max_element(v.begin(), v.end()); │ │ │ │ │ -42 } │ │ │ │ │ -43 │ │ │ │ │ -44 template ::value, int>::type = 0> │ │ │ │ │ -46 const T & max_value(const T & v) { return v; } │ │ │ │ │ -47 │ │ │ │ │ -53 template ::value, int>::type = 0> │ │ │ │ │ -55 typename T::value_type │ │ │ │ │ -56 min_value(const T & v) { │ │ │ │ │ -57 using std::min_element; │ │ │ │ │ -58 return *min_element(v.begin(), v.end()); │ │ │ │ │ -59 } │ │ │ │ │ -60 │ │ │ │ │ -61 template ::value, int>::type = 0> │ │ │ │ │ -63 const T & min_value(const T & v) { return v; } │ │ │ │ │ -64 │ │ │ │ │ -70 template ::value, int>::type = 0> │ │ │ │ │ -72 bool any_true(const T & v) { │ │ │ │ │ -73 bool b = false; │ │ │ │ │ -74 for (const auto & e : v) │ │ │ │ │ -75 b = b or bool(e); │ │ │ │ │ -76 return b; │ │ │ │ │ -77 } │ │ │ │ │ -78 │ │ │ │ │ -79 template ::value, int>::type = 0> │ │ │ │ │ -81 bool any_true(const T & v) { return v; } │ │ │ │ │ -82 │ │ │ │ │ -83 template │ │ │ │ │ -84 bool any_true(const std::bitset & b) │ │ │ │ │ -85 { │ │ │ │ │ -86 return b.any(); │ │ │ │ │ -87 } │ │ │ │ │ -88 │ │ │ │ │ -94 template ::value, int>::type = 0> │ │ │ │ │ -96 bool all_true(const T & v) { │ │ │ │ │ -97 bool b = true; │ │ │ │ │ -98 for (const auto & e : v) │ │ │ │ │ -99 b = b and bool(e); │ │ │ │ │ -100 return b; │ │ │ │ │ -101 } │ │ │ │ │ -102 │ │ │ │ │ -103 template ::value, int>::type = 0> │ │ │ │ │ -105 bool all_true(const T & v) { return v; } │ │ │ │ │ +5 │ │ │ │ │ +6#ifndef DUNE_COMMON_ARRAYLIST_HH │ │ │ │ │ +7#define DUNE_COMMON_ARRAYLIST_HH │ │ │ │ │ +8 │ │ │ │ │ +9#include │ │ │ │ │ +10#include │ │ │ │ │ +11#include │ │ │ │ │ +12#include │ │ │ │ │ +13#include "iteratorfacades.hh" │ │ │ │ │ +14 │ │ │ │ │ +15namespace Dune │ │ │ │ │ +16{ │ │ │ │ │ +17 // forward declaration │ │ │ │ │ +18 template │ │ │ │ │ +19 class ArrayListIterator; │ │ │ │ │ +20 │ │ │ │ │ +21 template │ │ │ │ │ +22 class ConstArrayListIterator; │ │ │ │ │ +23 │ │ │ │ │ +60 template > │ │ │ │ │ +61 class ArrayList │ │ │ │ │ +62 { │ │ │ │ │ +63 public: │ │ │ │ │ +69 typedef T MemberType; │ │ │ │ │ +70 │ │ │ │ │ +74 typedef T value_type; │ │ │ │ │ +75 │ │ │ │ │ +79 typedef T& reference; │ │ │ │ │ +80 │ │ │ │ │ +84 typedef const T& const_reference; │ │ │ │ │ +85 │ │ │ │ │ +89 typedef T* pointer; │ │ │ │ │ +90 │ │ │ │ │ +94 typedef const T* const_pointer; │ │ │ │ │ +95 │ │ │ │ │ +100 constexpr static int chunkSize_ = (N > 0) ? N : 1; │ │ │ │ │ +101 │ │ │ │ │ +105 typedef ArrayListIterator iterator; │ │ │ │ │ 106 │ │ │ │ │ -107 template │ │ │ │ │ -108 bool all_true(const std::bitset & b) │ │ │ │ │ -109 { │ │ │ │ │ -110 return b.all(); │ │ │ │ │ -111 } │ │ │ │ │ -112 │ │ │ │ │ -113 │ │ │ │ │ -114 │ │ │ │ │ -115 namespace Impl │ │ │ │ │ -116 { │ │ │ │ │ -117 │ │ │ │ │ -118 template │ │ │ │ │ -119 class IntegralRangeIterator │ │ │ │ │ -120 { │ │ │ │ │ -121 public: │ │ │ │ │ -122 typedef std::random_access_iterator_tag iterator_category; │ │ │ │ │ -123 typedef T value_type; │ │ │ │ │ -124 typedef std::make_signed_t difference_type; │ │ │ │ │ -125 typedef const T *pointer; │ │ │ │ │ -126 typedef T reference; │ │ │ │ │ +110 typedef ConstArrayListIterator const_iterator; │ │ │ │ │ +111 │ │ │ │ │ +115 typedef std::size_t size_type; │ │ │ │ │ +116 │ │ │ │ │ +120 typedef std::ptrdiff_t difference_type; │ │ │ │ │ +121 │ │ │ │ │ +126 iterator begin(); │ │ │ │ │ 127 │ │ │ │ │ -128 constexpr IntegralRangeIterator() noexcept : value_(0) {} │ │ │ │ │ -129 constexpr explicit IntegralRangeIterator(value_type value) noexcept : │ │ │ │ │ -value_(value) {} │ │ │ │ │ -130 │ │ │ │ │ -131 pointer operator->() const noexcept { return &value_; } │ │ │ │ │ -132 constexpr reference operator*() const noexcept { return value_; } │ │ │ │ │ -133 │ │ │ │ │ -134 constexpr reference operator[]( difference_type n ) const noexcept { return │ │ │ │ │ -(value_ + n); } │ │ │ │ │ -135 │ │ │ │ │ -136 constexpr bool operator==(const IntegralRangeIterator & other) const │ │ │ │ │ -noexcept { return (value_ == other.value_); } │ │ │ │ │ -137 constexpr bool operator!=(const IntegralRangeIterator & other) const │ │ │ │ │ -noexcept { return (value_ != other.value_); } │ │ │ │ │ -138 │ │ │ │ │ -139 constexpr bool operator<(const IntegralRangeIterator & other) const │ │ │ │ │ -noexcept { return (value_ <= other.value_); } │ │ │ │ │ -140 constexpr bool operator<=(const IntegralRangeIterator & other) const │ │ │ │ │ -noexcept { return (value_ <= other.value_); } │ │ │ │ │ -141 constexpr bool operator>(const IntegralRangeIterator & other) const │ │ │ │ │ -noexcept { return (value_ >= other.value_); } │ │ │ │ │ -142 constexpr bool operator>=(const IntegralRangeIterator & other) const │ │ │ │ │ -noexcept { return (value_ >= other.value_); } │ │ │ │ │ -143 │ │ │ │ │ -144 IntegralRangeIterator& operator++() noexcept { ++value_; return *this; } │ │ │ │ │ -145 IntegralRangeIterator operator++(int) noexcept { IntegralRangeIterator copy │ │ │ │ │ -( *this ); ++(*this); return copy; } │ │ │ │ │ +133 const_iterator begin() const; │ │ │ │ │ +134 │ │ │ │ │ +139 iterator end(); │ │ │ │ │ +140 │ │ │ │ │ +145 const_iterator end() const; │ │ │ │ │ 146 │ │ │ │ │ -147 IntegralRangeIterator& operator--() noexcept { --value_; return *this; } │ │ │ │ │ -148 IntegralRangeIterator operator--(int) noexcept { IntegralRangeIterator copy │ │ │ │ │ -( *this ); --(*this); return copy; } │ │ │ │ │ -149 │ │ │ │ │ -150 IntegralRangeIterator& operator+=(difference_type n) noexcept { value_ += │ │ │ │ │ -n; return *this; } │ │ │ │ │ -151 IntegralRangeIterator& operator-=(difference_type n) noexcept { value_ - │ │ │ │ │ -= n; return *this; } │ │ │ │ │ +151 inline void push_back(const_reference entry); │ │ │ │ │ 152 │ │ │ │ │ -153 friend constexpr IntegralRangeIterator operator+(const │ │ │ │ │ -IntegralRangeIterator &a, difference_type n) noexcept { return │ │ │ │ │ -IntegralRangeIterator(a.value_ + n); } │ │ │ │ │ -154 friend constexpr IntegralRangeIterator operator+(difference_type n, const │ │ │ │ │ -IntegralRangeIterator &a) noexcept { return IntegralRangeIterator(a.value_ + │ │ │ │ │ -n); } │ │ │ │ │ -155 friend constexpr IntegralRangeIterator operator-(const │ │ │ │ │ -IntegralRangeIterator &a, difference_type n) noexcept { return │ │ │ │ │ -IntegralRangeIterator(a.value_ - n); } │ │ │ │ │ -156 │ │ │ │ │ -157 constexpr difference_type operator-(const IntegralRangeIterator &other) │ │ │ │ │ -const noexcept { return (static_cast(value_) - static_ │ │ │ │ │ -cast(other.value_)); } │ │ │ │ │ -158 │ │ │ │ │ -159 private: │ │ │ │ │ -160 value_type value_; │ │ │ │ │ -161 }; │ │ │ │ │ -162 │ │ │ │ │ -163 } // namespace Impl │ │ │ │ │ -164 │ │ │ │ │ -165 │ │ │ │ │ +158 inline reference operator[](size_type i); │ │ │ │ │ +159 │ │ │ │ │ +165 inline const_reference operator[](size_type i) const; │ │ │ │ │ 166 │ │ │ │ │ -175 template │ │ │ │ │ -176 class IntegralRange │ │ │ │ │ -177 { │ │ │ │ │ -178 public: │ │ │ │ │ -180 typedef T value_type; │ │ │ │ │ -182 typedef Impl::IntegralRangeIterator iterator; │ │ │ │ │ -184 typedef std::make_unsigned_t size_type; │ │ │ │ │ -185 │ │ │ │ │ -187 constexpr IntegralRange(value_type from, value_type to) noexcept : from_ │ │ │ │ │ -(from), to_(to) {} │ │ │ │ │ -189 constexpr explicit IntegralRange(value_type to) noexcept : from_(0), to_ │ │ │ │ │ -(to) {} │ │ │ │ │ -191 constexpr IntegralRange(std::pair range) noexcept : │ │ │ │ │ -from_(range.first), to_(range.second) {} │ │ │ │ │ +171 inline size_type size() const; │ │ │ │ │ +172 │ │ │ │ │ +180 inline void purge(); │ │ │ │ │ +181 │ │ │ │ │ +185 inline void clear(); │ │ │ │ │ +189 ArrayList(); │ │ │ │ │ +190 │ │ │ │ │ +191 private: │ │ │ │ │ 192 │ │ │ │ │ -194 constexpr iterator begin() const noexcept { return iterator(from_); } │ │ │ │ │ -196 constexpr iterator end() const noexcept { return iterator(to_); } │ │ │ │ │ +196 using SmartPointerAllocator = typename std::allocator_traits::template │ │ │ │ │ +rebind_alloc< std::shared_ptr< std::array > >; │ │ │ │ │ 197 │ │ │ │ │ -199 constexpr value_type operator[](const value_type &i) const noexcept │ │ │ │ │ -{ return (from_ + i); } │ │ │ │ │ -200 │ │ │ │ │ -202 constexpr bool empty() const noexcept { return (from_ == to_); } │ │ │ │ │ -204 constexpr size_type size() const noexcept { return (static_cast │ │ │ │ │ -(to_) - static_cast(from_)); } │ │ │ │ │ -205 │ │ │ │ │ -207 constexpr bool contains(value_type index) const noexcept { return from_ <= │ │ │ │ │ -index && index < to_; } │ │ │ │ │ +201 using ArrayAllocator = typename std::allocator_traits::template rebind_ │ │ │ │ │ +alloc< std::array >; │ │ │ │ │ +202 │ │ │ │ │ +206 friend class ArrayListIterator; │ │ │ │ │ +207 friend class ConstArrayListIterator; │ │ │ │ │ 208 │ │ │ │ │ -209 private: │ │ │ │ │ -210 value_type from_, to_; │ │ │ │ │ -211 }; │ │ │ │ │ -212 │ │ │ │ │ -213 │ │ │ │ │ -228 template │ │ │ │ │ -229 class StaticIntegralRange │ │ │ │ │ -230 { │ │ │ │ │ -231 template │ │ │ │ │ -232 static std::integer_sequence shift_integer_sequence(std:: │ │ │ │ │ -integer_sequence); │ │ │ │ │ -233 │ │ │ │ │ -234 public: │ │ │ │ │ -236 typedef T value_type; │ │ │ │ │ -238 typedef Impl::IntegralRangeIterator iterator; │ │ │ │ │ -240 typedef std::make_unsigned_t size_type; │ │ │ │ │ -241 │ │ │ │ │ -243 typedef decltype(shift_integer_sequence(std::make_integer_sequence())) integer_sequence; │ │ │ │ │ -244 │ │ │ │ │ -246 constexpr StaticIntegralRange() noexcept = default; │ │ │ │ │ -247 │ │ │ │ │ -249 constexpr operator IntegralRange() const noexcept { return {from, to}; } │ │ │ │ │ -251 constexpr operator integer_sequence() const noexcept { return {}; } │ │ │ │ │ -252 │ │ │ │ │ -254 static constexpr integer_sequence to_integer_sequence() noexcept { return │ │ │ │ │ -{}; } │ │ │ │ │ -255 │ │ │ │ │ -257 static constexpr iterator begin() noexcept { return iterator(from); } │ │ │ │ │ -259 static constexpr iterator end() noexcept { return iterator(to); } │ │ │ │ │ -260 │ │ │ │ │ -262 template │ │ │ │ │ -263 constexpr auto operator[](const std::integral_constant &) const │ │ │ │ │ -noexcept │ │ │ │ │ -264 -> std::integral_constant(i)> │ │ │ │ │ -265 { │ │ │ │ │ -266 return {}; │ │ │ │ │ -267 } │ │ │ │ │ +210 std::vector >, │ │ │ │ │ +211 SmartPointerAllocator> chunks_; │ │ │ │ │ +220 size_type capacity_; │ │ │ │ │ +222 size_type size_; │ │ │ │ │ +224 size_type start_; │ │ │ │ │ +233 inline reference elementAt(size_type i); │ │ │ │ │ +234 │ │ │ │ │ +243 inline const_reference elementAt(size_type i) const; │ │ │ │ │ +244 }; │ │ │ │ │ +245 │ │ │ │ │ +246 │ │ │ │ │ +250 template │ │ │ │ │ +251 class ArrayListIterator : public │ │ │ │ │ +RandomAccessIteratorFacade, │ │ │ │ │ +252 typename A::value_type, │ │ │ │ │ +253 typename A::value_type &, │ │ │ │ │ +254 typename A::difference_type> │ │ │ │ │ +255 { │ │ │ │ │ +256 │ │ │ │ │ +257 friend class ArrayList; │ │ │ │ │ +258 friend class ConstArrayListIterator; │ │ │ │ │ +259 public: │ │ │ │ │ +263 typedef typename A::value_type MemberType; │ │ │ │ │ +264 │ │ │ │ │ +265 typedef typename A::difference_type difference_type; │ │ │ │ │ +266 │ │ │ │ │ +267 typedef typename A::size_type size_type; │ │ │ │ │ 268 │ │ │ │ │ -270 constexpr value_type operator[](const size_type &i) const noexcept { return │ │ │ │ │ -(from + static_cast(i)); } │ │ │ │ │ -271 │ │ │ │ │ -273 static constexpr std::integral_constant empty() noexcept │ │ │ │ │ -{ return {}; } │ │ │ │ │ -275 static constexpr std::integral_constant │ │ │ │ │ -(to) - static_cast(from) > size() noexcept { return {}; } │ │ │ │ │ -276 │ │ │ │ │ -278 static constexpr bool contains(value_type index) noexcept { return from <= │ │ │ │ │ -index && index < to; } │ │ │ │ │ +269 using reference = typename A::value_type &; │ │ │ │ │ +270 │ │ │ │ │ +271 using const_reference = typename A::value_type const&; │ │ │ │ │ +272 │ │ │ │ │ +278 constexpr static int chunkSize_ = (N > 0) ? N : 1; │ │ │ │ │ 279 │ │ │ │ │ -280 }; │ │ │ │ │ -281 │ │ │ │ │ -291 template, std::decay_t>::value, │ │ │ │ │ -int> = 0, │ │ │ │ │ -293 std::enable_if_t>::value, int> = 0> │ │ │ │ │ -294 inline static IntegralRange> range(T &&from, U &&to) │ │ │ │ │ -noexcept │ │ │ │ │ -295 { │ │ │ │ │ -296 return IntegralRange>(std::forward(from), std:: │ │ │ │ │ -forward(to)); │ │ │ │ │ -297 } │ │ │ │ │ -298 │ │ │ │ │ -299 template>:: │ │ │ │ │ -value, int> = 0> │ │ │ │ │ -300 inline static IntegralRange> range(T &&to) noexcept │ │ │ │ │ -301 { │ │ │ │ │ -302 return IntegralRange>(std::forward(to)); │ │ │ │ │ -303 } │ │ │ │ │ +280 │ │ │ │ │ +286 inline bool equals(const ArrayListIterator& other) const; │ │ │ │ │ +287 │ │ │ │ │ +293 inline bool equals(const ConstArrayListIterator& other) │ │ │ │ │ +const; │ │ │ │ │ +294 │ │ │ │ │ +298 inline void increment(); │ │ │ │ │ +299 │ │ │ │ │ +303 inline void decrement(); │ │ │ │ │ 304 │ │ │ │ │ -305 template>::value, │ │ │ │ │ -int> = 0> │ │ │ │ │ -306 inline static IntegralRange>> range │ │ │ │ │ -(T &&to) noexcept │ │ │ │ │ -307 { │ │ │ │ │ -308 return IntegralRange>>(std:: │ │ │ │ │ -forward(to)); │ │ │ │ │ -309 } │ │ │ │ │ +309 inline reference elementAt(size_type i) const; │ │ │ │ │ 310 │ │ │ │ │ -311 template │ │ │ │ │ -312 inline static StaticIntegralRange range(std::integral_ │ │ │ │ │ -constant, std::integral_constant) noexcept │ │ │ │ │ -313 { │ │ │ │ │ -314 return {}; │ │ │ │ │ -315 } │ │ │ │ │ +315 inline reference dereference() const; │ │ │ │ │ 316 │ │ │ │ │ -317 template │ │ │ │ │ -318 inline static StaticIntegralRange range(std::integral_constant) noexcept │ │ │ │ │ -319 { │ │ │ │ │ -320 return {}; │ │ │ │ │ -321 } │ │ │ │ │ -322 │ │ │ │ │ -323 │ │ │ │ │ -324 │ │ │ │ │ -328 struct ValueTransformationTag {}; │ │ │ │ │ -329 │ │ │ │ │ -333 struct IteratorTransformationTag {}; │ │ │ │ │ -334 │ │ │ │ │ -335 namespace Impl │ │ │ │ │ -336 { │ │ │ │ │ -337 │ │ │ │ │ -338 │ │ │ │ │ -339 │ │ │ │ │ -340 // An iterator transforming a wrapped iterator using │ │ │ │ │ -341 // an unary function. It inherits the iterator-category │ │ │ │ │ -342 // of the underlying iterator. │ │ │ │ │ -343 // │ │ │ │ │ -344 // \tparam I Type of the underlying iterator │ │ │ │ │ -345 // \tparam F Type of transformation function that can either be applied │ │ │ │ │ -directly or after dereferencing │ │ │ │ │ -346 // \tparam TT Type of transformation (ValueTransformationTag or │ │ │ │ │ -IteratorTransformationTag) │ │ │ │ │ -347 // \tparam C An iterator category tag, defaults to the one of I │ │ │ │ │ -348 template ::iterator_category> │ │ │ │ │ -349 class TransformedRangeIterator; │ │ │ │ │ -350 │ │ │ │ │ -351 template │ │ │ │ │ -352 struct TransformationRangeIteratorTraits │ │ │ │ │ -353 { │ │ │ │ │ -354 template │ │ │ │ │ -355 static decltype(auto) transform(FF&& f, const I& it) { │ │ │ │ │ -356 if constexpr (std::is_same_v) │ │ │ │ │ -357 { │ │ │ │ │ -358 if constexpr (Dune::IsCallable::value) │ │ │ │ │ -359 return f(it); │ │ │ │ │ -360 else │ │ │ │ │ -361 return (*f)(it); │ │ │ │ │ -362 } │ │ │ │ │ -363 else │ │ │ │ │ -364 { │ │ │ │ │ -365 if constexpr (Dune::IsCallable::value) │ │ │ │ │ -366 return f(*it); │ │ │ │ │ -367 else │ │ │ │ │ -368 return (*f)(*it); │ │ │ │ │ -369 } │ │ │ │ │ -370 } │ │ │ │ │ -371 │ │ │ │ │ -372 using reference = decltype(transform(std::declval(), std::declval │ │ │ │ │ -())); │ │ │ │ │ -373 using value_type = Dune::AutonomousValue; │ │ │ │ │ -374 using pointer = std::conditional_t, │ │ │ │ │ -value_type*, ProxyArrowResult>; │ │ │ │ │ -375 using difference_type = typename std::iterator_traits::difference_type; │ │ │ │ │ -376 using Facade = Dune::IteratorFacade, C, │ │ │ │ │ -value_type, reference, pointer, difference_type>; │ │ │ │ │ -377 }; │ │ │ │ │ +326 inline void eraseToHere(); │ │ │ │ │ +327 │ │ │ │ │ +329 inline size_type position(){return position_;} │ │ │ │ │ +330 │ │ │ │ │ +332 inline void advance(difference_type n); │ │ │ │ │ +333 │ │ │ │ │ +335 inline difference_type distanceTo(const ArrayListIterator& other) │ │ │ │ │ +const; │ │ │ │ │ +336 │ │ │ │ │ +338 inline ArrayListIterator() : position_(0), list_(nullptr) │ │ │ │ │ +339 {} │ │ │ │ │ +340 │ │ │ │ │ +341 private: │ │ │ │ │ +347 inline ArrayListIterator(ArrayList& arrayList, size_type position); │ │ │ │ │ +348 │ │ │ │ │ +352 size_type position_; │ │ │ │ │ +356 ArrayList* list_; │ │ │ │ │ +357 }; │ │ │ │ │ +358 │ │ │ │ │ +362 template │ │ │ │ │ +363 class ConstArrayListIterator │ │ │ │ │ +364 : public RandomAccessIteratorFacade, │ │ │ │ │ +365 const typename A::value_type, │ │ │ │ │ +366 typename A::value_type const&, │ │ │ │ │ +367 typename A::difference_type> │ │ │ │ │ +368 { │ │ │ │ │ +369 │ │ │ │ │ +370 friend class ArrayList; │ │ │ │ │ +371 friend class ArrayListIterator; │ │ │ │ │ +372 │ │ │ │ │ +373 public: │ │ │ │ │ +377 typedef typename A::value_type MemberType; │ │ │ │ │ 378 │ │ │ │ │ -379 │ │ │ │ │ -380 template │ │ │ │ │ -381 class TransformedRangeIterator : │ │ │ │ │ -382 public TransformationRangeIteratorTraits::Facade │ │ │ │ │ -383 { │ │ │ │ │ -384 using Traits = TransformationRangeIteratorTraits; │ │ │ │ │ -385 using Facade = typename Traits::Facade; │ │ │ │ │ +379 typedef typename A::difference_type difference_type; │ │ │ │ │ +380 │ │ │ │ │ +381 typedef typename A::size_type size_type; │ │ │ │ │ +382 │ │ │ │ │ +383 using reference = typename A::value_type const&; │ │ │ │ │ +384 │ │ │ │ │ +385 using const_reference = typename A::value_type const&; │ │ │ │ │ 386 │ │ │ │ │ -387 static constexpr bool isBidirectional = std::is_convertible_v; │ │ │ │ │ -388 static constexpr bool isRandomAccess = std::is_convertible_v; │ │ │ │ │ -389 │ │ │ │ │ -390 public: │ │ │ │ │ -391 │ │ │ │ │ -392 using Function = F; │ │ │ │ │ -393 using reference = typename Facade::reference; │ │ │ │ │ -394 using difference_type = typename Facade::difference_type; │ │ │ │ │ -395 │ │ │ │ │ -396 template │ │ │ │ │ -397 constexpr TransformedRangeIterator(II&& it, FF&& f) noexcept : │ │ │ │ │ -398 it_(std::forward(it)), │ │ │ │ │ -399 f_(std::forward(f)) │ │ │ │ │ -400 {} │ │ │ │ │ -401 │ │ │ │ │ -402 template =0, │ │ │ │ │ -404 std::enable_if_t and std::is_default_ │ │ │ │ │ -constructible_v, int> =0> │ │ │ │ │ -405 constexpr TransformedRangeIterator(II&& it) noexcept : │ │ │ │ │ -406 it_(std::forward(it)), │ │ │ │ │ -407 f_() │ │ │ │ │ -408 {} │ │ │ │ │ -409 │ │ │ │ │ -410 template =0, │ │ │ │ │ -412 std::enable_if_t and std::is_default_ │ │ │ │ │ -constructible_v, int> =0> │ │ │ │ │ -413 constexpr TransformedRangeIterator(FF&& f) noexcept : │ │ │ │ │ -414 it_(), │ │ │ │ │ -415 f_(std::forward(f)) │ │ │ │ │ -416 {} │ │ │ │ │ -417 │ │ │ │ │ -418 // Explicitly initialize members. Using a plain │ │ │ │ │ -419 // │ │ │ │ │ -420 // constexpr TransformedRangeIterator() noexcept {} │ │ │ │ │ -421 // │ │ │ │ │ -422 // would default-initialize the members while │ │ │ │ │ -423 // │ │ │ │ │ -424 // constexpr TransformedRangeIterator() noexcept : it_(), f_() {} │ │ │ │ │ -425 // │ │ │ │ │ -426 // leads to value-initialization. This is a case where │ │ │ │ │ -427 // both are really different. If it_ is a raw pointer (i.e. POD) │ │ │ │ │ -428 // then default-initialization leaves it uninitialized while │ │ │ │ │ -429 // value-initialization zero-initializes it. │ │ │ │ │ -430 constexpr TransformedRangeIterator() noexcept : │ │ │ │ │ -431 it_(), │ │ │ │ │ -432 f_() │ │ │ │ │ -433 {} │ │ │ │ │ -434 │ │ │ │ │ -435 // Dereferencing returns a value created by the function │ │ │ │ │ -436 constexpr reference operator*() const noexcept { │ │ │ │ │ -437 return Traits::transform(f_, it_); │ │ │ │ │ -438 } │ │ │ │ │ -439 │ │ │ │ │ -440 protected: │ │ │ │ │ -441 │ │ │ │ │ -442 friend Dune::IteratorFacadeAccess; │ │ │ │ │ -443 │ │ │ │ │ -444 // Export base iterator, such that equalilty comparison, │ │ │ │ │ -445 // differences, and inequality comparisons are automatically │ │ │ │ │ -446 // forwarded to the base iterator by the facade. │ │ │ │ │ -447 const I& baseIterator() const noexcept { │ │ │ │ │ -448 return it_; │ │ │ │ │ -449 } │ │ │ │ │ -450 │ │ │ │ │ -451 I& baseIterator() noexcept { │ │ │ │ │ -452 return it_; │ │ │ │ │ -453 } │ │ │ │ │ -454 │ │ │ │ │ -455 I it_; │ │ │ │ │ -456 Function f_; │ │ │ │ │ -457 }; │ │ │ │ │ -458 │ │ │ │ │ -459 } // namespace Impl │ │ │ │ │ +392 constexpr static int chunkSize_ = (N > 0) ? N : 1; │ │ │ │ │ +393 │ │ │ │ │ +399 inline bool equals(const ConstArrayListIterator& other) │ │ │ │ │ +const; │ │ │ │ │ +400 │ │ │ │ │ +404 inline void increment(); │ │ │ │ │ +405 │ │ │ │ │ +409 inline void decrement(); │ │ │ │ │ +410 │ │ │ │ │ +412 inline void advance(difference_type n); │ │ │ │ │ +413 │ │ │ │ │ +415 inline difference_type distanceTo(const ConstArrayListIterator& │ │ │ │ │ +other) const; │ │ │ │ │ +416 │ │ │ │ │ +421 inline reference elementAt(size_type i) const; │ │ │ │ │ +422 │ │ │ │ │ +427 inline reference dereference() const; │ │ │ │ │ +428 │ │ │ │ │ +429 inline ConstArrayListIterator() : position_(0), list_(nullptr) │ │ │ │ │ +430 {} │ │ │ │ │ +431 │ │ │ │ │ +432 inline ConstArrayListIterator(const ArrayListIterator& other); │ │ │ │ │ +433 │ │ │ │ │ +434 private: │ │ │ │ │ +435 │ │ │ │ │ +441 inline ConstArrayListIterator(const ArrayList& arrayList, size_type │ │ │ │ │ +position); │ │ │ │ │ +442 │ │ │ │ │ +446 size_type position_; │ │ │ │ │ +450 const ArrayList* list_; │ │ │ │ │ +451 }; │ │ │ │ │ +452 │ │ │ │ │ +453 │ │ │ │ │ +454 template │ │ │ │ │ +455 ArrayList::ArrayList() │ │ │ │ │ +456 : capacity_(0), size_(0), start_(0) │ │ │ │ │ +457 { │ │ │ │ │ +458 chunks_.reserve(100); │ │ │ │ │ +459 } │ │ │ │ │ 460 │ │ │ │ │ -461 │ │ │ │ │ -462 │ │ │ │ │ -499 template │ │ │ │ │ -500 class TransformedRangeView │ │ │ │ │ -501 { │ │ │ │ │ -502 using RawConstIterator = std::decay_t │ │ │ │ │ -().begin())>; │ │ │ │ │ -503 using RawIterator = std::decay_t().begin())>; │ │ │ │ │ -504 │ │ │ │ │ -505 public: │ │ │ │ │ +461 template │ │ │ │ │ +462 void ArrayList::clear(){ │ │ │ │ │ +463 capacity_=0; │ │ │ │ │ +464 size_=0; │ │ │ │ │ +465 start_=0; │ │ │ │ │ +466 chunks_.clear(); │ │ │ │ │ +467 } │ │ │ │ │ +468 │ │ │ │ │ +469 template │ │ │ │ │ +470 size_t ArrayList::size() const │ │ │ │ │ +471 { │ │ │ │ │ +472 return size_; │ │ │ │ │ +473 } │ │ │ │ │ +474 │ │ │ │ │ +475 template │ │ │ │ │ +476 void ArrayList::push_back(const_reference entry) │ │ │ │ │ +477 { │ │ │ │ │ +478 size_t index=start_+size_; │ │ │ │ │ +479 if(index==capacity_) │ │ │ │ │ +480 { │ │ │ │ │ +481 chunks_.push_back(std::make_shared >()); │ │ │ │ │ +482 capacity_ += chunkSize_; │ │ │ │ │ +483 } │ │ │ │ │ +484 elementAt(index)=entry; │ │ │ │ │ +485 ++size_; │ │ │ │ │ +486 } │ │ │ │ │ +487 │ │ │ │ │ +488 template │ │ │ │ │ +489 typename ArrayList::reference ArrayList::operator[](size_type │ │ │ │ │ +i) │ │ │ │ │ +490 { │ │ │ │ │ +491 return elementAt(start_+i); │ │ │ │ │ +492 } │ │ │ │ │ +493 │ │ │ │ │ +494 │ │ │ │ │ +495 template │ │ │ │ │ +496 typename ArrayList::const_reference ArrayList::operator[] │ │ │ │ │ +(size_type i) const │ │ │ │ │ +497 { │ │ │ │ │ +498 return elementAt(start_+i); │ │ │ │ │ +499 } │ │ │ │ │ +500 │ │ │ │ │ +501 template │ │ │ │ │ +502 typename ArrayList::reference ArrayList::elementAt(size_type │ │ │ │ │ +i) │ │ │ │ │ +503 { │ │ │ │ │ +504 return chunks_[i/chunkSize_]->operator[](i%chunkSize_); │ │ │ │ │ +505 } │ │ │ │ │ 506 │ │ │ │ │ -513 using const_iterator = Impl::TransformedRangeIterator; │ │ │ │ │ -514 │ │ │ │ │ -521 using iterator = Impl::TransformedRangeIterator; │ │ │ │ │ -522 │ │ │ │ │ -529 using RawRange = std::remove_reference_t; │ │ │ │ │ -530 │ │ │ │ │ -534 template │ │ │ │ │ -535 constexpr TransformedRangeView(RR&& rawRange, FF&& f) noexcept : │ │ │ │ │ -536 rawRange_(std::forward(rawRange)), │ │ │ │ │ -537 f_(std::forward(f)) │ │ │ │ │ -538 { │ │ │ │ │ -539 static_assert(std::is_same_v or std::is_same_ │ │ │ │ │ -v, │ │ │ │ │ -540 "The TransformationType passed to TransformedRangeView has to be either │ │ │ │ │ -ValueTransformationTag or IteratorTransformationTag."); │ │ │ │ │ -541 } │ │ │ │ │ -542 │ │ │ │ │ -551 constexpr const_iterator begin() const noexcept { │ │ │ │ │ -552 return const_iterator(rawRange_.begin(), &f_); │ │ │ │ │ -553 } │ │ │ │ │ -554 │ │ │ │ │ -555 constexpr iterator begin() noexcept { │ │ │ │ │ -556 return iterator(rawRange_.begin(), &f_); │ │ │ │ │ -557 } │ │ │ │ │ -558 │ │ │ │ │ -567 constexpr const_iterator end() const noexcept { │ │ │ │ │ -568 return const_iterator(rawRange_.end(), &f_); │ │ │ │ │ -569 } │ │ │ │ │ -570 │ │ │ │ │ -571 constexpr iterator end() noexcept { │ │ │ │ │ -572 return iterator(rawRange_.end(), &f_); │ │ │ │ │ -573 } │ │ │ │ │ -574 │ │ │ │ │ -578 template, int> = 0> │ │ │ │ │ -580 constexpr decltype(auto) operator[](std::size_t i) const noexcept │ │ │ │ │ +507 │ │ │ │ │ +508 template │ │ │ │ │ +509 typename ArrayList::const_reference ArrayList::elementAt │ │ │ │ │ +(size_type i) const │ │ │ │ │ +510 { │ │ │ │ │ +511 return chunks_[i/chunkSize_]->operator[](i%chunkSize_); │ │ │ │ │ +512 } │ │ │ │ │ +513 │ │ │ │ │ +514 template │ │ │ │ │ +515 ArrayListIterator ArrayList::begin() │ │ │ │ │ +516 { │ │ │ │ │ +517 return ArrayListIterator(*this, start_); │ │ │ │ │ +518 } │ │ │ │ │ +519 │ │ │ │ │ +520 template │ │ │ │ │ +521 ConstArrayListIterator ArrayList::begin() const │ │ │ │ │ +522 { │ │ │ │ │ +523 return ConstArrayListIterator(*this, start_); │ │ │ │ │ +524 } │ │ │ │ │ +525 │ │ │ │ │ +526 template │ │ │ │ │ +527 ArrayListIterator ArrayList::end() │ │ │ │ │ +528 { │ │ │ │ │ +529 return ArrayListIterator(*this, start_+size_); │ │ │ │ │ +530 } │ │ │ │ │ +531 │ │ │ │ │ +532 template │ │ │ │ │ +533 ConstArrayListIterator ArrayList::end() const │ │ │ │ │ +534 { │ │ │ │ │ +535 return ConstArrayListIterator(*this, start_+size_); │ │ │ │ │ +536 } │ │ │ │ │ +537 │ │ │ │ │ +538 template │ │ │ │ │ +539 void ArrayList::purge() │ │ │ │ │ +540 { │ │ │ │ │ +541 // Distance to copy to the left. │ │ │ │ │ +542 size_t distance = start_/chunkSize_; │ │ │ │ │ +543 if(distance>0) { │ │ │ │ │ +544 // Number of chunks with entries in it; │ │ │ │ │ +545 size_t chunks = ((start_%chunkSize_ + size_)/chunkSize_ ); │ │ │ │ │ +546 │ │ │ │ │ +547 // Copy chunks to the left. │ │ │ │ │ +548 std::copy(chunks_.begin()+distance, │ │ │ │ │ +549 chunks_.begin()+(distance+chunks), chunks_.begin()); │ │ │ │ │ +550 │ │ │ │ │ +551 // Calculate new parameters │ │ │ │ │ +552 start_ = start_ % chunkSize_; │ │ │ │ │ +553 //capacity += distance * chunkSize_; │ │ │ │ │ +554 } │ │ │ │ │ +555 } │ │ │ │ │ +556 │ │ │ │ │ +557 template │ │ │ │ │ +558 void ArrayListIterator::advance(difference_type i) │ │ │ │ │ +559 { │ │ │ │ │ +560 position_+=i; │ │ │ │ │ +561 } │ │ │ │ │ +562 │ │ │ │ │ +563 template │ │ │ │ │ +564 void ConstArrayListIterator::advance(difference_type i) │ │ │ │ │ +565 { │ │ │ │ │ +566 position_+=i; │ │ │ │ │ +567 } │ │ │ │ │ +568 │ │ │ │ │ +569 │ │ │ │ │ +570 template │ │ │ │ │ +571 bool ArrayListIterator::equals(const │ │ │ │ │ +ArrayListIterator& other) const │ │ │ │ │ +572 { │ │ │ │ │ +573 // Makes only sense if we reference a common list │ │ │ │ │ +574 assert(list_==(other.list_)); │ │ │ │ │ +575 return position_==other.position_ ; │ │ │ │ │ +576 } │ │ │ │ │ +577 │ │ │ │ │ +578 │ │ │ │ │ +579 template │ │ │ │ │ +580 bool ArrayListIterator::equals(const │ │ │ │ │ +ConstArrayListIterator& other) const │ │ │ │ │ 581 { │ │ │ │ │ -582 return this->begin()[i]; │ │ │ │ │ -583 } │ │ │ │ │ -584 │ │ │ │ │ -588 template, int> = 0> │ │ │ │ │ -590 constexpr decltype(auto) operator[](std::size_t i) noexcept │ │ │ │ │ -591 { │ │ │ │ │ -592 return this->begin()[i]; │ │ │ │ │ -593 } │ │ │ │ │ -594 │ │ │ │ │ -605 template().size())>> │ │ │ │ │ -607 auto size() const noexcept │ │ │ │ │ -608 { │ │ │ │ │ -609 return rawRange_.size(); │ │ │ │ │ -610 } │ │ │ │ │ -611 │ │ │ │ │ -615 constexpr bool empty() const noexcept │ │ │ │ │ +582 // Makes only sense if we reference a common list │ │ │ │ │ +583 assert(list_==(other.list_)); │ │ │ │ │ +584 return position_==other.position_ ; │ │ │ │ │ +585 } │ │ │ │ │ +586 │ │ │ │ │ +587 │ │ │ │ │ +588 template │ │ │ │ │ +589 bool ConstArrayListIterator::equals(const │ │ │ │ │ +ConstArrayListIterator& other) const │ │ │ │ │ +590 { │ │ │ │ │ +591 // Makes only sense if we reference a common list │ │ │ │ │ +592 assert(list_==(other.list_)); │ │ │ │ │ +593 return position_==other.position_ ; │ │ │ │ │ +594 } │ │ │ │ │ +595 │ │ │ │ │ +596 template │ │ │ │ │ +597 void ArrayListIterator::increment() │ │ │ │ │ +598 { │ │ │ │ │ +599 ++position_; │ │ │ │ │ +600 } │ │ │ │ │ +601 │ │ │ │ │ +602 template │ │ │ │ │ +603 void ConstArrayListIterator::increment() │ │ │ │ │ +604 { │ │ │ │ │ +605 ++position_; │ │ │ │ │ +606 } │ │ │ │ │ +607 │ │ │ │ │ +608 template │ │ │ │ │ +609 void ArrayListIterator::decrement() │ │ │ │ │ +610 { │ │ │ │ │ +611 --position_; │ │ │ │ │ +612 } │ │ │ │ │ +613 │ │ │ │ │ +614 template │ │ │ │ │ +615 void ConstArrayListIterator::decrement() │ │ │ │ │ 616 { │ │ │ │ │ -617 return rawRange_.begin() == rawRange_.end(); │ │ │ │ │ +617 --position_; │ │ │ │ │ 618 } │ │ │ │ │ 619 │ │ │ │ │ -623 const RawRange& rawRange() const noexcept │ │ │ │ │ -624 { │ │ │ │ │ -625 return rawRange_; │ │ │ │ │ -626 } │ │ │ │ │ -627 │ │ │ │ │ -631 RawRange& rawRange() noexcept │ │ │ │ │ -632 { │ │ │ │ │ -633 return rawRange_; │ │ │ │ │ -634 } │ │ │ │ │ -635 │ │ │ │ │ -636 private: │ │ │ │ │ -637 R rawRange_; │ │ │ │ │ -638 F f_; │ │ │ │ │ -639 }; │ │ │ │ │ -640 │ │ │ │ │ -669 template │ │ │ │ │ -670 auto transformedRangeView(R&& range, F&& f) │ │ │ │ │ -671 { │ │ │ │ │ -672 return TransformedRangeView, ValueTransformationTag> │ │ │ │ │ -(std::forward(range), std::forward(f)); │ │ │ │ │ -673 } │ │ │ │ │ -674 │ │ │ │ │ -702 template │ │ │ │ │ -703 auto iteratorTransformedRangeView(R&& range, F&& f) │ │ │ │ │ -704 { │ │ │ │ │ -705 return TransformedRangeView, IteratorTransformationTag> │ │ │ │ │ -(std::forward(range), std::forward(f)); │ │ │ │ │ -706 } │ │ │ │ │ -707 │ │ │ │ │ -708 │ │ │ │ │ -721 template │ │ │ │ │ -722 auto sparseRange(Range&& range) { │ │ │ │ │ -723 return Dune::iteratorTransformedRangeView(std::forward(range), [] │ │ │ │ │ -(auto&& it) { │ │ │ │ │ -724 return std::tuple(*it, it.index()); │ │ │ │ │ -725 }); │ │ │ │ │ -726 } │ │ │ │ │ -727 │ │ │ │ │ -732} │ │ │ │ │ -733 │ │ │ │ │ -734#endif // DUNE_COMMON_RANGE_UTILITIES_HH │ │ │ │ │ +620 template │ │ │ │ │ +621 typename ArrayListIterator::reference ArrayListIterator:: │ │ │ │ │ +elementAt(size_type i) const │ │ │ │ │ +622 { │ │ │ │ │ +623 return list_->elementAt(i+position_); │ │ │ │ │ +624 } │ │ │ │ │ +625 │ │ │ │ │ +626 template │ │ │ │ │ +627 typename ConstArrayListIterator::reference │ │ │ │ │ +ConstArrayListIterator::elementAt(size_type i) const │ │ │ │ │ +628 { │ │ │ │ │ +629 return list_->elementAt(i+position_); │ │ │ │ │ +630 } │ │ │ │ │ +631 │ │ │ │ │ +632 template │ │ │ │ │ +633 typename ArrayListIterator::reference ArrayListIterator:: │ │ │ │ │ +dereference() const │ │ │ │ │ +634 { │ │ │ │ │ +635 return list_->elementAt(position_); │ │ │ │ │ +636 } │ │ │ │ │ +637 │ │ │ │ │ +638 template │ │ │ │ │ +639 typename ConstArrayListIterator::reference │ │ │ │ │ +ConstArrayListIterator::dereference() const │ │ │ │ │ +640 { │ │ │ │ │ +641 return list_->elementAt(position_); │ │ │ │ │ +642 } │ │ │ │ │ +643 │ │ │ │ │ +644 template │ │ │ │ │ +645 typename ArrayListIterator::difference_type │ │ │ │ │ +ArrayListIterator::distanceTo(const ArrayListIterator& other) │ │ │ │ │ +const │ │ │ │ │ +646 { │ │ │ │ │ +647 // Makes only sense if we reference a common list │ │ │ │ │ +648 assert(list_==(other.list_)); │ │ │ │ │ +649 return other.position_ - position_; │ │ │ │ │ +650 } │ │ │ │ │ +651 │ │ │ │ │ +652 template │ │ │ │ │ +653 typename ConstArrayListIterator::difference_type │ │ │ │ │ +ConstArrayListIterator::distanceTo(const ConstArrayListIterator& │ │ │ │ │ +other) const │ │ │ │ │ +654 { │ │ │ │ │ +655 // Makes only sense if we reference a common list │ │ │ │ │ +656 assert(list_==(other.list_)); │ │ │ │ │ +657 return other.position_ - position_; │ │ │ │ │ +658 } │ │ │ │ │ +659 │ │ │ │ │ +660 template │ │ │ │ │ +661 void ArrayListIterator::eraseToHere() │ │ │ │ │ +662 { │ │ │ │ │ +663 list_->size_ -= ++position_ - list_->start_; │ │ │ │ │ +664 // chunk number of the new position. │ │ │ │ │ +665 size_t posChunkStart = position_ / chunkSize_; │ │ │ │ │ +666 // number of chunks to deallocate │ │ │ │ │ +667 size_t chunks = (position_ - list_->start_ + list_->start_ % chunkSize_) │ │ │ │ │ +668 / chunkSize_; │ │ │ │ │ +669 list_->start_ = position_; │ │ │ │ │ +670 │ │ │ │ │ +671 // Deallocate memory not needed any more. │ │ │ │ │ +672 for(size_t chunk=0; chunkchunks_[posChunkStart].reset(); │ │ │ │ │ +675 } │ │ │ │ │ +676 │ │ │ │ │ +677 // Capacity stays the same as the chunks before us │ │ │ │ │ +678 // are still there. They null pointers. │ │ │ │ │ +679 assert(list_->start_+list_->size_<=list_->capacity_); │ │ │ │ │ +680 } │ │ │ │ │ +681 │ │ │ │ │ +682 template │ │ │ │ │ +683 ArrayListIterator::ArrayListIterator(ArrayList& arrayList, │ │ │ │ │ +size_type position) │ │ │ │ │ +684 : position_(position), list_(&arrayList) │ │ │ │ │ +685 {} │ │ │ │ │ +686 │ │ │ │ │ +687 │ │ │ │ │ +688 template │ │ │ │ │ +689 ConstArrayListIterator::ConstArrayListIterator(const │ │ │ │ │ +ArrayList& arrayList, │ │ │ │ │ +690 size_type position) │ │ │ │ │ +691 : position_(position), list_(&arrayList) │ │ │ │ │ +692 {} │ │ │ │ │ +693 │ │ │ │ │ +694 template │ │ │ │ │ +695 ConstArrayListIterator::ConstArrayListIterator(const │ │ │ │ │ +ArrayListIterator& other) │ │ │ │ │ +696 : position_(other.position_), list_(other.list_) │ │ │ │ │ +697 {} │ │ │ │ │ +698 │ │ │ │ │ +699 │ │ │ │ │ +701} │ │ │ │ │ +702#endif │ │ │ │ │ iteratorfacades.hh │ │ │ │ │ This file implements iterator facade classes for writing stl conformant │ │ │ │ │ iterators. │ │ │ │ │ -typetraits.hh │ │ │ │ │ -Traits for type conversions and type information. │ │ │ │ │ -Dune::iteratorTransformedRangeView │ │ │ │ │ -auto iteratorTransformedRangeView(R &&range, F &&f) │ │ │ │ │ -Create a TransformedRangeView using an iterator transformation. │ │ │ │ │ -Definition rangeutilities.hh:703 │ │ │ │ │ -Dune::transformedRangeView │ │ │ │ │ -auto transformedRangeView(R &&range, F &&f) │ │ │ │ │ -Create a TransformedRangeView. │ │ │ │ │ -Definition rangeutilities.hh:670 │ │ │ │ │ -Dune::sparseRange │ │ │ │ │ -auto sparseRange(Range &&range) │ │ │ │ │ -Allow structured-binding for-loops for sparse iterators. │ │ │ │ │ -Definition rangeutilities.hh:722 │ │ │ │ │ -Dune::range │ │ │ │ │ -static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from │ │ │ │ │ ->, std::integral_constant< T, to >) noexcept │ │ │ │ │ -Definition rangeutilities.hh:312 │ │ │ │ │ -Dune::AutonomousValue │ │ │ │ │ -typename AutonomousValueType< T >::type AutonomousValue │ │ │ │ │ -Type free of internal references that T can be converted to. │ │ │ │ │ -Definition typetraits.hh:588 │ │ │ │ │ -Dune::operator* │ │ │ │ │ -bigunsignedint< k > operator*(const bigunsignedint< k > &x, std::uintmax_t y) │ │ │ │ │ -Definition bigunsignedint.hh:549 │ │ │ │ │ -Dune::operator- │ │ │ │ │ -bigunsignedint< k > operator-(const bigunsignedint< k > &x, std::uintmax_t y) │ │ │ │ │ -Definition bigunsignedint.hh:542 │ │ │ │ │ -Dune::operator+ │ │ │ │ │ -bigunsignedint< k > operator+(const bigunsignedint< k > &x, std::uintmax_t y) │ │ │ │ │ -Definition bigunsignedint.hh:535 │ │ │ │ │ -Dune::operator< │ │ │ │ │ -EnableIfInterOperable< T1, T2, bool >::type operator<(const │ │ │ │ │ -RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const │ │ │ │ │ -RandomAccessIteratorFacade< T2, V2, R2, D > &rhs) │ │ │ │ │ -Comparison operator. │ │ │ │ │ -Definition iteratorfacades.hh:638 │ │ │ │ │ -Dune::operator> │ │ │ │ │ -EnableIfInterOperable< T1, T2, bool >::type operator>(const │ │ │ │ │ -RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const │ │ │ │ │ -RandomAccessIteratorFacade< T2, V2, R2, D > &rhs) │ │ │ │ │ -Comparison operator. │ │ │ │ │ -Definition iteratorfacades.hh:684 │ │ │ │ │ -Dune::operator<= │ │ │ │ │ -EnableIfInterOperable< T1, T2, bool >::type operator<=(const │ │ │ │ │ -RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const │ │ │ │ │ -RandomAccessIteratorFacade< T2, V2, R2, D > &rhs) │ │ │ │ │ -Comparison operator. │ │ │ │ │ -Definition iteratorfacades.hh:661 │ │ │ │ │ -Dune::operator== │ │ │ │ │ -EnableIfInterOperable< T1, T2, bool >::type operator==(const │ │ │ │ │ -ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, │ │ │ │ │ -V2, R2, D > &rhs) │ │ │ │ │ -Checks for equality. │ │ │ │ │ -Definition iteratorfacades.hh:238 │ │ │ │ │ -Dune::operator>= │ │ │ │ │ -EnableIfInterOperable< T1, T2, bool >::type operator>=(const │ │ │ │ │ -RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const │ │ │ │ │ -RandomAccessIteratorFacade< T2, V2, R2, D > &rhs) │ │ │ │ │ -Comparison operator. │ │ │ │ │ -Definition iteratorfacades.hh:706 │ │ │ │ │ -Dune::operator!= │ │ │ │ │ -EnableIfInterOperable< T1, T2, bool >::type operator!=(const │ │ │ │ │ -ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, │ │ │ │ │ -V2, R2, D > &rhs) │ │ │ │ │ -Checks for inequality. │ │ │ │ │ -Definition iteratorfacades.hh:260 │ │ │ │ │ +Dune::ArrayList::operator[] │ │ │ │ │ +reference operator[](size_type i) │ │ │ │ │ +Get the element at specific position. │ │ │ │ │ +Definition arraylist.hh:489 │ │ │ │ │ +Dune::ArrayList::begin │ │ │ │ │ +iterator begin() │ │ │ │ │ +Get an iterator that is positioned at the first element. │ │ │ │ │ +Definition arraylist.hh:515 │ │ │ │ │ +Dune::ArrayListIterator::equals │ │ │ │ │ +bool equals(const ArrayListIterator< MemberType, N, A > &other) const │ │ │ │ │ +Compares two iterators. │ │ │ │ │ +Definition arraylist.hh:571 │ │ │ │ │ +Dune::ArrayListIterator::increment │ │ │ │ │ +void increment() │ │ │ │ │ +Increment the iterator. │ │ │ │ │ +Definition arraylist.hh:597 │ │ │ │ │ +Dune::ArrayList::size │ │ │ │ │ +size_type size() const │ │ │ │ │ +Get the number of elements in the list. │ │ │ │ │ +Definition arraylist.hh:470 │ │ │ │ │ +Dune::ConstArrayListIterator::ConstArrayListIterator │ │ │ │ │ +ConstArrayListIterator(const ArrayListIterator< T, N, A > &other) │ │ │ │ │ +Definition arraylist.hh:695 │ │ │ │ │ +Dune::ArrayList::purge │ │ │ │ │ +void purge() │ │ │ │ │ +Purge the list. │ │ │ │ │ +Definition arraylist.hh:539 │ │ │ │ │ +Dune::ArrayListIterator::decrement │ │ │ │ │ +void decrement() │ │ │ │ │ +decrement the iterator. │ │ │ │ │ +Definition arraylist.hh:609 │ │ │ │ │ +Dune::ArrayListIterator::eraseToHere │ │ │ │ │ +void eraseToHere() │ │ │ │ │ +Erase all entries before the current position and the one at the current │ │ │ │ │ +position. │ │ │ │ │ +Definition arraylist.hh:661 │ │ │ │ │ +Dune::ArrayList::ArrayList │ │ │ │ │ +ArrayList() │ │ │ │ │ +Constructs an Array list with one chunk. │ │ │ │ │ +Definition arraylist.hh:455 │ │ │ │ │ +Dune::ArrayList::begin │ │ │ │ │ +const_iterator begin() const │ │ │ │ │ +Get a random access iterator that is positioned at the first element. │ │ │ │ │ +Definition arraylist.hh:521 │ │ │ │ │ +Dune::ConstArrayListIterator::increment │ │ │ │ │ +void increment() │ │ │ │ │ +Increment the iterator. │ │ │ │ │ +Definition arraylist.hh:603 │ │ │ │ │ +Dune::ConstArrayListIterator::elementAt │ │ │ │ │ +reference elementAt(size_type i) const │ │ │ │ │ +Get the value of the list at an arbitrary position. │ │ │ │ │ +Definition arraylist.hh:627 │ │ │ │ │ +Dune::ArrayList::end │ │ │ │ │ +iterator end() │ │ │ │ │ +Get a random access iterator positioned after the last element. │ │ │ │ │ +Definition arraylist.hh:527 │ │ │ │ │ +Dune::ConstArrayListIterator::dereference │ │ │ │ │ +reference dereference() const │ │ │ │ │ +Access the element at the current position. │ │ │ │ │ +Definition arraylist.hh:639 │ │ │ │ │ +Dune::ArrayList::operator[] │ │ │ │ │ +const_reference operator[](size_type i) const │ │ │ │ │ +Get the element at specific position. │ │ │ │ │ +Definition arraylist.hh:496 │ │ │ │ │ +Dune::ConstArrayListIterator::decrement │ │ │ │ │ +void decrement() │ │ │ │ │ +decrement the iterator. │ │ │ │ │ +Definition arraylist.hh:615 │ │ │ │ │ +Dune::ConstArrayListIterator::advance │ │ │ │ │ +void advance(difference_type n) │ │ │ │ │ +Definition arraylist.hh:564 │ │ │ │ │ +Dune::ArrayList::end │ │ │ │ │ +const_iterator end() const │ │ │ │ │ +Get a random access iterator positioned after the last element. │ │ │ │ │ +Definition arraylist.hh:533 │ │ │ │ │ +Dune::ArrayList::clear │ │ │ │ │ +void clear() │ │ │ │ │ +Delete all entries from the list. │ │ │ │ │ +Definition arraylist.hh:462 │ │ │ │ │ +Dune::ArrayListIterator::elementAt │ │ │ │ │ +reference elementAt(size_type i) const │ │ │ │ │ +Get the value of the list at an arbitrary position. │ │ │ │ │ +Definition arraylist.hh:621 │ │ │ │ │ +Dune::ConstArrayListIterator::equals │ │ │ │ │ +bool equals(const ConstArrayListIterator< MemberType, N, A > &other) const │ │ │ │ │ +Compares to iterators. │ │ │ │ │ +Definition arraylist.hh:589 │ │ │ │ │ +Dune::ArrayListIterator::advance │ │ │ │ │ +void advance(difference_type n) │ │ │ │ │ +Definition arraylist.hh:558 │ │ │ │ │ +Dune::ConstArrayListIterator::distanceTo │ │ │ │ │ +difference_type distanceTo(const ConstArrayListIterator< T, N, A > &other) │ │ │ │ │ +const │ │ │ │ │ +Definition arraylist.hh:653 │ │ │ │ │ +Dune::ArrayListIterator::dereference │ │ │ │ │ +reference dereference() const │ │ │ │ │ +Access the element at the current position. │ │ │ │ │ +Definition arraylist.hh:633 │ │ │ │ │ +Dune::ArrayList::push_back │ │ │ │ │ +void push_back(const_reference entry) │ │ │ │ │ +Append an entry to the list. │ │ │ │ │ +Definition arraylist.hh:476 │ │ │ │ │ +Dune::ArrayListIterator::distanceTo │ │ │ │ │ +difference_type distanceTo(const ArrayListIterator< T, N, A > &other) const │ │ │ │ │ +Definition arraylist.hh:645 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::any_true │ │ │ │ │ -bool any_true(const AlignedNumber< bool, align > &val) │ │ │ │ │ -Definition debugalign.hh:506 │ │ │ │ │ -Dune::all_true │ │ │ │ │ -bool all_true(const AlignedNumber< bool, align > &val) │ │ │ │ │ -Definition debugalign.hh:512 │ │ │ │ │ -Dune::max_value │ │ │ │ │ -T max_value(const AlignedNumber< T, align > &val) │ │ │ │ │ -Definition debugalign.hh:494 │ │ │ │ │ -Dune::min_value │ │ │ │ │ -T min_value(const AlignedNumber< T, align > &val) │ │ │ │ │ -Definition debugalign.hh:500 │ │ │ │ │ -Dune::IteratorFacadeAccess │ │ │ │ │ -This class encapsulates access of IteratorFacade. │ │ │ │ │ -Definition iteratorfacades.hh:786 │ │ │ │ │ -Dune::IteratorFacade │ │ │ │ │ -CRTP-Mixing class for stl conformant iterators of given iterator category. │ │ │ │ │ -Definition iteratorfacades.hh:1053 │ │ │ │ │ -Dune::IteratorFacade::operator* │ │ │ │ │ -constexpr decltype(auto) operator*() const │ │ │ │ │ -Dereferencing operator. │ │ │ │ │ -Definition iteratorfacades.hh:1119 │ │ │ │ │ -Dune::IntegralRange │ │ │ │ │ -dynamic integer range for use in range-based for loops │ │ │ │ │ -Definition rangeutilities.hh:177 │ │ │ │ │ -Dune::IntegralRange::begin │ │ │ │ │ -constexpr iterator begin() const noexcept │ │ │ │ │ -obtain a random-access iterator to the first element │ │ │ │ │ -Definition rangeutilities.hh:194 │ │ │ │ │ -Dune::IntegralRange::end │ │ │ │ │ -constexpr iterator end() const noexcept │ │ │ │ │ -obtain a random-access iterator past the last element │ │ │ │ │ -Definition rangeutilities.hh:196 │ │ │ │ │ -Dune::IntegralRange::size_type │ │ │ │ │ -std::make_unsigned_t< T > size_type │ │ │ │ │ -unsigned integer type corresponding to value_type │ │ │ │ │ -Definition rangeutilities.hh:184 │ │ │ │ │ -Dune::IntegralRange::iterator │ │ │ │ │ -Impl::IntegralRangeIterator< T > iterator │ │ │ │ │ -type of iterator │ │ │ │ │ -Definition rangeutilities.hh:182 │ │ │ │ │ -Dune::IntegralRange::operator[] │ │ │ │ │ -constexpr value_type operator[](const value_type &i) const noexcept │ │ │ │ │ -access specified element │ │ │ │ │ -Definition rangeutilities.hh:199 │ │ │ │ │ -Dune::IntegralRange::contains │ │ │ │ │ -constexpr bool contains(value_type index) const noexcept │ │ │ │ │ -check whether given index is within range [from, to) │ │ │ │ │ -Definition rangeutilities.hh:207 │ │ │ │ │ -Dune::IntegralRange::empty │ │ │ │ │ -constexpr bool empty() const noexcept │ │ │ │ │ -check whether the range is empty │ │ │ │ │ -Definition rangeutilities.hh:202 │ │ │ │ │ -Dune::IntegralRange::IntegralRange │ │ │ │ │ -constexpr IntegralRange(std::pair< value_type, value_type > range) noexcept │ │ │ │ │ -construct integer range std::pair │ │ │ │ │ -Definition rangeutilities.hh:191 │ │ │ │ │ -Dune::IntegralRange::IntegralRange │ │ │ │ │ -constexpr IntegralRange(value_type from, value_type to) noexcept │ │ │ │ │ -construct integer range [from, to) │ │ │ │ │ -Definition rangeutilities.hh:187 │ │ │ │ │ -Dune::IntegralRange::size │ │ │ │ │ -constexpr size_type size() const noexcept │ │ │ │ │ -obtain number of elements in the range │ │ │ │ │ -Definition rangeutilities.hh:204 │ │ │ │ │ -Dune::IntegralRange::IntegralRange │ │ │ │ │ -constexpr IntegralRange(value_type to) noexcept │ │ │ │ │ -construct integer range [0, to) │ │ │ │ │ -Definition rangeutilities.hh:189 │ │ │ │ │ -Dune::IntegralRange::value_type │ │ │ │ │ +Dune::ArrayListIterator │ │ │ │ │ +A random access iterator for the Dune::ArrayList class. │ │ │ │ │ +Definition arraylist.hh:255 │ │ │ │ │ +Dune::ArrayListIterator::position │ │ │ │ │ +size_type position() │ │ │ │ │ +Definition arraylist.hh:329 │ │ │ │ │ +Dune::ArrayListIterator::MemberType │ │ │ │ │ +A::value_type MemberType │ │ │ │ │ +The member type. │ │ │ │ │ +Definition arraylist.hh:263 │ │ │ │ │ +Dune::ArrayListIterator::ArrayListIterator │ │ │ │ │ +ArrayListIterator() │ │ │ │ │ +Standard constructor. │ │ │ │ │ +Definition arraylist.hh:338 │ │ │ │ │ +Dune::ArrayListIterator::difference_type │ │ │ │ │ +A::difference_type difference_type │ │ │ │ │ +Definition arraylist.hh:265 │ │ │ │ │ +Dune::ArrayListIterator::chunkSize_ │ │ │ │ │ +static constexpr int chunkSize_ │ │ │ │ │ +The number of elements in one chunk of the list. │ │ │ │ │ +Definition arraylist.hh:278 │ │ │ │ │ +Dune::ArrayListIterator::size_type │ │ │ │ │ +A::size_type size_type │ │ │ │ │ +Definition arraylist.hh:267 │ │ │ │ │ +Dune::ArrayListIterator::const_reference │ │ │ │ │ +typename A::value_type const & const_reference │ │ │ │ │ +Definition arraylist.hh:271 │ │ │ │ │ +Dune::ArrayListIterator::reference │ │ │ │ │ +typename A::value_type & reference │ │ │ │ │ +Definition arraylist.hh:269 │ │ │ │ │ +Dune::ConstArrayListIterator │ │ │ │ │ +A constant random access iterator for the Dune::ArrayList class. │ │ │ │ │ +Definition arraylist.hh:368 │ │ │ │ │ +Dune::ConstArrayListIterator::chunkSize_ │ │ │ │ │ +static constexpr int chunkSize_ │ │ │ │ │ +The number of elements in one chunk of the list. │ │ │ │ │ +Definition arraylist.hh:392 │ │ │ │ │ +Dune::ConstArrayListIterator::ConstArrayListIterator │ │ │ │ │ +ConstArrayListIterator() │ │ │ │ │ +Definition arraylist.hh:429 │ │ │ │ │ +Dune::ConstArrayListIterator::reference │ │ │ │ │ +typename A::value_type const & reference │ │ │ │ │ +Definition arraylist.hh:383 │ │ │ │ │ +Dune::ConstArrayListIterator::MemberType │ │ │ │ │ +A::value_type MemberType │ │ │ │ │ +The member type. │ │ │ │ │ +Definition arraylist.hh:377 │ │ │ │ │ +Dune::ConstArrayListIterator::difference_type │ │ │ │ │ +A::difference_type difference_type │ │ │ │ │ +Definition arraylist.hh:379 │ │ │ │ │ +Dune::ConstArrayListIterator::const_reference │ │ │ │ │ +typename A::value_type const & const_reference │ │ │ │ │ +Definition arraylist.hh:385 │ │ │ │ │ +Dune::ConstArrayListIterator::size_type │ │ │ │ │ +A::size_type size_type │ │ │ │ │ +Definition arraylist.hh:381 │ │ │ │ │ +Dune::ArrayList │ │ │ │ │ +A dynamically growing random access list. │ │ │ │ │ +Definition arraylist.hh:62 │ │ │ │ │ +Dune::ArrayList::value_type │ │ │ │ │ T value_type │ │ │ │ │ -type of integers contained in the range │ │ │ │ │ -Definition rangeutilities.hh:180 │ │ │ │ │ -Dune::StaticIntegralRange │ │ │ │ │ -static integer range for use in range-based for loops │ │ │ │ │ -Definition rangeutilities.hh:230 │ │ │ │ │ -Dune::StaticIntegralRange::end │ │ │ │ │ -static constexpr iterator end() noexcept │ │ │ │ │ -obtain a random-access iterator past the last element │ │ │ │ │ -Definition rangeutilities.hh:259 │ │ │ │ │ -Dune::StaticIntegralRange::integer_sequence │ │ │ │ │ -decltype(shift_integer_sequence< from >(std::make_integer_sequence< T, to-from │ │ │ │ │ ->())) integer_sequence │ │ │ │ │ -type of corresponding std::integer_sequence │ │ │ │ │ -Definition rangeutilities.hh:243 │ │ │ │ │ -Dune::StaticIntegralRange::contains │ │ │ │ │ -static constexpr bool contains(value_type index) noexcept │ │ │ │ │ -check whether given index is within range [from, to) │ │ │ │ │ -Definition rangeutilities.hh:278 │ │ │ │ │ -Dune::StaticIntegralRange::StaticIntegralRange │ │ │ │ │ -constexpr StaticIntegralRange() noexcept=default │ │ │ │ │ -default constructor │ │ │ │ │ -Dune::StaticIntegralRange::size_type │ │ │ │ │ -std::make_unsigned_t< T > size_type │ │ │ │ │ -unsigned integer type corresponding to value_type │ │ │ │ │ -Definition rangeutilities.hh:240 │ │ │ │ │ -Dune::StaticIntegralRange::value_type │ │ │ │ │ -T value_type │ │ │ │ │ -type of integers contained in the range │ │ │ │ │ -Definition rangeutilities.hh:236 │ │ │ │ │ -Dune::StaticIntegralRange::operator[] │ │ │ │ │ -constexpr auto operator[](const std::integral_constant< U, i > &) const │ │ │ │ │ -noexcept -> std::integral_constant< value_type, from+static_cast< value_type > │ │ │ │ │ -(i)> │ │ │ │ │ -access specified element (static version) │ │ │ │ │ -Definition rangeutilities.hh:263 │ │ │ │ │ -Dune::StaticIntegralRange::empty │ │ │ │ │ -static constexpr std::integral_constant< bool, from==to > empty() noexcept │ │ │ │ │ -check whether the range is empty │ │ │ │ │ -Definition rangeutilities.hh:273 │ │ │ │ │ -Dune::StaticIntegralRange::begin │ │ │ │ │ -static constexpr iterator begin() noexcept │ │ │ │ │ -obtain a random-access iterator to the first element │ │ │ │ │ -Definition rangeutilities.hh:257 │ │ │ │ │ -Dune::StaticIntegralRange::to_integer_sequence │ │ │ │ │ -static constexpr integer_sequence to_integer_sequence() noexcept │ │ │ │ │ -return corresponding std::integer_sequence │ │ │ │ │ -Definition rangeutilities.hh:254 │ │ │ │ │ -Dune::StaticIntegralRange::operator[] │ │ │ │ │ -constexpr value_type operator[](const size_type &i) const noexcept │ │ │ │ │ -access specified element (dynamic version) │ │ │ │ │ -Definition rangeutilities.hh:270 │ │ │ │ │ -Dune::StaticIntegralRange::iterator │ │ │ │ │ -Impl::IntegralRangeIterator< T > iterator │ │ │ │ │ -type of iterator │ │ │ │ │ -Definition rangeutilities.hh:238 │ │ │ │ │ -Dune::StaticIntegralRange::size │ │ │ │ │ -static constexpr std::integral_constant< size_type, static_cast< size_type > │ │ │ │ │ -(to) - static_cast< size_type >(from) > size() noexcept │ │ │ │ │ -obtain number of elements in the range │ │ │ │ │ -Definition rangeutilities.hh:275 │ │ │ │ │ -Dune::ValueTransformationTag │ │ │ │ │ -Tag to enable value based transformations in TransformedRangeView. │ │ │ │ │ -Definition rangeutilities.hh:328 │ │ │ │ │ -Dune::IteratorTransformationTag │ │ │ │ │ -Tag to enable iterator based transformations in TransformedRangeView. │ │ │ │ │ -Definition rangeutilities.hh:333 │ │ │ │ │ -Dune::TransformedRangeView │ │ │ │ │ -A range transforming the values of another range on-the-fly. │ │ │ │ │ -Definition rangeutilities.hh:501 │ │ │ │ │ -Dune::TransformedRangeView::iterator │ │ │ │ │ -Impl::TransformedRangeIterator< RawIterator, F *, T > iterator │ │ │ │ │ -Iterator type. │ │ │ │ │ -Definition rangeutilities.hh:521 │ │ │ │ │ -Dune::TransformedRangeView::TransformedRangeView │ │ │ │ │ -constexpr TransformedRangeView(RR &&rawRange, FF &&f) noexcept │ │ │ │ │ -Construct from range and function. │ │ │ │ │ -Definition rangeutilities.hh:535 │ │ │ │ │ -Dune::TransformedRangeView::end │ │ │ │ │ -constexpr iterator end() noexcept │ │ │ │ │ -Definition rangeutilities.hh:571 │ │ │ │ │ -Dune::TransformedRangeView::const_iterator │ │ │ │ │ -Impl::TransformedRangeIterator< RawConstIterator, const F *, T > const_iterator │ │ │ │ │ -Const iterator type. │ │ │ │ │ -Definition rangeutilities.hh:513 │ │ │ │ │ -Dune::TransformedRangeView::RawRange │ │ │ │ │ -std::remove_reference_t< R > RawRange │ │ │ │ │ -Export type of the wrapped untransformed range. │ │ │ │ │ -Definition rangeutilities.hh:529 │ │ │ │ │ -Dune::TransformedRangeView::begin │ │ │ │ │ -constexpr iterator begin() noexcept │ │ │ │ │ -Definition rangeutilities.hh:555 │ │ │ │ │ -Dune::TransformedRangeView::rawRange │ │ │ │ │ -RawRange & rawRange() noexcept │ │ │ │ │ -Export the wrapped untransformed range. │ │ │ │ │ -Definition rangeutilities.hh:631 │ │ │ │ │ -Dune::TransformedRangeView::rawRange │ │ │ │ │ -const RawRange & rawRange() const noexcept │ │ │ │ │ -Export the wrapped untransformed range. │ │ │ │ │ -Definition rangeutilities.hh:623 │ │ │ │ │ -Dune::TransformedRangeView::begin │ │ │ │ │ -constexpr const_iterator begin() const noexcept │ │ │ │ │ -Obtain a iterator to the first element. │ │ │ │ │ -Definition rangeutilities.hh:551 │ │ │ │ │ -Dune::TransformedRangeView::size │ │ │ │ │ -auto size() const noexcept │ │ │ │ │ -Obtain the size of the range. │ │ │ │ │ -Definition rangeutilities.hh:607 │ │ │ │ │ -Dune::TransformedRangeView::end │ │ │ │ │ -constexpr const_iterator end() const noexcept │ │ │ │ │ -Obtain a iterator past the last element. │ │ │ │ │ -Definition rangeutilities.hh:567 │ │ │ │ │ -Dune::TransformedRangeView::empty │ │ │ │ │ -constexpr bool empty() const noexcept │ │ │ │ │ -Checks whether the range is empty. │ │ │ │ │ -Definition rangeutilities.hh:615 │ │ │ │ │ -Dune::IsCallable │ │ │ │ │ -Check if a type is callable with ()-operator and given arguments. │ │ │ │ │ -Definition typetraits.hh:162 │ │ │ │ │ +Value type for stl compliance. │ │ │ │ │ +Definition arraylist.hh:74 │ │ │ │ │ +Dune::ArrayList::chunkSize_ │ │ │ │ │ +static constexpr int chunkSize_ │ │ │ │ │ +The number of elements in one chunk of the list. This has to be at least one. │ │ │ │ │ +The default is 100. │ │ │ │ │ +Definition arraylist.hh:100 │ │ │ │ │ +Dune::ArrayList::const_pointer │ │ │ │ │ +const T * const_pointer │ │ │ │ │ +The type of a const pointer to the type we store. │ │ │ │ │ +Definition arraylist.hh:94 │ │ │ │ │ +Dune::ArrayList::iterator │ │ │ │ │ +ArrayListIterator< MemberType, N, A > iterator │ │ │ │ │ +A random access iterator. │ │ │ │ │ +Definition arraylist.hh:105 │ │ │ │ │ +Dune::ArrayList::const_reference │ │ │ │ │ +const T & const_reference │ │ │ │ │ +The type of a const reference to the type we store. │ │ │ │ │ +Definition arraylist.hh:84 │ │ │ │ │ +Dune::ArrayList::reference │ │ │ │ │ +T & reference │ │ │ │ │ +The type of a reference to the type we store. │ │ │ │ │ +Definition arraylist.hh:79 │ │ │ │ │ +Dune::ArrayList::size_type │ │ │ │ │ +std::size_t size_type │ │ │ │ │ +The size type. │ │ │ │ │ +Definition arraylist.hh:115 │ │ │ │ │ +Dune::ArrayList::MemberType │ │ │ │ │ +T MemberType │ │ │ │ │ +The member type that is stored. │ │ │ │ │ +Definition arraylist.hh:69 │ │ │ │ │ +Dune::ArrayList::pointer │ │ │ │ │ +T * pointer │ │ │ │ │ +The type of a pointer to the type we store. │ │ │ │ │ +Definition arraylist.hh:89 │ │ │ │ │ +Dune::ArrayList::const_iterator │ │ │ │ │ +ConstArrayListIterator< MemberType, N, A > const_iterator │ │ │ │ │ +A constant random access iterator. │ │ │ │ │ +Definition arraylist.hh:110 │ │ │ │ │ +Dune::ArrayList::difference_type │ │ │ │ │ +std::ptrdiff_t difference_type │ │ │ │ │ +The difference type. │ │ │ │ │ +Definition arraylist.hh:120 │ │ │ │ │ +Dune::RandomAccessIteratorFacade │ │ │ │ │ +Base class for stl conformant forward iterators. │ │ │ │ │ +Definition iteratorfacades.hh:435 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00083.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: genericiterator.hh File Reference │ │ │ │ +dune-common: fmatrixev.cc File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,60 +70,45 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Classes | │ │ │ │ -Namespaces
│ │ │ │ -
genericiterator.hh File Reference
│ │ │ │ +Macros
│ │ │ │ +
fmatrixev.cc File Reference
│ │ │ │ │ │ │ │
│ │ │ │ - │ │ │ │ -

Implements a generic iterator class for writing stl conformant iterators. │ │ │ │ -More...

│ │ │ │ -
#include <dune/common/iteratorfacades.hh>
│ │ │ │ +
#include <iostream>
│ │ │ │ +#include <cmath>
│ │ │ │ #include <cassert>
│ │ │ │ -
│ │ │ │ -

Go to the source code of this file.

│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Classes

struct  Dune::const_reference< R >
 Get the 'const' version of a reference to a mutable object. More...
 
struct  Dune::const_reference< const R >
 
struct  Dune::const_reference< R & >
 
struct  Dune::const_reference< const R & >
 
struct  Dune::mutable_reference< R >
 get the 'mutable' version of a reference to a const object More...
 
struct  Dune::mutable_reference< const R >
 
struct  Dune::mutable_reference< R & >
 
struct  Dune::mutable_reference< const R & >
 
class  Dune::GenericIterator< C, T, R, D, IteratorFacade >
 Generic class for stl-conforming iterators for container classes with operator[]. More...
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ +#include <dune-common-config.hh>
│ │ │ │ +#include <dune/common/exceptions.hh>
│ │ │ │ +#include <dune/common/fmatrixev.hh>
│ │ │ │ +

│ │ │ │ -Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ +Macros

#define DUNE_FMATRIXEIGENVALUES_CC
 
│ │ │ │ -

Detailed Description

│ │ │ │ -

Implements a generic iterator class for writing stl conformant iterators.

│ │ │ │ -

Using this generic iterator writing iterators for containers that implement operator[] is only a matter of seconds.

│ │ │ │ -
│ │ │ │ +

Macro Definition Documentation

│ │ │ │ + │ │ │ │ +

◆ DUNE_FMATRIXEIGENVALUES_CC

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_FMATRIXEIGENVALUES_CC
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,46 +1,22 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -genericiterator.hh File Reference │ │ │ │ │ -Implements a generic iterator class for writing stl conformant iterators. │ │ │ │ │ -More... │ │ │ │ │ -#include │ │ │ │ │ +Macros │ │ │ │ │ +fmatrixev.cc File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -Go_to_the_source_code_of_this_file. │ │ │ │ │ -Classes │ │ │ │ │ -struct   Dune::const_reference<_R_> │ │ │ │ │ -  Get the 'const' version of a reference to a mutable object. More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::const_reference<_const_R_> │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::const_reference<_R_&_> │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::const_reference<_const_R_&_> │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::mutable_reference<_R_> │ │ │ │ │ -  get the 'mutable' version of a reference to a const object More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::mutable_reference<_const_R_> │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::mutable_reference<_R_&_> │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::mutable_reference<_const_R_&_> │ │ │ │ │ -  │ │ │ │ │ - class   Dune::GenericIterator<_C,_T,_R,_D,_IteratorFacade_> │ │ │ │ │ -  Generic class for stl-conforming iterators for container classes with │ │ │ │ │ - operator[]. More... │ │ │ │ │ -  │ │ │ │ │ -Namespaces │ │ │ │ │ -namespace   Dune │ │ │ │ │ -  Dune namespace. │ │ │ │ │ -  │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -Implements a generic iterator class for writing stl conformant iterators. │ │ │ │ │ -Using this generic iterator writing iterators for containers that implement │ │ │ │ │ -operator[] is only a matter of seconds. │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +Macros │ │ │ │ │ +#define  DUNE_FMATRIXEIGENVALUES_CC │ │ │ │ │ +  │ │ │ │ │ +***** Macro Definition Documentation ***** │ │ │ │ │ +***** ◆ DUNE_FMATRIXEIGENVALUES_CC ***** │ │ │ │ │ +#define DUNE_FMATRIXEIGENVALUES_CC │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00086.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: propertymap.hh File Reference │ │ │ │ +dune-common: exceptions.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -72,77 +72,80 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ Namespaces | │ │ │ │ +Macros | │ │ │ │ Functions
│ │ │ │ -
propertymap.hh File Reference
│ │ │ │ +
exceptions.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ -
#include <cstddef>
│ │ │ │ -#include <iterator>
│ │ │ │ -#include <type_traits>
│ │ │ │ + │ │ │ │ +

A few common exception classes. │ │ │ │ +More...

│ │ │ │ +
#include <exception>
│ │ │ │ +#include <string>
│ │ │ │ +#include <sstream>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

struct  Dune::PropertyMapTraits< PM >
 
struct  Dune::ReadablePropertyMapTag
 Tag for the category of readable property maps. More...
 
struct  Dune::WritablePropertyMapTag
 Tag for the category of writable property maps. More...
class  Dune::Exception
 Base class for Dune-Exceptions. More...
 
struct  Dune::ReadWritePropertyMapTag
 Tag for the category of readable and writable property maps. More...
struct  Dune::ExceptionHook
 Base class to add a hook to the Dune::Exception. More...
 
struct  Dune::LvaluePropertyMapTag
 Tag for the category of lvalue property maps. More...
class  Dune::IOError
 Default exception class for I/O errors. More...
 
struct  Dune::PropertyMapTraits< T * >
class  Dune::MathError
 Default exception class for mathematical errors. More...
 
struct  Dune::PropertyMapTraits< const T * >
class  Dune::RangeError
 Default exception class for range errors. More...
 
struct  Dune::RAPropertyMapHelper< Reference, PropertyMap >
class  Dune::NotImplemented
 Default exception for dummy implementations. More...
 
class  Dune::IteratorPropertyMap< RAI, IM, T, R >
 Adapter to turn a random access iterator into a property map. More...
class  Dune::SystemError
 Default exception class for OS errors. More...
 
class  Dune::AssociativePropertyMap< T >
 An adapter to turn an unique associative container into a property map. More...
class  Dune::OutOfMemoryError
 Default exception if memory allocation fails. More...
 
class  Dune::ConstAssociativePropertyMap< T >
 An adaptor to turn an unique associative container into a property map. More...
class  Dune::InvalidStateException
 Default exception if a function was called while the object is not in a valid state for that function. More...
 
struct  Dune::IdentityMap
 A property map that applies the identity function to integers. More...
 
struct  Dune::PropertyMapTypeSelector< T, C >
 Selector for the property map type. More...
class  Dune::ParallelError
 Default exception if an error in the parallel communication of the program occurred. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Macros

#define DUNE_THROW(E, m)
 
│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Functions

template<class Reference , class PropertyMap , class Key >
Reference Dune::get (const RAPropertyMapHelper< Reference, PropertyMap > &pmap, const Key &key)
 
template<class Reference , class PropertyMap , class Key , class Value >
void Dune::put (const RAPropertyMapHelper< Reference, PropertyMap > &pmap, const Key &key, const Value &value)
 
std::ostream & Dune::operator<< (std::ostream &stream, const Exception &e)
 
│ │ │ │ -
│ │ │ │ +

Detailed Description

│ │ │ │ +

A few common exception classes.

│ │ │ │ +

This file defines a common framework for generating exception subclasses and to throw them in a simple manner

│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,65 +1,63 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Functions │ │ │ │ │ -propertymap.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces | Macros | Functions │ │ │ │ │ +exceptions.hh File Reference │ │ │ │ │ +Common » Exception_handling │ │ │ │ │ +A few common exception classes. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -struct   Dune::PropertyMapTraits<_PM_> │ │ │ │ │ + class   Dune::Exception │ │ │ │ │ +  Base class for Dune-Exceptions. More... │ │ │ │ │   │ │ │ │ │ -struct   Dune::ReadablePropertyMapTag │ │ │ │ │ -  Tag for the category of readable property maps. More... │ │ │ │ │ +struct   Dune::ExceptionHook │ │ │ │ │ +  Base class to add a hook to the Dune::Exception. More... │ │ │ │ │   │ │ │ │ │ -struct   Dune::WritablePropertyMapTag │ │ │ │ │ -  Tag for the category of writable property maps. More... │ │ │ │ │ + class   Dune::IOError │ │ │ │ │ +  Default exception class for I/O errors. More... │ │ │ │ │   │ │ │ │ │ -struct   Dune::ReadWritePropertyMapTag │ │ │ │ │ -  Tag for the category of readable and writable property maps. More... │ │ │ │ │ + class   Dune::MathError │ │ │ │ │ +  Default exception class for mathematical errors. More... │ │ │ │ │   │ │ │ │ │ -struct   Dune::LvaluePropertyMapTag │ │ │ │ │ -  Tag for the category of lvalue property maps. More... │ │ │ │ │ + class   Dune::RangeError │ │ │ │ │ +  Default exception class for range errors. More... │ │ │ │ │   │ │ │ │ │ -struct   Dune::PropertyMapTraits<_T_*_> │ │ │ │ │ + class   Dune::NotImplemented │ │ │ │ │ +  Default exception for dummy implementations. More... │ │ │ │ │   │ │ │ │ │ -struct   Dune::PropertyMapTraits<_const_T_*_> │ │ │ │ │ + class   Dune::SystemError │ │ │ │ │ +  Default exception class for OS errors. More... │ │ │ │ │   │ │ │ │ │ -struct   Dune::RAPropertyMapHelper<_Reference,_PropertyMap_> │ │ │ │ │ + class   Dune::OutOfMemoryError │ │ │ │ │ +  Default exception if memory allocation fails. More... │ │ │ │ │   │ │ │ │ │ - class   Dune::IteratorPropertyMap<_RAI,_IM,_T,_R_> │ │ │ │ │ -  Adapter to turn a random access iterator into a property map. More... │ │ │ │ │ + class   Dune::InvalidStateException │ │ │ │ │ +  Default exception if a function was called while the object is not in │ │ │ │ │ + a valid state for that function. More... │ │ │ │ │   │ │ │ │ │ - class   Dune::AssociativePropertyMap<_T_> │ │ │ │ │ -  An adapter to turn an unique associative container into a property │ │ │ │ │ - map. More... │ │ │ │ │ -  │ │ │ │ │ - class   Dune::ConstAssociativePropertyMap<_T_> │ │ │ │ │ -  An adaptor to turn an unique associative container into a property │ │ │ │ │ - map. More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::IdentityMap │ │ │ │ │ -  A property map that applies the identity function to integers. More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::PropertyMapTypeSelector<_T,_C_> │ │ │ │ │ -  Selector for the property map type. More... │ │ │ │ │ + class   Dune::ParallelError │ │ │ │ │ +  Default exception if an error in the parallel communication of the │ │ │ │ │ + program occurred. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ +Macros │ │ │ │ │ +#define  DUNE_THROW(E, m) │ │ │ │ │ +  │ │ │ │ │ Functions │ │ │ │ │ -template │ │ │ │ │ -Reference  Dune::get (const RAPropertyMapHelper< Reference, PropertyMap > │ │ │ │ │ - &pmap, const Key &key) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - void  Dune::put (const RAPropertyMapHelper< Reference, PropertyMap > │ │ │ │ │ - &pmap, const Key &key, const Value &value) │ │ │ │ │ +std::ostream &  Dune::operator<< (std::ostream &stream, const Exception &e) │ │ │ │ │   │ │ │ │ │ +***** Detailed Description ***** │ │ │ │ │ +A few common exception classes. │ │ │ │ │ +This file defines a common framework for generating exception subclasses and to │ │ │ │ │ +throw them in a simple manner │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00086_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: propertymap.hh Source File │ │ │ │ +dune-common: exceptions.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,307 +74,119 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
propertymap.hh
│ │ │ │ +
exceptions.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_PROPERTYMAP_HH
│ │ │ │ -
6#define DUNE_PROPERTYMAP_HH
│ │ │ │ -
7
│ │ │ │ -
8#include <cstddef>
│ │ │ │ -
9#include <iterator>
│ │ │ │ -
10#include <type_traits>
│ │ │ │ -
11
│ │ │ │ -
12namespace Dune
│ │ │ │ -
13{
│ │ │ │ +
5
│ │ │ │ +
6#ifndef DUNE_EXCEPTIONS_HH
│ │ │ │ +
7#define DUNE_EXCEPTIONS_HH
│ │ │ │ +
8
│ │ │ │ +
9#include <exception>
│ │ │ │ +
10#include <string>
│ │ │ │ +
11#include <sstream>
│ │ │ │ +
12
│ │ │ │ +
13namespace Dune {
│ │ │ │
14
│ │ │ │ -
15 template<class PM>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
17 {
│ │ │ │ -
21 typedef typename PM::KeyType KeyType;
│ │ │ │ -
25 typedef typename PM::ValueType ValueType;
│ │ │ │ -
29 typedef typename PM::Reference Reference;
│ │ │ │ -
33 typedef typename PM::Category Category;
│ │ │ │ -
34 };
│ │ │ │ -
│ │ │ │ -
35
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
38 {};
│ │ │ │ -
│ │ │ │ -
39
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
42 {};
│ │ │ │ -
│ │ │ │ -
43
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ -
50 {};
│ │ │ │ -
│ │ │ │ -
51
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ -
57 {};
│ │ │ │ -
│ │ │ │ -
58
│ │ │ │ -
59 template<class T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
61 {
│ │ │ │ -
62 typedef T ValueType;
│ │ │ │ - │ │ │ │ -
64 typedef std::ptrdiff_t KeyType;
│ │ │ │ - │ │ │ │ -
66 };
│ │ │ │ -
│ │ │ │ -
67
│ │ │ │ -
68
│ │ │ │ -
69 template<class T>
│ │ │ │ -
│ │ │ │ -
70 struct PropertyMapTraits<const T*>
│ │ │ │ -
71 {
│ │ │ │ -
72 typedef T ValueType;
│ │ │ │ -
73 typedef const ValueType& Reference;
│ │ │ │ -
74 typedef std::ptrdiff_t KeyType;
│ │ │ │ - │ │ │ │ -
76 };
│ │ │ │ -
│ │ │ │ -
77
│ │ │ │ -
78 template<class Reference, class PropertyMap>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
80 {};
│ │ │ │ -
│ │ │ │ -
81
│ │ │ │ -
82 template<class Reference, class PropertyMap, class Key>
│ │ │ │ -
83 inline Reference
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
85 const Key& key)
│ │ │ │ -
86 {
│ │ │ │ -
87 return static_cast<const PropertyMap&>(pmap)[key];
│ │ │ │ -
88 }
│ │ │ │ -
│ │ │ │ -
89
│ │ │ │ -
90 template<class Reference, class PropertyMap, class Key, class Value>
│ │ │ │ -
91 inline void
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
93 const Key& key, const Value& value)
│ │ │ │ -
94 {
│ │ │ │ -
95 static_assert(std::is_convertible<typename PropertyMap::Category,WritablePropertyMapTag>::value,
│ │ │ │ -
96 "WritablePropertyMapTag required!");
│ │ │ │ -
97 static_cast<const PropertyMap&>(pmap)[key] = value;
│ │ │ │ -
98 }
│ │ │ │ -
│ │ │ │ -
99
│ │ │ │ -
103 template<class RAI, class IM,
│ │ │ │ -
104 class T = typename std::iterator_traits<RAI>::value_type,
│ │ │ │ -
105 class R = typename std::iterator_traits<RAI>::reference>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
107 : public RAPropertyMapHelper<R,IteratorPropertyMap<RAI,IM,T,R> >
│ │ │ │ -
108 {
│ │ │ │ -
109 public:
│ │ │ │ - │ │ │ │ -
114
│ │ │ │ -
120 typedef IM IndexMap;
│ │ │ │ -
121
│ │ │ │ -
125 typedef typename IndexMap::KeyType KeyType;
│ │ │ │ -
126
│ │ │ │ -
130 typedef T ValueType;
│ │ │ │ -
131
│ │ │ │ -
135 typedef R Reference;
│ │ │ │ -
136
│ │ │ │ - │ │ │ │ -
141
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
150 const IndexMap& im=IndexMap())
│ │ │ │ -
151 : iter_(iter), indexMap_(im)
│ │ │ │ -
152 {}
│ │ │ │ -
│ │ │ │ -
153
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
156 : iter_(), indexMap_()
│ │ │ │ -
157 {}
│ │ │ │ -
│ │ │ │ -
158
│ │ │ │ -
│ │ │ │ -
160 inline Reference operator[](KeyType key) const
│ │ │ │ -
161 {
│ │ │ │ -
162 return *(iter_ + get(indexMap_, key));
│ │ │ │ -
163 }
│ │ │ │ -
│ │ │ │ -
164
│ │ │ │ -
165 private:
│ │ │ │ - │ │ │ │ -
169 IndexMap indexMap_;
│ │ │ │ -
170 };
│ │ │ │ -
│ │ │ │ -
171
│ │ │ │ -
176 template<typename T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
178 : RAPropertyMapHelper<typename T::value_type::second_type&,
│ │ │ │ -
179 AssociativePropertyMap<T> >
│ │ │ │ +
73 /* forward declarations */
│ │ │ │ +
74 class Exception;
│ │ │ │ +
75 struct ExceptionHook;
│ │ │ │ +
76
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
95 : public std::exception
│ │ │ │ +
96 {
│ │ │ │ +
97 public:
│ │ │ │ +
98 Exception ();
│ │ │ │ +
99 void message(const std::string &msg);
│ │ │ │ +
100 const char* what() const noexcept override;
│ │ │ │ +
101 static void registerHook (ExceptionHook * hook);
│ │ │ │ +
102 static void clearHook ();
│ │ │ │ +
103 private:
│ │ │ │ +
104 std::string _message;
│ │ │ │ +
105 static ExceptionHook * _hook;
│ │ │ │ +
106 };
│ │ │ │ +
│ │ │ │ +
107
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
174 {
│ │ │ │ +
175 virtual ~ExceptionHook() {}
│ │ │ │ +
176 virtual void operator () () = 0;
│ │ │ │ +
177 };
│ │ │ │ +
│ │ │ │ +
178
│ │ │ │ +
│ │ │ │ +
179 inline std::ostream& operator<<(std::ostream &stream, const Exception &e)
│ │ │ │
180 {
│ │ │ │ -
184 typedef T UniqueAssociativeContainer;
│ │ │ │ -
185
│ │ │ │ -
189 typedef typename UniqueAssociativeContainer::value_type::first_type
│ │ │ │ -
190 KeyType;
│ │ │ │ -
191
│ │ │ │ -
195 typedef typename UniqueAssociativeContainer::value_type::second_type
│ │ │ │ -
196 ValueType;
│ │ │ │ -
197
│ │ │ │ -
201 typedef ValueType& Reference;
│ │ │ │ -
202
│ │ │ │ - │ │ │ │ -
207
│ │ │ │ - │ │ │ │ -
210 : map_(0)
│ │ │ │ -
211 {}
│ │ │ │ -
212
│ │ │ │ -
214 inline AssociativePropertyMap(UniqueAssociativeContainer& map)
│ │ │ │ -
215 : map_(&map)
│ │ │ │ -
216 {}
│ │ │ │ -
217
│ │ │ │ -
222 inline Reference operator[](KeyType key) const
│ │ │ │ -
223 {
│ │ │ │ -
224 return map_->find(key)->second;
│ │ │ │ -
225 }
│ │ │ │ -
226 private:
│ │ │ │ -
227 UniqueAssociativeContainer* map_;
│ │ │ │ -
228 };
│ │ │ │ -
│ │ │ │ -
229
│ │ │ │ -
234 template<typename T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
236 : RAPropertyMapHelper<const typename T::value_type::second_type&,
│ │ │ │ -
237 ConstAssociativePropertyMap<T> >
│ │ │ │ -
238 {
│ │ │ │ -
242 typedef T UniqueAssociativeContainer;
│ │ │ │ -
243
│ │ │ │ -
247 typedef typename UniqueAssociativeContainer::value_type::first_type
│ │ │ │ -
248 KeyType;
│ │ │ │ -
249
│ │ │ │ -
253 typedef typename UniqueAssociativeContainer::value_type::second_type
│ │ │ │ -
254 ValueType;
│ │ │ │ +
181 return stream << e.what();
│ │ │ │ +
182 }
│ │ │ │ +
│ │ │ │ +
183
│ │ │ │ +
184#ifndef DOXYGEN
│ │ │ │ +
185 // the "format" the exception-type gets printed. __FILE__ and
│ │ │ │ +
186 // __LINE__ are standard C-defines, the GNU cpp-infofile claims that
│ │ │ │ +
187 // C99 defines __func__ as well. __FUNCTION__ is a GNU-extension
│ │ │ │ +
188#define THROWSPEC(E) # E << " [" << __func__ << ":" << __FILE__ << ":" << __LINE__ << "]: "
│ │ │ │ +
189#endif // DOXYGEN
│ │ │ │ +
190
│ │ │ │ +
216 // this is the magic: use the usual do { ... } while (0) trick, create
│ │ │ │ +
217 // the full message via a string stream and throw the created object
│ │ │ │ +
│ │ │ │ +
218#define DUNE_THROW(E, m) do { E th__ex; std::ostringstream th__out; \
│ │ │ │ +
219 th__out << THROWSPEC(E) << m; th__ex.message(th__out.str()); throw th__ex; \
│ │ │ │ +
220} while (0)
│ │ │ │ +
│ │ │ │ +
221
│ │ │ │ +
231 class IOError : public Exception {};
│ │ │ │ +
232
│ │ │ │ +
241 class MathError : public Exception {};
│ │ │ │ +
242
│ │ │ │ +
254 class RangeError : public Exception {};
│ │ │ │
255
│ │ │ │ -
259 typedef const ValueType& Reference;
│ │ │ │ -
260
│ │ │ │ - │ │ │ │ -
265
│ │ │ │ - │ │ │ │ -
268 : map_(0)
│ │ │ │ -
269 {}
│ │ │ │ -
270
│ │ │ │ -
272 inline ConstAssociativePropertyMap(const UniqueAssociativeContainer& map)
│ │ │ │ -
273 : map_(&map)
│ │ │ │ -
274 {}
│ │ │ │ -
275
│ │ │ │ -
280 inline Reference operator[](KeyType key) const
│ │ │ │ -
281 {
│ │ │ │ -
282 return map_->find(key)->second;
│ │ │ │ -
283 }
│ │ │ │ -
284 private:
│ │ │ │ -
285 const UniqueAssociativeContainer* map_;
│ │ │ │ -
286 };
│ │ │ │ -
│ │ │ │ -
287
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
292 : public RAPropertyMapHelper<std::size_t, IdentityMap>
│ │ │ │ -
293 {
│ │ │ │ -
295 typedef std::size_t KeyType;
│ │ │ │ -
296
│ │ │ │ -
298 typedef std::size_t ValueType;
│ │ │ │ -
299
│ │ │ │ -
301 typedef std::size_t Reference;
│ │ │ │ -
302
│ │ │ │ - │ │ │ │ -
305
│ │ │ │ -
│ │ │ │ -
306 inline ValueType operator[](const KeyType& key) const
│ │ │ │ -
307 {
│ │ │ │ -
308 return key;
│ │ │ │ -
309 }
│ │ │ │ -
│ │ │ │ -
310 };
│ │ │ │ -
│ │ │ │ -
311
│ │ │ │ -
312
│ │ │ │ -
318 template<typename T, typename C>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
320 {
│ │ │ │ -
324 typedef T Tag;
│ │ │ │ -
329 typedef C Container;
│ │ │ │ -
330 };
│ │ │ │ -
│ │ │ │ -
331
│ │ │ │ -
332}
│ │ │ │ -
333
│ │ │ │ -
334#endif
│ │ │ │ +
263 class NotImplemented : public Exception {};
│ │ │ │ +
264
│ │ │ │ +
271 class SystemError : public Exception {};
│ │ │ │ +
272
│ │ │ │ +
276 class OutOfMemoryError : public SystemError {};
│ │ │ │ +
277
│ │ │ │ + │ │ │ │ +
282
│ │ │ │ +
287 class ParallelError : public Exception {};
│ │ │ │ +
288
│ │ │ │ +
289} // end namespace
│ │ │ │ +
290
│ │ │ │ +
291#endif
│ │ │ │ +
std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x)
Definition bigunsignedint.hh:278
│ │ │ │ +
Exception()
Definition exceptions.cc:16
│ │ │ │ +
static void registerHook(ExceptionHook *hook)
add a functor which is called before a Dune::Exception is emitted (see Dune::ExceptionHook)
Definition exceptions.cc:22
│ │ │ │ +
static void clearHook()
remove all hooks
Definition exceptions.cc:27
│ │ │ │ +
void message(const std::string &msg)
store string in internal message buffer
Definition exceptions.cc:32
│ │ │ │ +
virtual void operator()()=0
│ │ │ │ +
virtual ~ExceptionHook()
Definition exceptions.hh:175
│ │ │ │ +
const char * what() const noexcept override
output internal message buffer
Definition exceptions.cc:37
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
void put(const RAPropertyMapHelper< Reference, PropertyMap > &pmap, const Key &key, const Value &value)
Definition propertymap.hh:92
│ │ │ │ -
constexpr auto get(std::integer_sequence< T, II... >, std::integral_constant< std::size_t, pos >={})
Return the entry at position pos of the given sequence.
Definition integersequence.hh:22
│ │ │ │ -
Definition propertymap.hh:17
│ │ │ │ -
PM::ValueType ValueType
The type of the values of the property map.
Definition propertymap.hh:25
│ │ │ │ -
PM::Category Category
The category the property map belongs to.
Definition propertymap.hh:33
│ │ │ │ -
PM::Reference Reference
The type of the reference to the values.
Definition propertymap.hh:29
│ │ │ │ -
PM::KeyType KeyType
The type of the key of the property map.
Definition propertymap.hh:21
│ │ │ │ -
Tag for the category of readable property maps.
Definition propertymap.hh:38
│ │ │ │ -
Tag for the category of writable property maps.
Definition propertymap.hh:42
│ │ │ │ -
Tag for the category of readable and writable property maps.
Definition propertymap.hh:50
│ │ │ │ -
Tag for the category of lvalue property maps.
Definition propertymap.hh:57
│ │ │ │ -
ValueType & Reference
Definition propertymap.hh:63
│ │ │ │ -
std::ptrdiff_t KeyType
Definition propertymap.hh:64
│ │ │ │ -
T ValueType
Definition propertymap.hh:62
│ │ │ │ -
LvaluePropertyMapTag Category
Definition propertymap.hh:65
│ │ │ │ -
std::ptrdiff_t KeyType
Definition propertymap.hh:74
│ │ │ │ -
const ValueType & Reference
Definition propertymap.hh:73
│ │ │ │ -
T ValueType
Definition propertymap.hh:72
│ │ │ │ -
LvaluePropertyMapTag Category
Definition propertymap.hh:75
│ │ │ │ -
Definition propertymap.hh:80
│ │ │ │ -
Adapter to turn a random access iterator into a property map.
Definition propertymap.hh:108
│ │ │ │ -
IndexMap::KeyType KeyType
The key type of the property map.
Definition propertymap.hh:125
│ │ │ │ -
R Reference
The reference type of the property map.
Definition propertymap.hh:135
│ │ │ │ -
T ValueType
The value type of the property map.
Definition propertymap.hh:130
│ │ │ │ -
Reference operator[](KeyType key) const
Access the a value by reference.
Definition propertymap.hh:160
│ │ │ │ -
IteratorPropertyMap(RandomAccessIterator iter, const IndexMap &im=IndexMap())
Constructor.
Definition propertymap.hh:149
│ │ │ │ -
IteratorPropertyMap()
Constructor.
Definition propertymap.hh:155
│ │ │ │ -
IM IndexMap
The type of the index map.
Definition propertymap.hh:120
│ │ │ │ -
RAI RandomAccessIterator
The type of the random access iterator.
Definition propertymap.hh:113
│ │ │ │ -
LvaluePropertyMapTag Category
The category of this property map.
Definition propertymap.hh:140
│ │ │ │ -
An adapter to turn an unique associative container into a property map.
Definition propertymap.hh:180
│ │ │ │ -
An adaptor to turn an unique associative container into a property map.
Definition propertymap.hh:238
│ │ │ │ -
A property map that applies the identity function to integers.
Definition propertymap.hh:293
│ │ │ │ -
std::size_t ValueType
The value type of the map.
Definition propertymap.hh:298
│ │ │ │ -
std::size_t KeyType
The key type of the map.
Definition propertymap.hh:295
│ │ │ │ -
ValueType operator[](const KeyType &key) const
Definition propertymap.hh:306
│ │ │ │ -
std::size_t Reference
The reference type of the map.
Definition propertymap.hh:301
│ │ │ │ -
ReadablePropertyMapTag Category
The category of the map.
Definition propertymap.hh:304
│ │ │ │ -
Selector for the property map type.
Definition propertymap.hh:320
│ │ │ │ -
T Tag
the tag identifying the property.
Definition propertymap.hh:324
│ │ │ │ -
C Container
The container type to whose entries the properties are attached.
Definition propertymap.hh:329
│ │ │ │ +
Base class for Dune-Exceptions.
Definition exceptions.hh:96
│ │ │ │ +
Base class to add a hook to the Dune::Exception.
Definition exceptions.hh:174
│ │ │ │ +
Default exception class for I/O errors.
Definition exceptions.hh:231
│ │ │ │ +
Default exception class for mathematical errors.
Definition exceptions.hh:241
│ │ │ │ +
Default exception class for range errors.
Definition exceptions.hh:254
│ │ │ │ +
Default exception for dummy implementations.
Definition exceptions.hh:263
│ │ │ │ +
Default exception class for OS errors.
Definition exceptions.hh:271
│ │ │ │ +
Default exception if memory allocation fails.
Definition exceptions.hh:276
│ │ │ │ +
Default exception if a function was called while the object is not in a valid state for that function...
Definition exceptions.hh:281
│ │ │ │ +
Default exception if an error in the parallel communication of the program occurred.
Definition exceptions.hh:287
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,368 +1,151 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -propertymap.hh │ │ │ │ │ +exceptions.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_PROPERTYMAP_HH │ │ │ │ │ -6#define DUNE_PROPERTYMAP_HH │ │ │ │ │ -7 │ │ │ │ │ -8#include │ │ │ │ │ -9#include │ │ │ │ │ -10#include │ │ │ │ │ -11 │ │ │ │ │ -12namespace Dune │ │ │ │ │ -13{ │ │ │ │ │ +5 │ │ │ │ │ +6#ifndef DUNE_EXCEPTIONS_HH │ │ │ │ │ +7#define DUNE_EXCEPTIONS_HH │ │ │ │ │ +8 │ │ │ │ │ +9#include │ │ │ │ │ +10#include │ │ │ │ │ +11#include │ │ │ │ │ +12 │ │ │ │ │ +13namespace Dune { │ │ │ │ │ 14 │ │ │ │ │ -15 template │ │ │ │ │ -16 struct PropertyMapTraits │ │ │ │ │ -17 { │ │ │ │ │ -21 typedef typename PM::KeyType KeyType; │ │ │ │ │ -25 typedef typename PM::ValueType ValueType; │ │ │ │ │ -29 typedef typename PM::Reference Reference; │ │ │ │ │ -33 typedef typename PM::Category Category; │ │ │ │ │ -34 }; │ │ │ │ │ -35 │ │ │ │ │ -37 struct ReadablePropertyMapTag │ │ │ │ │ -38 {}; │ │ │ │ │ -39 │ │ │ │ │ -41 struct WritablePropertyMapTag │ │ │ │ │ -42 {}; │ │ │ │ │ -43 │ │ │ │ │ -48 struct ReadWritePropertyMapTag │ │ │ │ │ -49 : public ReadablePropertyMapTag, public WritablePropertyMapTag │ │ │ │ │ -50 {}; │ │ │ │ │ -51 │ │ │ │ │ -55 struct LvaluePropertyMapTag │ │ │ │ │ -56 : public ReadWritePropertyMapTag │ │ │ │ │ -57 {}; │ │ │ │ │ -58 │ │ │ │ │ -59 template │ │ │ │ │ -60 struct PropertyMapTraits │ │ │ │ │ -61 { │ │ │ │ │ -62 typedef T ValueType; │ │ │ │ │ -63 typedef ValueType& Reference; │ │ │ │ │ -64 typedef std::ptrdiff_t KeyType; │ │ │ │ │ -65 typedef LvaluePropertyMapTag Category; │ │ │ │ │ -66 }; │ │ │ │ │ -67 │ │ │ │ │ -68 │ │ │ │ │ -69 template │ │ │ │ │ -70 struct PropertyMapTraits │ │ │ │ │ -71 { │ │ │ │ │ -72 typedef T ValueType; │ │ │ │ │ -73 typedef const ValueType& Reference; │ │ │ │ │ -74 typedef std::ptrdiff_t KeyType; │ │ │ │ │ -75 typedef LvaluePropertyMapTag Category; │ │ │ │ │ -76 }; │ │ │ │ │ -77 │ │ │ │ │ -78 template │ │ │ │ │ -79 struct RAPropertyMapHelper │ │ │ │ │ -80 {}; │ │ │ │ │ -81 │ │ │ │ │ -82 template │ │ │ │ │ -83 inline Reference │ │ │ │ │ -84 get(const RAPropertyMapHelper& pmap, │ │ │ │ │ -85 const Key& key) │ │ │ │ │ -86 { │ │ │ │ │ -87 return static_cast(pmap)[key]; │ │ │ │ │ -88 } │ │ │ │ │ -89 │ │ │ │ │ -90 template │ │ │ │ │ -91 inline void │ │ │ │ │ -92 put(const RAPropertyMapHelper& pmap, │ │ │ │ │ -93 const Key& key, const Value& value) │ │ │ │ │ -94 { │ │ │ │ │ -95 static_assert(std::is_convertible::value, │ │ │ │ │ -96 "WritablePropertyMapTag required!"); │ │ │ │ │ -97 static_cast(pmap)[key] = value; │ │ │ │ │ -98 } │ │ │ │ │ -99 │ │ │ │ │ -103 template::value_type, │ │ │ │ │ -105 class R = typename std::iterator_traits::reference> │ │ │ │ │ -106 class IteratorPropertyMap │ │ │ │ │ -107 : public RAPropertyMapHelper > │ │ │ │ │ -108 { │ │ │ │ │ -109 public: │ │ │ │ │ -113 typedef RAI RandomAccessIterator; │ │ │ │ │ -114 │ │ │ │ │ -120 typedef IM IndexMap; │ │ │ │ │ -121 │ │ │ │ │ -125 typedef typename IndexMap::KeyType KeyType; │ │ │ │ │ -126 │ │ │ │ │ -130 typedef T ValueType; │ │ │ │ │ -131 │ │ │ │ │ -135 typedef R Reference; │ │ │ │ │ -136 │ │ │ │ │ -140 typedef LvaluePropertyMapTag Category; │ │ │ │ │ -141 │ │ │ │ │ -149 inline IteratorPropertyMap(RandomAccessIterator iter, │ │ │ │ │ -150 const IndexMap& im=IndexMap()) │ │ │ │ │ -151 : iter_(iter), indexMap_(im) │ │ │ │ │ -152 {} │ │ │ │ │ -153 │ │ │ │ │ -155 inline IteratorPropertyMap() │ │ │ │ │ -156 : iter_(), indexMap_() │ │ │ │ │ -157 {} │ │ │ │ │ -158 │ │ │ │ │ -160 inline Reference operator[](KeyType key) const │ │ │ │ │ -161 { │ │ │ │ │ -162 return *(iter_ + get(indexMap_, key)); │ │ │ │ │ -163 } │ │ │ │ │ -164 │ │ │ │ │ -165 private: │ │ │ │ │ -167 RandomAccessIterator iter_; │ │ │ │ │ -169 IndexMap indexMap_; │ │ │ │ │ -170 }; │ │ │ │ │ -171 │ │ │ │ │ -176 template │ │ │ │ │ -177 class AssociativePropertyMap │ │ │ │ │ -178 : RAPropertyMapHelper > │ │ │ │ │ +73 /* forward declarations */ │ │ │ │ │ +74 class Exception; │ │ │ │ │ +75 struct ExceptionHook; │ │ │ │ │ +76 │ │ │ │ │ +94 class Exception │ │ │ │ │ +95 : public std::exception │ │ │ │ │ +96 { │ │ │ │ │ +97 public: │ │ │ │ │ +98 Exception (); │ │ │ │ │ +99 void message(const std::string &msg); │ │ │ │ │ +100 const char* what() const noexcept override; │ │ │ │ │ +101 static void registerHook (ExceptionHook * hook); │ │ │ │ │ +102 static void clearHook (); │ │ │ │ │ +103 private: │ │ │ │ │ +104 std::string _message; │ │ │ │ │ +105 static ExceptionHook * _hook; │ │ │ │ │ +106 }; │ │ │ │ │ +107 │ │ │ │ │ +173 struct ExceptionHook │ │ │ │ │ +174 { │ │ │ │ │ +175 virtual ~ExceptionHook() {} │ │ │ │ │ +176 virtual void operator_()_() = 0; │ │ │ │ │ +177 }; │ │ │ │ │ +178 │ │ │ │ │ +179 inline std::ostream& operator<<(std::ostream &stream, const Exception &e) │ │ │ │ │ 180 { │ │ │ │ │ -184 typedef T UniqueAssociativeContainer; │ │ │ │ │ -185 │ │ │ │ │ -189 typedef typename UniqueAssociativeContainer::value_type::first_type │ │ │ │ │ -190 KeyType; │ │ │ │ │ -191 │ │ │ │ │ -195 typedef typename UniqueAssociativeContainer::value_type::second_type │ │ │ │ │ -196 ValueType; │ │ │ │ │ -197 │ │ │ │ │ -201 typedef ValueType& Reference; │ │ │ │ │ -202 │ │ │ │ │ -206 typedef LvaluePropertyMapTag Category; │ │ │ │ │ -207 │ │ │ │ │ -209 inline AssociativePropertyMap() │ │ │ │ │ -210 : map_(0) │ │ │ │ │ -211 {} │ │ │ │ │ -212 │ │ │ │ │ -214 inline AssociativePropertyMap(UniqueAssociativeContainer& map) │ │ │ │ │ -215 : map_(&map) │ │ │ │ │ -216 {} │ │ │ │ │ -217 │ │ │ │ │ -222 inline Reference operator[](KeyType key) const │ │ │ │ │ -223 { │ │ │ │ │ -224 return map_->find(key)->second; │ │ │ │ │ -225 } │ │ │ │ │ -226 private: │ │ │ │ │ -227 UniqueAssociativeContainer* map_; │ │ │ │ │ -228 }; │ │ │ │ │ -229 │ │ │ │ │ -234 template │ │ │ │ │ -235 class ConstAssociativePropertyMap │ │ │ │ │ -236 : RAPropertyMapHelper > │ │ │ │ │ -238 { │ │ │ │ │ -242 typedef T UniqueAssociativeContainer; │ │ │ │ │ -243 │ │ │ │ │ -247 typedef typename UniqueAssociativeContainer::value_type::first_type │ │ │ │ │ -248 KeyType; │ │ │ │ │ -249 │ │ │ │ │ -253 typedef typename UniqueAssociativeContainer::value_type::second_type │ │ │ │ │ -254 ValueType; │ │ │ │ │ +181 return stream << e.what(); │ │ │ │ │ +182 } │ │ │ │ │ +183 │ │ │ │ │ +184#ifndef DOXYGEN │ │ │ │ │ +185 // the "format" the exception-type gets printed. __FILE__ and │ │ │ │ │ +186 // __LINE__ are standard C-defines, the GNU cpp-infofile claims that │ │ │ │ │ +187 // C99 defines __func__ as well. __FUNCTION__ is a GNU-extension │ │ │ │ │ +188#define THROWSPEC(E) # E << " [" << __func__ << ":" << __FILE__ << ":" << __ │ │ │ │ │ +LINE__ << "]: " │ │ │ │ │ +189#endif // DOXYGEN │ │ │ │ │ +190 │ │ │ │ │ +216 // this is the magic: use the usual do { ... } while (0) trick, create │ │ │ │ │ +217 // the full message via a string stream and throw the created object │ │ │ │ │ +218#define DUNE_THROW(E, m) do { E th__ex; std::ostringstream th__out; \ │ │ │ │ │ +219 th__out << THROWSPEC(E) << m; th__ex.message(th__out.str()); throw th__ex; │ │ │ │ │ +\ │ │ │ │ │ +220} while (0) │ │ │ │ │ +221 │ │ │ │ │ +231 class IOError : public Exception {}; │ │ │ │ │ +232 │ │ │ │ │ +241 class MathError : public Exception {}; │ │ │ │ │ +242 │ │ │ │ │ +254 class RangeError : public Exception {}; │ │ │ │ │ 255 │ │ │ │ │ -259 typedef const ValueType& Reference; │ │ │ │ │ -260 │ │ │ │ │ -264 typedef LvaluePropertyMapTag Category; │ │ │ │ │ -265 │ │ │ │ │ -267 inline ConstAssociativePropertyMap() │ │ │ │ │ -268 : map_(0) │ │ │ │ │ -269 {} │ │ │ │ │ -270 │ │ │ │ │ -272 inline ConstAssociativePropertyMap(const UniqueAssociativeContainer& map) │ │ │ │ │ -273 : map_(&map) │ │ │ │ │ -274 {} │ │ │ │ │ -275 │ │ │ │ │ -280 inline Reference operator[](KeyType key) const │ │ │ │ │ -281 { │ │ │ │ │ -282 return map_->find(key)->second; │ │ │ │ │ -283 } │ │ │ │ │ -284 private: │ │ │ │ │ -285 const UniqueAssociativeContainer* map_; │ │ │ │ │ -286 }; │ │ │ │ │ -287 │ │ │ │ │ -291 struct IdentityMap │ │ │ │ │ -292 : public RAPropertyMapHelper │ │ │ │ │ -293 { │ │ │ │ │ -295 typedef std::size_t KeyType; │ │ │ │ │ -296 │ │ │ │ │ -298 typedef std::size_t ValueType; │ │ │ │ │ -299 │ │ │ │ │ -301 typedef std::size_t Reference; │ │ │ │ │ -302 │ │ │ │ │ -304 typedef ReadablePropertyMapTag Category; │ │ │ │ │ -305 │ │ │ │ │ -306 inline ValueType operator[](const KeyType& key) const │ │ │ │ │ -307 { │ │ │ │ │ -308 return key; │ │ │ │ │ -309 } │ │ │ │ │ -310 }; │ │ │ │ │ -311 │ │ │ │ │ -312 │ │ │ │ │ -318 template │ │ │ │ │ -319 struct PropertyMapTypeSelector │ │ │ │ │ -320 { │ │ │ │ │ -324 typedef T Tag; │ │ │ │ │ -329 typedef C Container; │ │ │ │ │ -330 }; │ │ │ │ │ -331 │ │ │ │ │ -332} │ │ │ │ │ -333 │ │ │ │ │ -334#endif │ │ │ │ │ +263 class NotImplemented : public Exception {}; │ │ │ │ │ +264 │ │ │ │ │ +271 class SystemError : public Exception {}; │ │ │ │ │ +272 │ │ │ │ │ +276 class OutOfMemoryError : public SystemError {}; │ │ │ │ │ +277 │ │ │ │ │ +281 class InvalidStateException : public Exception {}; │ │ │ │ │ +282 │ │ │ │ │ +287 class ParallelError : public Exception {}; │ │ │ │ │ +288 │ │ │ │ │ +289} // end namespace │ │ │ │ │ +290 │ │ │ │ │ +291#endif │ │ │ │ │ +Dune::operator<< │ │ │ │ │ +std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x) │ │ │ │ │ +Definition bigunsignedint.hh:278 │ │ │ │ │ +Dune::Exception::Exception │ │ │ │ │ +Exception() │ │ │ │ │ +Definition exceptions.cc:16 │ │ │ │ │ +Dune::Exception::registerHook │ │ │ │ │ +static void registerHook(ExceptionHook *hook) │ │ │ │ │ +add a functor which is called before a Dune::Exception is emitted (see Dune:: │ │ │ │ │ +ExceptionHook) │ │ │ │ │ +Definition exceptions.cc:22 │ │ │ │ │ +Dune::Exception::clearHook │ │ │ │ │ +static void clearHook() │ │ │ │ │ +remove all hooks │ │ │ │ │ +Definition exceptions.cc:27 │ │ │ │ │ +Dune::Exception::message │ │ │ │ │ +void message(const std::string &msg) │ │ │ │ │ +store string in internal message buffer │ │ │ │ │ +Definition exceptions.cc:32 │ │ │ │ │ +Dune::ExceptionHook::operator() │ │ │ │ │ +virtual void operator()()=0 │ │ │ │ │ +Dune::ExceptionHook::~ExceptionHook │ │ │ │ │ +virtual ~ExceptionHook() │ │ │ │ │ +Definition exceptions.hh:175 │ │ │ │ │ +Dune::Exception::what │ │ │ │ │ +const char * what() const noexcept override │ │ │ │ │ +output internal message buffer │ │ │ │ │ +Definition exceptions.cc:37 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::put │ │ │ │ │ -void put(const RAPropertyMapHelper< Reference, PropertyMap > &pmap, const Key │ │ │ │ │ -&key, const Value &value) │ │ │ │ │ -Definition propertymap.hh:92 │ │ │ │ │ -Dune::get │ │ │ │ │ -constexpr auto get(std::integer_sequence< T, II... >, std::integral_constant< │ │ │ │ │ -std::size_t, pos >={}) │ │ │ │ │ -Return the entry at position pos of the given sequence. │ │ │ │ │ -Definition integersequence.hh:22 │ │ │ │ │ -Dune::PropertyMapTraits │ │ │ │ │ -Definition propertymap.hh:17 │ │ │ │ │ -Dune::PropertyMapTraits::ValueType │ │ │ │ │ -PM::ValueType ValueType │ │ │ │ │ -The type of the values of the property map. │ │ │ │ │ -Definition propertymap.hh:25 │ │ │ │ │ -Dune::PropertyMapTraits::Category │ │ │ │ │ -PM::Category Category │ │ │ │ │ -The category the property map belongs to. │ │ │ │ │ -Definition propertymap.hh:33 │ │ │ │ │ -Dune::PropertyMapTraits::Reference │ │ │ │ │ -PM::Reference Reference │ │ │ │ │ -The type of the reference to the values. │ │ │ │ │ -Definition propertymap.hh:29 │ │ │ │ │ -Dune::PropertyMapTraits::KeyType │ │ │ │ │ -PM::KeyType KeyType │ │ │ │ │ -The type of the key of the property map. │ │ │ │ │ -Definition propertymap.hh:21 │ │ │ │ │ -Dune::ReadablePropertyMapTag │ │ │ │ │ -Tag for the category of readable property maps. │ │ │ │ │ -Definition propertymap.hh:38 │ │ │ │ │ -Dune::WritablePropertyMapTag │ │ │ │ │ -Tag for the category of writable property maps. │ │ │ │ │ -Definition propertymap.hh:42 │ │ │ │ │ -Dune::ReadWritePropertyMapTag │ │ │ │ │ -Tag for the category of readable and writable property maps. │ │ │ │ │ -Definition propertymap.hh:50 │ │ │ │ │ -Dune::LvaluePropertyMapTag │ │ │ │ │ -Tag for the category of lvalue property maps. │ │ │ │ │ -Definition propertymap.hh:57 │ │ │ │ │ -Dune::PropertyMapTraits<_T_*_>::Reference │ │ │ │ │ -ValueType & Reference │ │ │ │ │ -Definition propertymap.hh:63 │ │ │ │ │ -Dune::PropertyMapTraits<_T_*_>::KeyType │ │ │ │ │ -std::ptrdiff_t KeyType │ │ │ │ │ -Definition propertymap.hh:64 │ │ │ │ │ -Dune::PropertyMapTraits<_T_*_>::ValueType │ │ │ │ │ -T ValueType │ │ │ │ │ -Definition propertymap.hh:62 │ │ │ │ │ -Dune::PropertyMapTraits<_T_*_>::Category │ │ │ │ │ -LvaluePropertyMapTag Category │ │ │ │ │ -Definition propertymap.hh:65 │ │ │ │ │ -Dune::PropertyMapTraits<_const_T_*_>::KeyType │ │ │ │ │ -std::ptrdiff_t KeyType │ │ │ │ │ -Definition propertymap.hh:74 │ │ │ │ │ -Dune::PropertyMapTraits<_const_T_*_>::Reference │ │ │ │ │ -const ValueType & Reference │ │ │ │ │ -Definition propertymap.hh:73 │ │ │ │ │ -Dune::PropertyMapTraits<_const_T_*_>::ValueType │ │ │ │ │ -T ValueType │ │ │ │ │ -Definition propertymap.hh:72 │ │ │ │ │ -Dune::PropertyMapTraits<_const_T_*_>::Category │ │ │ │ │ -LvaluePropertyMapTag Category │ │ │ │ │ -Definition propertymap.hh:75 │ │ │ │ │ -Dune::RAPropertyMapHelper │ │ │ │ │ -Definition propertymap.hh:80 │ │ │ │ │ -Dune::IteratorPropertyMap │ │ │ │ │ -Adapter to turn a random access iterator into a property map. │ │ │ │ │ -Definition propertymap.hh:108 │ │ │ │ │ -Dune::IteratorPropertyMap::KeyType │ │ │ │ │ -IndexMap::KeyType KeyType │ │ │ │ │ -The key type of the property map. │ │ │ │ │ -Definition propertymap.hh:125 │ │ │ │ │ -Dune::IteratorPropertyMap::Reference │ │ │ │ │ -R Reference │ │ │ │ │ -The reference type of the property map. │ │ │ │ │ -Definition propertymap.hh:135 │ │ │ │ │ -Dune::IteratorPropertyMap::ValueType │ │ │ │ │ -T ValueType │ │ │ │ │ -The value type of the property map. │ │ │ │ │ -Definition propertymap.hh:130 │ │ │ │ │ -Dune::IteratorPropertyMap::operator[] │ │ │ │ │ -Reference operator[](KeyType key) const │ │ │ │ │ -Access the a value by reference. │ │ │ │ │ -Definition propertymap.hh:160 │ │ │ │ │ -Dune::IteratorPropertyMap::IteratorPropertyMap │ │ │ │ │ -IteratorPropertyMap(RandomAccessIterator iter, const IndexMap &im=IndexMap()) │ │ │ │ │ -Constructor. │ │ │ │ │ -Definition propertymap.hh:149 │ │ │ │ │ -Dune::IteratorPropertyMap::IteratorPropertyMap │ │ │ │ │ -IteratorPropertyMap() │ │ │ │ │ -Constructor. │ │ │ │ │ -Definition propertymap.hh:155 │ │ │ │ │ -Dune::IteratorPropertyMap::IndexMap │ │ │ │ │ -IM IndexMap │ │ │ │ │ -The type of the index map. │ │ │ │ │ -Definition propertymap.hh:120 │ │ │ │ │ -Dune::IteratorPropertyMap::RandomAccessIterator │ │ │ │ │ -RAI RandomAccessIterator │ │ │ │ │ -The type of the random access iterator. │ │ │ │ │ -Definition propertymap.hh:113 │ │ │ │ │ -Dune::IteratorPropertyMap::Category │ │ │ │ │ -LvaluePropertyMapTag Category │ │ │ │ │ -The category of this property map. │ │ │ │ │ -Definition propertymap.hh:140 │ │ │ │ │ -Dune::AssociativePropertyMap │ │ │ │ │ -An adapter to turn an unique associative container into a property map. │ │ │ │ │ -Definition propertymap.hh:180 │ │ │ │ │ -Dune::ConstAssociativePropertyMap │ │ │ │ │ -An adaptor to turn an unique associative container into a property map. │ │ │ │ │ -Definition propertymap.hh:238 │ │ │ │ │ -Dune::IdentityMap │ │ │ │ │ -A property map that applies the identity function to integers. │ │ │ │ │ -Definition propertymap.hh:293 │ │ │ │ │ -Dune::IdentityMap::ValueType │ │ │ │ │ -std::size_t ValueType │ │ │ │ │ -The value type of the map. │ │ │ │ │ -Definition propertymap.hh:298 │ │ │ │ │ -Dune::IdentityMap::KeyType │ │ │ │ │ -std::size_t KeyType │ │ │ │ │ -The key type of the map. │ │ │ │ │ -Definition propertymap.hh:295 │ │ │ │ │ -Dune::IdentityMap::operator[] │ │ │ │ │ -ValueType operator[](const KeyType &key) const │ │ │ │ │ -Definition propertymap.hh:306 │ │ │ │ │ -Dune::IdentityMap::Reference │ │ │ │ │ -std::size_t Reference │ │ │ │ │ -The reference type of the map. │ │ │ │ │ -Definition propertymap.hh:301 │ │ │ │ │ -Dune::IdentityMap::Category │ │ │ │ │ -ReadablePropertyMapTag Category │ │ │ │ │ -The category of the map. │ │ │ │ │ -Definition propertymap.hh:304 │ │ │ │ │ -Dune::PropertyMapTypeSelector │ │ │ │ │ -Selector for the property map type. │ │ │ │ │ -Definition propertymap.hh:320 │ │ │ │ │ -Dune::PropertyMapTypeSelector::Tag │ │ │ │ │ -T Tag │ │ │ │ │ -the tag identifying the property. │ │ │ │ │ -Definition propertymap.hh:324 │ │ │ │ │ -Dune::PropertyMapTypeSelector::Container │ │ │ │ │ -C Container │ │ │ │ │ -The container type to whose entries the properties are attached. │ │ │ │ │ -Definition propertymap.hh:329 │ │ │ │ │ +Dune::Exception │ │ │ │ │ +Base class for Dune-Exceptions. │ │ │ │ │ +Definition exceptions.hh:96 │ │ │ │ │ +Dune::ExceptionHook │ │ │ │ │ +Base class to add a hook to the Dune::Exception. │ │ │ │ │ +Definition exceptions.hh:174 │ │ │ │ │ +Dune::IOError │ │ │ │ │ +Default exception class for I/O errors. │ │ │ │ │ +Definition exceptions.hh:231 │ │ │ │ │ +Dune::MathError │ │ │ │ │ +Default exception class for mathematical errors. │ │ │ │ │ +Definition exceptions.hh:241 │ │ │ │ │ +Dune::RangeError │ │ │ │ │ +Default exception class for range errors. │ │ │ │ │ +Definition exceptions.hh:254 │ │ │ │ │ +Dune::NotImplemented │ │ │ │ │ +Default exception for dummy implementations. │ │ │ │ │ +Definition exceptions.hh:263 │ │ │ │ │ +Dune::SystemError │ │ │ │ │ +Default exception class for OS errors. │ │ │ │ │ +Definition exceptions.hh:271 │ │ │ │ │ +Dune::OutOfMemoryError │ │ │ │ │ +Default exception if memory allocation fails. │ │ │ │ │ +Definition exceptions.hh:276 │ │ │ │ │ +Dune::InvalidStateException │ │ │ │ │ +Default exception if a function was called while the object is not in a valid │ │ │ │ │ +state for that function... │ │ │ │ │ +Definition exceptions.hh:281 │ │ │ │ │ +Dune::ParallelError │ │ │ │ │ +Default exception if an error in the parallel communication of the program │ │ │ │ │ +occurred. │ │ │ │ │ +Definition exceptions.hh:287 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00089.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: stdstreams.cc File Reference │ │ │ │ +dune-common: keywords.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,49 +70,36 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Namespaces | │ │ │ │ -Variables
│ │ │ │ -
stdstreams.cc File Reference
│ │ │ │ +Macros
│ │ │ │ +
keywords.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ -
#include <iostream>
│ │ │ │ -#include "stdstreams.hh"
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ +

Definitions of several macros that conditionally make C++ syntax available. │ │ │ │ +More...

│ │ │ │ + │ │ │ │ +

Go to the source code of this file.

│ │ │ │ +

│ │ │ │ -Variables

DVVerbType Dune::dvverb (std::cout)
 stream for very verbose output.
 
DVerbType Dune::dverb (std::cout)
 Singleton of verbose debug stream.
 
DInfoType Dune::dinfo (std::cout)
 Stream for informative output.
 
DWarnType Dune::dwarn (std::cerr)
 Stream for warnings indicating problems.
 
DGraveType Dune::dgrave (std::cerr)
 Stream for warnings indicating fatal errors.
 
DErrType Dune::derr (std::cerr)
 Stream for error messages.
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ +Macros

#define DUNE_INLINE_VARIABLE
 Preprocessor macro used for marking variables inline on supported compilers.
 
#define DUNE_GENERALIZED_CONSTEXPR
 Preprocessor macro used for marking code as constexpr under the relaxed rules of C++14 if supported by the compiler.
 
│ │ │ │ -
│ │ │ │ +

Detailed Description

│ │ │ │ +

Definitions of several macros that conditionally make C++ syntax available.

│ │ │ │ +

This header contains several macros that enable C++ features depending on your compiler. Most of these features are optional and provide additional functionality like making code constexpr.

│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,35 +1,28 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Namespaces | Variables │ │ │ │ │ -stdstreams.cc File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include "stdstreams.hh" │ │ │ │ │ -Namespaces │ │ │ │ │ -namespace   Dune │ │ │ │ │ -  Dune namespace. │ │ │ │ │ -  │ │ │ │ │ -Variables │ │ │ │ │ -DVVerbType  Dune::dvverb (std::cout) │ │ │ │ │ -  stream for very verbose output. │ │ │ │ │ -  │ │ │ │ │ - DVerbType  Dune::dverb (std::cout) │ │ │ │ │ -  Singleton of verbose debug stream. │ │ │ │ │ -  │ │ │ │ │ - DInfoType  Dune::dinfo (std::cout) │ │ │ │ │ -  Stream for informative output. │ │ │ │ │ -  │ │ │ │ │ - DWarnType  Dune::dwarn (std::cerr) │ │ │ │ │ -  Stream for warnings indicating problems. │ │ │ │ │ -  │ │ │ │ │ -DGraveType  Dune::dgrave (std::cerr) │ │ │ │ │ -  Stream for warnings indicating fatal errors. │ │ │ │ │ -  │ │ │ │ │ - DErrType  Dune::derr (std::cerr) │ │ │ │ │ -  Stream for error messages. │ │ │ │ │ -  │ │ │ │ │ +Macros │ │ │ │ │ +keywords.hh File Reference │ │ │ │ │ +Common » Utilities » C++_utilities_and_backports │ │ │ │ │ +Definitions of several macros that conditionally make C++ syntax available. │ │ │ │ │ +More... │ │ │ │ │ +Go_to_the_source_code_of_this_file. │ │ │ │ │ +Macros │ │ │ │ │ +#define  DUNE_INLINE_VARIABLE │ │ │ │ │ +  Preprocessor macro used for marking variables inline on supported │ │ │ │ │ + compilers. │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_GENERALIZED_CONSTEXPR │ │ │ │ │ +  Preprocessor macro used for marking code as constexpr under the │ │ │ │ │ + relaxed rules of C++14 if supported by the compiler. │ │ │ │ │ +  │ │ │ │ │ +***** Detailed Description ***** │ │ │ │ │ +Definitions of several macros that conditionally make C++ syntax available. │ │ │ │ │ +This header contains several macros that enable C++ features depending on your │ │ │ │ │ +compiler. Most of these features are optional and provide additional │ │ │ │ │ +functionality like making code constexpr. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00092.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: debugalign.hh File Reference │ │ │ │ +dune-common: overloadset.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,380 +70,42 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Classes | │ │ │ │ Namespaces | │ │ │ │ -Macros | │ │ │ │ -Typedefs | │ │ │ │ -Functions | │ │ │ │ -Variables
│ │ │ │ -
debugalign.hh File Reference
│ │ │ │ +Functions
│ │ │ │ +
overloadset.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ -
#include <algorithm>
│ │ │ │ -#include <cassert>
│ │ │ │ -#include <cmath>
│ │ │ │ -#include <complex>
│ │ │ │ -#include <cstddef>
│ │ │ │ -#include <cstdint>
│ │ │ │ -#include <cstdlib>
│ │ │ │ -#include <functional>
│ │ │ │ -#include <istream>
│ │ │ │ -#include <ostream>
│ │ │ │ +
#include <utility>
│ │ │ │ #include <type_traits>
│ │ │ │ -#include <utility>
│ │ │ │ -#include <dune/common/classname.hh>
│ │ │ │ -#include <dune/common/indices.hh>
│ │ │ │ -#include <dune/common/simd/base.hh>
│ │ │ │ -#include <dune/common/simd/defaults.hh>
│ │ │ │ -#include <dune/common/typetraits.hh>
│ │ │ │ +#include <dune/common/typetraits.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Classes

struct  Dune::AlignedBase< align, Impl >
 CRTP base mixin class to check alignment. More...
 
struct  Dune::IsNumber< AlignedNumberImpl::AlignedNumber< T, align > >
 
class  Dune::AlignedNumberImpl::AlignedNumber< T, align >
 aligned wrappers for arithmetic types More...
 
struct  Dune::Simd::Overloads::ScalarType< AlignedNumber< T, align > >
 
struct  Dune::Simd::Overloads::RebindType< U, AlignedNumber< T, align > >
 
struct  Dune::Simd::Overloads::LaneCount< AlignedNumber< T, align > >
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::AlignedNumberImpl
 
namespace  Dune::Simd
 Namespace for vectorization interface functions used by library developers.
 
namespace  Dune::Simd::Overloads
 Namespace for the overloads and specializations that make up a SIMD implementation.
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Macros

#define DUNE_ASSIGN_OP(OP)
 
#define DUNE_BINARY_OP(OP)
 
#define DUNE_UNARY_FUNC(name)
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │

│ │ │ │ -Typedefs

using Dune::ViolatedAlignmentHandler = std::function< void(const char *, std::size_t, const void *)>
 type of the handler called by violatedAlignment()
 
│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ Functions

ViolatedAlignmentHandlerDune::violatedAlignmentHandler ()
 access the handler called by violatedAlignment()
 
void Dune::violatedAlignment (const char *className, std::size_t expectedAlignment, const void *address)
 called when an alignment violation is detected
 
bool Dune::isAligned (const void *p, std::size_t align)
 check whether an address conforms to the given alignment
 
template<std::size_t align = debugAlignment, class T >
AlignedNumber< T, align > Dune::aligned (T value)
 align a value to a certain alignment
 
 Dune::AlignedNumberImpl::DUNE_BINARY_OP (+)
 
 Dune::AlignedNumberImpl::DUNE_BINARY_OP (-)
 
DUNE_BINARY_OP * Dune::AlignedNumberImpl::DUNE_BINARY_OP (/);DUNE_BINARY_OP(%
 
DUNE_BINARY_OP^ Dune::AlignedNumberImpl::DUNE_BINARY_OP (&);DUNE_BINARY_OP(|
 
 Dune::AlignedNumberImpl::DUNE_BINARY_OP (<<)
 
 Dune::AlignedNumberImpl::DUNE_BINARY_OP (> >)
 
 Dune::AlignedNumberImpl::DUNE_BINARY_OP (==)
 
 Dune::AlignedNumberImpl::DUNE_BINARY_OP (!=)
 
 Dune::AlignedNumberImpl::DUNE_BINARY_OP (<=)
 
 Dune::AlignedNumberImpl::DUNE_BINARY_OP (>=)
 
DUNE_BINARY_OP && Dune::AlignedNumberImpl::DUNE_BINARY_OP (||);#define DUNE_UNARY_FUNC(name) DUNE_UNARY_FUNC(abs
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (acos)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (acosh)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (asin)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (asinh)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (atan)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (atanh)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (cbrt)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (ceil)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (cos)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (cosh)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (erf)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (erfc)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (exp)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (exp2)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (expm1)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (fabs)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (floor)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (ilogb)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (lgamma)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (llrint)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (llround)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (log)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (log10)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (log1p)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (log2)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (logb)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (lrint)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (lround)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (nearbyint)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (rint)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (round)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (sin)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (sinh)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (sqrt)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (tan)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (tanh)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (tgamma)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (trunc)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (isfinite)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (isinf)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (isnan)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (isnormal)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (signbit)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (real)
 
template<class T , std::size_t align>
auto Dune::AlignedNumberImpl::max (const AlignedNumber< T, align > &a, const AlignedNumber< T, align > &b)
 
template<class T , std::size_t align>
auto Dune::AlignedNumberImpl::max (const T &a, const AlignedNumber< T, align > &b)
 
template<class T , std::size_t align>
auto Dune::AlignedNumberImpl::max (const AlignedNumber< T, align > &a, const T &b)
 
template<class T , std::size_t align>
auto Dune::AlignedNumberImpl::min (const AlignedNumber< T, align > &a, const AlignedNumber< T, align > &b)
 
template<class T , std::size_t align>
auto Dune::AlignedNumberImpl::min (const T &a, const AlignedNumber< T, align > &b)
 
template<class T , std::size_t align>
auto Dune::AlignedNumberImpl::min (const AlignedNumber< T, align > &a, const T &b)
 
template<class T , std::size_t align>
AlignedNumber< T, align > Dune::cond (const AlignedNumber< bool, align > &b, const AlignedNumber< T, align > &v1, const AlignedNumber< T, align > &v2)
 
template<class T , std::size_t align>
Dune::max_value (const AlignedNumber< T, align > &val)
 
template<class T , std::size_t align>
Dune::min_value (const AlignedNumber< T, align > &val)
 
template<std::size_t align>
bool Dune::any_true (const AlignedNumber< bool, align > &val)
 
template<std::size_t align>
bool Dune::all_true (const AlignedNumber< bool, align > &val)
 
template<class T , std::size_t align>
T & Dune::Simd::Overloads::lane (ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v)
 
template<class T , std::size_t align>
Dune::Simd::Overloads::lane (ADLTag< 5 >, std::size_t l, const AlignedNumber< T, align > &v)
 
template<class T , std::size_t align>
const AlignedNumber< T, align > & Dune::Simd::Overloads::cond (ADLTag< 5 >, AlignedNumber< bool, align > mask, const AlignedNumber< T, align > &ifTrue, const AlignedNumber< T, align > &ifFalse)
 
template<std::size_t align>
bool Dune::Simd::Overloads::anyTrue (ADLTag< 5 >, const AlignedNumber< bool, align > &mask)
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ -Variables

static constexpr auto Dune::debugAlignment = 2*alignof(std::max_align_t)
 an alignment large enough to trigger alignment errors
 
template<class... F>
auto Dune::overload (F &&... f)
 Create an overload set.
 
template<class... F>
auto Dune::orderedOverload (F &&... f)
 Create an ordered overload set.
 
│ │ │ │ -

Macro Definition Documentation

│ │ │ │ - │ │ │ │ -

◆ DUNE_ASSIGN_OP

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_ASSIGN_OP( OP)
│ │ │ │ -
│ │ │ │ -Value:
template<class U, std::size_t uAlign, \
│ │ │ │ -
class = std::enable_if_t< \
│ │ │ │ -
( uAlign <= align && \
│ │ │ │ -
sizeof(std::declval<T&>() OP std::declval<U>()) ) \
│ │ │ │ -
> > \
│ │ │ │ -
AlignedNumber &operator OP(const AlignedNumber<U, uAlign> &u) \
│ │ │ │ -
{ \
│ │ │ │ -
value_ OP U(u); \
│ │ │ │ -
return *this; \
│ │ │ │ -
} \
│ │ │ │ -
\
│ │ │ │ -
template<class U, \
│ │ │ │ -
class = std::void_t<decltype(std::declval<T&>() OP \
│ │ │ │ -
std::declval<U>())> > \
│ │ │ │ -
AlignedNumber &operator OP(const U &u) \
│ │ │ │ -
{ \
│ │ │ │ -
value_ OP u; \
│ │ │ │ -
return *this; \
│ │ │ │ -
} \
│ │ │ │ -
\
│ │ │ │ -
static_assert(true, "Require semicolon to unconfuse editors")
│ │ │ │ -
STL namespace.
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ DUNE_BINARY_OP

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_BINARY_OP( OP)
│ │ │ │ -
│ │ │ │ -Value:
template<class T, std::size_t tAlign, class U, std::size_t uAlign, \
│ │ │ │ -
class = std::void_t<decltype(std::declval<T>() \
│ │ │ │ -
OP std::declval<U>())> > \
│ │ │ │ -
decltype(auto) \
│ │ │ │ -
operator OP(const AlignedNumber<T, tAlign> &t, \
│ │ │ │ -
const AlignedNumber<U, uAlign> &u) \
│ │ │ │ -
{ \
│ │ │ │ -
/* can't use std::max(); not constexpr */ \
│ │ │ │ -
return aligned<(tAlign > uAlign ? tAlign : uAlign)>(T(t) OP U(u)); \
│ │ │ │ -
} \
│ │ │ │ -
\
│ │ │ │ -
template<class T, class U, std::size_t uAlign, \
│ │ │ │ -
class = std::void_t<decltype(std::declval<T>() \
│ │ │ │ -
OP std::declval<U>())> > \
│ │ │ │ -
decltype(auto) \
│ │ │ │ -
operator OP(const T &t, const AlignedNumber<U, uAlign> &u) \
│ │ │ │ -
{ \
│ │ │ │ -
return aligned<uAlign>(t OP U(u)); \
│ │ │ │ -
} \
│ │ │ │ -
\
│ │ │ │ -
template<class T, std::size_t tAlign, class U, \
│ │ │ │ -
class = std::void_t<decltype(std::declval<T>() \
│ │ │ │ -
OP std::declval<U>())> > \
│ │ │ │ -
decltype(auto) \
│ │ │ │ -
operator OP(const AlignedNumber<T, tAlign> &t, const U &u) \
│ │ │ │ -
{ \
│ │ │ │ -
return aligned<tAlign>(T(t) OP u); \
│ │ │ │ -
} \
│ │ │ │ -
\
│ │ │ │ -
static_assert(true, "Require semicolon to unconfuse editors")
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ DUNE_UNARY_FUNC

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_UNARY_FUNC( name)
│ │ │ │ -
│ │ │ │ -Value:
template<class T, std::size_t align> \
│ │ │ │ -
decltype(auto) name(const AlignedNumber<T, align> &u) \
│ │ │ │ -
{ \
│ │ │ │ -
using std::name; \
│ │ │ │ -
return aligned<align>(name(T(u))); \
│ │ │ │ -
} \
│ │ │ │ -
static_assert(true, "Require semicolon to unconfuse editors")
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,388 +1,27 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Macros | Typedefs | Functions | Variables │ │ │ │ │ -debugalign.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Namespaces | Functions │ │ │ │ │ +overloadset.hh File Reference │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ -Classes │ │ │ │ │ -struct   Dune::AlignedBase<_align,_Impl_> │ │ │ │ │ -  CRTP base mixin class to check alignment. More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::IsNumber<_AlignedNumberImpl::AlignedNumber<_T,_align_>_> │ │ │ │ │ -  │ │ │ │ │ - class   Dune::AlignedNumberImpl::AlignedNumber<_T,_align_> │ │ │ │ │ -  aligned wrappers for arithmetic types More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::Simd::Overloads::ScalarType<_AlignedNumber<_T,_align_>_> │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::Simd::Overloads::RebindType<_U,_AlignedNumber<_T,_align_>_> │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::Simd::Overloads::LaneCount<_AlignedNumber<_T,_align_>_> │ │ │ │ │ -  │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -namespace   Dune::AlignedNumberImpl │ │ │ │ │ -  │ │ │ │ │ -namespace   Dune::Simd │ │ │ │ │ -  Namespace for vectorization interface functions used by library │ │ │ │ │ - developers. │ │ │ │ │ -  │ │ │ │ │ -namespace   Dune::Simd::Overloads │ │ │ │ │ -  Namespace for the overloads and specializations that make up a SIMD │ │ │ │ │ - implementation. │ │ │ │ │ -  │ │ │ │ │ -Macros │ │ │ │ │ -#define  DUNE_ASSIGN_OP(OP) │ │ │ │ │ -  │ │ │ │ │ -#define  DUNE_BINARY_OP(OP) │ │ │ │ │ -  │ │ │ │ │ -#define  DUNE_UNARY_FUNC(name) │ │ │ │ │ -  │ │ │ │ │ -Typedefs │ │ │ │ │ -using  Dune::ViolatedAlignmentHandler = std::function< void(const char *, std:: │ │ │ │ │ - size_t, const void *)> │ │ │ │ │ -  type of the handler called by violatedAlignment() │ │ │ │ │ -  │ │ │ │ │ Functions │ │ │ │ │ - ViolatedAlignmentHandler &  Dune::violatedAlignmentHandler () │ │ │ │ │ -  access the handler called by │ │ │ │ │ - violatedAlignment() │ │ │ │ │ -  │ │ │ │ │ - void  Dune::violatedAlignment (const char │ │ │ │ │ - *className, std::size_t expectedAlignment, │ │ │ │ │ - const void *address) │ │ │ │ │ -  called when an alignment violation is │ │ │ │ │ - detected │ │ │ │ │ -  │ │ │ │ │ - bool  Dune::isAligned (const void *p, std::size_ │ │ │ │ │ - t align) │ │ │ │ │ -  check whether an address conforms to the │ │ │ │ │ - given alignment │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - AlignedNumber< T, align >  Dune::aligned (T value) │ │ │ │ │ -  align a value to a certain alignment │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_BINARY_OP (+) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_BINARY_OP (-) │ │ │ │ │ -  │ │ │ │ │ - DUNE_BINARY_OP *  Dune::AlignedNumberImpl::DUNE_BINARY_OP (/ │ │ │ │ │ - );DUNE_BINARY_OP(% │ │ │ │ │ -  │ │ │ │ │ - DUNE_BINARY_OP^  Dune::AlignedNumberImpl::DUNE_BINARY_OP │ │ │ │ │ - (&);DUNE_BINARY_OP(| │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_BINARY_OP (<<) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_BINARY_OP (> │ │ │ │ │ - >) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_BINARY_OP (==) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_BINARY_OP (!=) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_BINARY_OP (<=) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_BINARY_OP (>=) │ │ │ │ │ -  │ │ │ │ │ - DUNE_BINARY_OP &&  Dune::AlignedNumberImpl::DUNE_BINARY_OP │ │ │ │ │ - (||);#define DUNE_UNARY_FUNC(name) DUNE_ │ │ │ │ │ - UNARY_FUNC(abs │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (acos) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (acosh) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (asin) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (asinh) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (atan) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (atanh) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (cbrt) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (ceil) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (cos) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (cosh) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (erf) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (erfc) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (exp) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (exp2) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (expm1) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (fabs) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (floor) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (ilogb) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (lgamma) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (llrint) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (llround) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (log) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (log10) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (log1p) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (log2) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (logb) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (lrint) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (lround) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (nearbyint) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (rint) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (round) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (sin) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (sinh) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (sqrt) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (tan) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (tanh) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (tgamma) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (trunc) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (isfinite) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (isinf) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (isnan) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (isnormal) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (signbit) │ │ │ │ │ -  │ │ │ │ │ -   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ - (real) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::AlignedNumberImpl::max (const │ │ │ │ │ - AlignedNumber< T, align > &a, const │ │ │ │ │ - AlignedNumber< T, align > &b) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::AlignedNumberImpl::max (const T &a, │ │ │ │ │ - const AlignedNumber< T, align > &b) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::AlignedNumberImpl::max (const │ │ │ │ │ - AlignedNumber< T, align > &a, const T &b) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::AlignedNumberImpl::min (const │ │ │ │ │ - AlignedNumber< T, align > &a, const │ │ │ │ │ - AlignedNumber< T, align > &b) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::AlignedNumberImpl::min (const T &a, │ │ │ │ │ - const AlignedNumber< T, align > &b) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::AlignedNumberImpl::min (const │ │ │ │ │ - AlignedNumber< T, align > &a, const T &b) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - AlignedNumber< T, align >  Dune::cond (const AlignedNumber< bool, align │ │ │ │ │ - > &b, const AlignedNumber< T, align > &v1, │ │ │ │ │ - const AlignedNumber< T, align > &v2) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - T  Dune::max_value (const AlignedNumber< T, │ │ │ │ │ - align > &val) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - T  Dune::min_value (const AlignedNumber< T, │ │ │ │ │ - align > &val) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - bool  Dune::any_true (const AlignedNumber< bool, │ │ │ │ │ - align > &val) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - bool  Dune::all_true (const AlignedNumber< bool, │ │ │ │ │ - align > &val) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - T &  Dune::Simd::Overloads::lane (ADLTag< 5 >, │ │ │ │ │ - std::size_t l, AlignedNumber< T, align > &v) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - T  Dune::Simd::Overloads::lane (ADLTag< 5 >, │ │ │ │ │ - std::size_t l, const AlignedNumber< T, align │ │ │ │ │ - > &v) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -const AlignedNumber< T, align > &  Dune::Simd::Overloads::cond (ADLTag< 5 >, │ │ │ │ │ - AlignedNumber< bool, align > mask, const │ │ │ │ │ - AlignedNumber< T, align > &ifTrue, const │ │ │ │ │ - AlignedNumber< T, align > &ifFalse) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - bool  Dune::Simd::Overloads::anyTrue (ADLTag< 5 >, │ │ │ │ │ - const AlignedNumber< bool, align > &mask) │ │ │ │ │ -  │ │ │ │ │ -Variables │ │ │ │ │ -static constexpr auto  Dune::debugAlignment = 2*alignof(std::max_align_t) │ │ │ │ │ -  an alignment large enough to trigger alignment errors │ │ │ │ │ +template │ │ │ │ │ +auto  Dune::overload (F &&... f) │ │ │ │ │ +  Create an overload set. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +auto  Dune::orderedOverload (F &&... f) │ │ │ │ │ +  Create an ordered overload set. │ │ │ │ │   │ │ │ │ │ -***** Macro Definition Documentation ***** │ │ │ │ │ -***** ◆ DUNE_ASSIGN_OP ***** │ │ │ │ │ -#define DUNE_ASSIGN_OP (   OP ) │ │ │ │ │ -Value: │ │ │ │ │ -template() OP std::declval()) ) \ │ │ │ │ │ -> > \ │ │ │ │ │ -AlignedNumber &operator OP(const AlignedNumber &u) \ │ │ │ │ │ -{ \ │ │ │ │ │ -value_ OP U(u); \ │ │ │ │ │ -return *this; \ │ │ │ │ │ -} \ │ │ │ │ │ -\ │ │ │ │ │ -template() OP \ │ │ │ │ │ -std::declval())> > \ │ │ │ │ │ -AlignedNumber &operator OP(const U &u) \ │ │ │ │ │ -{ \ │ │ │ │ │ -value_ OP u; \ │ │ │ │ │ -return *this; \ │ │ │ │ │ -} \ │ │ │ │ │ -\ │ │ │ │ │ -static_assert(true, "Require semicolon to unconfuse editors") │ │ │ │ │ -std │ │ │ │ │ -STL namespace. │ │ │ │ │ -***** ◆ DUNE_BINARY_OP ***** │ │ │ │ │ -#define DUNE_BINARY_OP (   OP ) │ │ │ │ │ -Value: │ │ │ │ │ -template() \ │ │ │ │ │ -OP std::declval())> > \ │ │ │ │ │ -decltype(auto) \ │ │ │ │ │ -operator OP(const AlignedNumber &t, \ │ │ │ │ │ -const AlignedNumber &u) \ │ │ │ │ │ -{ \ │ │ │ │ │ -/* can't use std::max(); not constexpr */ \ │ │ │ │ │ -return aligned<(tAlign > uAlign ? tAlign : uAlign)>(T(t) OP U(u)); \ │ │ │ │ │ -} \ │ │ │ │ │ -\ │ │ │ │ │ -template() \ │ │ │ │ │ -OP std::declval())> > \ │ │ │ │ │ -decltype(auto) \ │ │ │ │ │ -operator OP(const T &t, const AlignedNumber &u) \ │ │ │ │ │ -{ \ │ │ │ │ │ -return aligned(t OP U(u)); \ │ │ │ │ │ -} \ │ │ │ │ │ -\ │ │ │ │ │ -template() \ │ │ │ │ │ -OP std::declval())> > \ │ │ │ │ │ -decltype(auto) \ │ │ │ │ │ -operator OP(const AlignedNumber &t, const U &u) \ │ │ │ │ │ -{ \ │ │ │ │ │ -return aligned(T(t) OP u); \ │ │ │ │ │ -} \ │ │ │ │ │ -\ │ │ │ │ │ -static_assert(true, "Require semicolon to unconfuse editors") │ │ │ │ │ -***** ◆ DUNE_UNARY_FUNC ***** │ │ │ │ │ -#define DUNE_UNARY_FUNC (   name ) │ │ │ │ │ -Value: │ │ │ │ │ -template \ │ │ │ │ │ -decltype(auto) name(const AlignedNumber &u) \ │ │ │ │ │ -{ \ │ │ │ │ │ -using std::name; \ │ │ │ │ │ -return aligned(name(T(u))); \ │ │ │ │ │ -} \ │ │ │ │ │ -static_assert(true, "Require semicolon to unconfuse editors") │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00092_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: debugalign.hh Source File │ │ │ │ +dune-common: overloadset.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,657 +74,139 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
debugalign.hh
│ │ │ │ +
overloadset.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_DEBUGALIGN_HH
│ │ │ │ -
6#define DUNE_DEBUGALIGN_HH
│ │ │ │ +
5#ifndef DUNE_COMMON_OVERLOADSET_HH
│ │ │ │ +
6#define DUNE_COMMON_OVERLOADSET_HH
│ │ │ │
7
│ │ │ │ -
8#include <algorithm>
│ │ │ │ -
9#include <cassert>
│ │ │ │ -
10#include <cmath>
│ │ │ │ -
11#include <complex>
│ │ │ │ -
12#include <cstddef>
│ │ │ │ -
13#include <cstdint>
│ │ │ │ -
14#include <cstdlib> // abs
│ │ │ │ -
15#include <functional>
│ │ │ │ -
16#include <istream>
│ │ │ │ -
17#include <ostream>
│ │ │ │ -
18#include <type_traits>
│ │ │ │ -
19#include <utility>
│ │ │ │ +
8#include <utility>
│ │ │ │ +
9#include <type_traits>
│ │ │ │ + │ │ │ │ +
11
│ │ │ │ +
12namespace Dune {
│ │ │ │ +
13
│ │ │ │ +
14namespace Impl {
│ │ │ │ +
15
│ │ │ │ +
16 template<typename... F>
│ │ │ │ +
17 class OverloadSet
│ │ │ │ +
18 : public F...
│ │ │ │ +
19 {
│ │ │ │
20
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
26
│ │ │ │ -
27namespace Dune {
│ │ │ │ -
28
│ │ │ │ - │ │ │ │ -
31 std::function<void(const char*, std::size_t, const void*)>;
│ │ │ │ -
32
│ │ │ │ +
21 public:
│ │ │ │ +
22
│ │ │ │ +
23 template<typename... FF>
│ │ │ │ +
24 OverloadSet(FF&&... ff)
│ │ │ │ +
25 : F(std::forward<FF>(ff))...
│ │ │ │ +
26 {}
│ │ │ │ +
27
│ │ │ │ +
28 using F::operator()...;
│ │ │ │ +
29
│ │ │ │ +
30 };
│ │ │ │ +
31
│ │ │ │ +
32} // end namespace Impl
│ │ │ │ +
33
│ │ │ │
34
│ │ │ │ - │ │ │ │ -
41
│ │ │ │ -
43
│ │ │ │ -
52 void violatedAlignment(const char *className, std::size_t expectedAlignment,
│ │ │ │ -
53 const void *address);
│ │ │ │ -
54
│ │ │ │ -
│ │ │ │ -
56 inline bool isAligned(const void *p, std::size_t align)
│ │ │ │ -
57 {
│ │ │ │ -
58 void* aligned_p = (void*)p;
│ │ │ │ -
59 std::size_t space = align*2;
│ │ │ │ -
60 return p == std::align(align, align, aligned_p, space);
│ │ │ │ -
61 }
│ │ │ │ -
│ │ │ │ -
62
│ │ │ │ -
64 template<std::size_t align, class Impl>
│ │ │ │ -
│ │ │ │ -
65 struct alignas(align) AlignedBase
│ │ │ │ -
66 {
│ │ │ │ -
│ │ │ │ -
75 static void* operator new(std::size_t count, void* ptr) {
│ │ │ │ -
76 if(!isAligned(ptr, align))
│ │ │ │ -
77 violatedAlignment(className<Impl>().c_str(), align, ptr);
│ │ │ │ -
78 return ::operator new(count*sizeof(Impl), ptr);
│ │ │ │ -
79 }
│ │ │ │ -
│ │ │ │ -
80
│ │ │ │ -
│ │ │ │ -
89 static void* operator new[](std::size_t count, void* ptr) {
│ │ │ │ -
90 if(!isAligned(ptr, align))
│ │ │ │ -
91 violatedAlignment(className<Impl>().c_str(), align, ptr);
│ │ │ │ -
92 return ::operator new[](count*sizeof(Impl), ptr);
│ │ │ │ -
93 }
│ │ │ │ -
│ │ │ │ -
94 };
│ │ │ │ -
│ │ │ │ -
95
│ │ │ │ -
97 static constexpr auto debugAlignment = 2*alignof(std::max_align_t);
│ │ │ │ -
98
│ │ │ │ -
│ │ │ │ -
99 namespace AlignedNumberImpl {
│ │ │ │ -
100
│ │ │ │ -
101 template<class T, std::size_t align = debugAlignment>
│ │ │ │ -
102 class AlignedNumber;
│ │ │ │ -
103
│ │ │ │ -
104 } // namespace AlignedNumberImpl
│ │ │ │ -
│ │ │ │ -
105
│ │ │ │ - │ │ │ │ -
107
│ │ │ │ -
108 template<class T, std::size_t align>
│ │ │ │ -
│ │ │ │ -
109 struct IsNumber<AlignedNumberImpl::AlignedNumber<T,align>>
│ │ │ │ -
110 : public std::true_type {};
│ │ │ │ -
│ │ │ │ +
35
│ │ │ │ +
60template<class... F>
│ │ │ │ +
│ │ │ │ +
61auto overload(F&&... f)
│ │ │ │ +
62{
│ │ │ │ +
63 return Impl::OverloadSet<std::decay_t<F>...>(std::forward<F>(f)...);
│ │ │ │ +
64}
│ │ │ │ +
│ │ │ │ +
65
│ │ │ │ +
66
│ │ │ │ +
67
│ │ │ │ +
68namespace Impl {
│ │ │ │ +
69
│ │ │ │ +
70 template<class F0, class... F>
│ │ │ │ +
71 class OrderedOverloadSet: public OrderedOverloadSet<F...>, F0
│ │ │ │ +
72 {
│ │ │ │ +
73 using Base = OrderedOverloadSet<F...>;
│ │ │ │ +
74 public:
│ │ │ │ +
75
│ │ │ │ +
76 template<class FF0, class... FF>
│ │ │ │ +
77 OrderedOverloadSet(FF0&& f0, FF&&... ff) :
│ │ │ │ +
78 Base(std::forward<FF>(ff)...),
│ │ │ │ +
79 F0(std::forward<FF0>(f0))
│ │ │ │ +
80 {}
│ │ │ │ +
81
│ │ │ │ +
82 // Forward to operator() of F0 if it can be called with the given arguments.
│ │ │ │ +
83 template<class... Args,
│ │ │ │ +
84 std::enable_if_t<IsCallable<F0(Args&&...)>::value, int> = 0>
│ │ │ │ +
85 decltype(auto) operator()(Args&&... args)
│ │ │ │ +
86 {
│ │ │ │ +
87 return F0::operator()(std::forward<Args>(args)...);
│ │ │ │ +
88 }
│ │ │ │ +
89
│ │ │ │ +
90 // Forward to operator() of base class if F0 cannot be called with the given
│ │ │ │ +
91 // arguments. In this case the base class will successively try operator()
│ │ │ │ +
92 // of all F... .
│ │ │ │ +
93 template<class... Args,
│ │ │ │ +
94 std::enable_if_t<not IsCallable<F0(Args&&...)>::value, int> = 0>
│ │ │ │ +
95 decltype(auto) operator()(Args&&... args)
│ │ │ │ +
96 {
│ │ │ │ +
97 return Base::operator()(std::forward<Args>(args)...);
│ │ │ │ +
98 }
│ │ │ │ +
99
│ │ │ │ +
100 };
│ │ │ │ +
101
│ │ │ │ +
102 template<class F0>
│ │ │ │ +
103 class OrderedOverloadSet<F0>: public F0
│ │ │ │ +
104 {
│ │ │ │ +
105 public:
│ │ │ │ +
106
│ │ │ │ +
107 template<class FF0>
│ │ │ │ +
108 OrderedOverloadSet(FF0&& f0) :
│ │ │ │ +
109 F0(std::forward<FF0>(f0))
│ │ │ │ +
110 {}
│ │ │ │
111
│ │ │ │ -
113 template<std::size_t align = debugAlignment, class T>
│ │ │ │ -
114 AlignedNumber<T, align> aligned(T value) { return { std::move(value) }; }
│ │ │ │ -
115
│ │ │ │ -
116 // The purpose of this namespace is to move the `<cmath>` function overloads
│ │ │ │ -
117 // out of namespace `Dune`. This avoids problems where people called
│ │ │ │ -
118 // e.g. `sqrt(1.0)` inside the `Dune` namespace, without first doing `using
│ │ │ │ -
119 // std::sqrt;`. Without any `Dune::sqrt()`, such a use will find
│ │ │ │ -
120 // `::sqrt()`, but with `Dune::sqrt()` it will find only `Dune::sqrt()`,
│ │ │ │ -
121 // which does not have an overload for `double`.
│ │ │ │ -
122 namespace AlignedNumberImpl {
│ │ │ │ -
123
│ │ │ │ -
125 template<class T, std::size_t align>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
127 : public AlignedBase<align, AlignedNumber<T, align> >
│ │ │ │ -
128 {
│ │ │ │ -
129 T value_;
│ │ │ │ -
130
│ │ │ │ -
131 public:
│ │ │ │ -
132 AlignedNumber() = default;
│ │ │ │ -
133 AlignedNumber(T value) : value_(std::move(value)) {}
│ │ │ │ -
134 template<class U, std::size_t uAlign,
│ │ │ │ -
135 class = std::enable_if_t<(align >= uAlign) &&
│ │ │ │ -
136 std::is_convertible<U, T>::value> >
│ │ │ │ -
137 AlignedNumber(const AlignedNumber<U, uAlign> &o) : value_(U(o)) {}
│ │ │ │ -
138
│ │ │ │ -
139 // accessors
│ │ │ │ -
140 template<class U,
│ │ │ │ -
141 class = std::enable_if_t<std::is_convertible<T, U>::value> >
│ │ │ │ -
142 explicit operator U() const { return value_; }
│ │ │ │ -
143
│ │ │ │ -
144 const T &value() const { return value_; }
│ │ │ │ -
145 T &value() { return value_; }
│ │ │ │ -
146
│ │ │ │ -
147 // I/O
│ │ │ │ -
148 template<class charT, class Traits>
│ │ │ │ -
149 friend std::basic_istream<charT, Traits>&
│ │ │ │ -
│ │ │ │ -
150 operator>>(std::basic_istream<charT, Traits>& str, AlignedNumber &u)
│ │ │ │ -
151 {
│ │ │ │ -
152 return str >> u.value_;
│ │ │ │ -
153 }
│ │ │ │ +
112 // Forward to operator() of F0. If it cannot be called with
│ │ │ │ +
113 // the given arguments a static assertion will fail.
│ │ │ │ +
114 template<class... Args>
│ │ │ │ +
115 decltype(auto) operator()(Args&&... args)
│ │ │ │ +
116 {
│ │ │ │ +
117 static_assert(IsCallable<F0(Args&&...)>::value,
│ │ │ │ +
118 "No matching overload found in OrderedOverloadSet");
│ │ │ │ +
119 return F0::operator()(std::forward<Args>(args)...);
│ │ │ │ +
120 }
│ │ │ │ +
121 };
│ │ │ │ +
122
│ │ │ │ +
123} // end namespace Impl
│ │ │ │ +
124
│ │ │ │ +
125
│ │ │ │ +
126
│ │ │ │ +
149template<class... F>
│ │ │ │ +
│ │ │ │ +
150auto orderedOverload(F&&... f)
│ │ │ │ +
151{
│ │ │ │ +
152 return Impl::OrderedOverloadSet<std::decay_t<F>...>(std::forward<F>(f)...);
│ │ │ │ +
153}
│ │ │ │
│ │ │ │
154
│ │ │ │ -
155 template<class charT, class Traits>
│ │ │ │ -
│ │ │ │ -
156 friend std::basic_ostream<charT, Traits>&
│ │ │ │ -
157 operator<<(std::basic_ostream<charT, Traits>& str,
│ │ │ │ -
158 const AlignedNumber &u)
│ │ │ │ -
159 {
│ │ │ │ -
160 return str << u.value_;
│ │ │ │ -
161 }
│ │ │ │ -
│ │ │ │ -
162
│ │ │ │ -
163 // The trick with `template<class U = T, class = std::void_t<expr(U)> >` is
│ │ │ │ -
164 // needed because at least g++-4.9 seems to evaluates a default argument
│ │ │ │ -
165 // in `template<class = std::void_t<expr(T))> >` as soon as possible and will
│ │ │ │ -
166 // error out if `expr(T)` is invalid. E.g. for `expr(T)` =
│ │ │ │ -
167 // `decltype(--std::declval<T&>())`, instantiating `AlignedNumber<bool>`
│ │ │ │ -
168 // will result in an unrecoverable error (`--` cannot be applied to a
│ │ │ │ -
169 // `bool`).
│ │ │ │ -
170
│ │ │ │ -
171 // Increment, decrement
│ │ │ │ -
172 template<class U = T, class = std::void_t<decltype(++std::declval<U&>())> >
│ │ │ │ -
173 AlignedNumber &operator++() { ++value_; return *this; }
│ │ │ │ -
174
│ │ │ │ -
175 template<class U = T, class = std::void_t<decltype(--std::declval<U&>())> >
│ │ │ │ -
176 AlignedNumber &operator--() { --value_; return *this; }
│ │ │ │ -
177
│ │ │ │ -
178 template<class U = T, class = std::void_t<decltype(std::declval<U&>()++)> >
│ │ │ │ -
179 decltype(auto) operator++(int) { return aligned<align>(value_++); }
│ │ │ │ -
180
│ │ │ │ -
181 template<class U = T, class = std::void_t<decltype(std::declval<U&>()--)> >
│ │ │ │ -
182 decltype(auto) operator--(int) { return aligned<align>(value_--); }
│ │ │ │ -
183
│ │ │ │ -
184 // unary operators
│ │ │ │ -
185 template<class U = T,
│ │ │ │ -
186 class = std::void_t<decltype(+std::declval<const U&>())> >
│ │ │ │ -
187 decltype(auto) operator+() const { return aligned<align>(+value_); }
│ │ │ │ -
188
│ │ │ │ -
189 template<class U = T,
│ │ │ │ -
190 class = std::void_t<decltype(-std::declval<const U&>())> >
│ │ │ │ -
191 decltype(auto) operator-() const { return aligned<align>(-value_); }
│ │ │ │ -
192
│ │ │ │ -
193 /*
│ │ │ │ -
194 * silence warnings from GCC about using `~` on a bool
│ │ │ │ -
195 * (when instantiated for T=bool)
│ │ │ │ -
196 */
│ │ │ │ -
197#if __GNUC__ >= 7
│ │ │ │ -
198# pragma GCC diagnostic push
│ │ │ │ -
199# pragma GCC diagnostic ignored "-Wbool-operation"
│ │ │ │ -
200#endif
│ │ │ │ -
201#ifdef __clang__
│ │ │ │ -
202# pragma clang diagnostic push
│ │ │ │ -
203# pragma clang diagnostic ignored "-Wbool-operation"
│ │ │ │ -
204#endif
│ │ │ │ -
205 template<class U = T,
│ │ │ │ -
206 class = std::void_t<decltype(~std::declval<const U&>())> >
│ │ │ │ -
207 decltype(auto) operator~() const { return aligned<align>(~value_); }
│ │ │ │ -
208#if __GNUC__ >= 7
│ │ │ │ -
209# pragma GCC diagnostic pop
│ │ │ │ -
210#endif
│ │ │ │ -
211#ifdef __clang__
│ │ │ │ -
212# pragma clang diagnostic pop
│ │ │ │ -
213#endif
│ │ │ │ -
214
│ │ │ │ -
215 template<class U = T,
│ │ │ │ -
216 class = std::void_t<decltype(!std::declval<const U&>())> >
│ │ │ │ -
217 decltype(auto) operator!() const { return aligned<align>(!value_); }
│ │ │ │ -
218
│ │ │ │ -
219 // assignment operators
│ │ │ │ -
│ │ │ │ -
220#define DUNE_ASSIGN_OP(OP) \
│ │ │ │ -
221 template<class U, std::size_t uAlign, \
│ │ │ │ -
222 class = std::enable_if_t< \
│ │ │ │ -
223 ( uAlign <= align && \
│ │ │ │ -
224 sizeof(std::declval<T&>() OP std::declval<U>()) ) \
│ │ │ │ -
225 > > \
│ │ │ │ -
226 AlignedNumber &operator OP(const AlignedNumber<U, uAlign> &u) \
│ │ │ │ -
227 { \
│ │ │ │ -
228 value_ OP U(u); \
│ │ │ │ -
229 return *this; \
│ │ │ │ -
230 } \
│ │ │ │ -
231 \
│ │ │ │ -
232 template<class U, \
│ │ │ │ -
233 class = std::void_t<decltype(std::declval<T&>() OP \
│ │ │ │ -
234 std::declval<U>())> > \
│ │ │ │ -
235 AlignedNumber &operator OP(const U &u) \
│ │ │ │ -
236 { \
│ │ │ │ -
237 value_ OP u; \
│ │ │ │ -
238 return *this; \
│ │ │ │ -
239 } \
│ │ │ │ -
240 \
│ │ │ │ -
241 static_assert(true, "Require semicolon to unconfuse editors")
│ │ │ │ -
│ │ │ │ -
242
│ │ │ │ - │ │ │ │ - │ │ │ │ -
245
│ │ │ │ - │ │ │ │ -
247 DUNE_ASSIGN_OP(/=);
│ │ │ │ -
248 DUNE_ASSIGN_OP(%=);
│ │ │ │ -
249
│ │ │ │ - │ │ │ │ -
251 DUNE_ASSIGN_OP(&=);
│ │ │ │ -
252 DUNE_ASSIGN_OP(|=);
│ │ │ │ -
253
│ │ │ │ - │ │ │ │ - │ │ │ │ -
256
│ │ │ │ -
257#undef DUNE_ASSIGN_OP
│ │ │ │ -
258 };
│ │ │ │ -
│ │ │ │ -
259
│ │ │ │ -
260 // binary operators
│ │ │ │ -
│ │ │ │ -
261#define DUNE_BINARY_OP(OP) \
│ │ │ │ -
262 template<class T, std::size_t tAlign, class U, std::size_t uAlign, \
│ │ │ │ -
263 class = std::void_t<decltype(std::declval<T>() \
│ │ │ │ -
264 OP std::declval<U>())> > \
│ │ │ │ -
265 decltype(auto) \
│ │ │ │ -
266 operator OP(const AlignedNumber<T, tAlign> &t, \
│ │ │ │ -
267 const AlignedNumber<U, uAlign> &u) \
│ │ │ │ -
268 { \
│ │ │ │ -
269 /* can't use std::max(); not constexpr */ \
│ │ │ │ -
270 return aligned<(tAlign > uAlign ? tAlign : uAlign)>(T(t) OP U(u)); \
│ │ │ │ -
271 } \
│ │ │ │ -
272 \
│ │ │ │ -
273 template<class T, class U, std::size_t uAlign, \
│ │ │ │ -
274 class = std::void_t<decltype(std::declval<T>() \
│ │ │ │ -
275 OP std::declval<U>())> > \
│ │ │ │ -
276 decltype(auto) \
│ │ │ │ -
277 operator OP(const T &t, const AlignedNumber<U, uAlign> &u) \
│ │ │ │ -
278 { \
│ │ │ │ -
279 return aligned<uAlign>(t OP U(u)); \
│ │ │ │ -
280 } \
│ │ │ │ -
281 \
│ │ │ │ -
282 template<class T, std::size_t tAlign, class U, \
│ │ │ │ -
283 class = std::void_t<decltype(std::declval<T>() \
│ │ │ │ -
284 OP std::declval<U>())> > \
│ │ │ │ -
285 decltype(auto) \
│ │ │ │ -
286 operator OP(const AlignedNumber<T, tAlign> &t, const U &u) \
│ │ │ │ -
287 { \
│ │ │ │ -
288 return aligned<tAlign>(T(t) OP u); \
│ │ │ │ -
289 } \
│ │ │ │ -
290 \
│ │ │ │ -
291 static_assert(true, "Require semicolon to unconfuse editors")
│ │ │ │ -
│ │ │ │ -
292
│ │ │ │ - │ │ │ │ - │ │ │ │ -
295
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
299
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
303
│ │ │ │ - │ │ │ │ - │ │ │ │ -
306
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
313
│ │ │ │ - │ │ │ │ -
315 DUNE_BINARY_OP(||);
│ │ │ │ -
316
│ │ │ │ -
317#undef DUNE_BINARY_OP
│ │ │ │ -
318
│ │ │ │ -
320 //
│ │ │ │ -
321 // Overloads for the functions provided by the standard library
│ │ │ │ -
322 //
│ │ │ │ -
323#define DUNE_UNARY_FUNC(name) \
│ │ │ │ -
324 template<class T, std::size_t align> \
│ │ │ │ -
325 decltype(auto) name(const AlignedNumber<T, align> &u) \
│ │ │ │ -
326 { \
│ │ │ │ -
327 using std::name; \
│ │ │ │ -
328 return aligned<align>(name(T(u))); \
│ │ │ │ -
329 } \
│ │ │ │ -
330 static_assert(true, "Require semicolon to unconfuse editors")
│ │ │ │ -
331
│ │ │ │ -
332 //
│ │ │ │ -
333 // <cmath> functions
│ │ │ │ -
334 //
│ │ │ │ -
335
│ │ │ │ -
336 // note: only unary functions are provided at the moment. Getting all the
│ │ │ │ -
337 // overloads right for functions with more than one argument is tricky.
│ │ │ │ -
338 // All <cmath> functions appear in the list below in the order they are
│ │ │ │ -
339 // listed in in the standard, but the unimplemented ones are commented
│ │ │ │ -
340 // out.
│ │ │ │ -
341
│ │ │ │ -
342 // note: abs is provided by both <cstdlib> (for integer) and <cmath> (for
│ │ │ │ -
343 // floating point). This overload works for both.
│ │ │ │ -
344 DUNE_UNARY_FUNC(abs);
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
350 // atan2
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
354 // copysign
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
363 // fdim
│ │ │ │ - │ │ │ │ -
365 // fma
│ │ │ │ -
366 // fmax
│ │ │ │ -
367 // fmin
│ │ │ │ -
368 // fmod
│ │ │ │ -
369 // frexp
│ │ │ │ -
370 // hypos
│ │ │ │ - │ │ │ │ -
372 // ldexp
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
383 // modf
│ │ │ │ -
384 DUNE_UNARY_FUNC(nearbyint);
│ │ │ │ -
385 // nextafter
│ │ │ │ -
386 // nexttoward
│ │ │ │ -
387 // pow
│ │ │ │ -
388 // remainder
│ │ │ │ -
389 // remquo
│ │ │ │ - │ │ │ │ - │ │ │ │ -
392 // scalbln
│ │ │ │ -
393 // scalbn
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
401
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
407
│ │ │ │ -
408 // isgreater
│ │ │ │ -
409 // isgreaterequal
│ │ │ │ -
410 // isless
│ │ │ │ -
411 // islessequal
│ │ │ │ -
412 // islessgreater
│ │ │ │ -
413 // isunordered
│ │ │ │ -
414
│ │ │ │ -
415 //
│ │ │ │ -
416 // <complex> functions
│ │ │ │ -
417 //
│ │ │ │ -
418
│ │ │ │ -
419 // not all functions are implemented, and unlike for <cmath>, no
│ │ │ │ -
420 // comprehensive list is provided
│ │ │ │ - │ │ │ │ -
422
│ │ │ │ -
423#undef DUNE_UNARY_FUNC
│ │ │ │ -
424
│ │ │ │ -
425 // We need to overload min() and max() since they require types to be
│ │ │ │ -
426 // LessThanComparable, which requires `a<b` to be "convertible to bool".
│ │ │ │ -
427 // That wording seems to be a leftover from C++03, and today is probably
│ │ │ │ -
428 // equivalent to "implicitly convertible". There is also issue 2114
│ │ │ │ -
429 // <https://cplusplus.github.io/LWG/issue2114> in the standard (still open
│ │ │ │ -
430 // as of 2018-07-06), which strives to require both "implicitly" and
│ │ │ │ -
431 // "contextually" convertible -- plus a few other things.
│ │ │ │ -
432 //
│ │ │ │ -
433 // We do not want our debug type to automatically decay to the underlying
│ │ │ │ -
434 // type, so we do not want to make the conversion non-explicit. So the
│ │ │ │ -
435 // only option left is to overload min() and max().
│ │ │ │ -
436
│ │ │ │ -
437 template<class T, std::size_t align>
│ │ │ │ -
│ │ │ │ -
438 auto max(const AlignedNumber<T, align> &a,
│ │ │ │ - │ │ │ │ -
440 {
│ │ │ │ -
441 using std::max;
│ │ │ │ -
442 return aligned<align>(max(T(a), T(b)));
│ │ │ │ -
443 }
│ │ │ │ -
│ │ │ │ -
444
│ │ │ │ -
445 template<class T, std::size_t align>
│ │ │ │ -
│ │ │ │ -
446 auto max(const T &a, const AlignedNumber<T, align> &b)
│ │ │ │ -
447 {
│ │ │ │ -
448 using std::max;
│ │ │ │ -
449 return aligned<align>(max(a, T(b)));
│ │ │ │ -
450 }
│ │ │ │ -
│ │ │ │ -
451
│ │ │ │ -
452 template<class T, std::size_t align>
│ │ │ │ -
│ │ │ │ -
453 auto max(const AlignedNumber<T, align> &a, const T &b)
│ │ │ │ -
454 {
│ │ │ │ -
455 using std::max;
│ │ │ │ -
456 return aligned<align>(max(T(a), b));
│ │ │ │ -
457 }
│ │ │ │ -
│ │ │ │ -
458
│ │ │ │ -
459 template<class T, std::size_t align>
│ │ │ │ -
│ │ │ │ -
460 auto min(const AlignedNumber<T, align> &a,
│ │ │ │ - │ │ │ │ -
462 {
│ │ │ │ -
463 using std::min;
│ │ │ │ -
464 return aligned<align>(min(T(a), T(b)));
│ │ │ │ -
465 }
│ │ │ │ -
│ │ │ │ -
466
│ │ │ │ -
467 template<class T, std::size_t align>
│ │ │ │ -
│ │ │ │ -
468 auto min(const T &a, const AlignedNumber<T, align> &b)
│ │ │ │ -
469 {
│ │ │ │ -
470 using std::min;
│ │ │ │ -
471 return aligned<align>(min(a, T(b)));
│ │ │ │ -
472 }
│ │ │ │ -
│ │ │ │ -
473
│ │ │ │ -
474 template<class T, std::size_t align>
│ │ │ │ -
│ │ │ │ -
475 auto min(const AlignedNumber<T, align> &a, const T &b)
│ │ │ │ -
476 {
│ │ │ │ -
477 using std::min;
│ │ │ │ -
478 return aligned<align>(min(T(a), b));
│ │ │ │ -
479 }
│ │ │ │ -
│ │ │ │ -
480
│ │ │ │ -
481 } // namespace AlignedNumberImpl
│ │ │ │ -
482
│ │ │ │ -
483 // SIMD-like functions from "conditional.hh"
│ │ │ │ -
484 template<class T, std::size_t align>
│ │ │ │ -
485 AlignedNumber<T, align>
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ -
488 {
│ │ │ │ -
489 return b ? v1 : v2;
│ │ │ │ -
490 }
│ │ │ │ -
│ │ │ │ -
491
│ │ │ │ -
492 // SIMD-like functions from "rangeutilities.hh"
│ │ │ │ -
493 template<class T, std::size_t align>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
495 {
│ │ │ │ -
496 return T(val);
│ │ │ │ -
497 }
│ │ │ │ -
│ │ │ │ -
498
│ │ │ │ -
499 template<class T, std::size_t align>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
501 {
│ │ │ │ -
502 return T(val);
│ │ │ │ -
503 }
│ │ │ │ -
│ │ │ │ -
504
│ │ │ │ -
505 template<std::size_t align>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
507 {
│ │ │ │ -
508 return bool(val);
│ │ │ │ -
509 }
│ │ │ │ -
│ │ │ │ -
510
│ │ │ │ -
511 template<std::size_t align>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
513 {
│ │ │ │ -
514 return bool(val);
│ │ │ │ -
515 }
│ │ │ │ -
│ │ │ │ -
516
│ │ │ │ -
517 // SIMD-like functionality from "simd/interface.hh"
│ │ │ │ -
│ │ │ │ -
518 namespace Simd {
│ │ │ │ -
│ │ │ │ -
519 namespace Overloads {
│ │ │ │ -
520
│ │ │ │ -
521 template<class T, std::size_t align>
│ │ │ │ - │ │ │ │ -
523
│ │ │ │ -
524 template<class U, class T, std::size_t align>
│ │ │ │ -
│ │ │ │ -
525 struct RebindType<U, AlignedNumber<T, align> > {
│ │ │ │ - │ │ │ │ -
527 };
│ │ │ │ -
│ │ │ │ -
528
│ │ │ │ -
529 template<class T, std::size_t align>
│ │ │ │ -
530 struct LaneCount<AlignedNumber<T, align> > : index_constant<1> {};
│ │ │ │ -
531
│ │ │ │ -
532 template<class T, std::size_t align>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
534 {
│ │ │ │ -
535 assert(l == 0);
│ │ │ │ -
536 return v.value();
│ │ │ │ -
537 }
│ │ │ │ -
│ │ │ │ -
538
│ │ │ │ -
539 template<class T, std::size_t align>
│ │ │ │ -
│ │ │ │ -
540 T lane(ADLTag<5>, std::size_t l, const AlignedNumber<T, align> &v)
│ │ │ │ -
541 {
│ │ │ │ -
542 assert(l == 0);
│ │ │ │ -
543 return v.value();
│ │ │ │ -
544 }
│ │ │ │ -
│ │ │ │ -
545
│ │ │ │ -
546 template<class T, std::size_t align>
│ │ │ │ - │ │ │ │ -
│ │ │ │ - │ │ │ │ -
549 const AlignedNumber<T, align> &ifTrue,
│ │ │ │ -
550 const AlignedNumber<T, align> &ifFalse)
│ │ │ │ -
551 {
│ │ │ │ -
552 return mask ? ifTrue : ifFalse;
│ │ │ │ -
553 }
│ │ │ │ -
│ │ │ │ -
554
│ │ │ │ -
555 template<std::size_t align>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
557 {
│ │ │ │ -
558 return bool(mask);
│ │ │ │ -
559 }
│ │ │ │ -
│ │ │ │ -
560
│ │ │ │ -
561 } // namespace Overloads
│ │ │ │ -
│ │ │ │ -
562
│ │ │ │ -
563 } // namespace Simd
│ │ │ │ -
│ │ │ │ -
564
│ │ │ │ -
565} // namespace Dune
│ │ │ │ -
566
│ │ │ │ -
567#endif // DUNE_DEBUGALIGN_HH
│ │ │ │ -
Default implementations for SIMD Implementations.
│ │ │ │ -
Basic definitions for SIMD Implementations.
│ │ │ │ -
A free function to provide the demangled class name of a given object or type as a string.
│ │ │ │ -
#define DUNE_BINARY_OP(OP)
Definition debugalign.hh:261
│ │ │ │ -
#define DUNE_UNARY_FUNC(name)
│ │ │ │ -
#define DUNE_ASSIGN_OP(OP)
Definition debugalign.hh:220
│ │ │ │ - │ │ │ │ -
Traits for type conversions and type information.
│ │ │ │ -
std::integral_constant< std::size_t, i > index_constant
An index constant with value i.
Definition indices.hh:29
│ │ │ │ -
std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x)
Definition bigunsignedint.hh:278
│ │ │ │ -
Mask< V > mask(ADLTag< 0, std::is_same< V, Mask< V > >::value >, const V &v)
implements Simd::mask()
Definition defaults.hh:153
│ │ │ │ +
155
│ │ │ │ +
156
│ │ │ │ +
157} // end namespace Dune
│ │ │ │ +
158
│ │ │ │ +
159#endif // DUNE_COMMON_OVERLOADSET_HH
│ │ │ │ +
Traits for type conversions and type information.
│ │ │ │ +
auto orderedOverload(F &&... f)
Create an ordered overload set.
Definition overloadset.hh:150
│ │ │ │ +
auto overload(F &&... f)
Create an overload set.
Definition overloadset.hh:61
│ │ │ │
STL namespace.
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
void violatedAlignment(const char *className, std::size_t expectedAlignment, const void *address)
called when an alignment violation is detected
Definition debugalign.cc:36
│ │ │ │ -
bool any_true(const AlignedNumber< bool, align > &val)
Definition debugalign.hh:506
│ │ │ │ -
bool all_true(const AlignedNumber< bool, align > &val)
Definition debugalign.hh:512
│ │ │ │ -
std::string className()
Provide the demangled class name of a type T as a string.
Definition classname.hh:47
│ │ │ │ -
static constexpr auto debugAlignment
an alignment large enough to trigger alignment errors
Definition debugalign.hh:97
│ │ │ │ -
const T1 cond(bool b, const T1 &v1, const T2 &v2)
conditional evaluate
Definition conditional.hh:28
│ │ │ │ -
AlignedNumber< T, align > aligned(T value)
align a value to a certain alignment
Definition debugalign.hh:114
│ │ │ │ -
ViolatedAlignmentHandler & violatedAlignmentHandler()
access the handler called by violatedAlignment()
Definition debugalign.cc:30
│ │ │ │ -
bool isAligned(const void *p, std::size_t align)
check whether an address conforms to the given alignment
Definition debugalign.hh:56
│ │ │ │ -
T max_value(const AlignedNumber< T, align > &val)
Definition debugalign.hh:494
│ │ │ │ -
std::function< void(const char *, std::size_t, const void *)> ViolatedAlignmentHandler
type of the handler called by violatedAlignment()
Definition debugalign.hh:31
│ │ │ │ -
T min_value(const AlignedNumber< T, align > &val)
Definition debugalign.hh:500
│ │ │ │ -
bool anyTrue(ADLTag< 5 >, const AlignedNumber< bool, align > &mask)
Definition debugalign.hh:556
│ │ │ │ -
T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v)
Definition debugalign.hh:533
│ │ │ │ -
Whether this type acts as a scalar in the context of (hierarchically blocked) containers.
Definition typetraits.hh:194
│ │ │ │ -
CRTP base mixin class to check alignment.
Definition debugalign.hh:66
│ │ │ │ -
aligned wrappers for arithmetic types
Definition debugalign.hh:128
│ │ │ │ - │ │ │ │ - │ │ │ │ -
decltype(auto) operator+() const
Definition debugalign.hh:187
│ │ │ │ - │ │ │ │ -
decltype(auto) operator--(int)
Definition debugalign.hh:182
│ │ │ │ -
DUNE_ASSIGN_OP * DUNE_ASSIGN_OP(/=);DUNE_ASSIGN_OP(%=
│ │ │ │ -
decltype(auto) operator++(int)
Definition debugalign.hh:179
│ │ │ │ -
decltype(auto) operator!() const
Definition debugalign.hh:217
│ │ │ │ -
T & value()
Definition debugalign.hh:145
│ │ │ │ -
const T & value() const
Definition debugalign.hh:144
│ │ │ │ -
DUNE_ASSIGN_OP^ DUNE_ASSIGN_OP(&=);DUNE_ASSIGN_OP(|=
│ │ │ │ -
friend std::basic_istream< charT, Traits > & operator>>(std::basic_istream< charT, Traits > &str, AlignedNumber &u)
Definition debugalign.hh:150
│ │ │ │ - │ │ │ │ - │ │ │ │ -
decltype(auto) operator~() const
Definition debugalign.hh:207
│ │ │ │ -
AlignedNumber(T value)
Definition debugalign.hh:133
│ │ │ │ -
AlignedNumber(const AlignedNumber< U, uAlign > &o)
Definition debugalign.hh:137
│ │ │ │ -
decltype(auto) operator-() const
Definition debugalign.hh:191
│ │ │ │ - │ │ │ │ -
Tag used to force late-binding lookup in Dune::Simd::Overloads.
Definition base.hh:182
│ │ │ │ -
should have a member type type
Definition standard.hh:60
│ │ │ │ -
should have a member type type
Definition standard.hh:67
│ │ │ │ -
should be derived from a Dune::index_constant
Definition standard.hh:74
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,701 +1,139 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -debugalign.hh │ │ │ │ │ +overloadset.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_DEBUGALIGN_HH │ │ │ │ │ -6#define DUNE_DEBUGALIGN_HH │ │ │ │ │ +5#ifndef DUNE_COMMON_OVERLOADSET_HH │ │ │ │ │ +6#define DUNE_COMMON_OVERLOADSET_HH │ │ │ │ │ 7 │ │ │ │ │ -8#include │ │ │ │ │ -9#include │ │ │ │ │ -10#include │ │ │ │ │ -11#include │ │ │ │ │ -12#include │ │ │ │ │ -13#include │ │ │ │ │ -14#include // abs │ │ │ │ │ -15#include │ │ │ │ │ -16#include │ │ │ │ │ -17#include │ │ │ │ │ -18#include │ │ │ │ │ -19#include │ │ │ │ │ +8#include │ │ │ │ │ +9#include │ │ │ │ │ +10#include │ │ │ │ │ +11 │ │ │ │ │ +12namespace Dune { │ │ │ │ │ +13 │ │ │ │ │ +14namespace Impl { │ │ │ │ │ +15 │ │ │ │ │ +16 template │ │ │ │ │ +17 class OverloadSet │ │ │ │ │ +18 : public F... │ │ │ │ │ +19 { │ │ │ │ │ 20 │ │ │ │ │ -21#include │ │ │ │ │ -22#include │ │ │ │ │ -23#include │ │ │ │ │ -24#include │ │ │ │ │ -25#include │ │ │ │ │ -26 │ │ │ │ │ -27namespace Dune { │ │ │ │ │ -28 │ │ │ │ │ -30 using ViolatedAlignmentHandler = │ │ │ │ │ -31 std::function; │ │ │ │ │ -32 │ │ │ │ │ +21 public: │ │ │ │ │ +22 │ │ │ │ │ +23 template │ │ │ │ │ +24 OverloadSet(FF&&... ff) │ │ │ │ │ +25 : F(std::forward(ff))... │ │ │ │ │ +26 {} │ │ │ │ │ +27 │ │ │ │ │ +28 using F::operator()...; │ │ │ │ │ +29 │ │ │ │ │ +30 }; │ │ │ │ │ +31 │ │ │ │ │ +32} // end namespace Impl │ │ │ │ │ +33 │ │ │ │ │ 34 │ │ │ │ │ -40 ViolatedAlignmentHandler &violatedAlignmentHandler(); │ │ │ │ │ -41 │ │ │ │ │ -43 │ │ │ │ │ -52 void violatedAlignment(const char *className, std::size_t expectedAlignment, │ │ │ │ │ -53 const void *address); │ │ │ │ │ -54 │ │ │ │ │ -56 inline bool isAligned(const void *p, std::size_t align) │ │ │ │ │ -57 { │ │ │ │ │ -58 void* aligned_p = (void*)p; │ │ │ │ │ -59 std::size_t space = align*2; │ │ │ │ │ -60 return p == std::align(align, align, aligned_p, space); │ │ │ │ │ -61 } │ │ │ │ │ -62 │ │ │ │ │ -64 template │ │ │ │ │ -65 struct alignas(align) AlignedBase │ │ │ │ │ -66 { │ │ │ │ │ -75 static void* operator new(std::size_t count, void* ptr) { │ │ │ │ │ -76 if(!isAligned(ptr, align)) │ │ │ │ │ -77 violatedAlignment(className().c_str(), align, ptr); │ │ │ │ │ -78 return ::operator new(count*sizeof(Impl), ptr); │ │ │ │ │ -79 } │ │ │ │ │ -80 │ │ │ │ │ -89 static void* operator new[](std::size_t count, void* ptr) { │ │ │ │ │ -90 if(!isAligned(ptr, align)) │ │ │ │ │ -91 violatedAlignment(className().c_str(), align, ptr); │ │ │ │ │ -92 return ::operator new[](count*sizeof(Impl), ptr); │ │ │ │ │ -93 } │ │ │ │ │ -94 }; │ │ │ │ │ -95 │ │ │ │ │ -97 static constexpr auto debugAlignment = 2*alignof(std::max_align_t); │ │ │ │ │ -98 │ │ │ │ │ -99 namespace AlignedNumberImpl { │ │ │ │ │ -100 │ │ │ │ │ -101 template │ │ │ │ │ -102 class AlignedNumber; │ │ │ │ │ -103 │ │ │ │ │ -104 } // namespace AlignedNumberImpl │ │ │ │ │ -105 │ │ │ │ │ -106 using AlignedNumberImpl::AlignedNumber; │ │ │ │ │ -107 │ │ │ │ │ -108 template │ │ │ │ │ -109 struct IsNumber> │ │ │ │ │ -110 : public std::true_type {}; │ │ │ │ │ +35 │ │ │ │ │ +60template │ │ │ │ │ +61auto overload(F&&... f) │ │ │ │ │ +62{ │ │ │ │ │ +63 return Impl::OverloadSet...>(std::forward(f)...); │ │ │ │ │ +64} │ │ │ │ │ +65 │ │ │ │ │ +66 │ │ │ │ │ +67 │ │ │ │ │ +68namespace Impl { │ │ │ │ │ +69 │ │ │ │ │ +70 template │ │ │ │ │ +71 class OrderedOverloadSet: public OrderedOverloadSet, F0 │ │ │ │ │ +72 { │ │ │ │ │ +73 using Base = OrderedOverloadSet; │ │ │ │ │ +74 public: │ │ │ │ │ +75 │ │ │ │ │ +76 template │ │ │ │ │ +77 OrderedOverloadSet(FF0&& f0, FF&&... ff) : │ │ │ │ │ +78 Base(std::forward(ff)...), │ │ │ │ │ +79 F0(std::forward(f0)) │ │ │ │ │ +80 {} │ │ │ │ │ +81 │ │ │ │ │ +82 // Forward to operator() of F0 if it can be called with the given arguments. │ │ │ │ │ +83 template::value, int> = 0> │ │ │ │ │ +85 decltype(auto) operator()(Args&&... args) │ │ │ │ │ +86 { │ │ │ │ │ +87 return F0::operator()(std::forward(args)...); │ │ │ │ │ +88 } │ │ │ │ │ +89 │ │ │ │ │ +90 // Forward to operator() of base class if F0 cannot be called with the given │ │ │ │ │ +91 // arguments. In this case the base class will successively try operator() │ │ │ │ │ +92 // of all F... . │ │ │ │ │ +93 template::value, int> = 0> │ │ │ │ │ +95 decltype(auto) operator()(Args&&... args) │ │ │ │ │ +96 { │ │ │ │ │ +97 return Base::operator()(std::forward(args)...); │ │ │ │ │ +98 } │ │ │ │ │ +99 │ │ │ │ │ +100 }; │ │ │ │ │ +101 │ │ │ │ │ +102 template │ │ │ │ │ +103 class OrderedOverloadSet: public F0 │ │ │ │ │ +104 { │ │ │ │ │ +105 public: │ │ │ │ │ +106 │ │ │ │ │ +107 template │ │ │ │ │ +108 OrderedOverloadSet(FF0&& f0) : │ │ │ │ │ +109 F0(std::forward(f0)) │ │ │ │ │ +110 {} │ │ │ │ │ 111 │ │ │ │ │ -113 template │ │ │ │ │ -114 AlignedNumber aligned(T value) { return { std::move(value) }; } │ │ │ │ │ -115 │ │ │ │ │ -116 // The purpose of this namespace is to move the `` function │ │ │ │ │ -overloads │ │ │ │ │ -117 // out of namespace `Dune`. This avoids problems where people called │ │ │ │ │ -118 // e.g. `sqrt(1.0)` inside the `Dune` namespace, without first doing `using │ │ │ │ │ -119 // std::sqrt;`. Without any `Dune::sqrt()`, such a use will find │ │ │ │ │ -120 // `::sqrt()`, but with `Dune::sqrt()` it will find only `Dune::sqrt()`, │ │ │ │ │ -121 // which does not have an overload for `double`. │ │ │ │ │ -122 namespace AlignedNumberImpl { │ │ │ │ │ -123 │ │ │ │ │ -125 template │ │ │ │ │ -126 class AlignedNumber │ │ │ │ │ -127 : public AlignedBase > │ │ │ │ │ -128 { │ │ │ │ │ -129 T value_; │ │ │ │ │ -130 │ │ │ │ │ -131 public: │ │ │ │ │ -132 AlignedNumber() = default; │ │ │ │ │ -133 AlignedNumber(T value) : value_(std::move(value)) {} │ │ │ │ │ -134 template= uAlign) && │ │ │ │ │ -136 std::is_convertible::value> > │ │ │ │ │ -137 AlignedNumber(const AlignedNumber &o) : value_(U(o)) {} │ │ │ │ │ -138 │ │ │ │ │ -139 // accessors │ │ │ │ │ -140 template::value> > │ │ │ │ │ -142 explicit operator U() const { return value_; } │ │ │ │ │ -143 │ │ │ │ │ -144 const T &value() const { return value_; } │ │ │ │ │ -145 T &value() { return value_; } │ │ │ │ │ -146 │ │ │ │ │ -147 // I/O │ │ │ │ │ -148 template │ │ │ │ │ -149 friend std::basic_istream& │ │ │ │ │ -150 operator>>(std::basic_istream& str, AlignedNumber &u) │ │ │ │ │ -151 { │ │ │ │ │ -152 return str >> u.value_; │ │ │ │ │ -153 } │ │ │ │ │ +112 // Forward to operator() of F0. If it cannot be called with │ │ │ │ │ +113 // the given arguments a static assertion will fail. │ │ │ │ │ +114 template │ │ │ │ │ +115 decltype(auto) operator()(Args&&... args) │ │ │ │ │ +116 { │ │ │ │ │ +117 static_assert(IsCallable::value, │ │ │ │ │ +118 "No matching overload found in OrderedOverloadSet"); │ │ │ │ │ +119 return F0::operator()(std::forward(args)...); │ │ │ │ │ +120 } │ │ │ │ │ +121 }; │ │ │ │ │ +122 │ │ │ │ │ +123} // end namespace Impl │ │ │ │ │ +124 │ │ │ │ │ +125 │ │ │ │ │ +126 │ │ │ │ │ +149template │ │ │ │ │ +150auto orderedOverload(F&&... f) │ │ │ │ │ +151{ │ │ │ │ │ +152 return Impl::OrderedOverloadSet...>(std::forward(f)...); │ │ │ │ │ +153} │ │ │ │ │ 154 │ │ │ │ │ -155 template │ │ │ │ │ -156 friend std::basic_ostream& │ │ │ │ │ -157 operator<<(std::basic_ostream& str, │ │ │ │ │ -158 const AlignedNumber &u) │ │ │ │ │ -159 { │ │ │ │ │ -160 return str << u.value_; │ │ │ │ │ -161 } │ │ │ │ │ -162 │ │ │ │ │ -163 // The trick with `template >` is │ │ │ │ │ -164 // needed because at least g++-4.9 seems to evaluates a default argument │ │ │ │ │ -165 // in `template >` as soon as possible and │ │ │ │ │ -will │ │ │ │ │ -166 // error out if `expr(T)` is invalid. E.g. for `expr(T)` = │ │ │ │ │ -167 // `decltype(--std::declval())`, instantiating `AlignedNumber` │ │ │ │ │ -168 // will result in an unrecoverable error (`--` cannot be applied to a │ │ │ │ │ -169 // `bool`). │ │ │ │ │ -170 │ │ │ │ │ -171 // Increment, decrement │ │ │ │ │ -172 template())> > │ │ │ │ │ -173 AlignedNumber &operator++() { ++value_; return *this; } │ │ │ │ │ -174 │ │ │ │ │ -175 template())> > │ │ │ │ │ -176 AlignedNumber &operator--() { --value_; return *this; } │ │ │ │ │ -177 │ │ │ │ │ -178 template()++)> > │ │ │ │ │ -179 decltype(auto) operator++(int) { return aligned(value_++); } │ │ │ │ │ -180 │ │ │ │ │ -181 template()--)> > │ │ │ │ │ -182 decltype(auto) operator--(int) { return aligned(value_--); } │ │ │ │ │ -183 │ │ │ │ │ -184 // unary operators │ │ │ │ │ -185 template())> > │ │ │ │ │ -187 decltype(auto) operator+() const { return aligned(+value_); } │ │ │ │ │ -188 │ │ │ │ │ -189 template())> > │ │ │ │ │ -191 decltype(auto) operator-() const { return aligned(-value_); } │ │ │ │ │ -192 │ │ │ │ │ -193 /* │ │ │ │ │ -194 * silence warnings from GCC about using `~` on a bool │ │ │ │ │ -195 * (when instantiated for T=bool) │ │ │ │ │ -196 */ │ │ │ │ │ -197#if __GNUC__ >= 7 │ │ │ │ │ -198# pragma GCC diagnostic push │ │ │ │ │ -199# pragma GCC diagnostic ignored "-Wbool-operation" │ │ │ │ │ -200#endif │ │ │ │ │ -201#ifdef __clang__ │ │ │ │ │ -202# pragma clang diagnostic push │ │ │ │ │ -203# pragma clang diagnostic ignored "-Wbool-operation" │ │ │ │ │ -204#endif │ │ │ │ │ -205 template())> > │ │ │ │ │ -207 decltype(auto) operator~() const { return aligned(~value_); } │ │ │ │ │ -208#if __GNUC__ >= 7 │ │ │ │ │ -209# pragma GCC diagnostic pop │ │ │ │ │ -210#endif │ │ │ │ │ -211#ifdef __clang__ │ │ │ │ │ -212# pragma clang diagnostic pop │ │ │ │ │ -213#endif │ │ │ │ │ -214 │ │ │ │ │ -215 template())> > │ │ │ │ │ -217 decltype(auto) operator!() const { return aligned(!value_); } │ │ │ │ │ -218 │ │ │ │ │ -219 // assignment operators │ │ │ │ │ -220#define DUNE_ASSIGN_OP(OP) \ │ │ │ │ │ -221 template() OP std::declval()) ) \ │ │ │ │ │ -225 > > \ │ │ │ │ │ -226 AlignedNumber &operator OP(const AlignedNumber &u) \ │ │ │ │ │ -227 { \ │ │ │ │ │ -228 value_ OP U(u); \ │ │ │ │ │ -229 return *this; \ │ │ │ │ │ -230 } \ │ │ │ │ │ -231 \ │ │ │ │ │ -232 template() OP \ │ │ │ │ │ -234 std::declval())> > \ │ │ │ │ │ -235 AlignedNumber &operator OP(const U &u) \ │ │ │ │ │ -236 { \ │ │ │ │ │ -237 value_ OP u; \ │ │ │ │ │ -238 return *this; \ │ │ │ │ │ -239 } \ │ │ │ │ │ -240 \ │ │ │ │ │ -241 static_assert(true, "Require semicolon to unconfuse editors") │ │ │ │ │ -242 │ │ │ │ │ -243 DUNE_ASSIGN_OP(+=); │ │ │ │ │ -244 DUNE_ASSIGN_OP(-=); │ │ │ │ │ -245 │ │ │ │ │ -246 DUNE_ASSIGN_OP(*=); │ │ │ │ │ -247 DUNE_ASSIGN_OP(/=); │ │ │ │ │ -248 DUNE_ASSIGN_OP(%=); │ │ │ │ │ -249 │ │ │ │ │ -250 DUNE_ASSIGN_OP(^=); │ │ │ │ │ -251 DUNE_ASSIGN_OP(&=); │ │ │ │ │ -252 DUNE_ASSIGN_OP(|=); │ │ │ │ │ -253 │ │ │ │ │ -254 DUNE_ASSIGN_OP(<<=); │ │ │ │ │ -255 DUNE_ASSIGN_OP(>>=); │ │ │ │ │ -256 │ │ │ │ │ -257#undef DUNE_ASSIGN_OP │ │ │ │ │ -258 }; │ │ │ │ │ -259 │ │ │ │ │ -260 // binary operators │ │ │ │ │ -261#define DUNE_BINARY_OP(OP) \ │ │ │ │ │ -262 template() \ │ │ │ │ │ -264 OP std::declval())> > \ │ │ │ │ │ -265 decltype(auto) \ │ │ │ │ │ -266 operator OP(const AlignedNumber &t, \ │ │ │ │ │ -267 const AlignedNumber &u) \ │ │ │ │ │ -268 { \ │ │ │ │ │ -269 /* can't use std::max(); not constexpr */ \ │ │ │ │ │ -270 return aligned<(tAlign > uAlign ? tAlign : uAlign)>(T(t) OP U(u)); \ │ │ │ │ │ -271 } \ │ │ │ │ │ -272 \ │ │ │ │ │ -273 template() \ │ │ │ │ │ -275 OP std::declval())> > \ │ │ │ │ │ -276 decltype(auto) \ │ │ │ │ │ -277 operator OP(const T &t, const AlignedNumber &u) \ │ │ │ │ │ -278 { \ │ │ │ │ │ -279 return aligned(t OP U(u)); \ │ │ │ │ │ -280 } \ │ │ │ │ │ -281 \ │ │ │ │ │ -282 template() \ │ │ │ │ │ -284 OP std::declval())> > \ │ │ │ │ │ -285 decltype(auto) \ │ │ │ │ │ -286 operator OP(const AlignedNumber &t, const U &u) \ │ │ │ │ │ -287 { \ │ │ │ │ │ -288 return aligned(T(t) OP u); \ │ │ │ │ │ -289 } \ │ │ │ │ │ -290 \ │ │ │ │ │ -291 static_assert(true, "Require semicolon to unconfuse editors") │ │ │ │ │ -292 │ │ │ │ │ -293 DUNE_BINARY_OP(+); │ │ │ │ │ -294 DUNE_BINARY_OP(-); │ │ │ │ │ -295 │ │ │ │ │ -296 DUNE_BINARY_OP(*); │ │ │ │ │ -297 DUNE_BINARY_OP(/); │ │ │ │ │ -298 DUNE_BINARY_OP(%); │ │ │ │ │ -299 │ │ │ │ │ -300 DUNE_BINARY_OP(^); │ │ │ │ │ -301 DUNE_BINARY_OP(&); │ │ │ │ │ -302 DUNE_BINARY_OP(|); │ │ │ │ │ -303 │ │ │ │ │ -304 DUNE_BINARY_OP(<<); │ │ │ │ │ -305 DUNE_BINARY_OP(>>); │ │ │ │ │ -306 │ │ │ │ │ -307 DUNE_BINARY_OP(==); │ │ │ │ │ -308 DUNE_BINARY_OP(!=); │ │ │ │ │ -309 DUNE_BINARY_OP(<); │ │ │ │ │ -310 DUNE_BINARY_OP(>); │ │ │ │ │ -311 DUNE_BINARY_OP(<=); │ │ │ │ │ -312 DUNE_BINARY_OP(>=); │ │ │ │ │ -313 │ │ │ │ │ -314 DUNE_BINARY_OP(&&); │ │ │ │ │ -315 DUNE_BINARY_OP(||); │ │ │ │ │ -316 │ │ │ │ │ -317#undef DUNE_BINARY_OP │ │ │ │ │ -318 │ │ │ │ │ -320 // │ │ │ │ │ -321 // Overloads for the functions provided by the standard library │ │ │ │ │ -322 // │ │ │ │ │ -323#define DUNE_UNARY_FUNC(name) \ │ │ │ │ │ -324 template \ │ │ │ │ │ -325 decltype(auto) name(const AlignedNumber &u) \ │ │ │ │ │ -326 { \ │ │ │ │ │ -327 using std::name; \ │ │ │ │ │ -328 return aligned(name(T(u))); \ │ │ │ │ │ -329 } \ │ │ │ │ │ -330 static_assert(true, "Require semicolon to unconfuse editors") │ │ │ │ │ -331 │ │ │ │ │ -332 // │ │ │ │ │ -333 // functions │ │ │ │ │ -334 // │ │ │ │ │ -335 │ │ │ │ │ -336 // note: only unary functions are provided at the moment. Getting all the │ │ │ │ │ -337 // overloads right for functions with more than one argument is tricky. │ │ │ │ │ -338 // All functions appear in the list below in the order they are │ │ │ │ │ -339 // listed in in the standard, but the unimplemented ones are commented │ │ │ │ │ -340 // out. │ │ │ │ │ -341 │ │ │ │ │ -342 // note: abs is provided by both (for integer) and (for │ │ │ │ │ -343 // floating point). This overload works for both. │ │ │ │ │ -344 DUNE_UNARY_FUNC(abs); │ │ │ │ │ -345 DUNE_UNARY_FUNC(acos); │ │ │ │ │ -346 DUNE_UNARY_FUNC(acosh); │ │ │ │ │ -347 DUNE_UNARY_FUNC(asin); │ │ │ │ │ -348 DUNE_UNARY_FUNC(asinh); │ │ │ │ │ -349 DUNE_UNARY_FUNC(atan); │ │ │ │ │ -350 // atan2 │ │ │ │ │ -351 DUNE_UNARY_FUNC(atanh); │ │ │ │ │ -352 DUNE_UNARY_FUNC(cbrt); │ │ │ │ │ -353 DUNE_UNARY_FUNC(ceil); │ │ │ │ │ -354 // copysign │ │ │ │ │ -355 DUNE_UNARY_FUNC(cos); │ │ │ │ │ -356 DUNE_UNARY_FUNC(cosh); │ │ │ │ │ -357 DUNE_UNARY_FUNC(erf); │ │ │ │ │ -358 DUNE_UNARY_FUNC(erfc); │ │ │ │ │ -359 DUNE_UNARY_FUNC(exp); │ │ │ │ │ -360 DUNE_UNARY_FUNC(exp2); │ │ │ │ │ -361 DUNE_UNARY_FUNC(expm1); │ │ │ │ │ -362 DUNE_UNARY_FUNC(fabs); │ │ │ │ │ -363 // fdim │ │ │ │ │ -364 DUNE_UNARY_FUNC(floor); │ │ │ │ │ -365 // fma │ │ │ │ │ -366 // fmax │ │ │ │ │ -367 // fmin │ │ │ │ │ -368 // fmod │ │ │ │ │ -369 // frexp │ │ │ │ │ -370 // hypos │ │ │ │ │ -371 DUNE_UNARY_FUNC(ilogb); │ │ │ │ │ -372 // ldexp │ │ │ │ │ -373 DUNE_UNARY_FUNC(lgamma); │ │ │ │ │ -374 DUNE_UNARY_FUNC(llrint); │ │ │ │ │ -375 DUNE_UNARY_FUNC(llround); │ │ │ │ │ -376 DUNE_UNARY_FUNC(log); │ │ │ │ │ -377 DUNE_UNARY_FUNC(log10); │ │ │ │ │ -378 DUNE_UNARY_FUNC(log1p); │ │ │ │ │ -379 DUNE_UNARY_FUNC(log2); │ │ │ │ │ -380 DUNE_UNARY_FUNC(logb); │ │ │ │ │ -381 DUNE_UNARY_FUNC(lrint); │ │ │ │ │ -382 DUNE_UNARY_FUNC(lround); │ │ │ │ │ -383 // modf │ │ │ │ │ -384 DUNE_UNARY_FUNC(nearbyint); │ │ │ │ │ -385 // nextafter │ │ │ │ │ -386 // nexttoward │ │ │ │ │ -387 // pow │ │ │ │ │ -388 // remainder │ │ │ │ │ -389 // remquo │ │ │ │ │ -390 DUNE_UNARY_FUNC(rint); │ │ │ │ │ -391 DUNE_UNARY_FUNC(round); │ │ │ │ │ -392 // scalbln │ │ │ │ │ -393 // scalbn │ │ │ │ │ -394 DUNE_UNARY_FUNC(sin); │ │ │ │ │ -395 DUNE_UNARY_FUNC(sinh); │ │ │ │ │ -396 DUNE_UNARY_FUNC(sqrt); │ │ │ │ │ -397 DUNE_UNARY_FUNC(tan); │ │ │ │ │ -398 DUNE_UNARY_FUNC(tanh); │ │ │ │ │ -399 DUNE_UNARY_FUNC(tgamma); │ │ │ │ │ -400 DUNE_UNARY_FUNC(trunc); │ │ │ │ │ -401 │ │ │ │ │ -402 DUNE_UNARY_FUNC(isfinite); │ │ │ │ │ -403 DUNE_UNARY_FUNC(isinf); │ │ │ │ │ -404 DUNE_UNARY_FUNC(isnan); │ │ │ │ │ -405 DUNE_UNARY_FUNC(isnormal); │ │ │ │ │ -406 DUNE_UNARY_FUNC(signbit); │ │ │ │ │ -407 │ │ │ │ │ -408 // isgreater │ │ │ │ │ -409 // isgreaterequal │ │ │ │ │ -410 // isless │ │ │ │ │ -411 // islessequal │ │ │ │ │ -412 // islessgreater │ │ │ │ │ -413 // isunordered │ │ │ │ │ -414 │ │ │ │ │ -415 // │ │ │ │ │ -416 // functions │ │ │ │ │ -417 // │ │ │ │ │ -418 │ │ │ │ │ -419 // not all functions are implemented, and unlike for , no │ │ │ │ │ -420 // comprehensive list is provided │ │ │ │ │ -421 DUNE_UNARY_FUNC(real); │ │ │ │ │ -422 │ │ │ │ │ -423#undef DUNE_UNARY_FUNC │ │ │ │ │ -424 │ │ │ │ │ -425 // We need to overload min() and max() since they require types to be │ │ │ │ │ -426 // LessThanComparable, which requires `a in the standard (still open │ │ │ │ │ -430 // as of 2018-07-06), which strives to require both "implicitly" and │ │ │ │ │ -431 // "contextually" convertible -- plus a few other things. │ │ │ │ │ -432 // │ │ │ │ │ -433 // We do not want our debug type to automatically decay to the underlying │ │ │ │ │ -434 // type, so we do not want to make the conversion non-explicit. So the │ │ │ │ │ -435 // only option left is to overload min() and max(). │ │ │ │ │ -436 │ │ │ │ │ -437 template │ │ │ │ │ -438 auto max(const AlignedNumber &a, │ │ │ │ │ -439 const AlignedNumber &b) │ │ │ │ │ -440 { │ │ │ │ │ -441 using std::max; │ │ │ │ │ -442 return aligned(max(T(a), T(b))); │ │ │ │ │ -443 } │ │ │ │ │ -444 │ │ │ │ │ -445 template │ │ │ │ │ -446 auto max(const T &a, const AlignedNumber &b) │ │ │ │ │ -447 { │ │ │ │ │ -448 using std::max; │ │ │ │ │ -449 return aligned(max(a, T(b))); │ │ │ │ │ -450 } │ │ │ │ │ -451 │ │ │ │ │ -452 template │ │ │ │ │ -453 auto max(const AlignedNumber &a, const T &b) │ │ │ │ │ -454 { │ │ │ │ │ -455 using std::max; │ │ │ │ │ -456 return aligned(max(T(a), b)); │ │ │ │ │ -457 } │ │ │ │ │ -458 │ │ │ │ │ -459 template │ │ │ │ │ -460 auto min(const AlignedNumber &a, │ │ │ │ │ -461 const AlignedNumber &b) │ │ │ │ │ -462 { │ │ │ │ │ -463 using std::min; │ │ │ │ │ -464 return aligned(min(T(a), T(b))); │ │ │ │ │ -465 } │ │ │ │ │ -466 │ │ │ │ │ -467 template │ │ │ │ │ -468 auto min(const T &a, const AlignedNumber &b) │ │ │ │ │ -469 { │ │ │ │ │ -470 using std::min; │ │ │ │ │ -471 return aligned(min(a, T(b))); │ │ │ │ │ -472 } │ │ │ │ │ -473 │ │ │ │ │ -474 template │ │ │ │ │ -475 auto min(const AlignedNumber &a, const T &b) │ │ │ │ │ -476 { │ │ │ │ │ -477 using std::min; │ │ │ │ │ -478 return aligned(min(T(a), b)); │ │ │ │ │ -479 } │ │ │ │ │ -480 │ │ │ │ │ -481 } // namespace AlignedNumberImpl │ │ │ │ │ -482 │ │ │ │ │ -483 // SIMD-like functions from "conditional.hh" │ │ │ │ │ -484 template │ │ │ │ │ -485 AlignedNumber │ │ │ │ │ -486 cond(const AlignedNumber &b, │ │ │ │ │ -487 const AlignedNumber &v1, const AlignedNumber &v2) │ │ │ │ │ -488 { │ │ │ │ │ -489 return b ? v1 : v2; │ │ │ │ │ -490 } │ │ │ │ │ -491 │ │ │ │ │ -492 // SIMD-like functions from "rangeutilities.hh" │ │ │ │ │ -493 template │ │ │ │ │ -494 T max_value(const AlignedNumber& val) │ │ │ │ │ -495 { │ │ │ │ │ -496 return T(val); │ │ │ │ │ -497 } │ │ │ │ │ -498 │ │ │ │ │ -499 template │ │ │ │ │ -500 T min_value(const AlignedNumber& val) │ │ │ │ │ -501 { │ │ │ │ │ -502 return T(val); │ │ │ │ │ -503 } │ │ │ │ │ -504 │ │ │ │ │ -505 template │ │ │ │ │ -506 bool any_true(const AlignedNumber& val) │ │ │ │ │ -507 { │ │ │ │ │ -508 return bool(val); │ │ │ │ │ -509 } │ │ │ │ │ -510 │ │ │ │ │ -511 template │ │ │ │ │ -512 bool all_true(const AlignedNumber& val) │ │ │ │ │ -513 { │ │ │ │ │ -514 return bool(val); │ │ │ │ │ -515 } │ │ │ │ │ -516 │ │ │ │ │ -517 // SIMD-like functionality from "simd/interface.hh" │ │ │ │ │ -518 namespace Simd { │ │ │ │ │ -519 namespace Overloads { │ │ │ │ │ -520 │ │ │ │ │ -521 template │ │ │ │ │ -522 struct ScalarType > { using type = T; }; │ │ │ │ │ -523 │ │ │ │ │ -524 template │ │ │ │ │ -525 struct RebindType > { │ │ │ │ │ -526 using type = AlignedNumber; │ │ │ │ │ -527 }; │ │ │ │ │ -528 │ │ │ │ │ -529 template │ │ │ │ │ -530 struct LaneCount > : index_constant<1> {}; │ │ │ │ │ -531 │ │ │ │ │ -532 template │ │ │ │ │ -533 T& lane(ADLTag<5>, std::size_t l, AlignedNumber &v) │ │ │ │ │ -534 { │ │ │ │ │ -535 assert(l == 0); │ │ │ │ │ -536 return v.value(); │ │ │ │ │ -537 } │ │ │ │ │ -538 │ │ │ │ │ -539 template │ │ │ │ │ -540 T lane(ADLTag<5>, std::size_t l, const AlignedNumber &v) │ │ │ │ │ -541 { │ │ │ │ │ -542 assert(l == 0); │ │ │ │ │ -543 return v.value(); │ │ │ │ │ -544 } │ │ │ │ │ -545 │ │ │ │ │ -546 template │ │ │ │ │ -547 const AlignedNumber & │ │ │ │ │ -548 cond(ADLTag<5>, AlignedNumber mask, │ │ │ │ │ -549 const AlignedNumber &ifTrue, │ │ │ │ │ -550 const AlignedNumber &ifFalse) │ │ │ │ │ -551 { │ │ │ │ │ -552 return mask ? ifTrue : ifFalse; │ │ │ │ │ -553 } │ │ │ │ │ -554 │ │ │ │ │ -555 template │ │ │ │ │ -556 bool anyTrue(ADLTag<5>, const AlignedNumber &mask) │ │ │ │ │ -557 { │ │ │ │ │ -558 return bool(mask); │ │ │ │ │ -559 } │ │ │ │ │ -560 │ │ │ │ │ -561 } // namespace Overloads │ │ │ │ │ -562 │ │ │ │ │ -563 } // namespace Simd │ │ │ │ │ -564 │ │ │ │ │ -565} // namespace Dune │ │ │ │ │ -566 │ │ │ │ │ -567#endif // DUNE_DEBUGALIGN_HH │ │ │ │ │ -defaults.hh │ │ │ │ │ -Default implementations for SIMD Implementations. │ │ │ │ │ -base.hh │ │ │ │ │ -Basic definitions for SIMD Implementations. │ │ │ │ │ -classname.hh │ │ │ │ │ -A free function to provide the demangled class name of a given object or type │ │ │ │ │ -as a string. │ │ │ │ │ -DUNE_BINARY_OP │ │ │ │ │ -#define DUNE_BINARY_OP(OP) │ │ │ │ │ -Definition debugalign.hh:261 │ │ │ │ │ -DUNE_UNARY_FUNC │ │ │ │ │ -#define DUNE_UNARY_FUNC(name) │ │ │ │ │ -DUNE_ASSIGN_OP │ │ │ │ │ -#define DUNE_ASSIGN_OP(OP) │ │ │ │ │ -Definition debugalign.hh:220 │ │ │ │ │ -indices.hh │ │ │ │ │ +155 │ │ │ │ │ +156 │ │ │ │ │ +157} // end namespace Dune │ │ │ │ │ +158 │ │ │ │ │ +159#endif // DUNE_COMMON_OVERLOADSET_HH │ │ │ │ │ typetraits.hh │ │ │ │ │ Traits for type conversions and type information. │ │ │ │ │ -Dune::index_constant │ │ │ │ │ -std::integral_constant< std::size_t, i > index_constant │ │ │ │ │ -An index constant with value i. │ │ │ │ │ -Definition indices.hh:29 │ │ │ │ │ -Dune::operator<< │ │ │ │ │ -std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x) │ │ │ │ │ -Definition bigunsignedint.hh:278 │ │ │ │ │ -Dune::Simd::Overloads::mask │ │ │ │ │ -Mask< V > mask(ADLTag< 0, std::is_same< V, Mask< V > >::value >, const V &v) │ │ │ │ │ -implements Simd::mask() │ │ │ │ │ -Definition defaults.hh:153 │ │ │ │ │ +Dune::orderedOverload │ │ │ │ │ +auto orderedOverload(F &&... f) │ │ │ │ │ +Create an ordered overload set. │ │ │ │ │ +Definition overloadset.hh:150 │ │ │ │ │ +Dune::overload │ │ │ │ │ +auto overload(F &&... f) │ │ │ │ │ +Create an overload set. │ │ │ │ │ +Definition overloadset.hh:61 │ │ │ │ │ std │ │ │ │ │ STL namespace. │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::violatedAlignment │ │ │ │ │ -void violatedAlignment(const char *className, std::size_t expectedAlignment, │ │ │ │ │ -const void *address) │ │ │ │ │ -called when an alignment violation is detected │ │ │ │ │ -Definition debugalign.cc:36 │ │ │ │ │ -Dune::any_true │ │ │ │ │ -bool any_true(const AlignedNumber< bool, align > &val) │ │ │ │ │ -Definition debugalign.hh:506 │ │ │ │ │ -Dune::all_true │ │ │ │ │ -bool all_true(const AlignedNumber< bool, align > &val) │ │ │ │ │ -Definition debugalign.hh:512 │ │ │ │ │ -Dune::className │ │ │ │ │ -std::string className() │ │ │ │ │ -Provide the demangled class name of a type T as a string. │ │ │ │ │ -Definition classname.hh:47 │ │ │ │ │ -Dune::debugAlignment │ │ │ │ │ -static constexpr auto debugAlignment │ │ │ │ │ -an alignment large enough to trigger alignment errors │ │ │ │ │ -Definition debugalign.hh:97 │ │ │ │ │ -Dune::cond │ │ │ │ │ -const T1 cond(bool b, const T1 &v1, const T2 &v2) │ │ │ │ │ -conditional evaluate │ │ │ │ │ -Definition conditional.hh:28 │ │ │ │ │ -Dune::aligned │ │ │ │ │ -AlignedNumber< T, align > aligned(T value) │ │ │ │ │ -align a value to a certain alignment │ │ │ │ │ -Definition debugalign.hh:114 │ │ │ │ │ -Dune::violatedAlignmentHandler │ │ │ │ │ -ViolatedAlignmentHandler & violatedAlignmentHandler() │ │ │ │ │ -access the handler called by violatedAlignment() │ │ │ │ │ -Definition debugalign.cc:30 │ │ │ │ │ -Dune::isAligned │ │ │ │ │ -bool isAligned(const void *p, std::size_t align) │ │ │ │ │ -check whether an address conforms to the given alignment │ │ │ │ │ -Definition debugalign.hh:56 │ │ │ │ │ -Dune::max_value │ │ │ │ │ -T max_value(const AlignedNumber< T, align > &val) │ │ │ │ │ -Definition debugalign.hh:494 │ │ │ │ │ -Dune::ViolatedAlignmentHandler │ │ │ │ │ -std::function< void(const char *, std::size_t, const void *)> │ │ │ │ │ -ViolatedAlignmentHandler │ │ │ │ │ -type of the handler called by violatedAlignment() │ │ │ │ │ -Definition debugalign.hh:31 │ │ │ │ │ -Dune::min_value │ │ │ │ │ -T min_value(const AlignedNumber< T, align > &val) │ │ │ │ │ -Definition debugalign.hh:500 │ │ │ │ │ -Dune::Simd::Overloads::anyTrue │ │ │ │ │ -bool anyTrue(ADLTag< 5 >, const AlignedNumber< bool, align > &mask) │ │ │ │ │ -Definition debugalign.hh:556 │ │ │ │ │ -Dune::Simd::Overloads::lane │ │ │ │ │ -T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v) │ │ │ │ │ -Definition debugalign.hh:533 │ │ │ │ │ -Dune::IsNumber │ │ │ │ │ -Whether this type acts as a scalar in the context of (hierarchically blocked) │ │ │ │ │ -containers. │ │ │ │ │ -Definition typetraits.hh:194 │ │ │ │ │ -Dune::AlignedBase │ │ │ │ │ -CRTP base mixin class to check alignment. │ │ │ │ │ -Definition debugalign.hh:66 │ │ │ │ │ -Dune::AlignedNumberImpl::AlignedNumber │ │ │ │ │ -aligned wrappers for arithmetic types │ │ │ │ │ -Definition debugalign.hh:128 │ │ │ │ │ -Dune::AlignedNumberImpl::AlignedNumber::DUNE_ASSIGN_OP │ │ │ │ │ -DUNE_ASSIGN_OP(<<=) │ │ │ │ │ -Dune::AlignedNumberImpl::AlignedNumber::DUNE_ASSIGN_OP │ │ │ │ │ -DUNE_ASSIGN_OP(-=) │ │ │ │ │ -Dune::AlignedNumberImpl::AlignedNumber::operator+ │ │ │ │ │ -decltype(auto) operator+() const │ │ │ │ │ -Definition debugalign.hh:187 │ │ │ │ │ -Dune::AlignedNumberImpl::AlignedNumber::DUNE_ASSIGN_OP │ │ │ │ │ -DUNE_ASSIGN_OP(+=) │ │ │ │ │ -Dune::AlignedNumberImpl::AlignedNumber::operator-- │ │ │ │ │ -decltype(auto) operator--(int) │ │ │ │ │ -Definition debugalign.hh:182 │ │ │ │ │ -Dune::AlignedNumberImpl::AlignedNumber::DUNE_ASSIGN_OP │ │ │ │ │ -DUNE_ASSIGN_OP * DUNE_ASSIGN_OP(/=);DUNE_ASSIGN_OP(%= │ │ │ │ │ -Dune::AlignedNumberImpl::AlignedNumber::operator++ │ │ │ │ │ -decltype(auto) operator++(int) │ │ │ │ │ -Definition debugalign.hh:179 │ │ │ │ │ -Dune::AlignedNumberImpl::AlignedNumber::operator! │ │ │ │ │ -decltype(auto) operator!() const │ │ │ │ │ -Definition debugalign.hh:217 │ │ │ │ │ -Dune::AlignedNumberImpl::AlignedNumber::value │ │ │ │ │ -T & value() │ │ │ │ │ -Definition debugalign.hh:145 │ │ │ │ │ -Dune::AlignedNumberImpl::AlignedNumber::value │ │ │ │ │ -const T & value() const │ │ │ │ │ -Definition debugalign.hh:144 │ │ │ │ │ -Dune::AlignedNumberImpl::AlignedNumber::DUNE_ASSIGN_OP │ │ │ │ │ -DUNE_ASSIGN_OP^ DUNE_ASSIGN_OP(&=);DUNE_ASSIGN_OP(|= │ │ │ │ │ -Dune::AlignedNumberImpl::AlignedNumber::operator>> │ │ │ │ │ -friend std::basic_istream< charT, Traits > & operator>>(std::basic_istream< │ │ │ │ │ -charT, Traits > &str, AlignedNumber &u) │ │ │ │ │ -Definition debugalign.hh:150 │ │ │ │ │ -Dune::AlignedNumberImpl::AlignedNumber::DUNE_ASSIGN_OP │ │ │ │ │ -DUNE_ASSIGN_OP(> >=) │ │ │ │ │ -Dune::AlignedNumberImpl::AlignedNumber::AlignedNumber │ │ │ │ │ -AlignedNumber()=default │ │ │ │ │ -Dune::AlignedNumberImpl::AlignedNumber::operator~ │ │ │ │ │ -decltype(auto) operator~() const │ │ │ │ │ -Definition debugalign.hh:207 │ │ │ │ │ -Dune::AlignedNumberImpl::AlignedNumber::AlignedNumber │ │ │ │ │ -AlignedNumber(T value) │ │ │ │ │ -Definition debugalign.hh:133 │ │ │ │ │ -Dune::AlignedNumberImpl::AlignedNumber::AlignedNumber │ │ │ │ │ -AlignedNumber(const AlignedNumber< U, uAlign > &o) │ │ │ │ │ -Definition debugalign.hh:137 │ │ │ │ │ -Dune::AlignedNumberImpl::AlignedNumber::operator- │ │ │ │ │ -decltype(auto) operator-() const │ │ │ │ │ -Definition debugalign.hh:191 │ │ │ │ │ -Dune::Simd::Overloads::ScalarType<_AlignedNumber<_T,_align_>_>::type │ │ │ │ │ -T type │ │ │ │ │ -Definition debugalign.hh:522 │ │ │ │ │ -Dune::Simd::Overloads::ADLTag │ │ │ │ │ -Tag used to force late-binding lookup in Dune::Simd::Overloads. │ │ │ │ │ -Definition base.hh:182 │ │ │ │ │ -Dune::Simd::Overloads::ScalarType │ │ │ │ │ -should have a member type type │ │ │ │ │ -Definition standard.hh:60 │ │ │ │ │ -Dune::Simd::Overloads::RebindType │ │ │ │ │ -should have a member type type │ │ │ │ │ -Definition standard.hh:67 │ │ │ │ │ -Dune::Simd::Overloads::LaneCount │ │ │ │ │ -should be derived from a Dune::index_constant │ │ │ │ │ -Definition standard.hh:74 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00095.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: binaryfunctions.hh File Reference │ │ │ │ +dune-common: math.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -71,40 +71,196 @@ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces
│ │ │ │ -
binaryfunctions.hh File Reference
│ │ │ │ +Namespaces | │ │ │ │ +Macros | │ │ │ │ +Functions
│ │ │ │ +
math.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

helper classes to provide unique types for standard functions │ │ │ │ +

Some useful basic math stuff. │ │ │ │ More...

│ │ │ │ -
#include <algorithm>
│ │ │ │ +
#include <cmath>
│ │ │ │ +#include <complex>
│ │ │ │ +#include <limits>
│ │ │ │ +#include <type_traits>
│ │ │ │ +#include <dune/common/typeutilities.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

struct  Dune::Min< Type >
struct  Dune::StandardMathematicalConstants< T >
 Standard implementation of MathematicalConstants. More...
 
struct  Dune::Max< Type >
struct  Dune::MathematicalConstants< Field >
 Provides commonly used mathematical constants. More...
 
struct  Dune::Factorial< m >
 
struct  Dune::Factorial< 0 >
 end of recursion of factorial via specialization More...
 
struct  Dune::MathOverloads::ADLTag
 Tag to make sure the functions in this namespace can be found by ADL. More...
 
struct  Dune::MathImpl::isUnorderedImpl
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::MathOverloads
 namespace for customization of math functions with Dune-Semantics
 
namespace  Dune::MathImpl
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Macros

#define DUNE_COMMON_MATH_ISFUNCTION(function, stdfunction)
 
#define DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR(function)
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ +Functions

template<class Base , class Exponent >
constexpr Base Dune::power (Base m, Exponent p)
 Power method for integer exponents.
 
template<class T >
static constexpr T Dune::factorial (const T &n) noexcept
 calculate the factorial of n as a constexpr
 
template<class T , T n>
static constexpr auto Dune::factorial (std::integral_constant< T, n >) noexcept
 calculate the factorial of n as a constexpr
 
template<class T >
static constexpr T Dune::binomial (const T &n, const T &k) noexcept
 calculate the binomial coefficient n over k as a constexpr
 
template<class T , T n, T k>
static constexpr auto Dune::binomial (std::integral_constant< T, n >, std::integral_constant< T, k >) noexcept
 calculate the binomial coefficient n over k as a constexpr
 
template<class T , T n>
static constexpr auto Dune::binomial (std::integral_constant< T, n >, std::integral_constant< T, n >) noexcept
 
template<class K >
Dune::conjugateComplex (const K &x)
 compute conjugate complex of x
 
template<class T >
int Dune::sign (const T &val)
 Return the sign of the value.
 
 Dune::MathOverloads::DUNE_COMMON_MATH_ISFUNCTION (isNaN, isnan)
 
 Dune::MathOverloads::DUNE_COMMON_MATH_ISFUNCTION (isInf, isinf)
 
 Dune::MathOverloads::DUNE_COMMON_MATH_ISFUNCTION (isFinite, isfinite)
 
template<class T >
auto Dune::MathOverloads::isUnordered (const T &t1, const T &t2, PriorityTag< 1 >, ADLTag) -> decltype(isUnordered(t1, t2))
 
template<class T >
auto Dune::MathOverloads::isUnordered (const T &t1, const T &t2, PriorityTag< 0 >, ADLTag)
 
 Dune::MathImpl::DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR (isNaN)
 
 Dune::MathImpl::DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR (isInf)
 
 Dune::MathImpl::DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR (isFinite)
 
template<class T , class = std::enable_if_t<Impl::isComplexLike<T>::value>>
auto Dune::MathOverloads::isNaN (const T &t, PriorityTag< 2 >, ADLTag)
 
template<class T , class = std::enable_if_t<Impl::isComplexLike<T>::value>>
auto Dune::MathOverloads::isInf (const T &t, PriorityTag< 2 >, ADLTag)
 
template<class T , class = std::enable_if_t<Impl::isComplexLike<T>::value>>
auto Dune::MathOverloads::isFinite (const T &t, PriorityTag< 2 >, ADLTag)
 
│ │ │ │

Detailed Description

│ │ │ │ -

helper classes to provide unique types for standard functions

│ │ │ │ -
│ │ │ │ +

Some useful basic math stuff.

│ │ │ │ +

Macro Definition Documentation

│ │ │ │ + │ │ │ │ +

◆ DUNE_COMMON_MATH_ISFUNCTION

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_COMMON_MATH_ISFUNCTION( function,
 stdfunction 
)
│ │ │ │ +
│ │ │ │ +Value:
template<class T> \
│ │ │ │ +
auto function(const T &t, PriorityTag<1>, ADLTag) \
│ │ │ │ +
-> decltype(function(t)) { \
│ │ │ │ +
return function(t); \
│ │ │ │ +
} \
│ │ │ │ +
template<class T> \
│ │ │ │ +
auto function(const T &t, PriorityTag<0>, ADLTag) { \
│ │ │ │ +
using std::stdfunction; \
│ │ │ │ +
return stdfunction(t); \
│ │ │ │ +
} \
│ │ │ │ +
static_assert(true, "Require semicolon to unconfuse editors")
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR( function)
│ │ │ │ +
│ │ │ │ +Value:
struct function##Impl { \
│ │ │ │ +
template<class T> \
│ │ │ │ +
constexpr auto operator()(const T &t) const { \
│ │ │ │ +
return function(t, PriorityTag<10>{}, MathOverloads::ADLTag{}); \
│ │ │ │ +
} \
│ │ │ │ +
}; \
│ │ │ │ +
static_assert(true, "Require semicolon to unconfuse editors")
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,24 +1,154 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -binaryfunctions.hh File Reference │ │ │ │ │ -helper classes to provide unique types for standard functions More... │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces | Macros | Functions │ │ │ │ │ +math.hh File Reference │ │ │ │ │ +Some useful basic math stuff. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -struct   Dune::Min<_Type_> │ │ │ │ │ +struct   Dune::StandardMathematicalConstants<_T_> │ │ │ │ │ +  Standard implementation of MathematicalConstants. More... │ │ │ │ │   │ │ │ │ │ -struct   Dune::Max<_Type_> │ │ │ │ │ +struct   Dune::MathematicalConstants<_Field_> │ │ │ │ │ +  Provides commonly used mathematical constants. More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::Factorial<_m_> │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::Factorial<_0_> │ │ │ │ │ +  end of recursion of factorial via specialization More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::MathOverloads::ADLTag │ │ │ │ │ +  Tag to make sure the functions in this namespace can be found by ADL. │ │ │ │ │ + More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::MathImpl::isUnorderedImpl │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ +namespace   Dune::MathOverloads │ │ │ │ │ +  namespace for customization of math functions with Dune-Semantics │ │ │ │ │ +  │ │ │ │ │ +namespace   Dune::MathImpl │ │ │ │ │ +  │ │ │ │ │ +Macros │ │ │ │ │ +#define  DUNE_COMMON_MATH_ISFUNCTION(function, stdfunction) │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR(function) │ │ │ │ │ +  │ │ │ │ │ +Functions │ │ │ │ │ +template │ │ │ │ │ + constexpr Base  Dune::power (Base m, Exponent p) │ │ │ │ │ +  Power method for integer exponents. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + static constexpr T  Dune::factorial (const T &n) noexcept │ │ │ │ │ +  calculate the factorial of n as a constexpr │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +static constexpr auto  Dune::factorial (std::integral_constant< T, n >) │ │ │ │ │ + noexcept │ │ │ │ │ +  calculate the factorial of n as a constexpr │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + static constexpr T  Dune::binomial (const T &n, const T &k) noexcept │ │ │ │ │ +  calculate the binomial coefficient n over k as a │ │ │ │ │ + constexpr │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +static constexpr auto  Dune::binomial (std::integral_constant< T, n >, std:: │ │ │ │ │ + integral_constant< T, k >) noexcept │ │ │ │ │ +  calculate the binomial coefficient n over k as a │ │ │ │ │ + constexpr │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +static constexpr auto  Dune::binomial (std::integral_constant< T, n >, std:: │ │ │ │ │ + integral_constant< T, n >) noexcept │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + K  Dune::conjugateComplex (const K &x) │ │ │ │ │ +  compute conjugate complex of x │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + int  Dune::sign (const T &val) │ │ │ │ │ +  Return the sign of the value. │ │ │ │ │ +  │ │ │ │ │ +   Dune::MathOverloads::DUNE_COMMON_MATH_ISFUNCTION (isNaN, │ │ │ │ │ + isnan) │ │ │ │ │ +  │ │ │ │ │ +   Dune::MathOverloads::DUNE_COMMON_MATH_ISFUNCTION (isInf, │ │ │ │ │ + isinf) │ │ │ │ │ +  │ │ │ │ │ +   Dune::MathOverloads::DUNE_COMMON_MATH_ISFUNCTION │ │ │ │ │ + (isFinite, isfinite) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::MathOverloads::isUnordered (const T &t1, const T │ │ │ │ │ + &t2, PriorityTag< 1 >, ADLTag) -> decltype(isUnordered │ │ │ │ │ + (t1, t2)) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::MathOverloads::isUnordered (const T &t1, const T │ │ │ │ │ + &t2, PriorityTag< 0 >, ADLTag) │ │ │ │ │ +  │ │ │ │ │ +   Dune::MathImpl::DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR │ │ │ │ │ + (isNaN) │ │ │ │ │ +  │ │ │ │ │ +   Dune::MathImpl::DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR │ │ │ │ │ + (isInf) │ │ │ │ │ +  │ │ │ │ │ +   Dune::MathImpl::DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR │ │ │ │ │ + (isFinite) │ │ │ │ │ +  │ │ │ │ │ +template::value>> │ │ │ │ │ + auto  Dune::MathOverloads::isNaN (const T &t, PriorityTag< 2 │ │ │ │ │ + >, ADLTag) │ │ │ │ │ +  │ │ │ │ │ +template::value>> │ │ │ │ │ + auto  Dune::MathOverloads::isInf (const T &t, PriorityTag< 2 │ │ │ │ │ + >, ADLTag) │ │ │ │ │ +  │ │ │ │ │ +template::value>> │ │ │ │ │ + auto  Dune::MathOverloads::isFinite (const T &t, PriorityTag< │ │ │ │ │ + 2 >, ADLTag) │ │ │ │ │ +  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -helper classes to provide unique types for standard functions │ │ │ │ │ +Some useful basic math stuff. │ │ │ │ │ +***** Macro Definition Documentation ***** │ │ │ │ │ +***** ◆ DUNE_COMMON_MATH_ISFUNCTION ***** │ │ │ │ │ +#define DUNE_COMMON_MATH_ISFUNCTION (   function, │ │ │ │ │ +   stdfunction  │ │ │ │ │ + ) │ │ │ │ │ +Value: │ │ │ │ │ +template \ │ │ │ │ │ +auto function(const T &t, PriorityTag<1>, ADLTag) \ │ │ │ │ │ +-> decltype(function(t)) { \ │ │ │ │ │ +return function(t); \ │ │ │ │ │ +} \ │ │ │ │ │ +template \ │ │ │ │ │ +auto function(const T &t, PriorityTag<0>, ADLTag) { \ │ │ │ │ │ +using std::stdfunction; \ │ │ │ │ │ +return stdfunction(t); \ │ │ │ │ │ +} \ │ │ │ │ │ +static_assert(true, "Require semicolon to unconfuse editors") │ │ │ │ │ +***** ◆ DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR ***** │ │ │ │ │ +#define DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR (   function ) │ │ │ │ │ +Value: │ │ │ │ │ +struct function##Impl { \ │ │ │ │ │ +template \ │ │ │ │ │ +constexpr auto operator()(const T &t) const { \ │ │ │ │ │ +return function(t, PriorityTag<10>{}, MathOverloads::ADLTag{}); \ │ │ │ │ │ +} \ │ │ │ │ │ +}; \ │ │ │ │ │ +static_assert(true, "Require semicolon to unconfuse editors") │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00095_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: binaryfunctions.hh Source File │ │ │ │ +dune-common: math.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,81 +74,373 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
binaryfunctions.hh
│ │ │ │ +
math.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_BINARYFUNCTIONS_HH
│ │ │ │ -
6#define DUNE_BINARYFUNCTIONS_HH
│ │ │ │ +
5#ifndef DUNE_MATH_HH
│ │ │ │ +
6#define DUNE_MATH_HH
│ │ │ │
7
│ │ │ │ -
12#include <algorithm>
│ │ │ │ -
13
│ │ │ │ -
14namespace Dune
│ │ │ │ -
15{
│ │ │ │ -
16 template<typename Type>
│ │ │ │ -
│ │ │ │ -
17 struct Min
│ │ │ │ -
18 {
│ │ │ │ -
19 using first_argument_type [[deprecated("This type alias is deprecated following similar deprecations in C++17")]] = Type;
│ │ │ │ -
20
│ │ │ │ -
21 using second_argument_type [[deprecated("This type alias is deprecated following similar deprecations in C++17")]] = Type;
│ │ │ │ -
22
│ │ │ │ -
23 using result_type [[deprecated("This type alias is deprecated following similar deprecations in C++17")]] = Type;
│ │ │ │ -
24
│ │ │ │ -
│ │ │ │ -
25 Type operator()(const Type& t1, const Type& t2) const
│ │ │ │ -
26 {
│ │ │ │ -
27 using std::min;
│ │ │ │ -
28 return min(t1,t2);
│ │ │ │ -
29 }
│ │ │ │ -
│ │ │ │ -
30 };
│ │ │ │ -
│ │ │ │ -
31
│ │ │ │ -
32 template<typename Type>
│ │ │ │ +
12#include <cmath>
│ │ │ │ +
13#include <complex>
│ │ │ │ +
14#include <limits>
│ │ │ │ +
15#include <type_traits>
│ │ │ │ +
16
│ │ │ │ + │ │ │ │ +
18
│ │ │ │ +
19namespace Dune
│ │ │ │ +
20{
│ │ │ │ +
21
│ │ │ │ +
32 template< class T >
│ │ │ │
│ │ │ │ -
33 struct Max
│ │ │ │ + │ │ │ │
34 {
│ │ │ │ -
35 using first_argument_type [[deprecated("This type alias is deprecated following similar deprecations in C++17")]] = Type;
│ │ │ │ -
36
│ │ │ │ -
37 using second_argument_type [[deprecated("This type alias is deprecated following similar deprecations in C++17")]] = Type;
│ │ │ │ -
38
│ │ │ │ -
39 using result_type [[deprecated("This type alias is deprecated following similar deprecations in C++17")]] = Type;
│ │ │ │ -
40
│ │ │ │ -
│ │ │ │ -
41 Type operator()(const Type& t1, const Type& t2) const
│ │ │ │ -
42 {
│ │ │ │ -
43 using std::max;
│ │ │ │ -
44 return max(t1,t2);
│ │ │ │ -
45 }
│ │ │ │ -
│ │ │ │ -
46 };
│ │ │ │ -
│ │ │ │ -
47}
│ │ │ │ -
48
│ │ │ │ -
49#endif
│ │ │ │ +
│ │ │ │ +
38 static const T e ()
│ │ │ │ +
39 {
│ │ │ │ +
40 using std::exp;
│ │ │ │ +
41 static const T e = exp( T( 1 ) );
│ │ │ │ +
42 return e;
│ │ │ │ +
43 }
│ │ │ │ +
│ │ │ │ +
44
│ │ │ │ +
│ │ │ │ +
48 static const T pi ()
│ │ │ │ +
49 {
│ │ │ │ +
50 using std::acos;
│ │ │ │ +
51 static const T pi = acos( T( -1 ) );
│ │ │ │ +
52 return pi;
│ │ │ │ +
53 }
│ │ │ │ +
│ │ │ │ +
54 };
│ │ │ │ +
│ │ │ │ +
55
│ │ │ │ +
56
│ │ │ │ +
64 template< class Field >
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
66 : public StandardMathematicalConstants<Field>
│ │ │ │ +
67 {};
│ │ │ │ +
│ │ │ │ +
68
│ │ │ │ +
69
│ │ │ │ +
74 template <class Base, class Exponent>
│ │ │ │ +
│ │ │ │ +
75 constexpr Base power(Base m, Exponent p)
│ │ │ │ +
76 {
│ │ │ │ +
77 static_assert(std::numeric_limits<Exponent>::is_integer, "Exponent must be an integer type!");
│ │ │ │ +
78
│ │ │ │ +
79 auto result = Base(1);
│ │ │ │ +
80 auto absp = (p<0) ? -p : p; // This is simply abs, but std::abs is not constexpr
│ │ │ │ +
81 for (Exponent i = Exponent(0); i<absp; i++)
│ │ │ │ +
82 result *= m;
│ │ │ │ +
83
│ │ │ │ +
84 if (p<0)
│ │ │ │ +
85 result = Base(1)/result;
│ │ │ │ +
86
│ │ │ │ +
87 return result;
│ │ │ │ +
88 }
│ │ │ │ +
│ │ │ │ +
89
│ │ │ │ +
92 template <int m>
│ │ │ │ +
│ │ │ │ +
93 struct Factorial
│ │ │ │ +
94 {
│ │ │ │ +
96 static constexpr int factorial = m * Factorial<m-1>::factorial;
│ │ │ │ +
97 };
│ │ │ │ +
│ │ │ │ +
98
│ │ │ │ +
100 template <>
│ │ │ │ +
│ │ │ │ +
101 struct [[deprecated("Use function factorial instead! Will be removed after Dune 2.9")]] Factorial<0>
│ │ │ │ +
102 {
│ │ │ │ +
103 // 0! = 1
│ │ │ │ +
104 static constexpr int factorial = 1;
│ │ │ │ +
105 };
│ │ │ │ +
│ │ │ │ +
106
│ │ │ │ +
107
│ │ │ │ +
109 // T has to be an integral type
│ │ │ │ +
110 template<class T>
│ │ │ │ +
│ │ │ │ +
111 constexpr inline static T factorial(const T& n) noexcept
│ │ │ │ +
112 {
│ │ │ │ +
113 static_assert(std::numeric_limits<T>::is_integer, "`factorial(n)` has to be called with an integer type.");
│ │ │ │ +
114 T fac = 1;
│ │ │ │ +
115 for(T k = 0; k < n; ++k)
│ │ │ │ +
116 fac *= k+1;
│ │ │ │ +
117 return fac;
│ │ │ │ +
118 }
│ │ │ │ +
│ │ │ │ +
119
│ │ │ │ +
121 template<class T, T n>
│ │ │ │ +
│ │ │ │ +
122 constexpr inline static auto factorial (std::integral_constant<T, n>) noexcept
│ │ │ │ +
123 {
│ │ │ │ +
124 return std::integral_constant<T, factorial(n)>{};
│ │ │ │ +
125 }
│ │ │ │ +
│ │ │ │ +
126
│ │ │ │ +
127
│ │ │ │ +
129 // T has to be an integral type
│ │ │ │ +
130 template<class T>
│ │ │ │ +
│ │ │ │ +
131 constexpr inline static T binomial (const T& n, const T& k) noexcept
│ │ │ │ +
132 {
│ │ │ │ +
133 static_assert(std::numeric_limits<T>::is_integer, "`binomial(n, k)` has to be called with an integer type.");
│ │ │ │ +
134
│ │ │ │ +
135 if( k < 0 || k > n )
│ │ │ │ +
136 return 0;
│ │ │ │ +
137
│ │ │ │ +
138 if (2*k > n)
│ │ │ │ +
139 return binomial(n, n-k);
│ │ │ │ +
140
│ │ │ │ +
141 T bin = 1;
│ │ │ │ +
142 for(auto i = n-k; i < n; ++i)
│ │ │ │ +
143 bin *= i+1;
│ │ │ │ +
144 return bin / factorial(k);
│ │ │ │ +
145 }
│ │ │ │ +
│ │ │ │ +
146
│ │ │ │ +
148 template<class T, T n, T k>
│ │ │ │ +
│ │ │ │ +
149 constexpr inline static auto binomial (std::integral_constant<T, n>, std::integral_constant<T, k>) noexcept
│ │ │ │ +
150 {
│ │ │ │ +
151 return std::integral_constant<T, binomial(n, k)>{};
│ │ │ │ +
152 }
│ │ │ │ +
│ │ │ │ +
153
│ │ │ │ +
154 template<class T, T n>
│ │ │ │ +
│ │ │ │ +
155 constexpr inline static auto binomial (std::integral_constant<T, n>, std::integral_constant<T, n>) noexcept
│ │ │ │ +
156 {
│ │ │ │ +
157 return std::integral_constant<T, (n >= 0 ? 1 : 0)>{};
│ │ │ │ +
158 }
│ │ │ │ +
│ │ │ │ +
159
│ │ │ │ +
160
│ │ │ │ +
162 // conjugate complex does nothing for non-complex types
│ │ │ │ +
163 template<class K>
│ │ │ │ +
│ │ │ │ +
164 inline K conjugateComplex (const K& x)
│ │ │ │ +
165 {
│ │ │ │ +
166 return x;
│ │ │ │ +
167 }
│ │ │ │ +
│ │ │ │ +
168
│ │ │ │ +
169#ifndef DOXYGEN
│ │ │ │ +
170 // specialization for complex
│ │ │ │ +
171 template<class K>
│ │ │ │ +
172 inline std::complex<K> conjugateComplex (const std::complex<K>& c)
│ │ │ │ +
173 {
│ │ │ │ +
174 return std::complex<K>(c.real(),-c.imag());
│ │ │ │ +
175 }
│ │ │ │ +
176#endif
│ │ │ │ +
177
│ │ │ │ +
179 template <class T>
│ │ │ │ +
│ │ │ │ +
180 int sign(const T& val)
│ │ │ │ +
181 {
│ │ │ │ +
182 return (val < 0 ? -1 : 1);
│ │ │ │ +
183 }
│ │ │ │ +
│ │ │ │ +
184
│ │ │ │ +
185
│ │ │ │ +
186 namespace Impl {
│ │ │ │ +
187 // Returns whether a given type behaves like std::complex<>, i.e. whether
│ │ │ │ +
188 // real() and imag() are defined
│ │ │ │ +
189 template<class T>
│ │ │ │ +
190 struct isComplexLike {
│ │ │ │ +
191 private:
│ │ │ │ +
192 template<class U>
│ │ │ │ +
193 static auto test(U* u) -> decltype(u->real(), u->imag(), std::true_type());
│ │ │ │ +
194
│ │ │ │ +
195 template<class U>
│ │ │ │ +
196 static auto test(...) -> decltype(std::false_type());
│ │ │ │ +
197
│ │ │ │ +
198 public:
│ │ │ │ +
199 static const bool value = decltype(test<T>(0))::value;
│ │ │ │ +
200 };
│ │ │ │ +
201 } // namespace Impl
│ │ │ │ +
202
│ │ │ │ +
204
│ │ │ │ +
227 namespace MathOverloads {
│ │ │ │ +
228
│ │ │ │ +
230 struct ADLTag {};
│ │ │ │ +
231
│ │ │ │ +
│ │ │ │ +
232#define DUNE_COMMON_MATH_ISFUNCTION(function, stdfunction) \
│ │ │ │ +
233 template<class T> \
│ │ │ │ +
234 auto function(const T &t, PriorityTag<1>, ADLTag) \
│ │ │ │ +
235 -> decltype(function(t)) { \
│ │ │ │ +
236 return function(t); \
│ │ │ │ +
237 } \
│ │ │ │ +
238 template<class T> \
│ │ │ │ +
239 auto function(const T &t, PriorityTag<0>, ADLTag) { \
│ │ │ │ +
240 using std::stdfunction; \
│ │ │ │ +
241 return stdfunction(t); \
│ │ │ │ +
242 } \
│ │ │ │ +
243 static_assert(true, "Require semicolon to unconfuse editors")
│ │ │ │ +
│ │ │ │ +
244
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
248#undef DUNE_COMMON_MATH_ISFUNCTION
│ │ │ │ +
249
│ │ │ │ +
250 template<class T>
│ │ │ │ +
│ │ │ │ +
251 auto isUnordered(const T &t1, const T &t2, PriorityTag<1>, ADLTag)
│ │ │ │ +
252 -> decltype(isUnordered(t1, t2)) {
│ │ │ │ +
253 return isUnordered(t1, t2);
│ │ │ │ +
254 }
│ │ │ │ +
│ │ │ │ +
255
│ │ │ │ +
256 template<class T>
│ │ │ │ +
│ │ │ │ +
257 auto isUnordered(const T &t1, const T &t2, PriorityTag<0>, ADLTag) {
│ │ │ │ +
258 using std::isunordered;
│ │ │ │ +
259 return isunordered(t1, t2);
│ │ │ │ +
260 }
│ │ │ │ +
│ │ │ │ +
261 }
│ │ │ │ +
262
│ │ │ │ +
│ │ │ │ +
263 namespace MathImpl {
│ │ │ │ +
264
│ │ │ │ +
265 // NOTE: it is important that these functors have names different from the
│ │ │ │ +
266 // names of the functions they are forwarding to. Otherwise the
│ │ │ │ +
267 // unqualified call would find the functor type, not a function, and ADL
│ │ │ │ +
268 // would never be attempted.
│ │ │ │ +
│ │ │ │ +
269#define DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR(function) \
│ │ │ │ +
270 struct function##Impl { \
│ │ │ │ +
271 template<class T> \
│ │ │ │ +
272 constexpr auto operator()(const T &t) const { \
│ │ │ │ +
273 return function(t, PriorityTag<10>{}, MathOverloads::ADLTag{}); \
│ │ │ │ +
274 } \
│ │ │ │ +
275 }; \
│ │ │ │ +
276 static_assert(true, "Require semicolon to unconfuse editors")
│ │ │ │ +
│ │ │ │ +
277
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
281#undef DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR
│ │ │ │ +
282
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
284 template<class T>
│ │ │ │ +
│ │ │ │ +
285 constexpr auto operator()(const T &t1, const T &t2) const {
│ │ │ │ +
286 return isUnordered(t1, t2, PriorityTag<10>{}, MathOverloads::ADLTag{});
│ │ │ │ +
287 }
│ │ │ │ +
│ │ │ │ +
288 };
│ │ │ │ +
│ │ │ │ +
289
│ │ │ │ +
290 } //MathImpl
│ │ │ │ +
│ │ │ │ +
291
│ │ │ │ +
292
│ │ │ │ +
293 namespace Impl {
│ │ │ │ +
294 /* This helper has a math functor as a static constexpr member. Doing
│ │ │ │ +
295 this as a static member of a template struct means we can do this
│ │ │ │ +
296 without violating the ODR or putting the definition into a separate
│ │ │ │ +
297 compilation unit, while still still ensuring the functor is the same
│ │ │ │ +
298 lvalue across all compilation units.
│ │ │ │ +
299 */
│ │ │ │ +
300 template<class T>
│ │ │ │ +
301 struct MathDummy
│ │ │ │ +
302 {
│ │ │ │ +
303 static constexpr T value{};
│ │ │ │ +
304 };
│ │ │ │ +
305
│ │ │ │ +
306 template<class T>
│ │ │ │ +
307 constexpr T MathDummy<T>::value;
│ │ │ │ +
308
│ │ │ │ +
309 } //namespace Impl
│ │ │ │ +
310
│ │ │ │ +
311 namespace {
│ │ │ │ +
312 /* Provide the math functors directly in the `Dune` namespace.
│ │ │ │ +
313
│ │ │ │ +
314 This actually declares a different name in each translation unit, but
│ │ │ │ +
315 they all resolve to the same lvalue.
│ │ │ │ +
316 */
│ │ │ │ +
317
│ │ │ │ +
319
│ │ │ │ +
323 constexpr auto const &isNaN = Impl::MathDummy<MathImpl::isNaNImpl>::value;
│ │ │ │ +
324
│ │ │ │ +
326
│ │ │ │ +
330 constexpr auto const &isInf = Impl::MathDummy<MathImpl::isInfImpl>::value;
│ │ │ │ +
331
│ │ │ │ +
333
│ │ │ │ +
337 constexpr auto const &isFinite = Impl::MathDummy<MathImpl::isFiniteImpl>::value;
│ │ │ │ +
338
│ │ │ │ +
340
│ │ │ │ +
345 constexpr auto const &isUnordered = Impl::MathDummy<MathImpl::isUnorderedImpl>::value;
│ │ │ │ +
346 }
│ │ │ │ +
347
│ │ │ │ +
348 namespace MathOverloads {
│ │ │ │ +
349 /*Overloads for complex types*/
│ │ │ │ +
350 template<class T, class = std::enable_if_t<Impl::isComplexLike<T>::value> >
│ │ │ │ +
│ │ │ │ +
351 auto isNaN(const T &t, PriorityTag<2>, ADLTag) {
│ │ │ │ +
352 return Dune::isNaN(real(t)) || Dune::isNaN(imag(t));
│ │ │ │ +
353 }
│ │ │ │ +
│ │ │ │ +
354
│ │ │ │ +
355 template<class T, class = std::enable_if_t<Impl::isComplexLike<T>::value> >
│ │ │ │ +
│ │ │ │ +
356 auto isInf(const T &t, PriorityTag<2>, ADLTag) {
│ │ │ │ +
357 return Dune::isInf(real(t)) || Dune::isInf(imag(t));
│ │ │ │ +
358 }
│ │ │ │ +
│ │ │ │ +
359
│ │ │ │ +
360 template<class T, class = std::enable_if_t<Impl::isComplexLike<T>::value> >
│ │ │ │ +
│ │ │ │ +
361 auto isFinite(const T &t, PriorityTag<2>, ADLTag) {
│ │ │ │ +
362 return Dune::isFinite(real(t)) && Dune::isFinite(imag(t));
│ │ │ │ +
363 }
│ │ │ │ +
│ │ │ │ +
364 } //MathOverloads
│ │ │ │ +
365}
│ │ │ │ +
366
│ │ │ │ +
367#endif // #ifndef DUNE_MATH_HH
│ │ │ │ +
#define DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR(function)
Definition math.hh:269
│ │ │ │ +
#define DUNE_COMMON_MATH_ISFUNCTION(function, stdfunction)
Definition math.hh:232
│ │ │ │ +
Utilities for type computations, constraining overloads, ...
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
Definition binaryfunctions.hh:18
│ │ │ │ -
Type result_type
Definition binaryfunctions.hh:23
│ │ │ │ -
Type operator()(const Type &t1, const Type &t2) const
Definition binaryfunctions.hh:25
│ │ │ │ -
Type first_argument_type
Definition binaryfunctions.hh:19
│ │ │ │ -
Type second_argument_type
Definition binaryfunctions.hh:21
│ │ │ │ -
Definition binaryfunctions.hh:34
│ │ │ │ -
Type operator()(const Type &t1, const Type &t2) const
Definition binaryfunctions.hh:41
│ │ │ │ -
Type result_type
Definition binaryfunctions.hh:39
│ │ │ │ -
Type first_argument_type
Definition binaryfunctions.hh:35
│ │ │ │ -
Type second_argument_type
Definition binaryfunctions.hh:37
│ │ │ │ +
static constexpr T binomial(const T &n, const T &k) noexcept
calculate the binomial coefficient n over k as a constexpr
Definition math.hh:131
│ │ │ │ +
constexpr Base power(Base m, Exponent p)
Power method for integer exponents.
Definition math.hh:75
│ │ │ │ +
static constexpr T factorial(const T &n) noexcept
calculate the factorial of n as a constexpr
Definition math.hh:111
│ │ │ │ +
int sign(const T &val)
Return the sign of the value.
Definition math.hh:180
│ │ │ │ +
K conjugateComplex(const K &x)
compute conjugate complex of x
Definition math.hh:164
│ │ │ │ +
bool isNaN(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag)
Returns whether any entry is NaN.
Definition fvector.hh:627
│ │ │ │ +
bool isInf(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag)
Returns whether any entry is infinite.
Definition fvector.hh:615
│ │ │ │ +
auto isFinite(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag)
Returns whether all entries are finite.
Definition fvector.hh:604
│ │ │ │ +
bool isUnordered(const FieldVector< K, 1 > &b, const FieldVector< K, 1 > &c, PriorityTag< 2 >, ADLTag)
Returns true if either b or c is NaN.
Definition fvector.hh:639
│ │ │ │ +
Standard implementation of MathematicalConstants.
Definition math.hh:34
│ │ │ │ +
static const T e()
Euler's number.
Definition math.hh:38
│ │ │ │ +
static const T pi()
Archimedes' constant.
Definition math.hh:48
│ │ │ │ +
Provides commonly used mathematical constants.
Definition math.hh:67
│ │ │ │ +
Definition math.hh:94
│ │ │ │ +
static constexpr int factorial
factorial stores m!
Definition math.hh:96
│ │ │ │ +
Tag to make sure the functions in this namespace can be found by ADL.
Definition math.hh:230
│ │ │ │ +
Definition math.hh:283
│ │ │ │ +
constexpr auto operator()(const T &t1, const T &t2) const
Definition math.hh:285
│ │ │ │ +
Helper class for tagging priorities.
Definition typeutilities.hh:73
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,93 +1,385 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -binaryfunctions.hh │ │ │ │ │ +math.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_BINARYFUNCTIONS_HH │ │ │ │ │ -6#define DUNE_BINARYFUNCTIONS_HH │ │ │ │ │ +5#ifndef DUNE_MATH_HH │ │ │ │ │ +6#define DUNE_MATH_HH │ │ │ │ │ 7 │ │ │ │ │ -12#include │ │ │ │ │ -13 │ │ │ │ │ -14namespace Dune │ │ │ │ │ -15{ │ │ │ │ │ -16 template │ │ │ │ │ -17 struct Min │ │ │ │ │ -18 { │ │ │ │ │ -19 using first_argument_type [[deprecated("This type alias is deprecated │ │ │ │ │ -following similar deprecations in C++17")]] = Type; │ │ │ │ │ -20 │ │ │ │ │ -21 using second_argument_type [[deprecated("This type alias is deprecated │ │ │ │ │ -following similar deprecations in C++17")]] = Type; │ │ │ │ │ -22 │ │ │ │ │ -23 using result_type [[deprecated("This type alias is deprecated following │ │ │ │ │ -similar deprecations in C++17")]] = Type; │ │ │ │ │ -24 │ │ │ │ │ -25 Type operator()(const Type& t1, const Type& t2) const │ │ │ │ │ -26 { │ │ │ │ │ -27 using std::min; │ │ │ │ │ -28 return min(t1,t2); │ │ │ │ │ -29 } │ │ │ │ │ -30 }; │ │ │ │ │ -31 │ │ │ │ │ -32 template │ │ │ │ │ -33 struct Max │ │ │ │ │ +12#include │ │ │ │ │ +13#include │ │ │ │ │ +14#include │ │ │ │ │ +15#include │ │ │ │ │ +16 │ │ │ │ │ +17#include │ │ │ │ │ +18 │ │ │ │ │ +19namespace Dune │ │ │ │ │ +20{ │ │ │ │ │ +21 │ │ │ │ │ +32 template< class T > │ │ │ │ │ +33 struct StandardMathematicalConstants │ │ │ │ │ 34 { │ │ │ │ │ -35 using first_argument_type [[deprecated("This type alias is deprecated │ │ │ │ │ -following similar deprecations in C++17")]] = Type; │ │ │ │ │ -36 │ │ │ │ │ -37 using second_argument_type [[deprecated("This type alias is deprecated │ │ │ │ │ -following similar deprecations in C++17")]] = Type; │ │ │ │ │ -38 │ │ │ │ │ -39 using result_type [[deprecated("This type alias is deprecated following │ │ │ │ │ -similar deprecations in C++17")]] = Type; │ │ │ │ │ -40 │ │ │ │ │ -41 Type operator()(const Type& t1, const Type& t2) const │ │ │ │ │ -42 { │ │ │ │ │ -43 using std::max; │ │ │ │ │ -44 return max(t1,t2); │ │ │ │ │ -45 } │ │ │ │ │ -46 }; │ │ │ │ │ -47} │ │ │ │ │ -48 │ │ │ │ │ -49#endif │ │ │ │ │ +38 static const T e () │ │ │ │ │ +39 { │ │ │ │ │ +40 using std::exp; │ │ │ │ │ +41 static const T e = exp( T( 1 ) ); │ │ │ │ │ +42 return e; │ │ │ │ │ +43 } │ │ │ │ │ +44 │ │ │ │ │ +48 static const T pi () │ │ │ │ │ +49 { │ │ │ │ │ +50 using std::acos; │ │ │ │ │ +51 static const T pi = acos( T( -1 ) ); │ │ │ │ │ +52 return pi; │ │ │ │ │ +53 } │ │ │ │ │ +54 }; │ │ │ │ │ +55 │ │ │ │ │ +56 │ │ │ │ │ +64 template< class Field > │ │ │ │ │ +65 struct MathematicalConstants │ │ │ │ │ +66 : public StandardMathematicalConstants │ │ │ │ │ +67 {}; │ │ │ │ │ +68 │ │ │ │ │ +69 │ │ │ │ │ +74 template │ │ │ │ │ +75 constexpr Base power(Base m, Exponent p) │ │ │ │ │ +76 { │ │ │ │ │ +77 static_assert(std::numeric_limits::is_integer, "Exponent must be │ │ │ │ │ +an integer type!"); │ │ │ │ │ +78 │ │ │ │ │ +79 auto result = Base(1); │ │ │ │ │ +80 auto absp = (p<0) ? -p : p; // This is simply abs, but std::abs is not │ │ │ │ │ +constexpr │ │ │ │ │ +81 for (Exponent i = Exponent(0); i │ │ │ │ │ +93 struct Factorial │ │ │ │ │ +94 { │ │ │ │ │ +96 static constexpr int factorial = m * Factorial::factorial; │ │ │ │ │ +97 }; │ │ │ │ │ +98 │ │ │ │ │ +100 template <> │ │ │ │ │ +101 struct [[deprecated("Use function factorial instead! Will be removed after │ │ │ │ │ +Dune 2.9")]] Factorial<0> │ │ │ │ │ +102 { │ │ │ │ │ +103 // 0! = 1 │ │ │ │ │ +104 static constexpr int factorial = 1; │ │ │ │ │ +105 }; │ │ │ │ │ +106 │ │ │ │ │ +107 │ │ │ │ │ +109 // T has to be an integral type │ │ │ │ │ +110 template │ │ │ │ │ +111 constexpr inline static T factorial(const T& n) noexcept │ │ │ │ │ +112 { │ │ │ │ │ +113 static_assert(std::numeric_limits::is_integer, "`factorial(n)` has to be │ │ │ │ │ +called with an integer type."); │ │ │ │ │ +114 T fac = 1; │ │ │ │ │ +115 for(T k = 0; k < n; ++k) │ │ │ │ │ +116 fac *= k+1; │ │ │ │ │ +117 return fac; │ │ │ │ │ +118 } │ │ │ │ │ +119 │ │ │ │ │ +121 template │ │ │ │ │ +122 constexpr inline static auto factorial (std::integral_constant) │ │ │ │ │ +noexcept │ │ │ │ │ +123 { │ │ │ │ │ +124 return std::integral_constant{}; │ │ │ │ │ +125 } │ │ │ │ │ +126 │ │ │ │ │ +127 │ │ │ │ │ +129 // T has to be an integral type │ │ │ │ │ +130 template │ │ │ │ │ +131 constexpr inline static T binomial (const T& n, const T& k) noexcept │ │ │ │ │ +132 { │ │ │ │ │ +133 static_assert(std::numeric_limits::is_integer, "`binomial(n, k)` has to │ │ │ │ │ +be called with an integer type."); │ │ │ │ │ +134 │ │ │ │ │ +135 if( k < 0 || k > n ) │ │ │ │ │ +136 return 0; │ │ │ │ │ +137 │ │ │ │ │ +138 if (2*k > n) │ │ │ │ │ +139 return binomial(n, n-k); │ │ │ │ │ +140 │ │ │ │ │ +141 T bin = 1; │ │ │ │ │ +142 for(auto i = n-k; i < n; ++i) │ │ │ │ │ +143 bin *= i+1; │ │ │ │ │ +144 return bin / factorial(k); │ │ │ │ │ +145 } │ │ │ │ │ +146 │ │ │ │ │ +148 template │ │ │ │ │ +149 constexpr inline static auto binomial (std::integral_constant, std:: │ │ │ │ │ +integral_constant) noexcept │ │ │ │ │ +150 { │ │ │ │ │ +151 return std::integral_constant{}; │ │ │ │ │ +152 } │ │ │ │ │ +153 │ │ │ │ │ +154 template │ │ │ │ │ +155 constexpr inline static auto binomial (std::integral_constant, std:: │ │ │ │ │ +integral_constant) noexcept │ │ │ │ │ +156 { │ │ │ │ │ +157 return std::integral_constant= 0 ? 1 : 0)>{}; │ │ │ │ │ +158 } │ │ │ │ │ +159 │ │ │ │ │ +160 │ │ │ │ │ +162 // conjugate complex does nothing for non-complex types │ │ │ │ │ +163 template │ │ │ │ │ +164 inline K conjugateComplex (const K& x) │ │ │ │ │ +165 { │ │ │ │ │ +166 return x; │ │ │ │ │ +167 } │ │ │ │ │ +168 │ │ │ │ │ +169#ifndef DOXYGEN │ │ │ │ │ +170 // specialization for complex │ │ │ │ │ +171 template │ │ │ │ │ +172 inline std::complex conjugateComplex (const std::complex& c) │ │ │ │ │ +173 { │ │ │ │ │ +174 return std::complex(c.real(),-c.imag()); │ │ │ │ │ +175 } │ │ │ │ │ +176#endif │ │ │ │ │ +177 │ │ │ │ │ +179 template │ │ │ │ │ +180 int sign(const T& val) │ │ │ │ │ +181 { │ │ │ │ │ +182 return (val < 0 ? -1 : 1); │ │ │ │ │ +183 } │ │ │ │ │ +184 │ │ │ │ │ +185 │ │ │ │ │ +186 namespace Impl { │ │ │ │ │ +187 // Returns whether a given type behaves like std::complex<>, i.e. whether │ │ │ │ │ +188 // real() and imag() are defined │ │ │ │ │ +189 template │ │ │ │ │ +190 struct isComplexLike { │ │ │ │ │ +191 private: │ │ │ │ │ +192 template │ │ │ │ │ +193 static auto test(U* u) -> decltype(u->real(), u->imag(), std::true_type()); │ │ │ │ │ +194 │ │ │ │ │ +195 template │ │ │ │ │ +196 static auto test(...) -> decltype(std::false_type()); │ │ │ │ │ +197 │ │ │ │ │ +198 public: │ │ │ │ │ +199 static const bool value = decltype(test(0))::value; │ │ │ │ │ +200 }; │ │ │ │ │ +201 } // namespace Impl │ │ │ │ │ +202 │ │ │ │ │ +204 │ │ │ │ │ +227 namespace MathOverloads { │ │ │ │ │ +228 │ │ │ │ │ +230 struct ADLTag {}; │ │ │ │ │ +231 │ │ │ │ │ +232#define DUNE_COMMON_MATH_ISFUNCTION(function, stdfunction) \ │ │ │ │ │ +233 template \ │ │ │ │ │ +234 auto function(const T &t, PriorityTag<1>, ADLTag) \ │ │ │ │ │ +235 -> decltype(function(t)) { \ │ │ │ │ │ +236 return function(t); \ │ │ │ │ │ +237 } \ │ │ │ │ │ +238 template \ │ │ │ │ │ +239 auto function(const T &t, PriorityTag<0>, ADLTag) { \ │ │ │ │ │ +240 using std::stdfunction; \ │ │ │ │ │ +241 return stdfunction(t); \ │ │ │ │ │ +242 } \ │ │ │ │ │ +243 static_assert(true, "Require semicolon to unconfuse editors") │ │ │ │ │ +244 │ │ │ │ │ +245 DUNE_COMMON_MATH_ISFUNCTION(isNaN,isnan); │ │ │ │ │ +246 DUNE_COMMON_MATH_ISFUNCTION(isInf,isinf); │ │ │ │ │ +247 DUNE_COMMON_MATH_ISFUNCTION(isFinite,isfinite); │ │ │ │ │ +248#undef DUNE_COMMON_MATH_ISFUNCTION │ │ │ │ │ +249 │ │ │ │ │ +250 template │ │ │ │ │ +251 auto isUnordered(const T &t1, const T &t2, PriorityTag<1>, ADLTag) │ │ │ │ │ +252 -> decltype(isUnordered(t1, t2)) { │ │ │ │ │ +253 return isUnordered(t1, t2); │ │ │ │ │ +254 } │ │ │ │ │ +255 │ │ │ │ │ +256 template │ │ │ │ │ +257 auto isUnordered(const T &t1, const T &t2, PriorityTag<0>, ADLTag) { │ │ │ │ │ +258 using std::isunordered; │ │ │ │ │ +259 return isunordered(t1, t2); │ │ │ │ │ +260 } │ │ │ │ │ +261 } │ │ │ │ │ +262 │ │ │ │ │ +263 namespace MathImpl { │ │ │ │ │ +264 │ │ │ │ │ +265 // NOTE: it is important that these functors have names different from the │ │ │ │ │ +266 // names of the functions they are forwarding to. Otherwise the │ │ │ │ │ +267 // unqualified call would find the functor type, not a function, and ADL │ │ │ │ │ +268 // would never be attempted. │ │ │ │ │ +269#define DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR(function) \ │ │ │ │ │ +270 struct function##Impl { \ │ │ │ │ │ +271 template \ │ │ │ │ │ +272 constexpr auto operator()(const T &t) const { \ │ │ │ │ │ +273 return function(t, PriorityTag<10>{}, MathOverloads::ADLTag{}); \ │ │ │ │ │ +274 } \ │ │ │ │ │ +275 }; \ │ │ │ │ │ +276 static_assert(true, "Require semicolon to unconfuse editors") │ │ │ │ │ +277 │ │ │ │ │ +278 DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR(isNaN); │ │ │ │ │ +279 DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR(isInf); │ │ │ │ │ +280 DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR(isFinite); │ │ │ │ │ +281#undef DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR │ │ │ │ │ +282 │ │ │ │ │ +283 struct isUnorderedImpl { │ │ │ │ │ +284 template │ │ │ │ │ +285 constexpr auto operator()(const T &t1, const T &t2) const { │ │ │ │ │ +286 return isUnordered(t1, t2, PriorityTag<10>{}, MathOverloads::ADLTag{}); │ │ │ │ │ +287 } │ │ │ │ │ +288 }; │ │ │ │ │ +289 │ │ │ │ │ +290 } //MathImpl │ │ │ │ │ +291 │ │ │ │ │ +292 │ │ │ │ │ +293 namespace Impl { │ │ │ │ │ +294 /* This helper has a math functor as a static constexpr member. Doing │ │ │ │ │ +295 this as a static member of a template struct means we can do this │ │ │ │ │ +296 without violating the ODR or putting the definition into a separate │ │ │ │ │ +297 compilation unit, while still still ensuring the functor is the same │ │ │ │ │ +298 lvalue across all compilation units. │ │ │ │ │ +299 */ │ │ │ │ │ +300 template │ │ │ │ │ +301 struct MathDummy │ │ │ │ │ +302 { │ │ │ │ │ +303 static constexpr T value{}; │ │ │ │ │ +304 }; │ │ │ │ │ +305 │ │ │ │ │ +306 template │ │ │ │ │ +307 constexpr T MathDummy::value; │ │ │ │ │ +308 │ │ │ │ │ +309 } //namespace Impl │ │ │ │ │ +310 │ │ │ │ │ +311 namespace { │ │ │ │ │ +312 /* Provide the math functors directly in the `Dune` namespace. │ │ │ │ │ +313 │ │ │ │ │ +314 This actually declares a different name in each translation unit, but │ │ │ │ │ +315 they all resolve to the same lvalue. │ │ │ │ │ +316 */ │ │ │ │ │ +317 │ │ │ │ │ +319 │ │ │ │ │ +323 constexpr auto const &isNaN = Impl::MathDummy::value; │ │ │ │ │ +324 │ │ │ │ │ +326 │ │ │ │ │ +330 constexpr auto const &isInf = Impl::MathDummy::value; │ │ │ │ │ +331 │ │ │ │ │ +333 │ │ │ │ │ +337 constexpr auto const &isFinite = Impl::MathDummy:: │ │ │ │ │ +value; │ │ │ │ │ +338 │ │ │ │ │ +340 │ │ │ │ │ +345 constexpr auto const &isUnordered = Impl::MathDummy::value; │ │ │ │ │ +346 } │ │ │ │ │ +347 │ │ │ │ │ +348 namespace MathOverloads { │ │ │ │ │ +349 /*Overloads for complex types*/ │ │ │ │ │ +350 template::value> > │ │ │ │ │ +351 auto isNaN(const T &t, PriorityTag<2>, ADLTag) { │ │ │ │ │ +352 return Dune::isNaN(real(t)) || Dune::isNaN(imag(t)); │ │ │ │ │ +353 } │ │ │ │ │ +354 │ │ │ │ │ +355 template::value> > │ │ │ │ │ +356 auto isInf(const T &t, PriorityTag<2>, ADLTag) { │ │ │ │ │ +357 return Dune::isInf(real(t)) || Dune::isInf(imag(t)); │ │ │ │ │ +358 } │ │ │ │ │ +359 │ │ │ │ │ +360 template::value> > │ │ │ │ │ +361 auto isFinite(const T &t, PriorityTag<2>, ADLTag) { │ │ │ │ │ +362 return Dune::isFinite(real(t)) && Dune::isFinite(imag(t)); │ │ │ │ │ +363 } │ │ │ │ │ +364 } //MathOverloads │ │ │ │ │ +365} │ │ │ │ │ +366 │ │ │ │ │ +367#endif // #ifndef DUNE_MATH_HH │ │ │ │ │ +DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR │ │ │ │ │ +#define DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR(function) │ │ │ │ │ +Definition math.hh:269 │ │ │ │ │ +DUNE_COMMON_MATH_ISFUNCTION │ │ │ │ │ +#define DUNE_COMMON_MATH_ISFUNCTION(function, stdfunction) │ │ │ │ │ +Definition math.hh:232 │ │ │ │ │ +typeutilities.hh │ │ │ │ │ +Utilities for type computations, constraining overloads, ... │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::Min │ │ │ │ │ -Definition binaryfunctions.hh:18 │ │ │ │ │ -Dune::Min::result_type │ │ │ │ │ -Type result_type │ │ │ │ │ -Definition binaryfunctions.hh:23 │ │ │ │ │ -Dune::Min::operator() │ │ │ │ │ -Type operator()(const Type &t1, const Type &t2) const │ │ │ │ │ -Definition binaryfunctions.hh:25 │ │ │ │ │ -Dune::Min::first_argument_type │ │ │ │ │ -Type first_argument_type │ │ │ │ │ -Definition binaryfunctions.hh:19 │ │ │ │ │ -Dune::Min::second_argument_type │ │ │ │ │ -Type second_argument_type │ │ │ │ │ -Definition binaryfunctions.hh:21 │ │ │ │ │ -Dune::Max │ │ │ │ │ -Definition binaryfunctions.hh:34 │ │ │ │ │ -Dune::Max::operator() │ │ │ │ │ -Type operator()(const Type &t1, const Type &t2) const │ │ │ │ │ -Definition binaryfunctions.hh:41 │ │ │ │ │ -Dune::Max::result_type │ │ │ │ │ -Type result_type │ │ │ │ │ -Definition binaryfunctions.hh:39 │ │ │ │ │ -Dune::Max::first_argument_type │ │ │ │ │ -Type first_argument_type │ │ │ │ │ -Definition binaryfunctions.hh:35 │ │ │ │ │ -Dune::Max::second_argument_type │ │ │ │ │ -Type second_argument_type │ │ │ │ │ -Definition binaryfunctions.hh:37 │ │ │ │ │ +Dune::binomial │ │ │ │ │ +static constexpr T binomial(const T &n, const T &k) noexcept │ │ │ │ │ +calculate the binomial coefficient n over k as a constexpr │ │ │ │ │ +Definition math.hh:131 │ │ │ │ │ +Dune::power │ │ │ │ │ +constexpr Base power(Base m, Exponent p) │ │ │ │ │ +Power method for integer exponents. │ │ │ │ │ +Definition math.hh:75 │ │ │ │ │ +Dune::factorial │ │ │ │ │ +static constexpr T factorial(const T &n) noexcept │ │ │ │ │ +calculate the factorial of n as a constexpr │ │ │ │ │ +Definition math.hh:111 │ │ │ │ │ +Dune::sign │ │ │ │ │ +int sign(const T &val) │ │ │ │ │ +Return the sign of the value. │ │ │ │ │ +Definition math.hh:180 │ │ │ │ │ +Dune::conjugateComplex │ │ │ │ │ +K conjugateComplex(const K &x) │ │ │ │ │ +compute conjugate complex of x │ │ │ │ │ +Definition math.hh:164 │ │ │ │ │ +Dune::MathOverloads::isNaN │ │ │ │ │ +bool isNaN(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag) │ │ │ │ │ +Returns whether any entry is NaN. │ │ │ │ │ +Definition fvector.hh:627 │ │ │ │ │ +Dune::MathOverloads::isInf │ │ │ │ │ +bool isInf(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag) │ │ │ │ │ +Returns whether any entry is infinite. │ │ │ │ │ +Definition fvector.hh:615 │ │ │ │ │ +Dune::MathOverloads::isFinite │ │ │ │ │ +auto isFinite(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag) │ │ │ │ │ +Returns whether all entries are finite. │ │ │ │ │ +Definition fvector.hh:604 │ │ │ │ │ +Dune::MathOverloads::isUnordered │ │ │ │ │ +bool isUnordered(const FieldVector< K, 1 > &b, const FieldVector< K, 1 > &c, │ │ │ │ │ +PriorityTag< 2 >, ADLTag) │ │ │ │ │ +Returns true if either b or c is NaN. │ │ │ │ │ +Definition fvector.hh:639 │ │ │ │ │ +Dune::StandardMathematicalConstants │ │ │ │ │ +Standard implementation of MathematicalConstants. │ │ │ │ │ +Definition math.hh:34 │ │ │ │ │ +Dune::StandardMathematicalConstants::e │ │ │ │ │ +static const T e() │ │ │ │ │ +Euler's number. │ │ │ │ │ +Definition math.hh:38 │ │ │ │ │ +Dune::StandardMathematicalConstants::pi │ │ │ │ │ +static const T pi() │ │ │ │ │ +Archimedes' constant. │ │ │ │ │ +Definition math.hh:48 │ │ │ │ │ +Dune::MathematicalConstants │ │ │ │ │ +Provides commonly used mathematical constants. │ │ │ │ │ +Definition math.hh:67 │ │ │ │ │ +Dune::Factorial │ │ │ │ │ +Definition math.hh:94 │ │ │ │ │ +Dune::Factorial::factorial │ │ │ │ │ +static constexpr int factorial │ │ │ │ │ +factorial stores m! │ │ │ │ │ +Definition math.hh:96 │ │ │ │ │ +Dune::MathOverloads::ADLTag │ │ │ │ │ +Tag to make sure the functions in this namespace can be found by ADL. │ │ │ │ │ +Definition math.hh:230 │ │ │ │ │ +Dune::MathImpl::isUnorderedImpl │ │ │ │ │ +Definition math.hh:283 │ │ │ │ │ +Dune::MathImpl::isUnorderedImpl::operator() │ │ │ │ │ +constexpr auto operator()(const T &t1, const T &t2) const │ │ │ │ │ +Definition math.hh:285 │ │ │ │ │ +Dune::PriorityTag │ │ │ │ │ +Helper class for tagging priorities. │ │ │ │ │ +Definition typeutilities.hh:73 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00098.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: sllist.hh File Reference │ │ │ │ +dune-common: simd.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -72,58 +72,94 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ Namespaces | │ │ │ │ +Typedefs | │ │ │ │ Functions
│ │ │ │ -
sllist.hh File Reference
│ │ │ │ +
simd.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ -

Implements a singly linked list together with the necessary iterators. │ │ │ │ +

Abstractions for support of dedicated SIMD data types. │ │ │ │ More...

│ │ │ │ -
#include <memory>
│ │ │ │ -#include <cassert>
│ │ │ │ -#include "iteratorfacades.hh"
│ │ │ │ -#include <ostream>
│ │ │ │ +
#include <cassert>
│ │ │ │ +#include <cstddef>
│ │ │ │ +#include <type_traits>
│ │ │ │ +#include <utility>
│ │ │ │ +#include <dune/common/conditional.hh>
│ │ │ │ +#include <dune/common/debugalign.hh>
│ │ │ │ +#include <dune/common/rangeutilities.hh>
│ │ │ │ +#include <dune/common/typetraits.hh>
│ │ │ │ +#include <dune/common/vc.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::SLList< T, A >
 A single linked list. More...
struct  Dune::SimdScalarTypeTraits< T >
 
class  Dune::SLListIterator< T, A >
 A mutable iterator for the SLList. More...
struct  Dune::SimdScalarTypeTraits< AlignedNumber< T, align > >
 deduce the underlying scalar data type of an AlignedNumber More...
 
class  Dune::SLListConstIterator< T, A >
 A constant iterator for the SLList. More...
struct  Dune::SimdIndexTypeTraits< V, typename >
 
class  Dune::SLListModifyIterator< T, A >
 A mutable iterator for the SLList. More...
struct  Dune::SimdMaskTypeTraits< V, typename >
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Typedefs

template<typename T >
using Dune::SimdScalar = typename SimdScalarTypeTraits< T >::type
 
template<typename V >
using Dune::SimdIndex = typename SimdIndexTypeTraits< V >::type
 An simd vector of indices corresponding to a simd vector V.
 
template<typename V >
using Dune::SimdMask = typename SimdMaskTypeTraits< V >::type
 A simd vector of truth values corresponding to a simd vector V.
 
│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Functions

template<typename T , typename A >
std::ostream & Dune::operator<< (std::ostream &os, const SLList< T, A > &sllist)
 
template<class T >
std::size_t Dune::lanes (const T &)
 get the number of lanes of a simd vector (scalar version)
 
template<class T >
Dune::lane (std::size_t l, const T &v)
 access a lane of a simd vector (scalar version)
 
template<class T >
T & Dune::lane (std::size_t l, T &v)
 access a lane of a simd vector (scalar version)
 
template<class T >
void Dune::assign (T &dst, const T &src, bool mask)
 masked Simd assignment (scalar version)
 
template<class T >
void Dune::swap (T &v1, T &v2, bool mask)
 
│ │ │ │

Detailed Description

│ │ │ │ -

Implements a singly linked list together with the necessary iterators.

│ │ │ │ -
Author
Markus Blatt
│ │ │ │ +

Abstractions for support of dedicated SIMD data types.

│ │ │ │ +

Libraries like Vc (https://github.com/VcDevel/Vc) add high-level data types for SIMD (or vectorization) support in C++. Most of these operations mimic the behavior of a numerical data type. Some boolean operations can not be implemented in a compatible way to trivial data types.

│ │ │ │ +

This header contains additional abstractions to help writing code that works with trivial numerical data types (like double) and Vc vectorization data types.

│ │ │ │ +

See also the conditional.hh and range_utils.hh headers.

│ │ │ │ +
Deprecated:
Use the newer simd architecture from dune/common/simd/simd.hh instead.
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,43 +1,79 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Functions │ │ │ │ │ -sllist.hh File Reference │ │ │ │ │ -Common │ │ │ │ │ -Implements a singly linked list together with the necessary iterators. More... │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces | Typedefs | Functions │ │ │ │ │ +simd.hh File Reference │ │ │ │ │ +Abstractions for support of dedicated SIMD data types. More... │ │ │ │ │ #include │ │ │ │ │ -#include "iteratorfacades.hh" │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class   Dune::SLList<_T,_A_> │ │ │ │ │ -  A single linked list. More... │ │ │ │ │ +struct   Dune::SimdScalarTypeTraits<_T_> │ │ │ │ │   │ │ │ │ │ -class   Dune::SLListIterator<_T,_A_> │ │ │ │ │ -  A mutable iterator for the SLList. More... │ │ │ │ │ +struct   Dune::SimdScalarTypeTraits<_AlignedNumber<_T,_align_>_> │ │ │ │ │ +  deduce the underlying scalar data type of an AlignedNumber More... │ │ │ │ │   │ │ │ │ │ -class   Dune::SLListConstIterator<_T,_A_> │ │ │ │ │ -  A constant iterator for the SLList. More... │ │ │ │ │ +struct   Dune::SimdIndexTypeTraits<_V,_typename_> │ │ │ │ │   │ │ │ │ │ -class   Dune::SLListModifyIterator<_T,_A_> │ │ │ │ │ -  A mutable iterator for the SLList. More... │ │ │ │ │ +struct   Dune::SimdMaskTypeTraits<_V,_typename_> │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ +Typedefs │ │ │ │ │ +template │ │ │ │ │ +using  Dune::SimdScalar = typename SimdScalarTypeTraits< T >::type │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +using  Dune::SimdIndex = typename SimdIndexTypeTraits< V >::type │ │ │ │ │ +  An simd vector of indices corresponding to a simd vector V. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +using  Dune::SimdMask = typename SimdMaskTypeTraits< V >::type │ │ │ │ │ +  A simd vector of truth values corresponding to a simd vector V. │ │ │ │ │ +  │ │ │ │ │ Functions │ │ │ │ │ -template │ │ │ │ │ -std::ostream &  Dune::operator<< (std::ostream &os, const SLList< T, A > │ │ │ │ │ - &sllist) │ │ │ │ │ +template │ │ │ │ │ +std::size_t  Dune::lanes (const T &) │ │ │ │ │ +  get the number of lanes of a simd vector (scalar version) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + T  Dune::lane (std::size_t l, const T &v) │ │ │ │ │ +  access a lane of a simd vector (scalar version) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + T &  Dune::lane (std::size_t l, T &v) │ │ │ │ │ +  access a lane of a simd vector (scalar version) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + void  Dune::assign (T &dst, const T &src, bool mask) │ │ │ │ │ +  masked Simd assignment (scalar version) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + void  Dune::swap (T &v1, T &v2, bool mask) │ │ │ │ │   │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Implements a singly linked list together with the necessary iterators. │ │ │ │ │ - Author │ │ │ │ │ - Markus Blatt │ │ │ │ │ +Abstractions for support of dedicated SIMD data types. │ │ │ │ │ +Libraries like Vc (https://github.com/VcDevel/Vc) add high-level data types for │ │ │ │ │ +SIMD (or vectorization) support in C++. Most of these operations mimic the │ │ │ │ │ +behavior of a numerical data type. Some boolean operations can not be │ │ │ │ │ +implemented in a compatible way to trivial data types. │ │ │ │ │ +This header contains additional abstractions to help writing code that works │ │ │ │ │ +with trivial numerical data types (like double) and Vc vectorization data │ │ │ │ │ +types. │ │ │ │ │ +See also the conditional.hh and range_utils.hh headers. │ │ │ │ │ + Deprecated: │ │ │ │ │ + Use the newer simd architecture from dune/common/simd/simd.hh instead. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00098_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: sllist.hh Source File │ │ │ │ +dune-common: simd.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,780 +74,518 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
sllist.hh
│ │ │ │ +
simd.hh
│ │ │ │
│ │ │ │
│ │ │ │ -Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │ -
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │ -
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ -
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_SLLIST_HH
│ │ │ │ -
6#define DUNE_SLLIST_HH
│ │ │ │ -
7
│ │ │ │ -
8#include <memory>
│ │ │ │ -
9#include <cassert>
│ │ │ │ -
10#include "iteratorfacades.hh"
│ │ │ │ -
11#include <ostream>
│ │ │ │ -
12
│ │ │ │ -
13namespace Dune
│ │ │ │ -
14{
│ │ │ │ -
26 template<typename T, class A>
│ │ │ │ -
27 class SLListIterator;
│ │ │ │ -
28
│ │ │ │ -
29 template<typename T, class A>
│ │ │ │ -
30 class SLListConstIterator;
│ │ │ │ -
31
│ │ │ │ -
32 template<typename T, class A>
│ │ │ │ -
33 class SLListModifyIterator;
│ │ │ │ +Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ +
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ +
3#ifndef DUNE_COMMON_SIMD_HH
│ │ │ │ +
4#define DUNE_COMMON_SIMD_HH
│ │ │ │ +
5
│ │ │ │ +
6#warning dune/common/simd.hh is deprecated.
│ │ │ │ +
7#warning Use the new infrastructure from dune/common/simd/simd.h instead.
│ │ │ │ +
8
│ │ │ │ +
30#include <cassert>
│ │ │ │ +
31#include <cstddef>
│ │ │ │ +
32#include <type_traits>
│ │ │ │ +
33#include <utility>
│ │ │ │
34
│ │ │ │ -
42 template<typename T, class A=std::allocator<T> >
│ │ │ │ -
│ │ │ │ -
43 class SLList
│ │ │ │ -
44 {
│ │ │ │ -
45 struct Element;
│ │ │ │ -
46 friend class SLListIterator<T,A>;
│ │ │ │ -
47 friend class SLListConstIterator<T,A>;
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
38#if HAVE_VC
│ │ │ │ +
39// include Vc part of new simd interface to provide compatibility for
│ │ │ │ +
40// functionality that has been switched over.
│ │ │ │ + │ │ │ │ +
42#endif
│ │ │ │ + │ │ │ │ +
44#include <dune/common/vc.hh>
│ │ │ │ +
45
│ │ │ │ +
46namespace Dune
│ │ │ │ +
47{
│ │ │ │
48
│ │ │ │ -
49 public:
│ │ │ │ -
50
│ │ │ │ -
54 typedef typename A::size_type size_type;
│ │ │ │ -
55
│ │ │ │ -
59 typedef T MemberType;
│ │ │ │ -
60
│ │ │ │ -
64 using Allocator = typename std::allocator_traits<A>::template rebind_alloc<Element>;
│ │ │ │ -
65
│ │ │ │ - │ │ │ │ -
70
│ │ │ │ - │ │ │ │ -
75
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
80
│ │ │ │ -
84 template<typename T1, typename A1>
│ │ │ │ -
│ │ │ │ -
85 SLList(const SLList<T1,A1>& other);
│ │ │ │ -
86
│ │ │ │ -
│ │ │ │ -
90 SLList(const SLList<T,A>& other);
│ │ │ │ -
91
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
98
│ │ │ │ - │ │ │ │ +
49#if HAVE_VC
│ │ │ │ +
50 namespace VcImpl {
│ │ │ │ +
52
│ │ │ │ +
61 template<class V>
│ │ │ │ +
62 class Proxy
│ │ │ │ +
63 {
│ │ │ │ +
64 static_assert(std::is_same<V, std::decay_t<V> >::value, "Class Proxy "
│ │ │ │ +
65 "may only be instantiated with unqualified types");
│ │ │ │ +
66 public:
│ │ │ │ +
67 using value_type = typename V::value_type;
│ │ │ │ +
68
│ │ │ │ +
69 private:
│ │ │ │ +
70 static_assert(std::is_arithmetic<value_type>::value,
│ │ │ │ +
71 "Only arithmetic types are supported");
│ │ │ │ +
72 V &vec_;
│ │ │ │ +
73 std::size_t idx_;
│ │ │ │ +
74
│ │ │ │ +
75 public:
│ │ │ │ +
76 Proxy(std::size_t idx, V &vec)
│ │ │ │ +
77 : vec_(vec), idx_(idx)
│ │ │ │ +
78 { }
│ │ │ │ +
79
│ │ │ │ +
80 operator value_type() const { return vec_[idx_]; }
│ │ │ │ +
81
│ │ │ │ +
82 // postfix operators
│ │ │ │ +
83
│ │ │ │ +
84 template<class T = value_type,
│ │ │ │ +
85 class = std::enable_if_t<!std::is_same<T, bool>::value> >
│ │ │ │ +
86 value_type operator++(int) { return vec_[idx_]++; }
│ │ │ │ +
87 template<class T = value_type,
│ │ │ │ +
88 class = std::enable_if_t<!std::is_same<T, bool>::value> >
│ │ │ │ +
89 value_type operator--(int) { return vec_[idx_]--; }
│ │ │ │ +
90
│ │ │ │ +
91 // unary (prefix) operators
│ │ │ │ +
92 template<class T = value_type,
│ │ │ │ +
93 class = std::enable_if_t<!std::is_same<T, bool>::value> >
│ │ │ │ +
94 Proxy &operator++() { ++(vec_[idx_]); return *this; }
│ │ │ │ +
95 template<class T = value_type,
│ │ │ │ +
96 class = std::enable_if_t<!std::is_same<T, bool>::value> >
│ │ │ │ +
97 Proxy &operator--() { --(vec_[idx_]); return *this; }
│ │ │ │ +
98 decltype(auto) operator!() const { return !(vec_[idx_]); }
│ │ │ │ +
99 decltype(auto) operator+() const { return +(vec_[idx_]); }
│ │ │ │ +
100 decltype(auto) operator-() const { return -(vec_[idx_]); }
│ │ │ │ +
101 template<class T = value_type,
│ │ │ │ +
102 class = std::enable_if_t<std::is_integral<T>::value> >
│ │ │ │ +
103 decltype(auto) operator~() const { return ~(vec_[idx_]); }
│ │ │ │
104
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
109
│ │ │ │ -
110
│ │ │ │ -
│ │ │ │ -
115 inline void push_back(const MemberType& item);
│ │ │ │ -
116
│ │ │ │ -
│ │ │ │ -
121 inline void push_front(const MemberType& item);
│ │ │ │ -
122
│ │ │ │ -
│ │ │ │ -
126 inline void pop_front();
│ │ │ │ -
127
│ │ │ │ -
│ │ │ │ -
129 inline void clear();
│ │ │ │ -
130
│ │ │ │ -
│ │ │ │ -
138 inline iterator begin();
│ │ │ │ -
139
│ │ │ │ -
│ │ │ │ -
147 inline const_iterator begin() const;
│ │ │ │ -
148
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
157
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
166
│ │ │ │ -
│ │ │ │ -
173 inline iterator end();
│ │ │ │ -
174
│ │ │ │ -
│ │ │ │ -
181 inline const_iterator end() const;
│ │ │ │ -
182
│ │ │ │ -
│ │ │ │ -
188 inline bool empty() const;
│ │ │ │ +
105 // binary operators
│ │ │ │ +
106#define DUNE_SIMD_VC_BINARY_OP(OP) \
│ │ │ │ +
107 template<class T> \
│ │ │ │ +
108 auto operator OP(T &&o) const \
│ │ │ │ +
109 -> decltype(vec_[idx_] OP valueCast(std::forward<T>(o))) \
│ │ │ │ +
110 { \
│ │ │ │ +
111 return vec_[idx_] OP valueCast(std::forward<T>(o)); \
│ │ │ │ +
112 } \
│ │ │ │ +
113 static_assert(true, "Require semicolon to unconfuse editors")
│ │ │ │ +
114
│ │ │ │ +
115 DUNE_SIMD_VC_BINARY_OP(*);
│ │ │ │ +
116 DUNE_SIMD_VC_BINARY_OP(/);
│ │ │ │ +
117 DUNE_SIMD_VC_BINARY_OP(%);
│ │ │ │ +
118
│ │ │ │ +
119 DUNE_SIMD_VC_BINARY_OP(+);
│ │ │ │ +
120 DUNE_SIMD_VC_BINARY_OP(-);
│ │ │ │ +
121
│ │ │ │ +
122 DUNE_SIMD_VC_BINARY_OP(<<);
│ │ │ │ +
123 DUNE_SIMD_VC_BINARY_OP(>>);
│ │ │ │ +
124
│ │ │ │ +
125 DUNE_SIMD_VC_BINARY_OP(<);
│ │ │ │ +
126 DUNE_SIMD_VC_BINARY_OP(>);
│ │ │ │ +
127 DUNE_SIMD_VC_BINARY_OP(<=);
│ │ │ │ +
128 DUNE_SIMD_VC_BINARY_OP(>=);
│ │ │ │ +
129
│ │ │ │ +
130 DUNE_SIMD_VC_BINARY_OP(==);
│ │ │ │ +
131 DUNE_SIMD_VC_BINARY_OP(!=);
│ │ │ │ +
132
│ │ │ │ +
133 DUNE_SIMD_VC_BINARY_OP(&);
│ │ │ │ +
134 DUNE_SIMD_VC_BINARY_OP(^);
│ │ │ │ +
135 DUNE_SIMD_VC_BINARY_OP(|);
│ │ │ │ +
136
│ │ │ │ +
137 DUNE_SIMD_VC_BINARY_OP(&&);
│ │ │ │ +
138 DUNE_SIMD_VC_BINARY_OP(||);
│ │ │ │ +
139#undef DUNE_SIMD_VC_BINARY_OP
│ │ │ │ +
140
│ │ │ │ +
141#define DUNE_SIMD_VC_ASSIGNMENT(OP) \
│ │ │ │ +
142 template<class T> \
│ │ │ │ +
143 auto operator OP(T &&o) \
│ │ │ │ +
144 -> std::enable_if_t<AlwaysTrue<decltype( \
│ │ │ │ +
145 vec_[idx_] OP valueCast(std::forward<T>(o)) \
│ │ │ │ +
146 )>::value, Proxy&> \
│ │ │ │ +
147 { \
│ │ │ │ +
148 vec_[idx_] OP valueCast(std::forward<T>(o)); \
│ │ │ │ +
149 return *this; \
│ │ │ │ +
150 } \
│ │ │ │ +
151 static_assert(true, "Require semicolon to unconfuse editors")
│ │ │ │ +
152
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
164#undef DUNE_SIMD_VC_ASSIGNMENT
│ │ │ │ +
165
│ │ │ │ +
166 // swap on proxies swaps the proxied vector entries. As such, it
│ │ │ │ +
167 // applies to rvalues of proxies too, not just lvalues
│ │ │ │ +
168 template<class V1, class V2>
│ │ │ │ +
169 friend void swap(Proxy<V1>, Proxy<V2>);
│ │ │ │ +
170
│ │ │ │ +
171 template<class T>
│ │ │ │ +
172 friend void swap(Proxy p1, T& s2)
│ │ │ │ +
173 {
│ │ │ │ +
174 // don't use swap() ourselves -- not supported by Vc 1.3.0 (but is
│ │ │ │ +
175 // supported by Vc 1.3.2)
│ │ │ │ +
176 T tmp = p1.vec_[p1.idx_];
│ │ │ │ +
177 p1.vec_[p1.idx_] = s2;
│ │ │ │ +
178 s2 = tmp;
│ │ │ │ +
179 }
│ │ │ │ +
180
│ │ │ │ +
181 template<class T>
│ │ │ │ +
182 friend void swap(T& s1, Proxy p2)
│ │ │ │ +
183 {
│ │ │ │ +
184 T tmp = s1;
│ │ │ │ +
185 s1 = p2.vec_[p2.idx_];
│ │ │ │ +
186 p2.vec_[p2.idx_] = tmp;
│ │ │ │ +
187 }
│ │ │ │ +
188 };
│ │ │ │
189
│ │ │ │ -
│ │ │ │ -
194 inline int size() const;
│ │ │ │ -
195
│ │ │ │ -
│ │ │ │ -
196 bool operator==(const SLList& sl) const;
│ │ │ │ -
197
│ │ │ │ -
198
│ │ │ │ -
│ │ │ │ -
199 bool operator!=(const SLList& sl) const;
│ │ │ │ -
200
│ │ │ │ -
201 private:
│ │ │ │ -
203 struct Element
│ │ │ │ -
204 {
│ │ │ │ - │ │ │ │ - │ │ │ │ -
213
│ │ │ │ -
│ │ │ │ -
214 Element(const MemberType& item, Element* next_=0);
│ │ │ │ -
215
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
217
│ │ │ │ - │ │ │ │ -
219 };
│ │ │ │ -
220
│ │ │ │ -
225 void deleteNext(Element* current);
│ │ │ │ -
226
│ │ │ │ -
231 void copyElements(const SLList<T,A>& other);
│ │ │ │ -
232
│ │ │ │ -
240 template<bool watchForTail>
│ │ │ │ -
241 void deleteNext(Element* current);
│ │ │ │ -
247 void insertAfter(Element* current, const T& item);
│ │ │ │ -
248
│ │ │ │ -
250 Element beforeHead_;
│ │ │ │ -
251
│ │ │ │ -
257 Element* tail_;
│ │ │ │ -
258
│ │ │ │ -
260 Allocator allocator_;
│ │ │ │ -
261
│ │ │ │ -
263 int size_;
│ │ │ │ -
264 };
│ │ │ │ -
265
│ │ │ │ -
269 template<typename T, class A>
│ │ │ │ -
│ │ │ │ -
270 class SLListIterator : public Dune::ForwardIteratorFacade<SLListIterator<T,A>, T, T&, std::size_t>
│ │ │ │ -
271 {
│ │ │ │ -
272 friend class SLListConstIterator<T,A>;
│ │ │ │ -
273 friend class SLListModifyIterator<T,A>;
│ │ │ │ -
274 friend class SLList<T,A>;
│ │ │ │ -
275
│ │ │ │ -
276 public:
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
278 SLList<T,A>* sllist)
│ │ │ │ -
279 : current_(item), list_(sllist)
│ │ │ │ -
280 {}
│ │ │ │ -
│ │ │ │ -
281
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
283 : current_(0), list_(0)
│ │ │ │ -
284 {}
│ │ │ │ -
│ │ │ │ -
285
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
287 : current_(other.iterator_.current_), list_(other.iterator_.list_)
│ │ │ │ -
288 {}
│ │ │ │ -
│ │ │ │ -
289
│ │ │ │ -
│ │ │ │ -
294 inline T& dereference() const
│ │ │ │ -
295 {
│ │ │ │ -
296 return current_->item_;
│ │ │ │ -
297 }
│ │ │ │ -
│ │ │ │ -
298
│ │ │ │ -
│ │ │ │ -
304 inline bool equals(const SLListConstIterator<T,A>& other) const
│ │ │ │ -
305 {
│ │ │ │ -
306 return current_==other.current_;
│ │ │ │ -
307 }
│ │ │ │ -
│ │ │ │ -
308
│ │ │ │ -
│ │ │ │ -
314 inline bool equals(const SLListIterator<T,A>& other) const
│ │ │ │ -
315 {
│ │ │ │ -
316 return current_==other.current_;
│ │ │ │ -
317 }
│ │ │ │ -
│ │ │ │ -
318
│ │ │ │ -
│ │ │ │ -
324 inline bool equals(const SLListModifyIterator<T,A>& other) const
│ │ │ │ -
325 {
│ │ │ │ -
326 return current_==other.iterator_.current_;
│ │ │ │ -
327 }
│ │ │ │ +
190 template<class V1, class V2>
│ │ │ │ +
191 void swap(Proxy<V1> p1, Proxy<V2> p2)
│ │ │ │ +
192 {
│ │ │ │ +
193 typename V1::value_type tmp = p1.vec_[p1.idx_];
│ │ │ │ +
194 p1.vec_[p1.idx_] = p2.vec_[p2.idx_];
│ │ │ │ +
195 p2.vec_[p2.idx_] = tmp;
│ │ │ │ +
196 }
│ │ │ │ +
197 } // namespace VcImpl
│ │ │ │ +
198#endif // HAVE_VC
│ │ │ │ +
199
│ │ │ │ +
200 template<typename T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
202 {
│ │ │ │ +
203 using type = T;
│ │ │ │ +
204 };
│ │ │ │ +
│ │ │ │ +
205
│ │ │ │ +
206 template<typename T>
│ │ │ │ + │ │ │ │ +
208
│ │ │ │ +
209#if HAVE_VC
│ │ │ │ +
210 /*
│ │ │ │ +
211 Add Vc specializations for the SimdScalarTypeTraits trais class
│ │ │ │ +
212 */
│ │ │ │ +
213 template<typename T, typename A>
│ │ │ │ +
214 struct SimdScalarTypeTraits< Vc::Vector<T,A> >
│ │ │ │ +
215 {
│ │ │ │ +
216 using type = T;
│ │ │ │ +
217 };
│ │ │ │ +
218
│ │ │ │ +
219 template<typename T, std::size_t N, typename V, std::size_t M>
│ │ │ │ +
220 struct SimdScalarTypeTraits< Vc::SimdArray<T,N,V,M> >
│ │ │ │ +
221 {
│ │ │ │ +
222 using type = T;
│ │ │ │ +
223 };
│ │ │ │ +
224#endif // HAVE_VC
│ │ │ │ +
225
│ │ │ │ +
227 template<typename T, std::size_t align>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
229 {
│ │ │ │ +
230 using type = T;
│ │ │ │ +
231 };
│ │ │ │
│ │ │ │ +
232
│ │ │ │ +
233 template<typename V, typename = void>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
235 using type = std::size_t;
│ │ │ │ +
236 };
│ │ │ │ +
│ │ │ │ +
237
│ │ │ │ +
239
│ │ │ │ +
245 template<typename V>
│ │ │ │ + │ │ │ │ +
247
│ │ │ │ +
248#if HAVE_VC
│ │ │ │ +
249 template<typename T, typename A>
│ │ │ │ +
250 struct SimdIndexTypeTraits<Vc::Vector<T, A> > {
│ │ │ │ +
251 using type = typename Vc::Vector<T, A>::index_type;
│ │ │ │ +
252 };
│ │ │ │ +
253
│ │ │ │ +
254 template<typename T, std::size_t n, typename V>
│ │ │ │ +
255 struct SimdIndexTypeTraits<Vc::SimdArray<T, n, V> > {
│ │ │ │ +
256 using type = typename Vc::SimdArray<T, n, V>::index_type;
│ │ │ │ +
257 };
│ │ │ │ +
258#endif // HAVE_VC
│ │ │ │ +
259
│ │ │ │ +
260 template<typename V, typename = void>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
262 using type = bool;
│ │ │ │ +
263 };
│ │ │ │ +
│ │ │ │ +
264
│ │ │ │ +
266
│ │ │ │ +
269 template<typename V>
│ │ │ │ + │ │ │ │ +
271
│ │ │ │ +
272#if HAVE_VC
│ │ │ │ +
273 template<typename T, typename A>
│ │ │ │ +
274 struct SimdMaskTypeTraits<Vc::Vector<T, A> > {
│ │ │ │ +
275 using type = typename Vc::Vector<T, A>::mask_type;
│ │ │ │ +
276 };
│ │ │ │ +
277
│ │ │ │ +
278 template<typename T, std::size_t n, typename V>
│ │ │ │ +
279 struct SimdMaskTypeTraits<Vc::SimdArray<T, n, V> > {
│ │ │ │ +
280 using type = typename Vc::SimdArray<T, n, V>::mask_type;
│ │ │ │ +
281 };
│ │ │ │ +
282#endif // HAVE_VC
│ │ │ │ +
283
│ │ │ │ +
284#if HAVE_VC
│ │ │ │ +
285 /*
│ │ │ │ +
286 Add Vc specializations for cond(), see conditional.hh
│ │ │ │ +
287 */
│ │ │ │ +
288 template<typename T, typename A>
│ │ │ │ +
289 Vc::Vector<T,A> cond(const Vc::Mask<T,A> & b,
│ │ │ │ +
290 const Vc::Vector<T,A> & v1,
│ │ │ │ +
291 const Vc::Vector<T,A> & v2)
│ │ │ │ +
292 {
│ │ │ │ +
293 return std::move(Vc::iif(b, v1, v2));
│ │ │ │ +
294 }
│ │ │ │ +
295
│ │ │ │ +
296 template<typename T, std::size_t N, typename V, std::size_t M>
│ │ │ │ +
297 Vc::SimdArray<T,N,V,M> cond(const typename Vc::SimdArray<T,N,V,M>::mask_type & b,
│ │ │ │ +
298 const Vc::SimdArray<T,N,V,M> & v1,
│ │ │ │ +
299 const Vc::SimdArray<T,N,V,M> & v2)
│ │ │ │ +
300 {
│ │ │ │ +
301 return std::move(Vc::iif(b, v1, v2));
│ │ │ │ +
302 }
│ │ │ │ +
303#endif // HAVE_VC
│ │ │ │ +
304
│ │ │ │ +
305#if HAVE_VC
│ │ │ │ +
306 /*
│ │ │ │ +
307 Add Vc specializations for several boolean operations, see rangeutitlities.hh:
│ │ │ │ +
308
│ │ │ │ +
309 max_value, min_value, any_true, all_true
│ │ │ │ +
310 */
│ │ │ │ +
311 template<typename T, typename A>
│ │ │ │ +
312 T max_value(const Vc::Vector<T,A> & v)
│ │ │ │ +
313 {
│ │ │ │ +
314 return v.max();
│ │ │ │ +
315 }
│ │ │ │ +
316
│ │ │ │ +
317 template<typename T, std::size_t N, typename V, std::size_t M>
│ │ │ │ +
318 double max_value(const Vc::SimdArray<T,N,V,M> & v)
│ │ │ │ +
319 {
│ │ │ │ +
320 return v.max();
│ │ │ │ +
321 }
│ │ │ │ +
322
│ │ │ │ +
323 template<typename T, typename A>
│ │ │ │ +
324 T min_value(const Vc::Vector<T,A> & v)
│ │ │ │ +
325 {
│ │ │ │ +
326 return v.min();
│ │ │ │ +
327 }
│ │ │ │
328
│ │ │ │ -
│ │ │ │ -
332 inline void increment()
│ │ │ │ -
333 {
│ │ │ │ -
334 current_ = current_->next_;
│ │ │ │ -
335 }
│ │ │ │ -
│ │ │ │ -
336
│ │ │ │ -
│ │ │ │ -
342 inline void insertAfter(const T& v) const
│ │ │ │ -
343 {
│ │ │ │ -
344 assert(list_ );
│ │ │ │ -
345 list_->insertAfter(current_, v);
│ │ │ │ -
346 }
│ │ │ │ -
│ │ │ │ -
347
│ │ │ │ -
│ │ │ │ -
353 inline void deleteNext() const
│ │ │ │ -
354 {
│ │ │ │ -
355 assert(list_);
│ │ │ │ -
356 list_->deleteNext(current_);
│ │ │ │ -
357 }
│ │ │ │ -
│ │ │ │ -
358
│ │ │ │ -
359 private:
│ │ │ │ -
361 typename SLList<T,A>::Element* current_;
│ │ │ │ - │ │ │ │ -
364 };
│ │ │ │ -
│ │ │ │ -
365
│ │ │ │ -
369 template<class T, class A>
│ │ │ │ -
│ │ │ │ -
370 class SLListConstIterator : public Dune::ForwardIteratorFacade<SLListConstIterator<T,A>, const T, const T&, std::size_t>
│ │ │ │ -
371 {
│ │ │ │ -
372 friend class SLListIterator<T,A>;
│ │ │ │ -
373 friend class SLList<T,A>;
│ │ │ │ -
374
│ │ │ │ -
375 public:
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
377 : current_(0)
│ │ │ │ -
378 {}
│ │ │ │ +
329 template<typename T, std::size_t N, typename V, std::size_t M>
│ │ │ │ +
330 double min_value(const Vc::SimdArray<T,N,V,M> & v)
│ │ │ │ +
331 {
│ │ │ │ +
332 return v.min();
│ │ │ │ +
333 }
│ │ │ │ +
334
│ │ │ │ +
335 template<typename T, typename A>
│ │ │ │ +
336 bool any_true(const Vc::Mask<T,A> & v)
│ │ │ │ +
337 {
│ │ │ │ +
338 return Vc::any_of(v);
│ │ │ │ +
339 }
│ │ │ │ +
340
│ │ │ │ +
341 template<typename T, std::size_t N, typename V, std::size_t M>
│ │ │ │ +
342 bool any_true(const Vc::SimdMaskArray<T,N,V,M> & v)
│ │ │ │ +
343 {
│ │ │ │ +
344 return Vc::any_of(v);
│ │ │ │ +
345 }
│ │ │ │ +
346
│ │ │ │ +
347 template<typename T, typename A>
│ │ │ │ +
348 bool all_true(const Vc::Mask<T,A> & v)
│ │ │ │ +
349 {
│ │ │ │ +
350 return Vc::all_of(v);
│ │ │ │ +
351 }
│ │ │ │ +
352
│ │ │ │ +
353 template<typename T, std::size_t N, typename V, std::size_t M>
│ │ │ │ +
354 bool all_true(const Vc::SimdMaskArray<T,N,V,M> & v)
│ │ │ │ +
355 {
│ │ │ │ +
356 return Vc::all_of(v);
│ │ │ │ +
357 }
│ │ │ │ +
358#endif // HAVE_VC
│ │ │ │ +
359
│ │ │ │ +
361 template<class T>
│ │ │ │ +
362 std::size_t lanes(const T &) { return 1; }
│ │ │ │ +
363
│ │ │ │ +
365 template<class T>
│ │ │ │ +
│ │ │ │ +
366 T lane(std::size_t l, const T &v)
│ │ │ │ +
367 {
│ │ │ │ +
368 assert(l == 0);
│ │ │ │ +
369 return v;
│ │ │ │ +
370 }
│ │ │ │ +
│ │ │ │ +
371
│ │ │ │ +
373 template<class T>
│ │ │ │ +
│ │ │ │ +
374 T &lane(std::size_t l, T &v)
│ │ │ │ +
375 {
│ │ │ │ +
376 assert(l == 0);
│ │ │ │ +
377 return v;
│ │ │ │ +
378 }
│ │ │ │
│ │ │ │
379
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
381 : current_(item)
│ │ │ │ -
382 {}
│ │ │ │ -
│ │ │ │ -
383
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
385 : current_(other.current_)
│ │ │ │ -
386 {}
│ │ │ │ -
│ │ │ │ -
387
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
389 : current_(other.iterator_.current_)
│ │ │ │ -
390 {}
│ │ │ │ -
│ │ │ │ -
391
│ │ │ │ -
│ │ │ │ -
396 inline const T& dereference() const
│ │ │ │ -
397 {
│ │ │ │ -
398 return current_->item_;
│ │ │ │ -
399 }
│ │ │ │ -
│ │ │ │ +
380#if HAVE_VC
│ │ │ │ +
381 template<class T, class A>
│ │ │ │ +
382 std::size_t lanes(const Vc::Vector<T, A> &)
│ │ │ │ +
383 {
│ │ │ │ +
384 return Vc::Vector<T, A>::size();
│ │ │ │ +
385 }
│ │ │ │ +
386
│ │ │ │ +
387 template<class T, class A>
│ │ │ │ +
388 T lane(std::size_t l, const Vc::Vector<T, A> &v)
│ │ │ │ +
389 {
│ │ │ │ +
390 assert(l < lanes(v));
│ │ │ │ +
391 return v[l];
│ │ │ │ +
392 }
│ │ │ │ +
393
│ │ │ │ +
394 template<class T, class A>
│ │ │ │ +
395 auto lane(std::size_t l, Vc::Vector<T, A> &v)
│ │ │ │ +
396 {
│ │ │ │ +
397 assert(l < lanes(v));
│ │ │ │ +
398 return VcImpl::Proxy<Vc::Vector<T, A> >{l, v};
│ │ │ │ +
399 }
│ │ │ │
400
│ │ │ │ -
│ │ │ │ -
406 inline bool equals(const SLListConstIterator<T,A>& other) const
│ │ │ │ -
407 {
│ │ │ │ -
408 return current_==other.current_;
│ │ │ │ -
409 }
│ │ │ │ -
│ │ │ │ -
410
│ │ │ │ -
│ │ │ │ -
414 inline void increment()
│ │ │ │ -
415 {
│ │ │ │ -
416 current_ = current_->next_;
│ │ │ │ -
417 }
│ │ │ │ -
│ │ │ │ -
418
│ │ │ │ -
419 private:
│ │ │ │ -
421 typename SLList<T,A>::Element* current_;
│ │ │ │ -
422 };
│ │ │ │ -
│ │ │ │ -
423
│ │ │ │ -
427 template<typename T, class A>
│ │ │ │ -
│ │ │ │ -
428 class SLListModifyIterator : public Dune::ForwardIteratorFacade<SLListModifyIterator<T,A>, T, T&, std::size_t>
│ │ │ │ +
401 template<class T, std::size_t n, class V>
│ │ │ │ +
402 std::size_t lanes(const Vc::SimdArray<T, n, V> &)
│ │ │ │ +
403 {
│ │ │ │ +
404 return n;
│ │ │ │ +
405 }
│ │ │ │ +
406
│ │ │ │ +
407 template<class T, std::size_t n, class V>
│ │ │ │ +
408 T lane(std::size_t l, const Vc::SimdArray<T, n, V> &v)
│ │ │ │ +
409 {
│ │ │ │ +
410 assert(l < n);
│ │ │ │ +
411 return v[l];
│ │ │ │ +
412 }
│ │ │ │ +
413
│ │ │ │ +
414 template<class T, std::size_t n, class V>
│ │ │ │ +
415 auto lane(std::size_t l, Vc::SimdArray<T, n, V> &v)
│ │ │ │ +
416 {
│ │ │ │ +
417 assert(l < n);
│ │ │ │ +
418 return VcImpl::Proxy<Vc::SimdArray<T, n, V> >{l, v};
│ │ │ │ +
419 }
│ │ │ │ +
420
│ │ │ │ +
421 template<class T, std::size_t n, class V>
│ │ │ │ +
422 std::size_t lanes(const Vc::SimdMaskArray<T, n, V> &)
│ │ │ │ +
423 {
│ │ │ │ +
424 return n;
│ │ │ │ +
425 }
│ │ │ │ +
426
│ │ │ │ +
427 template<class T, std::size_t n, class V>
│ │ │ │ +
428 bool lane(std::size_t l, const Vc::SimdMaskArray<T, n, V> &v)
│ │ │ │
429 {
│ │ │ │ -
430 friend class SLListConstIterator<T,A>;
│ │ │ │ -
431 friend class SLListIterator<T,A>;
│ │ │ │ -
432 public:
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
434 SLListIterator<T,A> _iterator)
│ │ │ │ -
435 : beforeIterator_(beforeIterator), iterator_(_iterator)
│ │ │ │ -
436 {}
│ │ │ │ -
│ │ │ │ -
437
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
439 : beforeIterator_(), iterator_()
│ │ │ │ -
440 {}
│ │ │ │ -
│ │ │ │ +
430 assert(l < n);
│ │ │ │ +
431 return v[l];
│ │ │ │ +
432 }
│ │ │ │ +
433
│ │ │ │ +
434 template<class T, std::size_t n, class V>
│ │ │ │ +
435 auto lane(std::size_t l, Vc::SimdMaskArray<T, n, V> &v)
│ │ │ │ +
436 {
│ │ │ │ +
437 assert(l < n);
│ │ │ │ +
438 return VcImpl::Proxy<Vc::SimdMaskArray<T, n, V> >{l, v};
│ │ │ │ +
439 }
│ │ │ │ +
440#endif // HAVE_VC
│ │ │ │
441
│ │ │ │ -
│ │ │ │ -
446 inline T& dereference() const
│ │ │ │ -
447 {
│ │ │ │ -
448 return *iterator_;
│ │ │ │ -
449 }
│ │ │ │ -
│ │ │ │ -
450
│ │ │ │ -
│ │ │ │ -
456 inline bool equals(const SLListConstIterator<T,A>& other) const
│ │ │ │ -
457 {
│ │ │ │ -
458 return iterator_== other;
│ │ │ │ -
459 }
│ │ │ │ -
│ │ │ │ -
460
│ │ │ │ -
461
│ │ │ │ -
│ │ │ │ -
467 inline bool equals(const SLListIterator<T,A>& other) const
│ │ │ │ -
468 {
│ │ │ │ -
469 return iterator_== other;
│ │ │ │ -
470 }
│ │ │ │ -
│ │ │ │ -
471
│ │ │ │ -
472
│ │ │ │ -
│ │ │ │ -
478 inline bool equals(const SLListModifyIterator<T,A>& other) const
│ │ │ │ -
479 {
│ │ │ │ -
480 return iterator_== other.iterator_;
│ │ │ │ -
481 }
│ │ │ │ -
│ │ │ │ -
482
│ │ │ │ -
│ │ │ │ -
486 inline void increment()
│ │ │ │ -
487 {
│ │ │ │ -
488 ++iterator_;
│ │ │ │ -
489 ++beforeIterator_;
│ │ │ │ -
490 }
│ │ │ │ -
│ │ │ │ -
491
│ │ │ │ -
│ │ │ │ -
505 inline void insert(const T& v)
│ │ │ │ -
506 {
│ │ │ │ -
507 beforeIterator_.insertAfter(v);
│ │ │ │ -
508 ++beforeIterator_;
│ │ │ │ -
509 }
│ │ │ │ -
│ │ │ │ -
510
│ │ │ │ -
│ │ │ │ -
518 inline void remove()
│ │ │ │ -
519 {
│ │ │ │ -
520 ++iterator_;
│ │ │ │ -
521 beforeIterator_.deleteNext();
│ │ │ │ -
522 }
│ │ │ │ -
│ │ │ │ -
523
│ │ │ │ -
524 private:
│ │ │ │ -
526 SLListIterator<T,A> beforeIterator_;
│ │ │ │ -
528 SLListIterator<T,A> iterator_;
│ │ │ │ -
529 };
│ │ │ │ -
│ │ │ │ -
530
│ │ │ │ -
531 template<typename T, typename A>
│ │ │ │ -
│ │ │ │ -
532 std::ostream& operator<<(std::ostream& os, const SLList<T,A>& sllist)
│ │ │ │ -
533 {
│ │ │ │ -
534 typedef typename SLList<T,A>::const_iterator Iterator;
│ │ │ │ -
535 Iterator end = sllist.end();
│ │ │ │ -
536 Iterator current= sllist.begin();
│ │ │ │ -
537
│ │ │ │ -
538 os << "{ ";
│ │ │ │ -
539
│ │ │ │ -
540 if(current!=end) {
│ │ │ │ -
541 os<<*current<<" ("<<static_cast<const void*>(&(*current))<<")";
│ │ │ │ -
542 ++current;
│ │ │ │ -
543
│ │ │ │ -
544 for(; current != end; ++current)
│ │ │ │ -
545 os<<", "<<*current<<" ("<<static_cast<const void*>(&(*current))<<")";
│ │ │ │ -
546 }
│ │ │ │ -
547 os<<"} ";
│ │ │ │ -
548 return os;
│ │ │ │ -
549 }
│ │ │ │ -
│ │ │ │ -
550
│ │ │ │ -
551 template<typename T, class A>
│ │ │ │ -
│ │ │ │ -
552 SLList<T,A>::Element::Element(const MemberType& item, Element* next)
│ │ │ │ -
553 : next_(next), item_(item)
│ │ │ │ -
554 {}
│ │ │ │ -
│ │ │ │ -
555
│ │ │ │ -
556 template<typename T, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
558 : next_(0), item_()
│ │ │ │ -
559 {}
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
560
│ │ │ │ -
561 template<typename T, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
563 {
│ │ │ │ -
564 next_=0;
│ │ │ │ -
565 }
│ │ │ │ -
│ │ │ │ -
566
│ │ │ │ -
567 template<typename T, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
569 : beforeHead_(), tail_(&beforeHead_), allocator_(), size_(0)
│ │ │ │ -
570 {
│ │ │ │ -
571 beforeHead_.next_=0;
│ │ │ │ -
572 assert(&beforeHead_==tail_);
│ │ │ │ -
573 assert(tail_->next_==0);
│ │ │ │ -
574 }
│ │ │ │ -
│ │ │ │ -
575
│ │ │ │ -
576 template<typename T, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
578 : beforeHead_(), tail_(&beforeHead_), allocator_(), size_(0)
│ │ │ │ -
579 {
│ │ │ │ -
580 copyElements(other);
│ │ │ │ -
581 }
│ │ │ │ -
│ │ │ │ -
582
│ │ │ │ -
583 template<typename T, class A>
│ │ │ │ -
584 template<typename T1, class A1>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
586 : beforeHead_(), tail_(&beforeHead_), allocator_(), size_(0)
│ │ │ │ -
587 {
│ │ │ │ -
588 copyElements(other);
│ │ │ │ -
589 }
│ │ │ │ -
│ │ │ │ -
590
│ │ │ │ -
591 template<typename T, typename A>
│ │ │ │ -
592 void SLList<T,A>::copyElements(const SLList<T,A>& other)
│ │ │ │ -
593 {
│ │ │ │ -
594 assert(tail_==&beforeHead_);
│ │ │ │ -
595 assert(size_==0);
│ │ │ │ -
596 typedef typename SLList<T,A>::const_iterator Iterator;
│ │ │ │ -
597 Iterator iend = other.end();
│ │ │ │ -
598 for(Iterator element=other.begin(); element != iend; ++element)
│ │ │ │ -
599 push_back(*element);
│ │ │ │ -
600
│ │ │ │ -
601 assert(other.size()==size());
│ │ │ │ -
602 }
│ │ │ │ -
603
│ │ │ │ -
604 template<typename T, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
606 {
│ │ │ │ -
607 clear();
│ │ │ │ -
608 }
│ │ │ │ -
│ │ │ │ -
609
│ │ │ │ -
610 template<typename T, class A>
│ │ │ │ -
│ │ │ │ -
611 bool SLList<T,A>::operator==(const SLList& other) const
│ │ │ │ -
612 {
│ │ │ │ -
613 if(size()!=other.size())
│ │ │ │ -
614 return false;
│ │ │ │ -
615 for(const_iterator iter=begin(), oiter=other.begin();
│ │ │ │ -
616 iter != end(); ++iter, ++oiter)
│ │ │ │ -
617 if(*iter!=*oiter)
│ │ │ │ -
618 return false;
│ │ │ │ -
619 return true;
│ │ │ │ -
620 }
│ │ │ │ -
│ │ │ │ -
621
│ │ │ │ -
622 template<typename T, class A>
│ │ │ │ -
│ │ │ │ -
623 bool SLList<T,A>::operator!=(const SLList& other) const
│ │ │ │ -
624 {
│ │ │ │ -
625 if(size()==other.size()) {
│ │ │ │ -
626 for(const_iterator iter=begin(), oiter=other.begin();
│ │ │ │ -
627 iter != end(); ++iter, ++oiter)
│ │ │ │ -
628 if(*iter!=*oiter)
│ │ │ │ -
629 return true;
│ │ │ │ -
630 return false;
│ │ │ │ -
631 }else
│ │ │ │ -
632 return true;
│ │ │ │ -
633 }
│ │ │ │ -
│ │ │ │ -
634 template<typename T, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
636 {
│ │ │ │ -
637 clear();
│ │ │ │ -
638 copyElements(other);
│ │ │ │ -
639 return *this;
│ │ │ │ -
640 }
│ │ │ │ -
│ │ │ │ -
641
│ │ │ │ -
642 template<typename T, class A>
│ │ │ │ -
│ │ │ │ -
643 inline void SLList<T,A>::push_back(const MemberType& item)
│ │ │ │ -
644 {
│ │ │ │ -
645 assert(size_>0 || tail_==&beforeHead_);
│ │ │ │ -
646 tail_->next_ = allocator_.allocate(1);
│ │ │ │ -
647 assert(size_>0 || tail_==&beforeHead_);
│ │ │ │ -
648 tail_ = tail_->next_;
│ │ │ │ -
649 ::new (static_cast<void*>(&(tail_->item_)))T(item);
│ │ │ │ -
650 tail_->next_=0;
│ │ │ │ -
651 assert(tail_->next_==0);
│ │ │ │ -
652 ++size_;
│ │ │ │ -
653 }
│ │ │ │ -
│ │ │ │ -
654
│ │ │ │ -
655 template<typename T, class A>
│ │ │ │ -
656 inline void SLList<T,A>::insertAfter(Element* current, const T& item)
│ │ │ │ -
657 {
│ │ │ │ -
658 assert(current);
│ │ │ │ -
659
│ │ │ │ -
660#ifndef NDEBUG
│ │ │ │ -
661 bool changeTail = (current == tail_);
│ │ │ │ -
662#endif
│ │ │ │ -
663
│ │ │ │ -
664 // Save old next element
│ │ │ │ -
665 Element* tmp = current->next_;
│ │ │ │ -
666
│ │ │ │ -
667 assert(!changeTail || !tmp);
│ │ │ │ -
668
│ │ │ │ -
669 // Allocate space
│ │ │ │ -
670 current->next_ = allocator_.allocate(1);
│ │ │ │ -
671
│ │ │ │ -
672 // Use copy constructor to initialize memory
│ │ │ │ -
673 std::allocator_traits<Allocator>::construct(allocator_, current->next_, Element(item,tmp));
│ │ │ │ -
674
│ │ │ │ -
675 //::new(static_cast<void*>(&(current->next_->item_))) T(item);
│ │ │ │ -
676
│ │ │ │ -
677 if(!current->next_->next_) {
│ │ │ │ -
678 // Update tail
│ │ │ │ -
679 assert(changeTail);
│ │ │ │ -
680 tail_ = current->next_;
│ │ │ │ -
681 }
│ │ │ │ -
682 ++size_;
│ │ │ │ -
683 assert(!tail_->next_);
│ │ │ │ -
684 }
│ │ │ │ -
685
│ │ │ │ -
686 template<typename T, class A>
│ │ │ │ -
│ │ │ │ -
687 inline void SLList<T,A>::push_front(const MemberType& item)
│ │ │ │ -
688 {
│ │ │ │ -
689 if(tail_ == &beforeHead_) {
│ │ │ │ -
690 // list was empty
│ │ │ │ -
691 beforeHead_.next_ = tail_ = allocator_.allocate(1, 0);
│ │ │ │ -
692 ::new(static_cast<void*>(&beforeHead_.next_->item_))T(item);
│ │ │ │ -
693 beforeHead_.next_->next_=0;
│ │ │ │ -
694 }else{
│ │ │ │ -
695 Element* added = allocator_.allocate(1, 0);
│ │ │ │ -
696 ::new(static_cast<void*>(&added->item_))T(item);
│ │ │ │ -
697 added->next_=beforeHead_.next_;
│ │ │ │ -
698 beforeHead_.next_=added;
│ │ │ │ -
699 }
│ │ │ │ -
700 assert(tail_->next_==0);
│ │ │ │ -
701 ++size_;
│ │ │ │ -
702 }
│ │ │ │ -
│ │ │ │ -
703
│ │ │ │ -
704
│ │ │ │ -
705 template<typename T, class A>
│ │ │ │ -
706 inline void SLList<T,A>::deleteNext(Element* current)
│ │ │ │ -
707 {
│ │ │ │ -
708 this->template deleteNext<true>(current);
│ │ │ │ -
709 }
│ │ │ │ -
710
│ │ │ │ -
711 template<typename T, class A>
│ │ │ │ -
712 template<bool watchForTail>
│ │ │ │ -
713 inline void SLList<T,A>::deleteNext(Element* current)
│ │ │ │ -
714 {
│ │ │ │ -
715 assert(current->next_);
│ │ │ │ -
716 Element* next = current->next_;
│ │ │ │ -
717
│ │ │ │ -
718 if(watchForTail)
│ │ │ │ -
719 if(next == tail_) {
│ │ │ │ -
720 // deleting last element changes tail!
│ │ │ │ -
721 tail_ = current;
│ │ │ │ -
722 }
│ │ │ │ -
723
│ │ │ │ -
724 current->next_ = next->next_;
│ │ │ │ -
725 std::allocator_traits<Allocator>::destroy(allocator_, next);
│ │ │ │ -
726 allocator_.deallocate(next, 1);
│ │ │ │ -
727 --size_;
│ │ │ │ -
728 assert(!watchForTail || &beforeHead_ != tail_ || size_==0);
│ │ │ │ -
729 }
│ │ │ │ -
730
│ │ │ │ -
731 template<typename T, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
733 {
│ │ │ │ -
734 deleteNext(&beforeHead_);
│ │ │ │ -
735 }
│ │ │ │ -
│ │ │ │ -
736
│ │ │ │ -
737 template<typename T, class A>
│ │ │ │ -
│ │ │ │ -
738 inline void SLList<T,A>::clear()
│ │ │ │ -
739 {
│ │ │ │ -
740 while(beforeHead_.next_ ) {
│ │ │ │ -
741 this->template deleteNext<false>(&beforeHead_);
│ │ │ │ -
742 }
│ │ │ │ -
743
│ │ │ │ -
744 assert(size_==0);
│ │ │ │ -
745 // update the tail!
│ │ │ │ -
746 tail_ = &beforeHead_;
│ │ │ │ -
747 }
│ │ │ │ -
│ │ │ │ -
748
│ │ │ │ -
749 template<typename T, class A>
│ │ │ │ -
│ │ │ │ -
750 inline bool SLList<T,A>::empty() const
│ │ │ │ -
751 {
│ │ │ │ -
752 return (&beforeHead_ == tail_);
│ │ │ │ -
753 }
│ │ │ │ -
│ │ │ │ -
754
│ │ │ │ -
755 template<typename T, class A>
│ │ │ │ -
│ │ │ │ -
756 inline int SLList<T,A>::size() const
│ │ │ │ -
757 {
│ │ │ │ -
758 return size_;
│ │ │ │ -
759 }
│ │ │ │ -
│ │ │ │ -
760
│ │ │ │ -
761 template<typename T, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
763 {
│ │ │ │ -
764 return iterator(beforeHead_.next_, this);
│ │ │ │ -
765 }
│ │ │ │ -
│ │ │ │ -
766
│ │ │ │ -
767 template<typename T, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
769 {
│ │ │ │ -
770 return const_iterator(beforeHead_.next_);
│ │ │ │ -
771 }
│ │ │ │ -
│ │ │ │ -
772
│ │ │ │ -
773 template<typename T, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
775 {
│ │ │ │ -
776 return iterator();
│ │ │ │ -
777 }
│ │ │ │ -
│ │ │ │ -
778
│ │ │ │ -
779 template<typename T, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
781 {
│ │ │ │ -
782 return SLListModifyIterator<T,A>(iterator(tail_, this),iterator());
│ │ │ │ -
783 }
│ │ │ │ -
│ │ │ │ -
784
│ │ │ │ -
785
│ │ │ │ -
786 template<typename T, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
788 {
│ │ │ │ -
789 return SLListModifyIterator<T,A>(iterator(&beforeHead_, this),
│ │ │ │ -
790 iterator(beforeHead_.next_, this));
│ │ │ │ -
791 }
│ │ │ │ -
│ │ │ │ -
792
│ │ │ │ -
793 template<typename T, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
795 {
│ │ │ │ -
796 return const_iterator();
│ │ │ │ -
797 }
│ │ │ │ -
│ │ │ │ -
798
│ │ │ │ -
800}
│ │ │ │ -
801#endif
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
This file implements iterator facade classes for writing stl conformant iterators.
│ │ │ │ -
void push_front(const MemberType &item)
Add a new entry to the beginning of the list.
Definition sllist.hh:687
│ │ │ │ -
bool equals(const SLListConstIterator< T, A > &other) const
Equality test for the iterator facade.
Definition sllist.hh:406
│ │ │ │ -
void push_back(const MemberType &item)
Add a new entry to the end of the list.
Definition sllist.hh:643
│ │ │ │ -
ModifyIterator endModify()
Get an iterator capable of deleting and inserting elements.
Definition sllist.hh:780
│ │ │ │ -
SLListModifyIterator()
Definition sllist.hh:438
│ │ │ │ -
Element()
Definition sllist.hh:557
│ │ │ │ -
T & dereference() const
Dereferencing function for the iterator facade.
Definition sllist.hh:294
│ │ │ │ -
bool operator!=(const SLList &sl) const
Definition sllist.hh:623
│ │ │ │ -
MemberType item_
The element we hold.
Definition sllist.hh:212
│ │ │ │ -
SLListConstIterator(typename SLList< T, A >::Element *item)
Definition sllist.hh:380
│ │ │ │ -
typename std::allocator_traits< A >::template rebind_alloc< Element > Allocator
The allocator to use.
Definition sllist.hh:64
│ │ │ │ -
void insertAfter(const T &v) const
Insert an element in the underlying list after the current position.
Definition sllist.hh:342
│ │ │ │ -
SLListIterator< T, A > iterator
The mutable iterator of the list.
Definition sllist.hh:69
│ │ │ │ -
SLListConstIterator(const SLListModifyIterator< T, A > &other)
Definition sllist.hh:388
│ │ │ │ -
SLListIterator()
Definition sllist.hh:282
│ │ │ │ -
~Element()
Definition sllist.hh:562
│ │ │ │ -
bool operator==(const SLList &sl) const
Definition sllist.hh:611
│ │ │ │ -
void deleteNext() const
Delete the entry after the current position.
Definition sllist.hh:353
│ │ │ │ -
SLList(const SLList< T, A > &other)
Copy constructor.
Definition sllist.hh:577
│ │ │ │ -
bool equals(const SLListModifyIterator< T, A > &other) const
Equality test for the iterator facade.
Definition sllist.hh:324
│ │ │ │ -
T & dereference() const
Dereferencing function for the iterator facade.
Definition sllist.hh:446
│ │ │ │ -
int size() const
Get the number of elements the list contains.
Definition sllist.hh:756
│ │ │ │ -
const_iterator begin() const
Get an iterator pointing to the first element in the list.
Definition sllist.hh:768
│ │ │ │ -
iterator end()
Get an iterator pointing to the end of the list.
Definition sllist.hh:774
│ │ │ │ -
void clear()
Remove all elements from the list.
Definition sllist.hh:738
│ │ │ │ -
SLList(const SLList< T1, A1 > &other)
Copy constructor with type conversion.
Definition sllist.hh:585
│ │ │ │ -
T MemberType
The type we store.
Definition sllist.hh:59
│ │ │ │ -
bool equals(const SLListModifyIterator< T, A > &other) const
Test whether another iterator is equal.
Definition sllist.hh:478
│ │ │ │ -
ModifyIterator beginModify()
Get an iterator capable of deleting and inserting elements.
Definition sllist.hh:787
│ │ │ │ -
SLList< T, A > & operator=(const SLList< T, A > &other)
Assignment operator.
Definition sllist.hh:635
│ │ │ │ -
SLListConstIterator(const SLListIterator< T, A > &other)
Definition sllist.hh:384
│ │ │ │ -
SLListConstIterator< T, A > const_iterator
The constant iterator of the list.
Definition sllist.hh:74
│ │ │ │ -
bool empty() const
Check whether the list is empty.
Definition sllist.hh:750
│ │ │ │ -
SLListConstIterator()
Definition sllist.hh:376
│ │ │ │ -
bool equals(const SLListConstIterator< T, A > &other) const
Equality test for the iterator facade.
Definition sllist.hh:304
│ │ │ │ -
bool equals(const SLListConstIterator< T, A > &other) const
Test whether another iterator is equal.
Definition sllist.hh:456
│ │ │ │ -
SLListModifyIterator< T, A > ModifyIterator
The type of the iterator capable of deletion and insertion.
Definition sllist.hh:103
│ │ │ │ -
const_iterator end() const
Get an iterator pointing to the end of the list.
Definition sllist.hh:794
│ │ │ │ -
SLList()
Constructor.
Definition sllist.hh:568
│ │ │ │ -
void insert(const T &v)
Insert an element at the current position.
Definition sllist.hh:505
│ │ │ │ -
SLListIterator(typename SLList< T, A >::Element *item, SLList< T, A > *sllist)
Definition sllist.hh:277
│ │ │ │ -
SLListModifyIterator(SLListIterator< T, A > beforeIterator, SLListIterator< T, A > _iterator)
Definition sllist.hh:433
│ │ │ │ -
void pop_front()
Remove the first item in the list.
Definition sllist.hh:732
│ │ │ │ -
void increment()
Increment function for the iterator facade.
Definition sllist.hh:332
│ │ │ │ -
SLListIterator(const SLListModifyIterator< T, A > &other)
Definition sllist.hh:286
│ │ │ │ -
A::size_type size_type
The size type.
Definition sllist.hh:54
│ │ │ │ -
void remove()
Delete the entry at the current position.
Definition sllist.hh:518
│ │ │ │ -
const T & dereference() const
Dereferencing function for the facade.
Definition sllist.hh:396
│ │ │ │ -
Element * next_
The next element in the list.
Definition sllist.hh:208
│ │ │ │ -
void increment()
Increment function for the iterator facade.
Definition sllist.hh:486
│ │ │ │ -
void increment()
Increment function for the iterator facade.
Definition sllist.hh:414
│ │ │ │ -
~SLList()
Destructor.
Definition sllist.hh:605
│ │ │ │ -
bool equals(const SLListIterator< T, A > &other) const
Test whether another iterator is equal.
Definition sllist.hh:467
│ │ │ │ -
iterator begin()
Get an iterator pointing to the first element in the list.
Definition sllist.hh:762
│ │ │ │ -
bool equals(const SLListIterator< T, A > &other) const
Equality test for the iterator facade.
Definition sllist.hh:314
│ │ │ │ -
std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x)
Definition bigunsignedint.hh:278
│ │ │ │ +
443
│ │ │ │ +
446 template<class T>
│ │ │ │ +
│ │ │ │ +
447 void assign(T &dst, const T &src, bool mask)
│ │ │ │ +
448 {
│ │ │ │ +
449 if(mask) dst = src;
│ │ │ │ +
450 }
│ │ │ │ +
│ │ │ │ +
451
│ │ │ │ +
452#if HAVE_VC
│ │ │ │ +
453 /*
│ │ │ │ +
454 Add Vc specializations for masked assignment
│ │ │ │ +
455 */
│ │ │ │ +
456 template<class T, class A>
│ │ │ │ +
457 void assign(Vc::Vector<T, A> &dst, const Vc::Vector<T, A> &src,
│ │ │ │ +
458 typename Vc::Vector<T, A>::mask_type mask)
│ │ │ │ +
459 {
│ │ │ │ +
460 dst(mask) = src;
│ │ │ │ +
461 }
│ │ │ │ +
462
│ │ │ │ +
463 template<class T, std::size_t n, class V>
│ │ │ │ +
464 void assign(Vc::SimdArray<T, n, V> &dst, const Vc::SimdArray<T, n, V> &src,
│ │ │ │ +
465 typename Vc::SimdArray<T, n, V>::mask_type mask)
│ │ │ │ +
466 {
│ │ │ │ +
467 dst(mask) = src;
│ │ │ │ +
468 }
│ │ │ │ +
469#endif // HAVE_VC
│ │ │ │ +
470
│ │ │ │ +
471 template<class T>
│ │ │ │ +
│ │ │ │ +
472 void swap(T &v1, T &v2, bool mask)
│ │ │ │ +
473 {
│ │ │ │ +
474 using std::swap;
│ │ │ │ +
475 if(mask) swap(v1, v2);
│ │ │ │ +
476 }
│ │ │ │ +
│ │ │ │ +
477
│ │ │ │ +
478#if HAVE_VC
│ │ │ │ +
479 /*
│ │ │ │ +
480 Add Vc specializations for masked swap
│ │ │ │ +
481 */
│ │ │ │ +
482 template<class T, class A>
│ │ │ │ +
483 void swap(Vc::Vector<T, A> &v1, Vc::Vector<T, A> &v2,
│ │ │ │ +
484 typename Vc::Vector<T, A>::mask_type mask)
│ │ │ │ +
485 {
│ │ │ │ +
486 auto tmp = v1;
│ │ │ │ +
487 v1(mask) = v2;
│ │ │ │ +
488 v2(mask) = tmp;
│ │ │ │ +
489 }
│ │ │ │ +
490
│ │ │ │ +
491 template<class T, std::size_t n, class V>
│ │ │ │ +
492 void swap(Vc::SimdArray<T, n, V> &v1, Vc::SimdArray<T, n, V> &v2,
│ │ │ │ +
493 typename Vc::SimdArray<T, n, V>::mask_type mask)
│ │ │ │ +
494 {
│ │ │ │ +
495 auto tmp = v1;
│ │ │ │ +
496 v1(mask) = v2;
│ │ │ │ +
497 v2(mask) = tmp;
│ │ │ │ +
498 }
│ │ │ │ +
499#endif // HAVE_VC
│ │ │ │ +
500
│ │ │ │ +
501} // end namespace Dune
│ │ │ │ +
502
│ │ │ │ +
503#endif // DUNE_COMMON_SIMD_HH
│ │ │ │ +
Traits for type conversions and type information.
│ │ │ │ + │ │ │ │ +
Compatibility header for including <Vc/Vc>
│ │ │ │ +
Utilities for reduction like operations on ranges.
│ │ │ │ + │ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
constexpr std::integer_sequence< T, II..., T(IN)> push_back(std::integer_sequence< T, II... >, std::integral_constant< T, IN >={})
Append an index IN to the back of the sequence.
Definition integersequence.hh:69
│ │ │ │ -
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition integersequence.hh:75
│ │ │ │ -
Base class for stl conformant forward iterators.
Definition iteratorfacades.hh:142
│ │ │ │ -
A mutable iterator for the SLList.
Definition sllist.hh:271
│ │ │ │ -
A constant iterator for the SLList.
Definition sllist.hh:371
│ │ │ │ -
A mutable iterator for the SLList.
Definition sllist.hh:429
│ │ │ │ -
A single linked list.
Definition sllist.hh:44
│ │ │ │ +
bool any_true(const AlignedNumber< bool, align > &val)
Definition debugalign.hh:506
│ │ │ │ +
bool all_true(const AlignedNumber< bool, align > &val)
Definition debugalign.hh:512
│ │ │ │ +
typename SimdIndexTypeTraits< V >::type SimdIndex
An simd vector of indices corresponding to a simd vector V.
Definition simd.hh:246
│ │ │ │ +
typename SimdScalarTypeTraits< T >::type SimdScalar
Definition simd.hh:207
│ │ │ │ +
typename SimdMaskTypeTraits< V >::type SimdMask
A simd vector of truth values corresponding to a simd vector V.
Definition simd.hh:270
│ │ │ │ +
T lane(std::size_t l, const T &v)
access a lane of a simd vector (scalar version)
Definition simd.hh:366
│ │ │ │ +
void swap(T &v1, T &v2, bool mask)
Definition simd.hh:472
│ │ │ │ +
void assign(T &dst, const T &src, bool mask)
masked Simd assignment (scalar version)
Definition simd.hh:447
│ │ │ │ +
const T1 cond(bool b, const T1 &v1, const T2 &v2)
conditional evaluate
Definition conditional.hh:28
│ │ │ │ +
T max_value(const AlignedNumber< T, align > &val)
Definition debugalign.hh:494
│ │ │ │ +
T min_value(const AlignedNumber< T, align > &val)
Definition debugalign.hh:500
│ │ │ │ +
std::size_t lanes(const T &)
get the number of lanes of a simd vector (scalar version)
Definition simd.hh:362
│ │ │ │ +
aligned wrappers for arithmetic types
Definition debugalign.hh:128
│ │ │ │ +
Definition simd.hh:202
│ │ │ │ +
T type
Definition simd.hh:203
│ │ │ │ + │ │ │ │ +
Definition simd.hh:234
│ │ │ │ +
std::size_t type
Definition simd.hh:235
│ │ │ │ +
Definition simd.hh:261
│ │ │ │ +
bool type
Definition simd.hh:262
│ │ │ │ +
SIMD abstractions for Vc.
│ │ │ │ +
#define DUNE_SIMD_VC_ASSIGNMENT(OP)
Definition simd/vc.hh:224
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,808 +1,549 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -sllist.hh │ │ │ │ │ +simd.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ -1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ -2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ -3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ +1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ -4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_SLLIST_HH │ │ │ │ │ -6#define DUNE_SLLIST_HH │ │ │ │ │ -7 │ │ │ │ │ -8#include │ │ │ │ │ -9#include │ │ │ │ │ -10#include "iteratorfacades.hh" │ │ │ │ │ -11#include │ │ │ │ │ -12 │ │ │ │ │ -13namespace Dune │ │ │ │ │ -14{ │ │ │ │ │ -26 template │ │ │ │ │ -27 class SLListIterator; │ │ │ │ │ -28 │ │ │ │ │ -29 template │ │ │ │ │ -30 class SLListConstIterator; │ │ │ │ │ -31 │ │ │ │ │ -32 template │ │ │ │ │ -33 class SLListModifyIterator; │ │ │ │ │ +2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ +3#ifndef DUNE_COMMON_SIMD_HH │ │ │ │ │ +4#define DUNE_COMMON_SIMD_HH │ │ │ │ │ +5 │ │ │ │ │ +6#warning dune/common/simd.hh is deprecated. │ │ │ │ │ +7#warning Use the new infrastructure from dune/common/simd/simd.h instead. │ │ │ │ │ +8 │ │ │ │ │ +30#include │ │ │ │ │ +31#include │ │ │ │ │ +32#include │ │ │ │ │ +33#include │ │ │ │ │ 34 │ │ │ │ │ -42 template > │ │ │ │ │ -43 class SLList │ │ │ │ │ -44 { │ │ │ │ │ -45 struct Element; │ │ │ │ │ -46 friend class SLListIterator; │ │ │ │ │ -47 friend class SLListConstIterator; │ │ │ │ │ +35#include │ │ │ │ │ +36#include │ │ │ │ │ +37#include │ │ │ │ │ +38#if HAVE_VC │ │ │ │ │ +39// include Vc part of new simd interface to provide compatibility for │ │ │ │ │ +40// functionality that has been switched over. │ │ │ │ │ +41#include │ │ │ │ │ +42#endif │ │ │ │ │ +43#include │ │ │ │ │ +44#include │ │ │ │ │ +45 │ │ │ │ │ +46namespace Dune │ │ │ │ │ +47{ │ │ │ │ │ 48 │ │ │ │ │ -49 public: │ │ │ │ │ -50 │ │ │ │ │ -54 typedef typename A::size_type size_type; │ │ │ │ │ -55 │ │ │ │ │ -59 typedef T MemberType; │ │ │ │ │ -60 │ │ │ │ │ -64 using Allocator = typename std::allocator_traits::template rebind_ │ │ │ │ │ -alloc; │ │ │ │ │ -65 │ │ │ │ │ -69 typedef SLListIterator iterator; │ │ │ │ │ -70 │ │ │ │ │ -74 typedef SLListConstIterator const_iterator; │ │ │ │ │ -75 │ │ │ │ │ -79 SLList(); │ │ │ │ │ -80 │ │ │ │ │ -84 template │ │ │ │ │ -85 SLList(const SLList& other); │ │ │ │ │ -86 │ │ │ │ │ -90 SLList(const SLList& other); │ │ │ │ │ -91 │ │ │ │ │ -97 ~SLList(); │ │ │ │ │ -98 │ │ │ │ │ -103 typedef SLListModifyIterator ModifyIterator; │ │ │ │ │ +49#if HAVE_VC │ │ │ │ │ +50 namespace VcImpl { │ │ │ │ │ +52 │ │ │ │ │ +61 template │ │ │ │ │ +62 class Proxy │ │ │ │ │ +63 { │ │ │ │ │ +64 static_assert(std::is_same >::value, "Class Proxy " │ │ │ │ │ +65 "may only be instantiated with unqualified types"); │ │ │ │ │ +66 public: │ │ │ │ │ +67 using value_type = typename V::value_type; │ │ │ │ │ +68 │ │ │ │ │ +69 private: │ │ │ │ │ +70 static_assert(std::is_arithmetic::value, │ │ │ │ │ +71 "Only arithmetic types are supported"); │ │ │ │ │ +72 V &vec_; │ │ │ │ │ +73 std::size_t idx_; │ │ │ │ │ +74 │ │ │ │ │ +75 public: │ │ │ │ │ +76 Proxy(std::size_t idx, V &vec) │ │ │ │ │ +77 : vec_(vec), idx_(idx) │ │ │ │ │ +78 { } │ │ │ │ │ +79 │ │ │ │ │ +80 operator value_type() const { return vec_[idx_]; } │ │ │ │ │ +81 │ │ │ │ │ +82 // postfix operators │ │ │ │ │ +83 │ │ │ │ │ +84 template::value> > │ │ │ │ │ +86 value_type operator++(int) { return vec_[idx_]++; } │ │ │ │ │ +87 template::value> > │ │ │ │ │ +89 value_type operator--(int) { return vec_[idx_]--; } │ │ │ │ │ +90 │ │ │ │ │ +91 // unary (prefix) operators │ │ │ │ │ +92 template::value> > │ │ │ │ │ +94 Proxy &operator++() { ++(vec_[idx_]); return *this; } │ │ │ │ │ +95 template::value> > │ │ │ │ │ +97 Proxy &operator--() { --(vec_[idx_]); return *this; } │ │ │ │ │ +98 decltype(auto) operator!() const { return !(vec_[idx_]); } │ │ │ │ │ +99 decltype(auto) operator+() const { return +(vec_[idx_]); } │ │ │ │ │ +100 decltype(auto) operator-() const { return -(vec_[idx_]); } │ │ │ │ │ +101 template::value> > │ │ │ │ │ +103 decltype(auto) operator~() const { return ~(vec_[idx_]); } │ │ │ │ │ 104 │ │ │ │ │ -108 SLList& operator=(const SLList& other); │ │ │ │ │ -109 │ │ │ │ │ -110 │ │ │ │ │ -115 inline void push_back(const MemberType& item); │ │ │ │ │ -116 │ │ │ │ │ -121 inline void push_front(const MemberType& item); │ │ │ │ │ -122 │ │ │ │ │ -126 inline void pop_front(); │ │ │ │ │ -127 │ │ │ │ │ -129 inline void clear(); │ │ │ │ │ -130 │ │ │ │ │ -138 inline iterator begin(); │ │ │ │ │ -139 │ │ │ │ │ -147 inline const_iterator begin() const; │ │ │ │ │ -148 │ │ │ │ │ -156 inline ModifyIterator beginModify(); │ │ │ │ │ -157 │ │ │ │ │ -165 inline ModifyIterator endModify(); │ │ │ │ │ -166 │ │ │ │ │ -173 inline iterator end(); │ │ │ │ │ -174 │ │ │ │ │ -181 inline const_iterator end() const; │ │ │ │ │ -182 │ │ │ │ │ -188 inline bool empty() const; │ │ │ │ │ +105 // binary operators │ │ │ │ │ +106#define DUNE_SIMD_VC_BINARY_OP(OP) \ │ │ │ │ │ +107 template \ │ │ │ │ │ +108 auto operator OP(T &&o) const \ │ │ │ │ │ +109 -> decltype(vec_[idx_] OP valueCast(std::forward(o))) \ │ │ │ │ │ +110 { \ │ │ │ │ │ +111 return vec_[idx_] OP valueCast(std::forward(o)); \ │ │ │ │ │ +112 } \ │ │ │ │ │ +113 static_assert(true, "Require semicolon to unconfuse editors") │ │ │ │ │ +114 │ │ │ │ │ +115 DUNE_SIMD_VC_BINARY_OP(*); │ │ │ │ │ +116 DUNE_SIMD_VC_BINARY_OP(/); │ │ │ │ │ +117 DUNE_SIMD_VC_BINARY_OP(%); │ │ │ │ │ +118 │ │ │ │ │ +119 DUNE_SIMD_VC_BINARY_OP(+); │ │ │ │ │ +120 DUNE_SIMD_VC_BINARY_OP(-); │ │ │ │ │ +121 │ │ │ │ │ +122 DUNE_SIMD_VC_BINARY_OP(<<); │ │ │ │ │ +123 DUNE_SIMD_VC_BINARY_OP(>>); │ │ │ │ │ +124 │ │ │ │ │ +125 DUNE_SIMD_VC_BINARY_OP(<); │ │ │ │ │ +126 DUNE_SIMD_VC_BINARY_OP(>); │ │ │ │ │ +127 DUNE_SIMD_VC_BINARY_OP(<=); │ │ │ │ │ +128 DUNE_SIMD_VC_BINARY_OP(>=); │ │ │ │ │ +129 │ │ │ │ │ +130 DUNE_SIMD_VC_BINARY_OP(==); │ │ │ │ │ +131 DUNE_SIMD_VC_BINARY_OP(!=); │ │ │ │ │ +132 │ │ │ │ │ +133 DUNE_SIMD_VC_BINARY_OP(&); │ │ │ │ │ +134 DUNE_SIMD_VC_BINARY_OP(^); │ │ │ │ │ +135 DUNE_SIMD_VC_BINARY_OP(|); │ │ │ │ │ +136 │ │ │ │ │ +137 DUNE_SIMD_VC_BINARY_OP(&&); │ │ │ │ │ +138 DUNE_SIMD_VC_BINARY_OP(||); │ │ │ │ │ +139#undef DUNE_SIMD_VC_BINARY_OP │ │ │ │ │ +140 │ │ │ │ │ +141#define DUNE_SIMD_VC_ASSIGNMENT(OP) \ │ │ │ │ │ +142 template \ │ │ │ │ │ +143 auto operator OP(T &&o) \ │ │ │ │ │ +144 -> std::enable_if_t(o)) \ │ │ │ │ │ +146 )>::value, Proxy&> \ │ │ │ │ │ +147 { \ │ │ │ │ │ +148 vec_[idx_] OP valueCast(std::forward(o)); \ │ │ │ │ │ +149 return *this; \ │ │ │ │ │ +150 } \ │ │ │ │ │ +151 static_assert(true, "Require semicolon to unconfuse editors") │ │ │ │ │ +152 │ │ │ │ │ +153 DUNE_SIMD_VC_ASSIGNMENT(=); │ │ │ │ │ +154 DUNE_SIMD_VC_ASSIGNMENT(*=); │ │ │ │ │ +155 DUNE_SIMD_VC_ASSIGNMENT(/=); │ │ │ │ │ +156 DUNE_SIMD_VC_ASSIGNMENT(%=); │ │ │ │ │ +157 DUNE_SIMD_VC_ASSIGNMENT(+=); │ │ │ │ │ +158 DUNE_SIMD_VC_ASSIGNMENT(-=); │ │ │ │ │ +159 DUNE_SIMD_VC_ASSIGNMENT(<<=); │ │ │ │ │ +160 DUNE_SIMD_VC_ASSIGNMENT(>>=); │ │ │ │ │ +161 DUNE_SIMD_VC_ASSIGNMENT(&=); │ │ │ │ │ +162 DUNE_SIMD_VC_ASSIGNMENT(^=); │ │ │ │ │ +163 DUNE_SIMD_VC_ASSIGNMENT(|=); │ │ │ │ │ +164#undef DUNE_SIMD_VC_ASSIGNMENT │ │ │ │ │ +165 │ │ │ │ │ +166 // swap on proxies swaps the proxied vector entries. As such, it │ │ │ │ │ +167 // applies to rvalues of proxies too, not just lvalues │ │ │ │ │ +168 template │ │ │ │ │ +169 friend void swap(Proxy, Proxy); │ │ │ │ │ +170 │ │ │ │ │ +171 template │ │ │ │ │ +172 friend void swap(Proxy p1, T& s2) │ │ │ │ │ +173 { │ │ │ │ │ +174 // don't use swap() ourselves -- not supported by Vc 1.3.0 (but is │ │ │ │ │ +175 // supported by Vc 1.3.2) │ │ │ │ │ +176 T tmp = p1.vec_[p1.idx_]; │ │ │ │ │ +177 p1.vec_[p1.idx_] = s2; │ │ │ │ │ +178 s2 = tmp; │ │ │ │ │ +179 } │ │ │ │ │ +180 │ │ │ │ │ +181 template │ │ │ │ │ +182 friend void swap(T& s1, Proxy p2) │ │ │ │ │ +183 { │ │ │ │ │ +184 T tmp = s1; │ │ │ │ │ +185 s1 = p2.vec_[p2.idx_]; │ │ │ │ │ +186 p2.vec_[p2.idx_] = tmp; │ │ │ │ │ +187 } │ │ │ │ │ +188 }; │ │ │ │ │ 189 │ │ │ │ │ -194 inline int size() const; │ │ │ │ │ -195 │ │ │ │ │ -196 bool operator==(const SLList& sl) const; │ │ │ │ │ -197 │ │ │ │ │ -198 │ │ │ │ │ -199 bool operator!=(const SLList& sl) const; │ │ │ │ │ -200 │ │ │ │ │ -201 private: │ │ │ │ │ -203 struct Element │ │ │ │ │ -204 { │ │ │ │ │ -208 Element* next_; │ │ │ │ │ -212 MemberType item_; │ │ │ │ │ -213 │ │ │ │ │ -214 Element(const MemberType& item, Element* next_=0); │ │ │ │ │ -215 │ │ │ │ │ -216 Element(); │ │ │ │ │ -217 │ │ │ │ │ -218 ~Element(); │ │ │ │ │ -219 }; │ │ │ │ │ -220 │ │ │ │ │ -225 void deleteNext(Element* current); │ │ │ │ │ -226 │ │ │ │ │ -231 void copyElements(const SLList& other); │ │ │ │ │ +190 template │ │ │ │ │ +191 void swap(Proxy p1, Proxy p2) │ │ │ │ │ +192 { │ │ │ │ │ +193 typename V1::value_type tmp = p1.vec_[p1.idx_]; │ │ │ │ │ +194 p1.vec_[p1.idx_] = p2.vec_[p2.idx_]; │ │ │ │ │ +195 p2.vec_[p2.idx_] = tmp; │ │ │ │ │ +196 } │ │ │ │ │ +197 } // namespace VcImpl │ │ │ │ │ +198#endif // HAVE_VC │ │ │ │ │ +199 │ │ │ │ │ +200 template │ │ │ │ │ +201 struct SimdScalarTypeTraits │ │ │ │ │ +202 { │ │ │ │ │ +203 using type = T; │ │ │ │ │ +204 }; │ │ │ │ │ +205 │ │ │ │ │ +206 template │ │ │ │ │ +207 using SimdScalar = typename SimdScalarTypeTraits::type; │ │ │ │ │ +208 │ │ │ │ │ +209#if HAVE_VC │ │ │ │ │ +210 /* │ │ │ │ │ +211 Add Vc specializations for the SimdScalarTypeTraits trais class │ │ │ │ │ +212 */ │ │ │ │ │ +213 template │ │ │ │ │ +214 struct SimdScalarTypeTraits< Vc::Vector > │ │ │ │ │ +215 { │ │ │ │ │ +216 using type = T; │ │ │ │ │ +217 }; │ │ │ │ │ +218 │ │ │ │ │ +219 template │ │ │ │ │ +220 struct SimdScalarTypeTraits< Vc::SimdArray > │ │ │ │ │ +221 { │ │ │ │ │ +222 using type = T; │ │ │ │ │ +223 }; │ │ │ │ │ +224#endif // HAVE_VC │ │ │ │ │ +225 │ │ │ │ │ +227 template │ │ │ │ │ +228 struct SimdScalarTypeTraits< AlignedNumber > │ │ │ │ │ +229 { │ │ │ │ │ +230 using type = T; │ │ │ │ │ +231 }; │ │ │ │ │ 232 │ │ │ │ │ -240 template │ │ │ │ │ -241 void deleteNext(Element* current); │ │ │ │ │ -247 void insertAfter(Element* current, const T& item); │ │ │ │ │ -248 │ │ │ │ │ -250 Element beforeHead_; │ │ │ │ │ -251 │ │ │ │ │ -257 Element* tail_; │ │ │ │ │ -258 │ │ │ │ │ -260 Allocator allocator_; │ │ │ │ │ -261 │ │ │ │ │ -263 int size_; │ │ │ │ │ -264 }; │ │ │ │ │ -265 │ │ │ │ │ -269 template │ │ │ │ │ -270 class SLListIterator : public Dune:: │ │ │ │ │ -ForwardIteratorFacade, T, T&, std::size_t> │ │ │ │ │ -271 { │ │ │ │ │ -272 friend class SLListConstIterator; │ │ │ │ │ -273 friend class SLListModifyIterator; │ │ │ │ │ -274 friend class SLList; │ │ │ │ │ -275 │ │ │ │ │ -276 public: │ │ │ │ │ -277 inline SLListIterator(typename SLList::Element* item, │ │ │ │ │ -278 SLList* sllist) │ │ │ │ │ -279 : current_(item), list_(sllist) │ │ │ │ │ -280 {} │ │ │ │ │ -281 │ │ │ │ │ -282 inline SLListIterator() │ │ │ │ │ -283 : current_(0), list_(0) │ │ │ │ │ -284 {} │ │ │ │ │ -285 │ │ │ │ │ -286 inline SLListIterator(const SLListModifyIterator& other) │ │ │ │ │ -287 : current_(other.iterator_.current_), list_(other.iterator_.list_) │ │ │ │ │ -288 {} │ │ │ │ │ -289 │ │ │ │ │ -294 inline T& dereference() const │ │ │ │ │ -295 { │ │ │ │ │ -296 return current_->item_; │ │ │ │ │ -297 } │ │ │ │ │ -298 │ │ │ │ │ -304 inline bool equals(const SLListConstIterator& other) const │ │ │ │ │ -305 { │ │ │ │ │ -306 return current_==other.current_; │ │ │ │ │ -307 } │ │ │ │ │ +233 template │ │ │ │ │ +234 struct SimdIndexTypeTraits { │ │ │ │ │ +235 using type = std::size_t; │ │ │ │ │ +236 }; │ │ │ │ │ +237 │ │ │ │ │ +239 │ │ │ │ │ +245 template │ │ │ │ │ +246 using SimdIndex = typename SimdIndexTypeTraits::type; │ │ │ │ │ +247 │ │ │ │ │ +248#if HAVE_VC │ │ │ │ │ +249 template │ │ │ │ │ +250 struct SimdIndexTypeTraits > { │ │ │ │ │ +251 using type = typename Vc::Vector::index_type; │ │ │ │ │ +252 }; │ │ │ │ │ +253 │ │ │ │ │ +254 template │ │ │ │ │ +255 struct SimdIndexTypeTraits > { │ │ │ │ │ +256 using type = typename Vc::SimdArray::index_type; │ │ │ │ │ +257 }; │ │ │ │ │ +258#endif // HAVE_VC │ │ │ │ │ +259 │ │ │ │ │ +260 template │ │ │ │ │ +261 struct SimdMaskTypeTraits { │ │ │ │ │ +262 using type = bool; │ │ │ │ │ +263 }; │ │ │ │ │ +264 │ │ │ │ │ +266 │ │ │ │ │ +269 template │ │ │ │ │ +270 using SimdMask = typename SimdMaskTypeTraits::type; │ │ │ │ │ +271 │ │ │ │ │ +272#if HAVE_VC │ │ │ │ │ +273 template │ │ │ │ │ +274 struct SimdMaskTypeTraits > { │ │ │ │ │ +275 using type = typename Vc::Vector::mask_type; │ │ │ │ │ +276 }; │ │ │ │ │ +277 │ │ │ │ │ +278 template │ │ │ │ │ +279 struct SimdMaskTypeTraits > { │ │ │ │ │ +280 using type = typename Vc::SimdArray::mask_type; │ │ │ │ │ +281 }; │ │ │ │ │ +282#endif // HAVE_VC │ │ │ │ │ +283 │ │ │ │ │ +284#if HAVE_VC │ │ │ │ │ +285 /* │ │ │ │ │ +286 Add Vc specializations for cond(), see conditional.hh │ │ │ │ │ +287 */ │ │ │ │ │ +288 template │ │ │ │ │ +289 Vc::Vector cond(const Vc::Mask & b, │ │ │ │ │ +290 const Vc::Vector & v1, │ │ │ │ │ +291 const Vc::Vector & v2) │ │ │ │ │ +292 { │ │ │ │ │ +293 return std::move(Vc::iif(b, v1, v2)); │ │ │ │ │ +294 } │ │ │ │ │ +295 │ │ │ │ │ +296 template │ │ │ │ │ +297 Vc::SimdArray cond(const typename Vc::SimdArray::mask_ │ │ │ │ │ +type & b, │ │ │ │ │ +298 const Vc::SimdArray & v1, │ │ │ │ │ +299 const Vc::SimdArray & v2) │ │ │ │ │ +300 { │ │ │ │ │ +301 return std::move(Vc::iif(b, v1, v2)); │ │ │ │ │ +302 } │ │ │ │ │ +303#endif // HAVE_VC │ │ │ │ │ +304 │ │ │ │ │ +305#if HAVE_VC │ │ │ │ │ +306 /* │ │ │ │ │ +307 Add Vc specializations for several boolean operations, see │ │ │ │ │ +rangeutitlities.hh: │ │ │ │ │ 308 │ │ │ │ │ -314 inline bool equals(const SLListIterator& other) const │ │ │ │ │ -315 { │ │ │ │ │ -316 return current_==other.current_; │ │ │ │ │ -317 } │ │ │ │ │ -318 │ │ │ │ │ -324 inline bool equals(const SLListModifyIterator& other) const │ │ │ │ │ +309 max_value, min_value, any_true, all_true │ │ │ │ │ +310 */ │ │ │ │ │ +311 template │ │ │ │ │ +312 T max_value(const Vc::Vector & v) │ │ │ │ │ +313 { │ │ │ │ │ +314 return v.max(); │ │ │ │ │ +315 } │ │ │ │ │ +316 │ │ │ │ │ +317 template │ │ │ │ │ +318 double max_value(const Vc::SimdArray & v) │ │ │ │ │ +319 { │ │ │ │ │ +320 return v.max(); │ │ │ │ │ +321 } │ │ │ │ │ +322 │ │ │ │ │ +323 template │ │ │ │ │ +324 T min_value(const Vc::Vector & v) │ │ │ │ │ 325 { │ │ │ │ │ -326 return current_==other.iterator_.current_; │ │ │ │ │ +326 return v.min(); │ │ │ │ │ 327 } │ │ │ │ │ 328 │ │ │ │ │ -332 inline void increment() │ │ │ │ │ -333 { │ │ │ │ │ -334 current_ = current_->next_; │ │ │ │ │ -335 } │ │ │ │ │ -336 │ │ │ │ │ -342 inline void insertAfter(const T& v) const │ │ │ │ │ +329 template │ │ │ │ │ +330 double min_value(const Vc::SimdArray & v) │ │ │ │ │ +331 { │ │ │ │ │ +332 return v.min(); │ │ │ │ │ +333 } │ │ │ │ │ +334 │ │ │ │ │ +335 template │ │ │ │ │ +336 bool any_true(const Vc::Mask & v) │ │ │ │ │ +337 { │ │ │ │ │ +338 return Vc::any_of(v); │ │ │ │ │ +339 } │ │ │ │ │ +340 │ │ │ │ │ +341 template │ │ │ │ │ +342 bool any_true(const Vc::SimdMaskArray & v) │ │ │ │ │ 343 { │ │ │ │ │ -344 assert(list_ ); │ │ │ │ │ -345 list_->insertAfter(current_, v); │ │ │ │ │ -346 } │ │ │ │ │ -347 │ │ │ │ │ -353 inline void deleteNext() const │ │ │ │ │ -354 { │ │ │ │ │ -355 assert(list_); │ │ │ │ │ -356 list_->deleteNext(current_); │ │ │ │ │ +344 return Vc::any_of(v); │ │ │ │ │ +345 } │ │ │ │ │ +346 │ │ │ │ │ +347 template │ │ │ │ │ +348 bool all_true(const Vc::Mask & v) │ │ │ │ │ +349 { │ │ │ │ │ +350 return Vc::all_of(v); │ │ │ │ │ +351 } │ │ │ │ │ +352 │ │ │ │ │ +353 template │ │ │ │ │ +354 bool all_true(const Vc::SimdMaskArray & v) │ │ │ │ │ +355 { │ │ │ │ │ +356 return Vc::all_of(v); │ │ │ │ │ 357 } │ │ │ │ │ -358 │ │ │ │ │ -359 private: │ │ │ │ │ -361 typename SLList::Element* current_; │ │ │ │ │ -363 SLList* list_; │ │ │ │ │ -364 }; │ │ │ │ │ -365 │ │ │ │ │ -369 template │ │ │ │ │ -370 class SLListConstIterator : public Dune:: │ │ │ │ │ -ForwardIteratorFacade, const T, const T&, std::size_t> │ │ │ │ │ -371 { │ │ │ │ │ -372 friend class SLListIterator; │ │ │ │ │ -373 friend class SLList; │ │ │ │ │ -374 │ │ │ │ │ -375 public: │ │ │ │ │ -376 inline SLListConstIterator() │ │ │ │ │ -377 : current_(0) │ │ │ │ │ -378 {} │ │ │ │ │ +358#endif // HAVE_VC │ │ │ │ │ +359 │ │ │ │ │ +361 template │ │ │ │ │ +362 std::size_t lanes(const T &) { return 1; } │ │ │ │ │ +363 │ │ │ │ │ +365 template │ │ │ │ │ +366 T lane(std::size_t l, const T &v) │ │ │ │ │ +367 { │ │ │ │ │ +368 assert(l == 0); │ │ │ │ │ +369 return v; │ │ │ │ │ +370 } │ │ │ │ │ +371 │ │ │ │ │ +373 template │ │ │ │ │ +374 T &lane(std::size_t l, T &v) │ │ │ │ │ +375 { │ │ │ │ │ +376 assert(l == 0); │ │ │ │ │ +377 return v; │ │ │ │ │ +378 } │ │ │ │ │ 379 │ │ │ │ │ -380 inline SLListConstIterator(typename SLList::Element* item) │ │ │ │ │ -381 : current_(item) │ │ │ │ │ -382 {} │ │ │ │ │ -383 │ │ │ │ │ -384 inline SLListConstIterator(const SLListIterator& other) │ │ │ │ │ -385 : current_(other.current_) │ │ │ │ │ -386 {} │ │ │ │ │ -387 │ │ │ │ │ -388 inline SLListConstIterator(const SLListModifyIterator& other) │ │ │ │ │ -389 : current_(other.iterator_.current_) │ │ │ │ │ -390 {} │ │ │ │ │ -391 │ │ │ │ │ -396 inline const T& dereference() const │ │ │ │ │ -397 { │ │ │ │ │ -398 return current_->item_; │ │ │ │ │ +380#if HAVE_VC │ │ │ │ │ +381 template │ │ │ │ │ +382 std::size_t lanes(const Vc::Vector &) │ │ │ │ │ +383 { │ │ │ │ │ +384 return Vc::Vector::size(); │ │ │ │ │ +385 } │ │ │ │ │ +386 │ │ │ │ │ +387 template │ │ │ │ │ +388 T lane(std::size_t l, const Vc::Vector &v) │ │ │ │ │ +389 { │ │ │ │ │ +390 assert(l < lanes(v)); │ │ │ │ │ +391 return v[l]; │ │ │ │ │ +392 } │ │ │ │ │ +393 │ │ │ │ │ +394 template │ │ │ │ │ +395 auto lane(std::size_t l, Vc::Vector &v) │ │ │ │ │ +396 { │ │ │ │ │ +397 assert(l < lanes(v)); │ │ │ │ │ +398 return VcImpl::Proxy >{l, v}; │ │ │ │ │ 399 } │ │ │ │ │ 400 │ │ │ │ │ -406 inline bool equals(const SLListConstIterator& other) const │ │ │ │ │ -407 { │ │ │ │ │ -408 return current_==other.current_; │ │ │ │ │ -409 } │ │ │ │ │ -410 │ │ │ │ │ -414 inline void increment() │ │ │ │ │ -415 { │ │ │ │ │ -416 current_ = current_->next_; │ │ │ │ │ -417 } │ │ │ │ │ -418 │ │ │ │ │ -419 private: │ │ │ │ │ -421 typename SLList::Element* current_; │ │ │ │ │ -422 }; │ │ │ │ │ -423 │ │ │ │ │ -427 template │ │ │ │ │ -428 class SLListModifyIterator : public Dune:: │ │ │ │ │ -ForwardIteratorFacade, T, T&, std::size_t> │ │ │ │ │ +401 template │ │ │ │ │ +402 std::size_t lanes(const Vc::SimdArray &) │ │ │ │ │ +403 { │ │ │ │ │ +404 return n; │ │ │ │ │ +405 } │ │ │ │ │ +406 │ │ │ │ │ +407 template │ │ │ │ │ +408 T lane(std::size_t l, const Vc::SimdArray &v) │ │ │ │ │ +409 { │ │ │ │ │ +410 assert(l < n); │ │ │ │ │ +411 return v[l]; │ │ │ │ │ +412 } │ │ │ │ │ +413 │ │ │ │ │ +414 template │ │ │ │ │ +415 auto lane(std::size_t l, Vc::SimdArray &v) │ │ │ │ │ +416 { │ │ │ │ │ +417 assert(l < n); │ │ │ │ │ +418 return VcImpl::Proxy >{l, v}; │ │ │ │ │ +419 } │ │ │ │ │ +420 │ │ │ │ │ +421 template │ │ │ │ │ +422 std::size_t lanes(const Vc::SimdMaskArray &) │ │ │ │ │ +423 { │ │ │ │ │ +424 return n; │ │ │ │ │ +425 } │ │ │ │ │ +426 │ │ │ │ │ +427 template │ │ │ │ │ +428 bool lane(std::size_t l, const Vc::SimdMaskArray &v) │ │ │ │ │ 429 { │ │ │ │ │ -430 friend class SLListConstIterator; │ │ │ │ │ -431 friend class SLListIterator; │ │ │ │ │ -432 public: │ │ │ │ │ -433 inline SLListModifyIterator(SLListIterator beforeIterator, │ │ │ │ │ -434 SLListIterator _iterator) │ │ │ │ │ -435 : beforeIterator_(beforeIterator), iterator_(_iterator) │ │ │ │ │ -436 {} │ │ │ │ │ -437 │ │ │ │ │ -438 inline SLListModifyIterator() │ │ │ │ │ -439 : beforeIterator_(), iterator_() │ │ │ │ │ -440 {} │ │ │ │ │ +430 assert(l < n); │ │ │ │ │ +431 return v[l]; │ │ │ │ │ +432 } │ │ │ │ │ +433 │ │ │ │ │ +434 template │ │ │ │ │ +435 auto lane(std::size_t l, Vc::SimdMaskArray &v) │ │ │ │ │ +436 { │ │ │ │ │ +437 assert(l < n); │ │ │ │ │ +438 return VcImpl::Proxy >{l, v}; │ │ │ │ │ +439 } │ │ │ │ │ +440#endif // HAVE_VC │ │ │ │ │ 441 │ │ │ │ │ -446 inline T& dereference() const │ │ │ │ │ -447 { │ │ │ │ │ -448 return *iterator_; │ │ │ │ │ -449 } │ │ │ │ │ -450 │ │ │ │ │ -456 inline bool equals(const SLListConstIterator& other) const │ │ │ │ │ -457 { │ │ │ │ │ -458 return iterator_== other; │ │ │ │ │ -459 } │ │ │ │ │ -460 │ │ │ │ │ -461 │ │ │ │ │ -467 inline bool equals(const SLListIterator& other) const │ │ │ │ │ -468 { │ │ │ │ │ -469 return iterator_== other; │ │ │ │ │ -470 } │ │ │ │ │ -471 │ │ │ │ │ -472 │ │ │ │ │ -478 inline bool equals(const SLListModifyIterator& other) const │ │ │ │ │ -479 { │ │ │ │ │ -480 return iterator_== other.iterator_; │ │ │ │ │ -481 } │ │ │ │ │ -482 │ │ │ │ │ -486 inline void increment() │ │ │ │ │ -487 { │ │ │ │ │ -488 ++iterator_; │ │ │ │ │ -489 ++beforeIterator_; │ │ │ │ │ -490 } │ │ │ │ │ -491 │ │ │ │ │ -505 inline void insert(const T& v) │ │ │ │ │ -506 { │ │ │ │ │ -507 beforeIterator_.insertAfter(v); │ │ │ │ │ -508 ++beforeIterator_; │ │ │ │ │ -509 } │ │ │ │ │ -510 │ │ │ │ │ -518 inline void remove() │ │ │ │ │ -519 { │ │ │ │ │ -520 ++iterator_; │ │ │ │ │ -521 beforeIterator_.deleteNext(); │ │ │ │ │ -522 } │ │ │ │ │ -523 │ │ │ │ │ -524 private: │ │ │ │ │ -526 SLListIterator beforeIterator_; │ │ │ │ │ -528 SLListIterator iterator_; │ │ │ │ │ -529 }; │ │ │ │ │ -530 │ │ │ │ │ -531 template │ │ │ │ │ -532 std::ostream& operator<<(std::ostream& os, const SLList& sllist) │ │ │ │ │ -533 { │ │ │ │ │ -534 typedef typename SLList::const_iterator Iterator; │ │ │ │ │ -535 Iterator end = sllist.end(); │ │ │ │ │ -536 Iterator current= sllist.begin(); │ │ │ │ │ -537 │ │ │ │ │ -538 os << "{ "; │ │ │ │ │ -539 │ │ │ │ │ -540 if(current!=end) { │ │ │ │ │ -541 os<<*current<<" ("<(&(*current))<<")"; │ │ │ │ │ -542 ++current; │ │ │ │ │ -543 │ │ │ │ │ -544 for(; current != end; ++current) │ │ │ │ │ -545 os<<", "<<*current<<" ("<(&(*current))<<")"; │ │ │ │ │ -546 } │ │ │ │ │ -547 os<<"} "; │ │ │ │ │ -548 return os; │ │ │ │ │ -549 } │ │ │ │ │ -550 │ │ │ │ │ -551 template │ │ │ │ │ -552 SLList::Element::Element(const MemberType& item, Element* next) │ │ │ │ │ -553 : next_(next), item_(item) │ │ │ │ │ -554 {} │ │ │ │ │ -555 │ │ │ │ │ -556 template │ │ │ │ │ -557 SLList::Element::Element() │ │ │ │ │ -558 : next_(0), item_() │ │ │ │ │ -559 {} │ │ │ │ │ -560 │ │ │ │ │ -561 template │ │ │ │ │ -562 SLList::Element::~Element() │ │ │ │ │ -563 { │ │ │ │ │ -564 next_=0; │ │ │ │ │ -565 } │ │ │ │ │ -566 │ │ │ │ │ -567 template │ │ │ │ │ -568 SLList::SLList() │ │ │ │ │ -569 : beforeHead_(), tail_(&beforeHead_), allocator_(), size_(0) │ │ │ │ │ -570 { │ │ │ │ │ -571 beforeHead_.next_=0; │ │ │ │ │ -572 assert(&beforeHead_==tail_); │ │ │ │ │ -573 assert(tail_->next_==0); │ │ │ │ │ -574 } │ │ │ │ │ -575 │ │ │ │ │ -576 template │ │ │ │ │ -577 SLList::SLList(const SLList& other) │ │ │ │ │ -578 : beforeHead_(), tail_(&beforeHead_), allocator_(), size_(0) │ │ │ │ │ -579 { │ │ │ │ │ -580 copyElements(other); │ │ │ │ │ -581 } │ │ │ │ │ -582 │ │ │ │ │ -583 template │ │ │ │ │ -584 template │ │ │ │ │ -585 SLList::SLList(const SLList& other) │ │ │ │ │ -586 : beforeHead_(), tail_(&beforeHead_), allocator_(), size_(0) │ │ │ │ │ -587 { │ │ │ │ │ -588 copyElements(other); │ │ │ │ │ -589 } │ │ │ │ │ -590 │ │ │ │ │ -591 template │ │ │ │ │ -592 void SLList::copyElements(const SLList& other) │ │ │ │ │ -593 { │ │ │ │ │ -594 assert(tail_==&beforeHead_); │ │ │ │ │ -595 assert(size_==0); │ │ │ │ │ -596 typedef typename SLList::const_iterator Iterator; │ │ │ │ │ -597 Iterator iend = other.end(); │ │ │ │ │ -598 for(Iterator element=other.begin(); element != iend; ++element) │ │ │ │ │ -599 push_back(*element); │ │ │ │ │ -600 │ │ │ │ │ -601 assert(other.size()==size()); │ │ │ │ │ -602 } │ │ │ │ │ -603 │ │ │ │ │ -604 template │ │ │ │ │ -605 SLList::~SLList() │ │ │ │ │ -606 { │ │ │ │ │ -607 clear(); │ │ │ │ │ -608 } │ │ │ │ │ -609 │ │ │ │ │ -610 template │ │ │ │ │ -611 bool SLList::operator==(const SLList& other) const │ │ │ │ │ -612 { │ │ │ │ │ -613 if(size()!=other.size()) │ │ │ │ │ -614 return false; │ │ │ │ │ -615 for(const_iterator iter=begin(), oiter=other.begin(); │ │ │ │ │ -616 iter != end(); ++iter, ++oiter) │ │ │ │ │ -617 if(*iter!=*oiter) │ │ │ │ │ -618 return false; │ │ │ │ │ -619 return true; │ │ │ │ │ -620 } │ │ │ │ │ -621 │ │ │ │ │ -622 template │ │ │ │ │ -623 bool SLList::operator!=(const SLList& other) const │ │ │ │ │ -624 { │ │ │ │ │ -625 if(size()==other.size()) { │ │ │ │ │ -626 for(const_iterator iter=begin(), oiter=other.begin(); │ │ │ │ │ -627 iter != end(); ++iter, ++oiter) │ │ │ │ │ -628 if(*iter!=*oiter) │ │ │ │ │ -629 return true; │ │ │ │ │ -630 return false; │ │ │ │ │ -631 }else │ │ │ │ │ -632 return true; │ │ │ │ │ -633 } │ │ │ │ │ -634 template │ │ │ │ │ -635 SLList& SLList::operator=(const SLList& other) │ │ │ │ │ -636 { │ │ │ │ │ -637 clear(); │ │ │ │ │ -638 copyElements(other); │ │ │ │ │ -639 return *this; │ │ │ │ │ -640 } │ │ │ │ │ -641 │ │ │ │ │ -642 template │ │ │ │ │ -643 inline void SLList::push_back(const MemberType& item) │ │ │ │ │ -644 { │ │ │ │ │ -645 assert(size_>0 || tail_==&beforeHead_); │ │ │ │ │ -646 tail_->next_ = allocator_.allocate(1); │ │ │ │ │ -647 assert(size_>0 || tail_==&beforeHead_); │ │ │ │ │ -648 tail_ = tail_->next_; │ │ │ │ │ -649 ::new (static_cast(&(tail_->item_)))T(item); │ │ │ │ │ -650 tail_->next_=0; │ │ │ │ │ -651 assert(tail_->next_==0); │ │ │ │ │ -652 ++size_; │ │ │ │ │ -653 } │ │ │ │ │ -654 │ │ │ │ │ -655 template │ │ │ │ │ -656 inline void SLList::insertAfter(Element* current, const T& item) │ │ │ │ │ -657 { │ │ │ │ │ -658 assert(current); │ │ │ │ │ -659 │ │ │ │ │ -660#ifndef NDEBUG │ │ │ │ │ -661 bool changeTail = (current == tail_); │ │ │ │ │ -662#endif │ │ │ │ │ -663 │ │ │ │ │ -664 // Save old next element │ │ │ │ │ -665 Element* tmp = current->next_; │ │ │ │ │ -666 │ │ │ │ │ -667 assert(!changeTail || !tmp); │ │ │ │ │ -668 │ │ │ │ │ -669 // Allocate space │ │ │ │ │ -670 current->next_ = allocator_.allocate(1); │ │ │ │ │ -671 │ │ │ │ │ -672 // Use copy constructor to initialize memory │ │ │ │ │ -673 std::allocator_traits::construct(allocator_, current->next_, │ │ │ │ │ -Element(item,tmp)); │ │ │ │ │ -674 │ │ │ │ │ -675 //::new(static_cast(&(current->next_->item_))) T(item); │ │ │ │ │ -676 │ │ │ │ │ -677 if(!current->next_->next_) { │ │ │ │ │ -678 // Update tail │ │ │ │ │ -679 assert(changeTail); │ │ │ │ │ -680 tail_ = current->next_; │ │ │ │ │ -681 } │ │ │ │ │ -682 ++size_; │ │ │ │ │ -683 assert(!tail_->next_); │ │ │ │ │ -684 } │ │ │ │ │ -685 │ │ │ │ │ -686 template │ │ │ │ │ -687 inline void SLList::push_front(const MemberType& item) │ │ │ │ │ -688 { │ │ │ │ │ -689 if(tail_ == &beforeHead_) { │ │ │ │ │ -690 // list was empty │ │ │ │ │ -691 beforeHead_.next_ = tail_ = allocator_.allocate(1, 0); │ │ │ │ │ -692 ::new(static_cast(&beforeHead_.next_->item_))T(item); │ │ │ │ │ -693 beforeHead_.next_->next_=0; │ │ │ │ │ -694 }else{ │ │ │ │ │ -695 Element* added = allocator_.allocate(1, 0); │ │ │ │ │ -696 ::new(static_cast(&added->item_))T(item); │ │ │ │ │ -697 added->next_=beforeHead_.next_; │ │ │ │ │ -698 beforeHead_.next_=added; │ │ │ │ │ -699 } │ │ │ │ │ -700 assert(tail_->next_==0); │ │ │ │ │ -701 ++size_; │ │ │ │ │ -702 } │ │ │ │ │ -703 │ │ │ │ │ -704 │ │ │ │ │ -705 template │ │ │ │ │ -706 inline void SLList::deleteNext(Element* current) │ │ │ │ │ -707 { │ │ │ │ │ -708 this->template deleteNext(current); │ │ │ │ │ -709 } │ │ │ │ │ -710 │ │ │ │ │ -711 template │ │ │ │ │ -712 template │ │ │ │ │ -713 inline void SLList::deleteNext(Element* current) │ │ │ │ │ -714 { │ │ │ │ │ -715 assert(current->next_); │ │ │ │ │ -716 Element* next = current->next_; │ │ │ │ │ -717 │ │ │ │ │ -718 if(watchForTail) │ │ │ │ │ -719 if(next == tail_) { │ │ │ │ │ -720 // deleting last element changes tail! │ │ │ │ │ -721 tail_ = current; │ │ │ │ │ -722 } │ │ │ │ │ -723 │ │ │ │ │ -724 current->next_ = next->next_; │ │ │ │ │ -725 std::allocator_traits::destroy(allocator_, next); │ │ │ │ │ -726 allocator_.deallocate(next, 1); │ │ │ │ │ -727 --size_; │ │ │ │ │ -728 assert(!watchForTail || &beforeHead_ != tail_ || size_==0); │ │ │ │ │ -729 } │ │ │ │ │ -730 │ │ │ │ │ -731 template │ │ │ │ │ -732 inline void SLList::pop_front() │ │ │ │ │ -733 { │ │ │ │ │ -734 deleteNext(&beforeHead_); │ │ │ │ │ -735 } │ │ │ │ │ -736 │ │ │ │ │ -737 template │ │ │ │ │ -738 inline void SLList::clear() │ │ │ │ │ -739 { │ │ │ │ │ -740 while(beforeHead_.next_ ) { │ │ │ │ │ -741 this->template deleteNext(&beforeHead_); │ │ │ │ │ -742 } │ │ │ │ │ -743 │ │ │ │ │ -744 assert(size_==0); │ │ │ │ │ -745 // update the tail! │ │ │ │ │ -746 tail_ = &beforeHead_; │ │ │ │ │ -747 } │ │ │ │ │ -748 │ │ │ │ │ -749 template │ │ │ │ │ -750 inline bool SLList::empty() const │ │ │ │ │ -751 { │ │ │ │ │ -752 return (&beforeHead_ == tail_); │ │ │ │ │ -753 } │ │ │ │ │ -754 │ │ │ │ │ -755 template │ │ │ │ │ -756 inline int SLList::size() const │ │ │ │ │ -757 { │ │ │ │ │ -758 return size_; │ │ │ │ │ -759 } │ │ │ │ │ -760 │ │ │ │ │ -761 template │ │ │ │ │ -762 inline SLListIterator SLList::begin() │ │ │ │ │ -763 { │ │ │ │ │ -764 return iterator(beforeHead_.next_, this); │ │ │ │ │ -765 } │ │ │ │ │ -766 │ │ │ │ │ -767 template │ │ │ │ │ -768 inline SLListConstIterator SLList::begin() const │ │ │ │ │ -769 { │ │ │ │ │ -770 return const_iterator(beforeHead_.next_); │ │ │ │ │ -771 } │ │ │ │ │ -772 │ │ │ │ │ -773 template │ │ │ │ │ -774 inline SLListIterator SLList::end() │ │ │ │ │ -775 { │ │ │ │ │ -776 return iterator(); │ │ │ │ │ -777 } │ │ │ │ │ -778 │ │ │ │ │ -779 template │ │ │ │ │ -780 inline SLListModifyIterator SLList::endModify() │ │ │ │ │ -781 { │ │ │ │ │ -782 return SLListModifyIterator(iterator(tail_, this),iterator()); │ │ │ │ │ -783 } │ │ │ │ │ -784 │ │ │ │ │ -785 │ │ │ │ │ -786 template │ │ │ │ │ -787 inline SLListModifyIterator SLList::beginModify() │ │ │ │ │ -788 { │ │ │ │ │ -789 return SLListModifyIterator(iterator(&beforeHead_, this), │ │ │ │ │ -790 iterator(beforeHead_.next_, this)); │ │ │ │ │ -791 } │ │ │ │ │ -792 │ │ │ │ │ -793 template │ │ │ │ │ -794 inline SLListConstIterator SLList::end() const │ │ │ │ │ -795 { │ │ │ │ │ -796 return const_iterator(); │ │ │ │ │ -797 } │ │ │ │ │ -798 │ │ │ │ │ -800} │ │ │ │ │ -801#endif │ │ │ │ │ -iteratorfacades.hh │ │ │ │ │ -This file implements iterator facade classes for writing stl conformant │ │ │ │ │ -iterators. │ │ │ │ │ -Dune::SLList::push_front │ │ │ │ │ -void push_front(const MemberType &item) │ │ │ │ │ -Add a new entry to the beginning of the list. │ │ │ │ │ -Definition sllist.hh:687 │ │ │ │ │ -Dune::SLListConstIterator::equals │ │ │ │ │ -bool equals(const SLListConstIterator< T, A > &other) const │ │ │ │ │ -Equality test for the iterator facade. │ │ │ │ │ -Definition sllist.hh:406 │ │ │ │ │ -Dune::SLList::push_back │ │ │ │ │ -void push_back(const MemberType &item) │ │ │ │ │ -Add a new entry to the end of the list. │ │ │ │ │ -Definition sllist.hh:643 │ │ │ │ │ -Dune::SLList::endModify │ │ │ │ │ -ModifyIterator endModify() │ │ │ │ │ -Get an iterator capable of deleting and inserting elements. │ │ │ │ │ -Definition sllist.hh:780 │ │ │ │ │ -Dune::SLListModifyIterator::SLListModifyIterator │ │ │ │ │ -SLListModifyIterator() │ │ │ │ │ -Definition sllist.hh:438 │ │ │ │ │ -Dune::SLList::Element::Element │ │ │ │ │ -Element() │ │ │ │ │ -Definition sllist.hh:557 │ │ │ │ │ -Dune::SLListIterator::dereference │ │ │ │ │ -T & dereference() const │ │ │ │ │ -Dereferencing function for the iterator facade. │ │ │ │ │ -Definition sllist.hh:294 │ │ │ │ │ -Dune::SLList::operator!= │ │ │ │ │ -bool operator!=(const SLList &sl) const │ │ │ │ │ -Definition sllist.hh:623 │ │ │ │ │ -Dune::SLList::Element::item_ │ │ │ │ │ -MemberType item_ │ │ │ │ │ -The element we hold. │ │ │ │ │ -Definition sllist.hh:212 │ │ │ │ │ -Dune::SLListConstIterator::SLListConstIterator │ │ │ │ │ -SLListConstIterator(typename SLList< T, A >::Element *item) │ │ │ │ │ -Definition sllist.hh:380 │ │ │ │ │ -Dune::SLList::Allocator │ │ │ │ │ -typename std::allocator_traits< A >::template rebind_alloc< Element > Allocator │ │ │ │ │ -The allocator to use. │ │ │ │ │ -Definition sllist.hh:64 │ │ │ │ │ -Dune::SLListIterator::insertAfter │ │ │ │ │ -void insertAfter(const T &v) const │ │ │ │ │ -Insert an element in the underlying list after the current position. │ │ │ │ │ -Definition sllist.hh:342 │ │ │ │ │ -Dune::SLList::iterator │ │ │ │ │ -SLListIterator< T, A > iterator │ │ │ │ │ -The mutable iterator of the list. │ │ │ │ │ -Definition sllist.hh:69 │ │ │ │ │ -Dune::SLListConstIterator::SLListConstIterator │ │ │ │ │ -SLListConstIterator(const SLListModifyIterator< T, A > &other) │ │ │ │ │ -Definition sllist.hh:388 │ │ │ │ │ -Dune::SLListIterator::SLListIterator │ │ │ │ │ -SLListIterator() │ │ │ │ │ -Definition sllist.hh:282 │ │ │ │ │ -Dune::SLList::Element::~Element │ │ │ │ │ -~Element() │ │ │ │ │ -Definition sllist.hh:562 │ │ │ │ │ -Dune::SLList::operator== │ │ │ │ │ -bool operator==(const SLList &sl) const │ │ │ │ │ -Definition sllist.hh:611 │ │ │ │ │ -Dune::SLListIterator::deleteNext │ │ │ │ │ -void deleteNext() const │ │ │ │ │ -Delete the entry after the current position. │ │ │ │ │ -Definition sllist.hh:353 │ │ │ │ │ -Dune::SLList::SLList │ │ │ │ │ -SLList(const SLList< T, A > &other) │ │ │ │ │ -Copy constructor. │ │ │ │ │ -Definition sllist.hh:577 │ │ │ │ │ -Dune::SLListIterator::equals │ │ │ │ │ -bool equals(const SLListModifyIterator< T, A > &other) const │ │ │ │ │ -Equality test for the iterator facade. │ │ │ │ │ -Definition sllist.hh:324 │ │ │ │ │ -Dune::SLListModifyIterator::dereference │ │ │ │ │ -T & dereference() const │ │ │ │ │ -Dereferencing function for the iterator facade. │ │ │ │ │ -Definition sllist.hh:446 │ │ │ │ │ -Dune::SLList::size │ │ │ │ │ -int size() const │ │ │ │ │ -Get the number of elements the list contains. │ │ │ │ │ -Definition sllist.hh:756 │ │ │ │ │ -Dune::SLList::begin │ │ │ │ │ -const_iterator begin() const │ │ │ │ │ -Get an iterator pointing to the first element in the list. │ │ │ │ │ -Definition sllist.hh:768 │ │ │ │ │ -Dune::SLList::end │ │ │ │ │ -iterator end() │ │ │ │ │ -Get an iterator pointing to the end of the list. │ │ │ │ │ -Definition sllist.hh:774 │ │ │ │ │ -Dune::SLList::clear │ │ │ │ │ -void clear() │ │ │ │ │ -Remove all elements from the list. │ │ │ │ │ -Definition sllist.hh:738 │ │ │ │ │ -Dune::SLList::SLList │ │ │ │ │ -SLList(const SLList< T1, A1 > &other) │ │ │ │ │ -Copy constructor with type conversion. │ │ │ │ │ -Definition sllist.hh:585 │ │ │ │ │ -Dune::SLList::MemberType │ │ │ │ │ -T MemberType │ │ │ │ │ -The type we store. │ │ │ │ │ -Definition sllist.hh:59 │ │ │ │ │ -Dune::SLListModifyIterator::equals │ │ │ │ │ -bool equals(const SLListModifyIterator< T, A > &other) const │ │ │ │ │ -Test whether another iterator is equal. │ │ │ │ │ -Definition sllist.hh:478 │ │ │ │ │ -Dune::SLList::beginModify │ │ │ │ │ -ModifyIterator beginModify() │ │ │ │ │ -Get an iterator capable of deleting and inserting elements. │ │ │ │ │ -Definition sllist.hh:787 │ │ │ │ │ -Dune::SLList::operator= │ │ │ │ │ -SLList< T, A > & operator=(const SLList< T, A > &other) │ │ │ │ │ -Assignment operator. │ │ │ │ │ -Definition sllist.hh:635 │ │ │ │ │ -Dune::SLListConstIterator::SLListConstIterator │ │ │ │ │ -SLListConstIterator(const SLListIterator< T, A > &other) │ │ │ │ │ -Definition sllist.hh:384 │ │ │ │ │ -Dune::SLList::const_iterator │ │ │ │ │ -SLListConstIterator< T, A > const_iterator │ │ │ │ │ -The constant iterator of the list. │ │ │ │ │ -Definition sllist.hh:74 │ │ │ │ │ -Dune::SLList::empty │ │ │ │ │ -bool empty() const │ │ │ │ │ -Check whether the list is empty. │ │ │ │ │ -Definition sllist.hh:750 │ │ │ │ │ -Dune::SLListConstIterator::SLListConstIterator │ │ │ │ │ -SLListConstIterator() │ │ │ │ │ -Definition sllist.hh:376 │ │ │ │ │ -Dune::SLListIterator::equals │ │ │ │ │ -bool equals(const SLListConstIterator< T, A > &other) const │ │ │ │ │ -Equality test for the iterator facade. │ │ │ │ │ -Definition sllist.hh:304 │ │ │ │ │ -Dune::SLListModifyIterator::equals │ │ │ │ │ -bool equals(const SLListConstIterator< T, A > &other) const │ │ │ │ │ -Test whether another iterator is equal. │ │ │ │ │ -Definition sllist.hh:456 │ │ │ │ │ -Dune::SLList::ModifyIterator │ │ │ │ │ -SLListModifyIterator< T, A > ModifyIterator │ │ │ │ │ -The type of the iterator capable of deletion and insertion. │ │ │ │ │ -Definition sllist.hh:103 │ │ │ │ │ -Dune::SLList::end │ │ │ │ │ -const_iterator end() const │ │ │ │ │ -Get an iterator pointing to the end of the list. │ │ │ │ │ -Definition sllist.hh:794 │ │ │ │ │ -Dune::SLList::SLList │ │ │ │ │ -SLList() │ │ │ │ │ -Constructor. │ │ │ │ │ -Definition sllist.hh:568 │ │ │ │ │ -Dune::SLListModifyIterator::insert │ │ │ │ │ -void insert(const T &v) │ │ │ │ │ -Insert an element at the current position. │ │ │ │ │ -Definition sllist.hh:505 │ │ │ │ │ -Dune::SLListIterator::SLListIterator │ │ │ │ │ -SLListIterator(typename SLList< T, A >::Element *item, SLList< T, A > *sllist) │ │ │ │ │ -Definition sllist.hh:277 │ │ │ │ │ -Dune::SLListModifyIterator::SLListModifyIterator │ │ │ │ │ -SLListModifyIterator(SLListIterator< T, A > beforeIterator, SLListIterator< T, │ │ │ │ │ -A > _iterator) │ │ │ │ │ -Definition sllist.hh:433 │ │ │ │ │ -Dune::SLList::pop_front │ │ │ │ │ -void pop_front() │ │ │ │ │ -Remove the first item in the list. │ │ │ │ │ -Definition sllist.hh:732 │ │ │ │ │ -Dune::SLListIterator::increment │ │ │ │ │ -void increment() │ │ │ │ │ -Increment function for the iterator facade. │ │ │ │ │ -Definition sllist.hh:332 │ │ │ │ │ -Dune::SLListIterator::SLListIterator │ │ │ │ │ -SLListIterator(const SLListModifyIterator< T, A > &other) │ │ │ │ │ -Definition sllist.hh:286 │ │ │ │ │ -Dune::SLList::size_type │ │ │ │ │ -A::size_type size_type │ │ │ │ │ -The size type. │ │ │ │ │ -Definition sllist.hh:54 │ │ │ │ │ -Dune::SLListModifyIterator::remove │ │ │ │ │ -void remove() │ │ │ │ │ -Delete the entry at the current position. │ │ │ │ │ -Definition sllist.hh:518 │ │ │ │ │ -Dune::SLListConstIterator::dereference │ │ │ │ │ -const T & dereference() const │ │ │ │ │ -Dereferencing function for the facade. │ │ │ │ │ -Definition sllist.hh:396 │ │ │ │ │ -Dune::SLList::Element::next_ │ │ │ │ │ -Element * next_ │ │ │ │ │ -The next element in the list. │ │ │ │ │ -Definition sllist.hh:208 │ │ │ │ │ -Dune::SLListModifyIterator::increment │ │ │ │ │ -void increment() │ │ │ │ │ -Increment function for the iterator facade. │ │ │ │ │ -Definition sllist.hh:486 │ │ │ │ │ -Dune::SLListConstIterator::increment │ │ │ │ │ -void increment() │ │ │ │ │ -Increment function for the iterator facade. │ │ │ │ │ -Definition sllist.hh:414 │ │ │ │ │ -Dune::SLList::~SLList │ │ │ │ │ -~SLList() │ │ │ │ │ -Destructor. │ │ │ │ │ -Definition sllist.hh:605 │ │ │ │ │ -Dune::SLListModifyIterator::equals │ │ │ │ │ -bool equals(const SLListIterator< T, A > &other) const │ │ │ │ │ -Test whether another iterator is equal. │ │ │ │ │ -Definition sllist.hh:467 │ │ │ │ │ -Dune::SLList::begin │ │ │ │ │ -iterator begin() │ │ │ │ │ -Get an iterator pointing to the first element in the list. │ │ │ │ │ -Definition sllist.hh:762 │ │ │ │ │ -Dune::SLListIterator::equals │ │ │ │ │ -bool equals(const SLListIterator< T, A > &other) const │ │ │ │ │ -Equality test for the iterator facade. │ │ │ │ │ -Definition sllist.hh:314 │ │ │ │ │ -Dune::operator<< │ │ │ │ │ -std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x) │ │ │ │ │ -Definition bigunsignedint.hh:278 │ │ │ │ │ +443 │ │ │ │ │ +446 template │ │ │ │ │ +447 void assign(T &dst, const T &src, bool mask) │ │ │ │ │ +448 { │ │ │ │ │ +449 if(mask) dst = src; │ │ │ │ │ +450 } │ │ │ │ │ +451 │ │ │ │ │ +452#if HAVE_VC │ │ │ │ │ +453 /* │ │ │ │ │ +454 Add Vc specializations for masked assignment │ │ │ │ │ +455 */ │ │ │ │ │ +456 template │ │ │ │ │ +457 void assign(Vc::Vector &dst, const Vc::Vector &src, │ │ │ │ │ +458 typename Vc::Vector::mask_type mask) │ │ │ │ │ +459 { │ │ │ │ │ +460 dst(mask) = src; │ │ │ │ │ +461 } │ │ │ │ │ +462 │ │ │ │ │ +463 template │ │ │ │ │ +464 void assign(Vc::SimdArray &dst, const Vc::SimdArray &src, │ │ │ │ │ +465 typename Vc::SimdArray::mask_type mask) │ │ │ │ │ +466 { │ │ │ │ │ +467 dst(mask) = src; │ │ │ │ │ +468 } │ │ │ │ │ +469#endif // HAVE_VC │ │ │ │ │ +470 │ │ │ │ │ +471 template │ │ │ │ │ +472 void swap(T &v1, T &v2, bool mask) │ │ │ │ │ +473 { │ │ │ │ │ +474 using std::swap; │ │ │ │ │ +475 if(mask) swap(v1, v2); │ │ │ │ │ +476 } │ │ │ │ │ +477 │ │ │ │ │ +478#if HAVE_VC │ │ │ │ │ +479 /* │ │ │ │ │ +480 Add Vc specializations for masked swap │ │ │ │ │ +481 */ │ │ │ │ │ +482 template │ │ │ │ │ +483 void swap(Vc::Vector &v1, Vc::Vector &v2, │ │ │ │ │ +484 typename Vc::Vector::mask_type mask) │ │ │ │ │ +485 { │ │ │ │ │ +486 auto tmp = v1; │ │ │ │ │ +487 v1(mask) = v2; │ │ │ │ │ +488 v2(mask) = tmp; │ │ │ │ │ +489 } │ │ │ │ │ +490 │ │ │ │ │ +491 template │ │ │ │ │ +492 void swap(Vc::SimdArray &v1, Vc::SimdArray &v2, │ │ │ │ │ +493 typename Vc::SimdArray::mask_type mask) │ │ │ │ │ +494 { │ │ │ │ │ +495 auto tmp = v1; │ │ │ │ │ +496 v1(mask) = v2; │ │ │ │ │ +497 v2(mask) = tmp; │ │ │ │ │ +498 } │ │ │ │ │ +499#endif // HAVE_VC │ │ │ │ │ +500 │ │ │ │ │ +501} // end namespace Dune │ │ │ │ │ +502 │ │ │ │ │ +503#endif // DUNE_COMMON_SIMD_HH │ │ │ │ │ +typetraits.hh │ │ │ │ │ +Traits for type conversions and type information. │ │ │ │ │ +debugalign.hh │ │ │ │ │ +vc.hh │ │ │ │ │ +Compatibility header for including │ │ │ │ │ +rangeutilities.hh │ │ │ │ │ +Utilities for reduction like operations on ranges. │ │ │ │ │ +conditional.hh │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::push_back │ │ │ │ │ -constexpr std::integer_sequence< T, II..., T(IN)> push_back(std::integer_ │ │ │ │ │ -sequence< T, II... >, std::integral_constant< T, IN >={}) │ │ │ │ │ -Append an index IN to the back of the sequence. │ │ │ │ │ -Definition integersequence.hh:69 │ │ │ │ │ -Dune::size │ │ │ │ │ -constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std:: │ │ │ │ │ -integer_sequence< T, II... >) │ │ │ │ │ -Return the size of the sequence. │ │ │ │ │ -Definition integersequence.hh:75 │ │ │ │ │ -Dune::ForwardIteratorFacade │ │ │ │ │ -Base class for stl conformant forward iterators. │ │ │ │ │ -Definition iteratorfacades.hh:142 │ │ │ │ │ -Dune::SLListIterator │ │ │ │ │ -A mutable iterator for the SLList. │ │ │ │ │ -Definition sllist.hh:271 │ │ │ │ │ -Dune::SLListConstIterator │ │ │ │ │ -A constant iterator for the SLList. │ │ │ │ │ -Definition sllist.hh:371 │ │ │ │ │ -Dune::SLListModifyIterator │ │ │ │ │ -A mutable iterator for the SLList. │ │ │ │ │ -Definition sllist.hh:429 │ │ │ │ │ -Dune::SLList │ │ │ │ │ -A single linked list. │ │ │ │ │ -Definition sllist.hh:44 │ │ │ │ │ +Dune::any_true │ │ │ │ │ +bool any_true(const AlignedNumber< bool, align > &val) │ │ │ │ │ +Definition debugalign.hh:506 │ │ │ │ │ +Dune::all_true │ │ │ │ │ +bool all_true(const AlignedNumber< bool, align > &val) │ │ │ │ │ +Definition debugalign.hh:512 │ │ │ │ │ +Dune::SimdIndex │ │ │ │ │ +typename SimdIndexTypeTraits< V >::type SimdIndex │ │ │ │ │ +An simd vector of indices corresponding to a simd vector V. │ │ │ │ │ +Definition simd.hh:246 │ │ │ │ │ +Dune::SimdScalar │ │ │ │ │ +typename SimdScalarTypeTraits< T >::type SimdScalar │ │ │ │ │ +Definition simd.hh:207 │ │ │ │ │ +Dune::SimdMask │ │ │ │ │ +typename SimdMaskTypeTraits< V >::type SimdMask │ │ │ │ │ +A simd vector of truth values corresponding to a simd vector V. │ │ │ │ │ +Definition simd.hh:270 │ │ │ │ │ +Dune::lane │ │ │ │ │ +T lane(std::size_t l, const T &v) │ │ │ │ │ +access a lane of a simd vector (scalar version) │ │ │ │ │ +Definition simd.hh:366 │ │ │ │ │ +Dune::swap │ │ │ │ │ +void swap(T &v1, T &v2, bool mask) │ │ │ │ │ +Definition simd.hh:472 │ │ │ │ │ +Dune::assign │ │ │ │ │ +void assign(T &dst, const T &src, bool mask) │ │ │ │ │ +masked Simd assignment (scalar version) │ │ │ │ │ +Definition simd.hh:447 │ │ │ │ │ +Dune::cond │ │ │ │ │ +const T1 cond(bool b, const T1 &v1, const T2 &v2) │ │ │ │ │ +conditional evaluate │ │ │ │ │ +Definition conditional.hh:28 │ │ │ │ │ +Dune::max_value │ │ │ │ │ +T max_value(const AlignedNumber< T, align > &val) │ │ │ │ │ +Definition debugalign.hh:494 │ │ │ │ │ +Dune::min_value │ │ │ │ │ +T min_value(const AlignedNumber< T, align > &val) │ │ │ │ │ +Definition debugalign.hh:500 │ │ │ │ │ +Dune::lanes │ │ │ │ │ +std::size_t lanes(const T &) │ │ │ │ │ +get the number of lanes of a simd vector (scalar version) │ │ │ │ │ +Definition simd.hh:362 │ │ │ │ │ +Dune::AlignedNumberImpl::AlignedNumber │ │ │ │ │ +aligned wrappers for arithmetic types │ │ │ │ │ +Definition debugalign.hh:128 │ │ │ │ │ +Dune::SimdScalarTypeTraits │ │ │ │ │ +Definition simd.hh:202 │ │ │ │ │ +Dune::SimdScalarTypeTraits::type │ │ │ │ │ +T type │ │ │ │ │ +Definition simd.hh:203 │ │ │ │ │ +Dune::SimdScalarTypeTraits<_AlignedNumber<_T,_align_>_>::type │ │ │ │ │ +T type │ │ │ │ │ +Definition simd.hh:230 │ │ │ │ │ +Dune::SimdIndexTypeTraits │ │ │ │ │ +Definition simd.hh:234 │ │ │ │ │ +Dune::SimdIndexTypeTraits::type │ │ │ │ │ +std::size_t type │ │ │ │ │ +Definition simd.hh:235 │ │ │ │ │ +Dune::SimdMaskTypeTraits │ │ │ │ │ +Definition simd.hh:261 │ │ │ │ │ +Dune::SimdMaskTypeTraits::type │ │ │ │ │ +bool type │ │ │ │ │ +Definition simd.hh:262 │ │ │ │ │ +vc.hh │ │ │ │ │ +SIMD abstractions for Vc. │ │ │ │ │ +DUNE_SIMD_VC_ASSIGNMENT │ │ │ │ │ +#define DUNE_SIMD_VC_ASSIGNMENT(OP) │ │ │ │ │ +Definition simd/vc.hh:224 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00101.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: quadmath.hh File Reference │ │ │ │ +dune-common: mallocallocator.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -69,19 +69,58 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
quadmath.hh File Reference
│ │ │ │ +
│ │ │ │ +Classes | │ │ │ │ +Namespaces | │ │ │ │ +Functions
│ │ │ │ +
mallocallocator.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ +

Allocators that use malloc/free. │ │ │ │ +More...

│ │ │ │ +
#include <exception>
│ │ │ │ +#include <cstdlib>
│ │ │ │ +#include <new>
│ │ │ │ +#include <utility>
│ │ │ │ +
│ │ │ │

Go to the source code of this file.

│ │ │ │ -
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Classes

class  Dune::MallocAllocator< T >
 Allocators implementation which simply calls malloc/free. More...
 
struct  Dune::MallocAllocator< T >::rebind< U >
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Functions

template<class T >
constexpr bool Dune::operator== (const MallocAllocator< T > &, const MallocAllocator< T > &)
 check whether allocators are equivalent
 
template<class T >
constexpr bool Dune::operator!= (const MallocAllocator< T > &, const MallocAllocator< T > &)
 check whether allocators are not equivalent
 
│ │ │ │ +

Detailed Description

│ │ │ │ +

Allocators that use malloc/free.

│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,10 +1,39 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -quadmath.hh File Reference │ │ │ │ │ +Classes | Namespaces | Functions │ │ │ │ │ +mallocallocator.hh File Reference │ │ │ │ │ +Allocators that use malloc/free. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ +Classes │ │ │ │ │ + class   Dune::MallocAllocator<_T_> │ │ │ │ │ +  Allocators implementation which simply calls malloc/free. More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::MallocAllocator<_T_>::rebind<_U_> │ │ │ │ │ +  │ │ │ │ │ +Namespaces │ │ │ │ │ +namespace   Dune │ │ │ │ │ +  Dune namespace. │ │ │ │ │ +  │ │ │ │ │ +Functions │ │ │ │ │ +template │ │ │ │ │ +constexpr bool  Dune::operator== (const MallocAllocator< T > &, const │ │ │ │ │ + MallocAllocator< T > &) │ │ │ │ │ +  check whether allocators are equivalent │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +constexpr bool  Dune::operator!= (const MallocAllocator< T > &, const │ │ │ │ │ + MallocAllocator< T > &) │ │ │ │ │ +  check whether allocators are not equivalent │ │ │ │ │ +  │ │ │ │ │ +***** Detailed Description ***** │ │ │ │ │ +Allocators that use malloc/free. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00101_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: quadmath.hh Source File │ │ │ │ +dune-common: mallocallocator.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,490 +74,162 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
quadmath.hh
│ │ │ │ +
mallocallocator.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_QUADMATH_HH
│ │ │ │ -
6#define DUNE_QUADMATH_HH
│ │ │ │ +
5#ifndef DUNE_MALLOC_ALLOCATOR_HH
│ │ │ │ +
6#define DUNE_MALLOC_ALLOCATOR_HH
│ │ │ │
7
│ │ │ │ -
8#if HAVE_QUADMATH
│ │ │ │ -
9#include <quadmath.h>
│ │ │ │ -
10
│ │ │ │ -
11#include <cmath>
│ │ │ │ -
12#include <cstddef>
│ │ │ │ -
13#include <cstdint>
│ │ │ │ -
14#include <cstdlib> // abs
│ │ │ │ -
15#include <istream>
│ │ │ │ -
16#include <ostream>
│ │ │ │ -
17#include <type_traits>
│ │ │ │ -
18#include <utility>
│ │ │ │ -
19
│ │ │ │ - │ │ │ │ - │ │ │ │ -
22
│ │ │ │ -
23namespace Dune
│ │ │ │ -
24{
│ │ │ │ -
25 namespace Impl
│ │ │ │ -
26 {
│ │ │ │ -
27 // forward declaration
│ │ │ │ -
28 class Float128;
│ │ │ │ -
29
│ │ │ │ -
30 } // end namespace Impl
│ │ │ │ -
31
│ │ │ │ -
32 using Impl::Float128;
│ │ │ │ -
33
│ │ │ │ -
34 // The purpose of this namespace is to move the `<cmath>` function overloads
│ │ │ │ -
35 // out of namespace `Dune`, see AlignedNumber in debugalign.hh.
│ │ │ │ -
36 namespace Impl
│ │ │ │ -
37 {
│ │ │ │ -
38 using float128_t = __float128;
│ │ │ │ -
39
│ │ │ │ -
41 class Float128
│ │ │ │ -
42 {
│ │ │ │ -
43 float128_t value_ = 0.0q;
│ │ │ │ +
8#include <exception>
│ │ │ │ +
9#include <cstdlib>
│ │ │ │ +
10#include <new>
│ │ │ │ +
11#include <utility>
│ │ │ │ +
12
│ │ │ │ +
17namespace Dune
│ │ │ │ +
18{
│ │ │ │ +
23 template <class T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
25 public:
│ │ │ │ +
26 typedef std::size_t size_type;
│ │ │ │ +
27 typedef std::ptrdiff_t difference_type;
│ │ │ │ +
28 typedef T* pointer;
│ │ │ │ +
29 typedef const T* const_pointer;
│ │ │ │ +
30 typedef T& reference;
│ │ │ │ +
31 typedef const T& const_reference;
│ │ │ │ +
32 typedef T value_type;
│ │ │ │ +
│ │ │ │ +
33 template <class U> struct rebind {
│ │ │ │ + │ │ │ │ +
35 };
│ │ │ │ +
│ │ │ │ +
36
│ │ │ │ +
38 MallocAllocator() noexcept {}
│ │ │ │ +
40 template <class U>
│ │ │ │ + │ │ │ │ +
43 ~MallocAllocator() noexcept {}
│ │ │ │
44
│ │ │ │ -
45 public:
│ │ │ │ -
46 constexpr Float128() = default;
│ │ │ │ -
47 constexpr Float128(const float128_t& value) noexcept
│ │ │ │ -
48 : value_(value)
│ │ │ │ -
49 {}
│ │ │ │ -
50
│ │ │ │ -
51 // constructor from any floating-point or integer type
│ │ │ │ -
52 template <class T,
│ │ │ │ -
53 std::enable_if_t<std::is_arithmetic<T>::value, int> = 0>
│ │ │ │ -
54 constexpr Float128(const T& value) noexcept
│ │ │ │ -
55 : value_(value)
│ │ │ │ -
56 {}
│ │ │ │ -
57
│ │ │ │ -
58 // constructor from pointer to null-terminated byte string
│ │ │ │ -
59 explicit Float128(const char* str) noexcept
│ │ │ │ -
60 : value_(strtoflt128(str, NULL))
│ │ │ │ -
61 {}
│ │ │ │ -
62
│ │ │ │ -
63 // accessors
│ │ │ │ -
64 constexpr operator float128_t() const noexcept { return value_; }
│ │ │ │ -
65
│ │ │ │ -
66 constexpr float128_t const& value() const noexcept { return value_; }
│ │ │ │ -
67 constexpr float128_t& value() noexcept { return value_; }
│ │ │ │ -
68
│ │ │ │ -
69 // I/O
│ │ │ │ -
70 template<class CharT, class Traits>
│ │ │ │ -
71 friend std::basic_istream<CharT, Traits>&
│ │ │ │ -
72 operator>>(std::basic_istream<CharT, Traits>& in, Float128& x)
│ │ │ │ -
73 {
│ │ │ │ -
74 std::string buf;
│ │ │ │ -
75 buf.reserve(128);
│ │ │ │ -
76 in >> buf;
│ │ │ │ -
77 x.value() = strtoflt128(buf.c_str(), NULL);
│ │ │ │ -
78 return in;
│ │ │ │ -
79 }
│ │ │ │ -
80
│ │ │ │ -
81 template<class CharT, class Traits>
│ │ │ │ -
82 friend std::basic_ostream<CharT, Traits>&
│ │ │ │ -
83 operator<<(std::basic_ostream<CharT, Traits>& out, const Float128& x)
│ │ │ │ -
84 {
│ │ │ │ -
85 const std::size_t bufSize = 128;
│ │ │ │ -
86 CharT buf[128];
│ │ │ │ -
87
│ │ │ │ -
88 std::string format = "%." + std::to_string(out.precision()) + "Q" +
│ │ │ │ -
89 ((out.flags() | std::ios_base::scientific) ? "e" : "f");
│ │ │ │ -
90 const int numChars = quadmath_snprintf(buf, bufSize, format.c_str(), x.value());
│ │ │ │ -
91 if (std::size_t(numChars) >= bufSize) {
│ │ │ │ -
92 DUNE_THROW(Dune::RangeError, "Failed to print Float128 value: buffer overflow");
│ │ │ │ -
93 }
│ │ │ │ -
94 out << buf;
│ │ │ │ -
95 return out;
│ │ │ │ -
96 }
│ │ │ │ -
97
│ │ │ │ -
98 // Increment, decrement
│ │ │ │ -
99 constexpr Float128& operator++() noexcept { ++value_; return *this; }
│ │ │ │ -
100 constexpr Float128& operator--() noexcept { --value_; return *this; }
│ │ │ │ -
101
│ │ │ │ -
102 constexpr Float128 operator++(int) noexcept { Float128 tmp{*this}; ++value_; return tmp; }
│ │ │ │ -
103 constexpr Float128 operator--(int) noexcept { Float128 tmp{*this}; --value_; return tmp; }
│ │ │ │ -
104
│ │ │ │ -
105 // unary operators
│ │ │ │ -
106 constexpr Float128 operator+() const noexcept { return Float128{+value_}; }
│ │ │ │ -
107 constexpr Float128 operator-() const noexcept { return Float128{-value_}; }
│ │ │ │ -
108
│ │ │ │ -
109 // assignment operators
│ │ │ │ -
110#define DUNE_ASSIGN_OP(OP) \
│ │ │ │ -
111 constexpr Float128& operator OP(const Float128& u) noexcept \
│ │ │ │ -
112 { \
│ │ │ │ -
113 value_ OP float128_t(u); \
│ │ │ │ -
114 return *this; \
│ │ │ │ -
115 } \
│ │ │ │ -
116 static_assert(true, "Require semicolon to unconfuse editors")
│ │ │ │ -
117
│ │ │ │ -
118 DUNE_ASSIGN_OP(+=);
│ │ │ │ -
119 DUNE_ASSIGN_OP(-=);
│ │ │ │ -
120
│ │ │ │ -
121 DUNE_ASSIGN_OP(*=);
│ │ │ │ -
122 DUNE_ASSIGN_OP(/=);
│ │ │ │ -
123
│ │ │ │ -
124#undef DUNE_ASSIGN_OP
│ │ │ │ -
125
│ │ │ │ -
126 }; // end class Float128
│ │ │ │ -
127
│ │ │ │ -
128 // binary operators:
│ │ │ │ -
129 // For symmetry provide overloads with arithmetic types
│ │ │ │ -
130 // in the first or second argument.
│ │ │ │ -
131#define DUNE_BINARY_OP(OP) \
│ │ │ │ -
132 constexpr Float128 operator OP(const Float128& t, \
│ │ │ │ -
133 const Float128& u) noexcept \
│ │ │ │ -
134 { \
│ │ │ │ -
135 return Float128{float128_t(t) OP float128_t(u)}; \
│ │ │ │ -
136 } \
│ │ │ │ -
137 constexpr Float128 operator OP(const float128_t& t, \
│ │ │ │ -
138 const Float128& u) noexcept \
│ │ │ │ -
139 { \
│ │ │ │ -
140 return Float128{t OP float128_t(u)}; \
│ │ │ │ -
141 } \
│ │ │ │ -
142 constexpr Float128 operator OP(const Float128& t, \
│ │ │ │ -
143 const float128_t& u) noexcept \
│ │ │ │ -
144 { \
│ │ │ │ -
145 return Float128{float128_t(t) OP u}; \
│ │ │ │ -
146 } \
│ │ │ │ -
147 template <class T, \
│ │ │ │ -
148 std::enable_if_t<std::is_arithmetic<T>::value, int> = 0> \
│ │ │ │ -
149 constexpr Float128 operator OP(const T& t, \
│ │ │ │ -
150 const Float128& u) noexcept \
│ │ │ │ -
151 { \
│ │ │ │ -
152 return Float128{float128_t(t) OP float128_t(u)}; \
│ │ │ │ -
153 } \
│ │ │ │ -
154 template <class U, \
│ │ │ │ -
155 std::enable_if_t<std::is_arithmetic<U>::value, int> = 0> \
│ │ │ │ -
156 constexpr Float128 operator OP(const Float128& t, \
│ │ │ │ -
157 const U& u) noexcept \
│ │ │ │ -
158 { \
│ │ │ │ -
159 return Float128{float128_t(t) OP float128_t(u)}; \
│ │ │ │ -
160 } \
│ │ │ │ -
161 static_assert(true, "Require semicolon to unconfuse editors")
│ │ │ │ -
162
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
167
│ │ │ │ -
168#undef DUNE_BINARY_OP
│ │ │ │ -
169
│ │ │ │ -
170 // logical operators:
│ │ │ │ -
171 // For symmetry provide overloads with arithmetic types
│ │ │ │ -
172 // in the first or second argument.
│ │ │ │ -
173#define DUNE_BINARY_BOOL_OP(OP) \
│ │ │ │ -
174 constexpr bool operator OP(const Float128& t, \
│ │ │ │ -
175 const Float128& u) noexcept \
│ │ │ │ -
176 { \
│ │ │ │ -
177 return float128_t(t) OP float128_t(u); \
│ │ │ │ -
178 } \
│ │ │ │ -
179 template <class T, \
│ │ │ │ -
180 std::enable_if_t<std::is_arithmetic<T>::value, int> = 0> \
│ │ │ │ -
181 constexpr bool operator OP(const T& t, \
│ │ │ │ -
182 const Float128& u) noexcept \
│ │ │ │ -
183 { \
│ │ │ │ -
184 return float128_t(t) OP float128_t(u); \
│ │ │ │ -
185 } \
│ │ │ │ -
186 template <class U, \
│ │ │ │ -
187 std::enable_if_t<std::is_arithmetic<U>::value, int> = 0> \
│ │ │ │ -
188 constexpr bool operator OP(const Float128& t, \
│ │ │ │ -
189 const U& u) noexcept \
│ │ │ │ -
190 { \
│ │ │ │ -
191 return float128_t(t) OP float128_t(u); \
│ │ │ │ -
192 } \
│ │ │ │ -
193 static_assert(true, "Require semicolon to unconfuse editors")
│ │ │ │ -
194
│ │ │ │ -
195 DUNE_BINARY_BOOL_OP(==);
│ │ │ │ -
196 DUNE_BINARY_BOOL_OP(!=);
│ │ │ │ -
197 DUNE_BINARY_BOOL_OP(<);
│ │ │ │ -
198 DUNE_BINARY_BOOL_OP(>);
│ │ │ │ -
199 DUNE_BINARY_BOOL_OP(<=);
│ │ │ │ -
200 DUNE_BINARY_BOOL_OP(>=);
│ │ │ │ -
201
│ │ │ │ -
202#undef DUNE_BINARY_BOOL_OP
│ │ │ │ -
203
│ │ │ │ -
204 // Overloads for the cmath functions
│ │ │ │ -
205
│ │ │ │ -
206 // function with name `name` redirects to quadmath function `func`
│ │ │ │ -
207#define DUNE_UNARY_FUNC(name,func) \
│ │ │ │ -
208 inline Float128 name(const Float128& u) noexcept \
│ │ │ │ -
209 { \
│ │ │ │ -
210 return Float128{func (float128_t(u))}; \
│ │ │ │ -
211 } \
│ │ │ │ -
212 static_assert(true, "Require semicolon to unconfuse editors")
│ │ │ │ -
213
│ │ │ │ -
214 // like DUNE_UNARY_FUNC but with custom return type
│ │ │ │ -
215#define DUNE_CUSTOM_UNARY_FUNC(type,name,func) \
│ │ │ │ -
216 inline type name(const Float128& u) noexcept \
│ │ │ │ -
217 { \
│ │ │ │ -
218 return (type)(func (float128_t(u))); \
│ │ │ │ -
219 } \
│ │ │ │ -
220 static_assert(true, "Require semicolon to unconfuse editors")
│ │ │ │ -
221
│ │ │ │ -
222 // redirects to quadmath function with two arguments
│ │ │ │ -
223#define DUNE_BINARY_FUNC(name,func) \
│ │ │ │ -
224 inline Float128 name(const Float128& t, \
│ │ │ │ -
225 const Float128& u) noexcept \
│ │ │ │ -
226 { \
│ │ │ │ -
227 return Float128{func (float128_t(t), float128_t(u))}; \
│ │ │ │ -
228 } \
│ │ │ │ -
229 static_assert(true, "Require semicolon to unconfuse editors")
│ │ │ │ -
230
│ │ │ │ -
231 DUNE_UNARY_FUNC(abs, fabsq);
│ │ │ │ -
232 DUNE_UNARY_FUNC(acos, acosq);
│ │ │ │ -
233 DUNE_UNARY_FUNC(acosh, acoshq);
│ │ │ │ -
234 DUNE_UNARY_FUNC(asin, asinq);
│ │ │ │ -
235 DUNE_UNARY_FUNC(asinh, asinhq);
│ │ │ │ -
236 DUNE_UNARY_FUNC(atan, atanq);
│ │ │ │ -
237 DUNE_UNARY_FUNC(atanh, atanhq);
│ │ │ │ -
238 DUNE_UNARY_FUNC(cbrt, cbrtq);
│ │ │ │ -
239 DUNE_UNARY_FUNC(ceil, ceilq);
│ │ │ │ -
240 DUNE_UNARY_FUNC(cos, cosq);
│ │ │ │ -
241 DUNE_UNARY_FUNC(cosh, coshq);
│ │ │ │ -
242 DUNE_UNARY_FUNC(erf, erfq);
│ │ │ │ -
243 DUNE_UNARY_FUNC(erfc, erfcq);
│ │ │ │ -
244 DUNE_UNARY_FUNC(exp, expq);
│ │ │ │ -
245 DUNE_UNARY_FUNC(expm1, expm1q);
│ │ │ │ -
246 DUNE_UNARY_FUNC(fabs, fabsq);
│ │ │ │ -
247 DUNE_UNARY_FUNC(floor, floorq);
│ │ │ │ -
248 DUNE_CUSTOM_UNARY_FUNC(int, ilogb, ilogbq);
│ │ │ │ -
249 DUNE_UNARY_FUNC(lgamma, lgammaq);
│ │ │ │ -
250 DUNE_CUSTOM_UNARY_FUNC(long long int, llrint, llrintq);
│ │ │ │ -
251 DUNE_CUSTOM_UNARY_FUNC(long long int, llround, llroundq);
│ │ │ │ -
252 DUNE_UNARY_FUNC(log, logq);
│ │ │ │ -
253 DUNE_UNARY_FUNC(log10, log10q);
│ │ │ │ -
254 DUNE_UNARY_FUNC(log1p, log1pq);
│ │ │ │ -
255 DUNE_UNARY_FUNC(log2, log2q);
│ │ │ │ -
256 // DUNE_UNARY_FUNC(logb, logbq); // not available in gcc5
│ │ │ │ -
257 DUNE_CUSTOM_UNARY_FUNC(long int, lrint, lrintq);
│ │ │ │ -
258 DUNE_CUSTOM_UNARY_FUNC(long int, lround, lroundq);
│ │ │ │ -
259 DUNE_UNARY_FUNC(nearbyint, nearbyintq);
│ │ │ │ -
260 DUNE_BINARY_FUNC(nextafter, nextafterq);
│ │ │ │ -
261 DUNE_BINARY_FUNC(pow, powq); // overload for integer argument see below
│ │ │ │ -
262 DUNE_UNARY_FUNC(rint, rintq);
│ │ │ │ -
263 DUNE_UNARY_FUNC(round, roundq);
│ │ │ │ -
264 DUNE_UNARY_FUNC(sin, sinq);
│ │ │ │ -
265 DUNE_UNARY_FUNC(sinh, sinhq);
│ │ │ │ -
266 DUNE_UNARY_FUNC(sqrt, sqrtq);
│ │ │ │ -
267 DUNE_UNARY_FUNC(tan, tanq);
│ │ │ │ -
268 DUNE_UNARY_FUNC(tanh, tanhq);
│ │ │ │ -
269 DUNE_UNARY_FUNC(tgamma, tgammaq);
│ │ │ │ -
270 DUNE_UNARY_FUNC(trunc, truncq);
│ │ │ │ -
271
│ │ │ │ -
272 DUNE_CUSTOM_UNARY_FUNC(bool, isfinite, finiteq);
│ │ │ │ -
273 DUNE_CUSTOM_UNARY_FUNC(bool, isinf, isinfq);
│ │ │ │ -
274 DUNE_CUSTOM_UNARY_FUNC(bool, isnan, isnanq);
│ │ │ │ -
275 DUNE_CUSTOM_UNARY_FUNC(bool, signbit, signbitq);
│ │ │ │ -
276
│ │ │ │ -
277#undef DUNE_UNARY_FUNC
│ │ │ │ -
278#undef DUNE_CUSTOM_UNARY_FUNC
│ │ │ │ -
279#undef DUNE_BINARY_FUNC
│ │ │ │ -
280
│ │ │ │ -
281 // like DUNE_BINARY_FUNC but provide overloads with arithmetic
│ │ │ │ -
282 // types in the first or second argument.
│ │ │ │ -
283#define DUNE_BINARY_ARITHMETIC_FUNC(name,func) \
│ │ │ │ -
284 inline Float128 name(const Float128& t, \
│ │ │ │ -
285 const Float128& u) noexcept \
│ │ │ │ -
286 { \
│ │ │ │ -
287 return Float128{func (float128_t(t), float128_t(u))}; \
│ │ │ │ -
288 } \
│ │ │ │ -
289 template <class T, \
│ │ │ │ -
290 std::enable_if_t<std::is_arithmetic<T>::value, int> = 0> \
│ │ │ │ -
291 inline Float128 name(const T& t, \
│ │ │ │ -
292 const Float128& u) noexcept \
│ │ │ │ -
293 { \
│ │ │ │ -
294 return Float128{func (float128_t(t), float128_t(u))}; \
│ │ │ │ -
295 } \
│ │ │ │ -
296 template <class U, \
│ │ │ │ -
297 std::enable_if_t<std::is_arithmetic<U>::value, int> = 0> \
│ │ │ │ -
298 inline Float128 name(const Float128& t, \
│ │ │ │ -
299 const U& u) noexcept \
│ │ │ │ -
300 { \
│ │ │ │ -
301 return Float128{func (float128_t(t), float128_t(u))}; \
│ │ │ │ -
302 } \
│ │ │ │ -
303 static_assert(true, "Require semicolon to unconfuse editors")
│ │ │ │ -
304
│ │ │ │ -
305 DUNE_BINARY_ARITHMETIC_FUNC(atan2,atan2q);
│ │ │ │ -
306 DUNE_BINARY_ARITHMETIC_FUNC(copysign,copysignq);
│ │ │ │ -
307 DUNE_BINARY_ARITHMETIC_FUNC(fdim,fdimq);
│ │ │ │ -
308 DUNE_BINARY_ARITHMETIC_FUNC(fmax,fmaxq);
│ │ │ │ -
309 DUNE_BINARY_ARITHMETIC_FUNC(fmin,fminq);
│ │ │ │ -
310 DUNE_BINARY_ARITHMETIC_FUNC(fmod,fmodq);
│ │ │ │ -
311 DUNE_BINARY_ARITHMETIC_FUNC(hypot,hypotq);
│ │ │ │ -
312 DUNE_BINARY_ARITHMETIC_FUNC(remainder,remainderq);
│ │ │ │ -
313
│ │ │ │ -
314#undef DUNE_BINARY_ARITHMETIC_FUNC
│ │ │ │ -
315
│ │ │ │ -
316 // some more cmath functions with special signature
│ │ │ │ -
317
│ │ │ │ -
318 inline Float128 fma(const Float128& t, const Float128& u, const Float128& v)
│ │ │ │ -
319 {
│ │ │ │ -
320 return Float128{fmaq(float128_t(t),float128_t(u),float128_t(v))};
│ │ │ │ -
321 }
│ │ │ │ -
322
│ │ │ │ -
323 inline Float128 frexp(const Float128& u, int* p)
│ │ │ │ -
324 {
│ │ │ │ -
325 return Float128{frexpq(float128_t(u), p)};
│ │ │ │ -
326 }
│ │ │ │ -
327
│ │ │ │ -
328 inline Float128 ldexp(const Float128& u, int p)
│ │ │ │ -
329 {
│ │ │ │ -
330 return Float128{ldexpq(float128_t(u), p)};
│ │ │ │ -
331 }
│ │ │ │ -
332
│ │ │ │ -
333 inline Float128 remquo(const Float128& t, const Float128& u, int* quo)
│ │ │ │ -
334 {
│ │ │ │ -
335 return Float128{remquoq(float128_t(t), float128_t(u), quo)};
│ │ │ │ -
336 }
│ │ │ │ -
337
│ │ │ │ -
338 inline Float128 scalbln(const Float128& u, long int e)
│ │ │ │ -
339 {
│ │ │ │ -
340 return Float128{scalblnq(float128_t(u), e)};
│ │ │ │ -
341 }
│ │ │ │ -
342
│ │ │ │ -
343 inline Float128 scalbn(const Float128& u, int e)
│ │ │ │ -
344 {
│ │ │ │ -
345 return Float128{scalbnq(float128_t(u), e)};
│ │ │ │ -
346 }
│ │ │ │ -
347
│ │ │ │ -
349 // NOTE: This is much faster than a pow(x, Float128(p)) call
│ │ │ │ -
350 // NOTE: This is a modified version of boost::math::cstdfloat::detail::pown
│ │ │ │ -
351 // (adapted to the type Float128) that is part of the Boost 1.65 Math toolkit 2.8.0
│ │ │ │ -
352 // and is implemented by Christopher Kormanyos, John Maddock, and Paul A. Bristow,
│ │ │ │ -
353 // distributed under the Boost Software License, Version 1.0
│ │ │ │ -
354 // (See http://www.boost.org/LICENSE_1_0.txt)
│ │ │ │ -
355 template <class Int,
│ │ │ │ -
356 std::enable_if_t<std::is_integral<Int>::value, int> = 0>
│ │ │ │ -
357 inline Float128 pow(const Float128& x, const Int p)
│ │ │ │ -
358 {
│ │ │ │ -
359 static const Float128 max_value = FLT128_MAX;
│ │ │ │ -
360 static const Float128 min_value = FLT128_MIN;
│ │ │ │ -
361 static const Float128 inf_value = float128_t{1} / float128_t{0};
│ │ │ │ -
362
│ │ │ │ -
363 const bool isneg = (x < 0);
│ │ │ │ -
364 const bool isnan = (x != x);
│ │ │ │ -
365 const bool isinf = (isneg ? bool(-x > max_value) : bool(+x > max_value));
│ │ │ │ -
366
│ │ │ │ -
367 if (isnan) { return x; }
│ │ │ │ -
368 if (isinf) { return Float128{nanq("")}; }
│ │ │ │ -
369
│ │ │ │ -
370 const Float128 abs_x = (isneg ? -x : x);
│ │ │ │ -
371 if (p < Int(0)) {
│ │ │ │ -
372 if (abs_x < min_value)
│ │ │ │ -
373 return (isneg ? -inf_value : +inf_value);
│ │ │ │ -
374 else
│ │ │ │ -
375 return Float128(1) / pow(x, Int(-p));
│ │ │ │ -
376 }
│ │ │ │ -
377
│ │ │ │ -
378 if (p == Int(0)) { return Float128(1); }
│ │ │ │ -
379 if (p == Int(1)) { return x; }
│ │ │ │ -
380 if (abs_x > max_value)
│ │ │ │ -
381 return (isneg ? -inf_value : +inf_value);
│ │ │ │ -
382
│ │ │ │ -
383 if (p == Int(2)) { return (x * x); }
│ │ │ │ -
384 if (p == Int(3)) { return ((x * x) * x); }
│ │ │ │ -
385 if (p == Int(4)) { const Float128 x2 = (x * x); return (x2 * x2); }
│ │ │ │ -
386
│ │ │ │ -
387 Float128 result = ((p % Int(2)) != Int(0)) ? x : Float128(1);
│ │ │ │ -
388 Float128 xn = x; // binary powers of x
│ │ │ │ -
389
│ │ │ │ -
390 Int p2 = p;
│ │ │ │ -
391 while (Int(p2 /= 2) != Int(0)) {
│ │ │ │ -
392 xn *= xn; // Square xn for each binary power
│ │ │ │ -
393
│ │ │ │ -
394 const bool has_binary_power = (Int(p2 % Int(2)) != Int(0));
│ │ │ │ -
395 if (has_binary_power)
│ │ │ │ -
396 result *= xn;
│ │ │ │ -
397 }
│ │ │ │ -
398
│ │ │ │ -
399 return result;
│ │ │ │ -
400 }
│ │ │ │ -
401
│ │ │ │ -
402
│ │ │ │ -
403 } // end namespace Impl
│ │ │ │ -
404
│ │ │ │ -
405 template <>
│ │ │ │ -
406 struct IsNumber<Impl::Float128>
│ │ │ │ -
407 : public std::true_type {};
│ │ │ │ -
408
│ │ │ │ -
409} // end namespace Dune
│ │ │ │ -
410
│ │ │ │ -
411namespace std
│ │ │ │ -
412{
│ │ │ │ -
413#ifndef NO_STD_NUMERIC_LIMITS_SPECIALIZATION
│ │ │ │ -
414 template <>
│ │ │ │ -
415 class numeric_limits<Dune::Impl::Float128>
│ │ │ │ -
416 {
│ │ │ │ -
417 using Float128 = Dune::Impl::Float128;
│ │ │ │ -
418 using float128_t = Dune::Impl::float128_t;
│ │ │ │ -
419
│ │ │ │ -
420 public:
│ │ │ │ -
421 static constexpr bool is_specialized = true;
│ │ │ │ -
422 static constexpr Float128 min() noexcept { return FLT128_MIN; }
│ │ │ │ -
423 static constexpr Float128 max() noexcept { return FLT128_MAX; }
│ │ │ │ -
424 static constexpr Float128 lowest() noexcept { return -FLT128_MAX; }
│ │ │ │ -
425 static constexpr int digits = FLT128_MANT_DIG;
│ │ │ │ -
426 static constexpr int digits10 = 34;
│ │ │ │ -
427 static constexpr int max_digits10 = 36;
│ │ │ │ -
428 static constexpr bool is_signed = true;
│ │ │ │ -
429 static constexpr bool is_integer = false;
│ │ │ │ -
430 static constexpr bool is_exact = false;
│ │ │ │ -
431 static constexpr int radix = 2;
│ │ │ │ -
432 static constexpr Float128 epsilon() noexcept { return FLT128_EPSILON; }
│ │ │ │ -
433 static constexpr Float128 round_error() noexcept { return float128_t{0.5}; }
│ │ │ │ -
434 static constexpr int min_exponent = FLT128_MIN_EXP;
│ │ │ │ -
435 static constexpr int min_exponent10 = FLT128_MIN_10_EXP;
│ │ │ │ -
436 static constexpr int max_exponent = FLT128_MAX_EXP;
│ │ │ │ -
437 static constexpr int max_exponent10 = FLT128_MAX_10_EXP;
│ │ │ │ -
438 static constexpr bool has_infinity = true;
│ │ │ │ -
439 static constexpr bool has_quiet_NaN = true;
│ │ │ │ -
440 static constexpr bool has_signaling_NaN = false;
│ │ │ │ -
441 static constexpr float_denorm_style has_denorm = denorm_present;
│ │ │ │ -
442 static constexpr bool has_denorm_loss = false;
│ │ │ │ -
443 static constexpr Float128 infinity() noexcept { return float128_t{1}/float128_t{0}; }
│ │ │ │ -
444 static Float128 quiet_NaN() noexcept { return nanq(""); }
│ │ │ │ -
445 static constexpr Float128 signaling_NaN() noexcept { return float128_t{}; }
│ │ │ │ -
446 static constexpr Float128 denorm_min() noexcept { return FLT128_DENORM_MIN; }
│ │ │ │ -
447 static constexpr bool is_iec559 = true;
│ │ │ │ -
448 static constexpr bool is_bounded = false;
│ │ │ │ -
449 static constexpr bool is_modulo = false;
│ │ │ │ -
450 static constexpr bool traps = false;
│ │ │ │ -
451 static constexpr bool tinyness_before = false;
│ │ │ │ -
452 static constexpr float_round_style round_style = round_to_nearest;
│ │ │ │ -
453 };
│ │ │ │ -
454#endif
│ │ │ │ -
455} // end namespace std
│ │ │ │ -
456
│ │ │ │ -
457#endif // HAVE_QUADMATH
│ │ │ │ -
458#endif // DUNE_QUADMATH_HH
│ │ │ │ -
#define DUNE_BINARY_OP(OP)
Definition debugalign.hh:261
│ │ │ │ -
#define DUNE_UNARY_FUNC(name)
│ │ │ │ -
#define DUNE_ASSIGN_OP(OP)
Definition debugalign.hh:220
│ │ │ │ -
A few common exception classes.
│ │ │ │ -
Traits for type conversions and type information.
│ │ │ │ -
Stream & operator>>(Stream &stream, std::tuple< Ts... > &t)
Read a std::tuple.
Definition streamoperators.hh:43
│ │ │ │ -
constexpr auto max
Function object that returns the greater of the given values.
Definition hybridutilities.hh:484
│ │ │ │ -
constexpr auto min
Function object that returns the smaller of the given values.
Definition hybridutilities.hh:506
│ │ │ │ -
std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x)
Definition bigunsignedint.hh:278
│ │ │ │ -
bigunsignedint< k > operator-(const bigunsignedint< k > &x, std::uintmax_t y)
Definition bigunsignedint.hh:542
│ │ │ │ -
bigunsignedint< k > operator+(const bigunsignedint< k > &x, std::uintmax_t y)
Definition bigunsignedint.hh:535
│ │ │ │ -
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
│ │ │ │ -
STL namespace.
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
46 {
│ │ │ │ +
47 return &x;
│ │ │ │ +
48 }
│ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
50 {
│ │ │ │ +
51 return &x;
│ │ │ │ +
52 }
│ │ │ │ +
│ │ │ │ +
53
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
56 [[maybe_unused]] const void* hint = 0)
│ │ │ │ +
57 {
│ │ │ │ +
58 if (n > this->max_size())
│ │ │ │ +
59 throw std::bad_alloc();
│ │ │ │ +
60
│ │ │ │ +
61 pointer ret = static_cast<pointer>(std::malloc(n * sizeof(T)));
│ │ │ │ +
62 if (!ret)
│ │ │ │ +
63 throw std::bad_alloc();
│ │ │ │ +
64 return ret;
│ │ │ │ +
65 }
│ │ │ │ +
│ │ │ │ +
66
│ │ │ │ +
│ │ │ │ +
68 void deallocate(pointer p, [[maybe_unused]] size_type n)
│ │ │ │ +
69 {
│ │ │ │ +
70 std::free(p);
│ │ │ │ +
71 }
│ │ │ │ +
│ │ │ │ +
72
│ │ │ │ +
│ │ │ │ +
74 size_type max_size() const noexcept
│ │ │ │ +
75 {
│ │ │ │ +
76 return size_type(-1) / sizeof(T);
│ │ │ │ +
77 }
│ │ │ │ +
│ │ │ │ +
78
│ │ │ │ +
│ │ │ │ +
80 void construct(pointer p, const T& val)
│ │ │ │ +
81 {
│ │ │ │ +
82 ::new((void*)p)T(val);
│ │ │ │ +
83 }
│ │ │ │ +
│ │ │ │ +
84
│ │ │ │ +
86 template<typename ... Args>
│ │ │ │ +
│ │ │ │ +
87 void construct(pointer p, Args&&... args)
│ │ │ │ +
88 {
│ │ │ │ +
89 ::new((void *)p)T(std::forward<Args>(args) ...);
│ │ │ │ +
90 }
│ │ │ │ +
│ │ │ │ +
91
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
94 {
│ │ │ │ +
95 p->~T();
│ │ │ │ +
96 }
│ │ │ │ +
│ │ │ │ +
97 };
│ │ │ │ +
│ │ │ │ +
98
│ │ │ │ +
100 template<class T>
│ │ │ │ +
101 constexpr bool
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
103 {
│ │ │ │ +
104 return true;
│ │ │ │ +
105 }
│ │ │ │ +
│ │ │ │ +
106
│ │ │ │ +
108 template<class T>
│ │ │ │ +
109 constexpr bool
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
111 {
│ │ │ │ +
112 return false;
│ │ │ │ +
113 }
│ │ │ │ +
│ │ │ │ +
114}
│ │ │ │ +
115
│ │ │ │ +
116#endif // DUNE_MALLOC_ALLOCATOR_HH
│ │ │ │ +
EnableIfInterOperable< T1, T2, bool >::type operator==(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for equality.
Definition iteratorfacades.hh:238
│ │ │ │ +
EnableIfInterOperable< T1, T2, bool >::type operator!=(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for inequality.
Definition iteratorfacades.hh:260
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
T max_value(const AlignedNumber< T, align > &val)
Definition debugalign.hh:494
│ │ │ │ -
T min_value(const AlignedNumber< T, align > &val)
Definition debugalign.hh:500
│ │ │ │ -
Default exception class for range errors.
Definition exceptions.hh:254
│ │ │ │ +
Allocators implementation which simply calls malloc/free.
Definition mallocallocator.hh:24
│ │ │ │ +
~MallocAllocator() noexcept
cleanup this allocator
Definition mallocallocator.hh:43
│ │ │ │ +
T * pointer
Definition mallocallocator.hh:28
│ │ │ │ +
void construct(pointer p, const T &val)
copy-construct an object of type T (i.e. make a placement new on p)
Definition mallocallocator.hh:80
│ │ │ │ +
MallocAllocator() noexcept
create a new MallocAllocator
Definition mallocallocator.hh:38
│ │ │ │ +
MallocAllocator(const MallocAllocator< U > &) noexcept
copy construct from an other MallocAllocator, possibly for a different result type
Definition mallocallocator.hh:41
│ │ │ │ +
std::size_t size_type
Definition mallocallocator.hh:26
│ │ │ │ +
std::ptrdiff_t difference_type
Definition mallocallocator.hh:27
│ │ │ │ +
void deallocate(pointer p, size_type n)
deallocate n objects of type T at address p
Definition mallocallocator.hh:68
│ │ │ │ +
T value_type
Definition mallocallocator.hh:32
│ │ │ │ +
const_pointer address(const_reference x) const
Definition mallocallocator.hh:49
│ │ │ │ +
const T & const_reference
Definition mallocallocator.hh:31
│ │ │ │ +
void destroy(pointer p)
destroy an object of type T (i.e. call the destructor)
Definition mallocallocator.hh:93
│ │ │ │ +
pointer allocate(size_type n, const void *hint=0)
allocate n objects of type T
Definition mallocallocator.hh:55
│ │ │ │ +
pointer address(reference x) const
Definition mallocallocator.hh:45
│ │ │ │ +
void construct(pointer p, Args &&... args)
construct an object of type T from variadic parameters
Definition mallocallocator.hh:87
│ │ │ │ +
T & reference
Definition mallocallocator.hh:30
│ │ │ │ +
size_type max_size() const noexcept
max size for allocate
Definition mallocallocator.hh:74
│ │ │ │ +
const T * const_pointer
Definition mallocallocator.hh:29
│ │ │ │ +
Definition mallocallocator.hh:33
│ │ │ │ +
MallocAllocator< U > other
Definition mallocallocator.hh:34
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,527 +1,195 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -quadmath.hh │ │ │ │ │ +mallocallocator.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_QUADMATH_HH │ │ │ │ │ -6#define DUNE_QUADMATH_HH │ │ │ │ │ +5#ifndef DUNE_MALLOC_ALLOCATOR_HH │ │ │ │ │ +6#define DUNE_MALLOC_ALLOCATOR_HH │ │ │ │ │ 7 │ │ │ │ │ -8#if HAVE_QUADMATH │ │ │ │ │ -9#include │ │ │ │ │ -10 │ │ │ │ │ -11#include │ │ │ │ │ -12#include │ │ │ │ │ -13#include │ │ │ │ │ -14#include // abs │ │ │ │ │ -15#include │ │ │ │ │ -16#include │ │ │ │ │ -17#include │ │ │ │ │ -18#include │ │ │ │ │ -19 │ │ │ │ │ -20#include │ │ │ │ │ -21#include │ │ │ │ │ -22 │ │ │ │ │ -23namespace Dune │ │ │ │ │ -24{ │ │ │ │ │ -25 namespace Impl │ │ │ │ │ -26 { │ │ │ │ │ -27 // forward declaration │ │ │ │ │ -28 class Float128; │ │ │ │ │ -29 │ │ │ │ │ -30 } // end namespace Impl │ │ │ │ │ -31 │ │ │ │ │ -32 using Impl::Float128; │ │ │ │ │ -33 │ │ │ │ │ -34 // The purpose of this namespace is to move the `` function overloads │ │ │ │ │ -35 // out of namespace `Dune`, see AlignedNumber in debugalign.hh. │ │ │ │ │ -36 namespace Impl │ │ │ │ │ -37 { │ │ │ │ │ -38 using float128_t = __float128; │ │ │ │ │ -39 │ │ │ │ │ -41 class Float128 │ │ │ │ │ -42 { │ │ │ │ │ -43 float128_t value_ = 0.0q; │ │ │ │ │ +8#include │ │ │ │ │ +9#include │ │ │ │ │ +10#include │ │ │ │ │ +11#include │ │ │ │ │ +12 │ │ │ │ │ +17namespace Dune │ │ │ │ │ +18{ │ │ │ │ │ +23 template │ │ │ │ │ +24 class MallocAllocator { │ │ │ │ │ +25 public: │ │ │ │ │ +26 typedef std::size_t size_type; │ │ │ │ │ +27 typedef std::ptrdiff_t difference_type; │ │ │ │ │ +28 typedef T* pointer; │ │ │ │ │ +29 typedef const T* const_pointer; │ │ │ │ │ +30 typedef T& reference; │ │ │ │ │ +31 typedef const T& const_reference; │ │ │ │ │ +32 typedef T value_type; │ │ │ │ │ +33 template struct rebind { │ │ │ │ │ +34 typedef MallocAllocator other; │ │ │ │ │ +35 }; │ │ │ │ │ +36 │ │ │ │ │ +38 MallocAllocator() noexcept {} │ │ │ │ │ +40 template │ │ │ │ │ +41 MallocAllocator(const MallocAllocator&) noexcept {} │ │ │ │ │ +43 ~MallocAllocator() noexcept {} │ │ │ │ │ 44 │ │ │ │ │ -45 public: │ │ │ │ │ -46 constexpr Float128() = default; │ │ │ │ │ -47 constexpr Float128(const float128_t& value) noexcept │ │ │ │ │ -48 : value_(value) │ │ │ │ │ -49 {} │ │ │ │ │ -50 │ │ │ │ │ -51 // constructor from any floating-point or integer type │ │ │ │ │ -52 template ::value, int> = 0> │ │ │ │ │ -54 constexpr Float128(const T& value) noexcept │ │ │ │ │ -55 : value_(value) │ │ │ │ │ -56 {} │ │ │ │ │ -57 │ │ │ │ │ -58 // constructor from pointer to null-terminated byte string │ │ │ │ │ -59 explicit Float128(const char* str) noexcept │ │ │ │ │ -60 : value_(strtoflt128(str, NULL)) │ │ │ │ │ -61 {} │ │ │ │ │ -62 │ │ │ │ │ -63 // accessors │ │ │ │ │ -64 constexpr operator float128_t() const noexcept { return value_; } │ │ │ │ │ -65 │ │ │ │ │ -66 constexpr float128_t const& value() const noexcept { return value_; } │ │ │ │ │ -67 constexpr float128_t& value() noexcept { return value_; } │ │ │ │ │ -68 │ │ │ │ │ -69 // I/O │ │ │ │ │ -70 template │ │ │ │ │ -71 friend std::basic_istream& │ │ │ │ │ -72 operator>>(std::basic_istream& in, Float128& x) │ │ │ │ │ -73 { │ │ │ │ │ -74 std::string buf; │ │ │ │ │ -75 buf.reserve(128); │ │ │ │ │ -76 in >> buf; │ │ │ │ │ -77 x.value() = strtoflt128(buf.c_str(), NULL); │ │ │ │ │ -78 return in; │ │ │ │ │ -79 } │ │ │ │ │ -80 │ │ │ │ │ -81 template │ │ │ │ │ -82 friend std::basic_ostream& │ │ │ │ │ -83 operator<<(std::basic_ostream& out, const Float128& x) │ │ │ │ │ -84 { │ │ │ │ │ -85 const std::size_t bufSize = 128; │ │ │ │ │ -86 CharT buf[128]; │ │ │ │ │ -87 │ │ │ │ │ -88 std::string format = "%." + std::to_string(out.precision()) + "Q" + │ │ │ │ │ -89 ((out.flags() | std::ios_base::scientific) ? "e" : "f"); │ │ │ │ │ -90 const int numChars = quadmath_snprintf(buf, bufSize, format.c_str(), x.value │ │ │ │ │ -()); │ │ │ │ │ -91 if (std::size_t(numChars) >= bufSize) { │ │ │ │ │ -92 DUNE_THROW(Dune::RangeError, "Failed to print Float128 value: buffer │ │ │ │ │ -overflow"); │ │ │ │ │ -93 } │ │ │ │ │ -94 out << buf; │ │ │ │ │ -95 return out; │ │ │ │ │ +45 pointer address(reference x) const │ │ │ │ │ +46 { │ │ │ │ │ +47 return &x; │ │ │ │ │ +48 } │ │ │ │ │ +49 const_pointer address(const_reference x) const │ │ │ │ │ +50 { │ │ │ │ │ +51 return &x; │ │ │ │ │ +52 } │ │ │ │ │ +53 │ │ │ │ │ +55 pointer allocate(size_type n, │ │ │ │ │ +56 [[maybe_unused]] const void* hint = 0) │ │ │ │ │ +57 { │ │ │ │ │ +58 if (n > this->max_size()) │ │ │ │ │ +59 throw std::bad_alloc(); │ │ │ │ │ +60 │ │ │ │ │ +61 pointer ret = static_cast(std::malloc(n * sizeof(T))); │ │ │ │ │ +62 if (!ret) │ │ │ │ │ +63 throw std::bad_alloc(); │ │ │ │ │ +64 return ret; │ │ │ │ │ +65 } │ │ │ │ │ +66 │ │ │ │ │ +68 void deallocate(pointer p, [[maybe_unused]] size_type n) │ │ │ │ │ +69 { │ │ │ │ │ +70 std::free(p); │ │ │ │ │ +71 } │ │ │ │ │ +72 │ │ │ │ │ +74 size_type max_size() const noexcept │ │ │ │ │ +75 { │ │ │ │ │ +76 return size_type(-1) / sizeof(T); │ │ │ │ │ +77 } │ │ │ │ │ +78 │ │ │ │ │ +80 void construct(pointer p, const T& val) │ │ │ │ │ +81 { │ │ │ │ │ +82 ::new((void*)p)T(val); │ │ │ │ │ +83 } │ │ │ │ │ +84 │ │ │ │ │ +86 template │ │ │ │ │ +87 void construct(pointer p, Args&&... args) │ │ │ │ │ +88 { │ │ │ │ │ +89 ::new((void *)p)T(std::forward(args) ...); │ │ │ │ │ +90 } │ │ │ │ │ +91 │ │ │ │ │ +93 void destroy(pointer p) │ │ │ │ │ +94 { │ │ │ │ │ +95 p->~T(); │ │ │ │ │ 96 } │ │ │ │ │ -97 │ │ │ │ │ -98 // Increment, decrement │ │ │ │ │ -99 constexpr Float128& operator++() noexcept { ++value_; return *this; } │ │ │ │ │ -100 constexpr Float128& operator--() noexcept { --value_; return *this; } │ │ │ │ │ -101 │ │ │ │ │ -102 constexpr Float128 operator++(int) noexcept { Float128 tmp{*this}; │ │ │ │ │ -++value_; return tmp; } │ │ │ │ │ -103 constexpr Float128 operator--(int) noexcept { Float128 tmp{*this}; -- │ │ │ │ │ -value_; return tmp; } │ │ │ │ │ -104 │ │ │ │ │ -105 // unary operators │ │ │ │ │ -106 constexpr Float128 operator+() const noexcept { return Float128{+value_}; } │ │ │ │ │ -107 constexpr Float128 operator-() const noexcept { return Float128{-value_}; } │ │ │ │ │ -108 │ │ │ │ │ -109 // assignment operators │ │ │ │ │ -110#define DUNE_ASSIGN_OP(OP) \ │ │ │ │ │ -111 constexpr Float128& operator OP(const Float128& u) noexcept \ │ │ │ │ │ -112 { \ │ │ │ │ │ -113 value_ OP float128_t(u); \ │ │ │ │ │ -114 return *this; \ │ │ │ │ │ -115 } \ │ │ │ │ │ -116 static_assert(true, "Require semicolon to unconfuse editors") │ │ │ │ │ -117 │ │ │ │ │ -118 DUNE_ASSIGN_OP(+=); │ │ │ │ │ -119 DUNE_ASSIGN_OP(-=); │ │ │ │ │ -120 │ │ │ │ │ -121 DUNE_ASSIGN_OP(*=); │ │ │ │ │ -122 DUNE_ASSIGN_OP(/=); │ │ │ │ │ -123 │ │ │ │ │ -124#undef DUNE_ASSIGN_OP │ │ │ │ │ -125 │ │ │ │ │ -126 }; // end class Float128 │ │ │ │ │ -127 │ │ │ │ │ -128 // binary operators: │ │ │ │ │ -129 // For symmetry provide overloads with arithmetic types │ │ │ │ │ -130 // in the first or second argument. │ │ │ │ │ -131#define DUNE_BINARY_OP(OP) \ │ │ │ │ │ -132 constexpr Float128 operator OP(const Float128& t, \ │ │ │ │ │ -133 const Float128& u) noexcept \ │ │ │ │ │ -134 { \ │ │ │ │ │ -135 return Float128{float128_t(t) OP float128_t(u)}; \ │ │ │ │ │ -136 } \ │ │ │ │ │ -137 constexpr Float128 operator OP(const float128_t& t, \ │ │ │ │ │ -138 const Float128& u) noexcept \ │ │ │ │ │ -139 { \ │ │ │ │ │ -140 return Float128{t OP float128_t(u)}; \ │ │ │ │ │ -141 } \ │ │ │ │ │ -142 constexpr Float128 operator OP(const Float128& t, \ │ │ │ │ │ -143 const float128_t& u) noexcept \ │ │ │ │ │ -144 { \ │ │ │ │ │ -145 return Float128{float128_t(t) OP u}; \ │ │ │ │ │ -146 } \ │ │ │ │ │ -147 template ::value, int> = 0> \ │ │ │ │ │ -149 constexpr Float128 operator OP(const T& t, \ │ │ │ │ │ -150 const Float128& u) noexcept \ │ │ │ │ │ -151 { \ │ │ │ │ │ -152 return Float128{float128_t(t) OP float128_t(u)}; \ │ │ │ │ │ -153 } \ │ │ │ │ │ -154 template ::value, int> = 0> \ │ │ │ │ │ -156 constexpr Float128 operator OP(const Float128& t, \ │ │ │ │ │ -157 const U& u) noexcept \ │ │ │ │ │ -158 { \ │ │ │ │ │ -159 return Float128{float128_t(t) OP float128_t(u)}; \ │ │ │ │ │ -160 } \ │ │ │ │ │ -161 static_assert(true, "Require semicolon to unconfuse editors") │ │ │ │ │ -162 │ │ │ │ │ -163 DUNE_BINARY_OP(+); │ │ │ │ │ -164 DUNE_BINARY_OP(-); │ │ │ │ │ -165 DUNE_BINARY_OP(*); │ │ │ │ │ -166 DUNE_BINARY_OP(/); │ │ │ │ │ -167 │ │ │ │ │ -168#undef DUNE_BINARY_OP │ │ │ │ │ -169 │ │ │ │ │ -170 // logical operators: │ │ │ │ │ -171 // For symmetry provide overloads with arithmetic types │ │ │ │ │ -172 // in the first or second argument. │ │ │ │ │ -173#define DUNE_BINARY_BOOL_OP(OP) \ │ │ │ │ │ -174 constexpr bool operator OP(const Float128& t, \ │ │ │ │ │ -175 const Float128& u) noexcept \ │ │ │ │ │ -176 { \ │ │ │ │ │ -177 return float128_t(t) OP float128_t(u); \ │ │ │ │ │ -178 } \ │ │ │ │ │ -179 template ::value, int> = 0> \ │ │ │ │ │ -181 constexpr bool operator OP(const T& t, \ │ │ │ │ │ -182 const Float128& u) noexcept \ │ │ │ │ │ -183 { \ │ │ │ │ │ -184 return float128_t(t) OP float128_t(u); \ │ │ │ │ │ -185 } \ │ │ │ │ │ -186 template ::value, int> = 0> \ │ │ │ │ │ -188 constexpr bool operator OP(const Float128& t, \ │ │ │ │ │ -189 const U& u) noexcept \ │ │ │ │ │ -190 { \ │ │ │ │ │ -191 return float128_t(t) OP float128_t(u); \ │ │ │ │ │ -192 } \ │ │ │ │ │ -193 static_assert(true, "Require semicolon to unconfuse editors") │ │ │ │ │ -194 │ │ │ │ │ -195 DUNE_BINARY_BOOL_OP(==); │ │ │ │ │ -196 DUNE_BINARY_BOOL_OP(!=); │ │ │ │ │ -197 DUNE_BINARY_BOOL_OP(<); │ │ │ │ │ -198 DUNE_BINARY_BOOL_OP(>); │ │ │ │ │ -199 DUNE_BINARY_BOOL_OP(<=); │ │ │ │ │ -200 DUNE_BINARY_BOOL_OP(>=); │ │ │ │ │ -201 │ │ │ │ │ -202#undef DUNE_BINARY_BOOL_OP │ │ │ │ │ -203 │ │ │ │ │ -204 // Overloads for the cmath functions │ │ │ │ │ -205 │ │ │ │ │ -206 // function with name `name` redirects to quadmath function `func` │ │ │ │ │ -207#define DUNE_UNARY_FUNC(name,func) \ │ │ │ │ │ -208 inline Float128 name(const Float128& u) noexcept \ │ │ │ │ │ -209 { \ │ │ │ │ │ -210 return Float128{func (float128_t(u))}; \ │ │ │ │ │ -211 } \ │ │ │ │ │ -212 static_assert(true, "Require semicolon to unconfuse editors") │ │ │ │ │ -213 │ │ │ │ │ -214 // like DUNE_UNARY_FUNC but with custom return type │ │ │ │ │ -215#define DUNE_CUSTOM_UNARY_FUNC(type,name,func) \ │ │ │ │ │ -216 inline type name(const Float128& u) noexcept \ │ │ │ │ │ -217 { \ │ │ │ │ │ -218 return (type)(func (float128_t(u))); \ │ │ │ │ │ -219 } \ │ │ │ │ │ -220 static_assert(true, "Require semicolon to unconfuse editors") │ │ │ │ │ -221 │ │ │ │ │ -222 // redirects to quadmath function with two arguments │ │ │ │ │ -223#define DUNE_BINARY_FUNC(name,func) \ │ │ │ │ │ -224 inline Float128 name(const Float128& t, \ │ │ │ │ │ -225 const Float128& u) noexcept \ │ │ │ │ │ -226 { \ │ │ │ │ │ -227 return Float128{func (float128_t(t), float128_t(u))}; \ │ │ │ │ │ -228 } \ │ │ │ │ │ -229 static_assert(true, "Require semicolon to unconfuse editors") │ │ │ │ │ -230 │ │ │ │ │ -231 DUNE_UNARY_FUNC(abs, fabsq); │ │ │ │ │ -232 DUNE_UNARY_FUNC(acos, acosq); │ │ │ │ │ -233 DUNE_UNARY_FUNC(acosh, acoshq); │ │ │ │ │ -234 DUNE_UNARY_FUNC(asin, asinq); │ │ │ │ │ -235 DUNE_UNARY_FUNC(asinh, asinhq); │ │ │ │ │ -236 DUNE_UNARY_FUNC(atan, atanq); │ │ │ │ │ -237 DUNE_UNARY_FUNC(atanh, atanhq); │ │ │ │ │ -238 DUNE_UNARY_FUNC(cbrt, cbrtq); │ │ │ │ │ -239 DUNE_UNARY_FUNC(ceil, ceilq); │ │ │ │ │ -240 DUNE_UNARY_FUNC(cos, cosq); │ │ │ │ │ -241 DUNE_UNARY_FUNC(cosh, coshq); │ │ │ │ │ -242 DUNE_UNARY_FUNC(erf, erfq); │ │ │ │ │ -243 DUNE_UNARY_FUNC(erfc, erfcq); │ │ │ │ │ -244 DUNE_UNARY_FUNC(exp, expq); │ │ │ │ │ -245 DUNE_UNARY_FUNC(expm1, expm1q); │ │ │ │ │ -246 DUNE_UNARY_FUNC(fabs, fabsq); │ │ │ │ │ -247 DUNE_UNARY_FUNC(floor, floorq); │ │ │ │ │ -248 DUNE_CUSTOM_UNARY_FUNC(int, ilogb, ilogbq); │ │ │ │ │ -249 DUNE_UNARY_FUNC(lgamma, lgammaq); │ │ │ │ │ -250 DUNE_CUSTOM_UNARY_FUNC(long long int, llrint, llrintq); │ │ │ │ │ -251 DUNE_CUSTOM_UNARY_FUNC(long long int, llround, llroundq); │ │ │ │ │ -252 DUNE_UNARY_FUNC(log, logq); │ │ │ │ │ -253 DUNE_UNARY_FUNC(log10, log10q); │ │ │ │ │ -254 DUNE_UNARY_FUNC(log1p, log1pq); │ │ │ │ │ -255 DUNE_UNARY_FUNC(log2, log2q); │ │ │ │ │ -256 // DUNE_UNARY_FUNC(logb, logbq); // not available in gcc5 │ │ │ │ │ -257 DUNE_CUSTOM_UNARY_FUNC(long int, lrint, lrintq); │ │ │ │ │ -258 DUNE_CUSTOM_UNARY_FUNC(long int, lround, lroundq); │ │ │ │ │ -259 DUNE_UNARY_FUNC(nearbyint, nearbyintq); │ │ │ │ │ -260 DUNE_BINARY_FUNC(nextafter, nextafterq); │ │ │ │ │ -261 DUNE_BINARY_FUNC(pow, powq); // overload for integer argument see below │ │ │ │ │ -262 DUNE_UNARY_FUNC(rint, rintq); │ │ │ │ │ -263 DUNE_UNARY_FUNC(round, roundq); │ │ │ │ │ -264 DUNE_UNARY_FUNC(sin, sinq); │ │ │ │ │ -265 DUNE_UNARY_FUNC(sinh, sinhq); │ │ │ │ │ -266 DUNE_UNARY_FUNC(sqrt, sqrtq); │ │ │ │ │ -267 DUNE_UNARY_FUNC(tan, tanq); │ │ │ │ │ -268 DUNE_UNARY_FUNC(tanh, tanhq); │ │ │ │ │ -269 DUNE_UNARY_FUNC(tgamma, tgammaq); │ │ │ │ │ -270 DUNE_UNARY_FUNC(trunc, truncq); │ │ │ │ │ -271 │ │ │ │ │ -272 DUNE_CUSTOM_UNARY_FUNC(bool, isfinite, finiteq); │ │ │ │ │ -273 DUNE_CUSTOM_UNARY_FUNC(bool, isinf, isinfq); │ │ │ │ │ -274 DUNE_CUSTOM_UNARY_FUNC(bool, isnan, isnanq); │ │ │ │ │ -275 DUNE_CUSTOM_UNARY_FUNC(bool, signbit, signbitq); │ │ │ │ │ -276 │ │ │ │ │ -277#undef DUNE_UNARY_FUNC │ │ │ │ │ -278#undef DUNE_CUSTOM_UNARY_FUNC │ │ │ │ │ -279#undef DUNE_BINARY_FUNC │ │ │ │ │ -280 │ │ │ │ │ -281 // like DUNE_BINARY_FUNC but provide overloads with arithmetic │ │ │ │ │ -282 // types in the first or second argument. │ │ │ │ │ -283#define DUNE_BINARY_ARITHMETIC_FUNC(name,func) \ │ │ │ │ │ -284 inline Float128 name(const Float128& t, \ │ │ │ │ │ -285 const Float128& u) noexcept \ │ │ │ │ │ -286 { \ │ │ │ │ │ -287 return Float128{func (float128_t(t), float128_t(u))}; \ │ │ │ │ │ -288 } \ │ │ │ │ │ -289 template ::value, int> = 0> \ │ │ │ │ │ -291 inline Float128 name(const T& t, \ │ │ │ │ │ -292 const Float128& u) noexcept \ │ │ │ │ │ -293 { \ │ │ │ │ │ -294 return Float128{func (float128_t(t), float128_t(u))}; \ │ │ │ │ │ -295 } \ │ │ │ │ │ -296 template ::value, int> = 0> \ │ │ │ │ │ -298 inline Float128 name(const Float128& t, \ │ │ │ │ │ -299 const U& u) noexcept \ │ │ │ │ │ -300 { \ │ │ │ │ │ -301 return Float128{func (float128_t(t), float128_t(u))}; \ │ │ │ │ │ -302 } \ │ │ │ │ │ -303 static_assert(true, "Require semicolon to unconfuse editors") │ │ │ │ │ -304 │ │ │ │ │ -305 DUNE_BINARY_ARITHMETIC_FUNC(atan2,atan2q); │ │ │ │ │ -306 DUNE_BINARY_ARITHMETIC_FUNC(copysign,copysignq); │ │ │ │ │ -307 DUNE_BINARY_ARITHMETIC_FUNC(fdim,fdimq); │ │ │ │ │ -308 DUNE_BINARY_ARITHMETIC_FUNC(fmax,fmaxq); │ │ │ │ │ -309 DUNE_BINARY_ARITHMETIC_FUNC(fmin,fminq); │ │ │ │ │ -310 DUNE_BINARY_ARITHMETIC_FUNC(fmod,fmodq); │ │ │ │ │ -311 DUNE_BINARY_ARITHMETIC_FUNC(hypot,hypotq); │ │ │ │ │ -312 DUNE_BINARY_ARITHMETIC_FUNC(remainder,remainderq); │ │ │ │ │ -313 │ │ │ │ │ -314#undef DUNE_BINARY_ARITHMETIC_FUNC │ │ │ │ │ -315 │ │ │ │ │ -316 // some more cmath functions with special signature │ │ │ │ │ -317 │ │ │ │ │ -318 inline Float128 fma(const Float128& t, const Float128& u, const Float128& │ │ │ │ │ -v) │ │ │ │ │ -319 { │ │ │ │ │ -320 return Float128{fmaq(float128_t(t),float128_t(u),float128_t(v))}; │ │ │ │ │ -321 } │ │ │ │ │ -322 │ │ │ │ │ -323 inline Float128 frexp(const Float128& u, int* p) │ │ │ │ │ -324 { │ │ │ │ │ -325 return Float128{frexpq(float128_t(u), p)}; │ │ │ │ │ -326 } │ │ │ │ │ -327 │ │ │ │ │ -328 inline Float128 ldexp(const Float128& u, int p) │ │ │ │ │ -329 { │ │ │ │ │ -330 return Float128{ldexpq(float128_t(u), p)}; │ │ │ │ │ -331 } │ │ │ │ │ -332 │ │ │ │ │ -333 inline Float128 remquo(const Float128& t, const Float128& u, int* quo) │ │ │ │ │ -334 { │ │ │ │ │ -335 return Float128{remquoq(float128_t(t), float128_t(u), quo)}; │ │ │ │ │ -336 } │ │ │ │ │ -337 │ │ │ │ │ -338 inline Float128 scalbln(const Float128& u, long int e) │ │ │ │ │ -339 { │ │ │ │ │ -340 return Float128{scalblnq(float128_t(u), e)}; │ │ │ │ │ -341 } │ │ │ │ │ -342 │ │ │ │ │ -343 inline Float128 scalbn(const Float128& u, int e) │ │ │ │ │ -344 { │ │ │ │ │ -345 return Float128{scalbnq(float128_t(u), e)}; │ │ │ │ │ -346 } │ │ │ │ │ -347 │ │ │ │ │ -349 // NOTE: This is much faster than a pow(x, Float128(p)) call │ │ │ │ │ -350 // NOTE: This is a modified version of boost::math::cstdfloat::detail::pown │ │ │ │ │ -351 // (adapted to the type Float128) that is part of the Boost 1.65 Math │ │ │ │ │ -toolkit 2.8.0 │ │ │ │ │ -352 // and is implemented by Christopher Kormanyos, John Maddock, and Paul A. │ │ │ │ │ -Bristow, │ │ │ │ │ -353 // distributed under the Boost Software License, Version 1.0 │ │ │ │ │ -354 // (See http://www.boost.org/LICENSE_1_0.txt) │ │ │ │ │ -355 template ::value, int> = 0> │ │ │ │ │ -357 inline Float128 pow(const Float128& x, const Int p) │ │ │ │ │ -358 { │ │ │ │ │ -359 static const Float128 max_value = FLT128_MAX; │ │ │ │ │ -360 static const Float128 min_value = FLT128_MIN; │ │ │ │ │ -361 static const Float128 inf_value = float128_t{1} / float128_t{0}; │ │ │ │ │ -362 │ │ │ │ │ -363 const bool isneg = (x < 0); │ │ │ │ │ -364 const bool isnan = (x != x); │ │ │ │ │ -365 const bool isinf = (isneg ? bool(-x > max_value) : bool(+x > max_value)); │ │ │ │ │ -366 │ │ │ │ │ -367 if (isnan) { return x; } │ │ │ │ │ -368 if (isinf) { return Float128{nanq("")}; } │ │ │ │ │ -369 │ │ │ │ │ -370 const Float128 abs_x = (isneg ? -x : x); │ │ │ │ │ -371 if (p < Int(0)) { │ │ │ │ │ -372 if (abs_x < min_value) │ │ │ │ │ -373 return (isneg ? -inf_value : +inf_value); │ │ │ │ │ -374 else │ │ │ │ │ -375 return Float128(1) / pow(x, Int(-p)); │ │ │ │ │ -376 } │ │ │ │ │ -377 │ │ │ │ │ -378 if (p == Int(0)) { return Float128(1); } │ │ │ │ │ -379 if (p == Int(1)) { return x; } │ │ │ │ │ -380 if (abs_x > max_value) │ │ │ │ │ -381 return (isneg ? -inf_value : +inf_value); │ │ │ │ │ -382 │ │ │ │ │ -383 if (p == Int(2)) { return (x * x); } │ │ │ │ │ -384 if (p == Int(3)) { return ((x * x) * x); } │ │ │ │ │ -385 if (p == Int(4)) { const Float128 x2 = (x * x); return (x2 * x2); } │ │ │ │ │ -386 │ │ │ │ │ -387 Float128 result = ((p % Int(2)) != Int(0)) ? x : Float128(1); │ │ │ │ │ -388 Float128 xn = x; // binary powers of x │ │ │ │ │ -389 │ │ │ │ │ -390 Int p2 = p; │ │ │ │ │ -391 while (Int(p2 /= 2) != Int(0)) { │ │ │ │ │ -392 xn *= xn; // Square xn for each binary power │ │ │ │ │ -393 │ │ │ │ │ -394 const bool has_binary_power = (Int(p2 % Int(2)) != Int(0)); │ │ │ │ │ -395 if (has_binary_power) │ │ │ │ │ -396 result *= xn; │ │ │ │ │ -397 } │ │ │ │ │ -398 │ │ │ │ │ -399 return result; │ │ │ │ │ -400 } │ │ │ │ │ -401 │ │ │ │ │ -402 │ │ │ │ │ -403 } // end namespace Impl │ │ │ │ │ -404 │ │ │ │ │ -405 template <> │ │ │ │ │ -406 struct IsNumber │ │ │ │ │ -407 : public std::true_type {}; │ │ │ │ │ -408 │ │ │ │ │ -409} // end namespace Dune │ │ │ │ │ -410 │ │ │ │ │ -411namespace std │ │ │ │ │ -412{ │ │ │ │ │ -413#ifndef NO_STD_NUMERIC_LIMITS_SPECIALIZATION │ │ │ │ │ -414 template <> │ │ │ │ │ -415 class numeric_limits │ │ │ │ │ -416 { │ │ │ │ │ -417 using Float128 = Dune::Impl::Float128; │ │ │ │ │ -418 using float128_t = Dune::Impl::float128_t; │ │ │ │ │ -419 │ │ │ │ │ -420 public: │ │ │ │ │ -421 static constexpr bool is_specialized = true; │ │ │ │ │ -422 static constexpr Float128 min() noexcept { return FLT128_MIN; } │ │ │ │ │ -423 static constexpr Float128 max() noexcept { return FLT128_MAX; } │ │ │ │ │ -424 static constexpr Float128 lowest() noexcept { return -FLT128_MAX; } │ │ │ │ │ -425 static constexpr int digits = FLT128_MANT_DIG; │ │ │ │ │ -426 static constexpr int digits10 = 34; │ │ │ │ │ -427 static constexpr int max_digits10 = 36; │ │ │ │ │ -428 static constexpr bool is_signed = true; │ │ │ │ │ -429 static constexpr bool is_integer = false; │ │ │ │ │ -430 static constexpr bool is_exact = false; │ │ │ │ │ -431 static constexpr int radix = 2; │ │ │ │ │ -432 static constexpr Float128 epsilon() noexcept { return FLT128_EPSILON; } │ │ │ │ │ -433 static constexpr Float128 round_error() noexcept { return float128_t{0.5}; │ │ │ │ │ -} │ │ │ │ │ -434 static constexpr int min_exponent = FLT128_MIN_EXP; │ │ │ │ │ -435 static constexpr int min_exponent10 = FLT128_MIN_10_EXP; │ │ │ │ │ -436 static constexpr int max_exponent = FLT128_MAX_EXP; │ │ │ │ │ -437 static constexpr int max_exponent10 = FLT128_MAX_10_EXP; │ │ │ │ │ -438 static constexpr bool has_infinity = true; │ │ │ │ │ -439 static constexpr bool has_quiet_NaN = true; │ │ │ │ │ -440 static constexpr bool has_signaling_NaN = false; │ │ │ │ │ -441 static constexpr float_denorm_style has_denorm = denorm_present; │ │ │ │ │ -442 static constexpr bool has_denorm_loss = false; │ │ │ │ │ -443 static constexpr Float128 infinity() noexcept { return float128_t{1}/ │ │ │ │ │ -float128_t{0}; } │ │ │ │ │ -444 static Float128 quiet_NaN() noexcept { return nanq(""); } │ │ │ │ │ -445 static constexpr Float128 signaling_NaN() noexcept { return float128_t{}; } │ │ │ │ │ -446 static constexpr Float128 denorm_min() noexcept { return FLT128_DENORM_MIN; │ │ │ │ │ -} │ │ │ │ │ -447 static constexpr bool is_iec559 = true; │ │ │ │ │ -448 static constexpr bool is_bounded = false; │ │ │ │ │ -449 static constexpr bool is_modulo = false; │ │ │ │ │ -450 static constexpr bool traps = false; │ │ │ │ │ -451 static constexpr bool tinyness_before = false; │ │ │ │ │ -452 static constexpr float_round_style round_style = round_to_nearest; │ │ │ │ │ -453 }; │ │ │ │ │ -454#endif │ │ │ │ │ -455} // end namespace std │ │ │ │ │ -456 │ │ │ │ │ -457#endif // HAVE_QUADMATH │ │ │ │ │ -458#endif // DUNE_QUADMATH_HH │ │ │ │ │ -DUNE_BINARY_OP │ │ │ │ │ -#define DUNE_BINARY_OP(OP) │ │ │ │ │ -Definition debugalign.hh:261 │ │ │ │ │ -DUNE_UNARY_FUNC │ │ │ │ │ -#define DUNE_UNARY_FUNC(name) │ │ │ │ │ -DUNE_ASSIGN_OP │ │ │ │ │ -#define DUNE_ASSIGN_OP(OP) │ │ │ │ │ -Definition debugalign.hh:220 │ │ │ │ │ -exceptions.hh │ │ │ │ │ -A few common exception classes. │ │ │ │ │ -typetraits.hh │ │ │ │ │ -Traits for type conversions and type information. │ │ │ │ │ -Dune::operator>> │ │ │ │ │ -Stream & operator>>(Stream &stream, std::tuple< Ts... > &t) │ │ │ │ │ -Read a std::tuple. │ │ │ │ │ -Definition streamoperators.hh:43 │ │ │ │ │ -Dune::Hybrid::max │ │ │ │ │ -constexpr auto max │ │ │ │ │ -Function object that returns the greater of the given values. │ │ │ │ │ -Definition hybridutilities.hh:484 │ │ │ │ │ -Dune::Hybrid::min │ │ │ │ │ -constexpr auto min │ │ │ │ │ -Function object that returns the smaller of the given values. │ │ │ │ │ -Definition hybridutilities.hh:506 │ │ │ │ │ -Dune::operator<< │ │ │ │ │ -std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x) │ │ │ │ │ -Definition bigunsignedint.hh:278 │ │ │ │ │ -Dune::operator- │ │ │ │ │ -bigunsignedint< k > operator-(const bigunsignedint< k > &x, std::uintmax_t y) │ │ │ │ │ -Definition bigunsignedint.hh:542 │ │ │ │ │ -Dune::operator+ │ │ │ │ │ -bigunsignedint< k > operator+(const bigunsignedint< k > &x, std::uintmax_t y) │ │ │ │ │ -Definition bigunsignedint.hh:535 │ │ │ │ │ -DUNE_THROW │ │ │ │ │ -#define DUNE_THROW(E, m) │ │ │ │ │ -Definition exceptions.hh:218 │ │ │ │ │ -std │ │ │ │ │ -STL namespace. │ │ │ │ │ +97 }; │ │ │ │ │ +98 │ │ │ │ │ +100 template │ │ │ │ │ +101 constexpr bool │ │ │ │ │ +102 operator==(const MallocAllocator &, const MallocAllocator &) │ │ │ │ │ +103 { │ │ │ │ │ +104 return true; │ │ │ │ │ +105 } │ │ │ │ │ +106 │ │ │ │ │ +108 template │ │ │ │ │ +109 constexpr bool │ │ │ │ │ +110 operator!=(const MallocAllocator &, const MallocAllocator &) │ │ │ │ │ +111 { │ │ │ │ │ +112 return false; │ │ │ │ │ +113 } │ │ │ │ │ +114} │ │ │ │ │ +115 │ │ │ │ │ +116#endif // DUNE_MALLOC_ALLOCATOR_HH │ │ │ │ │ +Dune::operator== │ │ │ │ │ +EnableIfInterOperable< T1, T2, bool >::type operator==(const │ │ │ │ │ +ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, │ │ │ │ │ +V2, R2, D > &rhs) │ │ │ │ │ +Checks for equality. │ │ │ │ │ +Definition iteratorfacades.hh:238 │ │ │ │ │ +Dune::operator!= │ │ │ │ │ +EnableIfInterOperable< T1, T2, bool >::type operator!=(const │ │ │ │ │ +ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, │ │ │ │ │ +V2, R2, D > &rhs) │ │ │ │ │ +Checks for inequality. │ │ │ │ │ +Definition iteratorfacades.hh:260 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::max_value │ │ │ │ │ -T max_value(const AlignedNumber< T, align > &val) │ │ │ │ │ -Definition debugalign.hh:494 │ │ │ │ │ -Dune::min_value │ │ │ │ │ -T min_value(const AlignedNumber< T, align > &val) │ │ │ │ │ -Definition debugalign.hh:500 │ │ │ │ │ -Dune::RangeError │ │ │ │ │ -Default exception class for range errors. │ │ │ │ │ -Definition exceptions.hh:254 │ │ │ │ │ +Dune::MallocAllocator │ │ │ │ │ +Allocators implementation which simply calls malloc/free. │ │ │ │ │ +Definition mallocallocator.hh:24 │ │ │ │ │ +Dune::MallocAllocator::~MallocAllocator │ │ │ │ │ +~MallocAllocator() noexcept │ │ │ │ │ +cleanup this allocator │ │ │ │ │ +Definition mallocallocator.hh:43 │ │ │ │ │ +Dune::MallocAllocator::pointer │ │ │ │ │ +T * pointer │ │ │ │ │ +Definition mallocallocator.hh:28 │ │ │ │ │ +Dune::MallocAllocator::construct │ │ │ │ │ +void construct(pointer p, const T &val) │ │ │ │ │ +copy-construct an object of type T (i.e. make a placement new on p) │ │ │ │ │ +Definition mallocallocator.hh:80 │ │ │ │ │ +Dune::MallocAllocator::MallocAllocator │ │ │ │ │ +MallocAllocator() noexcept │ │ │ │ │ +create a new MallocAllocator │ │ │ │ │ +Definition mallocallocator.hh:38 │ │ │ │ │ +Dune::MallocAllocator::MallocAllocator │ │ │ │ │ +MallocAllocator(const MallocAllocator< U > &) noexcept │ │ │ │ │ +copy construct from an other MallocAllocator, possibly for a different result │ │ │ │ │ +type │ │ │ │ │ +Definition mallocallocator.hh:41 │ │ │ │ │ +Dune::MallocAllocator::size_type │ │ │ │ │ +std::size_t size_type │ │ │ │ │ +Definition mallocallocator.hh:26 │ │ │ │ │ +Dune::MallocAllocator::difference_type │ │ │ │ │ +std::ptrdiff_t difference_type │ │ │ │ │ +Definition mallocallocator.hh:27 │ │ │ │ │ +Dune::MallocAllocator::deallocate │ │ │ │ │ +void deallocate(pointer p, size_type n) │ │ │ │ │ +deallocate n objects of type T at address p │ │ │ │ │ +Definition mallocallocator.hh:68 │ │ │ │ │ +Dune::MallocAllocator::value_type │ │ │ │ │ +T value_type │ │ │ │ │ +Definition mallocallocator.hh:32 │ │ │ │ │ +Dune::MallocAllocator::address │ │ │ │ │ +const_pointer address(const_reference x) const │ │ │ │ │ +Definition mallocallocator.hh:49 │ │ │ │ │ +Dune::MallocAllocator::const_reference │ │ │ │ │ +const T & const_reference │ │ │ │ │ +Definition mallocallocator.hh:31 │ │ │ │ │ +Dune::MallocAllocator::destroy │ │ │ │ │ +void destroy(pointer p) │ │ │ │ │ +destroy an object of type T (i.e. call the destructor) │ │ │ │ │ +Definition mallocallocator.hh:93 │ │ │ │ │ +Dune::MallocAllocator::allocate │ │ │ │ │ +pointer allocate(size_type n, const void *hint=0) │ │ │ │ │ +allocate n objects of type T │ │ │ │ │ +Definition mallocallocator.hh:55 │ │ │ │ │ +Dune::MallocAllocator::address │ │ │ │ │ +pointer address(reference x) const │ │ │ │ │ +Definition mallocallocator.hh:45 │ │ │ │ │ +Dune::MallocAllocator::construct │ │ │ │ │ +void construct(pointer p, Args &&... args) │ │ │ │ │ +construct an object of type T from variadic parameters │ │ │ │ │ +Definition mallocallocator.hh:87 │ │ │ │ │ +Dune::MallocAllocator::reference │ │ │ │ │ +T & reference │ │ │ │ │ +Definition mallocallocator.hh:30 │ │ │ │ │ +Dune::MallocAllocator::max_size │ │ │ │ │ +size_type max_size() const noexcept │ │ │ │ │ +max size for allocate │ │ │ │ │ +Definition mallocallocator.hh:74 │ │ │ │ │ +Dune::MallocAllocator::const_pointer │ │ │ │ │ +const T * const_pointer │ │ │ │ │ +Definition mallocallocator.hh:29 │ │ │ │ │ +Dune::MallocAllocator::rebind │ │ │ │ │ +Definition mallocallocator.hh:33 │ │ │ │ │ +Dune::MallocAllocator::rebind::other │ │ │ │ │ +MallocAllocator< U > other │ │ │ │ │ +Definition mallocallocator.hh:34 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00104.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: tupleutility.hh File Reference │ │ │ │ +dune-common: bitsetvector.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -71,117 +71,59 @@ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces | │ │ │ │ -Functions
│ │ │ │ -
tupleutility.hh File Reference
│ │ │ │ +Namespaces
│ │ │ │ +
bitsetvector.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

Contains utility classes which can be used with std::tuple. │ │ │ │ +

Efficient implementation of a dynamic array of static arrays of booleans. │ │ │ │ More...

│ │ │ │ -
#include <cstddef>
│ │ │ │ -#include <tuple>
│ │ │ │ -#include <type_traits>
│ │ │ │ -#include <utility>
│ │ │ │ -#include <dune/common/hybridutilities.hh>
│ │ │ │ -#include <dune/common/typetraits.hh>
│ │ │ │ +
#include <vector>
│ │ │ │ +#include <bitset>
│ │ │ │ +#include <iostream>
│ │ │ │ +#include <algorithm>
│ │ │ │ +#include <dune/common/boundschecking.hh>
│ │ │ │ +#include <dune/common/genericiterator.hh>
│ │ │ │ +#include <dune/common/exceptions.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

struct  Dune::TupleAccessTraits< T >
class  Dune::BitSetVectorConstReference< block_size, Alloc >
 A proxy class that acts as a const reference to a single bitset in a BitSetVector. More...
 
struct  Dune::TupleAccessTraits< T * >
class  Dune::BitSetVectorReference< block_size, Alloc >
 A proxy class that acts as a mutable reference to a single bitset in a BitSetVector. More...
 
struct  Dune::TupleAccessTraits< T & >
struct  Dune::const_reference< BitSetVectorReference< block_size, Alloc > >
 
struct  Dune::NullPointerInitialiser< std::tuple< Args... > >
struct  Dune::const_reference< BitSetVectorConstReference< block_size, Alloc > >
 
struct  Dune::ForEachType< TE, std::tuple< Args... > >
struct  Dune::mutable_reference< BitSetVectorReference< block_size, Alloc > >
 
class  Dune::TransformTupleFunctor< TE, Args >
struct  Dune::mutable_reference< BitSetVectorConstReference< block_size, Alloc > >
 
struct  Dune::TransformTupleFunctor< TE, Args >::TypeEvaluator< T >
 
struct  Dune::AddRefTypeEvaluator< T >
 TypeEvaluator to turn a type T into a reference to T More...
 
struct  Dune::AddPtrTypeEvaluator< T >
 TypeEvaluator to turn a type T into a pointer to T More...
 
struct  Dune::AddPtrTypeEvaluator< T & >
 
struct  Dune::AtType< N, Tuple >
 Type for reverse element access. More...
 
struct  Dune::At< N >
 Reverse element access. More...
 
struct  Dune::PointerPairDeletor< Tuple >
 Deletes all objects pointed to in a std::tuple of pointers. More...
 
class  Dune::FirstPredicateIndex< Tuple, Predicate, start, size >
 Finding the index of a certain type in a std::tuple. More...
 
struct  Dune::IsType< T >
 Generator for predicates accepting one particular type. More...
 
struct  Dune::IsType< T >::Predicate< U >
 The actual predicate. More...
 
struct  Dune::FirstTypeIndex< Tuple, T, start >
 Find the first occurrence of a type in a std::tuple. More...
 
struct  Dune::PushBackTuple< typename std::tuple< Args... >, T >
 
struct  Dune::PushFrontTuple< typename std::tuple< Args... >, T >
 
struct  Dune::ReduceTuple< F, Tuple, Seed, N >
 Apply reduce with meta binary function to template. More...
 
struct  Dune::ReduceTuple< F, Tuple, Seed, 0 >
 Apply reduce with meta binary function to template. More...
 
struct  Dune::JoinTuples< Head, Tail >
 Join two std::tuple's. More...
 
struct  Dune::FlattenTuple< Tuple >
 Flatten a std::tuple of std::tuple's. More...
class  Dune::BitSetVector< block_size, Allocator >
 A dynamic array of blocks of booleans. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │

│ │ │ │ -Functions

template<class F , class ArgTuple , class I , I... i>
decltype(auto) Dune::applyPartial (F &&f, ArgTuple &&args, std::integer_sequence< I, i... >)
 Apply function with arguments from a given tuple.
 
template<class Tuple , class Functor >
auto Dune::genericTransformTuple (Tuple &&t, Functor &&f) -> decltype(genericTransformTupleBackend(t, f))
 
template<template< class > class TE, class... Args>
TransformTupleFunctor< TE, Args... > Dune::makeTransformTupleFunctor (Args &&... args)
 
template<template< class > class TypeEvaluator, class Tuple , class... Args>
auto Dune::transformTuple (Tuple &&orig, Args &&... args) -> decltype(genericTransformTuple(orig, makeTransformTupleFunctor< TypeEvaluator >(args...)))
 
│ │ │ │

Detailed Description

│ │ │ │ -

Contains utility classes which can be used with std::tuple.

│ │ │ │ +

Efficient implementation of a dynamic array of static arrays of booleans.

│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,108 +1,48 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Functions │ │ │ │ │ -tupleutility.hh File Reference │ │ │ │ │ -Common » Utilities » Tuple_Utilities │ │ │ │ │ -Contains utility classes which can be used with std::tuple. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +bitsetvector.hh File Reference │ │ │ │ │ +Efficient implementation of a dynamic array of static arrays of booleans. │ │ │ │ │ +More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -struct   Dune::TupleAccessTraits<_T_> │ │ │ │ │ + class   Dune::BitSetVectorConstReference<_block_size,_Alloc_> │ │ │ │ │ +  A proxy class that acts as a const reference to a single bitset in a │ │ │ │ │ + BitSetVector. More... │ │ │ │ │   │ │ │ │ │ -struct   Dune::TupleAccessTraits<_T_*_> │ │ │ │ │ + class   Dune::BitSetVectorReference<_block_size,_Alloc_> │ │ │ │ │ +  A proxy class that acts as a mutable reference to a single bitset in a │ │ │ │ │ + BitSetVector. More... │ │ │ │ │   │ │ │ │ │ -struct   Dune::TupleAccessTraits<_T_&_> │ │ │ │ │ +struct   Dune::const_reference<_BitSetVectorReference<_block_size,_Alloc_>_> │ │ │ │ │   │ │ │ │ │ -struct   Dune::NullPointerInitialiser<_std::tuple<_Args..._>_> │ │ │ │ │ +struct   Dune::const_reference<_BitSetVectorConstReference<_block_size,_Alloc_> │ │ │ │ │ + > │ │ │ │ │   │ │ │ │ │ -struct   Dune::ForEachType<_TE,_std::tuple<_Args..._>_> │ │ │ │ │ +struct   Dune::mutable_reference<_BitSetVectorReference<_block_size,_Alloc_>_> │ │ │ │ │   │ │ │ │ │ - class   Dune::TransformTupleFunctor<_TE,_Args_> │ │ │ │ │ +struct   Dune::mutable_reference<_BitSetVectorConstReference<_block_size,_Alloc │ │ │ │ │ + >_> │ │ │ │ │   │ │ │ │ │ -struct   Dune::TransformTupleFunctor<_TE,_Args_>::TypeEvaluator<_T_> │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::AddRefTypeEvaluator<_T_> │ │ │ │ │ -  TypeEvaluator to turn a type T into a reference to T More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::AddPtrTypeEvaluator<_T_> │ │ │ │ │ -  TypeEvaluator to turn a type T into a pointer to T More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::AddPtrTypeEvaluator<_T_&_> │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::AtType<_N,_Tuple_> │ │ │ │ │ -  Type for reverse element access. More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::At<_N_> │ │ │ │ │ -  Reverse element access. More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::PointerPairDeletor<_Tuple_> │ │ │ │ │ -  Deletes all objects pointed to in a std::tuple of pointers. More... │ │ │ │ │ -  │ │ │ │ │ - class   Dune::FirstPredicateIndex<_Tuple,_Predicate,_start,_size_> │ │ │ │ │ -  Finding the index of a certain type in a std::tuple. More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::IsType<_T_> │ │ │ │ │ -  Generator for predicates accepting one particular type. More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::IsType<_T_>::Predicate<_U_> │ │ │ │ │ -  The actual predicate. More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::FirstTypeIndex<_Tuple,_T,_start_> │ │ │ │ │ -  Find the first occurrence of a type in a std::tuple. More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::PushBackTuple<_typename_std::tuple<_Args..._>,_T_> │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::PushFrontTuple<_typename_std::tuple<_Args..._>,_T_> │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::ReduceTuple<_F,_Tuple,_Seed,_N_> │ │ │ │ │ -  Apply reduce with meta binary function to template. More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::ReduceTuple<_F,_Tuple,_Seed,_0_> │ │ │ │ │ -  Apply reduce with meta binary function to template. More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::JoinTuples<_Head,_Tail_> │ │ │ │ │ -  Join two std::tuple's. More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::FlattenTuple<_Tuple_> │ │ │ │ │ -  Flatten a std::tuple of std::tuple's. More... │ │ │ │ │ + class   Dune::BitSetVector<_block_size,_Allocator_> │ │ │ │ │ +  A dynamic array of blocks of booleans. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -Functions │ │ │ │ │ -template │ │ │ │ │ - decltype(auto)  Dune::applyPartial (F &&f, ArgTuple &&args, │ │ │ │ │ - std::integer_sequence< I, i... >) │ │ │ │ │ -  Apply function with arguments from a given │ │ │ │ │ - tuple. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto  Dune::genericTransformTuple (Tuple &&t, │ │ │ │ │ - Functor &&f) -> decltype │ │ │ │ │ - (genericTransformTupleBackend(t, f)) │ │ │ │ │ -  │ │ │ │ │ -template class TE, class... Args> │ │ │ │ │ - TransformTupleFunctor< TE, Args... Dune::makeTransformTupleFunctor (Args &&... │ │ │ │ │ - >  args) │ │ │ │ │ -  │ │ │ │ │ -template class TypeEvaluator, class Tuple , class... Args> │ │ │ │ │ - auto  Dune::transformTuple (Tuple &&orig, Args │ │ │ │ │ - &&... args) -> decltype │ │ │ │ │ - (genericTransformTuple(orig, │ │ │ │ │ - makeTransformTupleFunctor< TypeEvaluator > │ │ │ │ │ - (args...))) │ │ │ │ │ -  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Contains utility classes which can be used with std::tuple. │ │ │ │ │ +Efficient implementation of a dynamic array of static arrays of booleans. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00104_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: tupleutility.hh Source File │ │ │ │ +dune-common: bitsetvector.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,448 +74,759 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
tupleutility.hh
│ │ │ │ +
bitsetvector.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5
│ │ │ │ -
6#ifndef DUNE_TUPLE_UTILITY_HH
│ │ │ │ -
7#define DUNE_TUPLE_UTILITY_HH
│ │ │ │ -
8
│ │ │ │ -
9#include <cstddef>
│ │ │ │ -
10#include <tuple>
│ │ │ │ -
11#include <type_traits>
│ │ │ │ -
12#include <utility>
│ │ │ │ -
13
│ │ │ │ - │ │ │ │ - │ │ │ │ +
5#ifndef DUNE_BLOCK_BITFIELD_HH
│ │ │ │ +
6#define DUNE_BLOCK_BITFIELD_HH
│ │ │ │ +
7
│ │ │ │ +
12#include <vector>
│ │ │ │ +
13#include <bitset>
│ │ │ │ +
14#include <iostream>
│ │ │ │ +
15#include <algorithm>
│ │ │ │
16
│ │ │ │ -
17namespace Dune {
│ │ │ │ -
18
│ │ │ │ -
41 template<class F, class ArgTuple, class I, I... i>
│ │ │ │ -
│ │ │ │ -
42 decltype(auto) applyPartial(F&& f, ArgTuple&& args, std::integer_sequence<I, i...> /*indices*/)
│ │ │ │ -
43 {
│ │ │ │ -
44 return f(std::get<i>(args)...);
│ │ │ │ -
45 }
│ │ │ │ -
│ │ │ │ -
46
│ │ │ │ -
47 template<class T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
49 {
│ │ │ │ -
50 typedef typename std::add_const<T>::type& ConstType;
│ │ │ │ -
51 typedef T& NonConstType;
│ │ │ │ -
52 typedef const typename std::remove_const<T>::type& ParameterType;
│ │ │ │ -
53 };
│ │ │ │ -
│ │ │ │ -
54
│ │ │ │ -
55 template<class T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
57 {
│ │ │ │ -
58 typedef typename std::add_const<T>::type* ConstType;
│ │ │ │ -
59 typedef T* NonConstType;
│ │ │ │ -
60 typedef T* ParameterType;
│ │ │ │ -
61 };
│ │ │ │ -
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
20
│ │ │ │ +
21namespace Dune {
│ │ │ │ +
22
│ │ │ │ +
23 template <int block_size, class Alloc> class BitSetVector;
│ │ │ │ +
24 template <int block_size, class Alloc> class BitSetVectorReference;
│ │ │ │ +
25
│ │ │ │ +
36 template <int block_size, class Alloc>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
38 {
│ │ │ │ +
39 protected:
│ │ │ │ +
40
│ │ │ │ + │ │ │ │ +
42 friend class Dune::BitSetVector<block_size, Alloc>;
│ │ │ │ +
43
│ │ │ │ +
│ │ │ │ +
44 BitSetVectorConstReference(const BitSetVector& blockBitField_, int block_number_) :
│ │ │ │ +
45 blockBitField(blockBitField_),
│ │ │ │ +
46 block_number(block_number_)
│ │ │ │ +
47 {
│ │ │ │ +
48 DUNE_ASSERT_BOUNDS(blockBitField_.size() > static_cast<size_t>(block_number_));
│ │ │ │ +
49 }
│ │ │ │ +
│ │ │ │ +
50
│ │ │ │ + │ │ │ │ +
53
│ │ │ │ +
54 public:
│ │ │ │ +
55
│ │ │ │ +
56 typedef std::bitset<block_size> bitset;
│ │ │ │ +
57
│ │ │ │ +
58 // bitset interface typedefs
│ │ │ │ +
59 typedef typename std::vector<bool, Alloc>::const_reference reference;
│ │ │ │ +
60 typedef typename std::vector<bool, Alloc>::const_reference const_reference;
│ │ │ │ +
61 typedef size_t size_type;
│ │ │ │
62
│ │ │ │ -
63 template<class T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
65 {
│ │ │ │ -
66 typedef T& ConstType;
│ │ │ │ -
67 typedef T& NonConstType;
│ │ │ │ -
68 typedef T& ParameterType;
│ │ │ │ -
69 };
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
65 {
│ │ │ │ +
66 bitset b = *this;
│ │ │ │ +
67 b <<= n;
│ │ │ │ +
68 return b;
│ │ │ │ +
69 }
│ │ │ │
│ │ │ │
70
│ │ │ │ -
78 template<class T>
│ │ │ │ - │ │ │ │ -
80
│ │ │ │ -
81 template<class... Args>
│ │ │ │ -
│ │ │ │ -
82 struct NullPointerInitialiser<std::tuple<Args...> >
│ │ │ │ -
83 {
│ │ │ │ -
84 typedef std::tuple<Args...> ResultType;
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
86 {
│ │ │ │ -
87 return ResultType(static_cast<Args>(nullptr)...);
│ │ │ │ -
88 }
│ │ │ │ -
│ │ │ │ -
89 };
│ │ │ │ -
│ │ │ │ -
90
│ │ │ │ -
115 template<template <class> class TE, class T>
│ │ │ │ - │ │ │ │ -
117
│ │ │ │ -
118 template<template <class> class TE, class... Args>
│ │ │ │ -
│ │ │ │ -
119 struct ForEachType<TE, std::tuple<Args...> >
│ │ │ │ -
120 {
│ │ │ │ -
121 typedef std::tuple<typename TE<Args>::Type...> Type;
│ │ │ │ -
122 };
│ │ │ │ -
│ │ │ │ -
123
│ │ │ │ -
124#ifndef DOXYGEN
│ │ │ │ -
125 template<class Tuple, class Functor, std::size_t... I>
│ │ │ │ -
126 inline auto genericTransformTupleBackendImpl(Tuple& t, Functor& f, const std::index_sequence<I...>& )
│ │ │ │ -
127 -> std::tuple<decltype(f(std::get<I>(t)))...>
│ │ │ │ -
128 {
│ │ │ │ -
129 return std::tuple<decltype(f(std::get<I>(t)))...>(f(std::get<I>(t))...);
│ │ │ │ -
130 }
│ │ │ │ -
131
│ │ │ │ -
132 template<class... Args, class Functor>
│ │ │ │ -
133 auto genericTransformTupleBackend(std::tuple<Args...>& t, Functor& f) ->
│ │ │ │ -
134 decltype(genericTransformTupleBackendImpl(t, f,std::index_sequence_for<Args...>{}))
│ │ │ │ -
135 {
│ │ │ │ -
136 return genericTransformTupleBackendImpl(t, f,std::index_sequence_for<Args...>{});
│ │ │ │ -
137 }
│ │ │ │ -
138
│ │ │ │ -
139 template<class... Args, class Functor>
│ │ │ │ -
140 auto genericTransformTupleBackend(const std::tuple<Args...>& t, Functor& f) ->
│ │ │ │ -
141 decltype(genericTransformTupleBackendImpl(t, f, std::index_sequence_for<Args...>{}))
│ │ │ │ -
142 {
│ │ │ │ -
143 return genericTransformTupleBackendImpl(t, f, std::index_sequence_for<Args...>{});
│ │ │ │ -
144 }
│ │ │ │ -
145#endif
│ │ │ │ -
146
│ │ │ │ -
185 template<class Tuple, class Functor>
│ │ │ │ -
│ │ │ │ -
186 auto genericTransformTuple(Tuple&& t, Functor&& f) ->
│ │ │ │ -
187 decltype(genericTransformTupleBackend(t, f))
│ │ │ │ -
188 {
│ │ │ │ -
189 return genericTransformTupleBackend(t, f);
│ │ │ │ -
190 }
│ │ │ │ -
│ │ │ │ -
191
│ │ │ │ -
224 template<template<class> class TE, class... Args>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
226 {
│ │ │ │ -
227 mutable std::tuple<Args&...> tup;
│ │ │ │ -
228
│ │ │ │ -
229 template<class T, std::size_t... I>
│ │ │ │ -
230 inline auto apply(T&& t, const std::index_sequence<I...>& ) ->
│ │ │ │ -
231 decltype(TE<T>::apply(t,std::get<I>(tup)...)) const
│ │ │ │ -
232 {
│ │ │ │ -
233 return TE<T>::apply(t,std::get<I>(tup)...);
│ │ │ │ -
234 }
│ │ │ │ -
235
│ │ │ │ -
236 public:
│ │ │ │ -
237 template<class T>
│ │ │ │ -
│ │ │ │ -
238 struct TypeEvaluator : public TE<T>
│ │ │ │ -
239 {};
│ │ │ │ -
│ │ │ │ -
240
│ │ │ │ -
│ │ │ │ -
241 TransformTupleFunctor(Args&&... args)
│ │ │ │ -
242 : tup(args...)
│ │ │ │ -
243 { }
│ │ │ │ -
│ │ │ │ -
244
│ │ │ │ -
245 template<class T>
│ │ │ │ -
│ │ │ │ -
246 inline auto operator()(T&& t) ->
│ │ │ │ -
247 decltype(this->apply(t,std::index_sequence_for<Args...>{})) const
│ │ │ │ -
248 {
│ │ │ │ -
249 return apply(t,std::index_sequence_for<Args...>{});
│ │ │ │ -
250 }
│ │ │ │ -
│ │ │ │ -
251 };
│ │ │ │ -
│ │ │ │ -
252
│ │ │ │ -
253 template<template<class> class TE, class... Args>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
255 {
│ │ │ │ -
256 return TransformTupleFunctor<TE, Args...>(args...);
│ │ │ │ -
257 }
│ │ │ │ -
│ │ │ │ -
258
│ │ │ │ -
291 template<template<class> class TypeEvaluator, class Tuple, class... Args>
│ │ │ │ -
│ │ │ │ -
292 auto transformTuple(Tuple&& orig, Args&&... args) ->
│ │ │ │ -
293 decltype(genericTransformTuple(orig, makeTransformTupleFunctor<TypeEvaluator>(args...)))
│ │ │ │ -
294 {
│ │ │ │ -
295 return genericTransformTuple(orig, makeTransformTupleFunctor<TypeEvaluator>(args...));
│ │ │ │ -
296 }
│ │ │ │ -
│ │ │ │ -
297
│ │ │ │ -
299
│ │ │ │ -
303 template<class T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
305 {
│ │ │ │ -
306 typedef T& Type;
│ │ │ │ -
│ │ │ │ -
307 static Type apply(T& t)
│ │ │ │ -
308 {
│ │ │ │ -
309 return t;
│ │ │ │ -
310 }
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
73 {
│ │ │ │ +
74 bitset b = *this;
│ │ │ │ +
75 b >>= n;
│ │ │ │ +
76 return b;
│ │ │ │ +
77 }
│ │ │ │ +
│ │ │ │ +
78
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
81 {
│ │ │ │ +
82 bitset b = *this;
│ │ │ │ +
83 b.flip();
│ │ │ │ +
84 return b;
│ │ │ │ +
85 }
│ │ │ │ +
│ │ │ │ +
86
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
89 {
│ │ │ │ +
90 return block_size;
│ │ │ │ +
91 }
│ │ │ │ +
│ │ │ │ +
92
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
95 {
│ │ │ │ +
96 size_type n = 0;
│ │ │ │ +
97 for(size_type i=0; i<block_size; ++i)
│ │ │ │ +
98 n += getBit(i);
│ │ │ │ +
99 return n;
│ │ │ │ +
100 }
│ │ │ │ +
│ │ │ │ +
101
│ │ │ │ +
│ │ │ │ +
103 bool any() const
│ │ │ │ +
104 {
│ │ │ │ +
105 return count();
│ │ │ │ +
106 }
│ │ │ │ +
│ │ │ │ +
107
│ │ │ │ +
│ │ │ │ +
109 bool none() const
│ │ │ │ +
110 {
│ │ │ │ +
111 return ! any();
│ │ │ │ +
112 }
│ │ │ │ +
│ │ │ │ +
113
│ │ │ │ +
│ │ │ │ +
115 bool all() const
│ │ │ │ +
116 {
│ │ │ │ +
117 for(size_type i=0; i<block_size; ++i)
│ │ │ │ +
118 if(not test(i))
│ │ │ │ +
119 return false;
│ │ │ │ +
120 return true;
│ │ │ │ +
121 }
│ │ │ │ +
│ │ │ │ +
122
│ │ │ │ +
│ │ │ │ +
124 bool test(size_type n) const
│ │ │ │ +
125 {
│ │ │ │ +
126 return getBit(n);
│ │ │ │ +
127 }
│ │ │ │ +
│ │ │ │ +
128
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
131 {
│ │ │ │ +
132 return getBit(i);
│ │ │ │ +
133 }
│ │ │ │ +
│ │ │ │ +
134
│ │ │ │ +
│ │ │ │ +
136 operator bitset() const
│ │ │ │ +
137 {
│ │ │ │ +
138 return blockBitField.getRepr(block_number);
│ │ │ │ +
139 }
│ │ │ │ +
│ │ │ │ +
140
│ │ │ │ +
│ │ │ │ +
142 bool operator== (const bitset& bs) const
│ │ │ │ +
143 {
│ │ │ │ +
144 return equals(bs);
│ │ │ │ +
145 }
│ │ │ │
│ │ │ │ -
311 };
│ │ │ │ +
146
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
149 {
│ │ │ │ +
150 return equals(bs);
│ │ │ │ +
151 }
│ │ │ │ +
│ │ │ │ +
152
│ │ │ │ +
│ │ │ │ +
154 bool operator!= (const bitset& bs) const
│ │ │ │ +
155 {
│ │ │ │ +
156 return ! equals(bs);
│ │ │ │ +
157 }
│ │ │ │ +
│ │ │ │ +
158
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
161 {
│ │ │ │ +
162 return ! equals(bs);
│ │ │ │ +
163 }
│ │ │ │ +
│ │ │ │ +
164
│ │ │ │ +
│ │ │ │ +
171 friend std::ostream& operator<< (std::ostream& s, const BitSetVectorConstReference& v)
│ │ │ │ +
172 {
│ │ │ │ +
173 s << "(";
│ │ │ │ +
174 for(int i=0; i<block_size; ++i)
│ │ │ │ +
175 s << v[i];
│ │ │ │ +
176 s << ")";
│ │ │ │ +
177 return s;
│ │ │ │ +
178 }
│ │ │ │ +
│ │ │ │ +
179
│ │ │ │ +
180 protected:
│ │ │ │ + │ │ │ │ + │ │ │ │ +
183
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
185 {
│ │ │ │ +
186 return blockBitField.getBit(block_number,i);
│ │ │ │ +
187 }
│ │ │ │ +
│ │ │ │ +
188
│ │ │ │ +
189 template<class BS>
│ │ │ │ +
│ │ │ │ +
190 bool equals(const BS & bs) const
│ │ │ │ +
191 {
│ │ │ │ +
192 bool eq = true;
│ │ │ │ +
193 for(int i=0; i<block_size; ++i)
│ │ │ │ +
194 eq &= (getBit(i) == bs[i]);
│ │ │ │ +
195 return eq;
│ │ │ │ +
196 }
│ │ │ │ +
│ │ │ │ +
197
│ │ │ │ +
198 private:
│ │ │ │ +
203 void operator & () = delete;
│ │ │ │ +
204
│ │ │ │ +
205 friend class BitSetVectorReference<block_size, Alloc>;
│ │ │ │ +
206 };
│ │ │ │ +
│ │ │ │ +
207
│ │ │ │ +
220 template <int block_size, class Alloc>
│ │ │ │ +
│ │ │ │ +
221 class BitSetVectorReference : public BitSetVectorConstReference<block_size,Alloc>
│ │ │ │ +
222 {
│ │ │ │ +
223 protected:
│ │ │ │ +
224
│ │ │ │ + │ │ │ │ +
226 friend class Dune::BitSetVector<block_size, Alloc>;
│ │ │ │ +
227
│ │ │ │ + │ │ │ │ +
229
│ │ │ │ +
│ │ │ │ +
230 BitSetVectorReference(BitSetVector& blockBitField_, int block_number_) :
│ │ │ │ +
231 BitSetVectorConstReference(blockBitField_, block_number_),
│ │ │ │ +
232 blockBitField(blockBitField_)
│ │ │ │ +
233 {}
│ │ │ │ +
│ │ │ │ +
234
│ │ │ │ +
235 public:
│ │ │ │ +
236 typedef std::bitset<block_size> bitset;
│ │ │ │ +
237
│ │ │ │ +
241 typedef typename std::vector<bool, Alloc>::reference reference;
│ │ │ │ +
243 typedef typename std::vector<bool, Alloc>::const_reference const_reference;
│ │ │ │ +
245
│ │ │ │ +
247 typedef size_t size_type;
│ │ │ │ +
248
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
251 {
│ │ │ │ +
252 for(int i=0; i<block_size; ++i)
│ │ │ │ +
253 getBit(i) = b;
│ │ │ │ +
254 return (*this);
│ │ │ │ +
255 }
│ │ │ │ +
│ │ │ │ +
256
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
259 {
│ │ │ │ +
260 for(int i=0; i<block_size; ++i)
│ │ │ │ +
261 getBit(i) = b.test(i);
│ │ │ │ +
262 return (*this);
│ │ │ │ +
263 }
│ │ │ │ +
│ │ │ │ +
264
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
267 {
│ │ │ │ +
268 for(int i=0; i<block_size; ++i)
│ │ │ │ +
269 getBit(i) = b.test(i);
│ │ │ │ +
270 return (*this);
│ │ │ │ +
271 }
│ │ │ │ +
│ │ │ │ +
272
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
275 {
│ │ │ │ +
276 for(int i=0; i<block_size; ++i)
│ │ │ │ +
277 getBit(i) = b.test(i);
│ │ │ │ +
278 return (*this);
│ │ │ │ +
279 }
│ │ │ │ +
│ │ │ │ +
280
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
283 {
│ │ │ │ +
284 for (size_type i=0; i<block_size; i++)
│ │ │ │ +
285 getBit(i) = (test(i) & x.test(i));
│ │ │ │ +
286 return *this;
│ │ │ │ +
287 }
│ │ │ │ +
│ │ │ │ +
288
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
291 {
│ │ │ │ +
292 for (size_type i=0; i<block_size; i++)
│ │ │ │ +
293 getBit(i) = (test(i) & x.test(i));
│ │ │ │ +
294 return *this;
│ │ │ │ +
295 }
│ │ │ │ +
│ │ │ │ +
296
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
299 {
│ │ │ │ +
300 for (size_type i=0; i<block_size; i++)
│ │ │ │ +
301 getBit(i) = (test(i) | x.test(i));
│ │ │ │ +
302 return *this;
│ │ │ │ +
303 }
│ │ │ │ +
│ │ │ │ +
304
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
307 {
│ │ │ │ +
308 for (size_type i=0; i<block_size; i++)
│ │ │ │ +
309 getBit(i) = (test(i) | x.test(i));
│ │ │ │ +
310 return *this;
│ │ │ │ +
311 }
│ │ │ │
│ │ │ │
312
│ │ │ │ -
314
│ │ │ │ -
318 template<class T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
320 {
│ │ │ │ -
321 typedef typename std::remove_reference<T>::type* Type;
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
315 {
│ │ │ │ +
316 for (size_type i=0; i<block_size; i++)
│ │ │ │ +
317 getBit(i) = (test(i) ^ x.test(i));
│ │ │ │ +
318 return *this;
│ │ │ │ +
319 }
│ │ │ │ +
│ │ │ │ +
320
│ │ │ │
│ │ │ │ -
322 static Type apply(T& t)
│ │ │ │ + │ │ │ │
323 {
│ │ │ │ -
324 return &t;
│ │ │ │ -
325 }
│ │ │ │ +
324 for (size_type i=0; i<block_size; i++)
│ │ │ │ +
325 getBit(i) = (test(i) ^ x.test(i));
│ │ │ │ +
326 return *this;
│ │ │ │ +
327 }
│ │ │ │ +
│ │ │ │ +
328
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
331 {
│ │ │ │ +
332 for (size_type i=0; i<block_size-n; i++)
│ │ │ │ +
333 getBit(i) = test(i+n);
│ │ │ │ +
334 return *this;
│ │ │ │ +
335 }
│ │ │ │ +
│ │ │ │ +
336
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
339 {
│ │ │ │ +
340 for (size_type i=0; i<block_size-n; i++)
│ │ │ │ +
341 getBit(i+n) = test(i);
│ │ │ │ +
342 return *this;
│ │ │ │ +
343 }
│ │ │ │ +
│ │ │ │ +
344
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
347 {
│ │ │ │ +
348 for (size_type i=0; i<block_size; i++)
│ │ │ │ +
349 set(i);
│ │ │ │ +
350 return *this;
│ │ │ │ +
351 }
│ │ │ │ +
│ │ │ │ +
352
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
355 {
│ │ │ │ +
356 for (size_type i=0; i<block_size; i++)
│ │ │ │ +
357 flip(i);
│ │ │ │ +
358 return *this;
│ │ │ │ +
359 }
│ │ │ │
│ │ │ │ -
326 };
│ │ │ │ -
│ │ │ │ -
327
│ │ │ │ -
328 // Specialization, in case the type is already a reference
│ │ │ │ -
329 template<class T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
331 {
│ │ │ │ -
332 typedef typename std::remove_reference<T>::type* Type;
│ │ │ │ -
│ │ │ │ -
333 static Type apply(T& t)
│ │ │ │ -
334 {
│ │ │ │ -
335 return &t;
│ │ │ │ -
336 }
│ │ │ │ -
│ │ │ │ -
337 };
│ │ │ │ -
│ │ │ │ -
338
│ │ │ │ -
344 template<int N, class Tuple>
│ │ │ │ -
│ │ │ │ -
345 struct AtType
│ │ │ │ -
346 {
│ │ │ │ -
347 typedef typename std::tuple_element<std::tuple_size<Tuple>::value - N - 1, Tuple>::type Type;
│ │ │ │ -
348 };
│ │ │ │ -
│ │ │ │ -
349
│ │ │ │ -
357 template<int N>
│ │ │ │ -
│ │ │ │ -
358 struct At
│ │ │ │ -
359 {
│ │ │ │ -
360 template<typename Tuple>
│ │ │ │ -
361 static typename TupleAccessTraits<typename AtType<N, Tuple>::Type>::NonConstType
│ │ │ │ +
360
│ │ │ │
│ │ │ │ -
362 get(Tuple& t)
│ │ │ │ + │ │ │ │
363 {
│ │ │ │ -
364 return std::get<std::tuple_size<Tuple>::value - N - 1>(t);
│ │ │ │ -
365 }
│ │ │ │ +
364 *this = false;
│ │ │ │ +
365 return *this;
│ │ │ │ +
366 }
│ │ │ │
│ │ │ │ -
366
│ │ │ │ -
367 template<typename Tuple>
│ │ │ │ -
368 static typename TupleAccessTraits<typename AtType<N, Tuple>::Type>::ConstType
│ │ │ │ +
367
│ │ │ │
│ │ │ │ -
369 get(const Tuple& t)
│ │ │ │ + │ │ │ │
370 {
│ │ │ │ -
371 return std::get<std::tuple_size<Tuple>::value - N - 1>(t);
│ │ │ │ -
372 }
│ │ │ │ -
│ │ │ │ -
373 };
│ │ │ │ +
371 getBit(n) = val;
│ │ │ │ +
372 return *this;
│ │ │ │ +
373 }
│ │ │ │
│ │ │ │
374
│ │ │ │ -
378 template<class Tuple>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
380 {
│ │ │ │ -
381 template<typename... Ts>
│ │ │ │ -
│ │ │ │ -
382 static void apply(std::tuple<Ts...>& t)
│ │ │ │ -
383 {
│ │ │ │ -
384 Hybrid::forEach(t,[&](auto&& ti){delete ti; ti=nullptr;});
│ │ │ │ -
385 }
│ │ │ │ -
│ │ │ │ -
386 };
│ │ │ │ -
│ │ │ │ -
387
│ │ │ │ -
411 template<class Tuple, template<class> class Predicate, std::size_t start = 0,
│ │ │ │ -
412 std::size_t size = std::tuple_size<Tuple>::value>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
377 {
│ │ │ │ +
378 set(n, false);
│ │ │ │ +
379 return *this;
│ │ │ │ +
380 }
│ │ │ │ +
│ │ │ │ +
381
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
384 {
│ │ │ │ +
385 getBit(n).flip();
│ │ │ │ +
386 return *this;
│ │ │ │ +
387 }
│ │ │ │ +
│ │ │ │ +
388
│ │ │ │ + │ │ │ │ +
390 using BitSetVectorConstReference::operator[];
│ │ │ │ +
391
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
394 {
│ │ │ │ +
395 return getBit(i);
│ │ │ │ +
396 }
│ │ │ │ +
│ │ │ │ +
397
│ │ │ │ +
398 protected:
│ │ │ │ + │ │ │ │ +
400
│ │ │ │ + │ │ │ │ +
402
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
404 {
│ │ │ │ +
405 return blockBitField.getBit(this->block_number,i);
│ │ │ │ +
406 }
│ │ │ │ +
│ │ │ │ +
407 };
│ │ │ │ +
│ │ │ │ +
408
│ │ │ │ +
412 template<int block_size, class Alloc>
│ │ │ │
│ │ │ │ - │ │ │ │ -
414 public std::conditional<Predicate<typename std::tuple_element<start,
│ │ │ │ -
415 Tuple>::type>::value,
│ │ │ │ -
416 std::integral_constant<std::size_t, start>,
│ │ │ │ -
417 FirstPredicateIndex<Tuple, Predicate, start+1> >::type
│ │ │ │ -
418 {
│ │ │ │ -
419 static_assert(std::tuple_size<Tuple>::value == size, "The \"size\" "
│ │ │ │ -
420 "template parameter of FirstPredicateIndex is an "
│ │ │ │ -
421 "implementation detail and should never be set "
│ │ │ │ -
422 "explicitly!");
│ │ │ │ -
423 };
│ │ │ │ -
│ │ │ │ -
424
│ │ │ │ -
425#ifndef DOXYGEN
│ │ │ │ -
426 template<class Tuple, template<class> class Predicate, std::size_t size>
│ │ │ │ -
427 class FirstPredicateIndex<Tuple, Predicate, size, size>
│ │ │ │ -
428 {
│ │ │ │ -
429 static_assert(AlwaysFalse<Tuple>::value, "None of the std::tuple element "
│ │ │ │ -
430 "types matches the predicate!");
│ │ │ │ -
431 };
│ │ │ │ -
432#endif // !DOXYGEN
│ │ │ │ -
433
│ │ │ │ -
443 template<class T>
│ │ │ │ -
│ │ │ │ -
444 struct IsType
│ │ │ │ -
445 {
│ │ │ │ -
447 template<class U>
│ │ │ │ -
448 struct Predicate : public std::is_same<T, U> {};
│ │ │ │ -
449 };
│ │ │ │ -
│ │ │ │ -
450
│ │ │ │ -
464 template<class Tuple, class T, std::size_t start = 0>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
466 public FirstPredicateIndex<Tuple, IsType<T>::template Predicate, start>
│ │ │ │ -
467 { };
│ │ │ │ -
│ │ │ │ -
468
│ │ │ │ -
475 template<class Tuple, class T>
│ │ │ │ - │ │ │ │ -
477
│ │ │ │ -
478 template<class... Args, class T>
│ │ │ │ -
│ │ │ │ -
479 struct PushBackTuple<typename std::tuple<Args...>, T>
│ │ │ │ -
480 {
│ │ │ │ -
481 typedef typename std::tuple<Args..., T> type;
│ │ │ │ -
482 };
│ │ │ │ -
│ │ │ │ -
483
│ │ │ │ -
490 template<class Tuple, class T>
│ │ │ │ - │ │ │ │ -
492
│ │ │ │ -
493 template<class... Args, class T>
│ │ │ │ -
│ │ │ │ -
494 struct PushFrontTuple<typename std::tuple<Args...>, T>
│ │ │ │ -
495 {
│ │ │ │ -
496 typedef typename std::tuple<T, Args...> type;
│ │ │ │ -
497 };
│ │ │ │ -
│ │ │ │ -
498
│ │ │ │ -
511 template<
│ │ │ │ -
512 template <class, class> class F,
│ │ │ │ -
513 class Tuple,
│ │ │ │ -
514 class Seed=std::tuple<>,
│ │ │ │ -
515 int N=std::tuple_size<Tuple>::value>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
517 {
│ │ │ │ -
518 typedef typename ReduceTuple<F, Tuple, Seed, N-1>::type Accumulated;
│ │ │ │ -
519 typedef typename std::tuple_element<N-1, Tuple>::type Value;
│ │ │ │ -
520
│ │ │ │ -
522 typedef typename F<Accumulated, Value>::type type;
│ │ │ │ -
523 };
│ │ │ │ -
│ │ │ │ -
524
│ │ │ │ -
535 template<
│ │ │ │ -
536 template <class, class> class F,
│ │ │ │ -
537 class Tuple,
│ │ │ │ -
538 class Seed>
│ │ │ │ -
│ │ │ │ -
539 struct ReduceTuple<F, Tuple, Seed, 0>
│ │ │ │ -
540 {
│ │ │ │ -
542 typedef Seed type;
│ │ │ │ -
543 };
│ │ │ │ +
413 struct const_reference< BitSetVectorReference<block_size,Alloc> >
│ │ │ │ +
414 {
│ │ │ │ + │ │ │ │ +
416 };
│ │ │ │ +
│ │ │ │ +
417
│ │ │ │ +
418 template<int block_size, class Alloc>
│ │ │ │ +
│ │ │ │ +
419 struct const_reference< BitSetVectorConstReference<block_size,Alloc> >
│ │ │ │ +
420 {
│ │ │ │ + │ │ │ │ +
422 };
│ │ │ │ +
│ │ │ │ +
423
│ │ │ │ +
424 template<int block_size, class Alloc>
│ │ │ │ +
│ │ │ │ +
425 struct mutable_reference< BitSetVectorReference<block_size,Alloc> >
│ │ │ │ +
426 {
│ │ │ │ + │ │ │ │ +
428 };
│ │ │ │ +
│ │ │ │ +
429
│ │ │ │ +
430 template<int block_size, class Alloc>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
432 {
│ │ │ │ + │ │ │ │ +
434 };
│ │ │ │ +
│ │ │ │ +
435
│ │ │ │ +
439 template <int block_size, class Allocator=std::allocator<bool> >
│ │ │ │ +
│ │ │ │ +
440 class BitSetVector : private std::vector<bool, Allocator>
│ │ │ │ +
441 {
│ │ │ │ +
443 typedef std::vector<bool, Allocator> BlocklessBaseClass;
│ │ │ │ +
444
│ │ │ │ +
445 public:
│ │ │ │ +
448
│ │ │ │ +
450 typedef std::bitset<block_size> value_type;
│ │ │ │ +
451
│ │ │ │ + │ │ │ │ +
454
│ │ │ │ + │ │ │ │ +
457
│ │ │ │ + │ │ │ │ +
460
│ │ │ │ + │ │ │ │ +
463
│ │ │ │ +
465 typedef typename std::vector<bool, Allocator>::size_type size_type;
│ │ │ │ +
466
│ │ │ │ +
468 typedef Allocator allocator_type;
│ │ │ │ +
470
│ │ │ │ + │ │ │ │ + │ │ │ │ +
476
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
479 return iterator(*this, 0);
│ │ │ │ +
480 }
│ │ │ │ +
│ │ │ │ +
481
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
484 return const_iterator(*this, 0);
│ │ │ │ +
485 }
│ │ │ │ +
│ │ │ │ +
486
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
489 return iterator(*this, size());
│ │ │ │ +
490 }
│ │ │ │ +
│ │ │ │ +
491
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
494 return const_iterator(*this, size());
│ │ │ │ +
495 }
│ │ │ │ +
│ │ │ │ +
496
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
499 BlocklessBaseClass()
│ │ │ │ +
500 {}
│ │ │ │ +
│ │ │ │ +
501
│ │ │ │ +
│ │ │ │ +
503 BitSetVector(const BlocklessBaseClass& blocklessBitField) :
│ │ │ │ +
504 BlocklessBaseClass(blocklessBitField)
│ │ │ │ +
505 {
│ │ │ │ +
506 if (blocklessBitField.size()%block_size != 0)
│ │ │ │ +
507 DUNE_THROW(RangeError, "Vector size is not a multiple of the block size!");
│ │ │ │ +
508 }
│ │ │ │ +
│ │ │ │ +
509
│ │ │ │ +
│ │ │ │ +
513 explicit BitSetVector(int n) :
│ │ │ │ +
514 BlocklessBaseClass(n*block_size)
│ │ │ │ +
515 {}
│ │ │ │ +
│ │ │ │ +
516
│ │ │ │ +
│ │ │ │ +
518 BitSetVector(int n, bool v) :
│ │ │ │ +
519 BlocklessBaseClass(n*block_size,v)
│ │ │ │ +
520 {}
│ │ │ │ +
│ │ │ │ +
521
│ │ │ │ +
│ │ │ │ +
523 void clear()
│ │ │ │ +
524 {
│ │ │ │ +
525 BlocklessBaseClass::clear();
│ │ │ │ +
526 }
│ │ │ │ +
│ │ │ │ +
527
│ │ │ │ +
│ │ │ │ +
529 void resize(int n, bool v = bool())
│ │ │ │ +
530 {
│ │ │ │ +
531 BlocklessBaseClass::resize(n*block_size, v);
│ │ │ │ +
532 }
│ │ │ │ +
│ │ │ │ +
533
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
536 {
│ │ │ │ +
537 return BlocklessBaseClass::size()/block_size;
│ │ │ │ +
538 }
│ │ │ │ +
│ │ │ │ +
539
│ │ │ │ +
│ │ │ │ +
541 void setAll() {
│ │ │ │ +
542 this->assign(BlocklessBaseClass::size(), true);
│ │ │ │ +
543 }
│ │ │ │
│ │ │ │
544
│ │ │ │ -
554 template<class Head, class Tail>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
556 {
│ │ │ │ - │ │ │ │ -
559 };
│ │ │ │ -
│ │ │ │ -
560
│ │ │ │ -
569 template<class Tuple>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
571 {
│ │ │ │ - │ │ │ │ -
574 };
│ │ │ │ -
│ │ │ │ -
575
│ │ │ │ -
577}
│ │ │ │ -
578
│ │ │ │ -
579#endif
│ │ │ │ - │ │ │ │ -
Traits for type conversions and type information.
│ │ │ │ -
std::add_const< T >::type & ConstType
Definition tupleutility.hh:50
│ │ │ │ -
static void apply(std::tuple< Ts... > &t)
Definition tupleutility.hh:382
│ │ │ │ -
T * ParameterType
Definition tupleutility.hh:60
│ │ │ │ -
auto transformTuple(Tuple &&orig, Args &&... args) -> decltype(genericTransformTuple(orig, makeTransformTupleFunctor< TypeEvaluator >(args...)))
Definition tupleutility.hh:292
│ │ │ │ -
T & ConstType
Definition tupleutility.hh:66
│ │ │ │ -
ReduceTuple< F, Tuple, Seed, N-1 >::type Accumulated
Definition tupleutility.hh:518
│ │ │ │ -
T * NonConstType
Definition tupleutility.hh:59
│ │ │ │ -
Seed type
Result of the reduce operation.
Definition tupleutility.hh:542
│ │ │ │ -
std::remove_reference< T >::type * Type
Definition tupleutility.hh:321
│ │ │ │ -
static Type apply(T &t)
Definition tupleutility.hh:307
│ │ │ │ -
static ResultType apply()
Definition tupleutility.hh:85
│ │ │ │ -
std::tuple< Args... > ResultType
Definition tupleutility.hh:84
│ │ │ │ -
std::remove_reference< T >::type * Type
Definition tupleutility.hh:332
│ │ │ │ -
TransformTupleFunctor(Args &&... args)
Definition tupleutility.hh:241
│ │ │ │ -
std::tuple_element< std::tuple_size< Tuple >::value-N-1, Tuple >::type Type
Definition tupleutility.hh:347
│ │ │ │ -
static Type apply(T &t)
Definition tupleutility.hh:333
│ │ │ │ -
auto operator()(T &&t) -> decltype(this->apply(t, std::index_sequence_for< Args... >{})) const
Definition tupleutility.hh:246
│ │ │ │ -
T & NonConstType
Definition tupleutility.hh:67
│ │ │ │ -
T & NonConstType
Definition tupleutility.hh:51
│ │ │ │ -
static TupleAccessTraits< typenameAtType< N, Tuple >::Type >::ConstType get(const Tuple &t)
Definition tupleutility.hh:369
│ │ │ │ -
T & Type
Definition tupleutility.hh:306
│ │ │ │ -
static TupleAccessTraits< typenameAtType< N, Tuple >::Type >::NonConstType get(Tuple &t)
Definition tupleutility.hh:362
│ │ │ │ -
std::tuple< Args..., T > type
Definition tupleutility.hh:481
│ │ │ │ -
std::tuple_element< N-1, Tuple >::type Value
Definition tupleutility.hh:519
│ │ │ │ -
std::tuple< T, Args... > type
Definition tupleutility.hh:496
│ │ │ │ -
ReduceTuple< JoinTuples, Tuple >::type type
Result of the flatten operation.
Definition tupleutility.hh:573
│ │ │ │ -
static Type apply(T &t)
Definition tupleutility.hh:322
│ │ │ │ -
F< Accumulated, Value >::type type
Result of the reduce operation.
Definition tupleutility.hh:522
│ │ │ │ -
ReduceTuple< PushBackTuple, Tail, Head >::type type
Result of the join operation.
Definition tupleutility.hh:558
│ │ │ │ -
std::tuple< typename TE< Args >::Type... > Type
Definition tupleutility.hh:121
│ │ │ │ -
auto genericTransformTuple(Tuple &&t, Functor &&f) -> decltype(genericTransformTupleBackend(t, f))
Definition tupleutility.hh:186
│ │ │ │ -
decltype(auto) applyPartial(F &&f, ArgTuple &&args, std::integer_sequence< I, i... >)
Apply function with arguments from a given tuple.
Definition tupleutility.hh:42
│ │ │ │ -
T & ParameterType
Definition tupleutility.hh:68
│ │ │ │ -
const std::remove_const< T >::type & ParameterType
Definition tupleutility.hh:52
│ │ │ │ -
std::add_const< T >::type * ConstType
Definition tupleutility.hh:58
│ │ │ │ -
TransformTupleFunctor< TE, Args... > makeTransformTupleFunctor(Args &&... args)
Definition tupleutility.hh:254
│ │ │ │ -
constexpr void forEach(Range &&range, F &&f)
Range based for loop.
Definition hybridutilities.hh:256
│ │ │ │ -
STL namespace.
│ │ │ │ +
│ │ │ │ +
546 void unsetAll() {
│ │ │ │ +
547 this->assign(BlocklessBaseClass::size(), false);
│ │ │ │ +
548 }
│ │ │ │ +
│ │ │ │ +
549
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
552 {
│ │ │ │ +
553 return reference(*this, i);
│ │ │ │ +
554 }
│ │ │ │ +
│ │ │ │ +
555
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
558 {
│ │ │ │ +
559 return const_reference(*this, i);
│ │ │ │ +
560 }
│ │ │ │ +
│ │ │ │ +
561
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
564 {
│ │ │ │ +
565 return reference(*this, size()-1);
│ │ │ │ +
566 }
│ │ │ │ +
│ │ │ │ +
567
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
570 {
│ │ │ │ +
571 return const_reference(*this, size()-1);
│ │ │ │ +
572 }
│ │ │ │ +
│ │ │ │ +
573
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
576 {
│ │ │ │ +
577 return std::count(BlocklessBaseClass::begin(), BlocklessBaseClass::end(), true);
│ │ │ │ +
578 }
│ │ │ │ +
│ │ │ │ +
579
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
582 {
│ │ │ │ +
583 size_type n = 0;
│ │ │ │ +
584 size_type blocks = size();
│ │ │ │ +
585 for(size_type i=0; i<blocks; ++i)
│ │ │ │ +
586 n += getBit(i,j);
│ │ │ │ +
587 return n;
│ │ │ │ +
588 }
│ │ │ │ +
│ │ │ │ +
589
│ │ │ │ +
│ │ │ │ +
591 friend std::ostream& operator<< (std::ostream& s, const BitSetVector& v)
│ │ │ │ +
592 {
│ │ │ │ +
593 for (size_t i=0; i<v.size(); i++)
│ │ │ │ +
594 s << v[i] << " ";
│ │ │ │ +
595 return s;
│ │ │ │ +
596 }
│ │ │ │ +
│ │ │ │ +
597
│ │ │ │ +
598 private:
│ │ │ │ +
599
│ │ │ │ +
601 value_type getRepr(int i) const
│ │ │ │ +
602 {
│ │ │ │ +
603 value_type bits;
│ │ │ │ +
604 for(int j=0; j<block_size; ++j)
│ │ │ │ +
605 bits.set(j, getBit(i,j));
│ │ │ │ +
606 return bits;
│ │ │ │ +
607 }
│ │ │ │ +
608
│ │ │ │ +
609 typename std::vector<bool>::reference getBit(size_type i, size_type j) {
│ │ │ │ +
610 DUNE_ASSERT_BOUNDS(j < block_size);
│ │ │ │ + │ │ │ │ +
612 return BlocklessBaseClass::operator[](i*block_size+j);
│ │ │ │ +
613 }
│ │ │ │ +
614
│ │ │ │ +
615 typename std::vector<bool>::const_reference getBit(size_type i, size_type j) const {
│ │ │ │ +
616 DUNE_ASSERT_BOUNDS(j < block_size);
│ │ │ │ + │ │ │ │ +
618 return BlocklessBaseClass::operator[](i*block_size+j);
│ │ │ │ +
619 }
│ │ │ │ +
620
│ │ │ │ +
621 friend class BitSetVectorReference<block_size,Allocator>;
│ │ │ │ +
622 friend class BitSetVectorConstReference<block_size,Allocator>;
│ │ │ │ +
623 };
│ │ │ │ +
│ │ │ │ +
624
│ │ │ │ +
625} // namespace Dune
│ │ │ │ +
626
│ │ │ │ +
627#endif
│ │ │ │ +
A few common exception classes.
│ │ │ │ +
Implements a generic iterator class for writing stl conformant iterators.
│ │ │ │ +
Macro for wrapping boundary checks.
│ │ │ │ +
#define DUNE_ASSERT_BOUNDS(cond)
If DUNE_CHECK_BOUNDS is defined: check if condition cond holds; otherwise, do nothing.
Definition boundschecking.hh:30
│ │ │ │ +
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition integersequence.hh:75
│ │ │ │ -
Definition tupleutility.hh:49
│ │ │ │ -
A helper template that initializes a std::tuple consisting of pointers to nullptr.
Definition tupleutility.hh:79
│ │ │ │ -
Helper template to clone the type definition of a std::tuple with the storage types replaced by a use...
Definition tupleutility.hh:116
│ │ │ │ -
Definition tupleutility.hh:226
│ │ │ │ -
Definition tupleutility.hh:239
│ │ │ │ -
TypeEvaluator to turn a type T into a reference to T
Definition tupleutility.hh:305
│ │ │ │ -
TypeEvaluator to turn a type T into a pointer to T
Definition tupleutility.hh:320
│ │ │ │ -
Type for reverse element access.
Definition tupleutility.hh:346
│ │ │ │ -
Reverse element access.
Definition tupleutility.hh:359
│ │ │ │ -
Deletes all objects pointed to in a std::tuple of pointers.
Definition tupleutility.hh:380
│ │ │ │ -
Finding the index of a certain type in a std::tuple.
Definition tupleutility.hh:418
│ │ │ │ -
Generator for predicates accepting one particular type.
Definition tupleutility.hh:445
│ │ │ │ -
The actual predicate.
Definition tupleutility.hh:448
│ │ │ │ -
Find the first occurrence of a type in a std::tuple.
Definition tupleutility.hh:467
│ │ │ │ -
Helper template to append a type to a std::tuple.
Definition tupleutility.hh:476
│ │ │ │ -
Helper template to prepend a type to a std::tuple.
Definition tupleutility.hh:491
│ │ │ │ -
Apply reduce with meta binary function to template.
Definition tupleutility.hh:517
│ │ │ │ -
Join two std::tuple's.
Definition tupleutility.hh:556
│ │ │ │ -
Flatten a std::tuple of std::tuple's.
Definition tupleutility.hh:571
│ │ │ │ -
template which always yields a false value
Definition typetraits.hh:124
│ │ │ │ +
void assign(T &dst, const T &src, bool mask)
masked Simd assignment (scalar version)
Definition simd.hh:447
│ │ │ │ +
A dynamic array of blocks of booleans.
Definition bitsetvector.hh:441
│ │ │ │ +
const_reference operator[](int i) const
Return const reference to i-th block.
Definition bitsetvector.hh:557
│ │ │ │ +
iterator begin()
Returns a iterator pointing to the beginning of the vector.
Definition bitsetvector.hh:478
│ │ │ │ +
BitSetVectorConstReference< block_size, Allocator > * const_pointer
Const pointer to a small block of bits.
Definition bitsetvector.hh:462
│ │ │ │ +
const_iterator end() const
Returns a const_iterator pointing to the end of the vector.
Definition bitsetvector.hh:493
│ │ │ │ +
BitSetVectorReference< block_size, Allocator > reference
Reference to a small block of bits.
Definition bitsetvector.hh:453
│ │ │ │ +
size_type countmasked(int j) const
Returns the number of set bits, while each block is masked with 1<<i.
Definition bitsetvector.hh:581
│ │ │ │ +
BitSetVectorConstReference< block_size, Allocator > const_reference
Const reference to a small block of bits.
Definition bitsetvector.hh:456
│ │ │ │ +
iterator end()
Returns an iterator pointing to the end of the vector.
Definition bitsetvector.hh:488
│ │ │ │ +
size_type count() const
Returns the number of bits that are set.
Definition bitsetvector.hh:575
│ │ │ │ +
BitSetVector()
Default constructor.
Definition bitsetvector.hh:498
│ │ │ │ +
void setAll()
Sets all entries to true
Definition bitsetvector.hh:541
│ │ │ │ +
Dune::GenericIterator< const BitSetVector< block_size, Allocator >, const value_type, const_reference, std::ptrdiff_t, ForwardIteratorFacade > const_iterator
Definition bitsetvector.hh:474
│ │ │ │ +
std::bitset< block_size > value_type
Type of the values stored by the container.
Definition bitsetvector.hh:450
│ │ │ │ +
reference back()
Return reference to last block.
Definition bitsetvector.hh:563
│ │ │ │ +
BitSetVector(const BlocklessBaseClass &blocklessBitField)
Construction from an unblocked bitfield.
Definition bitsetvector.hh:503
│ │ │ │ +
friend std::ostream & operator<<(std::ostream &s, const BitSetVector &v)
Send bitfield to an output stream.
Definition bitsetvector.hh:591
│ │ │ │ +
const_reference back() const
Return const reference to last block.
Definition bitsetvector.hh:569
│ │ │ │ +
void clear()
Erases all of the elements.
Definition bitsetvector.hh:523
│ │ │ │ +
BitSetVectorReference< block_size, Allocator > * pointer
Pointer to a small block of bits.
Definition bitsetvector.hh:459
│ │ │ │ +
reference operator[](int i)
Return reference to i-th block.
Definition bitsetvector.hh:551
│ │ │ │ +
size_type size() const
Return the number of blocks.
Definition bitsetvector.hh:535
│ │ │ │ +
std::vector< bool, Allocator >::size_type size_type
size type
Definition bitsetvector.hh:465
│ │ │ │ +
BitSetVector(int n, bool v)
Constructor which initializes the field with true or false.
Definition bitsetvector.hh:518
│ │ │ │ +
const_iterator begin() const
Returns a const_iterator pointing to the beginning of the vector.
Definition bitsetvector.hh:483
│ │ │ │ +
Dune::GenericIterator< BitSetVector< block_size, Allocator >, value_type, reference, std::ptrdiff_t, ForwardIteratorFacade > iterator
Definition bitsetvector.hh:473
│ │ │ │ +
void resize(int n, bool v=bool())
Resize field.
Definition bitsetvector.hh:529
│ │ │ │ +
Allocator allocator_type
The type of the allocator.
Definition bitsetvector.hh:468
│ │ │ │ +
BitSetVector(int n)
Definition bitsetvector.hh:513
│ │ │ │ +
void unsetAll()
Sets all entries to false
Definition bitsetvector.hh:546
│ │ │ │ +
A proxy class that acts as a mutable reference to a single bitset in a BitSetVector.
Definition bitsetvector.hh:222
│ │ │ │ +
bool test(size_type n) const
Returns true if bit n is set.
Definition bitsetvector.hh:124
│ │ │ │ +
BitSetVectorReference & operator=(const BitSetVectorConstReference &b)
Assignment from BitSetVectorConstReference.
Definition bitsetvector.hh:266
│ │ │ │ +
reference operator[](size_type i)
Return reference to the i-th bit.
Definition bitsetvector.hh:393
│ │ │ │ +
BitSetVectorReference & reset(size_type n)
Clears bit n.
Definition bitsetvector.hh:376
│ │ │ │ +
BitSetVectorReference & operator<<=(size_type n)
Left shift.
Definition bitsetvector.hh:330
│ │ │ │ +
Dune::BitSetVector< block_size, Alloc > BitSetVector
Definition bitsetvector.hh:225
│ │ │ │ +
std::vector< bool, Alloc >::const_reference const_reference
A proxy class that acts as a const reference to a single bit.
Definition bitsetvector.hh:243
│ │ │ │ +
BitSetVectorReference & operator=(const BitSetVectorReference &b)
Assignment from BitSetVectorReference.
Definition bitsetvector.hh:274
│ │ │ │ +
reference getBit(size_type i)
Definition bitsetvector.hh:403
│ │ │ │ +
BitSetVectorReference & operator&=(const BitSetVectorConstReference &x)
Bitwise and (for BitSetVectorConstReference and BitSetVectorReference)
Definition bitsetvector.hh:290
│ │ │ │ +
BitSetVectorReference(BitSetVector &blockBitField_, int block_number_)
Definition bitsetvector.hh:230
│ │ │ │ +
size_t size_type
size_type typedef (an unsigned integral type)
Definition bitsetvector.hh:247
│ │ │ │ +
BitSetVectorReference & operator=(const bitset &b)
Assignment from bitset.
Definition bitsetvector.hh:258
│ │ │ │ +
Dune::BitSetVectorConstReference< block_size, Alloc > BitSetVectorConstReference
Definition bitsetvector.hh:228
│ │ │ │ +
BitSetVectorReference & reset()
Clears every bit.
Definition bitsetvector.hh:362
│ │ │ │ +
BitSetVector & blockBitField
Definition bitsetvector.hh:399
│ │ │ │ +
BitSetVectorReference & operator|=(const BitSetVectorConstReference &x)
Bitwise inclusive or (for BitSetVectorConstReference and BitSetVectorReference)
Definition bitsetvector.hh:306
│ │ │ │ +
BitSetVectorReference & set(size_type n, int val=1)
Sets bit n if val is nonzero, and clears bit n if val is zero.
Definition bitsetvector.hh:369
│ │ │ │ +
std::bitset< block_size > bitset
Definition bitsetvector.hh:236
│ │ │ │ +
BitSetVectorReference & operator^=(const bitset &x)
Bitwise exclusive or (for bitset).
Definition bitsetvector.hh:314
│ │ │ │ +
std::vector< bool, Alloc >::reference reference
Definition bitsetvector.hh:241
│ │ │ │ +
BitSetVectorReference & operator|=(const bitset &x)
Bitwise inclusive or (for bitset)
Definition bitsetvector.hh:298
│ │ │ │ +
BitSetVectorReference & operator>>=(size_type n)
Right shift.
Definition bitsetvector.hh:338
│ │ │ │ +
BitSetVectorReference & operator^=(const BitSetVectorConstReference &x)
Bitwise exclusive or (for BitSetVectorConstReference and BitSetVectorReference)
Definition bitsetvector.hh:322
│ │ │ │ +
BitSetVectorReference & flip(size_type n)
Flips bit n.
Definition bitsetvector.hh:383
│ │ │ │ +
BitSetVectorReference & flip()
Flips the value of every bit.
Definition bitsetvector.hh:354
│ │ │ │ +
BitSetVectorReference & set()
Sets every bit.
Definition bitsetvector.hh:346
│ │ │ │ +
BitSetVectorReference & operator&=(const bitset &x)
Bitwise and (for bitset).
Definition bitsetvector.hh:282
│ │ │ │ +
BitSetVectorReference & operator=(bool b)
Assignment from bool, sets each bit in the bitset to b.
Definition bitsetvector.hh:250
│ │ │ │ +
A proxy class that acts as a const reference to a single bitset in a BitSetVector.
Definition bitsetvector.hh:38
│ │ │ │ +
bool operator==(const bitset &bs) const
Equality of reference and std::bitset.
Definition bitsetvector.hh:142
│ │ │ │ +
bool test(size_type n) const
Returns true if bit n is set.
Definition bitsetvector.hh:124
│ │ │ │ +
const_reference operator[](size_type i) const
Return reference to the i-th bit.
Definition bitsetvector.hh:130
│ │ │ │ +
bitset operator<<(size_type n) const
Returns a copy of *this shifted left by n bits.
Definition bitsetvector.hh:64
│ │ │ │ +
BitSetVectorConstReference(const BitSetVector &blockBitField_, int block_number_)
Definition bitsetvector.hh:44
│ │ │ │ +
const BitSetVector & blockBitField
Definition bitsetvector.hh:181
│ │ │ │ +
bitset operator>>(size_type n) const
Returns a copy of *this shifted right by n bits.
Definition bitsetvector.hh:72
│ │ │ │ +
const_reference getBit(size_type i) const
Definition bitsetvector.hh:184
│ │ │ │ +
bool operator!=(const bitset &bs) const
Inequality of reference and std::bitset.
Definition bitsetvector.hh:154
│ │ │ │ +
bool equals(const BS &bs) const
Definition bitsetvector.hh:190
│ │ │ │ +
Dune::BitSetVector< block_size, Alloc > BitSetVector
Definition bitsetvector.hh:41
│ │ │ │ +
std::bitset< block_size > bitset
Definition bitsetvector.hh:56
│ │ │ │ +
bool all() const
Returns true if all bits are set.
Definition bitsetvector.hh:115
│ │ │ │ +
size_t size_type
Definition bitsetvector.hh:61
│ │ │ │ +
bitset operator~() const
Returns a copy of *this with all of its bits flipped.
Definition bitsetvector.hh:80
│ │ │ │ +
std::vector< bool, Alloc >::const_reference reference
Definition bitsetvector.hh:59
│ │ │ │ +
size_type size() const
Returns block_size.
Definition bitsetvector.hh:88
│ │ │ │ +
size_type count() const
Returns the number of bits that are set.
Definition bitsetvector.hh:94
│ │ │ │ +
bool none() const
Returns true if no bits are set.
Definition bitsetvector.hh:109
│ │ │ │ +
bool any() const
Returns true if any bits are set.
Definition bitsetvector.hh:103
│ │ │ │ +
int block_number
Definition bitsetvector.hh:182
│ │ │ │ +
std::vector< bool, Alloc >::const_reference const_reference
Definition bitsetvector.hh:60
│ │ │ │ +
BitSetVectorConstReference & operator=(const BitSetVectorConstReference &b)=delete
disable assignment operator
│ │ │ │ +
friend std::ostream & operator<<(std::ostream &s, const BitSetVectorConstReference &v)
Definition bitsetvector.hh:171
│ │ │ │ +
BitSetVectorConstReference< block_size, Alloc > type
Definition bitsetvector.hh:415
│ │ │ │ +
BitSetVectorConstReference< block_size, Alloc > type
Definition bitsetvector.hh:421
│ │ │ │ +
BitSetVectorReference< block_size, Alloc > type
Definition bitsetvector.hh:427
│ │ │ │ +
BitSetVectorReference< block_size, Alloc > type
Definition bitsetvector.hh:433
│ │ │ │ +
Default exception class for range errors.
Definition exceptions.hh:254
│ │ │ │ +
Get the 'const' version of a reference to a mutable object.
Definition genericiterator.hh:87
│ │ │ │ +
get the 'mutable' version of a reference to a const object
Definition genericiterator.hh:116
│ │ │ │ +
Generic class for stl-conforming iterators for container classes with operator[].
Definition genericiterator.hh:153
│ │ │ │ +
Base class for stl conformant forward iterators.
Definition iteratorfacades.hh:142
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,520 +1,903 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -tupleutility.hh │ │ │ │ │ +bitsetvector.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5 │ │ │ │ │ -6#ifndef DUNE_TUPLE_UTILITY_HH │ │ │ │ │ -7#define DUNE_TUPLE_UTILITY_HH │ │ │ │ │ -8 │ │ │ │ │ -9#include │ │ │ │ │ -10#include │ │ │ │ │ -11#include │ │ │ │ │ -12#include │ │ │ │ │ -13 │ │ │ │ │ -14#include │ │ │ │ │ -15#include │ │ │ │ │ +5#ifndef DUNE_BLOCK_BITFIELD_HH │ │ │ │ │ +6#define DUNE_BLOCK_BITFIELD_HH │ │ │ │ │ +7 │ │ │ │ │ +12#include │ │ │ │ │ +13#include │ │ │ │ │ +14#include │ │ │ │ │ +15#include │ │ │ │ │ 16 │ │ │ │ │ -17namespace Dune { │ │ │ │ │ -18 │ │ │ │ │ -41 template │ │ │ │ │ -42 decltype(auto) applyPartial(F&& f, ArgTuple&& args, std::integer_sequence /*indices*/) │ │ │ │ │ -43 { │ │ │ │ │ -44 return f(std::get(args)...); │ │ │ │ │ -45 } │ │ │ │ │ -46 │ │ │ │ │ -47 template │ │ │ │ │ -48 struct TupleAccessTraits │ │ │ │ │ -49 { │ │ │ │ │ -50 typedef typename std::add_const::type& ConstType; │ │ │ │ │ -51 typedef T& NonConstType; │ │ │ │ │ -52 typedef const typename std::remove_const::type& ParameterType; │ │ │ │ │ -53 }; │ │ │ │ │ -54 │ │ │ │ │ -55 template │ │ │ │ │ -56 struct TupleAccessTraits │ │ │ │ │ -57 { │ │ │ │ │ -58 typedef typename std::add_const::type* ConstType; │ │ │ │ │ -59 typedef T* NonConstType; │ │ │ │ │ -60 typedef T* ParameterType; │ │ │ │ │ -61 }; │ │ │ │ │ +17#include │ │ │ │ │ +18#include │ │ │ │ │ +19#include │ │ │ │ │ +20 │ │ │ │ │ +21namespace Dune { │ │ │ │ │ +22 │ │ │ │ │ +23 template class BitSetVector; │ │ │ │ │ +24 template class BitSetVectorReference; │ │ │ │ │ +25 │ │ │ │ │ +36 template │ │ │ │ │ +37 class BitSetVectorConstReference │ │ │ │ │ +38 { │ │ │ │ │ +39 protected: │ │ │ │ │ +40 │ │ │ │ │ +41 typedef Dune::BitSetVector BitSetVector; │ │ │ │ │ +42 friend class Dune::BitSetVector; │ │ │ │ │ +43 │ │ │ │ │ +44 BitSetVectorConstReference(const BitSetVector& blockBitField_, int block_ │ │ │ │ │ +number_) : │ │ │ │ │ +45 blockBitField(blockBitField_), │ │ │ │ │ +46 block_number(block_number_) │ │ │ │ │ +47 { │ │ │ │ │ +48 DUNE_ASSERT_BOUNDS(blockBitField_.size() > static_cast(block_number_ │ │ │ │ │ +)); │ │ │ │ │ +49 } │ │ │ │ │ +50 │ │ │ │ │ +52 BitSetVectorConstReference& operator=(const BitSetVectorConstReference & b) │ │ │ │ │ += delete; │ │ │ │ │ +53 │ │ │ │ │ +54 public: │ │ │ │ │ +55 │ │ │ │ │ +56 typedef std::bitset bitset; │ │ │ │ │ +57 │ │ │ │ │ +58 // bitset interface typedefs │ │ │ │ │ +59 typedef typename std::vector::const_reference reference; │ │ │ │ │ +60 typedef typename std::vector::const_reference const_reference; │ │ │ │ │ +61 typedef size_t size_type; │ │ │ │ │ 62 │ │ │ │ │ -63 template │ │ │ │ │ -64 struct TupleAccessTraits │ │ │ │ │ +64 bitset operator<<(size_type n) const │ │ │ │ │ 65 { │ │ │ │ │ -66 typedef T& ConstType; │ │ │ │ │ -67 typedef T& NonConstType; │ │ │ │ │ -68 typedef T& ParameterType; │ │ │ │ │ -69 }; │ │ │ │ │ +66 bitset b = *this; │ │ │ │ │ +67 b <<= n; │ │ │ │ │ +68 return b; │ │ │ │ │ +69 } │ │ │ │ │ 70 │ │ │ │ │ -78 template │ │ │ │ │ -79 struct NullPointerInitialiser; │ │ │ │ │ -80 │ │ │ │ │ -81 template │ │ │ │ │ -82 struct NullPointerInitialiser > │ │ │ │ │ -83 { │ │ │ │ │ -84 typedef std::tuple ResultType; │ │ │ │ │ -85 static ResultType apply() │ │ │ │ │ -86 { │ │ │ │ │ -87 return ResultType(static_cast(nullptr)...); │ │ │ │ │ -88 } │ │ │ │ │ -89 }; │ │ │ │ │ -90 │ │ │ │ │ -115 template