--- /srv/reproducible-results/rbuild-debian/r-b-build.SSWuQd3L/b1/dune-common_2.9.0-6_armhf.changes +++ /srv/reproducible-results/rbuild-debian/r-b-build.SSWuQd3L/b2/dune-common_2.9.0-6_armhf.changes ├── Files │ @@ -1,4 +1,4 @@ │ │ 5174820672634c8ce597773639922877 532084 debug optional libdune-common-dev-dbgsym_2.9.0-6_armhf.deb │ c9f3ce4108cd9e6c0c48e95e4c99b59f 376224 libdevel optional libdune-common-dev_2.9.0-6_armhf.deb │ - 3bcdd2da75e80c1968d7b2f9c49c3068 3065596 doc optional libdune-common-doc_2.9.0-6_all.deb │ + 64120de434b6acd287351ecb4aeb7875 3063068 doc optional libdune-common-doc_2.9.0-6_all.deb ├── libdune-common-doc_2.9.0-6_all.deb │ ├── file list │ │ @@ -1,3 +1,3 @@ │ │ -rw-r--r-- 0 0 0 4 2023-12-26 18:41:53.000000 debian-binary │ │ --rw-r--r-- 0 0 0 26888 2023-12-26 18:41:53.000000 control.tar.xz │ │ --rw-r--r-- 0 0 0 3038516 2023-12-26 18:41:53.000000 data.tar.xz │ │ +-rw-r--r-- 0 0 0 26896 2023-12-26 18:41:53.000000 control.tar.xz │ │ +-rw-r--r-- 0 0 0 3035980 2023-12-26 18:41:53.000000 data.tar.xz │ ├── control.tar.xz │ │ ├── control.tar │ │ │ ├── ./md5sums │ │ │ │ ├── ./md5sums │ │ │ │ │┄ Files differ │ │ │ │ ├── line order │ │ │ │ │ @@ -23,14 +23,15 @@ │ │ │ │ │ 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 │ │ │ │ │ @@ -42,57 +43,56 @@ │ │ │ │ │ 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 │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00044_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00047.html │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00047_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00050.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00050_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00053.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00053_source.html │ │ │ │ │ -usr/share/doc/libdune-common-doc/doxygen/a00056.html │ │ │ │ │ -usr/share/doc/libdune-common-doc/doxygen/a00056_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00059.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00059_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00062.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00062_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00065.html │ │ │ │ │ -usr/share/doc/libdune-common-doc/doxygen/a00065_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00068.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00068_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00071.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00071_source.html │ │ │ │ │ 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 │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00101_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00104.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00104_source.html │ │ │ │ │ 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 │ │ │ │ │ @@ -105,14 +105,15 @@ │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00137_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00140.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00140_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00143.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00143_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00146.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00146_source.html │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00149.html │ │ │ │ │ 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/a00161.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00161_source.html │ │ │ │ │ @@ -139,58 +140,58 @@ │ │ │ │ │ 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/a00200_source.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 │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00227_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00230.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00230_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00233.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00233_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00236.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00236_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00239.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00239_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00242.html │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00242_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00245.html │ │ │ │ │ -usr/share/doc/libdune-common-doc/doxygen/a00245_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00248.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00248_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00251.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00251_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00254.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00254_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00257.html │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00257_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00260.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00260_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00263.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00263_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00266.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00266_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00269.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00269_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00272.html │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00272_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00275.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00275_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00278.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00278_source.html │ │ │ │ │ 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 │ │ │ │ │ @@ -198,28 +199,27 @@ │ │ │ │ │ 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 │ │ │ │ │ @@ -231,28 +231,28 @@ │ │ │ │ │ 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 │ │ │ │ │ -usr/share/doc/libdune-common-doc/doxygen/a00347_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00350.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00350_source.html │ │ │ │ │ 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 │ ├── data.tar.xz │ │ ├── data.tar │ │ │ ├── file list │ │ │ │ @@ -26,259 +26,259 @@ │ │ │ │ -rw-r--r-- 0 root (0) root (0) 2799 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/buildsystem/html/search.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 10569 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/buildsystem/html/searchindex.js │ │ │ │ -rw-r--r-- 0 root (0) root (0) 1934 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/changelog.Debian.gz │ │ │ │ -rw-r--r-- 0 root (0) root (0) 7231 2022-10-20 18:41:15.000000 ./usr/share/doc/libdune-common-doc/changelog.gz │ │ │ │ -rw-r--r-- 0 root (0) root (0) 9815 2023-01-07 21:56:09.000000 ./usr/share/doc/libdune-common-doc/copyright │ │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/ │ │ │ │ -rw-r--r-- 0 root (0) root (0) 3045 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00002.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6229 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00008.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 21246 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00008_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5049 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00011.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 23176 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00011_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 11654 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00014.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 55191 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00014_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3949 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00017.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5603 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00020.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9347 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00020_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5115 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00023.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9512 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00023_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 20708 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00026.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 66287 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00026_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7919 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00029.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 126603 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00029_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9499 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00032.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 250589 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00032_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4959 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00035.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6605 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00035_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 24718 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00038.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 121580 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00038_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6556 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00041.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 18103 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00041_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 20821 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00044.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 29928 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00044_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8394 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00047.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7494 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00050.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 31467 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00050_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6856 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00053.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 112071 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00053_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 14770 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00056.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 23217 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00056_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 45125 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00059.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 15704 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00059_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 17902 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00062.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 167223 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00062_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 13585 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00065.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 94215 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00065_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6240 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00068.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6782 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00068_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8731 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00071.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 61450 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00071_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6970 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00074.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5125 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00077.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 29707 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00077_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 17516 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00080.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 45459 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00080_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 14506 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00083.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 54081 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00083_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8196 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00086.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 148986 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00086_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5275 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00089.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 11331 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00089_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8170 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00092.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 63385 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00092_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6384 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00095.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 16097 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00095_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8690 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00098.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 15576 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00098_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9165 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00101.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5668 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00104.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10965 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00104_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5458 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00107.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8314 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00107_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7265 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00110.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 14139 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00110_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10991 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00113.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 22884 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00113_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3899 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00116.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4993 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00119.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 31445 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00119_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6176 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00122.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8812 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00122_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8828 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00125.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 15690 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00125_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6380 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00128.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 19421 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00128_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 14995 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00131.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 142940 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00131_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10469 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00134.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 33175 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00134_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6187 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00137.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 17742 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00137_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5654 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00140.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7234 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00140_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4366 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00143.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5137 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00143_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 33483 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00146.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 357109 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00146_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 13871 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00152.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 20199 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00152_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6713 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00155.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 11004 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00155_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3649 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00158.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 24039 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00161.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 42064 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00161_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 14005 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00164.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 86153 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00164_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3818 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00167.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6526 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00167_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 81300 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00170.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 145342 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00170_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9861 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00173.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 20797 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00173_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5356 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00176.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 41539 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00176_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 16771 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00179.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 48543 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00179_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5325 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00182.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10220 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00182_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7356 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00185.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9909 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00185_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9721 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00188.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 240955 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00188_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5980 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00191.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 21115 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00191_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5384 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00194.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8943 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00194_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4678 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00197.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7628 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00197_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4678 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00200.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7626 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00200_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 17652 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00203.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 42086 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00203_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4672 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00206.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6796 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00206_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5777 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00209.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10089 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00209_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3372 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00212.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 88030 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00212_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 12096 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00215.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 108064 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00215_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5043 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00218.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6951 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00218_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7124 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00221.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 23206 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00221_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 26419 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00224.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 61788 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00224_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5247 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00227.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9926 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00227_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6158 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00230.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 19960 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00230_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 21252 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00233.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 132735 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00233_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6586 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00236.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 44038 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00236_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3384 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00239.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 51921 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00239_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4748 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00242.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4394 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00245.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6435 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00245_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 13605 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00248.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 28676 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00248_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5347 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00251.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 33493 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00251_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5278 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00254.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 22235 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00254_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4979 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00257.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 19607 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00260.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 104969 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00260_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7345 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00263.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 18651 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00263_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5082 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00266.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8080 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00266_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8194 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00269.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 41231 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00269_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4128 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00272.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5767 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00275.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 16722 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00275_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4768 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00278.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 14349 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00278_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 60433 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00281.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 127266 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00281_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6807 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00284.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 12871 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00284_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8704 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00287.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 26496 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00287_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4310 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00290.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 17898 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00290_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 17882 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00293.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 79073 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00293_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4655 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00296.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7486 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00296_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5214 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00299.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 15233 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00299_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10687 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00302.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 108967 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00302_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8323 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00305.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 40740 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00305_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8836 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00308.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10533 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00308_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4125 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00311.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6781 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00314.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8264 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00314_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7783 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00317.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 12397 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00317_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6819 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00320.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 100137 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00320_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6662 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00323.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 52852 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00323_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7195 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00326.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 151469 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00326_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7721 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00329.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10469 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00329_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 14288 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00332.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 63256 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00332_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9141 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00335.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 172723 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00335_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8399 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00338.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 46563 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00338_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8766 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00341.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 71932 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00341_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9019 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00344.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 52516 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00344_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7409 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00347.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 33439 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00347_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6505 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00350.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 39913 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00350_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3649 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00353.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4983 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00353_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7592 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00356.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 136353 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00356_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6612 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00359.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 19861 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00359_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6616 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00362.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 58092 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00362_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6585 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00365.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 46321 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00365_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 23075 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00368.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5638 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00371.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 33611 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00371_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3658 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00374.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4980 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00374_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6398 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00377.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 33437 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00377_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5984 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00380.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 51317 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00380_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 13149 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00383.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 178064 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00383_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 19865 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00386.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 179606 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00386_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 11420 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00389.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 290483 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00389_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 11616 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00392.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 101374 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00392_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6612 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00008.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 19861 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00008_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6616 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00011.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 58092 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00011_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8399 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00014.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 46563 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00014_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7409 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00017.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 33439 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00017_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5638 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00020.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 33611 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00020_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 11616 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00023.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 101374 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00023_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9141 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00026.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 172723 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00026_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 19865 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00029.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 179606 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00029_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 11420 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00032.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 290483 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00032_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6505 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00035.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 39913 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00035_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6398 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00038.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 33437 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00038_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3658 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00041.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4980 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00041_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9019 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00044.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 52516 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00044_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7592 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00047.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 136353 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00047_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6585 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00050.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 46321 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00050_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 13149 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00053.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 178064 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00053_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5984 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00059.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 51317 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00059_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3649 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00062.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4983 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00062_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 23075 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00065.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8766 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00068.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 71932 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00068_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5668 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00071.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10965 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00071_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5654 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00074.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7234 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00074_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4768 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00077.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 14349 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00077_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9165 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00080.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 19607 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00083.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 104969 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00083_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4979 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00086.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10991 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00089.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 22884 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00089_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10687 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00092.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 108967 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00092_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6229 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00095.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 21246 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00095_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 11654 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00098.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 55191 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00098_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5247 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00101.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9926 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00101_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6384 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00104.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 16097 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00104_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5325 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00107.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10220 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00107_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4959 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00110.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6605 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00110_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 26419 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00113.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 61788 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00113_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10469 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00116.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 33175 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00116_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8731 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00119.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 61450 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00119_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4394 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00122.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6435 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00122_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 60433 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00125.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 127266 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00125_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8704 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00128.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 26496 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00128_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8836 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00131.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10533 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00131_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4310 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00134.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 17898 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00134_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6380 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00137.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 19421 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00137_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5125 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00140.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 29707 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00140_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9721 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00143.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 240955 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00143_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4366 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00146.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5137 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00146_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4128 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00149.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8196 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00152.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 148986 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00152_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6158 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00155.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 19960 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00155_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4748 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00158.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8828 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00161.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 15690 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00161_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6819 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00164.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 100137 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00164_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 13585 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00167.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 94215 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00167_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 20821 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00170.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 29928 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00170_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7345 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00173.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 18651 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00173_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9499 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00176.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 250589 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00176_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8170 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00179.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 63385 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00179_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3818 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00182.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6526 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00182_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5767 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00185.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 16722 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00185_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8690 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00188.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 15576 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00188_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5278 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00191.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 22235 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00191_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5115 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00194.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9512 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00194_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5214 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00197.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 15233 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00197_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 33483 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00200.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 357109 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00200_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3649 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00203.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 81300 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00206.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 145342 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00206_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9861 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00209.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 20797 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00209_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 13871 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00212.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 20199 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00212_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 14005 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00215.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 86153 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00215_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 24039 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00218.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 42064 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00218_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6713 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00221.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 11004 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00221_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6970 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00224.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7494 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00227.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 31467 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00227_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5347 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00230.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 33493 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00230_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 17882 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00233.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 79073 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00233_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6556 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00236.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 18103 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00236_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6807 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00239.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 12871 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00239_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7356 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00242.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9909 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00242_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3899 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00245.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3384 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00248.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 51921 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00248_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 13605 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00251.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 28676 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00251_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 12096 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00254.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 108064 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00254_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8323 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00257.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 40740 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00257_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6586 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00260.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 44038 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00260_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6187 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00263.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 17742 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00263_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4655 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00266.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7486 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00266_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5082 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00269.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8080 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00269_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6856 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00272.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 112071 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00272_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 24718 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00275.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 121580 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00275_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5980 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00278.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 21115 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00278_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7783 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00281.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 12397 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00281_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7919 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00284.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 126603 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00284_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 14506 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00287.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 54081 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00287_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4993 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00290.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 31445 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00290_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6176 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00293.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8812 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00293_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8394 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00296.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 14995 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00299.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 142940 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00299_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5603 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00302.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9347 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00302_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5356 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00305.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 41539 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00305_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 21252 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00308.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 132735 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00308_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 16771 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00311.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 48543 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00311_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 17902 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00314.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 167223 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00314_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4125 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00317.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3372 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00320.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 88030 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00320_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5384 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00323.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8943 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00323_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4678 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00326.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7626 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00326_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 17652 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00329.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 42086 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00329_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4678 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00332.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7628 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00332_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4672 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00335.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6796 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00335_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5777 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00338.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10089 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00338_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6240 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00341.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6782 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00341_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8194 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00344.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 41231 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00344_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3949 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00347.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5275 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00350.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 11331 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00350_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7195 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00353.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 151469 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00353_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 45125 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00356.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 15704 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00356_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 14770 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00359.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 23217 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00359_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5043 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00362.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6951 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00362_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 20708 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00365.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 66287 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00365_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 17516 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00368.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 45459 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00368_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5458 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00371.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8314 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00371_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 14288 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00374.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 63256 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00374_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6781 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00377.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8264 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00377_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7124 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00380.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 23206 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00380_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7721 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00383.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10469 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00383_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5049 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00386.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 23176 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00386_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6662 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00389.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 52852 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00389_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7265 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00392.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 14139 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00392_source.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 7897 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00395.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 5736 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00396.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 261282 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00397.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 27946 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00397.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 39665 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00398.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 2473 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00398.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 9343 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00399.html │ │ │ │ @@ -1127,15 +1127,15 @@ │ │ │ │ -rw-r--r-- 0 root (0) root (0) 5016 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/dir_ade7f944fd3a163752f5cc1af55c988a_dep.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 4572 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/dir_be46aaae597ce098e36afa8d6ef4f49b.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 2402 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/dir_be46aaae597ce098e36afa8d6ef4f49b_dep.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 48471 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/dir_e151556194dc695299293609645e9437.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 8980 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/dir_e151556194dc695299293609645e9437_dep.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 3669 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/dir_e68e8157741866f444e17edd764ebbae.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 45631 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/doxygen.css │ │ │ │ --rw-r--r-- 0 root (0) root (0) 149325 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/dune-common.tag.gz │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 149374 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/dune-common.tag.gz │ │ │ │ -rw-r--r-- 0 root (0) root (0) 7704 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/dynsections.js │ │ │ │ -rw-r--r-- 0 root (0) root (0) 51296 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/files.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 1145 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/form_0.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 1167 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/form_0_dark.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 1153 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/form_1.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 403 2023-12-26 18:41:53.000000 ./usr/share/doc/libdune-common-doc/doxygen/form_10.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 422 2023-12-26 18:41:53.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: dynmatrixev.hh File Reference │ │ │ │ +dune-common: localindex.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,51 +65,55 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ +Classes | │ │ │ │ Namespaces | │ │ │ │ -Functions
│ │ │ │ -
dynmatrixev.hh File Reference
│ │ │ │ +Enumerations
│ │ │ │ +
localindex.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

utility functions to compute eigenvalues for dense matrices. │ │ │ │ +

Provides classes for use as the local index in ParallelIndexSet. │ │ │ │ More...

│ │ │ │ -
#include <algorithm>
│ │ │ │ -#include <memory>
│ │ │ │ -#include "dynmatrix.hh"
│ │ │ │ -#include "fmatrixev.hh"
│ │ │ │ +
#include <cstddef>
│ │ │ │
│ │ │ │

Go to the source code of this file.

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

│ │ │ │ +Classes

class  Dune::LocalIndex
 An index present on the local process. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::DynamicMatrixHelp
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ -Functions

template<typename K , class C >
static void Dune::DynamicMatrixHelp::eigenValuesNonSym (const DynamicMatrix< K > &matrix, DynamicVector< C > &eigenValues, std::vector< DynamicVector< K > > *eigenVectors=nullptr)
 calculates the eigenvalues of a symmetric field matrix
 

│ │ │ │ +Enumerations

enum  Dune::LocalIndexState { Dune::VALID │ │ │ │ +, Dune::DELETED │ │ │ │ + }
 The states available for the local indices. More...
 
│ │ │ │

Detailed Description

│ │ │ │ -

utility functions to compute eigenvalues for dense matrices.

│ │ │ │ +

Provides classes for use as the local index in ParallelIndexSet.

│ │ │ │ +
Author
Markus Blatt
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,33 +6,33 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Namespaces | Functions │ │ │ │ │ -dynmatrixev.hh File Reference │ │ │ │ │ -utility functions to compute eigenvalues for dense matrices. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include "dynmatrix.hh" │ │ │ │ │ -#include "fmatrixev.hh" │ │ │ │ │ + * parallel │ │ │ │ │ +Classes | Namespaces | Enumerations │ │ │ │ │ +localindex.hh File Reference │ │ │ │ │ +Common » Parallel_Communication » Parallel_Computing_based_on_Indexsets │ │ │ │ │ +Provides classes for use as the local index in ParallelIndexSet. More... │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ + Classes │ │ │ │ │ +class  Dune::LocalIndex │ │ │ │ │ +  An index present on the local process. More... │ │ │ │ │ +  │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -namespace  Dune::DynamicMatrixHelp │ │ │ │ │ -  │ │ │ │ │ - Functions │ │ │ │ │ -template │ │ │ │ │ -static void Dune::DynamicMatrixHelp::eigenValuesNonSym (const DynamicMatrix< K │ │ │ │ │ - > &matrix, DynamicVector< C > &eigenValues, std::vector< │ │ │ │ │ - DynamicVector< K > > *eigenVectors=nullptr) │ │ │ │ │ -  calculates the eigenvalues of a symmetric field matrix │ │ │ │ │ + Enumerations │ │ │ │ │ +enum  Dune::LocalIndexState { Dune::VALID , Dune::DELETED } │ │ │ │ │ +  The states available for the local indices. More... │ │ │ │ │   │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -utility functions to compute eigenvalues for dense matrices. │ │ │ │ │ +Provides classes for use as the local index in ParallelIndexSet. │ │ │ │ │ + Author │ │ │ │ │ + Markus Blatt │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00008_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: dynmatrixev.hh Source File │ │ │ │ +dune-common: localindex.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,127 +70,117 @@ │ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
dynmatrixev.hh
│ │ │ │ +
localindex.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 (C) 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_DYNMATRIXEIGENVALUES_HH
│ │ │ │ -
6#define DUNE_DYNMATRIXEIGENVALUES_HH
│ │ │ │ -
7
│ │ │ │ -
8#include <algorithm>
│ │ │ │ -
9#include <memory>
│ │ │ │ +
5
│ │ │ │ +
6#ifndef DUNE_COMMON_LOCALINDEX_HH
│ │ │ │ +
7#define DUNE_COMMON_LOCALINDEX_HH
│ │ │ │ +
8
│ │ │ │ +
9#include <cstddef>
│ │ │ │
10
│ │ │ │ -
11#include "dynmatrix.hh"
│ │ │ │ -
12#include "fmatrixev.hh"
│ │ │ │ +
11namespace Dune
│ │ │ │ +
12{
│ │ │ │
13
│ │ │ │ -
22namespace Dune {
│ │ │ │ -
23
│ │ │ │ -
│ │ │ │ -
24 namespace DynamicMatrixHelp {
│ │ │ │ -
25
│ │ │ │ -
26#if HAVE_LAPACK
│ │ │ │ -
27 using Dune::FMatrixHelp::eigenValuesNonsymLapackCall;
│ │ │ │ -
28#endif
│ │ │ │ +
14
│ │ │ │ + │ │ │ │
29
│ │ │ │ -
38 template <typename K, class C>
│ │ │ │ -
│ │ │ │ -
39 static void eigenValuesNonSym(const DynamicMatrix<K>& matrix,
│ │ │ │ -
40 DynamicVector<C>& eigenValues,
│ │ │ │ -
41 std::vector<DynamicVector<K>>* eigenVectors = nullptr
│ │ │ │ -
42 )
│ │ │ │ -
43 {
│ │ │ │ +
30
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
35 {
│ │ │ │ +
36 public:
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
42 localIndex_(0), state_(VALID){}
│ │ │ │ +
│ │ │ │ +
43
│ │ │ │
44
│ │ │ │ -
45#if HAVE_LAPACK
│ │ │ │ -
46 {
│ │ │ │ -
47 const long int N = matrix.rows();
│ │ │ │ -
48 const char jobvl = 'n';
│ │ │ │ -
49 const char jobvr = eigenVectors ? 'v' : 'n';
│ │ │ │ -
50
│ │ │ │ -
51
│ │ │ │ -
52 // matrix to put into dgeev
│ │ │ │ -
53 auto matrixVector = std::make_unique<double[]>(N*N);
│ │ │ │ -
54
│ │ │ │ -
55 // copy matrix
│ │ │ │ -
56 int row = 0;
│ │ │ │ -
57 for(int i=0; i<N; ++i)
│ │ │ │ -
58 {
│ │ │ │ -
59 for(int j=0; j<N; ++j, ++row)
│ │ │ │ -
60 {
│ │ │ │ -
61 matrixVector[ row ] = matrix[ i ][ j ];
│ │ │ │ -
62 }
│ │ │ │ -
63 }
│ │ │ │ -
64
│ │ │ │ -
65 // working memory
│ │ │ │ -
66 auto eigenR = std::make_unique<double[]>(N);
│ │ │ │ -
67 auto eigenI = std::make_unique<double[]>(N);
│ │ │ │ +
│ │ │ │ +
49 LocalIndex(std::size_t index) :
│ │ │ │ +
50 localIndex_(index), state_(VALID){}
│ │ │ │ +
│ │ │ │ +
55 inline const std::size_t& local() const;
│ │ │ │ +
56
│ │ │ │ +
60 inline operator std::size_t() const;
│ │ │ │ +
61
│ │ │ │ +
67 inline LocalIndex& operator=(std::size_t index);
│ │ │ │
68
│ │ │ │ -
69 const long int lwork = eigenVectors ? 4*N : 3*N;
│ │ │ │ -
70 auto work = std::make_unique<double[]>(lwork);
│ │ │ │ -
71 auto vr = eigenVectors ? std::make_unique<double[]>(N*N) : std::unique_ptr<double[]>{};
│ │ │ │ -
72
│ │ │ │ -
73 // return value information
│ │ │ │ -
74 long int info = 0;
│ │ │ │ -
75
│ │ │ │ -
76 // call LAPACK routine (see fmatrixev_ext.cc)
│ │ │ │ -
77 eigenValuesNonsymLapackCall(&jobvl, &jobvr, &N, matrixVector.get(), &N,
│ │ │ │ -
78 eigenR.get(), eigenI.get(), nullptr, &N, vr.get(), &N, work.get(),
│ │ │ │ -
79 &lwork, &info);
│ │ │ │ +
73 inline LocalIndexState state() const;
│ │ │ │ +
74
│ │ │ │ +
79 inline void setState(LocalIndexState state);
│ │ │ │
80
│ │ │ │ -
81 if( info != 0 )
│ │ │ │ -
82 {
│ │ │ │ -
83 std::cerr << "For matrix " << matrix << " eigenvalue calculation failed! " << std::endl;
│ │ │ │ -
84 DUNE_THROW(InvalidStateException,"eigenValues: Eigenvalue calculation failed!");
│ │ │ │ -
85 }
│ │ │ │ -
86
│ │ │ │ -
87 eigenValues.resize(N);
│ │ │ │ -
88 for (int i=0; i<N; ++i)
│ │ │ │ -
89 eigenValues[i] = std::complex<double>(eigenR[i], eigenI[i]);
│ │ │ │ -
90
│ │ │ │ -
91 if (eigenVectors) {
│ │ │ │ -
92 eigenVectors->resize(N);
│ │ │ │ -
93 for (int i = 0; i < N; ++i) {
│ │ │ │ -
94 auto& v = (*eigenVectors)[i];
│ │ │ │ -
95 v.resize(N);
│ │ │ │ -
96 std::copy(vr.get() + N*i, vr.get() + N*(i+1), &v[0]);
│ │ │ │ -
97 }
│ │ │ │ -
98 }
│ │ │ │ -
99 }
│ │ │ │ -
100#else // #if HAVE_LAPACK
│ │ │ │ -
101 DUNE_THROW(NotImplemented,"LAPACK not found!");
│ │ │ │ -
102#endif
│ │ │ │ -
103 }
│ │ │ │ -
│ │ │ │ -
104 }
│ │ │ │ -
│ │ │ │ -
105
│ │ │ │ -
106}
│ │ │ │ -
108#endif
│ │ │ │ -
This file implements a dense matrix with dynamic numbers of rows and columns.
│ │ │ │ -
Eigenvalue computations for the FieldMatrix class.
│ │ │ │ -
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
│ │ │ │ +
81 private:
│ │ │ │ +
83 std::size_t localIndex_;
│ │ │ │ +
84
│ │ │ │ +
91 char state_;
│ │ │ │ +
92
│ │ │ │ +
93 };
│ │ │ │ +
│ │ │ │ +
94
│ │ │ │ +
95
│ │ │ │ +
96
│ │ │ │ +
│ │ │ │ +
97 inline const std::size_t& LocalIndex::local() const {
│ │ │ │ +
98 return localIndex_;
│ │ │ │ +
99 }
│ │ │ │ +
│ │ │ │ +
100
│ │ │ │ +
│ │ │ │ +
101 inline LocalIndex::operator std::size_t() const {
│ │ │ │ +
102 return localIndex_;
│ │ │ │ +
103 }
│ │ │ │ +
│ │ │ │ +
104
│ │ │ │ +
│ │ │ │ +
105 inline LocalIndex& LocalIndex::operator=(std::size_t index){
│ │ │ │ +
106 localIndex_ = index;
│ │ │ │ +
107 return *this;
│ │ │ │ +
108 }
│ │ │ │ +
│ │ │ │ +
109
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
111 return static_cast<LocalIndexState>(state_);
│ │ │ │ +
112 }
│ │ │ │ +
│ │ │ │ +
113
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
115 state_ = static_cast<char>(state);
│ │ │ │ +
116 }
│ │ │ │ +
│ │ │ │ +
117
│ │ │ │ +
120} // namespace Dune
│ │ │ │ +
121
│ │ │ │ +
122#endif
│ │ │ │ +
LocalIndexState
The states available for the local indices.
Definition localindex.hh:28
│ │ │ │ +
LocalIndex & operator=(std::size_t index)
Assign a new local index.
Definition localindex.hh:105
│ │ │ │ +
LocalIndexState state() const
Get the state.
Definition localindex.hh:110
│ │ │ │ +
const std::size_t & local() const
get the local index.
Definition localindex.hh:97
│ │ │ │ +
void setState(LocalIndexState state)
Set the state.
Definition localindex.hh:114
│ │ │ │ +
@ VALID
Definition localindex.hh:28
│ │ │ │ +
@ DELETED
Definition localindex.hh:28
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
static void eigenValuesNonSym(const DynamicMatrix< K > &matrix, DynamicVector< C > &eigenValues, std::vector< DynamicVector< K > > *eigenVectors=nullptr)
calculates the eigenvalues of a symmetric field matrix
Definition dynmatrixev.hh:39
│ │ │ │ -
constexpr size_type rows() const
number of rows
Definition densematrix.hh:709
│ │ │ │ -
Construct a matrix with a dynamic size.
Definition dynmatrix.hh:61
│ │ │ │ -
Construct a vector with a dynamic size.
Definition dynvector.hh:59
│ │ │ │ -
void resize(size_type n, value_type c=value_type())
Definition dynvector.hh:141
│ │ │ │ -
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
│ │ │ │ +
An index present on the local process.
Definition localindex.hh:35
│ │ │ │ +
LocalIndex()
Constructor. known to other processes.
Definition localindex.hh:41
│ │ │ │ +
LocalIndex(std::size_t index)
Constructor.
Definition localindex.hh:49
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,142 +7,123 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -dynmatrixev.hh │ │ │ │ │ + * parallel │ │ │ │ │ +localindex.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 (C) 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_DYNMATRIXEIGENVALUES_HH │ │ │ │ │ - 6#define DUNE_DYNMATRIXEIGENVALUES_HH │ │ │ │ │ - 7 │ │ │ │ │ - 8#include │ │ │ │ │ - 9#include │ │ │ │ │ + 5 │ │ │ │ │ + 6#ifndef DUNE_COMMON_LOCALINDEX_HH │ │ │ │ │ + 7#define DUNE_COMMON_LOCALINDEX_HH │ │ │ │ │ + 8 │ │ │ │ │ + 9#include │ │ │ │ │ 10 │ │ │ │ │ - 11#include "dynmatrix.hh" │ │ │ │ │ - 12#include "fmatrixev.hh" │ │ │ │ │ + 11namespace Dune │ │ │ │ │ + 12{ │ │ │ │ │ 13 │ │ │ │ │ - 22namespace Dune { │ │ │ │ │ - 23 │ │ │ │ │ -24 namespace DynamicMatrixHelp { │ │ │ │ │ - 25 │ │ │ │ │ - 26#if HAVE_LAPACK │ │ │ │ │ - 27 using Dune::FMatrixHelp::eigenValuesNonsymLapackCall; │ │ │ │ │ - 28#endif │ │ │ │ │ + 14 │ │ │ │ │ +28 enum LocalIndexState {VALID, DELETED}; │ │ │ │ │ 29 │ │ │ │ │ - 38 template │ │ │ │ │ -39 static void eigenValuesNonSym(const DynamicMatrix& matrix, │ │ │ │ │ - 40 DynamicVector& eigenValues, │ │ │ │ │ - 41 std::vector>* eigenVectors = nullptr │ │ │ │ │ - 42 ) │ │ │ │ │ - 43 { │ │ │ │ │ + 30 │ │ │ │ │ +34 class LocalIndex │ │ │ │ │ + 35 { │ │ │ │ │ + 36 public: │ │ │ │ │ +41 LocalIndex() : │ │ │ │ │ + 42 localIndex_(0), state_(VALID){} │ │ │ │ │ + 43 │ │ │ │ │ 44 │ │ │ │ │ - 45#if HAVE_LAPACK │ │ │ │ │ - 46 { │ │ │ │ │ - 47 const long int N = matrix.rows(); │ │ │ │ │ - 48 const char jobvl = 'n'; │ │ │ │ │ - 49 const char jobvr = eigenVectors ? 'v' : 'n'; │ │ │ │ │ - 50 │ │ │ │ │ - 51 │ │ │ │ │ - 52 // matrix to put into dgeev │ │ │ │ │ - 53 auto matrixVector = std::make_unique(N*N); │ │ │ │ │ - 54 │ │ │ │ │ - 55 // copy matrix │ │ │ │ │ - 56 int row = 0; │ │ │ │ │ - 57 for(int i=0; i(N); │ │ │ │ │ - 67 auto eigenI = std::make_unique(N); │ │ │ │ │ +49 LocalIndex(std::size_t index) : │ │ │ │ │ + 50 localIndex_(index), state_(VALID){} │ │ │ │ │ + 55 inline const std::size_t& local() const; │ │ │ │ │ + 56 │ │ │ │ │ + 60 inline operator std::size_t() const; │ │ │ │ │ + 61 │ │ │ │ │ + 67 inline LocalIndex& operator=(std::size_t index); │ │ │ │ │ 68 │ │ │ │ │ - 69 const long int lwork = eigenVectors ? 4*N : 3*N; │ │ │ │ │ - 70 auto work = std::make_unique(lwork); │ │ │ │ │ - 71 auto vr = eigenVectors ? std::make_unique(N*N) : std:: │ │ │ │ │ -unique_ptr{}; │ │ │ │ │ - 72 │ │ │ │ │ - 73 // return value information │ │ │ │ │ - 74 long int info = 0; │ │ │ │ │ - 75 │ │ │ │ │ - 76 // call LAPACK routine (see fmatrixev_ext.cc) │ │ │ │ │ - 77 eigenValuesNonsymLapackCall(&jobvl, &jobvr, &N, matrixVector.get(), &N, │ │ │ │ │ - 78 eigenR.get(), eigenI.get(), nullptr, &N, vr.get(), &N, work.get(), │ │ │ │ │ - 79 &lwork, &info); │ │ │ │ │ + 73 inline LocalIndexState state() const; │ │ │ │ │ + 74 │ │ │ │ │ + 79 inline void setState(LocalIndexState state); │ │ │ │ │ 80 │ │ │ │ │ - 81 if( info != 0 ) │ │ │ │ │ - 82 { │ │ │ │ │ - 83 std::cerr << "For matrix " << matrix << " eigenvalue calculation failed! " │ │ │ │ │ -<< std::endl; │ │ │ │ │ - 84 DUNE_THROW(InvalidStateException,"eigenValues: Eigenvalue calculation │ │ │ │ │ -failed!"); │ │ │ │ │ - 85 } │ │ │ │ │ - 86 │ │ │ │ │ - 87 eigenValues.resize(N); │ │ │ │ │ - 88 for (int i=0; i(eigenR[i], eigenI[i]); │ │ │ │ │ - 90 │ │ │ │ │ - 91 if (eigenVectors) { │ │ │ │ │ - 92 eigenVectors->resize(N); │ │ │ │ │ - 93 for (int i = 0; i < N; ++i) { │ │ │ │ │ - 94 auto& v = (*eigenVectors)[i]; │ │ │ │ │ - 95 v.resize(N); │ │ │ │ │ - 96 std::copy(vr.get() + N*i, vr.get() + N*(i+1), &v[0]); │ │ │ │ │ - 97 } │ │ │ │ │ - 98 } │ │ │ │ │ + 81 private: │ │ │ │ │ + 83 std::size_t localIndex_; │ │ │ │ │ + 84 │ │ │ │ │ + 91 char state_; │ │ │ │ │ + 92 │ │ │ │ │ + 93 }; │ │ │ │ │ + 94 │ │ │ │ │ + 95 │ │ │ │ │ + 96 │ │ │ │ │ +97 inline const std::size_t& LocalIndex::local() const { │ │ │ │ │ + 98 return localIndex_; │ │ │ │ │ 99 } │ │ │ │ │ - 100#else // #if HAVE_LAPACK │ │ │ │ │ - 101 DUNE_THROW(NotImplemented,"LAPACK not found!"); │ │ │ │ │ - 102#endif │ │ │ │ │ + 100 │ │ │ │ │ +101 inline LocalIndex::operator std::size_t() const { │ │ │ │ │ + 102 return localIndex_; │ │ │ │ │ 103 } │ │ │ │ │ - 104 } │ │ │ │ │ - 105 │ │ │ │ │ - 106} │ │ │ │ │ - 108#endif │ │ │ │ │ -dynmatrix.hh │ │ │ │ │ -This file implements a dense matrix with dynamic numbers of rows and columns. │ │ │ │ │ -fmatrixev.hh │ │ │ │ │ -Eigenvalue computations for the FieldMatrix class. │ │ │ │ │ -DUNE_THROW │ │ │ │ │ -#define DUNE_THROW(E, m) │ │ │ │ │ -Definition exceptions.hh:218 │ │ │ │ │ + 104 │ │ │ │ │ +105 inline LocalIndex& LocalIndex::operator=(std::size_t index){ │ │ │ │ │ + 106 localIndex_ = index; │ │ │ │ │ + 107 return *this; │ │ │ │ │ + 108 } │ │ │ │ │ + 109 │ │ │ │ │ +110 inline LocalIndexState LocalIndex::state() const { │ │ │ │ │ + 111 return static_cast(state_); │ │ │ │ │ + 112 } │ │ │ │ │ + 113 │ │ │ │ │ +114 inline void LocalIndex::setState(LocalIndexState state){ │ │ │ │ │ + 115 state_ = static_cast(state); │ │ │ │ │ + 116 } │ │ │ │ │ + 117 │ │ │ │ │ + 120} // namespace Dune │ │ │ │ │ + 121 │ │ │ │ │ + 122#endif │ │ │ │ │ +Dune::LocalIndexState │ │ │ │ │ +LocalIndexState │ │ │ │ │ +The states available for the local indices. │ │ │ │ │ +Definition localindex.hh:28 │ │ │ │ │ +Dune::LocalIndex::operator= │ │ │ │ │ +LocalIndex & operator=(std::size_t index) │ │ │ │ │ +Assign a new local index. │ │ │ │ │ +Definition localindex.hh:105 │ │ │ │ │ +Dune::LocalIndex::state │ │ │ │ │ +LocalIndexState state() const │ │ │ │ │ +Get the state. │ │ │ │ │ +Definition localindex.hh:110 │ │ │ │ │ +Dune::LocalIndex::local │ │ │ │ │ +const std::size_t & local() const │ │ │ │ │ +get the local index. │ │ │ │ │ +Definition localindex.hh:97 │ │ │ │ │ +Dune::LocalIndex::setState │ │ │ │ │ +void setState(LocalIndexState state) │ │ │ │ │ +Set the state. │ │ │ │ │ +Definition localindex.hh:114 │ │ │ │ │ +Dune::VALID │ │ │ │ │ +@ VALID │ │ │ │ │ +Definition localindex.hh:28 │ │ │ │ │ +Dune::DELETED │ │ │ │ │ +@ DELETED │ │ │ │ │ +Definition localindex.hh:28 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::DynamicMatrixHelp::eigenValuesNonSym │ │ │ │ │ -static void eigenValuesNonSym(const DynamicMatrix< K > &matrix, DynamicVector< │ │ │ │ │ -C > &eigenValues, std::vector< DynamicVector< K > > *eigenVectors=nullptr) │ │ │ │ │ -calculates the eigenvalues of a symmetric field matrix │ │ │ │ │ -Definition dynmatrixev.hh:39 │ │ │ │ │ -Dune::DenseMatrix::rows │ │ │ │ │ -constexpr size_type rows() const │ │ │ │ │ -number of rows │ │ │ │ │ -Definition densematrix.hh:709 │ │ │ │ │ -Dune::DynamicMatrix │ │ │ │ │ -Construct a matrix with a dynamic size. │ │ │ │ │ -Definition dynmatrix.hh:61 │ │ │ │ │ -Dune::DynamicVector │ │ │ │ │ -Construct a vector with a dynamic size. │ │ │ │ │ -Definition dynvector.hh:59 │ │ │ │ │ -Dune::DynamicVector::resize │ │ │ │ │ -void resize(size_type n, value_type c=value_type()) │ │ │ │ │ -Definition dynvector.hh:141 │ │ │ │ │ -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::LocalIndex │ │ │ │ │ +An index present on the local process. │ │ │ │ │ +Definition localindex.hh:35 │ │ │ │ │ +Dune::LocalIndex::LocalIndex │ │ │ │ │ +LocalIndex() │ │ │ │ │ +Constructor. known to other processes. │ │ │ │ │ +Definition localindex.hh:41 │ │ │ │ │ +Dune::LocalIndex::LocalIndex │ │ │ │ │ +LocalIndex(std::size_t index) │ │ │ │ │ +Constructor. │ │ │ │ │ +Definition localindex.hh:49 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00011.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: timer.hh File Reference │ │ │ │ +dune-common: selection.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,45 +65,53 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ Namespaces
│ │ │ │ -
timer.hh File Reference
│ │ │ │ + │ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ -

A simple timing class. │ │ │ │ +

Provides classes for selecting indices based on attribute flags. │ │ │ │ More...

│ │ │ │ -
#include <chrono>
│ │ │ │ +
#include "indexset.hh"
│ │ │ │ +#include <dune/common/iteratorfacades.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

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

│ │ │ │ Classes

class  Dune::Timer
 A simple stop watch. More...
class  Dune::SelectionIterator< TS, TG, TL, N >
 A const iterator over an uncached selection. More...
 
class  Dune::UncachedSelection< TS, TG, TL, N >
 An uncached selection of indices. More...
 
class  Dune::Selection< TS, TG, TL, N >
 A cached selection of indices. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │

Detailed Description

│ │ │ │ -

A simple timing class.

│ │ │ │ +

Provides classes for selecting indices based on attribute flags.

│ │ │ │ +
Author
Markus Blatt
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,26 +6,36 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ + * parallel │ │ │ │ │ Classes | Namespaces │ │ │ │ │ -timer.hh File Reference │ │ │ │ │ -Common │ │ │ │ │ -A simple timing class. More... │ │ │ │ │ -#include │ │ │ │ │ +selection.hh File Reference │ │ │ │ │ +Common » Parallel_Communication » Parallel_Computing_based_on_Indexsets │ │ │ │ │ +Provides classes for selecting indices based on attribute flags. More... │ │ │ │ │ +#include "indexset.hh" │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class  Dune::Timer │ │ │ │ │ -  A simple stop watch. More... │ │ │ │ │ +class  Dune::SelectionIterator<_TS,_TG,_TL,_N_> │ │ │ │ │ +  A const iterator over an uncached selection. More... │ │ │ │ │ +  │ │ │ │ │ +class  Dune::UncachedSelection<_TS,_TG,_TL,_N_> │ │ │ │ │ +  An uncached selection of indices. More... │ │ │ │ │ +  │ │ │ │ │ +class  Dune::Selection<_TS,_TG,_TL,_N_> │ │ │ │ │ +  A cached selection of indices. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -A simple timing class. │ │ │ │ │ +Provides classes for selecting indices based on attribute flags. │ │ │ │ │ + Author │ │ │ │ │ + Markus Blatt │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00011_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: timer.hh Source File │ │ │ │ +dune-common: selection.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,161 +70,322 @@ │ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
timer.hh
│ │ │ │ +
selection.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 (C) 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_TIMER_HH
│ │ │ │ -
6#define DUNE_TIMER_HH
│ │ │ │ +
5#ifndef DUNE_SELECTION_HH
│ │ │ │ +
6#define DUNE_SELECTION_HH
│ │ │ │
7
│ │ │ │ -
8#ifndef TIMER_USE_STD_CLOCK
│ │ │ │ -
9// headers for std::chrono
│ │ │ │ -
10#include <chrono>
│ │ │ │ -
11#else
│ │ │ │ -
12// headers for std::clock
│ │ │ │ -
13#include <ctime>
│ │ │ │ -
14#endif
│ │ │ │ -
15
│ │ │ │ -
16namespace Dune {
│ │ │ │ -
17
│ │ │ │ -
│ │ │ │ -
42 class Timer
│ │ │ │ -
43 {
│ │ │ │ -
44 public:
│ │ │ │ +
8#include "indexset.hh"
│ │ │ │ + │ │ │ │ +
10
│ │ │ │ +
11namespace Dune
│ │ │ │ +
12{
│ │ │ │ +
27 template<typename TS, typename TG, typename TL, int N>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
29 {
│ │ │ │ +
30 public:
│ │ │ │ +
39 typedef TS AttributeSet;
│ │ │ │ +
40
│ │ │ │ + │ │ │ │
45
│ │ │ │ -
│ │ │ │ -
50 Timer (bool startImmediately=true) noexcept
│ │ │ │ -
51 {
│ │ │ │ -
52 isRunning_ = startImmediately;
│ │ │ │ -
53 reset();
│ │ │ │ -
54 }
│ │ │ │ -
│ │ │ │ -
55
│ │ │ │ -
│ │ │ │ -
57 void reset() noexcept
│ │ │ │ -
58 {
│ │ │ │ -
59 sumElapsed_ = 0.0;
│ │ │ │ -
60 storedLastElapsed_ = 0.0;
│ │ │ │ -
61 rawReset();
│ │ │ │ -
62 }
│ │ │ │ -
│ │ │ │ -
63
│ │ │ │ -
64
│ │ │ │ -
│ │ │ │ -
66 void start() noexcept
│ │ │ │ -
67 {
│ │ │ │ -
68 if (not (isRunning_))
│ │ │ │ -
69 {
│ │ │ │ -
70 rawReset();
│ │ │ │ -
71 isRunning_ = true;
│ │ │ │ -
72 }
│ │ │ │ -
73 }
│ │ │ │ +
46 //typedef typename ParallelIndexSet::const_iterator ParallelIndexSetIterator;
│ │ │ │ +
47
│ │ │ │ +
48 typedef ConstArrayListIterator<IndexPair<TG,TL>, N, std::allocator<Dune::IndexPair<TG,TL> > > ParallelIndexSetIterator;
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
55 : iter_(iter), end_(end)
│ │ │ │ +
56 {
│ │ │ │ +
57 // Step to the first valid entry
│ │ │ │ +
58 while(iter_!=end_ && !AttributeSet::contains(iter_->local().attribute()))
│ │ │ │ +
59 ++iter_;
│ │ │ │ +
60 }
│ │ │ │ +
│ │ │ │ +
61
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
63 {
│ │ │ │ +
64 assert(iter_!=end_);
│ │ │ │ +
65 for(++iter_; iter_!=end_; ++iter_)
│ │ │ │ +
66 if(AttributeSet::contains(iter_->local().attribute()))
│ │ │ │ +
67 break;
│ │ │ │ +
68 }
│ │ │ │ +
│ │ │ │ +
69
│ │ │ │ +
70
│ │ │ │ +
│ │ │ │ +
71 uint32_t operator*() const
│ │ │ │ +
72 {
│ │ │ │ +
73 return iter_->local().local();
│ │ │ │ +
74 }
│ │ │ │
│ │ │ │ -
74
│ │ │ │
75
│ │ │ │ -
│ │ │ │ -
77 double elapsed () const noexcept
│ │ │ │ -
78 {
│ │ │ │ -
79 // if timer is running add the time elapsed since last start to sum
│ │ │ │ -
80 if (isRunning_)
│ │ │ │ -
81 return sumElapsed_ + lastElapsed();
│ │ │ │ -
82
│ │ │ │ -
83 return sumElapsed_;
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
77 {
│ │ │ │ +
78 return iter_ == other.iter_;
│ │ │ │ +
79 }
│ │ │ │ +
│ │ │ │ +
80
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
82 {
│ │ │ │ +
83 return iter_ != other.iter_;
│ │ │ │
84 }
│ │ │ │
│ │ │ │
85
│ │ │ │ -
86
│ │ │ │ -
│ │ │ │ -
88 double lastElapsed () const noexcept
│ │ │ │ -
89 {
│ │ │ │ -
90 // if timer is running return the current value
│ │ │ │ -
91 if (isRunning_)
│ │ │ │ -
92 return rawElapsed();
│ │ │ │ -
93
│ │ │ │ -
94 // if timer is not running return stored value from last run
│ │ │ │ -
95 return storedLastElapsed_;
│ │ │ │ -
96 }
│ │ │ │ -
│ │ │ │ -
97
│ │ │ │ -
98
│ │ │ │ -
│ │ │ │ -
100 double stop() noexcept
│ │ │ │ -
101 {
│ │ │ │ -
102 if (isRunning_)
│ │ │ │ -
103 {
│ │ │ │ -
104 // update storedLastElapsed_ and sumElapsed_ and stop timer
│ │ │ │ -
105 storedLastElapsed_ = lastElapsed();
│ │ │ │ -
106 sumElapsed_ += storedLastElapsed_;
│ │ │ │ -
107 isRunning_ = false;
│ │ │ │ -
108 }
│ │ │ │ -
109 return elapsed();
│ │ │ │ -
110 }
│ │ │ │ -
│ │ │ │ -
111
│ │ │ │ -
112
│ │ │ │ -
113 private:
│ │ │ │ -
114
│ │ │ │ -
115 bool isRunning_;
│ │ │ │ -
116 double sumElapsed_;
│ │ │ │ -
117 double storedLastElapsed_;
│ │ │ │ -
118
│ │ │ │ -
119
│ │ │ │ -
120#ifdef TIMER_USE_STD_CLOCK
│ │ │ │ -
121 void rawReset() noexcept
│ │ │ │ -
122 {
│ │ │ │ -
123 cstart = std::clock();
│ │ │ │ -
124 }
│ │ │ │ -
125
│ │ │ │ -
126 double rawElapsed () const noexcept
│ │ │ │ -
127 {
│ │ │ │ -
128 return (std::clock()-cstart) / static_cast<double>(CLOCKS_PER_SEC);
│ │ │ │ -
129 }
│ │ │ │ -
130
│ │ │ │ -
131 std::clock_t cstart;
│ │ │ │ -
132#else
│ │ │ │ -
133 void rawReset() noexcept
│ │ │ │ -
134 {
│ │ │ │ -
135 cstart = std::chrono::high_resolution_clock::now();
│ │ │ │ -
136 }
│ │ │ │ -
137
│ │ │ │ -
138 double rawElapsed () const noexcept
│ │ │ │ -
139 {
│ │ │ │ -
140 std::chrono::high_resolution_clock::time_point now = std::chrono::high_resolution_clock::now();
│ │ │ │ -
141 std::chrono::duration<double> time_span = std::chrono::duration_cast<std::chrono::duration<double> >(now - cstart);
│ │ │ │ -
142 return time_span.count();
│ │ │ │ -
143 }
│ │ │ │ -
144
│ │ │ │ -
145 std::chrono::high_resolution_clock::time_point cstart;
│ │ │ │ -
146#endif
│ │ │ │ -
147 }; // end class Timer
│ │ │ │ -
│ │ │ │ -
148
│ │ │ │ -
151} // end namespace
│ │ │ │ -
152
│ │ │ │ -
153#endif
│ │ │ │ +
86 private:
│ │ │ │ + │ │ │ │ +
88 const ParallelIndexSetIterator end_;
│ │ │ │ +
89 };
│ │ │ │ +
│ │ │ │ +
90
│ │ │ │ +
91
│ │ │ │ +
95 template<typename TS, typename TG, typename TL, int N>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
97 {
│ │ │ │ +
98 public:
│ │ │ │ +
107 typedef TS AttributeSet;
│ │ │ │ +
108
│ │ │ │ +
112 typedef TG GlobalIndex;
│ │ │ │ +
113
│ │ │ │ +
120 typedef TL LocalIndex;
│ │ │ │ +
121
│ │ │ │ + │ │ │ │ +
126
│ │ │ │ + │ │ │ │ +
131
│ │ │ │ + │ │ │ │ +
136
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
138 : indexSet_()
│ │ │ │ +
139 {}
│ │ │ │ +
│ │ │ │ +
140
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
142 : indexSet_(&indexset)
│ │ │ │ +
143 {}
│ │ │ │ +
│ │ │ │ +
148 void setIndexSet(const ParallelIndexSet& indexset);
│ │ │ │ +
149
│ │ │ │ +
153 //const ParallelIndexSet& indexSet() const;
│ │ │ │ +
154
│ │ │ │ +
159 const_iterator begin() const;
│ │ │ │ +
160
│ │ │ │ +
165 const_iterator end() const;
│ │ │ │ +
166
│ │ │ │ +
167
│ │ │ │ +
168 private:
│ │ │ │ +
169 const ParallelIndexSet* indexSet_;
│ │ │ │ +
170
│ │ │ │ +
171 };
│ │ │ │ +
│ │ │ │ +
172
│ │ │ │ +
176 template<typename TS, typename TG, typename TL, int N>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
178 {
│ │ │ │ +
179 public:
│ │ │ │ +
188 typedef TS AttributeSet;
│ │ │ │ +
189
│ │ │ │ +
193 typedef TG GlobalIndex;
│ │ │ │ +
194
│ │ │ │ +
201 typedef TL LocalIndex;
│ │ │ │ +
202
│ │ │ │ + │ │ │ │ +
207
│ │ │ │ +
211 typedef uint32_t* iterator;
│ │ │ │ +
212
│ │ │ │ +
216 typedef uint32_t* const_iterator;
│ │ │ │ +
217
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
219 : selected_()
│ │ │ │ +
220 {}
│ │ │ │ +
│ │ │ │ +
221
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
223 : selected_(), size_(0), built_(false)
│ │ │ │ +
224 {
│ │ │ │ +
225 setIndexSet(indexset);
│ │ │ │ +
226 }
│ │ │ │ +
│ │ │ │ +
227
│ │ │ │ +
228 ~Selection();
│ │ │ │ +
229
│ │ │ │ +
234 void setIndexSet(const ParallelIndexSet& indexset);
│ │ │ │ +
235
│ │ │ │ +
239 void free();
│ │ │ │ +
240
│ │ │ │ +
244 //IndexSet indexSet() const;
│ │ │ │ +
245
│ │ │ │ +
250 const_iterator begin() const;
│ │ │ │ +
251
│ │ │ │ +
256 const_iterator end() const;
│ │ │ │ +
257
│ │ │ │ +
258
│ │ │ │ +
259 private:
│ │ │ │ +
260 uint32_t* selected_;
│ │ │ │ +
261 size_t size_;
│ │ │ │ +
262 bool built_;
│ │ │ │ +
263
│ │ │ │ +
264 };
│ │ │ │ +
│ │ │ │ +
265
│ │ │ │ +
266 template<typename TS, typename TG, typename TL, int N>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
268 {
│ │ │ │ +
269 if(built_)
│ │ │ │ +
270 free();
│ │ │ │ +
271
│ │ │ │ +
272 // Count the number of entries the selection has to hold
│ │ │ │ + │ │ │ │ +
274 const const_iterator end = indexset.end();
│ │ │ │ +
275 int entries = 0;
│ │ │ │ +
276
│ │ │ │ +
277 for(const_iterator index = indexset.begin(); index != end; ++index)
│ │ │ │ +
278 if(AttributeSet::contains(index->local().attribute()))
│ │ │ │ +
279 ++entries;
│ │ │ │ +
280
│ │ │ │ +
281 selected_ = new uint32_t[entries];
│ │ │ │ +
282 built_ = true;
│ │ │ │ +
283
│ │ │ │ +
284 entries = 0;
│ │ │ │ +
285 for(const_iterator index = indexset.begin(); index != end; ++index)
│ │ │ │ +
286 if(AttributeSet::contains(index->local().attribute()))
│ │ │ │ +
287 selected_[entries++]= index->local().local();
│ │ │ │ +
288
│ │ │ │ +
289 size_=entries;
│ │ │ │ +
290 built_=true;
│ │ │ │ +
291 }
│ │ │ │ +
│ │ │ │ +
292
│ │ │ │ +
293 template<typename TS, typename TG, typename TL, int N>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
295 {
│ │ │ │ +
296 return selected_;
│ │ │ │ +
297 }
│ │ │ │ +
│ │ │ │ +
298
│ │ │ │ +
299 template<typename TS, typename TG, typename TL, int N>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
301 {
│ │ │ │ +
302 return selected_+size_;
│ │ │ │ +
303 }
│ │ │ │ +
│ │ │ │ +
304
│ │ │ │ +
305 template<typename TS, typename TG, typename TL, int N>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
307 {
│ │ │ │ +
308 delete[] selected_;
│ │ │ │ +
309 size_=0;
│ │ │ │ +
310 built_=false;
│ │ │ │ +
311 }
│ │ │ │ +
│ │ │ │ +
312
│ │ │ │ +
313 template<typename TS, typename TG, typename TL, int N>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
315 {
│ │ │ │ +
316 if(built_)
│ │ │ │ +
317 free();
│ │ │ │ +
318 }
│ │ │ │ +
│ │ │ │ +
319
│ │ │ │ +
320 template<typename TS, typename TG, typename TL, int N>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
322 {
│ │ │ │ +
323 return SelectionIterator<TS,TG,TL,N>(indexSet_->begin(),
│ │ │ │ +
324 indexSet_->end());
│ │ │ │ +
325 }
│ │ │ │ +
│ │ │ │ +
326
│ │ │ │ +
327 template<typename TS, typename TG, typename TL, int N>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
329 {
│ │ │ │ +
330 return SelectionIterator<TS,TG,TL,N>(indexSet_->end(),
│ │ │ │ +
331 indexSet_->end());
│ │ │ │ +
332 }
│ │ │ │ +
│ │ │ │ +
333 template<typename TS, typename TG, typename TL, int N>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
335 {
│ │ │ │ +
336 indexSet_ = &indexset;
│ │ │ │ +
337 }
│ │ │ │ +
│ │ │ │ +
338
│ │ │ │ +
342}
│ │ │ │ +
343#endif
│ │ │ │ +
Provides a map between global and local indices.
│ │ │ │ +
This file implements iterator facade classes for writing stl conformant iterators.
│ │ │ │ +
const_iterator end() const
Get an iterator over the selected indices.
Definition selection.hh:328
│ │ │ │ +
void setIndexSet(const ParallelIndexSet &indexset)
Set the index set of the selection.
Definition selection.hh:267
│ │ │ │ +
void setIndexSet(const ParallelIndexSet &indexset)
Set the index set of the selection.
Definition selection.hh:334
│ │ │ │ +
iterator begin()
Get an iterator over the indices positioned at the first index.
│ │ │ │ +
iterator end()
Get an iterator over the indices positioned after the last index.
│ │ │ │ +
const_iterator end() const
Get an iterator over the selected indices.
Definition selection.hh:300
│ │ │ │ +
const_iterator begin() const
Get the index set we are a selection for.
Definition selection.hh:294
│ │ │ │ +
void free()
Free allocated memory.
Definition selection.hh:306
│ │ │ │ +
const_iterator begin() const
Get the index set we are a selection for.
Definition selection.hh:321
│ │ │ │ +
~Selection()
Definition selection.hh:314
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
A simple stop watch.
Definition timer.hh:43
│ │ │ │ -
void reset() noexcept
Reset timer while keeping the running/stopped state.
Definition timer.hh:57
│ │ │ │ -
double stop() noexcept
Stop the timer and return elapsed().
Definition timer.hh:100
│ │ │ │ -
Timer(bool startImmediately=true) noexcept
A new timer, create and reset.
Definition timer.hh:50
│ │ │ │ -
double elapsed() const noexcept
Get elapsed user-time from last reset until now/last stop in seconds.
Definition timer.hh:77
│ │ │ │ -
double lastElapsed() const noexcept
Get elapsed user-time from last start until now/last stop in seconds.
Definition timer.hh:88
│ │ │ │ -
void start() noexcept
Start the timer and continue measurement if it is not running. Otherwise do nothing.
Definition timer.hh:66
│ │ │ │ +
A constant random access iterator for the Dune::ArrayList class.
Definition arraylist.hh:370
│ │ │ │ +
Manager class for the mapping between local indices and globally unique indices.
Definition indexset.hh:218
│ │ │ │ +
A const iterator over an uncached selection.
Definition selection.hh:29
│ │ │ │ +
ConstArrayListIterator< IndexPair< TG, TL >, N, std::allocator< Dune::IndexPair< TG, TL > > > ParallelIndexSetIterator
Definition selection.hh:48
│ │ │ │ +
void operator++()
Definition selection.hh:62
│ │ │ │ +
uint32_t operator*() const
Definition selection.hh:71
│ │ │ │ +
TS AttributeSet
The type of the Set of attributes.
Definition selection.hh:39
│ │ │ │ +
Dune::ParallelIndexSet< TG, TL, N > ParallelIndexSet
The type of the underlying index set.
Definition selection.hh:44
│ │ │ │ +
SelectionIterator(const ParallelIndexSetIterator &iter, const ParallelIndexSetIterator &end)
Constructor.
Definition selection.hh:54
│ │ │ │ +
bool operator!=(const SelectionIterator< TS, TG, TL, N > &other) const
Definition selection.hh:81
│ │ │ │ +
bool operator==(const SelectionIterator< TS, TG, TL, N > &other) const
Definition selection.hh:76
│ │ │ │ +
An uncached selection of indices.
Definition selection.hh:97
│ │ │ │ +
UncachedSelection()
Definition selection.hh:137
│ │ │ │ +
SelectionIterator< TS, TG, TL, N > iterator
The type of the iterator of the selected indices.
Definition selection.hh:130
│ │ │ │ +
TS AttributeSet
The type of the Set of attributes.
Definition selection.hh:107
│ │ │ │ +
iterator const_iterator
The type of the iterator of the selected indices.
Definition selection.hh:135
│ │ │ │ +
TG GlobalIndex
The type of the global index of the underlying index set.
Definition selection.hh:112
│ │ │ │ +
UncachedSelection(const ParallelIndexSet &indexset)
Definition selection.hh:141
│ │ │ │ +
Dune::ParallelIndexSet< GlobalIndex, LocalIndex, N > ParallelIndexSet
The type of the underlying index set.
Definition selection.hh:125
│ │ │ │ +
TL LocalIndex
The type of the local index of the underlying index set.
Definition selection.hh:120
│ │ │ │ +
A cached selection of indices.
Definition selection.hh:178
│ │ │ │ +
TG GlobalIndex
The type of the global index of the underlying index set.
Definition selection.hh:193
│ │ │ │ +
Selection(const ParallelIndexSet &indexset)
Definition selection.hh:222
│ │ │ │ +
Selection()
Definition selection.hh:218
│ │ │ │ +
TL LocalIndex
The type of the local index of the underlying index set.
Definition selection.hh:201
│ │ │ │ +
TS AttributeSet
The type of the set of attributes.
Definition selection.hh:188
│ │ │ │ +
uint32_t * iterator
The type of the iterator of the selected indices.
Definition selection.hh:211
│ │ │ │ +
uint32_t * const_iterator
The type of the iterator of the selected indices.
Definition selection.hh:216
│ │ │ │ +
Dune::ParallelIndexSet< GlobalIndex, LocalIndex, N > ParallelIndexSet
The type of the underlying index set.
Definition selection.hh:206
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,164 +7,388 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -timer.hh │ │ │ │ │ + * parallel │ │ │ │ │ +selection.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 (C) 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_TIMER_HH │ │ │ │ │ - 6#define DUNE_TIMER_HH │ │ │ │ │ + 5#ifndef DUNE_SELECTION_HH │ │ │ │ │ + 6#define DUNE_SELECTION_HH │ │ │ │ │ 7 │ │ │ │ │ - 8#ifndef TIMER_USE_STD_CLOCK │ │ │ │ │ - 9// headers for std::chrono │ │ │ │ │ - 10#include │ │ │ │ │ - 11#else │ │ │ │ │ - 12// headers for std::clock │ │ │ │ │ - 13#include │ │ │ │ │ - 14#endif │ │ │ │ │ - 15 │ │ │ │ │ - 16namespace Dune { │ │ │ │ │ - 17 │ │ │ │ │ -42 class Timer │ │ │ │ │ - 43 { │ │ │ │ │ - 44 public: │ │ │ │ │ + 8#include "indexset.hh" │ │ │ │ │ + 9#include │ │ │ │ │ + 10 │ │ │ │ │ + 11namespace Dune │ │ │ │ │ + 12{ │ │ │ │ │ + 27 template │ │ │ │ │ +28 class SelectionIterator │ │ │ │ │ + 29 { │ │ │ │ │ + 30 public: │ │ │ │ │ +39 typedef TS AttributeSet; │ │ │ │ │ + 40 │ │ │ │ │ +44 typedef Dune::ParallelIndexSet ParallelIndexSet; │ │ │ │ │ 45 │ │ │ │ │ -50 Timer (bool startImmediately=true) noexcept │ │ │ │ │ - 51 { │ │ │ │ │ - 52 isRunning_ = startImmediately; │ │ │ │ │ - 53 reset(); │ │ │ │ │ - 54 } │ │ │ │ │ - 55 │ │ │ │ │ -57 void reset() noexcept │ │ │ │ │ - 58 { │ │ │ │ │ - 59 sumElapsed_ = 0.0; │ │ │ │ │ - 60 storedLastElapsed_ = 0.0; │ │ │ │ │ - 61 rawReset(); │ │ │ │ │ - 62 } │ │ │ │ │ - 63 │ │ │ │ │ - 64 │ │ │ │ │ -66 void start() noexcept │ │ │ │ │ - 67 { │ │ │ │ │ - 68 if (not (isRunning_)) │ │ │ │ │ - 69 { │ │ │ │ │ - 70 rawReset(); │ │ │ │ │ - 71 isRunning_ = true; │ │ │ │ │ - 72 } │ │ │ │ │ - 73 } │ │ │ │ │ - 74 │ │ │ │ │ + 46 //typedef typename ParallelIndexSet::const_iterator │ │ │ │ │ +ParallelIndexSetIterator; │ │ │ │ │ + 47 │ │ │ │ │ +48 typedef ConstArrayListIterator, N, std::allocator > > ParallelIndexSetIterator; │ │ │ │ │ +54 SelectionIterator(const ParallelIndexSetIterator& iter, const │ │ │ │ │ +ParallelIndexSetIterator& end) │ │ │ │ │ + 55 : iter_(iter), end_(end) │ │ │ │ │ + 56 { │ │ │ │ │ + 57 // Step to the first valid entry │ │ │ │ │ + 58 while(iter_!=end_ && !AttributeSet::contains(iter_->local().attribute())) │ │ │ │ │ + 59 ++iter_; │ │ │ │ │ + 60 } │ │ │ │ │ + 61 │ │ │ │ │ +62 void operator++() │ │ │ │ │ + 63 { │ │ │ │ │ + 64 assert(iter_!=end_); │ │ │ │ │ + 65 for(++iter_; iter_!=end_; ++iter_) │ │ │ │ │ + 66 if(AttributeSet::contains(iter_->local().attribute())) │ │ │ │ │ + 67 break; │ │ │ │ │ + 68 } │ │ │ │ │ + 69 │ │ │ │ │ + 70 │ │ │ │ │ +71 uint32_t operator*() const │ │ │ │ │ + 72 { │ │ │ │ │ + 73 return iter_->local().local(); │ │ │ │ │ + 74 } │ │ │ │ │ 75 │ │ │ │ │ -77 double elapsed () const noexcept │ │ │ │ │ - 78 { │ │ │ │ │ - 79 // if timer is running add the time elapsed since last start to sum │ │ │ │ │ - 80 if (isRunning_) │ │ │ │ │ - 81 return sumElapsed_ + lastElapsed(); │ │ │ │ │ - 82 │ │ │ │ │ - 83 return sumElapsed_; │ │ │ │ │ +76 bool operator==(const SelectionIterator& other) const │ │ │ │ │ + 77 { │ │ │ │ │ + 78 return iter_ == other.iter_; │ │ │ │ │ + 79 } │ │ │ │ │ + 80 │ │ │ │ │ +81 bool operator!=(const SelectionIterator& other) const │ │ │ │ │ + 82 { │ │ │ │ │ + 83 return iter_ != other.iter_; │ │ │ │ │ 84 } │ │ │ │ │ 85 │ │ │ │ │ - 86 │ │ │ │ │ -88 double lastElapsed () const noexcept │ │ │ │ │ - 89 { │ │ │ │ │ - 90 // if timer is running return the current value │ │ │ │ │ - 91 if (isRunning_) │ │ │ │ │ - 92 return rawElapsed(); │ │ │ │ │ - 93 │ │ │ │ │ - 94 // if timer is not running return stored value from last run │ │ │ │ │ - 95 return storedLastElapsed_; │ │ │ │ │ - 96 } │ │ │ │ │ - 97 │ │ │ │ │ - 98 │ │ │ │ │ -100 double stop() noexcept │ │ │ │ │ - 101 { │ │ │ │ │ - 102 if (isRunning_) │ │ │ │ │ - 103 { │ │ │ │ │ - 104 // update storedLastElapsed_ and sumElapsed_ and stop timer │ │ │ │ │ - 105 storedLastElapsed_ = lastElapsed(); │ │ │ │ │ - 106 sumElapsed_ += storedLastElapsed_; │ │ │ │ │ - 107 isRunning_ = false; │ │ │ │ │ - 108 } │ │ │ │ │ - 109 return elapsed(); │ │ │ │ │ - 110 } │ │ │ │ │ - 111 │ │ │ │ │ - 112 │ │ │ │ │ - 113 private: │ │ │ │ │ - 114 │ │ │ │ │ - 115 bool isRunning_; │ │ │ │ │ - 116 double sumElapsed_; │ │ │ │ │ - 117 double storedLastElapsed_; │ │ │ │ │ - 118 │ │ │ │ │ - 119 │ │ │ │ │ - 120#ifdef TIMER_USE_STD_CLOCK │ │ │ │ │ - 121 void rawReset() noexcept │ │ │ │ │ - 122 { │ │ │ │ │ - 123 cstart = std::clock(); │ │ │ │ │ - 124 } │ │ │ │ │ - 125 │ │ │ │ │ - 126 double rawElapsed () const noexcept │ │ │ │ │ - 127 { │ │ │ │ │ - 128 return (std::clock()-cstart) / static_cast(CLOCKS_PER_SEC); │ │ │ │ │ - 129 } │ │ │ │ │ - 130 │ │ │ │ │ - 131 std::clock_t cstart; │ │ │ │ │ - 132#else │ │ │ │ │ - 133 void rawReset() noexcept │ │ │ │ │ - 134 { │ │ │ │ │ - 135 cstart = std::chrono::high_resolution_clock::now(); │ │ │ │ │ - 136 } │ │ │ │ │ - 137 │ │ │ │ │ - 138 double rawElapsed () const noexcept │ │ │ │ │ - 139 { │ │ │ │ │ - 140 std::chrono::high_resolution_clock::time_point now = std::chrono:: │ │ │ │ │ -high_resolution_clock::now(); │ │ │ │ │ - 141 std::chrono::duration time_span = std::chrono::duration_cast >(now - cstart); │ │ │ │ │ - 142 return time_span.count(); │ │ │ │ │ - 143 } │ │ │ │ │ - 144 │ │ │ │ │ - 145 std::chrono::high_resolution_clock::time_point cstart; │ │ │ │ │ - 146#endif │ │ │ │ │ - 147 }; // end class Timer │ │ │ │ │ - 148 │ │ │ │ │ - 151} // end namespace │ │ │ │ │ - 152 │ │ │ │ │ - 153#endif │ │ │ │ │ + 86 private: │ │ │ │ │ + 87 ParallelIndexSetIterator iter_; │ │ │ │ │ + 88 const ParallelIndexSetIterator end_; │ │ │ │ │ + 89 }; │ │ │ │ │ + 90 │ │ │ │ │ + 91 │ │ │ │ │ + 95 template │ │ │ │ │ +96 class UncachedSelection │ │ │ │ │ + 97 { │ │ │ │ │ + 98 public: │ │ │ │ │ +107 typedef TS AttributeSet; │ │ │ │ │ + 108 │ │ │ │ │ +112 typedef TG GlobalIndex; │ │ │ │ │ + 113 │ │ │ │ │ +120 typedef TL LocalIndex; │ │ │ │ │ + 121 │ │ │ │ │ +125 typedef Dune::ParallelIndexSet ParallelIndexSet; │ │ │ │ │ + 126 │ │ │ │ │ +130 typedef SelectionIterator iterator; │ │ │ │ │ + 131 │ │ │ │ │ +135 typedef iterator const_iterator; │ │ │ │ │ + 136 │ │ │ │ │ +137 UncachedSelection() │ │ │ │ │ + 138 : indexSet_() │ │ │ │ │ + 139 {} │ │ │ │ │ + 140 │ │ │ │ │ +141 UncachedSelection(const ParallelIndexSet& indexset) │ │ │ │ │ + 142 : indexSet_(&indexset) │ │ │ │ │ + 143 {} │ │ │ │ │ + 148 void setIndexSet(const ParallelIndexSet& indexset); │ │ │ │ │ + 149 │ │ │ │ │ + 153 //const ParallelIndexSet& indexSet() const; │ │ │ │ │ + 154 │ │ │ │ │ + 159 const_iterator begin() const; │ │ │ │ │ + 160 │ │ │ │ │ + 165 const_iterator end() const; │ │ │ │ │ + 166 │ │ │ │ │ + 167 │ │ │ │ │ + 168 private: │ │ │ │ │ + 169 const ParallelIndexSet* indexSet_; │ │ │ │ │ + 170 │ │ │ │ │ + 171 }; │ │ │ │ │ + 172 │ │ │ │ │ + 176 template │ │ │ │ │ +177 class Selection │ │ │ │ │ + 178 { │ │ │ │ │ + 179 public: │ │ │ │ │ +188 typedef TS AttributeSet; │ │ │ │ │ + 189 │ │ │ │ │ +193 typedef TG GlobalIndex; │ │ │ │ │ + 194 │ │ │ │ │ +201 typedef TL LocalIndex; │ │ │ │ │ + 202 │ │ │ │ │ +206 typedef Dune::ParallelIndexSet ParallelIndexSet; │ │ │ │ │ + 207 │ │ │ │ │ +211 typedef uint32_t* iterator; │ │ │ │ │ + 212 │ │ │ │ │ +216 typedef uint32_t* const_iterator; │ │ │ │ │ + 217 │ │ │ │ │ +218 Selection() │ │ │ │ │ + 219 : selected_() │ │ │ │ │ + 220 {} │ │ │ │ │ + 221 │ │ │ │ │ +222 Selection(const ParallelIndexSet& indexset) │ │ │ │ │ + 223 : selected_(), size_(0), built_(false) │ │ │ │ │ + 224 { │ │ │ │ │ + 225 setIndexSet(indexset); │ │ │ │ │ + 226 } │ │ │ │ │ + 227 │ │ │ │ │ + 228 ~Selection(); │ │ │ │ │ + 229 │ │ │ │ │ + 234 void setIndexSet(const ParallelIndexSet& indexset); │ │ │ │ │ + 235 │ │ │ │ │ + 239 void free(); │ │ │ │ │ + 240 │ │ │ │ │ + 244 //IndexSet indexSet() const; │ │ │ │ │ + 245 │ │ │ │ │ + 250 const_iterator begin() const; │ │ │ │ │ + 251 │ │ │ │ │ + 256 const_iterator end() const; │ │ │ │ │ + 257 │ │ │ │ │ + 258 │ │ │ │ │ + 259 private: │ │ │ │ │ + 260 uint32_t* selected_; │ │ │ │ │ + 261 size_t size_; │ │ │ │ │ + 262 bool built_; │ │ │ │ │ + 263 │ │ │ │ │ + 264 }; │ │ │ │ │ + 265 │ │ │ │ │ + 266 template │ │ │ │ │ +267 inline void Selection::setIndexSet(const ParallelIndexSet& │ │ │ │ │ +indexset) │ │ │ │ │ + 268 { │ │ │ │ │ + 269 if(built_) │ │ │ │ │ + 270 free(); │ │ │ │ │ + 271 │ │ │ │ │ + 272 // Count the number of entries the selection has to hold │ │ │ │ │ + 273 typedef typename ParallelIndexSet::const_iterator const_iterator; │ │ │ │ │ + 274 const const_iterator end = indexset.end(); │ │ │ │ │ + 275 int entries = 0; │ │ │ │ │ + 276 │ │ │ │ │ + 277 for(const_iterator index = indexset.begin(); index != end; ++index) │ │ │ │ │ + 278 if(AttributeSet::contains(index->local().attribute())) │ │ │ │ │ + 279 ++entries; │ │ │ │ │ + 280 │ │ │ │ │ + 281 selected_ = new uint32_t[entries]; │ │ │ │ │ + 282 built_ = true; │ │ │ │ │ + 283 │ │ │ │ │ + 284 entries = 0; │ │ │ │ │ + 285 for(const_iterator index = indexset.begin(); index != end; ++index) │ │ │ │ │ + 286 if(AttributeSet::contains(index->local().attribute())) │ │ │ │ │ + 287 selected_[entries++]= index->local().local(); │ │ │ │ │ + 288 │ │ │ │ │ + 289 size_=entries; │ │ │ │ │ + 290 built_=true; │ │ │ │ │ + 291 } │ │ │ │ │ + 292 │ │ │ │ │ + 293 template │ │ │ │ │ +294 uint32_t* Selection::begin() const │ │ │ │ │ + 295 { │ │ │ │ │ + 296 return selected_; │ │ │ │ │ + 297 } │ │ │ │ │ + 298 │ │ │ │ │ + 299 template │ │ │ │ │ +300 uint32_t* Selection::end() const │ │ │ │ │ + 301 { │ │ │ │ │ + 302 return selected_+size_; │ │ │ │ │ + 303 } │ │ │ │ │ + 304 │ │ │ │ │ + 305 template │ │ │ │ │ +306 inline void Selection::free() │ │ │ │ │ + 307 { │ │ │ │ │ + 308 delete[] selected_; │ │ │ │ │ + 309 size_=0; │ │ │ │ │ + 310 built_=false; │ │ │ │ │ + 311 } │ │ │ │ │ + 312 │ │ │ │ │ + 313 template │ │ │ │ │ +314 inline Selection::~Selection() │ │ │ │ │ + 315 { │ │ │ │ │ + 316 if(built_) │ │ │ │ │ + 317 free(); │ │ │ │ │ + 318 } │ │ │ │ │ + 319 │ │ │ │ │ + 320 template │ │ │ │ │ +321 SelectionIterator UncachedSelection::begin() const │ │ │ │ │ + 322 { │ │ │ │ │ + 323 return SelectionIterator(indexSet_->begin(), │ │ │ │ │ + 324 indexSet_->end()); │ │ │ │ │ + 325 } │ │ │ │ │ + 326 │ │ │ │ │ + 327 template │ │ │ │ │ +328 SelectionIterator UncachedSelection::end() const │ │ │ │ │ + 329 { │ │ │ │ │ + 330 return SelectionIterator(indexSet_->end(), │ │ │ │ │ + 331 indexSet_->end()); │ │ │ │ │ + 332 } │ │ │ │ │ + 333 template │ │ │ │ │ +334 void UncachedSelection::setIndexSet(const ParallelIndexSet& │ │ │ │ │ +indexset) │ │ │ │ │ + 335 { │ │ │ │ │ + 336 indexSet_ = &indexset; │ │ │ │ │ + 337 } │ │ │ │ │ + 338 │ │ │ │ │ + 342} │ │ │ │ │ + 343#endif │ │ │ │ │ +indexset.hh │ │ │ │ │ +Provides a map between global and local indices. │ │ │ │ │ +iteratorfacades.hh │ │ │ │ │ +This file implements iterator facade classes for writing stl conformant │ │ │ │ │ +iterators. │ │ │ │ │ +Dune::UncachedSelection::end │ │ │ │ │ +const_iterator end() const │ │ │ │ │ +Get an iterator over the selected indices. │ │ │ │ │ +Definition selection.hh:328 │ │ │ │ │ +Dune::Selection::setIndexSet │ │ │ │ │ +void setIndexSet(const ParallelIndexSet &indexset) │ │ │ │ │ +Set the index set of the selection. │ │ │ │ │ +Definition selection.hh:267 │ │ │ │ │ +Dune::UncachedSelection::setIndexSet │ │ │ │ │ +void setIndexSet(const ParallelIndexSet &indexset) │ │ │ │ │ +Set the index set of the selection. │ │ │ │ │ +Definition selection.hh:334 │ │ │ │ │ +Dune::ParallelIndexSet::begin │ │ │ │ │ +iterator begin() │ │ │ │ │ +Get an iterator over the indices positioned at the first index. │ │ │ │ │ +Dune::ParallelIndexSet::end │ │ │ │ │ +iterator end() │ │ │ │ │ +Get an iterator over the indices positioned after the last index. │ │ │ │ │ +Dune::Selection::end │ │ │ │ │ +const_iterator end() const │ │ │ │ │ +Get an iterator over the selected indices. │ │ │ │ │ +Definition selection.hh:300 │ │ │ │ │ +Dune::Selection::begin │ │ │ │ │ +const_iterator begin() const │ │ │ │ │ +Get the index set we are a selection for. │ │ │ │ │ +Definition selection.hh:294 │ │ │ │ │ +Dune::Selection::free │ │ │ │ │ +void free() │ │ │ │ │ +Free allocated memory. │ │ │ │ │ +Definition selection.hh:306 │ │ │ │ │ +Dune::UncachedSelection::begin │ │ │ │ │ +const_iterator begin() const │ │ │ │ │ +Get the index set we are a selection for. │ │ │ │ │ +Definition selection.hh:321 │ │ │ │ │ +Dune::Selection::~Selection │ │ │ │ │ +~Selection() │ │ │ │ │ +Definition selection.hh:314 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::Timer │ │ │ │ │ -A simple stop watch. │ │ │ │ │ -Definition timer.hh:43 │ │ │ │ │ -Dune::Timer::reset │ │ │ │ │ -void reset() noexcept │ │ │ │ │ -Reset timer while keeping the running/stopped state. │ │ │ │ │ -Definition timer.hh:57 │ │ │ │ │ -Dune::Timer::stop │ │ │ │ │ -double stop() noexcept │ │ │ │ │ -Stop the timer and return elapsed(). │ │ │ │ │ -Definition timer.hh:100 │ │ │ │ │ -Dune::Timer::Timer │ │ │ │ │ -Timer(bool startImmediately=true) noexcept │ │ │ │ │ -A new timer, create and reset. │ │ │ │ │ -Definition timer.hh:50 │ │ │ │ │ -Dune::Timer::elapsed │ │ │ │ │ -double elapsed() const noexcept │ │ │ │ │ -Get elapsed user-time from last reset until now/last stop in seconds. │ │ │ │ │ -Definition timer.hh:77 │ │ │ │ │ -Dune::Timer::lastElapsed │ │ │ │ │ -double lastElapsed() const noexcept │ │ │ │ │ -Get elapsed user-time from last start until now/last stop in seconds. │ │ │ │ │ -Definition timer.hh:88 │ │ │ │ │ -Dune::Timer::start │ │ │ │ │ -void start() noexcept │ │ │ │ │ -Start the timer and continue measurement if it is not running. Otherwise do │ │ │ │ │ -nothing. │ │ │ │ │ -Definition timer.hh:66 │ │ │ │ │ +Dune::ConstArrayListIterator │ │ │ │ │ +A constant random access iterator for the Dune::ArrayList class. │ │ │ │ │ +Definition arraylist.hh:370 │ │ │ │ │ +Dune::ParallelIndexSet │ │ │ │ │ +Manager class for the mapping between local indices and globally unique │ │ │ │ │ +indices. │ │ │ │ │ +Definition indexset.hh:218 │ │ │ │ │ +Dune::SelectionIterator │ │ │ │ │ +A const iterator over an uncached selection. │ │ │ │ │ +Definition selection.hh:29 │ │ │ │ │ +Dune::SelectionIterator::ParallelIndexSetIterator │ │ │ │ │ +ConstArrayListIterator< IndexPair< TG, TL >, N, std::allocator< Dune:: │ │ │ │ │ +IndexPair< TG, TL > > > ParallelIndexSetIterator │ │ │ │ │ +Definition selection.hh:48 │ │ │ │ │ +Dune::SelectionIterator::operator++ │ │ │ │ │ +void operator++() │ │ │ │ │ +Definition selection.hh:62 │ │ │ │ │ +Dune::SelectionIterator::operator* │ │ │ │ │ +uint32_t operator*() const │ │ │ │ │ +Definition selection.hh:71 │ │ │ │ │ +Dune::SelectionIterator::AttributeSet │ │ │ │ │ +TS AttributeSet │ │ │ │ │ +The type of the Set of attributes. │ │ │ │ │ +Definition selection.hh:39 │ │ │ │ │ +Dune::SelectionIterator::ParallelIndexSet │ │ │ │ │ +Dune::ParallelIndexSet< TG, TL, N > ParallelIndexSet │ │ │ │ │ +The type of the underlying index set. │ │ │ │ │ +Definition selection.hh:44 │ │ │ │ │ +Dune::SelectionIterator::SelectionIterator │ │ │ │ │ +SelectionIterator(const ParallelIndexSetIterator &iter, const │ │ │ │ │ +ParallelIndexSetIterator &end) │ │ │ │ │ +Constructor. │ │ │ │ │ +Definition selection.hh:54 │ │ │ │ │ +Dune::SelectionIterator::operator!= │ │ │ │ │ +bool operator!=(const SelectionIterator< TS, TG, TL, N > &other) const │ │ │ │ │ +Definition selection.hh:81 │ │ │ │ │ +Dune::SelectionIterator::operator== │ │ │ │ │ +bool operator==(const SelectionIterator< TS, TG, TL, N > &other) const │ │ │ │ │ +Definition selection.hh:76 │ │ │ │ │ +Dune::UncachedSelection │ │ │ │ │ +An uncached selection of indices. │ │ │ │ │ +Definition selection.hh:97 │ │ │ │ │ +Dune::UncachedSelection::UncachedSelection │ │ │ │ │ +UncachedSelection() │ │ │ │ │ +Definition selection.hh:137 │ │ │ │ │ +Dune::UncachedSelection::iterator │ │ │ │ │ +SelectionIterator< TS, TG, TL, N > iterator │ │ │ │ │ +The type of the iterator of the selected indices. │ │ │ │ │ +Definition selection.hh:130 │ │ │ │ │ +Dune::UncachedSelection::AttributeSet │ │ │ │ │ +TS AttributeSet │ │ │ │ │ +The type of the Set of attributes. │ │ │ │ │ +Definition selection.hh:107 │ │ │ │ │ +Dune::UncachedSelection::const_iterator │ │ │ │ │ +iterator const_iterator │ │ │ │ │ +The type of the iterator of the selected indices. │ │ │ │ │ +Definition selection.hh:135 │ │ │ │ │ +Dune::UncachedSelection::GlobalIndex │ │ │ │ │ +TG GlobalIndex │ │ │ │ │ +The type of the global index of the underlying index set. │ │ │ │ │ +Definition selection.hh:112 │ │ │ │ │ +Dune::UncachedSelection::UncachedSelection │ │ │ │ │ +UncachedSelection(const ParallelIndexSet &indexset) │ │ │ │ │ +Definition selection.hh:141 │ │ │ │ │ +Dune::UncachedSelection::ParallelIndexSet │ │ │ │ │ +Dune::ParallelIndexSet< GlobalIndex, LocalIndex, N > ParallelIndexSet │ │ │ │ │ +The type of the underlying index set. │ │ │ │ │ +Definition selection.hh:125 │ │ │ │ │ +Dune::UncachedSelection::LocalIndex │ │ │ │ │ +TL LocalIndex │ │ │ │ │ +The type of the local index of the underlying index set. │ │ │ │ │ +Definition selection.hh:120 │ │ │ │ │ +Dune::Selection │ │ │ │ │ +A cached selection of indices. │ │ │ │ │ +Definition selection.hh:178 │ │ │ │ │ +Dune::Selection::GlobalIndex │ │ │ │ │ +TG GlobalIndex │ │ │ │ │ +The type of the global index of the underlying index set. │ │ │ │ │ +Definition selection.hh:193 │ │ │ │ │ +Dune::Selection::Selection │ │ │ │ │ +Selection(const ParallelIndexSet &indexset) │ │ │ │ │ +Definition selection.hh:222 │ │ │ │ │ +Dune::Selection::Selection │ │ │ │ │ +Selection() │ │ │ │ │ +Definition selection.hh:218 │ │ │ │ │ +Dune::Selection::LocalIndex │ │ │ │ │ +TL LocalIndex │ │ │ │ │ +The type of the local index of the underlying index set. │ │ │ │ │ +Definition selection.hh:201 │ │ │ │ │ +Dune::Selection::AttributeSet │ │ │ │ │ +TS AttributeSet │ │ │ │ │ +The type of the set of attributes. │ │ │ │ │ +Definition selection.hh:188 │ │ │ │ │ +Dune::Selection::iterator │ │ │ │ │ +uint32_t * iterator │ │ │ │ │ +The type of the iterator of the selected indices. │ │ │ │ │ +Definition selection.hh:211 │ │ │ │ │ +Dune::Selection::const_iterator │ │ │ │ │ +uint32_t * const_iterator │ │ │ │ │ +The type of the iterator of the selected indices. │ │ │ │ │ +Definition selection.hh:216 │ │ │ │ │ +Dune::Selection::ParallelIndexSet │ │ │ │ │ +Dune::ParallelIndexSet< GlobalIndex, LocalIndex, N > ParallelIndexSet │ │ │ │ │ +The type of the underlying index set. │ │ │ │ │ +Definition selection.hh:206 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00014.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: propertymap.hh File Reference │ │ │ │ +dune-common: mpihelper.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,84 +65,72 @@ │ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces | │ │ │ │ -Functions
│ │ │ │ -
propertymap.hh File Reference
│ │ │ │ +Namespaces
│ │ │ │ +
mpihelper.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ -
#include <cstddef>
│ │ │ │ -#include <iterator>
│ │ │ │ -#include <type_traits>
│ │ │ │ + │ │ │ │ +

Helpers for dealing with MPI. │ │ │ │ +More...

│ │ │ │ +
#include <cassert>
│ │ │ │ +#include <mpi.h>
│ │ │ │ +#include <mutex>
│ │ │ │ +#include <dune/common/parallel/communication.hh>
│ │ │ │ +#include <dune/common/parallel/mpicommunication.hh>
│ │ │ │ +#include <dune/common/stdstreams.hh>
│ │ │ │ +#include <dune/common/visibility.hh>
│ │ │ │
│ │ │ │

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...
 
struct  Dune::ReadWritePropertyMapTag
 Tag for the category of readable and writable property maps. More...
 
struct  Dune::LvaluePropertyMapTag
 Tag for the category of lvalue property maps. More...
 
struct  Dune::PropertyMapTraits< T * >
 
struct  Dune::PropertyMapTraits< const T * >
class  Dune::FakeMPIHelper
 A fake mpi helper. More...
 
struct  Dune::RAPropertyMapHelper< Reference, PropertyMap >
 
class  Dune::IteratorPropertyMap< RAI, IM, T, R >
 Adapter to turn a random access iterator into a property map. 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::MPIHelper
 A real mpi helper. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

│ │ │ │ Namespaces

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

│ │ │ │ -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)
 
│ │ │ │ -
│ │ │ │ +

Detailed Description

│ │ │ │ +

Helpers for dealing with MPI.

│ │ │ │ +

Basically there are two helpers available:

│ │ │ │ +
FakeMPIHelper
│ │ │ │ +
A class adhering to the interface of MPIHelper that does not need MPI at all. This can be used to create a sequential program even if MPI is used to compile it.
│ │ │ │ +
MPIHelper
│ │ │ │ +
A real MPI helper. When the singleton gets instantiated MPI_Init will be called and before the program exits MPI_Finalize will be called.
│ │ │ │ +
│ │ │ │ +

Example of who to use these classes:

│ │ │ │ +

A program that is parallel if compiled with MPI and sequential otherwise:

int main(int argc, char** argv){
│ │ │ │ +
typedef Dune::MPIHelper MPIHelper;
│ │ │ │ +
MPIHelper::instance(argc, argv);
│ │ │ │ +
typename MPIHelper::MPICommunicator world =
│ │ │ │ +
MPIHelper::getCommunicator();
│ │ │ │ +
...
│ │ │ │ +
int main(int argc, char **argv)
Definition mpi_collective_benchmark.cc:293
│ │ │ │ +
A real mpi helper.
Definition mpihelper.hh:179
│ │ │ │ +

If one wants to have sequential program even if the code is compiled with mpi then one simply has to exchange the typedef with

typedef Dune::MPIHelper FakeMPIHelper;
│ │ │ │ +

.

│ │ │ │ +

For checking whether we really use MPI or just fake please use MPIHelper::isFake (this is also possible at compile time!)

│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,67 +6,64 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Functions │ │ │ │ │ -propertymap.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ + * parallel │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +mpihelper.hh File Reference │ │ │ │ │ +Common » Parallel_Communication │ │ │ │ │ +Helpers for dealing with MPI. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -struct  Dune::PropertyMapTraits<_PM_> │ │ │ │ │ +class  Dune::FakeMPIHelper │ │ │ │ │ +  A fake mpi helper. More... │ │ │ │ │   │ │ │ │ │ -struct  Dune::ReadablePropertyMapTag │ │ │ │ │ -  Tag for the category of readable property maps. More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::WritablePropertyMapTag │ │ │ │ │ -  Tag for the category of writable property maps. More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::ReadWritePropertyMapTag │ │ │ │ │ -  Tag for the category of readable and writable property maps. More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::LvaluePropertyMapTag │ │ │ │ │ -  Tag for the category of lvalue property maps. More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::PropertyMapTraits<_T_*_> │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::PropertyMapTraits<_const_T_*_> │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::RAPropertyMapHelper<_Reference,_PropertyMap_> │ │ │ │ │ -  │ │ │ │ │ - class  Dune::IteratorPropertyMap<_RAI,_IM,_T,_R_> │ │ │ │ │ -  Adapter to turn a random access iterator into a property map. 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::MPIHelper │ │ │ │ │ +  A real mpi helper. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ - 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) │ │ │ │ │ -  │ │ │ │ │ +***** Detailed Description ***** │ │ │ │ │ +Helpers for dealing with MPI. │ │ │ │ │ +Basically there are two helpers available: │ │ │ │ │ + FakeMPIHelper │ │ │ │ │ + A class adhering to the interface of MPIHelper that does not need MPI at │ │ │ │ │ + all. This can be used to create a sequential program even if MPI is used │ │ │ │ │ + to compile it. │ │ │ │ │ + MPIHelper │ │ │ │ │ + A real MPI helper. When the singleton gets instantiated MPI_Init will be │ │ │ │ │ + called and before the program exits MPI_Finalize will be called. │ │ │ │ │ +Example of who to use these classes: │ │ │ │ │ +A program that is parallel if compiled with MPI and sequential otherwise: │ │ │ │ │ +int main(int argc, char** argv){ │ │ │ │ │ +typedef Dune::MPIHelper MPIHelper; │ │ │ │ │ +MPIHelper::instance(argc, argv); │ │ │ │ │ +typename MPIHelper::MPICommunicator world = │ │ │ │ │ +MPIHelper::getCommunicator(); │ │ │ │ │ +... │ │ │ │ │ +main │ │ │ │ │ +int main(int argc, char **argv) │ │ │ │ │ +Definition mpi_collective_benchmark.cc:293 │ │ │ │ │ +Dune::MPIHelper │ │ │ │ │ +A real mpi helper. │ │ │ │ │ +Definition mpihelper.hh:179 │ │ │ │ │ +If one wants to have sequential program even if the code is compiled with mpi │ │ │ │ │ +then one simply has to exchange the typedef with │ │ │ │ │ +typedef Dune::MPIHelper FakeMPIHelper; │ │ │ │ │ +. │ │ │ │ │ +For checking whether we really use MPI or just fake please use MPIHelper:: │ │ │ │ │ +isFake (this is also possible at compile time!) │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00014_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: propertymap.hh Source File │ │ │ │ +dune-common: mpihelper.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,311 +70,267 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
propertymap.hh
│ │ │ │ +
mpihelper.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 (C) 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
│ │ │ │ +
5#ifndef DUNE_MPIHELPER
│ │ │ │ +
6#define DUNE_MPIHELPER
│ │ │ │
7
│ │ │ │ -
8#include <cstddef>
│ │ │ │ -
9#include <iterator>
│ │ │ │ -
10#include <type_traits>
│ │ │ │ -
11
│ │ │ │ -
12namespace Dune
│ │ │ │ -
13{
│ │ │ │ +
8#if HAVE_MPI
│ │ │ │ +
9#include <cassert>
│ │ │ │ +
10#include <mpi.h>
│ │ │ │ +
11#endif
│ │ │ │ +
12
│ │ │ │ +
13#include <mutex>
│ │ │ │
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 {};
│ │ │ │ -
│ │ │ │ + │ │ │ │ +
16#if HAVE_MPI
│ │ │ │ + │ │ │ │ + │ │ │ │ +
19#endif
│ │ │ │ + │ │ │ │ +
21
│ │ │ │ +
22namespace Dune
│ │ │ │ +
23{
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
74 {
│ │ │ │ +
75 public:
│ │ │ │ +
80 constexpr static bool isFake = true;
│ │ │ │
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 }
│ │ │ │ -
│ │ │ │ + │ │ │ │ +
86
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
94 {
│ │ │ │ +
95 static MPICommunicator comm;
│ │ │ │ +
96 return comm;
│ │ │ │ +
97 }
│ │ │ │ +
│ │ │ │ +
98
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
106 {
│ │ │ │ +
107 return getCommunicator();
│ │ │ │ +
108 }
│ │ │ │ +
│ │ │ │ +
109
│ │ │ │ +
110
│ │ │ │ +
111
│ │ │ │ +
117 [[deprecated("getCollectionCommunication is deprecated. Use getCommunication instead.")]]
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
119 {
│ │ │ │ + │ │ │ │ +
121 }
│ │ │ │ +
│ │ │ │ +
122
│ │ │ │ + │ │ │ │ +
│ │ │ │ + │ │ │ │ +
125 {
│ │ │ │ + │ │ │ │ +
127 }
│ │ │ │ +
│ │ │ │ +
128
│ │ │ │ +
│ │ │ │ +
144 DUNE_EXPORT static FakeMPIHelper& instance([[maybe_unused]] int argc,
│ │ │ │ +
145 [[maybe_unused]] char** argv)
│ │ │ │ +
146 {
│ │ │ │ +
147 return instance();
│ │ │ │ +
148 }
│ │ │ │ +
│ │ │ │ +
149
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
151 {
│ │ │ │ +
152 static FakeMPIHelper singleton;
│ │ │ │ +
153 return singleton;
│ │ │ │ +
154 }
│ │ │ │ +
│ │ │ │ +
155
│ │ │ │ +
159 int rank () const { return 0; }
│ │ │ │ +
163 int size () const { return 1; }
│ │ │ │
164
│ │ │ │
165 private:
│ │ │ │ - │ │ │ │ -
169 IndexMap indexMap_;
│ │ │ │ -
170 };
│ │ │ │ -
│ │ │ │ -
171
│ │ │ │ -
176 template<typename T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
178 : RAPropertyMapHelper<typename T::value_type::second_type&,
│ │ │ │ -
179 AssociativePropertyMap<T> >
│ │ │ │ -
180 {
│ │ │ │ -
184 typedef T UniqueAssociativeContainer;
│ │ │ │ -
185
│ │ │ │ -
189 typedef typename UniqueAssociativeContainer::value_type::first_type
│ │ │ │ -
190 KeyType;
│ │ │ │ +
166 FakeMPIHelper() {}
│ │ │ │ +
167 FakeMPIHelper(const FakeMPIHelper&);
│ │ │ │ +
168 FakeMPIHelper& operator=(const FakeMPIHelper);
│ │ │ │ +
169 };
│ │ │ │ +
│ │ │ │ +
170
│ │ │ │ +
171#if HAVE_MPI
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
179 {
│ │ │ │ +
180 public:
│ │ │ │ +
185 constexpr static bool isFake = false;
│ │ │ │ +
186
│ │ │ │ +
190 typedef MPI_Comm MPICommunicator;
│ │ │ │
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;
│ │ │ │ -
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 };
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
199 {
│ │ │ │ +
200 return MPI_COMM_WORLD;
│ │ │ │ +
201 }
│ │ │ │
│ │ │ │ +
202
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
210 {
│ │ │ │ +
211 return MPI_COMM_SELF;
│ │ │ │ +
212 }
│ │ │ │ +
│ │ │ │ +
213
│ │ │ │ +
219 [[deprecated("getCollectionCommunication is deprecated. Use getCommunication instead.")]]
│ │ │ │ + │ │ │ │ +
│ │ │ │ + │ │ │ │ +
222 {
│ │ │ │ + │ │ │ │ +
224 }
│ │ │ │ +
│ │ │ │ +
225
│ │ │ │ + │ │ │ │ +
│ │ │ │ + │ │ │ │ +
228 {
│ │ │ │ + │ │ │ │ +
230 }
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
246 DUNE_EXPORT static MPIHelper& instance(int& argc, char**& argv)
│ │ │ │ +
247 {
│ │ │ │ +
248 // create singleton instance
│ │ │ │ +
249 if (!instance_){
│ │ │ │ +
250 static std::mutex mutex;
│ │ │ │ +
251 std::lock_guard<std::mutex> guard(mutex);
│ │ │ │ +
252 if(!instance_)
│ │ │ │ +
253 instance_.reset(new MPIHelper(argc,argv));
│ │ │ │ +
254 }
│ │ │ │ +
255 return *instance_;
│ │ │ │ +
256 }
│ │ │ │ +
│ │ │ │ +
257
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
259 {
│ │ │ │ +
260 if(!instance_)
│ │ │ │ +
261 DUNE_THROW(InvalidStateException, "MPIHelper not initialized! Call MPIHelper::instance(argc, argv) with arguments first.");
│ │ │ │ +
262 return *instance_;
│ │ │ │ +
263 }
│ │ │ │ +
│ │ │ │ +
264
│ │ │ │ +
268 int rank () const { return rank_; }
│ │ │ │ +
272 int size () const { return size_; }
│ │ │ │ +
273
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
276 {
│ │ │ │ +
277 int wasFinalized = -1;
│ │ │ │ +
278 MPI_Finalized( &wasFinalized );
│ │ │ │ +
279 if(!wasFinalized && initializedHere_)
│ │ │ │ +
280 {
│ │ │ │ +
281 MPI_Finalize();
│ │ │ │ +
282 dverb << "Called MPI_Finalize on p=" << rank_ << "!" <<std::endl;
│ │ │ │ +
283 }
│ │ │ │ +
284
│ │ │ │ +
285 }
│ │ │ │ +
│ │ │ │ +
286
│ │ │ │ +
287 private:
│ │ │ │ +
288 int rank_;
│ │ │ │ +
289 int size_;
│ │ │ │ +
290 bool initializedHere_;
│ │ │ │ +
291 void prevent_warning(int){}
│ │ │ │ +
292 static inline std::unique_ptr<MPIHelper> instance_ = {};
│ │ │ │ +
293
│ │ │ │ +
295 MPIHelper(int& argc, char**& argv)
│ │ │ │ +
296 : initializedHere_(false)
│ │ │ │ +
297 {
│ │ │ │ +
298 int wasInitialized = -1;
│ │ │ │ +
299 MPI_Initialized( &wasInitialized );
│ │ │ │ +
300 if(!wasInitialized)
│ │ │ │ +
301 {
│ │ │ │ +
302 rank_ = -1;
│ │ │ │ +
303 size_ = -1;
│ │ │ │ +
304 static int is_initialized = MPI_Init(&argc, &argv);
│ │ │ │ +
305 prevent_warning(is_initialized);
│ │ │ │ +
306 initializedHere_ = true;
│ │ │ │ +
307 }
│ │ │ │ +
308
│ │ │ │ +
309 MPI_Comm_rank(MPI_COMM_WORLD,&rank_);
│ │ │ │ +
310 MPI_Comm_size(MPI_COMM_WORLD,&size_);
│ │ │ │
311
│ │ │ │ -
312
│ │ │ │ -
318 template<typename T, typename C>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
320 {
│ │ │ │ -
324 typedef T Tag;
│ │ │ │ -
329 typedef C Container;
│ │ │ │ -
330 };
│ │ │ │ -
│ │ │ │ +
312 assert( rank_ >= 0 );
│ │ │ │ +
313 assert( size_ >= 1 );
│ │ │ │ +
314
│ │ │ │ +
315 dverb << "Called MPI_Init on p=" << rank_ << "!" << std::endl;
│ │ │ │ +
316 }
│ │ │ │ +
317
│ │ │ │ +
318 MPIHelper(const MPIHelper&);
│ │ │ │ +
319 MPIHelper& operator=(const MPIHelper);
│ │ │ │ +
320 };
│ │ │ │ +
│ │ │ │ +
321#else // !HAVE_MPI
│ │ │ │ +
322 // We do not have MPI therefore FakeMPIHelper
│ │ │ │ +
323 // is the MPIHelper
│ │ │ │ +
328 typedef FakeMPIHelper MPIHelper;
│ │ │ │ +
329
│ │ │ │ +
330#endif // !HAVE_MPI
│ │ │ │
331
│ │ │ │ -
332}
│ │ │ │ -
333
│ │ │ │ -
334#endif
│ │ │ │ +
332} // end namespace Dune
│ │ │ │ +
333#endif
│ │ │ │ +
Implements an utility class that provides MPI's collective communication methods.
│ │ │ │ +
Implements an utility class that provides collective communication methods for sequential programs.
│ │ │ │ +
Standard Dune debug streams.
│ │ │ │ +
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
│ │ │ │ +
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
│ │ │ │ +
DVerbType dverb(std::cout)
Singleton of verbose debug stream.
Definition stdstreams.hh:116
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
void put(const RAPropertyMapHelper< Reference, PropertyMap > &pmap, const Key &key, const Value &value)
Definition propertymap.hh:92
│ │ │ │ -
Reference get(const RAPropertyMapHelper< Reference, PropertyMap > &pmap, const Key &key)
Definition propertymap.hh:84
│ │ │ │ -
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
│ │ │ │ +
Default exception if a function was called while the object is not in a valid state for that function...
Definition exceptions.hh:281
│ │ │ │ +
Definition communication.hh:46
│ │ │ │ +
Collective communication interface and sequential default implementation.
Definition communication.hh:100
│ │ │ │ +
A fake mpi helper.
Definition mpihelper.hh:74
│ │ │ │ +
static DUNE_EXPORT MPICommunicator getCommunicator()
get the default communicator
Definition mpihelper.hh:93
│ │ │ │ +
int size() const
return rank of process, i.e. one
Definition mpihelper.hh:163
│ │ │ │ +
static Communication< MPICommunicator > getCollectiveCommunication()
Definition mpihelper.hh:118
│ │ │ │ +
static MPICommunicator getLocalCommunicator()
get a local communicator
Definition mpihelper.hh:105
│ │ │ │ +
No_Comm MPICommunicator
The type of the mpi communicator.
Definition mpihelper.hh:85
│ │ │ │ +
static DUNE_EXPORT FakeMPIHelper & instance(int argc, char **argv)
Get the singleton instance of the helper.
Definition mpihelper.hh:144
│ │ │ │ +
static DUNE_EXPORT FakeMPIHelper & instance()
Definition mpihelper.hh:150
│ │ │ │ +
static Communication< MPICommunicator > getCommunication()
Definition mpihelper.hh:124
│ │ │ │ +
static constexpr bool isFake
Are we fake (i.e. pretend to have MPI support but are compiled without.)
Definition mpihelper.hh:80
│ │ │ │ +
int rank() const
return rank of process, i.e. zero
Definition mpihelper.hh:159
│ │ │ │ +
A real mpi helper.
Definition mpihelper.hh:179
│ │ │ │ +
int size() const
return number of processes
Definition mpihelper.hh:272
│ │ │ │ +
static DUNE_EXPORT MPIHelper & instance()
Definition mpihelper.hh:258
│ │ │ │ +
static constexpr bool isFake
Are we fake (i. e. pretend to have MPI support but are compiled without.
Definition mpihelper.hh:185
│ │ │ │ +
static DUNE_EXPORT MPIHelper & instance(int &argc, char **&argv)
Get the singleton instance of the helper.
Definition mpihelper.hh:246
│ │ │ │ +
static Communication< MPICommunicator > getCommunication()
Definition mpihelper.hh:227
│ │ │ │ +
~MPIHelper()
calls MPI_Finalize
Definition mpihelper.hh:275
│ │ │ │ +
int rank() const
return rank of process
Definition mpihelper.hh:268
│ │ │ │ +
MPI_Comm MPICommunicator
The type of the mpi communicator.
Definition mpihelper.hh:190
│ │ │ │ +
static MPICommunicator getCommunicator()
get the default communicator
Definition mpihelper.hh:198
│ │ │ │ +
static MPICommunicator getLocalCommunicator()
get a local communicator
Definition mpihelper.hh:209
│ │ │ │ +
static Communication< MPICommunicator > getCollectiveCommunication()
Definition mpihelper.hh:221
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,369 +7,316 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -propertymap.hh │ │ │ │ │ + * parallel │ │ │ │ │ +mpihelper.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 (C) 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 │ │ │ │ │ + 5#ifndef DUNE_MPIHELPER │ │ │ │ │ + 6#define DUNE_MPIHELPER │ │ │ │ │ 7 │ │ │ │ │ - 8#include │ │ │ │ │ - 9#include │ │ │ │ │ - 10#include │ │ │ │ │ - 11 │ │ │ │ │ - 12namespace Dune │ │ │ │ │ - 13{ │ │ │ │ │ + 8#if HAVE_MPI │ │ │ │ │ + 9#include │ │ │ │ │ + 10#include │ │ │ │ │ + 11#endif │ │ │ │ │ + 12 │ │ │ │ │ + 13#include │ │ │ │ │ 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 {}; │ │ │ │ │ + 15#include │ │ │ │ │ + 16#if HAVE_MPI │ │ │ │ │ + 17#include │ │ │ │ │ + 18#include │ │ │ │ │ + 19#endif │ │ │ │ │ + 20#include │ │ │ │ │ + 21 │ │ │ │ │ + 22namespace Dune │ │ │ │ │ + 23{ │ │ │ │ │ +73 class FakeMPIHelper │ │ │ │ │ + 74 { │ │ │ │ │ + 75 public: │ │ │ │ │ +80 constexpr static bool isFake = true; │ │ │ │ │ 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) │ │ │ │ │ +85 typedef No_Comm MPICommunicator; │ │ │ │ │ + 86 │ │ │ │ │ +93 DUNE_EXPORT static MPICommunicator getCommunicator () │ │ │ │ │ 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 } │ │ │ │ │ + 95 static MPICommunicator comm; │ │ │ │ │ + 96 return comm; │ │ │ │ │ + 97 } │ │ │ │ │ + 98 │ │ │ │ │ +105 static MPICommunicator getLocalCommunicator () │ │ │ │ │ + 106 { │ │ │ │ │ + 107 return getCommunicator(); │ │ │ │ │ + 108 } │ │ │ │ │ + 109 │ │ │ │ │ + 110 │ │ │ │ │ + 111 │ │ │ │ │ + 117 [[deprecated("getCollectionCommunication is deprecated. Use │ │ │ │ │ +getCommunication instead.")]] │ │ │ │ │ +118 static Communication getCollectiveCommunication() │ │ │ │ │ + 119 { │ │ │ │ │ + 120 return Communication(getCommunicator()); │ │ │ │ │ + 121 } │ │ │ │ │ + 122 │ │ │ │ │ + 123 static Communication │ │ │ │ │ +124 getCommunication() │ │ │ │ │ + 125 { │ │ │ │ │ + 126 return Communication(getCommunicator()); │ │ │ │ │ + 127 } │ │ │ │ │ + 128 │ │ │ │ │ +144 DUNE_EXPORT static FakeMPIHelper& instance([[maybe_unused]] int argc, │ │ │ │ │ + 145 [[maybe_unused]] char** argv) │ │ │ │ │ + 146 { │ │ │ │ │ + 147 return instance(); │ │ │ │ │ + 148 } │ │ │ │ │ + 149 │ │ │ │ │ +150 DUNE_EXPORT static FakeMPIHelper& instance() │ │ │ │ │ + 151 { │ │ │ │ │ + 152 static FakeMPIHelper singleton; │ │ │ │ │ + 153 return singleton; │ │ │ │ │ + 154 } │ │ │ │ │ + 155 │ │ │ │ │ +159 int rank () const { return 0; } │ │ │ │ │ +163 int size () const { return 1; } │ │ │ │ │ 164 │ │ │ │ │ 165 private: │ │ │ │ │ - 167 RandomAccessIterator iter_; │ │ │ │ │ - 169 IndexMap indexMap_; │ │ │ │ │ - 170 }; │ │ │ │ │ - 171 │ │ │ │ │ - 176 template │ │ │ │ │ -177 class AssociativePropertyMap │ │ │ │ │ - 178 : RAPropertyMapHelper > │ │ │ │ │ - 180 { │ │ │ │ │ - 184 typedef T UniqueAssociativeContainer; │ │ │ │ │ - 185 │ │ │ │ │ - 189 typedef typename UniqueAssociativeContainer::value_type::first_type │ │ │ │ │ - 190 KeyType; │ │ │ │ │ + 166 FakeMPIHelper() {} │ │ │ │ │ + 167 FakeMPIHelper(const FakeMPIHelper&); │ │ │ │ │ + 168 FakeMPIHelper& operator=(const FakeMPIHelper); │ │ │ │ │ + 169 }; │ │ │ │ │ + 170 │ │ │ │ │ + 171#if HAVE_MPI │ │ │ │ │ +178 class MPIHelper │ │ │ │ │ + 179 { │ │ │ │ │ + 180 public: │ │ │ │ │ +185 constexpr static bool isFake = false; │ │ │ │ │ + 186 │ │ │ │ │ +190 typedef MPI_Comm MPICommunicator; │ │ │ │ │ 191 │ │ │ │ │ - 195 typedef typename UniqueAssociativeContainer::value_type::second_type │ │ │ │ │ - 196 ValueType; │ │ │ │ │ - 197 │ │ │ │ │ - 201 typedef ValueType& Reference; │ │ │ │ │ +198 static MPICommunicator getCommunicator () │ │ │ │ │ + 199 { │ │ │ │ │ + 200 return MPI_COMM_WORLD; │ │ │ │ │ + 201 } │ │ │ │ │ 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; │ │ │ │ │ - 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; │ │ │ │ │ +209 static MPICommunicator getLocalCommunicator () │ │ │ │ │ + 210 { │ │ │ │ │ + 211 return MPI_COMM_SELF; │ │ │ │ │ + 212 } │ │ │ │ │ + 213 │ │ │ │ │ + 219 [[deprecated("getCollectionCommunication is deprecated. Use │ │ │ │ │ +getCommunication instead.")]] │ │ │ │ │ + 220 static Communication │ │ │ │ │ +221 getCollectiveCommunication() │ │ │ │ │ + 222 { │ │ │ │ │ + 223 return Communication(getCommunicator()); │ │ │ │ │ + 224 } │ │ │ │ │ + 225 │ │ │ │ │ + 226 static Communication │ │ │ │ │ +227 getCommunication() │ │ │ │ │ + 228 { │ │ │ │ │ + 229 return Communication(getCommunicator()); │ │ │ │ │ + 230 } │ │ │ │ │ +246 DUNE_EXPORT static MPIHelper& instance(int& argc, char**& argv) │ │ │ │ │ + 247 { │ │ │ │ │ + 248 // create singleton instance │ │ │ │ │ + 249 if (!instance_){ │ │ │ │ │ + 250 static std::mutex mutex; │ │ │ │ │ + 251 std::lock_guard guard(mutex); │ │ │ │ │ + 252 if(!instance_) │ │ │ │ │ + 253 instance_.reset(new MPIHelper(argc,argv)); │ │ │ │ │ + 254 } │ │ │ │ │ + 255 return *instance_; │ │ │ │ │ + 256 } │ │ │ │ │ + 257 │ │ │ │ │ +258 DUNE_EXPORT static MPIHelper& instance() │ │ │ │ │ + 259 { │ │ │ │ │ + 260 if(!instance_) │ │ │ │ │ + 261 DUNE_THROW(InvalidStateException, "MPIHelper not initialized! Call │ │ │ │ │ +MPIHelper::instance(argc, argv) with arguments first."); │ │ │ │ │ + 262 return *instance_; │ │ │ │ │ + 263 } │ │ │ │ │ + 264 │ │ │ │ │ +268 int rank () const { return rank_; } │ │ │ │ │ +272 int size () const { return size_; } │ │ │ │ │ + 273 │ │ │ │ │ +275 ~MPIHelper() │ │ │ │ │ + 276 { │ │ │ │ │ + 277 int wasFinalized = -1; │ │ │ │ │ + 278 MPI_Finalized( &wasFinalized ); │ │ │ │ │ + 279 if(!wasFinalized && initializedHere_) │ │ │ │ │ + 280 { │ │ │ │ │ + 281 MPI_Finalize(); │ │ │ │ │ + 282 dverb << "Called MPI_Finalize on p=" << rank_ << "!" < │ │ │ │ │ - 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 }; │ │ │ │ │ + 284 │ │ │ │ │ + 285 } │ │ │ │ │ + 286 │ │ │ │ │ + 287 private: │ │ │ │ │ + 288 int rank_; │ │ │ │ │ + 289 int size_; │ │ │ │ │ + 290 bool initializedHere_; │ │ │ │ │ + 291 void prevent_warning(int){} │ │ │ │ │ + 292 static inline std::unique_ptr instance_ = {}; │ │ │ │ │ + 293 │ │ │ │ │ + 295 MPIHelper(int& argc, char**& argv) │ │ │ │ │ + 296 : initializedHere_(false) │ │ │ │ │ + 297 { │ │ │ │ │ + 298 int wasInitialized = -1; │ │ │ │ │ + 299 MPI_Initialized( &wasInitialized ); │ │ │ │ │ + 300 if(!wasInitialized) │ │ │ │ │ + 301 { │ │ │ │ │ + 302 rank_ = -1; │ │ │ │ │ + 303 size_ = -1; │ │ │ │ │ + 304 static int is_initialized = MPI_Init(&argc, &argv); │ │ │ │ │ + 305 prevent_warning(is_initialized); │ │ │ │ │ + 306 initializedHere_ = true; │ │ │ │ │ + 307 } │ │ │ │ │ + 308 │ │ │ │ │ + 309 MPI_Comm_rank(MPI_COMM_WORLD,&rank_); │ │ │ │ │ + 310 MPI_Comm_size(MPI_COMM_WORLD,&size_); │ │ │ │ │ 311 │ │ │ │ │ - 312 │ │ │ │ │ - 318 template │ │ │ │ │ -319 struct PropertyMapTypeSelector │ │ │ │ │ - 320 { │ │ │ │ │ -324 typedef T Tag; │ │ │ │ │ -329 typedef C Container; │ │ │ │ │ - 330 }; │ │ │ │ │ + 312 assert( rank_ >= 0 ); │ │ │ │ │ + 313 assert( size_ >= 1 ); │ │ │ │ │ + 314 │ │ │ │ │ + 315 dverb << "Called MPI_Init on p=" << rank_ << "!" << std::endl; │ │ │ │ │ + 316 } │ │ │ │ │ + 317 │ │ │ │ │ + 318 MPIHelper(const MPIHelper&); │ │ │ │ │ + 319 MPIHelper& operator=(const MPIHelper); │ │ │ │ │ + 320 }; │ │ │ │ │ + 321#else // !HAVE_MPI │ │ │ │ │ + 322 // We do not have MPI therefore FakeMPIHelper │ │ │ │ │ + 323 // is the MPIHelper │ │ │ │ │ + 328 typedef FakeMPIHelper MPIHelper; │ │ │ │ │ + 329 │ │ │ │ │ + 330#endif // !HAVE_MPI │ │ │ │ │ 331 │ │ │ │ │ - 332} │ │ │ │ │ - 333 │ │ │ │ │ - 334#endif │ │ │ │ │ + 332} // end namespace Dune │ │ │ │ │ + 333#endif │ │ │ │ │ +mpicommunication.hh │ │ │ │ │ +Implements an utility class that provides MPI's collective communication │ │ │ │ │ +methods. │ │ │ │ │ +communication.hh │ │ │ │ │ +Implements an utility class that provides collective communication methods for │ │ │ │ │ +sequential programs. │ │ │ │ │ +stdstreams.hh │ │ │ │ │ +Standard Dune debug streams. │ │ │ │ │ +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_THROW │ │ │ │ │ +#define DUNE_THROW(E, m) │ │ │ │ │ +Definition exceptions.hh:218 │ │ │ │ │ +Dune::dverb │ │ │ │ │ +DVerbType dverb(std::cout) │ │ │ │ │ +Singleton of verbose debug stream. │ │ │ │ │ +Definition stdstreams.hh:116 │ │ │ │ │ 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 │ │ │ │ │ -Reference get(const RAPropertyMapHelper< Reference, PropertyMap > &pmap, const │ │ │ │ │ -Key &key) │ │ │ │ │ -Definition propertymap.hh:84 │ │ │ │ │ -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::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::No_Comm │ │ │ │ │ +Definition communication.hh:46 │ │ │ │ │ +Dune::Communication │ │ │ │ │ +Collective communication interface and sequential default implementation. │ │ │ │ │ +Definition communication.hh:100 │ │ │ │ │ +Dune::FakeMPIHelper │ │ │ │ │ +A fake mpi helper. │ │ │ │ │ +Definition mpihelper.hh:74 │ │ │ │ │ +Dune::FakeMPIHelper::getCommunicator │ │ │ │ │ +static DUNE_EXPORT MPICommunicator getCommunicator() │ │ │ │ │ +get the default communicator │ │ │ │ │ +Definition mpihelper.hh:93 │ │ │ │ │ +Dune::FakeMPIHelper::size │ │ │ │ │ +int size() const │ │ │ │ │ +return rank of process, i.e. one │ │ │ │ │ +Definition mpihelper.hh:163 │ │ │ │ │ +Dune::FakeMPIHelper::getCollectiveCommunication │ │ │ │ │ +static Communication< MPICommunicator > getCollectiveCommunication() │ │ │ │ │ +Definition mpihelper.hh:118 │ │ │ │ │ +Dune::FakeMPIHelper::getLocalCommunicator │ │ │ │ │ +static MPICommunicator getLocalCommunicator() │ │ │ │ │ +get a local communicator │ │ │ │ │ +Definition mpihelper.hh:105 │ │ │ │ │ +Dune::FakeMPIHelper::MPICommunicator │ │ │ │ │ +No_Comm MPICommunicator │ │ │ │ │ +The type of the mpi communicator. │ │ │ │ │ +Definition mpihelper.hh:85 │ │ │ │ │ +Dune::FakeMPIHelper::instance │ │ │ │ │ +static DUNE_EXPORT FakeMPIHelper & instance(int argc, char **argv) │ │ │ │ │ +Get the singleton instance of the helper. │ │ │ │ │ +Definition mpihelper.hh:144 │ │ │ │ │ +Dune::FakeMPIHelper::instance │ │ │ │ │ +static DUNE_EXPORT FakeMPIHelper & instance() │ │ │ │ │ +Definition mpihelper.hh:150 │ │ │ │ │ +Dune::FakeMPIHelper::getCommunication │ │ │ │ │ +static Communication< MPICommunicator > getCommunication() │ │ │ │ │ +Definition mpihelper.hh:124 │ │ │ │ │ +Dune::FakeMPIHelper::isFake │ │ │ │ │ +static constexpr bool isFake │ │ │ │ │ +Are we fake (i.e. pretend to have MPI support but are compiled without.) │ │ │ │ │ +Definition mpihelper.hh:80 │ │ │ │ │ +Dune::FakeMPIHelper::rank │ │ │ │ │ +int rank() const │ │ │ │ │ +return rank of process, i.e. zero │ │ │ │ │ +Definition mpihelper.hh:159 │ │ │ │ │ +Dune::MPIHelper │ │ │ │ │ +A real mpi helper. │ │ │ │ │ +Definition mpihelper.hh:179 │ │ │ │ │ +Dune::MPIHelper::size │ │ │ │ │ +int size() const │ │ │ │ │ +return number of processes │ │ │ │ │ +Definition mpihelper.hh:272 │ │ │ │ │ +Dune::MPIHelper::instance │ │ │ │ │ +static DUNE_EXPORT MPIHelper & instance() │ │ │ │ │ +Definition mpihelper.hh:258 │ │ │ │ │ +Dune::MPIHelper::isFake │ │ │ │ │ +static constexpr bool isFake │ │ │ │ │ +Are we fake (i. e. pretend to have MPI support but are compiled without. │ │ │ │ │ +Definition mpihelper.hh:185 │ │ │ │ │ +Dune::MPIHelper::instance │ │ │ │ │ +static DUNE_EXPORT MPIHelper & instance(int &argc, char **&argv) │ │ │ │ │ +Get the singleton instance of the helper. │ │ │ │ │ +Definition mpihelper.hh:246 │ │ │ │ │ +Dune::MPIHelper::getCommunication │ │ │ │ │ +static Communication< MPICommunicator > getCommunication() │ │ │ │ │ +Definition mpihelper.hh:227 │ │ │ │ │ +Dune::MPIHelper::~MPIHelper │ │ │ │ │ +~MPIHelper() │ │ │ │ │ +calls MPI_Finalize │ │ │ │ │ +Definition mpihelper.hh:275 │ │ │ │ │ +Dune::MPIHelper::rank │ │ │ │ │ +int rank() const │ │ │ │ │ +return rank of process │ │ │ │ │ +Definition mpihelper.hh:268 │ │ │ │ │ +Dune::MPIHelper::MPICommunicator │ │ │ │ │ +MPI_Comm MPICommunicator │ │ │ │ │ +The type of the mpi communicator. │ │ │ │ │ +Definition mpihelper.hh:190 │ │ │ │ │ +Dune::MPIHelper::getCommunicator │ │ │ │ │ +static MPICommunicator getCommunicator() │ │ │ │ │ +get the default communicator │ │ │ │ │ +Definition mpihelper.hh:198 │ │ │ │ │ +Dune::MPIHelper::getLocalCommunicator │ │ │ │ │ +static MPICommunicator getLocalCommunicator() │ │ │ │ │ +get a local communicator │ │ │ │ │ +Definition mpihelper.hh:209 │ │ │ │ │ +Dune::MPIHelper::getCollectiveCommunication │ │ │ │ │ +static Communication< MPICommunicator > getCollectiveCommunication() │ │ │ │ │ +Definition mpihelper.hh:221 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00017.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: parametertreeparser.cc File Reference │ │ │ │ +dune-common: mpidata.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,32 +65,61 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
parametertreeparser.cc File Reference
│ │ │ │ +
│ │ │ │ +Classes | │ │ │ │ +Namespaces | │ │ │ │ +Functions
│ │ │ │ +
mpidata.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ -
#include "parametertreeparser.hh"
│ │ │ │ -#include <cstdlib>
│ │ │ │ -#include <iostream>
│ │ │ │ -#include <ostream>
│ │ │ │ + │ │ │ │ +

Interface class to translate objects to a MPI_Datatype, void* and size used for MPI calls. │ │ │ │ +More...

│ │ │ │ +
#include <vector>
│ │ │ │ #include <string>
│ │ │ │ -#include <sstream>
│ │ │ │ -#include <fstream>
│ │ │ │ -#include <set>
│ │ │ │ -#include <map>
│ │ │ │ -#include <algorithm>
│ │ │ │ -#include <dune/common/exceptions.hh>
│ │ │ │ +#include <dune/common/typetraits.hh>
│ │ │ │ +#include <dune/common/std/type_traits.hh>
│ │ │ │ +#include <dune/common/parallel/mpitraits.hh>
│ │ │ │ +
│ │ │ │ +

Go to the source code of this file.

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

│ │ │ │ +Classes

struct  Dune::MPIData< T, Enable >
 
struct  Dune::MPIData< void >
 
struct  Dune::MPIData< T, std::void_t< std::tuple< decltype(std::declval< T >().data()), decltype(std::declval< T >().size()), typename std::decay_t< T >::value_type > > >
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Namespaces

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

│ │ │ │ +Functions

template<class T >
auto Dune::getMPIData (T &t)
 
│ │ │ │ +

Detailed Description

│ │ │ │ +

Interface class to translate objects to a MPI_Datatype, void* and size used for MPI calls.

│ │ │ │ +

Furthermore it can be used to resize the object if possible. This makes it possible to receive a message with variable size. See Communication::rrecv.

│ │ │ │ +

To 'register' a new dynamic type for MPI communication specialize MPIData or overload getMPIData.

│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,22 +6,46 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -parametertreeparser.cc File Reference │ │ │ │ │ -#include "parametertreeparser.hh" │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ + * parallel │ │ │ │ │ +Classes | Namespaces | Functions │ │ │ │ │ +mpidata.hh File Reference │ │ │ │ │ +Common » Parallel_Communication │ │ │ │ │ +Interface class to translate objects to a MPI_Datatype, void* and size used for │ │ │ │ │ +MPI calls. More... │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +Go_to_the_source_code_of_this_file. │ │ │ │ │ + Classes │ │ │ │ │ +struct  Dune::MPIData<_T,_Enable_> │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::MPIData<_void_> │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::MPIData<_T,_std::void_t<_std::tuple<_decltype(std::declval<_T_> │ │ │ │ │ + ().data()),_decltype(std::declval<_T_>().size()),_typename_std:: │ │ │ │ │ + decay_t<_T_>::value_type_>_>_> │ │ │ │ │ +  │ │ │ │ │ + Namespaces │ │ │ │ │ +namespace  Dune │ │ │ │ │ +  Dune namespace. │ │ │ │ │ +  │ │ │ │ │ + Functions │ │ │ │ │ +template │ │ │ │ │ +auto Dune::getMPIData (T &t) │ │ │ │ │ +  │ │ │ │ │ +***** Detailed Description ***** │ │ │ │ │ +Interface class to translate objects to a MPI_Datatype, void* and size used for │ │ │ │ │ +MPI calls. │ │ │ │ │ +Furthermore it can be used to resize the object if possible. This makes it │ │ │ │ │ +possible to receive a message with variable size. See Communication::rrecv. │ │ │ │ │ +To 'register' a new dynamic type for MPI communication specialize MPIData or │ │ │ │ │ +overload getMPIData. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00020.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: promotiontraits.hh File Reference │ │ │ │ +dune-common: mpitraits.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,48 +65,51 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ Namespaces
│ │ │ │ -
promotiontraits.hh File Reference
│ │ │ │ +
mpitraits.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ -

Compute type of the result of an arithmetic operation involving two different number types. │ │ │ │ +

Traits classes for mapping types onto MPI_Datatype. │ │ │ │ More...

│ │ │ │ -
#include <utility>
│ │ │ │ +
#include <cstddef>
│ │ │ │ +#include <cstdint>
│ │ │ │ +#include <type_traits>
│ │ │ │ +#include <utility>
│ │ │ │ +#include <complex>
│ │ │ │ +#include <mpi.h>
│ │ │ │
│ │ │ │

Go to the source code of this file.

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

│ │ │ │ Classes

struct  Dune::PromotionTraits< T1, T2 >
 Compute type of the result of an arithmetic operation involving two different number types. More...
 
struct  Dune::PromotionTraits< T1, T1 >
struct  Dune::MPITraits< T >
 A traits class describing the mapping of types onto MPI_Datatypes. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │

Detailed Description

│ │ │ │ -

Compute type of the result of an arithmetic operation involving two different number types.

│ │ │ │ -
Author
Matthias Wohlmuth
│ │ │ │ +

Traits classes for mapping types onto MPI_Datatype.

│ │ │ │ +
Author
Markus Blatt
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,32 +6,35 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ + * parallel │ │ │ │ │ Classes | Namespaces │ │ │ │ │ -promotiontraits.hh File Reference │ │ │ │ │ -Compute type of the result of an arithmetic operation involving two different │ │ │ │ │ -number types. More... │ │ │ │ │ +mpitraits.hh File Reference │ │ │ │ │ +Common » Parallel_Communication │ │ │ │ │ +Traits classes for mapping types onto MPI_Datatype. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -struct  Dune::PromotionTraits<_T1,_T2_> │ │ │ │ │ -  Compute type of the result of an arithmetic operation involving two │ │ │ │ │ - different number types. More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::PromotionTraits<_T1,_T1_> │ │ │ │ │ +struct  Dune::MPITraits<_T_> │ │ │ │ │ +  A traits class describing the mapping of types onto MPI_Datatypes. │ │ │ │ │ + More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Compute type of the result of an arithmetic operation involving two different │ │ │ │ │ -number types. │ │ │ │ │ +Traits classes for mapping types onto MPI_Datatype. │ │ │ │ │ Author │ │ │ │ │ - Matthias Wohlmuth │ │ │ │ │ + Markus Blatt │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00020_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: promotiontraits.hh Source File │ │ │ │ +dune-common: mpitraits.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,53 +70,218 @@ │ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
promotiontraits.hh
│ │ │ │ +
mpitraits.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 (C) 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_PROMOTIONTRAITS_HH
│ │ │ │ -
6#define DUNE_PROMOTIONTRAITS_HH
│ │ │ │ +
5#ifndef DUNE_MPITRAITS_HH
│ │ │ │ +
6#define DUNE_MPITRAITS_HH
│ │ │ │
7
│ │ │ │ -
8#include <utility>
│ │ │ │ -
9
│ │ │ │ -
10namespace Dune {
│ │ │ │ -
25 template <typename T1, typename T2>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
27 {
│ │ │ │ -
28 typedef decltype(std::declval<T1>()+std::declval<T2>()) PromotedType;
│ │ │ │ -
29 };
│ │ │ │ -
│ │ │ │ -
30
│ │ │ │ -
31 // Specialization for the case of two equal types
│ │ │ │ -
32 // One should think that the generic template should handle this case as well.
│ │ │ │ -
33 // However, the fvectortest.cc unit test fails without it if ENABLE_GMP is set.
│ │ │ │ -
34 template <typename T1>
│ │ │ │ -
35 struct PromotionTraits<T1,T1> { typedef T1 PromotedType; };
│ │ │ │ -
36
│ │ │ │ -
38} // end namespace
│ │ │ │ -
39
│ │ │ │ -
40
│ │ │ │ -
41#endif // DUNE_PROMOTIONTRAITS_HH
│ │ │ │ +
18#if HAVE_MPI
│ │ │ │ +
19
│ │ │ │ +
20#include <cstddef>
│ │ │ │ +
21#include <cstdint>
│ │ │ │ +
22#include <type_traits>
│ │ │ │ +
23#include <utility>
│ │ │ │ +
24#include <complex>
│ │ │ │ +
25
│ │ │ │ +
26#include <mpi.h>
│ │ │ │ +
27
│ │ │ │ +
28namespace Dune
│ │ │ │ +
29{
│ │ │ │ +
39 template<typename T>
│ │ │ │ +
│ │ │ │ +
40 struct MPITraits
│ │ │ │ +
41 {
│ │ │ │ +
42 private:
│ │ │ │ +
43 MPITraits(){}
│ │ │ │ +
44 MPITraits(const MPITraits&){}
│ │ │ │ +
45 static MPI_Datatype datatype;
│ │ │ │ +
46 static MPI_Datatype vectortype;
│ │ │ │ +
47 public:
│ │ │ │ +
│ │ │ │ +
48 static inline MPI_Datatype getType()
│ │ │ │ +
49 {
│ │ │ │ +
50 if(datatype==MPI_DATATYPE_NULL) {
│ │ │ │ +
51 MPI_Type_contiguous(sizeof(T),MPI_BYTE,&datatype);
│ │ │ │ +
52 MPI_Type_commit(&datatype);
│ │ │ │ +
53 }
│ │ │ │ +
54 return datatype;
│ │ │ │ +
55 }
│ │ │ │ +
│ │ │ │ +
56 static constexpr bool is_intrinsic = false;
│ │ │ │ +
57 };
│ │ │ │ +
│ │ │ │ +
58 template<class T>
│ │ │ │ +
59 MPI_Datatype MPITraits<T>::datatype = MPI_DATATYPE_NULL;
│ │ │ │ +
60
│ │ │ │ +
61#ifndef DOXYGEN
│ │ │ │ +
62
│ │ │ │ +
63 // A Macro for defining traits for the primitive data types
│ │ │ │ +
64#define ComposeMPITraits(p,m) \
│ │ │ │ +
65 template<> \
│ │ │ │ +
66 struct MPITraits<p>{ \
│ │ │ │ +
67 static inline MPI_Datatype getType(){ \
│ │ │ │ +
68 return m; \
│ │ │ │ +
69 } \
│ │ │ │ +
70 static constexpr bool is_intrinsic = true; \
│ │ │ │ +
71 }
│ │ │ │ +
72
│ │ │ │ +
73 ComposeMPITraits(char, MPI_CHAR);
│ │ │ │ +
74 ComposeMPITraits(unsigned char,MPI_UNSIGNED_CHAR);
│ │ │ │ +
75 ComposeMPITraits(short,MPI_SHORT);
│ │ │ │ +
76 ComposeMPITraits(unsigned short,MPI_UNSIGNED_SHORT);
│ │ │ │ +
77 ComposeMPITraits(int,MPI_INT);
│ │ │ │ +
78 ComposeMPITraits(unsigned int,MPI_UNSIGNED);
│ │ │ │ +
79 ComposeMPITraits(long,MPI_LONG);
│ │ │ │ +
80 ComposeMPITraits(unsigned long,MPI_UNSIGNED_LONG);
│ │ │ │ +
81 ComposeMPITraits(float,MPI_FLOAT);
│ │ │ │ +
82 ComposeMPITraits(double,MPI_DOUBLE);
│ │ │ │ +
83 ComposeMPITraits(long double,MPI_LONG_DOUBLE);
│ │ │ │ +
84 ComposeMPITraits(std::complex<double>, MPI_CXX_DOUBLE_COMPLEX);
│ │ │ │ +
85 ComposeMPITraits(std::complex<long double>, MPI_CXX_LONG_DOUBLE_COMPLEX);
│ │ │ │ +
86 ComposeMPITraits(std::complex<float>, MPI_CXX_FLOAT_COMPLEX);
│ │ │ │ +
87
│ │ │ │ +
88
│ │ │ │ +
89#undef ComposeMPITraits
│ │ │ │ +
90
│ │ │ │ +
91 template<class K, int n> class FieldVector;
│ │ │ │ +
92
│ │ │ │ +
93 template<class K, int n>
│ │ │ │ +
94 struct MPITraits<FieldVector<K,n> >
│ │ │ │ +
95 {
│ │ │ │ +
96 static MPI_Datatype datatype;
│ │ │ │ +
97 static MPI_Datatype vectortype;
│ │ │ │ +
98
│ │ │ │ +
99 static inline MPI_Datatype getType()
│ │ │ │ +
100 {
│ │ │ │ +
101 if(datatype==MPI_DATATYPE_NULL) {
│ │ │ │ +
102 MPI_Type_contiguous(n, MPITraits<K>::getType(), &vectortype);
│ │ │ │ +
103 MPI_Type_commit(&vectortype);
│ │ │ │ +
104 FieldVector<K,n> fvector;
│ │ │ │ +
105 MPI_Aint base;
│ │ │ │ +
106 MPI_Aint displ;
│ │ │ │ +
107 MPI_Get_address(&fvector, &base);
│ │ │ │ +
108 MPI_Get_address(&(fvector[0]), &displ);
│ │ │ │ +
109 displ -= base;
│ │ │ │ +
110 int length[1]={1};
│ │ │ │ +
111
│ │ │ │ +
112 MPI_Type_create_struct(1, length, &displ, &vectortype, &datatype);
│ │ │ │ +
113 MPI_Type_commit(&datatype);
│ │ │ │ +
114 }
│ │ │ │ +
115 return datatype;
│ │ │ │ +
116 }
│ │ │ │ +
117
│ │ │ │ +
118 };
│ │ │ │ +
119
│ │ │ │ +
120 template<class K, int n>
│ │ │ │ +
121 MPI_Datatype MPITraits<FieldVector<K,n> >::datatype = MPI_DATATYPE_NULL;
│ │ │ │ +
122 template<class K, int n>
│ │ │ │ +
123 MPI_Datatype MPITraits<FieldVector<K,n> >::vectortype = {MPI_DATATYPE_NULL};
│ │ │ │ +
124
│ │ │ │ +
125
│ │ │ │ +
126 template<int k>
│ │ │ │ +
127 class bigunsignedint;
│ │ │ │ +
128
│ │ │ │ +
129 template<int k>
│ │ │ │ +
130 struct MPITraits<bigunsignedint<k> >
│ │ │ │ +
131 {
│ │ │ │ +
132 static MPI_Datatype datatype;
│ │ │ │ +
133 static MPI_Datatype vectortype;
│ │ │ │ +
134
│ │ │ │ +
135 static inline MPI_Datatype getType()
│ │ │ │ +
136 {
│ │ │ │ +
137 if(datatype==MPI_DATATYPE_NULL) {
│ │ │ │ + │ │ │ │ +
139 &vectortype);
│ │ │ │ +
140 //MPI_Type_commit(&vectortype);
│ │ │ │ +
141 bigunsignedint<k> data;
│ │ │ │ +
142 MPI_Aint base;
│ │ │ │ +
143 MPI_Aint displ;
│ │ │ │ +
144 MPI_Get_address(&data, &base);
│ │ │ │ +
145 MPI_Get_address(&(data.digit), &displ);
│ │ │ │ +
146 displ -= base;
│ │ │ │ +
147 int length[1]={1};
│ │ │ │ +
148 MPI_Type_create_struct(1, length, &displ, &vectortype, &datatype);
│ │ │ │ +
149 MPI_Type_commit(&datatype);
│ │ │ │ +
150 }
│ │ │ │ +
151 return datatype;
│ │ │ │ +
152 }
│ │ │ │ +
153 };
│ │ │ │ +
154}
│ │ │ │ +
155
│ │ │ │ +
156namespace Dune
│ │ │ │ +
157{
│ │ │ │ +
158 template<int k>
│ │ │ │ +
159 MPI_Datatype MPITraits<bigunsignedint<k> >::datatype = MPI_DATATYPE_NULL;
│ │ │ │ +
160 template<int k>
│ │ │ │ +
161 MPI_Datatype MPITraits<bigunsignedint<k> >::vectortype = MPI_DATATYPE_NULL;
│ │ │ │ +
162
│ │ │ │ +
163 template<typename T1, typename T2>
│ │ │ │ +
164 struct MPITraits<std::pair<T1,T2 > >
│ │ │ │ +
165 {
│ │ │ │ +
166 public:
│ │ │ │ +
167 inline static MPI_Datatype getType();
│ │ │ │ +
168 private:
│ │ │ │ +
169 static MPI_Datatype type;
│ │ │ │ +
170 };
│ │ │ │ +
171 template<typename T1, typename T2>
│ │ │ │ +
172 MPI_Datatype MPITraits<std::pair<T1,T2> >::getType()
│ │ │ │ +
173 {
│ │ │ │ +
174 if(type==MPI_DATATYPE_NULL) {
│ │ │ │ +
175 int length[2] = {1, 1};
│ │ │ │ +
176 MPI_Aint disp[2];
│ │ │ │ +
177 MPI_Datatype types[2] = {MPITraits<T1>::getType(),
│ │ │ │ + │ │ │ │ +
179
│ │ │ │ +
180 using Pair = std::pair<T1, T2>;
│ │ │ │ +
181 static_assert(std::is_standard_layout<Pair>::value, "offsetof() is only defined for standard layout types");
│ │ │ │ +
182 disp[0] = offsetof(Pair, first);
│ │ │ │ +
183 disp[1] = offsetof(Pair, second);
│ │ │ │ +
184
│ │ │ │ +
185 MPI_Datatype tmp;
│ │ │ │ +
186 MPI_Type_create_struct(2, length, disp, types, &tmp);
│ │ │ │ +
187
│ │ │ │ +
188 MPI_Type_create_resized(tmp, 0, sizeof(Pair), &type);
│ │ │ │ +
189 MPI_Type_commit(&type);
│ │ │ │ +
190
│ │ │ │ +
191 MPI_Type_free(&tmp);
│ │ │ │ +
192 }
│ │ │ │ +
193 return type;
│ │ │ │ +
194 }
│ │ │ │ +
195
│ │ │ │ +
196 template<typename T1, typename T2>
│ │ │ │ +
197 MPI_Datatype MPITraits<std::pair<T1,T2> >::type=MPI_DATATYPE_NULL;
│ │ │ │ +
198
│ │ │ │ +
199#endif // !DOXYGEN
│ │ │ │ +
200
│ │ │ │ +
201} // namespace Dune
│ │ │ │ +
202
│ │ │ │ +
203#endif // HAVE_MPI
│ │ │ │ +
204
│ │ │ │ +
207#endif
│ │ │ │ +
STL namespace.
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
Compute type of the result of an arithmetic operation involving two different number types.
Definition promotiontraits.hh:27
│ │ │ │ -
decltype(std::declval< T1 >()+std::declval< T2 >()) PromotedType
Definition promotiontraits.hh:28
│ │ │ │ -
T1 PromotedType
Definition promotiontraits.hh:35
│ │ │ │ +
A traits class describing the mapping of types onto MPI_Datatypes.
Definition mpitraits.hh:41
│ │ │ │ +
static MPI_Datatype getType()
Definition mpitraits.hh:48
│ │ │ │ +
static constexpr bool is_intrinsic
Definition mpitraits.hh:56
│ │ │ │ +
static constexpr int n
Definition bigunsignedint.hh:78
│ │ │ │ +
vector space out of a tensor product of fields.
Definition fvector.hh:95
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,54 +7,224 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -promotiontraits.hh │ │ │ │ │ + * parallel │ │ │ │ │ +mpitraits.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 (C) 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_PROMOTIONTRAITS_HH │ │ │ │ │ - 6#define DUNE_PROMOTIONTRAITS_HH │ │ │ │ │ + 5#ifndef DUNE_MPITRAITS_HH │ │ │ │ │ + 6#define DUNE_MPITRAITS_HH │ │ │ │ │ 7 │ │ │ │ │ - 8#include │ │ │ │ │ - 9 │ │ │ │ │ - 10namespace Dune { │ │ │ │ │ - 25 template │ │ │ │ │ -26 struct PromotionTraits │ │ │ │ │ - 27 { │ │ │ │ │ -28 typedef decltype(std::declval()+std::declval()) PromotedType; │ │ │ │ │ - 29 }; │ │ │ │ │ - 30 │ │ │ │ │ - 31 // Specialization for the case of two equal types │ │ │ │ │ - 32 // One should think that the generic template should handle this case as │ │ │ │ │ -well. │ │ │ │ │ - 33 // However, the fvectortest.cc unit test fails without it if ENABLE_GMP is │ │ │ │ │ -set. │ │ │ │ │ - 34 template │ │ │ │ │ -35 struct PromotionTraits { typedef T1 PromotedType; }; │ │ │ │ │ - 36 │ │ │ │ │ - 38} // end namespace │ │ │ │ │ - 39 │ │ │ │ │ - 40 │ │ │ │ │ - 41#endif // DUNE_PROMOTIONTRAITS_HH │ │ │ │ │ + 18#if HAVE_MPI │ │ │ │ │ + 19 │ │ │ │ │ + 20#include │ │ │ │ │ + 21#include │ │ │ │ │ + 22#include │ │ │ │ │ + 23#include │ │ │ │ │ + 24#include │ │ │ │ │ + 25 │ │ │ │ │ + 26#include │ │ │ │ │ + 27 │ │ │ │ │ + 28namespace Dune │ │ │ │ │ + 29{ │ │ │ │ │ + 39 template │ │ │ │ │ +40 struct MPITraits │ │ │ │ │ + 41 { │ │ │ │ │ + 42 private: │ │ │ │ │ + 43 MPITraits(){} │ │ │ │ │ + 44 MPITraits(const MPITraits&){} │ │ │ │ │ + 45 static MPI_Datatype datatype; │ │ │ │ │ + 46 static MPI_Datatype vectortype; │ │ │ │ │ + 47 public: │ │ │ │ │ +48 static inline MPI_Datatype getType() │ │ │ │ │ + 49 { │ │ │ │ │ + 50 if(datatype==MPI_DATATYPE_NULL) { │ │ │ │ │ + 51 MPI_Type_contiguous(sizeof(T),MPI_BYTE,&datatype); │ │ │ │ │ + 52 MPI_Type_commit(&datatype); │ │ │ │ │ + 53 } │ │ │ │ │ + 54 return datatype; │ │ │ │ │ + 55 } │ │ │ │ │ +56 static constexpr bool is_intrinsic = false; │ │ │ │ │ + 57 }; │ │ │ │ │ + 58 template │ │ │ │ │ + 59 MPI_Datatype MPITraits::datatype = MPI_DATATYPE_NULL; │ │ │ │ │ + 60 │ │ │ │ │ + 61#ifndef DOXYGEN │ │ │ │ │ + 62 │ │ │ │ │ + 63 // A Macro for defining traits for the primitive data types │ │ │ │ │ + 64#define ComposeMPITraits(p,m) \ │ │ │ │ │ + 65 template<> \ │ │ │ │ │ + 66 struct MPITraits

{ \ │ │ │ │ │ + 67 static inline MPI_Datatype getType(){ \ │ │ │ │ │ + 68 return m; \ │ │ │ │ │ + 69 } \ │ │ │ │ │ + 70 static constexpr bool is_intrinsic = true; \ │ │ │ │ │ + 71 } │ │ │ │ │ + 72 │ │ │ │ │ + 73 ComposeMPITraits(char, MPI_CHAR); │ │ │ │ │ + 74 ComposeMPITraits(unsigned char,MPI_UNSIGNED_CHAR); │ │ │ │ │ + 75 ComposeMPITraits(short,MPI_SHORT); │ │ │ │ │ + 76 ComposeMPITraits(unsigned short,MPI_UNSIGNED_SHORT); │ │ │ │ │ + 77 ComposeMPITraits(int,MPI_INT); │ │ │ │ │ + 78 ComposeMPITraits(unsigned int,MPI_UNSIGNED); │ │ │ │ │ + 79 ComposeMPITraits(long,MPI_LONG); │ │ │ │ │ + 80 ComposeMPITraits(unsigned long,MPI_UNSIGNED_LONG); │ │ │ │ │ + 81 ComposeMPITraits(float,MPI_FLOAT); │ │ │ │ │ + 82 ComposeMPITraits(double,MPI_DOUBLE); │ │ │ │ │ + 83 ComposeMPITraits(long double,MPI_LONG_DOUBLE); │ │ │ │ │ + 84 ComposeMPITraits(std::complex, MPI_CXX_DOUBLE_COMPLEX); │ │ │ │ │ + 85 ComposeMPITraits(std::complex, MPI_CXX_LONG_DOUBLE_COMPLEX); │ │ │ │ │ + 86 ComposeMPITraits(std::complex, MPI_CXX_FLOAT_COMPLEX); │ │ │ │ │ + 87 │ │ │ │ │ + 88 │ │ │ │ │ + 89#undef ComposeMPITraits │ │ │ │ │ + 90 │ │ │ │ │ + 91 template class FieldVector; │ │ │ │ │ + 92 │ │ │ │ │ + 93 template │ │ │ │ │ + 94 struct MPITraits > │ │ │ │ │ + 95 { │ │ │ │ │ + 96 static MPI_Datatype datatype; │ │ │ │ │ + 97 static MPI_Datatype vectortype; │ │ │ │ │ + 98 │ │ │ │ │ + 99 static inline MPI_Datatype getType() │ │ │ │ │ + 100 { │ │ │ │ │ + 101 if(datatype==MPI_DATATYPE_NULL) { │ │ │ │ │ + 102 MPI_Type_contiguous(n, MPITraits::getType(), &vectortype); │ │ │ │ │ + 103 MPI_Type_commit(&vectortype); │ │ │ │ │ + 104 FieldVector fvector; │ │ │ │ │ + 105 MPI_Aint base; │ │ │ │ │ + 106 MPI_Aint displ; │ │ │ │ │ + 107 MPI_Get_address(&fvector, &base); │ │ │ │ │ + 108 MPI_Get_address(&(fvector[0]), &displ); │ │ │ │ │ + 109 displ -= base; │ │ │ │ │ + 110 int length[1]={1}; │ │ │ │ │ + 111 │ │ │ │ │ + 112 MPI_Type_create_struct(1, length, &displ, &vectortype, &datatype); │ │ │ │ │ + 113 MPI_Type_commit(&datatype); │ │ │ │ │ + 114 } │ │ │ │ │ + 115 return datatype; │ │ │ │ │ + 116 } │ │ │ │ │ + 117 │ │ │ │ │ + 118 }; │ │ │ │ │ + 119 │ │ │ │ │ + 120 template │ │ │ │ │ + 121 MPI_Datatype MPITraits >::datatype = MPI_DATATYPE_NULL; │ │ │ │ │ + 122 template │ │ │ │ │ + 123 MPI_Datatype MPITraits >::vectortype = │ │ │ │ │ +{MPI_DATATYPE_NULL}; │ │ │ │ │ + 124 │ │ │ │ │ + 125 │ │ │ │ │ + 126 template │ │ │ │ │ + 127 class bigunsignedint; │ │ │ │ │ + 128 │ │ │ │ │ + 129 template │ │ │ │ │ + 130 struct MPITraits > │ │ │ │ │ + 131 { │ │ │ │ │ + 132 static MPI_Datatype datatype; │ │ │ │ │ + 133 static MPI_Datatype vectortype; │ │ │ │ │ + 134 │ │ │ │ │ + 135 static inline MPI_Datatype getType() │ │ │ │ │ + 136 { │ │ │ │ │ + 137 if(datatype==MPI_DATATYPE_NULL) { │ │ │ │ │ + 138 MPI_Type_contiguous(bigunsignedint::n, MPITraits:: │ │ │ │ │ +getType(), │ │ │ │ │ + 139 &vectortype); │ │ │ │ │ + 140 //MPI_Type_commit(&vectortype); │ │ │ │ │ + 141 bigunsignedint data; │ │ │ │ │ + 142 MPI_Aint base; │ │ │ │ │ + 143 MPI_Aint displ; │ │ │ │ │ + 144 MPI_Get_address(&data, &base); │ │ │ │ │ + 145 MPI_Get_address(&(data.digit), &displ); │ │ │ │ │ + 146 displ -= base; │ │ │ │ │ + 147 int length[1]={1}; │ │ │ │ │ + 148 MPI_Type_create_struct(1, length, &displ, &vectortype, &datatype); │ │ │ │ │ + 149 MPI_Type_commit(&datatype); │ │ │ │ │ + 150 } │ │ │ │ │ + 151 return datatype; │ │ │ │ │ + 152 } │ │ │ │ │ + 153 }; │ │ │ │ │ + 154} │ │ │ │ │ + 155 │ │ │ │ │ + 156namespace Dune │ │ │ │ │ + 157{ │ │ │ │ │ + 158 template │ │ │ │ │ + 159 MPI_Datatype MPITraits >::datatype = MPI_DATATYPE_NULL; │ │ │ │ │ + 160 template │ │ │ │ │ + 161 MPI_Datatype MPITraits >::vectortype = │ │ │ │ │ +MPI_DATATYPE_NULL; │ │ │ │ │ + 162 │ │ │ │ │ + 163 template │ │ │ │ │ + 164 struct MPITraits > │ │ │ │ │ + 165 { │ │ │ │ │ + 166 public: │ │ │ │ │ + 167 inline static MPI_Datatype getType(); │ │ │ │ │ + 168 private: │ │ │ │ │ + 169 static MPI_Datatype type; │ │ │ │ │ + 170 }; │ │ │ │ │ + 171 template │ │ │ │ │ + 172 MPI_Datatype MPITraits >::getType() │ │ │ │ │ + 173 { │ │ │ │ │ + 174 if(type==MPI_DATATYPE_NULL) { │ │ │ │ │ + 175 int length[2] = {1, 1}; │ │ │ │ │ + 176 MPI_Aint disp[2]; │ │ │ │ │ + 177 MPI_Datatype types[2] = {MPITraits::getType(), │ │ │ │ │ + 178 MPITraits::getType()}; │ │ │ │ │ + 179 │ │ │ │ │ + 180 using Pair = std::pair; │ │ │ │ │ + 181 static_assert(std::is_standard_layout::value, "offsetof() is only │ │ │ │ │ +defined for standard layout types"); │ │ │ │ │ + 182 disp[0] = offsetof(Pair, first); │ │ │ │ │ + 183 disp[1] = offsetof(Pair, second); │ │ │ │ │ + 184 │ │ │ │ │ + 185 MPI_Datatype tmp; │ │ │ │ │ + 186 MPI_Type_create_struct(2, length, disp, types, &tmp); │ │ │ │ │ + 187 │ │ │ │ │ + 188 MPI_Type_create_resized(tmp, 0, sizeof(Pair), &type); │ │ │ │ │ + 189 MPI_Type_commit(&type); │ │ │ │ │ + 190 │ │ │ │ │ + 191 MPI_Type_free(&tmp); │ │ │ │ │ + 192 } │ │ │ │ │ + 193 return type; │ │ │ │ │ + 194 } │ │ │ │ │ + 195 │ │ │ │ │ + 196 template │ │ │ │ │ + 197 MPI_Datatype MPITraits >::type=MPI_DATATYPE_NULL; │ │ │ │ │ + 198 │ │ │ │ │ + 199#endif // !DOXYGEN │ │ │ │ │ + 200 │ │ │ │ │ + 201} // namespace Dune │ │ │ │ │ + 202 │ │ │ │ │ + 203#endif // HAVE_MPI │ │ │ │ │ + 204 │ │ │ │ │ + 207#endif │ │ │ │ │ +std │ │ │ │ │ +STL namespace. │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::PromotionTraits │ │ │ │ │ -Compute type of the result of an arithmetic operation involving two different │ │ │ │ │ -number types. │ │ │ │ │ -Definition promotiontraits.hh:27 │ │ │ │ │ -Dune::PromotionTraits::PromotedType │ │ │ │ │ -decltype(std::declval< T1 >()+std::declval< T2 >()) PromotedType │ │ │ │ │ -Definition promotiontraits.hh:28 │ │ │ │ │ -Dune::PromotionTraits<_T1,_T1_>::PromotedType │ │ │ │ │ -T1 PromotedType │ │ │ │ │ -Definition promotiontraits.hh:35 │ │ │ │ │ +Dune::MPITraits │ │ │ │ │ +A traits class describing the mapping of types onto MPI_Datatypes. │ │ │ │ │ +Definition mpitraits.hh:41 │ │ │ │ │ +Dune::MPITraits::getType │ │ │ │ │ +static MPI_Datatype getType() │ │ │ │ │ +Definition mpitraits.hh:48 │ │ │ │ │ +Dune::MPITraits::is_intrinsic │ │ │ │ │ +static constexpr bool is_intrinsic │ │ │ │ │ +Definition mpitraits.hh:56 │ │ │ │ │ +Dune::bigunsignedint::n │ │ │ │ │ +static constexpr int n │ │ │ │ │ +Definition bigunsignedint.hh:78 │ │ │ │ │ +Dune::FieldVector │ │ │ │ │ +vector space out of a tensor product of fields. │ │ │ │ │ +Definition fvector.hh:95 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00023.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: deprecated.hh File Reference │ │ │ │ +dune-common: mpicommunication.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,40 +65,114 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Macros
│ │ │ │ -
deprecated.hh File Reference
│ │ │ │ +Classes | │ │ │ │ +Namespaces | │ │ │ │ +Macros | │ │ │ │ +Functions
│ │ │ │ +
mpicommunication.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

Definition of the DUNE_NO_DEPRECATED_* macros. │ │ │ │ +

Implements an utility class that provides MPI's collective communication methods. │ │ │ │ More...

│ │ │ │ - │ │ │ │ +
#include <algorithm>
│ │ │ │ +#include <functional>
│ │ │ │ +#include <memory>
│ │ │ │ +#include <mpi.h>
│ │ │ │ +#include <dune/common/binaryfunctions.hh>
│ │ │ │ +#include <dune/common/exceptions.hh>
│ │ │ │ +#include <dune/common/parallel/communication.hh>
│ │ │ │ +#include <dune/common/parallel/mpitraits.hh>
│ │ │ │ +#include <dune/common/parallel/mpifuture.hh>
│ │ │ │ +#include <dune/common/parallel/mpidata.hh>
│ │ │ │ +
│ │ │ │

Go to the source code of this file.

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

│ │ │ │ +Classes

class  Dune::Generic_MPI_Op< Type, BinaryFunction, Enable >
 
class  Dune::Communication< MPI_Comm >
 Specialization of Communication for MPI. More...
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Namespaces

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

│ │ │ │ Macros

#define DUNE_NO_DEPRECATED_BEGIN   ...
 Ignore deprecation warnings (start)
 
#define DUNE_NO_DEPRECATED_END   ...
 Ignore deprecation warnings (end)
 
#define ComposeMPIOp(func, op)
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ +Functions

 Dune::ComposeMPIOp (std::plus, MPI_SUM)
 
 Dune::ComposeMPIOp (std::multiplies, MPI_PROD)
 
 Dune::ComposeMPIOp (Min, MPI_MIN)
 
 Dune::ComposeMPIOp (Max, MPI_MAX)
 
│ │ │ │

Detailed Description

│ │ │ │ -

Definition of the DUNE_NO_DEPRECATED_* macros.

│ │ │ │ -
│ │ │ │ +

Implements an utility class that provides MPI's collective communication methods.

│ │ │ │ +

Macro Definition Documentation

│ │ │ │ + │ │ │ │ +

◆ ComposeMPIOp

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define ComposeMPIOp( func,
 op 
)
│ │ │ │ +
│ │ │ │ +Value:
template<class T, class S> \
│ │ │ │ +
class Generic_MPI_Op<T, func<S>, std::enable_if_t<MPITraits<S>::is_intrinsic> >{ \
│ │ │ │ +
public: \
│ │ │ │ +
static MPI_Op get(){ \
│ │ │ │ +
return op; \
│ │ │ │ +
} \
│ │ │ │ +
private: \
│ │ │ │ +
Generic_MPI_Op () {} \
│ │ │ │ +
Generic_MPI_Op (const Generic_MPI_Op & ) {} \
│ │ │ │ +
}
│ │ │ │ +
STL namespace.
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,23 +6,71 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Macros │ │ │ │ │ -deprecated.hh File Reference │ │ │ │ │ -Definition of the DUNE_NO_DEPRECATED_* macros. More... │ │ │ │ │ + * parallel │ │ │ │ │ +Classes | Namespaces | Macros | Functions │ │ │ │ │ +mpicommunication.hh File Reference │ │ │ │ │ +Common » Parallel_Communication │ │ │ │ │ +Implements an utility class that provides MPI's collective communication │ │ │ │ │ +methods. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ + Classes │ │ │ │ │ +class  Dune::Generic_MPI_Op<_Type,_BinaryFunction,_Enable_> │ │ │ │ │ +  │ │ │ │ │ +class  Dune::Communication<_MPI_Comm_> │ │ │ │ │ +  Specialization of Communication for MPI. More... │ │ │ │ │ +  │ │ │ │ │ + Namespaces │ │ │ │ │ +namespace  Dune │ │ │ │ │ +  Dune namespace. │ │ │ │ │ +  │ │ │ │ │ Macros │ │ │ │ │ -#define DUNE_NO_DEPRECATED_BEGIN   ... │ │ │ │ │ -  Ignore deprecation warnings (start) │ │ │ │ │ +#define ComposeMPIOp(func, op) │ │ │ │ │ +  │ │ │ │ │ + Functions │ │ │ │ │ + Dune::ComposeMPIOp (std::plus, MPI_SUM) │ │ │ │ │ +  │ │ │ │ │ + Dune::ComposeMPIOp (std::multiplies, MPI_PROD) │ │ │ │ │ +  │ │ │ │ │ + Dune::ComposeMPIOp (Min, MPI_MIN) │ │ │ │ │   │ │ │ │ │ -#define DUNE_NO_DEPRECATED_END   ... │ │ │ │ │ -  Ignore deprecation warnings (end) │ │ │ │ │ + Dune::ComposeMPIOp (Max, MPI_MAX) │ │ │ │ │   │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Definition of the DUNE_NO_DEPRECATED_* macros. │ │ │ │ │ +Implements an utility class that provides MPI's collective communication │ │ │ │ │ +methods. │ │ │ │ │ +***** Macro Definition Documentation ***** │ │ │ │ │ +***** ◆ ComposeMPIOp ***** │ │ │ │ │ +#define ComposeMPIOp (  func, │ │ │ │ │ +  op  │ │ │ │ │ + ) │ │ │ │ │ +Value: │ │ │ │ │ +template \ │ │ │ │ │ +class Generic_MPI_Op, std::enable_if_t::is_intrinsic> > │ │ │ │ │ +{ \ │ │ │ │ │ +public: \ │ │ │ │ │ +static MPI_Op get(){ \ │ │ │ │ │ +return op; \ │ │ │ │ │ +} \ │ │ │ │ │ +private: \ │ │ │ │ │ +Generic_MPI_Op () {} \ │ │ │ │ │ +Generic_MPI_Op (const Generic_MPI_Op & ) {} \ │ │ │ │ │ +} │ │ │ │ │ +std │ │ │ │ │ +STL namespace. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00023_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: deprecated.hh Source File │ │ │ │ +dune-common: mpicommunication.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,56 +70,579 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
deprecated.hh
│ │ │ │ +
mpicommunication.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 (C) 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_DEPRECATED_HH
│ │ │ │ -
6#define DUNE_DEPRECATED_HH
│ │ │ │ +
5#ifndef DUNE_COMMON_PARALLEL_MPICOMMUNICATION_HH
│ │ │ │ +
6#define DUNE_COMMON_PARALLEL_MPICOMMUNICATION_HH
│ │ │ │
7
│ │ │ │ -
14#ifdef DOXYGEN
│ │ │ │ -
32#define DUNE_NO_DEPRECATED_BEGIN ...
│ │ │ │ -
38#define DUNE_NO_DEPRECATED_END ...
│ │ │ │ -
39#else
│ │ │ │ -
40# if defined __clang__
│ │ │ │ -
41# define DUNE_NO_DEPRECATED_BEGIN \
│ │ │ │ -
42 _Pragma("clang diagnostic push") \
│ │ │ │ -
43 _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
│ │ │ │ -
44# define DUNE_NO_DEPRECATED_END _Pragma("clang diagnostic pop")
│ │ │ │ -
45# elif defined __INTEL_COMPILER
│ │ │ │ -
46# define DUNE_NO_DEPRECATED_BEGIN \
│ │ │ │ -
47 _Pragma("warning push") \
│ │ │ │ -
48 _Pragma("warning(disable:1478)") \
│ │ │ │ -
49 _Pragma("warning(disable:1786)")
│ │ │ │ -
50# define DUNE_NO_DEPRECATED_END _Pragma("warning pop")
│ │ │ │ -
51# elif defined __GNUC__
│ │ │ │ -
52# define DUNE_NO_DEPRECATED_BEGIN \
│ │ │ │ -
53 _Pragma("GCC diagnostic push") \
│ │ │ │ -
54 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
│ │ │ │ -
55# define DUNE_NO_DEPRECATED_END _Pragma("GCC diagnostic pop")
│ │ │ │ -
56# else
│ │ │ │ -
57# define DUNE_NO_DEPRECATED_BEGIN /* Noop. */
│ │ │ │ -
58# define DUNE_NO_DEPRECATED_END /* Noop. */
│ │ │ │ -
59# endif
│ │ │ │ -
60#endif
│ │ │ │ +
16#if HAVE_MPI
│ │ │ │ +
17
│ │ │ │ +
18#include <algorithm>
│ │ │ │ +
19#include <functional>
│ │ │ │ +
20#include <memory>
│ │ │ │ +
21
│ │ │ │ +
22#include <mpi.h>
│ │ │ │ +
23
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
30
│ │ │ │ +
31namespace Dune
│ │ │ │ +
32{
│ │ │ │ +
33
│ │ │ │ +
34 //=======================================================
│ │ │ │ +
35 // use singleton pattern and template specialization to
│ │ │ │ +
36 // generate MPI operations
│ │ │ │ +
37 //=======================================================
│ │ │ │ +
38
│ │ │ │ +
39 template<typename Type, typename BinaryFunction, typename Enable=void>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
41 {
│ │ │ │ +
42
│ │ │ │ +
43 public:
│ │ │ │ +
│ │ │ │ +
44 static MPI_Op get ()
│ │ │ │ +
45 {
│ │ │ │ +
46 if (!op)
│ │ │ │ +
47 {
│ │ │ │ +
48 op = std::make_unique<MPI_Op>();
│ │ │ │ +
49 // The following line leaks an MPI operation object, because the corresponding
│ │ │ │ +
50 //`MPI_Op_free` is never called. It is never called because there is no easy
│ │ │ │ +
51 // way to call it at the right moment: right before the call to MPI_Finalize.
│ │ │ │ +
52 // See https://gitlab.dune-project.org/core/dune-istl/issues/80
│ │ │ │ +
53 MPI_Op_create((void (*)(void*, void*, int*, MPI_Datatype*))&operation,true,op.get());
│ │ │ │ +
54 }
│ │ │ │ +
55 return *op;
│ │ │ │ +
56 }
│ │ │ │ +
│ │ │ │ +
57 private:
│ │ │ │ +
58 static void operation (Type *in, Type *inout, int *len, MPI_Datatype*)
│ │ │ │ +
59 {
│ │ │ │ +
60 BinaryFunction func;
│ │ │ │
61
│ │ │ │ -
63
│ │ │ │ -
64#endif
│ │ │ │ +
62 for (int i=0; i< *len; ++i, ++in, ++inout) {
│ │ │ │ +
63 Type temp;
│ │ │ │ +
64 temp = func(*in, *inout);
│ │ │ │ +
65 *inout = temp;
│ │ │ │ +
66 }
│ │ │ │ +
67 }
│ │ │ │ +
68 Generic_MPI_Op () {}
│ │ │ │ +
69 Generic_MPI_Op (const Generic_MPI_Op& ) {}
│ │ │ │ +
70 static std::unique_ptr<MPI_Op> op;
│ │ │ │ +
71 };
│ │ │ │ +
│ │ │ │ +
72
│ │ │ │ +
73
│ │ │ │ +
74 template<typename Type, typename BinaryFunction, typename Enable>
│ │ │ │ +
75 std::unique_ptr<MPI_Op> Generic_MPI_Op<Type,BinaryFunction, Enable>::op;
│ │ │ │ +
76
│ │ │ │ +
│ │ │ │ +
77#define ComposeMPIOp(func,op) \
│ │ │ │ +
78 template<class T, class S> \
│ │ │ │ +
79 class Generic_MPI_Op<T, func<S>, std::enable_if_t<MPITraits<S>::is_intrinsic> >{ \
│ │ │ │ +
80 public: \
│ │ │ │ +
81 static MPI_Op get(){ \
│ │ │ │ +
82 return op; \
│ │ │ │ +
83 } \
│ │ │ │ +
84 private: \
│ │ │ │ +
85 Generic_MPI_Op () {} \
│ │ │ │ +
86 Generic_MPI_Op (const Generic_MPI_Op & ) {} \
│ │ │ │ +
87 }
│ │ │ │ +
│ │ │ │ +
88
│ │ │ │ +
89
│ │ │ │ +
90 ComposeMPIOp(std::plus, MPI_SUM);
│ │ │ │ +
91 ComposeMPIOp(std::multiplies, MPI_PROD);
│ │ │ │ +
92 ComposeMPIOp(Min, MPI_MIN);
│ │ │ │ +
93 ComposeMPIOp(Max, MPI_MAX);
│ │ │ │ +
94
│ │ │ │ +
95#undef ComposeMPIOp
│ │ │ │ +
96
│ │ │ │ +
97
│ │ │ │ +
98 //=======================================================
│ │ │ │ +
99 // use singleton pattern and template specialization to
│ │ │ │ +
100 // generate MPI operations
│ │ │ │ +
101 //=======================================================
│ │ │ │ +
102
│ │ │ │ +
106 template<>
│ │ │ │ +
│ │ │ │ +
107 class Communication<MPI_Comm>
│ │ │ │ +
108 {
│ │ │ │ +
109 public:
│ │ │ │ +
│ │ │ │ +
111 Communication (const MPI_Comm& c = MPI_COMM_WORLD)
│ │ │ │ +
112 : communicator(c)
│ │ │ │ +
113 {
│ │ │ │ +
114 if(communicator!=MPI_COMM_NULL) {
│ │ │ │ +
115 int initialized = 0;
│ │ │ │ +
116 MPI_Initialized(&initialized);
│ │ │ │ +
117 if (!initialized)
│ │ │ │ +
118 DUNE_THROW(ParallelError,"You must call MPIHelper::instance(argc,argv) in your main() function before using the MPI Communication!");
│ │ │ │ +
119 MPI_Comm_rank(communicator,&me);
│ │ │ │ +
120 MPI_Comm_size(communicator,&procs);
│ │ │ │ +
121 }else{
│ │ │ │ +
122 procs=0;
│ │ │ │ +
123 me=-1;
│ │ │ │ +
124 }
│ │ │ │ +
125 }
│ │ │ │ +
│ │ │ │ +
126
│ │ │ │ +
│ │ │ │ +
128 int rank () const
│ │ │ │ +
129 {
│ │ │ │ +
130 return me;
│ │ │ │ +
131 }
│ │ │ │ +
│ │ │ │ +
132
│ │ │ │ +
│ │ │ │ +
134 int size () const
│ │ │ │ +
135 {
│ │ │ │ +
136 return procs;
│ │ │ │ +
137 }
│ │ │ │ +
│ │ │ │ +
138
│ │ │ │ +
140 template<class T>
│ │ │ │ +
│ │ │ │ +
141 int send(const T& data, int dest_rank, int tag) const
│ │ │ │ +
142 {
│ │ │ │ +
143 auto mpi_data = getMPIData(data);
│ │ │ │ +
144 return MPI_Send(mpi_data.ptr(), mpi_data.size(), mpi_data.type(),
│ │ │ │ +
145 dest_rank, tag, communicator);
│ │ │ │ +
146 }
│ │ │ │ +
│ │ │ │ +
147
│ │ │ │ +
149 template<class T>
│ │ │ │ +
│ │ │ │ +
150 MPIFuture<const T> isend(const T&& data, int dest_rank, int tag) const
│ │ │ │ +
151 {
│ │ │ │ +
152 MPIFuture<const T> future(std::forward<const T>(data));
│ │ │ │ +
153 auto mpidata = future.get_mpidata();
│ │ │ │ +
154 MPI_Isend(mpidata.ptr(), mpidata.size(), mpidata.type(),
│ │ │ │ +
155 dest_rank, tag, communicator, &future.req_);
│ │ │ │ +
156 return future;
│ │ │ │ +
157 }
│ │ │ │ +
│ │ │ │ +
158
│ │ │ │ +
160 template<class T>
│ │ │ │ +
│ │ │ │ +
161 T recv(T&& data, int source_rank, int tag, MPI_Status* status = MPI_STATUS_IGNORE) const
│ │ │ │ +
162 {
│ │ │ │ +
163 T lvalue_data(std::forward<T>(data));
│ │ │ │ +
164 auto mpi_data = getMPIData(lvalue_data);
│ │ │ │ +
165 MPI_Recv(mpi_data.ptr(), mpi_data.size(), mpi_data.type(),
│ │ │ │ +
166 source_rank, tag, communicator, status);
│ │ │ │ +
167 return lvalue_data;
│ │ │ │ +
168 }
│ │ │ │ +
│ │ │ │ +
169
│ │ │ │ +
171 template<class T>
│ │ │ │ +
│ │ │ │ +
172 MPIFuture<T> irecv(T&& data, int source_rank, int tag) const
│ │ │ │ +
173 {
│ │ │ │ +
174 MPIFuture<T> future(std::forward<T>(data));
│ │ │ │ +
175 auto mpidata = future.get_mpidata();
│ │ │ │ +
176 MPI_Irecv(mpidata.ptr(), mpidata.size(), mpidata.type(),
│ │ │ │ +
177 source_rank, tag, communicator, &future.req_);
│ │ │ │ +
178 return future;
│ │ │ │ +
179 }
│ │ │ │ +
│ │ │ │ +
180
│ │ │ │ +
181 template<class T>
│ │ │ │ +
│ │ │ │ +
182 T rrecv(T&& data, int source_rank, int tag, MPI_Status* status = MPI_STATUS_IGNORE) const
│ │ │ │ +
183 {
│ │ │ │ +
184 MPI_Status _status;
│ │ │ │ +
185 MPI_Message _message;
│ │ │ │ +
186 T lvalue_data(std::forward<T>(data));
│ │ │ │ +
187 auto mpi_data = getMPIData(lvalue_data);
│ │ │ │ +
188 static_assert(!mpi_data.static_size, "rrecv work only for non-static-sized types.");
│ │ │ │ +
189 if(status == MPI_STATUS_IGNORE)
│ │ │ │ +
190 status = &_status;
│ │ │ │ +
191 MPI_Mprobe(source_rank, tag, communicator, &_message, status);
│ │ │ │ +
192 int size;
│ │ │ │ +
193 MPI_Get_count(status, mpi_data.type(), &size);
│ │ │ │ +
194 mpi_data.resize(size);
│ │ │ │ +
195 MPI_Mrecv(mpi_data.ptr(), mpi_data.size(), mpi_data.type(), &_message, status);
│ │ │ │ +
196 return lvalue_data;
│ │ │ │ +
197 }
│ │ │ │ +
│ │ │ │ +
198
│ │ │ │ +
200 template<typename T>
│ │ │ │ +
│ │ │ │ +
201 T sum (const T& in) const
│ │ │ │ +
202 {
│ │ │ │ +
203 T out;
│ │ │ │ +
204 allreduce<std::plus<T> >(&in,&out,1);
│ │ │ │ +
205 return out;
│ │ │ │ +
206 }
│ │ │ │ +
│ │ │ │ +
207
│ │ │ │ +
209 template<typename T>
│ │ │ │ +
│ │ │ │ +
210 int sum (T* inout, int len) const
│ │ │ │ +
211 {
│ │ │ │ +
212 return allreduce<std::plus<T> >(inout,len);
│ │ │ │ +
213 }
│ │ │ │ +
│ │ │ │ +
214
│ │ │ │ +
216 template<typename T>
│ │ │ │ +
│ │ │ │ +
217 T prod (const T& in) const
│ │ │ │ +
218 {
│ │ │ │ +
219 T out;
│ │ │ │ +
220 allreduce<std::multiplies<T> >(&in,&out,1);
│ │ │ │ +
221 return out;
│ │ │ │ +
222 }
│ │ │ │ +
│ │ │ │ +
223
│ │ │ │ +
225 template<typename T>
│ │ │ │ +
│ │ │ │ +
226 int prod (T* inout, int len) const
│ │ │ │ +
227 {
│ │ │ │ +
228 return allreduce<std::multiplies<T> >(inout,len);
│ │ │ │ +
229 }
│ │ │ │ +
│ │ │ │ +
230
│ │ │ │ +
232 template<typename T>
│ │ │ │ +
│ │ │ │ +
233 T min (const T& in) const
│ │ │ │ +
234 {
│ │ │ │ +
235 T out;
│ │ │ │ +
236 allreduce<Min<T> >(&in,&out,1);
│ │ │ │ +
237 return out;
│ │ │ │ +
238 }
│ │ │ │ +
│ │ │ │ +
239
│ │ │ │ +
241 template<typename T>
│ │ │ │ +
│ │ │ │ +
242 int min (T* inout, int len) const
│ │ │ │ +
243 {
│ │ │ │ +
244 return allreduce<Min<T> >(inout,len);
│ │ │ │ +
245 }
│ │ │ │ +
│ │ │ │ +
246
│ │ │ │ +
247
│ │ │ │ +
249 template<typename T>
│ │ │ │ +
│ │ │ │ +
250 T max (const T& in) const
│ │ │ │ +
251 {
│ │ │ │ +
252 T out;
│ │ │ │ +
253 allreduce<Max<T> >(&in,&out,1);
│ │ │ │ +
254 return out;
│ │ │ │ +
255 }
│ │ │ │ +
│ │ │ │ +
256
│ │ │ │ +
258 template<typename T>
│ │ │ │ +
│ │ │ │ +
259 int max (T* inout, int len) const
│ │ │ │ +
260 {
│ │ │ │ +
261 return allreduce<Max<T> >(inout,len);
│ │ │ │ +
262 }
│ │ │ │ +
│ │ │ │ +
263
│ │ │ │ +
│ │ │ │ +
265 int barrier () const
│ │ │ │ +
266 {
│ │ │ │ +
267 return MPI_Barrier(communicator);
│ │ │ │ +
268 }
│ │ │ │ +
│ │ │ │ +
269
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
272 {
│ │ │ │ +
273 MPIFuture<void> future(true); // make a valid MPIFuture<void>
│ │ │ │ +
274 MPI_Ibarrier(communicator, &future.req_);
│ │ │ │ +
275 return future;
│ │ │ │ +
276 }
│ │ │ │ +
│ │ │ │ +
277
│ │ │ │ +
278
│ │ │ │ +
280 template<typename T>
│ │ │ │ +
│ │ │ │ +
281 int broadcast (T* inout, int len, int root) const
│ │ │ │ +
282 {
│ │ │ │ +
283 return MPI_Bcast(inout,len,MPITraits<T>::getType(),root,communicator);
│ │ │ │ +
284 }
│ │ │ │ +
│ │ │ │ +
285
│ │ │ │ +
287 template<class T>
│ │ │ │ +
│ │ │ │ +
288 MPIFuture<T> ibroadcast(T&& data, int root) const{
│ │ │ │ +
289 MPIFuture<T> future(std::forward<T>(data));
│ │ │ │ +
290 auto mpidata = future.get_mpidata();
│ │ │ │ +
291 MPI_Ibcast(mpidata.ptr(),
│ │ │ │ +
292 mpidata.size(),
│ │ │ │ +
293 mpidata.type(),
│ │ │ │ +
294 root,
│ │ │ │ +
295 communicator,
│ │ │ │ +
296 &future.req_);
│ │ │ │ +
297 return future;
│ │ │ │ +
298 }
│ │ │ │ +
│ │ │ │ +
299
│ │ │ │ +
302 template<typename T>
│ │ │ │ +
│ │ │ │ +
303 int gather (const T* in, T* out, int len, int root) const
│ │ │ │ +
304 {
│ │ │ │ +
305 return MPI_Gather(const_cast<T*>(in),len,MPITraits<T>::getType(),
│ │ │ │ +
306 out,len,MPITraits<T>::getType(),
│ │ │ │ +
307 root,communicator);
│ │ │ │ +
308 }
│ │ │ │ +
│ │ │ │ +
309
│ │ │ │ +
311 template<class TIN, class TOUT = std::vector<TIN>>
│ │ │ │ +
│ │ │ │ +
312 MPIFuture<TOUT, TIN> igather(TIN&& data_in, TOUT&& data_out, int root) const{
│ │ │ │ +
313 MPIFuture<TOUT, TIN> future(std::forward<TOUT>(data_out), std::forward<TIN>(data_in));
│ │ │ │ +
314 auto mpidata_in = future.get_send_mpidata();
│ │ │ │ +
315 auto mpidata_out = future.get_mpidata();
│ │ │ │ +
316 assert(root != me || mpidata_in.size()*procs <= mpidata_out.size());
│ │ │ │ +
317 int outlen = (me==root) * mpidata_in.size();
│ │ │ │ +
318 MPI_Igather(mpidata_in.ptr(), mpidata_in.size(), mpidata_in.type(),
│ │ │ │ +
319 mpidata_out.ptr(), outlen, mpidata_out.type(),
│ │ │ │ +
320 root, communicator, &future.req_);
│ │ │ │ +
321 return future;
│ │ │ │ +
322 }
│ │ │ │ +
│ │ │ │ +
323
│ │ │ │ +
325 template<typename T>
│ │ │ │ +
│ │ │ │ +
326 int gatherv (const T* in, int sendDataLen, T* out, int* recvDataLen, int* displ, int root) const
│ │ │ │ +
327 {
│ │ │ │ +
328 return MPI_Gatherv(const_cast<T*>(in),sendDataLen,MPITraits<T>::getType(),
│ │ │ │ +
329 out,recvDataLen,displ,MPITraits<T>::getType(),
│ │ │ │ +
330 root,communicator);
│ │ │ │ +
331 }
│ │ │ │ +
│ │ │ │ +
332
│ │ │ │ +
335 template<typename T>
│ │ │ │ +
│ │ │ │ +
336 int scatter (const T* sendData, T* recvData, int len, int root) const
│ │ │ │ +
337 {
│ │ │ │ +
338 return MPI_Scatter(const_cast<T*>(sendData),len,MPITraits<T>::getType(),
│ │ │ │ +
339 recvData,len,MPITraits<T>::getType(),
│ │ │ │ +
340 root,communicator);
│ │ │ │ +
341 }
│ │ │ │ +
│ │ │ │ +
342
│ │ │ │ +
344 template<class TIN, class TOUT = TIN>
│ │ │ │ +
│ │ │ │ +
345 MPIFuture<TOUT, TIN> iscatter(TIN&& data_in, TOUT&& data_out, int root) const
│ │ │ │ +
346 {
│ │ │ │ +
347 MPIFuture<TOUT, TIN> future(std::forward<TOUT>(data_out), std::forward<TIN>(data_in));
│ │ │ │ +
348 auto mpidata_in = future.get_send_mpidata();
│ │ │ │ +
349 auto mpidata_out = future.get_mpidata();
│ │ │ │ +
350 int inlen = (me==root) * mpidata_in.size()/procs;
│ │ │ │ +
351 MPI_Iscatter(mpidata_in.ptr(), inlen, mpidata_in.type(),
│ │ │ │ +
352 mpidata_out.ptr(), mpidata_out.size(), mpidata_out.type(),
│ │ │ │ +
353 root, communicator, &future.req_);
│ │ │ │ +
354 return future;
│ │ │ │ +
355 }
│ │ │ │ +
│ │ │ │ +
356
│ │ │ │ +
358 template<typename T>
│ │ │ │ +
│ │ │ │ +
359 int scatterv (const T* sendData, int* sendDataLen, int* displ, T* recvData, int recvDataLen, int root) const
│ │ │ │ +
360 {
│ │ │ │ +
361 return MPI_Scatterv(const_cast<T*>(sendData),sendDataLen,displ,MPITraits<T>::getType(),
│ │ │ │ +
362 recvData,recvDataLen,MPITraits<T>::getType(),
│ │ │ │ +
363 root,communicator);
│ │ │ │ +
364 }
│ │ │ │ +
│ │ │ │ +
365
│ │ │ │ +
366
│ │ │ │ +
│ │ │ │ +
367 operator MPI_Comm () const
│ │ │ │ +
368 {
│ │ │ │ +
369 return communicator;
│ │ │ │ +
370 }
│ │ │ │ +
│ │ │ │ +
371
│ │ │ │ +
373 template<typename T, typename T1>
│ │ │ │ +
│ │ │ │ +
374 int allgather(const T* sbuf, int count, T1* rbuf) const
│ │ │ │ +
375 {
│ │ │ │ +
376 return MPI_Allgather(const_cast<T*>(sbuf), count, MPITraits<T>::getType(),
│ │ │ │ +
377 rbuf, count, MPITraits<T1>::getType(),
│ │ │ │ +
378 communicator);
│ │ │ │ +
379 }
│ │ │ │ +
│ │ │ │ +
380
│ │ │ │ +
382 template<class TIN, class TOUT = TIN>
│ │ │ │ +
│ │ │ │ +
383 MPIFuture<TOUT, TIN> iallgather(TIN&& data_in, TOUT&& data_out) const
│ │ │ │ +
384 {
│ │ │ │ +
385 MPIFuture<TOUT, TIN> future(std::forward<TOUT>(data_out), std::forward<TIN>(data_in));
│ │ │ │ +
386 auto mpidata_in = future.get_send_mpidata();
│ │ │ │ +
387 auto mpidata_out = future.get_mpidata();
│ │ │ │ +
388 assert(mpidata_in.size()*procs <= mpidata_out.size());
│ │ │ │ +
389 int outlen = mpidata_in.size();
│ │ │ │ +
390 MPI_Iallgather(mpidata_in.ptr(), mpidata_in.size(), mpidata_in.type(),
│ │ │ │ +
391 mpidata_out.ptr(), outlen, mpidata_out.type(),
│ │ │ │ +
392 communicator, &future.req_);
│ │ │ │ +
393 return future;
│ │ │ │ +
394 }
│ │ │ │ +
│ │ │ │ +
395
│ │ │ │ +
397 template<typename T>
│ │ │ │ +
│ │ │ │ +
398 int allgatherv (const T* in, int sendDataLen, T* out, int* recvDataLen, int* displ) const
│ │ │ │ +
399 {
│ │ │ │ +
400 return MPI_Allgatherv(const_cast<T*>(in),sendDataLen,MPITraits<T>::getType(),
│ │ │ │ +
401 out,recvDataLen,displ,MPITraits<T>::getType(),
│ │ │ │ +
402 communicator);
│ │ │ │ +
403 }
│ │ │ │ +
│ │ │ │ +
404
│ │ │ │ +
406 template<typename BinaryFunction, typename Type>
│ │ │ │ +
│ │ │ │ +
407 int allreduce(Type* inout, int len) const
│ │ │ │ +
408 {
│ │ │ │ +
409 Type* out = new Type[len];
│ │ │ │ +
410 int ret = allreduce<BinaryFunction>(inout,out,len);
│ │ │ │ +
411 std::copy(out, out+len, inout);
│ │ │ │ +
412 delete[] out;
│ │ │ │ +
413 return ret;
│ │ │ │ +
414 }
│ │ │ │ +
│ │ │ │ +
415
│ │ │ │ +
416 template<typename BinaryFunction, typename Type>
│ │ │ │ +
│ │ │ │ +
417 Type allreduce(Type&& in) const{
│ │ │ │ +
418 Type lvalue_data = std::forward<Type>(in);
│ │ │ │ +
419 auto data = getMPIData(lvalue_data);
│ │ │ │ +
420 MPI_Allreduce(MPI_IN_PLACE, data.ptr(), data.size(), data.type(),
│ │ │ │ + │ │ │ │ +
422 communicator);
│ │ │ │ +
423 return lvalue_data;
│ │ │ │ +
424 }
│ │ │ │ +
│ │ │ │ +
425
│ │ │ │ +
427 template<class BinaryFunction, class TIN, class TOUT = TIN>
│ │ │ │ +
│ │ │ │ +
428 MPIFuture<TOUT, TIN> iallreduce(TIN&& data_in, TOUT&& data_out) const {
│ │ │ │ +
429 MPIFuture<TOUT, TIN> future(std::forward<TOUT>(data_out), std::forward<TIN>(data_in));
│ │ │ │ +
430 auto mpidata_in = future.get_send_mpidata();
│ │ │ │ +
431 auto mpidata_out = future.get_mpidata();
│ │ │ │ +
432 assert(mpidata_out.size() == mpidata_in.size());
│ │ │ │ +
433 assert(mpidata_out.type() == mpidata_in.type());
│ │ │ │ +
434 MPI_Iallreduce(mpidata_in.ptr(), mpidata_out.ptr(),
│ │ │ │ +
435 mpidata_out.size(), mpidata_out.type(),
│ │ │ │ + │ │ │ │ +
437 communicator, &future.req_);
│ │ │ │ +
438 return future;
│ │ │ │ +
439 }
│ │ │ │ +
│ │ │ │ +
440
│ │ │ │ +
442 template<class BinaryFunction, class T>
│ │ │ │ +
│ │ │ │ +
443 MPIFuture<T> iallreduce(T&& data) const{
│ │ │ │ +
444 MPIFuture<T> future(std::forward<T>(data));
│ │ │ │ +
445 auto mpidata = future.get_mpidata();
│ │ │ │ +
446 MPI_Iallreduce(MPI_IN_PLACE, mpidata.ptr(),
│ │ │ │ +
447 mpidata.size(), mpidata.type(),
│ │ │ │ + │ │ │ │ +
449 communicator, &future.req_);
│ │ │ │ +
450 return future;
│ │ │ │ +
451 }
│ │ │ │ +
│ │ │ │ +
452
│ │ │ │ +
454 template<typename BinaryFunction, typename Type>
│ │ │ │ +
│ │ │ │ +
455 int allreduce(const Type* in, Type* out, int len) const
│ │ │ │ +
456 {
│ │ │ │ +
457 return MPI_Allreduce(const_cast<Type*>(in), out, len, MPITraits<Type>::getType(),
│ │ │ │ + │ │ │ │ +
459 }
│ │ │ │ +
│ │ │ │ +
460
│ │ │ │ +
461 private:
│ │ │ │ +
462 MPI_Comm communicator;
│ │ │ │ +
463 int me;
│ │ │ │ +
464 int procs;
│ │ │ │ +
465 };
│ │ │ │ +
│ │ │ │ +
466} // namespace dune
│ │ │ │ +
467
│ │ │ │ +
468#endif // HAVE_MPI
│ │ │ │ +
469
│ │ │ │ +
470#endif
│ │ │ │ +
Interface class to translate objects to a MPI_Datatype, void* and size used for MPI calls.
│ │ │ │ +
Traits classes for mapping types onto MPI_Datatype.
│ │ │ │ +
#define ComposeMPIOp(func, op)
Definition mpicommunication.hh:77
│ │ │ │ + │ │ │ │ +
Implements an utility class that provides collective communication methods for sequential programs.
│ │ │ │ +
A few common exception classes.
│ │ │ │ +
helper classes to provide unique types for standard functions
│ │ │ │ +
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
│ │ │ │ +
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ +
auto getMPIData(T &t)
Definition mpidata.hh:43
│ │ │ │ +
A traits class describing the mapping of types onto MPI_Datatypes.
Definition mpitraits.hh:41
│ │ │ │ +
Definition binaryfunctions.hh:18
│ │ │ │ +
Definition binaryfunctions.hh:34
│ │ │ │ +
Default exception if an error in the parallel communication of the program occurred.
Definition exceptions.hh:287
│ │ │ │ +
Collective communication interface and sequential default implementation.
Definition communication.hh:100
│ │ │ │ +
int size() const
Number of processes in set, is greater than 0.
Definition communication.hh:126
│ │ │ │ +
Definition mpicommunication.hh:41
│ │ │ │ +
static MPI_Op get()
Definition mpicommunication.hh:44
│ │ │ │ +
int max(T *inout, int len) const
Compute the maximum of the argument over all processes and return the result in every process....
Definition mpicommunication.hh:259
│ │ │ │ +
int allgatherv(const T *in, int sendDataLen, T *out, int *recvDataLen, int *displ) const
Gathers data of variable length from all tasks and distribute it to all.
Definition mpicommunication.hh:398
│ │ │ │ +
T max(const T &in) const
Compute the maximum of the argument over all processes and return the result in every process....
Definition mpicommunication.hh:250
│ │ │ │ +
MPIFuture< T > ibroadcast(T &&data, int root) const
Distribute an array from the process with rank root to all other processes nonblocking.
Definition mpicommunication.hh:288
│ │ │ │ +
MPIFuture< void > ibarrier() const
Nonblocking barrier.
Definition mpicommunication.hh:271
│ │ │ │ +
MPIFuture< const T > isend(const T &&data, int dest_rank, int tag) const
Sends the data to the dest_rank nonblocking.
Definition mpicommunication.hh:150
│ │ │ │ +
T recv(T &&data, int source_rank, int tag, MPI_Status *status=MPI_STATUS_IGNORE) const
Receives the data from the source_rank.
Definition mpicommunication.hh:161
│ │ │ │ +
int barrier() const
Wait until all processes have arrived at this point in the program.
Definition mpicommunication.hh:265
│ │ │ │ +
int rank() const
Return rank, is between 0 and size()-1.
Definition mpicommunication.hh:128
│ │ │ │ +
int scatterv(const T *sendData, int *sendDataLen, int *displ, T *recvData, int recvDataLen, int root) const
Scatter arrays of variable length from a root to all other tasks.
Definition mpicommunication.hh:359
│ │ │ │ +
MPIFuture< TOUT, TIN > iallgather(TIN &&data_in, TOUT &&data_out) const
Gathers data from all tasks and distribute it to all nonblocking.
Definition mpicommunication.hh:383
│ │ │ │ +
Type allreduce(Type &&in) const
Definition mpicommunication.hh:417
│ │ │ │ +
int sum(T *inout, int len) const
Compute the sum of the argument over all processes and return the result in every process....
Definition mpicommunication.hh:210
│ │ │ │ +
int broadcast(T *inout, int len, int root) const
Distribute an array from the process with rank root to all other processes.
Definition mpicommunication.hh:281
│ │ │ │ +
MPIFuture< T > iallreduce(T &&data) const
Compute something over all processes nonblocking.
Definition mpicommunication.hh:443
│ │ │ │ +
T sum(const T &in) const
Compute the sum of the argument over all processes and return the result in every process....
Definition mpicommunication.hh:201
│ │ │ │ +
int allreduce(const Type *in, Type *out, int len) const
Definition mpicommunication.hh:455
│ │ │ │ +
MPIFuture< TOUT, TIN > iallreduce(TIN &&data_in, TOUT &&data_out) const
Compute something over all processes nonblocking.
Definition mpicommunication.hh:428
│ │ │ │ +
int size() const
Number of processes in set, is greater than 0.
Definition mpicommunication.hh:134
│ │ │ │ +
int gather(const T *in, T *out, int len, int root) const
Gather arrays on root task.
Definition mpicommunication.hh:303
│ │ │ │ +
int allreduce(Type *inout, int len) const
Compute something over all processes for each component of an array and return the result in every pr...
Definition mpicommunication.hh:407
│ │ │ │ +
T rrecv(T &&data, int source_rank, int tag, MPI_Status *status=MPI_STATUS_IGNORE) const
Definition mpicommunication.hh:182
│ │ │ │ +
int scatter(const T *sendData, T *recvData, int len, int root) const
Scatter array from a root to all other task.
Definition mpicommunication.hh:336
│ │ │ │ +
MPIFuture< T > irecv(T &&data, int source_rank, int tag) const
Receives the data from the source_rank nonblocking.
Definition mpicommunication.hh:172
│ │ │ │ +
int prod(T *inout, int len) const
Compute the product of the argument over all processes and return the result in every process....
Definition mpicommunication.hh:226
│ │ │ │ +
MPIFuture< TOUT, TIN > igather(TIN &&data_in, TOUT &&data_out, int root) const
Gather arrays on root task nonblocking.
Definition mpicommunication.hh:312
│ │ │ │ +
T min(const T &in) const
Compute the minimum of the argument over all processes and return the result in every process....
Definition mpicommunication.hh:233
│ │ │ │ +
Communication(const MPI_Comm &c=MPI_COMM_WORLD)
Instantiation using a MPI communicator.
Definition mpicommunication.hh:111
│ │ │ │ +
MPIFuture< TOUT, TIN > iscatter(TIN &&data_in, TOUT &&data_out, int root) const
Scatter array from a root to all other task nonblocking.
Definition mpicommunication.hh:345
│ │ │ │ +
int gatherv(const T *in, int sendDataLen, T *out, int *recvDataLen, int *displ, int root) const
Gather arrays of variable size on root task.
Definition mpicommunication.hh:326
│ │ │ │ +
int min(T *inout, int len) const
Compute the minimum of the argument over all processes and return the result in every process....
Definition mpicommunication.hh:242
│ │ │ │ +
int allgather(const T *sbuf, int count, T1 *rbuf) const
Gathers data from all tasks and distribute it to all.
Definition mpicommunication.hh:374
│ │ │ │ +
int send(const T &data, int dest_rank, int tag) const
Sends the data to the dest_rank.
Definition mpicommunication.hh:141
│ │ │ │ +
T prod(const T &in) const
Compute the product of the argument over all processes and return the result in every process....
Definition mpicommunication.hh:217
│ │ │ │ +
Provides a future-like object for MPI communication. It contains the object that will be received and...
Definition mpifuture.hh:85
│ │ │ │ +
auto get_send_mpidata()
Definition mpifuture.hh:169
│ │ │ │ +
auto get_mpidata()
Definition mpifuture.hh:165
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,48 +7,667 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -deprecated.hh │ │ │ │ │ + * parallel │ │ │ │ │ +mpicommunication.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 (C) 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_DEPRECATED_HH │ │ │ │ │ - 6#define DUNE_DEPRECATED_HH │ │ │ │ │ + 5#ifndef DUNE_COMMON_PARALLEL_MPICOMMUNICATION_HH │ │ │ │ │ + 6#define DUNE_COMMON_PARALLEL_MPICOMMUNICATION_HH │ │ │ │ │ 7 │ │ │ │ │ - 14#ifdef DOXYGEN │ │ │ │ │ -32#define DUNE_NO_DEPRECATED_BEGIN ... │ │ │ │ │ -38#define DUNE_NO_DEPRECATED_END ... │ │ │ │ │ - 39#else │ │ │ │ │ - 40# if defined __clang__ │ │ │ │ │ - 41# define DUNE_NO_DEPRECATED_BEGIN \ │ │ │ │ │ - 42 _Pragma("clang diagnostic push") \ │ │ │ │ │ - 43 _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") │ │ │ │ │ - 44# define DUNE_NO_DEPRECATED_END _Pragma("clang diagnostic pop") │ │ │ │ │ - 45# elif defined __INTEL_COMPILER │ │ │ │ │ - 46# define DUNE_NO_DEPRECATED_BEGIN \ │ │ │ │ │ - 47 _Pragma("warning push") \ │ │ │ │ │ - 48 _Pragma("warning(disable:1478)") \ │ │ │ │ │ - 49 _Pragma("warning(disable:1786)") │ │ │ │ │ - 50# define DUNE_NO_DEPRECATED_END _Pragma("warning pop") │ │ │ │ │ - 51# elif defined __GNUC__ │ │ │ │ │ - 52# define DUNE_NO_DEPRECATED_BEGIN \ │ │ │ │ │ - 53 _Pragma("GCC diagnostic push") \ │ │ │ │ │ - 54 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") │ │ │ │ │ - 55# define DUNE_NO_DEPRECATED_END _Pragma("GCC diagnostic pop") │ │ │ │ │ - 56# else │ │ │ │ │ - 57# define DUNE_NO_DEPRECATED_BEGIN /* Noop. */ │ │ │ │ │ - 58# define DUNE_NO_DEPRECATED_END /* Noop. */ │ │ │ │ │ - 59# endif │ │ │ │ │ - 60#endif │ │ │ │ │ + 16#if HAVE_MPI │ │ │ │ │ + 17 │ │ │ │ │ + 18#include │ │ │ │ │ + 19#include │ │ │ │ │ + 20#include │ │ │ │ │ + 21 │ │ │ │ │ + 22#include │ │ │ │ │ + 23 │ │ │ │ │ + 24#include │ │ │ │ │ + 25#include │ │ │ │ │ + 26#include │ │ │ │ │ + 27#include │ │ │ │ │ + 28#include │ │ │ │ │ + 29#include │ │ │ │ │ + 30 │ │ │ │ │ + 31namespace Dune │ │ │ │ │ + 32{ │ │ │ │ │ + 33 │ │ │ │ │ + 34 //======================================================= │ │ │ │ │ + 35 // use singleton pattern and template specialization to │ │ │ │ │ + 36 // generate MPI operations │ │ │ │ │ + 37 //======================================================= │ │ │ │ │ + 38 │ │ │ │ │ + 39 template │ │ │ │ │ +40 class Generic_MPI_Op │ │ │ │ │ + 41 { │ │ │ │ │ + 42 │ │ │ │ │ + 43 public: │ │ │ │ │ +44 static MPI_Op get () │ │ │ │ │ + 45 { │ │ │ │ │ + 46 if (!op) │ │ │ │ │ + 47 { │ │ │ │ │ + 48 op = std::make_unique(); │ │ │ │ │ + 49 // The following line leaks an MPI operation object, because the │ │ │ │ │ +corresponding │ │ │ │ │ + 50 //`MPI_Op_free` is never called. It is never called because there is no │ │ │ │ │ +easy │ │ │ │ │ + 51 // way to call it at the right moment: right before the call to │ │ │ │ │ +MPI_Finalize. │ │ │ │ │ + 52 // See https://gitlab.dune-project.org/core/dune-istl/issues/80 │ │ │ │ │ + 53 MPI_Op_create((void (*)(void*, void*, int*, │ │ │ │ │ +MPI_Datatype*))&operation,true,op.get()); │ │ │ │ │ + 54 } │ │ │ │ │ + 55 return *op; │ │ │ │ │ + 56 } │ │ │ │ │ + 57 private: │ │ │ │ │ + 58 static void operation (Type *in, Type *inout, int *len, MPI_Datatype*) │ │ │ │ │ + 59 { │ │ │ │ │ + 60 BinaryFunction func; │ │ │ │ │ 61 │ │ │ │ │ - 63 │ │ │ │ │ - 64#endif │ │ │ │ │ + 62 for (int i=0; i< *len; ++i, ++in, ++inout) { │ │ │ │ │ + 63 Type temp; │ │ │ │ │ + 64 temp = func(*in, *inout); │ │ │ │ │ + 65 *inout = temp; │ │ │ │ │ + 66 } │ │ │ │ │ + 67 } │ │ │ │ │ + 68 Generic_MPI_Op () {} │ │ │ │ │ + 69 Generic_MPI_Op (const Generic_MPI_Op& ) {} │ │ │ │ │ + 70 static std::unique_ptr op; │ │ │ │ │ + 71 }; │ │ │ │ │ + 72 │ │ │ │ │ + 73 │ │ │ │ │ + 74 template │ │ │ │ │ + 75 std::unique_ptr Generic_MPI_Op::op; │ │ │ │ │ + 76 │ │ │ │ │ +77#define ComposeMPIOp(func,op) \ │ │ │ │ │ + 78 template \ │ │ │ │ │ + 79 class Generic_MPI_Op, std::enable_if_t:: │ │ │ │ │ +is_intrinsic> >{ \ │ │ │ │ │ + 80 public: \ │ │ │ │ │ + 81 static MPI_Op get(){ \ │ │ │ │ │ + 82 return op; \ │ │ │ │ │ + 83 } \ │ │ │ │ │ + 84 private: \ │ │ │ │ │ + 85 Generic_MPI_Op () {} \ │ │ │ │ │ + 86 Generic_MPI_Op (const Generic_MPI_Op & ) {} \ │ │ │ │ │ + 87 } │ │ │ │ │ + 88 │ │ │ │ │ + 89 │ │ │ │ │ +90 ComposeMPIOp(std::plus, MPI_SUM); │ │ │ │ │ +91 ComposeMPIOp(std::multiplies, MPI_PROD); │ │ │ │ │ +92 ComposeMPIOp(Min, MPI_MIN); │ │ │ │ │ +93 ComposeMPIOp(Max, MPI_MAX); │ │ │ │ │ + 94 │ │ │ │ │ + 95#undef ComposeMPIOp │ │ │ │ │ + 96 │ │ │ │ │ + 97 │ │ │ │ │ + 98 //======================================================= │ │ │ │ │ + 99 // use singleton pattern and template specialization to │ │ │ │ │ + 100 // generate MPI operations │ │ │ │ │ + 101 //======================================================= │ │ │ │ │ + 102 │ │ │ │ │ + 106 template<> │ │ │ │ │ +107 class Communication │ │ │ │ │ + 108 { │ │ │ │ │ + 109 public: │ │ │ │ │ +111 Communication (const MPI_Comm& c = MPI_COMM_WORLD) │ │ │ │ │ + 112 : communicator(c) │ │ │ │ │ + 113 { │ │ │ │ │ + 114 if(communicator!=MPI_COMM_NULL) { │ │ │ │ │ + 115 int initialized = 0; │ │ │ │ │ + 116 MPI_Initialized(&initialized); │ │ │ │ │ + 117 if (!initialized) │ │ │ │ │ + 118 DUNE_THROW(ParallelError,"You must call MPIHelper::instance(argc,argv) in │ │ │ │ │ +your main() function before using the MPI Communication!"); │ │ │ │ │ + 119 MPI_Comm_rank(communicator,&me); │ │ │ │ │ + 120 MPI_Comm_size(communicator,&procs); │ │ │ │ │ + 121 }else{ │ │ │ │ │ + 122 procs=0; │ │ │ │ │ + 123 me=-1; │ │ │ │ │ + 124 } │ │ │ │ │ + 125 } │ │ │ │ │ + 126 │ │ │ │ │ +128 int rank () const │ │ │ │ │ + 129 { │ │ │ │ │ + 130 return me; │ │ │ │ │ + 131 } │ │ │ │ │ + 132 │ │ │ │ │ +134 int size () const │ │ │ │ │ + 135 { │ │ │ │ │ + 136 return procs; │ │ │ │ │ + 137 } │ │ │ │ │ + 138 │ │ │ │ │ + 140 template │ │ │ │ │ +141 int send(const T& data, int dest_rank, int tag) const │ │ │ │ │ + 142 { │ │ │ │ │ + 143 auto mpi_data = getMPIData(data); │ │ │ │ │ + 144 return MPI_Send(mpi_data.ptr(), mpi_data.size(), mpi_data.type(), │ │ │ │ │ + 145 dest_rank, tag, communicator); │ │ │ │ │ + 146 } │ │ │ │ │ + 147 │ │ │ │ │ + 149 template │ │ │ │ │ +150 MPIFuture isend(const T&& data, int dest_rank, int tag) const │ │ │ │ │ + 151 { │ │ │ │ │ + 152 MPIFuture future(std::forward(data)); │ │ │ │ │ + 153 auto mpidata = future.get_mpidata(); │ │ │ │ │ + 154 MPI_Isend(mpidata.ptr(), mpidata.size(), mpidata.type(), │ │ │ │ │ + 155 dest_rank, tag, communicator, &future.req_); │ │ │ │ │ + 156 return future; │ │ │ │ │ + 157 } │ │ │ │ │ + 158 │ │ │ │ │ + 160 template │ │ │ │ │ +161 T recv(T&& data, int source_rank, int tag, MPI_Status* status = │ │ │ │ │ +MPI_STATUS_IGNORE) const │ │ │ │ │ + 162 { │ │ │ │ │ + 163 T lvalue_data(std::forward(data)); │ │ │ │ │ + 164 auto mpi_data = getMPIData(lvalue_data); │ │ │ │ │ + 165 MPI_Recv(mpi_data.ptr(), mpi_data.size(), mpi_data.type(), │ │ │ │ │ + 166 source_rank, tag, communicator, status); │ │ │ │ │ + 167 return lvalue_data; │ │ │ │ │ + 168 } │ │ │ │ │ + 169 │ │ │ │ │ + 171 template │ │ │ │ │ +172 MPIFuture irecv(T&& data, int source_rank, int tag) const │ │ │ │ │ + 173 { │ │ │ │ │ + 174 MPIFuture future(std::forward(data)); │ │ │ │ │ + 175 auto mpidata = future.get_mpidata(); │ │ │ │ │ + 176 MPI_Irecv(mpidata.ptr(), mpidata.size(), mpidata.type(), │ │ │ │ │ + 177 source_rank, tag, communicator, &future.req_); │ │ │ │ │ + 178 return future; │ │ │ │ │ + 179 } │ │ │ │ │ + 180 │ │ │ │ │ + 181 template │ │ │ │ │ +182 T rrecv(T&& data, int source_rank, int tag, MPI_Status* status = │ │ │ │ │ +MPI_STATUS_IGNORE) const │ │ │ │ │ + 183 { │ │ │ │ │ + 184 MPI_Status _status; │ │ │ │ │ + 185 MPI_Message _message; │ │ │ │ │ + 186 T lvalue_data(std::forward(data)); │ │ │ │ │ + 187 auto mpi_data = getMPIData(lvalue_data); │ │ │ │ │ + 188 static_assert(!mpi_data.static_size, "rrecv work only for non-static-sized │ │ │ │ │ +types."); │ │ │ │ │ + 189 if(status == MPI_STATUS_IGNORE) │ │ │ │ │ + 190 status = &_status; │ │ │ │ │ + 191 MPI_Mprobe(source_rank, tag, communicator, &_message, status); │ │ │ │ │ + 192 int size; │ │ │ │ │ + 193 MPI_Get_count(status, mpi_data.type(), &size); │ │ │ │ │ + 194 mpi_data.resize(size); │ │ │ │ │ + 195 MPI_Mrecv(mpi_data.ptr(), mpi_data.size(), mpi_data.type(), &_message, │ │ │ │ │ +status); │ │ │ │ │ + 196 return lvalue_data; │ │ │ │ │ + 197 } │ │ │ │ │ + 198 │ │ │ │ │ + 200 template │ │ │ │ │ +201 T sum (const T& in) const │ │ │ │ │ + 202 { │ │ │ │ │ + 203 T out; │ │ │ │ │ + 204 allreduce >(&in,&out,1); │ │ │ │ │ + 205 return out; │ │ │ │ │ + 206 } │ │ │ │ │ + 207 │ │ │ │ │ + 209 template │ │ │ │ │ +210 int sum (T* inout, int len) const │ │ │ │ │ + 211 { │ │ │ │ │ + 212 return allreduce >(inout,len); │ │ │ │ │ + 213 } │ │ │ │ │ + 214 │ │ │ │ │ + 216 template │ │ │ │ │ +217 T prod (const T& in) const │ │ │ │ │ + 218 { │ │ │ │ │ + 219 T out; │ │ │ │ │ + 220 allreduce >(&in,&out,1); │ │ │ │ │ + 221 return out; │ │ │ │ │ + 222 } │ │ │ │ │ + 223 │ │ │ │ │ + 225 template │ │ │ │ │ +226 int prod (T* inout, int len) const │ │ │ │ │ + 227 { │ │ │ │ │ + 228 return allreduce >(inout,len); │ │ │ │ │ + 229 } │ │ │ │ │ + 230 │ │ │ │ │ + 232 template │ │ │ │ │ +233 T min (const T& in) const │ │ │ │ │ + 234 { │ │ │ │ │ + 235 T out; │ │ │ │ │ + 236 allreduce >(&in,&out,1); │ │ │ │ │ + 237 return out; │ │ │ │ │ + 238 } │ │ │ │ │ + 239 │ │ │ │ │ + 241 template │ │ │ │ │ +242 int min (T* inout, int len) const │ │ │ │ │ + 243 { │ │ │ │ │ + 244 return allreduce >(inout,len); │ │ │ │ │ + 245 } │ │ │ │ │ + 246 │ │ │ │ │ + 247 │ │ │ │ │ + 249 template │ │ │ │ │ +250 T max (const T& in) const │ │ │ │ │ + 251 { │ │ │ │ │ + 252 T out; │ │ │ │ │ + 253 allreduce >(&in,&out,1); │ │ │ │ │ + 254 return out; │ │ │ │ │ + 255 } │ │ │ │ │ + 256 │ │ │ │ │ + 258 template │ │ │ │ │ +259 int max (T* inout, int len) const │ │ │ │ │ + 260 { │ │ │ │ │ + 261 return allreduce >(inout,len); │ │ │ │ │ + 262 } │ │ │ │ │ + 263 │ │ │ │ │ +265 int barrier () const │ │ │ │ │ + 266 { │ │ │ │ │ + 267 return MPI_Barrier(communicator); │ │ │ │ │ + 268 } │ │ │ │ │ + 269 │ │ │ │ │ +271 MPIFuture ibarrier () const │ │ │ │ │ + 272 { │ │ │ │ │ + 273 MPIFuture future(true); // make a valid MPIFuture │ │ │ │ │ + 274 MPI_Ibarrier(communicator, &future.req_); │ │ │ │ │ + 275 return future; │ │ │ │ │ + 276 } │ │ │ │ │ + 277 │ │ │ │ │ + 278 │ │ │ │ │ + 280 template │ │ │ │ │ +281 int broadcast (T* inout, int len, int root) const │ │ │ │ │ + 282 { │ │ │ │ │ + 283 return MPI_Bcast(inout,len,MPITraits::getType(),root,communicator); │ │ │ │ │ + 284 } │ │ │ │ │ + 285 │ │ │ │ │ + 287 template │ │ │ │ │ +288 MPIFuture ibroadcast(T&& data, int root) const{ │ │ │ │ │ + 289 MPIFuture future(std::forward(data)); │ │ │ │ │ + 290 auto mpidata = future.get_mpidata(); │ │ │ │ │ + 291 MPI_Ibcast(mpidata.ptr(), │ │ │ │ │ + 292 mpidata.size(), │ │ │ │ │ + 293 mpidata.type(), │ │ │ │ │ + 294 root, │ │ │ │ │ + 295 communicator, │ │ │ │ │ + 296 &future.req_); │ │ │ │ │ + 297 return future; │ │ │ │ │ + 298 } │ │ │ │ │ + 299 │ │ │ │ │ + 302 template │ │ │ │ │ +303 int gather (const T* in, T* out, int len, int root) const │ │ │ │ │ + 304 { │ │ │ │ │ + 305 return MPI_Gather(const_cast(in),len,MPITraits::getType(), │ │ │ │ │ + 306 out,len,MPITraits::getType(), │ │ │ │ │ + 307 root,communicator); │ │ │ │ │ + 308 } │ │ │ │ │ + 309 │ │ │ │ │ + 311 template> │ │ │ │ │ +312 MPIFuture igather(TIN&& data_in, TOUT&& data_out, int root) │ │ │ │ │ +const{ │ │ │ │ │ + 313 MPIFuture future(std::forward(data_out), std:: │ │ │ │ │ +forward(data_in)); │ │ │ │ │ + 314 auto mpidata_in = future.get_send_mpidata(); │ │ │ │ │ + 315 auto mpidata_out = future.get_mpidata(); │ │ │ │ │ + 316 assert(root != me || mpidata_in.size()*procs <= mpidata_out.size()); │ │ │ │ │ + 317 int outlen = (me==root) * mpidata_in.size(); │ │ │ │ │ + 318 MPI_Igather(mpidata_in.ptr(), mpidata_in.size(), mpidata_in.type(), │ │ │ │ │ + 319 mpidata_out.ptr(), outlen, mpidata_out.type(), │ │ │ │ │ + 320 root, communicator, &future.req_); │ │ │ │ │ + 321 return future; │ │ │ │ │ + 322 } │ │ │ │ │ + 323 │ │ │ │ │ + 325 template │ │ │ │ │ +326 int gatherv (const T* in, int sendDataLen, T* out, int* recvDataLen, int* │ │ │ │ │ +displ, int root) const │ │ │ │ │ + 327 { │ │ │ │ │ + 328 return MPI_Gatherv(const_cast(in),sendDataLen,MPITraits::getType(), │ │ │ │ │ + 329 out,recvDataLen,displ,MPITraits::getType(), │ │ │ │ │ + 330 root,communicator); │ │ │ │ │ + 331 } │ │ │ │ │ + 332 │ │ │ │ │ + 335 template │ │ │ │ │ +336 int scatter (const T* sendData, T* recvData, int len, int root) const │ │ │ │ │ + 337 { │ │ │ │ │ + 338 return MPI_Scatter(const_cast(sendData),len,MPITraits::getType(), │ │ │ │ │ + 339 recvData,len,MPITraits::getType(), │ │ │ │ │ + 340 root,communicator); │ │ │ │ │ + 341 } │ │ │ │ │ + 342 │ │ │ │ │ + 344 template │ │ │ │ │ +345 MPIFuture iscatter(TIN&& data_in, TOUT&& data_out, int root) │ │ │ │ │ +const │ │ │ │ │ + 346 { │ │ │ │ │ + 347 MPIFuture future(std::forward(data_out), std:: │ │ │ │ │ +forward(data_in)); │ │ │ │ │ + 348 auto mpidata_in = future.get_send_mpidata(); │ │ │ │ │ + 349 auto mpidata_out = future.get_mpidata(); │ │ │ │ │ + 350 int inlen = (me==root) * mpidata_in.size()/procs; │ │ │ │ │ + 351 MPI_Iscatter(mpidata_in.ptr(), inlen, mpidata_in.type(), │ │ │ │ │ + 352 mpidata_out.ptr(), mpidata_out.size(), mpidata_out.type(), │ │ │ │ │ + 353 root, communicator, &future.req_); │ │ │ │ │ + 354 return future; │ │ │ │ │ + 355 } │ │ │ │ │ + 356 │ │ │ │ │ + 358 template │ │ │ │ │ +359 int scatterv (const T* sendData, int* sendDataLen, int* displ, T* recvData, │ │ │ │ │ +int recvDataLen, int root) const │ │ │ │ │ + 360 { │ │ │ │ │ + 361 return MPI_Scatterv(const_cast │ │ │ │ │ +(sendData),sendDataLen,displ,MPITraits::getType(), │ │ │ │ │ + 362 recvData,recvDataLen,MPITraits::getType(), │ │ │ │ │ + 363 root,communicator); │ │ │ │ │ + 364 } │ │ │ │ │ + 365 │ │ │ │ │ + 366 │ │ │ │ │ +367 operator MPI_Comm () const │ │ │ │ │ + 368 { │ │ │ │ │ + 369 return communicator; │ │ │ │ │ + 370 } │ │ │ │ │ + 371 │ │ │ │ │ + 373 template │ │ │ │ │ +374 int allgather(const T* sbuf, int count, T1* rbuf) const │ │ │ │ │ + 375 { │ │ │ │ │ + 376 return MPI_Allgather(const_cast(sbuf), count, MPITraits::getType(), │ │ │ │ │ + 377 rbuf, count, MPITraits::getType(), │ │ │ │ │ + 378 communicator); │ │ │ │ │ + 379 } │ │ │ │ │ + 380 │ │ │ │ │ + 382 template │ │ │ │ │ +383 MPIFuture iallgather(TIN&& data_in, TOUT&& data_out) const │ │ │ │ │ + 384 { │ │ │ │ │ + 385 MPIFuture future(std::forward(data_out), std:: │ │ │ │ │ +forward(data_in)); │ │ │ │ │ + 386 auto mpidata_in = future.get_send_mpidata(); │ │ │ │ │ + 387 auto mpidata_out = future.get_mpidata(); │ │ │ │ │ + 388 assert(mpidata_in.size()*procs <= mpidata_out.size()); │ │ │ │ │ + 389 int outlen = mpidata_in.size(); │ │ │ │ │ + 390 MPI_Iallgather(mpidata_in.ptr(), mpidata_in.size(), mpidata_in.type(), │ │ │ │ │ + 391 mpidata_out.ptr(), outlen, mpidata_out.type(), │ │ │ │ │ + 392 communicator, &future.req_); │ │ │ │ │ + 393 return future; │ │ │ │ │ + 394 } │ │ │ │ │ + 395 │ │ │ │ │ + 397 template │ │ │ │ │ +398 int allgatherv (const T* in, int sendDataLen, T* out, int* recvDataLen, │ │ │ │ │ +int* displ) const │ │ │ │ │ + 399 { │ │ │ │ │ + 400 return MPI_Allgatherv(const_cast(in),sendDataLen,MPITraits::getType │ │ │ │ │ +(), │ │ │ │ │ + 401 out,recvDataLen,displ,MPITraits::getType(), │ │ │ │ │ + 402 communicator); │ │ │ │ │ + 403 } │ │ │ │ │ + 404 │ │ │ │ │ + 406 template │ │ │ │ │ +407 int allreduce(Type* inout, int len) const │ │ │ │ │ + 408 { │ │ │ │ │ + 409 Type* out = new Type[len]; │ │ │ │ │ + 410 int ret = allreduce(inout,out,len); │ │ │ │ │ + 411 std::copy(out, out+len, inout); │ │ │ │ │ + 412 delete[] out; │ │ │ │ │ + 413 return ret; │ │ │ │ │ + 414 } │ │ │ │ │ + 415 │ │ │ │ │ + 416 template │ │ │ │ │ +417 Type allreduce(Type&& in) const{ │ │ │ │ │ + 418 Type lvalue_data = std::forward(in); │ │ │ │ │ + 419 auto data = getMPIData(lvalue_data); │ │ │ │ │ + 420 MPI_Allreduce(MPI_IN_PLACE, data.ptr(), data.size(), data.type(), │ │ │ │ │ + 421 (Generic_MPI_Op::get()), │ │ │ │ │ + 422 communicator); │ │ │ │ │ + 423 return lvalue_data; │ │ │ │ │ + 424 } │ │ │ │ │ + 425 │ │ │ │ │ + 427 template │ │ │ │ │ +428 MPIFuture iallreduce(TIN&& data_in, TOUT&& data_out) const { │ │ │ │ │ + 429 MPIFuture future(std::forward(data_out), std:: │ │ │ │ │ +forward(data_in)); │ │ │ │ │ + 430 auto mpidata_in = future.get_send_mpidata(); │ │ │ │ │ + 431 auto mpidata_out = future.get_mpidata(); │ │ │ │ │ + 432 assert(mpidata_out.size() == mpidata_in.size()); │ │ │ │ │ + 433 assert(mpidata_out.type() == mpidata_in.type()); │ │ │ │ │ + 434 MPI_Iallreduce(mpidata_in.ptr(), mpidata_out.ptr(), │ │ │ │ │ + 435 mpidata_out.size(), mpidata_out.type(), │ │ │ │ │ + 436 (Generic_MPI_Op::get()), │ │ │ │ │ + 437 communicator, &future.req_); │ │ │ │ │ + 438 return future; │ │ │ │ │ + 439 } │ │ │ │ │ + 440 │ │ │ │ │ + 442 template │ │ │ │ │ +443 MPIFuture iallreduce(T&& data) const{ │ │ │ │ │ + 444 MPIFuture future(std::forward(data)); │ │ │ │ │ + 445 auto mpidata = future.get_mpidata(); │ │ │ │ │ + 446 MPI_Iallreduce(MPI_IN_PLACE, mpidata.ptr(), │ │ │ │ │ + 447 mpidata.size(), mpidata.type(), │ │ │ │ │ + 448 (Generic_MPI_Op::get()), │ │ │ │ │ + 449 communicator, &future.req_); │ │ │ │ │ + 450 return future; │ │ │ │ │ + 451 } │ │ │ │ │ + 452 │ │ │ │ │ + 454 template │ │ │ │ │ +455 int allreduce(const Type* in, Type* out, int len) const │ │ │ │ │ + 456 { │ │ │ │ │ + 457 return MPI_Allreduce(const_cast(in), out, len, MPITraits:: │ │ │ │ │ +getType(), │ │ │ │ │ + 458 (Generic_MPI_Op::get()),communicator); │ │ │ │ │ + 459 } │ │ │ │ │ + 460 │ │ │ │ │ + 461 private: │ │ │ │ │ + 462 MPI_Comm communicator; │ │ │ │ │ + 463 int me; │ │ │ │ │ + 464 int procs; │ │ │ │ │ + 465 }; │ │ │ │ │ + 466} // namespace dune │ │ │ │ │ + 467 │ │ │ │ │ + 468#endif // HAVE_MPI │ │ │ │ │ + 469 │ │ │ │ │ + 470#endif │ │ │ │ │ +mpidata.hh │ │ │ │ │ +Interface class to translate objects to a MPI_Datatype, void* and size used for │ │ │ │ │ +MPI calls. │ │ │ │ │ +mpitraits.hh │ │ │ │ │ +Traits classes for mapping types onto MPI_Datatype. │ │ │ │ │ +ComposeMPIOp │ │ │ │ │ +#define ComposeMPIOp(func, op) │ │ │ │ │ +Definition mpicommunication.hh:77 │ │ │ │ │ +mpifuture.hh │ │ │ │ │ +communication.hh │ │ │ │ │ +Implements an utility class that provides collective communication methods for │ │ │ │ │ +sequential programs. │ │ │ │ │ +exceptions.hh │ │ │ │ │ +A few common exception classes. │ │ │ │ │ +binaryfunctions.hh │ │ │ │ │ +helper classes to provide unique types for standard functions │ │ │ │ │ +DUNE_THROW │ │ │ │ │ +#define DUNE_THROW(E, m) │ │ │ │ │ +Definition exceptions.hh:218 │ │ │ │ │ +Dune │ │ │ │ │ +Dune namespace. │ │ │ │ │ +Definition alignedallocator.hh:13 │ │ │ │ │ +Dune::getMPIData │ │ │ │ │ +auto getMPIData(T &t) │ │ │ │ │ +Definition mpidata.hh:43 │ │ │ │ │ +Dune::MPITraits │ │ │ │ │ +A traits class describing the mapping of types onto MPI_Datatypes. │ │ │ │ │ +Definition mpitraits.hh:41 │ │ │ │ │ +Dune::Min │ │ │ │ │ +Definition binaryfunctions.hh:18 │ │ │ │ │ +Dune::Max │ │ │ │ │ +Definition binaryfunctions.hh:34 │ │ │ │ │ +Dune::ParallelError │ │ │ │ │ +Default exception if an error in the parallel communication of the program │ │ │ │ │ +occurred. │ │ │ │ │ +Definition exceptions.hh:287 │ │ │ │ │ +Dune::Communication │ │ │ │ │ +Collective communication interface and sequential default implementation. │ │ │ │ │ +Definition communication.hh:100 │ │ │ │ │ +Dune::Communication::size │ │ │ │ │ +int size() const │ │ │ │ │ +Number of processes in set, is greater than 0. │ │ │ │ │ +Definition communication.hh:126 │ │ │ │ │ +Dune::Generic_MPI_Op │ │ │ │ │ +Definition mpicommunication.hh:41 │ │ │ │ │ +Dune::Generic_MPI_Op::get │ │ │ │ │ +static MPI_Op get() │ │ │ │ │ +Definition mpicommunication.hh:44 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::max │ │ │ │ │ +int max(T *inout, int len) const │ │ │ │ │ +Compute the maximum of the argument over all processes and return the result in │ │ │ │ │ +every process.... │ │ │ │ │ +Definition mpicommunication.hh:259 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::allgatherv │ │ │ │ │ +int allgatherv(const T *in, int sendDataLen, T *out, int *recvDataLen, int │ │ │ │ │ +*displ) const │ │ │ │ │ +Gathers data of variable length from all tasks and distribute it to all. │ │ │ │ │ +Definition mpicommunication.hh:398 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::max │ │ │ │ │ +T max(const T &in) const │ │ │ │ │ +Compute the maximum of the argument over all processes and return the result in │ │ │ │ │ +every process.... │ │ │ │ │ +Definition mpicommunication.hh:250 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::ibroadcast │ │ │ │ │ +MPIFuture< T > ibroadcast(T &&data, int root) const │ │ │ │ │ +Distribute an array from the process with rank root to all other processes │ │ │ │ │ +nonblocking. │ │ │ │ │ +Definition mpicommunication.hh:288 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::ibarrier │ │ │ │ │ +MPIFuture< void > ibarrier() const │ │ │ │ │ +Nonblocking barrier. │ │ │ │ │ +Definition mpicommunication.hh:271 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::isend │ │ │ │ │ +MPIFuture< const T > isend(const T &&data, int dest_rank, int tag) const │ │ │ │ │ +Sends the data to the dest_rank nonblocking. │ │ │ │ │ +Definition mpicommunication.hh:150 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::recv │ │ │ │ │ +T recv(T &&data, int source_rank, int tag, MPI_Status │ │ │ │ │ +*status=MPI_STATUS_IGNORE) const │ │ │ │ │ +Receives the data from the source_rank. │ │ │ │ │ +Definition mpicommunication.hh:161 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::barrier │ │ │ │ │ +int barrier() const │ │ │ │ │ +Wait until all processes have arrived at this point in the program. │ │ │ │ │ +Definition mpicommunication.hh:265 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::rank │ │ │ │ │ +int rank() const │ │ │ │ │ +Return rank, is between 0 and size()-1. │ │ │ │ │ +Definition mpicommunication.hh:128 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::scatterv │ │ │ │ │ +int scatterv(const T *sendData, int *sendDataLen, int *displ, T *recvData, int │ │ │ │ │ +recvDataLen, int root) const │ │ │ │ │ +Scatter arrays of variable length from a root to all other tasks. │ │ │ │ │ +Definition mpicommunication.hh:359 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::iallgather │ │ │ │ │ +MPIFuture< TOUT, TIN > iallgather(TIN &&data_in, TOUT &&data_out) const │ │ │ │ │ +Gathers data from all tasks and distribute it to all nonblocking. │ │ │ │ │ +Definition mpicommunication.hh:383 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::allreduce │ │ │ │ │ +Type allreduce(Type &&in) const │ │ │ │ │ +Definition mpicommunication.hh:417 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::sum │ │ │ │ │ +int sum(T *inout, int len) const │ │ │ │ │ +Compute the sum of the argument over all processes and return the result in │ │ │ │ │ +every process.... │ │ │ │ │ +Definition mpicommunication.hh:210 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::broadcast │ │ │ │ │ +int broadcast(T *inout, int len, int root) const │ │ │ │ │ +Distribute an array from the process with rank root to all other processes. │ │ │ │ │ +Definition mpicommunication.hh:281 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::iallreduce │ │ │ │ │ +MPIFuture< T > iallreduce(T &&data) const │ │ │ │ │ +Compute something over all processes nonblocking. │ │ │ │ │ +Definition mpicommunication.hh:443 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::sum │ │ │ │ │ +T sum(const T &in) const │ │ │ │ │ +Compute the sum of the argument over all processes and return the result in │ │ │ │ │ +every process.... │ │ │ │ │ +Definition mpicommunication.hh:201 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::allreduce │ │ │ │ │ +int allreduce(const Type *in, Type *out, int len) const │ │ │ │ │ +Definition mpicommunication.hh:455 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::iallreduce │ │ │ │ │ +MPIFuture< TOUT, TIN > iallreduce(TIN &&data_in, TOUT &&data_out) const │ │ │ │ │ +Compute something over all processes nonblocking. │ │ │ │ │ +Definition mpicommunication.hh:428 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::size │ │ │ │ │ +int size() const │ │ │ │ │ +Number of processes in set, is greater than 0. │ │ │ │ │ +Definition mpicommunication.hh:134 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::gather │ │ │ │ │ +int gather(const T *in, T *out, int len, int root) const │ │ │ │ │ +Gather arrays on root task. │ │ │ │ │ +Definition mpicommunication.hh:303 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::allreduce │ │ │ │ │ +int allreduce(Type *inout, int len) const │ │ │ │ │ +Compute something over all processes for each component of an array and return │ │ │ │ │ +the result in every pr... │ │ │ │ │ +Definition mpicommunication.hh:407 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::rrecv │ │ │ │ │ +T rrecv(T &&data, int source_rank, int tag, MPI_Status │ │ │ │ │ +*status=MPI_STATUS_IGNORE) const │ │ │ │ │ +Definition mpicommunication.hh:182 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::scatter │ │ │ │ │ +int scatter(const T *sendData, T *recvData, int len, int root) const │ │ │ │ │ +Scatter array from a root to all other task. │ │ │ │ │ +Definition mpicommunication.hh:336 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::irecv │ │ │ │ │ +MPIFuture< T > irecv(T &&data, int source_rank, int tag) const │ │ │ │ │ +Receives the data from the source_rank nonblocking. │ │ │ │ │ +Definition mpicommunication.hh:172 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::prod │ │ │ │ │ +int prod(T *inout, int len) const │ │ │ │ │ +Compute the product of the argument over all processes and return the result in │ │ │ │ │ +every process.... │ │ │ │ │ +Definition mpicommunication.hh:226 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::igather │ │ │ │ │ +MPIFuture< TOUT, TIN > igather(TIN &&data_in, TOUT &&data_out, int root) const │ │ │ │ │ +Gather arrays on root task nonblocking. │ │ │ │ │ +Definition mpicommunication.hh:312 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::min │ │ │ │ │ +T min(const T &in) const │ │ │ │ │ +Compute the minimum of the argument over all processes and return the result in │ │ │ │ │ +every process.... │ │ │ │ │ +Definition mpicommunication.hh:233 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::Communication │ │ │ │ │ +Communication(const MPI_Comm &c=MPI_COMM_WORLD) │ │ │ │ │ +Instantiation using a MPI communicator. │ │ │ │ │ +Definition mpicommunication.hh:111 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::iscatter │ │ │ │ │ +MPIFuture< TOUT, TIN > iscatter(TIN &&data_in, TOUT &&data_out, int root) const │ │ │ │ │ +Scatter array from a root to all other task nonblocking. │ │ │ │ │ +Definition mpicommunication.hh:345 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::gatherv │ │ │ │ │ +int gatherv(const T *in, int sendDataLen, T *out, int *recvDataLen, int *displ, │ │ │ │ │ +int root) const │ │ │ │ │ +Gather arrays of variable size on root task. │ │ │ │ │ +Definition mpicommunication.hh:326 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::min │ │ │ │ │ +int min(T *inout, int len) const │ │ │ │ │ +Compute the minimum of the argument over all processes and return the result in │ │ │ │ │ +every process.... │ │ │ │ │ +Definition mpicommunication.hh:242 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::allgather │ │ │ │ │ +int allgather(const T *sbuf, int count, T1 *rbuf) const │ │ │ │ │ +Gathers data from all tasks and distribute it to all. │ │ │ │ │ +Definition mpicommunication.hh:374 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::send │ │ │ │ │ +int send(const T &data, int dest_rank, int tag) const │ │ │ │ │ +Sends the data to the dest_rank. │ │ │ │ │ +Definition mpicommunication.hh:141 │ │ │ │ │ +Dune::Communication<_MPI_Comm_>::prod │ │ │ │ │ +T prod(const T &in) const │ │ │ │ │ +Compute the product of the argument over all processes and return the result in │ │ │ │ │ +every process.... │ │ │ │ │ +Definition mpicommunication.hh:217 │ │ │ │ │ +Dune::MPIFuture │ │ │ │ │ +Provides a future-like object for MPI communication. It contains the object │ │ │ │ │ +that will be received and... │ │ │ │ │ +Definition mpifuture.hh:85 │ │ │ │ │ +Dune::MPIFuture::get_send_mpidata │ │ │ │ │ +auto get_send_mpidata() │ │ │ │ │ +Definition mpifuture.hh:169 │ │ │ │ │ +Dune::MPIFuture::get_mpidata │ │ │ │ │ +auto get_mpidata() │ │ │ │ │ +Definition mpifuture.hh:165 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00026.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: typetraits.hh File Reference │ │ │ │ +dune-common: communicator.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,141 +65,73 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces | │ │ │ │ -Typedefs | │ │ │ │ -Functions
│ │ │ │ -
typetraits.hh File Reference
│ │ │ │ +Namespaces
│ │ │ │ + │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

Traits for type conversions and type information. │ │ │ │ +

Provides utility classes for syncing distributed data via MPI communication. │ │ │ │ More...

│ │ │ │ -
#include <complex>
│ │ │ │ +
#include <cassert>
│ │ │ │ +#include <cstddef>
│ │ │ │ +#include <iostream>
│ │ │ │ +#include <map>
│ │ │ │ #include <type_traits>
│ │ │ │ #include <utility>
│ │ │ │ -#include <vector>
│ │ │ │ +#include <mpi.h>
│ │ │ │ +#include <dune/common/exceptions.hh>
│ │ │ │ +#include <dune/common/parallel/interface.hh>
│ │ │ │ +#include <dune/common/parallel/remoteindices.hh>
│ │ │ │ +#include <dune/common/stdstreams.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

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

│ │ │ │ Classes

struct  Dune::Empty
 Just an empty class. More...
struct  Dune::SizeOne
 Flag for marking indexed data structures where data at each index is of the same size. More...
 
struct  Dune::IsInteroperable< T1, T2 >
 Checks whether two types are interoperable. More...
struct  Dune::VariableSize
 Flag for marking indexed data structures where the data at each index may be a variable multiple of another type. More...
 
struct  Dune::EnableIfInterOperable< T1, T2, Type >
 Enable typedef if two types are interoperable. More...
struct  Dune::CommPolicy< V >
 Default policy used for communicating an indexed type. More...
 
struct  Dune::AlwaysFalse< T >
 template which always yields a false value More...
struct  Dune::CommPolicy< V >::CommPolicy< VariableBlockVector< FieldVector< K, n >, A > >
 
struct  Dune::AlwaysTrue< T >
 template which always yields a true value More...
class  Dune::CommPolicy< V >::CommunicationError
 Error thrown if there was a problem with the communication. More...
 
struct  Dune::IsCallable< F(Args...), R >
 Check if a type is callable with ()-operator and given arguments. More...
struct  Dune::CommPolicy< V >::CopyGatherScatter< T >
 GatherScatter default implementation that just copies data. More...
 
struct  Dune::IsNumber< T >
 Whether this type acts as a scalar in the context of (hierarchically blocked) containers. More...
 
struct  Dune::HasNaN< T >
 Whether this type has a value of NaN. More...
 
struct  Dune::IsIndexable< T, I >
 Type trait to determine whether an instance of T has an operator[](I), i.e. whether it can be indexed with an index of type I. More...
 
struct  Dune::IsIterable< T, typename >
 typetrait to check that a class has begin() and end() members More...
 
struct  Dune::IsTuple< T >
 Check if T is a std::tuple<...> More...
 
struct  Dune::IsTupleOrDerived< T >
 Check if T derived from a std::tuple<...> More...
 
struct  Dune::IsIntegralConstant< T >
 Check if T is an std::integral_constant<I, i> More...
 
struct  Dune::SizeOf< T >
 Compute size of variadic type list. More...
 
struct  Dune::AutonomousValueType< T >
 Type free of internal references that T can be converted to. More...
 
struct  Dune::AutonomousValueType< T & >
 Specialization to remove lvalue references. More...
 
struct  Dune::AutonomousValueType< T && >
 Specialization to remove rvalue references. More...
 
struct  Dune::AutonomousValueType< const T >
 Specialization to remove const qualifiers. More...
 
struct  Dune::AutonomousValueType< volatile T >
 Specialization to remove volatile qualifiers. More...
 
struct  Dune::AutonomousValueType< std::vector< bool >::reference >
 Specialization for the proxies of vector<bool> More...
 
struct  Dune::AutonomousValueType< volatile const T >
 Specialization to remove both const and volatile qualifiers. More...
class  Dune::BufferedCommunicator
 A communicator that uses buffers to gather and scatter the data to be send or received. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

│ │ │ │ Namespaces

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

│ │ │ │ -Typedefs

template<class... Types>
using Dune::void_t = typename Impl::voider< Types... >::type
 Is void for all valid input types. The workhorse for C++11 SFINAE-techniques.
 
template<class Type >
using Dune::field_t = typename FieldTraits< Type >::field_type
 Convenient access to FieldTraits<Type>::field_type.
 
template<class Type >
using Dune::real_t = typename FieldTraits< Type >::real_type
 Convenient access to FieldTraits<Type>::real_type.
 
template<class T >
using Dune::AutonomousValue = typename AutonomousValueType< T >::type
 Type free of internal references that T can be converted to.
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │

│ │ │ │ -Functions

template<class T , T... t, std::size_t index>
constexpr auto Dune::integerSequenceEntry (std::integer_sequence< T, t... >, std::integral_constant< std::size_t, index > i)
 Get entry of std::integer_sequence.
 
template<class T >
constexpr AutonomousValue< T > Dune::autoCopy (T &&v)
 Autonomous copy of an expression's value for use in auto type deduction.
 
│ │ │ │

Detailed Description

│ │ │ │ -

Traits for type conversions and type information.

│ │ │ │ -
Author
Markus Blatt, Christian Engwer
│ │ │ │ +

Provides utility classes for syncing distributed data via MPI communication.

│ │ │ │ +
Author
Markus Blatt
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,123 +6,61 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Typedefs | Functions │ │ │ │ │ -typetraits.hh File Reference │ │ │ │ │ -Traits for type conversions and type information. More... │ │ │ │ │ -#include │ │ │ │ │ + * parallel │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +communicator.hh File Reference │ │ │ │ │ +Common » Parallel_Communication » Parallel_Computing_based_on_Indexsets │ │ │ │ │ +Provides utility classes for syncing distributed data via MPI communication. │ │ │ │ │ +More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -struct  Dune::Empty │ │ │ │ │ -  Just an empty class. More... │ │ │ │ │ +struct  Dune::SizeOne │ │ │ │ │ +  Flag for marking indexed data structures where data at each index is │ │ │ │ │ + of the same size. More... │ │ │ │ │   │ │ │ │ │ -struct  Dune::IsInteroperable<_T1,_T2_> │ │ │ │ │ -  Checks whether two types are interoperable. More... │ │ │ │ │ +struct  Dune::VariableSize │ │ │ │ │ +  Flag for marking indexed data structures where the data at each index │ │ │ │ │ + may be a variable multiple of another type. More... │ │ │ │ │   │ │ │ │ │ -struct  Dune::EnableIfInterOperable<_T1,_T2,_Type_> │ │ │ │ │ -  Enable typedef if two types are interoperable. More... │ │ │ │ │ +struct  Dune::CommPolicy<_V_> │ │ │ │ │ +  Default policy used for communicating an indexed type. More... │ │ │ │ │   │ │ │ │ │ -struct  Dune::AlwaysFalse<_T_> │ │ │ │ │ -  template which always yields a false value More... │ │ │ │ │ +struct  Dune::CommPolicy<_V_>::CommPolicy<_VariableBlockVector<_FieldVector< │ │ │ │ │ + K,_n_>,_A_>_> │ │ │ │ │   │ │ │ │ │ -struct  Dune::AlwaysTrue<_T_> │ │ │ │ │ -  template which always yields a true value More... │ │ │ │ │ + class  Dune::CommPolicy<_V_>::CommunicationError │ │ │ │ │ +  Error thrown if there was a problem with the communication. More... │ │ │ │ │   │ │ │ │ │ -struct  Dune::IsCallable<_F(Args...),_R_> │ │ │ │ │ -  Check if a type is callable with ()-operator and given arguments. │ │ │ │ │ - More... │ │ │ │ │ +struct  Dune::CommPolicy<_V_>::CopyGatherScatter<_T_> │ │ │ │ │ +  GatherScatter default implementation that just copies data. More... │ │ │ │ │   │ │ │ │ │ -struct  Dune::IsNumber<_T_> │ │ │ │ │ -  Whether this type acts as a scalar in the context of (hierarchically │ │ │ │ │ - blocked) containers. More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::HasNaN<_T_> │ │ │ │ │ -  Whether this type has a value of NaN. More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::IsIndexable<_T,_I_> │ │ │ │ │ -  Type trait to determine whether an instance of T has an operator[](I), │ │ │ │ │ - i.e. whether it can be indexed with an index of type I. More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::IsIterable<_T,_typename_> │ │ │ │ │ -  typetrait to check that a class has begin() and end() members More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::IsTuple<_T_> │ │ │ │ │ -  Check if T is a std::tuple<...> More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::IsTupleOrDerived<_T_> │ │ │ │ │ -  Check if T derived from a std::tuple<...> More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::IsIntegralConstant<_T_> │ │ │ │ │ -  Check if T is an std::integral_constant More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::SizeOf<_T_> │ │ │ │ │ -  Compute size of variadic type list. More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::AutonomousValueType<_T_> │ │ │ │ │ -  Type free of internal references that T can be converted to. More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::AutonomousValueType<_T_&_> │ │ │ │ │ -  Specialization to remove lvalue references. More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::AutonomousValueType<_T_&&_> │ │ │ │ │ -  Specialization to remove rvalue references. More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::AutonomousValueType<_const_T_> │ │ │ │ │ -  Specialization to remove const qualifiers. More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::AutonomousValueType<_volatile_T_> │ │ │ │ │ -  Specialization to remove volatile qualifiers. More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::AutonomousValueType<_std::vector<_bool_>::reference_> │ │ │ │ │ -  Specialization for the proxies of vector More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::AutonomousValueType<_volatile_const_T_> │ │ │ │ │ -  Specialization to remove both const and volatile qualifiers. More... │ │ │ │ │ + class  Dune::BufferedCommunicator │ │ │ │ │ +  A communicator that uses buffers to gather and scatter the data to be │ │ │ │ │ + send or received. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ - Typedefs │ │ │ │ │ -template │ │ │ │ │ -using Dune::void_t = typename Impl::voider< Types... >::type │ │ │ │ │ -  Is void for all valid input types. The workhorse for C++11 SFINAE- │ │ │ │ │ - techniques. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -using Dune::field_t = typename FieldTraits< Type >::field_type │ │ │ │ │ -  Convenient access to FieldTraits::field_type. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -using Dune::real_t = typename FieldTraits< Type >::real_type │ │ │ │ │ -  Convenient access to FieldTraits::real_type. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -using Dune::AutonomousValue = typename AutonomousValueType< T >::type │ │ │ │ │ -  Type free of internal references that T can be converted to. │ │ │ │ │ -  │ │ │ │ │ - Functions │ │ │ │ │ -template │ │ │ │ │ - constexpr auto Dune::integerSequenceEntry (std:: │ │ │ │ │ - integer_sequence< T, t... >, std:: │ │ │ │ │ - integral_constant< std::size_t, index > i) │ │ │ │ │ -  Get entry of std::integer_sequence. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -constexpr AutonomousValue< T > Dune::autoCopy (T &&v) │ │ │ │ │ -  Autonomous copy of an expression's value for │ │ │ │ │ - use in auto type deduction. │ │ │ │ │ -  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Traits for type conversions and type information. │ │ │ │ │ +Provides utility classes for syncing distributed data via MPI communication. │ │ │ │ │ Author │ │ │ │ │ - Markus Blatt, Christian Engwer │ │ │ │ │ + Markus Blatt │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00026_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: typetraits.hh Source File │ │ │ │ +dune-common: communicator.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,415 +70,1040 @@ │ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
typetraits.hh
│ │ │ │ +
communicator.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 (C) 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_TYPETRAITS_HH
│ │ │ │ -
6#define DUNE_TYPETRAITS_HH
│ │ │ │ +
5#ifndef DUNE_COMMUNICATOR
│ │ │ │ +
6#define DUNE_COMMUNICATOR
│ │ │ │
7
│ │ │ │ -
8#include <complex>
│ │ │ │ -
9#include <type_traits>
│ │ │ │ -
10#include <utility>
│ │ │ │ -
11#include <vector>
│ │ │ │ -
12
│ │ │ │ -
13namespace Dune
│ │ │ │ -
14{
│ │ │ │ -
15
│ │ │ │ -
16 namespace Impl
│ │ │ │ -
17 {
│ │ │ │ -
19
│ │ │ │ -
23 template <class...>
│ │ │ │ -
24 struct voider
│ │ │ │ -
25 {
│ │ │ │ -
26 using type = void;
│ │ │ │ -
27 };
│ │ │ │ -
28 }
│ │ │ │ -
29
│ │ │ │ -
31
│ │ │ │ -
39 template <class... Types>
│ │ │ │ -
40 using void_t = typename Impl::voider<Types...>::type;
│ │ │ │ -
41
│ │ │ │ -
55 struct Empty {};
│ │ │ │ -
56
│ │ │ │ -
63 template<class T1, class T2>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
65 {
│ │ │ │ -
70 constexpr static bool value = std::is_convertible<T1,T2>::value || std::is_convertible<T2,T1>::value;
│ │ │ │ -
71 };
│ │ │ │ -
│ │ │ │ -
72
│ │ │ │ -
78 template<class T1, class T2, class Type>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
80 : public std::enable_if<IsInteroperable<T1,T2>::value, Type>
│ │ │ │ -
81 {};
│ │ │ │ -
│ │ │ │ -
82
│ │ │ │ -
100
│ │ │ │ -
116
│ │ │ │ -
123 template<typename T>
│ │ │ │ -
124 struct AlwaysFalse : public std::false_type {};
│ │ │ │ -
125
│ │ │ │ -
133 template<typename T>
│ │ │ │ -
134 struct AlwaysTrue : public std::true_type {};
│ │ │ │ -
135
│ │ │ │ -
161 template<typename D, typename R = void>
│ │ │ │ - │ │ │ │ -
163
│ │ │ │ -
168 template<typename R, typename F, typename... Args>
│ │ │ │ -
│ │ │ │ -
169 struct IsCallable<F(Args...), R>
│ │ │ │ -
170 : public std::bool_constant<
│ │ │ │ -
171 std::is_invocable_r_v<R, F, Args...>
│ │ │ │ -
172 && !std::is_member_pointer_v<std::decay_t<F>>
│ │ │ │ -
173 > {};
│ │ │ │ -
│ │ │ │ +
8#if HAVE_MPI
│ │ │ │ +
9
│ │ │ │ +
10#include <cassert>
│ │ │ │ +
11#include <cstddef>
│ │ │ │ +
12#include <iostream>
│ │ │ │ +
13#include <map>
│ │ │ │ +
14#include <type_traits>
│ │ │ │ +
15#include <utility>
│ │ │ │ +
16
│ │ │ │ +
17#include <mpi.h>
│ │ │ │ +
18
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
23
│ │ │ │ +
24namespace Dune
│ │ │ │ +
25{
│ │ │ │ +
│ │ │ │ +
109 struct SizeOne
│ │ │ │ +
110 {};
│ │ │ │ +
│ │ │ │ +
111
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
118 {};
│ │ │ │ +
│ │ │ │ +
119
│ │ │ │ +
120
│ │ │ │ +
126 template<class V>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
128 {
│ │ │ │ +
140 typedef V Type;
│ │ │ │ +
141
│ │ │ │ +
147 typedef typename V::value_type IndexedType;
│ │ │ │ +
148
│ │ │ │ + │ │ │ │ +
154
│ │ │ │ +
163 static const void* getAddress(const V& v, int index);
│ │ │ │ +
164
│ │ │ │ +
170 static int getSize(const V&, int index);
│ │ │ │ +
171 };
│ │ │ │ +
172
│ │ │ │ +
173 template<class K, int n> class FieldVector;
│ │ │ │
174
│ │ │ │ -
177
│ │ │ │ -
192 template <typename T>
│ │ │ │ -
│ │ │ │ -
193 struct IsNumber
│ │ │ │ -
194 : public std::integral_constant<bool, std::is_arithmetic<T>::value> {
│ │ │ │ -
195 };
│ │ │ │ +
175 template<class B, class A> class VariableBlockVector;
│ │ │ │ +
176
│ │ │ │ +
177 template<class K, class A, int n>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
179 {
│ │ │ │ + │ │ │ │ +
181
│ │ │ │ +
182 typedef typename Type::B IndexedType;
│ │ │ │ +
183
│ │ │ │ + │ │ │ │ +
185
│ │ │ │ +
186 static const void* getAddress(const Type& v, int i);
│ │ │ │ +
187
│ │ │ │ +
188 static int getSize(const Type& v, int i);
│ │ │ │ +
189 };
│ │ │ │ +
│ │ │ │ +
190
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
195 {};
│ │ │ │
│ │ │ │
196
│ │ │ │ -
197#ifndef DOXYGEN
│ │ │ │ -
198
│ │ │ │ -
199 template <typename T>
│ │ │ │ -
200 struct IsNumber<std::complex<T>>
│ │ │ │ -
201 : public std::integral_constant<bool, IsNumber<T>::value> {
│ │ │ │ -
202 };
│ │ │ │ -
203
│ │ │ │ -
204#endif // DOXYGEN
│ │ │ │ -
205
│ │ │ │ -
207
│ │ │ │ -
210 template <typename T>
│ │ │ │ -
│ │ │ │ -
211 struct HasNaN
│ │ │ │ -
212 : public std::integral_constant<bool, std::is_floating_point<T>::value> {
│ │ │ │ -
213 };
│ │ │ │ -
│ │ │ │ -
214
│ │ │ │ -
215#ifndef DOXYGEN
│ │ │ │ -
216
│ │ │ │ -
217 template <typename T>
│ │ │ │ -
218 struct HasNaN<std::complex<T>>
│ │ │ │ -
219 : public std::integral_constant<bool, std::is_floating_point<T>::value> {
│ │ │ │ -
220 };
│ │ │ │ -
221
│ │ │ │ -
222#endif // DOXYGEN
│ │ │ │ -
223
│ │ │ │ -
224#ifndef DOXYGEN
│ │ │ │ -
225
│ │ │ │ -
226 namespace Impl {
│ │ │ │ -
227
│ │ │ │ -
228 template<typename T, typename I, typename = int>
│ │ │ │ -
229 struct IsIndexable
│ │ │ │ -
230 : public std::false_type
│ │ │ │ -
231 {};
│ │ │ │ -
232
│ │ │ │ -
233 template<typename T, typename I>
│ │ │ │ -
234 struct IsIndexable<T,I,typename std::enable_if<(sizeof(std::declval<T>()[std::declval<I>()]) > 0),int>::type>
│ │ │ │ -
235 : public std::true_type
│ │ │ │ -
236 {};
│ │ │ │ -
237
│ │ │ │ -
238 }
│ │ │ │ -
239
│ │ │ │ -
240#endif // DOXYGEN
│ │ │ │ +
200 template<class T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
202 {
│ │ │ │ + │ │ │ │ +
204
│ │ │ │ +
205 static const IndexedType& gather(const T& vec, std::size_t i);
│ │ │ │ +
206
│ │ │ │ +
207 static void scatter(T& vec, const IndexedType& v, std::size_t i);
│ │ │ │ +
208
│ │ │ │ +
209 };
│ │ │ │ +
│ │ │ │ +
210
│ │ │ │ +
222 template<typename T>
│ │ │ │ +
223 class DatatypeCommunicator : public InterfaceBuilder
│ │ │ │ +
224 {
│ │ │ │ +
225 public:
│ │ │ │ +
226
│ │ │ │ +
230 typedef T ParallelIndexSet;
│ │ │ │ +
231
│ │ │ │ + │ │ │ │ +
236
│ │ │ │ +
240 typedef typename RemoteIndices::GlobalIndex GlobalIndex;
│ │ │ │
241
│ │ │ │ -
243
│ │ │ │ -
247 template<typename T, typename I = std::size_t>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
249 : public Impl::IsIndexable<T,I>
│ │ │ │ -
250 {};
│ │ │ │ -
│ │ │ │ +
245 typedef typename RemoteIndices::Attribute Attribute;
│ │ │ │ +
246
│ │ │ │ +
250 typedef typename RemoteIndices::LocalIndex LocalIndex;
│ │ │ │
251
│ │ │ │ -
252#ifndef DOXYGEN
│ │ │ │ -
253
│ │ │ │ -
254 namespace Impl {
│ │ │ │ -
255 // This function does nothing.
│ │ │ │ -
256 // By passing expressions to this function one can avoid
│ │ │ │ -
257 // "value computed is not used" warnings that may show up
│ │ │ │ -
258 // in a comma expression.
│ │ │ │ -
259 template<class...T>
│ │ │ │ -
260 void ignore(T&&... /*t*/)
│ │ │ │ -
261 {}
│ │ │ │ -
262 }
│ │ │ │ -
263
│ │ │ │ -
264#endif // DOXYGEN
│ │ │ │ -
265
│ │ │ │ -
269 // default version, gets picked if SFINAE fails
│ │ │ │ -
270 template<typename T, typename = void>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
272 : public std::false_type
│ │ │ │ -
273 {};
│ │ │ │ -
│ │ │ │ -
274
│ │ │ │ -
275#ifndef DOXYGEN
│ │ │ │ -
276 // version for types with begin() and end()
│ │ │ │ -
277 template<typename T>
│ │ │ │ -
278 struct IsIterable<T, decltype(Impl::ignore(
│ │ │ │ -
279 std::declval<T>().begin(),
│ │ │ │ -
280 std::declval<T>().end(),
│ │ │ │ -
281 std::declval<T>().begin() != std::declval<T>().end(),
│ │ │ │ -
282 decltype(std::declval<T>().begin()){std::declval<T>().end()},
│ │ │ │ -
283 ++(std::declval<std::add_lvalue_reference_t<decltype(std::declval<T>().begin())>>()),
│ │ │ │ -
284 *(std::declval<T>().begin())
│ │ │ │ -
285 ))>
│ │ │ │ -
286 : public std::true_type
│ │ │ │ -
287 {};
│ │ │ │ -
288#endif
│ │ │ │ -
289
│ │ │ │ -
290#ifndef DOXYGEN
│ │ │ │ -
291 // this is just a forward declaration
│ │ │ │ -
292 template <class> struct FieldTraits;
│ │ │ │ -
293#endif
│ │ │ │ -
294
│ │ │ │ -
296 template <class Type>
│ │ │ │ - │ │ │ │ -
298
│ │ │ │ -
300 template <class Type>
│ │ │ │ - │ │ │ │ -
302
│ │ │ │ -
303
│ │ │ │ -
304#ifndef DOXYGEN
│ │ │ │ -
305
│ │ │ │ -
306 // Implementation of IsTuple
│ │ │ │ -
307 namespace Impl {
│ │ │ │ -
308
│ │ │ │ -
309 template<class T>
│ │ │ │ -
310 struct IsTuple : public std::false_type
│ │ │ │ -
311 {};
│ │ │ │ -
312
│ │ │ │ -
313 template<class... T>
│ │ │ │ -
314 struct IsTuple<std::tuple<T...>> : public std::true_type
│ │ │ │ -
315 {};
│ │ │ │ -
316
│ │ │ │ -
317 } // namespace Impl
│ │ │ │ +
255 DatatypeCommunicator();
│ │ │ │ +
256
│ │ │ │ +
260 ~DatatypeCommunicator();
│ │ │ │ +
261
│ │ │ │ +
288 template<class T1, class T2, class V>
│ │ │ │ +
289 void build(const RemoteIndices& remoteIndices, const T1& sourceFlags, V& sendData, const T2& destFlags, V& receiveData);
│ │ │ │ +
290
│ │ │ │ +
294 void forward();
│ │ │ │ +
295
│ │ │ │ +
299 void backward();
│ │ │ │ +
300
│ │ │ │ +
304 void free();
│ │ │ │ +
305 private:
│ │ │ │ +
309 constexpr static int commTag_ = 234;
│ │ │ │ +
310
│ │ │ │ +
314 const RemoteIndices* remoteIndices_;
│ │ │ │ +
315
│ │ │ │ +
316 typedef std::map<int,std::pair<MPI_Datatype,MPI_Datatype> >
│ │ │ │ +
317 MessageTypeMap;
│ │ │ │
318
│ │ │ │ -
319#endif // DOXYGEN
│ │ │ │ -
320
│ │ │ │ -
326 template<class T>
│ │ │ │ -
│ │ │ │ -
327 struct IsTuple :
│ │ │ │ -
328 public Impl::IsTuple<T>
│ │ │ │ -
329 {};
│ │ │ │ -
│ │ │ │ +
322 MessageTypeMap messageTypes;
│ │ │ │ +
323
│ │ │ │ +
327 void* data_;
│ │ │ │ +
328
│ │ │ │ +
329 MPI_Request* requests_[2];
│ │ │ │
330
│ │ │ │ -
331
│ │ │ │ -
332#ifndef DOXYGEN
│ │ │ │ -
333
│ │ │ │ -
334 // Implementation of IsTupleOrDerived
│ │ │ │ -
335 namespace Impl {
│ │ │ │ -
336
│ │ │ │ -
337 template<class... T, class Dummy>
│ │ │ │ -
338 std::true_type isTupleOrDerived(const std::tuple<T...>*, Dummy)
│ │ │ │ -
339 { return {}; }
│ │ │ │ -
340
│ │ │ │ -
341 template<class Dummy>
│ │ │ │ -
342 std::false_type isTupleOrDerived(const void*, Dummy)
│ │ │ │ -
343 { return {}; }
│ │ │ │ -
344
│ │ │ │ -
345 } // namespace Impl
│ │ │ │ -
346
│ │ │ │ -
347#endif // DOXYGEN
│ │ │ │ -
348
│ │ │ │ -
354 template<class T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
356 public decltype(Impl::isTupleOrDerived(std::declval<T*>(), true))
│ │ │ │ -
357 {};
│ │ │ │ -
│ │ │ │ -
358
│ │ │ │ -
359
│ │ │ │ -
360#ifndef DOXYGEN
│ │ │ │ -
361
│ │ │ │ -
362 // Implementation of is IsIntegralConstant
│ │ │ │ -
363 namespace Impl {
│ │ │ │ -
364
│ │ │ │ -
365 template<class T>
│ │ │ │ -
366 struct IsIntegralConstant : public std::false_type
│ │ │ │ -
367 {};
│ │ │ │ -
368
│ │ │ │ -
369 template<class T, T t>
│ │ │ │ -
370 struct IsIntegralConstant<std::integral_constant<T, t>> : public std::true_type
│ │ │ │ -
371 {};
│ │ │ │ -
372
│ │ │ │ -
373 } // namespace Impl
│ │ │ │ -
374
│ │ │ │ -
375#endif // DOXYGEN
│ │ │ │ -
376
│ │ │ │ -
382 template<class T>
│ │ │ │ -
│ │ │ │ -
383 struct IsIntegralConstant : public Impl::IsIntegralConstant<std::decay_t<T>>
│ │ │ │ -
384 {};
│ │ │ │ -
│ │ │ │ -
385
│ │ │ │ -
386
│ │ │ │ -
387
│ │ │ │ -
401 template<typename... T>
│ │ │ │ -
│ │ │ │ -
402 struct SizeOf
│ │ │ │ -
403 : public std::integral_constant<std::size_t,sizeof...(T)>
│ │ │ │ -
404 {};
│ │ │ │ -
│ │ │ │ -
405
│ │ │ │ -
406
│ │ │ │ -
407#ifndef DOXYGEN
│ │ │ │ +
334 bool created_;
│ │ │ │ +
335
│ │ │ │ +
339 template<class V, bool FORWARD>
│ │ │ │ +
340 void createRequests(V& sendData, V& receiveData);
│ │ │ │ +
341
│ │ │ │ +
345 template<class T1, class T2, class V, bool send>
│ │ │ │ +
346 void createDataTypes(const T1& source, const T2& destination, V& data);
│ │ │ │ +
347
│ │ │ │ +
351 void sendRecv(MPI_Request* req);
│ │ │ │ +
352
│ │ │ │ +
356 struct IndexedTypeInformation
│ │ │ │ +
357 {
│ │ │ │ +
363 void build(int i)
│ │ │ │ +
364 {
│ │ │ │ +
365 length = new int[i];
│ │ │ │ +
366 displ = new MPI_Aint[i];
│ │ │ │ +
367 size = i;
│ │ │ │ +
368 }
│ │ │ │ +
369
│ │ │ │ +
373 void free()
│ │ │ │ +
374 {
│ │ │ │ +
375 delete[] length;
│ │ │ │ +
376 delete[] displ;
│ │ │ │ +
377 }
│ │ │ │ +
379 int* length;
│ │ │ │ +
381 MPI_Aint* displ;
│ │ │ │ +
387 int elements;
│ │ │ │ +
391 int size;
│ │ │ │ +
392 };
│ │ │ │ +
393
│ │ │ │ +
399 template<class V>
│ │ │ │ +
400 struct MPIDatatypeInformation
│ │ │ │ +
401 {
│ │ │ │ +
406 MPIDatatypeInformation(const V& data) : data_(data)
│ │ │ │ +
407 {}
│ │ │ │
408
│ │ │ │ -
409 namespace Impl {
│ │ │ │ -
410
│ │ │ │ -
411 template<class T, T...>
│ │ │ │ -
412 struct IntegerSequenceHelper;
│ │ │ │ -
413
│ │ │ │ -
414 // Helper struct to compute the i-th entry of a std::integer_sequence
│ │ │ │ -
415 //
│ │ │ │ -
416 // This could also be implemented using std::get<index>(std::make_tuple(t...)).
│ │ │ │ -
417 // However, the gcc-6 implementation of std::make_tuple increases the instantiation
│ │ │ │ -
418 // depth by 15 levels for each argument, such that the maximal instantiation depth
│ │ │ │ -
419 // is easily hit, especially with clang where it is set to 256.
│ │ │ │ -
420 template<class T, T head, T... tail>
│ │ │ │ -
421 struct IntegerSequenceHelper<T, head, tail...>
│ │ │ │ -
422 {
│ │ │ │ -
423
│ │ │ │ -
424 // get first entry
│ │ │ │ -
425 static constexpr auto get(std::integral_constant<std::size_t, 0>)
│ │ │ │ -
426 {
│ │ │ │ -
427 return std::integral_constant<T, head>();
│ │ │ │ -
428 }
│ │ │ │ -
429
│ │ │ │ -
430 // call get with first entry cut off and decremented index
│ │ │ │ -
431 template<std::size_t index,
│ │ │ │ -
432 std::enable_if_t<(index > 0) and (index < sizeof...(tail)+1), int> = 0>
│ │ │ │ -
433 static constexpr auto get(std::integral_constant<std::size_t, index>)
│ │ │ │ -
434 {
│ │ │ │ -
435 return IntegerSequenceHelper<T, tail...>::get(std::integral_constant<std::size_t, index-1>());
│ │ │ │ -
436 }
│ │ │ │ -
437
│ │ │ │ -
438 // use static assertion if index exceeds size
│ │ │ │ -
439 template<std::size_t index,
│ │ │ │ -
440 std::enable_if_t<(index >= sizeof...(tail)+1), int> = 0>
│ │ │ │ -
441 static constexpr auto get(std::integral_constant<std::size_t, index>)
│ │ │ │ -
442 {
│ │ │ │ -
443 static_assert(index < sizeof...(tail)+1, "index used in IntegerSequenceEntry exceed size");
│ │ │ │ -
444 }
│ │ │ │ -
445 };
│ │ │ │ -
446
│ │ │ │ -
447 } // end namespace Impl
│ │ │ │ -
448
│ │ │ │ -
449#endif // DOXYGEN
│ │ │ │ -
450
│ │ │ │ -
451
│ │ │ │ -
461 template<class T, T... t, std::size_t index>
│ │ │ │ -
│ │ │ │ -
462 constexpr auto integerSequenceEntry(std::integer_sequence<T, t...> /*seq*/, std::integral_constant<std::size_t, index> i)
│ │ │ │ -
463 {
│ │ │ │ -
464 static_assert(index < sizeof...(t), "index used in IntegerSequenceEntry exceed size");
│ │ │ │ -
465 return Impl::IntegerSequenceHelper<T, t...>::get(i);
│ │ │ │ -
466 }
│ │ │ │ -
│ │ │ │ -
467
│ │ │ │ -
468
│ │ │ │ -
475 template<class IntegerSequence, std::size_t index>
│ │ │ │ - │ │ │ │ -
477
│ │ │ │ -
478#ifndef DOXYGEN
│ │ │ │ -
479
│ │ │ │ -
480 template<class T, T... t, std::size_t i>
│ │ │ │ -
481 struct IntegerSequenceEntry<std::integer_sequence<T, t...>, i>
│ │ │ │ -
482 : public decltype(Impl::IntegerSequenceHelper<T, t...>::get(std::integral_constant<std::size_t, i>()))
│ │ │ │ -
483 {};
│ │ │ │ -
484
│ │ │ │ -
485#endif // DOXYGEN
│ │ │ │ -
486
│ │ │ │ -
500 template<class T>
│ │ │ │ -
501 struct AutonomousValueType { using type = T; };
│ │ │ │ -
502
│ │ │ │ -
504 template<class T>
│ │ │ │ - │ │ │ │ -
506
│ │ │ │ -
508 template<class T>
│ │ │ │ - │ │ │ │ -
510
│ │ │ │ -
512 template<class T>
│ │ │ │ - │ │ │ │ -
514
│ │ │ │ -
516 template<class T>
│ │ │ │ -
517 struct AutonomousValueType<volatile T> : AutonomousValueType<T> {};
│ │ │ │ -
518
│ │ │ │ -
520 template<>
│ │ │ │ -
│ │ │ │ -
521 struct AutonomousValueType<std::vector<bool>::reference>
│ │ │ │ -
522 {
│ │ │ │ -
523 using type = bool;
│ │ │ │ -
524 };
│ │ │ │ -
│ │ │ │ -
525
│ │ │ │ -
527 template<class T>
│ │ │ │ -
528 struct AutonomousValueType<volatile const T> : AutonomousValueType<T> {};
│ │ │ │ -
529
│ │ │ │ -
557 template<class T>
│ │ │ │ - │ │ │ │ -
559
│ │ │ │ -
641 template<class T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
643 {
│ │ │ │ -
644 return v;
│ │ │ │ -
645 }
│ │ │ │ -
│ │ │ │ -
646
│ │ │ │ -
648}
│ │ │ │ -
649#endif
│ │ │ │ -
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:462
│ │ │ │ -
typename FieldTraits< Type >::real_type real_t
Convenient access to FieldTraits<Type>::real_type.
Definition typetraits.hh:301
│ │ │ │ -
constexpr AutonomousValue< T > autoCopy(T &&v)
Autonomous copy of an expression's value for use in auto type deduction.
Definition typetraits.hh:642
│ │ │ │ -
typename AutonomousValueType< T >::type AutonomousValue
Type free of internal references that T can be converted to.
Definition typetraits.hh:558
│ │ │ │ -
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 FieldTraits< Type >::field_type field_t
Convenient access to FieldTraits<Type>::field_type.
Definition typetraits.hh:297
│ │ │ │ -
STL namespace.
│ │ │ │ +
414 void reserve(int proc, int size)
│ │ │ │ +
415 {
│ │ │ │ +
416 information_[proc].build(size);
│ │ │ │ +
417 }
│ │ │ │ +
424 void add(int proc, int local)
│ │ │ │ +
425 {
│ │ │ │ +
426 IndexedTypeInformation& info=information_[proc];
│ │ │ │ +
427 assert((info.elements)<info.size);
│ │ │ │ +
428 MPI_Get_address( const_cast<void*>(CommPolicy<V>::getAddress(data_, local)),
│ │ │ │ +
429 info.displ+info.elements);
│ │ │ │ +
430 info.length[info.elements]=CommPolicy<V>::getSize(data_, local);
│ │ │ │ +
431 info.elements++;
│ │ │ │ +
432 }
│ │ │ │ +
433
│ │ │ │ +
438 std::map<int,IndexedTypeInformation> information_;
│ │ │ │ +
442 const V& data_;
│ │ │ │ +
443
│ │ │ │ +
444 };
│ │ │ │ +
445
│ │ │ │ +
446 };
│ │ │ │ +
│ │ │ │ +
447
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
458 {
│ │ │ │ +
459
│ │ │ │ +
460 public:
│ │ │ │ + │ │ │ │ +
465
│ │ │ │ +
472 template<class Data, class Interface>
│ │ │ │ +
473 typename std::enable_if<std::is_same<SizeOne,typename CommPolicy<Data>::IndexedTypeFlag>::value, void>::type
│ │ │ │ +
474 build(const Interface& interface);
│ │ │ │ +
475
│ │ │ │ +
483 template<class Data, class Interface>
│ │ │ │ +
484 void build(const Data& source, const Data& target, const Interface& interface);
│ │ │ │ +
485
│ │ │ │ +
514 template<class GatherScatter, class Data>
│ │ │ │ +
515 void forward(const Data& source, Data& dest);
│ │ │ │ +
516
│ │ │ │ +
545 template<class GatherScatter, class Data>
│ │ │ │ +
546 void backward(Data& source, const Data& dest);
│ │ │ │ +
547
│ │ │ │ +
573 template<class GatherScatter, class Data>
│ │ │ │ +
574 void forward(Data& data);
│ │ │ │ +
575
│ │ │ │ +
601 template<class GatherScatter, class Data>
│ │ │ │ +
602 void backward(Data& data);
│ │ │ │ +
603
│ │ │ │ +
607 void free();
│ │ │ │ +
608
│ │ │ │ + │ │ │ │ +
613
│ │ │ │ +
614 private:
│ │ │ │ +
615
│ │ │ │ +
619 typedef std::map<int,std::pair<InterfaceInformation,InterfaceInformation> >
│ │ │ │ +
620 InterfaceMap;
│ │ │ │ +
621
│ │ │ │ +
622
│ │ │ │ +
626 template<class Data, typename IndexedTypeFlag>
│ │ │ │ +
627 struct MessageSizeCalculator
│ │ │ │ +
628 {};
│ │ │ │ +
629
│ │ │ │ +
634 template<class Data>
│ │ │ │ +
635 struct MessageSizeCalculator<Data,SizeOne>
│ │ │ │ +
636 {
│ │ │ │ +
643 inline int operator()(const InterfaceInformation& info) const;
│ │ │ │ +
652 inline int operator()(const Data& data, const InterfaceInformation& info) const;
│ │ │ │ +
653 };
│ │ │ │ +
654
│ │ │ │ +
659 template<class Data>
│ │ │ │ +
660 struct MessageSizeCalculator<Data,VariableSize>
│ │ │ │ +
661 {
│ │ │ │ +
670 inline int operator()(const Data& data, const InterfaceInformation& info) const;
│ │ │ │ +
671 };
│ │ │ │ +
672
│ │ │ │ +
676 template<class Data, class GatherScatter, bool send, typename IndexedTypeFlag>
│ │ │ │ +
677 struct MessageGatherer
│ │ │ │ +
678 {};
│ │ │ │ +
679
│ │ │ │ +
684 template<class Data, class GatherScatter, bool send>
│ │ │ │ +
685 struct MessageGatherer<Data,GatherScatter,send,SizeOne>
│ │ │ │ +
686 {
│ │ │ │ +
688 typedef typename CommPolicy<Data>::IndexedType Type;
│ │ │ │ +
689
│ │ │ │ +
694 typedef GatherScatter Gatherer;
│ │ │ │ +
695
│ │ │ │ +
701 constexpr static bool forward = send;
│ │ │ │ +
702
│ │ │ │ +
710 inline void operator()(const InterfaceMap& interface, const Data& data, Type* buffer, size_t bufferSize) const;
│ │ │ │ +
711 };
│ │ │ │ +
712
│ │ │ │ +
717 template<class Data, class GatherScatter, bool send>
│ │ │ │ +
718 struct MessageGatherer<Data,GatherScatter,send,VariableSize>
│ │ │ │ +
719 {
│ │ │ │ +
721 typedef typename CommPolicy<Data>::IndexedType Type;
│ │ │ │ +
722
│ │ │ │ +
727 typedef GatherScatter Gatherer;
│ │ │ │ +
728
│ │ │ │ +
734 constexpr static bool forward = send;
│ │ │ │ +
735
│ │ │ │ +
743 inline void operator()(const InterfaceMap& interface, const Data& data, Type* buffer, size_t bufferSize) const;
│ │ │ │ +
744 };
│ │ │ │ +
745
│ │ │ │ +
749 template<class Data, class GatherScatter, bool send, typename IndexedTypeFlag>
│ │ │ │ +
750 struct MessageScatterer
│ │ │ │ +
751 {};
│ │ │ │ +
752
│ │ │ │ +
757 template<class Data, class GatherScatter, bool send>
│ │ │ │ +
758 struct MessageScatterer<Data,GatherScatter,send,SizeOne>
│ │ │ │ +
759 {
│ │ │ │ +
761 typedef typename CommPolicy<Data>::IndexedType Type;
│ │ │ │ +
762
│ │ │ │ +
767 typedef GatherScatter Scatterer;
│ │ │ │ +
768
│ │ │ │ +
774 constexpr static bool forward = send;
│ │ │ │ +
775
│ │ │ │ +
783 inline void operator()(const InterfaceMap& interface, Data& data, Type* buffer, const int& proc) const;
│ │ │ │ +
784 };
│ │ │ │ +
789 template<class Data, class GatherScatter, bool send>
│ │ │ │ +
790 struct MessageScatterer<Data,GatherScatter,send,VariableSize>
│ │ │ │ +
791 {
│ │ │ │ +
793 typedef typename CommPolicy<Data>::IndexedType Type;
│ │ │ │ +
794
│ │ │ │ +
799 typedef GatherScatter Scatterer;
│ │ │ │ +
800
│ │ │ │ +
806 constexpr static bool forward = send;
│ │ │ │ +
807
│ │ │ │ +
815 inline void operator()(const InterfaceMap& interface, Data& data, Type* buffer, const int& proc) const;
│ │ │ │ +
816 };
│ │ │ │ +
817
│ │ │ │ +
821 struct MessageInformation
│ │ │ │ +
822 {
│ │ │ │ +
824 MessageInformation()
│ │ │ │ +
825 : start_(0), size_(0)
│ │ │ │ +
826 {}
│ │ │ │ +
827
│ │ │ │ +
835 MessageInformation(size_t start, size_t size)
│ │ │ │ +
836 : start_(start), size_(size)
│ │ │ │ +
837 {}
│ │ │ │ +
841 size_t start_;
│ │ │ │ +
845 size_t size_;
│ │ │ │ +
846 };
│ │ │ │ +
847
│ │ │ │ +
854 typedef std::map<int,std::pair<MessageInformation,MessageInformation> >
│ │ │ │ +
855 InformationMap;
│ │ │ │ +
859 InformationMap messageInformation_;
│ │ │ │ +
863 char* buffers_[2];
│ │ │ │ +
867 size_t bufferSize_[2];
│ │ │ │ +
868
│ │ │ │ +
872 constexpr static int commTag_ = 0;
│ │ │ │ +
873
│ │ │ │ +
877 std::map<int,std::pair<InterfaceInformation,InterfaceInformation> > interfaces_;
│ │ │ │ +
878
│ │ │ │ +
879 MPI_Comm communicator_;
│ │ │ │ +
880
│ │ │ │ +
884 template<class GatherScatter, bool FORWARD, class Data>
│ │ │ │ +
885 void sendRecv(const Data& source, Data& target);
│ │ │ │ +
886
│ │ │ │ +
887 };
│ │ │ │ +
│ │ │ │ +
888
│ │ │ │ +
889#ifndef DOXYGEN
│ │ │ │ +
890
│ │ │ │ +
891 template<class V>
│ │ │ │ +
892 inline const void* CommPolicy<V>::getAddress(const V& v, int index)
│ │ │ │ +
893 {
│ │ │ │ +
894 return &(v[index]);
│ │ │ │ +
895 }
│ │ │ │ +
896
│ │ │ │ +
897 template<class V>
│ │ │ │ +
898 inline int CommPolicy<V>::getSize([[maybe_unused]] const V& v, [[maybe_unused]] int index)
│ │ │ │ +
899 {
│ │ │ │ +
900 return 1;
│ │ │ │ +
901 }
│ │ │ │ +
902
│ │ │ │ +
903 template<class K, class A, int n>
│ │ │ │ +
904 inline const void* CommPolicy<VariableBlockVector<FieldVector<K, n>, A> >::getAddress(const Type& v, int index)
│ │ │ │ +
905 {
│ │ │ │ +
906 return &(v[index][0]);
│ │ │ │ +
907 }
│ │ │ │ +
908
│ │ │ │ +
909 template<class K, class A, int n>
│ │ │ │ +
910 inline int CommPolicy<VariableBlockVector<FieldVector<K, n>, A> >::getSize(const Type& v, int index)
│ │ │ │ +
911 {
│ │ │ │ +
912 return v[index].getsize();
│ │ │ │ +
913 }
│ │ │ │ +
914
│ │ │ │ +
915 template<class T>
│ │ │ │ +
916 inline const typename CopyGatherScatter<T>::IndexedType& CopyGatherScatter<T>::gather(const T & vec, std::size_t i)
│ │ │ │ +
917 {
│ │ │ │ +
918 return vec[i];
│ │ │ │ +
919 }
│ │ │ │ +
920
│ │ │ │ +
921 template<class T>
│ │ │ │ +
922 inline void CopyGatherScatter<T>::scatter(T& vec, const IndexedType& v, std::size_t i)
│ │ │ │ +
923 {
│ │ │ │ +
924 vec[i]=v;
│ │ │ │ +
925 }
│ │ │ │ +
926
│ │ │ │ +
927 template<typename T>
│ │ │ │ +
928 DatatypeCommunicator<T>::DatatypeCommunicator()
│ │ │ │ +
929 : remoteIndices_(0), created_(false)
│ │ │ │ +
930 {
│ │ │ │ +
931 requests_[0]=0;
│ │ │ │ +
932 requests_[1]=0;
│ │ │ │ +
933 }
│ │ │ │ +
934
│ │ │ │ +
935
│ │ │ │ +
936
│ │ │ │ +
937 template<typename T>
│ │ │ │ +
938 DatatypeCommunicator<T>::~DatatypeCommunicator()
│ │ │ │ +
939 {
│ │ │ │ +
940 free();
│ │ │ │ +
941 }
│ │ │ │ +
942
│ │ │ │ +
943 template<typename T>
│ │ │ │ +
944 template<class T1, class T2, class V>
│ │ │ │ +
945 inline void DatatypeCommunicator<T>::build(const RemoteIndices& remoteIndices,
│ │ │ │ +
946 const T1& source, V& sendData,
│ │ │ │ +
947 const T2& destination, V& receiveData)
│ │ │ │ +
948 {
│ │ │ │ +
949 remoteIndices_ = &remoteIndices;
│ │ │ │ +
950 free();
│ │ │ │ +
951 createDataTypes<T1,T2,V,false>(source,destination, receiveData);
│ │ │ │ +
952 createDataTypes<T1,T2,V,true>(source,destination, sendData);
│ │ │ │ +
953 createRequests<V,true>(sendData, receiveData);
│ │ │ │ +
954 createRequests<V,false>(receiveData, sendData);
│ │ │ │ +
955 created_=true;
│ │ │ │ +
956 }
│ │ │ │ +
957
│ │ │ │ +
958 template<typename T>
│ │ │ │ +
959 void DatatypeCommunicator<T>::free()
│ │ │ │ +
960 {
│ │ │ │ +
961 if(created_) {
│ │ │ │ +
962 delete[] requests_[0];
│ │ │ │ +
963 delete[] requests_[1];
│ │ │ │ +
964 typedef MessageTypeMap::iterator iterator;
│ │ │ │ +
965 typedef MessageTypeMap::const_iterator const_iterator;
│ │ │ │ +
966
│ │ │ │ +
967 const const_iterator end=messageTypes.end();
│ │ │ │ +
968
│ │ │ │ +
969 for(iterator process = messageTypes.begin(); process != end; ++process) {
│ │ │ │ +
970 MPI_Datatype *type = &(process->second.first);
│ │ │ │ +
971 int finalized=0;
│ │ │ │ +
972 MPI_Finalized(&finalized);
│ │ │ │ +
973 if(*type!=MPI_DATATYPE_NULL && !finalized)
│ │ │ │ +
974 MPI_Type_free(type);
│ │ │ │ +
975 type = &(process->second.second);
│ │ │ │ +
976 if(*type!=MPI_DATATYPE_NULL && !finalized)
│ │ │ │ +
977 MPI_Type_free(type);
│ │ │ │ +
978 }
│ │ │ │ +
979 messageTypes.clear();
│ │ │ │ +
980 created_=false;
│ │ │ │ +
981 }
│ │ │ │ +
982
│ │ │ │ +
983 }
│ │ │ │ +
984
│ │ │ │ +
985 template<typename T>
│ │ │ │ +
986 template<class T1, class T2, class V, bool send>
│ │ │ │ +
987 void DatatypeCommunicator<T>::createDataTypes(const T1& sourceFlags, const T2& destFlags, V& data)
│ │ │ │ +
988 {
│ │ │ │ +
989
│ │ │ │ +
990 MPIDatatypeInformation<V> dataInfo(data);
│ │ │ │ +
991 this->template buildInterface<RemoteIndices,T1,T2,MPIDatatypeInformation<V>,send>(*remoteIndices_,sourceFlags, destFlags, dataInfo);
│ │ │ │ +
992
│ │ │ │ +
993 typedef typename RemoteIndices::RemoteIndexMap::const_iterator const_iterator;
│ │ │ │ +
994 const const_iterator end=this->remoteIndices_->end();
│ │ │ │ +
995
│ │ │ │ +
996 // Allocate MPI_Datatypes and deallocate memory for the type construction.
│ │ │ │ +
997 for(const_iterator process=this->remoteIndices_->begin(); process != end; ++process) {
│ │ │ │ +
998 IndexedTypeInformation& info=dataInfo.information_[process->first];
│ │ │ │ +
999 // Shift the displacement
│ │ │ │ +
1000 MPI_Aint base;
│ │ │ │ +
1001 MPI_Get_address(const_cast<void *>(CommPolicy<V>::getAddress(data, 0)), &base);
│ │ │ │ +
1002
│ │ │ │ +
1003 for(int i=0; i< info.elements; i++) {
│ │ │ │ +
1004 info.displ[i]-=base;
│ │ │ │ +
1005 }
│ │ │ │ +
1006
│ │ │ │ +
1007 // Create data type
│ │ │ │ +
1008 MPI_Datatype* type = &( send ? messageTypes[process->first].first : messageTypes[process->first].second);
│ │ │ │ +
1009 MPI_Type_create_hindexed(info.elements, info.length, info.displ,
│ │ │ │ +
1010 MPITraits<typename CommPolicy<V>::IndexedType>::getType(), type);
│ │ │ │ +
1011 MPI_Type_commit(type);
│ │ │ │ +
1012 // Deallocate memory
│ │ │ │ +
1013 info.free();
│ │ │ │ +
1014 }
│ │ │ │ +
1015 }
│ │ │ │ +
1016
│ │ │ │ +
1017 template<typename T>
│ │ │ │ +
1018 template<class V, bool createForward>
│ │ │ │ +
1019 void DatatypeCommunicator<T>::createRequests(V& sendData, V& receiveData)
│ │ │ │ +
1020 {
│ │ │ │ +
1021 typedef std::map<int,std::pair<MPI_Datatype,MPI_Datatype> >::const_iterator MapIterator;
│ │ │ │ +
1022 int rank;
│ │ │ │ +
1023 static int index = createForward ? 1 : 0;
│ │ │ │ +
1024 int noMessages = messageTypes.size();
│ │ │ │ +
1025 // allocate request handles
│ │ │ │ +
1026 requests_[index] = new MPI_Request[2*noMessages];
│ │ │ │ +
1027 const MapIterator end = messageTypes.end();
│ │ │ │ +
1028 int request=0;
│ │ │ │ +
1029 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
│ │ │ │ +
1030
│ │ │ │ +
1031 // Set up the requests for receiving first
│ │ │ │ +
1032 for(MapIterator process = messageTypes.begin(); process != end;
│ │ │ │ +
1033 ++process, ++request) {
│ │ │ │ +
1034 MPI_Datatype type = createForward ? process->second.second : process->second.first;
│ │ │ │ +
1035 void* address = const_cast<void*>(CommPolicy<V>::getAddress(receiveData,0));
│ │ │ │ +
1036 MPI_Recv_init(address, 1, type, process->first, commTag_, this->remoteIndices_->communicator(), requests_[index]+request);
│ │ │ │ +
1037 }
│ │ │ │ +
1038
│ │ │ │ +
1039 // And now the send requests
│ │ │ │ +
1040
│ │ │ │ +
1041 for(MapIterator process = messageTypes.begin(); process != end;
│ │ │ │ +
1042 ++process, ++request) {
│ │ │ │ +
1043 MPI_Datatype type = createForward ? process->second.first : process->second.second;
│ │ │ │ +
1044 void* address = const_cast<void*>(CommPolicy<V>::getAddress(sendData, 0));
│ │ │ │ +
1045 MPI_Ssend_init(address, 1, type, process->first, commTag_, this->remoteIndices_->communicator(), requests_[index]+request);
│ │ │ │ +
1046 }
│ │ │ │ +
1047 }
│ │ │ │ +
1048
│ │ │ │ +
1049 template<typename T>
│ │ │ │ +
1050 void DatatypeCommunicator<T>::forward()
│ │ │ │ +
1051 {
│ │ │ │ +
1052 sendRecv(requests_[1]);
│ │ │ │ +
1053 }
│ │ │ │ +
1054
│ │ │ │ +
1055 template<typename T>
│ │ │ │ +
1056 void DatatypeCommunicator<T>::backward()
│ │ │ │ +
1057 {
│ │ │ │ +
1058 sendRecv(requests_[0]);
│ │ │ │ +
1059 }
│ │ │ │ +
1060
│ │ │ │ +
1061 template<typename T>
│ │ │ │ +
1062 void DatatypeCommunicator<T>::sendRecv(MPI_Request* requests)
│ │ │ │ +
1063 {
│ │ │ │ +
1064 int noMessages = messageTypes.size();
│ │ │ │ +
1065 // Start the receive calls first
│ │ │ │ +
1066 MPI_Startall(noMessages, requests);
│ │ │ │ +
1067 // Now the send calls
│ │ │ │ +
1068 MPI_Startall(noMessages, requests+noMessages);
│ │ │ │ +
1069
│ │ │ │ +
1070 // Wait for completion of the communication send first then receive
│ │ │ │ +
1071 MPI_Status* status=new MPI_Status[2*noMessages];
│ │ │ │ +
1072 for(int i=0; i<2*noMessages; i++)
│ │ │ │ +
1073 status[i].MPI_ERROR=MPI_SUCCESS;
│ │ │ │ +
1074
│ │ │ │ +
1075 int send = MPI_Waitall(noMessages, requests+noMessages, status+noMessages);
│ │ │ │ +
1076 int receive = MPI_Waitall(noMessages, requests, status);
│ │ │ │ +
1077
│ │ │ │ +
1078 // Error checks
│ │ │ │ +
1079 int success=1, globalSuccess=0;
│ │ │ │ +
1080 if(send==MPI_ERR_IN_STATUS) {
│ │ │ │ +
1081 int rank;
│ │ │ │ +
1082 MPI_Comm_rank(this->remoteIndices_->communicator(), &rank);
│ │ │ │ +
1083 std::cerr<<rank<<": Error in sending :"<<std::endl;
│ │ │ │ +
1084 // Search for the error
│ │ │ │ +
1085 for(int i=noMessages; i< 2*noMessages; i++)
│ │ │ │ +
1086 if(status[i].MPI_ERROR!=MPI_SUCCESS) {
│ │ │ │ +
1087 char message[300];
│ │ │ │ +
1088 int messageLength;
│ │ │ │ +
1089 MPI_Error_string(status[i].MPI_ERROR, message, &messageLength);
│ │ │ │ +
1090 std::cerr<<" source="<<status[i].MPI_SOURCE<<" message: ";
│ │ │ │ +
1091 for(int j = 0; j < messageLength; j++)
│ │ │ │ +
1092 std::cout << message[j];
│ │ │ │ +
1093 }
│ │ │ │ +
1094 std::cerr<<std::endl;
│ │ │ │ +
1095 success=0;
│ │ │ │ +
1096 }
│ │ │ │ +
1097
│ │ │ │ +
1098 if(receive==MPI_ERR_IN_STATUS) {
│ │ │ │ +
1099 int rank;
│ │ │ │ +
1100 MPI_Comm_rank(this->remoteIndices_->communicator(), &rank);
│ │ │ │ +
1101 std::cerr<<rank<<": Error in receiving!"<<std::endl;
│ │ │ │ +
1102 // Search for the error
│ │ │ │ +
1103 for(int i=0; i< noMessages; i++)
│ │ │ │ +
1104 if(status[i].MPI_ERROR!=MPI_SUCCESS) {
│ │ │ │ +
1105 char message[300];
│ │ │ │ +
1106 int messageLength;
│ │ │ │ +
1107 MPI_Error_string(status[i].MPI_ERROR, message, &messageLength);
│ │ │ │ +
1108 std::cerr<<" source="<<status[i].MPI_SOURCE<<" message: ";
│ │ │ │ +
1109 for(int j = 0; j < messageLength; j++)
│ │ │ │ +
1110 std::cerr << message[j];
│ │ │ │ +
1111 }
│ │ │ │ +
1112 std::cerr<<std::endl;
│ │ │ │ +
1113 success=0;
│ │ │ │ +
1114 }
│ │ │ │ +
1115
│ │ │ │ +
1116 MPI_Allreduce(&success, &globalSuccess, 1, MPI_INT, MPI_MIN, this->remoteIndices_->communicator());
│ │ │ │ +
1117
│ │ │ │ +
1118 delete[] status;
│ │ │ │ +
1119
│ │ │ │ +
1120 if(!globalSuccess)
│ │ │ │ +
1121 DUNE_THROW(CommunicationError, "A communication error occurred!");
│ │ │ │ +
1122
│ │ │ │ +
1123 }
│ │ │ │ +
1124
│ │ │ │ + │ │ │ │ +
1126 {
│ │ │ │ +
1127 buffers_[0]=0;
│ │ │ │ +
1128 buffers_[1]=0;
│ │ │ │ +
1129 bufferSize_[0]=0;
│ │ │ │ +
1130 bufferSize_[1]=0;
│ │ │ │ +
1131 }
│ │ │ │ +
1132
│ │ │ │ +
1133 template<class Data, class Interface>
│ │ │ │ +
1134 typename std::enable_if<std::is_same<SizeOne, typename CommPolicy<Data>::IndexedTypeFlag>::value, void>::type
│ │ │ │ +
1135 BufferedCommunicator::build(const Interface& interface)
│ │ │ │ +
1136 {
│ │ │ │ +
1137 interfaces_=interface.interfaces();
│ │ │ │ +
1138 communicator_=interface.communicator();
│ │ │ │ +
1139 typedef typename std::map<int,std::pair<InterfaceInformation,InterfaceInformation> >
│ │ │ │ +
1140 ::const_iterator const_iterator;
│ │ │ │ +
1141 typedef typename CommPolicy<Data>::IndexedTypeFlag Flag;
│ │ │ │ +
1142 const const_iterator end = interfaces_.end();
│ │ │ │ +
1143 int lrank;
│ │ │ │ +
1144 MPI_Comm_rank(communicator_, &lrank);
│ │ │ │ +
1145
│ │ │ │ +
1146 bufferSize_[0]=0;
│ │ │ │ +
1147 bufferSize_[1]=0;
│ │ │ │ +
1148
│ │ │ │ +
1149 for(const_iterator interfacePair = interfaces_.begin();
│ │ │ │ +
1150 interfacePair != end; ++interfacePair) {
│ │ │ │ +
1151 int noSend = MessageSizeCalculator<Data,Flag>() (interfacePair->second.first);
│ │ │ │ +
1152 int noRecv = MessageSizeCalculator<Data,Flag>() (interfacePair->second.second);
│ │ │ │ +
1153 if (noSend + noRecv > 0)
│ │ │ │ +
1154 messageInformation_.insert(std::make_pair(interfacePair->first,
│ │ │ │ +
1155 std::make_pair(MessageInformation(bufferSize_[0],
│ │ │ │ +
1156 noSend*sizeof(typename CommPolicy<Data>::IndexedType)),
│ │ │ │ +
1157 MessageInformation(bufferSize_[1],
│ │ │ │ +
1158 noRecv*sizeof(typename CommPolicy<Data>::IndexedType)))));
│ │ │ │ +
1159 bufferSize_[0] += noSend;
│ │ │ │ +
1160 bufferSize_[1] += noRecv;
│ │ │ │ +
1161 }
│ │ │ │ +
1162
│ │ │ │ +
1163 // allocate the buffers
│ │ │ │ +
1164 bufferSize_[0] *= sizeof(typename CommPolicy<Data>::IndexedType);
│ │ │ │ +
1165 bufferSize_[1] *= sizeof(typename CommPolicy<Data>::IndexedType);
│ │ │ │ +
1166
│ │ │ │ +
1167 buffers_[0] = new char[bufferSize_[0]];
│ │ │ │ +
1168 buffers_[1] = new char[bufferSize_[1]];
│ │ │ │ +
1169 }
│ │ │ │ +
1170
│ │ │ │ +
1171 template<class Data, class Interface>
│ │ │ │ +
1172 void BufferedCommunicator::build(const Data& source, const Data& dest, const Interface& interface)
│ │ │ │ +
1173 {
│ │ │ │ +
1174
│ │ │ │ +
1175 interfaces_=interface.interfaces();
│ │ │ │ +
1176 communicator_=interface.communicator();
│ │ │ │ +
1177 typedef typename std::map<int,std::pair<InterfaceInformation,InterfaceInformation> >
│ │ │ │ +
1178 ::const_iterator const_iterator;
│ │ │ │ +
1179 typedef typename CommPolicy<Data>::IndexedTypeFlag Flag;
│ │ │ │ +
1180 const const_iterator end = interfaces_.end();
│ │ │ │ +
1181
│ │ │ │ +
1182 bufferSize_[0]=0;
│ │ │ │ +
1183 bufferSize_[1]=0;
│ │ │ │ +
1184
│ │ │ │ +
1185 for(const_iterator interfacePair = interfaces_.begin();
│ │ │ │ +
1186 interfacePair != end; ++interfacePair) {
│ │ │ │ +
1187 int noSend = MessageSizeCalculator<Data,Flag>() (source, interfacePair->second.first);
│ │ │ │ +
1188 int noRecv = MessageSizeCalculator<Data,Flag>() (dest, interfacePair->second.second);
│ │ │ │ +
1189 if (noSend + noRecv > 0)
│ │ │ │ +
1190 messageInformation_.insert(std::make_pair(interfacePair->first,
│ │ │ │ +
1191 std::make_pair(MessageInformation(bufferSize_[0],
│ │ │ │ +
1192 noSend*sizeof(typename CommPolicy<Data>::IndexedType)),
│ │ │ │ +
1193 MessageInformation(bufferSize_[1],
│ │ │ │ +
1194 noRecv*sizeof(typename CommPolicy<Data>::IndexedType)))));
│ │ │ │ +
1195 bufferSize_[0] += noSend;
│ │ │ │ +
1196 bufferSize_[1] += noRecv;
│ │ │ │ +
1197 }
│ │ │ │ +
1198
│ │ │ │ +
1199 bufferSize_[0] *= sizeof(typename CommPolicy<Data>::IndexedType);
│ │ │ │ +
1200 bufferSize_[1] *= sizeof(typename CommPolicy<Data>::IndexedType);
│ │ │ │ +
1201 // allocate the buffers
│ │ │ │ +
1202 buffers_[0] = new char[bufferSize_[0]];
│ │ │ │ +
1203 buffers_[1] = new char[bufferSize_[1]];
│ │ │ │ +
1204 }
│ │ │ │ +
1205
│ │ │ │ +
1206 inline void BufferedCommunicator::free()
│ │ │ │ +
1207 {
│ │ │ │ +
1208 messageInformation_.clear();
│ │ │ │ +
1209 if(buffers_[0])
│ │ │ │ +
1210 delete[] buffers_[0];
│ │ │ │ +
1211
│ │ │ │ +
1212 if(buffers_[1])
│ │ │ │ +
1213 delete[] buffers_[1];
│ │ │ │ +
1214 buffers_[0]=buffers_[1]=0;
│ │ │ │ +
1215 }
│ │ │ │ +
1216
│ │ │ │ + │ │ │ │ +
1218 {
│ │ │ │ +
1219 free();
│ │ │ │ +
1220 }
│ │ │ │ +
1221
│ │ │ │ +
1222 template<class Data>
│ │ │ │ +
1223 inline int BufferedCommunicator::MessageSizeCalculator<Data,SizeOne>::operator()
│ │ │ │ +
1224 (const InterfaceInformation& info) const
│ │ │ │ +
1225 {
│ │ │ │ +
1226 return info.size();
│ │ │ │ +
1227 }
│ │ │ │ +
1228
│ │ │ │ +
1229
│ │ │ │ +
1230 template<class Data>
│ │ │ │ +
1231 inline int BufferedCommunicator::MessageSizeCalculator<Data,SizeOne>::operator()
│ │ │ │ +
1232 (const Data&, const InterfaceInformation& info) const
│ │ │ │ +
1233 {
│ │ │ │ +
1234 return operator()(info);
│ │ │ │ +
1235 }
│ │ │ │ +
1236
│ │ │ │ +
1237
│ │ │ │ +
1238 template<class Data>
│ │ │ │ +
1239 inline int BufferedCommunicator::MessageSizeCalculator<Data, VariableSize>::operator()
│ │ │ │ +
1240 (const Data& data, const InterfaceInformation& info) const
│ │ │ │ +
1241 {
│ │ │ │ +
1242 int entries=0;
│ │ │ │ +
1243
│ │ │ │ +
1244 for(size_t i=0; i < info.size(); i++)
│ │ │ │ +
1245 entries += CommPolicy<Data>::getSize(data,info[i]);
│ │ │ │ +
1246
│ │ │ │ +
1247 return entries;
│ │ │ │ +
1248 }
│ │ │ │ +
1249
│ │ │ │ +
1250
│ │ │ │ +
1251 template<class Data, class GatherScatter, bool FORWARD>
│ │ │ │ +
1252 inline void BufferedCommunicator::MessageGatherer<Data,GatherScatter,FORWARD,VariableSize>::operator()(const InterfaceMap& interfaces,const Data& data, Type* buffer, [[maybe_unused]] size_t bufferSize) const
│ │ │ │ +
1253 {
│ │ │ │ +
1254 typedef typename InterfaceMap::const_iterator
│ │ │ │ +
1255 const_iterator;
│ │ │ │ +
1256
│ │ │ │ +
1257 int rank;
│ │ │ │ +
1258 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
│ │ │ │ +
1259 const const_iterator end = interfaces.end();
│ │ │ │ +
1260 size_t index=0;
│ │ │ │ +
1261
│ │ │ │ +
1262 for(const_iterator interfacePair = interfaces.begin();
│ │ │ │ +
1263 interfacePair != end; ++interfacePair) {
│ │ │ │ +
1264 int size = forward ? interfacePair->second.first.size() :
│ │ │ │ +
1265 interfacePair->second.second.size();
│ │ │ │ +
1266
│ │ │ │ +
1267 for(int i=0; i < size; i++) {
│ │ │ │ +
1268 int local = forward ? interfacePair->second.first[i] :
│ │ │ │ +
1269 interfacePair->second.second[i];
│ │ │ │ +
1270 for(std::size_t j=0; j < CommPolicy<Data>::getSize(data, local); j++, index++) {
│ │ │ │ +
1271
│ │ │ │ +
1272#ifdef DUNE_ISTL_WITH_CHECKING
│ │ │ │ +
1273 assert(bufferSize>=(index+1)*sizeof(typename CommPolicy<Data>::IndexedType));
│ │ │ │ +
1274#endif
│ │ │ │ +
1275 buffer[index]=GatherScatter::gather(data, local, j);
│ │ │ │ +
1276 }
│ │ │ │ +
1277
│ │ │ │ +
1278 }
│ │ │ │ +
1279 }
│ │ │ │ +
1280
│ │ │ │ +
1281 }
│ │ │ │ +
1282
│ │ │ │ +
1283
│ │ │ │ +
1284 template<class Data, class GatherScatter, bool FORWARD>
│ │ │ │ +
1285 inline void BufferedCommunicator::MessageGatherer<Data,GatherScatter,FORWARD,SizeOne>::operator()(
│ │ │ │ +
1286 const InterfaceMap& interfaces, const Data& data, Type* buffer, [[maybe_unused]] size_t bufferSize) const
│ │ │ │ +
1287 {
│ │ │ │ +
1288 typedef typename InterfaceMap::const_iterator
│ │ │ │ +
1289 const_iterator;
│ │ │ │ +
1290 const const_iterator end = interfaces.end();
│ │ │ │ +
1291 size_t index = 0;
│ │ │ │ +
1292
│ │ │ │ +
1293 int rank;
│ │ │ │ +
1294 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
│ │ │ │ +
1295
│ │ │ │ +
1296 for(const_iterator interfacePair = interfaces.begin();
│ │ │ │ +
1297 interfacePair != end; ++interfacePair) {
│ │ │ │ +
1298 size_t size = FORWARD ? interfacePair->second.first.size() :
│ │ │ │ +
1299 interfacePair->second.second.size();
│ │ │ │ +
1300
│ │ │ │ +
1301 for(size_t i=0; i < size; i++) {
│ │ │ │ +
1302
│ │ │ │ +
1303#ifdef DUNE_ISTL_WITH_CHECKING
│ │ │ │ +
1304 assert(bufferSize>=(index+1)*sizeof(typename CommPolicy<Data>::IndexedType));
│ │ │ │ +
1305#endif
│ │ │ │ +
1306
│ │ │ │ +
1307 buffer[index++] = GatherScatter::gather(data, FORWARD ? interfacePair->second.first[i] :
│ │ │ │ +
1308 interfacePair->second.second[i]);
│ │ │ │ +
1309 }
│ │ │ │ +
1310 }
│ │ │ │ +
1311
│ │ │ │ +
1312 }
│ │ │ │ +
1313
│ │ │ │ +
1314
│ │ │ │ +
1315 template<class Data, class GatherScatter, bool FORWARD>
│ │ │ │ +
1316 inline void BufferedCommunicator::MessageScatterer<Data,GatherScatter,FORWARD,VariableSize>::operator()(const InterfaceMap& interfaces, Data& data, Type* buffer, const int& proc) const
│ │ │ │ +
1317 {
│ │ │ │ +
1318 typedef typename InterfaceMap::value_type::second_type::first_type Information;
│ │ │ │ +
1319 const typename InterfaceMap::const_iterator infoPair = interfaces.find(proc);
│ │ │ │ +
1320
│ │ │ │ +
1321 assert(infoPair!=interfaces.end());
│ │ │ │ +
1322
│ │ │ │ +
1323 const Information& info = FORWARD ? infoPair->second.second :
│ │ │ │ +
1324 infoPair->second.first;
│ │ │ │ +
1325
│ │ │ │ +
1326 for(size_t i=0, index=0; i < info.size(); i++) {
│ │ │ │ +
1327 for(size_t j=0; j < CommPolicy<Data>::getSize(data, info[i]); j++)
│ │ │ │ +
1328 GatherScatter::scatter(data, buffer[index++], info[i], j);
│ │ │ │ +
1329 }
│ │ │ │ +
1330 }
│ │ │ │ +
1331
│ │ │ │ +
1332
│ │ │ │ +
1333 template<class Data, class GatherScatter, bool FORWARD>
│ │ │ │ +
1334 inline void BufferedCommunicator::MessageScatterer<Data,GatherScatter,FORWARD,SizeOne>::operator()(const InterfaceMap& interfaces, Data& data, Type* buffer, const int& proc) const
│ │ │ │ +
1335 {
│ │ │ │ +
1336 typedef typename InterfaceMap::value_type::second_type::first_type Information;
│ │ │ │ +
1337 const typename InterfaceMap::const_iterator infoPair = interfaces.find(proc);
│ │ │ │ +
1338
│ │ │ │ +
1339 assert(infoPair!=interfaces.end());
│ │ │ │ +
1340
│ │ │ │ +
1341 const Information& info = FORWARD ? infoPair->second.second :
│ │ │ │ +
1342 infoPair->second.first;
│ │ │ │ +
1343
│ │ │ │ +
1344 for(size_t i=0; i < info.size(); i++) {
│ │ │ │ +
1345 GatherScatter::scatter(data, buffer[i], info[i]);
│ │ │ │ +
1346 }
│ │ │ │ +
1347 }
│ │ │ │ +
1348
│ │ │ │ +
1349
│ │ │ │ +
1350 template<class GatherScatter,class Data>
│ │ │ │ +
1351 void BufferedCommunicator::forward(Data& data)
│ │ │ │ +
1352 {
│ │ │ │ +
1353 this->template sendRecv<GatherScatter,true>(data, data);
│ │ │ │ +
1354 }
│ │ │ │ +
1355
│ │ │ │ +
1356
│ │ │ │ +
1357 template<class GatherScatter, class Data>
│ │ │ │ +
1358 void BufferedCommunicator::backward(Data& data)
│ │ │ │ +
1359 {
│ │ │ │ +
1360 this->template sendRecv<GatherScatter,false>(data, data);
│ │ │ │ +
1361 }
│ │ │ │ +
1362
│ │ │ │ +
1363
│ │ │ │ +
1364 template<class GatherScatter, class Data>
│ │ │ │ +
1365 void BufferedCommunicator::forward(const Data& source, Data& dest)
│ │ │ │ +
1366 {
│ │ │ │ +
1367 this->template sendRecv<GatherScatter,true>(source, dest);
│ │ │ │ +
1368 }
│ │ │ │ +
1369
│ │ │ │ +
1370
│ │ │ │ +
1371 template<class GatherScatter, class Data>
│ │ │ │ +
1372 void BufferedCommunicator::backward(Data& source, const Data& dest)
│ │ │ │ +
1373 {
│ │ │ │ +
1374 this->template sendRecv<GatherScatter,false>(dest, source);
│ │ │ │ +
1375 }
│ │ │ │ +
1376
│ │ │ │ +
1377
│ │ │ │ +
1378 template<class GatherScatter, bool FORWARD, class Data>
│ │ │ │ +
1379 void BufferedCommunicator::sendRecv(const Data& source, Data& dest)
│ │ │ │ +
1380 {
│ │ │ │ +
1381 int rank, lrank;
│ │ │ │ +
1382
│ │ │ │ +
1383 MPI_Comm_rank(MPI_COMM_WORLD,&rank);
│ │ │ │ +
1384 MPI_Comm_rank(MPI_COMM_WORLD,&lrank);
│ │ │ │ +
1385
│ │ │ │ +
1386 typedef typename CommPolicy<Data>::IndexedType Type;
│ │ │ │ +
1387 Type *sendBuffer, *recvBuffer;
│ │ │ │ +
1388 size_t sendBufferSize;
│ │ │ │ +
1389#ifndef NDEBUG
│ │ │ │ +
1390 size_t recvBufferSize;
│ │ │ │ +
1391#endif
│ │ │ │ +
1392
│ │ │ │ +
1393 if(FORWARD) {
│ │ │ │ +
1394 sendBuffer = reinterpret_cast<Type*>(buffers_[0]);
│ │ │ │ +
1395 sendBufferSize = bufferSize_[0];
│ │ │ │ +
1396 recvBuffer = reinterpret_cast<Type*>(buffers_[1]);
│ │ │ │ +
1397#ifndef NDEBUG
│ │ │ │ +
1398 recvBufferSize = bufferSize_[1];
│ │ │ │ +
1399#endif
│ │ │ │ +
1400 }else{
│ │ │ │ +
1401 sendBuffer = reinterpret_cast<Type*>(buffers_[1]);
│ │ │ │ +
1402 sendBufferSize = bufferSize_[1];
│ │ │ │ +
1403 recvBuffer = reinterpret_cast<Type*>(buffers_[0]);
│ │ │ │ +
1404#ifndef NDEBUG
│ │ │ │ +
1405 recvBufferSize = bufferSize_[0];
│ │ │ │ +
1406#endif
│ │ │ │ +
1407 }
│ │ │ │ +
1408 typedef typename CommPolicy<Data>::IndexedTypeFlag Flag;
│ │ │ │ +
1409
│ │ │ │ +
1410 MessageGatherer<Data,GatherScatter,FORWARD,Flag>() (interfaces_, source, sendBuffer, sendBufferSize);
│ │ │ │ +
1411
│ │ │ │ +
1412 MPI_Request* sendRequests = new MPI_Request[messageInformation_.size()];
│ │ │ │ +
1413 MPI_Request* recvRequests = new MPI_Request[messageInformation_.size()];
│ │ │ │ +
1414 /* Number of recvRequests that are not MPI_REQUEST_NULL */
│ │ │ │ +
1415 size_t numberOfRealRecvRequests = 0;
│ │ │ │ +
1416
│ │ │ │ +
1417 // Setup receive first
│ │ │ │ +
1418 typedef typename InformationMap::const_iterator const_iterator;
│ │ │ │ +
1419
│ │ │ │ +
1420 const const_iterator end = messageInformation_.end();
│ │ │ │ +
1421 size_t i=0;
│ │ │ │ +
1422 int* processMap = new int[messageInformation_.size()];
│ │ │ │ +
1423
│ │ │ │ +
1424 for(const_iterator info = messageInformation_.begin(); info != end; ++info, ++i) {
│ │ │ │ +
1425 processMap[i]=info->first;
│ │ │ │ +
1426 if(FORWARD) {
│ │ │ │ +
1427 assert(info->second.second.start_*sizeof(typename CommPolicy<Data>::IndexedType)+info->second.second.size_ <= recvBufferSize );
│ │ │ │ +
1428 Dune::dvverb<<rank<<": receiving "<<info->second.second.size_<<" from "<<info->first<<std::endl;
│ │ │ │ +
1429 if(info->second.second.size_) {
│ │ │ │ +
1430 MPI_Irecv(recvBuffer+info->second.second.start_, info->second.second.size_,
│ │ │ │ +
1431 MPI_BYTE, info->first, commTag_, communicator_,
│ │ │ │ +
1432 recvRequests+i);
│ │ │ │ +
1433 numberOfRealRecvRequests += 1;
│ │ │ │ +
1434 } else {
│ │ │ │ +
1435 // Nothing to receive -> set request to inactive
│ │ │ │ +
1436 recvRequests[i]=MPI_REQUEST_NULL;
│ │ │ │ +
1437 }
│ │ │ │ +
1438 }else{
│ │ │ │ +
1439 assert(info->second.first.start_*sizeof(typename CommPolicy<Data>::IndexedType)+info->second.first.size_ <= recvBufferSize );
│ │ │ │ +
1440 Dune::dvverb<<rank<<": receiving "<<info->second.first.size_<<" to "<<info->first<<std::endl;
│ │ │ │ +
1441 if(info->second.first.size_) {
│ │ │ │ +
1442 MPI_Irecv(recvBuffer+info->second.first.start_, info->second.first.size_,
│ │ │ │ +
1443 MPI_BYTE, info->first, commTag_, communicator_,
│ │ │ │ +
1444 recvRequests+i);
│ │ │ │ +
1445 numberOfRealRecvRequests += 1;
│ │ │ │ +
1446 } else {
│ │ │ │ +
1447 // Nothing to receive -> set request to inactive
│ │ │ │ +
1448 recvRequests[i]=MPI_REQUEST_NULL;
│ │ │ │ +
1449 }
│ │ │ │ +
1450 }
│ │ │ │ +
1451 }
│ │ │ │ +
1452
│ │ │ │ +
1453 // now the send requests
│ │ │ │ +
1454 i=0;
│ │ │ │ +
1455 for(const_iterator info = messageInformation_.begin(); info != end; ++info, ++i)
│ │ │ │ +
1456 if(FORWARD) {
│ │ │ │ +
1457 assert(info->second.second.start_*sizeof(typename CommPolicy<Data>::IndexedType)+info->second.second.size_ <= recvBufferSize );
│ │ │ │ +
1458 Dune::dvverb<<rank<<": sending "<<info->second.first.size_<<" to "<<info->first<<std::endl;
│ │ │ │ +
1459 assert(info->second.first.start_*sizeof(typename CommPolicy<Data>::IndexedType)+info->second.first.size_ <= sendBufferSize );
│ │ │ │ +
1460 if(info->second.first.size_)
│ │ │ │ +
1461 MPI_Issend(sendBuffer+info->second.first.start_, info->second.first.size_,
│ │ │ │ +
1462 MPI_BYTE, info->first, commTag_, communicator_,
│ │ │ │ +
1463 sendRequests+i);
│ │ │ │ +
1464 else
│ │ │ │ +
1465 // Nothing to send -> set request to inactive
│ │ │ │ +
1466 sendRequests[i]=MPI_REQUEST_NULL;
│ │ │ │ +
1467 }else{
│ │ │ │ +
1468 assert(info->second.second.start_*sizeof(typename CommPolicy<Data>::IndexedType)+info->second.second.size_ <= sendBufferSize );
│ │ │ │ +
1469 Dune::dvverb<<rank<<": sending "<<info->second.second.size_<<" to "<<info->first<<std::endl;
│ │ │ │ +
1470 if(info->second.second.size_)
│ │ │ │ +
1471 MPI_Issend(sendBuffer+info->second.second.start_, info->second.second.size_,
│ │ │ │ +
1472 MPI_BYTE, info->first, commTag_, communicator_,
│ │ │ │ +
1473 sendRequests+i);
│ │ │ │ +
1474 else
│ │ │ │ +
1475 // Nothing to send -> set request to inactive
│ │ │ │ +
1476 sendRequests[i]=MPI_REQUEST_NULL;
│ │ │ │ +
1477 }
│ │ │ │ +
1478
│ │ │ │ +
1479 // Wait for completion of receive and immediately start scatter
│ │ │ │ +
1480 i=0;
│ │ │ │ +
1481 //int success = 1;
│ │ │ │ +
1482 int finished = MPI_UNDEFINED;
│ │ │ │ +
1483 MPI_Status status; //[messageInformation_.size()];
│ │ │ │ +
1484 //MPI_Waitall(messageInformation_.size(), recvRequests, status);
│ │ │ │ +
1485
│ │ │ │ +
1486 for(i=0; i< numberOfRealRecvRequests; i++) {
│ │ │ │ +
1487 status.MPI_ERROR=MPI_SUCCESS;
│ │ │ │ +
1488 MPI_Waitany(messageInformation_.size(), recvRequests, &finished, &status);
│ │ │ │ +
1489 assert(finished != MPI_UNDEFINED);
│ │ │ │ +
1490
│ │ │ │ +
1491 if(status.MPI_ERROR==MPI_SUCCESS) {
│ │ │ │ +
1492 int& proc = processMap[finished];
│ │ │ │ +
1493 typename InformationMap::const_iterator infoIter = messageInformation_.find(proc);
│ │ │ │ +
1494 assert(infoIter != messageInformation_.end());
│ │ │ │ +
1495
│ │ │ │ +
1496 MessageInformation info = (FORWARD) ? infoIter->second.second : infoIter->second.first;
│ │ │ │ +
1497 assert(info.start_+info.size_ <= recvBufferSize);
│ │ │ │ +
1498
│ │ │ │ +
1499 MessageScatterer<Data,GatherScatter,FORWARD,Flag>() (interfaces_, dest, recvBuffer+info.start_, proc);
│ │ │ │ +
1500 }else{
│ │ │ │ +
1501 std::cerr<<rank<<": MPI_Error occurred while receiving message from "<<processMap[finished]<<std::endl;
│ │ │ │ +
1502 //success=0;
│ │ │ │ +
1503 }
│ │ │ │ +
1504 }
│ │ │ │ +
1505
│ │ │ │ +
1506 MPI_Status recvStatus;
│ │ │ │ +
1507
│ │ │ │ +
1508 // Wait for completion of sends
│ │ │ │ +
1509 for(i=0; i< messageInformation_.size(); i++)
│ │ │ │ +
1510 if(MPI_SUCCESS!=MPI_Wait(sendRequests+i, &recvStatus)) {
│ │ │ │ +
1511 std::cerr<<rank<<": MPI_Error occurred while sending message to "<<processMap[finished]<<std::endl;
│ │ │ │ +
1512 //success=0;
│ │ │ │ +
1513 }
│ │ │ │ +
1514 /*
│ │ │ │ +
1515 int globalSuccess;
│ │ │ │ +
1516 MPI_Allreduce(&success, &globalSuccess, 1, MPI_INT, MPI_MIN, interface_->communicator());
│ │ │ │ +
1517
│ │ │ │ +
1518 if(!globalSuccess)
│ │ │ │ +
1519 DUNE_THROW(CommunicationError, "A communication error occurred!");
│ │ │ │ +
1520 */
│ │ │ │ +
1521 delete[] processMap;
│ │ │ │ +
1522 delete[] sendRequests;
│ │ │ │ +
1523 delete[] recvRequests;
│ │ │ │ +
1524
│ │ │ │ +
1525 }
│ │ │ │ +
1526
│ │ │ │ +
1527#endif // DOXYGEN
│ │ │ │ +
1528
│ │ │ │ +
1530}
│ │ │ │ +
1531
│ │ │ │ +
1532#endif // HAVE_MPI
│ │ │ │ +
1533
│ │ │ │ +
1534#endif
│ │ │ │ +
Classes describing a distributed indexset.
│ │ │ │ +
A few common exception classes.
│ │ │ │ +
Standard Dune debug streams.
│ │ │ │ +
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
│ │ │ │ +
DVVerbType dvverb(std::cout)
stream for very verbose output.
Definition stdstreams.hh:95
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
Reference get(const RAPropertyMapHelper< Reference, PropertyMap > &pmap, const Key &key)
Definition propertymap.hh:84
│ │ │ │ -
Whether this type acts as a scalar in the context of (hierarchically blocked) containers.
Definition typetraits.hh:194
│ │ │ │ -
T field_type
export the type representing the field
Definition ftraits.hh:28
│ │ │ │ -
T real_type
export the type representing the real type of the field
Definition ftraits.hh:30
│ │ │ │ -
Just an empty class.
Definition typetraits.hh:55
│ │ │ │ -
Checks whether two types are interoperable.
Definition typetraits.hh:65
│ │ │ │ -
static constexpr bool value
True if either a conversion from T1 to T2 or vice versa exists.
Definition typetraits.hh:70
│ │ │ │ -
Enable typedef if two types are interoperable.
Definition typetraits.hh:81
│ │ │ │ -
template which always yields a false value
Definition typetraits.hh:124
│ │ │ │ -
template which always yields a true value
Definition typetraits.hh:134
│ │ │ │ -
Check if a type is callable with ()-operator and given arguments.
Definition typetraits.hh:162
│ │ │ │ -
Whether this type has a value of NaN.
Definition typetraits.hh:212
│ │ │ │ -
Type trait to determine whether an instance of T has an operator[](I), i.e. whether it can be indexed...
Definition typetraits.hh:250
│ │ │ │ -
typetrait to check that a class has begin() and end() members
Definition typetraits.hh:273
│ │ │ │ -
Check if T is a std::tuple<...>
Definition typetraits.hh:329
│ │ │ │ -
Check if T derived from a std::tuple<...>
Definition typetraits.hh:357
│ │ │ │ -
Check if T is an std::integral_constant<I, i>
Definition typetraits.hh:384
│ │ │ │ -
Compute size of variadic type list.
Definition typetraits.hh:404
│ │ │ │ -
Get entry of std::integer_sequence.
Definition typetraits.hh:476
│ │ │ │ -
Type free of internal references that T can be converted to.
Definition typetraits.hh:501
│ │ │ │ -
T type
Definition typetraits.hh:501
│ │ │ │ - │ │ │ │ +
Default exception class for I/O errors.
Definition exceptions.hh:231
│ │ │ │ +
Flag for marking indexed data structures where data at each index is of the same size.
Definition communicator.hh:110
│ │ │ │ +
Flag for marking indexed data structures where the data at each index may be a variable multiple of a...
Definition communicator.hh:118
│ │ │ │ +
Default policy used for communicating an indexed type.
Definition communicator.hh:128
│ │ │ │ +
V::value_type IndexedType
The type we get at each index with operator[].
Definition communicator.hh:147
│ │ │ │ +
static int getSize(const V &, int index)
Get the number of primitive elements at that index.
│ │ │ │ +
SizeOne IndexedTypeFlag
Whether the indexed type has variable size or there is always one value at each index.
Definition communicator.hh:153
│ │ │ │ +
static const void * getAddress(const V &v, int index)
Get the address of entry at an index.
│ │ │ │ +
V Type
The type the policy is for.
Definition communicator.hh:140
│ │ │ │ +
Definition communicator.hh:173
│ │ │ │ +
Definition communicator.hh:175
│ │ │ │ + │ │ │ │ + │ │ │ │ +
VariableBlockVector< FieldVector< K, n >, A > Type
Definition communicator.hh:180
│ │ │ │ + │ │ │ │ + │ │ │ │ +
Error thrown if there was a problem with the communication.
Definition communicator.hh:195
│ │ │ │ +
GatherScatter default implementation that just copies data.
Definition communicator.hh:202
│ │ │ │ +
static void scatter(T &vec, const IndexedType &v, std::size_t i)
│ │ │ │ +
CommPolicy< T >::IndexedType IndexedType
Definition communicator.hh:203
│ │ │ │ +
static const IndexedType & gather(const T &vec, std::size_t i)
│ │ │ │ +
A communicator that uses buffers to gather and scatter the data to be send or received.
Definition communicator.hh:458
│ │ │ │ +
void backward(Data &data)
Backward send where target and source are the same.
│ │ │ │ +
BufferedCommunicator()
Constructor.
│ │ │ │ +
~BufferedCommunicator()
Destructor.
│ │ │ │ +
void forward(const Data &source, Data &dest)
Send from source to target.
│ │ │ │ +
void free()
Free the allocated memory (i.e. buffers and message information.
│ │ │ │ +
std::enable_if< std::is_same< SizeOne, typenameCommPolicy< Data >::IndexedTypeFlag >::value, void >::type build(const Interface &interface)
Build the buffers and information for the communication process.
│ │ │ │ +
void backward(Data &source, const Data &dest)
Communicate in the reverse direction, i.e. send from target to source.
│ │ │ │ +
void build(const Data &source, const Data &target, const Interface &interface)
Build the buffers and information for the communication process.
│ │ │ │ +
void forward(Data &data)
Forward send where target and source are the same.
│ │ │ │ +
Manager class for the mapping between local indices and globally unique indices.
Definition indexset.hh:218
│ │ │ │ +
Base class of all classes representing a communication interface.
Definition parallel/interface.hh:35
│ │ │ │ +
Information describing an interface.
Definition parallel/interface.hh:101
│ │ │ │ +
Communication interface between remote and local indices.
Definition parallel/interface.hh:209
│ │ │ │ +
An index present on the local process.
Definition localindex.hh:35
│ │ │ │ +
The indices present on remote processes.
Definition remoteindices.hh:189
│ │ │ │ +
ParallelIndexSet::GlobalIndex GlobalIndex
The type of the global index.
Definition remoteindices.hh:215
│ │ │ │ +
LocalIndex::Attribute Attribute
The type of the attribute.
Definition remoteindices.hh:226
│ │ │ │ +
ParallelIndexSet::LocalIndex LocalIndex
The type of the local index.
Definition remoteindices.hh:221
│ │ │ │ +
Provides classes for building the communication interface between remote indices.
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,464 +7,1208 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -typetraits.hh │ │ │ │ │ + * parallel │ │ │ │ │ +communicator.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 (C) 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_TYPETRAITS_HH │ │ │ │ │ - 6#define DUNE_TYPETRAITS_HH │ │ │ │ │ + 5#ifndef DUNE_COMMUNICATOR │ │ │ │ │ + 6#define DUNE_COMMUNICATOR │ │ │ │ │ 7 │ │ │ │ │ - 8#include │ │ │ │ │ - 9#include │ │ │ │ │ - 10#include │ │ │ │ │ - 11#include │ │ │ │ │ - 12 │ │ │ │ │ - 13namespace Dune │ │ │ │ │ - 14{ │ │ │ │ │ - 15 │ │ │ │ │ - 16 namespace Impl │ │ │ │ │ - 17 { │ │ │ │ │ - 19 │ │ │ │ │ - 23 template │ │ │ │ │ - 24 struct voider │ │ │ │ │ - 25 { │ │ │ │ │ - 26 using type = void; │ │ │ │ │ - 27 }; │ │ │ │ │ - 28 } │ │ │ │ │ - 29 │ │ │ │ │ - 31 │ │ │ │ │ - 39 template │ │ │ │ │ -40 using void_t = typename Impl::voider::type; │ │ │ │ │ - 41 │ │ │ │ │ -55 struct Empty {}; │ │ │ │ │ - 56 │ │ │ │ │ - 63 template │ │ │ │ │ -64 struct IsInteroperable │ │ │ │ │ - 65 { │ │ │ │ │ -70 constexpr static bool value = std::is_convertible::value || std:: │ │ │ │ │ -is_convertible::value; │ │ │ │ │ - 71 }; │ │ │ │ │ - 72 │ │ │ │ │ - 78 template │ │ │ │ │ -79 struct EnableIfInterOperable │ │ │ │ │ - 80 : public std::enable_if::value, Type> │ │ │ │ │ - 81 {}; │ │ │ │ │ - 82 │ │ │ │ │ - 100 │ │ │ │ │ - 116 │ │ │ │ │ - 123 template │ │ │ │ │ -124 struct AlwaysFalse : public std::false_type {}; │ │ │ │ │ - 125 │ │ │ │ │ - 133 template │ │ │ │ │ -134 struct AlwaysTrue : public std::true_type {}; │ │ │ │ │ - 135 │ │ │ │ │ - 161 template │ │ │ │ │ -162 struct IsCallable; │ │ │ │ │ - 163 │ │ │ │ │ - 168 template │ │ │ │ │ -169 struct IsCallable │ │ │ │ │ - 170 : public std::bool_constant< │ │ │ │ │ - 171 std::is_invocable_r_v │ │ │ │ │ - 172 && !std::is_member_pointer_v> │ │ │ │ │ - 173 > {}; │ │ │ │ │ + 8#if HAVE_MPI │ │ │ │ │ + 9 │ │ │ │ │ + 10#include │ │ │ │ │ + 11#include │ │ │ │ │ + 12#include │ │ │ │ │ + 13#include │ │ │ │ │ + 14#include │ │ │ │ │ + 15#include │ │ │ │ │ + 16 │ │ │ │ │ + 17#include │ │ │ │ │ + 18 │ │ │ │ │ + 19#include │ │ │ │ │ + 20#include │ │ │ │ │ + 21#include │ │ │ │ │ + 22#include │ │ │ │ │ + 23 │ │ │ │ │ + 24namespace Dune │ │ │ │ │ + 25{ │ │ │ │ │ +109 struct SizeOne │ │ │ │ │ + 110 {}; │ │ │ │ │ + 111 │ │ │ │ │ +117 struct VariableSize │ │ │ │ │ + 118 {}; │ │ │ │ │ + 119 │ │ │ │ │ + 120 │ │ │ │ │ + 126 template │ │ │ │ │ +127 struct CommPolicy │ │ │ │ │ + 128 { │ │ │ │ │ +140 typedef V Type; │ │ │ │ │ + 141 │ │ │ │ │ +147 typedef typename V::value_type IndexedType; │ │ │ │ │ + 148 │ │ │ │ │ +153 typedef SizeOne IndexedTypeFlag; │ │ │ │ │ + 154 │ │ │ │ │ +163 static const void* getAddress(const V& v, int index); │ │ │ │ │ + 164 │ │ │ │ │ +170 static int getSize(const V&, int index); │ │ │ │ │ + 171 }; │ │ │ │ │ + 172 │ │ │ │ │ +173 template class FieldVector; │ │ │ │ │ 174 │ │ │ │ │ - 177 │ │ │ │ │ - 192 template │ │ │ │ │ -193 struct IsNumber │ │ │ │ │ - 194 : public std::integral_constant::value> { │ │ │ │ │ - 195 }; │ │ │ │ │ +175 template class VariableBlockVector; │ │ │ │ │ + 176 │ │ │ │ │ + 177 template │ │ │ │ │ +178 struct CommPolicy, A> > │ │ │ │ │ + 179 { │ │ │ │ │ +180 typedef VariableBlockVector, A> Type; │ │ │ │ │ + 181 │ │ │ │ │ +182 typedef typename Type::B IndexedType; │ │ │ │ │ + 183 │ │ │ │ │ +184 typedef VariableSize IndexedTypeFlag; │ │ │ │ │ + 185 │ │ │ │ │ +186 static const void* getAddress(const Type& v, int i); │ │ │ │ │ + 187 │ │ │ │ │ +188 static int getSize(const Type& v, int i); │ │ │ │ │ + 189 }; │ │ │ │ │ + 190 │ │ │ │ │ +194 class CommunicationError : public IOError │ │ │ │ │ + 195 {}; │ │ │ │ │ 196 │ │ │ │ │ - 197#ifndef DOXYGEN │ │ │ │ │ - 198 │ │ │ │ │ - 199 template │ │ │ │ │ - 200 struct IsNumber> │ │ │ │ │ - 201 : public std::integral_constant::value> { │ │ │ │ │ - 202 }; │ │ │ │ │ - 203 │ │ │ │ │ - 204#endif // DOXYGEN │ │ │ │ │ - 205 │ │ │ │ │ - 207 │ │ │ │ │ - 210 template │ │ │ │ │ -211 struct HasNaN │ │ │ │ │ - 212 : public std::integral_constant::value> { │ │ │ │ │ - 213 }; │ │ │ │ │ - 214 │ │ │ │ │ - 215#ifndef DOXYGEN │ │ │ │ │ - 216 │ │ │ │ │ - 217 template │ │ │ │ │ - 218 struct HasNaN> │ │ │ │ │ - 219 : public std::integral_constant::value> { │ │ │ │ │ - 220 }; │ │ │ │ │ - 221 │ │ │ │ │ - 222#endif // DOXYGEN │ │ │ │ │ - 223 │ │ │ │ │ - 224#ifndef DOXYGEN │ │ │ │ │ - 225 │ │ │ │ │ - 226 namespace Impl { │ │ │ │ │ - 227 │ │ │ │ │ - 228 template │ │ │ │ │ - 229 struct IsIndexable │ │ │ │ │ - 230 : public std::false_type │ │ │ │ │ - 231 {}; │ │ │ │ │ - 232 │ │ │ │ │ - 233 template │ │ │ │ │ - 234 struct IsIndexable() │ │ │ │ │ -[std::declval()]) > 0),int>::type> │ │ │ │ │ - 235 : public std::true_type │ │ │ │ │ - 236 {}; │ │ │ │ │ - 237 │ │ │ │ │ - 238 } │ │ │ │ │ - 239 │ │ │ │ │ - 240#endif // DOXYGEN │ │ │ │ │ + 200 template │ │ │ │ │ +201 struct CopyGatherScatter │ │ │ │ │ + 202 { │ │ │ │ │ +203 typedef typename CommPolicy::IndexedType IndexedType; │ │ │ │ │ + 204 │ │ │ │ │ +205 static const IndexedType& gather(const T& vec, std::size_t i); │ │ │ │ │ + 206 │ │ │ │ │ +207 static void scatter(T& vec, const IndexedType& v, std::size_t i); │ │ │ │ │ + 208 │ │ │ │ │ + 209 }; │ │ │ │ │ + 210 │ │ │ │ │ + 222 template │ │ │ │ │ + 223 class DatatypeCommunicator : public InterfaceBuilder │ │ │ │ │ + 224 { │ │ │ │ │ + 225 public: │ │ │ │ │ + 226 │ │ │ │ │ + 230 typedef T ParallelIndexSet; │ │ │ │ │ + 231 │ │ │ │ │ + 235 typedef Dune::RemoteIndices RemoteIndices; │ │ │ │ │ + 236 │ │ │ │ │ + 240 typedef typename RemoteIndices::GlobalIndex GlobalIndex; │ │ │ │ │ 241 │ │ │ │ │ - 243 │ │ │ │ │ - 247 template │ │ │ │ │ -248 struct IsIndexable │ │ │ │ │ - 249 : public Impl::IsIndexable │ │ │ │ │ - 250 {}; │ │ │ │ │ + 245 typedef typename RemoteIndices::Attribute Attribute; │ │ │ │ │ + 246 │ │ │ │ │ + 250 typedef typename RemoteIndices::LocalIndex LocalIndex; │ │ │ │ │ 251 │ │ │ │ │ - 252#ifndef DOXYGEN │ │ │ │ │ - 253 │ │ │ │ │ - 254 namespace Impl { │ │ │ │ │ - 255 // This function does nothing. │ │ │ │ │ - 256 // By passing expressions to this function one can avoid │ │ │ │ │ - 257 // "value computed is not used" warnings that may show up │ │ │ │ │ - 258 // in a comma expression. │ │ │ │ │ - 259 template │ │ │ │ │ - 260 void ignore(T&&... /*t*/) │ │ │ │ │ - 261 {} │ │ │ │ │ - 262 } │ │ │ │ │ - 263 │ │ │ │ │ - 264#endif // DOXYGEN │ │ │ │ │ - 265 │ │ │ │ │ - 269 // default version, gets picked if SFINAE fails │ │ │ │ │ - 270 template │ │ │ │ │ -271 struct IsIterable │ │ │ │ │ - 272 : public std::false_type │ │ │ │ │ - 273 {}; │ │ │ │ │ - 274 │ │ │ │ │ - 275#ifndef DOXYGEN │ │ │ │ │ - 276 // version for types with begin() and end() │ │ │ │ │ - 277 template │ │ │ │ │ - 278 struct IsIterable().begin(), │ │ │ │ │ - 280 std::declval().end(), │ │ │ │ │ - 281 std::declval().begin() != std::declval().end(), │ │ │ │ │ - 282 decltype(std::declval().begin()){std::declval().end()}, │ │ │ │ │ - 283 ++(std::declval │ │ │ │ │ -().begin())>>()), │ │ │ │ │ - 284 *(std::declval().begin()) │ │ │ │ │ - 285 ))> │ │ │ │ │ - 286 : public std::true_type │ │ │ │ │ - 287 {}; │ │ │ │ │ - 288#endif │ │ │ │ │ - 289 │ │ │ │ │ - 290#ifndef DOXYGEN │ │ │ │ │ - 291 // this is just a forward declaration │ │ │ │ │ - 292 template struct FieldTraits; │ │ │ │ │ - 293#endif │ │ │ │ │ - 294 │ │ │ │ │ - 296 template │ │ │ │ │ -297 using field_t = typename FieldTraits::field_type; │ │ │ │ │ - 298 │ │ │ │ │ - 300 template │ │ │ │ │ -301 using real_t = typename FieldTraits::real_type; │ │ │ │ │ - 302 │ │ │ │ │ - 303 │ │ │ │ │ - 304#ifndef DOXYGEN │ │ │ │ │ - 305 │ │ │ │ │ - 306 // Implementation of IsTuple │ │ │ │ │ - 307 namespace Impl { │ │ │ │ │ - 308 │ │ │ │ │ - 309 template │ │ │ │ │ - 310 struct IsTuple : public std::false_type │ │ │ │ │ - 311 {}; │ │ │ │ │ - 312 │ │ │ │ │ - 313 template │ │ │ │ │ - 314 struct IsTuple> : public std::true_type │ │ │ │ │ - 315 {}; │ │ │ │ │ - 316 │ │ │ │ │ - 317 } // namespace Impl │ │ │ │ │ + 255 DatatypeCommunicator(); │ │ │ │ │ + 256 │ │ │ │ │ + 260 ~DatatypeCommunicator(); │ │ │ │ │ + 261 │ │ │ │ │ + 288 template │ │ │ │ │ + 289 void build(const RemoteIndices& remoteIndices, const T1& sourceFlags, V& │ │ │ │ │ +sendData, const T2& destFlags, V& receiveData); │ │ │ │ │ + 290 │ │ │ │ │ + 294 void forward(); │ │ │ │ │ + 295 │ │ │ │ │ + 299 void backward(); │ │ │ │ │ + 300 │ │ │ │ │ + 304 void free(); │ │ │ │ │ + 305 private: │ │ │ │ │ + 309 constexpr static int commTag_ = 234; │ │ │ │ │ + 310 │ │ │ │ │ + 314 const RemoteIndices* remoteIndices_; │ │ │ │ │ + 315 │ │ │ │ │ + 316 typedef std::map > │ │ │ │ │ + 317 MessageTypeMap; │ │ │ │ │ 318 │ │ │ │ │ - 319#endif // DOXYGEN │ │ │ │ │ - 320 │ │ │ │ │ - 326 template │ │ │ │ │ -327 struct IsTuple : │ │ │ │ │ - 328 public Impl::IsTuple │ │ │ │ │ - 329 {}; │ │ │ │ │ + 322 MessageTypeMap messageTypes; │ │ │ │ │ + 323 │ │ │ │ │ + 327 void* data_; │ │ │ │ │ + 328 │ │ │ │ │ + 329 MPI_Request* requests_[2]; │ │ │ │ │ 330 │ │ │ │ │ - 331 │ │ │ │ │ - 332#ifndef DOXYGEN │ │ │ │ │ - 333 │ │ │ │ │ - 334 // Implementation of IsTupleOrDerived │ │ │ │ │ - 335 namespace Impl { │ │ │ │ │ - 336 │ │ │ │ │ - 337 template │ │ │ │ │ - 338 std::true_type isTupleOrDerived(const std::tuple*, Dummy) │ │ │ │ │ - 339 { return {}; } │ │ │ │ │ - 340 │ │ │ │ │ - 341 template │ │ │ │ │ - 342 std::false_type isTupleOrDerived(const void*, Dummy) │ │ │ │ │ - 343 { return {}; } │ │ │ │ │ - 344 │ │ │ │ │ - 345 } // namespace Impl │ │ │ │ │ - 346 │ │ │ │ │ - 347#endif // DOXYGEN │ │ │ │ │ - 348 │ │ │ │ │ - 354 template │ │ │ │ │ -355 struct IsTupleOrDerived : │ │ │ │ │ - 356 public decltype(Impl::isTupleOrDerived(std::declval(), true)) │ │ │ │ │ - 357 {}; │ │ │ │ │ - 358 │ │ │ │ │ - 359 │ │ │ │ │ - 360#ifndef DOXYGEN │ │ │ │ │ - 361 │ │ │ │ │ - 362 // Implementation of is IsIntegralConstant │ │ │ │ │ - 363 namespace Impl { │ │ │ │ │ - 364 │ │ │ │ │ - 365 template │ │ │ │ │ - 366 struct IsIntegralConstant : public std::false_type │ │ │ │ │ - 367 {}; │ │ │ │ │ - 368 │ │ │ │ │ - 369 template │ │ │ │ │ - 370 struct IsIntegralConstant> : public std:: │ │ │ │ │ -true_type │ │ │ │ │ - 371 {}; │ │ │ │ │ - 372 │ │ │ │ │ - 373 } // namespace Impl │ │ │ │ │ - 374 │ │ │ │ │ - 375#endif // DOXYGEN │ │ │ │ │ - 376 │ │ │ │ │ - 382 template │ │ │ │ │ -383 struct IsIntegralConstant : public Impl::IsIntegralConstant> │ │ │ │ │ - 384 {}; │ │ │ │ │ - 385 │ │ │ │ │ - 386 │ │ │ │ │ - 387 │ │ │ │ │ - 401 template │ │ │ │ │ -402 struct SizeOf │ │ │ │ │ - 403 : public std::integral_constant │ │ │ │ │ - 404 {}; │ │ │ │ │ - 405 │ │ │ │ │ - 406 │ │ │ │ │ - 407#ifndef DOXYGEN │ │ │ │ │ + 334 bool created_; │ │ │ │ │ + 335 │ │ │ │ │ + 339 template │ │ │ │ │ + 340 void createRequests(V& sendData, V& receiveData); │ │ │ │ │ + 341 │ │ │ │ │ + 345 template │ │ │ │ │ + 346 void createDataTypes(const T1& source, const T2& destination, V& data); │ │ │ │ │ + 347 │ │ │ │ │ + 351 void sendRecv(MPI_Request* req); │ │ │ │ │ + 352 │ │ │ │ │ + 356 struct IndexedTypeInformation │ │ │ │ │ + 357 { │ │ │ │ │ + 363 void build(int i) │ │ │ │ │ + 364 { │ │ │ │ │ + 365 length = new int[i]; │ │ │ │ │ + 366 displ = new MPI_Aint[i]; │ │ │ │ │ + 367 size = i; │ │ │ │ │ + 368 } │ │ │ │ │ + 369 │ │ │ │ │ + 373 void free() │ │ │ │ │ + 374 { │ │ │ │ │ + 375 delete[] length; │ │ │ │ │ + 376 delete[] displ; │ │ │ │ │ + 377 } │ │ │ │ │ + 379 int* length; │ │ │ │ │ + 381 MPI_Aint* displ; │ │ │ │ │ + 387 int elements; │ │ │ │ │ + 391 int size; │ │ │ │ │ + 392 }; │ │ │ │ │ + 393 │ │ │ │ │ + 399 template │ │ │ │ │ + 400 struct MPIDatatypeInformation │ │ │ │ │ + 401 { │ │ │ │ │ + 406 MPIDatatypeInformation(const V& data) : data_(data) │ │ │ │ │ + 407 {} │ │ │ │ │ 408 │ │ │ │ │ - 409 namespace Impl { │ │ │ │ │ - 410 │ │ │ │ │ - 411 template │ │ │ │ │ - 412 struct IntegerSequenceHelper; │ │ │ │ │ - 413 │ │ │ │ │ - 414 // Helper struct to compute the i-th entry of a std::integer_sequence │ │ │ │ │ - 415 // │ │ │ │ │ - 416 // This could also be implemented using std::get(std::make_tuple │ │ │ │ │ -(t...)). │ │ │ │ │ - 417 // However, the gcc-6 implementation of std::make_tuple increases the │ │ │ │ │ -instantiation │ │ │ │ │ - 418 // depth by 15 levels for each argument, such that the maximal │ │ │ │ │ -instantiation depth │ │ │ │ │ - 419 // is easily hit, especially with clang where it is set to 256. │ │ │ │ │ - 420 template │ │ │ │ │ - 421 struct IntegerSequenceHelper │ │ │ │ │ - 422 { │ │ │ │ │ - 423 │ │ │ │ │ - 424 // get first entry │ │ │ │ │ - 425 static constexpr auto get(std::integral_constant) │ │ │ │ │ - 426 { │ │ │ │ │ - 427 return std::integral_constant(); │ │ │ │ │ - 428 } │ │ │ │ │ - 429 │ │ │ │ │ - 430 // call get with first entry cut off and decremented index │ │ │ │ │ - 431 template 0) and (index < sizeof...(tail)+1), int> = 0> │ │ │ │ │ - 433 static constexpr auto get(std::integral_constant) │ │ │ │ │ - 434 { │ │ │ │ │ - 435 return IntegerSequenceHelper::get(std::integral_constant()); │ │ │ │ │ - 436 } │ │ │ │ │ - 437 │ │ │ │ │ - 438 // use static assertion if index exceeds size │ │ │ │ │ - 439 template= sizeof...(tail)+1), int> = 0> │ │ │ │ │ - 441 static constexpr auto get(std::integral_constant) │ │ │ │ │ - 442 { │ │ │ │ │ - 443 static_assert(index < sizeof...(tail)+1, "index used in │ │ │ │ │ -IntegerSequenceEntry exceed size"); │ │ │ │ │ - 444 } │ │ │ │ │ - 445 }; │ │ │ │ │ - 446 │ │ │ │ │ - 447 } // end namespace Impl │ │ │ │ │ - 448 │ │ │ │ │ - 449#endif // DOXYGEN │ │ │ │ │ - 450 │ │ │ │ │ - 451 │ │ │ │ │ - 461 template │ │ │ │ │ -462 constexpr auto integerSequenceEntry(std::integer_sequence /*seq*/, │ │ │ │ │ -std::integral_constant i) │ │ │ │ │ - 463 { │ │ │ │ │ - 464 static_assert(index < sizeof...(t), "index used in IntegerSequenceEntry │ │ │ │ │ -exceed size"); │ │ │ │ │ - 465 return Impl::IntegerSequenceHelper::get(i); │ │ │ │ │ - 466 } │ │ │ │ │ - 467 │ │ │ │ │ - 468 │ │ │ │ │ - 475 template │ │ │ │ │ -476 struct IntegerSequenceEntry; │ │ │ │ │ - 477 │ │ │ │ │ - 478#ifndef DOXYGEN │ │ │ │ │ - 479 │ │ │ │ │ - 480 template │ │ │ │ │ - 481 struct IntegerSequenceEntry, i> │ │ │ │ │ - 482 : public decltype(Impl::IntegerSequenceHelper::get(std:: │ │ │ │ │ -integral_constant())) │ │ │ │ │ - 483 {}; │ │ │ │ │ - 484 │ │ │ │ │ - 485#endif // DOXYGEN │ │ │ │ │ - 486 │ │ │ │ │ - 500 template │ │ │ │ │ -501 struct AutonomousValueType { using type = T; }; │ │ │ │ │ - 502 │ │ │ │ │ - 504 template │ │ │ │ │ -505 struct AutonomousValueType : AutonomousValueType {}; │ │ │ │ │ - 506 │ │ │ │ │ - 508 template │ │ │ │ │ -509 struct AutonomousValueType : AutonomousValueType {}; │ │ │ │ │ - 510 │ │ │ │ │ - 512 template │ │ │ │ │ -513 struct AutonomousValueType : AutonomousValueType {}; │ │ │ │ │ - 514 │ │ │ │ │ - 516 template │ │ │ │ │ -517 struct AutonomousValueType : AutonomousValueType {}; │ │ │ │ │ - 518 │ │ │ │ │ - 520 template<> │ │ │ │ │ -521 struct AutonomousValueType::reference> │ │ │ │ │ - 522 { │ │ │ │ │ -523 using type = bool; │ │ │ │ │ - 524 }; │ │ │ │ │ - 525 │ │ │ │ │ - 527 template │ │ │ │ │ -528 struct AutonomousValueType : AutonomousValueType {}; │ │ │ │ │ - 529 │ │ │ │ │ - 557 template │ │ │ │ │ -558 using AutonomousValue = typename AutonomousValueType::type; │ │ │ │ │ - 559 │ │ │ │ │ - 641 template │ │ │ │ │ -642 constexpr AutonomousValue autoCopy(T &&v) │ │ │ │ │ - 643 { │ │ │ │ │ - 644 return v; │ │ │ │ │ - 645 } │ │ │ │ │ - 646 │ │ │ │ │ - 648} │ │ │ │ │ - 649#endif │ │ │ │ │ -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:462 │ │ │ │ │ -Dune::real_t │ │ │ │ │ -typename FieldTraits< Type >::real_type real_t │ │ │ │ │ -Convenient access to FieldTraits::real_type. │ │ │ │ │ -Definition typetraits.hh:301 │ │ │ │ │ -Dune::autoCopy │ │ │ │ │ -constexpr AutonomousValue< T > autoCopy(T &&v) │ │ │ │ │ -Autonomous copy of an expression's value for use in auto type deduction. │ │ │ │ │ -Definition typetraits.hh:642 │ │ │ │ │ -Dune::AutonomousValue │ │ │ │ │ -typename AutonomousValueType< T >::type AutonomousValue │ │ │ │ │ -Type free of internal references that T can be converted to. │ │ │ │ │ -Definition typetraits.hh:558 │ │ │ │ │ -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::field_t │ │ │ │ │ -typename FieldTraits< Type >::field_type field_t │ │ │ │ │ -Convenient access to FieldTraits::field_type. │ │ │ │ │ -Definition typetraits.hh:297 │ │ │ │ │ -std │ │ │ │ │ -STL namespace. │ │ │ │ │ + 414 void reserve(int proc, int size) │ │ │ │ │ + 415 { │ │ │ │ │ + 416 information_[proc].build(size); │ │ │ │ │ + 417 } │ │ │ │ │ + 424 void add(int proc, int local) │ │ │ │ │ + 425 { │ │ │ │ │ + 426 IndexedTypeInformation& info=information_[proc]; │ │ │ │ │ + 427 assert((info.elements)(CommPolicy::getAddress(data_, │ │ │ │ │ +local)), │ │ │ │ │ + 429 info.displ+info.elements); │ │ │ │ │ + 430 info.length[info.elements]=CommPolicy::getSize(data_, local); │ │ │ │ │ + 431 info.elements++; │ │ │ │ │ + 432 } │ │ │ │ │ + 433 │ │ │ │ │ + 438 std::map information_; │ │ │ │ │ + 442 const V& data_; │ │ │ │ │ + 443 │ │ │ │ │ + 444 }; │ │ │ │ │ + 445 │ │ │ │ │ + 446 }; │ │ │ │ │ + 447 │ │ │ │ │ +457 class BufferedCommunicator │ │ │ │ │ + 458 { │ │ │ │ │ + 459 │ │ │ │ │ + 460 public: │ │ │ │ │ +464 BufferedCommunicator(); │ │ │ │ │ + 465 │ │ │ │ │ + 472 template │ │ │ │ │ + 473 typename std::enable_if:: │ │ │ │ │ +IndexedTypeFlag>::value, void>::type │ │ │ │ │ +474 build(const Interface& interface); │ │ │ │ │ + 475 │ │ │ │ │ + 483 template │ │ │ │ │ +484 void build(const Data& source, const Data& target, const Interface& │ │ │ │ │ +interface); │ │ │ │ │ + 485 │ │ │ │ │ + 514 template │ │ │ │ │ +515 void forward(const Data& source, Data& dest); │ │ │ │ │ + 516 │ │ │ │ │ + 545 template │ │ │ │ │ +546 void backward(Data& source, const Data& dest); │ │ │ │ │ + 547 │ │ │ │ │ + 573 template │ │ │ │ │ +574 void forward(Data& data); │ │ │ │ │ + 575 │ │ │ │ │ + 601 template │ │ │ │ │ +602 void backward(Data& data); │ │ │ │ │ + 603 │ │ │ │ │ +607 void free(); │ │ │ │ │ + 608 │ │ │ │ │ +612 ~BufferedCommunicator(); │ │ │ │ │ + 613 │ │ │ │ │ + 614 private: │ │ │ │ │ + 615 │ │ │ │ │ + 619 typedef std::map │ │ │ │ │ +> │ │ │ │ │ + 620 InterfaceMap; │ │ │ │ │ + 621 │ │ │ │ │ + 622 │ │ │ │ │ + 626 template │ │ │ │ │ + 627 struct MessageSizeCalculator │ │ │ │ │ + 628 {}; │ │ │ │ │ + 629 │ │ │ │ │ + 634 template │ │ │ │ │ + 635 struct MessageSizeCalculator │ │ │ │ │ + 636 { │ │ │ │ │ + 643 inline int operator()(const InterfaceInformation& info) const; │ │ │ │ │ + 652 inline int operator()(const Data& data, const InterfaceInformation& info) │ │ │ │ │ +const; │ │ │ │ │ + 653 }; │ │ │ │ │ + 654 │ │ │ │ │ + 659 template │ │ │ │ │ + 660 struct MessageSizeCalculator │ │ │ │ │ + 661 { │ │ │ │ │ + 670 inline int operator()(const Data& data, const InterfaceInformation& info) │ │ │ │ │ +const; │ │ │ │ │ + 671 }; │ │ │ │ │ + 672 │ │ │ │ │ + 676 template │ │ │ │ │ + 677 struct MessageGatherer │ │ │ │ │ + 678 {}; │ │ │ │ │ + 679 │ │ │ │ │ + 684 template │ │ │ │ │ + 685 struct MessageGatherer │ │ │ │ │ + 686 { │ │ │ │ │ + 688 typedef typename CommPolicy::IndexedType Type; │ │ │ │ │ + 689 │ │ │ │ │ + 694 typedef GatherScatter Gatherer; │ │ │ │ │ + 695 │ │ │ │ │ + 701 constexpr static bool forward = send; │ │ │ │ │ + 702 │ │ │ │ │ + 710 inline void operator()(const InterfaceMap& interface, const Data& data, │ │ │ │ │ +Type* buffer, size_t bufferSize) const; │ │ │ │ │ + 711 }; │ │ │ │ │ + 712 │ │ │ │ │ + 717 template │ │ │ │ │ + 718 struct MessageGatherer │ │ │ │ │ + 719 { │ │ │ │ │ + 721 typedef typename CommPolicy::IndexedType Type; │ │ │ │ │ + 722 │ │ │ │ │ + 727 typedef GatherScatter Gatherer; │ │ │ │ │ + 728 │ │ │ │ │ + 734 constexpr static bool forward = send; │ │ │ │ │ + 735 │ │ │ │ │ + 743 inline void operator()(const InterfaceMap& interface, const Data& data, │ │ │ │ │ +Type* buffer, size_t bufferSize) const; │ │ │ │ │ + 744 }; │ │ │ │ │ + 745 │ │ │ │ │ + 749 template │ │ │ │ │ + 750 struct MessageScatterer │ │ │ │ │ + 751 {}; │ │ │ │ │ + 752 │ │ │ │ │ + 757 template │ │ │ │ │ + 758 struct MessageScatterer │ │ │ │ │ + 759 { │ │ │ │ │ + 761 typedef typename CommPolicy::IndexedType Type; │ │ │ │ │ + 762 │ │ │ │ │ + 767 typedef GatherScatter Scatterer; │ │ │ │ │ + 768 │ │ │ │ │ + 774 constexpr static bool forward = send; │ │ │ │ │ + 775 │ │ │ │ │ + 783 inline void operator()(const InterfaceMap& interface, Data& data, Type* │ │ │ │ │ +buffer, const int& proc) const; │ │ │ │ │ + 784 }; │ │ │ │ │ + 789 template │ │ │ │ │ + 790 struct MessageScatterer │ │ │ │ │ + 791 { │ │ │ │ │ + 793 typedef typename CommPolicy::IndexedType Type; │ │ │ │ │ + 794 │ │ │ │ │ + 799 typedef GatherScatter Scatterer; │ │ │ │ │ + 800 │ │ │ │ │ + 806 constexpr static bool forward = send; │ │ │ │ │ + 807 │ │ │ │ │ + 815 inline void operator()(const InterfaceMap& interface, Data& data, Type* │ │ │ │ │ +buffer, const int& proc) const; │ │ │ │ │ + 816 }; │ │ │ │ │ + 817 │ │ │ │ │ + 821 struct MessageInformation │ │ │ │ │ + 822 { │ │ │ │ │ + 824 MessageInformation() │ │ │ │ │ + 825 : start_(0), size_(0) │ │ │ │ │ + 826 {} │ │ │ │ │ + 827 │ │ │ │ │ + 835 MessageInformation(size_t start, size_t size) │ │ │ │ │ + 836 : start_(start), size_(size) │ │ │ │ │ + 837 {} │ │ │ │ │ + 841 size_t start_; │ │ │ │ │ + 845 size_t size_; │ │ │ │ │ + 846 }; │ │ │ │ │ + 847 │ │ │ │ │ + 854 typedef std::map > │ │ │ │ │ + 855 InformationMap; │ │ │ │ │ + 859 InformationMap messageInformation_; │ │ │ │ │ + 863 char* buffers_[2]; │ │ │ │ │ + 867 size_t bufferSize_[2]; │ │ │ │ │ + 868 │ │ │ │ │ + 872 constexpr static int commTag_ = 0; │ │ │ │ │ + 873 │ │ │ │ │ + 877 std::map > │ │ │ │ │ +interfaces_; │ │ │ │ │ + 878 │ │ │ │ │ + 879 MPI_Comm communicator_; │ │ │ │ │ + 880 │ │ │ │ │ + 884 template │ │ │ │ │ + 885 void sendRecv(const Data& source, Data& target); │ │ │ │ │ + 886 │ │ │ │ │ + 887 }; │ │ │ │ │ + 888 │ │ │ │ │ + 889#ifndef DOXYGEN │ │ │ │ │ + 890 │ │ │ │ │ + 891 template │ │ │ │ │ + 892 inline const void* CommPolicy::getAddress(const V& v, int index) │ │ │ │ │ + 893 { │ │ │ │ │ + 894 return &(v[index]); │ │ │ │ │ + 895 } │ │ │ │ │ + 896 │ │ │ │ │ + 897 template │ │ │ │ │ + 898 inline int CommPolicy::getSize([[maybe_unused]] const V& v, [ │ │ │ │ │ +[maybe_unused]] int index) │ │ │ │ │ + 899 { │ │ │ │ │ + 900 return 1; │ │ │ │ │ + 901 } │ │ │ │ │ + 902 │ │ │ │ │ + 903 template │ │ │ │ │ + 904 inline const void* CommPolicy, A> │ │ │ │ │ +>::getAddress(const Type& v, int index) │ │ │ │ │ + 905 { │ │ │ │ │ + 906 return &(v[index][0]); │ │ │ │ │ + 907 } │ │ │ │ │ + 908 │ │ │ │ │ + 909 template │ │ │ │ │ + 910 inline int CommPolicy, A> >::getSize │ │ │ │ │ +(const Type& v, int index) │ │ │ │ │ + 911 { │ │ │ │ │ + 912 return v[index].getsize(); │ │ │ │ │ + 913 } │ │ │ │ │ + 914 │ │ │ │ │ + 915 template │ │ │ │ │ + 916 inline const typename CopyGatherScatter::IndexedType& │ │ │ │ │ +CopyGatherScatter::gather(const T & vec, std::size_t i) │ │ │ │ │ + 917 { │ │ │ │ │ + 918 return vec[i]; │ │ │ │ │ + 919 } │ │ │ │ │ + 920 │ │ │ │ │ + 921 template │ │ │ │ │ + 922 inline void CopyGatherScatter::scatter(T& vec, const IndexedType& v, │ │ │ │ │ +std::size_t i) │ │ │ │ │ + 923 { │ │ │ │ │ + 924 vec[i]=v; │ │ │ │ │ + 925 } │ │ │ │ │ + 926 │ │ │ │ │ + 927 template │ │ │ │ │ + 928 DatatypeCommunicator::DatatypeCommunicator() │ │ │ │ │ + 929 : remoteIndices_(0), created_(false) │ │ │ │ │ + 930 { │ │ │ │ │ + 931 requests_[0]=0; │ │ │ │ │ + 932 requests_[1]=0; │ │ │ │ │ + 933 } │ │ │ │ │ + 934 │ │ │ │ │ + 935 │ │ │ │ │ + 936 │ │ │ │ │ + 937 template │ │ │ │ │ + 938 DatatypeCommunicator::~DatatypeCommunicator() │ │ │ │ │ + 939 { │ │ │ │ │ + 940 free(); │ │ │ │ │ + 941 } │ │ │ │ │ + 942 │ │ │ │ │ + 943 template │ │ │ │ │ + 944 template │ │ │ │ │ + 945 inline void DatatypeCommunicator::build(const RemoteIndices& │ │ │ │ │ +remoteIndices, │ │ │ │ │ + 946 const T1& source, V& sendData, │ │ │ │ │ + 947 const T2& destination, V& receiveData) │ │ │ │ │ + 948 { │ │ │ │ │ + 949 remoteIndices_ = &remoteIndices; │ │ │ │ │ + 950 free(); │ │ │ │ │ + 951 createDataTypes(source,destination, receiveData); │ │ │ │ │ + 952 createDataTypes(source,destination, sendData); │ │ │ │ │ + 953 createRequests(sendData, receiveData); │ │ │ │ │ + 954 createRequests(receiveData, sendData); │ │ │ │ │ + 955 created_=true; │ │ │ │ │ + 956 } │ │ │ │ │ + 957 │ │ │ │ │ + 958 template │ │ │ │ │ + 959 void DatatypeCommunicator::free() │ │ │ │ │ + 960 { │ │ │ │ │ + 961 if(created_) { │ │ │ │ │ + 962 delete[] requests_[0]; │ │ │ │ │ + 963 delete[] requests_[1]; │ │ │ │ │ + 964 typedef MessageTypeMap::iterator iterator; │ │ │ │ │ + 965 typedef MessageTypeMap::const_iterator const_iterator; │ │ │ │ │ + 966 │ │ │ │ │ + 967 const const_iterator end=messageTypes.end(); │ │ │ │ │ + 968 │ │ │ │ │ + 969 for(iterator process = messageTypes.begin(); process != end; ++process) { │ │ │ │ │ + 970 MPI_Datatype *type = &(process->second.first); │ │ │ │ │ + 971 int finalized=0; │ │ │ │ │ + 972 MPI_Finalized(&finalized); │ │ │ │ │ + 973 if(*type!=MPI_DATATYPE_NULL && !finalized) │ │ │ │ │ + 974 MPI_Type_free(type); │ │ │ │ │ + 975 type = &(process->second.second); │ │ │ │ │ + 976 if(*type!=MPI_DATATYPE_NULL && !finalized) │ │ │ │ │ + 977 MPI_Type_free(type); │ │ │ │ │ + 978 } │ │ │ │ │ + 979 messageTypes.clear(); │ │ │ │ │ + 980 created_=false; │ │ │ │ │ + 981 } │ │ │ │ │ + 982 │ │ │ │ │ + 983 } │ │ │ │ │ + 984 │ │ │ │ │ + 985 template │ │ │ │ │ + 986 template │ │ │ │ │ + 987 void DatatypeCommunicator::createDataTypes(const T1& sourceFlags, const │ │ │ │ │ +T2& destFlags, V& data) │ │ │ │ │ + 988 { │ │ │ │ │ + 989 │ │ │ │ │ + 990 MPIDatatypeInformation dataInfo(data); │ │ │ │ │ + 991 this->template │ │ │ │ │ +buildInterface,send> │ │ │ │ │ +(*remoteIndices_,sourceFlags, destFlags, dataInfo); │ │ │ │ │ + 992 │ │ │ │ │ + 993 typedef typename RemoteIndices::RemoteIndexMap::const_iterator │ │ │ │ │ +const_iterator; │ │ │ │ │ + 994 const const_iterator end=this->remoteIndices_->end(); │ │ │ │ │ + 995 │ │ │ │ │ + 996 // Allocate MPI_Datatypes and deallocate memory for the type construction. │ │ │ │ │ + 997 for(const_iterator process=this->remoteIndices_->begin(); process != end; │ │ │ │ │ +++process) { │ │ │ │ │ + 998 IndexedTypeInformation& info=dataInfo.information_[process->first]; │ │ │ │ │ + 999 // Shift the displacement │ │ │ │ │ + 1000 MPI_Aint base; │ │ │ │ │ + 1001 MPI_Get_address(const_cast(CommPolicy::getAddress(data, 0)), │ │ │ │ │ +&base); │ │ │ │ │ + 1002 │ │ │ │ │ + 1003 for(int i=0; i< info.elements; i++) { │ │ │ │ │ + 1004 info.displ[i]-=base; │ │ │ │ │ + 1005 } │ │ │ │ │ + 1006 │ │ │ │ │ + 1007 // Create data type │ │ │ │ │ + 1008 MPI_Datatype* type = &( send ? messageTypes[process->first].first : │ │ │ │ │ +messageTypes[process->first].second); │ │ │ │ │ + 1009 MPI_Type_create_hindexed(info.elements, info.length, info.displ, │ │ │ │ │ + 1010 MPITraits::IndexedType>::getType(), type); │ │ │ │ │ + 1011 MPI_Type_commit(type); │ │ │ │ │ + 1012 // Deallocate memory │ │ │ │ │ + 1013 info.free(); │ │ │ │ │ + 1014 } │ │ │ │ │ + 1015 } │ │ │ │ │ + 1016 │ │ │ │ │ + 1017 template │ │ │ │ │ + 1018 template │ │ │ │ │ + 1019 void DatatypeCommunicator::createRequests(V& sendData, V& receiveData) │ │ │ │ │ + 1020 { │ │ │ │ │ + 1021 typedef std::map >:: │ │ │ │ │ +const_iterator MapIterator; │ │ │ │ │ + 1022 int rank; │ │ │ │ │ + 1023 static int index = createForward ? 1 : 0; │ │ │ │ │ + 1024 int noMessages = messageTypes.size(); │ │ │ │ │ + 1025 // allocate request handles │ │ │ │ │ + 1026 requests_[index] = new MPI_Request[2*noMessages]; │ │ │ │ │ + 1027 const MapIterator end = messageTypes.end(); │ │ │ │ │ + 1028 int request=0; │ │ │ │ │ + 1029 MPI_Comm_rank(MPI_COMM_WORLD, &rank); │ │ │ │ │ + 1030 │ │ │ │ │ + 1031 // Set up the requests for receiving first │ │ │ │ │ + 1032 for(MapIterator process = messageTypes.begin(); process != end; │ │ │ │ │ + 1033 ++process, ++request) { │ │ │ │ │ + 1034 MPI_Datatype type = createForward ? process->second.second : process- │ │ │ │ │ +>second.first; │ │ │ │ │ + 1035 void* address = const_cast(CommPolicy::getAddress │ │ │ │ │ +(receiveData,0)); │ │ │ │ │ + 1036 MPI_Recv_init(address, 1, type, process->first, commTag_, this- │ │ │ │ │ +>remoteIndices_->communicator(), requests_[index]+request); │ │ │ │ │ + 1037 } │ │ │ │ │ + 1038 │ │ │ │ │ + 1039 // And now the send requests │ │ │ │ │ + 1040 │ │ │ │ │ + 1041 for(MapIterator process = messageTypes.begin(); process != end; │ │ │ │ │ + 1042 ++process, ++request) { │ │ │ │ │ + 1043 MPI_Datatype type = createForward ? process->second.first : process- │ │ │ │ │ +>second.second; │ │ │ │ │ + 1044 void* address = const_cast(CommPolicy::getAddress(sendData, │ │ │ │ │ +0)); │ │ │ │ │ + 1045 MPI_Ssend_init(address, 1, type, process->first, commTag_, this- │ │ │ │ │ +>remoteIndices_->communicator(), requests_[index]+request); │ │ │ │ │ + 1046 } │ │ │ │ │ + 1047 } │ │ │ │ │ + 1048 │ │ │ │ │ + 1049 template │ │ │ │ │ + 1050 void DatatypeCommunicator::forward() │ │ │ │ │ + 1051 { │ │ │ │ │ + 1052 sendRecv(requests_[1]); │ │ │ │ │ + 1053 } │ │ │ │ │ + 1054 │ │ │ │ │ + 1055 template │ │ │ │ │ + 1056 void DatatypeCommunicator::backward() │ │ │ │ │ + 1057 { │ │ │ │ │ + 1058 sendRecv(requests_[0]); │ │ │ │ │ + 1059 } │ │ │ │ │ + 1060 │ │ │ │ │ + 1061 template │ │ │ │ │ + 1062 void DatatypeCommunicator::sendRecv(MPI_Request* requests) │ │ │ │ │ + 1063 { │ │ │ │ │ + 1064 int noMessages = messageTypes.size(); │ │ │ │ │ + 1065 // Start the receive calls first │ │ │ │ │ + 1066 MPI_Startall(noMessages, requests); │ │ │ │ │ + 1067 // Now the send calls │ │ │ │ │ + 1068 MPI_Startall(noMessages, requests+noMessages); │ │ │ │ │ + 1069 │ │ │ │ │ + 1070 // Wait for completion of the communication send first then receive │ │ │ │ │ + 1071 MPI_Status* status=new MPI_Status[2*noMessages]; │ │ │ │ │ + 1072 for(int i=0; i<2*noMessages; i++) │ │ │ │ │ + 1073 status[i].MPI_ERROR=MPI_SUCCESS; │ │ │ │ │ + 1074 │ │ │ │ │ + 1075 int send = MPI_Waitall(noMessages, requests+noMessages, │ │ │ │ │ +status+noMessages); │ │ │ │ │ + 1076 int receive = MPI_Waitall(noMessages, requests, status); │ │ │ │ │ + 1077 │ │ │ │ │ + 1078 // Error checks │ │ │ │ │ + 1079 int success=1, globalSuccess=0; │ │ │ │ │ + 1080 if(send==MPI_ERR_IN_STATUS) { │ │ │ │ │ + 1081 int rank; │ │ │ │ │ + 1082 MPI_Comm_rank(this->remoteIndices_->communicator(), &rank); │ │ │ │ │ + 1083 std::cerr<remoteIndices_->communicator(), &rank); │ │ │ │ │ + 1101 std::cerr<remoteIndices_->communicator()); │ │ │ │ │ + 1117 │ │ │ │ │ + 1118 delete[] status; │ │ │ │ │ + 1119 │ │ │ │ │ + 1120 if(!globalSuccess) │ │ │ │ │ + 1121 DUNE_THROW(CommunicationError, "A communication error occurred!"); │ │ │ │ │ + 1122 │ │ │ │ │ + 1123 } │ │ │ │ │ + 1124 │ │ │ │ │ + 1125 inline BufferedCommunicator::BufferedCommunicator() │ │ │ │ │ + 1126 { │ │ │ │ │ + 1127 buffers_[0]=0; │ │ │ │ │ + 1128 buffers_[1]=0; │ │ │ │ │ + 1129 bufferSize_[0]=0; │ │ │ │ │ + 1130 bufferSize_[1]=0; │ │ │ │ │ + 1131 } │ │ │ │ │ + 1132 │ │ │ │ │ + 1133 template │ │ │ │ │ + 1134 typename std::enable_if:: │ │ │ │ │ +IndexedTypeFlag>::value, void>::type │ │ │ │ │ + 1135 BufferedCommunicator::build(const Interface& interface) │ │ │ │ │ + 1136 { │ │ │ │ │ + 1137 interfaces_=interface.interfaces(); │ │ │ │ │ + 1138 communicator_=interface.communicator(); │ │ │ │ │ + 1139 typedef typename std::map > │ │ │ │ │ + 1140 ::const_iterator const_iterator; │ │ │ │ │ + 1141 typedef typename CommPolicy::IndexedTypeFlag Flag; │ │ │ │ │ + 1142 const const_iterator end = interfaces_.end(); │ │ │ │ │ + 1143 int lrank; │ │ │ │ │ + 1144 MPI_Comm_rank(communicator_, &lrank); │ │ │ │ │ + 1145 │ │ │ │ │ + 1146 bufferSize_[0]=0; │ │ │ │ │ + 1147 bufferSize_[1]=0; │ │ │ │ │ + 1148 │ │ │ │ │ + 1149 for(const_iterator interfacePair = interfaces_.begin(); │ │ │ │ │ + 1150 interfacePair != end; ++interfacePair) { │ │ │ │ │ + 1151 int noSend = MessageSizeCalculator() (interfacePair- │ │ │ │ │ +>second.first); │ │ │ │ │ + 1152 int noRecv = MessageSizeCalculator() (interfacePair- │ │ │ │ │ +>second.second); │ │ │ │ │ + 1153 if (noSend + noRecv > 0) │ │ │ │ │ + 1154 messageInformation_.insert(std::make_pair(interfacePair->first, │ │ │ │ │ + 1155 std::make_pair(MessageInformation(bufferSize_[0], │ │ │ │ │ + 1156 noSend*sizeof(typename CommPolicy::IndexedType)), │ │ │ │ │ + 1157 MessageInformation(bufferSize_[1], │ │ │ │ │ + 1158 noRecv*sizeof(typename CommPolicy::IndexedType))))); │ │ │ │ │ + 1159 bufferSize_[0] += noSend; │ │ │ │ │ + 1160 bufferSize_[1] += noRecv; │ │ │ │ │ + 1161 } │ │ │ │ │ + 1162 │ │ │ │ │ + 1163 // allocate the buffers │ │ │ │ │ + 1164 bufferSize_[0] *= sizeof(typename CommPolicy::IndexedType); │ │ │ │ │ + 1165 bufferSize_[1] *= sizeof(typename CommPolicy::IndexedType); │ │ │ │ │ + 1166 │ │ │ │ │ + 1167 buffers_[0] = new char[bufferSize_[0]]; │ │ │ │ │ + 1168 buffers_[1] = new char[bufferSize_[1]]; │ │ │ │ │ + 1169 } │ │ │ │ │ + 1170 │ │ │ │ │ + 1171 template │ │ │ │ │ + 1172 void BufferedCommunicator::build(const Data& source, const Data& dest, │ │ │ │ │ +const Interface& interface) │ │ │ │ │ + 1173 { │ │ │ │ │ + 1174 │ │ │ │ │ + 1175 interfaces_=interface.interfaces(); │ │ │ │ │ + 1176 communicator_=interface.communicator(); │ │ │ │ │ + 1177 typedef typename std::map > │ │ │ │ │ + 1178 ::const_iterator const_iterator; │ │ │ │ │ + 1179 typedef typename CommPolicy::IndexedTypeFlag Flag; │ │ │ │ │ + 1180 const const_iterator end = interfaces_.end(); │ │ │ │ │ + 1181 │ │ │ │ │ + 1182 bufferSize_[0]=0; │ │ │ │ │ + 1183 bufferSize_[1]=0; │ │ │ │ │ + 1184 │ │ │ │ │ + 1185 for(const_iterator interfacePair = interfaces_.begin(); │ │ │ │ │ + 1186 interfacePair != end; ++interfacePair) { │ │ │ │ │ + 1187 int noSend = MessageSizeCalculator() (source, interfacePair- │ │ │ │ │ +>second.first); │ │ │ │ │ + 1188 int noRecv = MessageSizeCalculator() (dest, interfacePair- │ │ │ │ │ +>second.second); │ │ │ │ │ + 1189 if (noSend + noRecv > 0) │ │ │ │ │ + 1190 messageInformation_.insert(std::make_pair(interfacePair->first, │ │ │ │ │ + 1191 std::make_pair(MessageInformation(bufferSize_[0], │ │ │ │ │ + 1192 noSend*sizeof(typename CommPolicy::IndexedType)), │ │ │ │ │ + 1193 MessageInformation(bufferSize_[1], │ │ │ │ │ + 1194 noRecv*sizeof(typename CommPolicy::IndexedType))))); │ │ │ │ │ + 1195 bufferSize_[0] += noSend; │ │ │ │ │ + 1196 bufferSize_[1] += noRecv; │ │ │ │ │ + 1197 } │ │ │ │ │ + 1198 │ │ │ │ │ + 1199 bufferSize_[0] *= sizeof(typename CommPolicy::IndexedType); │ │ │ │ │ + 1200 bufferSize_[1] *= sizeof(typename CommPolicy::IndexedType); │ │ │ │ │ + 1201 // allocate the buffers │ │ │ │ │ + 1202 buffers_[0] = new char[bufferSize_[0]]; │ │ │ │ │ + 1203 buffers_[1] = new char[bufferSize_[1]]; │ │ │ │ │ + 1204 } │ │ │ │ │ + 1205 │ │ │ │ │ + 1206 inline void BufferedCommunicator::free() │ │ │ │ │ + 1207 { │ │ │ │ │ + 1208 messageInformation_.clear(); │ │ │ │ │ + 1209 if(buffers_[0]) │ │ │ │ │ + 1210 delete[] buffers_[0]; │ │ │ │ │ + 1211 │ │ │ │ │ + 1212 if(buffers_[1]) │ │ │ │ │ + 1213 delete[] buffers_[1]; │ │ │ │ │ + 1214 buffers_[0]=buffers_[1]=0; │ │ │ │ │ + 1215 } │ │ │ │ │ + 1216 │ │ │ │ │ + 1217 inline BufferedCommunicator::~BufferedCommunicator() │ │ │ │ │ + 1218 { │ │ │ │ │ + 1219 free(); │ │ │ │ │ + 1220 } │ │ │ │ │ + 1221 │ │ │ │ │ + 1222 template │ │ │ │ │ + 1223 inline int BufferedCommunicator::MessageSizeCalculator:: │ │ │ │ │ +operator() │ │ │ │ │ + 1224 (const InterfaceInformation& info) const │ │ │ │ │ + 1225 { │ │ │ │ │ + 1226 return info.size(); │ │ │ │ │ + 1227 } │ │ │ │ │ + 1228 │ │ │ │ │ + 1229 │ │ │ │ │ + 1230 template │ │ │ │ │ + 1231 inline int BufferedCommunicator::MessageSizeCalculator:: │ │ │ │ │ +operator() │ │ │ │ │ + 1232 (const Data&, const InterfaceInformation& info) const │ │ │ │ │ + 1233 { │ │ │ │ │ + 1234 return operator()(info); │ │ │ │ │ + 1235 } │ │ │ │ │ + 1236 │ │ │ │ │ + 1237 │ │ │ │ │ + 1238 template │ │ │ │ │ + 1239 inline int BufferedCommunicator::MessageSizeCalculator::operator() │ │ │ │ │ + 1240 (const Data& data, const InterfaceInformation& info) const │ │ │ │ │ + 1241 { │ │ │ │ │ + 1242 int entries=0; │ │ │ │ │ + 1243 │ │ │ │ │ + 1244 for(size_t i=0; i < info.size(); i++) │ │ │ │ │ + 1245 entries += CommPolicy::getSize(data,info[i]); │ │ │ │ │ + 1246 │ │ │ │ │ + 1247 return entries; │ │ │ │ │ + 1248 } │ │ │ │ │ + 1249 │ │ │ │ │ + 1250 │ │ │ │ │ + 1251 template │ │ │ │ │ + 1252 inline void BufferedCommunicator:: │ │ │ │ │ +MessageGatherer::operator()(const │ │ │ │ │ +InterfaceMap& interfaces,const Data& data, Type* buffer, [[maybe_unused]] │ │ │ │ │ +size_t bufferSize) const │ │ │ │ │ + 1253 { │ │ │ │ │ + 1254 typedef typename InterfaceMap::const_iterator │ │ │ │ │ + 1255 const_iterator; │ │ │ │ │ + 1256 │ │ │ │ │ + 1257 int rank; │ │ │ │ │ + 1258 MPI_Comm_rank(MPI_COMM_WORLD, &rank); │ │ │ │ │ + 1259 const const_iterator end = interfaces.end(); │ │ │ │ │ + 1260 size_t index=0; │ │ │ │ │ + 1261 │ │ │ │ │ + 1262 for(const_iterator interfacePair = interfaces.begin(); │ │ │ │ │ + 1263 interfacePair != end; ++interfacePair) { │ │ │ │ │ + 1264 int size = forward ? interfacePair->second.first.size() : │ │ │ │ │ + 1265 interfacePair->second.second.size(); │ │ │ │ │ + 1266 │ │ │ │ │ + 1267 for(int i=0; i < size; i++) { │ │ │ │ │ + 1268 int local = forward ? interfacePair->second.first[i] : │ │ │ │ │ + 1269 interfacePair->second.second[i]; │ │ │ │ │ + 1270 for(std::size_t j=0; j < CommPolicy::getSize(data, local); j++, │ │ │ │ │ +index++) { │ │ │ │ │ + 1271 │ │ │ │ │ + 1272#ifdef DUNE_ISTL_WITH_CHECKING │ │ │ │ │ + 1273 assert(bufferSize>=(index+1)*sizeof(typename CommPolicy:: │ │ │ │ │ +IndexedType)); │ │ │ │ │ + 1274#endif │ │ │ │ │ + 1275 buffer[index]=GatherScatter::gather(data, local, j); │ │ │ │ │ + 1276 } │ │ │ │ │ + 1277 │ │ │ │ │ + 1278 } │ │ │ │ │ + 1279 } │ │ │ │ │ + 1280 │ │ │ │ │ + 1281 } │ │ │ │ │ + 1282 │ │ │ │ │ + 1283 │ │ │ │ │ + 1284 template │ │ │ │ │ + 1285 inline void BufferedCommunicator:: │ │ │ │ │ +MessageGatherer::operator()( │ │ │ │ │ + 1286 const InterfaceMap& interfaces, const Data& data, Type* buffer, [ │ │ │ │ │ +[maybe_unused]] size_t bufferSize) const │ │ │ │ │ + 1287 { │ │ │ │ │ + 1288 typedef typename InterfaceMap::const_iterator │ │ │ │ │ + 1289 const_iterator; │ │ │ │ │ + 1290 const const_iterator end = interfaces.end(); │ │ │ │ │ + 1291 size_t index = 0; │ │ │ │ │ + 1292 │ │ │ │ │ + 1293 int rank; │ │ │ │ │ + 1294 MPI_Comm_rank(MPI_COMM_WORLD, &rank); │ │ │ │ │ + 1295 │ │ │ │ │ + 1296 for(const_iterator interfacePair = interfaces.begin(); │ │ │ │ │ + 1297 interfacePair != end; ++interfacePair) { │ │ │ │ │ + 1298 size_t size = FORWARD ? interfacePair->second.first.size() : │ │ │ │ │ + 1299 interfacePair->second.second.size(); │ │ │ │ │ + 1300 │ │ │ │ │ + 1301 for(size_t i=0; i < size; i++) { │ │ │ │ │ + 1302 │ │ │ │ │ + 1303#ifdef DUNE_ISTL_WITH_CHECKING │ │ │ │ │ + 1304 assert(bufferSize>=(index+1)*sizeof(typename CommPolicy:: │ │ │ │ │ +IndexedType)); │ │ │ │ │ + 1305#endif │ │ │ │ │ + 1306 │ │ │ │ │ + 1307 buffer[index++] = GatherScatter::gather(data, FORWARD ? interfacePair- │ │ │ │ │ +>second.first[i] : │ │ │ │ │ + 1308 interfacePair->second.second[i]); │ │ │ │ │ + 1309 } │ │ │ │ │ + 1310 } │ │ │ │ │ + 1311 │ │ │ │ │ + 1312 } │ │ │ │ │ + 1313 │ │ │ │ │ + 1314 │ │ │ │ │ + 1315 template │ │ │ │ │ + 1316 inline void BufferedCommunicator:: │ │ │ │ │ +MessageScatterer::operator()(const │ │ │ │ │ +InterfaceMap& interfaces, Data& data, Type* buffer, const int& proc) const │ │ │ │ │ + 1317 { │ │ │ │ │ + 1318 typedef typename InterfaceMap::value_type::second_type::first_type │ │ │ │ │ +Information; │ │ │ │ │ + 1319 const typename InterfaceMap::const_iterator infoPair = interfaces.find │ │ │ │ │ +(proc); │ │ │ │ │ + 1320 │ │ │ │ │ + 1321 assert(infoPair!=interfaces.end()); │ │ │ │ │ + 1322 │ │ │ │ │ + 1323 const Information& info = FORWARD ? infoPair->second.second : │ │ │ │ │ + 1324 infoPair->second.first; │ │ │ │ │ + 1325 │ │ │ │ │ + 1326 for(size_t i=0, index=0; i < info.size(); i++) { │ │ │ │ │ + 1327 for(size_t j=0; j < CommPolicy::getSize(data, info[i]); j++) │ │ │ │ │ + 1328 GatherScatter::scatter(data, buffer[index++], info[i], j); │ │ │ │ │ + 1329 } │ │ │ │ │ + 1330 } │ │ │ │ │ + 1331 │ │ │ │ │ + 1332 │ │ │ │ │ + 1333 template │ │ │ │ │ + 1334 inline void BufferedCommunicator:: │ │ │ │ │ +MessageScatterer::operator()(const │ │ │ │ │ +InterfaceMap& interfaces, Data& data, Type* buffer, const int& proc) const │ │ │ │ │ + 1335 { │ │ │ │ │ + 1336 typedef typename InterfaceMap::value_type::second_type::first_type │ │ │ │ │ +Information; │ │ │ │ │ + 1337 const typename InterfaceMap::const_iterator infoPair = interfaces.find │ │ │ │ │ +(proc); │ │ │ │ │ + 1338 │ │ │ │ │ + 1339 assert(infoPair!=interfaces.end()); │ │ │ │ │ + 1340 │ │ │ │ │ + 1341 const Information& info = FORWARD ? infoPair->second.second : │ │ │ │ │ + 1342 infoPair->second.first; │ │ │ │ │ + 1343 │ │ │ │ │ + 1344 for(size_t i=0; i < info.size(); i++) { │ │ │ │ │ + 1345 GatherScatter::scatter(data, buffer[i], info[i]); │ │ │ │ │ + 1346 } │ │ │ │ │ + 1347 } │ │ │ │ │ + 1348 │ │ │ │ │ + 1349 │ │ │ │ │ + 1350 template │ │ │ │ │ + 1351 void BufferedCommunicator::forward(Data& data) │ │ │ │ │ + 1352 { │ │ │ │ │ + 1353 this->template sendRecv(data, data); │ │ │ │ │ + 1354 } │ │ │ │ │ + 1355 │ │ │ │ │ + 1356 │ │ │ │ │ + 1357 template │ │ │ │ │ + 1358 void BufferedCommunicator::backward(Data& data) │ │ │ │ │ + 1359 { │ │ │ │ │ + 1360 this->template sendRecv(data, data); │ │ │ │ │ + 1361 } │ │ │ │ │ + 1362 │ │ │ │ │ + 1363 │ │ │ │ │ + 1364 template │ │ │ │ │ + 1365 void BufferedCommunicator::forward(const Data& source, Data& dest) │ │ │ │ │ + 1366 { │ │ │ │ │ + 1367 this->template sendRecv(source, dest); │ │ │ │ │ + 1368 } │ │ │ │ │ + 1369 │ │ │ │ │ + 1370 │ │ │ │ │ + 1371 template │ │ │ │ │ + 1372 void BufferedCommunicator::backward(Data& source, const Data& dest) │ │ │ │ │ + 1373 { │ │ │ │ │ + 1374 this->template sendRecv(dest, source); │ │ │ │ │ + 1375 } │ │ │ │ │ + 1376 │ │ │ │ │ + 1377 │ │ │ │ │ + 1378 template │ │ │ │ │ + 1379 void BufferedCommunicator::sendRecv(const Data& source, Data& dest) │ │ │ │ │ + 1380 { │ │ │ │ │ + 1381 int rank, lrank; │ │ │ │ │ + 1382 │ │ │ │ │ + 1383 MPI_Comm_rank(MPI_COMM_WORLD,&rank); │ │ │ │ │ + 1384 MPI_Comm_rank(MPI_COMM_WORLD,&lrank); │ │ │ │ │ + 1385 │ │ │ │ │ + 1386 typedef typename CommPolicy::IndexedType Type; │ │ │ │ │ + 1387 Type *sendBuffer, *recvBuffer; │ │ │ │ │ + 1388 size_t sendBufferSize; │ │ │ │ │ + 1389#ifndef NDEBUG │ │ │ │ │ + 1390 size_t recvBufferSize; │ │ │ │ │ + 1391#endif │ │ │ │ │ + 1392 │ │ │ │ │ + 1393 if(FORWARD) { │ │ │ │ │ + 1394 sendBuffer = reinterpret_cast(buffers_[0]); │ │ │ │ │ + 1395 sendBufferSize = bufferSize_[0]; │ │ │ │ │ + 1396 recvBuffer = reinterpret_cast(buffers_[1]); │ │ │ │ │ + 1397#ifndef NDEBUG │ │ │ │ │ + 1398 recvBufferSize = bufferSize_[1]; │ │ │ │ │ + 1399#endif │ │ │ │ │ + 1400 }else{ │ │ │ │ │ + 1401 sendBuffer = reinterpret_cast(buffers_[1]); │ │ │ │ │ + 1402 sendBufferSize = bufferSize_[1]; │ │ │ │ │ + 1403 recvBuffer = reinterpret_cast(buffers_[0]); │ │ │ │ │ + 1404#ifndef NDEBUG │ │ │ │ │ + 1405 recvBufferSize = bufferSize_[0]; │ │ │ │ │ + 1406#endif │ │ │ │ │ + 1407 } │ │ │ │ │ + 1408 typedef typename CommPolicy::IndexedTypeFlag Flag; │ │ │ │ │ + 1409 │ │ │ │ │ + 1410 MessageGatherer() (interfaces_, source, │ │ │ │ │ +sendBuffer, sendBufferSize); │ │ │ │ │ + 1411 │ │ │ │ │ + 1412 MPI_Request* sendRequests = new MPI_Request[messageInformation_.size()]; │ │ │ │ │ + 1413 MPI_Request* recvRequests = new MPI_Request[messageInformation_.size()]; │ │ │ │ │ + 1414 /* Number of recvRequests that are not MPI_REQUEST_NULL */ │ │ │ │ │ + 1415 size_t numberOfRealRecvRequests = 0; │ │ │ │ │ + 1416 │ │ │ │ │ + 1417 // Setup receive first │ │ │ │ │ + 1418 typedef typename InformationMap::const_iterator const_iterator; │ │ │ │ │ + 1419 │ │ │ │ │ + 1420 const const_iterator end = messageInformation_.end(); │ │ │ │ │ + 1421 size_t i=0; │ │ │ │ │ + 1422 int* processMap = new int[messageInformation_.size()]; │ │ │ │ │ + 1423 │ │ │ │ │ + 1424 for(const_iterator info = messageInformation_.begin(); info != end; │ │ │ │ │ +++info, ++i) { │ │ │ │ │ + 1425 processMap[i]=info->first; │ │ │ │ │ + 1426 if(FORWARD) { │ │ │ │ │ + 1427 assert(info->second.second.start_*sizeof(typename CommPolicy:: │ │ │ │ │ +IndexedType)+info->second.second.size_ <= recvBufferSize ); │ │ │ │ │ + 1428 Dune::dvverb<second.second.size_<<" from │ │ │ │ │ +"<first<second.second.size_) { │ │ │ │ │ + 1430 MPI_Irecv(recvBuffer+info->second.second.start_, info- │ │ │ │ │ +>second.second.size_, │ │ │ │ │ + 1431 MPI_BYTE, info->first, commTag_, communicator_, │ │ │ │ │ + 1432 recvRequests+i); │ │ │ │ │ + 1433 numberOfRealRecvRequests += 1; │ │ │ │ │ + 1434 } else { │ │ │ │ │ + 1435 // Nothing to receive -> set request to inactive │ │ │ │ │ + 1436 recvRequests[i]=MPI_REQUEST_NULL; │ │ │ │ │ + 1437 } │ │ │ │ │ + 1438 }else{ │ │ │ │ │ + 1439 assert(info->second.first.start_*sizeof(typename CommPolicy:: │ │ │ │ │ +IndexedType)+info->second.first.size_ <= recvBufferSize ); │ │ │ │ │ + 1440 Dune::dvverb<second.first.size_<<" to │ │ │ │ │ +"<first<second.first.size_) { │ │ │ │ │ + 1442 MPI_Irecv(recvBuffer+info->second.first.start_, info->second.first.size_, │ │ │ │ │ + 1443 MPI_BYTE, info->first, commTag_, communicator_, │ │ │ │ │ + 1444 recvRequests+i); │ │ │ │ │ + 1445 numberOfRealRecvRequests += 1; │ │ │ │ │ + 1446 } else { │ │ │ │ │ + 1447 // Nothing to receive -> set request to inactive │ │ │ │ │ + 1448 recvRequests[i]=MPI_REQUEST_NULL; │ │ │ │ │ + 1449 } │ │ │ │ │ + 1450 } │ │ │ │ │ + 1451 } │ │ │ │ │ + 1452 │ │ │ │ │ + 1453 // now the send requests │ │ │ │ │ + 1454 i=0; │ │ │ │ │ + 1455 for(const_iterator info = messageInformation_.begin(); info != end; │ │ │ │ │ +++info, ++i) │ │ │ │ │ + 1456 if(FORWARD) { │ │ │ │ │ + 1457 assert(info->second.second.start_*sizeof(typename CommPolicy:: │ │ │ │ │ +IndexedType)+info->second.second.size_ <= recvBufferSize ); │ │ │ │ │ + 1458 Dune::dvverb<second.first.size_<<" to "<first<second.first.start_*sizeof(typename CommPolicy:: │ │ │ │ │ +IndexedType)+info->second.first.size_ <= sendBufferSize ); │ │ │ │ │ + 1460 if(info->second.first.size_) │ │ │ │ │ + 1461 MPI_Issend(sendBuffer+info->second.first.start_, info- │ │ │ │ │ +>second.first.size_, │ │ │ │ │ + 1462 MPI_BYTE, info->first, commTag_, communicator_, │ │ │ │ │ + 1463 sendRequests+i); │ │ │ │ │ + 1464 else │ │ │ │ │ + 1465 // Nothing to send -> set request to inactive │ │ │ │ │ + 1466 sendRequests[i]=MPI_REQUEST_NULL; │ │ │ │ │ + 1467 }else{ │ │ │ │ │ + 1468 assert(info->second.second.start_*sizeof(typename CommPolicy:: │ │ │ │ │ +IndexedType)+info->second.second.size_ <= sendBufferSize ); │ │ │ │ │ + 1469 Dune::dvverb<second.second.size_<<" to │ │ │ │ │ +"<first<second.second.size_) │ │ │ │ │ + 1471 MPI_Issend(sendBuffer+info->second.second.start_, info- │ │ │ │ │ +>second.second.size_, │ │ │ │ │ + 1472 MPI_BYTE, info->first, commTag_, communicator_, │ │ │ │ │ + 1473 sendRequests+i); │ │ │ │ │ + 1474 else │ │ │ │ │ + 1475 // Nothing to send -> set request to inactive │ │ │ │ │ + 1476 sendRequests[i]=MPI_REQUEST_NULL; │ │ │ │ │ + 1477 } │ │ │ │ │ + 1478 │ │ │ │ │ + 1479 // Wait for completion of receive and immediately start scatter │ │ │ │ │ + 1480 i=0; │ │ │ │ │ + 1481 //int success = 1; │ │ │ │ │ + 1482 int finished = MPI_UNDEFINED; │ │ │ │ │ + 1483 MPI_Status status; //[messageInformation_.size()]; │ │ │ │ │ + 1484 //MPI_Waitall(messageInformation_.size(), recvRequests, status); │ │ │ │ │ + 1485 │ │ │ │ │ + 1486 for(i=0; i< numberOfRealRecvRequests; i++) { │ │ │ │ │ + 1487 status.MPI_ERROR=MPI_SUCCESS; │ │ │ │ │ + 1488 MPI_Waitany(messageInformation_.size(), recvRequests, &finished, │ │ │ │ │ +&status); │ │ │ │ │ + 1489 assert(finished != MPI_UNDEFINED); │ │ │ │ │ + 1490 │ │ │ │ │ + 1491 if(status.MPI_ERROR==MPI_SUCCESS) { │ │ │ │ │ + 1492 int& proc = processMap[finished]; │ │ │ │ │ + 1493 typename InformationMap::const_iterator infoIter = │ │ │ │ │ +messageInformation_.find(proc); │ │ │ │ │ + 1494 assert(infoIter != messageInformation_.end()); │ │ │ │ │ + 1495 │ │ │ │ │ + 1496 MessageInformation info = (FORWARD) ? infoIter->second.second : infoIter- │ │ │ │ │ +>second.first; │ │ │ │ │ + 1497 assert(info.start_+info.size_ <= recvBufferSize); │ │ │ │ │ + 1498 │ │ │ │ │ + 1499 MessageScatterer() (interfaces_, dest, │ │ │ │ │ +recvBuffer+info.start_, proc); │ │ │ │ │ + 1500 }else{ │ │ │ │ │ + 1501 std::cerr<communicator()); │ │ │ │ │ + 1517 │ │ │ │ │ + 1518 if(!globalSuccess) │ │ │ │ │ + 1519 DUNE_THROW(CommunicationError, "A communication error occurred!"); │ │ │ │ │ + 1520 */ │ │ │ │ │ + 1521 delete[] processMap; │ │ │ │ │ + 1522 delete[] sendRequests; │ │ │ │ │ + 1523 delete[] recvRequests; │ │ │ │ │ + 1524 │ │ │ │ │ + 1525 } │ │ │ │ │ + 1526 │ │ │ │ │ + 1527#endif // DOXYGEN │ │ │ │ │ + 1528 │ │ │ │ │ + 1530} │ │ │ │ │ + 1531 │ │ │ │ │ + 1532#endif // HAVE_MPI │ │ │ │ │ + 1533 │ │ │ │ │ + 1534#endif │ │ │ │ │ +remoteindices.hh │ │ │ │ │ +Classes describing a distributed indexset. │ │ │ │ │ +exceptions.hh │ │ │ │ │ +A few common exception classes. │ │ │ │ │ +stdstreams.hh │ │ │ │ │ +Standard Dune debug streams. │ │ │ │ │ +DUNE_THROW │ │ │ │ │ +#define DUNE_THROW(E, m) │ │ │ │ │ +Definition exceptions.hh:218 │ │ │ │ │ +Dune::dvverb │ │ │ │ │ +DVVerbType dvverb(std::cout) │ │ │ │ │ +stream for very verbose output. │ │ │ │ │ +Definition stdstreams.hh:95 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::get │ │ │ │ │ -Reference get(const RAPropertyMapHelper< Reference, PropertyMap > &pmap, const │ │ │ │ │ -Key &key) │ │ │ │ │ -Definition propertymap.hh:84 │ │ │ │ │ -Dune::IsNumber │ │ │ │ │ -Whether this type acts as a scalar in the context of (hierarchically blocked) │ │ │ │ │ -containers. │ │ │ │ │ -Definition typetraits.hh:194 │ │ │ │ │ -Dune::FieldTraits::field_type │ │ │ │ │ -T field_type │ │ │ │ │ -export the type representing the field │ │ │ │ │ -Definition ftraits.hh:28 │ │ │ │ │ -Dune::FieldTraits::real_type │ │ │ │ │ -T real_type │ │ │ │ │ -export the type representing the real type of the field │ │ │ │ │ -Definition ftraits.hh:30 │ │ │ │ │ -Dune::Empty │ │ │ │ │ -Just an empty class. │ │ │ │ │ -Definition typetraits.hh:55 │ │ │ │ │ -Dune::IsInteroperable │ │ │ │ │ -Checks whether two types are interoperable. │ │ │ │ │ -Definition typetraits.hh:65 │ │ │ │ │ -Dune::IsInteroperable::value │ │ │ │ │ -static constexpr bool value │ │ │ │ │ -True if either a conversion from T1 to T2 or vice versa exists. │ │ │ │ │ -Definition typetraits.hh:70 │ │ │ │ │ -Dune::EnableIfInterOperable │ │ │ │ │ -Enable typedef if two types are interoperable. │ │ │ │ │ -Definition typetraits.hh:81 │ │ │ │ │ -Dune::AlwaysFalse │ │ │ │ │ -template which always yields a false value │ │ │ │ │ -Definition typetraits.hh:124 │ │ │ │ │ -Dune::AlwaysTrue │ │ │ │ │ -template which always yields a true value │ │ │ │ │ -Definition typetraits.hh:134 │ │ │ │ │ -Dune::IsCallable │ │ │ │ │ -Check if a type is callable with ()-operator and given arguments. │ │ │ │ │ -Definition typetraits.hh:162 │ │ │ │ │ -Dune::HasNaN │ │ │ │ │ -Whether this type has a value of NaN. │ │ │ │ │ -Definition typetraits.hh:212 │ │ │ │ │ -Dune::IsIndexable │ │ │ │ │ -Type trait to determine whether an instance of T has an operator[](I), i.e. │ │ │ │ │ -whether it can be indexed... │ │ │ │ │ -Definition typetraits.hh:250 │ │ │ │ │ -Dune::IsIterable │ │ │ │ │ -typetrait to check that a class has begin() and end() members │ │ │ │ │ -Definition typetraits.hh:273 │ │ │ │ │ -Dune::IsTuple │ │ │ │ │ -Check if T is a std::tuple<...> │ │ │ │ │ -Definition typetraits.hh:329 │ │ │ │ │ -Dune::IsTupleOrDerived │ │ │ │ │ -Check if T derived from a std::tuple<...> │ │ │ │ │ -Definition typetraits.hh:357 │ │ │ │ │ -Dune::IsIntegralConstant │ │ │ │ │ -Check if T is an std::integral_constant │ │ │ │ │ -Definition typetraits.hh:384 │ │ │ │ │ -Dune::SizeOf │ │ │ │ │ -Compute size of variadic type list. │ │ │ │ │ -Definition typetraits.hh:404 │ │ │ │ │ -Dune::IntegerSequenceEntry │ │ │ │ │ -Get entry of std::integer_sequence. │ │ │ │ │ -Definition typetraits.hh:476 │ │ │ │ │ -Dune::AutonomousValueType │ │ │ │ │ -Type free of internal references that T can be converted to. │ │ │ │ │ -Definition typetraits.hh:501 │ │ │ │ │ -Dune::AutonomousValueType::type │ │ │ │ │ -T type │ │ │ │ │ -Definition typetraits.hh:501 │ │ │ │ │ -Dune::AutonomousValueType<_std::vector<_bool_>::reference_>::type │ │ │ │ │ -bool type │ │ │ │ │ -Definition typetraits.hh:523 │ │ │ │ │ +Dune::IOError │ │ │ │ │ +Default exception class for I/O errors. │ │ │ │ │ +Definition exceptions.hh:231 │ │ │ │ │ +Dune::SizeOne │ │ │ │ │ +Flag for marking indexed data structures where data at each index is of the │ │ │ │ │ +same size. │ │ │ │ │ +Definition communicator.hh:110 │ │ │ │ │ +Dune::VariableSize │ │ │ │ │ +Flag for marking indexed data structures where the data at each index may be a │ │ │ │ │ +variable multiple of a... │ │ │ │ │ +Definition communicator.hh:118 │ │ │ │ │ +Dune::CommPolicy │ │ │ │ │ +Default policy used for communicating an indexed type. │ │ │ │ │ +Definition communicator.hh:128 │ │ │ │ │ +Dune::CommPolicy::IndexedType │ │ │ │ │ +V::value_type IndexedType │ │ │ │ │ +The type we get at each index with operator[]. │ │ │ │ │ +Definition communicator.hh:147 │ │ │ │ │ +Dune::CommPolicy::getSize │ │ │ │ │ +static int getSize(const V &, int index) │ │ │ │ │ +Get the number of primitive elements at that index. │ │ │ │ │ +Dune::CommPolicy::IndexedTypeFlag │ │ │ │ │ +SizeOne IndexedTypeFlag │ │ │ │ │ +Whether the indexed type has variable size or there is always one value at each │ │ │ │ │ +index. │ │ │ │ │ +Definition communicator.hh:153 │ │ │ │ │ +Dune::CommPolicy::getAddress │ │ │ │ │ +static const void * getAddress(const V &v, int index) │ │ │ │ │ +Get the address of entry at an index. │ │ │ │ │ +Dune::CommPolicy::Type │ │ │ │ │ +V Type │ │ │ │ │ +The type the policy is for. │ │ │ │ │ +Definition communicator.hh:140 │ │ │ │ │ +Dune::CommPolicy::FieldVector │ │ │ │ │ +Definition communicator.hh:173 │ │ │ │ │ +Dune::CommPolicy::VariableBlockVector │ │ │ │ │ +Definition communicator.hh:175 │ │ │ │ │ +Dune::CommPolicy::CommPolicy<_VariableBlockVector<_FieldVector<_K,_n_>,_A_>_>:: │ │ │ │ │ +getSize │ │ │ │ │ +static int getSize(const Type &v, int i) │ │ │ │ │ +Dune::CommPolicy::CommPolicy<_VariableBlockVector<_FieldVector<_K,_n_>,_A_>_>:: │ │ │ │ │ +IndexedTypeFlag │ │ │ │ │ +VariableSize IndexedTypeFlag │ │ │ │ │ +Definition communicator.hh:184 │ │ │ │ │ +Dune::CommPolicy::CommPolicy<_VariableBlockVector<_FieldVector<_K,_n_>,_A_>_>:: │ │ │ │ │ +Type │ │ │ │ │ +VariableBlockVector< FieldVector< K, n >, A > Type │ │ │ │ │ +Definition communicator.hh:180 │ │ │ │ │ +Dune::CommPolicy::CommPolicy<_VariableBlockVector<_FieldVector<_K,_n_>,_A_>_>:: │ │ │ │ │ +getAddress │ │ │ │ │ +static const void * getAddress(const Type &v, int i) │ │ │ │ │ +Dune::CommPolicy::CommPolicy<_VariableBlockVector<_FieldVector<_K,_n_>,_A_>_>:: │ │ │ │ │ +IndexedType │ │ │ │ │ +Type::B IndexedType │ │ │ │ │ +Definition communicator.hh:182 │ │ │ │ │ +Dune::CommPolicy::CommunicationError │ │ │ │ │ +Error thrown if there was a problem with the communication. │ │ │ │ │ +Definition communicator.hh:195 │ │ │ │ │ +Dune::CommPolicy::CopyGatherScatter │ │ │ │ │ +GatherScatter default implementation that just copies data. │ │ │ │ │ +Definition communicator.hh:202 │ │ │ │ │ +Dune::CommPolicy::CopyGatherScatter::scatter │ │ │ │ │ +static void scatter(T &vec, const IndexedType &v, std::size_t i) │ │ │ │ │ +Dune::CommPolicy::CopyGatherScatter::IndexedType │ │ │ │ │ +CommPolicy< T >::IndexedType IndexedType │ │ │ │ │ +Definition communicator.hh:203 │ │ │ │ │ +Dune::CommPolicy::CopyGatherScatter::gather │ │ │ │ │ +static const IndexedType & gather(const T &vec, std::size_t i) │ │ │ │ │ +Dune::BufferedCommunicator │ │ │ │ │ +A communicator that uses buffers to gather and scatter the data to be send or │ │ │ │ │ +received. │ │ │ │ │ +Definition communicator.hh:458 │ │ │ │ │ +Dune::BufferedCommunicator::backward │ │ │ │ │ +void backward(Data &data) │ │ │ │ │ +Backward send where target and source are the same. │ │ │ │ │ +Dune::BufferedCommunicator::BufferedCommunicator │ │ │ │ │ +BufferedCommunicator() │ │ │ │ │ +Constructor. │ │ │ │ │ +Dune::BufferedCommunicator::~BufferedCommunicator │ │ │ │ │ +~BufferedCommunicator() │ │ │ │ │ +Destructor. │ │ │ │ │ +Dune::BufferedCommunicator::forward │ │ │ │ │ +void forward(const Data &source, Data &dest) │ │ │ │ │ +Send from source to target. │ │ │ │ │ +Dune::BufferedCommunicator::free │ │ │ │ │ +void free() │ │ │ │ │ +Free the allocated memory (i.e. buffers and message information. │ │ │ │ │ +Dune::BufferedCommunicator::build │ │ │ │ │ +std::enable_if< std::is_same< SizeOne, typenameCommPolicy< Data >:: │ │ │ │ │ +IndexedTypeFlag >::value, void >::type build(const Interface &interface) │ │ │ │ │ +Build the buffers and information for the communication process. │ │ │ │ │ +Dune::BufferedCommunicator::backward │ │ │ │ │ +void backward(Data &source, const Data &dest) │ │ │ │ │ +Communicate in the reverse direction, i.e. send from target to source. │ │ │ │ │ +Dune::BufferedCommunicator::build │ │ │ │ │ +void build(const Data &source, const Data &target, const Interface &interface) │ │ │ │ │ +Build the buffers and information for the communication process. │ │ │ │ │ +Dune::BufferedCommunicator::forward │ │ │ │ │ +void forward(Data &data) │ │ │ │ │ +Forward send where target and source are the same. │ │ │ │ │ +Dune::ParallelIndexSet │ │ │ │ │ +Manager class for the mapping between local indices and globally unique │ │ │ │ │ +indices. │ │ │ │ │ +Definition indexset.hh:218 │ │ │ │ │ +Dune::InterfaceBuilder │ │ │ │ │ +Base class of all classes representing a communication interface. │ │ │ │ │ +Definition parallel/interface.hh:35 │ │ │ │ │ +Dune::InterfaceInformation │ │ │ │ │ +Information describing an interface. │ │ │ │ │ +Definition parallel/interface.hh:101 │ │ │ │ │ +Dune::Interface │ │ │ │ │ +Communication interface between remote and local indices. │ │ │ │ │ +Definition parallel/interface.hh:209 │ │ │ │ │ +Dune::LocalIndex │ │ │ │ │ +An index present on the local process. │ │ │ │ │ +Definition localindex.hh:35 │ │ │ │ │ +Dune::RemoteIndices │ │ │ │ │ +The indices present on remote processes. │ │ │ │ │ +Definition remoteindices.hh:189 │ │ │ │ │ +Dune::RemoteIndices::GlobalIndex │ │ │ │ │ +ParallelIndexSet::GlobalIndex GlobalIndex │ │ │ │ │ +The type of the global index. │ │ │ │ │ +Definition remoteindices.hh:215 │ │ │ │ │ +Dune::RemoteIndices::Attribute │ │ │ │ │ +LocalIndex::Attribute Attribute │ │ │ │ │ +The type of the attribute. │ │ │ │ │ +Definition remoteindices.hh:226 │ │ │ │ │ +Dune::RemoteIndices::LocalIndex │ │ │ │ │ +ParallelIndexSet::LocalIndex LocalIndex │ │ │ │ │ +The type of the local index. │ │ │ │ │ +Definition remoteindices.hh:221 │ │ │ │ │ +interface.hh │ │ │ │ │ +Provides classes for building the communication interface between remote │ │ │ │ │ +indices. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00029.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: sllist.hh File Reference │ │ │ │ +dune-common: indexset.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,64 +65,123 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ Namespaces | │ │ │ │ +Enumerations | │ │ │ │ Functions
│ │ │ │ -
sllist.hh File Reference
│ │ │ │ + │ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ -

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

Provides a map between global and local indices. │ │ │ │ More...

│ │ │ │ -
#include <memory>
│ │ │ │ -#include <cassert>
│ │ │ │ -#include "iteratorfacades.hh"
│ │ │ │ -#include <ostream>
│ │ │ │ +
#include <algorithm>
│ │ │ │ +#include <dune/common/arraylist.hh>
│ │ │ │ +#include <dune/common/exceptions.hh>
│ │ │ │ +#include <iostream>
│ │ │ │ +#include "localindex.hh"
│ │ │ │ +#include <stdint.h>
│ │ │ │
│ │ │ │

Go to the source code of this file.

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

│ │ │ │ Classes

class  Dune::SLList< T, A >
 A single linked list. More...
class  Dune::IndexPair< TG, TL >
 A pair consisting of a global and local index. More...
 
class  Dune::SLListIterator< T, A >
 A mutable iterator for the SLList. More...
class  Dune::InvalidIndexSetState
 Exception indicating that the index set is not in the expected state. More...
 
class  Dune::SLListConstIterator< T, A >
 A constant iterator for the SLList. More...
class  Dune::ParallelIndexSet< TG, TL, N >
 Manager class for the mapping between local indices and globally unique indices. More...
 
class  Dune::SLListModifyIterator< T, A >
 A mutable iterator for the SLList. More...
class  Dune::ParallelIndexSet< TG, TL, N >::iterator
 The iterator over the pairs. More...
 
class  Dune::GlobalLookupIndexSet< I >
 Decorates an index set with the possibility to find a global index that is mapped to a specific local. More...
 
struct  Dune::LocalIndexComparator< T >
 
struct  Dune::IndexSetSortFunctor< TG, TL >
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

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

│ │ │ │ +Enumerations

enum  Dune::ParallelIndexSetState { Dune::GROUND │ │ │ │ +, Dune::RESIZE │ │ │ │ + }
 The states the index set can be in. More...
 
│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Functions

template<typename T , typename A >
std::ostream & Dune::operator<< (std::ostream &os, const SLList< T, A > &sllist)
 
template<class TG , class TL >
std::ostream & Dune::operator<< (std::ostream &os, const IndexPair< TG, TL > &pair)
 Print an index pair.
 
template<class TG , class TL >
bool Dune::operator== (const IndexPair< TG, TL > &, const IndexPair< TG, TL > &)
 
template<class TG , class TL >
bool Dune::operator!= (const IndexPair< TG, TL > &, const IndexPair< TG, TL > &)
 
template<class TG , class TL >
bool Dune::operator< (const IndexPair< TG, TL > &, const IndexPair< TG, TL > &)
 
template<class TG , class TL >
bool Dune::operator> (const IndexPair< TG, TL > &, const IndexPair< TG, TL > &)
 
template<class TG , class TL >
bool Dune::operator<= (const IndexPair< TG, TL > &, const IndexPair< TG, TL > &)
 
template<class TG , class TL >
bool Dune::operator>= (const IndexPair< TG, TL > &, const IndexPair< TG, TL > &)
 
template<class TG , class TL >
bool Dune::operator== (const IndexPair< TG, TL > &, const TG &)
 
template<class TG , class TL >
bool Dune::operator!= (const IndexPair< TG, TL > &, const TG &)
 
template<class TG , class TL >
bool Dune::operator< (const IndexPair< TG, TL > &, const TG &)
 
template<class TG , class TL >
bool Dune::operator> (const IndexPair< TG, TL > &, const TG &)
 
template<class TG , class TL >
bool Dune::operator<= (const IndexPair< TG, TL > &, const TG &)
 
template<class TG , class TL >
bool Dune::operator>= (const IndexPair< TG, TL > &, const TG &)
 
template<class TG , class TL , int N>
std::ostream & Dune::operator<< (std::ostream &os, const ParallelIndexSet< TG, TL, N > &indexSet)
 Print an index set.
 
│ │ │ │

Detailed Description

│ │ │ │ -

Implements a singly linked list together with the necessary iterators.

│ │ │ │ +

Provides a map between global and local indices.

│ │ │ │
Author
Markus Blatt
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,45 +6,110 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ 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 │ │ │ │ │ -#include │ │ │ │ │ -#include "iteratorfacades.hh" │ │ │ │ │ -#include │ │ │ │ │ + * parallel │ │ │ │ │ +Classes | Namespaces | Enumerations | Functions │ │ │ │ │ +indexset.hh File Reference │ │ │ │ │ +Common » Parallel_Communication » Parallel_Computing_based_on_Indexsets │ │ │ │ │ +Provides a map between global and local indices. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include "localindex.hh" │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class  Dune::SLList<_T,_A_> │ │ │ │ │ -  A single linked list. More... │ │ │ │ │ + class  Dune::IndexPair<_TG,_TL_> │ │ │ │ │ +  A pair consisting of a global and local index. More... │ │ │ │ │   │ │ │ │ │ -class  Dune::SLListIterator<_T,_A_> │ │ │ │ │ -  A mutable iterator for the SLList. More... │ │ │ │ │ + class  Dune::InvalidIndexSetState │ │ │ │ │ +  Exception indicating that the index set is not in the expected state. │ │ │ │ │ + More... │ │ │ │ │   │ │ │ │ │ -class  Dune::SLListConstIterator<_T,_A_> │ │ │ │ │ -  A constant iterator for the SLList. More... │ │ │ │ │ + class  Dune::ParallelIndexSet<_TG,_TL,_N_> │ │ │ │ │ +  Manager class for the mapping between local indices and globally │ │ │ │ │ + unique indices. More... │ │ │ │ │   │ │ │ │ │ -class  Dune::SLListModifyIterator<_T,_A_> │ │ │ │ │ -  A mutable iterator for the SLList. More... │ │ │ │ │ + class  Dune::ParallelIndexSet<_TG,_TL,_N_>::iterator │ │ │ │ │ +  The iterator over the pairs. More... │ │ │ │ │ +  │ │ │ │ │ + class  Dune::GlobalLookupIndexSet<_I_> │ │ │ │ │ +  Decorates an index set with the possibility to find a global index │ │ │ │ │ + that is mapped to a specific local. More... │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::LocalIndexComparator<_T_> │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::IndexSetSortFunctor<_TG,_TL_> │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ + Enumerations │ │ │ │ │ +enum  Dune::ParallelIndexSetState { Dune::GROUND , Dune::RESIZE } │ │ │ │ │ +  The states the index set can be in. More... │ │ │ │ │ +  │ │ │ │ │ Functions │ │ │ │ │ -template │ │ │ │ │ -std::ostream & Dune::operator<< (std::ostream &os, const SLList< T, A > │ │ │ │ │ - &sllist) │ │ │ │ │ +template │ │ │ │ │ +std::ostream & Dune::operator<< (std::ostream &os, const IndexPair< TG, TL > │ │ │ │ │ + &pair) │ │ │ │ │ +  Print an index pair. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool Dune::operator== (const IndexPair< TG, TL > &, const IndexPair< │ │ │ │ │ + TG, TL > &) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool Dune::operator!= (const IndexPair< TG, TL > &, const IndexPair< │ │ │ │ │ + TG, TL > &) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool Dune::operator< (const IndexPair< TG, TL > &, const IndexPair< │ │ │ │ │ + TG, TL > &) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool Dune::operator> (const IndexPair< TG, TL > &, const IndexPair< │ │ │ │ │ + TG, TL > &) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool Dune::operator<= (const IndexPair< TG, TL > &, const IndexPair< │ │ │ │ │ + TG, TL > &) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool Dune::operator>= (const IndexPair< TG, TL > &, const IndexPair< │ │ │ │ │ + TG, TL > &) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool Dune::operator== (const IndexPair< TG, TL > &, const TG &) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool Dune::operator!= (const IndexPair< TG, TL > &, const TG &) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool Dune::operator< (const IndexPair< TG, TL > &, const TG &) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool Dune::operator> (const IndexPair< TG, TL > &, const TG &) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool Dune::operator<= (const IndexPair< TG, TL > &, const TG &) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool Dune::operator>= (const IndexPair< TG, TL > &, const TG &) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +std::ostream & Dune::operator<< (std::ostream &os, const ParallelIndexSet< TG, │ │ │ │ │ + TL, N > &indexSet) │ │ │ │ │ +  Print an index set. │ │ │ │ │   │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Implements a singly linked list together with the necessary iterators. │ │ │ │ │ +Provides a map between global and local indices. │ │ │ │ │ Author │ │ │ │ │ Markus Blatt │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00029_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: sllist.hh Source File │ │ │ │ +dune-common: indexset.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,782 +70,961 @@ │ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
sllist.hh
│ │ │ │ +
indexset.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 (C) 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
│ │ │ │ +
5#ifndef DUNE_INDEXSET_HH
│ │ │ │ +
6#define DUNE_INDEXSET_HH
│ │ │ │
7
│ │ │ │ -
8#include <memory>
│ │ │ │ -
9#include <cassert>
│ │ │ │ -
10#include "iteratorfacades.hh"
│ │ │ │ -
11#include <ostream>
│ │ │ │ +
8#include <algorithm>
│ │ │ │ + │ │ │ │ + │ │ │ │ +
11#include <iostream>
│ │ │ │
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;
│ │ │ │ -
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>;
│ │ │ │ -
48
│ │ │ │ -
49 public:
│ │ │ │ -
50
│ │ │ │ -
54 typedef typename A::size_type size_type;
│ │ │ │ +
13#include "localindex.hh"
│ │ │ │ +
14
│ │ │ │ +
15#include <stdint.h> // for uint32_t
│ │ │ │ +
16
│ │ │ │ +
17namespace Dune
│ │ │ │ +
18{
│ │ │ │ +
28 // forward declarations
│ │ │ │ +
29
│ │ │ │ +
30 template<class TG, class TL>
│ │ │ │ +
31 class IndexPair;
│ │ │ │ +
32
│ │ │ │ +
38 template<class TG, class TL>
│ │ │ │ +
39 std::ostream& operator<<(std::ostream& os, const IndexPair<TG,TL>& pair);
│ │ │ │ +
40
│ │ │ │ +
41 template<class TG, class TL>
│ │ │ │ +
42 bool operator==(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
│ │ │ │ +
43
│ │ │ │ +
44 template<class TG, class TL>
│ │ │ │ +
45 bool operator!=(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
│ │ │ │ +
46
│ │ │ │ +
47 template<class TG, class TL>
│ │ │ │ +
48 bool operator<(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
│ │ │ │ +
49
│ │ │ │ +
50 template<class TG, class TL>
│ │ │ │ +
51 bool operator>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
│ │ │ │ +
52
│ │ │ │ +
53 template<class TG, class TL>
│ │ │ │ +
54 bool operator<=(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
│ │ │ │
55
│ │ │ │ -
59 typedef T MemberType;
│ │ │ │ -
60
│ │ │ │ -
64 using Allocator = typename std::allocator_traits<A>::template rebind_alloc<Element>;
│ │ │ │ -
65
│ │ │ │ - │ │ │ │ +
56 template<class TG, class TL>
│ │ │ │ +
57 bool operator >=(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
│ │ │ │ +
58
│ │ │ │ +
59 template<class TG, class TL>
│ │ │ │ +
60 bool operator==(const IndexPair<TG,TL>&, const TG&);
│ │ │ │ +
61
│ │ │ │ +
62 template<class TG, class TL>
│ │ │ │ +
63 bool operator!=(const IndexPair<TG,TL>&, const TG&);
│ │ │ │ +
64
│ │ │ │ +
65 template<class TG, class TL>
│ │ │ │ +
66 bool operator<(const IndexPair<TG,TL>&, const TG&);
│ │ │ │ +
67
│ │ │ │ +
68 template<class TG, class TL>
│ │ │ │ +
69 bool operator>(const IndexPair<TG,TL>&, const TG&);
│ │ │ │
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
│ │ │ │ - │ │ │ │ -
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;
│ │ │ │ +
71 template<class TG, class TL>
│ │ │ │ +
72 bool operator<=(const IndexPair<TG,TL>&, const TG&);
│ │ │ │ +
73
│ │ │ │ +
74 template<class TG, class TL>
│ │ │ │ +
75 bool operator >=(const IndexPair<TG,TL>&, const TG&);
│ │ │ │ +
76
│ │ │ │ +
77 template<typename T>
│ │ │ │ +
78 struct MPITraits;
│ │ │ │ +
79
│ │ │ │ +
83 template<class TG, class TL>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
85 {
│ │ │ │ +
86 friend std::ostream& operator<<<>(std::ostream&, const IndexPair<TG,TL>&);
│ │ │ │ +
87 friend bool operator==<>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
│ │ │ │ +
88 friend bool operator!=<>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
│ │ │ │ +
89 friend bool operator< <>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
│ │ │ │ +
90 friend bool operator><>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
│ │ │ │ +
91 friend bool operator<=<>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
│ │ │ │ +
92 friend bool operator>=<>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
│ │ │ │ +
93 friend bool operator==<>(const IndexPair<TG,TL>&, const TG &);
│ │ │ │ +
94 friend bool operator!=<>(const IndexPair<TG,TL>&, const TG &);
│ │ │ │ +
95 friend bool operator< <>(const IndexPair<TG,TL>&, const TG &);
│ │ │ │ +
96 friend bool operator> <>(const IndexPair<TG,TL>&, const TG &);
│ │ │ │ +
97 friend bool operator<=<>(const IndexPair<TG,TL>&, const TG &);
│ │ │ │ +
98 friend bool operator>=<>(const IndexPair<TG,TL>&, const TG &);
│ │ │ │ +
99 friend struct MPITraits<IndexPair<TG,TL> >;
│ │ │ │ +
100
│ │ │ │ +
101 public:
│ │ │ │ +
107 typedef TG GlobalIndex;
│ │ │ │ +
108
│ │ │ │ +
120 typedef TL LocalIndex;
│ │ │ │ +
121
│ │ │ │ + │ │ │ │ +
129
│ │ │ │ + │ │ │ │ + │ │ │ │ +
141
│ │ │ │ +
147 inline const GlobalIndex& global() const;
│ │ │ │
148
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
157
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
166
│ │ │ │ -
│ │ │ │ -
173 inline iterator end();
│ │ │ │ -
174
│ │ │ │ -
│ │ │ │ -
181 inline const_iterator end() const;
│ │ │ │ -
182
│ │ │ │ -
│ │ │ │ -
188 inline bool empty() const;
│ │ │ │ -
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 };
│ │ │ │ +
154 inline LocalIndex& local();
│ │ │ │ +
155
│ │ │ │ +
161 inline const LocalIndex& local() const;
│ │ │ │ +
162
│ │ │ │ +
168 inline void setLocal(int index);
│ │ │ │ +
169 private:
│ │ │ │ +
171 GlobalIndex global_;
│ │ │ │ + │ │ │ │ +
174 };
│ │ │ │ +
│ │ │ │ +
175
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
181 {
│ │ │ │ + │ │ │ │ +
190 RESIZE
│ │ │ │ +
200 };
│ │ │ │ +
│ │ │ │ +
201
│ │ │ │ + │ │ │ │ +
206
│ │ │ │ +
207 // Forward declaration
│ │ │ │ +
208 template<class I> class GlobalLookupIndexSet;
│ │ │ │ +
209
│ │ │ │ +
216 template<typename TG, typename TL, int N=100>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
218 {
│ │ │ │ +
219 friend class GlobalLookupIndexSet<ParallelIndexSet<TG,TL,N> >;
│ │ │ │
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 {}
│ │ │ │ +
221 public:
│ │ │ │ +
226 typedef TG GlobalIndex;
│ │ │ │ +
227
│ │ │ │ +
239 typedef TL LocalIndex;
│ │ │ │ +
240
│ │ │ │ + │ │ │ │ +
245
│ │ │ │ +
252 constexpr static int arraySize = (N>0) ? N : 1;
│ │ │ │ +
253
│ │ │ │ +
│ │ │ │ +
255 class iterator :
│ │ │ │ +
256 public ArrayList<IndexPair,N>::iterator
│ │ │ │ +
257 {
│ │ │ │ +
258 typedef typename ArrayList<IndexPair,N>::iterator
│ │ │ │ + │ │ │ │ + │ │ │ │ +
261 public:
│ │ │ │ +
│ │ │ │ +
262 iterator(ParallelIndexSet<TG,TL,N>& indexSet, const Father& father)
│ │ │ │ +
263 : Father(father), indexSet_(&indexSet)
│ │ │ │ +
264 {}
│ │ │ │
│ │ │ │ +
265
│ │ │ │ +
266 private:
│ │ │ │ +
276 inline void markAsDeleted() const
│ │ │ │ +
277 {
│ │ │ │ +
278#ifndef NDEBUG
│ │ │ │ +
279 if(indexSet_->state_ != RESIZE)
│ │ │ │ +
280 DUNE_THROW(InvalidIndexSetState, "Indices can only be removed "
│ │ │ │ +
281 <<"while in RESIZE state!");
│ │ │ │ +
282#endif
│ │ │ │ +
283 Father::operator*().local().setState(DELETED);
│ │ │ │ +
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 }
│ │ │ │ +
287 ParallelIndexSet<TG,TL,N>* indexSet_;
│ │ │ │ +
288
│ │ │ │ +
289 };
│ │ │ │ +
│ │ │ │ +
290
│ │ │ │ +
291
│ │ │ │ +
292
│ │ │ │ +
294 typedef typename
│ │ │ │ + │ │ │ │ + │ │ │ │ +
297
│ │ │ │ + │ │ │ │ +
302
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
308 {
│ │ │ │ +
309 return state_;
│ │ │ │ +
310 }
│ │ │ │
│ │ │ │ +
311
│ │ │ │ + │ │ │ │
318
│ │ │ │ -
│ │ │ │ -
324 inline bool equals(const SLListModifyIterator<T,A>& other) const
│ │ │ │ -
325 {
│ │ │ │ -
326 return current_==other.iterator_.current_;
│ │ │ │ -
327 }
│ │ │ │ -
│ │ │ │ +
327 inline void add(const GlobalIndex& global);
│ │ │ │
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 }
│ │ │ │ -
│ │ │ │ +
337 inline void add(const GlobalIndex& global, const LocalIndex& local);
│ │ │ │ +
338
│ │ │ │ +
346 inline void markAsDeleted(const iterator& position);
│ │ │ │
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>;
│ │ │ │ +
360 void endResize();
│ │ │ │ +
361
│ │ │ │ +
372 inline IndexPair&
│ │ │ │ +
373 operator[](const GlobalIndex& global);
│ │ │ │
374
│ │ │ │ -
375 public:
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
377 : current_(0)
│ │ │ │ -
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 }
│ │ │ │ -
│ │ │ │ -
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 };
│ │ │ │ -
│ │ │ │ +
384 inline IndexPair&
│ │ │ │ +
385 at(const GlobalIndex& global);
│ │ │ │ +
386
│ │ │ │ +
396 inline bool
│ │ │ │ +
397 exists (const GlobalIndex& global) const;
│ │ │ │ +
398
│ │ │ │ +
409 inline const IndexPair&
│ │ │ │ +
410 operator[](const GlobalIndex& global) const;
│ │ │ │ +
411
│ │ │ │ +
421 inline const IndexPair&
│ │ │ │ +
422 at(const GlobalIndex& global) const;
│ │ │ │
423
│ │ │ │ -
427 template<typename T, class A>
│ │ │ │ -
│ │ │ │ -
428 class SLListModifyIterator : public Dune::ForwardIteratorFacade<SLListModifyIterator<T,A>, T, T&, std::size_t>
│ │ │ │ -
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 {}
│ │ │ │ -
│ │ │ │ +
428 inline iterator begin();
│ │ │ │ +
429
│ │ │ │ +
434 inline iterator end();
│ │ │ │ +
435
│ │ │ │ +
440 inline const_iterator begin() const;
│ │ │ │
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
│ │ │ │ +
446 inline const_iterator end() const;
│ │ │ │ +
447
│ │ │ │ +
457 inline void renumberLocal();
│ │ │ │ +
458
│ │ │ │ +
465 inline int seqNo() const;
│ │ │ │ +
466
│ │ │ │ +
471 inline size_t size() const;
│ │ │ │
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 }
│ │ │ │ +
473 private:
│ │ │ │ +
475 ArrayList<IndexPair,N> localIndices_;
│ │ │ │ +
477 ArrayList<IndexPair,N> newIndices_;
│ │ │ │ + │ │ │ │ +
481 int seqNo_;
│ │ │ │ +
483 bool deletedEntries_;
│ │ │ │ +
488 inline void merge();
│ │ │ │ +
489 };
│ │ │ │
│ │ │ │ +
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 }
│ │ │ │ -
│ │ │ │ +
497 template<class TG, class TL, int N>
│ │ │ │ +
498 std::ostream& operator<<(std::ostream& os, const ParallelIndexSet<TG,TL,N>& indexSet);
│ │ │ │ +
499
│ │ │ │ +
505 template<class I>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
507 {
│ │ │ │ +
508 public:
│ │ │ │ + │ │ │ │ +
513
│ │ │ │ + │ │ │ │ +
518
│ │ │ │ + │ │ │ │
523
│ │ │ │ -
524 private:
│ │ │ │ -
526 SLListIterator<T,A> beforeIterator_;
│ │ │ │ -
528 SLListIterator<T,A> iterator_;
│ │ │ │ -
529 };
│ │ │ │ -
│ │ │ │ + │ │ │ │ +
528
│ │ │ │ + │ │ │ │
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 }
│ │ │ │ -
│ │ │ │ +
537 GlobalLookupIndexSet(const ParallelIndexSet& indexset, std::size_t size);
│ │ │ │ +
538
│ │ │ │ + │ │ │ │ +
545
│ │ │ │ + │ │ │ │
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 }
│ │ │ │ -
│ │ │ │ +
560 inline const IndexPair&
│ │ │ │ +
561 operator[](const GlobalIndex& global) const;
│ │ │ │ +
562
│ │ │ │ +
566 inline const IndexPair*
│ │ │ │ +
567 pair(const std::size_t& local) const;
│ │ │ │ +
568
│ │ │ │ +
573 inline const_iterator begin() const;
│ │ │ │ +
574
│ │ │ │ +
579 inline const_iterator end() const;
│ │ │ │ +
580
│ │ │ │ +
587 inline int seqNo() const;
│ │ │ │ +
588
│ │ │ │ +
593 inline size_t size() const;
│ │ │ │ +
594 private:
│ │ │ │ +
598 const ParallelIndexSet& indexSet_;
│ │ │ │ +
599
│ │ │ │ +
603 std::size_t size_;
│ │ │ │ +
604
│ │ │ │ +
608 std::vector<const IndexPair*> indices_;
│ │ │ │
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 }
│ │ │ │ +
610 };
│ │ │ │ +
│ │ │ │ +
611
│ │ │ │ +
612
│ │ │ │ +
613 template<typename T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
615 {
│ │ │ │ +
│ │ │ │ +
616 static bool compare([[maybe_unused]] const T& t1, [[maybe_unused]] const T& t2)
│ │ │ │ +
617 {
│ │ │ │ +
618 return false;
│ │ │ │ +
619 }
│ │ │ │ +
│ │ │ │ +
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;
│ │ │ │ +
622 template<class TG, class TL>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
624 {
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
626 {
│ │ │ │ +
627 return i1.global()<i2.global() || (i1.global()==i2.global() &&
│ │ │ │ + │ │ │ │ +
629 i2.local()));
│ │ │ │ +
630 }
│ │ │ │ +
│ │ │ │ +
631 };
│ │ │ │ +
│ │ │ │ +
632
│ │ │ │ +
633
│ │ │ │ +
634
│ │ │ │ +
635 template<class TG, class TL>
│ │ │ │ +
│ │ │ │ +
636 inline std::ostream& operator<<(std::ostream& os, const IndexPair<TG,TL>& pair)
│ │ │ │ +
637 {
│ │ │ │ +
638 os<<"{global="<<pair.global_<<", local="<<pair.local_<<"}";
│ │ │ │ +
639 return os;
│ │ │ │
640 }
│ │ │ │
│ │ │ │
641
│ │ │ │ -
642 template<typename T, class A>
│ │ │ │ +
642 template<class TG, class TL, int N>
│ │ │ │
│ │ │ │ -
643 inline void SLList<T,A>::push_back(const MemberType& item)
│ │ │ │ +
643 inline std::ostream& operator<<(std::ostream& os, const ParallelIndexSet<TG,TL,N>& indexSet)
│ │ │ │
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_;
│ │ │ │ +
645 typedef typename ParallelIndexSet<TG,TL,N>::const_iterator Iterator;
│ │ │ │ +
646 Iterator end = indexSet.end();
│ │ │ │ +
647 os<<"{";
│ │ │ │ +
648 for(Iterator index = indexSet.begin(); index != end; ++index)
│ │ │ │ +
649 os<<*index<<" ";
│ │ │ │ +
650 os<<"}";
│ │ │ │ +
651 return os;
│ │ │ │ +
652
│ │ │ │
653 }
│ │ │ │
│ │ │ │
654
│ │ │ │ -
655 template<typename T, class A>
│ │ │ │ -
656 inline void SLList<T,A>::insertAfter(Element* current, const T& item)
│ │ │ │ +
655 template<class TG, class TL>
│ │ │ │ +
│ │ │ │ +
656 inline bool operator==(const IndexPair<TG,TL>& a, const IndexPair<TG,TL>& b)
│ │ │ │
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 }
│ │ │ │ +
658 return a.global_==b.global_;
│ │ │ │ +
659 }
│ │ │ │ +
│ │ │ │ +
660
│ │ │ │ +
661 template<class TG, class TL>
│ │ │ │ +
│ │ │ │ +
662 inline bool operator!=(const IndexPair<TG,TL>& a, const IndexPair<TG,TL>& b)
│ │ │ │ +
663 {
│ │ │ │ +
664 return a.global_!=b.global_;
│ │ │ │ +
665 }
│ │ │ │
│ │ │ │ +
666
│ │ │ │ +
667 template<class TG, class TL>
│ │ │ │ +
│ │ │ │ +
668 inline bool operator<(const IndexPair<TG,TL>& a, const IndexPair<TG,TL>& b)
│ │ │ │ +
669 {
│ │ │ │ +
670 return a.global_<b.global_;
│ │ │ │ +
671 }
│ │ │ │ +
│ │ │ │ +
672
│ │ │ │ +
673 template<class TG, class TL>
│ │ │ │ +
│ │ │ │ +
674 inline bool operator>(const IndexPair<TG,TL>& a, const IndexPair<TG,TL>& b)
│ │ │ │ +
675 {
│ │ │ │ +
676 return a.global_>b.global_;
│ │ │ │ +
677 }
│ │ │ │ +
│ │ │ │ +
678
│ │ │ │ +
679 template<class TG, class TL>
│ │ │ │ +
│ │ │ │ +
680 inline bool operator<=(const IndexPair<TG,TL>& a, const IndexPair<TG,TL>& b)
│ │ │ │ +
681 {
│ │ │ │ +
682 return a.global_<=b.global_;
│ │ │ │ +
683 }
│ │ │ │ +
│ │ │ │ +
684
│ │ │ │ +
685 template<class TG, class TL>
│ │ │ │ +
│ │ │ │ +
686 inline bool operator >=(const IndexPair<TG,TL>& a, const IndexPair<TG,TL>& b)
│ │ │ │ +
687 {
│ │ │ │ +
688 return a.global_>=b.global_;
│ │ │ │ +
689 }
│ │ │ │ +
│ │ │ │ +
690
│ │ │ │ +
691 template<class TG, class TL>
│ │ │ │ +
│ │ │ │ +
692 inline bool operator==(const IndexPair<TG,TL>& a, const TG& b)
│ │ │ │ +
693 {
│ │ │ │ +
694 return a.global_==b;
│ │ │ │ +
695 }
│ │ │ │ +
│ │ │ │ +
696
│ │ │ │ +
697 template<class TG, class TL>
│ │ │ │ +
│ │ │ │ +
698 inline bool operator!=(const IndexPair<TG,TL>& a, const TG& b)
│ │ │ │ +
699 {
│ │ │ │ +
700 return a.global_!=b;
│ │ │ │ +
701 }
│ │ │ │ +
│ │ │ │ +
702
│ │ │ │ +
703 template<class TG, class TL>
│ │ │ │ +
│ │ │ │ +
704 inline bool operator<(const IndexPair<TG,TL>& a, const TG& b)
│ │ │ │ +
705 {
│ │ │ │ +
706 return a.global_<b;
│ │ │ │ +
707 }
│ │ │ │ +
│ │ │ │ +
708
│ │ │ │ +
709 template<class TG, class TL>
│ │ │ │ +
│ │ │ │ +
710 inline bool operator>(const IndexPair<TG,TL>& a, const TG& b)
│ │ │ │ +
711 {
│ │ │ │ +
712 return a.global_>b;
│ │ │ │ +
713 }
│ │ │ │ +
│ │ │ │ +
714
│ │ │ │ +
715 template<class TG, class TL>
│ │ │ │ +
│ │ │ │ +
716 inline bool operator<=(const IndexPair<TG,TL>& a, const TG& b)
│ │ │ │ +
717 {
│ │ │ │ +
718 return a.global_<=b;
│ │ │ │ +
719 }
│ │ │ │ +
│ │ │ │ +
720
│ │ │ │ +
721 template<class TG, class TL>
│ │ │ │ +
│ │ │ │ +
722 inline bool operator >=(const IndexPair<TG,TL>& a, const TG& b)
│ │ │ │ +
723 {
│ │ │ │ +
724 return a.global_>=b;
│ │ │ │ +
725 }
│ │ │ │ +
│ │ │ │ +
726
│ │ │ │ +
727#ifndef DOXYGEN
│ │ │ │ +
728
│ │ │ │ +
729 template<class TG, class TL>
│ │ │ │ +
730 IndexPair<TG,TL>::IndexPair(const TG& global, const TL& local)
│ │ │ │ +
731 : global_(global), local_(local){}
│ │ │ │ +
732
│ │ │ │ +
733 template<class TG, class TL>
│ │ │ │ +
734 IndexPair<TG,TL>::IndexPair(const TG& global)
│ │ │ │ +
735 : global_(global), local_(){}
│ │ │ │
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_;
│ │ │ │ +
737 template<class TG, class TL>
│ │ │ │ + │ │ │ │ +
739 : global_(), local_(){}
│ │ │ │ +
740
│ │ │ │ +
741 template<class TG, class TL>
│ │ │ │ +
742 inline const TG& IndexPair<TG,TL>::global() const {
│ │ │ │ +
743 return global_;
│ │ │ │ +
744 }
│ │ │ │ +
745
│ │ │ │ +
746 template<class TG, class TL>
│ │ │ │ +
747 inline TL& IndexPair<TG,TL>::local() {
│ │ │ │ +
748 return local_;
│ │ │ │ +
749 }
│ │ │ │ +
750
│ │ │ │ +
751 template<class TG, class TL>
│ │ │ │ +
752 inline const TL& IndexPair<TG,TL>::local() const {
│ │ │ │ +
753 return local_;
│ │ │ │ +
754 }
│ │ │ │ +
755
│ │ │ │ +
756 template<class TG, class TL>
│ │ │ │ +
757 inline void IndexPair<TG,TL>::setLocal(int local){
│ │ │ │ +
758 local_=local;
│ │ │ │
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
│ │ │ │ +
761 template<class TG, class TL, int N>
│ │ │ │ + │ │ │ │ +
763 : state_(GROUND), seqNo_(0), deletedEntries_()
│ │ │ │ +
764 {}
│ │ │ │ +
765
│ │ │ │ +
766 template<class TG, class TL, int N>
│ │ │ │ + │ │ │ │ +
768 {
│ │ │ │ +
769
│ │ │ │ +
770 // Checks in unproductive code
│ │ │ │ +
771#ifndef NDEBUG
│ │ │ │ +
772 if(state_!=GROUND)
│ │ │ │ +
773 DUNE_THROW(InvalidIndexSetState,
│ │ │ │ +
774 "IndexSet has to be in GROUND state, when "
│ │ │ │ +
775 << "beginResize() is called!");
│ │ │ │ +
776#endif
│ │ │ │ +
777
│ │ │ │ +
778 state_ = RESIZE;
│ │ │ │ +
779 deletedEntries_ = false;
│ │ │ │ +
780 }
│ │ │ │ +
781
│ │ │ │ +
782 template<class TG, class TL, int N>
│ │ │ │ +
783 inline void ParallelIndexSet<TG,TL,N>::add(const GlobalIndex& global)
│ │ │ │ +
784 {
│ │ │ │ +
785 // Checks in unproductive code
│ │ │ │ +
786#ifndef NDEBUG
│ │ │ │ +
787 if(state_ != RESIZE)
│ │ │ │ +
788 DUNE_THROW(InvalidIndexSetState, "Indices can only be added "
│ │ │ │ +
789 <<"while in RESIZE state!");
│ │ │ │ +
790#endif
│ │ │ │ +
791 newIndices_.push_back(IndexPair(global));
│ │ │ │ +
792 }
│ │ │ │ +
793
│ │ │ │ +
794 template<class TG, class TL, int N>
│ │ │ │ +
795 inline void ParallelIndexSet<TG,TL,N>::add(const TG& global, const TL& local)
│ │ │ │ +
796 {
│ │ │ │ +
797 // Checks in unproductive code
│ │ │ │ +
798#ifndef NDEBUG
│ │ │ │ +
799 if(state_ != RESIZE)
│ │ │ │ +
800 DUNE_THROW(InvalidIndexSetState, "Indices can only be added "
│ │ │ │ +
801 <<"while in RESIZE state!");
│ │ │ │ +
802#endif
│ │ │ │ +
803 newIndices_.push_back(IndexPair(global,local));
│ │ │ │ +
804 }
│ │ │ │ +
805
│ │ │ │ +
806 template<class TG, class TL, int N>
│ │ │ │ +
807 inline void ParallelIndexSet<TG,TL,N>::markAsDeleted(const iterator& global)
│ │ │ │ +
808 {
│ │ │ │ +
809 // Checks in unproductive code
│ │ │ │ +
810#ifndef NDEBUG
│ │ │ │ +
811 if(state_ != RESIZE)
│ │ │ │ +
812 DUNE_THROW(InvalidIndexSetState, "Indices can only be removed "
│ │ │ │ +
813 <<"while in RESIZE state!");
│ │ │ │ +
814#endif
│ │ │ │ +
815 deletedEntries_ = true;
│ │ │ │ +
816
│ │ │ │ +
817 global.markAsDeleted();
│ │ │ │ +
818 }
│ │ │ │ +
819
│ │ │ │ +
820 template<class TG, class TL, int N>
│ │ │ │ + │ │ │ │ +
822 // Checks in unproductive code
│ │ │ │ +
823#ifndef NDEBUG
│ │ │ │ +
824 if(state_ != RESIZE)
│ │ │ │ +
825 DUNE_THROW(InvalidIndexSetState, "endResize called while not "
│ │ │ │ +
826 <<"in RESIZE state!");
│ │ │ │ +
827#endif
│ │ │ │ +
828
│ │ │ │ +
829 std::sort(newIndices_.begin(), newIndices_.end(), IndexSetSortFunctor<TG,TL>());
│ │ │ │ +
830 merge();
│ │ │ │ +
831 seqNo_++;
│ │ │ │ +
832 state_ = GROUND;
│ │ │ │ +
833 }
│ │ │ │ +
834
│ │ │ │ +
835
│ │ │ │ +
836 template<class TG, class TL, int N>
│ │ │ │ +
837 inline void ParallelIndexSet<TG,TL,N>::merge(){
│ │ │ │ +
838 if(localIndices_.size()==0)
│ │ │ │ +
839 {
│ │ │ │ +
840 localIndices_=newIndices_;
│ │ │ │ +
841 newIndices_.clear();
│ │ │ │ +
842 }
│ │ │ │ +
843 else if(newIndices_.size()>0 || deletedEntries_)
│ │ │ │ +
844 {
│ │ │ │ +
845 ArrayList<IndexPair,N> tempPairs;
│ │ │ │ +
846
│ │ │ │ +
847 auto old = localIndices_.begin();
│ │ │ │ +
848 auto added = newIndices_.begin();
│ │ │ │ +
849 const auto endold = localIndices_.end();
│ │ │ │ +
850 const auto endadded = newIndices_.end();
│ │ │ │ +
851
│ │ │ │ +
852 while(old != endold && added!= endadded)
│ │ │ │ +
853 {
│ │ │ │ +
854 if(old->local().state()==DELETED) {
│ │ │ │ +
855 old.eraseToHere();
│ │ │ │ +
856 }
│ │ │ │ +
857 else
│ │ │ │ +
858 {
│ │ │ │ +
859 if(old->global() < added->global() ||
│ │ │ │ +
860 (old->global() == added->global()
│ │ │ │ +
861 && LocalIndexComparator<TL>::compare(old->local(),added->local())))
│ │ │ │ +
862 {
│ │ │ │ +
863 tempPairs.push_back(*old);
│ │ │ │ +
864 old.eraseToHere();
│ │ │ │ +
865 continue;
│ │ │ │ +
866 }else
│ │ │ │ +
867 {
│ │ │ │ +
868 tempPairs.push_back(*added);
│ │ │ │ +
869 added.eraseToHere();
│ │ │ │ +
870 }
│ │ │ │ +
871 }
│ │ │ │ +
872 }
│ │ │ │ +
873
│ │ │ │ +
874 while(old != endold)
│ │ │ │ +
875 {
│ │ │ │ +
876 if(old->local().state()!=DELETED) {
│ │ │ │ +
877 tempPairs.push_back(*old);
│ │ │ │ +
878 }
│ │ │ │ +
879 old.eraseToHere();
│ │ │ │ +
880 }
│ │ │ │ +
881
│ │ │ │ +
882 while(added!= endadded)
│ │ │ │ +
883 {
│ │ │ │ +
884 tempPairs.push_back(*added);
│ │ │ │ +
885 added.eraseToHere();
│ │ │ │ +
886 }
│ │ │ │ +
887 localIndices_ = tempPairs;
│ │ │ │ +
888 }
│ │ │ │ +
889 }
│ │ │ │ +
890
│ │ │ │ +
891
│ │ │ │ +
892 template<class TG, class TL, int N>
│ │ │ │ +
893 inline const IndexPair<TG,TL>&
│ │ │ │ +
894 ParallelIndexSet<TG,TL,N>::at(const TG& global) const
│ │ │ │ +
895 {
│ │ │ │ +
896 // perform a binary search
│ │ │ │ +
897 int low=0, high=localIndices_.size()-1, probe=-1;
│ │ │ │ +
898
│ │ │ │ +
899 while(low<high)
│ │ │ │ +
900 {
│ │ │ │ +
901 probe = (high + low) / 2;
│ │ │ │ +
902 if(global <= localIndices_[probe].global())
│ │ │ │ +
903 high = probe;
│ │ │ │ +
904 else
│ │ │ │ +
905 low = probe+1;
│ │ │ │ +
906 }
│ │ │ │ +
907
│ │ │ │ +
908 if(probe==-1)
│ │ │ │ +
909 DUNE_THROW(RangeError, "No entries!");
│ │ │ │ +
910
│ │ │ │ +
911 if( localIndices_[low].global() != global)
│ │ │ │ +
912 DUNE_THROW(RangeError, "Could not find entry of "<<global);
│ │ │ │ +
913 else
│ │ │ │ +
914 return localIndices_[low];
│ │ │ │ +
915 }
│ │ │ │ +
916
│ │ │ │ +
917 template<class TG, class TL, int N>
│ │ │ │ +
918 inline const IndexPair<TG,TL>&
│ │ │ │ +
919 ParallelIndexSet<TG,TL,N>::operator[](const TG& global) const
│ │ │ │ +
920 {
│ │ │ │ +
921 // perform a binary search
│ │ │ │ +
922 int low=0, high=localIndices_.size()-1, probe=-1;
│ │ │ │ +
923
│ │ │ │ +
924 while(low<high)
│ │ │ │ +
925 {
│ │ │ │ +
926 probe = (high + low) / 2;
│ │ │ │ +
927 if(global <= localIndices_[probe].global())
│ │ │ │ +
928 high = probe;
│ │ │ │ +
929 else
│ │ │ │ +
930 low = probe+1;
│ │ │ │ +
931 }
│ │ │ │ +
932
│ │ │ │ +
933 return localIndices_[low];
│ │ │ │ +
934 }
│ │ │ │ +
935 template<class TG, class TL, int N>
│ │ │ │ +
936 inline IndexPair<TG,TL>& ParallelIndexSet<TG,TL,N>::at(const TG& global)
│ │ │ │ +
937 {
│ │ │ │ +
938 // perform a binary search
│ │ │ │ +
939 int low=0, high=localIndices_.size()-1, probe=-1;
│ │ │ │ +
940
│ │ │ │ +
941 while(low<high)
│ │ │ │ +
942 {
│ │ │ │ +
943 probe = (high + low) / 2;
│ │ │ │ +
944 if(localIndices_[probe].global() >= global)
│ │ │ │ +
945 high = probe;
│ │ │ │ +
946 else
│ │ │ │ +
947 low = probe+1;
│ │ │ │ +
948 }
│ │ │ │ +
949
│ │ │ │ +
950 if(probe==-1)
│ │ │ │ +
951 DUNE_THROW(RangeError, "No entries!");
│ │ │ │ +
952
│ │ │ │ +
953 if( localIndices_[low].global() != global)
│ │ │ │ +
954 DUNE_THROW(RangeError, "Could not find entry of "<<global);
│ │ │ │ +
955 else
│ │ │ │ +
956 return localIndices_[low];
│ │ │ │ +
957 }
│ │ │ │ +
958
│ │ │ │ +
959 template<class TG, class TL, int N>
│ │ │ │ +
960 inline bool ParallelIndexSet<TG,TL,N>::exists (const TG& global) const
│ │ │ │ +
961 {
│ │ │ │ +
962 // perform a binary search
│ │ │ │ +
963 int low=0, high=localIndices_.size()-1, probe=-1;
│ │ │ │ +
964
│ │ │ │ +
965 while(low<high)
│ │ │ │ +
966 {
│ │ │ │ +
967 probe = (high + low) / 2;
│ │ │ │ +
968 if(localIndices_[probe].global() >= global)
│ │ │ │ +
969 high = probe;
│ │ │ │ +
970 else
│ │ │ │ +
971 low = probe+1;
│ │ │ │ +
972 }
│ │ │ │ +
973
│ │ │ │ +
974 if(probe==-1)
│ │ │ │ +
975 return false;
│ │ │ │ +
976
│ │ │ │ +
977 if( localIndices_[low].global() != global)
│ │ │ │ +
978 return false;
│ │ │ │ +
979 return true;
│ │ │ │ +
980 }
│ │ │ │ +
981
│ │ │ │ +
982 template<class TG, class TL, int N>
│ │ │ │ +
983 inline IndexPair<TG,TL>& ParallelIndexSet<TG,TL,N>::operator[](const TG& global)
│ │ │ │ +
984 {
│ │ │ │ +
985 // perform a binary search
│ │ │ │ +
986 int low=0, high=localIndices_.size()-1, probe=-1;
│ │ │ │ +
987
│ │ │ │ +
988 while(low<high)
│ │ │ │ +
989 {
│ │ │ │ +
990 probe = (high + low) / 2;
│ │ │ │ +
991 if(localIndices_[probe].global() >= global)
│ │ │ │ +
992 high = probe;
│ │ │ │ +
993 else
│ │ │ │ +
994 low = probe+1;
│ │ │ │ +
995 }
│ │ │ │ +
996
│ │ │ │ +
997 return localIndices_[low];
│ │ │ │ +
998 }
│ │ │ │ +
999 template<class TG, class TL, int N>
│ │ │ │ +
1000 inline typename ParallelIndexSet<TG,TL,N>::iterator
│ │ │ │ + │ │ │ │ +
1002 {
│ │ │ │ +
1003 return iterator(*this, localIndices_.begin());
│ │ │ │ +
1004 }
│ │ │ │ +
1005
│ │ │ │ +
1006
│ │ │ │ +
1007 template<class TG, class TL, int N>
│ │ │ │ +
1008 inline typename ParallelIndexSet<TG,TL,N>::iterator
│ │ │ │ + │ │ │ │ +
1010 {
│ │ │ │ +
1011 return iterator(*this,localIndices_.end());
│ │ │ │ +
1012 }
│ │ │ │ +
1013
│ │ │ │ +
1014 template<class TG, class TL, int N>
│ │ │ │ +
1015 inline typename ParallelIndexSet<TG,TL,N>::const_iterator
│ │ │ │ + │ │ │ │ +
1017 {
│ │ │ │ +
1018 return localIndices_.begin();
│ │ │ │ +
1019 }
│ │ │ │ +
1020
│ │ │ │ +
1021
│ │ │ │ +
1022 template<class TG, class TL, int N>
│ │ │ │ +
1023 inline typename ParallelIndexSet<TG,TL,N>::const_iterator
│ │ │ │ + │ │ │ │ +
1025 {
│ │ │ │ +
1026 return localIndices_.end();
│ │ │ │ +
1027 }
│ │ │ │ +
1028
│ │ │ │ +
1029 template<class TG, class TL, int N>
│ │ │ │ + │ │ │ │ +
1031#ifndef NDEBUG
│ │ │ │ +
1032 if(state_==RESIZE)
│ │ │ │ +
1033 DUNE_THROW(InvalidIndexSetState, "IndexSet has to be in "
│ │ │ │ +
1034 <<"GROUND state for renumberLocal()");
│ │ │ │ +
1035#endif
│ │ │ │ +
1036
│ │ │ │ +
1037 const auto end_ = end();
│ │ │ │ +
1038 uint32_t index=0;
│ │ │ │ +
1039
│ │ │ │ +
1040 for(auto pair=begin(); pair!=end_; index++, ++pair)
│ │ │ │ +
1041 pair->local()=index;
│ │ │ │ +
1042 }
│ │ │ │ +
1043
│ │ │ │ +
1044 template<class TG, class TL, int N>
│ │ │ │ +
1045 inline int ParallelIndexSet<TG,TL,N>::seqNo() const
│ │ │ │ +
1046 {
│ │ │ │ +
1047 return seqNo_;
│ │ │ │ +
1048 }
│ │ │ │ +
1049
│ │ │ │ +
1050 template<class TG, class TL, int N>
│ │ │ │ +
1051 inline size_t ParallelIndexSet<TG,TL,N>::size() const
│ │ │ │ +
1052 {
│ │ │ │ +
1053 return localIndices_.size();
│ │ │ │ +
1054 }
│ │ │ │ +
1055
│ │ │ │ +
1056 template<class I>
│ │ │ │ + │ │ │ │ +
1058 std::size_t size)
│ │ │ │ +
1059 : indexSet_(indexset), size_(size),
│ │ │ │ +
1060 indices_(size_, static_cast<const IndexPair*>(0))
│ │ │ │ +
1061 {
│ │ │ │ +
1062 const_iterator end_ = indexSet_.end();
│ │ │ │ +
1063
│ │ │ │ +
1064 for(const_iterator pair = indexSet_.begin(); pair!=end_; ++pair) {
│ │ │ │ +
1065 assert(pair->local()<size_);
│ │ │ │ +
1066 indices_[pair->local()] = &(*pair);
│ │ │ │ +
1067 }
│ │ │ │ +
1068 }
│ │ │ │ +
1069
│ │ │ │ +
1070 template<class I>
│ │ │ │ + │ │ │ │ +
1072 : indexSet_(indexset), size_(0)
│ │ │ │ +
1073 {
│ │ │ │ +
1074 const_iterator end_ = indexSet_.end();
│ │ │ │ +
1075 for(const_iterator pair = indexSet_.begin(); pair!=end_; ++pair)
│ │ │ │ +
1076 size_=std::max(size_,static_cast<std::size_t>(pair->local()));
│ │ │ │ +
1077
│ │ │ │ +
1078 indices_.resize(++size_, 0);
│ │ │ │ +
1079
│ │ │ │ +
1080 for(const_iterator pair = indexSet_.begin(); pair!=end_; ++pair)
│ │ │ │ +
1081 indices_[pair->local()] = &(*pair);
│ │ │ │ +
1082 }
│ │ │ │ +
1083
│ │ │ │ +
1084 template<class I>
│ │ │ │ + │ │ │ │ +
1086 {}
│ │ │ │ +
1087
│ │ │ │ +
1088 template<class I>
│ │ │ │ +
1089 inline const IndexPair<typename I::GlobalIndex, typename I::LocalIndex>*
│ │ │ │ +
1090 GlobalLookupIndexSet<I>::pair(const std::size_t& local) const
│ │ │ │ +
1091 {
│ │ │ │ +
1092 return indices_[local];
│ │ │ │ +
1093 }
│ │ │ │ +
1094
│ │ │ │ +
1095 template<class I>
│ │ │ │ +
1096 inline const IndexPair<typename I::GlobalIndex, typename I::LocalIndex>&
│ │ │ │ +
1097 GlobalLookupIndexSet<I>::operator[](const GlobalIndex& global) const
│ │ │ │ +
1098 {
│ │ │ │ +
1099 return indexSet_[global];
│ │ │ │ +
1100 }
│ │ │ │ +
1101
│ │ │ │ +
1102 template<class I>
│ │ │ │ +
1103 typename I::const_iterator GlobalLookupIndexSet<I>::begin() const
│ │ │ │ +
1104 {
│ │ │ │ +
1105 return indexSet_.begin();
│ │ │ │ +
1106 }
│ │ │ │ +
1107
│ │ │ │ +
1108 template<class I>
│ │ │ │ +
1109 typename I::const_iterator GlobalLookupIndexSet<I>::end() const
│ │ │ │ +
1110 {
│ │ │ │ +
1111 return indexSet_.end();
│ │ │ │ +
1112 }
│ │ │ │ +
1113
│ │ │ │ +
1114 template<class I>
│ │ │ │ +
1115 inline size_t GlobalLookupIndexSet<I>::size() const
│ │ │ │ +
1116 {
│ │ │ │ +
1117 return size_;
│ │ │ │ +
1118 }
│ │ │ │ +
1119
│ │ │ │ +
1120 template<class I>
│ │ │ │ +
1121 inline int GlobalLookupIndexSet<I>::seqNo() const
│ │ │ │ +
1122 {
│ │ │ │ +
1123 return indexSet_.seqNo();
│ │ │ │ +
1124 }
│ │ │ │ +
1125
│ │ │ │ +
1126 template<typename TG, typename TL, int N, typename TG1, typename TL1, int N1>
│ │ │ │ +
1127 bool operator==(const ParallelIndexSet<TG,TL,N>& idxset,
│ │ │ │ +
1128 const ParallelIndexSet<TG1,TL1,N1>& idxset1)
│ │ │ │ +
1129 {
│ │ │ │ +
1130 if(idxset.size()!=idxset1.size())
│ │ │ │ +
1131 return false;
│ │ │ │ +
1132 typedef typename ParallelIndexSet<TG,TL,N>::const_iterator Iter;
│ │ │ │ +
1133 typedef typename ParallelIndexSet<TG1,TL1,N1>::const_iterator Iter1;
│ │ │ │ +
1134 Iter iter=idxset.begin();
│ │ │ │ +
1135 for(Iter1 iter1=idxset1.begin(); iter1 != idxset1.end(); ++iter, ++iter1) {
│ │ │ │ +
1136 if(iter1->global()!=iter->global())
│ │ │ │ +
1137 return false;
│ │ │ │ +
1138 typedef typename ParallelIndexSet<TG,TL,N>::LocalIndex PI;
│ │ │ │ +
1139 const PI& pi=iter->local(), pi1=iter1->local();
│ │ │ │ +
1140
│ │ │ │ +
1141 if(pi!=pi1)
│ │ │ │ +
1142 return false;
│ │ │ │ +
1143 }
│ │ │ │ +
1144 return true;
│ │ │ │ +
1145 }
│ │ │ │ +
1146
│ │ │ │ +
1147 template<typename TG, typename TL, int N, typename TG1, typename TL1, int N1>
│ │ │ │ +
1148 bool operator!=(const ParallelIndexSet<TG,TL,N>& idxset,
│ │ │ │ +
1149 const ParallelIndexSet<TG1,TL1,N1>& idxset1)
│ │ │ │ +
1150 {
│ │ │ │ +
1151 return !(idxset==idxset1);
│ │ │ │ +
1152 }
│ │ │ │ +
1153
│ │ │ │ +
1154
│ │ │ │ +
1155#endif // DOXYGEN
│ │ │ │ +
1156
│ │ │ │ +
1157}
│ │ │ │ +
1158#endif
│ │ │ │ +
Provides classes for use as the local index in ParallelIndexSet.
│ │ │ │ +
A few common exception classes.
│ │ │ │ +
Implements a random-access container that can efficiently change size (similar to std::deque)
│ │ │ │
std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x)
Definition bigunsignedint.hh:278
│ │ │ │ +
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
│ │ │ │ +
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:637
│ │ │ │ +
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:683
│ │ │ │ +
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:660
│ │ │ │ +
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:237
│ │ │ │ +
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:705
│ │ │ │ +
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:259
│ │ │ │ +
IndexPair & operator[](const GlobalIndex &global)
Find the index pair with a specific global id.
│ │ │ │ +
static constexpr int arraySize
The size of the individual arrays in the underlying ArrayList.
Definition indexset.hh:252
│ │ │ │ +
void beginResize()
Indicate that the index set is to be resized.
│ │ │ │ +
ParallelIndexSetState
The states the index set can be in.
Definition indexset.hh:181
│ │ │ │ +
void renumberLocal()
Renumbers the local index numbers.
│ │ │ │ +
bool exists(const GlobalIndex &global) const
Find the index pair with a specific global id.
│ │ │ │ +
size_t size() const
Get the total number (public and nonpublic) indices.
│ │ │ │ +
ArrayList< IndexPair, N >::const_iterator const_iterator
The constant iterator over the pairs.
Definition indexset.hh:296
│ │ │ │ +
bool operator()(const IndexPair< TG, TL > &i1, const IndexPair< TG, TL > &i2)
Definition indexset.hh:625
│ │ │ │ +
void add(const GlobalIndex &global)
Add an new index to the set.
│ │ │ │ +
const_iterator end() const
Get an iterator over the indices positioned after the last index.
│ │ │ │ +
const LocalIndex & local() const
Get the local index.
│ │ │ │ +
const IndexPair & at(const GlobalIndex &global) const
Find the index pair with a specific global id.
│ │ │ │ +
GlobalLookupIndexSet(const ParallelIndexSet &indexset)
Constructor.
│ │ │ │ +
TL LocalIndex
the type of the local index.
Definition indexset.hh:120
│ │ │ │ +
int seqNo() const
Get the internal sequence number.
│ │ │ │ +
static bool compare(const T &t1, const T &t2)
Definition indexset.hh:616
│ │ │ │ +
iterator begin()
Get an iterator over the indices positioned at the first index.
│ │ │ │ +
Dune::IndexPair< typename I::GlobalIndex, typename I::LocalIndex > IndexPair
Definition indexset.hh:529
│ │ │ │ +
iterator end()
Get an iterator over the indices positioned after the last index.
│ │ │ │ +
ParallelIndexSet::const_iterator const_iterator
The iterator over the index pairs.
Definition indexset.hh:527
│ │ │ │ +
const_iterator begin() const
Get an iterator over the indices positioned at the first index.
│ │ │ │ +
const IndexPair & operator[](const GlobalIndex &global) const
Find the index pair with a specific global id.
│ │ │ │ +
const ParallelIndexSetState & state()
Get the state the index set is in.
Definition indexset.hh:307
│ │ │ │ +
const_iterator begin() const
Get an iterator over the indices positioned at the first index.
│ │ │ │ +
const IndexPair & operator[](const GlobalIndex &global) const
Find the index pair with a specific global id.
│ │ │ │ +
IndexPair()
Construct a new Pair.
│ │ │ │ +
I ParallelIndexSet
The type of the index set.
Definition indexset.hh:512
│ │ │ │ +
TL LocalIndex
The type of the local index, e.g. ParallelLocalIndex.
Definition indexset.hh:239
│ │ │ │ +
void markAsDeleted(const iterator &position)
Mark an index as deleted.
│ │ │ │ +
ParallelIndexSet::LocalIndex LocalIndex
The type of the local index.
Definition indexset.hh:517
│ │ │ │ +
IndexPair(const GlobalIndex &global, const LocalIndex &local)
Constructs a new Pair.
│ │ │ │ +
void setLocal(int index)
Set the local index.
│ │ │ │ +
const GlobalIndex & global() const
Get the global index.
│ │ │ │ +
void add(const GlobalIndex &global, const LocalIndex &local)
Add an new index to the set.
│ │ │ │ +
const_iterator end() const
Get an iterator over the indices positioned after the last index.
│ │ │ │ +
IndexPair & at(const GlobalIndex &global)
Find the index pair with a specific global id.
│ │ │ │ +
ParallelIndexSet()
Constructor.
│ │ │ │ +
void endResize()
Indicate that the resizing finishes.
│ │ │ │ +
~GlobalLookupIndexSet()
Destructor.
│ │ │ │ +
const IndexPair * pair(const std::size_t &local) const
Get the index pair corresponding to a local index.
│ │ │ │ +
LocalIndex & local()
Get the local index.
│ │ │ │ +
size_t size() const
Get the total number (public and nonpublic) indices.
│ │ │ │ +
IndexPair(const GlobalIndex &global)
Constructs a new Pair.
│ │ │ │ +
TG GlobalIndex
the type of the global index. This type has to provide at least a operator< for sorting.
Definition indexset.hh:226
│ │ │ │ +
TG GlobalIndex
the type of the global index.
Definition indexset.hh:107
│ │ │ │ +
int seqNo() const
Get the internal sequence number.
│ │ │ │ +
iterator(ParallelIndexSet< TG, TL, N > &indexSet, const Father &father)
Definition indexset.hh:262
│ │ │ │ +
GlobalLookupIndexSet(const ParallelIndexSet &indexset, std::size_t size)
Constructor.
│ │ │ │ +
ParallelIndexSet::GlobalIndex GlobalIndex
The type of the global index.
Definition indexset.hh:522
│ │ │ │ +
Dune::IndexPair< GlobalIndex, LocalIndex > IndexPair
The type of the pair stored.
Definition indexset.hh:244
│ │ │ │ +
@ RESIZE
Indicates that the index set is currently being resized.
Definition indexset.hh:190
│ │ │ │ +
@ GROUND
The default mode. Indicates that the index set is ready to be used.
Definition indexset.hh:186
│ │ │ │ +
@ DELETED
Definition localindex.hh:28
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
Base class for stl conformant forward iterators.
Definition iteratorfacades.hh:141
│ │ │ │ -
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
│ │ │ │ +
A random access iterator for the Dune::ArrayList class.
Definition arraylist.hh:255
│ │ │ │ +
A constant random access iterator for the Dune::ArrayList class.
Definition arraylist.hh:370
│ │ │ │ +
A dynamically growing random access list.
Definition arraylist.hh:62
│ │ │ │ +
ConstArrayListIterator< MemberType, N, A > const_iterator
A constant random access iterator.
Definition arraylist.hh:110
│ │ │ │ +
A traits class describing the mapping of types onto MPI_Datatypes.
Definition mpitraits.hh:41
│ │ │ │ +
Default exception if a function was called while the object is not in a valid state for that function...
Definition exceptions.hh:281
│ │ │ │ + │ │ │ │ +
A pair consisting of a global and local index.
Definition indexset.hh:85
│ │ │ │ +
Exception indicating that the index set is not in the expected state.
Definition indexset.hh:205
│ │ │ │ +
Decorates an index set with the possibility to find a global index that is mapped to a specific local...
Definition indexset.hh:507
│ │ │ │ +
Manager class for the mapping between local indices and globally unique indices.
Definition indexset.hh:218
│ │ │ │ +
The iterator over the pairs.
Definition indexset.hh:257
│ │ │ │ +
Definition indexset.hh:615
│ │ │ │ +
Definition indexset.hh:624
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,800 +7,1116 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -sllist.hh │ │ │ │ │ + * parallel │ │ │ │ │ +indexset.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 (C) 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 │ │ │ │ │ + 5#ifndef DUNE_INDEXSET_HH │ │ │ │ │ + 6#define DUNE_INDEXSET_HH │ │ │ │ │ 7 │ │ │ │ │ - 8#include │ │ │ │ │ - 9#include │ │ │ │ │ - 10#include "iteratorfacades.hh" │ │ │ │ │ - 11#include │ │ │ │ │ + 8#include │ │ │ │ │ + 9#include │ │ │ │ │ + 10#include │ │ │ │ │ + 11#include │ │ │ │ │ 12 │ │ │ │ │ - 13namespace Dune │ │ │ │ │ - 14{ │ │ │ │ │ - 26 template │ │ │ │ │ - 27 class SLListIterator; │ │ │ │ │ - 28 │ │ │ │ │ - 29 template │ │ │ │ │ - 30 class SLListConstIterator; │ │ │ │ │ - 31 │ │ │ │ │ - 32 template │ │ │ │ │ - 33 class SLListModifyIterator; │ │ │ │ │ - 34 │ │ │ │ │ - 42 template > │ │ │ │ │ -43 class SLList │ │ │ │ │ - 44 { │ │ │ │ │ - 45 struct Element; │ │ │ │ │ - 46 friend class SLListIterator; │ │ │ │ │ - 47 friend class SLListConstIterator; │ │ │ │ │ - 48 │ │ │ │ │ - 49 public: │ │ │ │ │ - 50 │ │ │ │ │ -54 typedef typename A::size_type size_type; │ │ │ │ │ + 13#include "localindex.hh" │ │ │ │ │ + 14 │ │ │ │ │ + 15#include // for uint32_t │ │ │ │ │ + 16 │ │ │ │ │ + 17namespace Dune │ │ │ │ │ + 18{ │ │ │ │ │ + 28 // forward declarations │ │ │ │ │ + 29 │ │ │ │ │ + 30 template │ │ │ │ │ + 31 class IndexPair; │ │ │ │ │ + 32 │ │ │ │ │ + 38 template │ │ │ │ │ + 39 std::ostream& operator<<(std::ostream& os, const IndexPair& pair); │ │ │ │ │ + 40 │ │ │ │ │ + 41 template │ │ │ │ │ + 42 bool operator==(const IndexPair&, const IndexPair&); │ │ │ │ │ + 43 │ │ │ │ │ + 44 template │ │ │ │ │ + 45 bool operator!=(const IndexPair&, const IndexPair&); │ │ │ │ │ + 46 │ │ │ │ │ + 47 template │ │ │ │ │ + 48 bool operator<(const IndexPair&, const IndexPair&); │ │ │ │ │ + 49 │ │ │ │ │ + 50 template │ │ │ │ │ + 51 bool operator>(const IndexPair&, const IndexPair&); │ │ │ │ │ + 52 │ │ │ │ │ + 53 template │ │ │ │ │ + 54 bool operator<=(const IndexPair&, const IndexPair&); │ │ │ │ │ 55 │ │ │ │ │ -59 typedef T MemberType; │ │ │ │ │ - 60 │ │ │ │ │ -64 using Allocator = typename std::allocator_traits::template │ │ │ │ │ -rebind_alloc; │ │ │ │ │ - 65 │ │ │ │ │ -69 typedef SLListIterator iterator; │ │ │ │ │ + 56 template │ │ │ │ │ + 57 bool operator_>=(const IndexPair&, const IndexPair&); │ │ │ │ │ + 58 │ │ │ │ │ + 59 template │ │ │ │ │ + 60 bool operator==(const IndexPair&, const TG&); │ │ │ │ │ + 61 │ │ │ │ │ + 62 template │ │ │ │ │ + 63 bool operator!=(const IndexPair&, const TG&); │ │ │ │ │ + 64 │ │ │ │ │ + 65 template │ │ │ │ │ + 66 bool operator<(const IndexPair&, const TG&); │ │ │ │ │ + 67 │ │ │ │ │ + 68 template │ │ │ │ │ + 69 bool operator>(const IndexPair&, const TG&); │ │ │ │ │ 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; │ │ │ │ │ - 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; │ │ │ │ │ + 71 template │ │ │ │ │ + 72 bool operator<=(const IndexPair&, const TG&); │ │ │ │ │ + 73 │ │ │ │ │ + 74 template │ │ │ │ │ + 75 bool operator_>=(const IndexPair&, const TG&); │ │ │ │ │ + 76 │ │ │ │ │ + 77 template │ │ │ │ │ + 78 struct MPITraits; │ │ │ │ │ + 79 │ │ │ │ │ + 83 template │ │ │ │ │ +84 class IndexPair │ │ │ │ │ + 85 { │ │ │ │ │ + 86 friend std::ostream& operator<<<>(std::ostream&, const IndexPair&); │ │ │ │ │ + 87 friend bool operator==<>(const IndexPair&, const IndexPair&); │ │ │ │ │ + 88 friend bool operator!=<>(const IndexPair&, const IndexPair&); │ │ │ │ │ + 89 friend bool operator< <>(const IndexPair&, const IndexPair&); │ │ │ │ │ + 90 friend bool operator><>(const IndexPair&, const IndexPair&); │ │ │ │ │ + 91 friend bool operator<=<>(const IndexPair&, const IndexPair&); │ │ │ │ │ + 92 friend bool operator>=<>(const IndexPair&, const IndexPair&); │ │ │ │ │ + 93 friend bool operator==<>(const IndexPair&, const TG &); │ │ │ │ │ + 94 friend bool operator!=<>(const IndexPair&, const TG &); │ │ │ │ │ + 95 friend bool operator< <>(const IndexPair&, const TG &); │ │ │ │ │ + 96 friend bool operator> <>(const IndexPair&, const TG &); │ │ │ │ │ + 97 friend bool operator<=<>(const IndexPair&, const TG &); │ │ │ │ │ +98 friend bool operator>=<>(const IndexPair&, const TG &); │ │ │ │ │ + 99 friend struct MPITraits >; │ │ │ │ │ + 100 │ │ │ │ │ + 101 public: │ │ │ │ │ +107 typedef TG GlobalIndex; │ │ │ │ │ + 108 │ │ │ │ │ +120 typedef TL LocalIndex; │ │ │ │ │ + 121 │ │ │ │ │ +128 IndexPair(const GlobalIndex& global, const LocalIndex& local); │ │ │ │ │ + 129 │ │ │ │ │ +133 IndexPair(); │ │ │ │ │ +140 IndexPair(const GlobalIndex& global); │ │ │ │ │ + 141 │ │ │ │ │ +147 inline const GlobalIndex& global() 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; │ │ │ │ │ - 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 }; │ │ │ │ │ +154 inline LocalIndex& local(); │ │ │ │ │ + 155 │ │ │ │ │ +161 inline const LocalIndex& local() const; │ │ │ │ │ + 162 │ │ │ │ │ +168 inline void setLocal(int index); │ │ │ │ │ + 169 private: │ │ │ │ │ + 171 GlobalIndex global_; │ │ │ │ │ +173 LocalIndex local_; │ │ │ │ │ + 174 }; │ │ │ │ │ + 175 │ │ │ │ │ +180 enum ParallelIndexSetState │ │ │ │ │ + 181 { │ │ │ │ │ +186 GROUND, │ │ │ │ │ + 190 RESIZE │ │ │ │ │ +200 }; │ │ │ │ │ + 201 │ │ │ │ │ +205 class InvalidIndexSetState : public InvalidStateException {}; │ │ │ │ │ + 206 │ │ │ │ │ + 207 // Forward declaration │ │ │ │ │ + 208 template class GlobalLookupIndexSet; │ │ │ │ │ + 209 │ │ │ │ │ + 216 template │ │ │ │ │ +217 class ParallelIndexSet │ │ │ │ │ + 218 { │ │ │ │ │ + 219 friend class GlobalLookupIndexSet >; │ │ │ │ │ 220 │ │ │ │ │ - 225 void deleteNext(Element* current); │ │ │ │ │ - 226 │ │ │ │ │ - 231 void copyElements(const SLList& other); │ │ │ │ │ - 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 }; │ │ │ │ │ + 221 public: │ │ │ │ │ +226 typedef TG GlobalIndex; │ │ │ │ │ + 227 │ │ │ │ │ +239 typedef TL LocalIndex; │ │ │ │ │ + 240 │ │ │ │ │ +244 typedef Dune::IndexPair IndexPair; │ │ │ │ │ + 245 │ │ │ │ │ +252 constexpr static int arraySize = (N>0) ? N : 1; │ │ │ │ │ + 253 │ │ │ │ │ +255 class iterator : │ │ │ │ │ + 256 public ArrayList::iterator │ │ │ │ │ + 257 { │ │ │ │ │ + 258 typedef typename ArrayList::iterator │ │ │ │ │ +259 Father; │ │ │ │ │ + 260 friend class ParallelIndexSet; │ │ │ │ │ + 261 public: │ │ │ │ │ +262 iterator(ParallelIndexSet& indexSet, const Father& father) │ │ │ │ │ + 263 : Father(father), indexSet_(&indexSet) │ │ │ │ │ + 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 {} │ │ │ │ │ + 266 private: │ │ │ │ │ + 276 inline void markAsDeleted() const │ │ │ │ │ + 277 { │ │ │ │ │ + 278#ifndef NDEBUG │ │ │ │ │ + 279 if(indexSet_->state_ != RESIZE) │ │ │ │ │ + 280 DUNE_THROW(InvalidIndexSetState, "Indices can only be removed " │ │ │ │ │ + 281 <<"while in RESIZE state!"); │ │ │ │ │ + 282#endif │ │ │ │ │ + 283 Father::operator*().local().setState(DELETED); │ │ │ │ │ + 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 } │ │ │ │ │ - 308 │ │ │ │ │ -314 inline bool equals(const SLListIterator& other) const │ │ │ │ │ - 315 { │ │ │ │ │ - 316 return current_==other.current_; │ │ │ │ │ - 317 } │ │ │ │ │ + 287 ParallelIndexSet* indexSet_; │ │ │ │ │ + 288 │ │ │ │ │ + 289 }; │ │ │ │ │ + 290 │ │ │ │ │ + 291 │ │ │ │ │ + 292 │ │ │ │ │ + 294 typedef typename │ │ │ │ │ + 295 ArrayList::const_iterator │ │ │ │ │ +296 const_iterator; │ │ │ │ │ + 297 │ │ │ │ │ +301 ParallelIndexSet(); │ │ │ │ │ + 302 │ │ │ │ │ +307 inline const ParallelIndexSetState& state() │ │ │ │ │ + 308 { │ │ │ │ │ + 309 return state_; │ │ │ │ │ + 310 } │ │ │ │ │ + 311 │ │ │ │ │ +317 void beginResize(); │ │ │ │ │ 318 │ │ │ │ │ -324 inline bool equals(const SLListModifyIterator& other) const │ │ │ │ │ - 325 { │ │ │ │ │ - 326 return current_==other.iterator_.current_; │ │ │ │ │ - 327 } │ │ │ │ │ +327 inline void add(const GlobalIndex& global); │ │ │ │ │ 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 } │ │ │ │ │ +337 inline void add(const GlobalIndex& global, const LocalIndex& local); │ │ │ │ │ + 338 │ │ │ │ │ +346 inline void markAsDeleted(const iterator& position); │ │ │ │ │ 347 │ │ │ │ │ -353 inline void deleteNext() const │ │ │ │ │ - 354 { │ │ │ │ │ - 355 assert(list_); │ │ │ │ │ - 356 list_->deleteNext(current_); │ │ │ │ │ - 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; │ │ │ │ │ +360 void endResize(); │ │ │ │ │ + 361 │ │ │ │ │ + 372 inline IndexPair& │ │ │ │ │ +373 operator[](const GlobalIndex& global); │ │ │ │ │ 374 │ │ │ │ │ - 375 public: │ │ │ │ │ -376 inline SLListConstIterator() │ │ │ │ │ - 377 : current_(0) │ │ │ │ │ - 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_; │ │ │ │ │ - 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 }; │ │ │ │ │ + 384 inline IndexPair& │ │ │ │ │ +385 at(const GlobalIndex& global); │ │ │ │ │ + 386 │ │ │ │ │ + 396 inline bool │ │ │ │ │ +397 exists (const GlobalIndex& global) const; │ │ │ │ │ + 398 │ │ │ │ │ + 409 inline const IndexPair& │ │ │ │ │ +410 operator[](const GlobalIndex& global) const; │ │ │ │ │ + 411 │ │ │ │ │ + 421 inline const IndexPair& │ │ │ │ │ +422 at(const GlobalIndex& global) const; │ │ │ │ │ 423 │ │ │ │ │ - 427 template │ │ │ │ │ -428 class SLListModifyIterator : public Dune:: │ │ │ │ │ -ForwardIteratorFacade, T, T&, std::size_t> │ │ │ │ │ - 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 {} │ │ │ │ │ +428 inline iterator begin(); │ │ │ │ │ + 429 │ │ │ │ │ +434 inline iterator end(); │ │ │ │ │ + 435 │ │ │ │ │ +440 inline const_iterator begin() const; │ │ │ │ │ 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 │ │ │ │ │ +446 inline const_iterator end() const; │ │ │ │ │ + 447 │ │ │ │ │ +457 inline void renumberLocal(); │ │ │ │ │ + 458 │ │ │ │ │ +465 inline int seqNo() const; │ │ │ │ │ + 466 │ │ │ │ │ +471 inline size_t size() const; │ │ │ │ │ 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 } │ │ │ │ │ + 473 private: │ │ │ │ │ + 475 ArrayList localIndices_; │ │ │ │ │ + 477 ArrayList newIndices_; │ │ │ │ │ + 479 ParallelIndexSetState state_; │ │ │ │ │ + 481 int seqNo_; │ │ │ │ │ + 483 bool deletedEntries_; │ │ │ │ │ + 488 inline void merge(); │ │ │ │ │ + 489 }; │ │ │ │ │ + 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 } │ │ │ │ │ + 497 template │ │ │ │ │ + 498 std::ostream& operator<<(std::ostream& os, const │ │ │ │ │ +ParallelIndexSet& indexSet); │ │ │ │ │ + 499 │ │ │ │ │ + 505 template │ │ │ │ │ +506 class GlobalLookupIndexSet │ │ │ │ │ + 507 { │ │ │ │ │ + 508 public: │ │ │ │ │ +512 typedef I ParallelIndexSet; │ │ │ │ │ + 513 │ │ │ │ │ +517 typedef typename ParallelIndexSet::LocalIndex LocalIndex; │ │ │ │ │ + 518 │ │ │ │ │ +522 typedef typename ParallelIndexSet::GlobalIndex GlobalIndex; │ │ │ │ │ 523 │ │ │ │ │ - 524 private: │ │ │ │ │ - 526 SLListIterator beforeIterator_; │ │ │ │ │ - 528 SLListIterator iterator_; │ │ │ │ │ - 529 }; │ │ │ │ │ +527 typedef typename ParallelIndexSet::const_iterator const_iterator; │ │ │ │ │ + 528 │ │ │ │ │ +529 typedef Dune::IndexPair │ │ │ │ │ +IndexPair; │ │ │ │ │ 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 } │ │ │ │ │ +537 GlobalLookupIndexSet(const ParallelIndexSet& indexset, std::size_t size); │ │ │ │ │ + 538 │ │ │ │ │ +544 GlobalLookupIndexSet(const ParallelIndexSet& indexset); │ │ │ │ │ + 545 │ │ │ │ │ +549 ~GlobalLookupIndexSet(); │ │ │ │ │ 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 } │ │ │ │ │ + 560 inline const IndexPair& │ │ │ │ │ +561 operator[](const GlobalIndex& global) const; │ │ │ │ │ + 562 │ │ │ │ │ + 566 inline const IndexPair* │ │ │ │ │ +567 pair(const std::size_t& local) const; │ │ │ │ │ + 568 │ │ │ │ │ +573 inline const_iterator begin() const; │ │ │ │ │ + 574 │ │ │ │ │ +579 inline const_iterator end() const; │ │ │ │ │ + 580 │ │ │ │ │ +587 inline int seqNo() const; │ │ │ │ │ + 588 │ │ │ │ │ +593 inline size_t size() const; │ │ │ │ │ + 594 private: │ │ │ │ │ + 598 const ParallelIndexSet& indexSet_; │ │ │ │ │ + 599 │ │ │ │ │ + 603 std::size_t size_; │ │ │ │ │ + 604 │ │ │ │ │ + 608 std::vector indices_; │ │ │ │ │ 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) │ │ │ │ │ + 610 }; │ │ │ │ │ + 611 │ │ │ │ │ + 612 │ │ │ │ │ + 613 template │ │ │ │ │ +614 struct LocalIndexComparator │ │ │ │ │ + 615 { │ │ │ │ │ +616 static bool compare([[maybe_unused]] const T& t1, [[maybe_unused]] const T& │ │ │ │ │ +t2) │ │ │ │ │ + 617 { │ │ │ │ │ 618 return false; │ │ │ │ │ - 619 return true; │ │ │ │ │ - 620 } │ │ │ │ │ + 619 } │ │ │ │ │ + 620 }; │ │ │ │ │ 621 │ │ │ │ │ - 622 template │ │ │ │ │ -623 bool SLList::operator!=(const SLList& other) const │ │ │ │ │ + 622 template │ │ │ │ │ +623 struct IndexSetSortFunctor │ │ │ │ │ 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; │ │ │ │ │ +625 bool operator()(const IndexPair& i1, const IndexPair& i2) │ │ │ │ │ + 626 { │ │ │ │ │ + 627 return i1.global()::compare(i1.local(), │ │ │ │ │ + 629 i2.local())); │ │ │ │ │ + 630 } │ │ │ │ │ + 631 }; │ │ │ │ │ + 632 │ │ │ │ │ + 633 │ │ │ │ │ + 634 │ │ │ │ │ + 635 template │ │ │ │ │ +636 inline std::ostream& operator<<(std::ostream& os, const IndexPair& │ │ │ │ │ +pair) │ │ │ │ │ + 637 { │ │ │ │ │ + 638 os<<"{global="< │ │ │ │ │ -643 inline void SLList::push_back(const MemberType& item) │ │ │ │ │ + 642 template │ │ │ │ │ +643 inline std::ostream& operator<<(std::ostream& os, const │ │ │ │ │ +ParallelIndexSet& indexSet) │ │ │ │ │ 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_; │ │ │ │ │ + 645 typedef typename ParallelIndexSet::const_iterator Iterator; │ │ │ │ │ + 646 Iterator end = indexSet.end(); │ │ │ │ │ + 647 os<<"{"; │ │ │ │ │ + 648 for(Iterator index = indexSet.begin(); index != end; ++index) │ │ │ │ │ + 649 os<<*index<<" "; │ │ │ │ │ + 650 os<<"}"; │ │ │ │ │ + 651 return os; │ │ │ │ │ + 652 │ │ │ │ │ 653 } │ │ │ │ │ 654 │ │ │ │ │ - 655 template │ │ │ │ │ - 656 inline void SLList::insertAfter(Element* current, const T& item) │ │ │ │ │ + 655 template │ │ │ │ │ +656 inline bool operator==(const IndexPair& a, const IndexPair& │ │ │ │ │ +b) │ │ │ │ │ 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_; │ │ │ │ │ + 658 return a.global_==b.global_; │ │ │ │ │ + 659 } │ │ │ │ │ + 660 │ │ │ │ │ + 661 template │ │ │ │ │ +662 inline bool operator!=(const IndexPair& a, const IndexPair& │ │ │ │ │ +b) │ │ │ │ │ + 663 { │ │ │ │ │ + 664 return a.global_!=b.global_; │ │ │ │ │ + 665 } │ │ │ │ │ 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 } │ │ │ │ │ + 667 template │ │ │ │ │ +668 inline bool operator<(const IndexPair& a, const IndexPair& b) │ │ │ │ │ + 669 { │ │ │ │ │ + 670 return a.global_ │ │ │ │ │ +674 inline bool operator>(const IndexPair& a, const IndexPair& b) │ │ │ │ │ + 675 { │ │ │ │ │ + 676 return a.global_>b.global_; │ │ │ │ │ + 677 } │ │ │ │ │ + 678 │ │ │ │ │ + 679 template │ │ │ │ │ +680 inline bool operator<=(const IndexPair& a, const IndexPair& │ │ │ │ │ +b) │ │ │ │ │ + 681 { │ │ │ │ │ + 682 return a.global_<=b.global_; │ │ │ │ │ + 683 } │ │ │ │ │ + 684 │ │ │ │ │ + 685 template │ │ │ │ │ +686 inline bool operator_>=(const IndexPair& a, const IndexPair& │ │ │ │ │ +b) │ │ │ │ │ + 687 { │ │ │ │ │ + 688 return a.global_>=b.global_; │ │ │ │ │ + 689 } │ │ │ │ │ + 690 │ │ │ │ │ + 691 template │ │ │ │ │ +692 inline bool operator==(const IndexPair& a, const TG& b) │ │ │ │ │ + 693 { │ │ │ │ │ + 694 return a.global_==b; │ │ │ │ │ + 695 } │ │ │ │ │ + 696 │ │ │ │ │ + 697 template │ │ │ │ │ +698 inline bool operator!=(const IndexPair& a, const TG& b) │ │ │ │ │ + 699 { │ │ │ │ │ + 700 return a.global_!=b; │ │ │ │ │ + 701 } │ │ │ │ │ + 702 │ │ │ │ │ + 703 template │ │ │ │ │ +704 inline bool operator<(const IndexPair& a, const TG& b) │ │ │ │ │ + 705 { │ │ │ │ │ + 706 return a.global_ │ │ │ │ │ +710 inline bool operator>(const IndexPair& a, const TG& b) │ │ │ │ │ + 711 { │ │ │ │ │ + 712 return a.global_>b; │ │ │ │ │ + 713 } │ │ │ │ │ + 714 │ │ │ │ │ + 715 template │ │ │ │ │ +716 inline bool operator<=(const IndexPair& a, const TG& b) │ │ │ │ │ + 717 { │ │ │ │ │ + 718 return a.global_<=b; │ │ │ │ │ + 719 } │ │ │ │ │ + 720 │ │ │ │ │ + 721 template │ │ │ │ │ +722 inline bool operator_>=(const IndexPair& a, const TG& b) │ │ │ │ │ + 723 { │ │ │ │ │ + 724 return a.global_>=b; │ │ │ │ │ + 725 } │ │ │ │ │ + 726 │ │ │ │ │ + 727#ifndef DOXYGEN │ │ │ │ │ + 728 │ │ │ │ │ + 729 template │ │ │ │ │ + 730 IndexPair::IndexPair(const TG& global, const TL& local) │ │ │ │ │ + 731 : global_(global), local_(local){} │ │ │ │ │ + 732 │ │ │ │ │ + 733 template │ │ │ │ │ + 734 IndexPair::IndexPair(const TG& global) │ │ │ │ │ + 735 : global_(global), local_(){} │ │ │ │ │ 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_; │ │ │ │ │ + 737 template │ │ │ │ │ + 738 IndexPair::IndexPair() │ │ │ │ │ + 739 : global_(), local_(){} │ │ │ │ │ + 740 │ │ │ │ │ + 741 template │ │ │ │ │ + 742 inline const TG& IndexPair::global() const { │ │ │ │ │ + 743 return global_; │ │ │ │ │ + 744 } │ │ │ │ │ + 745 │ │ │ │ │ + 746 template │ │ │ │ │ + 747 inline TL& IndexPair::local() { │ │ │ │ │ + 748 return local_; │ │ │ │ │ + 749 } │ │ │ │ │ + 750 │ │ │ │ │ + 751 template │ │ │ │ │ + 752 inline const TL& IndexPair::local() const { │ │ │ │ │ + 753 return local_; │ │ │ │ │ + 754 } │ │ │ │ │ + 755 │ │ │ │ │ + 756 template │ │ │ │ │ + 757 inline void IndexPair::setLocal(int local){ │ │ │ │ │ + 758 local_=local; │ │ │ │ │ 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 │ │ │ │ │ + 761 template │ │ │ │ │ + 762 ParallelIndexSet::ParallelIndexSet() │ │ │ │ │ + 763 : state_(GROUND), seqNo_(0), deletedEntries_() │ │ │ │ │ + 764 {} │ │ │ │ │ + 765 │ │ │ │ │ + 766 template │ │ │ │ │ + 767 void ParallelIndexSet::beginResize() │ │ │ │ │ + 768 { │ │ │ │ │ + 769 │ │ │ │ │ + 770 // Checks in unproductive code │ │ │ │ │ + 771#ifndef NDEBUG │ │ │ │ │ + 772 if(state_!=GROUND) │ │ │ │ │ + 773 DUNE_THROW(InvalidIndexSetState, │ │ │ │ │ + 774 "IndexSet has to be in GROUND state, when " │ │ │ │ │ + 775 << "beginResize() is called!"); │ │ │ │ │ + 776#endif │ │ │ │ │ + 777 │ │ │ │ │ + 778 state_ = RESIZE; │ │ │ │ │ + 779 deletedEntries_ = false; │ │ │ │ │ + 780 } │ │ │ │ │ + 781 │ │ │ │ │ + 782 template │ │ │ │ │ + 783 inline void ParallelIndexSet::add(const GlobalIndex& global) │ │ │ │ │ + 784 { │ │ │ │ │ + 785 // Checks in unproductive code │ │ │ │ │ + 786#ifndef NDEBUG │ │ │ │ │ + 787 if(state_ != RESIZE) │ │ │ │ │ + 788 DUNE_THROW(InvalidIndexSetState, "Indices can only be added " │ │ │ │ │ + 789 <<"while in RESIZE state!"); │ │ │ │ │ + 790#endif │ │ │ │ │ + 791 newIndices_.push_back(IndexPair(global)); │ │ │ │ │ + 792 } │ │ │ │ │ + 793 │ │ │ │ │ + 794 template │ │ │ │ │ + 795 inline void ParallelIndexSet::add(const TG& global, const TL& │ │ │ │ │ +local) │ │ │ │ │ + 796 { │ │ │ │ │ + 797 // Checks in unproductive code │ │ │ │ │ + 798#ifndef NDEBUG │ │ │ │ │ + 799 if(state_ != RESIZE) │ │ │ │ │ + 800 DUNE_THROW(InvalidIndexSetState, "Indices can only be added " │ │ │ │ │ + 801 <<"while in RESIZE state!"); │ │ │ │ │ + 802#endif │ │ │ │ │ + 803 newIndices_.push_back(IndexPair(global,local)); │ │ │ │ │ + 804 } │ │ │ │ │ + 805 │ │ │ │ │ + 806 template │ │ │ │ │ + 807 inline void ParallelIndexSet::markAsDeleted(const iterator& │ │ │ │ │ +global) │ │ │ │ │ + 808 { │ │ │ │ │ + 809 // Checks in unproductive code │ │ │ │ │ + 810#ifndef NDEBUG │ │ │ │ │ + 811 if(state_ != RESIZE) │ │ │ │ │ + 812 DUNE_THROW(InvalidIndexSetState, "Indices can only be removed " │ │ │ │ │ + 813 <<"while in RESIZE state!"); │ │ │ │ │ + 814#endif │ │ │ │ │ + 815 deletedEntries_ = true; │ │ │ │ │ + 816 │ │ │ │ │ + 817 global.markAsDeleted(); │ │ │ │ │ + 818 } │ │ │ │ │ + 819 │ │ │ │ │ + 820 template │ │ │ │ │ + 821 void ParallelIndexSet::endResize() { │ │ │ │ │ + 822 // Checks in unproductive code │ │ │ │ │ + 823#ifndef NDEBUG │ │ │ │ │ + 824 if(state_ != RESIZE) │ │ │ │ │ + 825 DUNE_THROW(InvalidIndexSetState, "endResize called while not " │ │ │ │ │ + 826 <<"in RESIZE state!"); │ │ │ │ │ + 827#endif │ │ │ │ │ + 828 │ │ │ │ │ + 829 std::sort(newIndices_.begin(), newIndices_.end(), │ │ │ │ │ +IndexSetSortFunctor()); │ │ │ │ │ + 830 merge(); │ │ │ │ │ + 831 seqNo_++; │ │ │ │ │ + 832 state_ = GROUND; │ │ │ │ │ + 833 } │ │ │ │ │ + 834 │ │ │ │ │ + 835 │ │ │ │ │ + 836 template │ │ │ │ │ + 837 inline void ParallelIndexSet::merge(){ │ │ │ │ │ + 838 if(localIndices_.size()==0) │ │ │ │ │ + 839 { │ │ │ │ │ + 840 localIndices_=newIndices_; │ │ │ │ │ + 841 newIndices_.clear(); │ │ │ │ │ + 842 } │ │ │ │ │ + 843 else if(newIndices_.size()>0 || deletedEntries_) │ │ │ │ │ + 844 { │ │ │ │ │ + 845 ArrayList tempPairs; │ │ │ │ │ + 846 │ │ │ │ │ + 847 auto old = localIndices_.begin(); │ │ │ │ │ + 848 auto added = newIndices_.begin(); │ │ │ │ │ + 849 const auto endold = localIndices_.end(); │ │ │ │ │ + 850 const auto endadded = newIndices_.end(); │ │ │ │ │ + 851 │ │ │ │ │ + 852 while(old != endold && added!= endadded) │ │ │ │ │ + 853 { │ │ │ │ │ + 854 if(old->local().state()==DELETED) { │ │ │ │ │ + 855 old.eraseToHere(); │ │ │ │ │ + 856 } │ │ │ │ │ + 857 else │ │ │ │ │ + 858 { │ │ │ │ │ + 859 if(old->global() < added->global() || │ │ │ │ │ + 860 (old->global() == added->global() │ │ │ │ │ + 861 && LocalIndexComparator::compare(old->local(),added->local()))) │ │ │ │ │ + 862 { │ │ │ │ │ + 863 tempPairs.push_back(*old); │ │ │ │ │ + 864 old.eraseToHere(); │ │ │ │ │ + 865 continue; │ │ │ │ │ + 866 }else │ │ │ │ │ + 867 { │ │ │ │ │ + 868 tempPairs.push_back(*added); │ │ │ │ │ + 869 added.eraseToHere(); │ │ │ │ │ + 870 } │ │ │ │ │ + 871 } │ │ │ │ │ + 872 } │ │ │ │ │ + 873 │ │ │ │ │ + 874 while(old != endold) │ │ │ │ │ + 875 { │ │ │ │ │ + 876 if(old->local().state()!=DELETED) { │ │ │ │ │ + 877 tempPairs.push_back(*old); │ │ │ │ │ + 878 } │ │ │ │ │ + 879 old.eraseToHere(); │ │ │ │ │ + 880 } │ │ │ │ │ + 881 │ │ │ │ │ + 882 while(added!= endadded) │ │ │ │ │ + 883 { │ │ │ │ │ + 884 tempPairs.push_back(*added); │ │ │ │ │ + 885 added.eraseToHere(); │ │ │ │ │ + 886 } │ │ │ │ │ + 887 localIndices_ = tempPairs; │ │ │ │ │ + 888 } │ │ │ │ │ + 889 } │ │ │ │ │ + 890 │ │ │ │ │ + 891 │ │ │ │ │ + 892 template │ │ │ │ │ + 893 inline const IndexPair& │ │ │ │ │ + 894 ParallelIndexSet::at(const TG& global) const │ │ │ │ │ + 895 { │ │ │ │ │ + 896 // perform a binary search │ │ │ │ │ + 897 int low=0, high=localIndices_.size()-1, probe=-1; │ │ │ │ │ + 898 │ │ │ │ │ + 899 while(low │ │ │ │ │ + 918 inline const IndexPair& │ │ │ │ │ + 919 ParallelIndexSet::operator[](const TG& global) const │ │ │ │ │ + 920 { │ │ │ │ │ + 921 // perform a binary search │ │ │ │ │ + 922 int low=0, high=localIndices_.size()-1, probe=-1; │ │ │ │ │ + 923 │ │ │ │ │ + 924 while(low │ │ │ │ │ + 936 inline IndexPair& ParallelIndexSet::at(const TG& global) │ │ │ │ │ + 937 { │ │ │ │ │ + 938 // perform a binary search │ │ │ │ │ + 939 int low=0, high=localIndices_.size()-1, probe=-1; │ │ │ │ │ + 940 │ │ │ │ │ + 941 while(low= global) │ │ │ │ │ + 945 high = probe; │ │ │ │ │ + 946 else │ │ │ │ │ + 947 low = probe+1; │ │ │ │ │ + 948 } │ │ │ │ │ + 949 │ │ │ │ │ + 950 if(probe==-1) │ │ │ │ │ + 951 DUNE_THROW(RangeError, "No entries!"); │ │ │ │ │ + 952 │ │ │ │ │ + 953 if( localIndices_[low].global() != global) │ │ │ │ │ + 954 DUNE_THROW(RangeError, "Could not find entry of "< │ │ │ │ │ + 960 inline bool ParallelIndexSet::exists (const TG& global) const │ │ │ │ │ + 961 { │ │ │ │ │ + 962 // perform a binary search │ │ │ │ │ + 963 int low=0, high=localIndices_.size()-1, probe=-1; │ │ │ │ │ + 964 │ │ │ │ │ + 965 while(low= global) │ │ │ │ │ + 969 high = probe; │ │ │ │ │ + 970 else │ │ │ │ │ + 971 low = probe+1; │ │ │ │ │ + 972 } │ │ │ │ │ + 973 │ │ │ │ │ + 974 if(probe==-1) │ │ │ │ │ + 975 return false; │ │ │ │ │ + 976 │ │ │ │ │ + 977 if( localIndices_[low].global() != global) │ │ │ │ │ + 978 return false; │ │ │ │ │ + 979 return true; │ │ │ │ │ + 980 } │ │ │ │ │ + 981 │ │ │ │ │ + 982 template │ │ │ │ │ + 983 inline IndexPair& ParallelIndexSet::operator[](const TG& │ │ │ │ │ +global) │ │ │ │ │ + 984 { │ │ │ │ │ + 985 // perform a binary search │ │ │ │ │ + 986 int low=0, high=localIndices_.size()-1, probe=-1; │ │ │ │ │ + 987 │ │ │ │ │ + 988 while(low= global) │ │ │ │ │ + 992 high = probe; │ │ │ │ │ + 993 else │ │ │ │ │ + 994 low = probe+1; │ │ │ │ │ + 995 } │ │ │ │ │ + 996 │ │ │ │ │ + 997 return localIndices_[low]; │ │ │ │ │ + 998 } │ │ │ │ │ + 999 template │ │ │ │ │ + 1000 inline typename ParallelIndexSet::iterator │ │ │ │ │ + 1001 ParallelIndexSet::begin() │ │ │ │ │ + 1002 { │ │ │ │ │ + 1003 return iterator(*this, localIndices_.begin()); │ │ │ │ │ + 1004 } │ │ │ │ │ + 1005 │ │ │ │ │ + 1006 │ │ │ │ │ + 1007 template │ │ │ │ │ + 1008 inline typename ParallelIndexSet::iterator │ │ │ │ │ + 1009 ParallelIndexSet::end() │ │ │ │ │ + 1010 { │ │ │ │ │ + 1011 return iterator(*this,localIndices_.end()); │ │ │ │ │ + 1012 } │ │ │ │ │ + 1013 │ │ │ │ │ + 1014 template │ │ │ │ │ + 1015 inline typename ParallelIndexSet::const_iterator │ │ │ │ │ + 1016 ParallelIndexSet::begin() const │ │ │ │ │ + 1017 { │ │ │ │ │ + 1018 return localIndices_.begin(); │ │ │ │ │ + 1019 } │ │ │ │ │ + 1020 │ │ │ │ │ + 1021 │ │ │ │ │ + 1022 template │ │ │ │ │ + 1023 inline typename ParallelIndexSet::const_iterator │ │ │ │ │ + 1024 ParallelIndexSet::end() const │ │ │ │ │ + 1025 { │ │ │ │ │ + 1026 return localIndices_.end(); │ │ │ │ │ + 1027 } │ │ │ │ │ + 1028 │ │ │ │ │ + 1029 template │ │ │ │ │ + 1030 void ParallelIndexSet::renumberLocal(){ │ │ │ │ │ + 1031#ifndef NDEBUG │ │ │ │ │ + 1032 if(state_==RESIZE) │ │ │ │ │ + 1033 DUNE_THROW(InvalidIndexSetState, "IndexSet has to be in " │ │ │ │ │ + 1034 <<"GROUND state for renumberLocal()"); │ │ │ │ │ + 1035#endif │ │ │ │ │ + 1036 │ │ │ │ │ + 1037 const auto end_ = end(); │ │ │ │ │ + 1038 uint32_t index=0; │ │ │ │ │ + 1039 │ │ │ │ │ + 1040 for(auto pair=begin(); pair!=end_; index++, ++pair) │ │ │ │ │ + 1041 pair->local()=index; │ │ │ │ │ + 1042 } │ │ │ │ │ + 1043 │ │ │ │ │ + 1044 template │ │ │ │ │ + 1045 inline int ParallelIndexSet::seqNo() const │ │ │ │ │ + 1046 { │ │ │ │ │ + 1047 return seqNo_; │ │ │ │ │ + 1048 } │ │ │ │ │ + 1049 │ │ │ │ │ + 1050 template │ │ │ │ │ + 1051 inline size_t ParallelIndexSet::size() const │ │ │ │ │ + 1052 { │ │ │ │ │ + 1053 return localIndices_.size(); │ │ │ │ │ + 1054 } │ │ │ │ │ + 1055 │ │ │ │ │ + 1056 template │ │ │ │ │ + 1057 GlobalLookupIndexSet::GlobalLookupIndexSet(const I& indexset, │ │ │ │ │ + 1058 std::size_t size) │ │ │ │ │ + 1059 : indexSet_(indexset), size_(size), │ │ │ │ │ + 1060 indices_(size_, static_cast(0)) │ │ │ │ │ + 1061 { │ │ │ │ │ + 1062 const_iterator end_ = indexSet_.end(); │ │ │ │ │ + 1063 │ │ │ │ │ + 1064 for(const_iterator pair = indexSet_.begin(); pair!=end_; ++pair) { │ │ │ │ │ + 1065 assert(pair->local()local()] = &(*pair); │ │ │ │ │ + 1067 } │ │ │ │ │ + 1068 } │ │ │ │ │ + 1069 │ │ │ │ │ + 1070 template │ │ │ │ │ + 1071 GlobalLookupIndexSet::GlobalLookupIndexSet(const I& indexset) │ │ │ │ │ + 1072 : indexSet_(indexset), size_(0) │ │ │ │ │ + 1073 { │ │ │ │ │ + 1074 const_iterator end_ = indexSet_.end(); │ │ │ │ │ + 1075 for(const_iterator pair = indexSet_.begin(); pair!=end_; ++pair) │ │ │ │ │ + 1076 size_=std::max(size_,static_cast(pair->local())); │ │ │ │ │ + 1077 │ │ │ │ │ + 1078 indices_.resize(++size_, 0); │ │ │ │ │ + 1079 │ │ │ │ │ + 1080 for(const_iterator pair = indexSet_.begin(); pair!=end_; ++pair) │ │ │ │ │ + 1081 indices_[pair->local()] = &(*pair); │ │ │ │ │ + 1082 } │ │ │ │ │ + 1083 │ │ │ │ │ + 1084 template │ │ │ │ │ + 1085 GlobalLookupIndexSet::~GlobalLookupIndexSet() │ │ │ │ │ + 1086 {} │ │ │ │ │ + 1087 │ │ │ │ │ + 1088 template │ │ │ │ │ + 1089 inline const IndexPair* │ │ │ │ │ + 1090 GlobalLookupIndexSet::pair(const std::size_t& local) const │ │ │ │ │ + 1091 { │ │ │ │ │ + 1092 return indices_[local]; │ │ │ │ │ + 1093 } │ │ │ │ │ + 1094 │ │ │ │ │ + 1095 template │ │ │ │ │ + 1096 inline const IndexPair& │ │ │ │ │ + 1097 GlobalLookupIndexSet::operator[](const GlobalIndex& global) const │ │ │ │ │ + 1098 { │ │ │ │ │ + 1099 return indexSet_[global]; │ │ │ │ │ + 1100 } │ │ │ │ │ + 1101 │ │ │ │ │ + 1102 template │ │ │ │ │ + 1103 typename I::const_iterator GlobalLookupIndexSet::begin() const │ │ │ │ │ + 1104 { │ │ │ │ │ + 1105 return indexSet_.begin(); │ │ │ │ │ + 1106 } │ │ │ │ │ + 1107 │ │ │ │ │ + 1108 template │ │ │ │ │ + 1109 typename I::const_iterator GlobalLookupIndexSet::end() const │ │ │ │ │ + 1110 { │ │ │ │ │ + 1111 return indexSet_.end(); │ │ │ │ │ + 1112 } │ │ │ │ │ + 1113 │ │ │ │ │ + 1114 template │ │ │ │ │ + 1115 inline size_t GlobalLookupIndexSet::size() const │ │ │ │ │ + 1116 { │ │ │ │ │ + 1117 return size_; │ │ │ │ │ + 1118 } │ │ │ │ │ + 1119 │ │ │ │ │ + 1120 template │ │ │ │ │ + 1121 inline int GlobalLookupIndexSet::seqNo() const │ │ │ │ │ + 1122 { │ │ │ │ │ + 1123 return indexSet_.seqNo(); │ │ │ │ │ + 1124 } │ │ │ │ │ + 1125 │ │ │ │ │ + 1126 template │ │ │ │ │ + 1127 bool operator==(const ParallelIndexSet& idxset, │ │ │ │ │ + 1128 const ParallelIndexSet& idxset1) │ │ │ │ │ + 1129 { │ │ │ │ │ + 1130 if(idxset.size()!=idxset1.size()) │ │ │ │ │ + 1131 return false; │ │ │ │ │ + 1132 typedef typename ParallelIndexSet::const_iterator Iter; │ │ │ │ │ + 1133 typedef typename ParallelIndexSet::const_iterator Iter1; │ │ │ │ │ + 1134 Iter iter=idxset.begin(); │ │ │ │ │ + 1135 for(Iter1 iter1=idxset1.begin(); iter1 != idxset1.end(); ++iter, ++iter1) │ │ │ │ │ +{ │ │ │ │ │ + 1136 if(iter1->global()!=iter->global()) │ │ │ │ │ + 1137 return false; │ │ │ │ │ + 1138 typedef typename ParallelIndexSet::LocalIndex PI; │ │ │ │ │ + 1139 const PI& pi=iter->local(), pi1=iter1->local(); │ │ │ │ │ + 1140 │ │ │ │ │ + 1141 if(pi!=pi1) │ │ │ │ │ + 1142 return false; │ │ │ │ │ + 1143 } │ │ │ │ │ + 1144 return true; │ │ │ │ │ + 1145 } │ │ │ │ │ + 1146 │ │ │ │ │ + 1147 template │ │ │ │ │ + 1148 bool operator!=(const ParallelIndexSet& idxset, │ │ │ │ │ + 1149 const ParallelIndexSet& idxset1) │ │ │ │ │ + 1150 { │ │ │ │ │ + 1151 return !(idxset==idxset1); │ │ │ │ │ + 1152 } │ │ │ │ │ + 1153 │ │ │ │ │ + 1154 │ │ │ │ │ + 1155#endif // DOXYGEN │ │ │ │ │ + 1156 │ │ │ │ │ + 1157} │ │ │ │ │ + 1158#endif │ │ │ │ │ +localindex.hh │ │ │ │ │ +Provides classes for use as the local index in ParallelIndexSet. │ │ │ │ │ +exceptions.hh │ │ │ │ │ +A few common exception classes. │ │ │ │ │ +arraylist.hh │ │ │ │ │ +Implements a random-access container that can efficiently change size (similar │ │ │ │ │ +to std::deque) │ │ │ │ │ +Dune::operator<< │ │ │ │ │ +std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x) │ │ │ │ │ +Definition bigunsignedint.hh:278 │ │ │ │ │ +DUNE_THROW │ │ │ │ │ +#define DUNE_THROW(E, m) │ │ │ │ │ +Definition exceptions.hh:218 │ │ │ │ │ +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:637 │ │ │ │ │ +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:683 │ │ │ │ │ +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:660 │ │ │ │ │ +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:237 │ │ │ │ │ +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:705 │ │ │ │ │ +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:259 │ │ │ │ │ +Dune::ParallelIndexSet::operator[] │ │ │ │ │ +IndexPair & operator[](const GlobalIndex &global) │ │ │ │ │ +Find the index pair with a specific global id. │ │ │ │ │ +Dune::ParallelIndexSet::arraySize │ │ │ │ │ +static constexpr int arraySize │ │ │ │ │ +The size of the individual arrays in the underlying ArrayList. │ │ │ │ │ +Definition indexset.hh:252 │ │ │ │ │ +Dune::ParallelIndexSet::beginResize │ │ │ │ │ +void beginResize() │ │ │ │ │ +Indicate that the index set is to be resized. │ │ │ │ │ +Dune::ParallelIndexSetState │ │ │ │ │ +ParallelIndexSetState │ │ │ │ │ +The states the index set can be in. │ │ │ │ │ +Definition indexset.hh:181 │ │ │ │ │ +Dune::ParallelIndexSet::renumberLocal │ │ │ │ │ +void renumberLocal() │ │ │ │ │ +Renumbers the local index numbers. │ │ │ │ │ +Dune::ParallelIndexSet::exists │ │ │ │ │ +bool exists(const GlobalIndex &global) const │ │ │ │ │ +Find the index pair with a specific global id. │ │ │ │ │ +Dune::ParallelIndexSet::size │ │ │ │ │ +size_t size() const │ │ │ │ │ +Get the total number (public and nonpublic) indices. │ │ │ │ │ +Dune::ParallelIndexSet::const_iterator │ │ │ │ │ +ArrayList< IndexPair, N >::const_iterator const_iterator │ │ │ │ │ +The constant iterator over the pairs. │ │ │ │ │ +Definition indexset.hh:296 │ │ │ │ │ +Dune::IndexSetSortFunctor::operator() │ │ │ │ │ +bool operator()(const IndexPair< TG, TL > &i1, const IndexPair< TG, TL > &i2) │ │ │ │ │ +Definition indexset.hh:625 │ │ │ │ │ +Dune::ParallelIndexSet::add │ │ │ │ │ +void add(const GlobalIndex &global) │ │ │ │ │ +Add an new index to the set. │ │ │ │ │ +Dune::GlobalLookupIndexSet::end │ │ │ │ │ +const_iterator end() const │ │ │ │ │ +Get an iterator over the indices positioned after the last index. │ │ │ │ │ +Dune::IndexPair::local │ │ │ │ │ +const LocalIndex & local() const │ │ │ │ │ +Get the local index. │ │ │ │ │ +Dune::ParallelIndexSet::at │ │ │ │ │ +const IndexPair & at(const GlobalIndex &global) const │ │ │ │ │ +Find the index pair with a specific global id. │ │ │ │ │ +Dune::GlobalLookupIndexSet::GlobalLookupIndexSet │ │ │ │ │ +GlobalLookupIndexSet(const ParallelIndexSet &indexset) │ │ │ │ │ +Constructor. │ │ │ │ │ +Dune::IndexPair::LocalIndex │ │ │ │ │ +TL LocalIndex │ │ │ │ │ +the type of the local index. │ │ │ │ │ +Definition indexset.hh:120 │ │ │ │ │ +Dune::GlobalLookupIndexSet::seqNo │ │ │ │ │ +int seqNo() const │ │ │ │ │ +Get the internal sequence number. │ │ │ │ │ +Dune::LocalIndexComparator::compare │ │ │ │ │ +static bool compare(const T &t1, const T &t2) │ │ │ │ │ +Definition indexset.hh:616 │ │ │ │ │ +Dune::ParallelIndexSet::begin │ │ │ │ │ +iterator begin() │ │ │ │ │ +Get an iterator over the indices positioned at the first index. │ │ │ │ │ +Dune::GlobalLookupIndexSet::IndexPair │ │ │ │ │ +Dune::IndexPair< typename I::GlobalIndex, typename I::LocalIndex > IndexPair │ │ │ │ │ +Definition indexset.hh:529 │ │ │ │ │ +Dune::ParallelIndexSet::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 │ │ │ │ │ +Get an iterator over the indices positioned after the last index. │ │ │ │ │ +Dune::GlobalLookupIndexSet::const_iterator │ │ │ │ │ +ParallelIndexSet::const_iterator const_iterator │ │ │ │ │ +The iterator over the index pairs. │ │ │ │ │ +Definition indexset.hh:527 │ │ │ │ │ +Dune::GlobalLookupIndexSet::begin │ │ │ │ │ +const_iterator begin() const │ │ │ │ │ +Get an iterator over the indices positioned at the first index. │ │ │ │ │ +Dune::ParallelIndexSet::operator[] │ │ │ │ │ +const IndexPair & operator[](const GlobalIndex &global) const │ │ │ │ │ +Find the index pair with a specific global id. │ │ │ │ │ +Dune::ParallelIndexSet::state │ │ │ │ │ +const ParallelIndexSetState & state() │ │ │ │ │ +Get the state the index set is in. │ │ │ │ │ +Definition indexset.hh:307 │ │ │ │ │ +Dune::ParallelIndexSet::begin │ │ │ │ │ +const_iterator begin() const │ │ │ │ │ +Get an iterator over the indices positioned at the first index. │ │ │ │ │ +Dune::GlobalLookupIndexSet::operator[] │ │ │ │ │ +const IndexPair & operator[](const GlobalIndex &global) const │ │ │ │ │ +Find the index pair with a specific global id. │ │ │ │ │ +Dune::IndexPair::IndexPair │ │ │ │ │ +IndexPair() │ │ │ │ │ +Construct a new Pair. │ │ │ │ │ +Dune::GlobalLookupIndexSet::ParallelIndexSet │ │ │ │ │ +I ParallelIndexSet │ │ │ │ │ +The type of the index set. │ │ │ │ │ +Definition indexset.hh:512 │ │ │ │ │ +Dune::ParallelIndexSet::LocalIndex │ │ │ │ │ +TL LocalIndex │ │ │ │ │ +The type of the local index, e.g. ParallelLocalIndex. │ │ │ │ │ +Definition indexset.hh:239 │ │ │ │ │ +Dune::ParallelIndexSet::markAsDeleted │ │ │ │ │ +void markAsDeleted(const iterator &position) │ │ │ │ │ +Mark an index as deleted. │ │ │ │ │ +Dune::GlobalLookupIndexSet::LocalIndex │ │ │ │ │ +ParallelIndexSet::LocalIndex LocalIndex │ │ │ │ │ +The type of the local index. │ │ │ │ │ +Definition indexset.hh:517 │ │ │ │ │ +Dune::IndexPair::IndexPair │ │ │ │ │ +IndexPair(const GlobalIndex &global, const LocalIndex &local) │ │ │ │ │ +Constructs a new Pair. │ │ │ │ │ +Dune::IndexPair::setLocal │ │ │ │ │ +void setLocal(int index) │ │ │ │ │ +Set the local index. │ │ │ │ │ +Dune::IndexPair::global │ │ │ │ │ +const GlobalIndex & global() const │ │ │ │ │ +Get the global index. │ │ │ │ │ +Dune::ParallelIndexSet::add │ │ │ │ │ +void add(const GlobalIndex &global, const LocalIndex &local) │ │ │ │ │ +Add an new index to the set. │ │ │ │ │ +Dune::ParallelIndexSet::end │ │ │ │ │ const_iterator end() const │ │ │ │ │ -Get an iterator pointing to the end of the list. │ │ │ │ │ -Definition sllist.hh:794 │ │ │ │ │ -Dune::SLList::SLList │ │ │ │ │ -SLList() │ │ │ │ │ +Get an iterator over the indices positioned after the last index. │ │ │ │ │ +Dune::ParallelIndexSet::at │ │ │ │ │ +IndexPair & at(const GlobalIndex &global) │ │ │ │ │ +Find the index pair with a specific global id. │ │ │ │ │ +Dune::ParallelIndexSet::ParallelIndexSet │ │ │ │ │ +ParallelIndexSet() │ │ │ │ │ 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() │ │ │ │ │ +Dune::ParallelIndexSet::endResize │ │ │ │ │ +void endResize() │ │ │ │ │ +Indicate that the resizing finishes. │ │ │ │ │ +Dune::GlobalLookupIndexSet::~GlobalLookupIndexSet │ │ │ │ │ +~GlobalLookupIndexSet() │ │ │ │ │ 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 │ │ │ │ │ +Dune::GlobalLookupIndexSet::pair │ │ │ │ │ +const IndexPair * pair(const std::size_t &local) const │ │ │ │ │ +Get the index pair corresponding to a local index. │ │ │ │ │ +Dune::IndexPair::local │ │ │ │ │ +LocalIndex & local() │ │ │ │ │ +Get the local index. │ │ │ │ │ +Dune::GlobalLookupIndexSet::size │ │ │ │ │ +size_t size() const │ │ │ │ │ +Get the total number (public and nonpublic) indices. │ │ │ │ │ +Dune::IndexPair::IndexPair │ │ │ │ │ +IndexPair(const GlobalIndex &global) │ │ │ │ │ +Constructs a new Pair. │ │ │ │ │ +Dune::ParallelIndexSet::GlobalIndex │ │ │ │ │ +TG GlobalIndex │ │ │ │ │ +the type of the global index. This type has to provide at least a operator< for │ │ │ │ │ +sorting. │ │ │ │ │ +Definition indexset.hh:226 │ │ │ │ │ +Dune::IndexPair::GlobalIndex │ │ │ │ │ +TG GlobalIndex │ │ │ │ │ +the type of the global index. │ │ │ │ │ +Definition indexset.hh:107 │ │ │ │ │ +Dune::ParallelIndexSet::seqNo │ │ │ │ │ +int seqNo() const │ │ │ │ │ +Get the internal sequence number. │ │ │ │ │ +Dune::ParallelIndexSet::iterator::iterator │ │ │ │ │ +iterator(ParallelIndexSet< TG, TL, N > &indexSet, const Father &father) │ │ │ │ │ +Definition indexset.hh:262 │ │ │ │ │ +Dune::GlobalLookupIndexSet::GlobalLookupIndexSet │ │ │ │ │ +GlobalLookupIndexSet(const ParallelIndexSet &indexset, std::size_t size) │ │ │ │ │ +Constructor. │ │ │ │ │ +Dune::GlobalLookupIndexSet::GlobalIndex │ │ │ │ │ +ParallelIndexSet::GlobalIndex GlobalIndex │ │ │ │ │ +The type of the global index. │ │ │ │ │ +Definition indexset.hh:522 │ │ │ │ │ +Dune::ParallelIndexSet::IndexPair │ │ │ │ │ +Dune::IndexPair< GlobalIndex, LocalIndex > IndexPair │ │ │ │ │ +The type of the pair stored. │ │ │ │ │ +Definition indexset.hh:244 │ │ │ │ │ +Dune::RESIZE │ │ │ │ │ +@ RESIZE │ │ │ │ │ +Indicates that the index set is currently being resized. │ │ │ │ │ +Definition indexset.hh:190 │ │ │ │ │ +Dune::GROUND │ │ │ │ │ +@ GROUND │ │ │ │ │ +The default mode. Indicates that the index set is ready to be used. │ │ │ │ │ +Definition indexset.hh:186 │ │ │ │ │ +Dune::DELETED │ │ │ │ │ +@ DELETED │ │ │ │ │ +Definition localindex.hh:28 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::ForwardIteratorFacade │ │ │ │ │ -Base class for stl conformant forward iterators. │ │ │ │ │ -Definition iteratorfacades.hh:141 │ │ │ │ │ -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::ArrayListIterator │ │ │ │ │ +A random access iterator for the Dune::ArrayList class. │ │ │ │ │ +Definition arraylist.hh:255 │ │ │ │ │ +Dune::ConstArrayListIterator │ │ │ │ │ +A constant random access iterator for the Dune::ArrayList class. │ │ │ │ │ +Definition arraylist.hh:370 │ │ │ │ │ +Dune::ArrayList │ │ │ │ │ +A dynamically growing random access list. │ │ │ │ │ +Definition arraylist.hh:62 │ │ │ │ │ +Dune::ArrayList::const_iterator │ │ │ │ │ +ConstArrayListIterator< MemberType, N, A > const_iterator │ │ │ │ │ +A constant random access iterator. │ │ │ │ │ +Definition arraylist.hh:110 │ │ │ │ │ +Dune::MPITraits │ │ │ │ │ +A traits class describing the mapping of types onto MPI_Datatypes. │ │ │ │ │ +Definition mpitraits.hh:41 │ │ │ │ │ +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::RandomAccessIteratorFacade<_ArrayListIterator<_T,_N,_A_>,_A::value_type, │ │ │ │ │ +A::value_type_&,_A::difference_type_>::operator* │ │ │ │ │ +Reference operator*() const │ │ │ │ │ +Dereferencing operator. │ │ │ │ │ +Definition iteratorfacades.hh:500 │ │ │ │ │ +Dune::IndexPair │ │ │ │ │ +A pair consisting of a global and local index. │ │ │ │ │ +Definition indexset.hh:85 │ │ │ │ │ +Dune::InvalidIndexSetState │ │ │ │ │ +Exception indicating that the index set is not in the expected state. │ │ │ │ │ +Definition indexset.hh:205 │ │ │ │ │ +Dune::GlobalLookupIndexSet │ │ │ │ │ +Decorates an index set with the possibility to find a global index that is │ │ │ │ │ +mapped to a specific local... │ │ │ │ │ +Definition indexset.hh:507 │ │ │ │ │ +Dune::ParallelIndexSet │ │ │ │ │ +Manager class for the mapping between local indices and globally unique │ │ │ │ │ +indices. │ │ │ │ │ +Definition indexset.hh:218 │ │ │ │ │ +Dune::ParallelIndexSet::iterator │ │ │ │ │ +The iterator over the pairs. │ │ │ │ │ +Definition indexset.hh:257 │ │ │ │ │ +Dune::LocalIndexComparator │ │ │ │ │ +Definition indexset.hh:615 │ │ │ │ │ +Dune::IndexSetSortFunctor │ │ │ │ │ +Definition indexset.hh:624 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00032.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: diagonalmatrix.hh File Reference │ │ │ │ +dune-common: remoteindices.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,80 +65,89 @@ │ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces
│ │ │ │ -
diagonalmatrix.hh File Reference
│ │ │ │ +Namespaces | │ │ │ │ +Functions
│ │ │ │ + │ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ -

This file implements a quadratic diagonal matrix of fixed size. │ │ │ │ +

Classes describing a distributed indexset. │ │ │ │ More...

│ │ │ │ -
#include <algorithm>
│ │ │ │ -#include <cassert>
│ │ │ │ -#include <cmath>
│ │ │ │ -#include <complex>
│ │ │ │ -#include <cstddef>
│ │ │ │ -#include <initializer_list>
│ │ │ │ +
#include <cassert>
│ │ │ │ #include <iostream>
│ │ │ │ +#include <ostream>
│ │ │ │ +#include <map>
│ │ │ │ #include <memory>
│ │ │ │ -#include <dune/common/boundschecking.hh>
│ │ │ │ -#include <dune/common/densematrix.hh>
│ │ │ │ -#include <dune/common/exceptions.hh>
│ │ │ │ -#include <dune/common/fmatrix.hh>
│ │ │ │ -#include <dune/common/fvector.hh>
│ │ │ │ -#include <dune/common/genericiterator.hh>
│ │ │ │ -#include <dune/common/typetraits.hh>
│ │ │ │ +#include <set>
│ │ │ │ +#include <utility>
│ │ │ │ +#include <vector>
│ │ │ │ +#include <mpi.h>
│ │ │ │ +#include <dune/common/exceptions.hh>
│ │ │ │ +#include <dune/common/parallel/indexset.hh>
│ │ │ │ +#include <dune/common/parallel/mpitraits.hh>
│ │ │ │ +#include <dune/common/parallel/plocalindex.hh>
│ │ │ │ +#include <dune/common/sllist.hh>
│ │ │ │ +#include <dune/common/stdstreams.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

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

│ │ │ │ Classes

class  Dune::DiagonalMatrix< K, n >
 A diagonal matrix of static size. More...
class  Dune::MPITraits< IndexPair< TG, ParallelLocalIndex< TA > > >
 
struct  Dune::FieldTraits< DiagonalMatrix< K, n > >
class  Dune::RemoteIndex< T1, T2 >
 Information about an index residing on another processor. More...
 
class  Dune::DiagonalMatrixWrapper< DiagonalMatrixType >
class  Dune::RemoteIndices< T, A >
 The indices present on remote processes. More...
 
class  Dune::DiagonalRowVectorConst< K, n >
class  Dune::RemoteIndexListModifier< T, A, mode >
 Modifier for adding and/or deleting remote indices from the remote index list. More...
 
class  Dune::DiagonalRowVector< K, n >
class  Dune::RemoteIndexListModifier< T, A, mode >::InvalidPosition
 
struct  Dune::const_reference< DiagonalRowVector< K, n > >
class  Dune::CollectiveIterator< T, A >
 A collective iterator for moving over the remote indices for all processes collectively. More...
 
struct  Dune::const_reference< DiagonalRowVectorConst< K, n > >
 
struct  Dune::mutable_reference< DiagonalRowVector< K, n > >
 
struct  Dune::mutable_reference< DiagonalRowVectorConst< K, n > >
 
class  Dune::ContainerWrapperIterator< CW, T, R >
 Iterator class for sparse vector-like containers. More...
 
struct  Dune::DenseMatrixAssigner< DenseMatrix, DiagonalMatrix< field, N > >
class  Dune::CollectiveIterator< T, A >::iterator
 Iterator over the valid underlying iterators. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ +

│ │ │ │ Namespaces

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

│ │ │ │ +Functions

template<typename T1 , typename T2 >
std::ostream & Dune::operator<< (std::ostream &os, const RemoteIndex< T1, T2 > &index)
 
template<class T , class A >
std::ostream & Dune::operator<< (std::ostream &os, const RemoteIndices< T, A > &indices)
 
template<typename TG , typename TA >
std::ostream & Dune::operator<< (std::ostream &os, const RemoteIndex< TG, TA > &index)
 
│ │ │ │

Detailed Description

│ │ │ │ -

This file implements a quadratic diagonal matrix of fixed size.

│ │ │ │ +

Classes describing a distributed indexset.

│ │ │ │ +
Author
Markus Blatt
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,60 +6,74 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -diagonalmatrix.hh File Reference │ │ │ │ │ -This file implements a quadratic diagonal matrix of fixed size. More... │ │ │ │ │ -#include │ │ │ │ │ + * parallel │ │ │ │ │ +Classes | Namespaces | Functions │ │ │ │ │ +remoteindices.hh File Reference │ │ │ │ │ +Common » Parallel_Communication » Parallel_Computing_based_on_Indexsets │ │ │ │ │ +Classes describing a distributed indexset. More... │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ #include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#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::DiagonalMatrix<_K,_n_> │ │ │ │ │ -  A diagonal matrix of static size. More... │ │ │ │ │ +class  Dune::MPITraits<_IndexPair<_TG,_ParallelLocalIndex<_TA_>_>_> │ │ │ │ │   │ │ │ │ │ -struct  Dune::FieldTraits<_DiagonalMatrix<_K,_n_>_> │ │ │ │ │ +class  Dune::RemoteIndex<_T1,_T2_> │ │ │ │ │ +  Information about an index residing on another processor. More... │ │ │ │ │   │ │ │ │ │ - class  Dune::DiagonalMatrixWrapper<_DiagonalMatrixType_> │ │ │ │ │ +class  Dune::RemoteIndices<_T,_A_> │ │ │ │ │ +  The indices present on remote processes. More... │ │ │ │ │   │ │ │ │ │ - class  Dune::DiagonalRowVectorConst<_K,_n_> │ │ │ │ │ +class  Dune::RemoteIndexListModifier<_T,_A,_mode_> │ │ │ │ │ +  Modifier for adding and/or deleting remote indices from the remote │ │ │ │ │ + index list. More... │ │ │ │ │   │ │ │ │ │ - class  Dune::DiagonalRowVector<_K,_n_> │ │ │ │ │ +class  Dune::RemoteIndexListModifier<_T,_A,_mode_>::InvalidPosition │ │ │ │ │   │ │ │ │ │ -struct  Dune::const_reference<_DiagonalRowVector<_K,_n_>_> │ │ │ │ │ +class  Dune::CollectiveIterator<_T,_A_> │ │ │ │ │ +  A collective iterator for moving over the remote indices for all │ │ │ │ │ + processes collectively. More... │ │ │ │ │   │ │ │ │ │ -struct  Dune::const_reference<_DiagonalRowVectorConst<_K,_n_>_> │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::mutable_reference<_DiagonalRowVector<_K,_n_>_> │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::mutable_reference<_DiagonalRowVectorConst<_K,_n_>_> │ │ │ │ │ -  │ │ │ │ │ - class  Dune::ContainerWrapperIterator<_CW,_T,_R_> │ │ │ │ │ -  Iterator class for sparse vector-like containers. More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::DenseMatrixAssigner<_DenseMatrix,_DiagonalMatrix<_field,_N_>_> │ │ │ │ │ +class  Dune::CollectiveIterator<_T,_A_>::iterator │ │ │ │ │ +  Iterator over the valid underlying iterators. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ + Functions │ │ │ │ │ +template │ │ │ │ │ +std::ostream & Dune::operator<< (std::ostream &os, const RemoteIndex< T1, T2 > │ │ │ │ │ + &index) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +std::ostream & Dune::operator<< (std::ostream &os, const RemoteIndices< T, A > │ │ │ │ │ + &indices) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +std::ostream & Dune::operator<< (std::ostream &os, const RemoteIndex< TG, TA > │ │ │ │ │ + &index) │ │ │ │ │ +  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -This file implements a quadratic diagonal matrix of fixed size. │ │ │ │ │ +Classes describing a distributed indexset. │ │ │ │ │ + Author │ │ │ │ │ + Markus Blatt │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00032_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: diagonalmatrix.hh Source File │ │ │ │ +dune-common: remoteindices.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,1357 +70,1697 @@ │ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
diagonalmatrix.hh
│ │ │ │ +
remoteindices.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 (C) 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_DIAGONAL_MATRIX_HH
│ │ │ │ -
6#define DUNE_DIAGONAL_MATRIX_HH
│ │ │ │ +
5#ifndef DUNE_REMOTEINDICES_HH
│ │ │ │ +
6#define DUNE_REMOTEINDICES_HH
│ │ │ │
7
│ │ │ │ -
12#include <algorithm>
│ │ │ │ -
13#include <cassert>
│ │ │ │ -
14#include <cmath>
│ │ │ │ -
15#include <complex>
│ │ │ │ -
16#include <cstddef>
│ │ │ │ -
17#include <initializer_list>
│ │ │ │ -
18#include <iostream>
│ │ │ │ -
19#include <memory>
│ │ │ │ +
8#if HAVE_MPI
│ │ │ │ +
9
│ │ │ │ +
10#include <cassert>
│ │ │ │ +
11#include <iostream>
│ │ │ │ +
12#include <ostream>
│ │ │ │ +
13#include <map>
│ │ │ │ +
14#include <memory>
│ │ │ │ +
15#include <set>
│ │ │ │ +
16#include <utility>
│ │ │ │ +
17#include <vector>
│ │ │ │ +
18
│ │ │ │ +
19#include <mpi.h>
│ │ │ │
20
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
28
│ │ │ │ -
29
│ │ │ │ -
30namespace Dune {
│ │ │ │ -
31
│ │ │ │ -
32 template< class K, int n > class DiagonalRowVectorConst;
│ │ │ │ -
33 template< class K, int n > class DiagonalRowVector;
│ │ │ │ -
34 template< class DiagonalMatrixType > class DiagonalMatrixWrapper;
│ │ │ │ -
35 template< class C, class T, class R> class ContainerWrapperIterator;
│ │ │ │ -
36
│ │ │ │ -
51 template<class K, int n>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
53 {
│ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
25#include <dune/common/sllist.hh>
│ │ │ │ + │ │ │ │ +
27
│ │ │ │ +
28namespace Dune {
│ │ │ │ +
40 template<typename TG, typename TA>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
42 {
│ │ │ │ +
43 public:
│ │ │ │ +
44 inline static MPI_Datatype getType();
│ │ │ │ +
45 private:
│ │ │ │ +
46 static MPI_Datatype type;
│ │ │ │ +
47 };
│ │ │ │ +
│ │ │ │ +
48
│ │ │ │ +
49
│ │ │ │ +
50 template<typename T, typename A>
│ │ │ │ +
51 class RemoteIndices;
│ │ │ │ +
52
│ │ │ │ +
53 template<typename T1, typename T2>
│ │ │ │ +
54 class RemoteIndex;
│ │ │ │
55
│ │ │ │ -
56 public:
│ │ │ │ -
57 //===== type definitions and constants
│ │ │ │ -
58
│ │ │ │ -
60 typedef K value_type;
│ │ │ │ - │ │ │ │ +
56 // forward declaration needed for friend declaration.
│ │ │ │ +
57 template<typename T>
│ │ │ │ +
58 class IndicesSyncer;
│ │ │ │ +
59
│ │ │ │ +
60 template<typename T1, typename T2>
│ │ │ │ +
61 std::ostream& operator<<(std::ostream& os, const RemoteIndex<T1,T2>& index);
│ │ │ │
62
│ │ │ │ -
64 typedef K block_type;
│ │ │ │ -
65
│ │ │ │ -
67 typedef std::size_t size_type;
│ │ │ │ -
68
│ │ │ │ -
70 constexpr static int blocklevel = 1;
│ │ │ │ -
71
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
79
│ │ │ │ -
81 constexpr static int rows = n;
│ │ │ │ -
83 constexpr static int cols = n;
│ │ │ │ +
63
│ │ │ │ +
64 template<typename T, typename A, bool mode>
│ │ │ │ + │ │ │ │ +
66
│ │ │ │ +
67
│ │ │ │ +
71 template<typename T1, typename T2>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
73 {
│ │ │ │ +
74 template<typename T>
│ │ │ │ +
75 friend class IndicesSyncer;
│ │ │ │ +
76
│ │ │ │ +
77 template<typename T, typename A, typename A1>
│ │ │ │ +
78 friend void repairLocalIndexPointers(std::map<int,SLList<std::pair<typename T::GlobalIndex, typename T::LocalIndex::Attribute>,A> >&,
│ │ │ │ + │ │ │ │ +
80 const T&);
│ │ │ │ +
81
│ │ │ │ +
82 template<typename T, typename A, bool mode>
│ │ │ │ + │ │ │ │
84
│ │ │ │ -
85 //==== size
│ │ │ │ -
86
│ │ │ │ -
│ │ │ │ -
87 static constexpr size_type size ()
│ │ │ │ -
88 {
│ │ │ │ -
89 return rows;
│ │ │ │ -
90 }
│ │ │ │ -
│ │ │ │ -
91
│ │ │ │ -
92 //===== constructors
│ │ │ │ -
93
│ │ │ │ -
95 constexpr DiagonalMatrix() = default;
│ │ │ │ -
96
│ │ │ │ -
│ │ │ │ -
98 DiagonalMatrix (const K& k)
│ │ │ │ -
99 : diag_(k)
│ │ │ │ -
100 {}
│ │ │ │ -
│ │ │ │ -
101
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
104 : diag_(diag)
│ │ │ │ -
105 {}
│ │ │ │ -
│ │ │ │ +
85 public:
│ │ │ │ +
90 typedef T1 GlobalIndex;
│ │ │ │ +
99 typedef T2 Attribute;
│ │ │ │ +
100
│ │ │ │ + │ │ │ │ + │ │ │ │
106
│ │ │ │ -
│ │ │ │ -
115 DiagonalMatrix (std::initializer_list<K> const &l)
│ │ │ │ -
116 {
│ │ │ │ -
117 std::copy_n(l.begin(), std::min(static_cast<std::size_t>(rows),
│ │ │ │ -
118 l.size()),
│ │ │ │ -
119 diag_.begin());
│ │ │ │ -
120 }
│ │ │ │ -
│ │ │ │ -
121
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
124 {
│ │ │ │ -
125 diag_ = k;
│ │ │ │ -
126 return *this;
│ │ │ │ -
127 }
│ │ │ │ -
│ │ │ │ -
128
│ │ │ │ -
│ │ │ │ -
130 bool identical(const DiagonalMatrix<K,n>& other) const
│ │ │ │ -
131 {
│ │ │ │ -
132 return (this==&other);
│ │ │ │ -
133 }
│ │ │ │ -
│ │ │ │ +
111 const Attribute attribute() const;
│ │ │ │ +
112
│ │ │ │ +
118 const PairType& localIndexPair() const;
│ │ │ │ +
119
│ │ │ │ +
123 RemoteIndex();
│ │ │ │ +
124
│ │ │ │ +
125
│ │ │ │ +
131 RemoteIndex(const T2& attribute,
│ │ │ │ +
132 const PairType* local);
│ │ │ │ +
133
│ │ │ │
134
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
137 {
│ │ │ │ -
138 return *this;
│ │ │ │ -
139 }
│ │ │ │ -
│ │ │ │ -
140
│ │ │ │ -
141 //===== iterator interface to rows of the matrix
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
150
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
153 {
│ │ │ │ -
154 return Iterator(WrapperType(this),0);
│ │ │ │ -
155 }
│ │ │ │ -
│ │ │ │ -
156
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
159 {
│ │ │ │ -
160 return Iterator(WrapperType(this),n);
│ │ │ │ -
161 }
│ │ │ │ -
│ │ │ │ -
162
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
166 {
│ │ │ │ -
167 return Iterator(WrapperType(this),n-1);
│ │ │ │ -
168 }
│ │ │ │ -
│ │ │ │ +
140 RemoteIndex(const T2& attribute);
│ │ │ │ +
141
│ │ │ │ +
142 bool operator==(const RemoteIndex& ri) const;
│ │ │ │ +
143
│ │ │ │ +
144 bool operator!=(const RemoteIndex& ri) const;
│ │ │ │ +
145 private:
│ │ │ │ +
147 const PairType* localIndex_;
│ │ │ │ +
148
│ │ │ │ +
150 char attribute_;
│ │ │ │ +
151 };
│ │ │ │ +
│ │ │ │ +
152
│ │ │ │ +
153 template<class T, class A>
│ │ │ │ +
154 std::ostream& operator<<(std::ostream& os, const RemoteIndices<T,A>& indices);
│ │ │ │ +
155
│ │ │ │ +
156 class InterfaceBuilder;
│ │ │ │ +
157
│ │ │ │ +
158 template<class T, class A>
│ │ │ │ +
159 class CollectiveIterator;
│ │ │ │ +
160
│ │ │ │ +
161 // forward declaration needed for friend declaration.
│ │ │ │ +
162 template<class T>
│ │ │ │ +
163 class IndicesSyncer;
│ │ │ │ +
164
│ │ │ │ +
165 // forward declaration needed for friend declaration.
│ │ │ │ +
166 template<typename T1, typename T2>
│ │ │ │ + │ │ │ │ +
168
│ │ │ │
169
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
173 {
│ │ │ │ -
174 return Iterator(WrapperType(this),-1);
│ │ │ │ -
175 }
│ │ │ │ -
│ │ │ │ -
176
│ │ │ │ -
177
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
186
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
189 {
│ │ │ │ -
190 return ConstIterator(WrapperType(this),0);
│ │ │ │ -
191 }
│ │ │ │ -
│ │ │ │ -
192
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
195 {
│ │ │ │ -
196 return ConstIterator(WrapperType(this),n);
│ │ │ │ -
197 }
│ │ │ │ -
│ │ │ │ -
198
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
202 {
│ │ │ │ -
203 return ConstIterator(WrapperType(this),n-1);
│ │ │ │ -
204 }
│ │ │ │ -
│ │ │ │ -
205
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
209 {
│ │ │ │ -
210 return ConstIterator(WrapperType(this),-1);
│ │ │ │ -
211 }
│ │ │ │ -
│ │ │ │ -
212
│ │ │ │ -
213
│ │ │ │ -
214
│ │ │ │ -
215 //===== vector space arithmetic
│ │ │ │ +
186 template<class T, class A=std::allocator<RemoteIndex<typename T::GlobalIndex,
│ │ │ │ +
187 typename T::LocalIndex::Attribute> > >
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
189 {
│ │ │ │ +
190 friend class InterfaceBuilder;
│ │ │ │ +
191 friend class IndicesSyncer<T>;
│ │ │ │ +
192 template<typename T1, typename A2, typename A1>
│ │ │ │ +
193 friend void repairLocalIndexPointers(std::map<int,SLList<std::pair<typename T1::GlobalIndex, typename T1::LocalIndex::Attribute>,A2> >&,
│ │ │ │ + │ │ │ │ +
195 const T1&);
│ │ │ │ +
196
│ │ │ │ +
197 template<class G, class T1, class T2>
│ │ │ │ + │ │ │ │ +
199 friend std::ostream& operator<<<>(std::ostream&, const RemoteIndices<T>&);
│ │ │ │ +
200
│ │ │ │ +
201 public:
│ │ │ │ +
202
│ │ │ │ + │ │ │ │ +
207
│ │ │ │ + │ │ │ │ +
211
│ │ │ │ + │ │ │ │
216
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
219 {
│ │ │ │ -
220 diag_ += y.diag_;
│ │ │ │ -
221 return *this;
│ │ │ │ -
222 }
│ │ │ │ -
│ │ │ │ -
223
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
226 {
│ │ │ │ -
227 diag_ -= y.diag_;
│ │ │ │ -
228 return *this;
│ │ │ │ -
229 }
│ │ │ │ -
│ │ │ │ -
230
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
233 {
│ │ │ │ -
234 diag_ += k;
│ │ │ │ -
235 return *this;
│ │ │ │ -
236 }
│ │ │ │ -
│ │ │ │ -
237
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
240 {
│ │ │ │ -
241 diag_ -= k;
│ │ │ │ -
242 return *this;
│ │ │ │ -
243 }
│ │ │ │ -
│ │ │ │ -
244
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
247 {
│ │ │ │ -
248 diag_ *= k;
│ │ │ │ -
249 return *this;
│ │ │ │ -
250 }
│ │ │ │ -
│ │ │ │ -
251
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
254 {
│ │ │ │ -
255 diag_ /= k;
│ │ │ │ -
256 return *this;
│ │ │ │ -
257 }
│ │ │ │ -
│ │ │ │ -
258
│ │ │ │ -
259 //===== comparison ops
│ │ │ │ -
260
│ │ │ │ -
│ │ │ │ -
262 bool operator==(const DiagonalMatrix& other) const
│ │ │ │ -
263 {
│ │ │ │ -
264 return diag_==other.diagonal();
│ │ │ │ -
265 }
│ │ │ │ -
│ │ │ │ -
266
│ │ │ │ -
│ │ │ │ -
268 bool operator!=(const DiagonalMatrix& other) const
│ │ │ │ -
269 {
│ │ │ │ -
270 return diag_!=other.diagonal();
│ │ │ │ -
271 }
│ │ │ │ -
│ │ │ │ -
272
│ │ │ │ -
273
│ │ │ │ -
274 //===== linear maps
│ │ │ │ -
275
│ │ │ │ -
277 template<class X, class Y>
│ │ │ │ -
│ │ │ │ -
278 void mv (const X& x, Y& y) const
│ │ │ │ -
279 {
│ │ │ │ -
280#ifdef DUNE_FMatrix_WITH_CHECKING
│ │ │ │ -
281 if (x.N()!=M()) DUNE_THROW(FMatrixError,"index out of range");
│ │ │ │ -
282 if (y.N()!=N()) DUNE_THROW(FMatrixError,"index out of range");
│ │ │ │ -
283#endif
│ │ │ │ -
284 for (size_type i=0; i<n; ++i)
│ │ │ │ -
285 y[i] = diag_[i] * x[i];
│ │ │ │ -
286 }
│ │ │ │ -
│ │ │ │ -
287
│ │ │ │ -
289 template<class X, class Y>
│ │ │ │ -
│ │ │ │ -
290 void mtv (const X& x, Y& y) const
│ │ │ │ -
291 {
│ │ │ │ -
292 mv(x, y);
│ │ │ │ -
293 }
│ │ │ │ -
│ │ │ │ -
294
│ │ │ │ -
296 template<class X, class Y>
│ │ │ │ -
│ │ │ │ -
297 void umv (const X& x, Y& y) const
│ │ │ │ -
298 {
│ │ │ │ -
299#ifdef DUNE_FMatrix_WITH_CHECKING
│ │ │ │ -
300 if (x.N()!=M()) DUNE_THROW(FMatrixError,"index out of range");
│ │ │ │ -
301 if (y.N()!=N()) DUNE_THROW(FMatrixError,"index out of range");
│ │ │ │ -
302#endif
│ │ │ │ -
303 for (size_type i=0; i<n; ++i)
│ │ │ │ -
304 y[i] += diag_[i] * x[i];
│ │ │ │ +
217
│ │ │ │ + │ │ │ │ +
222
│ │ │ │ +
226 typedef typename LocalIndex::Attribute Attribute;
│ │ │ │ +
227
│ │ │ │ + │ │ │ │ +
232
│ │ │ │ +
233
│ │ │ │ +
237 using Allocator = typename std::allocator_traits<A>::template rebind_alloc<RemoteIndex>;
│ │ │ │ +
238
│ │ │ │ + │ │ │ │ + │ │ │ │ +
242
│ │ │ │ +
244 typedef std::map<int, std::pair<RemoteIndexList*,RemoteIndexList*> >
│ │ │ │ + │ │ │ │ +
246
│ │ │ │ +
247 typedef typename RemoteIndexMap::const_iterator const_iterator;
│ │ │ │ +
248
│ │ │ │ +
266 inline RemoteIndices(const ParallelIndexSet& source, const ParallelIndexSet& destination,
│ │ │ │ +
267 const MPI_Comm& comm, const std::vector<int>& neighbours=std::vector<int>(), bool includeSelf=false);
│ │ │ │ +
268
│ │ │ │ + │ │ │ │ +
270
│ │ │ │ +
278 void setIncludeSelf(bool includeSelf);
│ │ │ │ +
279
│ │ │ │ +
296 void setIndexSets(const ParallelIndexSet& source, const ParallelIndexSet& destination,
│ │ │ │ +
297 const MPI_Comm& comm, const std::vector<int>& neighbours=std::vector<int>());
│ │ │ │ +
298
│ │ │ │ +
299 template<typename C>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
301 {
│ │ │ │ +
302 neighbourIds.clear();
│ │ │ │ +
303 neighbourIds.insert(neighbours.begin(), neighbours.end());
│ │ │ │ +
304
│ │ │ │
305 }
│ │ │ │
│ │ │ │
306
│ │ │ │ -
308 template<class X, class Y>
│ │ │ │ -
│ │ │ │ -
309 void umtv (const X& x, Y& y) const
│ │ │ │ -
310 {
│ │ │ │ -
311#ifdef DUNE_FMatrix_WITH_CHECKING
│ │ │ │ -
312 if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range");
│ │ │ │ -
313 if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range");
│ │ │ │ -
314#endif
│ │ │ │ -
315 for (size_type i=0; i<n; ++i)
│ │ │ │ -
316 y[i] += diag_[i] * x[i];
│ │ │ │ -
317 }
│ │ │ │ -
│ │ │ │ -
318
│ │ │ │ -
320 template<class X, class Y>
│ │ │ │ -
│ │ │ │ -
321 void umhv (const X& x, Y& y) const
│ │ │ │ -
322 {
│ │ │ │ -
323#ifdef DUNE_FMatrix_WITH_CHECKING
│ │ │ │ -
324 if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range");
│ │ │ │ -
325 if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range");
│ │ │ │ -
326#endif
│ │ │ │ -
327 for (size_type i=0; i<n; i++)
│ │ │ │ -
328 y[i] += conjugateComplex(diag_[i])*x[i];
│ │ │ │ -
329 }
│ │ │ │ -
│ │ │ │ +
│ │ │ │ +
307 const std::set<int>& getNeighbours() const
│ │ │ │ +
308 {
│ │ │ │ +
309 return neighbourIds;
│ │ │ │ +
310 }
│ │ │ │ +
│ │ │ │ +
311
│ │ │ │ + │ │ │ │ +
316
│ │ │ │ +
326 template<bool ignorePublic>
│ │ │ │ +
327 void rebuild();
│ │ │ │ +
328
│ │ │ │ +
329 bool operator==(const RemoteIndices& ri) const;
│ │ │ │
330
│ │ │ │ -
332 template<class X, class Y>
│ │ │ │ -
│ │ │ │ -
333 void mmv (const X& x, Y& y) const
│ │ │ │ -
334 {
│ │ │ │ -
335#ifdef DUNE_FMatrix_WITH_CHECKING
│ │ │ │ -
336 if (x.N()!=M()) DUNE_THROW(FMatrixError,"index out of range");
│ │ │ │ -
337 if (y.N()!=N()) DUNE_THROW(FMatrixError,"index out of range");
│ │ │ │ -
338#endif
│ │ │ │ -
339 for (size_type i=0; i<n; ++i)
│ │ │ │ -
340 y[i] -= diag_[i] * x[i];
│ │ │ │ -
341 }
│ │ │ │ -
│ │ │ │ -
342
│ │ │ │ -
344 template<class X, class Y>
│ │ │ │ -
│ │ │ │ -
345 void mmtv (const X& x, Y& y) const
│ │ │ │ -
346 {
│ │ │ │ -
347#ifdef DUNE_FMatrix_WITH_CHECKING
│ │ │ │ -
348 if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range");
│ │ │ │ -
349 if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range");
│ │ │ │ -
350#endif
│ │ │ │ -
351 for (size_type i=0; i<n; ++i)
│ │ │ │ -
352 y[i] -= diag_[i] * x[i];
│ │ │ │ -
353 }
│ │ │ │ -
│ │ │ │ -
354
│ │ │ │ -
356 template<class X, class Y>
│ │ │ │ -
│ │ │ │ -
357 void mmhv (const X& x, Y& y) const
│ │ │ │ -
358 {
│ │ │ │ -
359#ifdef DUNE_FMatrix_WITH_CHECKING
│ │ │ │ -
360 if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range");
│ │ │ │ -
361 if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range");
│ │ │ │ -
362#endif
│ │ │ │ -
363 for (size_type i=0; i<n; i++)
│ │ │ │ -
364 y[i] -= conjugateComplex(diag_[i])*x[i];
│ │ │ │ -
365 }
│ │ │ │ -
│ │ │ │ -
366
│ │ │ │ -
368 template<class X, class Y>
│ │ │ │ -
│ │ │ │ -
369 void usmv (const typename FieldTraits<Y>::field_type & alpha,
│ │ │ │ -
370 const X& x, Y& y) const
│ │ │ │ -
371 {
│ │ │ │ -
372#ifdef DUNE_FMatrix_WITH_CHECKING
│ │ │ │ -
373 if (x.N()!=M()) DUNE_THROW(FMatrixError,"index out of range");
│ │ │ │ -
374 if (y.N()!=N()) DUNE_THROW(FMatrixError,"index out of range");
│ │ │ │ -
375#endif
│ │ │ │ -
376 for (size_type i=0; i<n; i++)
│ │ │ │ -
377 y[i] += alpha * diag_[i] * x[i];
│ │ │ │ -
378 }
│ │ │ │ -
│ │ │ │ -
379
│ │ │ │ -
381 template<class X, class Y>
│ │ │ │ -
│ │ │ │ -
382 void usmtv (const typename FieldTraits<Y>::field_type & alpha,
│ │ │ │ -
383 const X& x, Y& y) const
│ │ │ │ -
384 {
│ │ │ │ -
385#ifdef DUNE_FMatrix_WITH_CHECKING
│ │ │ │ -
386 if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range");
│ │ │ │ -
387 if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range");
│ │ │ │ -
388#endif
│ │ │ │ -
389 for (size_type i=0; i<n; i++)
│ │ │ │ -
390 y[i] += alpha * diag_[i] * x[i];
│ │ │ │ -
391 }
│ │ │ │ -
│ │ │ │ +
338 inline bool isSynced() const;
│ │ │ │ +
339
│ │ │ │ +
343 inline MPI_Comm communicator() const;
│ │ │ │ +
344
│ │ │ │ +
359 template<bool mode, bool send>
│ │ │ │ + │ │ │ │ +
361
│ │ │ │ +
368 inline const_iterator find(int proc) const;
│ │ │ │ +
369
│ │ │ │ +
374 inline const_iterator begin() const;
│ │ │ │ +
375
│ │ │ │ +
380 inline const_iterator end() const;
│ │ │ │ +
381
│ │ │ │ +
385 template<bool send>
│ │ │ │ +
386 inline CollectiveIteratorT iterator() const;
│ │ │ │ +
387
│ │ │ │ +
391 inline void free();
│ │ │ │
392
│ │ │ │ -
394 template<class X, class Y>
│ │ │ │ -
│ │ │ │ -
395 void usmhv (const typename FieldTraits<Y>::field_type & alpha,
│ │ │ │ -
396 const X& x, Y& y) const
│ │ │ │ -
397 {
│ │ │ │ -
398#ifdef DUNE_FMatrix_WITH_CHECKING
│ │ │ │ -
399 if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range");
│ │ │ │ -
400 if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range");
│ │ │ │ -
401#endif
│ │ │ │ -
402 for (size_type i=0; i<n; i++)
│ │ │ │ -
403 y[i] += alpha * conjugateComplex(diag_[i]) * x[i];
│ │ │ │ -
404 }
│ │ │ │ -
│ │ │ │ -
405
│ │ │ │ -
406 //===== norms
│ │ │ │ -
407
│ │ │ │ -
│ │ │ │ -
409 double frobenius_norm () const
│ │ │ │ -
410 {
│ │ │ │ -
411 return diag_.two_norm();
│ │ │ │ -
412 }
│ │ │ │ -
│ │ │ │ -
413
│ │ │ │ -
│ │ │ │ -
415 double frobenius_norm2 () const
│ │ │ │ -
416 {
│ │ │ │ -
417 return diag_.two_norm2();
│ │ │ │ -
418 }
│ │ │ │ -
│ │ │ │ -
419
│ │ │ │ -
│ │ │ │ -
421 double infinity_norm () const
│ │ │ │ -
422 {
│ │ │ │ -
423 return diag_.infinity_norm();
│ │ │ │ -
424 }
│ │ │ │ -
│ │ │ │ -
425
│ │ │ │ -
│ │ │ │ -
427 double infinity_norm_real () const
│ │ │ │ -
428 {
│ │ │ │ -
429 return diag_.infinity_norm_real();
│ │ │ │ -
430 }
│ │ │ │ -
│ │ │ │ -
431
│ │ │ │ -
432
│ │ │ │ -
433
│ │ │ │ -
434 //===== solve
│ │ │ │ -
435
│ │ │ │ -
437 template<class V>
│ │ │ │ -
│ │ │ │ -
438 void solve (V& x, const V& b) const
│ │ │ │ -
439 {
│ │ │ │ -
440 for (int i=0; i<n; i++)
│ │ │ │ -
441 x[i] = b[i]/diag_[i];
│ │ │ │ -
442 }
│ │ │ │ -
│ │ │ │ -
443
│ │ │ │ -
│ │ │ │ -
445 void invert()
│ │ │ │ -
446 {
│ │ │ │ -
447 using real_type = typename FieldTraits<K>::real_type;
│ │ │ │ -
448 for (int i=0; i<n; i++)
│ │ │ │ -
449 diag_[i] = real_type(1.0)/diag_[i];
│ │ │ │ -
450 }
│ │ │ │ -
│ │ │ │ -
451
│ │ │ │ -
│ │ │ │ -
453 K determinant () const
│ │ │ │ -
454 {
│ │ │ │ -
455 K det = diag_[0];
│ │ │ │ -
456 for (int i=1; i<n; i++)
│ │ │ │ -
457 det *= diag_[i];
│ │ │ │ -
458 return det;
│ │ │ │ -
459 }
│ │ │ │ -
│ │ │ │ -
460
│ │ │ │ -
461
│ │ │ │ -
462
│ │ │ │ -
463 //===== matrix-matrix multiplication
│ │ │ │ -
464
│ │ │ │ -
467 template <class OtherScalar>
│ │ │ │ -
│ │ │ │ -
468 friend auto operator* ( const DiagonalMatrix& matrixA,
│ │ │ │ -
469 const DiagonalMatrix<OtherScalar, n>& matrixB)
│ │ │ │ -
470 {
│ │ │ │ - │ │ │ │ -
472 for(int i=0; i<n; ++i)
│ │ │ │ -
473 result.diagonal(i) = matrixA.diagonal(i)*matrixB.diagonal(i);
│ │ │ │ -
474 return result;
│ │ │ │ -
475 }
│ │ │ │ -
│ │ │ │ -
476
│ │ │ │ -
477
│ │ │ │ -
478
│ │ │ │ -
479 //===== sizes
│ │ │ │ -
480
│ │ │ │ -
│ │ │ │ -
482 static constexpr size_type N ()
│ │ │ │ -
483 {
│ │ │ │ -
484 return n;
│ │ │ │ -
485 }
│ │ │ │ -
│ │ │ │ +
397 inline int neighbours() const;
│ │ │ │ +
398
│ │ │ │ +
400 inline const ParallelIndexSet& sourceIndexSet() const;
│ │ │ │ +
401
│ │ │ │ +
403 inline const ParallelIndexSet& destinationIndexSet() const;
│ │ │ │ +
404
│ │ │ │ +
405 private:
│ │ │ │ +
407 RemoteIndices(const RemoteIndices&) = delete;
│ │ │ │ +
408
│ │ │ │ +
410 const ParallelIndexSet* source_;
│ │ │ │ +
411
│ │ │ │ +
413 const ParallelIndexSet* target_;
│ │ │ │ +
414
│ │ │ │ +
416 MPI_Comm comm_;
│ │ │ │ +
417
│ │ │ │ +
420 std::set<int> neighbourIds;
│ │ │ │ +
421
│ │ │ │ +
423 const static int commTag_=333;
│ │ │ │ +
424
│ │ │ │ +
429 int sourceSeqNo_;
│ │ │ │ +
430
│ │ │ │ +
435 int destSeqNo_;
│ │ │ │ +
436
│ │ │ │ +
440 bool publicIgnored;
│ │ │ │ +
441
│ │ │ │ +
445 bool firstBuild;
│ │ │ │ +
446
│ │ │ │ +
447 /*
│ │ │ │ +
448 * @brief If true, sending from indices of the processor to other
│ │ │ │ +
449 * indices on the same processor is enabled even if the same indexset is used
│ │ │ │ +
450 * on both the
│ │ │ │ +
451 * sending and receiving side.
│ │ │ │ +
452 */
│ │ │ │ +
453 bool includeSelf;
│ │ │ │ +
454
│ │ │ │ + │ │ │ │ +
457 PairType;
│ │ │ │ +
458
│ │ │ │ +
465 RemoteIndexMap remoteIndices_;
│ │ │ │ +
466
│ │ │ │ +
477 template<bool ignorePublic>
│ │ │ │ +
478 inline void buildRemote(bool includeSelf);
│ │ │ │ +
479
│ │ │ │ +
485 inline int noPublic(const ParallelIndexSet& indexSet);
│ │ │ │
486
│ │ │ │ -
│ │ │ │ -
488 static constexpr size_type M ()
│ │ │ │ -
489 {
│ │ │ │ -
490 return n;
│ │ │ │ -
491 }
│ │ │ │ -
│ │ │ │ -
492
│ │ │ │ -
493
│ │ │ │ -
494
│ │ │ │ -
495 //===== query
│ │ │ │ -
496
│ │ │ │ -
│ │ │ │ -
498 bool exists (size_type i, size_type j) const
│ │ │ │ -
499 {
│ │ │ │ -
500 DUNE_ASSERT_BOUNDS(i >= 0 && i < n);
│ │ │ │ -
501 DUNE_ASSERT_BOUNDS(j >= 0 && j < n);
│ │ │ │ -
502 return i==j;
│ │ │ │ -
503 }
│ │ │ │ -
│ │ │ │ -
504
│ │ │ │ -
505
│ │ │ │ -
506
│ │ │ │ -
│ │ │ │ -
508 friend std::ostream& operator<< (std::ostream& s, const DiagonalMatrix<K,n>& a)
│ │ │ │ -
509 {
│ │ │ │ -
510 for (size_type i=0; i<n; i++) {
│ │ │ │ -
511 for (size_type j=0; j<n; j++)
│ │ │ │ -
512 s << ((i==j) ? a.diag_[i] : 0) << " ";
│ │ │ │ -
513 s << std::endl;
│ │ │ │ -
514 }
│ │ │ │ -
515 return s;
│ │ │ │ -
516 }
│ │ │ │ -
│ │ │ │ -
517
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
520 {
│ │ │ │ -
521 return reference(const_cast<K*>(&diag_[i]), i);
│ │ │ │ -
522 }
│ │ │ │ -
│ │ │ │ -
523
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
526 {
│ │ │ │ -
527 return const_reference(const_cast<K*>(&diag_[i]), i);
│ │ │ │ -
528 }
│ │ │ │ -
│ │ │ │ -
529
│ │ │ │ -
│ │ │ │ -
531 const K& diagonal(size_type i) const
│ │ │ │ -
532 {
│ │ │ │ -
533 return diag_[i];
│ │ │ │ -
534 }
│ │ │ │ -
│ │ │ │ -
535
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
538 {
│ │ │ │ -
539 return diag_[i];
│ │ │ │ -
540 }
│ │ │ │ -
│ │ │ │ -
541
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
544 {
│ │ │ │ -
545 return diag_;
│ │ │ │ -
546 }
│ │ │ │ -
│ │ │ │ -
547
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
550 {
│ │ │ │ -
551 return diag_;
│ │ │ │ -
552 }
│ │ │ │ -
│ │ │ │ -
553
│ │ │ │ -
554 private:
│ │ │ │ +
498 template<bool ignorePublic>
│ │ │ │ +
499 inline void packEntries(PairType** myPairs, const ParallelIndexSet& indexSet,
│ │ │ │ +
500 char* p_out, MPI_Datatype type, int bufferSize,
│ │ │ │ +
501 int* position, int n);
│ │ │ │ +
502
│ │ │ │ +
516 inline void unpackIndices(RemoteIndexList& remote, int remoteEntries,
│ │ │ │ +
517 PairType** local, int localEntries, char* p_in,
│ │ │ │ +
518 MPI_Datatype type, int* position, int bufferSize,
│ │ │ │ +
519 bool fromOurself);
│ │ │ │ +
520
│ │ │ │ +
521 inline void unpackIndices(RemoteIndexList& send, RemoteIndexList& receive,
│ │ │ │ +
522 int remoteEntries, PairType** localSource,
│ │ │ │ +
523 int localSourceEntries, PairType** localDest,
│ │ │ │ +
524 int localDestEntries, char* p_in,
│ │ │ │ +
525 MPI_Datatype type, int* position, int bufferSize);
│ │ │ │ +
526
│ │ │ │ +
527 void unpackCreateRemote(char* p_in, PairType** sourcePairs, PairType** DestPairs,
│ │ │ │ +
528 int remoteProc, int sourcePublish, int destPublish,
│ │ │ │ +
529 int bufferSize, bool sendTwo, bool fromOurSelf=false);
│ │ │ │ +
530 };
│ │ │ │ +
│ │ │ │ +
531
│ │ │ │ +
549 template<class T, class A, bool mode>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
551 {
│ │ │ │ +
552
│ │ │ │ +
553 template<typename T1, typename A1>
│ │ │ │ +
554 friend class RemoteIndices;
│ │ │ │
555
│ │ │ │ -
556 // the data, a FieldVector storing the diagonal
│ │ │ │ -
557 FieldVector<K,n> diag_;
│ │ │ │ -
558 };
│ │ │ │ +
556 public:
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
558 {};
│ │ │ │
│ │ │ │
559
│ │ │ │ -
560 template< class K, int n >
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
562 {
│ │ │ │ - │ │ │ │ - │ │ │ │ -
565 };
│ │ │ │ -
│ │ │ │ -
566
│ │ │ │ -
567
│ │ │ │ -
568#ifndef DOXYGEN // hide specialization
│ │ │ │ -
571 template< class K >
│ │ │ │ -
572 class DiagonalMatrix<K, 1> : public FieldMatrix<K, 1, 1>
│ │ │ │ -
573 {
│ │ │ │ -
574 typedef FieldMatrix<K,1,1> Base;
│ │ │ │ -
575 public:
│ │ │ │ -
577 typedef typename Base::size_type size_type;
│ │ │ │ -
578
│ │ │ │ -
581 constexpr static int blocklevel = 1;
│ │ │ │ -
582
│ │ │ │ -
583 typedef typename Base::row_type row_type;
│ │ │ │ +
568 constexpr static bool MODIFYINDEXSET = mode;
│ │ │ │ +
569
│ │ │ │ + │ │ │ │ +
574
│ │ │ │ + │ │ │ │ +
579
│ │ │ │ + │ │ │ │
584
│ │ │ │ -
585 typedef typename Base::row_reference row_reference;
│ │ │ │ -
586 typedef typename Base::const_row_reference const_row_reference;
│ │ │ │ -
587
│ │ │ │ -
590 constexpr static int rows = 1;
│ │ │ │ -
593 constexpr static int cols = 1;
│ │ │ │ +
588 typedef typename LocalIndex::Attribute Attribute;
│ │ │ │ +
589
│ │ │ │ + │ │ │ │
594
│ │ │ │ -
595
│ │ │ │ -
597 constexpr DiagonalMatrix() = default;
│ │ │ │ -
598
│ │ │ │ -
600 DiagonalMatrix(const K& scalar)
│ │ │ │ -
601 {
│ │ │ │ -
602 (*this)[0][0] = scalar;
│ │ │ │ -
603 }
│ │ │ │ -
604
│ │ │ │ -
606 const K& diagonal(size_type) const
│ │ │ │ -
607 {
│ │ │ │ -
608 return (*this)[0][0];
│ │ │ │ -
609 }
│ │ │ │ -
610
│ │ │ │ - │ │ │ │ -
613 {
│ │ │ │ -
614 return (*this)[0][0];
│ │ │ │ -
615 }
│ │ │ │ -
616
│ │ │ │ -
618 const FieldVector<K,1>& diagonal() const
│ │ │ │ -
619 {
│ │ │ │ -
620 return (*this)[0];
│ │ │ │ -
621 }
│ │ │ │ -
622
│ │ │ │ -
624 FieldVector<K,1>& diagonal()
│ │ │ │ -
625 {
│ │ │ │ -
626 return (*this)[0];
│ │ │ │ -
627 }
│ │ │ │ +
598 typedef A Allocator;
│ │ │ │ +
599
│ │ │ │ + │ │ │ │ + │ │ │ │ +
603
│ │ │ │ + │ │ │ │ +
608
│ │ │ │ + │ │ │ │ +
613
│ │ │ │ +
627 void insert(const RemoteIndex& index);
│ │ │ │
628
│ │ │ │ -
630 DiagonalMatrix<K, 1> transposed() const
│ │ │ │ -
631 {
│ │ │ │ -
632 return *this;
│ │ │ │ -
633 }
│ │ │ │ -
634
│ │ │ │ -
637 template <class OtherScalar>
│ │ │ │ -
638 friend auto operator* ( const DiagonalMatrix& matrixA,
│ │ │ │ -
639 const DiagonalMatrix<OtherScalar, 1>& matrixB)
│ │ │ │ -
640 {
│ │ │ │ -
641 return DiagonalMatrix<typename PromotionTraits<K,OtherScalar>::PromotedType, 1>{matrixA.diagonal(0)*matrixB.diagonal(0)};
│ │ │ │ -
642 }
│ │ │ │ -
643
│ │ │ │ -
644 };
│ │ │ │ -
645#endif
│ │ │ │ -
646
│ │ │ │ -
647
│ │ │ │ -
648 template<class DiagonalMatrixType>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
650 {
│ │ │ │ -
651 typedef typename DiagonalMatrixType::reference reference;
│ │ │ │ -
652 typedef typename DiagonalMatrixType::const_reference const_reference;
│ │ │ │ -
653 typedef typename DiagonalMatrixType::field_type K;
│ │ │ │ - │ │ │ │ -
655 typedef std::size_t size_type;
│ │ │ │ - │ │ │ │ -
657
│ │ │ │ -
658 friend class ContainerWrapperIterator<const MyType, reference, reference>;
│ │ │ │ -
659 friend class ContainerWrapperIterator<const MyType, const_reference, const_reference>;
│ │ │ │ -
660
│ │ │ │ -
661 public:
│ │ │ │ -
662
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
664 mat_(0)
│ │ │ │ -
665 {}
│ │ │ │ -
│ │ │ │ -
666
│ │ │ │ -
│ │ │ │ -
667 DiagonalMatrixWrapper(const DiagonalMatrixType* mat) :
│ │ │ │ -
668 mat_(const_cast<DiagonalMatrixType*>(mat))
│ │ │ │ -
669 {}
│ │ │ │ -
│ │ │ │ -
670
│ │ │ │ -
│ │ │ │ -
671 size_type realIndex(int i) const
│ │ │ │ -
672 {
│ │ │ │ -
673 return i;
│ │ │ │ -
674 }
│ │ │ │ -
│ │ │ │ -
675
│ │ │ │ +
629
│ │ │ │ +
644 void insert(const RemoteIndex& index, const GlobalIndex& global);
│ │ │ │ +
645
│ │ │ │ +
653 bool remove(const GlobalIndex& global);
│ │ │ │ +
654
│ │ │ │ + │ │ │ │ +
668
│ │ │ │ +
669
│ │ │ │ + │ │ │ │ +
671
│ │ │ │
│ │ │ │ -
676 row_type* pointer(int i) const
│ │ │ │ -
677 {
│ │ │ │ -
678 row_ = row_type(&(mat_->diagonal(i)), i);
│ │ │ │ -
679 return &row_;
│ │ │ │ -
680 }
│ │ │ │ + │ │ │ │ +
677 : glist_()
│ │ │ │ +
678 {}
│ │ │ │
│ │ │ │ +
679
│ │ │ │ +
680 private:
│ │ │ │
681
│ │ │ │ -
│ │ │ │ -
682 bool identical(const DiagonalMatrixWrapper& other) const
│ │ │ │ -
683 {
│ │ │ │ -
684 return mat_==other.mat_;
│ │ │ │ -
685 }
│ │ │ │ -
│ │ │ │ -
686
│ │ │ │ -
687 private:
│ │ │ │ -
688
│ │ │ │ -
689 mutable DiagonalMatrixType* mat_;
│ │ │ │ -
690 mutable row_type row_;
│ │ │ │ -
691 };
│ │ │ │ -
│ │ │ │ -
692
│ │ │ │ -
696 template< class K, int n >
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
698 {
│ │ │ │ -
699 template<class DiagonalMatrixType>
│ │ │ │ - │ │ │ │ -
701 friend class ContainerWrapperIterator<DiagonalRowVectorConst<K,n>, const K, const K&>;
│ │ │ │ -
702
│ │ │ │ -
703 public:
│ │ │ │ -
704 // remember size of vector
│ │ │ │ -
705 constexpr static int dimension = n;
│ │ │ │ -
706
│ │ │ │ -
707 // standard constructor and everything is sufficient ...
│ │ │ │ -
708
│ │ │ │ -
709 //===== type definitions and constants
│ │ │ │ -
710
│ │ │ │ -
712 typedef K field_type;
│ │ │ │ -
713
│ │ │ │ -
715 typedef K block_type;
│ │ │ │ -
716
│ │ │ │ -
718 typedef std::size_t size_type;
│ │ │ │ + │ │ │ │ +
688 RemoteIndexList& rList);
│ │ │ │ +
689
│ │ │ │ +
690 typedef SLList<GlobalIndex,Allocator> GlobalList;
│ │ │ │ +
691 typedef typename GlobalList::ModifyIterator GlobalModifyIterator;
│ │ │ │ +
692 RemoteIndexList* rList_;
│ │ │ │ +
693 const ParallelIndexSet* indexSet_;
│ │ │ │ +
694 GlobalList glist_;
│ │ │ │ +
695 ModifyIterator iter_;
│ │ │ │ +
696 GlobalModifyIterator giter_;
│ │ │ │ +
697 ConstIterator end_;
│ │ │ │ +
698 bool first_;
│ │ │ │ +
699 GlobalIndex last_;
│ │ │ │ +
700 };
│ │ │ │ +
│ │ │ │ +
701
│ │ │ │ +
706 template<class T, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
708 {
│ │ │ │ +
709
│ │ │ │ +
713 typedef T ParallelIndexSet;
│ │ │ │ +
714
│ │ │ │ +
718 typedef typename ParallelIndexSet::GlobalIndex GlobalIndex;
│ │ │ │
719
│ │ │ │ -
721 constexpr static int blocklevel = 1;
│ │ │ │ -
722
│ │ │ │ -
724 constexpr static int size = n;
│ │ │ │ -
725
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
728 p_(0),
│ │ │ │ -
729 row_(0)
│ │ │ │ -
730 {}
│ │ │ │ -
│ │ │ │ -
731
│ │ │ │ -
│ │ │ │ -
733 explicit DiagonalRowVectorConst (K* p, int col) :
│ │ │ │ -
734 p_(p),
│ │ │ │ -
735 row_(col)
│ │ │ │ -
736 {}
│ │ │ │ -
│ │ │ │ -
737
│ │ │ │ -
738 //===== access to components
│ │ │ │ -
739
│ │ │ │ -
│ │ │ │ -
741 const K& operator[] ([[maybe_unused]] size_type i) const
│ │ │ │ -
742 {
│ │ │ │ - │ │ │ │ -
744 return *p_;
│ │ │ │ -
745 }
│ │ │ │ -
│ │ │ │ -
746
│ │ │ │ -
747 // check if row is identical to other row (not only identical values)
│ │ │ │ -
748 // since this is a proxy class we need to check equality of the stored pointer
│ │ │ │ -
│ │ │ │ -
749 bool identical(const DiagonalRowVectorConst<K,n>& other) const
│ │ │ │ -
750 {
│ │ │ │ -
751 return ((p_ == other.p_)and (row_ == other.row_));
│ │ │ │ -
752 }
│ │ │ │ -
│ │ │ │ -
753
│ │ │ │ - │ │ │ │ - │ │ │ │ -
758
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
761 {
│ │ │ │ -
762 return ConstIterator(*this,0);
│ │ │ │ -
763 }
│ │ │ │ -
│ │ │ │ -
764
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
767 {
│ │ │ │ -
768 return ConstIterator(*this,1);
│ │ │ │ -
769 }
│ │ │ │ -
│ │ │ │ -
770
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
774 {
│ │ │ │ -
775 return ConstIterator(*this,0);
│ │ │ │ -
776 }
│ │ │ │ -
│ │ │ │ +
723 typedef typename ParallelIndexSet::LocalIndex LocalIndex;
│ │ │ │ +
724
│ │ │ │ +
728 typedef typename LocalIndex::Attribute Attribute;
│ │ │ │ +
729
│ │ │ │ + │ │ │ │ +
732
│ │ │ │ +
734 using Allocator = typename std::allocator_traits<A>::template rebind_alloc<RemoteIndex>;
│ │ │ │ +
735
│ │ │ │ + │ │ │ │ +
738
│ │ │ │ +
740 typedef std::map<int,std::pair<typename RemoteIndexList::const_iterator,
│ │ │ │ +
741 const typename RemoteIndexList::const_iterator> >
│ │ │ │ +
742 Map;
│ │ │ │ +
743
│ │ │ │ +
744 public:
│ │ │ │ +
745
│ │ │ │ +
747 typedef std::map<int, std::pair<RemoteIndexList*,RemoteIndexList*> >
│ │ │ │ + │ │ │ │ +
749
│ │ │ │ +
755 inline CollectiveIterator(const RemoteIndexMap& map_, bool send);
│ │ │ │ +
756
│ │ │ │ +
765 inline void advance(const GlobalIndex& global);
│ │ │ │ +
766
│ │ │ │ +
776 inline void advance(const GlobalIndex& global, const Attribute& attribute);
│ │ │ │
777
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
781 {
│ │ │ │ -
782 return ConstIterator(*this,-1);
│ │ │ │ -
783 }
│ │ │ │ -
│ │ │ │ + │ │ │ │ +
779
│ │ │ │ +
783 inline bool empty() const;
│ │ │ │
784
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
787 {
│ │ │ │ -
788 return ((p_==y.p_)and (row_==y.row_));
│ │ │ │ -
789 }
│ │ │ │ -
│ │ │ │ -
790
│ │ │ │ -
791 //===== sizes
│ │ │ │ -
792
│ │ │ │ -
│ │ │ │ -
794 size_type N () const
│ │ │ │ -
795 {
│ │ │ │ -
796 return n;
│ │ │ │ -
797 }
│ │ │ │ -
│ │ │ │ -
798
│ │ │ │ -
│ │ │ │ -
800 size_type dim () const
│ │ │ │ -
801 {
│ │ │ │ -
802 return n;
│ │ │ │ -
803 }
│ │ │ │ -
│ │ │ │ -
804
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
807 {
│ │ │ │ -
808 return row_;
│ │ │ │ -
809 }
│ │ │ │ -
│ │ │ │ -
810
│ │ │ │ -
│ │ │ │ -
812 const K& diagonal() const
│ │ │ │ -
813 {
│ │ │ │ -
814 return *p_;
│ │ │ │ -
815 }
│ │ │ │ -
│ │ │ │ -
816
│ │ │ │ -
817 protected:
│ │ │ │ -
818
│ │ │ │ -
│ │ │ │ -
819 size_type realIndex([[maybe_unused]] int i) const
│ │ │ │ -
820 {
│ │ │ │ -
821 return rowIndex();
│ │ │ │ -
822 }
│ │ │ │ -
│ │ │ │ -
823
│ │ │ │ -
│ │ │ │ -
824 K* pointer([[maybe_unused]] size_type i) const
│ │ │ │ -
825 {
│ │ │ │ -
826 return const_cast<K*>(p_);
│ │ │ │ -
827 }
│ │ │ │ -
│ │ │ │ -
828
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
830 {
│ │ │ │ -
831 return this;
│ │ │ │ -
832 }
│ │ │ │ -
│ │ │ │ -
833
│ │ │ │ -
834 // the data, very simply a pointer to the diagonal value and the row number
│ │ │ │ -
835 K* p_;
│ │ │ │ - │ │ │ │ -
837 };
│ │ │ │ -
│ │ │ │ -
838
│ │ │ │ -
839 template< class K, int n >
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
841 {
│ │ │ │ -
842 template<class DiagonalMatrixType>
│ │ │ │ - │ │ │ │ -
844 friend class ContainerWrapperIterator<DiagonalRowVector<K,n>, K, K&>;
│ │ │ │ -
845
│ │ │ │ -
846 public:
│ │ │ │ -
847 // standard constructor and everything is sufficient ...
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
792 {
│ │ │ │ +
793 public:
│ │ │ │ +
794 typedef typename Map::iterator RealIterator;
│ │ │ │ +
795 typedef typename Map::iterator ConstRealIterator;
│ │ │ │ +
796
│ │ │ │ +
797
│ │ │ │ +
│ │ │ │ +
799 iterator(const RealIterator& iter, const ConstRealIterator& end, GlobalIndex& index)
│ │ │ │ +
800 : iter_(iter), end_(end), index_(index), hasAttribute(false)
│ │ │ │ +
801 {
│ │ │ │ +
802 // Move to the first valid entry
│ │ │ │ +
803 while(iter_!=end_ && iter_->second.first->localIndexPair().global()!=index_)
│ │ │ │ +
804 ++iter_;
│ │ │ │ +
805 }
│ │ │ │ +
│ │ │ │ +
806
│ │ │ │ +
│ │ │ │ +
807 iterator(const RealIterator& iter, const ConstRealIterator& end, GlobalIndex index,
│ │ │ │ +
808 Attribute attribute)
│ │ │ │ +
809 : iter_(iter), end_(end), index_(index), attribute_(attribute), hasAttribute(true)
│ │ │ │ +
810 {
│ │ │ │ +
811 // Move to the first valid entry or the end
│ │ │ │ +
812 while(iter_!=end_ && (iter_->second.first->localIndexPair().global()!=index_
│ │ │ │ +
813 || iter_->second.first->localIndexPair().local().attribute()!=attribute))
│ │ │ │ +
814 ++iter_;
│ │ │ │ +
815 }
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
817 iterator(const iterator& other)
│ │ │ │ +
818 : iter_(other.iter_), end_(other.end_), index_(other.index_)
│ │ │ │ +
819 { }
│ │ │ │ +
│ │ │ │ +
820
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
823 {
│ │ │ │ +
824 ++iter_;
│ │ │ │ +
825 // If entry is not valid move on
│ │ │ │ +
826 while(iter_!=end_ && (iter_->second.first->localIndexPair().global()!=index_ ||
│ │ │ │ +
827 (hasAttribute &&
│ │ │ │ +
828 iter_->second.first->localIndexPair().local().attribute()!=attribute_)))
│ │ │ │ +
829 ++iter_;
│ │ │ │ +
830 assert(iter_==end_ ||
│ │ │ │ +
831 (iter_->second.first->localIndexPair().global()==index_));
│ │ │ │ +
832 assert(iter_==end_ || !hasAttribute ||
│ │ │ │ +
833 (iter_->second.first->localIndexPair().local().attribute()==attribute_));
│ │ │ │ +
834 return *this;
│ │ │ │ +
835 }
│ │ │ │ +
│ │ │ │ +
836
│ │ │ │ +
│ │ │ │ +
838 const RemoteIndex& operator*() const
│ │ │ │ +
839 {
│ │ │ │ +
840 return *(iter_->second.first);
│ │ │ │ +
841 }
│ │ │ │ +
│ │ │ │ +
842
│ │ │ │ +
│ │ │ │ +
844 int process() const
│ │ │ │ +
845 {
│ │ │ │ +
846 return iter_->first;
│ │ │ │ +
847 }
│ │ │ │ +
│ │ │ │
848
│ │ │ │ -
849 //===== type definitions and constants
│ │ │ │ -
850
│ │ │ │ -
852 typedef K field_type;
│ │ │ │ -
853
│ │ │ │ -
855 typedef K block_type;
│ │ │ │ -
856
│ │ │ │ -
858 typedef std::size_t size_type;
│ │ │ │ -
859
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
862 {}
│ │ │ │ -
│ │ │ │ -
863
│ │ │ │ -
│ │ │ │ -
865 explicit DiagonalRowVector (K* p, int col) : DiagonalRowVectorConst<K,n>(p, col)
│ │ │ │ -
866 {}
│ │ │ │ -
│ │ │ │ -
867
│ │ │ │ -
868 //===== assignment from scalar
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
871 {
│ │ │ │ -
872 *p_ = k;
│ │ │ │ -
873 return *this;
│ │ │ │ -
874 }
│ │ │ │ -
│ │ │ │ -
875
│ │ │ │ -
876 //===== access to components
│ │ │ │ -
877
│ │ │ │ -
│ │ │ │ -
879 K& operator[] ([[maybe_unused]] size_type i)
│ │ │ │ -
880 {
│ │ │ │ - │ │ │ │ -
882 return *p_;
│ │ │ │ -
883 }
│ │ │ │ -
│ │ │ │ -
884
│ │ │ │ - │ │ │ │ - │ │ │ │ -
889
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
892 {
│ │ │ │ -
893 return Iterator(*this, 0);
│ │ │ │ -
894 }
│ │ │ │ -
│ │ │ │ -
895
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
898 {
│ │ │ │ -
899 return Iterator(*this, 1);
│ │ │ │ -
900 }
│ │ │ │ -
│ │ │ │ -
901
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
905 {
│ │ │ │ -
906 return Iterator(*this, 0);
│ │ │ │ -
907 }
│ │ │ │ -
│ │ │ │ -
908
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
912 {
│ │ │ │ -
913 return Iterator(*this, -1);
│ │ │ │ -
914 }
│ │ │ │ +
│ │ │ │ +
850 const RemoteIndex* operator->() const
│ │ │ │ +
851 {
│ │ │ │ +
852 return iter_->second.first.operator->();
│ │ │ │ +
853 }
│ │ │ │ +
│ │ │ │ +
854
│ │ │ │ +
│ │ │ │ +
856 bool operator==(const iterator& other) const
│ │ │ │ +
857 {
│ │ │ │ +
858 return other.iter_==iter_;
│ │ │ │ +
859 }
│ │ │ │ +
│ │ │ │ +
860
│ │ │ │ +
│ │ │ │ +
862 bool operator!=(const iterator& other) const
│ │ │ │ +
863 {
│ │ │ │ +
864 return other.iter_!=iter_;
│ │ │ │ +
865 }
│ │ │ │ +
│ │ │ │ +
866
│ │ │ │ +
867 private:
│ │ │ │ +
868 iterator();
│ │ │ │ +
869
│ │ │ │ +
870 RealIterator iter_;
│ │ │ │ +
871 RealIterator end_;
│ │ │ │ +
872 GlobalIndex index_;
│ │ │ │ +
873 Attribute attribute_;
│ │ │ │ +
874 bool hasAttribute;
│ │ │ │ +
875 };
│ │ │ │ +
│ │ │ │ +
876
│ │ │ │ +
877 iterator begin();
│ │ │ │ +
878
│ │ │ │ +
879 iterator end();
│ │ │ │ +
880
│ │ │ │ +
881 private:
│ │ │ │ +
882
│ │ │ │ +
883 Map map_;
│ │ │ │ +
884 GlobalIndex index_;
│ │ │ │ +
885 Attribute attribute_;
│ │ │ │ +
886 bool noattribute;
│ │ │ │ +
887 };
│ │ │ │ +
│ │ │ │ +
888
│ │ │ │ +
889 template<typename TG, typename TA>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
891 {
│ │ │ │ +
892 if(type==MPI_DATATYPE_NULL) {
│ │ │ │ +
893 int length[2] = {1, 1};
│ │ │ │ +
894 MPI_Aint base;
│ │ │ │ +
895 MPI_Aint disp[2];
│ │ │ │ +
896 MPI_Datatype types[2] = {MPITraits<TG>::getType(),
│ │ │ │ + │ │ │ │ + │ │ │ │ +
899 MPI_Get_address(&rep, &base); // lower bound of the datatype
│ │ │ │ +
900 MPI_Get_address(&(rep.global_), &disp[0]);
│ │ │ │ +
901 MPI_Get_address(&(rep.local_), &disp[1]);
│ │ │ │ +
902 for (MPI_Aint& d : disp)
│ │ │ │ +
903 d -= base;
│ │ │ │ +
904
│ │ │ │ +
905 MPI_Datatype tmp;
│ │ │ │ +
906 MPI_Type_create_struct(2, length, disp, types, &tmp);
│ │ │ │ +
907
│ │ │ │ +
908 MPI_Type_create_resized(tmp, 0, sizeof(IndexPair<TG,ParallelLocalIndex<TA> >), &type);
│ │ │ │ +
909 MPI_Type_commit(&type);
│ │ │ │ +
910
│ │ │ │ +
911 MPI_Type_free(&tmp);
│ │ │ │ +
912 }
│ │ │ │ +
913 return type;
│ │ │ │ +
914 }
│ │ │ │
│ │ │ │
915
│ │ │ │ - │ │ │ │ - │ │ │ │ -
920
│ │ │ │ - │ │ │ │ -
922 using DiagonalRowVectorConst<K,n>::operator[];
│ │ │ │ -
923 using DiagonalRowVectorConst<K,n>::operator==;
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
928 using DiagonalRowVectorConst<K,n>::N;
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
932
│ │ │ │ -
933 protected:
│ │ │ │ -
934
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
936 {
│ │ │ │ -
937 return this;
│ │ │ │ -
938 }
│ │ │ │ -
│ │ │ │ -
939
│ │ │ │ -
940 private:
│ │ │ │ -
941
│ │ │ │ - │ │ │ │ - │ │ │ │ -
944 };
│ │ │ │ -
│ │ │ │ -
945
│ │ │ │ -
946
│ │ │ │ -
947 // implement type traits
│ │ │ │ -
948 template<class K, int n>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
950 {
│ │ │ │ - │ │ │ │ -
952 };
│ │ │ │ -
│ │ │ │ -
953
│ │ │ │ -
954 template<class K, int n>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
956 {
│ │ │ │ - │ │ │ │ -
958 };
│ │ │ │ -
│ │ │ │ -
959
│ │ │ │ -
960 template<class K, int n>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
962 {
│ │ │ │ - │ │ │ │ -
964 };
│ │ │ │ -
│ │ │ │ -
965
│ │ │ │ -
966 template<class K, int n>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
968 {
│ │ │ │ - │ │ │ │ -
970 };
│ │ │ │ -
│ │ │ │ -
971
│ │ │ │ -
972
│ │ │ │ -
973
│ │ │ │ -
996 template<class CW, class T, class R>
│ │ │ │ -
│ │ │ │ -
997 class ContainerWrapperIterator : public BidirectionalIteratorFacade<ContainerWrapperIterator<CW,T,R>,T, R, int>
│ │ │ │ -
998 {
│ │ │ │ -
999 typedef typename std::remove_const<CW>::type NonConstCW;
│ │ │ │ -
1000
│ │ │ │ -
1001 friend class ContainerWrapperIterator<CW, typename mutable_reference<T>::type, typename mutable_reference<R>::type>;
│ │ │ │ -
1002 friend class ContainerWrapperIterator<CW, typename const_reference<T>::type, typename const_reference<R>::type>;
│ │ │ │ -
1003
│ │ │ │ -
1004 typedef ContainerWrapperIterator<CW, typename mutable_reference<T>::type, typename mutable_reference<R>::type> MyType;
│ │ │ │ -
1005 typedef ContainerWrapperIterator<CW, typename const_reference<T>::type, typename const_reference<R>::type> MyConstType;
│ │ │ │ -
1006
│ │ │ │ -
1007 public:
│ │ │ │ -
1008
│ │ │ │ -
1009 // Constructors needed by the facade iterators.
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
1011 containerWrapper_(),
│ │ │ │ -
1012 position_(0)
│ │ │ │ -
1013 {}
│ │ │ │ -
│ │ │ │ -
1014
│ │ │ │ -
│ │ │ │ -
1015 ContainerWrapperIterator(CW containerWrapper, int position) :
│ │ │ │ -
1016 containerWrapper_(containerWrapper),
│ │ │ │ -
1017 position_(position)
│ │ │ │ -
1018 {}
│ │ │ │ +
916 template<typename TG, typename TA>
│ │ │ │ +
917 MPI_Datatype MPITraits<IndexPair<TG,ParallelLocalIndex<TA> > >::type=MPI_DATATYPE_NULL;
│ │ │ │ +
918
│ │ │ │ +
919 template<typename T1, typename T2>
│ │ │ │ +
│ │ │ │ +
920 RemoteIndex<T1,T2>::RemoteIndex(const T2& attribute, const PairType* local)
│ │ │ │ +
921 : localIndex_(local), attribute_(static_cast<std::underlying_type_t<T2>>(attribute))
│ │ │ │ +
922 {}
│ │ │ │ +
│ │ │ │ +
923
│ │ │ │ +
924 template<typename T1, typename T2>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
926 : localIndex_(0), attribute_(static_cast<std::underlying_type_t<T2>>(attribute))
│ │ │ │ +
927 {}
│ │ │ │ +
│ │ │ │ +
928
│ │ │ │ +
929 template<typename T1, typename T2>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
931 : localIndex_(0), attribute_()
│ │ │ │ +
932 {}
│ │ │ │ +
│ │ │ │ +
933 template<typename T1, typename T2>
│ │ │ │ +
│ │ │ │ +
934 inline bool RemoteIndex<T1,T2>::operator==(const RemoteIndex& ri) const
│ │ │ │ +
935 {
│ │ │ │ +
936 return localIndex_==ri.localIndex_ && attribute_==ri.attribute;
│ │ │ │ +
937 }
│ │ │ │ +
│ │ │ │ +
938
│ │ │ │ +
939 template<typename T1, typename T2>
│ │ │ │ +
│ │ │ │ +
940 inline bool RemoteIndex<T1,T2>::operator!=(const RemoteIndex& ri) const
│ │ │ │ +
941 {
│ │ │ │ +
942 return localIndex_!=ri.localIndex_ || attribute_!=ri.attribute_;
│ │ │ │ +
943 }
│ │ │ │ +
│ │ │ │ +
944
│ │ │ │ +
945 template<typename T1, typename T2>
│ │ │ │ +
│ │ │ │ +
946 inline const T2 RemoteIndex<T1,T2>::attribute() const
│ │ │ │ +
947 {
│ │ │ │ +
948 return T2(attribute_);
│ │ │ │ +
949 }
│ │ │ │ +
│ │ │ │ +
950
│ │ │ │ +
951 template<typename T1, typename T2>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
953 {
│ │ │ │ +
954 return *localIndex_;
│ │ │ │ +
955 }
│ │ │ │ +
│ │ │ │ +
956
│ │ │ │ +
957 template<typename T, typename A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
959 const ParallelIndexSet& destination,
│ │ │ │ +
960 const MPI_Comm& comm,
│ │ │ │ +
961 const std::vector<int>& neighbours,
│ │ │ │ +
962 bool includeSelf_)
│ │ │ │ +
963 : source_(&source), target_(&destination), comm_(comm),
│ │ │ │ +
964 sourceSeqNo_(-1), destSeqNo_(-1), publicIgnored(false), firstBuild(true),
│ │ │ │ +
965 includeSelf(includeSelf_)
│ │ │ │ +
966 {
│ │ │ │ + │ │ │ │ +
968 }
│ │ │ │ +
│ │ │ │ +
969
│ │ │ │ +
970 template<typename T, typename A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
972 {
│ │ │ │ +
973 includeSelf=b;
│ │ │ │ +
974 }
│ │ │ │ +
│ │ │ │ +
975
│ │ │ │ +
976 template<typename T, typename A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
978 : source_(0), target_(0), sourceSeqNo_(-1),
│ │ │ │ +
979 destSeqNo_(-1), publicIgnored(false), firstBuild(true),
│ │ │ │ +
980 includeSelf(false)
│ │ │ │ +
981 {}
│ │ │ │ +
│ │ │ │ +
982
│ │ │ │ +
983 template<class T, typename A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
985 const ParallelIndexSet& destination,
│ │ │ │ +
986 const MPI_Comm& comm,
│ │ │ │ +
987 const std::vector<int>& neighbours)
│ │ │ │ +
988 {
│ │ │ │ +
989 free();
│ │ │ │ +
990 source_ = &source;
│ │ │ │ +
991 target_ = &destination;
│ │ │ │ +
992 comm_ = comm;
│ │ │ │ +
993 firstBuild = true;
│ │ │ │ +
994 setNeighbours(neighbours);
│ │ │ │ +
995 }
│ │ │ │ +
│ │ │ │ +
996
│ │ │ │ +
997 template<typename T, typename A>
│ │ │ │ + │ │ │ │ +
│ │ │ │ + │ │ │ │ +
1000 {
│ │ │ │ +
1001 return *source_;
│ │ │ │ +
1002 }
│ │ │ │
│ │ │ │ -
1019
│ │ │ │ -
1020 template<class OtherContainerWrapperIteratorType>
│ │ │ │ +
1003
│ │ │ │ +
1004
│ │ │ │ +
1005 template<typename T, typename A>
│ │ │ │ + │ │ │ │ +
│ │ │ │ + │ │ │ │ +
1008 {
│ │ │ │ +
1009 return *target_;
│ │ │ │ +
1010 }
│ │ │ │ +
│ │ │ │ +
1011
│ │ │ │ +
1012
│ │ │ │ +
1013 template<typename T, typename A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
1015 {
│ │ │ │ +
1016 free();
│ │ │ │ +
1017 }
│ │ │ │ +
│ │ │ │ +
1018
│ │ │ │ +
1019 template<typename T, typename A>
│ │ │ │ +
1020 template<bool ignorePublic>
│ │ │ │
│ │ │ │ -
1021 ContainerWrapperIterator(OtherContainerWrapperIteratorType& other) :
│ │ │ │ -
1022 containerWrapper_(other.containerWrapper_),
│ │ │ │ -
1023 position_(other.position_)
│ │ │ │ -
1024 {}
│ │ │ │ -
│ │ │ │ -
1025
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
1027 containerWrapper_(other.containerWrapper_),
│ │ │ │ -
1028 position_(other.position_)
│ │ │ │ -
1029 {}
│ │ │ │ -
│ │ │ │ + │ │ │ │ +
1022 const ParallelIndexSet& indexSet,
│ │ │ │ +
1023 char* p_out, MPI_Datatype type,
│ │ │ │ +
1024 int bufferSize,
│ │ │ │ +
1025 int *position,
│ │ │ │ +
1026 [[maybe_unused]] int n)
│ │ │ │ +
1027 {
│ │ │ │ +
1028 // fill with own indices
│ │ │ │ +
1029 const auto end = indexSet.end();
│ │ │ │
1030
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
1032 containerWrapper_(other.containerWrapper_),
│ │ │ │ -
1033 position_(other.position_)
│ │ │ │ -
1034 {}
│ │ │ │ -
│ │ │ │ +
1031 //Now pack the source indices
│ │ │ │ +
1032 int i=0;
│ │ │ │ +
1033 for(auto index = indexSet.begin(); index != end; ++index)
│ │ │ │ +
1034 if(ignorePublic || index->local().isPublic()) {
│ │ │ │
1035
│ │ │ │ -
1036 template<class OtherContainerWrapperIteratorType>
│ │ │ │ -
│ │ │ │ -
1037 ContainerWrapperIterator& operator=(OtherContainerWrapperIteratorType& other)
│ │ │ │ -
1038 {
│ │ │ │ -
1039 containerWrapper_ = other.containerWrapper_;
│ │ │ │ -
1040 position_ = other.position_;
│ │ │ │ -
1041 return *this;
│ │ │ │ -
1042 }
│ │ │ │ -
│ │ │ │ -
1043
│ │ │ │ -
1044 // This operator is needed since we can not get the address of the
│ │ │ │ -
1045 // temporary object returned by dereference
│ │ │ │ -
│ │ │ │ -
1046 T* operator->() const
│ │ │ │ -
1047 {
│ │ │ │ -
1048 return containerWrapper_.pointer(position_);
│ │ │ │ -
1049 }
│ │ │ │ -
│ │ │ │ +
1036 MPI_Pack(const_cast<PairType*>(&(*index)), 1,
│ │ │ │ +
1037 type,
│ │ │ │ +
1038 p_out, bufferSize, position, comm_);
│ │ │ │ +
1039 pairs[i++] = const_cast<PairType*>(&(*index));
│ │ │ │ +
1040
│ │ │ │ +
1041 }
│ │ │ │ +
1042 assert(i==n);
│ │ │ │ +
1043 }
│ │ │ │ +
│ │ │ │ +
1044
│ │ │ │ +
1045 template<typename T, typename A>
│ │ │ │ +
1046 inline int RemoteIndices<T,A>::noPublic(const ParallelIndexSet& indexSet)
│ │ │ │ +
1047 {
│ │ │ │ +
1048
│ │ │ │ +
1049 int noPublic=0;
│ │ │ │
1050
│ │ │ │ -
1051 // Methods needed by the forward iterator
│ │ │ │ -
│ │ │ │ -
1052 bool equals(const MyType& other) const
│ │ │ │ -
1053 {
│ │ │ │ -
1054 return position_ == other.position_ && containerWrapper_.identical(other.containerWrapper_);
│ │ │ │ -
1055 }
│ │ │ │ -
│ │ │ │ -
1056
│ │ │ │ -
│ │ │ │ -
1057 bool equals(const MyConstType& other) const
│ │ │ │ -
1058 {
│ │ │ │ -
1059 return position_ == other.position_ && containerWrapper_.identical(other.containerWrapper_);
│ │ │ │ -
1060 }
│ │ │ │ -
│ │ │ │ -
1061
│ │ │ │ -
│ │ │ │ -
1062 R dereference() const
│ │ │ │ -
1063 {
│ │ │ │ -
1064 return *containerWrapper_.pointer(position_);
│ │ │ │ -
1065 }
│ │ │ │ -
│ │ │ │ -
1066
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
1068 {
│ │ │ │ -
1069 ++position_;
│ │ │ │ -
1070 }
│ │ │ │ -
│ │ │ │ -
1071
│ │ │ │ -
1072 // Additional function needed by BidirectionalIterator
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
1074 {
│ │ │ │ -
1075 --position_;
│ │ │ │ -
1076 }
│ │ │ │ -
│ │ │ │ -
1077
│ │ │ │ -
1078 // Additional function needed by RandomAccessIterator
│ │ │ │ -
│ │ │ │ -
1079 R elementAt(int i) const
│ │ │ │ -
1080 {
│ │ │ │ -
1081 return *containerWrapper_.pointer(position_+i);
│ │ │ │ -
1082 }
│ │ │ │ -
│ │ │ │ -
1083
│ │ │ │ -
│ │ │ │ -
1084 void advance(int n)
│ │ │ │ -
1085 {
│ │ │ │ -
1086 position_=position_+n;
│ │ │ │ -
1087 }
│ │ │ │ -
│ │ │ │ -
1088
│ │ │ │ -
1089 template<class OtherContainerWrapperIteratorType>
│ │ │ │ -
│ │ │ │ -
1090 std::ptrdiff_t distanceTo(OtherContainerWrapperIteratorType& other) const
│ │ │ │ -
1091 {
│ │ │ │ -
1092 assert(containerWrapper_.identical(other));
│ │ │ │ -
1093 return other.position_ - position_;
│ │ │ │ -
1094 }
│ │ │ │ -
│ │ │ │ -
1095
│ │ │ │ -
│ │ │ │ -
1096 std::ptrdiff_t index() const
│ │ │ │ -
1097 {
│ │ │ │ -
1098 return containerWrapper_.realIndex(position_);
│ │ │ │ -
1099 }
│ │ │ │ -
│ │ │ │ -
1100
│ │ │ │ -
1101 private:
│ │ │ │ -
1102 NonConstCW containerWrapper_;
│ │ │ │ -
1103 size_t position_;
│ │ │ │ -
1104 };
│ │ │ │ -
│ │ │ │ -
1105
│ │ │ │ -
1106 template <class DenseMatrix, class field, int N>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
1108 static void apply(DenseMatrix& denseMatrix,
│ │ │ │ -
1109 DiagonalMatrix<field, N> const& rhs) {
│ │ │ │ -
1110 DUNE_ASSERT_BOUNDS(denseMatrix.M() == N);
│ │ │ │ -
1111 DUNE_ASSERT_BOUNDS(denseMatrix.N() == N);
│ │ │ │ -
1112 denseMatrix = field(0);
│ │ │ │ -
1113 for (int i = 0; i < N; ++i)
│ │ │ │ -
1114 denseMatrix[i][i] = rhs.diagonal()[i];
│ │ │ │ -
1115 }
│ │ │ │ -
│ │ │ │ -
1116 };
│ │ │ │ -
│ │ │ │ -
1117 /* @} */
│ │ │ │ -
1118} // end namespace
│ │ │ │ -
1119#endif
│ │ │ │ -
Traits for type conversions and type information.
│ │ │ │ -
Implements a matrix constructed from a given type representing a field and compile-time given number ...
│ │ │ │ -
A few common exception classes.
│ │ │ │ -
Implements a matrix constructed from a given type representing a field and a compile-time given numbe...
│ │ │ │ -
Implements a vector constructed from a given type representing a field and a compile-time given size.
│ │ │ │ -
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
│ │ │ │ -
ConstIterator beforeBegin() const
Definition diagonalmatrix.hh:208
│ │ │ │ -
DiagonalMatrix< K, n > transposed() const
Return transposed of the matrix as DiagonalMatrix.
Definition diagonalmatrix.hh:136
│ │ │ │ -
void mmhv(const X &x, Y &y) const
y -= A^H x
Definition diagonalmatrix.hh:357
│ │ │ │ -
DiagonalMatrix & operator*=(const K &k)
vector space multiplication with scalar
Definition diagonalmatrix.hh:246
│ │ │ │ -
FieldTraits< K >::field_type field_type
Definition diagonalmatrix.hh:563
│ │ │ │ -
std::size_t size_type
The type used for the index access and size operations.
Definition diagonalmatrix.hh:67
│ │ │ │ -
size_type dim() const
dimension of the vector space
Definition diagonalmatrix.hh:800
│ │ │ │ -
ConstIterator ConstRowIterator
rename the iterators for easier access
Definition diagonalmatrix.hh:183
│ │ │ │ -
row_type row_reference
Definition diagonalmatrix.hh:75
│ │ │ │ -
K & operator[](size_type i)
random access
Definition diagonalmatrix.hh:879
│ │ │ │ -
ContainerWrapperIterator & operator=(OtherContainerWrapperIteratorType &other)
Definition diagonalmatrix.hh:1037
│ │ │ │ -
static constexpr int rows
The number of rows.
Definition diagonalmatrix.hh:81
│ │ │ │ -
static constexpr size_type M()
number of blocks in column direction
Definition diagonalmatrix.hh:488
│ │ │ │ -
FieldVector< K, n > & diagonal()
Get reference to diagonal vector.
Definition diagonalmatrix.hh:549
│ │ │ │ -
void usmhv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) const
y += alpha A^H x
Definition diagonalmatrix.hh:395
│ │ │ │ -
Iterator iterator
typedef for stl compliant access
Definition diagonalmatrix.hh:888
│ │ │ │ -
void increment()
Definition diagonalmatrix.hh:1067
│ │ │ │ -
static constexpr int blocklevel
The number of block levels we contain. This is the leaf, that is, 1.
Definition diagonalmatrix.hh:70
│ │ │ │ -
DiagonalRowVectorConst< K, n > type
Definition diagonalmatrix.hh:957
│ │ │ │ -
T * operator->() const
Definition diagonalmatrix.hh:1046
│ │ │ │ -
static constexpr int size
The size of this vector.
Definition diagonalmatrix.hh:724
│ │ │ │ -
K * pointer(size_type i) const
Definition diagonalmatrix.hh:824
│ │ │ │ -
K field_type
export the type representing the field
Definition diagonalmatrix.hh:712
│ │ │ │ -
DiagonalRowVector< K, n > type
Definition diagonalmatrix.hh:963
│ │ │ │ -
ConstIterator beforeEnd() const
Definition diagonalmatrix.hh:773
│ │ │ │ -
const_row_type::ConstIterator ConstColIterator
rename the iterators for easier access
Definition diagonalmatrix.hh:185
│ │ │ │ -
bool exists(size_type i, size_type j) const
return true when (i,j) is in pattern
Definition diagonalmatrix.hh:498
│ │ │ │ -
ContainerWrapperIterator< const WrapperType, const_reference, const_reference > ConstIterator
Iterator class for sequential access.
Definition diagonalmatrix.hh:179
│ │ │ │ -
const_row_type const_row_reference
Definition diagonalmatrix.hh:78
│ │ │ │ -
static constexpr size_type size()
Definition diagonalmatrix.hh:87
│ │ │ │ -
size_type row_
Definition diagonalmatrix.hh:836
│ │ │ │ -
ContainerWrapperIterator(CW containerWrapper, int position)
Definition diagonalmatrix.hh:1015
│ │ │ │ -
DiagonalRowVector(K *p, int col)
Constructor making vector with identical coordinates.
Definition diagonalmatrix.hh:865
│ │ │ │ -
K & diagonal(size_type i)
Get reference to diagonal entry.
Definition diagonalmatrix.hh:537
│ │ │ │ -
void solve(V &x, const V &b) const
Solve system A x = b.
Definition diagonalmatrix.hh:438
│ │ │ │ -
static constexpr size_type N()
number of blocks in row direction
Definition diagonalmatrix.hh:482
│ │ │ │ -
Iterator beforeBegin()
Definition diagonalmatrix.hh:911
│ │ │ │ -
ContainerWrapperIterator(OtherContainerWrapperIteratorType &other)
Definition diagonalmatrix.hh:1021
│ │ │ │ -
const_reference operator[](size_type i) const
Return const_reference object as row replacement.
Definition diagonalmatrix.hh:525
│ │ │ │ -
Iterator iterator
typedef for stl compliant access
Definition diagonalmatrix.hh:145
│ │ │ │ -
ConstIterator begin() const
begin ConstIterator
Definition diagonalmatrix.hh:760
│ │ │ │ -
ConstIterator const_iterator
typedef for stl compliant access
Definition diagonalmatrix.hh:919
│ │ │ │ -
bool identical(const DiagonalRowVectorConst< K, n > &other) const
Definition diagonalmatrix.hh:749
│ │ │ │ -
DiagonalMatrix & operator-=(const DiagonalMatrix &y)
vector space subtraction
Definition diagonalmatrix.hh:225
│ │ │ │ -
DiagonalRowVectorConst(K *p, int col)
Constructor making vector with identical coordinates.
Definition diagonalmatrix.hh:733
│ │ │ │ -
void mmtv(const X &x, Y &y) const
y -= A^T x
Definition diagonalmatrix.hh:345
│ │ │ │ -
static constexpr int blocklevel
The number of block levels we contain.
Definition diagonalmatrix.hh:721
│ │ │ │ -
row_type * pointer(int i) const
Definition diagonalmatrix.hh:676
│ │ │ │ -
DiagonalMatrix(const K &k)
Constructor initializing the whole matrix with a scalar.
Definition diagonalmatrix.hh:98
│ │ │ │ -
ContainerWrapperIterator< DiagonalRowVector< K, n >, K, K & > Iterator
Iterator class for sequential access.
Definition diagonalmatrix.hh:886
│ │ │ │ -
R elementAt(int i) const
Definition diagonalmatrix.hh:1079
│ │ │ │ -
std::ptrdiff_t distanceTo(OtherContainerWrapperIteratorType &other) const
Definition diagonalmatrix.hh:1090
│ │ │ │ -
Iterator beforeEnd()
Definition diagonalmatrix.hh:904
│ │ │ │ -
void umtv(const X &x, Y &y) const
y += A^T x
Definition diagonalmatrix.hh:309
│ │ │ │ -
ConstIterator const_iterator
typedef for stl compliant access
Definition diagonalmatrix.hh:757
│ │ │ │ -
double infinity_norm_real() const
simplified infinity norm (uses Manhattan norm for complex values)
Definition diagonalmatrix.hh:427
│ │ │ │ -
DiagonalMatrixWrapper(const DiagonalMatrixType *mat)
Definition diagonalmatrix.hh:667
│ │ │ │ -
void umv(const X &x, Y &y) const
y += A x
Definition diagonalmatrix.hh:297
│ │ │ │ -
ContainerWrapperIterator< const WrapperType, reference, reference > Iterator
Iterator class for sequential access.
Definition diagonalmatrix.hh:143
│ │ │ │ -
DiagonalRowVector< K, n > type
Definition diagonalmatrix.hh:969
│ │ │ │ -
void mv(const X &x, Y &y) const
y = A x
Definition diagonalmatrix.hh:278
│ │ │ │ -
double frobenius_norm() const
frobenius norm: sqrt(sum over squared values of entries)
Definition diagonalmatrix.hh:409
│ │ │ │ -
ConstIterator end() const
end iterator
Definition diagonalmatrix.hh:194
│ │ │ │ -
static constexpr int cols
The number of columns.
Definition diagonalmatrix.hh:83
│ │ │ │ -
static constexpr int dimension
Definition diagonalmatrix.hh:705
│ │ │ │ -
K * p_
Definition diagonalmatrix.hh:835
│ │ │ │ -
size_type rowIndex() const
index of this row in surrounding matrix
Definition diagonalmatrix.hh:806
│ │ │ │ -
R dereference() const
Definition diagonalmatrix.hh:1062
│ │ │ │ -
DiagonalRowVector & operator=(const K &k)
Assignment operator for scalar.
Definition diagonalmatrix.hh:870
│ │ │ │ -
bool operator!=(const DiagonalMatrix &other) const
incomparison operator
Definition diagonalmatrix.hh:268
│ │ │ │ -
value_type field_type
Definition diagonalmatrix.hh:61
│ │ │ │ -
void advance(int n)
Definition diagonalmatrix.hh:1084
│ │ │ │ -
ConstIterator begin() const
begin iterator
Definition diagonalmatrix.hh:188
│ │ │ │ -
Iterator begin()
begin iterator
Definition diagonalmatrix.hh:891
│ │ │ │ -
void mmv(const X &x, Y &y) const
y -= A x
Definition diagonalmatrix.hh:333
│ │ │ │ -
DiagonalMatrix & operator/=(const K &k)
vector space division by scalar
Definition diagonalmatrix.hh:253
│ │ │ │ -
ConstIterator const_iterator
typedef for stl compliant access
Definition diagonalmatrix.hh:181
│ │ │ │ -
const_row_type const_reference
Definition diagonalmatrix.hh:77
│ │ │ │ -
bool identical(const DiagonalMatrix< K, n > &other) const
Check if matrix is the same object as the other matrix.
Definition diagonalmatrix.hh:130
│ │ │ │ -
friend auto operator*(const DiagonalMatrix &matrixA, const DiagonalMatrix< OtherScalar, n > &matrixB)
Matrix-matrix multiplication.
Definition diagonalmatrix.hh:468
│ │ │ │ -
size_type realIndex(int i) const
Definition diagonalmatrix.hh:671
│ │ │ │ -
Iterator end()
end iterator
Definition diagonalmatrix.hh:158
│ │ │ │ -
const K & operator[](size_type i) const
same for read only access
Definition diagonalmatrix.hh:741
│ │ │ │ -
DiagonalRowVector()
Constructor making uninitialized vector.
Definition diagonalmatrix.hh:861
│ │ │ │ -
row_type reference
Definition diagonalmatrix.hh:74
│ │ │ │ -
DiagonalRowVectorConst * operator&()
Definition diagonalmatrix.hh:829
│ │ │ │ -
bool operator==(const DiagonalRowVectorConst &y) const
Binary vector comparison.
Definition diagonalmatrix.hh:786
│ │ │ │ -
double frobenius_norm2() const
square of frobenius norm, need for block recursion
Definition diagonalmatrix.hh:415
│ │ │ │ -
constexpr DiagonalMatrix()=default
Default constructor.
│ │ │ │ -
void mtv(const X &x, Y &y) const
y = A^T x
Definition diagonalmatrix.hh:290
│ │ │ │ -
ContainerWrapperIterator< DiagonalRowVectorConst< K, n >, const K, const K & > ConstIterator
ConstIterator class for sequential access.
Definition diagonalmatrix.hh:917
│ │ │ │ -
bool identical(const DiagonalMatrixWrapper &other) const
Definition diagonalmatrix.hh:682
│ │ │ │ -
void usmtv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) const
y += alpha A^T x
Definition diagonalmatrix.hh:382
│ │ │ │ -
void decrement()
Definition diagonalmatrix.hh:1073
│ │ │ │ -
std::ptrdiff_t index() const
Definition diagonalmatrix.hh:1096
│ │ │ │ -
const FieldVector< K, n > & diagonal() const
Get const reference to diagonal vector.
Definition diagonalmatrix.hh:543
│ │ │ │ -
void invert()
Compute inverse.
Definition diagonalmatrix.hh:445
│ │ │ │ -
DiagonalRowVector * operator&()
Definition diagonalmatrix.hh:935
│ │ │ │ -
const K & diagonal(size_type i) const
Get const reference to diagonal entry.
Definition diagonalmatrix.hh:531
│ │ │ │ -
size_type N() const
number of blocks in the vector (are of size 1 here)
Definition diagonalmatrix.hh:794
│ │ │ │ -
DiagonalMatrix(std::initializer_list< K > const &l)
Construct diagonal matrix from an initializer list.
Definition diagonalmatrix.hh:115
│ │ │ │ -
row_type::Iterator ColIterator
rename the iterators for easier access
Definition diagonalmatrix.hh:149
│ │ │ │ -
K field_type
export the type representing the field
Definition diagonalmatrix.hh:852
│ │ │ │ -
reference operator[](size_type i)
Return reference object as row replacement.
Definition diagonalmatrix.hh:519
│ │ │ │ -
DiagonalRowVectorConst< K, n > type
Definition diagonalmatrix.hh:951
│ │ │ │ -
Iterator end()
end iterator
Definition diagonalmatrix.hh:897
│ │ │ │ -
DiagonalMatrix(const FieldVector< K, n > &diag)
Constructor initializing the diagonal with a vector.
Definition diagonalmatrix.hh:103
│ │ │ │ -
std::size_t size_type
The type used for the index access and size operation.
Definition diagonalmatrix.hh:858
│ │ │ │ -
void usmv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) const
y += alpha A x
Definition diagonalmatrix.hh:369
│ │ │ │ -
double infinity_norm() const
infinity norm (row sum norm, how to generalize for blocks?)
Definition diagonalmatrix.hh:421
│ │ │ │ -
DiagonalMatrix & operator+=(const DiagonalMatrix &y)
vector space addition
Definition diagonalmatrix.hh:218
│ │ │ │ -
K block_type
export the type representing the components
Definition diagonalmatrix.hh:64
│ │ │ │ -
void umhv(const X &x, Y &y) const
y += A^H x
Definition diagonalmatrix.hh:321
│ │ │ │ -
Iterator beforeBegin()
Definition diagonalmatrix.hh:172
│ │ │ │ -
static void apply(DenseMatrix &denseMatrix, DiagonalMatrix< field, N > const &rhs)
Definition diagonalmatrix.hh:1108
│ │ │ │ -
ContainerWrapperIterator(const MyType &other)
Definition diagonalmatrix.hh:1026
│ │ │ │ -
ConstIterator end() const
end ConstIterator
Definition diagonalmatrix.hh:766
│ │ │ │ -
std::size_t size_type
The type used for the index access and size operation.
Definition diagonalmatrix.hh:718
│ │ │ │ -
DiagonalMatrix & operator=(const K &k)
Assignment from a scalar.
Definition diagonalmatrix.hh:123
│ │ │ │ -
DiagonalRowVectorConst()
Constructor making uninitialized vector.
Definition diagonalmatrix.hh:727
│ │ │ │ -
Iterator beforeEnd()
Definition diagonalmatrix.hh:165
│ │ │ │ -
size_type realIndex(int i) const
Definition diagonalmatrix.hh:819
│ │ │ │ -
friend std::ostream & operator<<(std::ostream &s, const DiagonalMatrix< K, n > &a)
Sends the matrix to an output stream.
Definition diagonalmatrix.hh:508
│ │ │ │ -
K value_type
export the type representing the field
Definition diagonalmatrix.hh:60
│ │ │ │ -
K block_type
export the type representing the components
Definition diagonalmatrix.hh:715
│ │ │ │ -
K determinant() const
calculates the determinant of this matrix
Definition diagonalmatrix.hh:453
│ │ │ │ -
FieldTraits< K >::real_type real_type
Definition diagonalmatrix.hh:564
│ │ │ │ -
ConstIterator beforeBegin() const
Definition diagonalmatrix.hh:780
│ │ │ │ -
DiagonalMatrixWrapper()
Definition diagonalmatrix.hh:663
│ │ │ │ -
ContainerWrapperIterator< DiagonalRowVectorConst< K, n >, const K, const K & > ConstIterator
ConstIterator class for sequential access.
Definition diagonalmatrix.hh:755
│ │ │ │ -
Iterator begin()
begin iterator
Definition diagonalmatrix.hh:152
│ │ │ │ -
bool operator==(const DiagonalMatrix &other) const
comparison operator
Definition diagonalmatrix.hh:262
│ │ │ │ -
DiagonalRowVectorConst< K, n > const_row_type
Definition diagonalmatrix.hh:76
│ │ │ │ -
DiagonalRowVector< K, n > row_type
Each row is implemented by a field vector.
Definition diagonalmatrix.hh:73
│ │ │ │ -
bool equals(const MyType &other) const
Definition diagonalmatrix.hh:1052
│ │ │ │ -
Iterator RowIterator
rename the iterators for easier access
Definition diagonalmatrix.hh:147
│ │ │ │ -
K block_type
export the type representing the components
Definition diagonalmatrix.hh:855
│ │ │ │ -
ConstIterator beforeEnd() const
Definition diagonalmatrix.hh:201
│ │ │ │ -
const K & diagonal() const
the diagonal value
Definition diagonalmatrix.hh:812
│ │ │ │ +
1051 const auto end=indexSet.end();
│ │ │ │ +
1052 for(auto index=indexSet.begin(); index!=end; ++index)
│ │ │ │ +
1053 if(index->local().isPublic())
│ │ │ │ +
1054 noPublic++;
│ │ │ │ +
1055
│ │ │ │ +
1056 return noPublic;
│ │ │ │ +
1057
│ │ │ │ +
1058 }
│ │ │ │ +
1059
│ │ │ │ +
1060
│ │ │ │ +
1061 template<typename T, typename A>
│ │ │ │ +
1062 inline void RemoteIndices<T,A>::unpackCreateRemote(char* p_in, PairType** sourcePairs,
│ │ │ │ +
1063 PairType** destPairs, int remoteProc,
│ │ │ │ +
1064 int sourcePublish, int destPublish,
│ │ │ │ +
1065 int bufferSize, bool sendTwo,
│ │ │ │ +
1066 bool fromOurSelf)
│ │ │ │ +
1067 {
│ │ │ │ +
1068
│ │ │ │ +
1069 // unpack the number of indices we received
│ │ │ │ +
1070 int noRemoteSource=-1, noRemoteDest=-1;
│ │ │ │ +
1071 char twoIndexSets=0;
│ │ │ │ +
1072 int position=0;
│ │ │ │ +
1073 // Did we receive two index sets?
│ │ │ │ +
1074 MPI_Unpack(p_in, bufferSize, &position, &twoIndexSets, 1, MPI_CHAR, comm_);
│ │ │ │ +
1075 // The number of source indices received
│ │ │ │ +
1076 MPI_Unpack(p_in, bufferSize, &position, &noRemoteSource, 1, MPI_INT, comm_);
│ │ │ │ +
1077 // The number of destination indices received
│ │ │ │ +
1078 MPI_Unpack(p_in, bufferSize, &position, &noRemoteDest, 1, MPI_INT, comm_);
│ │ │ │ +
1079
│ │ │ │ +
1080
│ │ │ │ +
1081 // Indices for which we receive
│ │ │ │ +
1082 RemoteIndexList* receive= new RemoteIndexList();
│ │ │ │ +
1083 // Indices for which we send
│ │ │ │ +
1084 RemoteIndexList* send=0;
│ │ │ │ +
1085
│ │ │ │ +
1086 MPI_Datatype type= MPITraits<PairType>::getType();
│ │ │ │ +
1087
│ │ │ │ +
1088 if(!twoIndexSets) {
│ │ │ │ +
1089 if(sendTwo) {
│ │ │ │ +
1090 send = new RemoteIndexList();
│ │ │ │ +
1091 // Create both remote index sets simultaneously
│ │ │ │ +
1092 unpackIndices(*send, *receive, noRemoteSource, sourcePairs, sourcePublish,
│ │ │ │ +
1093 destPairs, destPublish, p_in, type, &position, bufferSize);
│ │ │ │ +
1094 }else{
│ │ │ │ +
1095 // we only need one list
│ │ │ │ +
1096 unpackIndices(*receive, noRemoteSource, sourcePairs, sourcePublish,
│ │ │ │ +
1097 p_in, type, &position, bufferSize, fromOurSelf);
│ │ │ │ +
1098 send=receive;
│ │ │ │ +
1099 }
│ │ │ │ +
1100 }else{
│ │ │ │ +
1101
│ │ │ │ +
1102 int oldPos=position;
│ │ │ │ +
1103 // Two index sets received
│ │ │ │ +
1104 unpackIndices(*receive, noRemoteSource, destPairs, destPublish,
│ │ │ │ +
1105 p_in, type, &position, bufferSize, fromOurSelf);
│ │ │ │ +
1106 if(!sendTwo)
│ │ │ │ +
1107 //unpack source entries again as destination entries
│ │ │ │ +
1108 position=oldPos;
│ │ │ │ +
1109
│ │ │ │ +
1110 send = new RemoteIndexList();
│ │ │ │ +
1111 unpackIndices(*send, noRemoteDest, sourcePairs, sourcePublish,
│ │ │ │ +
1112 p_in, type, &position, bufferSize, fromOurSelf);
│ │ │ │ +
1113 }
│ │ │ │ +
1114
│ │ │ │ +
1115 if(receive->empty() && send->empty()) {
│ │ │ │ +
1116 if(send==receive) {
│ │ │ │ +
1117 delete send;
│ │ │ │ +
1118 }else{
│ │ │ │ +
1119 delete send;
│ │ │ │ +
1120 delete receive;
│ │ │ │ +
1121 }
│ │ │ │ +
1122 }else{
│ │ │ │ +
1123 remoteIndices_.insert(std::make_pair(remoteProc,
│ │ │ │ +
1124 std::make_pair(send,receive)));
│ │ │ │ +
1125 }
│ │ │ │ +
1126 }
│ │ │ │ +
1127
│ │ │ │ +
1128
│ │ │ │ +
1129 template<typename T, typename A>
│ │ │ │ +
1130 template<bool ignorePublic>
│ │ │ │ +
1131 inline void RemoteIndices<T,A>::buildRemote(bool includeSelf_)
│ │ │ │ +
1132 {
│ │ │ │ +
1133 // Processor configuration
│ │ │ │ +
1134 int rank, procs;
│ │ │ │ +
1135 MPI_Comm_rank(comm_, &rank);
│ │ │ │ +
1136 MPI_Comm_size(comm_, &procs);
│ │ │ │ +
1137
│ │ │ │ +
1138 // number of local indices to publish
│ │ │ │ +
1139 // The indices of the destination will be send.
│ │ │ │ +
1140 int sourcePublish, destPublish;
│ │ │ │ +
1141
│ │ │ │ +
1142 // Do we need to send two index sets?
│ │ │ │ +
1143 char sendTwo = (source_ != target_);
│ │ │ │ +
1144
│ │ │ │ +
1145 if(procs==1 && !(sendTwo || includeSelf_))
│ │ │ │ +
1146 // Nothing to communicate
│ │ │ │ +
1147 return;
│ │ │ │ +
1148
│ │ │ │ +
1149 sourcePublish = (ignorePublic) ? source_->size() : noPublic(*source_);
│ │ │ │ +
1150
│ │ │ │ +
1151 if(sendTwo)
│ │ │ │ +
1152 destPublish = (ignorePublic) ? target_->size() : noPublic(*target_);
│ │ │ │ +
1153 else
│ │ │ │ +
1154 // we only need to send one set of indices
│ │ │ │ +
1155 destPublish = 0;
│ │ │ │ +
1156
│ │ │ │ +
1157 int maxPublish, publish=sourcePublish+destPublish;
│ │ │ │ +
1158
│ │ │ │ +
1159 // Calculate maximum number of indices send
│ │ │ │ +
1160 MPI_Allreduce(&publish, &maxPublish, 1, MPI_INT, MPI_MAX, comm_);
│ │ │ │ +
1161
│ │ │ │ +
1162 // allocate buffers
│ │ │ │ +
1163 PairType** destPairs;
│ │ │ │ +
1164 PairType** sourcePairs = new PairType*[sourcePublish>0 ? sourcePublish : 1];
│ │ │ │ +
1165
│ │ │ │ +
1166 if(sendTwo)
│ │ │ │ +
1167 destPairs = new PairType*[destPublish>0 ? destPublish : 1];
│ │ │ │ +
1168 else
│ │ │ │ +
1169 destPairs=sourcePairs;
│ │ │ │ +
1170
│ │ │ │ +
1171 char** buffer = new char*[2];
│ │ │ │ +
1172 int bufferSize;
│ │ │ │ +
1173 int position=0;
│ │ │ │ +
1174 int intSize;
│ │ │ │ +
1175 int charSize;
│ │ │ │ +
1176
│ │ │ │ +
1177 // calculate buffer size
│ │ │ │ +
1178 MPI_Datatype type = MPITraits<PairType>::getType();
│ │ │ │ +
1179
│ │ │ │ +
1180 MPI_Pack_size(maxPublish, type, comm_,
│ │ │ │ +
1181 &bufferSize);
│ │ │ │ +
1182 MPI_Pack_size(1, MPI_INT, comm_,
│ │ │ │ +
1183 &intSize);
│ │ │ │ +
1184 MPI_Pack_size(1, MPI_CHAR, comm_,
│ │ │ │ +
1185 &charSize);
│ │ │ │ +
1186 // Our message will contain the following:
│ │ │ │ +
1187 // a bool whether two index sets where sent
│ │ │ │ +
1188 // the size of the source and the dest indexset,
│ │ │ │ +
1189 // then the source and destination indices
│ │ │ │ +
1190 bufferSize += 2 * intSize + charSize;
│ │ │ │ +
1191
│ │ │ │ +
1192 if(bufferSize<=0) bufferSize=1;
│ │ │ │ +
1193
│ │ │ │ +
1194 buffer[0] = new char[bufferSize];
│ │ │ │ +
1195 buffer[1] = new char[bufferSize];
│ │ │ │ +
1196
│ │ │ │ +
1197
│ │ │ │ +
1198 // pack entries into buffer[0], p_out below!
│ │ │ │ +
1199 MPI_Pack(&sendTwo, 1, MPI_CHAR, buffer[0], bufferSize, &position,
│ │ │ │ +
1200 comm_);
│ │ │ │ +
1201
│ │ │ │ +
1202 // The number of indices we send for each index set
│ │ │ │ +
1203 MPI_Pack(&sourcePublish, 1, MPI_INT, buffer[0], bufferSize, &position,
│ │ │ │ +
1204 comm_);
│ │ │ │ +
1205 MPI_Pack(&destPublish, 1, MPI_INT, buffer[0], bufferSize, &position,
│ │ │ │ +
1206 comm_);
│ │ │ │ +
1207
│ │ │ │ +
1208 // Now pack the source indices and setup the destination pairs
│ │ │ │ +
1209 packEntries<ignorePublic>(sourcePairs, *source_, buffer[0], type,
│ │ │ │ +
1210 bufferSize, &position, sourcePublish);
│ │ │ │ +
1211 // If necessary send the dest indices and setup the source pairs
│ │ │ │ +
1212 if(sendTwo)
│ │ │ │ +
1213 packEntries<ignorePublic>(destPairs, *target_, buffer[0], type,
│ │ │ │ +
1214 bufferSize, &position, destPublish);
│ │ │ │ +
1215
│ │ │ │ +
1216
│ │ │ │ +
1217 // Update remote indices for ourself
│ │ │ │ +
1218 if(sendTwo|| includeSelf_)
│ │ │ │ +
1219 unpackCreateRemote(buffer[0], sourcePairs, destPairs, rank, sourcePublish,
│ │ │ │ +
1220 destPublish, bufferSize, sendTwo, includeSelf_);
│ │ │ │ +
1221
│ │ │ │ +
1222 neighbourIds.erase(rank);
│ │ │ │ +
1223
│ │ │ │ +
1224 if(neighbourIds.size()==0)
│ │ │ │ +
1225 {
│ │ │ │ +
1226 Dune::dvverb<<rank<<": Sending messages in a ring"<<std::endl;
│ │ │ │ +
1227 // send messages in ring
│ │ │ │ +
1228 for(int proc=1; proc<procs; proc++) {
│ │ │ │ +
1229 // pointers to the current input and output buffers
│ │ │ │ +
1230 char* p_out = buffer[1-(proc%2)];
│ │ │ │ +
1231 char* p_in = buffer[proc%2];
│ │ │ │ +
1232
│ │ │ │ +
1233 MPI_Status status;
│ │ │ │ +
1234 if(rank%2==0) {
│ │ │ │ +
1235 MPI_Ssend(p_out, bufferSize, MPI_PACKED, (rank+1)%procs,
│ │ │ │ +
1236 commTag_, comm_);
│ │ │ │ +
1237 MPI_Recv(p_in, bufferSize, MPI_PACKED, (rank+procs-1)%procs,
│ │ │ │ +
1238 commTag_, comm_, &status);
│ │ │ │ +
1239 }else{
│ │ │ │ +
1240 MPI_Recv(p_in, bufferSize, MPI_PACKED, (rank+procs-1)%procs,
│ │ │ │ +
1241 commTag_, comm_, &status);
│ │ │ │ +
1242 MPI_Ssend(p_out, bufferSize, MPI_PACKED, (rank+1)%procs,
│ │ │ │ +
1243 commTag_, comm_);
│ │ │ │ +
1244 }
│ │ │ │ +
1245
│ │ │ │ +
1246
│ │ │ │ +
1247 // The process these indices are from
│ │ │ │ +
1248 int remoteProc = (rank+procs-proc)%procs;
│ │ │ │ +
1249
│ │ │ │ +
1250 unpackCreateRemote(p_in, sourcePairs, destPairs, remoteProc, sourcePublish,
│ │ │ │ +
1251 destPublish, bufferSize, sendTwo);
│ │ │ │ +
1252
│ │ │ │ +
1253 }
│ │ │ │ +
1254
│ │ │ │ +
1255 }
│ │ │ │ +
1256 else
│ │ │ │ +
1257 {
│ │ │ │ +
1258 MPI_Request* requests=new MPI_Request[neighbourIds.size()];
│ │ │ │ +
1259 MPI_Request* req=requests;
│ │ │ │ +
1260
│ │ │ │ +
1261 typedef typename std::set<int>::size_type size_type;
│ │ │ │ +
1262 size_type noNeighbours=neighbourIds.size();
│ │ │ │ +
1263
│ │ │ │ +
1264 // setup sends
│ │ │ │ +
1265 for(std::set<int>::iterator neighbour=neighbourIds.begin();
│ │ │ │ +
1266 neighbour!= neighbourIds.end(); ++neighbour) {
│ │ │ │ +
1267 // Only send the information to the neighbouring processors
│ │ │ │ +
1268 MPI_Issend(buffer[0], position , MPI_PACKED, *neighbour, commTag_, comm_, req++);
│ │ │ │ +
1269 }
│ │ │ │ +
1270
│ │ │ │ +
1271 //Test for received messages
│ │ │ │ +
1272
│ │ │ │ +
1273 for(size_type received=0; received <noNeighbours; ++received)
│ │ │ │ +
1274 {
│ │ │ │ +
1275 MPI_Status status;
│ │ │ │ +
1276 // probe for next message
│ │ │ │ +
1277 MPI_Probe(MPI_ANY_SOURCE, commTag_, comm_, &status);
│ │ │ │ +
1278 int remoteProc=status.MPI_SOURCE;
│ │ │ │ +
1279 int size;
│ │ │ │ +
1280 MPI_Get_count(&status, MPI_PACKED, &size);
│ │ │ │ +
1281 // receive message
│ │ │ │ +
1282 MPI_Recv(buffer[1], size, MPI_PACKED, remoteProc,
│ │ │ │ +
1283 commTag_, comm_, &status);
│ │ │ │ +
1284
│ │ │ │ +
1285 unpackCreateRemote(buffer[1], sourcePairs, destPairs, remoteProc, sourcePublish,
│ │ │ │ +
1286 destPublish, bufferSize, sendTwo);
│ │ │ │ +
1287 }
│ │ │ │ +
1288 // wait for completion of pending requests
│ │ │ │ +
1289 MPI_Status* statuses = new MPI_Status[neighbourIds.size()];
│ │ │ │ +
1290
│ │ │ │ +
1291 if(MPI_ERR_IN_STATUS==MPI_Waitall(neighbourIds.size(), requests, statuses)) {
│ │ │ │ +
1292 for(size_type i=0; i < neighbourIds.size(); ++i)
│ │ │ │ +
1293 if(statuses[i].MPI_ERROR!=MPI_SUCCESS) {
│ │ │ │ +
1294 std::cerr<<rank<<": MPI_Error occurred while receiving message."<<std::endl;
│ │ │ │ +
1295 MPI_Abort(comm_, 999);
│ │ │ │ +
1296 }
│ │ │ │ +
1297 }
│ │ │ │ +
1298 delete[] requests;
│ │ │ │ +
1299 delete[] statuses;
│ │ │ │ +
1300 }
│ │ │ │ +
1301
│ │ │ │ +
1302
│ │ │ │ +
1303 // delete allocated memory
│ │ │ │ +
1304 if(destPairs!=sourcePairs)
│ │ │ │ +
1305 delete[] destPairs;
│ │ │ │ +
1306
│ │ │ │ +
1307 delete[] sourcePairs;
│ │ │ │ +
1308 delete[] buffer[0];
│ │ │ │ +
1309 delete[] buffer[1];
│ │ │ │ +
1310 delete[] buffer;
│ │ │ │ +
1311 }
│ │ │ │ +
1312
│ │ │ │ +
1313 template<typename T, typename A>
│ │ │ │ +
1314 inline void RemoteIndices<T,A>::unpackIndices(RemoteIndexList& remote,
│ │ │ │ +
1315 int remoteEntries,
│ │ │ │ +
1316 PairType** local,
│ │ │ │ +
1317 int localEntries,
│ │ │ │ +
1318 char* p_in,
│ │ │ │ +
1319 MPI_Datatype type,
│ │ │ │ +
1320 int* position,
│ │ │ │ +
1321 int bufferSize,
│ │ │ │ +
1322 bool fromOurSelf)
│ │ │ │ +
1323 {
│ │ │ │ +
1324 if(remoteEntries==0)
│ │ │ │ +
1325 return;
│ │ │ │ +
1326
│ │ │ │ +
1327 PairType index;
│ │ │ │ +
1328 MPI_Unpack(p_in, bufferSize, position, &index, 1,
│ │ │ │ +
1329 type, comm_);
│ │ │ │ +
1330 GlobalIndex oldGlobal=index.global();
│ │ │ │ +
1331 int n_in=0, localIndex=0;
│ │ │ │ +
1332
│ │ │ │ +
1333 //Check if we know the global index
│ │ │ │ +
1334 while(localIndex<localEntries) {
│ │ │ │ +
1335 if(local[localIndex]->global()==index.global()) {
│ │ │ │ +
1336 int oldLocalIndex=localIndex;
│ │ │ │ +
1337
│ │ │ │ +
1338 while(localIndex<localEntries &&
│ │ │ │ +
1339 local[localIndex]->global()==index.global()) {
│ │ │ │ +
1340 if(!fromOurSelf || index.local().attribute() !=
│ │ │ │ +
1341 local[localIndex]->local().attribute())
│ │ │ │ +
1342 // if index is from us it has to have a different attribute
│ │ │ │ +
1343 remote.push_back(RemoteIndex(index.local().attribute(),
│ │ │ │ +
1344 local[localIndex]));
│ │ │ │ +
1345 localIndex++;
│ │ │ │ +
1346 }
│ │ │ │ +
1347
│ │ │ │ +
1348 // unpack next remote index
│ │ │ │ +
1349 if((++n_in) < remoteEntries) {
│ │ │ │ +
1350 MPI_Unpack(p_in, bufferSize, position, &index, 1,
│ │ │ │ +
1351 type, comm_);
│ │ │ │ +
1352 if(index.global()==oldGlobal)
│ │ │ │ +
1353 // Restart comparison for the same global indices
│ │ │ │ +
1354 localIndex=oldLocalIndex;
│ │ │ │ +
1355 else
│ │ │ │ +
1356 oldGlobal=index.global();
│ │ │ │ +
1357 }else{
│ │ │ │ +
1358 // No more received indices
│ │ │ │ +
1359 break;
│ │ │ │ +
1360 }
│ │ │ │ +
1361 continue;
│ │ │ │ +
1362 }
│ │ │ │ +
1363
│ │ │ │ +
1364 if (local[localIndex]->global()<index.global()) {
│ │ │ │ +
1365 // compare with next entry in our list
│ │ │ │ +
1366 ++localIndex;
│ │ │ │ +
1367 }else{
│ │ │ │ +
1368 // We do not know the index, unpack next
│ │ │ │ +
1369 if((++n_in) < remoteEntries) {
│ │ │ │ +
1370 MPI_Unpack(p_in, bufferSize, position, &index, 1,
│ │ │ │ +
1371 type, comm_);
│ │ │ │ +
1372 oldGlobal=index.global();
│ │ │ │ +
1373 }else
│ │ │ │ +
1374 // No more received indices
│ │ │ │ +
1375 break;
│ │ │ │ +
1376 }
│ │ │ │ +
1377 }
│ │ │ │ +
1378
│ │ │ │ +
1379 // Unpack the other received indices without doing anything
│ │ │ │ +
1380 while(++n_in < remoteEntries)
│ │ │ │ +
1381 MPI_Unpack(p_in, bufferSize, position, &index, 1,
│ │ │ │ +
1382 type, comm_);
│ │ │ │ +
1383 }
│ │ │ │ +
1384
│ │ │ │ +
1385
│ │ │ │ +
1386 template<typename T, typename A>
│ │ │ │ +
1387 inline void RemoteIndices<T,A>::unpackIndices(RemoteIndexList& send,
│ │ │ │ +
1388 RemoteIndexList& receive,
│ │ │ │ +
1389 int remoteEntries,
│ │ │ │ +
1390 PairType** localSource,
│ │ │ │ +
1391 int localSourceEntries,
│ │ │ │ +
1392 PairType** localDest,
│ │ │ │ +
1393 int localDestEntries,
│ │ │ │ +
1394 char* p_in,
│ │ │ │ +
1395 MPI_Datatype type,
│ │ │ │ +
1396 int* position,
│ │ │ │ +
1397 int bufferSize)
│ │ │ │ +
1398 {
│ │ │ │ +
1399 int n_in=0, sourceIndex=0, destIndex=0;
│ │ │ │ +
1400
│ │ │ │ +
1401 //Check if we know the global index
│ │ │ │ +
1402 while(n_in<remoteEntries && (sourceIndex<localSourceEntries || destIndex<localDestEntries)) {
│ │ │ │ +
1403 // Unpack next index
│ │ │ │ +
1404 PairType index;
│ │ │ │ +
1405 MPI_Unpack(p_in, bufferSize, position, &index, 1,
│ │ │ │ +
1406 type, comm_);
│ │ │ │ +
1407 n_in++;
│ │ │ │ +
1408
│ │ │ │ +
1409 // Advance until global index in localSource and localDest are >= than the one in the unpacked index
│ │ │ │ +
1410 while(sourceIndex<localSourceEntries && localSource[sourceIndex]->global()<index.global())
│ │ │ │ +
1411 sourceIndex++;
│ │ │ │ +
1412
│ │ │ │ +
1413 while(destIndex<localDestEntries && localDest[destIndex]->global()<index.global())
│ │ │ │ +
1414 destIndex++;
│ │ │ │ +
1415
│ │ │ │ +
1416 // Add a remote index if we found the global index.
│ │ │ │ +
1417 if(sourceIndex<localSourceEntries && localSource[sourceIndex]->global()==index.global())
│ │ │ │ +
1418 send.push_back(RemoteIndex(index.local().attribute(),
│ │ │ │ +
1419 localSource[sourceIndex]));
│ │ │ │ +
1420
│ │ │ │ +
1421 if(destIndex < localDestEntries && localDest[destIndex]->global() == index.global())
│ │ │ │ +
1422 receive.push_back(RemoteIndex(index.local().attribute(),
│ │ │ │ +
1423 localDest[sourceIndex]));
│ │ │ │ +
1424 }
│ │ │ │ +
1425
│ │ │ │ +
1426 }
│ │ │ │ +
1427
│ │ │ │ +
1428 template<typename T, typename A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
1430 {
│ │ │ │ +
1431 auto lend = remoteIndices_.end();
│ │ │ │ +
1432 for(auto lists=remoteIndices_.begin(); lists != lend; ++lists) {
│ │ │ │ +
1433 if(lists->second.first==lists->second.second) {
│ │ │ │ +
1434 // there is only one remote index list.
│ │ │ │ +
1435 delete lists->second.first;
│ │ │ │ +
1436 }else{
│ │ │ │ +
1437 delete lists->second.first;
│ │ │ │ +
1438 delete lists->second.second;
│ │ │ │ +
1439 }
│ │ │ │ +
1440 }
│ │ │ │ +
1441 remoteIndices_.clear();
│ │ │ │ +
1442 firstBuild=true;
│ │ │ │ +
1443 }
│ │ │ │ +
│ │ │ │ +
1444
│ │ │ │ +
1445 template<typename T, typename A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
1447 {
│ │ │ │ +
1448 return remoteIndices_.size();
│ │ │ │ +
1449 }
│ │ │ │ +
│ │ │ │ +
1450
│ │ │ │ +
1451 template<typename T, typename A>
│ │ │ │ +
1452 template<bool ignorePublic>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
1454 {
│ │ │ │ +
1455 // Test whether a rebuild is Needed.
│ │ │ │ +
1456 if(firstBuild ||
│ │ │ │ +
1457 ignorePublic!=publicIgnored || !
│ │ │ │ +
1458 isSynced()) {
│ │ │ │ +
1459 free();
│ │ │ │ +
1460
│ │ │ │ +
1461 buildRemote<ignorePublic>(includeSelf);
│ │ │ │ +
1462
│ │ │ │ +
1463 sourceSeqNo_ = source_->seqNo();
│ │ │ │ +
1464 destSeqNo_ = target_->seqNo();
│ │ │ │ +
1465 firstBuild=false;
│ │ │ │ +
1466 publicIgnored=ignorePublic;
│ │ │ │ +
1467 }
│ │ │ │ +
1468
│ │ │ │ +
1469
│ │ │ │ +
1470 }
│ │ │ │ +
│ │ │ │ +
1471
│ │ │ │ +
1472 template<typename T, typename A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
1474 {
│ │ │ │ +
1475 return sourceSeqNo_==source_->seqNo() && destSeqNo_ ==target_->seqNo();
│ │ │ │ +
1476 }
│ │ │ │ +
│ │ │ │ +
1477
│ │ │ │ +
1478 template<typename T, typename A>
│ │ │ │ +
1479 template<bool mode, bool send>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
1481 {
│ │ │ │ +
1482
│ │ │ │ +
1483 // The user are on their own now!
│ │ │ │ +
1484 // We assume they know what they are doing and just set the
│ │ │ │ +
1485 // remote indices to synced status.
│ │ │ │ +
1486 sourceSeqNo_ = source_->seqNo();
│ │ │ │ +
1487 destSeqNo_ = target_->seqNo();
│ │ │ │ +
1488
│ │ │ │ +
1489 typename RemoteIndexMap::iterator found = remoteIndices_.find(process);
│ │ │ │ +
1490
│ │ │ │ +
1491 if(found == remoteIndices_.end())
│ │ │ │ +
1492 {
│ │ │ │ +
1493 if(source_ != target_)
│ │ │ │ +
1494 found = remoteIndices_.insert(found, std::make_pair(process,
│ │ │ │ +
1495 std::make_pair(new RemoteIndexList(),
│ │ │ │ +
1496 new RemoteIndexList())));
│ │ │ │ +
1497 else{
│ │ │ │ +
1498 RemoteIndexList* rlist = new RemoteIndexList();
│ │ │ │ +
1499 found = remoteIndices_.insert(found,
│ │ │ │ +
1500 std::make_pair(process,
│ │ │ │ +
1501 std::make_pair(rlist, rlist)));
│ │ │ │ +
1502 }
│ │ │ │ +
1503 }
│ │ │ │ +
1504
│ │ │ │ +
1505 firstBuild = false;
│ │ │ │ +
1506
│ │ │ │ +
1507 if(send)
│ │ │ │ +
1508 return RemoteIndexListModifier<T,A,mode>(*source_, *(found->second.first));
│ │ │ │ +
1509 else
│ │ │ │ +
1510 return RemoteIndexListModifier<T,A,mode>(*target_, *(found->second.second));
│ │ │ │ +
1511 }
│ │ │ │ +
│ │ │ │ +
1512
│ │ │ │ +
1513 template<typename T, typename A>
│ │ │ │ + │ │ │ │ +
│ │ │ │ + │ │ │ │ +
1516 {
│ │ │ │ +
1517 return remoteIndices_.find(proc);
│ │ │ │ +
1518 }
│ │ │ │ +
│ │ │ │ +
1519
│ │ │ │ +
1520 template<typename T, typename A>
│ │ │ │ + │ │ │ │ +
│ │ │ │ + │ │ │ │ +
1523 {
│ │ │ │ +
1524 return remoteIndices_.begin();
│ │ │ │ +
1525 }
│ │ │ │ +
│ │ │ │ +
1526
│ │ │ │ +
1527 template<typename T, typename A>
│ │ │ │ + │ │ │ │ +
│ │ │ │ + │ │ │ │ +
1530 {
│ │ │ │ +
1531 return remoteIndices_.end();
│ │ │ │ +
1532 }
│ │ │ │ +
│ │ │ │ +
1533
│ │ │ │ +
1534
│ │ │ │ +
1535 template<typename T, typename A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
1537 {
│ │ │ │ +
1538 if(neighbours()!=ri.neighbours())
│ │ │ │ +
1539 return false;
│ │ │ │ +
1540
│ │ │ │ +
1541 const auto rend = remoteIndices_.end();
│ │ │ │ +
1542
│ │ │ │ +
1543 for(auto rindex = remoteIndices_.begin(), rindex1=ri.remoteIndices_.begin(); rindex!=rend; ++rindex, ++rindex1) {
│ │ │ │ +
1544 if(rindex->first != rindex1->first)
│ │ │ │ +
1545 return false;
│ │ │ │ +
1546 if(*(rindex->second.first) != *(rindex1->second.first))
│ │ │ │ +
1547 return false;
│ │ │ │ +
1548 if(*(rindex->second.second) != *(rindex1->second.second))
│ │ │ │ +
1549 return false;
│ │ │ │ +
1550 }
│ │ │ │ +
1551 return true;
│ │ │ │ +
1552 }
│ │ │ │ +
│ │ │ │ +
1553
│ │ │ │ +
1554 template<class T, class A, bool mode>
│ │ │ │ + │ │ │ │ +
1556 RemoteIndexList& rList)
│ │ │ │ +
1557 : rList_(&rList), indexSet_(&indexSet), iter_(rList.beginModify()), end_(rList.end()), first_(true)
│ │ │ │ +
1558 {
│ │ │ │ +
1559 if(MODIFYINDEXSET) {
│ │ │ │ +
1560 assert(indexSet_);
│ │ │ │ +
1561 for(ConstIterator iter=iter_; iter != end_; ++iter)
│ │ │ │ +
1562 glist_.push_back(iter->localIndexPair().global());
│ │ │ │ +
1563 giter_ = glist_.beginModify();
│ │ │ │ +
1564 }
│ │ │ │ +
1565 }
│ │ │ │ +
1566
│ │ │ │ +
1567 template<typename T, typename A, bool mode>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
1569 : rList_(other.rList_), indexSet_(other.indexSet_),
│ │ │ │ +
1570 glist_(other.glist_), iter_(other.iter_), giter_(other.giter_), end_(other.end_),
│ │ │ │ +
1571 first_(other.first_), last_(other.last_)
│ │ │ │ +
1572 {}
│ │ │ │ +
│ │ │ │ +
1573
│ │ │ │ +
1574 template<typename T, typename A, bool mode>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
1576 {
│ │ │ │ +
1577 if(MODIFYINDEXSET) {
│ │ │ │ +
1578 // repair pointers to local index set.
│ │ │ │ +
1579#ifdef DUNE_ISTL_WITH_CHECKING
│ │ │ │ +
1580 if(indexSet_->state()!=GROUND)
│ │ │ │ +
1581 DUNE_THROW(InvalidIndexSetState, "Index has to be in ground mode for repairing pointers to indices");
│ │ │ │ +
1582#endif
│ │ │ │ +
1583 auto giter = glist_.begin();
│ │ │ │ +
1584 auto index = indexSet_->begin();
│ │ │ │ +
1585
│ │ │ │ +
1586 for(auto iter=rList_->begin(); iter != end_; ++iter) {
│ │ │ │ +
1587 while(index->global()<*giter) {
│ │ │ │ +
1588 ++index;
│ │ │ │ +
1589#ifdef DUNE_ISTL_WITH_CHECKING
│ │ │ │ +
1590 if(index == indexSet_->end())
│ │ │ │ +
1591 DUNE_THROW(InvalidPosition, "No such global index in set!");
│ │ │ │ +
1592#endif
│ │ │ │ +
1593 }
│ │ │ │ +
1594
│ │ │ │ +
1595#ifdef DUNE_ISTL_WITH_CHECKING
│ │ │ │ +
1596 if(index->global() != *giter)
│ │ │ │ +
1597 DUNE_THROW(InvalidPosition, "No such global index in set!");
│ │ │ │ +
1598#endif
│ │ │ │ +
1599 iter->localIndex_ = &(*index);
│ │ │ │ +
1600 }
│ │ │ │ +
1601 }
│ │ │ │ +
1602 }
│ │ │ │ +
│ │ │ │ +
1603
│ │ │ │ +
1604 template<typename T, typename A, bool mode>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
1606 {
│ │ │ │ +
1607 static_assert(!mode,"Not allowed if the mode indicates that new indices"
│ │ │ │ +
1608 "might be added to the underlying index set. Use "
│ │ │ │ +
1609 "insert(const RemoteIndex&, const GlobalIndex&) instead");
│ │ │ │ +
1610
│ │ │ │ +
1611#ifdef DUNE_ISTL_WITH_CHECKING
│ │ │ │ +
1612 if(!first_ && index.localIndexPair().global()<last_)
│ │ │ │ +
1613 DUNE_THROW(InvalidPosition, "Modification of remote indices have to occur with ascending global index.");
│ │ │ │ +
1614#endif
│ │ │ │ +
1615 // Move to the correct position
│ │ │ │ +
1616 while(iter_ != end_ && iter_->localIndexPair().global() < index.localIndexPair().global()) {
│ │ │ │ +
1617 ++iter_;
│ │ │ │ +
1618 }
│ │ │ │ +
1619
│ │ │ │ +
1620 // No duplicate entries allowed
│ │ │ │ +
1621 assert(iter_==end_ || iter_->localIndexPair().global() != index.localIndexPair().global());
│ │ │ │ +
1622 iter_.insert(index);
│ │ │ │ +
1623 last_ = index.localIndexPair().global();
│ │ │ │ +
1624 first_ = false;
│ │ │ │ +
1625 }
│ │ │ │ +
│ │ │ │ +
1626
│ │ │ │ +
1627 template<typename T, typename A, bool mode>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
1629 {
│ │ │ │ +
1630 static_assert(mode,"Not allowed if the mode indicates that no new indices"
│ │ │ │ +
1631 "might be added to the underlying index set. Use "
│ │ │ │ +
1632 "insert(const RemoteIndex&) instead");
│ │ │ │ +
1633#ifdef DUNE_ISTL_WITH_CHECKING
│ │ │ │ +
1634 if(!first_ && global<last_)
│ │ │ │ +
1635 DUNE_THROW(InvalidPosition, "Modification of remote indices have to occur with ascending global index.");
│ │ │ │ +
1636#endif
│ │ │ │ +
1637 // Move to the correct position
│ │ │ │ +
1638 while(iter_ != end_ && *giter_ < global) {
│ │ │ │ +
1639 ++giter_;
│ │ │ │ +
1640 ++iter_;
│ │ │ │ +
1641 }
│ │ │ │ +
1642
│ │ │ │ +
1643 // No duplicate entries allowed
│ │ │ │ +
1644 assert(iter_->localIndexPair().global() != global);
│ │ │ │ +
1645 iter_.insert(index);
│ │ │ │ +
1646 giter_.insert(global);
│ │ │ │ +
1647
│ │ │ │ +
1648 last_ = global;
│ │ │ │ +
1649 first_ = false;
│ │ │ │ +
1650 }
│ │ │ │ +
│ │ │ │ +
1651
│ │ │ │ +
1652 template<typename T, typename A, bool mode>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
1654 {
│ │ │ │ +
1655#ifdef DUNE_ISTL_WITH_CHECKING
│ │ │ │ +
1656 if(!first_ && global<last_)
│ │ │ │ +
1657 DUNE_THROW(InvalidPosition, "Modification of remote indices have to occur with ascending global index.");
│ │ │ │ +
1658#endif
│ │ │ │ +
1659
│ │ │ │ +
1660 bool found= false;
│ │ │ │ +
1661
│ │ │ │ +
1662 if(MODIFYINDEXSET) {
│ │ │ │ +
1663 // Move to the correct position
│ │ │ │ +
1664 while(iter_!=end_ && *giter_< global) {
│ │ │ │ +
1665 ++giter_;
│ │ │ │ +
1666 ++iter_;
│ │ │ │ +
1667 }
│ │ │ │ +
1668 if(*giter_ == global) {
│ │ │ │ +
1669 giter_.remove();
│ │ │ │ +
1670 iter_.remove();
│ │ │ │ +
1671 found=true;
│ │ │ │ +
1672 }
│ │ │ │ +
1673 }else{
│ │ │ │ +
1674 while(iter_!=end_ && iter_->localIndexPair().global() < global)
│ │ │ │ +
1675 ++iter_;
│ │ │ │ +
1676
│ │ │ │ +
1677 if(iter_->localIndexPair().global()==global) {
│ │ │ │ +
1678 iter_.remove();
│ │ │ │ +
1679 found = true;
│ │ │ │ +
1680 }
│ │ │ │ +
1681 }
│ │ │ │ +
1682
│ │ │ │ +
1683 last_ = global;
│ │ │ │ +
1684 first_ = false;
│ │ │ │ +
1685 return found;
│ │ │ │ +
1686 }
│ │ │ │ +
│ │ │ │ +
1687
│ │ │ │ +
1688 template<typename T, typename A>
│ │ │ │ +
1689 template<bool send>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
1691 {
│ │ │ │ +
1692 return CollectiveIterator<T,A>(remoteIndices_, send);
│ │ │ │ +
1693 }
│ │ │ │ +
│ │ │ │ +
1694
│ │ │ │ +
1695 template<typename T, typename A>
│ │ │ │ +
│ │ │ │ +
1696 inline MPI_Comm RemoteIndices<T,A>::communicator() const
│ │ │ │ +
1697 {
│ │ │ │ +
1698 return comm_;
│ │ │ │ +
1699
│ │ │ │ +
1700 }
│ │ │ │ +
│ │ │ │ +
1701
│ │ │ │ +
1702 template<typename T, typename A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
1704 {
│ │ │ │ +
1705
│ │ │ │ +
1706 const auto end = pmap.end();
│ │ │ │ +
1707 for(auto process = pmap.begin(); process != end; ++process) {
│ │ │ │ +
1708 const RemoteIndexList* list = send ? process->second.first : process->second.second;
│ │ │ │ +
1709 using ri_iterator = typename RemoteIndexList::const_iterator;
│ │ │ │ +
1710 map_.insert(std::make_pair(process->first,
│ │ │ │ +
1711 std::pair<ri_iterator, const ri_iterator>(list->begin(), list->end())));
│ │ │ │ +
1712 }
│ │ │ │ +
1713 }
│ │ │ │ +
│ │ │ │ +
1714
│ │ │ │ +
1715 template<typename T, typename A>
│ │ │ │ +
│ │ │ │ +
1716 inline void CollectiveIterator<T,A>::advance(const GlobalIndex& index)
│ │ │ │ +
1717 {
│ │ │ │ +
1718 const auto end = map_.end();
│ │ │ │ +
1719
│ │ │ │ +
1720 for(auto iter = map_.begin(); iter != end;) {
│ │ │ │ +
1721 // Step the iterator until we are >= index
│ │ │ │ +
1722 typename RemoteIndexList::const_iterator current = iter->second.first;
│ │ │ │ +
1723 typename RemoteIndexList::const_iterator rend = iter->second.second;
│ │ │ │ +
1724 RemoteIndex remoteIndex;
│ │ │ │ +
1725 if(current != rend)
│ │ │ │ +
1726 remoteIndex = *current;
│ │ │ │ +
1727
│ │ │ │ +
1728 while(iter->second.first!=iter->second.second && iter->second.first->localIndexPair().global()<index)
│ │ │ │ +
1729 ++(iter->second.first);
│ │ │ │ +
1730
│ │ │ │ +
1731 // erase from the map if there are no more entries.
│ │ │ │ +
1732 if(iter->second.first == iter->second.second)
│ │ │ │ +
1733 map_.erase(iter++);
│ │ │ │ +
1734 else{
│ │ │ │ +
1735 ++iter;
│ │ │ │ +
1736 }
│ │ │ │ +
1737 }
│ │ │ │ +
1738 index_=index;
│ │ │ │ +
1739 noattribute=true;
│ │ │ │ +
1740 }
│ │ │ │ +
│ │ │ │ +
1741
│ │ │ │ +
1742 template<typename T, typename A>
│ │ │ │ +
│ │ │ │ +
1743 inline void CollectiveIterator<T,A>::advance(const GlobalIndex& index,
│ │ │ │ +
1744 const Attribute& attribute)
│ │ │ │ +
1745 {
│ │ │ │ +
1746 const auto end = map_.end();
│ │ │ │ +
1747
│ │ │ │ +
1748 for(auto iter = map_.begin(); iter != end;) {
│ │ │ │ +
1749 // Step the iterator until we are >= index
│ │ │ │ +
1750 typename RemoteIndexList::const_iterator current = iter->second.first;
│ │ │ │ +
1751 typename RemoteIndexList::const_iterator rend = iter->second.second;
│ │ │ │ +
1752 RemoteIndex remoteIndex;
│ │ │ │ +
1753 if(current != rend)
│ │ │ │ +
1754 remoteIndex = *current;
│ │ │ │ +
1755
│ │ │ │ +
1756 // Move to global index or bigger
│ │ │ │ +
1757 while(iter->second.first!=iter->second.second && iter->second.first->localIndexPair().global()<index)
│ │ │ │ +
1758 ++(iter->second.first);
│ │ │ │ +
1759
│ │ │ │ +
1760 // move to attribute or bigger
│ │ │ │ +
1761 while(iter->second.first!=iter->second.second
│ │ │ │ +
1762 && iter->second.first->localIndexPair().global()==index
│ │ │ │ +
1763 && iter->second.first->localIndexPair().local().attribute()<attribute)
│ │ │ │ +
1764 ++(iter->second.first);
│ │ │ │ +
1765
│ │ │ │ +
1766 // erase from the map if there are no more entries.
│ │ │ │ +
1767 if(iter->second.first == iter->second.second)
│ │ │ │ +
1768 map_.erase(iter++);
│ │ │ │ +
1769 else{
│ │ │ │ +
1770 ++iter;
│ │ │ │ +
1771 }
│ │ │ │ +
1772 }
│ │ │ │ +
1773 index_=index;
│ │ │ │ +
1774 attribute_=attribute;
│ │ │ │ +
1775 noattribute=false;
│ │ │ │ +
1776 }
│ │ │ │ +
│ │ │ │ +
1777
│ │ │ │ +
1778 template<typename T, typename A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
1780 {
│ │ │ │ +
1781 const auto end = map_.end();
│ │ │ │ +
1782
│ │ │ │ +
1783 for(auto iter = map_.begin(); iter != end;) {
│ │ │ │ +
1784 // Step the iterator until we are >= index
│ │ │ │ +
1785 auto current = iter->second.first;
│ │ │ │ +
1786 auto rend = iter->second.second;
│ │ │ │ +
1787
│ │ │ │ +
1788 // move all iterators pointing to the current global index to next value
│ │ │ │ +
1789 if(iter->second.first->localIndexPair().global()==index_ &&
│ │ │ │ +
1790 (noattribute || iter->second.first->localIndexPair().local().attribute() == attribute_))
│ │ │ │ +
1791 ++(iter->second.first);
│ │ │ │ +
1792
│ │ │ │ +
1793 // erase from the map if there are no more entries.
│ │ │ │ +
1794 if(iter->second.first == iter->second.second)
│ │ │ │ +
1795 map_.erase(iter++);
│ │ │ │ +
1796 else{
│ │ │ │ +
1797 ++iter;
│ │ │ │ +
1798 }
│ │ │ │ +
1799 }
│ │ │ │ +
1800 return *this;
│ │ │ │ +
1801 }
│ │ │ │ +
│ │ │ │ +
1802
│ │ │ │ +
1803 template<typename T, typename A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
1805 {
│ │ │ │ +
1806 return map_.empty();
│ │ │ │ +
1807 }
│ │ │ │ +
│ │ │ │ +
1808
│ │ │ │ +
1809 template<typename T, typename A>
│ │ │ │ +
1810 inline typename CollectiveIterator<T,A>::iterator
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
1812 {
│ │ │ │ +
1813 if(noattribute)
│ │ │ │ +
1814 return iterator(map_.begin(), map_.end(), index_);
│ │ │ │ +
1815 else
│ │ │ │ +
1816 return iterator(map_.begin(), map_.end(), index_,
│ │ │ │ +
1817 attribute_);
│ │ │ │ +
1818 }
│ │ │ │ +
│ │ │ │ +
1819
│ │ │ │ +
1820 template<typename T, typename A>
│ │ │ │ +
1821 inline typename CollectiveIterator<T,A>::iterator
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
1823 {
│ │ │ │ +
1824 return iterator(map_.end(), map_.end(), index_);
│ │ │ │ +
1825 }
│ │ │ │ +
│ │ │ │ +
1826
│ │ │ │ +
1827 template<typename TG, typename TA>
│ │ │ │ +
│ │ │ │ +
1828 inline std::ostream& operator<<(std::ostream& os, const RemoteIndex<TG,TA>& index)
│ │ │ │ +
1829 {
│ │ │ │ +
1830 os<<"[global="<<index.localIndexPair().global()<<", remote attribute="<<index.attribute()<<" local attribute="<<index.localIndexPair().local().attribute()<<"]";
│ │ │ │ +
1831 return os;
│ │ │ │ +
1832 }
│ │ │ │ +
│ │ │ │ +
1833
│ │ │ │ +
1834 template<typename T, typename A>
│ │ │ │ +
│ │ │ │ +
1835 inline std::ostream& operator<<(std::ostream& os, const RemoteIndices<T,A>& indices)
│ │ │ │ +
1836 {
│ │ │ │ +
1837 int rank;
│ │ │ │ +
1838 MPI_Comm_rank(indices.comm_, &rank);
│ │ │ │ +
1839 const auto rend = indices.remoteIndices_.end();
│ │ │ │ +
1840
│ │ │ │ +
1841 for(auto rindex = indices.remoteIndices_.begin(); rindex!=rend; ++rindex) {
│ │ │ │ +
1842 os<<rank<<": Process "<<rindex->first<<":";
│ │ │ │ +
1843
│ │ │ │ +
1844 if(!rindex->second.first->empty()) {
│ │ │ │ +
1845 os<<" send:";
│ │ │ │ +
1846
│ │ │ │ +
1847 const auto send= rindex->second.first->end();
│ │ │ │ +
1848
│ │ │ │ +
1849 for(auto index = rindex->second.first->begin();
│ │ │ │ +
1850 index != send; ++index)
│ │ │ │ +
1851 os<<*index<<" ";
│ │ │ │ +
1852 os<<std::endl;
│ │ │ │ +
1853 }
│ │ │ │ +
1854 if(!rindex->second.second->empty()) {
│ │ │ │ +
1855 os<<rank<<": Process "<<rindex->first<<": "<<"receive: ";
│ │ │ │ +
1856
│ │ │ │ +
1857 for(const auto& index : *(rindex->second.second))
│ │ │ │ +
1858 os << index << " ";
│ │ │ │ +
1859 }
│ │ │ │ +
1860 os<<std::endl<<std::flush;
│ │ │ │ +
1861 }
│ │ │ │ +
1862 return os;
│ │ │ │ +
1863 }
│ │ │ │ +
│ │ │ │ +
1865}
│ │ │ │ +
1866
│ │ │ │ +
1867#endif // HAVE_MPI
│ │ │ │ +
1868
│ │ │ │ +
1869#endif
│ │ │ │ +
Traits classes for mapping types onto MPI_Datatype.
│ │ │ │ +
Provides a map between global and local indices.
│ │ │ │ +
Provides classes for use as the local index in ParallelIndexSet for distributed computing.
│ │ │ │ +
A few common exception classes.
│ │ │ │ +
Implements a singly linked list together with the necessary iterators.
│ │ │ │ +
Standard Dune debug streams.
│ │ │ │ +
iterator end()
Get an iterator pointing to the end of the list.
Definition sllist.hh:774
│ │ │ │ +
SLListConstIterator< RemoteIndex, Allocator > const_iterator
The constant iterator of the list.
Definition sllist.hh:74
│ │ │ │ +
SLListModifyIterator< GlobalIndex, Allocator > ModifyIterator
The type of the iterator capable of deletion and insertion.
Definition sllist.hh:103
│ │ │ │ +
iterator begin()
Get an iterator pointing to the first element in the list.
Definition sllist.hh:762
│ │ │ │ +
std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x)
Definition bigunsignedint.hh:278
│ │ │ │
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
│ │ │ │ +
iterator begin()
Get an iterator over the indices positioned at the first index.
│ │ │ │ +
iterator end()
Get an iterator over the indices positioned after the last index.
│ │ │ │ +
TL LocalIndex
The type of the local index, e.g. ParallelLocalIndex.
Definition indexset.hh:239
│ │ │ │ +
const GlobalIndex & global() const
Get the global index.
│ │ │ │ +
LocalIndex & local()
Get the local index.
│ │ │ │ +
TG GlobalIndex
the type of the global index. This type has to provide at least a operator< for sorting.
Definition indexset.hh:226
│ │ │ │ +
@ GROUND
The default mode. Indicates that the index set is ready to be used.
Definition indexset.hh:186
│ │ │ │ +
DVVerbType dvverb(std::cout)
stream for very verbose output.
Definition stdstreams.hh:95
│ │ │ │ +
STL namespace.
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
K conjugateComplex(const K &x)
compute conjugate complex of x
Definition math.hh:164
│ │ │ │ -
A dense n x m matrix.
Definition densematrix.hh:140
│ │ │ │ -
constexpr size_type M() const
number of columns
Definition densematrix.hh:703
│ │ │ │ -
constexpr size_type N() const
number of rows
Definition densematrix.hh:697
│ │ │ │ -
A dense n x m matrix.
Definition fmatrix.hh:117
│ │ │ │ -
vector space out of a tensor product of fields.
Definition fvector.hh:95
│ │ │ │ -
you have to specialize this structure for any type that should be assignable to a DenseMatrix
Definition densematrix.hh:59
│ │ │ │ -
Error thrown if operations of a FieldMatrix fail.
Definition densematrix.hh:126
│ │ │ │ -
FieldTraits< value_type >::real_type two_norm2() const
square of two norm (sum over squared values of entries), need for block recursion
Definition densevector.hh:650
│ │ │ │ -
FieldTraits< value_type >::real_type two_norm() const
two norm sqrt(sum over squared values of entries)
Definition densevector.hh:641
│ │ │ │ -
Iterator begin()
begin iterator
Definition densevector.hh:347
│ │ │ │ -
FieldTraits< vt >::real_type infinity_norm() const
infinity norm (maximum of absolute values of entries)
Definition densevector.hh:661
│ │ │ │ -
FieldTraits< vt >::real_type infinity_norm_real() const
simplified infinity norm (uses Manhattan norm for complex values)
Definition densevector.hh:677
│ │ │ │ -
Definition diagonalmatrix.hh:698
│ │ │ │ -
Definition diagonalmatrix.hh:841
│ │ │ │ -
Definition diagonalmatrix.hh:650
│ │ │ │ -
Iterator class for sparse vector-like containers.
Definition diagonalmatrix.hh:998
│ │ │ │ -
ContainerWrapperIterator(const MyConstType &other)
Definition diagonalmatrix.hh:1031
│ │ │ │ -
bool equals(const MyConstType &other) const
Definition diagonalmatrix.hh:1057
│ │ │ │ -
A diagonal matrix of static size.
Definition diagonalmatrix.hh:53
│ │ │ │ -
Definition ftraits.hh:26
│ │ │ │ -
T field_type
export the type representing the field
Definition ftraits.hh:28
│ │ │ │ -
T real_type
export the type representing the real type of the field
Definition ftraits.hh:30
│ │ │ │ -
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
│ │ │ │ -
Facade class for stl conformant bidirectional iterators.
Definition iteratorfacades.hh:274
│ │ │ │ +
A traits class describing the mapping of types onto MPI_Datatypes.
Definition mpitraits.hh:41
│ │ │ │ +
static MPI_Datatype getType()
Definition mpitraits.hh:48
│ │ │ │ +
Default exception class for range errors.
Definition exceptions.hh:254
│ │ │ │ +
A pair consisting of a global and local index.
Definition indexset.hh:85
│ │ │ │ +
Exception indicating that the index set is not in the expected state.
Definition indexset.hh:205
│ │ │ │ +
Manager class for the mapping between local indices and globally unique indices.
Definition indexset.hh:218
│ │ │ │ +
Class for recomputing missing indices of a distributed index set.
Definition indicessyncer.hh:41
│ │ │ │ +
Base class of all classes representing a communication interface.
Definition parallel/interface.hh:35
│ │ │ │ +
An index present on the local process with an additional attribute flag.
Definition plocalindex.hh:49
│ │ │ │ +
The indices present on remote processes.
Definition remoteindices.hh:189
│ │ │ │ +
const std::set< int > & getNeighbours() const
Definition remoteindices.hh:307
│ │ │ │ +
Dune::RemoteIndex< GlobalIndex, Attribute > RemoteIndex
Type of the remote indices we manage.
Definition remoteindices.hh:231
│ │ │ │ +
RemoteIndices()
Definition remoteindices.hh:977
│ │ │ │ +
friend void fillIndexSetHoles(const G &graph, Dune::OwnerOverlapCopyCommunication< T1, T2 > &oocomm)
│ │ │ │ +
void setIndexSets(const ParallelIndexSet &source, const ParallelIndexSet &destination, const MPI_Comm &comm, const std::vector< int > &neighbours=std::vector< int >())
Set the index sets and communicator we work with.
Definition remoteindices.hh:984
│ │ │ │ +
void free()
Free the index lists.
Definition remoteindices.hh:1429
│ │ │ │ +
friend void repairLocalIndexPointers(std::map< int, SLList< std::pair< typename T1::GlobalIndex, typename T1::LocalIndex::Attribute >, A2 > > &, RemoteIndices< T1, A1 > &, const T1 &)
│ │ │ │ +
ParallelIndexSet::GlobalIndex GlobalIndex
The type of the global index.
Definition remoteindices.hh:215
│ │ │ │ +
void rebuild()
Rebuilds the set of remote indices.
Definition remoteindices.hh:1453
│ │ │ │ +
T ParallelIndexSet
Type of the index set we use, e.g. ParallelLocalIndexSet.
Definition remoteindices.hh:206
│ │ │ │ +
MPI_Comm communicator() const
Get the mpi communicator used.
Definition remoteindices.hh:1696
│ │ │ │ +
LocalIndex::Attribute Attribute
The type of the attribute.
Definition remoteindices.hh:226
│ │ │ │ +
CollectiveIteratorT iterator() const
Get an iterator for colletively iterating over the remote indices of all remote processes.
Definition remoteindices.hh:1690
│ │ │ │ +
void setIncludeSelf(bool includeSelf)
Tell whether sending from indices of the processor to other indices on the same processor is enabled ...
Definition remoteindices.hh:971
│ │ │ │ +
const_iterator end() const
Get an iterator over all remote index lists.
Definition remoteindices.hh:1529
│ │ │ │ +
bool operator==(const RemoteIndices &ri) const
Definition remoteindices.hh:1536
│ │ │ │ +
std::map< int, std::pair< RemoteIndexList *, RemoteIndexList * > > RemoteIndexMap
The type of the map from rank to remote index list.
Definition remoteindices.hh:245
│ │ │ │ +
void setNeighbours(const C &neighbours)
Definition remoteindices.hh:300
│ │ │ │ +
RemoteIndexListModifier< T, A, mode > getModifier(int process)
Get a modifier for a remote index list.
Definition remoteindices.hh:1480
│ │ │ │ +
const ParallelIndexSet & sourceIndexSet() const
Get the index set at the source.
Definition remoteindices.hh:999
│ │ │ │ +
~RemoteIndices()
Destructor.
Definition remoteindices.hh:1014
│ │ │ │ +
Dune::SLList< RemoteIndex, Allocator > RemoteIndexList
The type of the remote index list.
Definition remoteindices.hh:241
│ │ │ │ +
int neighbours() const
Get the number of processors we share indices with.
Definition remoteindices.hh:1446
│ │ │ │ +
CollectiveIterator< T, A > CollectiveIteratorT
The type of the collective iterator over all remote indices.
Definition remoteindices.hh:210
│ │ │ │ +
const ParallelIndexSet & destinationIndexSet() const
Get the index set at destination.
Definition remoteindices.hh:1007
│ │ │ │ +
typename std::allocator_traits< A >::template rebind_alloc< RemoteIndex > Allocator
The type of the allocator for the remote index list.
Definition remoteindices.hh:237
│ │ │ │ +
const_iterator find(int proc) const
Find an iterator over the remote index lists of a specific process.
Definition remoteindices.hh:1515
│ │ │ │ +
bool isSynced() const
Checks whether the remote indices are synced with the indexsets.
Definition remoteindices.hh:1473
│ │ │ │ +
const_iterator begin() const
Get an iterator over all remote index lists.
Definition remoteindices.hh:1522
│ │ │ │ +
ParallelIndexSet::LocalIndex LocalIndex
The type of the local index.
Definition remoteindices.hh:221
│ │ │ │ +
RemoteIndexMap::const_iterator const_iterator
Definition remoteindices.hh:247
│ │ │ │ +
Information about an index residing on another processor.
Definition remoteindices.hh:73
│ │ │ │ +
const Attribute attribute() const
Get the attribute of the index on the remote process.
Definition remoteindices.hh:946
│ │ │ │ +
friend void repairLocalIndexPointers(std::map< int, SLList< std::pair< typename T::GlobalIndex, typename T::LocalIndex::Attribute >, A > > &, RemoteIndices< T, A1 > &, const T &)
│ │ │ │ +
bool operator==(const RemoteIndex &ri) const
Definition remoteindices.hh:934
│ │ │ │ +
T1 GlobalIndex
the type of the global index. This type has to provide at least a operator< for sorting.
Definition remoteindices.hh:90
│ │ │ │ +
T2 Attribute
The type of the attributes. Normally this will be an enumeration like.
Definition remoteindices.hh:99
│ │ │ │ +
IndexPair< GlobalIndex, ParallelLocalIndex< Attribute > > PairType
The type of the index pair.
Definition remoteindices.hh:105
│ │ │ │ +
const PairType & localIndexPair() const
Get the corresponding local index pair.
Definition remoteindices.hh:952
│ │ │ │ +
RemoteIndex()
Parameterless Constructor.
Definition remoteindices.hh:930
│ │ │ │ +
bool operator!=(const RemoteIndex &ri) const
Definition remoteindices.hh:940
│ │ │ │ +
Modifier for adding and/or deleting remote indices from the remote index list.
Definition remoteindices.hh:551
│ │ │ │ +
void repairLocalIndexPointers()
Repair the pointers to the local index pairs.
Definition remoteindices.hh:1575
│ │ │ │ +
Dune::SLList< RemoteIndex, Allocator > RemoteIndexList
The type of the remote index list.
Definition remoteindices.hh:602
│ │ │ │ +
A Allocator
The type of the allocator for the remote index list.
Definition remoteindices.hh:598
│ │ │ │ +
void insert(const RemoteIndex &index)
Insert an index to the list.
Definition remoteindices.hh:1605
│ │ │ │ +
ParallelIndexSet::GlobalIndex GlobalIndex
The type of the global index.
Definition remoteindices.hh:578
│ │ │ │ +
ParallelIndexSet::LocalIndex LocalIndex
The type of the local index.
Definition remoteindices.hh:583
│ │ │ │ +
RemoteIndexList::const_iterator ConstIterator
The type of the remote index list iterator.
Definition remoteindices.hh:612
│ │ │ │ +
SLListModifyIterator< RemoteIndex, Allocator > ModifyIterator
The type of the modifying iterator of the remote index list.
Definition remoteindices.hh:607
│ │ │ │ +
bool remove(const GlobalIndex &global)
Remove a remote index.
Definition remoteindices.hh:1653
│ │ │ │ +
T ParallelIndexSet
Type of the index set we use.
Definition remoteindices.hh:573
│ │ │ │ +
RemoteIndexListModifier()
Default constructor.
Definition remoteindices.hh:676
│ │ │ │ +
LocalIndex::Attribute Attribute
The type of the attribute.
Definition remoteindices.hh:588
│ │ │ │ +
Dune::RemoteIndex< GlobalIndex, Attribute > RemoteIndex
Type of the remote indices we manage.
Definition remoteindices.hh:593
│ │ │ │ +
static constexpr bool MODIFYINDEXSET
If true the index set corresponding to the remote indices might get modified.
Definition remoteindices.hh:568
│ │ │ │ +
A collective iterator for moving over the remote indices for all processes collectively.
Definition remoteindices.hh:708
│ │ │ │ +
CollectiveIterator & operator++()
Definition remoteindices.hh:1779
│ │ │ │ +
iterator end()
Definition remoteindices.hh:1822
│ │ │ │ +
CollectiveIterator(const RemoteIndexMap &map_, bool send)
Constructor.
Definition remoteindices.hh:1703
│ │ │ │ +
bool empty() const
Checks whether there are still iterators in the map.
Definition remoteindices.hh:1804
│ │ │ │ +
void advance(const GlobalIndex &global)
Advances all underlying iterators.
Definition remoteindices.hh:1716
│ │ │ │ +
std::map< int, std::pair< RemoteIndexList *, RemoteIndexList * > > RemoteIndexMap
The type of the map from rank to remote index list.
Definition remoteindices.hh:748
│ │ │ │ +
iterator begin()
Definition remoteindices.hh:1811
│ │ │ │ +
Definition remoteindices.hh:167
│ │ │ │ +
Definition remoteindices.hh:558
│ │ │ │ +
Iterator over the valid underlying iterators.
Definition remoteindices.hh:792
│ │ │ │ +
iterator(const RealIterator &iter, const ConstRealIterator &end, GlobalIndex &index)
Definition remoteindices.hh:799
│ │ │ │ +
iterator(const iterator &other)
Definition remoteindices.hh:817
│ │ │ │ +
const RemoteIndex & operator*() const
Definition remoteindices.hh:838
│ │ │ │ +
Map::iterator ConstRealIterator
Definition remoteindices.hh:795
│ │ │ │ +
iterator & operator++()
Definition remoteindices.hh:822
│ │ │ │ +
const RemoteIndex * operator->() const
Definition remoteindices.hh:850
│ │ │ │ +
bool operator==(const iterator &other) const
Definition remoteindices.hh:856
│ │ │ │ +
int process() const
Definition remoteindices.hh:844
│ │ │ │ +
iterator(const RealIterator &iter, const ConstRealIterator &end, GlobalIndex index, Attribute attribute)
Definition remoteindices.hh:807
│ │ │ │ +
bool operator!=(const iterator &other) const
Definition remoteindices.hh:862
│ │ │ │ +
Map::iterator RealIterator
Definition remoteindices.hh:794
│ │ │ │ +
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
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,1604 +7,1932 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -diagonalmatrix.hh │ │ │ │ │ + * parallel │ │ │ │ │ +remoteindices.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 (C) 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_DIAGONAL_MATRIX_HH │ │ │ │ │ - 6#define DUNE_DIAGONAL_MATRIX_HH │ │ │ │ │ + 5#ifndef DUNE_REMOTEINDICES_HH │ │ │ │ │ + 6#define DUNE_REMOTEINDICES_HH │ │ │ │ │ 7 │ │ │ │ │ - 12#include │ │ │ │ │ - 13#include │ │ │ │ │ - 14#include │ │ │ │ │ - 15#include │ │ │ │ │ - 16#include │ │ │ │ │ - 17#include │ │ │ │ │ - 18#include │ │ │ │ │ - 19#include │ │ │ │ │ + 8#if HAVE_MPI │ │ │ │ │ + 9 │ │ │ │ │ + 10#include │ │ │ │ │ + 11#include │ │ │ │ │ + 12#include │ │ │ │ │ + 13#include │ │ │ │ │ + 14#include │ │ │ │ │ + 15#include │ │ │ │ │ + 16#include │ │ │ │ │ + 17#include │ │ │ │ │ + 18 │ │ │ │ │ + 19#include │ │ │ │ │ 20 │ │ │ │ │ - 21#include │ │ │ │ │ - 22#include │ │ │ │ │ - 23#include │ │ │ │ │ - 24#include │ │ │ │ │ - 25#include │ │ │ │ │ - 26#include │ │ │ │ │ - 27#include │ │ │ │ │ - 28 │ │ │ │ │ - 29 │ │ │ │ │ - 30namespace Dune { │ │ │ │ │ - 31 │ │ │ │ │ - 32 template< class K, int n > class DiagonalRowVectorConst; │ │ │ │ │ - 33 template< class K, int n > class DiagonalRowVector; │ │ │ │ │ - 34 template< class DiagonalMatrixType > class DiagonalMatrixWrapper; │ │ │ │ │ - 35 template< class C, class T, class R> class ContainerWrapperIterator; │ │ │ │ │ - 36 │ │ │ │ │ - 51 template │ │ │ │ │ -52 class DiagonalMatrix │ │ │ │ │ - 53 { │ │ │ │ │ - 54 typedef DiagonalMatrixWrapper<_DiagonalMatrix > WrapperType; │ │ │ │ │ + 21#include │ │ │ │ │ + 22#include │ │ │ │ │ + 23#include │ │ │ │ │ + 24#include │ │ │ │ │ + 25#include │ │ │ │ │ + 26#include │ │ │ │ │ + 27 │ │ │ │ │ + 28namespace Dune { │ │ │ │ │ + 40 template │ │ │ │ │ +41 class MPITraits > > │ │ │ │ │ + 42 { │ │ │ │ │ + 43 public: │ │ │ │ │ + 44 inline static MPI_Datatype getType(); │ │ │ │ │ + 45 private: │ │ │ │ │ + 46 static MPI_Datatype type; │ │ │ │ │ + 47 }; │ │ │ │ │ + 48 │ │ │ │ │ + 49 │ │ │ │ │ + 50 template │ │ │ │ │ + 51 class RemoteIndices; │ │ │ │ │ + 52 │ │ │ │ │ + 53 template │ │ │ │ │ + 54 class RemoteIndex; │ │ │ │ │ 55 │ │ │ │ │ - 56 public: │ │ │ │ │ - 57 //===== type definitions and constants │ │ │ │ │ - 58 │ │ │ │ │ -60 typedef K value_type; │ │ │ │ │ -61 typedef value_type field_type; │ │ │ │ │ + 56 // forward declaration needed for friend declaration. │ │ │ │ │ + 57 template │ │ │ │ │ + 58 class IndicesSyncer; │ │ │ │ │ + 59 │ │ │ │ │ + 60 template │ │ │ │ │ +61 std::ostream& operator<<(std::ostream& os, const RemoteIndex& index); │ │ │ │ │ 62 │ │ │ │ │ -64 typedef K block_type; │ │ │ │ │ - 65 │ │ │ │ │ -67 typedef std::size_t size_type; │ │ │ │ │ - 68 │ │ │ │ │ -70 constexpr static int blocklevel = 1; │ │ │ │ │ - 71 │ │ │ │ │ -73 typedef DiagonalRowVector row_type; │ │ │ │ │ -74 typedef row_type reference; │ │ │ │ │ -75 typedef row_type row_reference; │ │ │ │ │ -76 typedef DiagonalRowVectorConst const_row_type; │ │ │ │ │ -77 typedef const_row_type const_reference; │ │ │ │ │ -78 typedef const_row_type const_row_reference; │ │ │ │ │ - 79 │ │ │ │ │ -81 constexpr static int rows = n; │ │ │ │ │ -83 constexpr static int cols = n; │ │ │ │ │ + 63 │ │ │ │ │ + 64 template │ │ │ │ │ + 65 class RemoteIndexListModifier; │ │ │ │ │ + 66 │ │ │ │ │ + 67 │ │ │ │ │ + 71 template │ │ │ │ │ +72 class RemoteIndex │ │ │ │ │ + 73 { │ │ │ │ │ + 74 template │ │ │ │ │ +75 friend class IndicesSyncer; │ │ │ │ │ + 76 │ │ │ │ │ + 77 template │ │ │ │ │ +78 friend void repairLocalIndexPointers(std::map,A> >&, │ │ │ │ │ + 79 RemoteIndices&, │ │ │ │ │ + 80 const T&); │ │ │ │ │ + 81 │ │ │ │ │ + 82 template │ │ │ │ │ +83 friend class RemoteIndexListModifier; │ │ │ │ │ 84 │ │ │ │ │ - 85 //==== size │ │ │ │ │ - 86 │ │ │ │ │ -87 static constexpr size_type size () │ │ │ │ │ - 88 { │ │ │ │ │ - 89 return rows; │ │ │ │ │ - 90 } │ │ │ │ │ - 91 │ │ │ │ │ - 92 //===== constructors │ │ │ │ │ - 93 │ │ │ │ │ -95 constexpr DiagonalMatrix() = default; │ │ │ │ │ - 96 │ │ │ │ │ -98 DiagonalMatrix (const K& k) │ │ │ │ │ - 99 : diag_(k) │ │ │ │ │ - 100 {} │ │ │ │ │ - 101 │ │ │ │ │ -103 DiagonalMatrix (const FieldVector& diag) │ │ │ │ │ - 104 : diag_(diag) │ │ │ │ │ - 105 {} │ │ │ │ │ + 85 public: │ │ │ │ │ +90 typedef T1 GlobalIndex; │ │ │ │ │ +99 typedef T2 Attribute; │ │ │ │ │ + 100 │ │ │ │ │ + 104 typedef IndexPair > │ │ │ │ │ +105 PairType; │ │ │ │ │ 106 │ │ │ │ │ -115 DiagonalMatrix (std::initializer_list const &l) │ │ │ │ │ - 116 { │ │ │ │ │ - 117 std::copy_n(l.begin(), std::min(static_cast(rows), │ │ │ │ │ - 118 l.size()), │ │ │ │ │ - 119 diag_.begin()); │ │ │ │ │ - 120 } │ │ │ │ │ - 121 │ │ │ │ │ -123 DiagonalMatrix& operator=(const K& k) │ │ │ │ │ - 124 { │ │ │ │ │ - 125 diag_ = k; │ │ │ │ │ - 126 return *this; │ │ │ │ │ - 127 } │ │ │ │ │ - 128 │ │ │ │ │ -130 bool identical(const DiagonalMatrix& other) const │ │ │ │ │ - 131 { │ │ │ │ │ - 132 return (this==&other); │ │ │ │ │ - 133 } │ │ │ │ │ + 111 const Attribute attribute() const; │ │ │ │ │ + 112 │ │ │ │ │ + 118 const PairType& localIndexPair() const; │ │ │ │ │ + 119 │ │ │ │ │ + 123 RemoteIndex(); │ │ │ │ │ + 124 │ │ │ │ │ + 125 │ │ │ │ │ + 131 RemoteIndex(const T2& attribute, │ │ │ │ │ + 132 const PairType* local); │ │ │ │ │ + 133 │ │ │ │ │ 134 │ │ │ │ │ -136 DiagonalMatrix transposed() const │ │ │ │ │ - 137 { │ │ │ │ │ - 138 return *this; │ │ │ │ │ - 139 } │ │ │ │ │ - 140 │ │ │ │ │ - 141 //===== iterator interface to rows of the matrix │ │ │ │ │ -143 typedef ContainerWrapperIterator │ │ │ │ │ -Iterator; │ │ │ │ │ -145 typedef Iterator iterator; │ │ │ │ │ -147 typedef Iterator RowIterator; │ │ │ │ │ -149 typedef typename row_type::Iterator ColIterator; │ │ │ │ │ - 150 │ │ │ │ │ -152 Iterator begin () │ │ │ │ │ - 153 { │ │ │ │ │ - 154 return Iterator(WrapperType(this),0); │ │ │ │ │ - 155 } │ │ │ │ │ - 156 │ │ │ │ │ -158 Iterator end () │ │ │ │ │ - 159 { │ │ │ │ │ - 160 return Iterator(WrapperType(this),n); │ │ │ │ │ - 161 } │ │ │ │ │ - 162 │ │ │ │ │ -165 Iterator beforeEnd () │ │ │ │ │ - 166 { │ │ │ │ │ - 167 return Iterator(WrapperType(this),n-1); │ │ │ │ │ - 168 } │ │ │ │ │ + 140 RemoteIndex(const T2& attribute); │ │ │ │ │ + 141 │ │ │ │ │ + 142 bool operator==(const RemoteIndex& ri) const; │ │ │ │ │ + 143 │ │ │ │ │ + 144 bool operator!=(const RemoteIndex& ri) const; │ │ │ │ │ + 145 private: │ │ │ │ │ + 147 const PairType* localIndex_; │ │ │ │ │ + 148 │ │ │ │ │ + 150 char attribute_; │ │ │ │ │ + 151 }; │ │ │ │ │ + 152 │ │ │ │ │ + 153 template │ │ │ │ │ + 154 std::ostream& operator<<(std::ostream& os, const RemoteIndices& │ │ │ │ │ +indices); │ │ │ │ │ + 155 │ │ │ │ │ + 156 class InterfaceBuilder; │ │ │ │ │ + 157 │ │ │ │ │ + 158 template │ │ │ │ │ + 159 class CollectiveIterator; │ │ │ │ │ + 160 │ │ │ │ │ + 161 // forward declaration needed for friend declaration. │ │ │ │ │ + 162 template │ │ │ │ │ + 163 class IndicesSyncer; │ │ │ │ │ + 164 │ │ │ │ │ + 165 // forward declaration needed for friend declaration. │ │ │ │ │ + 166 template │ │ │ │ │ +167 class OwnerOverlapCopyCommunication; │ │ │ │ │ + 168 │ │ │ │ │ 169 │ │ │ │ │ -172 Iterator beforeBegin () │ │ │ │ │ - 173 { │ │ │ │ │ - 174 return Iterator(WrapperType(this),-1); │ │ │ │ │ - 175 } │ │ │ │ │ - 176 │ │ │ │ │ - 177 │ │ │ │ │ -179 typedef ContainerWrapperIterator ConstIterator; │ │ │ │ │ -181 typedef ConstIterator const_iterator; │ │ │ │ │ -183 typedef ConstIterator ConstRowIterator; │ │ │ │ │ -185 typedef typename const_row_type::ConstIterator ConstColIterator; │ │ │ │ │ - 186 │ │ │ │ │ -188 ConstIterator begin () const │ │ │ │ │ + 186 template > > │ │ │ │ │ +188 class RemoteIndices │ │ │ │ │ 189 { │ │ │ │ │ - 190 return ConstIterator(WrapperType(this),0); │ │ │ │ │ - 191 } │ │ │ │ │ - 192 │ │ │ │ │ -194 ConstIterator end () const │ │ │ │ │ - 195 { │ │ │ │ │ - 196 return ConstIterator(WrapperType(this),n); │ │ │ │ │ - 197 } │ │ │ │ │ - 198 │ │ │ │ │ -201 ConstIterator beforeEnd() const │ │ │ │ │ - 202 { │ │ │ │ │ - 203 return ConstIterator(WrapperType(this),n-1); │ │ │ │ │ - 204 } │ │ │ │ │ - 205 │ │ │ │ │ -208 ConstIterator beforeBegin () const │ │ │ │ │ - 209 { │ │ │ │ │ - 210 return ConstIterator(WrapperType(this),-1); │ │ │ │ │ - 211 } │ │ │ │ │ - 212 │ │ │ │ │ - 213 │ │ │ │ │ - 214 │ │ │ │ │ - 215 //===== vector space arithmetic │ │ │ │ │ +190 friend class InterfaceBuilder; │ │ │ │ │ + 191 friend class IndicesSyncer; │ │ │ │ │ + 192 template │ │ │ │ │ +193 friend void repairLocalIndexPointers(std::map,A2> >&, │ │ │ │ │ + 194 RemoteIndices&, │ │ │ │ │ + 195 const T1&); │ │ │ │ │ + 196 │ │ │ │ │ + 197 template │ │ │ │ │ +198 friend void fillIndexSetHoles(const G& graph, Dune:: │ │ │ │ │ +OwnerOverlapCopyCommunication& oocomm); │ │ │ │ │ +199 friend std::ostream& operator<<<>(std::ostream&, const RemoteIndices&); │ │ │ │ │ + 200 │ │ │ │ │ + 201 public: │ │ │ │ │ + 202 │ │ │ │ │ +206 typedef T ParallelIndexSet; │ │ │ │ │ + 207 │ │ │ │ │ +210 typedef CollectiveIterator CollectiveIteratorT; │ │ │ │ │ + 211 │ │ │ │ │ +215 typedef typename ParallelIndexSet::GlobalIndex GlobalIndex; │ │ │ │ │ 216 │ │ │ │ │ -218 DiagonalMatrix& operator+=(const DiagonalMatrix& y) │ │ │ │ │ - 219 { │ │ │ │ │ - 220 diag_ += y.diag_; │ │ │ │ │ - 221 return *this; │ │ │ │ │ - 222 } │ │ │ │ │ - 223 │ │ │ │ │ -225 DiagonalMatrix& operator-=(const DiagonalMatrix& y) │ │ │ │ │ - 226 { │ │ │ │ │ - 227 diag_ -= y.diag_; │ │ │ │ │ - 228 return *this; │ │ │ │ │ - 229 } │ │ │ │ │ - 230 │ │ │ │ │ -232 DiagonalMatrix& operator+=(const K& k) │ │ │ │ │ - 233 { │ │ │ │ │ - 234 diag_ += k; │ │ │ │ │ - 235 return *this; │ │ │ │ │ - 236 } │ │ │ │ │ - 237 │ │ │ │ │ -239 DiagonalMatrix& operator-=(const K& k) │ │ │ │ │ - 240 { │ │ │ │ │ - 241 diag_ -= k; │ │ │ │ │ - 242 return *this; │ │ │ │ │ - 243 } │ │ │ │ │ - 244 │ │ │ │ │ -246 DiagonalMatrix& operator*=(const K& k) │ │ │ │ │ - 247 { │ │ │ │ │ - 248 diag_ *= k; │ │ │ │ │ - 249 return *this; │ │ │ │ │ - 250 } │ │ │ │ │ - 251 │ │ │ │ │ -253 DiagonalMatrix& operator/=(const K& k) │ │ │ │ │ - 254 { │ │ │ │ │ - 255 diag_ /= k; │ │ │ │ │ - 256 return *this; │ │ │ │ │ - 257 } │ │ │ │ │ - 258 │ │ │ │ │ - 259 //===== comparison ops │ │ │ │ │ - 260 │ │ │ │ │ -262 bool operator==(const DiagonalMatrix& other) const │ │ │ │ │ - 263 { │ │ │ │ │ - 264 return diag_==other.diagonal(); │ │ │ │ │ - 265 } │ │ │ │ │ - 266 │ │ │ │ │ -268 bool operator!=(const DiagonalMatrix& other) const │ │ │ │ │ - 269 { │ │ │ │ │ - 270 return diag_!=other.diagonal(); │ │ │ │ │ - 271 } │ │ │ │ │ - 272 │ │ │ │ │ - 273 │ │ │ │ │ - 274 //===== linear maps │ │ │ │ │ - 275 │ │ │ │ │ - 277 template │ │ │ │ │ -278 void mv (const X& x, Y& y) const │ │ │ │ │ - 279 { │ │ │ │ │ - 280#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ - 281 if (x.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ - 282 if (y.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ - 283#endif │ │ │ │ │ - 284 for (size_type i=0; i │ │ │ │ │ -290 void mtv (const X& x, Y& y) const │ │ │ │ │ - 291 { │ │ │ │ │ - 292 mv(x, y); │ │ │ │ │ - 293 } │ │ │ │ │ - 294 │ │ │ │ │ - 296 template │ │ │ │ │ -297 void umv (const X& x, Y& y) const │ │ │ │ │ - 298 { │ │ │ │ │ - 299#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ - 300 if (x.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ - 301 if (y.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ - 302#endif │ │ │ │ │ - 303 for (size_type i=0; i RemoteIndex; │ │ │ │ │ + 232 │ │ │ │ │ + 233 │ │ │ │ │ +237 using Allocator = typename std::allocator_traits::template │ │ │ │ │ +rebind_alloc; │ │ │ │ │ + 238 │ │ │ │ │ + 240 typedef Dune::SLList │ │ │ │ │ +241 RemoteIndexList; │ │ │ │ │ + 242 │ │ │ │ │ + 244 typedef std::map > │ │ │ │ │ +245 RemoteIndexMap; │ │ │ │ │ + 246 │ │ │ │ │ +247 typedef typename RemoteIndexMap::const_iterator const_iterator; │ │ │ │ │ + 248 │ │ │ │ │ + 266 inline RemoteIndices(const ParallelIndexSet& source, const │ │ │ │ │ +ParallelIndexSet& destination, │ │ │ │ │ + 267 const MPI_Comm& comm, const std::vector& neighbours=std::vector │ │ │ │ │ +(), bool includeSelf=false); │ │ │ │ │ + 268 │ │ │ │ │ + 269 RemoteIndices(); │ │ │ │ │ + 270 │ │ │ │ │ + 278 void setIncludeSelf(bool includeSelf); │ │ │ │ │ + 279 │ │ │ │ │ + 296 void setIndexSets(const ParallelIndexSet& source, const ParallelIndexSet& │ │ │ │ │ +destination, │ │ │ │ │ + 297 const MPI_Comm& comm, const std::vector& neighbours=std::vector │ │ │ │ │ +()); │ │ │ │ │ + 298 │ │ │ │ │ + 299 template │ │ │ │ │ +300 void setNeighbours(const C& neighbours) │ │ │ │ │ + 301 { │ │ │ │ │ + 302 neighbourIds.clear(); │ │ │ │ │ + 303 neighbourIds.insert(neighbours.begin(), neighbours.end()); │ │ │ │ │ + 304 │ │ │ │ │ 305 } │ │ │ │ │ 306 │ │ │ │ │ - 308 template │ │ │ │ │ -309 void umtv (const X& x, Y& y) const │ │ │ │ │ - 310 { │ │ │ │ │ - 311#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ - 312 if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ - 313 if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ - 314#endif │ │ │ │ │ - 315 for (size_type i=0; i │ │ │ │ │ -321 void umhv (const X& x, Y& y) const │ │ │ │ │ - 322 { │ │ │ │ │ - 323#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ - 324 if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ - 325 if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ - 326#endif │ │ │ │ │ - 327 for (size_type i=0; i& getNeighbours() const │ │ │ │ │ + 308 { │ │ │ │ │ + 309 return neighbourIds; │ │ │ │ │ + 310 } │ │ │ │ │ + 311 │ │ │ │ │ + 315 ~RemoteIndices(); │ │ │ │ │ + 316 │ │ │ │ │ + 326 template │ │ │ │ │ + 327 void rebuild(); │ │ │ │ │ + 328 │ │ │ │ │ + 329 bool operator==(const RemoteIndices& ri) const; │ │ │ │ │ 330 │ │ │ │ │ - 332 template │ │ │ │ │ -333 void mmv (const X& x, Y& y) const │ │ │ │ │ - 334 { │ │ │ │ │ - 335#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ - 336 if (x.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ - 337 if (y.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ - 338#endif │ │ │ │ │ - 339 for (size_type i=0; i │ │ │ │ │ -345 void mmtv (const X& x, Y& y) const │ │ │ │ │ - 346 { │ │ │ │ │ - 347#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ - 348 if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ - 349 if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ - 350#endif │ │ │ │ │ - 351 for (size_type i=0; i │ │ │ │ │ -357 void mmhv (const X& x, Y& y) const │ │ │ │ │ - 358 { │ │ │ │ │ - 359#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ - 360 if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ - 361 if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ - 362#endif │ │ │ │ │ - 363 for (size_type i=0; i │ │ │ │ │ -369 void usmv (const typename FieldTraits::field_type & alpha, │ │ │ │ │ - 370 const X& x, Y& y) const │ │ │ │ │ - 371 { │ │ │ │ │ - 372#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ - 373 if (x.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ - 374 if (y.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ - 375#endif │ │ │ │ │ - 376 for (size_type i=0; i │ │ │ │ │ -382 void usmtv (const typename FieldTraits::field_type & alpha, │ │ │ │ │ - 383 const X& x, Y& y) const │ │ │ │ │ - 384 { │ │ │ │ │ - 385#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ - 386 if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ - 387 if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ - 388#endif │ │ │ │ │ - 389 for (size_type i=0; i │ │ │ │ │ + 360 inline RemoteIndexListModifier getModifier(int process); │ │ │ │ │ + 361 │ │ │ │ │ + 368 inline const_iterator find(int proc) const; │ │ │ │ │ + 369 │ │ │ │ │ + 374 inline const_iterator begin() const; │ │ │ │ │ + 375 │ │ │ │ │ + 380 inline const_iterator end() const; │ │ │ │ │ + 381 │ │ │ │ │ + 385 template │ │ │ │ │ + 386 inline CollectiveIteratorT iterator() const; │ │ │ │ │ + 387 │ │ │ │ │ + 391 inline void free(); │ │ │ │ │ 392 │ │ │ │ │ - 394 template │ │ │ │ │ -395 void usmhv (const typename FieldTraits::field_type & alpha, │ │ │ │ │ - 396 const X& x, Y& y) const │ │ │ │ │ - 397 { │ │ │ │ │ - 398#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ - 399 if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ - 400 if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ - 401#endif │ │ │ │ │ - 402 for (size_type i=0; i │ │ │ │ │ -438 void solve (V& x, const V& b) const │ │ │ │ │ - 439 { │ │ │ │ │ - 440 for (int i=0; i::real_type; │ │ │ │ │ - 448 for (int i=0; i │ │ │ │ │ -468 friend auto operator*( const DiagonalMatrix& matrixA, │ │ │ │ │ - 469 const DiagonalMatrix& matrixB) │ │ │ │ │ - 470 { │ │ │ │ │ - 471 auto result = DiagonalMatrix:: │ │ │ │ │ -PromotedType, n>{}; │ │ │ │ │ - 472 for(int i=0; i neighbourIds; │ │ │ │ │ + 421 │ │ │ │ │ + 423 const static int commTag_=333; │ │ │ │ │ + 424 │ │ │ │ │ + 429 int sourceSeqNo_; │ │ │ │ │ + 430 │ │ │ │ │ + 435 int destSeqNo_; │ │ │ │ │ + 436 │ │ │ │ │ + 440 bool publicIgnored; │ │ │ │ │ + 441 │ │ │ │ │ + 445 bool firstBuild; │ │ │ │ │ + 446 │ │ │ │ │ + 447 /* │ │ │ │ │ + 448 * @brief If true, sending from indices of the processor to other │ │ │ │ │ + 449 * indices on the same processor is enabled even if the same indexset is │ │ │ │ │ +used │ │ │ │ │ + 450 * on both the │ │ │ │ │ + 451 * sending and receiving side. │ │ │ │ │ + 452 */ │ │ │ │ │ + 453 bool includeSelf; │ │ │ │ │ + 454 │ │ │ │ │ + 456 typedef IndexPair │ │ │ │ │ + 457 PairType; │ │ │ │ │ + 458 │ │ │ │ │ + 465 RemoteIndexMap remoteIndices_; │ │ │ │ │ + 466 │ │ │ │ │ + 477 template │ │ │ │ │ + 478 inline void buildRemote(bool includeSelf); │ │ │ │ │ + 479 │ │ │ │ │ + 485 inline int noPublic(const ParallelIndexSet& indexSet); │ │ │ │ │ 486 │ │ │ │ │ -488 static constexpr size_type M () │ │ │ │ │ - 489 { │ │ │ │ │ - 490 return n; │ │ │ │ │ - 491 } │ │ │ │ │ - 492 │ │ │ │ │ - 493 │ │ │ │ │ - 494 │ │ │ │ │ - 495 //===== query │ │ │ │ │ - 496 │ │ │ │ │ -498 bool exists (size_type i, size_type j) const │ │ │ │ │ - 499 { │ │ │ │ │ - 500 DUNE_ASSERT_BOUNDS(i >= 0 && i < n); │ │ │ │ │ - 501 DUNE_ASSERT_BOUNDS(j >= 0 && j < n); │ │ │ │ │ - 502 return i==j; │ │ │ │ │ - 503 } │ │ │ │ │ - 504 │ │ │ │ │ - 505 │ │ │ │ │ - 506 │ │ │ │ │ -508 friend std::ostream& operator<<(std::ostream& s, const DiagonalMatrix& │ │ │ │ │ -a) │ │ │ │ │ - 509 { │ │ │ │ │ - 510 for (size_type i=0; i(&diag_[i]), i); │ │ │ │ │ - 522 } │ │ │ │ │ - 523 │ │ │ │ │ -525 const_reference operator[](size_type i) const │ │ │ │ │ - 526 { │ │ │ │ │ - 527 return const_reference(const_cast(&diag_[i]), i); │ │ │ │ │ - 528 } │ │ │ │ │ - 529 │ │ │ │ │ -531 const K& diagonal(size_type i) const │ │ │ │ │ - 532 { │ │ │ │ │ - 533 return diag_[i]; │ │ │ │ │ - 534 } │ │ │ │ │ - 535 │ │ │ │ │ -537 K& diagonal(size_type i) │ │ │ │ │ - 538 { │ │ │ │ │ - 539 return diag_[i]; │ │ │ │ │ - 540 } │ │ │ │ │ - 541 │ │ │ │ │ -543 const FieldVector& diagonal() const │ │ │ │ │ - 544 { │ │ │ │ │ - 545 return diag_; │ │ │ │ │ - 546 } │ │ │ │ │ - 547 │ │ │ │ │ -549 FieldVector& diagonal() │ │ │ │ │ - 550 { │ │ │ │ │ - 551 return diag_; │ │ │ │ │ - 552 } │ │ │ │ │ - 553 │ │ │ │ │ - 554 private: │ │ │ │ │ + 498 template │ │ │ │ │ + 499 inline void packEntries(PairType** myPairs, const ParallelIndexSet& │ │ │ │ │ +indexSet, │ │ │ │ │ + 500 char* p_out, MPI_Datatype type, int bufferSize, │ │ │ │ │ + 501 int* position, int n); │ │ │ │ │ + 502 │ │ │ │ │ + 516 inline void unpackIndices(RemoteIndexList& remote, int remoteEntries, │ │ │ │ │ + 517 PairType** local, int localEntries, char* p_in, │ │ │ │ │ + 518 MPI_Datatype type, int* position, int bufferSize, │ │ │ │ │ + 519 bool fromOurself); │ │ │ │ │ + 520 │ │ │ │ │ + 521 inline void unpackIndices(RemoteIndexList& send, RemoteIndexList& receive, │ │ │ │ │ + 522 int remoteEntries, PairType** localSource, │ │ │ │ │ + 523 int localSourceEntries, PairType** localDest, │ │ │ │ │ + 524 int localDestEntries, char* p_in, │ │ │ │ │ + 525 MPI_Datatype type, int* position, int bufferSize); │ │ │ │ │ + 526 │ │ │ │ │ + 527 void unpackCreateRemote(char* p_in, PairType** sourcePairs, PairType** │ │ │ │ │ +DestPairs, │ │ │ │ │ + 528 int remoteProc, int sourcePublish, int destPublish, │ │ │ │ │ + 529 int bufferSize, bool sendTwo, bool fromOurSelf=false); │ │ │ │ │ + 530 }; │ │ │ │ │ + 531 │ │ │ │ │ + 549 template │ │ │ │ │ +550 class RemoteIndexListModifier │ │ │ │ │ + 551 { │ │ │ │ │ + 552 │ │ │ │ │ + 553 template │ │ │ │ │ +554 friend class RemoteIndices; │ │ │ │ │ 555 │ │ │ │ │ - 556 // the data, a FieldVector storing the diagonal │ │ │ │ │ - 557 FieldVector diag_; │ │ │ │ │ - 558 }; │ │ │ │ │ + 556 public: │ │ │ │ │ +557 class InvalidPosition : public RangeError │ │ │ │ │ + 558 {}; │ │ │ │ │ 559 │ │ │ │ │ - 560 template< class K, int n > │ │ │ │ │ -561 struct FieldTraits< DiagonalMatrix > │ │ │ │ │ - 562 { │ │ │ │ │ -563 typedef typename FieldTraits::field_type field_type; │ │ │ │ │ -564 typedef typename FieldTraits::real_type real_type; │ │ │ │ │ - 565 }; │ │ │ │ │ - 566 │ │ │ │ │ - 567 │ │ │ │ │ - 568#ifndef DOXYGEN // hide specialization │ │ │ │ │ - 571 template< class K > │ │ │ │ │ - 572 class DiagonalMatrix : public FieldMatrix │ │ │ │ │ - 573 { │ │ │ │ │ - 574 typedef FieldMatrix Base; │ │ │ │ │ - 575 public: │ │ │ │ │ - 577 typedef typename Base::size_type size_type; │ │ │ │ │ - 578 │ │ │ │ │ - 581 constexpr static int blocklevel = 1; │ │ │ │ │ - 582 │ │ │ │ │ - 583 typedef typename Base::row_type row_type; │ │ │ │ │ +568 constexpr static bool MODIFYINDEXSET = mode; │ │ │ │ │ + 569 │ │ │ │ │ +573 typedef T ParallelIndexSet; │ │ │ │ │ + 574 │ │ │ │ │ +578 typedef typename ParallelIndexSet::GlobalIndex GlobalIndex; │ │ │ │ │ + 579 │ │ │ │ │ +583 typedef typename ParallelIndexSet::LocalIndex LocalIndex; │ │ │ │ │ 584 │ │ │ │ │ - 585 typedef typename Base::row_reference row_reference; │ │ │ │ │ - 586 typedef typename Base::const_row_reference const_row_reference; │ │ │ │ │ - 587 │ │ │ │ │ - 590 constexpr static int rows = 1; │ │ │ │ │ - 593 constexpr static int cols = 1; │ │ │ │ │ +588 typedef typename LocalIndex::Attribute Attribute; │ │ │ │ │ + 589 │ │ │ │ │ +593 typedef Dune::RemoteIndex RemoteIndex; │ │ │ │ │ 594 │ │ │ │ │ - 595 │ │ │ │ │ - 597 constexpr DiagonalMatrix() = default; │ │ │ │ │ - 598 │ │ │ │ │ - 600 DiagonalMatrix(const K& scalar) │ │ │ │ │ - 601 { │ │ │ │ │ - 602 (*this)[0][0] = scalar; │ │ │ │ │ - 603 } │ │ │ │ │ - 604 │ │ │ │ │ - 606 const K& diagonal(size_type) const │ │ │ │ │ - 607 { │ │ │ │ │ - 608 return (*this)[0][0]; │ │ │ │ │ - 609 } │ │ │ │ │ - 610 │ │ │ │ │ - 612 K& diagonal(size_type) │ │ │ │ │ - 613 { │ │ │ │ │ - 614 return (*this)[0][0]; │ │ │ │ │ - 615 } │ │ │ │ │ - 616 │ │ │ │ │ - 618 const FieldVector& diagonal() const │ │ │ │ │ - 619 { │ │ │ │ │ - 620 return (*this)[0]; │ │ │ │ │ - 621 } │ │ │ │ │ - 622 │ │ │ │ │ - 624 FieldVector& diagonal() │ │ │ │ │ - 625 { │ │ │ │ │ - 626 return (*this)[0]; │ │ │ │ │ - 627 } │ │ │ │ │ +598 typedef A Allocator; │ │ │ │ │ + 599 │ │ │ │ │ + 601 typedef Dune::SLList │ │ │ │ │ +602 RemoteIndexList; │ │ │ │ │ + 603 │ │ │ │ │ +607 typedef SLListModifyIterator ModifyIterator; │ │ │ │ │ + 608 │ │ │ │ │ +612 typedef typename RemoteIndexList::const_iterator ConstIterator; │ │ │ │ │ + 613 │ │ │ │ │ + 627 void insert(const RemoteIndex& index); │ │ │ │ │ 628 │ │ │ │ │ - 630 DiagonalMatrix transposed() const │ │ │ │ │ - 631 { │ │ │ │ │ - 632 return *this; │ │ │ │ │ - 633 } │ │ │ │ │ - 634 │ │ │ │ │ - 637 template │ │ │ │ │ - 638 friend auto operator*( const DiagonalMatrix& matrixA, │ │ │ │ │ - 639 const DiagonalMatrix& matrixB) │ │ │ │ │ - 640 { │ │ │ │ │ - 641 return DiagonalMatrix:: │ │ │ │ │ -PromotedType, 1>{matrixA.diagonal(0)*matrixB.diagonal(0)}; │ │ │ │ │ - 642 } │ │ │ │ │ - 643 │ │ │ │ │ - 644 }; │ │ │ │ │ - 645#endif │ │ │ │ │ - 646 │ │ │ │ │ - 647 │ │ │ │ │ - 648 template │ │ │ │ │ -649 class DiagonalMatrixWrapper │ │ │ │ │ - 650 { │ │ │ │ │ - 651 typedef typename DiagonalMatrixType::reference reference; │ │ │ │ │ - 652 typedef typename DiagonalMatrixType::const_reference const_reference; │ │ │ │ │ - 653 typedef typename DiagonalMatrixType::field_type K; │ │ │ │ │ - 654 typedef DiagonalRowVector row_type; │ │ │ │ │ - 655 typedef std::size_t size_type; │ │ │ │ │ -656 typedef DiagonalMatrixWrapper<_DiagonalMatrixType> MyType; │ │ │ │ │ - 657 │ │ │ │ │ - 658 friend class ContainerWrapperIterator; │ │ │ │ │ - 659 friend class ContainerWrapperIterator; │ │ │ │ │ - 660 │ │ │ │ │ - 661 public: │ │ │ │ │ - 662 │ │ │ │ │ -663 DiagonalMatrixWrapper() : │ │ │ │ │ - 664 mat_(0) │ │ │ │ │ - 665 {} │ │ │ │ │ - 666 │ │ │ │ │ -667 DiagonalMatrixWrapper(const DiagonalMatrixType* mat) : │ │ │ │ │ - 668 mat_(const_cast(mat)) │ │ │ │ │ - 669 {} │ │ │ │ │ - 670 │ │ │ │ │ -671 size_type realIndex(int i) const │ │ │ │ │ - 672 { │ │ │ │ │ - 673 return i; │ │ │ │ │ - 674 } │ │ │ │ │ - 675 │ │ │ │ │ -676 row_type* pointer(int i) const │ │ │ │ │ - 677 { │ │ │ │ │ - 678 row_ = row_type(&(mat_->diagonal(i)), i); │ │ │ │ │ - 679 return &row_; │ │ │ │ │ - 680 } │ │ │ │ │ + 629 │ │ │ │ │ + 644 void insert(const RemoteIndex& index, const GlobalIndex& global); │ │ │ │ │ + 645 │ │ │ │ │ + 653 bool remove(const GlobalIndex& global); │ │ │ │ │ + 654 │ │ │ │ │ + 667 void repairLocalIndexPointers(); │ │ │ │ │ + 668 │ │ │ │ │ + 669 │ │ │ │ │ + 670 RemoteIndexListModifier(const RemoteIndexListModifier&); │ │ │ │ │ + 671 │ │ │ │ │ +676 RemoteIndexListModifier() │ │ │ │ │ + 677 : glist_() │ │ │ │ │ + 678 {} │ │ │ │ │ + 679 │ │ │ │ │ + 680 private: │ │ │ │ │ 681 │ │ │ │ │ -682 bool identical(const DiagonalMatrixWrapper& other) const │ │ │ │ │ - 683 { │ │ │ │ │ - 684 return mat_==other.mat_; │ │ │ │ │ - 685 } │ │ │ │ │ - 686 │ │ │ │ │ - 687 private: │ │ │ │ │ - 688 │ │ │ │ │ - 689 mutable DiagonalMatrixType* mat_; │ │ │ │ │ - 690 mutable row_type row_; │ │ │ │ │ - 691 }; │ │ │ │ │ - 692 │ │ │ │ │ - 696 template< class K, int n > │ │ │ │ │ -697 class DiagonalRowVectorConst │ │ │ │ │ - 698 { │ │ │ │ │ - 699 template │ │ │ │ │ -700 friend class DiagonalMatrixWrapper; │ │ │ │ │ - 701 friend class ContainerWrapperIterator, const │ │ │ │ │ -K, const K&>; │ │ │ │ │ - 702 │ │ │ │ │ - 703 public: │ │ │ │ │ - 704 // remember size of vector │ │ │ │ │ -705 constexpr static int dimension = n; │ │ │ │ │ - 706 │ │ │ │ │ - 707 // standard constructor and everything is sufficient ... │ │ │ │ │ - 708 │ │ │ │ │ - 709 //===== type definitions and constants │ │ │ │ │ - 710 │ │ │ │ │ -712 typedef K field_type; │ │ │ │ │ - 713 │ │ │ │ │ -715 typedef K block_type; │ │ │ │ │ - 716 │ │ │ │ │ -718 typedef std::size_t size_type; │ │ │ │ │ + 687 RemoteIndexListModifier(const ParallelIndexSet& indexSet, │ │ │ │ │ + 688 RemoteIndexList& rList); │ │ │ │ │ + 689 │ │ │ │ │ + 690 typedef SLList GlobalList; │ │ │ │ │ + 691 typedef typename GlobalList::ModifyIterator GlobalModifyIterator; │ │ │ │ │ + 692 RemoteIndexList* rList_; │ │ │ │ │ + 693 const ParallelIndexSet* indexSet_; │ │ │ │ │ + 694 GlobalList glist_; │ │ │ │ │ + 695 ModifyIterator iter_; │ │ │ │ │ + 696 GlobalModifyIterator giter_; │ │ │ │ │ + 697 ConstIterator end_; │ │ │ │ │ + 698 bool first_; │ │ │ │ │ + 699 GlobalIndex last_; │ │ │ │ │ + 700 }; │ │ │ │ │ + 701 │ │ │ │ │ + 706 template │ │ │ │ │ +707 class CollectiveIterator │ │ │ │ │ + 708 { │ │ │ │ │ + 709 │ │ │ │ │ + 713 typedef T ParallelIndexSet; │ │ │ │ │ + 714 │ │ │ │ │ + 718 typedef typename ParallelIndexSet::GlobalIndex GlobalIndex; │ │ │ │ │ 719 │ │ │ │ │ -721 constexpr static int blocklevel = 1; │ │ │ │ │ - 722 │ │ │ │ │ -724 constexpr static int size = n; │ │ │ │ │ - 725 │ │ │ │ │ -727 DiagonalRowVectorConst() : │ │ │ │ │ - 728 p_(0), │ │ │ │ │ - 729 row_(0) │ │ │ │ │ - 730 {} │ │ │ │ │ - 731 │ │ │ │ │ -733 explicit DiagonalRowVectorConst (K* p, int col) : │ │ │ │ │ - 734 p_(p), │ │ │ │ │ - 735 row_(col) │ │ │ │ │ - 736 {} │ │ │ │ │ - 737 │ │ │ │ │ - 738 //===== access to components │ │ │ │ │ - 739 │ │ │ │ │ -741 const K& operator[]([[maybe_unused]] size_type i) const │ │ │ │ │ - 742 { │ │ │ │ │ - 743 DUNE_ASSERT_BOUNDS(i == row_); │ │ │ │ │ - 744 return *p_; │ │ │ │ │ - 745 } │ │ │ │ │ - 746 │ │ │ │ │ - 747 // check if row is identical to other row (not only identical values) │ │ │ │ │ - 748 // since this is a proxy class we need to check equality of the stored │ │ │ │ │ -pointer │ │ │ │ │ -749 bool identical(const DiagonalRowVectorConst& other) const │ │ │ │ │ - 750 { │ │ │ │ │ - 751 return ((p_ == other.p_)and (row_ == other.row_)); │ │ │ │ │ - 752 } │ │ │ │ │ - 753 │ │ │ │ │ -755 typedef ContainerWrapperIterator, const K, │ │ │ │ │ -const K&> ConstIterator; │ │ │ │ │ -757 typedef ConstIterator const_iterator; │ │ │ │ │ - 758 │ │ │ │ │ -760 ConstIterator begin () const │ │ │ │ │ - 761 { │ │ │ │ │ - 762 return ConstIterator(*this,0); │ │ │ │ │ - 763 } │ │ │ │ │ - 764 │ │ │ │ │ -766 ConstIterator end () const │ │ │ │ │ - 767 { │ │ │ │ │ - 768 return ConstIterator(*this,1); │ │ │ │ │ - 769 } │ │ │ │ │ - 770 │ │ │ │ │ -773 ConstIterator beforeEnd() const │ │ │ │ │ - 774 { │ │ │ │ │ - 775 return ConstIterator(*this,0); │ │ │ │ │ - 776 } │ │ │ │ │ + 723 typedef typename ParallelIndexSet::LocalIndex LocalIndex; │ │ │ │ │ + 724 │ │ │ │ │ + 728 typedef typename LocalIndex::Attribute Attribute; │ │ │ │ │ + 729 │ │ │ │ │ + 731 typedef Dune::RemoteIndex RemoteIndex; │ │ │ │ │ + 732 │ │ │ │ │ + 734 using Allocator = typename std::allocator_traits::template │ │ │ │ │ +rebind_alloc; │ │ │ │ │ + 735 │ │ │ │ │ + 737 typedef Dune::SLList RemoteIndexList; │ │ │ │ │ + 738 │ │ │ │ │ + 740 typedef std::map > │ │ │ │ │ + 742 Map; │ │ │ │ │ + 743 │ │ │ │ │ + 744 public: │ │ │ │ │ + 745 │ │ │ │ │ + 747 typedef std::map > │ │ │ │ │ +748 RemoteIndexMap; │ │ │ │ │ + 749 │ │ │ │ │ + 755 inline CollectiveIterator(const RemoteIndexMap& map_, bool send); │ │ │ │ │ + 756 │ │ │ │ │ + 765 inline void advance(const GlobalIndex& global); │ │ │ │ │ + 766 │ │ │ │ │ + 776 inline void advance(const GlobalIndex& global, const Attribute& │ │ │ │ │ +attribute); │ │ │ │ │ 777 │ │ │ │ │ -780 ConstIterator beforeBegin () const │ │ │ │ │ - 781 { │ │ │ │ │ - 782 return ConstIterator(*this,-1); │ │ │ │ │ - 783 } │ │ │ │ │ + 778 CollectiveIterator& operator++(); │ │ │ │ │ + 779 │ │ │ │ │ + 783 inline bool empty() const; │ │ │ │ │ 784 │ │ │ │ │ -786 bool operator==(const DiagonalRowVectorConst& y) const │ │ │ │ │ - 787 { │ │ │ │ │ - 788 return ((p_==y.p_)and (row_==y.row_)); │ │ │ │ │ - 789 } │ │ │ │ │ - 790 │ │ │ │ │ - 791 //===== sizes │ │ │ │ │ - 792 │ │ │ │ │ -794 size_type N () const │ │ │ │ │ - 795 { │ │ │ │ │ - 796 return n; │ │ │ │ │ - 797 } │ │ │ │ │ - 798 │ │ │ │ │ -800 size_type dim () const │ │ │ │ │ +791 class iterator │ │ │ │ │ + 792 { │ │ │ │ │ + 793 public: │ │ │ │ │ +794 typedef typename Map::iterator RealIterator; │ │ │ │ │ +795 typedef typename Map::iterator ConstRealIterator; │ │ │ │ │ + 796 │ │ │ │ │ + 797 │ │ │ │ │ +799 iterator(const RealIterator& iter, const ConstRealIterator& end, │ │ │ │ │ +GlobalIndex& index) │ │ │ │ │ + 800 : iter_(iter), end_(end), index_(index), hasAttribute(false) │ │ │ │ │ 801 { │ │ │ │ │ - 802 return n; │ │ │ │ │ - 803 } │ │ │ │ │ - 804 │ │ │ │ │ -806 size_type rowIndex() const │ │ │ │ │ - 807 { │ │ │ │ │ - 808 return row_; │ │ │ │ │ - 809 } │ │ │ │ │ - 810 │ │ │ │ │ -812 const K& diagonal() const │ │ │ │ │ - 813 { │ │ │ │ │ - 814 return *p_; │ │ │ │ │ + 802 // Move to the first valid entry │ │ │ │ │ + 803 while(iter_!=end_ && iter_->second.first->localIndexPair().global │ │ │ │ │ +()!=index_) │ │ │ │ │ + 804 ++iter_; │ │ │ │ │ + 805 } │ │ │ │ │ + 806 │ │ │ │ │ +807 iterator(const RealIterator& iter, const ConstRealIterator& end, │ │ │ │ │ +GlobalIndex index, │ │ │ │ │ + 808 Attribute attribute) │ │ │ │ │ + 809 : iter_(iter), end_(end), index_(index), attribute_(attribute), │ │ │ │ │ +hasAttribute(true) │ │ │ │ │ + 810 { │ │ │ │ │ + 811 // Move to the first valid entry or the end │ │ │ │ │ + 812 while(iter_!=end_ && (iter_->second.first->localIndexPair().global │ │ │ │ │ +()!=index_ │ │ │ │ │ + 813 || iter_->second.first->localIndexPair().local().attribute()!=attribute)) │ │ │ │ │ + 814 ++iter_; │ │ │ │ │ 815 } │ │ │ │ │ - 816 │ │ │ │ │ - 817 protected: │ │ │ │ │ - 818 │ │ │ │ │ -819 size_type realIndex([[maybe_unused]] int i) const │ │ │ │ │ - 820 { │ │ │ │ │ - 821 return rowIndex(); │ │ │ │ │ - 822 } │ │ │ │ │ - 823 │ │ │ │ │ -824 K* pointer([[maybe_unused]] size_type i) const │ │ │ │ │ - 825 { │ │ │ │ │ - 826 return const_cast(p_); │ │ │ │ │ - 827 } │ │ │ │ │ - 828 │ │ │ │ │ -829 DiagonalRowVectorConst* operator&() │ │ │ │ │ - 830 { │ │ │ │ │ - 831 return this; │ │ │ │ │ - 832 } │ │ │ │ │ - 833 │ │ │ │ │ - 834 // the data, very simply a pointer to the diagonal value and the row │ │ │ │ │ -number │ │ │ │ │ -835 K* p_; │ │ │ │ │ -836 size_type row_; │ │ │ │ │ - 837 }; │ │ │ │ │ - 838 │ │ │ │ │ - 839 template< class K, int n > │ │ │ │ │ -840 class DiagonalRowVector : public DiagonalRowVectorConst │ │ │ │ │ - 841 { │ │ │ │ │ - 842 template │ │ │ │ │ -843 friend class DiagonalMatrixWrapper; │ │ │ │ │ - 844 friend class ContainerWrapperIterator, K, K&>; │ │ │ │ │ - 845 │ │ │ │ │ - 846 public: │ │ │ │ │ - 847 // standard constructor and everything is sufficient ... │ │ │ │ │ +817 iterator(const iterator& other) │ │ │ │ │ + 818 : iter_(other.iter_), end_(other.end_), index_(other.index_) │ │ │ │ │ + 819 { } │ │ │ │ │ + 820 │ │ │ │ │ +822 iterator& operator++() │ │ │ │ │ + 823 { │ │ │ │ │ + 824 ++iter_; │ │ │ │ │ + 825 // If entry is not valid move on │ │ │ │ │ + 826 while(iter_!=end_ && (iter_->second.first->localIndexPair().global │ │ │ │ │ +()!=index_ || │ │ │ │ │ + 827 (hasAttribute && │ │ │ │ │ + 828 iter_->second.first->localIndexPair().local().attribute()!=attribute_))) │ │ │ │ │ + 829 ++iter_; │ │ │ │ │ + 830 assert(iter_==end_ || │ │ │ │ │ + 831 (iter_->second.first->localIndexPair().global()==index_)); │ │ │ │ │ + 832 assert(iter_==end_ || !hasAttribute || │ │ │ │ │ + 833 (iter_->second.first->localIndexPair().local().attribute()==attribute_)); │ │ │ │ │ + 834 return *this; │ │ │ │ │ + 835 } │ │ │ │ │ + 836 │ │ │ │ │ +838 const RemoteIndex& operator*() const │ │ │ │ │ + 839 { │ │ │ │ │ + 840 return *(iter_->second.first); │ │ │ │ │ + 841 } │ │ │ │ │ + 842 │ │ │ │ │ +844 int process() const │ │ │ │ │ + 845 { │ │ │ │ │ + 846 return iter_->first; │ │ │ │ │ + 847 } │ │ │ │ │ 848 │ │ │ │ │ - 849 //===== type definitions and constants │ │ │ │ │ - 850 │ │ │ │ │ -852 typedef K field_type; │ │ │ │ │ - 853 │ │ │ │ │ -855 typedef K block_type; │ │ │ │ │ - 856 │ │ │ │ │ -858 typedef std::size_t size_type; │ │ │ │ │ - 859 │ │ │ │ │ -861 DiagonalRowVector() : DiagonalRowVectorConst() │ │ │ │ │ - 862 {} │ │ │ │ │ - 863 │ │ │ │ │ -865 explicit DiagonalRowVector (K* p, int col) : DiagonalRowVectorConst(p, │ │ │ │ │ -col) │ │ │ │ │ - 866 {} │ │ │ │ │ - 867 │ │ │ │ │ - 868 //===== assignment from scalar │ │ │ │ │ -870 DiagonalRowVector& operator=(const K& k) │ │ │ │ │ - 871 { │ │ │ │ │ - 872 *p_ = k; │ │ │ │ │ - 873 return *this; │ │ │ │ │ - 874 } │ │ │ │ │ - 875 │ │ │ │ │ - 876 //===== access to components │ │ │ │ │ - 877 │ │ │ │ │ -879 K& operator[]([[maybe_unused]] size_type i) │ │ │ │ │ - 880 { │ │ │ │ │ - 881 DUNE_ASSERT_BOUNDS(i == row_); │ │ │ │ │ - 882 return *p_; │ │ │ │ │ - 883 } │ │ │ │ │ - 884 │ │ │ │ │ -886 typedef ContainerWrapperIterator, K, K&> Iterator; │ │ │ │ │ -888 typedef Iterator iterator; │ │ │ │ │ - 889 │ │ │ │ │ -891 Iterator begin () │ │ │ │ │ - 892 { │ │ │ │ │ - 893 return Iterator(*this, 0); │ │ │ │ │ - 894 } │ │ │ │ │ - 895 │ │ │ │ │ -897 Iterator end () │ │ │ │ │ - 898 { │ │ │ │ │ - 899 return Iterator(*this, 1); │ │ │ │ │ - 900 } │ │ │ │ │ - 901 │ │ │ │ │ -904 Iterator beforeEnd () │ │ │ │ │ - 905 { │ │ │ │ │ - 906 return Iterator(*this, 0); │ │ │ │ │ - 907 } │ │ │ │ │ - 908 │ │ │ │ │ -911 Iterator beforeBegin () │ │ │ │ │ - 912 { │ │ │ │ │ - 913 return Iterator(*this, -1); │ │ │ │ │ +850 const RemoteIndex* operator->() const │ │ │ │ │ + 851 { │ │ │ │ │ + 852 return iter_->second.first.operator->(); │ │ │ │ │ + 853 } │ │ │ │ │ + 854 │ │ │ │ │ +856 bool operator==(const iterator& other) const │ │ │ │ │ + 857 { │ │ │ │ │ + 858 return other.iter_==iter_; │ │ │ │ │ + 859 } │ │ │ │ │ + 860 │ │ │ │ │ +862 bool operator!=(const iterator& other) const │ │ │ │ │ + 863 { │ │ │ │ │ + 864 return other.iter_!=iter_; │ │ │ │ │ + 865 } │ │ │ │ │ + 866 │ │ │ │ │ + 867 private: │ │ │ │ │ + 868 iterator(); │ │ │ │ │ + 869 │ │ │ │ │ + 870 RealIterator iter_; │ │ │ │ │ + 871 RealIterator end_; │ │ │ │ │ + 872 GlobalIndex index_; │ │ │ │ │ + 873 Attribute attribute_; │ │ │ │ │ + 874 bool hasAttribute; │ │ │ │ │ + 875 }; │ │ │ │ │ + 876 │ │ │ │ │ + 877 iterator begin(); │ │ │ │ │ + 878 │ │ │ │ │ + 879 iterator end(); │ │ │ │ │ + 880 │ │ │ │ │ + 881 private: │ │ │ │ │ + 882 │ │ │ │ │ + 883 Map map_; │ │ │ │ │ + 884 GlobalIndex index_; │ │ │ │ │ + 885 Attribute attribute_; │ │ │ │ │ + 886 bool noattribute; │ │ │ │ │ + 887 }; │ │ │ │ │ + 888 │ │ │ │ │ + 889 template │ │ │ │ │ +890 MPI_Datatype MPITraits > >::getType() │ │ │ │ │ + 891 { │ │ │ │ │ + 892 if(type==MPI_DATATYPE_NULL) { │ │ │ │ │ + 893 int length[2] = {1, 1}; │ │ │ │ │ + 894 MPI_Aint base; │ │ │ │ │ + 895 MPI_Aint disp[2]; │ │ │ │ │ + 896 MPI_Datatype types[2] = {MPITraits::getType(), │ │ │ │ │ + 897 MPITraits >::getType()}; │ │ │ │ │ + 898 IndexPair > rep; │ │ │ │ │ + 899 MPI_Get_address(&rep, &base); // lower bound of the datatype │ │ │ │ │ + 900 MPI_Get_address(&(rep.global_), &disp[0]); │ │ │ │ │ + 901 MPI_Get_address(&(rep.local_), &disp[1]); │ │ │ │ │ + 902 for (MPI_Aint& d : disp) │ │ │ │ │ + 903 d -= base; │ │ │ │ │ + 904 │ │ │ │ │ + 905 MPI_Datatype tmp; │ │ │ │ │ + 906 MPI_Type_create_struct(2, length, disp, types, &tmp); │ │ │ │ │ + 907 │ │ │ │ │ + 908 MPI_Type_create_resized(tmp, 0, sizeof(IndexPair │ │ │ │ │ +>), &type); │ │ │ │ │ + 909 MPI_Type_commit(&type); │ │ │ │ │ + 910 │ │ │ │ │ + 911 MPI_Type_free(&tmp); │ │ │ │ │ + 912 } │ │ │ │ │ + 913 return type; │ │ │ │ │ 914 } │ │ │ │ │ 915 │ │ │ │ │ -917 typedef ContainerWrapperIterator, const K, │ │ │ │ │ -const K&> ConstIterator; │ │ │ │ │ -919 typedef ConstIterator const_iterator; │ │ │ │ │ - 920 │ │ │ │ │ - 921 using DiagonalRowVectorConst::identical; │ │ │ │ │ - 922 using DiagonalRowVectorConst::operator[]; │ │ │ │ │ - 923 using DiagonalRowVectorConst::operator==; │ │ │ │ │ - 924 using DiagonalRowVectorConst::begin; │ │ │ │ │ - 925 using DiagonalRowVectorConst::end; │ │ │ │ │ - 926 using DiagonalRowVectorConst::beforeEnd; │ │ │ │ │ - 927 using DiagonalRowVectorConst::beforeBegin; │ │ │ │ │ - 928 using DiagonalRowVectorConst::N; │ │ │ │ │ - 929 using DiagonalRowVectorConst::dim; │ │ │ │ │ - 930 using DiagonalRowVectorConst::rowIndex; │ │ │ │ │ - 931 using DiagonalRowVectorConst::diagonal; │ │ │ │ │ - 932 │ │ │ │ │ - 933 protected: │ │ │ │ │ - 934 │ │ │ │ │ -935 DiagonalRowVector* operator&() │ │ │ │ │ - 936 { │ │ │ │ │ - 937 return this; │ │ │ │ │ - 938 } │ │ │ │ │ - 939 │ │ │ │ │ - 940 private: │ │ │ │ │ - 941 │ │ │ │ │ - 942 using DiagonalRowVectorConst::p_; │ │ │ │ │ - 943 using DiagonalRowVectorConst::row_; │ │ │ │ │ - 944 }; │ │ │ │ │ - 945 │ │ │ │ │ - 946 │ │ │ │ │ - 947 // implement type traits │ │ │ │ │ - 948 template │ │ │ │ │ -949 struct const_reference< DiagonalRowVector > │ │ │ │ │ - 950 { │ │ │ │ │ -951 typedef DiagonalRowVectorConst type; │ │ │ │ │ - 952 }; │ │ │ │ │ - 953 │ │ │ │ │ - 954 template │ │ │ │ │ -955 struct const_reference< DiagonalRowVectorConst > │ │ │ │ │ - 956 { │ │ │ │ │ -957 typedef DiagonalRowVectorConst type; │ │ │ │ │ - 958 }; │ │ │ │ │ - 959 │ │ │ │ │ - 960 template │ │ │ │ │ -961 struct mutable_reference< DiagonalRowVector > │ │ │ │ │ - 962 { │ │ │ │ │ -963 typedef DiagonalRowVector type; │ │ │ │ │ - 964 }; │ │ │ │ │ - 965 │ │ │ │ │ - 966 template │ │ │ │ │ -967 struct mutable_reference< DiagonalRowVectorConst > │ │ │ │ │ - 968 { │ │ │ │ │ -969 typedef DiagonalRowVector type; │ │ │ │ │ - 970 }; │ │ │ │ │ - 971 │ │ │ │ │ - 972 │ │ │ │ │ - 973 │ │ │ │ │ - 996 template │ │ │ │ │ -997 class ContainerWrapperIterator : public │ │ │ │ │ -BidirectionalIteratorFacade,T, R, int> │ │ │ │ │ - 998 { │ │ │ │ │ -999 typedef typename std::remove_const::type NonConstCW; │ │ │ │ │ - 1000 │ │ │ │ │ - 1001 friend class ContainerWrapperIterator:: │ │ │ │ │ -type, typename mutable_reference::type>; │ │ │ │ │ - 1002 friend class ContainerWrapperIterator:: │ │ │ │ │ -type, typename const_reference::type>; │ │ │ │ │ + 916 template │ │ │ │ │ + 917 MPI_Datatype MPITraits > >:: │ │ │ │ │ +type=MPI_DATATYPE_NULL; │ │ │ │ │ + 918 │ │ │ │ │ + 919 template │ │ │ │ │ +920 RemoteIndex::RemoteIndex(const T2& attribute, const PairType* local) │ │ │ │ │ + 921 : localIndex_(local), attribute_(static_cast> │ │ │ │ │ +(attribute)) │ │ │ │ │ + 922 {} │ │ │ │ │ + 923 │ │ │ │ │ + 924 template │ │ │ │ │ +925 RemoteIndex::RemoteIndex(const T2& attribute) │ │ │ │ │ + 926 : localIndex_(0), attribute_(static_cast> │ │ │ │ │ +(attribute)) │ │ │ │ │ + 927 {} │ │ │ │ │ + 928 │ │ │ │ │ + 929 template │ │ │ │ │ +930 RemoteIndex::RemoteIndex() │ │ │ │ │ + 931 : localIndex_(0), attribute_() │ │ │ │ │ + 932 {} │ │ │ │ │ + 933 template │ │ │ │ │ +934 inline bool RemoteIndex::operator==(const RemoteIndex& ri) const │ │ │ │ │ + 935 { │ │ │ │ │ + 936 return localIndex_==ri.localIndex_ && attribute_==ri.attribute; │ │ │ │ │ + 937 } │ │ │ │ │ + 938 │ │ │ │ │ + 939 template │ │ │ │ │ +940 inline bool RemoteIndex::operator!=(const RemoteIndex& ri) const │ │ │ │ │ + 941 { │ │ │ │ │ + 942 return localIndex_!=ri.localIndex_ || attribute_!=ri.attribute_; │ │ │ │ │ + 943 } │ │ │ │ │ + 944 │ │ │ │ │ + 945 template │ │ │ │ │ +946 inline const T2 RemoteIndex::attribute() const │ │ │ │ │ + 947 { │ │ │ │ │ + 948 return T2(attribute_); │ │ │ │ │ + 949 } │ │ │ │ │ + 950 │ │ │ │ │ + 951 template │ │ │ │ │ +952 inline const IndexPair >& RemoteIndex:: │ │ │ │ │ +localIndexPair() const │ │ │ │ │ + 953 { │ │ │ │ │ + 954 return *localIndex_; │ │ │ │ │ + 955 } │ │ │ │ │ + 956 │ │ │ │ │ + 957 template │ │ │ │ │ +958 inline RemoteIndices::RemoteIndices(const ParallelIndexSet& source, │ │ │ │ │ + 959 const ParallelIndexSet& destination, │ │ │ │ │ + 960 const MPI_Comm& comm, │ │ │ │ │ + 961 const std::vector& neighbours, │ │ │ │ │ + 962 bool includeSelf_) │ │ │ │ │ + 963 : source_(&source), target_(&destination), comm_(comm), │ │ │ │ │ + 964 sourceSeqNo_(-1), destSeqNo_(-1), publicIgnored(false), firstBuild(true), │ │ │ │ │ + 965 includeSelf(includeSelf_) │ │ │ │ │ + 966 { │ │ │ │ │ + 967 setNeighbours(neighbours); │ │ │ │ │ + 968 } │ │ │ │ │ + 969 │ │ │ │ │ + 970 template │ │ │ │ │ +971 void RemoteIndices::setIncludeSelf(bool b) │ │ │ │ │ + 972 { │ │ │ │ │ + 973 includeSelf=b; │ │ │ │ │ + 974 } │ │ │ │ │ + 975 │ │ │ │ │ + 976 template │ │ │ │ │ +977 RemoteIndices::RemoteIndices() │ │ │ │ │ + 978 : source_(0), target_(0), sourceSeqNo_(-1), │ │ │ │ │ + 979 destSeqNo_(-1), publicIgnored(false), firstBuild(true), │ │ │ │ │ + 980 includeSelf(false) │ │ │ │ │ + 981 {} │ │ │ │ │ + 982 │ │ │ │ │ + 983 template │ │ │ │ │ +984 void RemoteIndices::setIndexSets(const ParallelIndexSet& source, │ │ │ │ │ + 985 const ParallelIndexSet& destination, │ │ │ │ │ + 986 const MPI_Comm& comm, │ │ │ │ │ + 987 const std::vector& neighbours) │ │ │ │ │ + 988 { │ │ │ │ │ + 989 free(); │ │ │ │ │ + 990 source_ = &source; │ │ │ │ │ + 991 target_ = &destination; │ │ │ │ │ + 992 comm_ = comm; │ │ │ │ │ + 993 firstBuild = true; │ │ │ │ │ + 994 setNeighbours(neighbours); │ │ │ │ │ + 995 } │ │ │ │ │ + 996 │ │ │ │ │ + 997 template │ │ │ │ │ + 998 const typename RemoteIndices::ParallelIndexSet& │ │ │ │ │ +999 RemoteIndices::sourceIndexSet() const │ │ │ │ │ + 1000 { │ │ │ │ │ + 1001 return *source_; │ │ │ │ │ + 1002 } │ │ │ │ │ 1003 │ │ │ │ │ - 1004 typedef ContainerWrapperIterator::type, │ │ │ │ │ -typename mutable_reference::type> MyType; │ │ │ │ │ - 1005 typedef ContainerWrapperIterator::type, │ │ │ │ │ -typename const_reference::type> MyConstType; │ │ │ │ │ - 1006 │ │ │ │ │ - 1007 public: │ │ │ │ │ - 1008 │ │ │ │ │ - 1009 // Constructors needed by the facade iterators. │ │ │ │ │ -1010 ContainerWrapperIterator() : │ │ │ │ │ - 1011 containerWrapper_(), │ │ │ │ │ - 1012 position_(0) │ │ │ │ │ - 1013 {} │ │ │ │ │ - 1014 │ │ │ │ │ -1015 ContainerWrapperIterator(CW containerWrapper, int position) : │ │ │ │ │ - 1016 containerWrapper_(containerWrapper), │ │ │ │ │ - 1017 position_(position) │ │ │ │ │ - 1018 {} │ │ │ │ │ - 1019 │ │ │ │ │ - 1020 template │ │ │ │ │ -1021 ContainerWrapperIterator(OtherContainerWrapperIteratorType& other) : │ │ │ │ │ - 1022 containerWrapper_(other.containerWrapper_), │ │ │ │ │ - 1023 position_(other.position_) │ │ │ │ │ - 1024 {} │ │ │ │ │ - 1025 │ │ │ │ │ -1026 ContainerWrapperIterator(const MyType& other) : │ │ │ │ │ - 1027 containerWrapper_(other.containerWrapper_), │ │ │ │ │ - 1028 position_(other.position_) │ │ │ │ │ - 1029 {} │ │ │ │ │ + 1004 │ │ │ │ │ + 1005 template │ │ │ │ │ + 1006 const typename RemoteIndices::ParallelIndexSet& │ │ │ │ │ +1007 RemoteIndices::destinationIndexSet() const │ │ │ │ │ + 1008 { │ │ │ │ │ + 1009 return *target_; │ │ │ │ │ + 1010 } │ │ │ │ │ + 1011 │ │ │ │ │ + 1012 │ │ │ │ │ + 1013 template │ │ │ │ │ +1014 RemoteIndices::~RemoteIndices() │ │ │ │ │ + 1015 { │ │ │ │ │ + 1016 free(); │ │ │ │ │ + 1017 } │ │ │ │ │ + 1018 │ │ │ │ │ + 1019 template │ │ │ │ │ + 1020 template │ │ │ │ │ +1021 inline void RemoteIndices::packEntries │ │ │ │ │ +(IndexPair** pairs, │ │ │ │ │ + 1022 const ParallelIndexSet& indexSet, │ │ │ │ │ + 1023 char* p_out, MPI_Datatype type, │ │ │ │ │ + 1024 int bufferSize, │ │ │ │ │ + 1025 int *position, │ │ │ │ │ + 1026 [[maybe_unused]] int n) │ │ │ │ │ + 1027 { │ │ │ │ │ + 1028 // fill with own indices │ │ │ │ │ + 1029 const auto end = indexSet.end(); │ │ │ │ │ 1030 │ │ │ │ │ -1031 ContainerWrapperIterator(const MyConstType& other) : │ │ │ │ │ - 1032 containerWrapper_(other.containerWrapper_), │ │ │ │ │ - 1033 position_(other.position_) │ │ │ │ │ - 1034 {} │ │ │ │ │ + 1031 //Now pack the source indices │ │ │ │ │ + 1032 int i=0; │ │ │ │ │ + 1033 for(auto index = indexSet.begin(); index != end; ++index) │ │ │ │ │ + 1034 if(ignorePublic || index->local().isPublic()) { │ │ │ │ │ 1035 │ │ │ │ │ - 1036 template │ │ │ │ │ -1037 ContainerWrapperIterator& operator=(OtherContainerWrapperIteratorType& │ │ │ │ │ -other) │ │ │ │ │ - 1038 { │ │ │ │ │ - 1039 containerWrapper_ = other.containerWrapper_; │ │ │ │ │ - 1040 position_ = other.position_; │ │ │ │ │ - 1041 return *this; │ │ │ │ │ - 1042 } │ │ │ │ │ - 1043 │ │ │ │ │ - 1044 // This operator is needed since we can not get the address of the │ │ │ │ │ - 1045 // temporary object returned by dereference │ │ │ │ │ -1046 T* operator->() const │ │ │ │ │ + 1036 MPI_Pack(const_cast(&(*index)), 1, │ │ │ │ │ + 1037 type, │ │ │ │ │ + 1038 p_out, bufferSize, position, comm_); │ │ │ │ │ + 1039 pairs[i++] = const_cast(&(*index)); │ │ │ │ │ + 1040 │ │ │ │ │ + 1041 } │ │ │ │ │ + 1042 assert(i==n); │ │ │ │ │ + 1043 } │ │ │ │ │ + 1044 │ │ │ │ │ + 1045 template │ │ │ │ │ + 1046 inline int RemoteIndices::noPublic(const ParallelIndexSet& indexSet) │ │ │ │ │ 1047 { │ │ │ │ │ - 1048 return containerWrapper_.pointer(position_); │ │ │ │ │ - 1049 } │ │ │ │ │ + 1048 │ │ │ │ │ + 1049 int noPublic=0; │ │ │ │ │ 1050 │ │ │ │ │ - 1051 // Methods needed by the forward iterator │ │ │ │ │ -1052 bool equals(const MyType& other) const │ │ │ │ │ - 1053 { │ │ │ │ │ - 1054 return position_ == other.position_ && containerWrapper_.identical │ │ │ │ │ -(other.containerWrapper_); │ │ │ │ │ - 1055 } │ │ │ │ │ - 1056 │ │ │ │ │ -1057 bool equals(const MyConstType& other) const │ │ │ │ │ - 1058 { │ │ │ │ │ - 1059 return position_ == other.position_ && containerWrapper_.identical │ │ │ │ │ -(other.containerWrapper_); │ │ │ │ │ - 1060 } │ │ │ │ │ - 1061 │ │ │ │ │ -1062 R dereference() const │ │ │ │ │ - 1063 { │ │ │ │ │ - 1064 return *containerWrapper_.pointer(position_); │ │ │ │ │ - 1065 } │ │ │ │ │ - 1066 │ │ │ │ │ -1067 void increment() │ │ │ │ │ - 1068 { │ │ │ │ │ - 1069 ++position_; │ │ │ │ │ - 1070 } │ │ │ │ │ - 1071 │ │ │ │ │ - 1072 // Additional function needed by BidirectionalIterator │ │ │ │ │ -1073 void decrement() │ │ │ │ │ - 1074 { │ │ │ │ │ - 1075 --position_; │ │ │ │ │ - 1076 } │ │ │ │ │ - 1077 │ │ │ │ │ - 1078 // Additional function needed by RandomAccessIterator │ │ │ │ │ -1079 R elementAt(int i) const │ │ │ │ │ - 1080 { │ │ │ │ │ - 1081 return *containerWrapper_.pointer(position_+i); │ │ │ │ │ - 1082 } │ │ │ │ │ - 1083 │ │ │ │ │ -1084 void advance(int n) │ │ │ │ │ - 1085 { │ │ │ │ │ - 1086 position_=position_+n; │ │ │ │ │ - 1087 } │ │ │ │ │ - 1088 │ │ │ │ │ - 1089 template │ │ │ │ │ -1090 std::ptrdiff_t distanceTo(OtherContainerWrapperIteratorType& other) const │ │ │ │ │ - 1091 { │ │ │ │ │ - 1092 assert(containerWrapper_.identical(other)); │ │ │ │ │ - 1093 return other.position_ - position_; │ │ │ │ │ - 1094 } │ │ │ │ │ - 1095 │ │ │ │ │ -1096 std::ptrdiff_t index() const │ │ │ │ │ - 1097 { │ │ │ │ │ - 1098 return containerWrapper_.realIndex(position_); │ │ │ │ │ + 1051 const auto end=indexSet.end(); │ │ │ │ │ + 1052 for(auto index=indexSet.begin(); index!=end; ++index) │ │ │ │ │ + 1053 if(index->local().isPublic()) │ │ │ │ │ + 1054 noPublic++; │ │ │ │ │ + 1055 │ │ │ │ │ + 1056 return noPublic; │ │ │ │ │ + 1057 │ │ │ │ │ + 1058 } │ │ │ │ │ + 1059 │ │ │ │ │ + 1060 │ │ │ │ │ + 1061 template │ │ │ │ │ + 1062 inline void RemoteIndices::unpackCreateRemote(char* p_in, PairType** │ │ │ │ │ +sourcePairs, │ │ │ │ │ + 1063 PairType** destPairs, int remoteProc, │ │ │ │ │ + 1064 int sourcePublish, int destPublish, │ │ │ │ │ + 1065 int bufferSize, bool sendTwo, │ │ │ │ │ + 1066 bool fromOurSelf) │ │ │ │ │ + 1067 { │ │ │ │ │ + 1068 │ │ │ │ │ + 1069 // unpack the number of indices we received │ │ │ │ │ + 1070 int noRemoteSource=-1, noRemoteDest=-1; │ │ │ │ │ + 1071 char twoIndexSets=0; │ │ │ │ │ + 1072 int position=0; │ │ │ │ │ + 1073 // Did we receive two index sets? │ │ │ │ │ + 1074 MPI_Unpack(p_in, bufferSize, &position, &twoIndexSets, 1, MPI_CHAR, │ │ │ │ │ +comm_); │ │ │ │ │ + 1075 // The number of source indices received │ │ │ │ │ + 1076 MPI_Unpack(p_in, bufferSize, &position, &noRemoteSource, 1, MPI_INT, │ │ │ │ │ +comm_); │ │ │ │ │ + 1077 // The number of destination indices received │ │ │ │ │ + 1078 MPI_Unpack(p_in, bufferSize, &position, &noRemoteDest, 1, MPI_INT, │ │ │ │ │ +comm_); │ │ │ │ │ + 1079 │ │ │ │ │ + 1080 │ │ │ │ │ + 1081 // Indices for which we receive │ │ │ │ │ + 1082 RemoteIndexList* receive= new RemoteIndexList(); │ │ │ │ │ + 1083 // Indices for which we send │ │ │ │ │ + 1084 RemoteIndexList* send=0; │ │ │ │ │ + 1085 │ │ │ │ │ + 1086 MPI_Datatype type= MPITraits::getType(); │ │ │ │ │ + 1087 │ │ │ │ │ + 1088 if(!twoIndexSets) { │ │ │ │ │ + 1089 if(sendTwo) { │ │ │ │ │ + 1090 send = new RemoteIndexList(); │ │ │ │ │ + 1091 // Create both remote index sets simultaneously │ │ │ │ │ + 1092 unpackIndices(*send, *receive, noRemoteSource, sourcePairs, │ │ │ │ │ +sourcePublish, │ │ │ │ │ + 1093 destPairs, destPublish, p_in, type, &position, bufferSize); │ │ │ │ │ + 1094 }else{ │ │ │ │ │ + 1095 // we only need one list │ │ │ │ │ + 1096 unpackIndices(*receive, noRemoteSource, sourcePairs, sourcePublish, │ │ │ │ │ + 1097 p_in, type, &position, bufferSize, fromOurSelf); │ │ │ │ │ + 1098 send=receive; │ │ │ │ │ 1099 } │ │ │ │ │ - 1100 │ │ │ │ │ - 1101 private: │ │ │ │ │ - 1102 NonConstCW containerWrapper_; │ │ │ │ │ - 1103 size_t position_; │ │ │ │ │ - 1104 }; │ │ │ │ │ - 1105 │ │ │ │ │ - 1106 template │ │ │ │ │ -1107 struct DenseMatrixAssigner> { │ │ │ │ │ -1108 static void apply(DenseMatrix& denseMatrix, │ │ │ │ │ - 1109 DiagonalMatrix const& rhs) { │ │ │ │ │ - 1110 DUNE_ASSERT_BOUNDS(denseMatrix.M() == N); │ │ │ │ │ - 1111 DUNE_ASSERT_BOUNDS(denseMatrix.N() == N); │ │ │ │ │ - 1112 denseMatrix = field(0); │ │ │ │ │ - 1113 for (int i = 0; i < N; ++i) │ │ │ │ │ - 1114 denseMatrix[i][i] = rhs.diagonal()[i]; │ │ │ │ │ - 1115 } │ │ │ │ │ - 1116 }; │ │ │ │ │ - 1117 /* @} */ │ │ │ │ │ - 1118} // end namespace │ │ │ │ │ - 1119#endif │ │ │ │ │ -typetraits.hh │ │ │ │ │ -Traits for type conversions and type information. │ │ │ │ │ -fmatrix.hh │ │ │ │ │ -Implements a matrix constructed from a given type representing a field and │ │ │ │ │ -compile-time given number ... │ │ │ │ │ + 1100 }else{ │ │ │ │ │ + 1101 │ │ │ │ │ + 1102 int oldPos=position; │ │ │ │ │ + 1103 // Two index sets received │ │ │ │ │ + 1104 unpackIndices(*receive, noRemoteSource, destPairs, destPublish, │ │ │ │ │ + 1105 p_in, type, &position, bufferSize, fromOurSelf); │ │ │ │ │ + 1106 if(!sendTwo) │ │ │ │ │ + 1107 //unpack source entries again as destination entries │ │ │ │ │ + 1108 position=oldPos; │ │ │ │ │ + 1109 │ │ │ │ │ + 1110 send = new RemoteIndexList(); │ │ │ │ │ + 1111 unpackIndices(*send, noRemoteDest, sourcePairs, sourcePublish, │ │ │ │ │ + 1112 p_in, type, &position, bufferSize, fromOurSelf); │ │ │ │ │ + 1113 } │ │ │ │ │ + 1114 │ │ │ │ │ + 1115 if(receive->empty() && send->empty()) { │ │ │ │ │ + 1116 if(send==receive) { │ │ │ │ │ + 1117 delete send; │ │ │ │ │ + 1118 }else{ │ │ │ │ │ + 1119 delete send; │ │ │ │ │ + 1120 delete receive; │ │ │ │ │ + 1121 } │ │ │ │ │ + 1122 }else{ │ │ │ │ │ + 1123 remoteIndices_.insert(std::make_pair(remoteProc, │ │ │ │ │ + 1124 std::make_pair(send,receive))); │ │ │ │ │ + 1125 } │ │ │ │ │ + 1126 } │ │ │ │ │ + 1127 │ │ │ │ │ + 1128 │ │ │ │ │ + 1129 template │ │ │ │ │ + 1130 template │ │ │ │ │ + 1131 inline void RemoteIndices::buildRemote(bool includeSelf_) │ │ │ │ │ + 1132 { │ │ │ │ │ + 1133 // Processor configuration │ │ │ │ │ + 1134 int rank, procs; │ │ │ │ │ + 1135 MPI_Comm_rank(comm_, &rank); │ │ │ │ │ + 1136 MPI_Comm_size(comm_, &procs); │ │ │ │ │ + 1137 │ │ │ │ │ + 1138 // number of local indices to publish │ │ │ │ │ + 1139 // The indices of the destination will be send. │ │ │ │ │ + 1140 int sourcePublish, destPublish; │ │ │ │ │ + 1141 │ │ │ │ │ + 1142 // Do we need to send two index sets? │ │ │ │ │ + 1143 char sendTwo = (source_ != target_); │ │ │ │ │ + 1144 │ │ │ │ │ + 1145 if(procs==1 && !(sendTwo || includeSelf_)) │ │ │ │ │ + 1146 // Nothing to communicate │ │ │ │ │ + 1147 return; │ │ │ │ │ + 1148 │ │ │ │ │ + 1149 sourcePublish = (ignorePublic) ? source_->size() : noPublic(*source_); │ │ │ │ │ + 1150 │ │ │ │ │ + 1151 if(sendTwo) │ │ │ │ │ + 1152 destPublish = (ignorePublic) ? target_->size() : noPublic(*target_); │ │ │ │ │ + 1153 else │ │ │ │ │ + 1154 // we only need to send one set of indices │ │ │ │ │ + 1155 destPublish = 0; │ │ │ │ │ + 1156 │ │ │ │ │ + 1157 int maxPublish, publish=sourcePublish+destPublish; │ │ │ │ │ + 1158 │ │ │ │ │ + 1159 // Calculate maximum number of indices send │ │ │ │ │ + 1160 MPI_Allreduce(&publish, &maxPublish, 1, MPI_INT, MPI_MAX, comm_); │ │ │ │ │ + 1161 │ │ │ │ │ + 1162 // allocate buffers │ │ │ │ │ + 1163 PairType** destPairs; │ │ │ │ │ + 1164 PairType** sourcePairs = new PairType*[sourcePublish>0 ? sourcePublish : │ │ │ │ │ +1]; │ │ │ │ │ + 1165 │ │ │ │ │ + 1166 if(sendTwo) │ │ │ │ │ + 1167 destPairs = new PairType*[destPublish>0 ? destPublish : 1]; │ │ │ │ │ + 1168 else │ │ │ │ │ + 1169 destPairs=sourcePairs; │ │ │ │ │ + 1170 │ │ │ │ │ + 1171 char** buffer = new char*[2]; │ │ │ │ │ + 1172 int bufferSize; │ │ │ │ │ + 1173 int position=0; │ │ │ │ │ + 1174 int intSize; │ │ │ │ │ + 1175 int charSize; │ │ │ │ │ + 1176 │ │ │ │ │ + 1177 // calculate buffer size │ │ │ │ │ + 1178 MPI_Datatype type = MPITraits::getType(); │ │ │ │ │ + 1179 │ │ │ │ │ + 1180 MPI_Pack_size(maxPublish, type, comm_, │ │ │ │ │ + 1181 &bufferSize); │ │ │ │ │ + 1182 MPI_Pack_size(1, MPI_INT, comm_, │ │ │ │ │ + 1183 &intSize); │ │ │ │ │ + 1184 MPI_Pack_size(1, MPI_CHAR, comm_, │ │ │ │ │ + 1185 &charSize); │ │ │ │ │ + 1186 // Our message will contain the following: │ │ │ │ │ + 1187 // a bool whether two index sets where sent │ │ │ │ │ + 1188 // the size of the source and the dest indexset, │ │ │ │ │ + 1189 // then the source and destination indices │ │ │ │ │ + 1190 bufferSize += 2 * intSize + charSize; │ │ │ │ │ + 1191 │ │ │ │ │ + 1192 if(bufferSize<=0) bufferSize=1; │ │ │ │ │ + 1193 │ │ │ │ │ + 1194 buffer[0] = new char[bufferSize]; │ │ │ │ │ + 1195 buffer[1] = new char[bufferSize]; │ │ │ │ │ + 1196 │ │ │ │ │ + 1197 │ │ │ │ │ + 1198 // pack entries into buffer[0], p_out below! │ │ │ │ │ + 1199 MPI_Pack(&sendTwo, 1, MPI_CHAR, buffer[0], bufferSize, &position, │ │ │ │ │ + 1200 comm_); │ │ │ │ │ + 1201 │ │ │ │ │ + 1202 // The number of indices we send for each index set │ │ │ │ │ + 1203 MPI_Pack(&sourcePublish, 1, MPI_INT, buffer[0], bufferSize, &position, │ │ │ │ │ + 1204 comm_); │ │ │ │ │ + 1205 MPI_Pack(&destPublish, 1, MPI_INT, buffer[0], bufferSize, &position, │ │ │ │ │ + 1206 comm_); │ │ │ │ │ + 1207 │ │ │ │ │ + 1208 // Now pack the source indices and setup the destination pairs │ │ │ │ │ + 1209 packEntries(sourcePairs, *source_, buffer[0], type, │ │ │ │ │ + 1210 bufferSize, &position, sourcePublish); │ │ │ │ │ + 1211 // If necessary send the dest indices and setup the source pairs │ │ │ │ │ + 1212 if(sendTwo) │ │ │ │ │ + 1213 packEntries(destPairs, *target_, buffer[0], type, │ │ │ │ │ + 1214 bufferSize, &position, destPublish); │ │ │ │ │ + 1215 │ │ │ │ │ + 1216 │ │ │ │ │ + 1217 // Update remote indices for ourself │ │ │ │ │ + 1218 if(sendTwo|| includeSelf_) │ │ │ │ │ + 1219 unpackCreateRemote(buffer[0], sourcePairs, destPairs, rank, │ │ │ │ │ +sourcePublish, │ │ │ │ │ + 1220 destPublish, bufferSize, sendTwo, includeSelf_); │ │ │ │ │ + 1221 │ │ │ │ │ + 1222 neighbourIds.erase(rank); │ │ │ │ │ + 1223 │ │ │ │ │ + 1224 if(neighbourIds.size()==0) │ │ │ │ │ + 1225 { │ │ │ │ │ + 1226 Dune::dvverb<::size_type size_type; │ │ │ │ │ + 1262 size_type noNeighbours=neighbourIds.size(); │ │ │ │ │ + 1263 │ │ │ │ │ + 1264 // setup sends │ │ │ │ │ + 1265 for(std::set::iterator neighbour=neighbourIds.begin(); │ │ │ │ │ + 1266 neighbour!= neighbourIds.end(); ++neighbour) { │ │ │ │ │ + 1267 // Only send the information to the neighbouring processors │ │ │ │ │ + 1268 MPI_Issend(buffer[0], position , MPI_PACKED, *neighbour, commTag_, comm_, │ │ │ │ │ +req++); │ │ │ │ │ + 1269 } │ │ │ │ │ + 1270 │ │ │ │ │ + 1271 //Test for received messages │ │ │ │ │ + 1272 │ │ │ │ │ + 1273 for(size_type received=0; received │ │ │ │ │ + 1314 inline void RemoteIndices::unpackIndices(RemoteIndexList& remote, │ │ │ │ │ + 1315 int remoteEntries, │ │ │ │ │ + 1316 PairType** local, │ │ │ │ │ + 1317 int localEntries, │ │ │ │ │ + 1318 char* p_in, │ │ │ │ │ + 1319 MPI_Datatype type, │ │ │ │ │ + 1320 int* position, │ │ │ │ │ + 1321 int bufferSize, │ │ │ │ │ + 1322 bool fromOurSelf) │ │ │ │ │ + 1323 { │ │ │ │ │ + 1324 if(remoteEntries==0) │ │ │ │ │ + 1325 return; │ │ │ │ │ + 1326 │ │ │ │ │ + 1327 PairType index; │ │ │ │ │ + 1328 MPI_Unpack(p_in, bufferSize, position, &index, 1, │ │ │ │ │ + 1329 type, comm_); │ │ │ │ │ + 1330 GlobalIndex oldGlobal=index.global(); │ │ │ │ │ + 1331 int n_in=0, localIndex=0; │ │ │ │ │ + 1332 │ │ │ │ │ + 1333 //Check if we know the global index │ │ │ │ │ + 1334 while(localIndexglobal()==index.global()) { │ │ │ │ │ + 1336 int oldLocalIndex=localIndex; │ │ │ │ │ + 1337 │ │ │ │ │ + 1338 while(localIndexglobal()==index.global()) { │ │ │ │ │ + 1340 if(!fromOurSelf || index.local().attribute() != │ │ │ │ │ + 1341 local[localIndex]->local().attribute()) │ │ │ │ │ + 1342 // if index is from us it has to have a different attribute │ │ │ │ │ + 1343 remote.push_back(RemoteIndex(index.local().attribute(), │ │ │ │ │ + 1344 local[localIndex])); │ │ │ │ │ + 1345 localIndex++; │ │ │ │ │ + 1346 } │ │ │ │ │ + 1347 │ │ │ │ │ + 1348 // unpack next remote index │ │ │ │ │ + 1349 if((++n_in) < remoteEntries) { │ │ │ │ │ + 1350 MPI_Unpack(p_in, bufferSize, position, &index, 1, │ │ │ │ │ + 1351 type, comm_); │ │ │ │ │ + 1352 if(index.global()==oldGlobal) │ │ │ │ │ + 1353 // Restart comparison for the same global indices │ │ │ │ │ + 1354 localIndex=oldLocalIndex; │ │ │ │ │ + 1355 else │ │ │ │ │ + 1356 oldGlobal=index.global(); │ │ │ │ │ + 1357 }else{ │ │ │ │ │ + 1358 // No more received indices │ │ │ │ │ + 1359 break; │ │ │ │ │ + 1360 } │ │ │ │ │ + 1361 continue; │ │ │ │ │ + 1362 } │ │ │ │ │ + 1363 │ │ │ │ │ + 1364 if (local[localIndex]->global() │ │ │ │ │ + 1387 inline void RemoteIndices::unpackIndices(RemoteIndexList& send, │ │ │ │ │ + 1388 RemoteIndexList& receive, │ │ │ │ │ + 1389 int remoteEntries, │ │ │ │ │ + 1390 PairType** localSource, │ │ │ │ │ + 1391 int localSourceEntries, │ │ │ │ │ + 1392 PairType** localDest, │ │ │ │ │ + 1393 int localDestEntries, │ │ │ │ │ + 1394 char* p_in, │ │ │ │ │ + 1395 MPI_Datatype type, │ │ │ │ │ + 1396 int* position, │ │ │ │ │ + 1397 int bufferSize) │ │ │ │ │ + 1398 { │ │ │ │ │ + 1399 int n_in=0, sourceIndex=0, destIndex=0; │ │ │ │ │ + 1400 │ │ │ │ │ + 1401 //Check if we know the global index │ │ │ │ │ + 1402 while(n_in= than │ │ │ │ │ +the one in the unpacked index │ │ │ │ │ + 1410 while(sourceIndexglobal │ │ │ │ │ +()global │ │ │ │ │ +()global │ │ │ │ │ +()==index.global()) │ │ │ │ │ + 1418 send.push_back(RemoteIndex(index.local().attribute(), │ │ │ │ │ + 1419 localSource[sourceIndex])); │ │ │ │ │ + 1420 │ │ │ │ │ + 1421 if(destIndex < localDestEntries && localDest[destIndex]->global() == │ │ │ │ │ +index.global()) │ │ │ │ │ + 1422 receive.push_back(RemoteIndex(index.local().attribute(), │ │ │ │ │ + 1423 localDest[sourceIndex])); │ │ │ │ │ + 1424 } │ │ │ │ │ + 1425 │ │ │ │ │ + 1426 } │ │ │ │ │ + 1427 │ │ │ │ │ + 1428 template │ │ │ │ │ +1429 inline void RemoteIndices::free() │ │ │ │ │ + 1430 { │ │ │ │ │ + 1431 auto lend = remoteIndices_.end(); │ │ │ │ │ + 1432 for(auto lists=remoteIndices_.begin(); lists != lend; ++lists) { │ │ │ │ │ + 1433 if(lists->second.first==lists->second.second) { │ │ │ │ │ + 1434 // there is only one remote index list. │ │ │ │ │ + 1435 delete lists->second.first; │ │ │ │ │ + 1436 }else{ │ │ │ │ │ + 1437 delete lists->second.first; │ │ │ │ │ + 1438 delete lists->second.second; │ │ │ │ │ + 1439 } │ │ │ │ │ + 1440 } │ │ │ │ │ + 1441 remoteIndices_.clear(); │ │ │ │ │ + 1442 firstBuild=true; │ │ │ │ │ + 1443 } │ │ │ │ │ + 1444 │ │ │ │ │ + 1445 template │ │ │ │ │ +1446 inline int RemoteIndices::neighbours() const │ │ │ │ │ + 1447 { │ │ │ │ │ + 1448 return remoteIndices_.size(); │ │ │ │ │ + 1449 } │ │ │ │ │ + 1450 │ │ │ │ │ + 1451 template │ │ │ │ │ + 1452 template │ │ │ │ │ +1453 inline void RemoteIndices::rebuild() │ │ │ │ │ + 1454 { │ │ │ │ │ + 1455 // Test whether a rebuild is Needed. │ │ │ │ │ + 1456 if(firstBuild || │ │ │ │ │ + 1457 ignorePublic!=publicIgnored || ! │ │ │ │ │ + 1458 isSynced()) { │ │ │ │ │ + 1459 free(); │ │ │ │ │ + 1460 │ │ │ │ │ + 1461 buildRemote(includeSelf); │ │ │ │ │ + 1462 │ │ │ │ │ + 1463 sourceSeqNo_ = source_->seqNo(); │ │ │ │ │ + 1464 destSeqNo_ = target_->seqNo(); │ │ │ │ │ + 1465 firstBuild=false; │ │ │ │ │ + 1466 publicIgnored=ignorePublic; │ │ │ │ │ + 1467 } │ │ │ │ │ + 1468 │ │ │ │ │ + 1469 │ │ │ │ │ + 1470 } │ │ │ │ │ + 1471 │ │ │ │ │ + 1472 template │ │ │ │ │ +1473 inline bool RemoteIndices::isSynced() const │ │ │ │ │ + 1474 { │ │ │ │ │ + 1475 return sourceSeqNo_==source_->seqNo() && destSeqNo_ ==target_->seqNo(); │ │ │ │ │ + 1476 } │ │ │ │ │ + 1477 │ │ │ │ │ + 1478 template │ │ │ │ │ + 1479 template │ │ │ │ │ +1480 RemoteIndexListModifier RemoteIndices::getModifier(int │ │ │ │ │ +process) │ │ │ │ │ + 1481 { │ │ │ │ │ + 1482 │ │ │ │ │ + 1483 // The user are on their own now! │ │ │ │ │ + 1484 // We assume they know what they are doing and just set the │ │ │ │ │ + 1485 // remote indices to synced status. │ │ │ │ │ + 1486 sourceSeqNo_ = source_->seqNo(); │ │ │ │ │ + 1487 destSeqNo_ = target_->seqNo(); │ │ │ │ │ + 1488 │ │ │ │ │ + 1489 typename RemoteIndexMap::iterator found = remoteIndices_.find(process); │ │ │ │ │ + 1490 │ │ │ │ │ + 1491 if(found == remoteIndices_.end()) │ │ │ │ │ + 1492 { │ │ │ │ │ + 1493 if(source_ != target_) │ │ │ │ │ + 1494 found = remoteIndices_.insert(found, std::make_pair(process, │ │ │ │ │ + 1495 std::make_pair(new RemoteIndexList(), │ │ │ │ │ + 1496 new RemoteIndexList()))); │ │ │ │ │ + 1497 else{ │ │ │ │ │ + 1498 RemoteIndexList* rlist = new RemoteIndexList(); │ │ │ │ │ + 1499 found = remoteIndices_.insert(found, │ │ │ │ │ + 1500 std::make_pair(process, │ │ │ │ │ + 1501 std::make_pair(rlist, rlist))); │ │ │ │ │ + 1502 } │ │ │ │ │ + 1503 } │ │ │ │ │ + 1504 │ │ │ │ │ + 1505 firstBuild = false; │ │ │ │ │ + 1506 │ │ │ │ │ + 1507 if(send) │ │ │ │ │ + 1508 return RemoteIndexListModifier(*source_, *(found- │ │ │ │ │ +>second.first)); │ │ │ │ │ + 1509 else │ │ │ │ │ + 1510 return RemoteIndexListModifier(*target_, *(found- │ │ │ │ │ +>second.second)); │ │ │ │ │ + 1511 } │ │ │ │ │ + 1512 │ │ │ │ │ + 1513 template │ │ │ │ │ + 1514 inline typename RemoteIndices::const_iterator │ │ │ │ │ +1515 RemoteIndices::find(int proc) const │ │ │ │ │ + 1516 { │ │ │ │ │ + 1517 return remoteIndices_.find(proc); │ │ │ │ │ + 1518 } │ │ │ │ │ + 1519 │ │ │ │ │ + 1520 template │ │ │ │ │ + 1521 inline typename RemoteIndices::const_iterator │ │ │ │ │ +1522 RemoteIndices::begin() const │ │ │ │ │ + 1523 { │ │ │ │ │ + 1524 return remoteIndices_.begin(); │ │ │ │ │ + 1525 } │ │ │ │ │ + 1526 │ │ │ │ │ + 1527 template │ │ │ │ │ + 1528 inline typename RemoteIndices::const_iterator │ │ │ │ │ +1529 RemoteIndices::end() const │ │ │ │ │ + 1530 { │ │ │ │ │ + 1531 return remoteIndices_.end(); │ │ │ │ │ + 1532 } │ │ │ │ │ + 1533 │ │ │ │ │ + 1534 │ │ │ │ │ + 1535 template │ │ │ │ │ +1536 bool RemoteIndices::operator==(const RemoteIndices& ri) const │ │ │ │ │ + 1537 { │ │ │ │ │ + 1538 if(neighbours()!=ri.neighbours()) │ │ │ │ │ + 1539 return false; │ │ │ │ │ + 1540 │ │ │ │ │ + 1541 const auto rend = remoteIndices_.end(); │ │ │ │ │ + 1542 │ │ │ │ │ + 1543 for(auto rindex = remoteIndices_.begin(), rindex1=ri.remoteIndices_.begin │ │ │ │ │ +(); rindex!=rend; ++rindex, ++rindex1) { │ │ │ │ │ + 1544 if(rindex->first != rindex1->first) │ │ │ │ │ + 1545 return false; │ │ │ │ │ + 1546 if(*(rindex->second.first) != *(rindex1->second.first)) │ │ │ │ │ + 1547 return false; │ │ │ │ │ + 1548 if(*(rindex->second.second) != *(rindex1->second.second)) │ │ │ │ │ + 1549 return false; │ │ │ │ │ + 1550 } │ │ │ │ │ + 1551 return true; │ │ │ │ │ + 1552 } │ │ │ │ │ + 1553 │ │ │ │ │ + 1554 template │ │ │ │ │ + 1555 RemoteIndexListModifier::RemoteIndexListModifier(const │ │ │ │ │ +ParallelIndexSet& indexSet, │ │ │ │ │ + 1556 RemoteIndexList& rList) │ │ │ │ │ + 1557 : rList_(&rList), indexSet_(&indexSet), iter_(rList.beginModify()), end_ │ │ │ │ │ +(rList.end()), first_(true) │ │ │ │ │ + 1558 { │ │ │ │ │ + 1559 if(MODIFYINDEXSET) { │ │ │ │ │ + 1560 assert(indexSet_); │ │ │ │ │ + 1561 for(ConstIterator iter=iter_; iter != end_; ++iter) │ │ │ │ │ + 1562 glist_.push_back(iter->localIndexPair().global()); │ │ │ │ │ + 1563 giter_ = glist_.beginModify(); │ │ │ │ │ + 1564 } │ │ │ │ │ + 1565 } │ │ │ │ │ + 1566 │ │ │ │ │ + 1567 template │ │ │ │ │ +1568 RemoteIndexListModifier::RemoteIndexListModifier(const │ │ │ │ │ +RemoteIndexListModifier& other) │ │ │ │ │ + 1569 : rList_(other.rList_), indexSet_(other.indexSet_), │ │ │ │ │ + 1570 glist_(other.glist_), iter_(other.iter_), giter_(other.giter_), end_ │ │ │ │ │ +(other.end_), │ │ │ │ │ + 1571 first_(other.first_), last_(other.last_) │ │ │ │ │ + 1572 {} │ │ │ │ │ + 1573 │ │ │ │ │ + 1574 template │ │ │ │ │ +1575 inline void RemoteIndexListModifier::repairLocalIndexPointers() │ │ │ │ │ + 1576 { │ │ │ │ │ + 1577 if(MODIFYINDEXSET) { │ │ │ │ │ + 1578 // repair pointers to local index set. │ │ │ │ │ + 1579#ifdef DUNE_ISTL_WITH_CHECKING │ │ │ │ │ + 1580 if(indexSet_->state()!=GROUND) │ │ │ │ │ + 1581 DUNE_THROW(InvalidIndexSetState, "Index has to be in ground mode for │ │ │ │ │ +repairing pointers to indices"); │ │ │ │ │ + 1582#endif │ │ │ │ │ + 1583 auto giter = glist_.begin(); │ │ │ │ │ + 1584 auto index = indexSet_->begin(); │ │ │ │ │ + 1585 │ │ │ │ │ + 1586 for(auto iter=rList_->begin(); iter != end_; ++iter) { │ │ │ │ │ + 1587 while(index->global()<*giter) { │ │ │ │ │ + 1588 ++index; │ │ │ │ │ + 1589#ifdef DUNE_ISTL_WITH_CHECKING │ │ │ │ │ + 1590 if(index == indexSet_->end()) │ │ │ │ │ + 1591 DUNE_THROW(InvalidPosition, "No such global index in set!"); │ │ │ │ │ + 1592#endif │ │ │ │ │ + 1593 } │ │ │ │ │ + 1594 │ │ │ │ │ + 1595#ifdef DUNE_ISTL_WITH_CHECKING │ │ │ │ │ + 1596 if(index->global() != *giter) │ │ │ │ │ + 1597 DUNE_THROW(InvalidPosition, "No such global index in set!"); │ │ │ │ │ + 1598#endif │ │ │ │ │ + 1599 iter->localIndex_ = &(*index); │ │ │ │ │ + 1600 } │ │ │ │ │ + 1601 } │ │ │ │ │ + 1602 } │ │ │ │ │ + 1603 │ │ │ │ │ + 1604 template │ │ │ │ │ +1605 inline void RemoteIndexListModifier::insert(const RemoteIndex& │ │ │ │ │ +index) │ │ │ │ │ + 1606 { │ │ │ │ │ + 1607 static_assert(!mode,"Not allowed if the mode indicates that new indices" │ │ │ │ │ + 1608 "might be added to the underlying index set. Use " │ │ │ │ │ + 1609 "insert(const RemoteIndex&, const GlobalIndex&) instead"); │ │ │ │ │ + 1610 │ │ │ │ │ + 1611#ifdef DUNE_ISTL_WITH_CHECKING │ │ │ │ │ + 1612 if(!first_ && index.localIndexPair().global()localIndexPair().global() < │ │ │ │ │ +index.localIndexPair().global()) { │ │ │ │ │ + 1617 ++iter_; │ │ │ │ │ + 1618 } │ │ │ │ │ + 1619 │ │ │ │ │ + 1620 // No duplicate entries allowed │ │ │ │ │ + 1621 assert(iter_==end_ || iter_->localIndexPair().global() != │ │ │ │ │ +index.localIndexPair().global()); │ │ │ │ │ + 1622 iter_.insert(index); │ │ │ │ │ + 1623 last_ = index.localIndexPair().global(); │ │ │ │ │ + 1624 first_ = false; │ │ │ │ │ + 1625 } │ │ │ │ │ + 1626 │ │ │ │ │ + 1627 template │ │ │ │ │ +1628 inline void RemoteIndexListModifier::insert(const RemoteIndex& │ │ │ │ │ +index, const GlobalIndex& global) │ │ │ │ │ + 1629 { │ │ │ │ │ + 1630 static_assert(mode,"Not allowed if the mode indicates that no new │ │ │ │ │ +indices" │ │ │ │ │ + 1631 "might be added to the underlying index set. Use " │ │ │ │ │ + 1632 "insert(const RemoteIndex&) instead"); │ │ │ │ │ + 1633#ifdef DUNE_ISTL_WITH_CHECKING │ │ │ │ │ + 1634 if(!first_ && globallocalIndexPair().global() != global); │ │ │ │ │ + 1645 iter_.insert(index); │ │ │ │ │ + 1646 giter_.insert(global); │ │ │ │ │ + 1647 │ │ │ │ │ + 1648 last_ = global; │ │ │ │ │ + 1649 first_ = false; │ │ │ │ │ + 1650 } │ │ │ │ │ + 1651 │ │ │ │ │ + 1652 template │ │ │ │ │ +1653 bool RemoteIndexListModifier::remove(const GlobalIndex& global) │ │ │ │ │ + 1654 { │ │ │ │ │ + 1655#ifdef DUNE_ISTL_WITH_CHECKING │ │ │ │ │ + 1656 if(!first_ && globallocalIndexPair().global() < global) │ │ │ │ │ + 1675 ++iter_; │ │ │ │ │ + 1676 │ │ │ │ │ + 1677 if(iter_->localIndexPair().global()==global) { │ │ │ │ │ + 1678 iter_.remove(); │ │ │ │ │ + 1679 found = true; │ │ │ │ │ + 1680 } │ │ │ │ │ + 1681 } │ │ │ │ │ + 1682 │ │ │ │ │ + 1683 last_ = global; │ │ │ │ │ + 1684 first_ = false; │ │ │ │ │ + 1685 return found; │ │ │ │ │ + 1686 } │ │ │ │ │ + 1687 │ │ │ │ │ + 1688 template │ │ │ │ │ + 1689 template │ │ │ │ │ +1690 inline typename RemoteIndices::CollectiveIteratorT │ │ │ │ │ +RemoteIndices::iterator() const │ │ │ │ │ + 1691 { │ │ │ │ │ + 1692 return CollectiveIterator(remoteIndices_, send); │ │ │ │ │ + 1693 } │ │ │ │ │ + 1694 │ │ │ │ │ + 1695 template │ │ │ │ │ +1696 inline MPI_Comm RemoteIndices::communicator() const │ │ │ │ │ + 1697 { │ │ │ │ │ + 1698 return comm_; │ │ │ │ │ + 1699 │ │ │ │ │ + 1700 } │ │ │ │ │ + 1701 │ │ │ │ │ + 1702 template │ │ │ │ │ +1703 CollectiveIterator::CollectiveIterator(const RemoteIndexMap& pmap, │ │ │ │ │ +bool send) │ │ │ │ │ + 1704 { │ │ │ │ │ + 1705 │ │ │ │ │ + 1706 const auto end = pmap.end(); │ │ │ │ │ + 1707 for(auto process = pmap.begin(); process != end; ++process) { │ │ │ │ │ + 1708 const RemoteIndexList* list = send ? process->second.first : process- │ │ │ │ │ +>second.second; │ │ │ │ │ + 1709 using ri_iterator = typename RemoteIndexList::const_iterator; │ │ │ │ │ + 1710 map_.insert(std::make_pair(process->first, │ │ │ │ │ + 1711 std::pair(list->begin(), list->end()))); │ │ │ │ │ + 1712 } │ │ │ │ │ + 1713 } │ │ │ │ │ + 1714 │ │ │ │ │ + 1715 template │ │ │ │ │ +1716 inline void CollectiveIterator::advance(const GlobalIndex& index) │ │ │ │ │ + 1717 { │ │ │ │ │ + 1718 const auto end = map_.end(); │ │ │ │ │ + 1719 │ │ │ │ │ + 1720 for(auto iter = map_.begin(); iter != end;) { │ │ │ │ │ + 1721 // Step the iterator until we are >= index │ │ │ │ │ + 1722 typename RemoteIndexList::const_iterator current = iter->second.first; │ │ │ │ │ + 1723 typename RemoteIndexList::const_iterator rend = iter->second.second; │ │ │ │ │ + 1724 RemoteIndex remoteIndex; │ │ │ │ │ + 1725 if(current != rend) │ │ │ │ │ + 1726 remoteIndex = *current; │ │ │ │ │ + 1727 │ │ │ │ │ + 1728 while(iter->second.first!=iter->second.second && iter->second.first- │ │ │ │ │ +>localIndexPair().global()second.first); │ │ │ │ │ + 1730 │ │ │ │ │ + 1731 // erase from the map if there are no more entries. │ │ │ │ │ + 1732 if(iter->second.first == iter->second.second) │ │ │ │ │ + 1733 map_.erase(iter++); │ │ │ │ │ + 1734 else{ │ │ │ │ │ + 1735 ++iter; │ │ │ │ │ + 1736 } │ │ │ │ │ + 1737 } │ │ │ │ │ + 1738 index_=index; │ │ │ │ │ + 1739 noattribute=true; │ │ │ │ │ + 1740 } │ │ │ │ │ + 1741 │ │ │ │ │ + 1742 template │ │ │ │ │ +1743 inline void CollectiveIterator::advance(const GlobalIndex& index, │ │ │ │ │ + 1744 const Attribute& attribute) │ │ │ │ │ + 1745 { │ │ │ │ │ + 1746 const auto end = map_.end(); │ │ │ │ │ + 1747 │ │ │ │ │ + 1748 for(auto iter = map_.begin(); iter != end;) { │ │ │ │ │ + 1749 // Step the iterator until we are >= index │ │ │ │ │ + 1750 typename RemoteIndexList::const_iterator current = iter->second.first; │ │ │ │ │ + 1751 typename RemoteIndexList::const_iterator rend = iter->second.second; │ │ │ │ │ + 1752 RemoteIndex remoteIndex; │ │ │ │ │ + 1753 if(current != rend) │ │ │ │ │ + 1754 remoteIndex = *current; │ │ │ │ │ + 1755 │ │ │ │ │ + 1756 // Move to global index or bigger │ │ │ │ │ + 1757 while(iter->second.first!=iter->second.second && iter->second.first- │ │ │ │ │ +>localIndexPair().global()second.first); │ │ │ │ │ + 1759 │ │ │ │ │ + 1760 // move to attribute or bigger │ │ │ │ │ + 1761 while(iter->second.first!=iter->second.second │ │ │ │ │ + 1762 && iter->second.first->localIndexPair().global()==index │ │ │ │ │ + 1763 && iter->second.first->localIndexPair().local().attribute()second.first); │ │ │ │ │ + 1765 │ │ │ │ │ + 1766 // erase from the map if there are no more entries. │ │ │ │ │ + 1767 if(iter->second.first == iter->second.second) │ │ │ │ │ + 1768 map_.erase(iter++); │ │ │ │ │ + 1769 else{ │ │ │ │ │ + 1770 ++iter; │ │ │ │ │ + 1771 } │ │ │ │ │ + 1772 } │ │ │ │ │ + 1773 index_=index; │ │ │ │ │ + 1774 attribute_=attribute; │ │ │ │ │ + 1775 noattribute=false; │ │ │ │ │ + 1776 } │ │ │ │ │ + 1777 │ │ │ │ │ + 1778 template │ │ │ │ │ +1779 inline CollectiveIterator& CollectiveIterator::operator++() │ │ │ │ │ + 1780 { │ │ │ │ │ + 1781 const auto end = map_.end(); │ │ │ │ │ + 1782 │ │ │ │ │ + 1783 for(auto iter = map_.begin(); iter != end;) { │ │ │ │ │ + 1784 // Step the iterator until we are >= index │ │ │ │ │ + 1785 auto current = iter->second.first; │ │ │ │ │ + 1786 auto rend = iter->second.second; │ │ │ │ │ + 1787 │ │ │ │ │ + 1788 // move all iterators pointing to the current global index to next value │ │ │ │ │ + 1789 if(iter->second.first->localIndexPair().global()==index_ && │ │ │ │ │ + 1790 (noattribute || iter->second.first->localIndexPair().local().attribute() │ │ │ │ │ +== attribute_)) │ │ │ │ │ + 1791 ++(iter->second.first); │ │ │ │ │ + 1792 │ │ │ │ │ + 1793 // erase from the map if there are no more entries. │ │ │ │ │ + 1794 if(iter->second.first == iter->second.second) │ │ │ │ │ + 1795 map_.erase(iter++); │ │ │ │ │ + 1796 else{ │ │ │ │ │ + 1797 ++iter; │ │ │ │ │ + 1798 } │ │ │ │ │ + 1799 } │ │ │ │ │ + 1800 return *this; │ │ │ │ │ + 1801 } │ │ │ │ │ + 1802 │ │ │ │ │ + 1803 template │ │ │ │ │ +1804 inline bool CollectiveIterator::empty() const │ │ │ │ │ + 1805 { │ │ │ │ │ + 1806 return map_.empty(); │ │ │ │ │ + 1807 } │ │ │ │ │ + 1808 │ │ │ │ │ + 1809 template │ │ │ │ │ + 1810 inline typename CollectiveIterator::iterator │ │ │ │ │ +1811 CollectiveIterator::begin() │ │ │ │ │ + 1812 { │ │ │ │ │ + 1813 if(noattribute) │ │ │ │ │ + 1814 return iterator(map_.begin(), map_.end(), index_); │ │ │ │ │ + 1815 else │ │ │ │ │ + 1816 return iterator(map_.begin(), map_.end(), index_, │ │ │ │ │ + 1817 attribute_); │ │ │ │ │ + 1818 } │ │ │ │ │ + 1819 │ │ │ │ │ + 1820 template │ │ │ │ │ + 1821 inline typename CollectiveIterator::iterator │ │ │ │ │ +1822 CollectiveIterator::end() │ │ │ │ │ + 1823 { │ │ │ │ │ + 1824 return iterator(map_.end(), map_.end(), index_); │ │ │ │ │ + 1825 } │ │ │ │ │ + 1826 │ │ │ │ │ + 1827 template │ │ │ │ │ +1828 inline std::ostream& operator<<(std::ostream& os, const │ │ │ │ │ +RemoteIndex& index) │ │ │ │ │ + 1829 { │ │ │ │ │ + 1830 os<<"[global="< │ │ │ │ │ +1835 inline std::ostream& operator<<(std::ostream& os, const │ │ │ │ │ +RemoteIndices& indices) │ │ │ │ │ + 1836 { │ │ │ │ │ + 1837 int rank; │ │ │ │ │ + 1838 MPI_Comm_rank(indices.comm_, &rank); │ │ │ │ │ + 1839 const auto rend = indices.remoteIndices_.end(); │ │ │ │ │ + 1840 │ │ │ │ │ + 1841 for(auto rindex = indices.remoteIndices_.begin(); rindex!=rend; ++rindex) │ │ │ │ │ +{ │ │ │ │ │ + 1842 os<first<<":"; │ │ │ │ │ + 1843 │ │ │ │ │ + 1844 if(!rindex->second.first->empty()) { │ │ │ │ │ + 1845 os<<" send:"; │ │ │ │ │ + 1846 │ │ │ │ │ + 1847 const auto send= rindex->second.first->end(); │ │ │ │ │ + 1848 │ │ │ │ │ + 1849 for(auto index = rindex->second.first->begin(); │ │ │ │ │ + 1850 index != send; ++index) │ │ │ │ │ + 1851 os<<*index<<" "; │ │ │ │ │ + 1852 os<second.second->empty()) { │ │ │ │ │ + 1855 os<first<<": "<<"receive: "; │ │ │ │ │ + 1856 │ │ │ │ │ + 1857 for(const auto& index : *(rindex->second.second)) │ │ │ │ │ + 1858 os << index << " "; │ │ │ │ │ + 1859 } │ │ │ │ │ + 1860 os< transposed() const │ │ │ │ │ -Return transposed of the matrix as DiagonalMatrix. │ │ │ │ │ -Definition diagonalmatrix.hh:136 │ │ │ │ │ -Dune::DiagonalMatrix::mmhv │ │ │ │ │ -void mmhv(const X &x, Y &y) const │ │ │ │ │ -y -= A^H x │ │ │ │ │ -Definition diagonalmatrix.hh:357 │ │ │ │ │ -Dune::DiagonalMatrix::operator*= │ │ │ │ │ -DiagonalMatrix & operator*=(const K &k) │ │ │ │ │ -vector space multiplication with scalar │ │ │ │ │ -Definition diagonalmatrix.hh:246 │ │ │ │ │ -Dune::FieldTraits<_DiagonalMatrix<_K,_n_>_>::field_type │ │ │ │ │ -FieldTraits< K >::field_type field_type │ │ │ │ │ -Definition diagonalmatrix.hh:563 │ │ │ │ │ -Dune::DiagonalMatrix::size_type │ │ │ │ │ -std::size_t size_type │ │ │ │ │ -The type used for the index access and size operations. │ │ │ │ │ -Definition diagonalmatrix.hh:67 │ │ │ │ │ -Dune::DiagonalRowVectorConst::dim │ │ │ │ │ -size_type dim() const │ │ │ │ │ -dimension of the vector space │ │ │ │ │ -Definition diagonalmatrix.hh:800 │ │ │ │ │ -Dune::DiagonalMatrix::ConstRowIterator │ │ │ │ │ -ConstIterator ConstRowIterator │ │ │ │ │ -rename the iterators for easier access │ │ │ │ │ -Definition diagonalmatrix.hh:183 │ │ │ │ │ -Dune::DiagonalMatrix::row_reference │ │ │ │ │ -row_type row_reference │ │ │ │ │ -Definition diagonalmatrix.hh:75 │ │ │ │ │ -Dune::DiagonalRowVector::operator[] │ │ │ │ │ -K & operator[](size_type i) │ │ │ │ │ -random access │ │ │ │ │ -Definition diagonalmatrix.hh:879 │ │ │ │ │ -Dune::ContainerWrapperIterator::operator= │ │ │ │ │ -ContainerWrapperIterator & operator=(OtherContainerWrapperIteratorType &other) │ │ │ │ │ -Definition diagonalmatrix.hh:1037 │ │ │ │ │ -Dune::DiagonalMatrix::rows │ │ │ │ │ -static constexpr int rows │ │ │ │ │ -The number of rows. │ │ │ │ │ -Definition diagonalmatrix.hh:81 │ │ │ │ │ -Dune::DiagonalMatrix::M │ │ │ │ │ -static constexpr size_type M() │ │ │ │ │ -number of blocks in column direction │ │ │ │ │ -Definition diagonalmatrix.hh:488 │ │ │ │ │ -Dune::DiagonalMatrix::diagonal │ │ │ │ │ -FieldVector< K, n > & diagonal() │ │ │ │ │ -Get reference to diagonal vector. │ │ │ │ │ -Definition diagonalmatrix.hh:549 │ │ │ │ │ -Dune::DiagonalMatrix::usmhv │ │ │ │ │ -void usmhv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y │ │ │ │ │ -&y) const │ │ │ │ │ -y += alpha A^H x │ │ │ │ │ -Definition diagonalmatrix.hh:395 │ │ │ │ │ -Dune::DiagonalRowVector::iterator │ │ │ │ │ -Iterator iterator │ │ │ │ │ -typedef for stl compliant access │ │ │ │ │ -Definition diagonalmatrix.hh:888 │ │ │ │ │ -Dune::ContainerWrapperIterator::increment │ │ │ │ │ -void increment() │ │ │ │ │ -Definition diagonalmatrix.hh:1067 │ │ │ │ │ -Dune::DiagonalMatrix::blocklevel │ │ │ │ │ -static constexpr int blocklevel │ │ │ │ │ -The number of block levels we contain. This is the leaf, that is, 1. │ │ │ │ │ -Definition diagonalmatrix.hh:70 │ │ │ │ │ -Dune::const_reference<_DiagonalRowVectorConst<_K,_n_>_>::type │ │ │ │ │ -DiagonalRowVectorConst< K, n > type │ │ │ │ │ -Definition diagonalmatrix.hh:957 │ │ │ │ │ -Dune::ContainerWrapperIterator::operator-> │ │ │ │ │ -T * operator->() const │ │ │ │ │ -Definition diagonalmatrix.hh:1046 │ │ │ │ │ -Dune::DiagonalRowVectorConst::size │ │ │ │ │ -static constexpr int size │ │ │ │ │ -The size of this vector. │ │ │ │ │ -Definition diagonalmatrix.hh:724 │ │ │ │ │ -Dune::DiagonalRowVectorConst::pointer │ │ │ │ │ -K * pointer(size_type i) const │ │ │ │ │ -Definition diagonalmatrix.hh:824 │ │ │ │ │ -Dune::DiagonalRowVectorConst::field_type │ │ │ │ │ -K field_type │ │ │ │ │ -export the type representing the field │ │ │ │ │ -Definition diagonalmatrix.hh:712 │ │ │ │ │ -Dune::mutable_reference<_DiagonalRowVector<_K,_n_>_>::type │ │ │ │ │ -DiagonalRowVector< K, n > type │ │ │ │ │ -Definition diagonalmatrix.hh:963 │ │ │ │ │ -Dune::DiagonalRowVectorConst::beforeEnd │ │ │ │ │ -ConstIterator beforeEnd() const │ │ │ │ │ -Definition diagonalmatrix.hh:773 │ │ │ │ │ -Dune::DiagonalMatrix::ConstColIterator │ │ │ │ │ -const_row_type::ConstIterator ConstColIterator │ │ │ │ │ -rename the iterators for easier access │ │ │ │ │ -Definition diagonalmatrix.hh:185 │ │ │ │ │ -Dune::DiagonalMatrix::exists │ │ │ │ │ -bool exists(size_type i, size_type j) const │ │ │ │ │ -return true when (i,j) is in pattern │ │ │ │ │ -Definition diagonalmatrix.hh:498 │ │ │ │ │ -Dune::DiagonalMatrix::ConstIterator │ │ │ │ │ -ContainerWrapperIterator< const WrapperType, const_reference, const_reference > │ │ │ │ │ -ConstIterator │ │ │ │ │ -Iterator class for sequential access. │ │ │ │ │ -Definition diagonalmatrix.hh:179 │ │ │ │ │ -Dune::DiagonalMatrix::const_row_reference │ │ │ │ │ -const_row_type const_row_reference │ │ │ │ │ -Definition diagonalmatrix.hh:78 │ │ │ │ │ -Dune::DiagonalMatrix::size │ │ │ │ │ -static constexpr size_type size() │ │ │ │ │ -Definition diagonalmatrix.hh:87 │ │ │ │ │ -Dune::DiagonalRowVectorConst::row_ │ │ │ │ │ -size_type row_ │ │ │ │ │ -Definition diagonalmatrix.hh:836 │ │ │ │ │ -Dune::ContainerWrapperIterator::ContainerWrapperIterator │ │ │ │ │ -ContainerWrapperIterator(CW containerWrapper, int position) │ │ │ │ │ -Definition diagonalmatrix.hh:1015 │ │ │ │ │ -Dune::DiagonalRowVector::DiagonalRowVector │ │ │ │ │ -DiagonalRowVector(K *p, int col) │ │ │ │ │ -Constructor making vector with identical coordinates. │ │ │ │ │ -Definition diagonalmatrix.hh:865 │ │ │ │ │ -Dune::DiagonalMatrix::diagonal │ │ │ │ │ -K & diagonal(size_type i) │ │ │ │ │ -Get reference to diagonal entry. │ │ │ │ │ -Definition diagonalmatrix.hh:537 │ │ │ │ │ -Dune::DiagonalMatrix::solve │ │ │ │ │ -void solve(V &x, const V &b) const │ │ │ │ │ -Solve system A x = b. │ │ │ │ │ -Definition diagonalmatrix.hh:438 │ │ │ │ │ -Dune::DiagonalMatrix::N │ │ │ │ │ -static constexpr size_type N() │ │ │ │ │ -number of blocks in row direction │ │ │ │ │ -Definition diagonalmatrix.hh:482 │ │ │ │ │ -Dune::DiagonalRowVector::beforeBegin │ │ │ │ │ -Iterator beforeBegin() │ │ │ │ │ -Definition diagonalmatrix.hh:911 │ │ │ │ │ -Dune::ContainerWrapperIterator::ContainerWrapperIterator │ │ │ │ │ -ContainerWrapperIterator(OtherContainerWrapperIteratorType &other) │ │ │ │ │ -Definition diagonalmatrix.hh:1021 │ │ │ │ │ -Dune::DiagonalMatrix::operator[] │ │ │ │ │ -const_reference operator[](size_type i) const │ │ │ │ │ -Return const_reference object as row replacement. │ │ │ │ │ -Definition diagonalmatrix.hh:525 │ │ │ │ │ -Dune::DiagonalMatrix::iterator │ │ │ │ │ -Iterator iterator │ │ │ │ │ -typedef for stl compliant access │ │ │ │ │ -Definition diagonalmatrix.hh:145 │ │ │ │ │ -Dune::DiagonalRowVectorConst::begin │ │ │ │ │ -ConstIterator begin() const │ │ │ │ │ -begin ConstIterator │ │ │ │ │ -Definition diagonalmatrix.hh:760 │ │ │ │ │ -Dune::DiagonalRowVector::const_iterator │ │ │ │ │ -ConstIterator const_iterator │ │ │ │ │ -typedef for stl compliant access │ │ │ │ │ -Definition diagonalmatrix.hh:919 │ │ │ │ │ -Dune::DiagonalRowVectorConst::identical │ │ │ │ │ -bool identical(const DiagonalRowVectorConst< K, n > &other) const │ │ │ │ │ -Definition diagonalmatrix.hh:749 │ │ │ │ │ -Dune::DiagonalMatrix::operator-= │ │ │ │ │ -DiagonalMatrix & operator-=(const DiagonalMatrix &y) │ │ │ │ │ -vector space subtraction │ │ │ │ │ -Definition diagonalmatrix.hh:225 │ │ │ │ │ -Dune::DiagonalRowVectorConst::DiagonalRowVectorConst │ │ │ │ │ -DiagonalRowVectorConst(K *p, int col) │ │ │ │ │ -Constructor making vector with identical coordinates. │ │ │ │ │ -Definition diagonalmatrix.hh:733 │ │ │ │ │ -Dune::DiagonalMatrix::mmtv │ │ │ │ │ -void mmtv(const X &x, Y &y) const │ │ │ │ │ -y -= A^T x │ │ │ │ │ -Definition diagonalmatrix.hh:345 │ │ │ │ │ -Dune::DiagonalRowVectorConst::blocklevel │ │ │ │ │ -static constexpr int blocklevel │ │ │ │ │ -The number of block levels we contain. │ │ │ │ │ -Definition diagonalmatrix.hh:721 │ │ │ │ │ -Dune::DiagonalMatrixWrapper::pointer │ │ │ │ │ -row_type * pointer(int i) const │ │ │ │ │ -Definition diagonalmatrix.hh:676 │ │ │ │ │ -Dune::DiagonalMatrix::DiagonalMatrix │ │ │ │ │ -DiagonalMatrix(const K &k) │ │ │ │ │ -Constructor initializing the whole matrix with a scalar. │ │ │ │ │ -Definition diagonalmatrix.hh:98 │ │ │ │ │ -Dune::DiagonalRowVector::Iterator │ │ │ │ │ -ContainerWrapperIterator< DiagonalRowVector< K, n >, K, K & > Iterator │ │ │ │ │ -Iterator class for sequential access. │ │ │ │ │ -Definition diagonalmatrix.hh:886 │ │ │ │ │ -Dune::ContainerWrapperIterator::elementAt │ │ │ │ │ -R elementAt(int i) const │ │ │ │ │ -Definition diagonalmatrix.hh:1079 │ │ │ │ │ -Dune::ContainerWrapperIterator::distanceTo │ │ │ │ │ -std::ptrdiff_t distanceTo(OtherContainerWrapperIteratorType &other) const │ │ │ │ │ -Definition diagonalmatrix.hh:1090 │ │ │ │ │ -Dune::DiagonalRowVector::beforeEnd │ │ │ │ │ -Iterator beforeEnd() │ │ │ │ │ -Definition diagonalmatrix.hh:904 │ │ │ │ │ -Dune::DiagonalMatrix::umtv │ │ │ │ │ -void umtv(const X &x, Y &y) const │ │ │ │ │ -y += A^T x │ │ │ │ │ -Definition diagonalmatrix.hh:309 │ │ │ │ │ -Dune::DiagonalRowVectorConst::const_iterator │ │ │ │ │ -ConstIterator const_iterator │ │ │ │ │ -typedef for stl compliant access │ │ │ │ │ -Definition diagonalmatrix.hh:757 │ │ │ │ │ -Dune::DiagonalMatrix::infinity_norm_real │ │ │ │ │ -double infinity_norm_real() const │ │ │ │ │ -simplified infinity norm (uses Manhattan norm for complex values) │ │ │ │ │ -Definition diagonalmatrix.hh:427 │ │ │ │ │ -Dune::DiagonalMatrixWrapper::DiagonalMatrixWrapper │ │ │ │ │ -DiagonalMatrixWrapper(const DiagonalMatrixType *mat) │ │ │ │ │ -Definition diagonalmatrix.hh:667 │ │ │ │ │ -Dune::DiagonalMatrix::umv │ │ │ │ │ -void umv(const X &x, Y &y) const │ │ │ │ │ -y += A x │ │ │ │ │ -Definition diagonalmatrix.hh:297 │ │ │ │ │ -Dune::DiagonalMatrix::Iterator │ │ │ │ │ -ContainerWrapperIterator< const WrapperType, reference, reference > Iterator │ │ │ │ │ -Iterator class for sequential access. │ │ │ │ │ -Definition diagonalmatrix.hh:143 │ │ │ │ │ -Dune::mutable_reference<_DiagonalRowVectorConst<_K,_n_>_>::type │ │ │ │ │ -DiagonalRowVector< K, n > type │ │ │ │ │ -Definition diagonalmatrix.hh:969 │ │ │ │ │ -Dune::DiagonalMatrix::mv │ │ │ │ │ -void mv(const X &x, Y &y) const │ │ │ │ │ -y = A x │ │ │ │ │ -Definition diagonalmatrix.hh:278 │ │ │ │ │ -Dune::DiagonalMatrix::frobenius_norm │ │ │ │ │ -double frobenius_norm() const │ │ │ │ │ -frobenius norm: sqrt(sum over squared values of entries) │ │ │ │ │ -Definition diagonalmatrix.hh:409 │ │ │ │ │ -Dune::DiagonalMatrix::end │ │ │ │ │ -ConstIterator end() const │ │ │ │ │ -end iterator │ │ │ │ │ -Definition diagonalmatrix.hh:194 │ │ │ │ │ -Dune::DiagonalMatrix::cols │ │ │ │ │ -static constexpr int cols │ │ │ │ │ -The number of columns. │ │ │ │ │ -Definition diagonalmatrix.hh:83 │ │ │ │ │ -Dune::DiagonalRowVectorConst::dimension │ │ │ │ │ -static constexpr int dimension │ │ │ │ │ -Definition diagonalmatrix.hh:705 │ │ │ │ │ -Dune::DiagonalRowVectorConst::p_ │ │ │ │ │ -K * p_ │ │ │ │ │ -Definition diagonalmatrix.hh:835 │ │ │ │ │ -Dune::DiagonalRowVectorConst::rowIndex │ │ │ │ │ -size_type rowIndex() const │ │ │ │ │ -index of this row in surrounding matrix │ │ │ │ │ -Definition diagonalmatrix.hh:806 │ │ │ │ │ -Dune::ContainerWrapperIterator::dereference │ │ │ │ │ -R dereference() const │ │ │ │ │ -Definition diagonalmatrix.hh:1062 │ │ │ │ │ -Dune::DiagonalRowVector::operator= │ │ │ │ │ -DiagonalRowVector & operator=(const K &k) │ │ │ │ │ -Assignment operator for scalar. │ │ │ │ │ -Definition diagonalmatrix.hh:870 │ │ │ │ │ -Dune::DiagonalMatrix::operator!= │ │ │ │ │ -bool operator!=(const DiagonalMatrix &other) const │ │ │ │ │ -incomparison operator │ │ │ │ │ -Definition diagonalmatrix.hh:268 │ │ │ │ │ -Dune::DiagonalMatrix::field_type │ │ │ │ │ -value_type field_type │ │ │ │ │ -Definition diagonalmatrix.hh:61 │ │ │ │ │ -Dune::ContainerWrapperIterator::advance │ │ │ │ │ -void advance(int n) │ │ │ │ │ -Definition diagonalmatrix.hh:1084 │ │ │ │ │ -Dune::DiagonalMatrix::begin │ │ │ │ │ -ConstIterator begin() const │ │ │ │ │ -begin iterator │ │ │ │ │ -Definition diagonalmatrix.hh:188 │ │ │ │ │ -Dune::DiagonalRowVector::begin │ │ │ │ │ -Iterator begin() │ │ │ │ │ -begin iterator │ │ │ │ │ -Definition diagonalmatrix.hh:891 │ │ │ │ │ -Dune::DiagonalMatrix::mmv │ │ │ │ │ -void mmv(const X &x, Y &y) const │ │ │ │ │ -y -= A x │ │ │ │ │ -Definition diagonalmatrix.hh:333 │ │ │ │ │ -Dune::DiagonalMatrix::operator/= │ │ │ │ │ -DiagonalMatrix & operator/=(const K &k) │ │ │ │ │ -vector space division by scalar │ │ │ │ │ -Definition diagonalmatrix.hh:253 │ │ │ │ │ -Dune::DiagonalMatrix::const_iterator │ │ │ │ │ -ConstIterator const_iterator │ │ │ │ │ -typedef for stl compliant access │ │ │ │ │ -Definition diagonalmatrix.hh:181 │ │ │ │ │ -Dune::DiagonalMatrix::const_reference │ │ │ │ │ -const_row_type const_reference │ │ │ │ │ -Definition diagonalmatrix.hh:77 │ │ │ │ │ -Dune::DiagonalMatrix::identical │ │ │ │ │ -bool identical(const DiagonalMatrix< K, n > &other) const │ │ │ │ │ -Check if matrix is the same object as the other matrix. │ │ │ │ │ -Definition diagonalmatrix.hh:130 │ │ │ │ │ -Dune::DiagonalMatrix::operator* │ │ │ │ │ -friend auto operator*(const DiagonalMatrix &matrixA, const DiagonalMatrix< │ │ │ │ │ -OtherScalar, n > &matrixB) │ │ │ │ │ -Matrix-matrix multiplication. │ │ │ │ │ -Definition diagonalmatrix.hh:468 │ │ │ │ │ -Dune::DiagonalMatrixWrapper::realIndex │ │ │ │ │ -size_type realIndex(int i) const │ │ │ │ │ -Definition diagonalmatrix.hh:671 │ │ │ │ │ -Dune::DiagonalMatrix::end │ │ │ │ │ -Iterator end() │ │ │ │ │ -end iterator │ │ │ │ │ -Definition diagonalmatrix.hh:158 │ │ │ │ │ -Dune::DiagonalRowVectorConst::operator[] │ │ │ │ │ -const K & operator[](size_type i) const │ │ │ │ │ -same for read only access │ │ │ │ │ -Definition diagonalmatrix.hh:741 │ │ │ │ │ -Dune::DiagonalRowVector::DiagonalRowVector │ │ │ │ │ -DiagonalRowVector() │ │ │ │ │ -Constructor making uninitialized vector. │ │ │ │ │ -Definition diagonalmatrix.hh:861 │ │ │ │ │ -Dune::DiagonalMatrix::reference │ │ │ │ │ -row_type reference │ │ │ │ │ -Definition diagonalmatrix.hh:74 │ │ │ │ │ -Dune::DiagonalRowVectorConst::operator& │ │ │ │ │ -DiagonalRowVectorConst * operator&() │ │ │ │ │ -Definition diagonalmatrix.hh:829 │ │ │ │ │ -Dune::DiagonalRowVectorConst::operator== │ │ │ │ │ -bool operator==(const DiagonalRowVectorConst &y) const │ │ │ │ │ -Binary vector comparison. │ │ │ │ │ -Definition diagonalmatrix.hh:786 │ │ │ │ │ -Dune::DiagonalMatrix::frobenius_norm2 │ │ │ │ │ -double frobenius_norm2() const │ │ │ │ │ -square of frobenius norm, need for block recursion │ │ │ │ │ -Definition diagonalmatrix.hh:415 │ │ │ │ │ -Dune::DiagonalMatrix::DiagonalMatrix │ │ │ │ │ -constexpr DiagonalMatrix()=default │ │ │ │ │ -Default constructor. │ │ │ │ │ -Dune::DiagonalMatrix::mtv │ │ │ │ │ -void mtv(const X &x, Y &y) const │ │ │ │ │ -y = A^T x │ │ │ │ │ -Definition diagonalmatrix.hh:290 │ │ │ │ │ -Dune::DiagonalRowVector::ConstIterator │ │ │ │ │ -ContainerWrapperIterator< DiagonalRowVectorConst< K, n >, const K, const K & > │ │ │ │ │ -ConstIterator │ │ │ │ │ -ConstIterator class for sequential access. │ │ │ │ │ -Definition diagonalmatrix.hh:917 │ │ │ │ │ -Dune::DiagonalMatrixWrapper::identical │ │ │ │ │ -bool identical(const DiagonalMatrixWrapper &other) const │ │ │ │ │ -Definition diagonalmatrix.hh:682 │ │ │ │ │ -Dune::DiagonalMatrix::usmtv │ │ │ │ │ -void usmtv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y │ │ │ │ │ -&y) const │ │ │ │ │ -y += alpha A^T x │ │ │ │ │ -Definition diagonalmatrix.hh:382 │ │ │ │ │ -Dune::ContainerWrapperIterator::decrement │ │ │ │ │ -void decrement() │ │ │ │ │ -Definition diagonalmatrix.hh:1073 │ │ │ │ │ -Dune::ContainerWrapperIterator::index │ │ │ │ │ -std::ptrdiff_t index() const │ │ │ │ │ -Definition diagonalmatrix.hh:1096 │ │ │ │ │ -Dune::DiagonalMatrix::diagonal │ │ │ │ │ -const FieldVector< K, n > & diagonal() const │ │ │ │ │ -Get const reference to diagonal vector. │ │ │ │ │ -Definition diagonalmatrix.hh:543 │ │ │ │ │ -Dune::DiagonalMatrix::invert │ │ │ │ │ -void invert() │ │ │ │ │ -Compute inverse. │ │ │ │ │ -Definition diagonalmatrix.hh:445 │ │ │ │ │ -Dune::DiagonalRowVector::operator& │ │ │ │ │ -DiagonalRowVector * operator&() │ │ │ │ │ -Definition diagonalmatrix.hh:935 │ │ │ │ │ -Dune::DiagonalMatrix::diagonal │ │ │ │ │ -const K & diagonal(size_type i) const │ │ │ │ │ -Get const reference to diagonal entry. │ │ │ │ │ -Definition diagonalmatrix.hh:531 │ │ │ │ │ -Dune::DiagonalRowVectorConst::N │ │ │ │ │ -size_type N() const │ │ │ │ │ -number of blocks in the vector (are of size 1 here) │ │ │ │ │ -Definition diagonalmatrix.hh:794 │ │ │ │ │ -Dune::DiagonalMatrix::DiagonalMatrix │ │ │ │ │ -DiagonalMatrix(std::initializer_list< K > const &l) │ │ │ │ │ -Construct diagonal matrix from an initializer list. │ │ │ │ │ -Definition diagonalmatrix.hh:115 │ │ │ │ │ -Dune::DiagonalMatrix::ColIterator │ │ │ │ │ -row_type::Iterator ColIterator │ │ │ │ │ -rename the iterators for easier access │ │ │ │ │ -Definition diagonalmatrix.hh:149 │ │ │ │ │ -Dune::DiagonalRowVector::field_type │ │ │ │ │ -K field_type │ │ │ │ │ -export the type representing the field │ │ │ │ │ -Definition diagonalmatrix.hh:852 │ │ │ │ │ -Dune::DiagonalMatrix::operator[] │ │ │ │ │ -reference operator[](size_type i) │ │ │ │ │ -Return reference object as row replacement. │ │ │ │ │ -Definition diagonalmatrix.hh:519 │ │ │ │ │ -Dune::const_reference<_DiagonalRowVector<_K,_n_>_>::type │ │ │ │ │ -DiagonalRowVectorConst< K, n > type │ │ │ │ │ -Definition diagonalmatrix.hh:951 │ │ │ │ │ -Dune::DiagonalRowVector::end │ │ │ │ │ -Iterator end() │ │ │ │ │ -end iterator │ │ │ │ │ -Definition diagonalmatrix.hh:897 │ │ │ │ │ -Dune::DiagonalMatrix::DiagonalMatrix │ │ │ │ │ -DiagonalMatrix(const FieldVector< K, n > &diag) │ │ │ │ │ -Constructor initializing the diagonal with a vector. │ │ │ │ │ -Definition diagonalmatrix.hh:103 │ │ │ │ │ -Dune::DiagonalRowVector::size_type │ │ │ │ │ -std::size_t size_type │ │ │ │ │ -The type used for the index access and size operation. │ │ │ │ │ -Definition diagonalmatrix.hh:858 │ │ │ │ │ -Dune::DiagonalMatrix::usmv │ │ │ │ │ -void usmv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) │ │ │ │ │ -const │ │ │ │ │ -y += alpha A x │ │ │ │ │ -Definition diagonalmatrix.hh:369 │ │ │ │ │ -Dune::DiagonalMatrix::infinity_norm │ │ │ │ │ -double infinity_norm() const │ │ │ │ │ -infinity norm (row sum norm, how to generalize for blocks?) │ │ │ │ │ -Definition diagonalmatrix.hh:421 │ │ │ │ │ -Dune::DiagonalMatrix::operator+= │ │ │ │ │ -DiagonalMatrix & operator+=(const DiagonalMatrix &y) │ │ │ │ │ -vector space addition │ │ │ │ │ -Definition diagonalmatrix.hh:218 │ │ │ │ │ -Dune::DiagonalMatrix::block_type │ │ │ │ │ -K block_type │ │ │ │ │ -export the type representing the components │ │ │ │ │ -Definition diagonalmatrix.hh:64 │ │ │ │ │ -Dune::DiagonalMatrix::umhv │ │ │ │ │ -void umhv(const X &x, Y &y) const │ │ │ │ │ -y += A^H x │ │ │ │ │ -Definition diagonalmatrix.hh:321 │ │ │ │ │ -Dune::DiagonalMatrix::beforeBegin │ │ │ │ │ -Iterator beforeBegin() │ │ │ │ │ -Definition diagonalmatrix.hh:172 │ │ │ │ │ -Dune::DenseMatrixAssigner<_DenseMatrix,_DiagonalMatrix<_field,_N_>_>::apply │ │ │ │ │ -static void apply(DenseMatrix &denseMatrix, DiagonalMatrix< field, N > const │ │ │ │ │ -&rhs) │ │ │ │ │ -Definition diagonalmatrix.hh:1108 │ │ │ │ │ -Dune::ContainerWrapperIterator::ContainerWrapperIterator │ │ │ │ │ -ContainerWrapperIterator(const MyType &other) │ │ │ │ │ -Definition diagonalmatrix.hh:1026 │ │ │ │ │ -Dune::DiagonalRowVectorConst::end │ │ │ │ │ -ConstIterator end() const │ │ │ │ │ -end ConstIterator │ │ │ │ │ -Definition diagonalmatrix.hh:766 │ │ │ │ │ -Dune::DiagonalRowVectorConst::size_type │ │ │ │ │ -std::size_t size_type │ │ │ │ │ -The type used for the index access and size operation. │ │ │ │ │ -Definition diagonalmatrix.hh:718 │ │ │ │ │ -Dune::DiagonalMatrix::operator= │ │ │ │ │ -DiagonalMatrix & operator=(const K &k) │ │ │ │ │ -Assignment from a scalar. │ │ │ │ │ -Definition diagonalmatrix.hh:123 │ │ │ │ │ -Dune::DiagonalRowVectorConst::DiagonalRowVectorConst │ │ │ │ │ -DiagonalRowVectorConst() │ │ │ │ │ -Constructor making uninitialized vector. │ │ │ │ │ -Definition diagonalmatrix.hh:727 │ │ │ │ │ -Dune::DiagonalMatrix::beforeEnd │ │ │ │ │ -Iterator beforeEnd() │ │ │ │ │ -Definition diagonalmatrix.hh:165 │ │ │ │ │ -Dune::DiagonalRowVectorConst::realIndex │ │ │ │ │ -size_type realIndex(int i) const │ │ │ │ │ -Definition diagonalmatrix.hh:819 │ │ │ │ │ -Dune::DiagonalMatrix::operator<< │ │ │ │ │ -friend std::ostream & operator<<(std::ostream &s, const DiagonalMatrix< K, n > │ │ │ │ │ -&a) │ │ │ │ │ -Sends the matrix to an output stream. │ │ │ │ │ -Definition diagonalmatrix.hh:508 │ │ │ │ │ -Dune::DiagonalMatrix::value_type │ │ │ │ │ -K value_type │ │ │ │ │ -export the type representing the field │ │ │ │ │ -Definition diagonalmatrix.hh:60 │ │ │ │ │ -Dune::DiagonalRowVectorConst::block_type │ │ │ │ │ -K block_type │ │ │ │ │ -export the type representing the components │ │ │ │ │ -Definition diagonalmatrix.hh:715 │ │ │ │ │ -Dune::DiagonalMatrix::determinant │ │ │ │ │ -K determinant() const │ │ │ │ │ -calculates the determinant of this matrix │ │ │ │ │ -Definition diagonalmatrix.hh:453 │ │ │ │ │ -Dune::FieldTraits<_DiagonalMatrix<_K,_n_>_>::real_type │ │ │ │ │ -FieldTraits< K >::real_type real_type │ │ │ │ │ -Definition diagonalmatrix.hh:564 │ │ │ │ │ -Dune::DiagonalRowVectorConst::beforeBegin │ │ │ │ │ -ConstIterator beforeBegin() const │ │ │ │ │ -Definition diagonalmatrix.hh:780 │ │ │ │ │ -Dune::DiagonalMatrixWrapper::DiagonalMatrixWrapper │ │ │ │ │ -DiagonalMatrixWrapper() │ │ │ │ │ -Definition diagonalmatrix.hh:663 │ │ │ │ │ -Dune::DiagonalRowVectorConst::ConstIterator │ │ │ │ │ -ContainerWrapperIterator< DiagonalRowVectorConst< K, n >, const K, const K & > │ │ │ │ │ -ConstIterator │ │ │ │ │ -ConstIterator class for sequential access. │ │ │ │ │ -Definition diagonalmatrix.hh:755 │ │ │ │ │ -Dune::DiagonalMatrix::begin │ │ │ │ │ -Iterator begin() │ │ │ │ │ -begin iterator │ │ │ │ │ -Definition diagonalmatrix.hh:152 │ │ │ │ │ -Dune::DiagonalMatrix::operator== │ │ │ │ │ -bool operator==(const DiagonalMatrix &other) const │ │ │ │ │ -comparison operator │ │ │ │ │ -Definition diagonalmatrix.hh:262 │ │ │ │ │ -Dune::DiagonalMatrix::const_row_type │ │ │ │ │ -DiagonalRowVectorConst< K, n > const_row_type │ │ │ │ │ -Definition diagonalmatrix.hh:76 │ │ │ │ │ -Dune::DiagonalMatrix::row_type │ │ │ │ │ -DiagonalRowVector< K, n > row_type │ │ │ │ │ -Each row is implemented by a field vector. │ │ │ │ │ -Definition diagonalmatrix.hh:73 │ │ │ │ │ -Dune::ContainerWrapperIterator::equals │ │ │ │ │ -bool equals(const MyType &other) const │ │ │ │ │ -Definition diagonalmatrix.hh:1052 │ │ │ │ │ -Dune::DiagonalMatrix::RowIterator │ │ │ │ │ -Iterator RowIterator │ │ │ │ │ -rename the iterators for easier access │ │ │ │ │ -Definition diagonalmatrix.hh:147 │ │ │ │ │ -Dune::DiagonalRowVector::block_type │ │ │ │ │ -K block_type │ │ │ │ │ -export the type representing the components │ │ │ │ │ -Definition diagonalmatrix.hh:855 │ │ │ │ │ -Dune::DiagonalMatrix::beforeEnd │ │ │ │ │ -ConstIterator beforeEnd() const │ │ │ │ │ -Definition diagonalmatrix.hh:201 │ │ │ │ │ -Dune::DiagonalRowVectorConst::diagonal │ │ │ │ │ -const K & diagonal() const │ │ │ │ │ -the diagonal value │ │ │ │ │ -Definition diagonalmatrix.hh:812 │ │ │ │ │ +sllist.hh │ │ │ │ │ +Implements a singly linked list together with the necessary iterators. │ │ │ │ │ +stdstreams.hh │ │ │ │ │ +Standard Dune debug streams. │ │ │ │ │ +Dune::SLList::end │ │ │ │ │ +iterator end() │ │ │ │ │ +Get an iterator pointing to the end of the list. │ │ │ │ │ +Definition sllist.hh:774 │ │ │ │ │ +Dune::SLList<_RemoteIndex,_Allocator_>::const_iterator │ │ │ │ │ +SLListConstIterator< RemoteIndex, Allocator > const_iterator │ │ │ │ │ +The constant iterator of the list. │ │ │ │ │ +Definition sllist.hh:74 │ │ │ │ │ +Dune::SLList<_GlobalIndex,_Allocator_>::ModifyIterator │ │ │ │ │ +SLListModifyIterator< GlobalIndex, Allocator > ModifyIterator │ │ │ │ │ +The type of the iterator capable of deletion and insertion. │ │ │ │ │ +Definition sllist.hh:103 │ │ │ │ │ +Dune::SLList::begin │ │ │ │ │ +iterator begin() │ │ │ │ │ +Get an iterator pointing to the first element in the list. │ │ │ │ │ +Definition sllist.hh:762 │ │ │ │ │ +Dune::operator<< │ │ │ │ │ +std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x) │ │ │ │ │ +Definition bigunsignedint.hh:278 │ │ │ │ │ DUNE_THROW │ │ │ │ │ #define DUNE_THROW(E, m) │ │ │ │ │ Definition exceptions.hh:218 │ │ │ │ │ +Dune::ParallelIndexSet::begin │ │ │ │ │ +iterator begin() │ │ │ │ │ +Get an iterator over the indices positioned at the first index. │ │ │ │ │ +Dune::ParallelIndexSet::end │ │ │ │ │ +iterator end() │ │ │ │ │ +Get an iterator over the indices positioned after the last index. │ │ │ │ │ +Dune::ParallelIndexSet::LocalIndex │ │ │ │ │ +TL LocalIndex │ │ │ │ │ +The type of the local index, e.g. ParallelLocalIndex. │ │ │ │ │ +Definition indexset.hh:239 │ │ │ │ │ +Dune::IndexPair::global │ │ │ │ │ +const GlobalIndex & global() const │ │ │ │ │ +Get the global index. │ │ │ │ │ +Dune::IndexPair::local │ │ │ │ │ +LocalIndex & local() │ │ │ │ │ +Get the local index. │ │ │ │ │ +Dune::ParallelIndexSet::GlobalIndex │ │ │ │ │ +TG GlobalIndex │ │ │ │ │ +the type of the global index. This type has to provide at least a operator< for │ │ │ │ │ +sorting. │ │ │ │ │ +Definition indexset.hh:226 │ │ │ │ │ +Dune::GROUND │ │ │ │ │ +@ GROUND │ │ │ │ │ +The default mode. Indicates that the index set is ready to be used. │ │ │ │ │ +Definition indexset.hh:186 │ │ │ │ │ +Dune::dvverb │ │ │ │ │ +DVVerbType dvverb(std::cout) │ │ │ │ │ +stream for very verbose output. │ │ │ │ │ +Definition stdstreams.hh:95 │ │ │ │ │ +std │ │ │ │ │ +STL namespace. │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::conjugateComplex │ │ │ │ │ -K conjugateComplex(const K &x) │ │ │ │ │ -compute conjugate complex of x │ │ │ │ │ -Definition math.hh:164 │ │ │ │ │ -Dune::DenseMatrix │ │ │ │ │ -A dense n x m matrix. │ │ │ │ │ -Definition densematrix.hh:140 │ │ │ │ │ -Dune::DenseMatrix::M │ │ │ │ │ -constexpr size_type M() const │ │ │ │ │ -number of columns │ │ │ │ │ -Definition densematrix.hh:703 │ │ │ │ │ -Dune::DenseMatrix::N │ │ │ │ │ -constexpr size_type N() const │ │ │ │ │ -number of rows │ │ │ │ │ -Definition densematrix.hh:697 │ │ │ │ │ -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:95 │ │ │ │ │ -Dune::DenseMatrixAssigner │ │ │ │ │ -you have to specialize this structure for any type that should be assignable to │ │ │ │ │ -a DenseMatrix │ │ │ │ │ -Definition densematrix.hh:59 │ │ │ │ │ -Dune::FMatrixError │ │ │ │ │ -Error thrown if operations of a FieldMatrix fail. │ │ │ │ │ -Definition densematrix.hh:126 │ │ │ │ │ -Dune::DenseVector::two_norm2 │ │ │ │ │ -FieldTraits< value_type >::real_type two_norm2() const │ │ │ │ │ -square of two norm (sum over squared values of entries), need for block │ │ │ │ │ -recursion │ │ │ │ │ -Definition densevector.hh:650 │ │ │ │ │ -Dune::DenseVector::two_norm │ │ │ │ │ -FieldTraits< value_type >::real_type two_norm() const │ │ │ │ │ -two norm sqrt(sum over squared values of entries) │ │ │ │ │ -Definition densevector.hh:641 │ │ │ │ │ -Dune::DenseVector::begin │ │ │ │ │ -Iterator begin() │ │ │ │ │ -begin iterator │ │ │ │ │ -Definition densevector.hh:347 │ │ │ │ │ -Dune::DenseVector::infinity_norm │ │ │ │ │ -FieldTraits< vt >::real_type infinity_norm() const │ │ │ │ │ -infinity norm (maximum of absolute values of entries) │ │ │ │ │ -Definition densevector.hh:661 │ │ │ │ │ -Dune::DenseVector::infinity_norm_real │ │ │ │ │ -FieldTraits< vt >::real_type infinity_norm_real() const │ │ │ │ │ -simplified infinity norm (uses Manhattan norm for complex values) │ │ │ │ │ -Definition densevector.hh:677 │ │ │ │ │ -Dune::DiagonalRowVectorConst │ │ │ │ │ -Definition diagonalmatrix.hh:698 │ │ │ │ │ -Dune::DiagonalRowVector │ │ │ │ │ -Definition diagonalmatrix.hh:841 │ │ │ │ │ -Dune::DiagonalMatrixWrapper │ │ │ │ │ -Definition diagonalmatrix.hh:650 │ │ │ │ │ -Dune::ContainerWrapperIterator │ │ │ │ │ -Iterator class for sparse vector-like containers. │ │ │ │ │ -Definition diagonalmatrix.hh:998 │ │ │ │ │ -Dune::ContainerWrapperIterator::ContainerWrapperIterator │ │ │ │ │ -ContainerWrapperIterator(const MyConstType &other) │ │ │ │ │ -Definition diagonalmatrix.hh:1031 │ │ │ │ │ -Dune::ContainerWrapperIterator::equals │ │ │ │ │ -bool equals(const MyConstType &other) const │ │ │ │ │ -Definition diagonalmatrix.hh:1057 │ │ │ │ │ -Dune::DiagonalMatrix │ │ │ │ │ -A diagonal matrix of static size. │ │ │ │ │ -Definition diagonalmatrix.hh:53 │ │ │ │ │ -Dune::FieldTraits │ │ │ │ │ -Definition ftraits.hh:26 │ │ │ │ │ -Dune::FieldTraits::field_type │ │ │ │ │ -T field_type │ │ │ │ │ -export the type representing the field │ │ │ │ │ -Definition ftraits.hh:28 │ │ │ │ │ -Dune::FieldTraits::real_type │ │ │ │ │ -T real_type │ │ │ │ │ -export the type representing the real type of the field │ │ │ │ │ -Definition ftraits.hh:30 │ │ │ │ │ -Dune::const_reference │ │ │ │ │ -Get the 'const' version of a reference to a mutable object. │ │ │ │ │ -Definition genericiterator.hh:87 │ │ │ │ │ -Dune::mutable_reference │ │ │ │ │ -get the 'mutable' version of a reference to a const object │ │ │ │ │ -Definition genericiterator.hh:116 │ │ │ │ │ -Dune::BidirectionalIteratorFacade │ │ │ │ │ -Facade class for stl conformant bidirectional iterators. │ │ │ │ │ -Definition iteratorfacades.hh:274 │ │ │ │ │ +Dune::MPITraits │ │ │ │ │ +A traits class describing the mapping of types onto MPI_Datatypes. │ │ │ │ │ +Definition mpitraits.hh:41 │ │ │ │ │ +Dune::MPITraits::getType │ │ │ │ │ +static MPI_Datatype getType() │ │ │ │ │ +Definition mpitraits.hh:48 │ │ │ │ │ +Dune::RangeError │ │ │ │ │ +Default exception class for range errors. │ │ │ │ │ +Definition exceptions.hh:254 │ │ │ │ │ +Dune::IndexPair │ │ │ │ │ +A pair consisting of a global and local index. │ │ │ │ │ +Definition indexset.hh:85 │ │ │ │ │ +Dune::InvalidIndexSetState │ │ │ │ │ +Exception indicating that the index set is not in the expected state. │ │ │ │ │ +Definition indexset.hh:205 │ │ │ │ │ +Dune::ParallelIndexSet │ │ │ │ │ +Manager class for the mapping between local indices and globally unique │ │ │ │ │ +indices. │ │ │ │ │ +Definition indexset.hh:218 │ │ │ │ │ +Dune::IndicesSyncer │ │ │ │ │ +Class for recomputing missing indices of a distributed index set. │ │ │ │ │ +Definition indicessyncer.hh:41 │ │ │ │ │ +Dune::InterfaceBuilder │ │ │ │ │ +Base class of all classes representing a communication interface. │ │ │ │ │ +Definition parallel/interface.hh:35 │ │ │ │ │ +Dune::ParallelLocalIndex │ │ │ │ │ +An index present on the local process with an additional attribute flag. │ │ │ │ │ +Definition plocalindex.hh:49 │ │ │ │ │ +Dune::RemoteIndices │ │ │ │ │ +The indices present on remote processes. │ │ │ │ │ +Definition remoteindices.hh:189 │ │ │ │ │ +Dune::RemoteIndices::getNeighbours │ │ │ │ │ +const std::set< int > & getNeighbours() const │ │ │ │ │ +Definition remoteindices.hh:307 │ │ │ │ │ +Dune::RemoteIndices::RemoteIndex │ │ │ │ │ +Dune::RemoteIndex< GlobalIndex, Attribute > RemoteIndex │ │ │ │ │ +Type of the remote indices we manage. │ │ │ │ │ +Definition remoteindices.hh:231 │ │ │ │ │ +Dune::RemoteIndices::RemoteIndices │ │ │ │ │ +RemoteIndices() │ │ │ │ │ +Definition remoteindices.hh:977 │ │ │ │ │ +Dune::RemoteIndices::fillIndexSetHoles │ │ │ │ │ +friend void fillIndexSetHoles(const G &graph, Dune:: │ │ │ │ │ +OwnerOverlapCopyCommunication< T1, T2 > &oocomm) │ │ │ │ │ +Dune::RemoteIndices::setIndexSets │ │ │ │ │ +void setIndexSets(const ParallelIndexSet &source, const ParallelIndexSet │ │ │ │ │ +&destination, const MPI_Comm &comm, const std::vector< int > &neighbours=std:: │ │ │ │ │ +vector< int >()) │ │ │ │ │ +Set the index sets and communicator we work with. │ │ │ │ │ +Definition remoteindices.hh:984 │ │ │ │ │ +Dune::RemoteIndices::free │ │ │ │ │ +void free() │ │ │ │ │ +Free the index lists. │ │ │ │ │ +Definition remoteindices.hh:1429 │ │ │ │ │ +Dune::RemoteIndices::repairLocalIndexPointers │ │ │ │ │ +friend void repairLocalIndexPointers(std::map< int, SLList< std::pair< typename │ │ │ │ │ +T1::GlobalIndex, typename T1::LocalIndex::Attribute >, A2 > > &, RemoteIndices< │ │ │ │ │ +T1, A1 > &, const T1 &) │ │ │ │ │ +Dune::RemoteIndices::GlobalIndex │ │ │ │ │ +ParallelIndexSet::GlobalIndex GlobalIndex │ │ │ │ │ +The type of the global index. │ │ │ │ │ +Definition remoteindices.hh:215 │ │ │ │ │ +Dune::RemoteIndices::rebuild │ │ │ │ │ +void rebuild() │ │ │ │ │ +Rebuilds the set of remote indices. │ │ │ │ │ +Definition remoteindices.hh:1453 │ │ │ │ │ +Dune::RemoteIndices::ParallelIndexSet │ │ │ │ │ +T ParallelIndexSet │ │ │ │ │ +Type of the index set we use, e.g. ParallelLocalIndexSet. │ │ │ │ │ +Definition remoteindices.hh:206 │ │ │ │ │ +Dune::RemoteIndices::communicator │ │ │ │ │ +MPI_Comm communicator() const │ │ │ │ │ +Get the mpi communicator used. │ │ │ │ │ +Definition remoteindices.hh:1696 │ │ │ │ │ +Dune::RemoteIndices::Attribute │ │ │ │ │ +LocalIndex::Attribute Attribute │ │ │ │ │ +The type of the attribute. │ │ │ │ │ +Definition remoteindices.hh:226 │ │ │ │ │ +Dune::RemoteIndices::iterator │ │ │ │ │ +CollectiveIteratorT iterator() const │ │ │ │ │ +Get an iterator for colletively iterating over the remote indices of all remote │ │ │ │ │ +processes. │ │ │ │ │ +Definition remoteindices.hh:1690 │ │ │ │ │ +Dune::RemoteIndices::setIncludeSelf │ │ │ │ │ +void setIncludeSelf(bool includeSelf) │ │ │ │ │ +Tell whether sending from indices of the processor to other indices on the same │ │ │ │ │ +processor is enabled ... │ │ │ │ │ +Definition remoteindices.hh:971 │ │ │ │ │ +Dune::RemoteIndices::end │ │ │ │ │ +const_iterator end() const │ │ │ │ │ +Get an iterator over all remote index lists. │ │ │ │ │ +Definition remoteindices.hh:1529 │ │ │ │ │ +Dune::RemoteIndices::operator== │ │ │ │ │ +bool operator==(const RemoteIndices &ri) const │ │ │ │ │ +Definition remoteindices.hh:1536 │ │ │ │ │ +Dune::RemoteIndices::RemoteIndexMap │ │ │ │ │ +std::map< int, std::pair< RemoteIndexList *, RemoteIndexList * > > │ │ │ │ │ +RemoteIndexMap │ │ │ │ │ +The type of the map from rank to remote index list. │ │ │ │ │ +Definition remoteindices.hh:245 │ │ │ │ │ +Dune::RemoteIndices::setNeighbours │ │ │ │ │ +void setNeighbours(const C &neighbours) │ │ │ │ │ +Definition remoteindices.hh:300 │ │ │ │ │ +Dune::RemoteIndices::getModifier │ │ │ │ │ +RemoteIndexListModifier< T, A, mode > getModifier(int process) │ │ │ │ │ +Get a modifier for a remote index list. │ │ │ │ │ +Definition remoteindices.hh:1480 │ │ │ │ │ +Dune::RemoteIndices::sourceIndexSet │ │ │ │ │ +const ParallelIndexSet & sourceIndexSet() const │ │ │ │ │ +Get the index set at the source. │ │ │ │ │ +Definition remoteindices.hh:999 │ │ │ │ │ +Dune::RemoteIndices::~RemoteIndices │ │ │ │ │ +~RemoteIndices() │ │ │ │ │ +Destructor. │ │ │ │ │ +Definition remoteindices.hh:1014 │ │ │ │ │ +Dune::RemoteIndices::RemoteIndexList │ │ │ │ │ +Dune::SLList< RemoteIndex, Allocator > RemoteIndexList │ │ │ │ │ +The type of the remote index list. │ │ │ │ │ +Definition remoteindices.hh:241 │ │ │ │ │ +Dune::RemoteIndices::neighbours │ │ │ │ │ +int neighbours() const │ │ │ │ │ +Get the number of processors we share indices with. │ │ │ │ │ +Definition remoteindices.hh:1446 │ │ │ │ │ +Dune::RemoteIndices::CollectiveIteratorT │ │ │ │ │ +CollectiveIterator< T, A > CollectiveIteratorT │ │ │ │ │ +The type of the collective iterator over all remote indices. │ │ │ │ │ +Definition remoteindices.hh:210 │ │ │ │ │ +Dune::RemoteIndices::destinationIndexSet │ │ │ │ │ +const ParallelIndexSet & destinationIndexSet() const │ │ │ │ │ +Get the index set at destination. │ │ │ │ │ +Definition remoteindices.hh:1007 │ │ │ │ │ +Dune::RemoteIndices::Allocator │ │ │ │ │ +typename std::allocator_traits< A >::template rebind_alloc< RemoteIndex > │ │ │ │ │ +Allocator │ │ │ │ │ +The type of the allocator for the remote index list. │ │ │ │ │ +Definition remoteindices.hh:237 │ │ │ │ │ +Dune::RemoteIndices::find │ │ │ │ │ +const_iterator find(int proc) const │ │ │ │ │ +Find an iterator over the remote index lists of a specific process. │ │ │ │ │ +Definition remoteindices.hh:1515 │ │ │ │ │ +Dune::RemoteIndices::isSynced │ │ │ │ │ +bool isSynced() const │ │ │ │ │ +Checks whether the remote indices are synced with the indexsets. │ │ │ │ │ +Definition remoteindices.hh:1473 │ │ │ │ │ +Dune::RemoteIndices::begin │ │ │ │ │ +const_iterator begin() const │ │ │ │ │ +Get an iterator over all remote index lists. │ │ │ │ │ +Definition remoteindices.hh:1522 │ │ │ │ │ +Dune::RemoteIndices::LocalIndex │ │ │ │ │ +ParallelIndexSet::LocalIndex LocalIndex │ │ │ │ │ +The type of the local index. │ │ │ │ │ +Definition remoteindices.hh:221 │ │ │ │ │ +Dune::RemoteIndices::const_iterator │ │ │ │ │ +RemoteIndexMap::const_iterator const_iterator │ │ │ │ │ +Definition remoteindices.hh:247 │ │ │ │ │ +Dune::RemoteIndex │ │ │ │ │ +Information about an index residing on another processor. │ │ │ │ │ +Definition remoteindices.hh:73 │ │ │ │ │ +Dune::RemoteIndex::attribute │ │ │ │ │ +const Attribute attribute() const │ │ │ │ │ +Get the attribute of the index on the remote process. │ │ │ │ │ +Definition remoteindices.hh:946 │ │ │ │ │ +Dune::RemoteIndex::repairLocalIndexPointers │ │ │ │ │ +friend void repairLocalIndexPointers(std::map< int, SLList< std::pair< typename │ │ │ │ │ +T::GlobalIndex, typename T::LocalIndex::Attribute >, A > > &, RemoteIndices< T, │ │ │ │ │ +A1 > &, const T &) │ │ │ │ │ +Dune::RemoteIndex::operator== │ │ │ │ │ +bool operator==(const RemoteIndex &ri) const │ │ │ │ │ +Definition remoteindices.hh:934 │ │ │ │ │ +Dune::RemoteIndex::GlobalIndex │ │ │ │ │ +T1 GlobalIndex │ │ │ │ │ +the type of the global index. This type has to provide at least a operator< for │ │ │ │ │ +sorting. │ │ │ │ │ +Definition remoteindices.hh:90 │ │ │ │ │ +Dune::RemoteIndex::Attribute │ │ │ │ │ +T2 Attribute │ │ │ │ │ +The type of the attributes. Normally this will be an enumeration like. │ │ │ │ │ +Definition remoteindices.hh:99 │ │ │ │ │ +Dune::RemoteIndex::PairType │ │ │ │ │ +IndexPair< GlobalIndex, ParallelLocalIndex< Attribute > > PairType │ │ │ │ │ +The type of the index pair. │ │ │ │ │ +Definition remoteindices.hh:105 │ │ │ │ │ +Dune::RemoteIndex::localIndexPair │ │ │ │ │ +const PairType & localIndexPair() const │ │ │ │ │ +Get the corresponding local index pair. │ │ │ │ │ +Definition remoteindices.hh:952 │ │ │ │ │ +Dune::RemoteIndex::RemoteIndex │ │ │ │ │ +RemoteIndex() │ │ │ │ │ +Parameterless Constructor. │ │ │ │ │ +Definition remoteindices.hh:930 │ │ │ │ │ +Dune::RemoteIndex::operator!= │ │ │ │ │ +bool operator!=(const RemoteIndex &ri) const │ │ │ │ │ +Definition remoteindices.hh:940 │ │ │ │ │ +Dune::RemoteIndexListModifier │ │ │ │ │ +Modifier for adding and/or deleting remote indices from the remote index list. │ │ │ │ │ +Definition remoteindices.hh:551 │ │ │ │ │ +Dune::RemoteIndexListModifier::repairLocalIndexPointers │ │ │ │ │ +void repairLocalIndexPointers() │ │ │ │ │ +Repair the pointers to the local index pairs. │ │ │ │ │ +Definition remoteindices.hh:1575 │ │ │ │ │ +Dune::RemoteIndexListModifier::RemoteIndexList │ │ │ │ │ +Dune::SLList< RemoteIndex, Allocator > RemoteIndexList │ │ │ │ │ +The type of the remote index list. │ │ │ │ │ +Definition remoteindices.hh:602 │ │ │ │ │ +Dune::RemoteIndexListModifier::Allocator │ │ │ │ │ +A Allocator │ │ │ │ │ +The type of the allocator for the remote index list. │ │ │ │ │ +Definition remoteindices.hh:598 │ │ │ │ │ +Dune::RemoteIndexListModifier::insert │ │ │ │ │ +void insert(const RemoteIndex &index) │ │ │ │ │ +Insert an index to the list. │ │ │ │ │ +Definition remoteindices.hh:1605 │ │ │ │ │ +Dune::RemoteIndexListModifier::GlobalIndex │ │ │ │ │ +ParallelIndexSet::GlobalIndex GlobalIndex │ │ │ │ │ +The type of the global index. │ │ │ │ │ +Definition remoteindices.hh:578 │ │ │ │ │ +Dune::RemoteIndexListModifier::LocalIndex │ │ │ │ │ +ParallelIndexSet::LocalIndex LocalIndex │ │ │ │ │ +The type of the local index. │ │ │ │ │ +Definition remoteindices.hh:583 │ │ │ │ │ +Dune::RemoteIndexListModifier::ConstIterator │ │ │ │ │ +RemoteIndexList::const_iterator ConstIterator │ │ │ │ │ +The type of the remote index list iterator. │ │ │ │ │ +Definition remoteindices.hh:612 │ │ │ │ │ +Dune::RemoteIndexListModifier::ModifyIterator │ │ │ │ │ +SLListModifyIterator< RemoteIndex, Allocator > ModifyIterator │ │ │ │ │ +The type of the modifying iterator of the remote index list. │ │ │ │ │ +Definition remoteindices.hh:607 │ │ │ │ │ +Dune::RemoteIndexListModifier::remove │ │ │ │ │ +bool remove(const GlobalIndex &global) │ │ │ │ │ +Remove a remote index. │ │ │ │ │ +Definition remoteindices.hh:1653 │ │ │ │ │ +Dune::RemoteIndexListModifier::ParallelIndexSet │ │ │ │ │ +T ParallelIndexSet │ │ │ │ │ +Type of the index set we use. │ │ │ │ │ +Definition remoteindices.hh:573 │ │ │ │ │ +Dune::RemoteIndexListModifier::RemoteIndexListModifier │ │ │ │ │ +RemoteIndexListModifier() │ │ │ │ │ +Default constructor. │ │ │ │ │ +Definition remoteindices.hh:676 │ │ │ │ │ +Dune::RemoteIndexListModifier::Attribute │ │ │ │ │ +LocalIndex::Attribute Attribute │ │ │ │ │ +The type of the attribute. │ │ │ │ │ +Definition remoteindices.hh:588 │ │ │ │ │ +Dune::RemoteIndexListModifier::RemoteIndex │ │ │ │ │ +Dune::RemoteIndex< GlobalIndex, Attribute > RemoteIndex │ │ │ │ │ +Type of the remote indices we manage. │ │ │ │ │ +Definition remoteindices.hh:593 │ │ │ │ │ +Dune::RemoteIndexListModifier::MODIFYINDEXSET │ │ │ │ │ +static constexpr bool MODIFYINDEXSET │ │ │ │ │ +If true the index set corresponding to the remote indices might get modified. │ │ │ │ │ +Definition remoteindices.hh:568 │ │ │ │ │ +Dune::CollectiveIterator │ │ │ │ │ +A collective iterator for moving over the remote indices for all processes │ │ │ │ │ +collectively. │ │ │ │ │ +Definition remoteindices.hh:708 │ │ │ │ │ +Dune::CollectiveIterator::operator++ │ │ │ │ │ +CollectiveIterator & operator++() │ │ │ │ │ +Definition remoteindices.hh:1779 │ │ │ │ │ +Dune::CollectiveIterator::end │ │ │ │ │ +iterator end() │ │ │ │ │ +Definition remoteindices.hh:1822 │ │ │ │ │ +Dune::CollectiveIterator::CollectiveIterator │ │ │ │ │ +CollectiveIterator(const RemoteIndexMap &map_, bool send) │ │ │ │ │ +Constructor. │ │ │ │ │ +Definition remoteindices.hh:1703 │ │ │ │ │ +Dune::CollectiveIterator::empty │ │ │ │ │ +bool empty() const │ │ │ │ │ +Checks whether there are still iterators in the map. │ │ │ │ │ +Definition remoteindices.hh:1804 │ │ │ │ │ +Dune::CollectiveIterator::advance │ │ │ │ │ +void advance(const GlobalIndex &global) │ │ │ │ │ +Advances all underlying iterators. │ │ │ │ │ +Definition remoteindices.hh:1716 │ │ │ │ │ +Dune::CollectiveIterator::RemoteIndexMap │ │ │ │ │ +std::map< int, std::pair< RemoteIndexList *, RemoteIndexList * > > │ │ │ │ │ +RemoteIndexMap │ │ │ │ │ +The type of the map from rank to remote index list. │ │ │ │ │ +Definition remoteindices.hh:748 │ │ │ │ │ +Dune::CollectiveIterator::begin │ │ │ │ │ +iterator begin() │ │ │ │ │ +Definition remoteindices.hh:1811 │ │ │ │ │ +Dune::OwnerOverlapCopyCommunication │ │ │ │ │ +Definition remoteindices.hh:167 │ │ │ │ │ +Dune::RemoteIndexListModifier::InvalidPosition │ │ │ │ │ +Definition remoteindices.hh:558 │ │ │ │ │ +Dune::CollectiveIterator::iterator │ │ │ │ │ +Iterator over the valid underlying iterators. │ │ │ │ │ +Definition remoteindices.hh:792 │ │ │ │ │ +Dune::CollectiveIterator::iterator::iterator │ │ │ │ │ +iterator(const RealIterator &iter, const ConstRealIterator &end, GlobalIndex │ │ │ │ │ +&index) │ │ │ │ │ +Definition remoteindices.hh:799 │ │ │ │ │ +Dune::CollectiveIterator::iterator::iterator │ │ │ │ │ +iterator(const iterator &other) │ │ │ │ │ +Definition remoteindices.hh:817 │ │ │ │ │ +Dune::CollectiveIterator::iterator::operator* │ │ │ │ │ +const RemoteIndex & operator*() const │ │ │ │ │ +Definition remoteindices.hh:838 │ │ │ │ │ +Dune::CollectiveIterator::iterator::ConstRealIterator │ │ │ │ │ +Map::iterator ConstRealIterator │ │ │ │ │ +Definition remoteindices.hh:795 │ │ │ │ │ +Dune::CollectiveIterator::iterator::operator++ │ │ │ │ │ +iterator & operator++() │ │ │ │ │ +Definition remoteindices.hh:822 │ │ │ │ │ +Dune::CollectiveIterator::iterator::operator-> │ │ │ │ │ +const RemoteIndex * operator->() const │ │ │ │ │ +Definition remoteindices.hh:850 │ │ │ │ │ +Dune::CollectiveIterator::iterator::operator== │ │ │ │ │ +bool operator==(const iterator &other) const │ │ │ │ │ +Definition remoteindices.hh:856 │ │ │ │ │ +Dune::CollectiveIterator::iterator::process │ │ │ │ │ +int process() const │ │ │ │ │ +Definition remoteindices.hh:844 │ │ │ │ │ +Dune::CollectiveIterator::iterator::iterator │ │ │ │ │ +iterator(const RealIterator &iter, const ConstRealIterator &end, GlobalIndex │ │ │ │ │ +index, Attribute attribute) │ │ │ │ │ +Definition remoteindices.hh:807 │ │ │ │ │ +Dune::CollectiveIterator::iterator::operator!= │ │ │ │ │ +bool operator!=(const iterator &other) const │ │ │ │ │ +Definition remoteindices.hh:862 │ │ │ │ │ +Dune::CollectiveIterator::iterator::RealIterator │ │ │ │ │ +Map::iterator RealIterator │ │ │ │ │ +Definition remoteindices.hh:794 │ │ │ │ │ +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 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00035.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: matvectraits.hh File Reference │ │ │ │ +dune-common: future.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,43 +65,49 @@ │ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ Namespaces
│ │ │ │ -
matvectraits.hh File Reference
│ │ │ │ +
future.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ - │ │ │ │ -

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

│ │ │ │ - │ │ │ │ +
#include <memory>
│ │ │ │ +#include <dune/common/exceptions.hh>
│ │ │ │ +
│ │ │ │

Go to the source code of this file.

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

│ │ │ │ Classes

struct  Dune::DenseMatVecTraits< T >
class  Dune::InvalidFutureException
 This exception is thrown when ready(), wait() or get() is called on an invalid future. A future is valid until get() is called and if it is not default-constructed and it was not moved from. More...
 
class  Dune::Future< T >
 Type-erasure for future-like objects. A future-like object is a object satisfying the interface of FutureBase. More...
 
class  Dune::PseudoFuture< T >
 A wrapper-class for a object which is ready immediately. More...
 
class  Dune::PseudoFuture< void >
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ -

Detailed Description

│ │ │ │ -

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

│ │ │ │ -
│ │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,25 +6,35 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ + * parallel │ │ │ │ │ Classes | Namespaces │ │ │ │ │ -matvectraits.hh File Reference │ │ │ │ │ -Documentation of the traits classes you need to write for each implementation │ │ │ │ │ -of DenseVector or DenseMatrix. More... │ │ │ │ │ +future.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -struct  Dune::DenseMatVecTraits<_T_> │ │ │ │ │ +class  Dune::InvalidFutureException │ │ │ │ │ + This exception is thrown when ready(), wait() or get() is called on an │ │ │ │ │ +  invalid future. A future is valid until get() is called and if it is │ │ │ │ │ + not default-constructed and it was not moved from. More... │ │ │ │ │ +  │ │ │ │ │ +class  Dune::Future<_T_> │ │ │ │ │ +  Type-erasure for future-like objects. A future-like object is a object │ │ │ │ │ + satisfying the interface of FutureBase. More... │ │ │ │ │ +  │ │ │ │ │ +class  Dune::PseudoFuture<_T_> │ │ │ │ │ +  A wrapper-class for a object which is ready immediately. More... │ │ │ │ │ +  │ │ │ │ │ +class  Dune::PseudoFuture<_void_> │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -Documentation of the traits classes you need to write for each implementation │ │ │ │ │ -of DenseVector or DenseMatrix. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00035_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: matvectraits.hh Source File │ │ │ │ +dune-common: future.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,41 +70,254 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
matvectraits.hh
│ │ │ │ +
future.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 (C) 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_PARALLEL_FUTURE_HH
│ │ │ │ +
6#define DUNE_COMMON_PARALLEL_FUTURE_HH
│ │ │ │
7
│ │ │ │ -
12namespace Dune {
│ │ │ │ -
13
│ │ │ │ -
22
│ │ │ │ -
24
│ │ │ │ -
26
│ │ │ │ -
30 template<class T>
│ │ │ │ - │ │ │ │ -
32
│ │ │ │ -
33} // end namespace Dune
│ │ │ │ -
34
│ │ │ │ -
35#endif // DUNE_FTRAITS_HH
│ │ │ │ +
8#include <memory>
│ │ │ │ + │ │ │ │ +
10
│ │ │ │ +
11namespace Dune{
│ │ │ │ +
12
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
18 {};
│ │ │ │ +
│ │ │ │ +
19
│ │ │ │ +
20 // forward declaration
│ │ │ │ +
21 template<class T>
│ │ │ │ +
22 class PseudoFuture;
│ │ │ │ +
23
│ │ │ │ +
27 template<class T>
│ │ │ │ +
│ │ │ │ +
28 class Future{
│ │ │ │ +
29 // Future interface:
│ │ │ │ +
30 class FutureBase{
│ │ │ │ +
31 public:
│ │ │ │ +
32 virtual ~FutureBase() = default;
│ │ │ │ +
33 virtual void wait() = 0;
│ │ │ │ +
34 virtual bool ready() const = 0;
│ │ │ │ +
35 virtual bool valid() const = 0;
│ │ │ │ +
36 virtual T get() = 0;
│ │ │ │ +
37 };
│ │ │ │ +
38
│ │ │ │ +
39 // model class
│ │ │ │ +
40 template<class F>
│ │ │ │ +
41 class FutureModel
│ │ │ │ +
42 : public FutureBase
│ │ │ │ +
43 {
│ │ │ │ +
44 F _future;
│ │ │ │ +
45 public:
│ │ │ │ +
46 FutureModel(F&& f)
│ │ │ │ +
47 : _future(std::forward<F>(f))
│ │ │ │ +
48 {}
│ │ │ │ +
49
│ │ │ │ +
50 virtual void wait() override
│ │ │ │ +
51 {
│ │ │ │ +
52 _future.wait();
│ │ │ │ +
53 }
│ │ │ │ +
54
│ │ │ │ +
55 virtual bool ready() const override
│ │ │ │ +
56 {
│ │ │ │ +
57 return _future.ready();
│ │ │ │ +
58 }
│ │ │ │ +
59
│ │ │ │ +
60 virtual bool valid() const override
│ │ │ │ +
61 {
│ │ │ │ +
62 return _future.valid();
│ │ │ │ +
63 }
│ │ │ │ +
64
│ │ │ │ +
65 virtual T get() override{
│ │ │ │ +
66 return (T)_future.get();
│ │ │ │ +
67 }
│ │ │ │ +
68 };
│ │ │ │ +
69
│ │ │ │ +
70 std::unique_ptr<FutureBase> _future;
│ │ │ │ +
71 public:
│ │ │ │ +
72 template<class F>
│ │ │ │ +
│ │ │ │ +
73 Future(F&& f)
│ │ │ │ +
74 : _future(std::make_unique<FutureModel<F>>(std::forward<F>(f)))
│ │ │ │ +
75 {}
│ │ │ │ +
│ │ │ │ +
76
│ │ │ │ +
77 template<class U, std::enable_if_t<std::is_same<U,T>::value && !std::is_same<T,void>::value>>
│ │ │ │ +
│ │ │ │ +
78 Future(U&& data)
│ │ │ │ +
79 : _future(std::make_unique<FutureModel<PseudoFuture<T>>>(PseudoFuture<T>(std::forward<U>(data))))
│ │ │ │ +
80 {}
│ │ │ │ +
│ │ │ │ +
81
│ │ │ │ +
82 Future() = default;
│ │ │ │ +
83
│ │ │ │ +
│ │ │ │ +
87 void wait(){
│ │ │ │ +
88 _future->wait();
│ │ │ │ +
89 }
│ │ │ │ +
│ │ │ │ +
90
│ │ │ │ +
│ │ │ │ +
95 T get() {
│ │ │ │ +
96 return _future->get();
│ │ │ │ +
97 }
│ │ │ │ +
│ │ │ │ +
98
│ │ │ │ +
│ │ │ │ +
103 bool ready() const {
│ │ │ │ +
104 return _future->ready();
│ │ │ │ +
105 }
│ │ │ │ +
│ │ │ │ +
106
│ │ │ │ +
│ │ │ │ +
112 bool valid() const {
│ │ │ │ +
113 if(_future)
│ │ │ │ +
114 return _future->valid();
│ │ │ │ +
115 return false;
│ │ │ │ +
116 }
│ │ │ │ +
│ │ │ │ +
117 };
│ │ │ │ +
│ │ │ │ +
118
│ │ │ │ +
121 template<class T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
123 bool valid_;
│ │ │ │ +
124 T data_;
│ │ │ │ +
125 public:
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
127 valid_(false)
│ │ │ │ +
128 {}
│ │ │ │ +
│ │ │ │ +
129
│ │ │ │ +
130 template<class U>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
132 valid_(true),
│ │ │ │ +
133 data_(std::forward<U>(u))
│ │ │ │ +
134 {}
│ │ │ │ +
│ │ │ │ +
135
│ │ │ │ +
│ │ │ │ +
136 void wait() {
│ │ │ │ +
137 if(!valid_)
│ │ │ │ +
138 DUNE_THROW(InvalidFutureException, "The PseudoFuture is not valid");
│ │ │ │ +
139 }
│ │ │ │ +
│ │ │ │ +
140
│ │ │ │ +
│ │ │ │ +
141 bool ready() const {
│ │ │ │ +
142 if(!valid_)
│ │ │ │ +
143 DUNE_THROW(InvalidFutureException, "The PseudoFuture is not valid");
│ │ │ │ +
144 return true;
│ │ │ │ +
145 }
│ │ │ │ +
│ │ │ │ +
146
│ │ │ │ +
│ │ │ │ +
147 T get() {
│ │ │ │ +
148 if(!valid_)
│ │ │ │ +
149 DUNE_THROW(InvalidFutureException, "The PseudoFuture is not valid");
│ │ │ │ +
150 valid_ = false;
│ │ │ │ +
151 return std::forward<T>(data_);
│ │ │ │ +
152 }
│ │ │ │ +
│ │ │ │ +
153
│ │ │ │ +
│ │ │ │ +
154 bool valid() const {
│ │ │ │ +
155 return valid_;
│ │ │ │ +
156 }
│ │ │ │ +
│ │ │ │ +
157 };
│ │ │ │ +
│ │ │ │ +
158
│ │ │ │ +
159 template<>
│ │ │ │ +
│ │ │ │ +
160 class PseudoFuture<void>{
│ │ │ │ +
161 bool valid_;
│ │ │ │ +
162 public:
│ │ │ │ +
│ │ │ │ +
163 PseudoFuture(bool valid = false) :
│ │ │ │ +
164 valid_(valid)
│ │ │ │ +
165 {}
│ │ │ │ +
│ │ │ │ +
166
│ │ │ │ +
│ │ │ │ +
167 void wait(){
│ │ │ │ +
168 if(!valid_)
│ │ │ │ +
169 DUNE_THROW(InvalidFutureException, "The PseudoFuture is not valid");
│ │ │ │ +
170 }
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
171 bool ready() const{
│ │ │ │ +
172 if(!valid_)
│ │ │ │ +
173 DUNE_THROW(InvalidFutureException, "The PseudoFuture is not valid");
│ │ │ │ +
174 return true;
│ │ │ │ +
175 }
│ │ │ │ +
│ │ │ │ +
176
│ │ │ │ +
│ │ │ │ +
177 void get(){
│ │ │ │ +
178 if(!valid_)
│ │ │ │ +
179 DUNE_THROW(InvalidFutureException, "The PseudoFuture is not valid");
│ │ │ │ +
180 valid_ = false;
│ │ │ │ +
181 }
│ │ │ │ +
│ │ │ │ +
182
│ │ │ │ +
│ │ │ │ +
183 bool valid() const{
│ │ │ │ +
184 return valid_;
│ │ │ │ +
185 }
│ │ │ │ +
│ │ │ │ +
186 };
│ │ │ │ +
│ │ │ │ +
187}
│ │ │ │ +
188
│ │ │ │ +
189#endif
│ │ │ │ +
A few common exception classes.
│ │ │ │ +
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
│ │ │ │ +
STL namespace.
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
Definition matvectraits.hh:31
│ │ │ │ +
Reference get(const RAPropertyMapHelper< Reference, PropertyMap > &pmap, const Key &key)
Definition propertymap.hh:84
│ │ │ │ +
Default exception if a function was called while the object is not in a valid state for that function...
Definition exceptions.hh:281
│ │ │ │ +
This exception is thrown when ready(), wait() or get() is called on an invalid future....
Definition future.hh:18
│ │ │ │ +
A wrapper-class for a object which is ready immediately.
Definition future.hh:122
│ │ │ │ +
bool ready() const
Definition future.hh:141
│ │ │ │ +
T get()
Definition future.hh:147
│ │ │ │ +
PseudoFuture(U &&u)
Definition future.hh:131
│ │ │ │ +
PseudoFuture()
Definition future.hh:126
│ │ │ │ +
void wait()
Definition future.hh:136
│ │ │ │ +
bool valid() const
Definition future.hh:154
│ │ │ │ +
Type-erasure for future-like objects. A future-like object is a object satisfying the interface of Fu...
Definition future.hh:28
│ │ │ │ +
bool ready() const
Definition future.hh:103
│ │ │ │ +
void wait()
wait until the future is ready
Definition future.hh:87
│ │ │ │ +
Future(U &&data)
Definition future.hh:78
│ │ │ │ +
T get()
Waits until the future is ready and returns the resulting value.
Definition future.hh:95
│ │ │ │ +
Future()=default
│ │ │ │ +
bool valid() const
Checks whether the future is valid. I.e. ‘get()’ was not called on that future and when it was not de...
Definition future.hh:112
│ │ │ │ +
Future(F &&f)
Definition future.hh:73
│ │ │ │ +
bool ready() const
Definition future.hh:171
│ │ │ │ +
bool valid() const
Definition future.hh:183
│ │ │ │ +
void get()
Definition future.hh:177
│ │ │ │ +
PseudoFuture(bool valid=false)
Definition future.hh:163
│ │ │ │ +
void wait()
Definition future.hh:167
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── encoding │ │ │ │ │ @@ -1 +1 @@ │ │ │ │ │ -us-ascii │ │ │ │ │ +utf-8 │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,36 +7,266 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -matvectraits.hh │ │ │ │ │ + * parallel │ │ │ │ │ +future.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 (C) 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_PARALLEL_FUTURE_HH │ │ │ │ │ + 6#define DUNE_COMMON_PARALLEL_FUTURE_HH │ │ │ │ │ 7 │ │ │ │ │ - 12namespace Dune { │ │ │ │ │ - 13 │ │ │ │ │ - 22 │ │ │ │ │ - 24 │ │ │ │ │ - 26 │ │ │ │ │ - 30 template │ │ │ │ │ -31 struct DenseMatVecTraits {}; │ │ │ │ │ - 32 │ │ │ │ │ - 33} // end namespace Dune │ │ │ │ │ - 34 │ │ │ │ │ - 35#endif // DUNE_FTRAITS_HH │ │ │ │ │ + 8#include │ │ │ │ │ + 9#include │ │ │ │ │ + 10 │ │ │ │ │ + 11namespace Dune{ │ │ │ │ │ + 12 │ │ │ │ │ +17 class InvalidFutureException : public InvalidStateException │ │ │ │ │ + 18 {}; │ │ │ │ │ + 19 │ │ │ │ │ + 20 // forward declaration │ │ │ │ │ + 21 template │ │ │ │ │ + 22 class PseudoFuture; │ │ │ │ │ + 23 │ │ │ │ │ + 27 template │ │ │ │ │ +28 class Future{ │ │ │ │ │ + 29 // Future interface: │ │ │ │ │ + 30 class FutureBase{ │ │ │ │ │ + 31 public: │ │ │ │ │ + 32 virtual ~FutureBase() = default; │ │ │ │ │ + 33 virtual void wait() = 0; │ │ │ │ │ + 34 virtual bool ready() const = 0; │ │ │ │ │ + 35 virtual bool valid() const = 0; │ │ │ │ │ + 36 virtual T get() = 0; │ │ │ │ │ + 37 }; │ │ │ │ │ + 38 │ │ │ │ │ + 39 // model class │ │ │ │ │ + 40 template │ │ │ │ │ + 41 class FutureModel │ │ │ │ │ + 42 : public FutureBase │ │ │ │ │ + 43 { │ │ │ │ │ + 44 F _future; │ │ │ │ │ + 45 public: │ │ │ │ │ + 46 FutureModel(F&& f) │ │ │ │ │ + 47 : _future(std::forward(f)) │ │ │ │ │ + 48 {} │ │ │ │ │ + 49 │ │ │ │ │ + 50 virtual void wait() override │ │ │ │ │ + 51 { │ │ │ │ │ + 52 _future.wait(); │ │ │ │ │ + 53 } │ │ │ │ │ + 54 │ │ │ │ │ + 55 virtual bool ready() const override │ │ │ │ │ + 56 { │ │ │ │ │ + 57 return _future.ready(); │ │ │ │ │ + 58 } │ │ │ │ │ + 59 │ │ │ │ │ + 60 virtual bool valid() const override │ │ │ │ │ + 61 { │ │ │ │ │ + 62 return _future.valid(); │ │ │ │ │ + 63 } │ │ │ │ │ + 64 │ │ │ │ │ + 65 virtual T get() override{ │ │ │ │ │ + 66 return (T)_future.get(); │ │ │ │ │ + 67 } │ │ │ │ │ + 68 }; │ │ │ │ │ + 69 │ │ │ │ │ + 70 std::unique_ptr _future; │ │ │ │ │ + 71 public: │ │ │ │ │ + 72 template │ │ │ │ │ +73 Future(F&& f) │ │ │ │ │ + 74 : _future(std::make_unique>(std::forward(f))) │ │ │ │ │ + 75 {} │ │ │ │ │ + 76 │ │ │ │ │ + 77 template::value && !std:: │ │ │ │ │ +is_same::value>> │ │ │ │ │ +78 Future(U&& data) │ │ │ │ │ + 79 : _future(std::make_unique>>(PseudoFuture │ │ │ │ │ +(std::forward(data)))) │ │ │ │ │ + 80 {} │ │ │ │ │ + 81 │ │ │ │ │ +82 Future() = default; │ │ │ │ │ + 83 │ │ │ │ │ +87 void wait(){ │ │ │ │ │ + 88 _future->wait(); │ │ │ │ │ + 89 } │ │ │ │ │ + 90 │ │ │ │ │ +95 T get() { │ │ │ │ │ + 96 return _future->get(); │ │ │ │ │ + 97 } │ │ │ │ │ + 98 │ │ │ │ │ +103 bool ready() const { │ │ │ │ │ + 104 return _future->ready(); │ │ │ │ │ + 105 } │ │ │ │ │ + 106 │ │ │ │ │ +112 bool valid() const { │ │ │ │ │ + 113 if(_future) │ │ │ │ │ + 114 return _future->valid(); │ │ │ │ │ + 115 return false; │ │ │ │ │ + 116 } │ │ │ │ │ + 117 }; │ │ │ │ │ + 118 │ │ │ │ │ + 121 template │ │ │ │ │ +122 class PseudoFuture{ │ │ │ │ │ + 123 bool valid_; │ │ │ │ │ + 124 T data_; │ │ │ │ │ + 125 public: │ │ │ │ │ +126 PseudoFuture() : │ │ │ │ │ + 127 valid_(false) │ │ │ │ │ + 128 {} │ │ │ │ │ + 129 │ │ │ │ │ + 130 template │ │ │ │ │ +131 PseudoFuture(U&& u) : │ │ │ │ │ + 132 valid_(true), │ │ │ │ │ + 133 data_(std::forward(u)) │ │ │ │ │ + 134 {} │ │ │ │ │ + 135 │ │ │ │ │ +136 void wait() { │ │ │ │ │ + 137 if(!valid_) │ │ │ │ │ + 138 DUNE_THROW(InvalidFutureException, "The PseudoFuture is not valid"); │ │ │ │ │ + 139 } │ │ │ │ │ + 140 │ │ │ │ │ +141 bool ready() const { │ │ │ │ │ + 142 if(!valid_) │ │ │ │ │ + 143 DUNE_THROW(InvalidFutureException, "The PseudoFuture is not valid"); │ │ │ │ │ + 144 return true; │ │ │ │ │ + 145 } │ │ │ │ │ + 146 │ │ │ │ │ +147 T get() { │ │ │ │ │ + 148 if(!valid_) │ │ │ │ │ + 149 DUNE_THROW(InvalidFutureException, "The PseudoFuture is not valid"); │ │ │ │ │ + 150 valid_ = false; │ │ │ │ │ + 151 return std::forward(data_); │ │ │ │ │ + 152 } │ │ │ │ │ + 153 │ │ │ │ │ +154 bool valid() const { │ │ │ │ │ + 155 return valid_; │ │ │ │ │ + 156 } │ │ │ │ │ + 157 }; │ │ │ │ │ + 158 │ │ │ │ │ + 159 template<> │ │ │ │ │ +160 class PseudoFuture{ │ │ │ │ │ + 161 bool valid_; │ │ │ │ │ + 162 public: │ │ │ │ │ +163 PseudoFuture(bool valid = false) : │ │ │ │ │ + 164 valid_(valid) │ │ │ │ │ + 165 {} │ │ │ │ │ + 166 │ │ │ │ │ +167 void wait(){ │ │ │ │ │ + 168 if(!valid_) │ │ │ │ │ + 169 DUNE_THROW(InvalidFutureException, "The PseudoFuture is not valid"); │ │ │ │ │ + 170 } │ │ │ │ │ +171 bool ready() const{ │ │ │ │ │ + 172 if(!valid_) │ │ │ │ │ + 173 DUNE_THROW(InvalidFutureException, "The PseudoFuture is not valid"); │ │ │ │ │ + 174 return true; │ │ │ │ │ + 175 } │ │ │ │ │ + 176 │ │ │ │ │ +177 void get(){ │ │ │ │ │ + 178 if(!valid_) │ │ │ │ │ + 179 DUNE_THROW(InvalidFutureException, "The PseudoFuture is not valid"); │ │ │ │ │ + 180 valid_ = false; │ │ │ │ │ + 181 } │ │ │ │ │ + 182 │ │ │ │ │ +183 bool valid() const{ │ │ │ │ │ + 184 return valid_; │ │ │ │ │ + 185 } │ │ │ │ │ + 186 }; │ │ │ │ │ + 187} │ │ │ │ │ + 188 │ │ │ │ │ + 189#endif │ │ │ │ │ +exceptions.hh │ │ │ │ │ +A few common exception classes. │ │ │ │ │ +DUNE_THROW │ │ │ │ │ +#define DUNE_THROW(E, m) │ │ │ │ │ +Definition exceptions.hh:218 │ │ │ │ │ +std │ │ │ │ │ +STL namespace. │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::DenseMatVecTraits │ │ │ │ │ -Definition matvectraits.hh:31 │ │ │ │ │ +Dune::get │ │ │ │ │ +Reference get(const RAPropertyMapHelper< Reference, PropertyMap > &pmap, const │ │ │ │ │ +Key &key) │ │ │ │ │ +Definition propertymap.hh:84 │ │ │ │ │ +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::InvalidFutureException │ │ │ │ │ +This exception is thrown when ready(), wait() or get() is called on an invalid │ │ │ │ │ +future.... │ │ │ │ │ +Definition future.hh:18 │ │ │ │ │ +Dune::PseudoFuture │ │ │ │ │ +A wrapper-class for a object which is ready immediately. │ │ │ │ │ +Definition future.hh:122 │ │ │ │ │ +Dune::PseudoFuture::ready │ │ │ │ │ +bool ready() const │ │ │ │ │ +Definition future.hh:141 │ │ │ │ │ +Dune::PseudoFuture::get │ │ │ │ │ +T get() │ │ │ │ │ +Definition future.hh:147 │ │ │ │ │ +Dune::PseudoFuture::PseudoFuture │ │ │ │ │ +PseudoFuture(U &&u) │ │ │ │ │ +Definition future.hh:131 │ │ │ │ │ +Dune::PseudoFuture::PseudoFuture │ │ │ │ │ +PseudoFuture() │ │ │ │ │ +Definition future.hh:126 │ │ │ │ │ +Dune::PseudoFuture::wait │ │ │ │ │ +void wait() │ │ │ │ │ +Definition future.hh:136 │ │ │ │ │ +Dune::PseudoFuture::valid │ │ │ │ │ +bool valid() const │ │ │ │ │ +Definition future.hh:154 │ │ │ │ │ +Dune::Future │ │ │ │ │ +Type-erasure for future-like objects. A future-like object is a object │ │ │ │ │ +satisfying the interface of Fu... │ │ │ │ │ +Definition future.hh:28 │ │ │ │ │ +Dune::Future::ready │ │ │ │ │ +bool ready() const │ │ │ │ │ +Definition future.hh:103 │ │ │ │ │ +Dune::Future::wait │ │ │ │ │ +void wait() │ │ │ │ │ +wait until the future is ready │ │ │ │ │ +Definition future.hh:87 │ │ │ │ │ +Dune::Future::Future │ │ │ │ │ +Future(U &&data) │ │ │ │ │ +Definition future.hh:78 │ │ │ │ │ +Dune::Future::get │ │ │ │ │ +T get() │ │ │ │ │ +Waits until the future is ready and returns the resulting value. │ │ │ │ │ +Definition future.hh:95 │ │ │ │ │ +Dune::Future::Future │ │ │ │ │ +Future()=default │ │ │ │ │ +Dune::Future::valid │ │ │ │ │ +bool valid() const │ │ │ │ │ +Checks whether the future is valid. I.e. ‘get()’ was not called on that future │ │ │ │ │ +and when it was not de... │ │ │ │ │ +Definition future.hh:112 │ │ │ │ │ +Dune::Future::Future │ │ │ │ │ +Future(F &&f) │ │ │ │ │ +Definition future.hh:73 │ │ │ │ │ +Dune::PseudoFuture<_void_>::ready │ │ │ │ │ +bool ready() const │ │ │ │ │ +Definition future.hh:171 │ │ │ │ │ +Dune::PseudoFuture<_void_>::valid │ │ │ │ │ +bool valid() const │ │ │ │ │ +Definition future.hh:183 │ │ │ │ │ +Dune::PseudoFuture<_void_>::get │ │ │ │ │ +void get() │ │ │ │ │ +Definition future.hh:177 │ │ │ │ │ +Dune::PseudoFuture<_void_>::PseudoFuture │ │ │ │ │ +PseudoFuture(bool valid=false) │ │ │ │ │ +Definition future.hh:163 │ │ │ │ │ +Dune::PseudoFuture<_void_>::wait │ │ │ │ │ +void wait() │ │ │ │ │ +Definition future.hh:167 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00038.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: float_cmp.cc File Reference │ │ │ │ +dune-common: mpiguard.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,125 +65,52 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces | │ │ │ │ -Functions
│ │ │ │ -
float_cmp.cc File Reference
│ │ │ │ +Namespaces
│ │ │ │ +
mpiguard.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ -
#include "float_cmp.hh"
│ │ │ │ -#include <vector>
│ │ │ │ -#include <limits>
│ │ │ │ -#include <algorithm>
│ │ │ │ -#include <cstdlib>
│ │ │ │ -#include <dune/common/fvector.hh>
│ │ │ │ + │ │ │ │ +

Implements a MPIGuard which detects an error on a remote process. │ │ │ │ +More...

│ │ │ │ +
#include "mpihelper.hh"
│ │ │ │ +#include "communication.hh"
│ │ │ │ +#include "mpicommunication.hh"
│ │ │ │ +#include <dune/common/exceptions.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

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

│ │ │ │ Classes

struct  Dune::FloatCmp::EpsilonType< T >
 Mapping of value type to epsilon type. More...
 
struct  Dune::FloatCmp::EpsilonType< std::vector< T, A > >
 Specialization of EpsilonType for std::vector. More...
 
struct  Dune::FloatCmp::EpsilonType< FieldVector< T, n > >
 Specialization of EpsilonType for Dune::FieldVector. More...
 
struct  Dune::FloatCmp::DefaultEpsilon< T, relativeWeak >
class  Dune::MPIGuardError
 This exception is thrown if the MPIGuard detects an error on a remote process. More...
 
struct  Dune::FloatCmp::DefaultEpsilon< T, relativeStrong >
 
struct  Dune::FloatCmp::DefaultEpsilon< T, absolute >
class  Dune::MPIGuard
 detects a thrown exception and communicates to all other processes More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::FloatCmp
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │

│ │ │ │ -Functions

template<class T , CmpStyle style>
bool Dune::FloatCmp::eq (const T &first, const T &second, typename EpsilonType< T >::Type epsilon=DefaultEpsilon< T, style >::value())
 test for equality using epsilon
 
template<class T , CmpStyle style>
bool Dune::FloatCmp::ne (const T &first, const T &second, typename EpsilonType< T >::Type epsilon=DefaultEpsilon< T, style >::value())
 test for inequality using epsilon
 
template<class T , CmpStyle style>
bool Dune::FloatCmp::gt (const T &first, const T &second, typename EpsilonType< T >::Type epsilon=DefaultEpsilon< T, style >::value())
 test if first greater than second
 
template<class T , CmpStyle style>
bool Dune::FloatCmp::lt (const T &first, const T &second, typename EpsilonType< T >::Type epsilon=DefaultEpsilon< T, style >::value())
 test if first lesser than second
 
template<class T , CmpStyle style>
bool Dune::FloatCmp::ge (const T &first, const T &second, typename EpsilonType< T >::Type epsilon=DefaultEpsilon< T, style >::value())
 test if first greater or equal second
 
template<class T , CmpStyle style>
bool Dune::FloatCmp::le (const T &first, const T &second, typename EpsilonType< T >::Type epsilon=DefaultEpsilon< T, style >::value())
 test if first lesser or equal second
 
template<class T >
bool Dune::FloatCmp::eq (const T &first, const T &second, typename EpsilonType< T >::Type epsilon=DefaultEpsilon< T, defaultCmpStyle >::value())
 
template<class T >
bool Dune::FloatCmp::ne (const T &first, const T &second, typename EpsilonType< T >::Type epsilon=DefaultEpsilon< T, defaultCmpStyle >::value())
 
template<class T >
bool Dune::FloatCmp::gt (const T &first, const T &second, typename EpsilonType< T >::Type epsilon=DefaultEpsilon< T, defaultCmpStyle >::value())
 
template<class T >
bool Dune::FloatCmp::lt (const T &first, const T &second, typename EpsilonType< T >::Type epsilon=DefaultEpsilon< T, defaultCmpStyle >::value())
 
template<class T >
bool Dune::FloatCmp::ge (const T &first, const T &second, typename EpsilonType< T >::Type epsilon=DefaultEpsilon< T, defaultCmpStyle >::value())
 
template<class T >
bool Dune::FloatCmp::le (const T &first, const T &second, typename EpsilonType< T >::Type epsilon=DefaultEpsilon< T, defaultCmpStyle >::value())
 
template<class I , class T , CmpStyle cstyle, RoundingStyle rstyle>
Dune::FloatCmp::round (const T &val, typename EpsilonType< T >::Type epsilon=DefaultEpsilon< T, cstyle >::value())
 round using epsilon
 
template<class I , class T , CmpStyle cstyle>
Dune::FloatCmp::round (const T &val, typename EpsilonType< T >::Type epsilon=DefaultEpsilon< T, cstyle >::value())
 
template<class I , class T >
Dune::FloatCmp::round (const T &val, typename EpsilonType< T >::Type epsilon=DefaultEpsilon< T, defaultCmpStyle >::value())
 
template<class I , class T , CmpStyle cstyle, RoundingStyle rstyle>
Dune::FloatCmp::trunc (const T &val, typename EpsilonType< T >::Type epsilon=DefaultEpsilon< T, cstyle >::value())
 truncate using epsilon
 
template<class I , class T , CmpStyle cstyle>
Dune::FloatCmp::trunc (const T &val, typename EpsilonType< T >::Type epsilon=DefaultEpsilon< T, cstyle >::value())
 
template<class I , class T >
Dune::FloatCmp::trunc (const T &val, typename EpsilonType< T >::Type epsilon=DefaultEpsilon< T, defaultCmpStyle >::value())
 
│ │ │ │ -
│ │ │ │ +

Detailed Description

│ │ │ │ +

Implements a MPIGuard which detects an error on a remote process.

│ │ │ │ +
Author
Christian Engwer
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,128 +6,37 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Functions │ │ │ │ │ -float_cmp.cc File Reference │ │ │ │ │ -#include "float_cmp.hh" │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ + * parallel │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +mpiguard.hh File Reference │ │ │ │ │ +Common » Parallel_Communication │ │ │ │ │ +Implements a MPIGuard which detects an error on a remote process. More... │ │ │ │ │ +#include "mpihelper.hh" │ │ │ │ │ +#include "communication.hh" │ │ │ │ │ +#include "mpicommunication.hh" │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -struct  Dune::FloatCmp::EpsilonType<_T_> │ │ │ │ │ -  Mapping of value type to epsilon type. More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::FloatCmp::EpsilonType<_std::vector<_T,_A_>_> │ │ │ │ │ -  Specialization of EpsilonType for std::vector. More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::FloatCmp::EpsilonType<_FieldVector<_T,_n_>_> │ │ │ │ │ -  Specialization of EpsilonType for Dune::FieldVector. More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::FloatCmp::DefaultEpsilon<_T,_relativeWeak_> │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::FloatCmp::DefaultEpsilon<_T,_relativeStrong_> │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::FloatCmp::DefaultEpsilon<_T,_absolute_> │ │ │ │ │ +class  Dune::MPIGuardError │ │ │ │ │ +  This exception is thrown if the MPIGuard detects an error on a remote │ │ │ │ │ + process. More... │ │ │ │ │ +  │ │ │ │ │ +class  Dune::MPIGuard │ │ │ │ │ +  detects a thrown exception and communicates to all other processes │ │ │ │ │ + More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -namespace  Dune::FloatCmp │ │ │ │ │ -  │ │ │ │ │ - Functions │ │ │ │ │ -template │ │ │ │ │ -bool Dune::FloatCmp::eq (const T &first, const T &second, typename │ │ │ │ │ - EpsilonType< T >::Type epsilon=DefaultEpsilon< T, style >::value()) │ │ │ │ │ -  test for equality using epsilon │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool Dune::FloatCmp::ne (const T &first, const T &second, typename │ │ │ │ │ - EpsilonType< T >::Type epsilon=DefaultEpsilon< T, style >::value()) │ │ │ │ │ -  test for inequality using epsilon │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool Dune::FloatCmp::gt (const T &first, const T &second, typename │ │ │ │ │ - EpsilonType< T >::Type epsilon=DefaultEpsilon< T, style >::value()) │ │ │ │ │ -  test if first greater than second │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool Dune::FloatCmp::lt (const T &first, const T &second, typename │ │ │ │ │ - EpsilonType< T >::Type epsilon=DefaultEpsilon< T, style >::value()) │ │ │ │ │ -  test if first lesser than second │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool Dune::FloatCmp::ge (const T &first, const T &second, typename │ │ │ │ │ - EpsilonType< T >::Type epsilon=DefaultEpsilon< T, style >::value()) │ │ │ │ │ -  test if first greater or equal second │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool Dune::FloatCmp::le (const T &first, const T &second, typename │ │ │ │ │ - EpsilonType< T >::Type epsilon=DefaultEpsilon< T, style >::value()) │ │ │ │ │ -  test if first lesser or equal second │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool Dune::FloatCmp::eq (const T &first, const T &second, typename │ │ │ │ │ - EpsilonType< T >::Type epsilon=DefaultEpsilon< T, defaultCmpStyle >:: │ │ │ │ │ - value()) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool Dune::FloatCmp::ne (const T &first, const T &second, typename │ │ │ │ │ - EpsilonType< T >::Type epsilon=DefaultEpsilon< T, defaultCmpStyle >:: │ │ │ │ │ - value()) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool Dune::FloatCmp::gt (const T &first, const T &second, typename │ │ │ │ │ - EpsilonType< T >::Type epsilon=DefaultEpsilon< T, defaultCmpStyle >:: │ │ │ │ │ - value()) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool Dune::FloatCmp::lt (const T &first, const T &second, typename │ │ │ │ │ - EpsilonType< T >::Type epsilon=DefaultEpsilon< T, defaultCmpStyle >:: │ │ │ │ │ - value()) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool Dune::FloatCmp::ge (const T &first, const T &second, typename │ │ │ │ │ - EpsilonType< T >::Type epsilon=DefaultEpsilon< T, defaultCmpStyle >:: │ │ │ │ │ - value()) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool Dune::FloatCmp::le (const T &first, const T &second, typename │ │ │ │ │ - EpsilonType< T >::Type epsilon=DefaultEpsilon< T, defaultCmpStyle >:: │ │ │ │ │ - value()) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - I Dune::FloatCmp::round (const T &val, typename EpsilonType< T >::Type │ │ │ │ │ - epsilon=DefaultEpsilon< T, cstyle >::value()) │ │ │ │ │ -  round using epsilon │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - I Dune::FloatCmp::round (const T &val, typename EpsilonType< T >::Type │ │ │ │ │ - epsilon=DefaultEpsilon< T, cstyle >::value()) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - I Dune::FloatCmp::round (const T &val, typename EpsilonType< T >::Type │ │ │ │ │ - epsilon=DefaultEpsilon< T, defaultCmpStyle >::value()) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - I Dune::FloatCmp::trunc (const T &val, typename EpsilonType< T >::Type │ │ │ │ │ - epsilon=DefaultEpsilon< T, cstyle >::value()) │ │ │ │ │ -  truncate using epsilon │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - I Dune::FloatCmp::trunc (const T &val, typename EpsilonType< T >::Type │ │ │ │ │ - epsilon=DefaultEpsilon< T, cstyle >::value()) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - I Dune::FloatCmp::trunc (const T &val, typename EpsilonType< T >::Type │ │ │ │ │ - epsilon=DefaultEpsilon< T, defaultCmpStyle >::value()) │ │ │ │ │ -  │ │ │ │ │ +***** Detailed Description ***** │ │ │ │ │ +Implements a MPIGuard which detects an error on a remote process. │ │ │ │ │ + Author │ │ │ │ │ + Christian Engwer │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00038_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: float_cmp.cc Source File │ │ │ │ +dune-common: mpiguard.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,631 +70,212 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
float_cmp.cc
│ │ │ │ +
mpiguard.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 (C) DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#include "float_cmp.hh"
│ │ │ │ -
6
│ │ │ │ -
7#include <vector>
│ │ │ │ -
8#include <limits>
│ │ │ │ -
9#include <algorithm>
│ │ │ │ -
10#include <cstdlib>
│ │ │ │ - │ │ │ │ -
12
│ │ │ │ -
13namespace Dune {
│ │ │ │ -
14
│ │ │ │ +
5
│ │ │ │ +
13#ifndef DUNE_COMMON_MPIGUARD_HH
│ │ │ │ +
14#define DUNE_COMMON_MPIGUARD_HH
│ │ │ │
15
│ │ │ │ -
│ │ │ │ -
16 namespace FloatCmp {
│ │ │ │ -
17 // traits
│ │ │ │ -
19
│ │ │ │ -
│ │ │ │ -
23 template<class T> struct EpsilonType {
│ │ │ │ -
25 typedef T Type;
│ │ │ │ -
26 };
│ │ │ │ -
│ │ │ │ -
28
│ │ │ │ -
33 template<class T, typename A>
│ │ │ │ -
│ │ │ │ -
34 struct EpsilonType<std::vector<T, A> > {
│ │ │ │ -
36 typedef typename EpsilonType<T>::Type Type;
│ │ │ │ -
37 };
│ │ │ │ -
│ │ │ │ -
39
│ │ │ │ -
44 template<class T, int n>
│ │ │ │ -
│ │ │ │ -
45 struct EpsilonType<FieldVector<T, n> > {
│ │ │ │ -
47 typedef typename EpsilonType<T>::Type Type;
│ │ │ │ -
48 };
│ │ │ │ -
│ │ │ │ -
49
│ │ │ │ -
50 // default epsilon
│ │ │ │ -
51 template<class T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
53 static typename EpsilonType<T>::Type value()
│ │ │ │ -
54 { return std::numeric_limits<typename EpsilonType<T>::Type>::epsilon()*8.; }
│ │ │ │ -
│ │ │ │ -
55 };
│ │ │ │ -
│ │ │ │ -
56 template<class T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
58 static typename EpsilonType<T>::Type value()
│ │ │ │ -
59 { return std::numeric_limits<typename EpsilonType<T>::Type>::epsilon()*8.; }
│ │ │ │ -
│ │ │ │ -
60 };
│ │ │ │ -
│ │ │ │ -
61 template<class T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
63 static typename EpsilonType<T>::Type value()
│ │ │ │ -
64 { return std::max(std::numeric_limits<typename EpsilonType<T>::Type>::epsilon(), 1e-6); }
│ │ │ │ -
│ │ │ │ -
65 };
│ │ │ │ -
│ │ │ │ -
66
│ │ │ │ -
67 namespace Impl {
│ │ │ │ -
68 // basic comparison
│ │ │ │ -
69 template<class T, CmpStyle style = defaultCmpStyle>
│ │ │ │ -
70 struct eq_t;
│ │ │ │ -
71 template<class T>
│ │ │ │ -
72 struct eq_t<T, relativeWeak> {
│ │ │ │ -
73 static bool eq(const T &first,
│ │ │ │ -
74 const T &second,
│ │ │ │ - │ │ │ │ -
76 {
│ │ │ │ -
77 using std::abs;
│ │ │ │ -
78 return abs(first - second) <= epsilon*std::max(abs(first), abs(second));
│ │ │ │ -
79 }
│ │ │ │ -
80 };
│ │ │ │ -
81 template<class T>
│ │ │ │ -
82 struct eq_t<T, relativeStrong> {
│ │ │ │ -
83 static bool eq(const T &first,
│ │ │ │ -
84 const T &second,
│ │ │ │ - │ │ │ │ -
86 {
│ │ │ │ -
87 using std::abs;
│ │ │ │ -
88 return abs(first - second) <= epsilon*std::min(abs(first), abs(second));
│ │ │ │ -
89 }
│ │ │ │ -
90 };
│ │ │ │ -
91 template<class T>
│ │ │ │ -
92 struct eq_t<T, absolute> {
│ │ │ │ -
93 static bool eq(const T &first,
│ │ │ │ -
94 const T &second,
│ │ │ │ - │ │ │ │ -
96 {
│ │ │ │ -
97 using std::abs;
│ │ │ │ -
98 return abs(first-second) <= epsilon;
│ │ │ │ -
99 }
│ │ │ │ -
100 };
│ │ │ │ -
101 template<class T, CmpStyle cstyle>
│ │ │ │ -
102 struct eq_t_std_vec {
│ │ │ │ -
103 typedef std::vector<T> V;
│ │ │ │ -
104 static bool eq(const V &first,
│ │ │ │ -
105 const V &second,
│ │ │ │ -
106 typename EpsilonType<V>::Type epsilon = DefaultEpsilon<V>::value()) {
│ │ │ │ -
107 auto size = first.size();
│ │ │ │ -
108 if(size != second.size()) return false;
│ │ │ │ -
109 for(unsigned int i = 0; i < size; ++i)
│ │ │ │ -
110 if(!eq_t<T, cstyle>::eq(first[i], second[i], epsilon))
│ │ │ │ -
111 return false;
│ │ │ │ -
112 return true;
│ │ │ │ -
113 }
│ │ │ │ -
114 };
│ │ │ │ -
115 template< class T>
│ │ │ │ -
116 struct eq_t<std::vector<T>, relativeWeak> : eq_t_std_vec<T, relativeWeak> {};
│ │ │ │ -
117 template< class T>
│ │ │ │ -
118 struct eq_t<std::vector<T>, relativeStrong> : eq_t_std_vec<T, relativeStrong> {};
│ │ │ │ -
119 template< class T>
│ │ │ │ -
120 struct eq_t<std::vector<T>, absolute> : eq_t_std_vec<T, absolute> {};
│ │ │ │ -
121
│ │ │ │ -
122 template<class T, int n, CmpStyle cstyle>
│ │ │ │ -
123 struct eq_t_fvec {
│ │ │ │ -
124 typedef Dune::FieldVector<T, n> V;
│ │ │ │ -
125 static bool eq(const V &first,
│ │ │ │ -
126 const V &second,
│ │ │ │ -
127 typename EpsilonType<V>::Type epsilon = DefaultEpsilon<V>::value()) {
│ │ │ │ -
128 for(int i = 0; i < n; ++i)
│ │ │ │ -
129 if(!eq_t<T, cstyle>::eq(first[i], second[i], epsilon))
│ │ │ │ -
130 return false;
│ │ │ │ -
131 return true;
│ │ │ │ -
132 }
│ │ │ │ -
133 };
│ │ │ │ -
134 template< class T, int n >
│ │ │ │ -
135 struct eq_t< Dune::FieldVector<T, n>, relativeWeak> : eq_t_fvec<T, n, relativeWeak> {};
│ │ │ │ -
136 template< class T, int n >
│ │ │ │ -
137 struct eq_t< Dune::FieldVector<T, n>, relativeStrong> : eq_t_fvec<T, n, relativeStrong> {};
│ │ │ │ -
138 template< class T, int n >
│ │ │ │ -
139 struct eq_t< Dune::FieldVector<T, n>, absolute> : eq_t_fvec<T, n, absolute> {};
│ │ │ │ -
140 } // namespace Impl
│ │ │ │ -
141
│ │ │ │ -
142 // operations in functional style
│ │ │ │ -
143 template <class T, CmpStyle style>
│ │ │ │ -
│ │ │ │ -
144 bool eq(const T &first,
│ │ │ │ -
145 const T &second,
│ │ │ │ -
146 typename EpsilonType<T>::Type epsilon)
│ │ │ │ -
147 {
│ │ │ │ -
148 return Impl::eq_t<T, style>::eq(first, second, epsilon);
│ │ │ │ -
149 }
│ │ │ │ -
│ │ │ │ -
150 template <class T, CmpStyle style>
│ │ │ │ -
│ │ │ │ -
151 bool ne(const T &first,
│ │ │ │ -
152 const T &second,
│ │ │ │ -
153 typename EpsilonType<T>::Type epsilon)
│ │ │ │ -
154 {
│ │ │ │ -
155 return !eq<T, style>(first, second, epsilon);
│ │ │ │ -
156 }
│ │ │ │ -
│ │ │ │ -
157 template <class T, CmpStyle style>
│ │ │ │ -
│ │ │ │ -
158 bool gt(const T &first,
│ │ │ │ -
159 const T &second,
│ │ │ │ -
160 typename EpsilonType<T>::Type epsilon)
│ │ │ │ -
161 {
│ │ │ │ -
162 return first > second && ne<T, style>(first, second, epsilon);
│ │ │ │ -
163 }
│ │ │ │ -
│ │ │ │ -
164 template <class T, CmpStyle style>
│ │ │ │ -
│ │ │ │ -
165 bool lt(const T &first,
│ │ │ │ -
166 const T &second,
│ │ │ │ -
167 typename EpsilonType<T>::Type epsilon)
│ │ │ │ -
168 {
│ │ │ │ -
169 return first < second && ne<T, style>(first, second, epsilon);
│ │ │ │ -
170 }
│ │ │ │ -
│ │ │ │ -
171 template <class T, CmpStyle style>
│ │ │ │ -
│ │ │ │ -
172 bool ge(const T &first,
│ │ │ │ -
173 const T &second,
│ │ │ │ -
174 typename EpsilonType<T>::Type epsilon)
│ │ │ │ -
175 {
│ │ │ │ -
176 return first > second || eq<T, style>(first, second, epsilon);
│ │ │ │ -
177 }
│ │ │ │ -
│ │ │ │ -
178 template <class T, CmpStyle style>
│ │ │ │ -
│ │ │ │ -
179 bool le(const T &first,
│ │ │ │ -
180 const T &second,
│ │ │ │ -
181 typename EpsilonType<T>::Type epsilon)
│ │ │ │ -
182 {
│ │ │ │ -
183 return first < second || eq<T, style>(first, second, epsilon);
│ │ │ │ -
184 }
│ │ │ │ +
16#include "mpihelper.hh"
│ │ │ │ +
17#include "communication.hh"
│ │ │ │ +
18#include "mpicommunication.hh"
│ │ │ │ + │ │ │ │ +
20
│ │ │ │ +
21namespace Dune
│ │ │ │ +
22{
│ │ │ │ +
23
│ │ │ │ +
24#ifndef DOXYGEN
│ │ │ │ +
25
│ │ │ │ +
26 /*
│ │ │ │ +
27 Interface class for the communication needed by MPIGuard
│ │ │ │ +
28 */
│ │ │ │ +
29 struct GuardCommunicator
│ │ │ │ +
30 {
│ │ │ │ +
31 // cleanup
│ │ │ │ +
32 virtual ~GuardCommunicator() {};
│ │ │ │ +
33 // all the communication methods we need
│ │ │ │ +
34 virtual int rank() = 0;
│ │ │ │ +
35 virtual int size() = 0;
│ │ │ │ +
36 virtual int sum(int i) = 0;
│ │ │ │ +
37 // create a new GuardCommunicator pointer
│ │ │ │ +
38 template <class C>
│ │ │ │ +
39 static GuardCommunicator * create(const Communication<C> & c);
│ │ │ │ +
40#if HAVE_MPI
│ │ │ │ +
41 inline
│ │ │ │ +
42 static GuardCommunicator * create(const MPI_Comm & c);
│ │ │ │ +
43#endif
│ │ │ │ +
44 };
│ │ │ │ +
45
│ │ │ │ +
46 namespace {
│ │ │ │ +
47 /*
│ │ │ │ +
48 templated implementation of different communication classes
│ │ │ │ +
49 */
│ │ │ │ +
50 // the default class will always fail, due to the missing implementation of "sum"
│ │ │ │ +
51 template <class Imp>
│ │ │ │ +
52 struct GenericGuardCommunicator
│ │ │ │ +
53 : public GuardCommunicator
│ │ │ │ +
54 {};
│ │ │ │ +
55 // specialization for Communication
│ │ │ │ +
56 template <class T>
│ │ │ │ +
57 struct GenericGuardCommunicator< Communication<T> >
│ │ │ │ +
58 : public GuardCommunicator
│ │ │ │ +
59 {
│ │ │ │ +
60 const Communication<T> comm;
│ │ │ │ +
61 GenericGuardCommunicator(const Communication<T> & c) :
│ │ │ │ +
62 comm(c) {}
│ │ │ │ +
63 int rank() override { return comm.rank(); };
│ │ │ │ +
64 int size() override { return comm.size(); };
│ │ │ │ +
65 int sum(int i) override { return comm.sum(i); }
│ │ │ │ +
66 };
│ │ │ │ +
67
│ │ │ │ +
68#if HAVE_MPI
│ │ │ │ +
69 // specialization for MPI_Comm
│ │ │ │ +
70 template <>
│ │ │ │ +
71 struct GenericGuardCommunicator<MPI_Comm>
│ │ │ │ +
72 : public GenericGuardCommunicator< Communication<MPI_Comm> >
│ │ │ │ +
73 {
│ │ │ │ +
74 GenericGuardCommunicator(const MPI_Comm & c) :
│ │ │ │ +
75 GenericGuardCommunicator< Communication<MPI_Comm> >(
│ │ │ │ +
76 Communication<MPI_Comm>(c)) {}
│ │ │ │ +
77 };
│ │ │ │ +
78#endif
│ │ │ │ +
79 } // anonymous namespace
│ │ │ │ +
80
│ │ │ │ +
81 template<class C>
│ │ │ │ +
82 GuardCommunicator * GuardCommunicator::create(const Communication<C> & comm)
│ │ │ │ +
83 {
│ │ │ │ +
84 return new GenericGuardCommunicator< Communication<C> >(comm);
│ │ │ │ +
85 }
│ │ │ │ +
86
│ │ │ │ +
87#if HAVE_MPI
│ │ │ │ +
88 GuardCommunicator * GuardCommunicator::create(const MPI_Comm & comm)
│ │ │ │ +
89 {
│ │ │ │ +
90 return new GenericGuardCommunicator< Communication<MPI_Comm> >(comm);
│ │ │ │ +
91 }
│ │ │ │ +
92#endif
│ │ │ │ +
93
│ │ │ │ +
94#endif
│ │ │ │ +
95
│ │ │ │ +
99 class MPIGuardError : public ParallelError {};
│ │ │ │ +
100
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
134 {
│ │ │ │ +
135 GuardCommunicator * comm_;
│ │ │ │ +
136 bool active_;
│ │ │ │ +
137
│ │ │ │ +
138 // we don't want to copy this class
│ │ │ │ +
139 MPIGuard (const MPIGuard &);
│ │ │ │ +
140
│ │ │ │ +
141 public:
│ │ │ │ +
│ │ │ │ +
146 MPIGuard (bool active=true) :
│ │ │ │ +
147 comm_(GuardCommunicator::create(
│ │ │ │ +
148 MPIHelper::getCommunication())),
│ │ │ │ +
149 active_(active)
│ │ │ │ +
150 {}
│ │ │ │ +
│ │ │ │ +
151
│ │ │ │ +
│ │ │ │ +
157 MPIGuard (MPIHelper & m, bool active=true) :
│ │ │ │ +
158 comm_(GuardCommunicator::create(
│ │ │ │ +
159 m.getCommunication())),
│ │ │ │ +
160 active_(active)
│ │ │ │ +
161 {}
│ │ │ │ +
│ │ │ │ +
162
│ │ │ │ +
173 template <class C>
│ │ │ │ +
│ │ │ │ +
174 MPIGuard (const C & comm, bool active=true) :
│ │ │ │ +
175 comm_(GuardCommunicator::create(comm)),
│ │ │ │ +
176 active_(active)
│ │ │ │ +
177 {}
│ │ │ │ +
│ │ │ │ +
178
│ │ │ │ +
179#if HAVE_MPI
│ │ │ │ +
│ │ │ │ +
180 MPIGuard (const MPI_Comm & comm, bool active=true) :
│ │ │ │ +
181 comm_(GuardCommunicator::create(comm)),
│ │ │ │ +
182 active_(active)
│ │ │ │ +
183 {}
│ │ │ │
│ │ │ │ +
184#endif
│ │ │ │
185
│ │ │ │ -
186 // default template arguments
│ │ │ │ -
187 template <class T>
│ │ │ │
│ │ │ │ -
188 bool eq(const T &first,
│ │ │ │ -
189 const T &second,
│ │ │ │ - │ │ │ │ -
191 {
│ │ │ │ -
192 return eq<T, defaultCmpStyle>(first, second, epsilon);
│ │ │ │ -
193 }
│ │ │ │ -
│ │ │ │ -
194 template <class T>
│ │ │ │ -
│ │ │ │ -
195 bool ne(const T &first,
│ │ │ │ -
196 const T &second,
│ │ │ │ - │ │ │ │ -
198 {
│ │ │ │ -
199 return ne<T, defaultCmpStyle>(first, second, epsilon);
│ │ │ │ -
200 }
│ │ │ │ + │ │ │ │ +
189 {
│ │ │ │ +
190 if (active_)
│ │ │ │ +
191 {
│ │ │ │ +
192 active_ = false;
│ │ │ │ +
193 finalize(false);
│ │ │ │ +
194 }
│ │ │ │ +
195 delete comm_;
│ │ │ │ +
196 }
│ │ │ │
│ │ │ │ -
201 template <class T>
│ │ │ │ +
197
│ │ │ │
│ │ │ │ -
202 bool gt(const T &first,
│ │ │ │ -
203 const T &second,
│ │ │ │ - │ │ │ │ -
205 {
│ │ │ │ -
206 return gt<T, defaultCmpStyle>(first, second, epsilon);
│ │ │ │ -
207 }
│ │ │ │ -
│ │ │ │ -
208 template <class T>
│ │ │ │ -
│ │ │ │ -
209 bool lt(const T &first,
│ │ │ │ -
210 const T &second,
│ │ │ │ - │ │ │ │ -
212 {
│ │ │ │ -
213 return lt<T, defaultCmpStyle>(first, second, epsilon);
│ │ │ │ -
214 }
│ │ │ │ -
│ │ │ │ -
215 template <class T>
│ │ │ │ -
│ │ │ │ -
216 bool ge(const T &first,
│ │ │ │ -
217 const T &second,
│ │ │ │ - │ │ │ │ +
202 void reactivate() {
│ │ │ │ +
203 if (active_ == true)
│ │ │ │ +
204 finalize();
│ │ │ │ +
205 active_ = true;
│ │ │ │ +
206 }
│ │ │ │ +
│ │ │ │ +
207
│ │ │ │ +
│ │ │ │ +
218 void finalize(bool success = true)
│ │ │ │
219 {
│ │ │ │ -
220 return ge<T, defaultCmpStyle>(first, second, epsilon);
│ │ │ │ -
221 }
│ │ │ │ -
│ │ │ │ -
222 template <class T>
│ │ │ │ -
│ │ │ │ -
223 bool le(const T &first,
│ │ │ │ -
224 const T &second,
│ │ │ │ - │ │ │ │ -
226 {
│ │ │ │ -
227 return le<T, defaultCmpStyle>(first, second, epsilon);
│ │ │ │ -
228 }
│ │ │ │ -
│ │ │ │ -
229
│ │ │ │ -
230 // rounding operations
│ │ │ │ -
231 namespace Impl {
│ │ │ │ -
232 template<class I, class T, CmpStyle cstyle = defaultCmpStyle, RoundingStyle rstyle = defaultRoundingStyle>
│ │ │ │ -
233 struct round_t;
│ │ │ │ -
234 template<class I, class T, CmpStyle cstyle>
│ │ │ │ -
235 struct round_t<I, T, cstyle, downward> {
│ │ │ │ -
236 static I
│ │ │ │ -
237 round(const T &val,
│ │ │ │ - │ │ │ │ -
239 // first get an approximation
│ │ │ │ -
240 I lower = I(val);
│ │ │ │ -
241 I upper;
│ │ │ │ -
242 if(eq<T, cstyle>(T(lower), val, epsilon)) return lower;
│ │ │ │ -
243 if(T(lower) > val) { upper = lower; lower--; }
│ │ │ │ -
244 else upper = lower+1;
│ │ │ │ -
245 if(le<T, cstyle>(val - T(lower), T(upper) - val, epsilon))
│ │ │ │ -
246 return lower;
│ │ │ │ -
247 else return upper;
│ │ │ │ -
248 }
│ │ │ │ -
249 };
│ │ │ │ -
250 template<class I, class T, CmpStyle cstyle>
│ │ │ │ -
251 struct round_t<I, T, cstyle, upward> {
│ │ │ │ -
252 static I
│ │ │ │ -
253 round(const T &val,
│ │ │ │ - │ │ │ │ -
255 // first get an approximation
│ │ │ │ -
256 I lower = I(val);
│ │ │ │ -
257 I upper;
│ │ │ │ -
258 if(eq<T, cstyle>(T(lower), val, epsilon)) return lower;
│ │ │ │ -
259 if(T(lower) > val) { upper = lower; lower--; }
│ │ │ │ -
260 else upper = lower+1;
│ │ │ │ -
261 if(lt<T, cstyle>(val - T(lower), T(upper) - val, epsilon))
│ │ │ │ -
262 return lower;
│ │ │ │ -
263 else return upper;
│ │ │ │ -
264 }
│ │ │ │ -
265 };
│ │ │ │ -
266 template<class I, class T, CmpStyle cstyle>
│ │ │ │ -
267 struct round_t<I, T, cstyle, towardZero> {
│ │ │ │ -
268 static I
│ │ │ │ -
269 round(const T &val,
│ │ │ │ - │ │ │ │ -
271 if(val > T(0))
│ │ │ │ -
272 return round_t<I, T, cstyle, downward>::round(val, epsilon);
│ │ │ │ -
273 else return round_t<I, T, cstyle, upward>::round(val, epsilon);
│ │ │ │ -
274 }
│ │ │ │ -
275 };
│ │ │ │ -
276 template<class I, class T, CmpStyle cstyle>
│ │ │ │ -
277 struct round_t<I, T, cstyle, towardInf> {
│ │ │ │ -
278 static I
│ │ │ │ -
279 round(const T &val,
│ │ │ │ - │ │ │ │ -
281 if(val > T(0))
│ │ │ │ -
282 return round_t<I, T, cstyle, upward>::round(val, epsilon);
│ │ │ │ -
283 else return round_t<I, T, cstyle, downward>::round(val, epsilon);
│ │ │ │ -
284 }
│ │ │ │ -
285 };
│ │ │ │ -
286 template<class I, class T, CmpStyle cstyle, RoundingStyle rstyle>
│ │ │ │ -
287 struct round_t<std::vector<I>, std::vector<T>, cstyle, rstyle> {
│ │ │ │ -
288 static std::vector<I>
│ │ │ │ -
289 round(const T &val,
│ │ │ │ - │ │ │ │ -
291 unsigned int size = val.size();
│ │ │ │ -
292 std::vector<I> res(size);
│ │ │ │ -
293 for(unsigned int i = 0; i < size; ++i)
│ │ │ │ -
294 res[i] = round_t<I, T, cstyle, rstyle>::round(val[i], epsilon);
│ │ │ │ -
295 return res;
│ │ │ │ -
296 }
│ │ │ │ -
297 };
│ │ │ │ -
298 template<class I, class T, int n, CmpStyle cstyle, RoundingStyle rstyle>
│ │ │ │ -
299 struct round_t<Dune::FieldVector<I, n>, Dune::FieldVector<T, n>, cstyle, rstyle> {
│ │ │ │ - │ │ │ │ -
301 round(const T &val,
│ │ │ │ - │ │ │ │ - │ │ │ │ -
304 for(int i = 0; i < n; ++i)
│ │ │ │ -
305 res[i] = round_t<I, T, cstyle, rstyle>::round(val[i], epsilon);
│ │ │ │ -
306 return res;
│ │ │ │ -
307 }
│ │ │ │ -
308 };
│ │ │ │ -
309 } // end namespace Impl
│ │ │ │ -
310 template<class I, class T, CmpStyle cstyle, RoundingStyle rstyle>
│ │ │ │ -
│ │ │ │ -
311 I round(const T &val, typename EpsilonType<T>::Type epsilon /*= DefaultEpsilon<T, cstyle>::value()*/)
│ │ │ │ -
312 {
│ │ │ │ -
313 return Impl::round_t<I, T, cstyle, rstyle>::round(val, epsilon);
│ │ │ │ -
314 }
│ │ │ │ -
│ │ │ │ -
315 template<class I, class T, CmpStyle cstyle>
│ │ │ │ -
│ │ │ │ -
316 I round(const T &val, typename EpsilonType<T>::Type epsilon = DefaultEpsilon<T, cstyle>::value())
│ │ │ │ -
317 {
│ │ │ │ -
318 return round<I, T, cstyle, defaultRoundingStyle>(val, epsilon);
│ │ │ │ -
319 }
│ │ │ │ -
│ │ │ │ -
320 template<class I, class T, RoundingStyle rstyle>
│ │ │ │ -
321 I round(const T &val, typename EpsilonType<T>::Type epsilon = DefaultEpsilon<T, defaultCmpStyle>::value())
│ │ │ │ -
322 {
│ │ │ │ -
323 return round<I, T, defaultCmpStyle, rstyle>(val, epsilon);
│ │ │ │ -
324 }
│ │ │ │ -
325 template<class I, class T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
327 {
│ │ │ │ -
328 return round<I, T, defaultCmpStyle>(val, epsilon);
│ │ │ │ -
329 }
│ │ │ │ -
│ │ │ │ -
330
│ │ │ │ -
331 // truncation
│ │ │ │ -
332 namespace Impl {
│ │ │ │ -
333 template<class I, class T, CmpStyle cstyle = defaultCmpStyle, RoundingStyle rstyle = defaultRoundingStyle>
│ │ │ │ -
334 struct trunc_t;
│ │ │ │ -
335 template<class I, class T, CmpStyle cstyle>
│ │ │ │ -
336 struct trunc_t<I, T, cstyle, downward> {
│ │ │ │ -
337 static I
│ │ │ │ -
338 trunc(const T &val,
│ │ │ │ - │ │ │ │ -
340 // this should be optimized away unless needed
│ │ │ │ -
341 if(!std::numeric_limits<I>::is_signed)
│ │ │ │ -
342 // make sure this works for all useful cases even if I is an unsigned type
│ │ │ │ -
343 if(eq<T, cstyle>(val, T(0), epsilon)) return I(0);
│ │ │ │ -
344 // first get an approximation
│ │ │ │ -
345 I lower = I(val); // now |val-lower| < 1
│ │ │ │ -
346 // make sure we're really lower in case the cast truncated to an unexpected direction
│ │ │ │ -
347 if(T(lower) > val) lower--; // now val-lower < 1
│ │ │ │ -
348 // check whether lower + 1 is approximately val
│ │ │ │ -
349 if(eq<T, cstyle>(T(lower+1), val, epsilon))
│ │ │ │ -
350 return lower+1;
│ │ │ │ -
351 else return lower;
│ │ │ │ -
352 }
│ │ │ │ -
353 };
│ │ │ │ -
354 template<class I, class T, CmpStyle cstyle>
│ │ │ │ -
355 struct trunc_t<I, T, cstyle, upward> {
│ │ │ │ -
356 static I
│ │ │ │ -
357 trunc(const T &val,
│ │ │ │ - │ │ │ │ -
359 I upper = trunc_t<I, T, cstyle, downward>::trunc(val, epsilon);
│ │ │ │ -
360 if(ne<T, cstyle>(T(upper), val, epsilon)) ++upper;
│ │ │ │ -
361 return upper;
│ │ │ │ -
362 }
│ │ │ │ -
363 };
│ │ │ │ -
364 template<class I, class T, CmpStyle cstyle>
│ │ │ │ -
365 struct trunc_t<I, T, cstyle, towardZero> {
│ │ │ │ -
366 static I
│ │ │ │ -
367 trunc(const T &val,
│ │ │ │ - │ │ │ │ -
369 if(val > T(0)) return trunc_t<I, T, cstyle, downward>::trunc(val, epsilon);
│ │ │ │ -
370 else return trunc_t<I, T, cstyle, upward>::trunc(val, epsilon);
│ │ │ │ -
371 }
│ │ │ │ -
372 };
│ │ │ │ -
373 template<class I, class T, CmpStyle cstyle>
│ │ │ │ -
374 struct trunc_t<I, T, cstyle, towardInf> {
│ │ │ │ -
375 static I
│ │ │ │ -
376 trunc(const T &val,
│ │ │ │ - │ │ │ │ -
378 if(val > T(0)) return trunc_t<I, T, cstyle, upward>::trunc(val, epsilon);
│ │ │ │ -
379 else return trunc_t<I, T, cstyle, downward>::trunc(val, epsilon);
│ │ │ │ -
380 }
│ │ │ │ -
381 };
│ │ │ │ -
382 template<class I, class T, CmpStyle cstyle, RoundingStyle rstyle>
│ │ │ │ -
383 struct trunc_t<std::vector<I>, std::vector<T>, cstyle, rstyle> {
│ │ │ │ -
384 static std::vector<I>
│ │ │ │ -
385 trunc(const std::vector<T> &val,
│ │ │ │ - │ │ │ │ -
387 unsigned int size = val.size();
│ │ │ │ -
388 std::vector<I> res(size);
│ │ │ │ -
389 for(unsigned int i = 0; i < size; ++i)
│ │ │ │ -
390 res[i] = trunc_t<I, T, cstyle, rstyle>::trunc(val[i], epsilon);
│ │ │ │ -
391 return res;
│ │ │ │ -
392 }
│ │ │ │ -
393 };
│ │ │ │ -
394 template<class I, class T, int n, CmpStyle cstyle, RoundingStyle rstyle>
│ │ │ │ -
395 struct trunc_t<Dune::FieldVector<I, n>, Dune::FieldVector<T, n>, cstyle, rstyle> {
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
400 for(int i = 0; i < n; ++i)
│ │ │ │ -
401 res[i] = trunc_t<I, T, cstyle, rstyle>::trunc(val[i], epsilon);
│ │ │ │ -
402 return res;
│ │ │ │ -
403 }
│ │ │ │ -
404 };
│ │ │ │ -
405 } // namespace Impl
│ │ │ │ -
406 template<class I, class T, CmpStyle cstyle, RoundingStyle rstyle>
│ │ │ │ -
│ │ │ │ -
407 I trunc(const T &val, typename EpsilonType<T>::Type epsilon /*= DefaultEpsilon<T, cstyle>::value()*/)
│ │ │ │ -
408 {
│ │ │ │ -
409 return Impl::trunc_t<I, T, cstyle, rstyle>::trunc(val, epsilon);
│ │ │ │ -
410 }
│ │ │ │ -
│ │ │ │ -
411 template<class I, class T, CmpStyle cstyle>
│ │ │ │ -
│ │ │ │ -
412 I trunc(const T &val, typename EpsilonType<T>::Type epsilon = DefaultEpsilon<T, cstyle>::value())
│ │ │ │ -
413 {
│ │ │ │ -
414 return trunc<I, T, cstyle, defaultRoundingStyle>(val, epsilon);
│ │ │ │ -
415 }
│ │ │ │ -
│ │ │ │ -
416 template<class I, class T, RoundingStyle rstyle>
│ │ │ │ -
417 I trunc(const T &val, typename EpsilonType<T>::Type epsilon = DefaultEpsilon<T, defaultCmpStyle>::value())
│ │ │ │ -
418 {
│ │ │ │ -
419 return trunc<I, T, defaultCmpStyle, rstyle>(val, epsilon);
│ │ │ │ -
420 }
│ │ │ │ -
421 template<class I, class T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
423 {
│ │ │ │ -
424 return trunc<I, T, defaultCmpStyle>(val, epsilon);
│ │ │ │ -
425 }
│ │ │ │ -
│ │ │ │ -
426 } //namespace Dune
│ │ │ │ -
│ │ │ │ -
427
│ │ │ │ -
428 // oo interface
│ │ │ │ -
429 template<class T, FloatCmp::CmpStyle cstyle_, FloatCmp::RoundingStyle rstyle_>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
431 FloatCmpOps(EpsilonType epsilon) : epsilon_(epsilon) {}
│ │ │ │ -
│ │ │ │ -
432
│ │ │ │ -
433
│ │ │ │ -
434 template<class T, FloatCmp::CmpStyle cstyle_, FloatCmp::RoundingStyle rstyle_>
│ │ │ │ - │ │ │ │ -
│ │ │ │ - │ │ │ │ -
437 {
│ │ │ │ -
438 return epsilon_;
│ │ │ │ -
439 }
│ │ │ │ -
│ │ │ │ -
440
│ │ │ │ -
441 template<class T, FloatCmp::CmpStyle cstyle_, FloatCmp::RoundingStyle rstyle_>
│ │ │ │ -
442 void
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
444 {
│ │ │ │ -
445 epsilon_ = epsilon__;
│ │ │ │ -
446 }
│ │ │ │ -
│ │ │ │ -
447
│ │ │ │ -
448
│ │ │ │ -
449 template<class T, FloatCmp::CmpStyle cstyle_, FloatCmp::RoundingStyle rstyle_>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
451 eq(const ValueType &first, const ValueType &second) const
│ │ │ │ -
452 {
│ │ │ │ -
453 return Dune::FloatCmp::eq<ValueType, cstyle>(first, second, epsilon_);
│ │ │ │ -
454 }
│ │ │ │ -
│ │ │ │ -
455
│ │ │ │ -
456 template<class T, FloatCmp::CmpStyle cstyle_, FloatCmp::RoundingStyle rstyle_>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
458 ne(const ValueType &first, const ValueType &second) const
│ │ │ │ -
459 {
│ │ │ │ -
460 return Dune::FloatCmp::ne<ValueType, cstyle>(first, second, epsilon_);
│ │ │ │ -
461 }
│ │ │ │ -
│ │ │ │ -
462
│ │ │ │ -
463 template<class T, FloatCmp::CmpStyle cstyle_, FloatCmp::RoundingStyle rstyle_>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
465 gt(const ValueType &first, const ValueType &second) const
│ │ │ │ -
466 {
│ │ │ │ -
467 return Dune::FloatCmp::gt<ValueType, cstyle>(first, second, epsilon_);
│ │ │ │ -
468 }
│ │ │ │ -
│ │ │ │ -
469
│ │ │ │ -
470 template<class T, FloatCmp::CmpStyle cstyle_, FloatCmp::RoundingStyle rstyle_>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
472 lt(const ValueType &first, const ValueType &second) const
│ │ │ │ -
473 {
│ │ │ │ -
474 return Dune::FloatCmp::lt<ValueType, cstyle>(first, second, epsilon_);
│ │ │ │ -
475 }
│ │ │ │ -
│ │ │ │ -
476
│ │ │ │ -
477 template<class T, FloatCmp::CmpStyle cstyle_, FloatCmp::RoundingStyle rstyle_>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
479 ge(const ValueType &first, const ValueType &second) const
│ │ │ │ -
480 {
│ │ │ │ -
481 return Dune::FloatCmp::ge<ValueType, cstyle>(first, second, epsilon_);
│ │ │ │ -
482 }
│ │ │ │ -
│ │ │ │ -
483
│ │ │ │ -
484 template<class T, FloatCmp::CmpStyle cstyle_, FloatCmp::RoundingStyle rstyle_>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
486 le(const ValueType &first, const ValueType &second) const
│ │ │ │ -
487 {
│ │ │ │ -
488 return Dune::FloatCmp::le<ValueType, cstyle>(first, second, epsilon_);
│ │ │ │ -
489 }
│ │ │ │ -
│ │ │ │ -
490
│ │ │ │ -
491
│ │ │ │ -
492 template<class T, FloatCmp::CmpStyle cstyle_, FloatCmp::RoundingStyle rstyle_>
│ │ │ │ -
493 template<class I>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
495 round(const ValueType &val) const
│ │ │ │ -
496 {
│ │ │ │ -
497 return Dune::FloatCmp::round<I, ValueType, cstyle, rstyle_>(val, epsilon_);
│ │ │ │ -
498 }
│ │ │ │ -
│ │ │ │ -
499
│ │ │ │ -
500 template<class T, FloatCmp::CmpStyle cstyle_, FloatCmp::RoundingStyle rstyle_>
│ │ │ │ -
501 template<class I>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
503 trunc(const ValueType &val) const
│ │ │ │ -
504 {
│ │ │ │ -
505 return Dune::FloatCmp::trunc<I, ValueType, cstyle, rstyle_>(val, epsilon_);
│ │ │ │ -
506 }
│ │ │ │ -
│ │ │ │ -
507
│ │ │ │ -
508} //namespace Dune
│ │ │ │ -
Various ways to compare floating-point numbers.
│ │ │ │ -
Implements a vector constructed from a given type representing a field and a compile-time given size.
│ │ │ │ -
bool ne(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test for inequality using epsilon
Definition float_cmp.cc:151
│ │ │ │ -
bool eq(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test for equality using epsilon
Definition float_cmp.cc:144
│ │ │ │ -
I round(const T &val, typename EpsilonType< T >::Type epsilon)
round using epsilon
Definition float_cmp.cc:311
│ │ │ │ -
I trunc(const T &val, typename EpsilonType< T >::Type epsilon)
truncate using epsilon
Definition float_cmp.cc:407
│ │ │ │ -
bool lt(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test if first lesser than second
Definition float_cmp.cc:165
│ │ │ │ -
bool gt(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test if first greater than second
Definition float_cmp.cc:158
│ │ │ │ -
bool ge(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test if first greater or equal second
Definition float_cmp.cc:172
│ │ │ │ -
bool le(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test if first lesser or equal second
Definition float_cmp.cc:179
│ │ │ │ -
@ relativeStrong
|a-b|/|a| <= epsilon && |a-b|/|b| <= epsilon
Definition float_cmp.hh:108
│ │ │ │ -
@ relativeWeak
|a-b|/|a| <= epsilon || |a-b|/|b| <= epsilon
Definition float_cmp.hh:106
│ │ │ │ -
@ absolute
|a-b| <= epsilon
Definition float_cmp.hh:110
│ │ │ │ -
@ towardZero
always round toward 0
Definition float_cmp.hh:118
│ │ │ │ -
@ towardInf
always round away from 0
Definition float_cmp.hh:120
│ │ │ │ -
@ upward
round toward
Definition float_cmp.hh:124
│ │ │ │ -
@ downward
round toward
Definition float_cmp.hh:122
│ │ │ │ -
STL namespace.
│ │ │ │ +
220 int result = success ? 0 : 1;
│ │ │ │ +
221 bool was_active = active_;
│ │ │ │ +
222 active_ = false;
│ │ │ │ +
223 result = comm_->sum(result);
│ │ │ │ +
224 if (result>0 && was_active)
│ │ │ │ +
225 {
│ │ │ │ +
226 DUNE_THROW(MPIGuardError, "Terminating process "
│ │ │ │ +
227 << comm_->rank() << " due to "
│ │ │ │ +
228 << result << " remote error(s)");
│ │ │ │ +
229 }
│ │ │ │ +
230 }
│ │ │ │ +
│ │ │ │ +
231 };
│ │ │ │ +
│ │ │ │ +
232
│ │ │ │ +
233}
│ │ │ │ +
234
│ │ │ │ +
235#endif // DUNE_COMMON_MPIGUARD_HH
│ │ │ │ +
Helpers for dealing with MPI.
│ │ │ │ +
Implements an utility class that provides MPI's collective communication methods.
│ │ │ │ +
Implements an utility class that provides collective communication methods for sequential programs.
│ │ │ │ +
A few common exception classes.
│ │ │ │ +
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
vector space out of a tensor product of fields.
Definition fvector.hh:95
│ │ │ │ -
Mapping of value type to epsilon type.
Definition float_cmp.cc:23
│ │ │ │ -
T Type
The epsilon type corresponding to value type T.
Definition float_cmp.cc:25
│ │ │ │ -
EpsilonType< T >::Type Type
The epsilon type corresponding to value type std::vector<T, A>
Definition float_cmp.cc:36
│ │ │ │ -
EpsilonType< T >::Type Type
The epsilon type corresponding to value type Dune::FieldVector<T, n>
Definition float_cmp.cc:47
│ │ │ │ -
static EpsilonType< T >::Type value()
Definition float_cmp.cc:53
│ │ │ │ -
static EpsilonType< T >::Type value()
Definition float_cmp.cc:58
│ │ │ │ -
static EpsilonType< T >::Type value()
Definition float_cmp.cc:63
│ │ │ │ -
mapping from a value type and a compare style to a default epsilon
Definition float_cmp.hh:138
│ │ │ │ -
static EpsilonType< T >::Type value()
Returns the default epsilon for the given value type and compare style.
│ │ │ │ -
bool le(const ValueType &first, const ValueType &second) const
test if first lesser or equal second
Definition float_cmp.cc:486
│ │ │ │ -
FloatCmpOps(EpsilonType epsilon=DefaultEpsilon::value())
construct an operations object
Definition float_cmp.cc:431
│ │ │ │ -
bool eq(const ValueType &first, const ValueType &second) const
test for equality using epsilon
Definition float_cmp.cc:451
│ │ │ │ -
bool lt(const ValueType &first, const ValueType &second) const
test if first lesser than second
Definition float_cmp.cc:472
│ │ │ │ -
bool ge(const ValueType &first, const ValueType &second) const
test if first greater or equal second
Definition float_cmp.cc:479
│ │ │ │ -
FloatCmp::EpsilonType< T >::Type EpsilonType
Type of the epsilon.
Definition float_cmp.hh:304
│ │ │ │ -
bool ne(const ValueType &first, const ValueType &second) const
test for inequality using epsilon
Definition float_cmp.cc:458
│ │ │ │ -
T ValueType
Type of the values to compare.
Definition float_cmp.hh:299
│ │ │ │ -
EpsilonType epsilon() const
return the current epsilon
Definition float_cmp.cc:436
│ │ │ │ -
I round(const ValueType &val) const
round using epsilon
Definition float_cmp.cc:495
│ │ │ │ -
I trunc(const ValueType &val) const
truncate using epsilon
Definition float_cmp.cc:503
│ │ │ │ -
bool gt(const ValueType &first, const ValueType &second) const
test if first greater than second
Definition float_cmp.cc:465
│ │ │ │ +
Default exception if an error in the parallel communication of the program occurred.
Definition exceptions.hh:287
│ │ │ │ +
This exception is thrown if the MPIGuard detects an error on a remote process.
Definition mpiguard.hh:99
│ │ │ │ +
detects a thrown exception and communicates to all other processes
Definition mpiguard.hh:134
│ │ │ │ +
void reactivate()
reactivate the guard.
Definition mpiguard.hh:202
│ │ │ │ +
void finalize(bool success=true)
stop the guard.
Definition mpiguard.hh:218
│ │ │ │ +
~MPIGuard()
destroy the guard and check for undetected exceptions
Definition mpiguard.hh:188
│ │ │ │ +
MPIGuard(const C &comm, bool active=true)
create an MPIGuard operating on an arbitrary communicator.
Definition mpiguard.hh:174
│ │ │ │ +
MPIGuard(const MPI_Comm &comm, bool active=true)
Definition mpiguard.hh:180
│ │ │ │ +
MPIGuard(bool active=true)
create an MPIGuard operating on the Communicator of the global Dune::MPIHelper
Definition mpiguard.hh:146
│ │ │ │ +
MPIGuard(MPIHelper &m, bool active=true)
create an MPIGuard operating on the Communicator of a special Dune::MPIHelper m
Definition mpiguard.hh:157
│ │ │ │ +
A real mpi helper.
Definition mpihelper.hh:179
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,714 +7,230 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -float_cmp.cc │ │ │ │ │ + * parallel │ │ │ │ │ +mpiguard.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 (C) DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ - 5#include "float_cmp.hh" │ │ │ │ │ - 6 │ │ │ │ │ - 7#include │ │ │ │ │ - 8#include │ │ │ │ │ - 9#include │ │ │ │ │ - 10#include │ │ │ │ │ - 11#include │ │ │ │ │ - 12 │ │ │ │ │ - 13namespace Dune { │ │ │ │ │ - 14 │ │ │ │ │ + 5 │ │ │ │ │ + 13#ifndef DUNE_COMMON_MPIGUARD_HH │ │ │ │ │ + 14#define DUNE_COMMON_MPIGUARD_HH │ │ │ │ │ 15 │ │ │ │ │ -16 namespace FloatCmp { │ │ │ │ │ - 17 // traits │ │ │ │ │ - 19 │ │ │ │ │ -23 template struct EpsilonType { │ │ │ │ │ -25 typedef T Type; │ │ │ │ │ - 26 }; │ │ │ │ │ - 28 │ │ │ │ │ - 33 template │ │ │ │ │ -34 struct EpsilonType > { │ │ │ │ │ -36 typedef typename EpsilonType::Type Type; │ │ │ │ │ - 37 }; │ │ │ │ │ - 39 │ │ │ │ │ - 44 template │ │ │ │ │ -45 struct EpsilonType > { │ │ │ │ │ -47 typedef typename EpsilonType::Type Type; │ │ │ │ │ - 48 }; │ │ │ │ │ - 49 │ │ │ │ │ - 50 // default epsilon │ │ │ │ │ - 51 template │ │ │ │ │ -52 struct DefaultEpsilon { │ │ │ │ │ -53 static typename EpsilonType::Type value() │ │ │ │ │ - 54 { return std::numeric_limits::Type>::epsilon()*8.; │ │ │ │ │ -} │ │ │ │ │ - 55 }; │ │ │ │ │ - 56 template │ │ │ │ │ -57 struct DefaultEpsilon { │ │ │ │ │ -58 static typename EpsilonType::Type value() │ │ │ │ │ - 59 { return std::numeric_limits::Type>::epsilon()*8.; │ │ │ │ │ -} │ │ │ │ │ - 60 }; │ │ │ │ │ - 61 template │ │ │ │ │ -62 struct DefaultEpsilon { │ │ │ │ │ -63 static typename EpsilonType::Type value() │ │ │ │ │ - 64 { return std::max(std::numeric_limits::Type>:: │ │ │ │ │ -epsilon(), 1e-6); } │ │ │ │ │ - 65 }; │ │ │ │ │ - 66 │ │ │ │ │ - 67 namespace Impl { │ │ │ │ │ - 68 // basic comparison │ │ │ │ │ - 69 template │ │ │ │ │ - 70 struct eq_t; │ │ │ │ │ - 71 template │ │ │ │ │ - 72 struct eq_t { │ │ │ │ │ - 73 static bool eq(const T &first, │ │ │ │ │ - 74 const T &second, │ │ │ │ │ - 75 typename EpsilonType::Type epsilon = DefaultEpsilon::value()) │ │ │ │ │ - 76 { │ │ │ │ │ - 77 using std::abs; │ │ │ │ │ - 78 return abs(first - second) <= epsilon*std::max(abs(first), abs(second)); │ │ │ │ │ - 79 } │ │ │ │ │ - 80 }; │ │ │ │ │ - 81 template │ │ │ │ │ - 82 struct eq_t { │ │ │ │ │ - 83 static bool eq(const T &first, │ │ │ │ │ - 84 const T &second, │ │ │ │ │ - 85 typename EpsilonType::Type epsilon = DefaultEpsilon::value()) │ │ │ │ │ - 86 { │ │ │ │ │ - 87 using std::abs; │ │ │ │ │ - 88 return abs(first - second) <= epsilon*std::min(abs(first), abs(second)); │ │ │ │ │ - 89 } │ │ │ │ │ - 90 }; │ │ │ │ │ - 91 template │ │ │ │ │ - 92 struct eq_t { │ │ │ │ │ - 93 static bool eq(const T &first, │ │ │ │ │ - 94 const T &second, │ │ │ │ │ - 95 typename EpsilonType::Type epsilon = DefaultEpsilon::value()) │ │ │ │ │ - 96 { │ │ │ │ │ - 97 using std::abs; │ │ │ │ │ - 98 return abs(first-second) <= epsilon; │ │ │ │ │ - 99 } │ │ │ │ │ - 100 }; │ │ │ │ │ - 101 template │ │ │ │ │ - 102 struct eq_t_std_vec { │ │ │ │ │ - 103 typedef std::vector V; │ │ │ │ │ - 104 static bool eq(const V &first, │ │ │ │ │ - 105 const V &second, │ │ │ │ │ - 106 typename EpsilonType::Type epsilon = DefaultEpsilon::value()) { │ │ │ │ │ - 107 auto size = first.size(); │ │ │ │ │ - 108 if(size != second.size()) return false; │ │ │ │ │ - 109 for(unsigned int i = 0; i < size; ++i) │ │ │ │ │ - 110 if(!eq_t::eq(first[i], second[i], epsilon)) │ │ │ │ │ - 111 return false; │ │ │ │ │ - 112 return true; │ │ │ │ │ - 113 } │ │ │ │ │ - 114 }; │ │ │ │ │ - 115 template< class T> │ │ │ │ │ - 116 struct eq_t, relativeWeak> : eq_t_std_vec │ │ │ │ │ -{}; │ │ │ │ │ - 117 template< class T> │ │ │ │ │ - 118 struct eq_t, relativeStrong> : eq_t_std_vec {}; │ │ │ │ │ - 119 template< class T> │ │ │ │ │ - 120 struct eq_t, absolute> : eq_t_std_vec {}; │ │ │ │ │ - 121 │ │ │ │ │ - 122 template │ │ │ │ │ - 123 struct eq_t_fvec { │ │ │ │ │ - 124 typedef Dune::FieldVector V; │ │ │ │ │ - 125 static bool eq(const V &first, │ │ │ │ │ - 126 const V &second, │ │ │ │ │ - 127 typename EpsilonType::Type epsilon = DefaultEpsilon::value()) { │ │ │ │ │ - 128 for(int i = 0; i < n; ++i) │ │ │ │ │ - 129 if(!eq_t::eq(first[i], second[i], epsilon)) │ │ │ │ │ - 130 return false; │ │ │ │ │ - 131 return true; │ │ │ │ │ - 132 } │ │ │ │ │ - 133 }; │ │ │ │ │ - 134 template< class T, int n > │ │ │ │ │ - 135 struct eq_t< Dune::FieldVector, relativeWeak> : eq_t_fvec {}; │ │ │ │ │ - 136 template< class T, int n > │ │ │ │ │ - 137 struct eq_t< Dune::FieldVector, relativeStrong> : eq_t_fvec {}; │ │ │ │ │ - 138 template< class T, int n > │ │ │ │ │ - 139 struct eq_t< Dune::FieldVector, absolute> : eq_t_fvec {}; │ │ │ │ │ - 140 } // namespace Impl │ │ │ │ │ - 141 │ │ │ │ │ - 142 // operations in functional style │ │ │ │ │ - 143 template │ │ │ │ │ -144 bool eq(const T &first, │ │ │ │ │ - 145 const T &second, │ │ │ │ │ - 146 typename EpsilonType::Type epsilon) │ │ │ │ │ - 147 { │ │ │ │ │ - 148 return Impl::eq_t::eq(first, second, epsilon); │ │ │ │ │ - 149 } │ │ │ │ │ - 150 template │ │ │ │ │ -151 bool ne(const T &first, │ │ │ │ │ - 152 const T &second, │ │ │ │ │ - 153 typename EpsilonType::Type epsilon) │ │ │ │ │ - 154 { │ │ │ │ │ - 155 return !eq(first, second, epsilon); │ │ │ │ │ - 156 } │ │ │ │ │ - 157 template │ │ │ │ │ -158 bool gt(const T &first, │ │ │ │ │ - 159 const T &second, │ │ │ │ │ - 160 typename EpsilonType::Type epsilon) │ │ │ │ │ - 161 { │ │ │ │ │ - 162 return first > second && ne(first, second, epsilon); │ │ │ │ │ - 163 } │ │ │ │ │ - 164 template │ │ │ │ │ -165 bool lt(const T &first, │ │ │ │ │ - 166 const T &second, │ │ │ │ │ - 167 typename EpsilonType::Type epsilon) │ │ │ │ │ - 168 { │ │ │ │ │ - 169 return first < second && ne(first, second, epsilon); │ │ │ │ │ - 170 } │ │ │ │ │ - 171 template │ │ │ │ │ -172 bool ge(const T &first, │ │ │ │ │ - 173 const T &second, │ │ │ │ │ - 174 typename EpsilonType::Type epsilon) │ │ │ │ │ - 175 { │ │ │ │ │ - 176 return first > second || eq(first, second, epsilon); │ │ │ │ │ - 177 } │ │ │ │ │ - 178 template │ │ │ │ │ -179 bool le(const T &first, │ │ │ │ │ - 180 const T &second, │ │ │ │ │ - 181 typename EpsilonType::Type epsilon) │ │ │ │ │ - 182 { │ │ │ │ │ - 183 return first < second || eq(first, second, epsilon); │ │ │ │ │ - 184 } │ │ │ │ │ + 16#include "mpihelper.hh" │ │ │ │ │ + 17#include "communication.hh" │ │ │ │ │ + 18#include "mpicommunication.hh" │ │ │ │ │ + 19#include │ │ │ │ │ + 20 │ │ │ │ │ + 21namespace Dune │ │ │ │ │ + 22{ │ │ │ │ │ + 23 │ │ │ │ │ + 24#ifndef DOXYGEN │ │ │ │ │ + 25 │ │ │ │ │ + 26 /* │ │ │ │ │ + 27 Interface class for the communication needed by MPIGuard │ │ │ │ │ + 28 */ │ │ │ │ │ + 29 struct GuardCommunicator │ │ │ │ │ + 30 { │ │ │ │ │ + 31 // cleanup │ │ │ │ │ + 32 virtual ~GuardCommunicator() {}; │ │ │ │ │ + 33 // all the communication methods we need │ │ │ │ │ + 34 virtual int rank() = 0; │ │ │ │ │ + 35 virtual int size() = 0; │ │ │ │ │ + 36 virtual int sum(int i) = 0; │ │ │ │ │ + 37 // create a new GuardCommunicator pointer │ │ │ │ │ + 38 template │ │ │ │ │ + 39 static GuardCommunicator * create(const Communication & c); │ │ │ │ │ + 40#if HAVE_MPI │ │ │ │ │ + 41 inline │ │ │ │ │ + 42 static GuardCommunicator * create(const MPI_Comm & c); │ │ │ │ │ + 43#endif │ │ │ │ │ + 44 }; │ │ │ │ │ + 45 │ │ │ │ │ + 46 namespace { │ │ │ │ │ + 47 /* │ │ │ │ │ + 48 templated implementation of different communication classes │ │ │ │ │ + 49 */ │ │ │ │ │ + 50 // the default class will always fail, due to the missing implementation of │ │ │ │ │ +"sum" │ │ │ │ │ + 51 template │ │ │ │ │ + 52 struct GenericGuardCommunicator │ │ │ │ │ + 53 : public GuardCommunicator │ │ │ │ │ + 54 {}; │ │ │ │ │ + 55 // specialization for Communication │ │ │ │ │ + 56 template │ │ │ │ │ + 57 struct GenericGuardCommunicator< Communication > │ │ │ │ │ + 58 : public GuardCommunicator │ │ │ │ │ + 59 { │ │ │ │ │ + 60 const Communication comm; │ │ │ │ │ + 61 GenericGuardCommunicator(const Communication & c) : │ │ │ │ │ + 62 comm(c) {} │ │ │ │ │ + 63 int rank() override { return comm.rank(); }; │ │ │ │ │ + 64 int size() override { return comm.size(); }; │ │ │ │ │ + 65 int sum(int i) override { return comm.sum(i); } │ │ │ │ │ + 66 }; │ │ │ │ │ + 67 │ │ │ │ │ + 68#if HAVE_MPI │ │ │ │ │ + 69 // specialization for MPI_Comm │ │ │ │ │ + 70 template <> │ │ │ │ │ + 71 struct GenericGuardCommunicator │ │ │ │ │ + 72 : public GenericGuardCommunicator< Communication > │ │ │ │ │ + 73 { │ │ │ │ │ + 74 GenericGuardCommunicator(const MPI_Comm & c) : │ │ │ │ │ + 75 GenericGuardCommunicator< Communication >( │ │ │ │ │ + 76 Communication(c)) {} │ │ │ │ │ + 77 }; │ │ │ │ │ + 78#endif │ │ │ │ │ + 79 } // anonymous namespace │ │ │ │ │ + 80 │ │ │ │ │ + 81 template │ │ │ │ │ + 82 GuardCommunicator * GuardCommunicator::create(const Communication & │ │ │ │ │ +comm) │ │ │ │ │ + 83 { │ │ │ │ │ + 84 return new GenericGuardCommunicator< Communication >(comm); │ │ │ │ │ + 85 } │ │ │ │ │ + 86 │ │ │ │ │ + 87#if HAVE_MPI │ │ │ │ │ + 88 GuardCommunicator * GuardCommunicator::create(const MPI_Comm & comm) │ │ │ │ │ + 89 { │ │ │ │ │ + 90 return new GenericGuardCommunicator< Communication >(comm); │ │ │ │ │ + 91 } │ │ │ │ │ + 92#endif │ │ │ │ │ + 93 │ │ │ │ │ + 94#endif │ │ │ │ │ + 95 │ │ │ │ │ +99 class MPIGuardError : public ParallelError {}; │ │ │ │ │ + 100 │ │ │ │ │ +133 class MPIGuard │ │ │ │ │ + 134 { │ │ │ │ │ + 135 GuardCommunicator * comm_; │ │ │ │ │ + 136 bool active_; │ │ │ │ │ + 137 │ │ │ │ │ + 138 // we don't want to copy this class │ │ │ │ │ + 139 MPIGuard (const MPIGuard &); │ │ │ │ │ + 140 │ │ │ │ │ + 141 public: │ │ │ │ │ +146 MPIGuard (bool active=true) : │ │ │ │ │ + 147 comm_(GuardCommunicator::create( │ │ │ │ │ + 148 MPIHelper::getCommunication())), │ │ │ │ │ + 149 active_(active) │ │ │ │ │ + 150 {} │ │ │ │ │ + 151 │ │ │ │ │ +157 MPIGuard (MPIHelper & m, bool active=true) : │ │ │ │ │ + 158 comm_(GuardCommunicator::create( │ │ │ │ │ + 159 m.getCommunication())), │ │ │ │ │ + 160 active_(active) │ │ │ │ │ + 161 {} │ │ │ │ │ + 162 │ │ │ │ │ + 173 template │ │ │ │ │ +174 MPIGuard (const C & comm, bool active=true) : │ │ │ │ │ + 175 comm_(GuardCommunicator::create(comm)), │ │ │ │ │ + 176 active_(active) │ │ │ │ │ + 177 {} │ │ │ │ │ + 178 │ │ │ │ │ + 179#if HAVE_MPI │ │ │ │ │ +180 MPIGuard (const MPI_Comm & comm, bool active=true) : │ │ │ │ │ + 181 comm_(GuardCommunicator::create(comm)), │ │ │ │ │ + 182 active_(active) │ │ │ │ │ + 183 {} │ │ │ │ │ + 184#endif │ │ │ │ │ 185 │ │ │ │ │ - 186 // default template arguments │ │ │ │ │ - 187 template │ │ │ │ │ -188 bool eq(const T &first, │ │ │ │ │ - 189 const T &second, │ │ │ │ │ - 190 typename EpsilonType::Type epsilon = DefaultEpsilon::value()) │ │ │ │ │ +188 ~MPIGuard() │ │ │ │ │ + 189 { │ │ │ │ │ + 190 if (active_) │ │ │ │ │ 191 { │ │ │ │ │ - 192 return eq(first, second, epsilon); │ │ │ │ │ - 193 } │ │ │ │ │ - 194 template │ │ │ │ │ -195 bool ne(const T &first, │ │ │ │ │ - 196 const T &second, │ │ │ │ │ - 197 typename EpsilonType::Type epsilon = DefaultEpsilon::value()) │ │ │ │ │ - 198 { │ │ │ │ │ - 199 return ne(first, second, epsilon); │ │ │ │ │ - 200 } │ │ │ │ │ - 201 template │ │ │ │ │ -202 bool gt(const T &first, │ │ │ │ │ - 203 const T &second, │ │ │ │ │ - 204 typename EpsilonType::Type epsilon = DefaultEpsilon::value()) │ │ │ │ │ - 205 { │ │ │ │ │ - 206 return gt(first, second, epsilon); │ │ │ │ │ - 207 } │ │ │ │ │ - 208 template │ │ │ │ │ -209 bool lt(const T &first, │ │ │ │ │ - 210 const T &second, │ │ │ │ │ - 211 typename EpsilonType::Type epsilon = DefaultEpsilon::value()) │ │ │ │ │ - 212 { │ │ │ │ │ - 213 return lt(first, second, epsilon); │ │ │ │ │ - 214 } │ │ │ │ │ - 215 template │ │ │ │ │ -216 bool ge(const T &first, │ │ │ │ │ - 217 const T &second, │ │ │ │ │ - 218 typename EpsilonType::Type epsilon = DefaultEpsilon::value()) │ │ │ │ │ + 192 active_ = false; │ │ │ │ │ + 193 finalize(false); │ │ │ │ │ + 194 } │ │ │ │ │ + 195 delete comm_; │ │ │ │ │ + 196 } │ │ │ │ │ + 197 │ │ │ │ │ +202 void reactivate() { │ │ │ │ │ + 203 if (active_ == true) │ │ │ │ │ + 204 finalize(); │ │ │ │ │ + 205 active_ = true; │ │ │ │ │ + 206 } │ │ │ │ │ + 207 │ │ │ │ │ +218 void finalize(bool success = true) │ │ │ │ │ 219 { │ │ │ │ │ - 220 return ge(first, second, epsilon); │ │ │ │ │ - 221 } │ │ │ │ │ - 222 template │ │ │ │ │ -223 bool le(const T &first, │ │ │ │ │ - 224 const T &second, │ │ │ │ │ - 225 typename EpsilonType::Type epsilon = DefaultEpsilon::value()) │ │ │ │ │ - 226 { │ │ │ │ │ - 227 return le(first, second, epsilon); │ │ │ │ │ - 228 } │ │ │ │ │ - 229 │ │ │ │ │ - 230 // rounding operations │ │ │ │ │ - 231 namespace Impl { │ │ │ │ │ - 232 template │ │ │ │ │ - 233 struct round_t; │ │ │ │ │ - 234 template │ │ │ │ │ - 235 struct round_t { │ │ │ │ │ - 236 static I │ │ │ │ │ - 237 round(const T &val, │ │ │ │ │ - 238 typename EpsilonType::Type epsilon = (DefaultEpsilon::value │ │ │ │ │ -())) { │ │ │ │ │ - 239 // first get an approximation │ │ │ │ │ - 240 I lower = I(val); │ │ │ │ │ - 241 I upper; │ │ │ │ │ - 242 if(eq(T(lower), val, epsilon)) return lower; │ │ │ │ │ - 243 if(T(lower) > val) { upper = lower; lower--; } │ │ │ │ │ - 244 else upper = lower+1; │ │ │ │ │ - 245 if(le(val - T(lower), T(upper) - val, epsilon)) │ │ │ │ │ - 246 return lower; │ │ │ │ │ - 247 else return upper; │ │ │ │ │ - 248 } │ │ │ │ │ - 249 }; │ │ │ │ │ - 250 template │ │ │ │ │ - 251 struct round_t { │ │ │ │ │ - 252 static I │ │ │ │ │ - 253 round(const T &val, │ │ │ │ │ - 254 typename EpsilonType::Type epsilon = (DefaultEpsilon::value │ │ │ │ │ -())) { │ │ │ │ │ - 255 // first get an approximation │ │ │ │ │ - 256 I lower = I(val); │ │ │ │ │ - 257 I upper; │ │ │ │ │ - 258 if(eq(T(lower), val, epsilon)) return lower; │ │ │ │ │ - 259 if(T(lower) > val) { upper = lower; lower--; } │ │ │ │ │ - 260 else upper = lower+1; │ │ │ │ │ - 261 if(lt(val - T(lower), T(upper) - val, epsilon)) │ │ │ │ │ - 262 return lower; │ │ │ │ │ - 263 else return upper; │ │ │ │ │ - 264 } │ │ │ │ │ - 265 }; │ │ │ │ │ - 266 template │ │ │ │ │ - 267 struct round_t { │ │ │ │ │ - 268 static I │ │ │ │ │ - 269 round(const T &val, │ │ │ │ │ - 270 typename EpsilonType::Type epsilon = (DefaultEpsilon::value │ │ │ │ │ -())) { │ │ │ │ │ - 271 if(val > T(0)) │ │ │ │ │ - 272 return round_t::round(val, epsilon); │ │ │ │ │ - 273 else return round_t::round(val, epsilon); │ │ │ │ │ - 274 } │ │ │ │ │ - 275 }; │ │ │ │ │ - 276 template │ │ │ │ │ - 277 struct round_t { │ │ │ │ │ - 278 static I │ │ │ │ │ - 279 round(const T &val, │ │ │ │ │ - 280 typename EpsilonType::Type epsilon = (DefaultEpsilon::value │ │ │ │ │ -())) { │ │ │ │ │ - 281 if(val > T(0)) │ │ │ │ │ - 282 return round_t::round(val, epsilon); │ │ │ │ │ - 283 else return round_t::round(val, epsilon); │ │ │ │ │ - 284 } │ │ │ │ │ - 285 }; │ │ │ │ │ - 286 template │ │ │ │ │ - 287 struct round_t, std::vector, cstyle, rstyle> { │ │ │ │ │ - 288 static std::vector │ │ │ │ │ - 289 round(const T &val, │ │ │ │ │ - 290 typename EpsilonType::Type epsilon = (DefaultEpsilon::value │ │ │ │ │ -())) { │ │ │ │ │ - 291 unsigned int size = val.size(); │ │ │ │ │ - 292 std::vector res(size); │ │ │ │ │ - 293 for(unsigned int i = 0; i < size; ++i) │ │ │ │ │ - 294 res[i] = round_t::round(val[i], epsilon); │ │ │ │ │ - 295 return res; │ │ │ │ │ - 296 } │ │ │ │ │ - 297 }; │ │ │ │ │ - 298 template │ │ │ │ │ - 299 struct round_t, Dune::FieldVector, cstyle, │ │ │ │ │ -rstyle> { │ │ │ │ │ - 300 static Dune::FieldVector │ │ │ │ │ - 301 round(const T &val, │ │ │ │ │ - 302 typename EpsilonType::Type epsilon = (DefaultEpsilon::value │ │ │ │ │ -())) { │ │ │ │ │ - 303 Dune::FieldVector res; │ │ │ │ │ - 304 for(int i = 0; i < n; ++i) │ │ │ │ │ - 305 res[i] = round_t::round(val[i], epsilon); │ │ │ │ │ - 306 return res; │ │ │ │ │ - 307 } │ │ │ │ │ - 308 }; │ │ │ │ │ - 309 } // end namespace Impl │ │ │ │ │ - 310 template │ │ │ │ │ -311 I round(const T &val, typename EpsilonType::Type epsilon /*= │ │ │ │ │ -DefaultEpsilon::value()*/) │ │ │ │ │ - 312 { │ │ │ │ │ - 313 return Impl::round_t::round(val, epsilon); │ │ │ │ │ - 314 } │ │ │ │ │ - 315 template │ │ │ │ │ -316 I round(const T &val, typename EpsilonType::Type epsilon = │ │ │ │ │ -DefaultEpsilon::value()) │ │ │ │ │ - 317 { │ │ │ │ │ - 318 return round(val, epsilon); │ │ │ │ │ - 319 } │ │ │ │ │ - 320 template │ │ │ │ │ - 321 I round(const T &val, typename EpsilonType::Type epsilon = │ │ │ │ │ -DefaultEpsilon::value()) │ │ │ │ │ - 322 { │ │ │ │ │ - 323 return round(val, epsilon); │ │ │ │ │ - 324 } │ │ │ │ │ - 325 template │ │ │ │ │ -326 I round(const T &val, typename EpsilonType::Type epsilon = │ │ │ │ │ -DefaultEpsilon::value()) │ │ │ │ │ - 327 { │ │ │ │ │ - 328 return round(val, epsilon); │ │ │ │ │ - 329 } │ │ │ │ │ - 330 │ │ │ │ │ - 331 // truncation │ │ │ │ │ - 332 namespace Impl { │ │ │ │ │ - 333 template │ │ │ │ │ - 334 struct trunc_t; │ │ │ │ │ - 335 template │ │ │ │ │ - 336 struct trunc_t { │ │ │ │ │ - 337 static I │ │ │ │ │ - 338 trunc(const T &val, │ │ │ │ │ - 339 typename EpsilonType::Type epsilon = (DefaultEpsilon::value │ │ │ │ │ -())) { │ │ │ │ │ - 340 // this should be optimized away unless needed │ │ │ │ │ - 341 if(!std::numeric_limits::is_signed) │ │ │ │ │ - 342 // make sure this works for all useful cases even if I is an unsigned type │ │ │ │ │ - 343 if(eq(val, T(0), epsilon)) return I(0); │ │ │ │ │ - 344 // first get an approximation │ │ │ │ │ - 345 I lower = I(val); // now |val-lower| < 1 │ │ │ │ │ - 346 // make sure we're really lower in case the cast truncated to an │ │ │ │ │ -unexpected direction │ │ │ │ │ - 347 if(T(lower) > val) lower--; // now val-lower < 1 │ │ │ │ │ - 348 // check whether lower + 1 is approximately val │ │ │ │ │ - 349 if(eq(T(lower+1), val, epsilon)) │ │ │ │ │ - 350 return lower+1; │ │ │ │ │ - 351 else return lower; │ │ │ │ │ - 352 } │ │ │ │ │ - 353 }; │ │ │ │ │ - 354 template │ │ │ │ │ - 355 struct trunc_t { │ │ │ │ │ - 356 static I │ │ │ │ │ - 357 trunc(const T &val, │ │ │ │ │ - 358 typename EpsilonType::Type epsilon = (DefaultEpsilon::value │ │ │ │ │ -())) { │ │ │ │ │ - 359 I upper = trunc_t::trunc(val, epsilon); │ │ │ │ │ - 360 if(ne(T(upper), val, epsilon)) ++upper; │ │ │ │ │ - 361 return upper; │ │ │ │ │ - 362 } │ │ │ │ │ - 363 }; │ │ │ │ │ - 364 template │ │ │ │ │ - 365 struct trunc_t { │ │ │ │ │ - 366 static I │ │ │ │ │ - 367 trunc(const T &val, │ │ │ │ │ - 368 typename EpsilonType::Type epsilon = (DefaultEpsilon::value │ │ │ │ │ -())) { │ │ │ │ │ - 369 if(val > T(0)) return trunc_t::trunc(val, │ │ │ │ │ -epsilon); │ │ │ │ │ - 370 else return trunc_t::trunc(val, epsilon); │ │ │ │ │ - 371 } │ │ │ │ │ - 372 }; │ │ │ │ │ - 373 template │ │ │ │ │ - 374 struct trunc_t { │ │ │ │ │ - 375 static I │ │ │ │ │ - 376 trunc(const T &val, │ │ │ │ │ - 377 typename EpsilonType::Type epsilon = (DefaultEpsilon::value │ │ │ │ │ -())) { │ │ │ │ │ - 378 if(val > T(0)) return trunc_t::trunc(val, epsilon); │ │ │ │ │ - 379 else return trunc_t::trunc(val, epsilon); │ │ │ │ │ - 380 } │ │ │ │ │ - 381 }; │ │ │ │ │ - 382 template │ │ │ │ │ - 383 struct trunc_t, std::vector, cstyle, rstyle> { │ │ │ │ │ - 384 static std::vector │ │ │ │ │ - 385 trunc(const std::vector &val, │ │ │ │ │ - 386 typename EpsilonType::Type epsilon = (DefaultEpsilon::value │ │ │ │ │ -())) { │ │ │ │ │ - 387 unsigned int size = val.size(); │ │ │ │ │ - 388 std::vector res(size); │ │ │ │ │ - 389 for(unsigned int i = 0; i < size; ++i) │ │ │ │ │ - 390 res[i] = trunc_t::trunc(val[i], epsilon); │ │ │ │ │ - 391 return res; │ │ │ │ │ - 392 } │ │ │ │ │ - 393 }; │ │ │ │ │ - 394 template │ │ │ │ │ - 395 struct trunc_t, Dune::FieldVector, cstyle, │ │ │ │ │ -rstyle> { │ │ │ │ │ - 396 static Dune::FieldVector │ │ │ │ │ - 397 trunc(const Dune::FieldVector &val, │ │ │ │ │ - 398 typename EpsilonType::Type epsilon = (DefaultEpsilon::value │ │ │ │ │ -())) { │ │ │ │ │ - 399 Dune::FieldVector res; │ │ │ │ │ - 400 for(int i = 0; i < n; ++i) │ │ │ │ │ - 401 res[i] = trunc_t::trunc(val[i], epsilon); │ │ │ │ │ - 402 return res; │ │ │ │ │ - 403 } │ │ │ │ │ - 404 }; │ │ │ │ │ - 405 } // namespace Impl │ │ │ │ │ - 406 template │ │ │ │ │ -407 I trunc(const T &val, typename EpsilonType::Type epsilon /*= │ │ │ │ │ -DefaultEpsilon::value()*/) │ │ │ │ │ - 408 { │ │ │ │ │ - 409 return Impl::trunc_t::trunc(val, epsilon); │ │ │ │ │ - 410 } │ │ │ │ │ - 411 template │ │ │ │ │ -412 I trunc(const T &val, typename EpsilonType::Type epsilon = │ │ │ │ │ -DefaultEpsilon::value()) │ │ │ │ │ - 413 { │ │ │ │ │ - 414 return trunc(val, epsilon); │ │ │ │ │ - 415 } │ │ │ │ │ - 416 template │ │ │ │ │ - 417 I trunc(const T &val, typename EpsilonType::Type epsilon = │ │ │ │ │ -DefaultEpsilon::value()) │ │ │ │ │ - 418 { │ │ │ │ │ - 419 return trunc(val, epsilon); │ │ │ │ │ - 420 } │ │ │ │ │ - 421 template │ │ │ │ │ -422 I trunc(const T &val, typename EpsilonType::Type epsilon = │ │ │ │ │ -DefaultEpsilon::value()) │ │ │ │ │ - 423 { │ │ │ │ │ - 424 return trunc(val, epsilon); │ │ │ │ │ - 425 } │ │ │ │ │ - 426 } //namespace Dune │ │ │ │ │ - 427 │ │ │ │ │ - 428 // oo interface │ │ │ │ │ - 429 template │ │ │ │ │ -430 FloatCmpOps:: │ │ │ │ │ - 431FloatCmpOps(EpsilonType epsilon) : epsilon_(epsilon) {} │ │ │ │ │ - 432 │ │ │ │ │ - 433 │ │ │ │ │ - 434 template │ │ │ │ │ - 435 typename FloatCmpOps::EpsilonType │ │ │ │ │ -436 FloatCmpOps::epsilon() const │ │ │ │ │ - 437 { │ │ │ │ │ - 438 return epsilon_; │ │ │ │ │ - 439 } │ │ │ │ │ - 440 │ │ │ │ │ - 441 template │ │ │ │ │ - 442 void │ │ │ │ │ -443 FloatCmpOps::epsilon(EpsilonType epsilon__) │ │ │ │ │ - 444 { │ │ │ │ │ - 445 epsilon_ = epsilon__; │ │ │ │ │ - 446 } │ │ │ │ │ - 447 │ │ │ │ │ - 448 │ │ │ │ │ - 449 template │ │ │ │ │ -450 bool FloatCmpOps:: │ │ │ │ │ - 451eq(const ValueType &first, const ValueType &second) const │ │ │ │ │ - 452 { │ │ │ │ │ - 453 return Dune::FloatCmp::eq(first, second, epsilon_); │ │ │ │ │ - 454 } │ │ │ │ │ - 455 │ │ │ │ │ - 456 template │ │ │ │ │ -457 bool FloatCmpOps:: │ │ │ │ │ - 458ne(const ValueType &first, const ValueType &second) const │ │ │ │ │ - 459 { │ │ │ │ │ - 460 return Dune::FloatCmp::ne(first, second, epsilon_); │ │ │ │ │ - 461 } │ │ │ │ │ - 462 │ │ │ │ │ - 463 template │ │ │ │ │ -464 bool FloatCmpOps:: │ │ │ │ │ - 465gt(const ValueType &first, const ValueType &second) const │ │ │ │ │ - 466 { │ │ │ │ │ - 467 return Dune::FloatCmp::gt(first, second, epsilon_); │ │ │ │ │ - 468 } │ │ │ │ │ - 469 │ │ │ │ │ - 470 template │ │ │ │ │ -471 bool FloatCmpOps:: │ │ │ │ │ - 472lt(const ValueType &first, const ValueType &second) const │ │ │ │ │ - 473 { │ │ │ │ │ - 474 return Dune::FloatCmp::lt(first, second, epsilon_); │ │ │ │ │ - 475 } │ │ │ │ │ - 476 │ │ │ │ │ - 477 template │ │ │ │ │ -478 bool FloatCmpOps:: │ │ │ │ │ - 479ge(const ValueType &first, const ValueType &second) const │ │ │ │ │ - 480 { │ │ │ │ │ - 481 return Dune::FloatCmp::ge(first, second, epsilon_); │ │ │ │ │ - 482 } │ │ │ │ │ - 483 │ │ │ │ │ - 484 template │ │ │ │ │ -485 bool FloatCmpOps:: │ │ │ │ │ - 486le(const ValueType &first, const ValueType &second) const │ │ │ │ │ - 487 { │ │ │ │ │ - 488 return Dune::FloatCmp::le(first, second, epsilon_); │ │ │ │ │ - 489 } │ │ │ │ │ - 490 │ │ │ │ │ - 491 │ │ │ │ │ - 492 template │ │ │ │ │ - 493 template │ │ │ │ │ -494 I FloatCmpOps:: │ │ │ │ │ - 495round(const ValueType &val) const │ │ │ │ │ - 496 { │ │ │ │ │ - 497 return Dune::FloatCmp::round(val, │ │ │ │ │ -epsilon_); │ │ │ │ │ - 498 } │ │ │ │ │ - 499 │ │ │ │ │ - 500 template │ │ │ │ │ - 501 template │ │ │ │ │ -502 I FloatCmpOps:: │ │ │ │ │ - 503trunc(const ValueType &val) const │ │ │ │ │ - 504 { │ │ │ │ │ - 505 return Dune::FloatCmp::trunc(val, │ │ │ │ │ -epsilon_); │ │ │ │ │ - 506 } │ │ │ │ │ - 507 │ │ │ │ │ - 508} //namespace Dune │ │ │ │ │ -float_cmp.hh │ │ │ │ │ -Various ways to compare floating-point numbers. │ │ │ │ │ -fvector.hh │ │ │ │ │ -Implements a vector constructed from a given type representing a field and a │ │ │ │ │ -compile-time given size. │ │ │ │ │ -Dune::FloatCmp::ne │ │ │ │ │ -bool ne(const T &first, const T &second, typename EpsilonType< T >::Type │ │ │ │ │ -epsilon) │ │ │ │ │ -test for inequality using epsilon │ │ │ │ │ -Definition float_cmp.cc:151 │ │ │ │ │ -Dune::FloatCmp::eq │ │ │ │ │ -bool eq(const T &first, const T &second, typename EpsilonType< T >::Type │ │ │ │ │ -epsilon) │ │ │ │ │ -test for equality using epsilon │ │ │ │ │ -Definition float_cmp.cc:144 │ │ │ │ │ -Dune::FloatCmp::round │ │ │ │ │ -I round(const T &val, typename EpsilonType< T >::Type epsilon) │ │ │ │ │ -round using epsilon │ │ │ │ │ -Definition float_cmp.cc:311 │ │ │ │ │ -Dune::FloatCmp::trunc │ │ │ │ │ -I trunc(const T &val, typename EpsilonType< T >::Type epsilon) │ │ │ │ │ -truncate using epsilon │ │ │ │ │ -Definition float_cmp.cc:407 │ │ │ │ │ -Dune::FloatCmp::lt │ │ │ │ │ -bool lt(const T &first, const T &second, typename EpsilonType< T >::Type │ │ │ │ │ -epsilon) │ │ │ │ │ -test if first lesser than second │ │ │ │ │ -Definition float_cmp.cc:165 │ │ │ │ │ -Dune::FloatCmp::gt │ │ │ │ │ -bool gt(const T &first, const T &second, typename EpsilonType< T >::Type │ │ │ │ │ -epsilon) │ │ │ │ │ -test if first greater than second │ │ │ │ │ -Definition float_cmp.cc:158 │ │ │ │ │ -Dune::FloatCmp::ge │ │ │ │ │ -bool ge(const T &first, const T &second, typename EpsilonType< T >::Type │ │ │ │ │ -epsilon) │ │ │ │ │ -test if first greater or equal second │ │ │ │ │ -Definition float_cmp.cc:172 │ │ │ │ │ -Dune::FloatCmp::le │ │ │ │ │ -bool le(const T &first, const T &second, typename EpsilonType< T >::Type │ │ │ │ │ -epsilon) │ │ │ │ │ -test if first lesser or equal second │ │ │ │ │ -Definition float_cmp.cc:179 │ │ │ │ │ -Dune::FloatCmp::relativeStrong │ │ │ │ │ -@ relativeStrong │ │ │ │ │ -|a-b|/|a| <= epsilon && |a-b|/|b| <= epsilon │ │ │ │ │ -Definition float_cmp.hh:108 │ │ │ │ │ -Dune::FloatCmp::relativeWeak │ │ │ │ │ -@ relativeWeak │ │ │ │ │ -|a-b|/|a| <= epsilon || |a-b|/|b| <= epsilon │ │ │ │ │ -Definition float_cmp.hh:106 │ │ │ │ │ -Dune::FloatCmp::absolute │ │ │ │ │ -@ absolute │ │ │ │ │ -|a-b| <= epsilon │ │ │ │ │ -Definition float_cmp.hh:110 │ │ │ │ │ -Dune::FloatCmp::towardZero │ │ │ │ │ -@ towardZero │ │ │ │ │ -always round toward 0 │ │ │ │ │ -Definition float_cmp.hh:118 │ │ │ │ │ -Dune::FloatCmp::towardInf │ │ │ │ │ -@ towardInf │ │ │ │ │ -always round away from 0 │ │ │ │ │ -Definition float_cmp.hh:120 │ │ │ │ │ -Dune::FloatCmp::upward │ │ │ │ │ -@ upward │ │ │ │ │ -round toward │ │ │ │ │ -Definition float_cmp.hh:124 │ │ │ │ │ -Dune::FloatCmp::downward │ │ │ │ │ -@ downward │ │ │ │ │ -round toward │ │ │ │ │ -Definition float_cmp.hh:122 │ │ │ │ │ -std │ │ │ │ │ -STL namespace. │ │ │ │ │ + 220 int result = success ? 0 : 1; │ │ │ │ │ + 221 bool was_active = active_; │ │ │ │ │ + 222 active_ = false; │ │ │ │ │ + 223 result = comm_->sum(result); │ │ │ │ │ + 224 if (result>0 && was_active) │ │ │ │ │ + 225 { │ │ │ │ │ + 226 DUNE_THROW(MPIGuardError, "Terminating process " │ │ │ │ │ + 227 << comm_->rank() << " due to " │ │ │ │ │ + 228 << result << " remote error(s)"); │ │ │ │ │ + 229 } │ │ │ │ │ + 230 } │ │ │ │ │ + 231 }; │ │ │ │ │ + 232 │ │ │ │ │ + 233} │ │ │ │ │ + 234 │ │ │ │ │ + 235#endif // DUNE_COMMON_MPIGUARD_HH │ │ │ │ │ +mpihelper.hh │ │ │ │ │ +Helpers for dealing with MPI. │ │ │ │ │ +mpicommunication.hh │ │ │ │ │ +Implements an utility class that provides MPI's collective communication │ │ │ │ │ +methods. │ │ │ │ │ +communication.hh │ │ │ │ │ +Implements an utility class that provides collective communication methods for │ │ │ │ │ +sequential programs. │ │ │ │ │ +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::FieldVector │ │ │ │ │ -vector space out of a tensor product of fields. │ │ │ │ │ -Definition fvector.hh:95 │ │ │ │ │ -Dune::FloatCmp::EpsilonType │ │ │ │ │ -Mapping of value type to epsilon type. │ │ │ │ │ -Definition float_cmp.cc:23 │ │ │ │ │ -Dune::FloatCmp::EpsilonType::Type │ │ │ │ │ -T Type │ │ │ │ │ -The epsilon type corresponding to value type T. │ │ │ │ │ -Definition float_cmp.cc:25 │ │ │ │ │ -Dune::FloatCmp::EpsilonType<_std::vector<_T,_A_>_>::Type │ │ │ │ │ -EpsilonType< T >::Type Type │ │ │ │ │ -The epsilon type corresponding to value type std::vector │ │ │ │ │ -Definition float_cmp.cc:36 │ │ │ │ │ -Dune::FloatCmp::EpsilonType<_FieldVector<_T,_n_>_>::Type │ │ │ │ │ -EpsilonType< T >::Type Type │ │ │ │ │ -The epsilon type corresponding to value type Dune::FieldVector │ │ │ │ │ -Definition float_cmp.cc:47 │ │ │ │ │ -Dune::FloatCmp::DefaultEpsilon<_T,_relativeWeak_>::value │ │ │ │ │ -static EpsilonType< T >::Type value() │ │ │ │ │ -Definition float_cmp.cc:53 │ │ │ │ │ -Dune::FloatCmp::DefaultEpsilon<_T,_relativeStrong_>::value │ │ │ │ │ -static EpsilonType< T >::Type value() │ │ │ │ │ -Definition float_cmp.cc:58 │ │ │ │ │ -Dune::FloatCmp::DefaultEpsilon<_T,_absolute_>::value │ │ │ │ │ -static EpsilonType< T >::Type value() │ │ │ │ │ -Definition float_cmp.cc:63 │ │ │ │ │ -Dune::FloatCmp::DefaultEpsilon │ │ │ │ │ -mapping from a value type and a compare style to a default epsilon │ │ │ │ │ -Definition float_cmp.hh:138 │ │ │ │ │ -Dune::FloatCmp::DefaultEpsilon::value │ │ │ │ │ -static EpsilonType< T >::Type value() │ │ │ │ │ -Returns the default epsilon for the given value type and compare style. │ │ │ │ │ -Dune::FloatCmpOps::le │ │ │ │ │ -bool le(const ValueType &first, const ValueType &second) const │ │ │ │ │ -test if first lesser or equal second │ │ │ │ │ -Definition float_cmp.cc:486 │ │ │ │ │ -Dune::FloatCmpOps::FloatCmpOps │ │ │ │ │ -FloatCmpOps(EpsilonType epsilon=DefaultEpsilon::value()) │ │ │ │ │ -construct an operations object │ │ │ │ │ -Definition float_cmp.cc:431 │ │ │ │ │ -Dune::FloatCmpOps::eq │ │ │ │ │ -bool eq(const ValueType &first, const ValueType &second) const │ │ │ │ │ -test for equality using epsilon │ │ │ │ │ -Definition float_cmp.cc:451 │ │ │ │ │ -Dune::FloatCmpOps::lt │ │ │ │ │ -bool lt(const ValueType &first, const ValueType &second) const │ │ │ │ │ -test if first lesser than second │ │ │ │ │ -Definition float_cmp.cc:472 │ │ │ │ │ -Dune::FloatCmpOps::ge │ │ │ │ │ -bool ge(const ValueType &first, const ValueType &second) const │ │ │ │ │ -test if first greater or equal second │ │ │ │ │ -Definition float_cmp.cc:479 │ │ │ │ │ -Dune::FloatCmpOps::EpsilonType │ │ │ │ │ -FloatCmp::EpsilonType< T >::Type EpsilonType │ │ │ │ │ -Type of the epsilon. │ │ │ │ │ -Definition float_cmp.hh:304 │ │ │ │ │ -Dune::FloatCmpOps::ne │ │ │ │ │ -bool ne(const ValueType &first, const ValueType &second) const │ │ │ │ │ -test for inequality using epsilon │ │ │ │ │ -Definition float_cmp.cc:458 │ │ │ │ │ -Dune::FloatCmpOps::ValueType │ │ │ │ │ -T ValueType │ │ │ │ │ -Type of the values to compare. │ │ │ │ │ -Definition float_cmp.hh:299 │ │ │ │ │ -Dune::FloatCmpOps::epsilon │ │ │ │ │ -EpsilonType epsilon() const │ │ │ │ │ -return the current epsilon │ │ │ │ │ -Definition float_cmp.cc:436 │ │ │ │ │ -Dune::FloatCmpOps::round │ │ │ │ │ -I round(const ValueType &val) const │ │ │ │ │ -round using epsilon │ │ │ │ │ -Definition float_cmp.cc:495 │ │ │ │ │ -Dune::FloatCmpOps::trunc │ │ │ │ │ -I trunc(const ValueType &val) const │ │ │ │ │ -truncate using epsilon │ │ │ │ │ -Definition float_cmp.cc:503 │ │ │ │ │ -Dune::FloatCmpOps::gt │ │ │ │ │ -bool gt(const ValueType &first, const ValueType &second) const │ │ │ │ │ -test if first greater than second │ │ │ │ │ -Definition float_cmp.cc:465 │ │ │ │ │ +Dune::ParallelError │ │ │ │ │ +Default exception if an error in the parallel communication of the program │ │ │ │ │ +occurred. │ │ │ │ │ +Definition exceptions.hh:287 │ │ │ │ │ +Dune::MPIGuardError │ │ │ │ │ +This exception is thrown if the MPIGuard detects an error on a remote process. │ │ │ │ │ +Definition mpiguard.hh:99 │ │ │ │ │ +Dune::MPIGuard │ │ │ │ │ +detects a thrown exception and communicates to all other processes │ │ │ │ │ +Definition mpiguard.hh:134 │ │ │ │ │ +Dune::MPIGuard::reactivate │ │ │ │ │ +void reactivate() │ │ │ │ │ +reactivate the guard. │ │ │ │ │ +Definition mpiguard.hh:202 │ │ │ │ │ +Dune::MPIGuard::finalize │ │ │ │ │ +void finalize(bool success=true) │ │ │ │ │ +stop the guard. │ │ │ │ │ +Definition mpiguard.hh:218 │ │ │ │ │ +Dune::MPIGuard::~MPIGuard │ │ │ │ │ +~MPIGuard() │ │ │ │ │ +destroy the guard and check for undetected exceptions │ │ │ │ │ +Definition mpiguard.hh:188 │ │ │ │ │ +Dune::MPIGuard::MPIGuard │ │ │ │ │ +MPIGuard(const C &comm, bool active=true) │ │ │ │ │ +create an MPIGuard operating on an arbitrary communicator. │ │ │ │ │ +Definition mpiguard.hh:174 │ │ │ │ │ +Dune::MPIGuard::MPIGuard │ │ │ │ │ +MPIGuard(const MPI_Comm &comm, bool active=true) │ │ │ │ │ +Definition mpiguard.hh:180 │ │ │ │ │ +Dune::MPIGuard::MPIGuard │ │ │ │ │ +MPIGuard(bool active=true) │ │ │ │ │ +create an MPIGuard operating on the Communicator of the global Dune::MPIHelper │ │ │ │ │ +Definition mpiguard.hh:146 │ │ │ │ │ +Dune::MPIGuard::MPIGuard │ │ │ │ │ +MPIGuard(MPIHelper &m, bool active=true) │ │ │ │ │ +create an MPIGuard operating on the Communicator of a special Dune::MPIHelper m │ │ │ │ │ +Definition mpiguard.hh:157 │ │ │ │ │ +Dune::MPIHelper │ │ │ │ │ +A real mpi helper. │ │ │ │ │ +Definition mpihelper.hh:179 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00041.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: parametertreeparser.hh File Reference │ │ │ │ +dune-common: mpicollectivecommunication.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,55 +65,24 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
│ │ │ │ -Classes | │ │ │ │ -Namespaces
│ │ │ │ -
parametertreeparser.hh File Reference
│ │ │ │ +
mpicollectivecommunication.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ - │ │ │ │ -

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

│ │ │ │ -
#include <istream>
│ │ │ │ -#include <string>
│ │ │ │ -#include <vector>
│ │ │ │ -#include <dune/common/parametertree.hh>
│ │ │ │ -#include <dune/common/exceptions.hh>
│ │ │ │ +
#include <dune/common/parallel/mpicommunication.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...
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ -

Detailed Description

│ │ │ │ -

Various parser methods to get data into a ParameterTree object.

│ │ │ │ -
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,35 +6,14 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -parametertreeparser.hh File Reference │ │ │ │ │ -Various parser methods to get data into a ParameterTree object. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ + * parallel │ │ │ │ │ +mpicollectivecommunication.hh File Reference │ │ │ │ │ +#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... │ │ │ │ │ -  │ │ │ │ │ - Namespaces │ │ │ │ │ -namespace  Dune │ │ │ │ │ -  Dune namespace. │ │ │ │ │ -  │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -Various parser methods to get data into a ParameterTree object. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00041_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: parametertreeparser.hh Source File │ │ │ │ +dune-common: mpicollectivecommunication.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,96 +70,27 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
parametertreeparser.hh
│ │ │ │ +
mpicollectivecommunication.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 (C) 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
│ │ │ │ -
7
│ │ │ │ -
12#include <istream>
│ │ │ │ -
13#include <string>
│ │ │ │ -
14#include <vector>
│ │ │ │ -
15
│ │ │ │ - │ │ │ │ - │ │ │ │ -
18
│ │ │ │ -
19namespace Dune {
│ │ │ │ -
20
│ │ │ │ - │ │ │ │ -
28 class HelpRequest : public Exception {};
│ │ │ │ -
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 hierarchical structure of string parameters.
│ │ │ │ -
A few common exception classes.
│ │ │ │ -
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:159
│ │ │ │ -
static void readINITree(std::istream &in, ParameterTree &pt, bool overwrite)
parse C++ stream
Definition parametertreeparser.cc:74
│ │ │ │ -
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:175
│ │ │ │ +Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright (C) DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ +
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ +
3// Will be removed after the 2.7 release
│ │ │ │ +
4#warning "Deprecated header, use #include <dune/common/parallel/mpicommunication.hh> instead!"
│ │ │ │ + │ │ │ │ +
Implements an utility class that provides MPI's collective communication methods.
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,118 +7,23 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -parametertreeparser.hh │ │ │ │ │ + * parallel │ │ │ │ │ +mpicollectivecommunication.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 (C) DUNE Project contributors, see file │ │ │ │ │ + 1// SPDX-FileCopyrightInfo: Copyright (C) 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 │ │ │ │ │ - 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 {}; │ │ │ │ │ - 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 │ │ │ │ │ -parametertree.hh │ │ │ │ │ -A hierarchical structure of string parameters. │ │ │ │ │ -exceptions.hh │ │ │ │ │ -A few common exception classes. │ │ │ │ │ -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:159 │ │ │ │ │ -Dune::ParameterTreeParser::readINITree │ │ │ │ │ -static void readINITree(std::istream &in, ParameterTree &pt, bool overwrite) │ │ │ │ │ -parse C++ stream │ │ │ │ │ -Definition parametertreeparser.cc:74 │ │ │ │ │ -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:175 │ │ │ │ │ + 2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ + 3// Will be removed after the 2.7 release │ │ │ │ │ + 4#warning "Deprecated header, use #include instead!" │ │ │ │ │ + 5#include │ │ │ │ │ +mpicommunication.hh │ │ │ │ │ +Implements an utility class that provides MPI's collective communication │ │ │ │ │ +methods. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00044.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: indices.hh File Reference │ │ │ │ +dune-common: plocalindex.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,119 +65,67 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ +Classes | │ │ │ │ Namespaces | │ │ │ │ -Typedefs | │ │ │ │ -Functions | │ │ │ │ -Variables
│ │ │ │ -
indices.hh File Reference
│ │ │ │ +Functions
│ │ │ │ + │ │ │ │ │ │ │ │
│ │ │ │ -
#include <cstddef>
│ │ │ │ -#include <type_traits>
│ │ │ │ -#include <utility>
│ │ │ │ -#include <dune/common/keywords.hh>
│ │ │ │ + │ │ │ │ +

Provides classes for use as the local index in ParallelIndexSet for distributed computing. │ │ │ │ +More...

│ │ │ │ +
#include "localindex.hh"
│ │ │ │ +#include "indexset.hh"
│ │ │ │ +#include "mpitraits.hh"
│ │ │ │ +#include <iostream>
│ │ │ │
│ │ │ │

Go to the source code of this file.

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

│ │ │ │ +Classes

class  Dune::ParallelLocalIndex< T >
 An index present on the local process with an additional attribute flag. More...
 
struct  Dune::LocalIndexComparator< ParallelLocalIndex< T > >
 
class  Dune::MPITraits< ParallelLocalIndex< T > >
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::Indices
 Namespace with predefined compile time indices for the range [0,19].
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │

│ │ │ │ -Typedefs

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

│ │ │ │ Functions

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>...
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ -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.
 
template<class T >
std::ostream & Dune::operator<< (std::ostream &os, const ParallelLocalIndex< T > &index)
 Print the local index to a stream.
 
template<typename T >
bool Dune::operator== (const ParallelLocalIndex< T > &p1, const ParallelLocalIndex< T > &p2)
 
template<typename T >
bool Dune::operator!= (const ParallelLocalIndex< T > &p1, const ParallelLocalIndex< T > &p2)
 
│ │ │ │ -
│ │ │ │ +

Detailed Description

│ │ │ │ +

Provides classes for use as the local index in ParallelIndexSet for distributed computing.

│ │ │ │ +
Author
Markus Blatt
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,98 +6,53 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Namespaces | Typedefs | Functions | Variables │ │ │ │ │ -indices.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ + * parallel │ │ │ │ │ +Classes | Namespaces | Functions │ │ │ │ │ +plocalindex.hh File Reference │ │ │ │ │ +Common » Parallel_Communication » Parallel_Computing_based_on_Indexsets │ │ │ │ │ +Provides classes for use as the local index in ParallelIndexSet for distributed │ │ │ │ │ +computing. More... │ │ │ │ │ +#include "localindex.hh" │ │ │ │ │ +#include "indexset.hh" │ │ │ │ │ +#include "mpitraits.hh" │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ + Classes │ │ │ │ │ + class  Dune::ParallelLocalIndex<_T_> │ │ │ │ │ +  An index present on the local process with an additional attribute │ │ │ │ │ + flag. More... │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::LocalIndexComparator<_ParallelLocalIndex<_T_>_> │ │ │ │ │ +  │ │ │ │ │ + class  Dune::MPITraits<_ParallelLocalIndex<_T_>_> │ │ │ │ │ +  │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -namespace  Dune::Indices │ │ │ │ │ -  Namespace with predefined compile time indices for the range │ │ │ │ │ - [0,19]. │ │ │ │ │ -  │ │ │ │ │ - Typedefs │ │ │ │ │ -template │ │ │ │ │ -using Dune::index_constant = std::integral_constant< std::size_t, i > │ │ │ │ │ -  An index constant with value i. │ │ │ │ │ -  │ │ │ │ │ Functions │ │ │ │ │ -template │ │ │ │ │ -decltype(auto) constexpr Dune::unpackIntegerSequence (F &&f, std:: │ │ │ │ │ - integer_sequence< I, i... > sequence) │ │ │ │ │ -  Unpack an std::integer_sequence to std:: │ │ │ │ │ - integral_constant... │ │ │ │ │ -  │ │ │ │ │ - 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. │ │ │ │ │ -  │ │ │ │ │ +template │ │ │ │ │ +std::ostream & Dune::operator<< (std::ostream &os, const ParallelLocalIndex< T │ │ │ │ │ + > &index) │ │ │ │ │ +  Print the local index to a stream. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool Dune::operator== (const ParallelLocalIndex< T > &p1, const │ │ │ │ │ + ParallelLocalIndex< T > &p2) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool Dune::operator!= (const ParallelLocalIndex< T > &p1, const │ │ │ │ │ + ParallelLocalIndex< T > &p2) │ │ │ │ │ +  │ │ │ │ │ +***** Detailed Description ***** │ │ │ │ │ +Provides classes for use as the local index in ParallelIndexSet for distributed │ │ │ │ │ +computing. │ │ │ │ │ + Author │ │ │ │ │ + Markus Blatt │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00044_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: indices.hh Source File │ │ │ │ +dune-common: plocalindex.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,124 +70,306 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
indices.hh
│ │ │ │ +
plocalindex.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 (C) 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_INDICES_HH
│ │ │ │ -
7#define DUNE_COMMON_INDICES_HH
│ │ │ │ +
6#ifndef DUNE_PLOCALINDEX_HH
│ │ │ │ +
7#define DUNE_PLOCALINDEX_HH
│ │ │ │
8
│ │ │ │ -
9#include <cstddef>
│ │ │ │ -
10#include <type_traits>
│ │ │ │ -
11#include <utility>
│ │ │ │ +
9#include "localindex.hh"
│ │ │ │ +
10#include "indexset.hh"
│ │ │ │ +
11#include "mpitraits.hh"
│ │ │ │
12
│ │ │ │ - │ │ │ │ +
13#include <iostream>
│ │ │ │
14
│ │ │ │
15namespace Dune
│ │ │ │
16{
│ │ │ │ -
29 template<std::size_t i>
│ │ │ │ -
30 using index_constant = std::integral_constant<std::size_t, i>;
│ │ │ │ -
31
│ │ │ │ -
32
│ │ │ │ -
33
│ │ │ │ -
│ │ │ │ -
50 namespace Indices
│ │ │ │ -
51 {
│ │ │ │ - │ │ │ │ -
54
│ │ │ │ - │ │ │ │ -
57
│ │ │ │ - │ │ │ │ -
60
│ │ │ │ - │ │ │ │ -
63
│ │ │ │ - │ │ │ │ -
66
│ │ │ │ - │ │ │ │ -
69
│ │ │ │ - │ │ │ │ -
72
│ │ │ │ - │ │ │ │ -
75
│ │ │ │ - │ │ │ │ -
78
│ │ │ │ - │ │ │ │ -
81
│ │ │ │ - │ │ │ │ -
84
│ │ │ │ - │ │ │ │ -
87
│ │ │ │ - │ │ │ │ +
17
│ │ │ │ +
18
│ │ │ │ +
29 template<class T> class ParallelLocalIndex;
│ │ │ │ +
30
│ │ │ │ +
36 template<class T>
│ │ │ │ +
│ │ │ │ +
37 std::ostream& operator<<(std::ostream& os, const ParallelLocalIndex<T>& index)
│ │ │ │ +
38 {
│ │ │ │ +
39 os<<"{local="<<index.localIndex_<<", attr="<<T(index.attribute_)<<", public="
│ │ │ │ +
40 <<(index.public_ ? true : false)<<"}";
│ │ │ │ +
41 return os;
│ │ │ │ +
42 }
│ │ │ │ +
│ │ │ │ +
43
│ │ │ │ +
47 template<typename T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
49 {
│ │ │ │ +
50#if HAVE_MPI
│ │ │ │ +
51 // friend declaration needed for MPITraits
│ │ │ │ +
52 friend struct MPITraits<ParallelLocalIndex<T> >;
│ │ │ │ +
53#endif
│ │ │ │ +
54 friend std::ostream& operator<<<>(std::ostream& os, const ParallelLocalIndex<T>& index);
│ │ │ │ +
55
│ │ │ │ +
56 public:
│ │ │ │ +
64 typedef T Attribute;
│ │ │ │ + │ │ │ │ +
74
│ │ │ │ +
83 ParallelLocalIndex(size_t localIndex, const Attribute& attribute, bool isPublic=true);
│ │ │ │ + │ │ │ │
90
│ │ │ │ - │ │ │ │ -
93
│ │ │ │ - │ │ │ │ -
96
│ │ │ │ - │ │ │ │ -
99
│ │ │ │ - │ │ │ │ -
102
│ │ │ │ - │ │ │ │ -
105
│ │ │ │ - │ │ │ │ -
108
│ │ │ │ - │ │ │ │ -
111
│ │ │ │ -
112 } // namespace Indices
│ │ │ │ -
│ │ │ │ -
113
│ │ │ │ -
124 template<class F, class I, I... i>
│ │ │ │ -
│ │ │ │ -
125 decltype(auto) constexpr unpackIntegerSequence(F&& f, std::integer_sequence<I, i...> sequence)
│ │ │ │ -
126 {
│ │ │ │ -
127 return f(std::integral_constant<I, i>()...);
│ │ │ │ -
128 }
│ │ │ │ -
│ │ │ │ -
129
│ │ │ │ -
130} //namespace Dune
│ │ │ │ -
131
│ │ │ │ -
132#endif // DUNE_COMMON_INDICES_HH
│ │ │ │ -
Definitions of several macros that conditionally make C++ syntax available.
│ │ │ │ -
#define DUNE_INLINE_VARIABLE
Definition keywords.hh:19
│ │ │ │ -
constexpr index_constant< 16 > _16
Compile time index with value 16.
Definition indices.hh:101
│ │ │ │ -
constexpr index_constant< 15 > _15
Compile time index with value 15.
Definition indices.hh:98
│ │ │ │ -
constexpr index_constant< 8 > _8
Compile time index with value 8.
Definition indices.hh:77
│ │ │ │ -
constexpr index_constant< 7 > _7
Compile time index with value 7.
Definition indices.hh:74
│ │ │ │ -
constexpr index_constant< 0 > _0
Compile time index with value 0.
Definition indices.hh:53
│ │ │ │ -
constexpr index_constant< 9 > _9
Compile time index with value 9.
Definition indices.hh:80
│ │ │ │ -
constexpr index_constant< 14 > _14
Compile time index with value 14.
Definition indices.hh:95
│ │ │ │ -
constexpr index_constant< 1 > _1
Compile time index with value 1.
Definition indices.hh:56
│ │ │ │ -
constexpr index_constant< 3 > _3
Compile time index with value 3.
Definition indices.hh:62
│ │ │ │ -
constexpr index_constant< 12 > _12
Compile time index with value 12.
Definition indices.hh:89
│ │ │ │ -
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:125
│ │ │ │ -
constexpr index_constant< 11 > _11
Compile time index with value 11.
Definition indices.hh:86
│ │ │ │ -
constexpr index_constant< 18 > _18
Compile time index with value 18.
Definition indices.hh:107
│ │ │ │ -
constexpr index_constant< 13 > _13
Compile time index with value 13.
Definition indices.hh:92
│ │ │ │ -
constexpr index_constant< 5 > _5
Compile time index with value 5.
Definition indices.hh:68
│ │ │ │ -
constexpr index_constant< 17 > _17
Compile time index with value 17.
Definition indices.hh:104
│ │ │ │ -
constexpr index_constant< 10 > _10
Compile time index with value 10.
Definition indices.hh:83
│ │ │ │ -
constexpr index_constant< 2 > _2
Compile time index with value 2.
Definition indices.hh:59
│ │ │ │ -
std::integral_constant< std::size_t, i > index_constant
An index constant with value i.
Definition indices.hh:30
│ │ │ │ -
constexpr index_constant< 19 > _19
Compile time index with value 19.
Definition indices.hh:110
│ │ │ │ -
constexpr index_constant< 6 > _6
Compile time index with value 6.
Definition indices.hh:71
│ │ │ │ -
constexpr index_constant< 4 > _4
Compile time index with value 4.
Definition indices.hh:65
│ │ │ │ +
91#if 0
│ │ │ │ + │ │ │ │ +
102#endif
│ │ │ │ +
103
│ │ │ │ +
108 inline const Attribute attribute() const;
│ │ │ │ +
109
│ │ │ │ +
114 inline void setAttribute(const Attribute& attribute);
│ │ │ │ +
115
│ │ │ │ +
120 inline size_t local() const;
│ │ │ │ +
121
│ │ │ │ +
125 inline operator size_t() const;
│ │ │ │ +
126
│ │ │ │ +
132 inline ParallelLocalIndex<Attribute>& operator=(size_t index);
│ │ │ │ +
133
│ │ │ │ +
138 inline bool isPublic() const;
│ │ │ │ +
139
│ │ │ │ +
144 inline LocalIndexState state() const;
│ │ │ │ +
145
│ │ │ │ +
150 inline void setState(const LocalIndexState& state);
│ │ │ │ +
151
│ │ │ │ +
152 private:
│ │ │ │ +
154 size_t localIndex_;
│ │ │ │ +
155
│ │ │ │ +
157 char attribute_;
│ │ │ │ +
158
│ │ │ │ +
160 char public_;
│ │ │ │ +
161
│ │ │ │ +
168 char state_;
│ │ │ │ +
169
│ │ │ │ +
170 };
│ │ │ │ +
│ │ │ │ +
171
│ │ │ │ +
172 template<typename T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
174 const ParallelLocalIndex<T>& p2)
│ │ │ │ +
175 {
│ │ │ │ +
176 if(p1.local()!=p2.local())
│ │ │ │ +
177 return false;
│ │ │ │ +
178 if(p1.attribute()!=p2.attribute())
│ │ │ │ +
179 return false;
│ │ │ │ +
180 if(p1.isPublic()!=p2.isPublic())
│ │ │ │ +
181 return false;
│ │ │ │ +
182 return true;
│ │ │ │ +
183 }
│ │ │ │ +
│ │ │ │ +
184 template<typename T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
186 const ParallelLocalIndex<T>& p2)
│ │ │ │ +
187 {
│ │ │ │ +
188 return !(p1==p2);
│ │ │ │ +
189 }
│ │ │ │ +
│ │ │ │ +
190
│ │ │ │ +
191
│ │ │ │ +
192 template<typename T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
194 {
│ │ │ │ +
│ │ │ │ +
195 static bool compare(const ParallelLocalIndex<T>& t1,
│ │ │ │ +
196 const ParallelLocalIndex<T>& t2){
│ │ │ │ +
197 return t1.attribute()<t2.attribute();
│ │ │ │ +
198 }
│ │ │ │ +
│ │ │ │ +
199 };
│ │ │ │ +
│ │ │ │ +
200
│ │ │ │ +
201
│ │ │ │ +
202#if HAVE_MPI
│ │ │ │ +
203
│ │ │ │ +
205 template<typename T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
207 {
│ │ │ │ +
208 public:
│ │ │ │ +
209 static MPI_Datatype getType();
│ │ │ │ +
210 private:
│ │ │ │ +
211 static MPI_Datatype type;
│ │ │ │ +
212
│ │ │ │ +
213 };
│ │ │ │ +
│ │ │ │ +
214
│ │ │ │ +
215#endif
│ │ │ │ +
216
│ │ │ │ +
217 template<class T>
│ │ │ │ +
│ │ │ │ +
218 ParallelLocalIndex<T>::ParallelLocalIndex(const T& attribute, bool isPublic)
│ │ │ │ +
219 : localIndex_(0), attribute_(static_cast<char>(attribute)),
│ │ │ │ +
220 public_(static_cast<char>(isPublic)), state_(static_cast<char>(VALID))
│ │ │ │ +
221 {}
│ │ │ │ +
│ │ │ │ +
222
│ │ │ │ +
223
│ │ │ │ +
224 template<class T>
│ │ │ │ +
│ │ │ │ +
225 ParallelLocalIndex<T>::ParallelLocalIndex(size_t local, const T& attribute, bool isPublic)
│ │ │ │ +
226 : localIndex_(local), attribute_(static_cast<char>(attribute)),
│ │ │ │ +
227 public_(static_cast<char>(isPublic)), state_(static_cast<char>(VALID))
│ │ │ │ +
228 {}
│ │ │ │ +
│ │ │ │ +
229
│ │ │ │ +
230 template<class T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
232 : localIndex_(0), attribute_(), public_(static_cast<char>(false)),
│ │ │ │ +
233 state_(static_cast<char>(VALID))
│ │ │ │ +
234 {}
│ │ │ │ +
│ │ │ │ +
235
│ │ │ │ +
236 template<class T>
│ │ │ │ +
│ │ │ │ +
237 inline const T ParallelLocalIndex<T>::attribute() const
│ │ │ │ +
238 {
│ │ │ │ +
239 return T(attribute_);
│ │ │ │ +
240 }
│ │ │ │ +
│ │ │ │ +
241
│ │ │ │ +
242 template<class T>
│ │ │ │ +
243 inline void
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
245 {
│ │ │ │ +
246 attribute_ = attribute;
│ │ │ │ +
247 }
│ │ │ │ +
│ │ │ │ +
248
│ │ │ │ +
249 template<class T>
│ │ │ │ +
│ │ │ │ +
250 inline size_t ParallelLocalIndex<T>::local() const
│ │ │ │ +
251 {
│ │ │ │ +
252 return localIndex_;
│ │ │ │ +
253 }
│ │ │ │ +
│ │ │ │ +
254
│ │ │ │ +
255 template<class T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
257 {
│ │ │ │ +
258 return localIndex_;
│ │ │ │ +
259 }
│ │ │ │ +
│ │ │ │ +
260
│ │ │ │ +
261 template<class T>
│ │ │ │ + │ │ │ │ +
│ │ │ │ + │ │ │ │ +
264 {
│ │ │ │ +
265 localIndex_=index;
│ │ │ │ +
266 return *this;
│ │ │ │ +
267 }
│ │ │ │ +
│ │ │ │ +
268
│ │ │ │ +
269 template<class T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
271 {
│ │ │ │ +
272 return static_cast<bool>(public_);
│ │ │ │ +
273 }
│ │ │ │ +
│ │ │ │ +
274
│ │ │ │ +
275 template<class T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
277 {
│ │ │ │ +
278 return LocalIndexState(state_);
│ │ │ │ +
279 }
│ │ │ │ +
│ │ │ │ +
280
│ │ │ │ +
281 template<class T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
283 {
│ │ │ │ +
284 state_=static_cast<char>(state);
│ │ │ │ +
285 }
│ │ │ │ +
│ │ │ │ +
286
│ │ │ │ +
287#if HAVE_MPI
│ │ │ │ +
288
│ │ │ │ +
289 template<typename T>
│ │ │ │ +
│ │ │ │ +
290 MPI_Datatype MPITraits<ParallelLocalIndex<T> >::getType()
│ │ │ │ +
291 {
│ │ │ │ +
292
│ │ │ │ +
293 if(type==MPI_DATATYPE_NULL) {
│ │ │ │ +
294 int length = 1;
│ │ │ │ +
295 MPI_Aint base, disp;
│ │ │ │ +
296 MPI_Datatype types[1] = {MPITraits<char>::getType()};
│ │ │ │ + │ │ │ │ +
298 MPI_Get_address(&rep, &base);
│ │ │ │ +
299 MPI_Get_address(&(rep.attribute_), &disp);
│ │ │ │ +
300 disp -= base;
│ │ │ │ +
301
│ │ │ │ +
302 MPI_Datatype tmp;
│ │ │ │ +
303 MPI_Type_create_struct(1, &length, &disp, types, &tmp);
│ │ │ │ +
304
│ │ │ │ +
305 MPI_Type_create_resized(tmp, 0, sizeof(ParallelLocalIndex<T>), &type);
│ │ │ │ +
306 MPI_Type_commit(&type);
│ │ │ │ +
307
│ │ │ │ +
308 MPI_Type_free(&tmp);
│ │ │ │ +
309 }
│ │ │ │ +
310 return type;
│ │ │ │ +
311 }
│ │ │ │ +
│ │ │ │ +
312
│ │ │ │ +
313 template<typename T>
│ │ │ │ +
314 MPI_Datatype MPITraits<ParallelLocalIndex<T> >::type = MPI_DATATYPE_NULL;
│ │ │ │ +
315
│ │ │ │ +
316#endif
│ │ │ │ +
317
│ │ │ │ +
318
│ │ │ │ +
320} // namespace Dune
│ │ │ │ +
321
│ │ │ │ +
322#endif
│ │ │ │ +
Provides classes for use as the local index in ParallelIndexSet.
│ │ │ │ +
Traits classes for mapping types onto MPI_Datatype.
│ │ │ │ +
Provides a map between global and local indices.
│ │ │ │ +
std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x)
Definition bigunsignedint.hh:278
│ │ │ │ +
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:237
│ │ │ │ +
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:259
│ │ │ │ +
bool isPublic() const
Check whether the index might also be known other processes.
Definition plocalindex.hh:270
│ │ │ │ +
void setAttribute(const Attribute &attribute)
Set the attribute of the index.
Definition plocalindex.hh:244
│ │ │ │ +
size_t local() const
get the local index.
Definition plocalindex.hh:250
│ │ │ │ +
LocalIndexState
The states available for the local indices.
Definition localindex.hh:28
│ │ │ │ +
void setState(const LocalIndexState &state)
Set the state.
Definition plocalindex.hh:282
│ │ │ │ +
ParallelLocalIndex< Attribute > & operator=(size_t index)
Assign a new local index.
Definition plocalindex.hh:263
│ │ │ │ +
LocalIndexState state() const
Get the state.
Definition plocalindex.hh:276
│ │ │ │ +
ParallelLocalIndex()
Parameterless constructor.
Definition plocalindex.hh:231
│ │ │ │ +
const Attribute attribute() const
Get the attribute of the index.
Definition plocalindex.hh:237
│ │ │ │ +
@ VALID
Definition localindex.hh:28
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ +
A traits class describing the mapping of types onto MPI_Datatypes.
Definition mpitraits.hh:41
│ │ │ │ +
static MPI_Datatype getType()
Definition mpitraits.hh:48
│ │ │ │ +
Definition indexset.hh:615
│ │ │ │ +
An index present on the local process with an additional attribute flag.
Definition plocalindex.hh:49
│ │ │ │ +
T Attribute
The type of the attributes. Normally this will be an enumeration like.
Definition plocalindex.hh:64
│ │ │ │ +
static bool compare(const ParallelLocalIndex< T > &t1, const ParallelLocalIndex< T > &t2)
Definition plocalindex.hh:195
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,185 +7,327 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -indices.hh │ │ │ │ │ + * parallel │ │ │ │ │ +plocalindex.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 (C) 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_INDICES_HH │ │ │ │ │ - 7#define DUNE_COMMON_INDICES_HH │ │ │ │ │ + 6#ifndef DUNE_PLOCALINDEX_HH │ │ │ │ │ + 7#define DUNE_PLOCALINDEX_HH │ │ │ │ │ 8 │ │ │ │ │ - 9#include │ │ │ │ │ - 10#include │ │ │ │ │ - 11#include │ │ │ │ │ + 9#include "localindex.hh" │ │ │ │ │ + 10#include "indexset.hh" │ │ │ │ │ + 11#include "mpitraits.hh" │ │ │ │ │ 12 │ │ │ │ │ - 13#include │ │ │ │ │ + 13#include │ │ │ │ │ 14 │ │ │ │ │ 15namespace Dune │ │ │ │ │ 16{ │ │ │ │ │ - 29 template │ │ │ │ │ -30 using index_constant = std::integral_constant; │ │ │ │ │ - 31 │ │ │ │ │ - 32 │ │ │ │ │ - 33 │ │ │ │ │ -50 namespace Indices │ │ │ │ │ - 51 { │ │ │ │ │ -53 DUNE_INLINE_VARIABLE constexpr index_constant<_0> _0 = {}; │ │ │ │ │ - 54 │ │ │ │ │ -56 DUNE_INLINE_VARIABLE constexpr index_constant<_1> _1 = {}; │ │ │ │ │ - 57 │ │ │ │ │ -59 DUNE_INLINE_VARIABLE constexpr index_constant<_2> _2 = {}; │ │ │ │ │ - 60 │ │ │ │ │ -62 DUNE_INLINE_VARIABLE constexpr index_constant<_3> _3 = {}; │ │ │ │ │ - 63 │ │ │ │ │ -65 DUNE_INLINE_VARIABLE constexpr index_constant<_4> _4 = {}; │ │ │ │ │ - 66 │ │ │ │ │ -68 DUNE_INLINE_VARIABLE constexpr index_constant<_5> _5 = {}; │ │ │ │ │ - 69 │ │ │ │ │ -71 DUNE_INLINE_VARIABLE constexpr index_constant<_6> _6 = {}; │ │ │ │ │ - 72 │ │ │ │ │ -74 DUNE_INLINE_VARIABLE constexpr index_constant<_7> _7 = {}; │ │ │ │ │ - 75 │ │ │ │ │ -77 DUNE_INLINE_VARIABLE constexpr index_constant<_8> _8 = {}; │ │ │ │ │ - 78 │ │ │ │ │ -80 DUNE_INLINE_VARIABLE constexpr index_constant<_9> _9 = {}; │ │ │ │ │ - 81 │ │ │ │ │ -83 DUNE_INLINE_VARIABLE constexpr index_constant<10> _10 = {}; │ │ │ │ │ - 84 │ │ │ │ │ -86 DUNE_INLINE_VARIABLE constexpr index_constant<11> _11 = {}; │ │ │ │ │ - 87 │ │ │ │ │ -89 DUNE_INLINE_VARIABLE constexpr index_constant<12> _12 = {}; │ │ │ │ │ + 17 │ │ │ │ │ + 18 │ │ │ │ │ + 29 template class ParallelLocalIndex; │ │ │ │ │ + 30 │ │ │ │ │ + 36 template │ │ │ │ │ +37 std::ostream& operator<<(std::ostream& os, const ParallelLocalIndex& │ │ │ │ │ +index) │ │ │ │ │ + 38 { │ │ │ │ │ + 39 os<<"{local="< │ │ │ │ │ +48 class ParallelLocalIndex │ │ │ │ │ + 49 { │ │ │ │ │ + 50#if HAVE_MPI │ │ │ │ │ + 51 // friend declaration needed for MPITraits │ │ │ │ │ + 52 friend struct MPITraits >; │ │ │ │ │ + 53#endif │ │ │ │ │ + 54 friend std::ostream& operator<<<>(std::ostream& os, const │ │ │ │ │ +ParallelLocalIndex& index); │ │ │ │ │ + 55 │ │ │ │ │ + 56 public: │ │ │ │ │ +64 typedef T Attribute; │ │ │ │ │ + 73 ParallelLocalIndex(const Attribute& attribute, bool isPublic); │ │ │ │ │ + 74 │ │ │ │ │ + 83 ParallelLocalIndex(size_t localIndex, const Attribute& attribute, bool │ │ │ │ │ +isPublic=true); │ │ │ │ │ + 89 ParallelLocalIndex(); │ │ │ │ │ 90 │ │ │ │ │ -92 DUNE_INLINE_VARIABLE constexpr index_constant<13> _13 = {}; │ │ │ │ │ - 93 │ │ │ │ │ -95 DUNE_INLINE_VARIABLE constexpr index_constant<14> _14 = {}; │ │ │ │ │ - 96 │ │ │ │ │ -98 DUNE_INLINE_VARIABLE constexpr index_constant<15> _15 = {}; │ │ │ │ │ - 99 │ │ │ │ │ -101 DUNE_INLINE_VARIABLE constexpr index_constant<16> _16 = {}; │ │ │ │ │ - 102 │ │ │ │ │ -104 DUNE_INLINE_VARIABLE constexpr index_constant<17> _17 = {}; │ │ │ │ │ - 105 │ │ │ │ │ -107 DUNE_INLINE_VARIABLE constexpr index_constant<18> _18 = {}; │ │ │ │ │ - 108 │ │ │ │ │ -110 DUNE_INLINE_VARIABLE constexpr index_constant<19> _19 = {}; │ │ │ │ │ - 111 │ │ │ │ │ - 112 } // namespace Indices │ │ │ │ │ - 113 │ │ │ │ │ - 124 template │ │ │ │ │ -125 decltype(auto) constexpr unpackIntegerSequence(F&& f, std:: │ │ │ │ │ -integer_sequence sequence) │ │ │ │ │ - 126 { │ │ │ │ │ - 127 return f(std::integral_constant()...); │ │ │ │ │ - 128 } │ │ │ │ │ - 129 │ │ │ │ │ - 130} //namespace Dune │ │ │ │ │ - 131 │ │ │ │ │ - 132#endif // DUNE_COMMON_INDICES_HH │ │ │ │ │ -keywords.hh │ │ │ │ │ -Definitions of several macros that conditionally make C++ syntax available. │ │ │ │ │ -DUNE_INLINE_VARIABLE │ │ │ │ │ -#define DUNE_INLINE_VARIABLE │ │ │ │ │ -Definition keywords.hh:19 │ │ │ │ │ -Dune::Indices::_16 │ │ │ │ │ -constexpr index_constant< 16 > _16 │ │ │ │ │ -Compile time index with value 16. │ │ │ │ │ -Definition indices.hh:101 │ │ │ │ │ -Dune::Indices::_15 │ │ │ │ │ -constexpr index_constant< 15 > _15 │ │ │ │ │ -Compile time index with value 15. │ │ │ │ │ -Definition indices.hh:98 │ │ │ │ │ -Dune::Indices::_8 │ │ │ │ │ -constexpr index_constant< 8 > _8 │ │ │ │ │ -Compile time index with value 8. │ │ │ │ │ -Definition indices.hh:77 │ │ │ │ │ -Dune::Indices::_7 │ │ │ │ │ -constexpr index_constant< 7 > _7 │ │ │ │ │ -Compile time index with value 7. │ │ │ │ │ -Definition indices.hh:74 │ │ │ │ │ -Dune::Indices::_0 │ │ │ │ │ -constexpr index_constant< 0 > _0 │ │ │ │ │ -Compile time index with value 0. │ │ │ │ │ -Definition indices.hh:53 │ │ │ │ │ -Dune::Indices::_9 │ │ │ │ │ -constexpr index_constant< 9 > _9 │ │ │ │ │ -Compile time index with value 9. │ │ │ │ │ -Definition indices.hh:80 │ │ │ │ │ -Dune::Indices::_14 │ │ │ │ │ -constexpr index_constant< 14 > _14 │ │ │ │ │ -Compile time index with value 14. │ │ │ │ │ -Definition indices.hh:95 │ │ │ │ │ -Dune::Indices::_1 │ │ │ │ │ -constexpr index_constant< 1 > _1 │ │ │ │ │ -Compile time index with value 1. │ │ │ │ │ -Definition indices.hh:56 │ │ │ │ │ -Dune::Indices::_3 │ │ │ │ │ -constexpr index_constant< 3 > _3 │ │ │ │ │ -Compile time index with value 3. │ │ │ │ │ -Definition indices.hh:62 │ │ │ │ │ -Dune::Indices::_12 │ │ │ │ │ -constexpr index_constant< 12 > _12 │ │ │ │ │ -Compile time index with value 12. │ │ │ │ │ -Definition indices.hh:89 │ │ │ │ │ -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:125 │ │ │ │ │ -Dune::Indices::_11 │ │ │ │ │ -constexpr index_constant< 11 > _11 │ │ │ │ │ -Compile time index with value 11. │ │ │ │ │ -Definition indices.hh:86 │ │ │ │ │ -Dune::Indices::_18 │ │ │ │ │ -constexpr index_constant< 18 > _18 │ │ │ │ │ -Compile time index with value 18. │ │ │ │ │ -Definition indices.hh:107 │ │ │ │ │ -Dune::Indices::_13 │ │ │ │ │ -constexpr index_constant< 13 > _13 │ │ │ │ │ -Compile time index with value 13. │ │ │ │ │ -Definition indices.hh:92 │ │ │ │ │ -Dune::Indices::_5 │ │ │ │ │ -constexpr index_constant< 5 > _5 │ │ │ │ │ -Compile time index with value 5. │ │ │ │ │ -Definition indices.hh:68 │ │ │ │ │ -Dune::Indices::_17 │ │ │ │ │ -constexpr index_constant< 17 > _17 │ │ │ │ │ -Compile time index with value 17. │ │ │ │ │ -Definition indices.hh:104 │ │ │ │ │ -Dune::Indices::_10 │ │ │ │ │ -constexpr index_constant< 10 > _10 │ │ │ │ │ -Compile time index with value 10. │ │ │ │ │ -Definition indices.hh:83 │ │ │ │ │ -Dune::Indices::_2 │ │ │ │ │ -constexpr index_constant< 2 > _2 │ │ │ │ │ -Compile time index with value 2. │ │ │ │ │ -Definition indices.hh:59 │ │ │ │ │ -Dune::index_constant │ │ │ │ │ -std::integral_constant< std::size_t, i > index_constant │ │ │ │ │ -An index constant with value i. │ │ │ │ │ -Definition indices.hh:30 │ │ │ │ │ -Dune::Indices::_19 │ │ │ │ │ -constexpr index_constant< 19 > _19 │ │ │ │ │ -Compile time index with value 19. │ │ │ │ │ -Definition indices.hh:110 │ │ │ │ │ -Dune::Indices::_6 │ │ │ │ │ -constexpr index_constant< 6 > _6 │ │ │ │ │ -Compile time index with value 6. │ │ │ │ │ -Definition indices.hh:71 │ │ │ │ │ -Dune::Indices::_4 │ │ │ │ │ -constexpr index_constant< 4 > _4 │ │ │ │ │ -Compile time index with value 4. │ │ │ │ │ -Definition indices.hh:65 │ │ │ │ │ + 91#if 0 │ │ │ │ │ + 101 ParallelLocalIndex(const Attribute& attribute, size_t local, bool │ │ │ │ │ +isPublic); │ │ │ │ │ + 102#endif │ │ │ │ │ + 103 │ │ │ │ │ + 108 inline const Attribute attribute() const; │ │ │ │ │ + 109 │ │ │ │ │ + 114 inline void setAttribute(const Attribute& attribute); │ │ │ │ │ + 115 │ │ │ │ │ + 120 inline size_t local() const; │ │ │ │ │ + 121 │ │ │ │ │ + 125 inline operator size_t() const; │ │ │ │ │ + 126 │ │ │ │ │ + 132 inline ParallelLocalIndex& operator=(size_t index); │ │ │ │ │ + 133 │ │ │ │ │ + 138 inline bool isPublic() const; │ │ │ │ │ + 139 │ │ │ │ │ + 144 inline LocalIndexState state() const; │ │ │ │ │ + 145 │ │ │ │ │ + 150 inline void setState(const LocalIndexState& state); │ │ │ │ │ + 151 │ │ │ │ │ + 152 private: │ │ │ │ │ + 154 size_t localIndex_; │ │ │ │ │ + 155 │ │ │ │ │ + 157 char attribute_; │ │ │ │ │ + 158 │ │ │ │ │ + 160 char public_; │ │ │ │ │ + 161 │ │ │ │ │ + 168 char state_; │ │ │ │ │ + 169 │ │ │ │ │ + 170 }; │ │ │ │ │ + 171 │ │ │ │ │ + 172 template │ │ │ │ │ +173 bool operator==(const ParallelLocalIndex& p1, │ │ │ │ │ + 174 const ParallelLocalIndex& p2) │ │ │ │ │ + 175 { │ │ │ │ │ + 176 if(p1.local()!=p2.local()) │ │ │ │ │ + 177 return false; │ │ │ │ │ + 178 if(p1.attribute()!=p2.attribute()) │ │ │ │ │ + 179 return false; │ │ │ │ │ + 180 if(p1.isPublic()!=p2.isPublic()) │ │ │ │ │ + 181 return false; │ │ │ │ │ + 182 return true; │ │ │ │ │ + 183 } │ │ │ │ │ + 184 template │ │ │ │ │ +185 bool operator!=(const ParallelLocalIndex& p1, │ │ │ │ │ + 186 const ParallelLocalIndex& p2) │ │ │ │ │ + 187 { │ │ │ │ │ + 188 return !(p1==p2); │ │ │ │ │ + 189 } │ │ │ │ │ + 190 │ │ │ │ │ + 191 │ │ │ │ │ + 192 template │ │ │ │ │ +193 struct LocalIndexComparator > │ │ │ │ │ + 194 { │ │ │ │ │ +195 static bool compare(const ParallelLocalIndex& t1, │ │ │ │ │ + 196 const ParallelLocalIndex& t2){ │ │ │ │ │ + 197 return t1.attribute() │ │ │ │ │ +206 class MPITraits > │ │ │ │ │ + 207 { │ │ │ │ │ + 208 public: │ │ │ │ │ + 209 static MPI_Datatype getType(); │ │ │ │ │ + 210 private: │ │ │ │ │ + 211 static MPI_Datatype type; │ │ │ │ │ + 212 │ │ │ │ │ + 213 }; │ │ │ │ │ + 214 │ │ │ │ │ + 215#endif │ │ │ │ │ + 216 │ │ │ │ │ + 217 template │ │ │ │ │ +218 ParallelLocalIndex::ParallelLocalIndex(const T& attribute, bool │ │ │ │ │ +isPublic) │ │ │ │ │ + 219 : localIndex_(0), attribute_(static_cast(attribute)), │ │ │ │ │ + 220 public_(static_cast(isPublic)), state_(static_cast(VALID)) │ │ │ │ │ + 221 {} │ │ │ │ │ + 222 │ │ │ │ │ + 223 │ │ │ │ │ + 224 template │ │ │ │ │ +225 ParallelLocalIndex::ParallelLocalIndex(size_t local, const T& attribute, │ │ │ │ │ +bool isPublic) │ │ │ │ │ + 226 : localIndex_(local), attribute_(static_cast(attribute)), │ │ │ │ │ + 227 public_(static_cast(isPublic)), state_(static_cast(VALID)) │ │ │ │ │ + 228 {} │ │ │ │ │ + 229 │ │ │ │ │ + 230 template │ │ │ │ │ +231 ParallelLocalIndex::ParallelLocalIndex() │ │ │ │ │ + 232 : localIndex_(0), attribute_(), public_(static_cast(false)), │ │ │ │ │ + 233 state_(static_cast(VALID)) │ │ │ │ │ + 234 {} │ │ │ │ │ + 235 │ │ │ │ │ + 236 template │ │ │ │ │ +237 inline const T ParallelLocalIndex::attribute() const │ │ │ │ │ + 238 { │ │ │ │ │ + 239 return T(attribute_); │ │ │ │ │ + 240 } │ │ │ │ │ + 241 │ │ │ │ │ + 242 template │ │ │ │ │ + 243 inline void │ │ │ │ │ +244 ParallelLocalIndex::setAttribute(const Attribute& attribute) │ │ │ │ │ + 245 { │ │ │ │ │ + 246 attribute_ = attribute; │ │ │ │ │ + 247 } │ │ │ │ │ + 248 │ │ │ │ │ + 249 template │ │ │ │ │ +250 inline size_t ParallelLocalIndex::local() const │ │ │ │ │ + 251 { │ │ │ │ │ + 252 return localIndex_; │ │ │ │ │ + 253 } │ │ │ │ │ + 254 │ │ │ │ │ + 255 template │ │ │ │ │ +256 inline ParallelLocalIndex::operator size_t() const │ │ │ │ │ + 257 { │ │ │ │ │ + 258 return localIndex_; │ │ │ │ │ + 259 } │ │ │ │ │ + 260 │ │ │ │ │ + 261 template │ │ │ │ │ + 262 inline ParallelLocalIndex& │ │ │ │ │ +263 ParallelLocalIndex::operator=(size_t index) │ │ │ │ │ + 264 { │ │ │ │ │ + 265 localIndex_=index; │ │ │ │ │ + 266 return *this; │ │ │ │ │ + 267 } │ │ │ │ │ + 268 │ │ │ │ │ + 269 template │ │ │ │ │ +270 inline bool ParallelLocalIndex::isPublic() const │ │ │ │ │ + 271 { │ │ │ │ │ + 272 return static_cast(public_); │ │ │ │ │ + 273 } │ │ │ │ │ + 274 │ │ │ │ │ + 275 template │ │ │ │ │ +276 inline LocalIndexState ParallelLocalIndex::state() const │ │ │ │ │ + 277 { │ │ │ │ │ + 278 return LocalIndexState(state_); │ │ │ │ │ + 279 } │ │ │ │ │ + 280 │ │ │ │ │ + 281 template │ │ │ │ │ +282 inline void ParallelLocalIndex::setState(const LocalIndexState& state) │ │ │ │ │ + 283 { │ │ │ │ │ + 284 state_=static_cast(state); │ │ │ │ │ + 285 } │ │ │ │ │ + 286 │ │ │ │ │ + 287#if HAVE_MPI │ │ │ │ │ + 288 │ │ │ │ │ + 289 template │ │ │ │ │ +290 MPI_Datatype MPITraits >::getType() │ │ │ │ │ + 291 { │ │ │ │ │ + 292 │ │ │ │ │ + 293 if(type==MPI_DATATYPE_NULL) { │ │ │ │ │ + 294 int length = 1; │ │ │ │ │ + 295 MPI_Aint base, disp; │ │ │ │ │ + 296 MPI_Datatype types[1] = {MPITraits::getType()}; │ │ │ │ │ + 297 ParallelLocalIndex rep; │ │ │ │ │ + 298 MPI_Get_address(&rep, &base); │ │ │ │ │ + 299 MPI_Get_address(&(rep.attribute_), &disp); │ │ │ │ │ + 300 disp -= base; │ │ │ │ │ + 301 │ │ │ │ │ + 302 MPI_Datatype tmp; │ │ │ │ │ + 303 MPI_Type_create_struct(1, &length, &disp, types, &tmp); │ │ │ │ │ + 304 │ │ │ │ │ + 305 MPI_Type_create_resized(tmp, 0, sizeof(ParallelLocalIndex), &type); │ │ │ │ │ + 306 MPI_Type_commit(&type); │ │ │ │ │ + 307 │ │ │ │ │ + 308 MPI_Type_free(&tmp); │ │ │ │ │ + 309 } │ │ │ │ │ + 310 return type; │ │ │ │ │ + 311 } │ │ │ │ │ + 312 │ │ │ │ │ + 313 template │ │ │ │ │ +314 MPI_Datatype MPITraits >::type = MPI_DATATYPE_NULL; │ │ │ │ │ + 315 │ │ │ │ │ + 316#endif │ │ │ │ │ + 317 │ │ │ │ │ + 318 │ │ │ │ │ + 320} // namespace Dune │ │ │ │ │ + 321 │ │ │ │ │ + 322#endif │ │ │ │ │ +localindex.hh │ │ │ │ │ +Provides classes for use as the local index in ParallelIndexSet. │ │ │ │ │ +mpitraits.hh │ │ │ │ │ +Traits classes for mapping types onto MPI_Datatype. │ │ │ │ │ +indexset.hh │ │ │ │ │ +Provides a map between global and local indices. │ │ │ │ │ +Dune::operator<< │ │ │ │ │ +std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x) │ │ │ │ │ +Definition bigunsignedint.hh:278 │ │ │ │ │ +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:237 │ │ │ │ │ +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:259 │ │ │ │ │ +Dune::ParallelLocalIndex::isPublic │ │ │ │ │ +bool isPublic() const │ │ │ │ │ +Check whether the index might also be known other processes. │ │ │ │ │ +Definition plocalindex.hh:270 │ │ │ │ │ +Dune::ParallelLocalIndex::setAttribute │ │ │ │ │ +void setAttribute(const Attribute &attribute) │ │ │ │ │ +Set the attribute of the index. │ │ │ │ │ +Definition plocalindex.hh:244 │ │ │ │ │ +Dune::ParallelLocalIndex::local │ │ │ │ │ +size_t local() const │ │ │ │ │ +get the local index. │ │ │ │ │ +Definition plocalindex.hh:250 │ │ │ │ │ +Dune::LocalIndexState │ │ │ │ │ +LocalIndexState │ │ │ │ │ +The states available for the local indices. │ │ │ │ │ +Definition localindex.hh:28 │ │ │ │ │ +Dune::ParallelLocalIndex::setState │ │ │ │ │ +void setState(const LocalIndexState &state) │ │ │ │ │ +Set the state. │ │ │ │ │ +Definition plocalindex.hh:282 │ │ │ │ │ +Dune::ParallelLocalIndex::operator= │ │ │ │ │ +ParallelLocalIndex< Attribute > & operator=(size_t index) │ │ │ │ │ +Assign a new local index. │ │ │ │ │ +Definition plocalindex.hh:263 │ │ │ │ │ +Dune::ParallelLocalIndex::state │ │ │ │ │ +LocalIndexState state() const │ │ │ │ │ +Get the state. │ │ │ │ │ +Definition plocalindex.hh:276 │ │ │ │ │ +Dune::ParallelLocalIndex::ParallelLocalIndex │ │ │ │ │ +ParallelLocalIndex() │ │ │ │ │ +Parameterless constructor. │ │ │ │ │ +Definition plocalindex.hh:231 │ │ │ │ │ +Dune::ParallelLocalIndex::attribute │ │ │ │ │ +const Attribute attribute() const │ │ │ │ │ +Get the attribute of the index. │ │ │ │ │ +Definition plocalindex.hh:237 │ │ │ │ │ +Dune::VALID │ │ │ │ │ +@ VALID │ │ │ │ │ +Definition localindex.hh:28 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ +Dune::MPITraits │ │ │ │ │ +A traits class describing the mapping of types onto MPI_Datatypes. │ │ │ │ │ +Definition mpitraits.hh:41 │ │ │ │ │ +Dune::MPITraits::getType │ │ │ │ │ +static MPI_Datatype getType() │ │ │ │ │ +Definition mpitraits.hh:48 │ │ │ │ │ +Dune::LocalIndexComparator │ │ │ │ │ +Definition indexset.hh:615 │ │ │ │ │ +Dune::ParallelLocalIndex │ │ │ │ │ +An index present on the local process with an additional attribute flag. │ │ │ │ │ +Definition plocalindex.hh:49 │ │ │ │ │ +Dune::ParallelLocalIndex::Attribute │ │ │ │ │ +T Attribute │ │ │ │ │ +The type of the attributes. Normally this will be an enumeration like. │ │ │ │ │ +Definition plocalindex.hh:64 │ │ │ │ │ +Dune::LocalIndexComparator<_ParallelLocalIndex<_T_>_>::compare │ │ │ │ │ +static bool compare(const ParallelLocalIndex< T > &t1, const │ │ │ │ │ +ParallelLocalIndex< T > &t2) │ │ │ │ │ +Definition plocalindex.hh:195 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00047.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: stdstreams.cc File Reference │ │ │ │ +dune-common: variablesizecommunicator.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,53 +65,79 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Namespaces | │ │ │ │ -Variables
│ │ │ │ -
stdstreams.cc File Reference
│ │ │ │ +Classes | │ │ │ │ +Namespaces
│ │ │ │ +
variablesizecommunicator.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ -
#include "stdstreams.hh"
│ │ │ │ -
│ │ │ │ + │ │ │ │ +

A communicator that only needs to know the number of elements per index at the sender side. │ │ │ │ +More...

│ │ │ │ +
#include <algorithm>
│ │ │ │ +#include <cassert>
│ │ │ │ +#include <cstddef>
│ │ │ │ +#include <functional>
│ │ │ │ +#include <map>
│ │ │ │ +#include <memory>
│ │ │ │ +#include <utility>
│ │ │ │ +#include <vector>
│ │ │ │ +#include <mpi.h>
│ │ │ │ +#include <dune/common/concept.hh>
│ │ │ │ +#include <dune/common/parallel/interface.hh>
│ │ │ │ +#include <dune/common/parallel/mpitraits.hh>
│ │ │ │ +
│ │ │ │ +

Go to the source code of this file.

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

│ │ │ │ +Classes

struct  Dune::Concept::HasFixedSize
 
class  Dune::VariableSizeCommunicator< Allocator >
 A buffered communicator where the amount of data sent does not have to be known a priori. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

│ │ │ │ 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.
 
namespace  Dune::Concept
 Namespace for concepts.
 
│ │ │ │ +

Detailed Description

│ │ │ │ +

A communicator that only needs to know the number of elements per index at the sender side.

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

Variable Documentation

│ │ │ │ + │ │ │ │ +

◆ fixedSize

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
std::size_t fixedSize
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

The number of data items per index if it is fixed, 0 otherwise.

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,36 +6,52 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Namespaces | Variables │ │ │ │ │ -stdstreams.cc File Reference │ │ │ │ │ -#include "stdstreams.hh" │ │ │ │ │ + * parallel │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +variablesizecommunicator.hh File Reference │ │ │ │ │ +Common » Parallel_Communication » Parallel_Computing_based_on_Indexsets │ │ │ │ │ +A communicator that only needs to know the number of elements per index at the │ │ │ │ │ +sender side. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +Go_to_the_source_code_of_this_file. │ │ │ │ │ + Classes │ │ │ │ │ +struct  Dune::Concept::HasFixedSize │ │ │ │ │ +  │ │ │ │ │ + class  Dune::VariableSizeCommunicator<_Allocator_> │ │ │ │ │ +  A buffered communicator where the amount of data sent does not have to │ │ │ │ │ + be known a priori. More... │ │ │ │ │ +  │ │ │ │ │ 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. │ │ │ │ │ +namespace  Dune::Concept │ │ │ │ │ +  Namespace for concepts. │ │ │ │ │   │ │ │ │ │ +***** Detailed Description ***** │ │ │ │ │ +A communicator that only needs to know the number of elements per index at the │ │ │ │ │ +sender side. │ │ │ │ │ + Author │ │ │ │ │ + Markus Blatt │ │ │ │ │ +***** Variable Documentation ***** │ │ │ │ │ +***** ◆ fixedSize ***** │ │ │ │ │ +std::size_t fixedSize │ │ │ │ │ +The number of data items per index if it is fixed, 0 otherwise. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00050.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: mallocallocator.hh File Reference │ │ │ │ +dune-common: mpifuture.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,62 +65,51 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces | │ │ │ │ -Functions
│ │ │ │ -
mallocallocator.hh File Reference
│ │ │ │ +Namespaces
│ │ │ │ +
mpifuture.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ - │ │ │ │ -

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

│ │ │ │ -
#include <exception>
│ │ │ │ -#include <cstdlib>
│ │ │ │ -#include <new>
│ │ │ │ -#include <utility>
│ │ │ │ +
#include <optional>
│ │ │ │ +#include <dune/common/parallel/communication.hh>
│ │ │ │ +#include <dune/common/parallel/future.hh>
│ │ │ │ +#include <dune/common/parallel/mpidata.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

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

│ │ │ │ Classes

class  Dune::MallocAllocator< T >
 Allocators implementation which simply calls malloc/free. More...
struct  Dune::impl::Buffer< T >
 
struct  Dune::impl::Buffer< T & >
 
struct  Dune::impl::Buffer< void >
 
struct  Dune::MallocAllocator< T >::rebind< U >
class  Dune::MPIFuture< R, S >
 Provides a future-like object for MPI communication. It contains the object that will be received and might contain also a sending object, which must be hold (keep alive) until the communication has been completed. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

│ │ │ │ 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
 
namespace  Dune::impl
 
│ │ │ │ -

Detailed Description

│ │ │ │ -

Allocators that use malloc/free.

│ │ │ │ -
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,41 +6,37 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Functions │ │ │ │ │ -mallocallocator.hh File Reference │ │ │ │ │ -Allocators that use malloc/free. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ + * parallel │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +mpifuture.hh File Reference │ │ │ │ │ +#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::impl::Buffer<_T_> │ │ │ │ │   │ │ │ │ │ -struct  Dune::MallocAllocator<_T_>::rebind<_U_> │ │ │ │ │ +struct  Dune::impl::Buffer<_T_&_> │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::impl::Buffer<_void_> │ │ │ │ │ +  │ │ │ │ │ + class  Dune::MPIFuture<_R,_S_> │ │ │ │ │ + Provides a future-like object for MPI communication. It contains the │ │ │ │ │ +  object that will be received and might contain also a sending object, │ │ │ │ │ + which must be hold (keep alive) until the communication has been │ │ │ │ │ + completed. More... │ │ │ │ │   │ │ │ │ │ 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 │ │ │ │ │ +namespace  Dune::impl │ │ │ │ │   │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -Allocators that use malloc/free. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00050_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: mallocallocator.hh Source File │ │ │ │ +dune-common: mpifuture.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,166 +70,290 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
mallocallocator.hh
│ │ │ │ +
mpifuture.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 (C) 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_MALLOC_ALLOCATOR_HH
│ │ │ │ -
6#define DUNE_MALLOC_ALLOCATOR_HH
│ │ │ │ +
5#ifndef DUNE_COMMON_PARALLEL_MPIFUTURE_HH
│ │ │ │ +
6#define DUNE_COMMON_PARALLEL_MPIFUTURE_HH
│ │ │ │
7
│ │ │ │ -
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
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
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 }
│ │ │ │ +
8#include <optional>
│ │ │ │ +
9
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
13
│ │ │ │ +
14#if HAVE_MPI
│ │ │ │ +
15namespace Dune{
│ │ │ │ +
16
│ │ │ │ +
│ │ │ │ +
17 namespace impl{
│ │ │ │ +
18 template<class T>
│ │ │ │ +
│ │ │ │ +
19 struct Buffer{
│ │ │ │ +
│ │ │ │ +
20 Buffer(bool valid){
│ │ │ │ +
21 if(valid)
│ │ │ │ +
22 value = std::make_unique<T>();
│ │ │ │ +
23 }
│ │ │ │ +
│ │ │ │ +
24 template<class V>
│ │ │ │ +
│ │ │ │ +
25 Buffer(V&& t)
│ │ │ │ +
26 : value(std::make_unique<T>(std::forward<V>(t)))
│ │ │ │ +
27 {}
│ │ │ │ +
│ │ │ │ +
28 std::unique_ptr<T> value;
│ │ │ │ +
│ │ │ │ +
29 T get(){
│ │ │ │ +
30 T tmp = std::move(*value);
│ │ │ │ +
31 value.reset();
│ │ │ │ +
32 return tmp;
│ │ │ │ +
33 }
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
34 operator bool () const {
│ │ │ │ +
35 return (bool)value;
│ │ │ │ +
36 }
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
37 T& operator *() const{
│ │ │ │ +
38 return *value;
│ │ │ │ +
39 }
│ │ │ │ +
│ │ │ │ +
40 };
│ │ │ │ +
│ │ │ │ +
41
│ │ │ │ +
42 template<class T>
│ │ │ │ +
│ │ │ │ +
43 struct Buffer<T&>{
│ │ │ │ +
│ │ │ │ +
44 Buffer(bool valid = false)
│ │ │ │ +
45 {
│ │ │ │ +
46 if(valid)
│ │ │ │ +
47 value = T();
│ │ │ │ +
48 }
│ │ │ │ +
│ │ │ │ +
49 template<class V>
│ │ │ │ +
│ │ │ │ +
50 Buffer(V&& t)
│ │ │ │ +
51 : value(std::forward<V>(t))
│ │ │ │ +
52 {}
│ │ │ │ +
│ │ │ │ +
53 std::optional<std::reference_wrapper<T>> value;
│ │ │ │ +
│ │ │ │ +
54 T& get(){
│ │ │ │ +
55 T& tmp = *value;
│ │ │ │ +
56 value.reset();
│ │ │ │ +
57 return tmp;
│ │ │ │ +
58 }
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
59 operator bool () const{
│ │ │ │ +
60 return (bool)value;
│ │ │ │ +
61 }
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
62 T& operator *() const{
│ │ │ │ +
63 return *value;
│ │ │ │ +
64 }
│ │ │ │ +
│ │ │ │ +
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:237
│ │ │ │ -
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:259
│ │ │ │ +
67 template<>
│ │ │ │ +
│ │ │ │ +
68 struct Buffer<void>{
│ │ │ │ +
69 bool valid_;
│ │ │ │ +
│ │ │ │ +
70 Buffer(bool valid = false)
│ │ │ │ +
71 : valid_(valid)
│ │ │ │ +
72 {}
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
73 operator bool () const{
│ │ │ │ +
74 return valid_;
│ │ │ │ +
75 }
│ │ │ │ +
│ │ │ │ +
76 void get(){}
│ │ │ │ +
77 };
│ │ │ │ +
│ │ │ │ +
78 }
│ │ │ │ +
│ │ │ │ +
79
│ │ │ │ +
84 template<class R, class S = void>
│ │ │ │ +
│ │ │ │ +
85 class MPIFuture{
│ │ │ │ +
86 mutable MPI_Request req_;
│ │ │ │ +
87 mutable MPI_Status status_;
│ │ │ │ +
88 impl::Buffer<R> data_;
│ │ │ │ +
89 impl::Buffer<S> send_data_;
│ │ │ │ +
90 friend class Communication<MPI_Comm>;
│ │ │ │ +
91 public:
│ │ │ │ +
│ │ │ │ +
92 MPIFuture(bool valid = false)
│ │ │ │ +
93 : req_(MPI_REQUEST_NULL)
│ │ │ │ +
94 , data_(valid)
│ │ │ │ +
95 {}
│ │ │ │ +
│ │ │ │ +
96
│ │ │ │ +
97 // Hide this constructor if R or S is void
│ │ │ │ +
98 template<class V = R, class U = S>
│ │ │ │ +
│ │ │ │ +
99 MPIFuture(V&& recv_data, U&& send_data, typename std::enable_if_t<!std::is_void<V>::value && !std::is_void<U>::value>* = 0) :
│ │ │ │ +
100 req_(MPI_REQUEST_NULL)
│ │ │ │ +
101 , data_(std::forward<R>(recv_data))
│ │ │ │ +
102 , send_data_(std::forward<S>(send_data))
│ │ │ │ +
103 {}
│ │ │ │ +
│ │ │ │ +
104
│ │ │ │ +
105 // hide this constructor if R is void
│ │ │ │ +
106 template<class V = R>
│ │ │ │ +
│ │ │ │ +
107 MPIFuture(V&& recv_data, typename std::enable_if_t<!std::is_void<V>::value>* = 0)
│ │ │ │ +
108 : req_(MPI_REQUEST_NULL)
│ │ │ │ +
109 , data_(std::forward<V>(recv_data))
│ │ │ │ +
110 {}
│ │ │ │ +
│ │ │ │ +
111
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
113 if(req_ != MPI_REQUEST_NULL){
│ │ │ │ +
114 try{ // might fail when it is a collective communication
│ │ │ │ +
115 MPI_Cancel(&req_);
│ │ │ │ +
116 MPI_Request_free(&req_);
│ │ │ │ +
117 }catch(...){
│ │ │ │ +
118 }
│ │ │ │ +
119 }
│ │ │ │ +
120 }
│ │ │ │ +
│ │ │ │ +
121
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
123 : req_(MPI_REQUEST_NULL)
│ │ │ │ +
124 , data_(std::move(f.data_))
│ │ │ │ +
125 , send_data_(std::move(f.send_data_))
│ │ │ │ +
126 {
│ │ │ │ +
127 std::swap(req_, f.req_);
│ │ │ │ +
128 std::swap(status_, f.status_);
│ │ │ │ +
129 }
│ │ │ │ +
│ │ │ │ +
130
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
132 std::swap(req_, f.req_);
│ │ │ │ +
133 std::swap(status_, f.status_);
│ │ │ │ +
134 std::swap(data_, f.data_);
│ │ │ │ +
135 std::swap(send_data_, f.send_data_);
│ │ │ │ +
136 return *this;
│ │ │ │ +
137 }
│ │ │ │ +
│ │ │ │ +
138
│ │ │ │ +
│ │ │ │ +
139 bool valid() const{
│ │ │ │ +
140 return (bool)data_;
│ │ │ │ +
141 }
│ │ │ │ +
│ │ │ │ +
142
│ │ │ │ +
│ │ │ │ +
143 void wait(){
│ │ │ │ +
144 if(!valid())
│ │ │ │ +
145 DUNE_THROW(InvalidFutureException, "The MPIFuture is not valid!");
│ │ │ │ +
146 MPI_Wait(&req_, &status_);
│ │ │ │ +
147 }
│ │ │ │ +
│ │ │ │ +
148
│ │ │ │ +
│ │ │ │ +
149 bool ready() const{
│ │ │ │ +
150 int flag = -1;
│ │ │ │ +
151 MPI_Test(&req_, &flag, &status_);
│ │ │ │ +
152 return flag;
│ │ │ │ +
153 }
│ │ │ │ +
│ │ │ │ +
154
│ │ │ │ +
│ │ │ │ +
155 R get() {
│ │ │ │ +
156 wait();
│ │ │ │ +
157 return data_.get();
│ │ │ │ +
158 }
│ │ │ │ +
│ │ │ │ +
159
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
161 wait();
│ │ │ │ +
162 return send_data_.get();
│ │ │ │ +
163 }
│ │ │ │ +
│ │ │ │ +
164
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
166 return getMPIData(*data_);
│ │ │ │ +
167 }
│ │ │ │ +
│ │ │ │ +
168
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
170 return getMPIData(*send_data_);
│ │ │ │ +
171 }
│ │ │ │ +
│ │ │ │ +
172 };
│ │ │ │ +
│ │ │ │ +
173
│ │ │ │ +
174}
│ │ │ │ +
175#endif
│ │ │ │ +
176#endif
│ │ │ │ +
Interface class to translate objects to a MPI_Datatype, void* and size used for MPI calls.
│ │ │ │ + │ │ │ │ +
Implements an utility class that provides collective communication methods for sequential programs.
│ │ │ │ +
bigunsignedint< k > operator*(const bigunsignedint< k > &x, std::uintmax_t y)
Definition bigunsignedint.hh:549
│ │ │ │ +
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
│ │ │ │ +
STL namespace.
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
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
│ │ │ │ +
auto getMPIData(T &t)
Definition mpidata.hh:43
│ │ │ │ +
Collective communication interface and sequential default implementation.
Definition communication.hh:100
│ │ │ │ +
This exception is thrown when ready(), wait() or get() is called on an invalid future....
Definition future.hh:18
│ │ │ │ +
Definition mpifuture.hh:19
│ │ │ │ +
std::unique_ptr< T > value
Definition mpifuture.hh:28
│ │ │ │ +
T & operator*() const
Definition mpifuture.hh:37
│ │ │ │ +
Buffer(V &&t)
Definition mpifuture.hh:25
│ │ │ │ +
T get()
Definition mpifuture.hh:29
│ │ │ │ +
Buffer(bool valid)
Definition mpifuture.hh:20
│ │ │ │ +
std::optional< std::reference_wrapper< T > > value
Definition mpifuture.hh:53
│ │ │ │ +
Buffer(bool valid=false)
Definition mpifuture.hh:44
│ │ │ │ +
T & get()
Definition mpifuture.hh:54
│ │ │ │ +
Buffer(V &&t)
Definition mpifuture.hh:50
│ │ │ │ +
bool valid_
Definition mpifuture.hh:69
│ │ │ │ +
void get()
Definition mpifuture.hh:76
│ │ │ │ +
Buffer(bool valid=false)
Definition mpifuture.hh:70
│ │ │ │ +
Provides a future-like object for MPI communication. It contains the object that will be received and...
Definition mpifuture.hh:85
│ │ │ │ +
MPIFuture(V &&recv_data, typename std::enable_if_t<!std::is_void< V >::value > *=0)
Definition mpifuture.hh:107
│ │ │ │ +
bool ready() const
Definition mpifuture.hh:149
│ │ │ │ +
bool valid() const
Definition mpifuture.hh:139
│ │ │ │ +
~MPIFuture()
Definition mpifuture.hh:112
│ │ │ │ +
MPIFuture(bool valid=false)
Definition mpifuture.hh:92
│ │ │ │ +
MPIFuture & operator=(MPIFuture &&f)
Definition mpifuture.hh:131
│ │ │ │ +
auto get_send_mpidata()
Definition mpifuture.hh:169
│ │ │ │ +
void wait()
Definition mpifuture.hh:143
│ │ │ │ +
auto get_mpidata()
Definition mpifuture.hh:165
│ │ │ │ +
R get()
Definition mpifuture.hh:155
│ │ │ │ +
MPIFuture(V &&recv_data, U &&send_data, typename std::enable_if_t<!std::is_void< V >::value &&!std::is_void< U >::value > *=0)
Definition mpifuture.hh:99
│ │ │ │ +
S get_send_data()
Definition mpifuture.hh:160
│ │ │ │ +
MPIFuture(MPIFuture &&f)
Definition mpifuture.hh:122
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,197 +7,299 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -mallocallocator.hh │ │ │ │ │ + * parallel │ │ │ │ │ +mpifuture.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 (C) 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_MALLOC_ALLOCATOR_HH │ │ │ │ │ - 6#define DUNE_MALLOC_ALLOCATOR_HH │ │ │ │ │ + 5#ifndef DUNE_COMMON_PARALLEL_MPIFUTURE_HH │ │ │ │ │ + 6#define DUNE_COMMON_PARALLEL_MPIFUTURE_HH │ │ │ │ │ 7 │ │ │ │ │ - 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 pointer address(reference x) const │ │ │ │ │ - 46 { │ │ │ │ │ - 47 return &x; │ │ │ │ │ + 8#include │ │ │ │ │ + 9 │ │ │ │ │ + 10#include │ │ │ │ │ + 11#include │ │ │ │ │ + 12#include │ │ │ │ │ + 13 │ │ │ │ │ + 14#if HAVE_MPI │ │ │ │ │ + 15namespace Dune{ │ │ │ │ │ + 16 │ │ │ │ │ +17 namespace impl{ │ │ │ │ │ + 18 template │ │ │ │ │ +19 struct Buffer{ │ │ │ │ │ +20 Buffer(bool valid){ │ │ │ │ │ + 21 if(valid) │ │ │ │ │ + 22 value = std::make_unique(); │ │ │ │ │ + 23 } │ │ │ │ │ + 24 template │ │ │ │ │ +25 Buffer(V&& t) │ │ │ │ │ + 26 : value(std::make_unique(std::forward(t))) │ │ │ │ │ + 27 {} │ │ │ │ │ +28 std::unique_ptr value; │ │ │ │ │ +29 T get(){ │ │ │ │ │ + 30 T tmp = std::move(*value); │ │ │ │ │ + 31 value.reset(); │ │ │ │ │ + 32 return tmp; │ │ │ │ │ + 33 } │ │ │ │ │ +34 operator bool () const { │ │ │ │ │ + 35 return (bool)value; │ │ │ │ │ + 36 } │ │ │ │ │ +37 T& operator_*() const{ │ │ │ │ │ + 38 return *value; │ │ │ │ │ + 39 } │ │ │ │ │ + 40 }; │ │ │ │ │ + 41 │ │ │ │ │ + 42 template │ │ │ │ │ +43 struct Buffer{ │ │ │ │ │ +44 Buffer(bool valid = false) │ │ │ │ │ + 45 { │ │ │ │ │ + 46 if(valid) │ │ │ │ │ + 47 value = T(); │ │ │ │ │ 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 } │ │ │ │ │ + 49 template │ │ │ │ │ +50 Buffer(V&& t) │ │ │ │ │ + 51 : value(std::forward(t)) │ │ │ │ │ + 52 {} │ │ │ │ │ +53 std::optional> value; │ │ │ │ │ +54 T& get(){ │ │ │ │ │ + 55 T& tmp = *value; │ │ │ │ │ + 56 value.reset(); │ │ │ │ │ + 57 return tmp; │ │ │ │ │ + 58 } │ │ │ │ │ +59 operator bool () const{ │ │ │ │ │ + 60 return (bool)value; │ │ │ │ │ + 61 } │ │ │ │ │ +62 T& operator_*() const{ │ │ │ │ │ + 63 return *value; │ │ │ │ │ + 64 } │ │ │ │ │ + 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 │ │ │ │ │ - 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:237 │ │ │ │ │ -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:259 │ │ │ │ │ + 67 template<> │ │ │ │ │ +68 struct Buffer{ │ │ │ │ │ +69 bool valid_; │ │ │ │ │ +70 Buffer(bool valid = false) │ │ │ │ │ + 71 : valid_(valid) │ │ │ │ │ + 72 {} │ │ │ │ │ +73 operator bool () const{ │ │ │ │ │ + 74 return valid_; │ │ │ │ │ + 75 } │ │ │ │ │ +76 void get(){} │ │ │ │ │ + 77 }; │ │ │ │ │ + 78 } │ │ │ │ │ + 79 │ │ │ │ │ + 84 template │ │ │ │ │ +85 class MPIFuture{ │ │ │ │ │ + 86 mutable MPI_Request req_; │ │ │ │ │ + 87 mutable MPI_Status status_; │ │ │ │ │ + 88 impl::Buffer data_; │ │ │ │ │ +89 impl::Buffer send_data_; │ │ │ │ │ + 90 friend class Communication; │ │ │ │ │ + 91 public: │ │ │ │ │ +92 MPIFuture(bool valid = false) │ │ │ │ │ + 93 : req_(MPI_REQUEST_NULL) │ │ │ │ │ + 94 , data_(valid) │ │ │ │ │ + 95 {} │ │ │ │ │ + 96 │ │ │ │ │ + 97 // Hide this constructor if R or S is void │ │ │ │ │ + 98 template │ │ │ │ │ +99 MPIFuture(V&& recv_data, U&& send_data, typename std::enable_if_t::value && !std::is_void::value>* = 0) : │ │ │ │ │ + 100 req_(MPI_REQUEST_NULL) │ │ │ │ │ + 101 , data_(std::forward(recv_data)) │ │ │ │ │ + 102 , send_data_(std::forward(send_data)) │ │ │ │ │ + 103 {} │ │ │ │ │ + 104 │ │ │ │ │ + 105 // hide this constructor if R is void │ │ │ │ │ + 106 template │ │ │ │ │ +107 MPIFuture(V&& recv_data, typename std::enable_if_t:: │ │ │ │ │ +value>* = 0) │ │ │ │ │ + 108 : req_(MPI_REQUEST_NULL) │ │ │ │ │ + 109 , data_(std::forward(recv_data)) │ │ │ │ │ + 110 {} │ │ │ │ │ + 111 │ │ │ │ │ +112 ~MPIFuture() { │ │ │ │ │ + 113 if(req_ != MPI_REQUEST_NULL){ │ │ │ │ │ + 114 try{ // might fail when it is a collective communication │ │ │ │ │ + 115 MPI_Cancel(&req_); │ │ │ │ │ + 116 MPI_Request_free(&req_); │ │ │ │ │ + 117 }catch(...){ │ │ │ │ │ + 118 } │ │ │ │ │ + 119 } │ │ │ │ │ + 120 } │ │ │ │ │ + 121 │ │ │ │ │ +122 MPIFuture(MPIFuture&& f) │ │ │ │ │ + 123 : req_(MPI_REQUEST_NULL) │ │ │ │ │ + 124 , data_(std::move(f.data_)) │ │ │ │ │ + 125 , send_data_(std::move(f.send_data_)) │ │ │ │ │ + 126 { │ │ │ │ │ + 127 std::swap(req_, f.req_); │ │ │ │ │ + 128 std::swap(status_, f.status_); │ │ │ │ │ + 129 } │ │ │ │ │ + 130 │ │ │ │ │ +131 MPIFuture& operator=(MPIFuture&& f){ │ │ │ │ │ + 132 std::swap(req_, f.req_); │ │ │ │ │ + 133 std::swap(status_, f.status_); │ │ │ │ │ + 134 std::swap(data_, f.data_); │ │ │ │ │ + 135 std::swap(send_data_, f.send_data_); │ │ │ │ │ + 136 return *this; │ │ │ │ │ + 137 } │ │ │ │ │ + 138 │ │ │ │ │ +139 bool valid() const{ │ │ │ │ │ + 140 return (bool)data_; │ │ │ │ │ + 141 } │ │ │ │ │ + 142 │ │ │ │ │ +143 void wait(){ │ │ │ │ │ + 144 if(!valid()) │ │ │ │ │ + 145 DUNE_THROW(InvalidFutureException, "The MPIFuture is not valid!"); │ │ │ │ │ + 146 MPI_Wait(&req_, &status_); │ │ │ │ │ + 147 } │ │ │ │ │ + 148 │ │ │ │ │ +149 bool ready() const{ │ │ │ │ │ + 150 int flag = -1; │ │ │ │ │ + 151 MPI_Test(&req_, &flag, &status_); │ │ │ │ │ + 152 return flag; │ │ │ │ │ + 153 } │ │ │ │ │ + 154 │ │ │ │ │ +155 R get() { │ │ │ │ │ + 156 wait(); │ │ │ │ │ + 157 return data_.get(); │ │ │ │ │ + 158 } │ │ │ │ │ + 159 │ │ │ │ │ +160 S get_send_data(){ │ │ │ │ │ + 161 wait(); │ │ │ │ │ + 162 return send_data_.get(); │ │ │ │ │ + 163 } │ │ │ │ │ + 164 │ │ │ │ │ +165 auto get_mpidata(){ │ │ │ │ │ + 166 return getMPIData(*data_); │ │ │ │ │ + 167 } │ │ │ │ │ + 168 │ │ │ │ │ +169 auto get_send_mpidata(){ │ │ │ │ │ + 170 return getMPIData(*send_data_); │ │ │ │ │ + 171 } │ │ │ │ │ + 172 }; │ │ │ │ │ + 173 │ │ │ │ │ + 174} │ │ │ │ │ + 175#endif │ │ │ │ │ + 176#endif │ │ │ │ │ +mpidata.hh │ │ │ │ │ +Interface class to translate objects to a MPI_Datatype, void* and size used for │ │ │ │ │ +MPI calls. │ │ │ │ │ +future.hh │ │ │ │ │ +communication.hh │ │ │ │ │ +Implements an utility class that provides collective communication methods for │ │ │ │ │ +sequential programs. │ │ │ │ │ +Dune::operator* │ │ │ │ │ +bigunsignedint< k > operator*(const bigunsignedint< k > &x, std::uintmax_t y) │ │ │ │ │ +Definition bigunsignedint.hh:549 │ │ │ │ │ +DUNE_THROW │ │ │ │ │ +#define DUNE_THROW(E, m) │ │ │ │ │ +Definition exceptions.hh:218 │ │ │ │ │ +std │ │ │ │ │ +STL namespace. │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -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 │ │ │ │ │ +Dune::getMPIData │ │ │ │ │ +auto getMPIData(T &t) │ │ │ │ │ +Definition mpidata.hh:43 │ │ │ │ │ +Dune::Communication │ │ │ │ │ +Collective communication interface and sequential default implementation. │ │ │ │ │ +Definition communication.hh:100 │ │ │ │ │ +Dune::InvalidFutureException │ │ │ │ │ +This exception is thrown when ready(), wait() or get() is called on an invalid │ │ │ │ │ +future.... │ │ │ │ │ +Definition future.hh:18 │ │ │ │ │ +Dune::impl::Buffer │ │ │ │ │ +Definition mpifuture.hh:19 │ │ │ │ │ +Dune::impl::Buffer::value │ │ │ │ │ +std::unique_ptr< T > value │ │ │ │ │ +Definition mpifuture.hh:28 │ │ │ │ │ +Dune::impl::Buffer::operator* │ │ │ │ │ +T & operator*() const │ │ │ │ │ +Definition mpifuture.hh:37 │ │ │ │ │ +Dune::impl::Buffer::Buffer │ │ │ │ │ +Buffer(V &&t) │ │ │ │ │ +Definition mpifuture.hh:25 │ │ │ │ │ +Dune::impl::Buffer::get │ │ │ │ │ +T get() │ │ │ │ │ +Definition mpifuture.hh:29 │ │ │ │ │ +Dune::impl::Buffer::Buffer │ │ │ │ │ +Buffer(bool valid) │ │ │ │ │ +Definition mpifuture.hh:20 │ │ │ │ │ +Dune::impl::Buffer<_T_&_>::value │ │ │ │ │ +std::optional< std::reference_wrapper< T > > value │ │ │ │ │ +Definition mpifuture.hh:53 │ │ │ │ │ +Dune::impl::Buffer<_T_&_>::Buffer │ │ │ │ │ +Buffer(bool valid=false) │ │ │ │ │ +Definition mpifuture.hh:44 │ │ │ │ │ +Dune::impl::Buffer<_T_&_>::get │ │ │ │ │ +T & get() │ │ │ │ │ +Definition mpifuture.hh:54 │ │ │ │ │ +Dune::impl::Buffer<_T_&_>::Buffer │ │ │ │ │ +Buffer(V &&t) │ │ │ │ │ +Definition mpifuture.hh:50 │ │ │ │ │ +Dune::impl::Buffer<_void_>::valid_ │ │ │ │ │ +bool valid_ │ │ │ │ │ +Definition mpifuture.hh:69 │ │ │ │ │ +Dune::impl::Buffer<_void_>::get │ │ │ │ │ +void get() │ │ │ │ │ +Definition mpifuture.hh:76 │ │ │ │ │ +Dune::impl::Buffer<_void_>::Buffer │ │ │ │ │ +Buffer(bool valid=false) │ │ │ │ │ +Definition mpifuture.hh:70 │ │ │ │ │ +Dune::MPIFuture │ │ │ │ │ +Provides a future-like object for MPI communication. It contains the object │ │ │ │ │ +that will be received and... │ │ │ │ │ +Definition mpifuture.hh:85 │ │ │ │ │ +Dune::MPIFuture::MPIFuture │ │ │ │ │ +MPIFuture(V &&recv_data, typename std::enable_if_t::value > │ │ │ │ │ +*=0) │ │ │ │ │ +Definition mpifuture.hh:107 │ │ │ │ │ +Dune::MPIFuture::ready │ │ │ │ │ +bool ready() const │ │ │ │ │ +Definition mpifuture.hh:149 │ │ │ │ │ +Dune::MPIFuture::valid │ │ │ │ │ +bool valid() const │ │ │ │ │ +Definition mpifuture.hh:139 │ │ │ │ │ +Dune::MPIFuture::~MPIFuture │ │ │ │ │ +~MPIFuture() │ │ │ │ │ +Definition mpifuture.hh:112 │ │ │ │ │ +Dune::MPIFuture::MPIFuture │ │ │ │ │ +MPIFuture(bool valid=false) │ │ │ │ │ +Definition mpifuture.hh:92 │ │ │ │ │ +Dune::MPIFuture::operator= │ │ │ │ │ +MPIFuture & operator=(MPIFuture &&f) │ │ │ │ │ +Definition mpifuture.hh:131 │ │ │ │ │ +Dune::MPIFuture::get_send_mpidata │ │ │ │ │ +auto get_send_mpidata() │ │ │ │ │ +Definition mpifuture.hh:169 │ │ │ │ │ +Dune::MPIFuture::wait │ │ │ │ │ +void wait() │ │ │ │ │ +Definition mpifuture.hh:143 │ │ │ │ │ +Dune::MPIFuture::get_mpidata │ │ │ │ │ +auto get_mpidata() │ │ │ │ │ +Definition mpifuture.hh:165 │ │ │ │ │ +Dune::MPIFuture::get │ │ │ │ │ +R get() │ │ │ │ │ +Definition mpifuture.hh:155 │ │ │ │ │ +Dune::MPIFuture::MPIFuture │ │ │ │ │ +MPIFuture(V &&recv_data, U &&send_data, typename std::enable_if_t::value &&!std::is_void< U >::value > *=0) │ │ │ │ │ +Definition mpifuture.hh:99 │ │ │ │ │ +Dune::MPIFuture::get_send_data │ │ │ │ │ +S get_send_data() │ │ │ │ │ +Definition mpifuture.hh:160 │ │ │ │ │ +Dune::MPIFuture::MPIFuture │ │ │ │ │ +MPIFuture(MPIFuture &&f) │ │ │ │ │ +Definition mpifuture.hh:122 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00053.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: arraylist.hh File Reference │ │ │ │ +dune-common: indicessyncer.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,56 +65,86 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces
│ │ │ │ -
arraylist.hh File Reference
│ │ │ │ +Namespaces | │ │ │ │ +Functions
│ │ │ │ + │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

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

Class for adding missing indices of a distributed index set in a local communication. │ │ │ │ More...

│ │ │ │ -
#include <array>
│ │ │ │ +
#include "indexset.hh"
│ │ │ │ +#include "remoteindices.hh"
│ │ │ │ +#include <dune/common/stdstreams.hh>
│ │ │ │ +#include <dune/common/sllist.hh>
│ │ │ │ #include <cassert>
│ │ │ │ -#include <memory>
│ │ │ │ -#include <vector>
│ │ │ │ -#include "iteratorfacades.hh"
│ │ │ │ +#include <cmath>
│ │ │ │ +#include <limits>
│ │ │ │ +#include <algorithm>
│ │ │ │ +#include <functional>
│ │ │ │ +#include <map>
│ │ │ │ +#include <tuple>
│ │ │ │
│ │ │ │

Go to the source code of this file.

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

│ │ │ │ Classes

class  Dune::ArrayList< T, N, A >
 A dynamically growing random access list. More...
 
class  Dune::ArrayListIterator< T, N, A >
 A random access iterator for the Dune::ArrayList class. More...
 
class  Dune::ConstArrayListIterator< T, N, A >
 A constant random access iterator for the Dune::ArrayList class. More...
class  Dune::IndicesSyncer< T >
 Class for recomputing missing indices of a distributed index set. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ +

│ │ │ │ Namespaces

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

│ │ │ │ +Functions

template<typename TG , typename TA >
bool Dune::operator< (const IndexPair< TG, ParallelLocalIndex< TA > > &i1, const std::pair< TG, TA > &i2)
 
template<typename TG , typename TA >
bool Dune::operator< (const std::pair< TG, TA > &i1, const IndexPair< TG, ParallelLocalIndex< TA > > &i2)
 
template<typename TG , typename TA >
bool Dune::operator== (const IndexPair< TG, ParallelLocalIndex< TA > > &i1, const std::pair< TG, TA > &i2)
 
template<typename TG , typename TA >
bool Dune::operator!= (const IndexPair< TG, ParallelLocalIndex< TA > > &i1, const std::pair< TG, TA > &i2)
 
template<typename TG , typename TA >
bool Dune::operator== (const std::pair< TG, TA > &i2, const IndexPair< TG, ParallelLocalIndex< TA > > &i1)
 
template<typename TG , typename TA >
bool Dune::operator!= (const std::pair< TG, TA > &i2, const IndexPair< TG, ParallelLocalIndex< TA > > &i1)
 
template<typename T , typename A , typename A1 >
void Dune::storeGlobalIndicesOfRemoteIndices (std::map< int, SLList< std::pair< typename T::GlobalIndex, typename T::LocalIndex::Attribute >, A > > &globalMap, const RemoteIndices< T, A1 > &remoteIndices)
 Stores the corresponding global indices of the remote index information.
 
template<typename T , typename A , typename A1 >
void Dune::repairLocalIndexPointers (std::map< int, SLList< std::pair< typename T::GlobalIndex, typename T::LocalIndex::Attribute >, A > > &globalMap, RemoteIndices< T, A1 > &remoteIndices, const T &indexSet)
 Repair the pointers to the local indices in the remote indices.
 
│ │ │ │

Detailed Description

│ │ │ │ -

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
│ │ │ │ +

Class for adding missing indices of a distributed index set in a local communication.

│ │ │ │ +
Author
Markus Blatt
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,43 +6,79 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -arraylist.hh File Reference │ │ │ │ │ -Implements a random-access container that can efficiently change size (similar │ │ │ │ │ -to std::deque) More... │ │ │ │ │ -#include │ │ │ │ │ + * parallel │ │ │ │ │ +Classes | Namespaces | Functions │ │ │ │ │ +indicessyncer.hh File Reference │ │ │ │ │ +Common » Parallel_Communication » Parallel_Computing_based_on_Indexsets │ │ │ │ │ +Class for adding missing indices of a distributed index set in a local │ │ │ │ │ +communication. More... │ │ │ │ │ +#include "indexset.hh" │ │ │ │ │ +#include "remoteindices.hh" │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include "iteratorfacades.hh" │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class  Dune::ArrayList<_T,_N,_A_> │ │ │ │ │ -  A dynamically growing random access list. More... │ │ │ │ │ -  │ │ │ │ │ -class  Dune::ArrayListIterator<_T,_N,_A_> │ │ │ │ │ -  A random access iterator for the Dune::ArrayList class. More... │ │ │ │ │ -  │ │ │ │ │ -class  Dune::ConstArrayListIterator<_T,_N,_A_> │ │ │ │ │ -  A constant random access iterator for the Dune::ArrayList class. │ │ │ │ │ +class  Dune::IndicesSyncer<_T_> │ │ │ │ │ +  Class for recomputing missing indices of a distributed index set. │ │ │ │ │ More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ + Functions │ │ │ │ │ +template │ │ │ │ │ +bool Dune::operator< (const IndexPair< TG, ParallelLocalIndex< TA > > &i1, │ │ │ │ │ + const std::pair< TG, TA > &i2) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +bool Dune::operator< (const std::pair< TG, TA > &i1, const IndexPair< TG, │ │ │ │ │ + ParallelLocalIndex< TA > > &i2) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +bool Dune::operator== (const IndexPair< TG, ParallelLocalIndex< TA > > &i1, │ │ │ │ │ + const std::pair< TG, TA > &i2) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +bool Dune::operator!= (const IndexPair< TG, ParallelLocalIndex< TA > > &i1, │ │ │ │ │ + const std::pair< TG, TA > &i2) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +bool Dune::operator== (const std::pair< TG, TA > &i2, const IndexPair< TG, │ │ │ │ │ + ParallelLocalIndex< TA > > &i1) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +bool Dune::operator!= (const std::pair< TG, TA > &i2, const IndexPair< TG, │ │ │ │ │ + ParallelLocalIndex< TA > > &i1) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +void Dune::storeGlobalIndicesOfRemoteIndices (std::map< int, SLList< std:: │ │ │ │ │ + pair< typename T::GlobalIndex, typename T::LocalIndex::Attribute >, A > > │ │ │ │ │ + &globalMap, const RemoteIndices< T, A1 > &remoteIndices) │ │ │ │ │ +  Stores the corresponding global indices of the remote index information. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +void Dune::repairLocalIndexPointers (std::map< int, SLList< std::pair< │ │ │ │ │ + typename T::GlobalIndex, typename T::LocalIndex::Attribute >, A > > │ │ │ │ │ + &globalMap, RemoteIndices< T, A1 > &remoteIndices, const T &indexSet) │ │ │ │ │ +  Repair the pointers to the local indices in the remote indices. │ │ │ │ │ +  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -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. │ │ │ │ │ +Class for adding missing indices of a distributed index set in a local │ │ │ │ │ +communication. │ │ │ │ │ Author │ │ │ │ │ Markus Blatt │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00053_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: arraylist.hh Source File │ │ │ │ +dune-common: indicessyncer.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,627 +70,1051 @@ │ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
arraylist.hh
│ │ │ │ +
indicessyncer.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 (C) 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_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;
│ │ │ │ +
5#ifndef DUNE_INDICESSYNCER_HH
│ │ │ │ +
6#define DUNE_INDICESSYNCER_HH
│ │ │ │ +
7
│ │ │ │ +
8#include "indexset.hh"
│ │ │ │ +
9#include "remoteindices.hh"
│ │ │ │ + │ │ │ │ +
11#include <dune/common/sllist.hh>
│ │ │ │ +
12#include <cassert>
│ │ │ │ +
13#include <cmath>
│ │ │ │ +
14#include <limits>
│ │ │ │ +
15#include <algorithm>
│ │ │ │ +
16#include <functional>
│ │ │ │ +
17#include <map>
│ │ │ │ +
18#include <tuple>
│ │ │ │ +
19
│ │ │ │ +
20#if HAVE_MPI
│ │ │ │ +
21namespace Dune
│ │ │ │ +
22{
│ │ │ │ +
39 template<typename T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
41 {
│ │ │ │ +
42 public:
│ │ │ │ +
43
│ │ │ │ + │ │ │ │ +
46
│ │ │ │ + │ │ │ │ +
49
│ │ │ │ + │ │ │ │ +
52
│ │ │ │ +
54 typedef typename ParallelIndexSet::LocalIndex::Attribute Attribute;
│ │ │ │ +
55
│ │ │ │ + │ │ │ │ +
60
│ │ │ │ + │ │ │ │ +
71 RemoteIndices& remoteIndices);
│ │ │ │ +
72
│ │ │ │ +
82 void sync();
│ │ │ │ +
83
│ │ │ │ +
94 template<typename T1>
│ │ │ │ +
95 void sync(T1& numberer);
│ │ │ │ +
96
│ │ │ │ +
97 private:
│ │ │ │ +
98
│ │ │ │ +
100 ParallelIndexSet& indexSet_;
│ │ │ │
101
│ │ │ │ - │ │ │ │ -
106
│ │ │ │ - │ │ │ │ -
111
│ │ │ │ -
115 typedef std::size_t size_type;
│ │ │ │ +
103 RemoteIndices& remoteIndices_;
│ │ │ │ +
104
│ │ │ │ +
106 char** sendBuffers_;
│ │ │ │ +
107
│ │ │ │ +
109 char* receiveBuffer_;
│ │ │ │ +
110
│ │ │ │ +
112 std::size_t* sendBufferSizes_;
│ │ │ │ +
113
│ │ │ │ +
115 int receiveBufferSize_; // int because of MPI
│ │ │ │
116
│ │ │ │ -
120 typedef std::ptrdiff_t difference_type;
│ │ │ │ -
121
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
127
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
134
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
140
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
146
│ │ │ │ -
│ │ │ │ -
151 inline void push_back(const_reference entry);
│ │ │ │ -
152
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
159
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
166
│ │ │ │ -
│ │ │ │ -
171 inline size_type size() const;
│ │ │ │ -
172
│ │ │ │ -
│ │ │ │ -
180 inline void purge();
│ │ │ │ -
181
│ │ │ │ -
│ │ │ │ -
185 inline void clear();
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
190
│ │ │ │ -
191 private:
│ │ │ │ -
192
│ │ │ │ -
196 using SmartPointerAllocator = typename std::allocator_traits<A>::template rebind_alloc< std::shared_ptr< std::array<MemberType,chunkSize_> > >;
│ │ │ │ +
120 struct MessageInformation
│ │ │ │ +
121 {
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
123 : publish(), pairs()
│ │ │ │ +
124 {}
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
131 int pairs;
│ │ │ │ +
132 };
│ │ │ │ +
133
│ │ │ │ +
137 class DefaultNumberer
│ │ │ │ +
138 {
│ │ │ │ +
139 public:
│ │ │ │ +
145 std::size_t operator()([[maybe_unused]] const GlobalIndex& global)
│ │ │ │ +
146 {
│ │ │ │ +
147 return std::numeric_limits<size_t>::max();
│ │ │ │ +
148 }
│ │ │ │ +
149 };
│ │ │ │ +
150
│ │ │ │ +
152 MPI_Datatype datatype_;
│ │ │ │ +
153
│ │ │ │ +
155 int rank_;
│ │ │ │ +
156
│ │ │ │ +
161 typedef SLList<std::pair<GlobalIndex,Attribute>, typename RemoteIndices::Allocator> GlobalIndexList;
│ │ │ │ +
162
│ │ │ │ +
164 typedef typename GlobalIndexList::ModifyIterator GlobalIndexModifier;
│ │ │ │ +
165
│ │ │ │ + │ │ │ │ +
170 GlobalIndexIterator;
│ │ │ │ +
171
│ │ │ │ +
173 typedef std::map<int, GlobalIndexList> GlobalIndicesMap;
│ │ │ │ +
174
│ │ │ │ +
183 GlobalIndicesMap globalMap_;
│ │ │ │ +
184
│ │ │ │ + │ │ │ │ +
189
│ │ │ │ +
193 typedef typename BoolList::iterator BoolIterator;
│ │ │ │ +
194
│ │ │ │ +
196 typedef typename BoolList::ModifyIterator BoolListModifier;
│ │ │ │
197
│ │ │ │ -
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
│ │ │ │ -
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 {
│ │ │ │ +
199 typedef std::map<int,BoolList> BoolMap;
│ │ │ │ +
200
│ │ │ │ +
205 BoolMap oldMap_;
│ │ │ │ +
206
│ │ │ │ +
208 std::map<int,MessageInformation> infoSend_;
│ │ │ │ +
209
│ │ │ │ +
211 typedef typename RemoteIndices::RemoteIndexList RemoteIndexList;
│ │ │ │ +
212
│ │ │ │ +
214 typedef typename RemoteIndexList::ModifyIterator RemoteIndexModifier;
│ │ │ │ +
215
│ │ │ │ + │ │ │ │ +
218
│ │ │ │ +
220 typedef typename RemoteIndexList::iterator RemoteIndexIterator;
│ │ │ │ +
221
│ │ │ │ +
223 typedef typename RemoteIndexList::const_iterator ConstRemoteIndexIterator;
│ │ │ │ +
224
│ │ │ │ +
226 typedef std::tuple<RemoteIndexModifier,GlobalIndexModifier,BoolListModifier,
│ │ │ │ +
227 const ConstRemoteIndexIterator> IteratorTuple;
│ │ │ │ +
228
│ │ │ │ +
236 class Iterators
│ │ │ │ +
237 {
│ │ │ │ +
238 friend class IndicesSyncer<T>;
│ │ │ │ +
239 public:
│ │ │ │ +
249 Iterators(RemoteIndexList& remoteIndices, GlobalIndexList& globalIndices,
│ │ │ │ +
250 BoolList& booleans);
│ │ │ │ +
251
│ │ │ │ +
255 Iterators();
│ │ │ │
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
│ │ │ │ -
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
│ │ │ │ -
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
│ │ │ │ -
309 inline reference elementAt(size_type i) const;
│ │ │ │ -
310
│ │ │ │ -
315 inline reference dereference() const;
│ │ │ │ + │ │ │ │ +
261
│ │ │ │ +
267 void insert(const RemoteIndex& index,
│ │ │ │ +
268 const std::pair<GlobalIndex,Attribute>& global);
│ │ │ │ +
269
│ │ │ │ +
274 RemoteIndex& remoteIndex() const;
│ │ │ │ +
275
│ │ │ │ +
280 std::pair<GlobalIndex,Attribute>& globalIndexPair() const;
│ │ │ │ +
281
│ │ │ │ + │ │ │ │ +
283
│ │ │ │ +
289 bool isOld() const;
│ │ │ │ +
290
│ │ │ │ +
300 void reset(RemoteIndexList& remoteIndices, GlobalIndexList& globalIndices,
│ │ │ │ +
301 BoolList& booleans);
│ │ │ │ +
302
│ │ │ │ +
308 bool isNotAtEnd() const;
│ │ │ │ +
309
│ │ │ │ +
315 bool isAtEnd() const;
│ │ │ │
316
│ │ │ │ -
328 inline void eraseToHere();
│ │ │ │ +
317 private:
│ │ │ │ +
327 IteratorTuple iterators_;
│ │ │ │ +
328 };
│ │ │ │
329
│ │ │ │ -
331 inline size_type position(){return position_;}
│ │ │ │ +
331 typedef std::map<int,Iterators> IteratorsMap;
│ │ │ │
332
│ │ │ │ -
334 inline void advance(difference_type n);
│ │ │ │ -
335
│ │ │ │ -
337 inline difference_type distanceTo(const ArrayListIterator<T,N,A>& other) const;
│ │ │ │ -
338
│ │ │ │ -
│ │ │ │ -
340 inline ArrayListIterator() : position_(0), list_(nullptr)
│ │ │ │ -
341 {}
│ │ │ │ -
│ │ │ │ -
342
│ │ │ │ -
343 private:
│ │ │ │ - │ │ │ │ -
350
│ │ │ │ -
354 size_type position_;
│ │ │ │ - │ │ │ │ -
359 };
│ │ │ │ -
│ │ │ │ -
360
│ │ │ │ -
364 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
366 : public RandomAccessIteratorFacade<ConstArrayListIterator<T,N,A>,
│ │ │ │ -
367 const typename A::value_type,
│ │ │ │ -
368 typename A::value_type const&,
│ │ │ │ -
369 typename A::difference_type>
│ │ │ │ -
370 {
│ │ │ │ -
371
│ │ │ │ -
372 friend class ArrayList<T,N,A>;
│ │ │ │ -
373 friend class ArrayListIterator<T,N,A>;
│ │ │ │ -
374
│ │ │ │ -
375 public:
│ │ │ │ -
379 typedef typename A::value_type MemberType;
│ │ │ │ -
380
│ │ │ │ -
381 typedef typename A::difference_type difference_type;
│ │ │ │ -
382
│ │ │ │ -
383 typedef typename A::size_type size_type;
│ │ │ │ -
384
│ │ │ │ -
385 using reference = typename A::value_type &;
│ │ │ │ -
386
│ │ │ │ -
387 using const_reference = typename A::value_type const&;
│ │ │ │ -
388
│ │ │ │ -
394 constexpr static int chunkSize_ = (N > 0) ? N : 1;
│ │ │ │ -
395
│ │ │ │ +
344 IteratorsMap iteratorsMap_;
│ │ │ │ +
345
│ │ │ │ +
347 void calculateMessageSizes();
│ │ │ │ +
348
│ │ │ │ +
356 void packAndSend(int destination, char* buffer, std::size_t bufferSize, MPI_Request& req);
│ │ │ │ +
357
│ │ │ │ +
362 template<typename T1>
│ │ │ │ +
363 void recvAndUnpack(T1& numberer);
│ │ │ │ +
364
│ │ │ │ +
368 void registerMessageDatatype();
│ │ │ │ +
369
│ │ │ │ +
373 void insertIntoRemoteIndexList(int process,
│ │ │ │ +
374 const std::pair<GlobalIndex,Attribute>& global,
│ │ │ │ +
375 char attribute);
│ │ │ │ +
376
│ │ │ │ +
380 void resetIteratorsMap();
│ │ │ │ +
381
│ │ │ │ +
386 bool checkReset();
│ │ │ │ +
387
│ │ │ │ +
396 bool checkReset(const Iterators& iterators, RemoteIndexList& rlist, GlobalIndexList& gList,
│ │ │ │ +
397 BoolList& bList);
│ │ │ │ +
398 };
│ │ │ │ +
│ │ │ │ +
399
│ │ │ │ +
400 template<typename TG, typename TA>
│ │ │ │
│ │ │ │ -
401 inline bool equals(const ConstArrayListIterator<MemberType,N,A>& other) const;
│ │ │ │ -
402
│ │ │ │ -
│ │ │ │ -
406 inline void increment();
│ │ │ │ + │ │ │ │ +
402 const std::pair<TG,TA>& i2)
│ │ │ │ +
403 {
│ │ │ │ +
404 return i1.global() < i2.first ||
│ │ │ │ +
405 (i1.global() == i2.first && i1.local().attribute()<i2.second);
│ │ │ │ +
406 }
│ │ │ │ +
│ │ │ │
407
│ │ │ │ -
│ │ │ │ -
411 inline void decrement();
│ │ │ │ -
412
│ │ │ │ -
│ │ │ │ -
414 inline void advance(difference_type n);
│ │ │ │ +
408 template<typename TG, typename TA>
│ │ │ │ +
│ │ │ │ +
409 bool operator<(const std::pair<TG,TA>& i1,
│ │ │ │ +
410 const IndexPair<TG,ParallelLocalIndex<TA> >& i2)
│ │ │ │ +
411 {
│ │ │ │ +
412 return i1.first < i2.global() ||
│ │ │ │ +
413 (i1.first == i2.global() && i1.second<i2.local().attribute());
│ │ │ │ +
414 }
│ │ │ │ +
│ │ │ │
415
│ │ │ │ +
416 template<typename TG, typename TA>
│ │ │ │
│ │ │ │ - │ │ │ │ -
418
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
424
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
430
│ │ │ │ -
│ │ │ │ -
431 inline ConstArrayListIterator() : position_(0), list_(nullptr)
│ │ │ │ -
432 {}
│ │ │ │ + │ │ │ │ +
418 const std::pair<TG,TA>& i2)
│ │ │ │ +
419 {
│ │ │ │ +
420 return (i1.global() == i2.first && i1.local().attribute()==i2.second);
│ │ │ │ +
421 }
│ │ │ │ +
│ │ │ │ +
422
│ │ │ │ +
423 template<typename TG, typename TA>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
425 const std::pair<TG,TA>& i2)
│ │ │ │ +
426 {
│ │ │ │ +
427 return (i1.global() != i2.first || i1.local().attribute()!=i2.second);
│ │ │ │ +
428 }
│ │ │ │
│ │ │ │ -
433
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
435
│ │ │ │ -
436 private:
│ │ │ │ -
437
│ │ │ │ -
443 inline ConstArrayListIterator(const ArrayList<T,N,A>& arrayList, size_type position);
│ │ │ │ -
444
│ │ │ │ -
448 size_type position_;
│ │ │ │ -
452 const ArrayList<T,N,A>* list_;
│ │ │ │ -
453 };
│ │ │ │ -
454
│ │ │ │ -
455
│ │ │ │ -
456 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
458 : capacity_(0), size_(0), start_(0)
│ │ │ │ -
459 {
│ │ │ │ -
460 chunks_.reserve(100);
│ │ │ │ -
461 }
│ │ │ │ -
│ │ │ │ -
462
│ │ │ │ -
463 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
465 capacity_=0;
│ │ │ │ -
466 size_=0;
│ │ │ │ -
467 start_=0;
│ │ │ │ -
468 chunks_.clear();
│ │ │ │ -
469 }
│ │ │ │ -
│ │ │ │ -
470
│ │ │ │ -
471 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
473 {
│ │ │ │ -
474 return size_;
│ │ │ │ -
475 }
│ │ │ │ -
│ │ │ │ -
476
│ │ │ │ -
477 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
479 {
│ │ │ │ -
480 size_t index=start_+size_;
│ │ │ │ -
481 if(index==capacity_)
│ │ │ │ -
482 {
│ │ │ │ -
483 chunks_.push_back(std::make_shared<std::array<MemberType,chunkSize_> >());
│ │ │ │ -
484 capacity_ += chunkSize_;
│ │ │ │ -
485 }
│ │ │ │ -
486 elementAt(index)=entry;
│ │ │ │ -
487 ++size_;
│ │ │ │ -
488 }
│ │ │ │ -
│ │ │ │ -
489
│ │ │ │ -
490 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ +
429
│ │ │ │ +
430 template<typename TG, typename TA>
│ │ │ │ +
│ │ │ │ +
431 bool operator==(const std::pair<TG,TA>& i2,
│ │ │ │ +
432 const IndexPair<TG,ParallelLocalIndex<TA> >& i1)
│ │ │ │ +
433 {
│ │ │ │ +
434 return (i1.global() == i2.first && i1.local().attribute()==i2.second);
│ │ │ │ +
435 }
│ │ │ │ +
│ │ │ │ +
436
│ │ │ │ +
437 template<typename TG, typename TA>
│ │ │ │ +
│ │ │ │ +
438 bool operator!=(const std::pair<TG,TA>& i2,
│ │ │ │ +
439 const IndexPair<TG,ParallelLocalIndex<TA> >& i1)
│ │ │ │ +
440 {
│ │ │ │ +
441 return (i1.global() != i2.first || i1.local().attribute()!=i2.second);
│ │ │ │ +
442 }
│ │ │ │ +
│ │ │ │ +
443
│ │ │ │ +
460 template<typename T, typename A, typename A1>
│ │ │ │ +
│ │ │ │ +
461 void storeGlobalIndicesOfRemoteIndices(std::map<int,SLList<std::pair<typename T::GlobalIndex, typename T::LocalIndex::Attribute>,A> >& globalMap,
│ │ │ │ +
462 const RemoteIndices<T,A1>& remoteIndices)
│ │ │ │ +
463 {
│ │ │ │ +
464 for(auto remote = remoteIndices.begin(), end =remoteIndices.end(); remote != end; ++remote) {
│ │ │ │ +
465 typedef typename RemoteIndices<T,A1>::RemoteIndexList RemoteIndexList;
│ │ │ │ + │ │ │ │ +
467 GlobalIndexList& global = globalMap[remote->first];
│ │ │ │ +
468 RemoteIndexList& rList = *(remote->second.first);
│ │ │ │ +
469
│ │ │ │ +
470 for(auto index = rList.begin(), riEnd = rList.end();
│ │ │ │ +
471 index != riEnd; ++index) {
│ │ │ │ +
472 global.push_back(std::make_pair(index->localIndexPair().global(),
│ │ │ │ +
473 index->localIndexPair().local().attribute()));
│ │ │ │ +
474 }
│ │ │ │ +
475 }
│ │ │ │ +
476 }
│ │ │ │ +
│ │ │ │ +
477
│ │ │ │ +
486 template<typename T, typename A, typename A1>
│ │ │ │ +
│ │ │ │ +
487 inline void repairLocalIndexPointers(std::map<int,
│ │ │ │ +
488 SLList<std::pair<typename T::GlobalIndex,
│ │ │ │ +
489 typename T::LocalIndex::Attribute>,A> >& globalMap,
│ │ │ │ +
490 RemoteIndices<T,A1>& remoteIndices,
│ │ │ │ +
491 const T& indexSet)
│ │ │ │
492 {
│ │ │ │ -
493 return elementAt(start_+i);
│ │ │ │ -
494 }
│ │ │ │ -
│ │ │ │ -
495
│ │ │ │ -
496
│ │ │ │ -
497 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
499 {
│ │ │ │ -
500 return elementAt(start_+i);
│ │ │ │ -
501 }
│ │ │ │ -
│ │ │ │ -
502
│ │ │ │ -
503 template<class T, int N, class A>
│ │ │ │ - │ │ │ │ -
505 {
│ │ │ │ -
506 return chunks_[i/chunkSize_]->operator[](i%chunkSize_);
│ │ │ │ -
507 }
│ │ │ │ -
508
│ │ │ │ -
509
│ │ │ │ -
510 template<class T, int N, class A>
│ │ │ │ -
511 typename ArrayList<T,N,A>::const_reference ArrayList<T,N,A>::elementAt(size_type i) const
│ │ │ │ -
512 {
│ │ │ │ -
513 return chunks_[i/chunkSize_]->operator[](i%chunkSize_);
│ │ │ │ -
514 }
│ │ │ │ -
515
│ │ │ │ -
516 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
518 {
│ │ │ │ -
519 return ArrayListIterator<T,N,A>(*this, start_);
│ │ │ │ -
520 }
│ │ │ │ -
│ │ │ │ -
521
│ │ │ │ -
522 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
524 {
│ │ │ │ -
525 return ConstArrayListIterator<T,N,A>(*this, start_);
│ │ │ │ -
526 }
│ │ │ │ -
│ │ │ │ -
527
│ │ │ │ -
528 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
530 {
│ │ │ │ -
531 return ArrayListIterator<T,N,A>(*this, start_+size_);
│ │ │ │ -
532 }
│ │ │ │ -
│ │ │ │ -
533
│ │ │ │ -
534 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
536 {
│ │ │ │ -
537 return ConstArrayListIterator<T,N,A>(*this, start_+size_);
│ │ │ │ -
538 }
│ │ │ │ -
│ │ │ │ -
539
│ │ │ │ -
540 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
542 {
│ │ │ │ -
543 // Distance to copy to the left.
│ │ │ │ -
544 size_t distance = start_/chunkSize_;
│ │ │ │ -
545 if(distance>0) {
│ │ │ │ -
546 // Number of chunks with entries in it;
│ │ │ │ -
547 size_t chunks = ((start_%chunkSize_ + size_)/chunkSize_ );
│ │ │ │ -
548
│ │ │ │ -
549 // Copy chunks to the left.
│ │ │ │ -
550 std::copy(chunks_.begin()+distance,
│ │ │ │ -
551 chunks_.begin()+(distance+chunks), chunks_.begin());
│ │ │ │ -
552
│ │ │ │ -
553 // Calculate new parameters
│ │ │ │ -
554 start_ = start_ % chunkSize_;
│ │ │ │ -
555 //capacity += distance * chunkSize_;
│ │ │ │ -
556 }
│ │ │ │ -
557 }
│ │ │ │ +
493 assert(globalMap.size()==static_cast<std::size_t>(remoteIndices.neighbours()));
│ │ │ │ +
494 // Repair pointers to index set in remote indices.
│ │ │ │ +
495 auto global = globalMap.begin();
│ │ │ │ +
496 auto end = remoteIndices.remoteIndices_.end();
│ │ │ │ +
497
│ │ │ │ +
498 for(auto remote = remoteIndices.remoteIndices_.begin(); remote != end; ++remote, ++global) {
│ │ │ │ +
499 assert(remote->first==global->first);
│ │ │ │ +
500 assert(remote->second.first->size() == global->second.size());
│ │ │ │ +
501
│ │ │ │ +
502 auto riEnd = remote->second.first->end();
│ │ │ │ +
503 auto rIndex = remote->second.first->begin();
│ │ │ │ +
504 auto gIndex = global->second.begin();
│ │ │ │ +
505 auto index = indexSet.begin();
│ │ │ │ +
506
│ │ │ │ +
507 assert(rIndex==riEnd || gIndex != global->second.end());
│ │ │ │ +
508 while(rIndex != riEnd) {
│ │ │ │ +
509 // Search for the index in the set.
│ │ │ │ +
510 assert(gIndex != global->second.end());
│ │ │ │ +
511
│ │ │ │ +
512 while(!(index->global() == gIndex->first
│ │ │ │ +
513 && index->local().attribute() == gIndex->second)) {
│ │ │ │ +
514 ++index;
│ │ │ │ +
515 // this is only needed for ALU, where there may exist
│ │ │ │ +
516 // more entries with the same global index in the remote index set
│ │ │ │ +
517 // than in the index set
│ │ │ │ +
518 if (index->global() > gIndex->first) {
│ │ │ │ +
519 index=indexSet.begin();
│ │ │ │ +
520 }
│ │ │ │ +
521 }
│ │ │ │ +
522
│ │ │ │ +
523 assert(index != indexSet.end() && *index == *gIndex);
│ │ │ │ +
524
│ │ │ │ +
525 rIndex->localIndex_ = &(*index);
│ │ │ │ +
526 ++index;
│ │ │ │ +
527 ++rIndex;
│ │ │ │ +
528 ++gIndex;
│ │ │ │ +
529 }
│ │ │ │ +
530 }
│ │ │ │ +
531 remoteIndices.sourceSeqNo_ = remoteIndices.source_->seqNo();
│ │ │ │ +
532 remoteIndices.destSeqNo_ = remoteIndices.target_->seqNo();
│ │ │ │ +
533 }
│ │ │ │ +
│ │ │ │ +
534
│ │ │ │ +
535 template<typename T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
537 RemoteIndices& remoteIndices)
│ │ │ │ +
538 : indexSet_(indexSet), remoteIndices_(remoteIndices)
│ │ │ │ +
539 {
│ │ │ │ +
540 // index sets must match.
│ │ │ │ +
541 assert(remoteIndices.source_ == remoteIndices.target_);
│ │ │ │ +
542 assert(remoteIndices.source_ == &indexSet);
│ │ │ │ +
543 MPI_Comm_rank(remoteIndices_.communicator(), &rank_);
│ │ │ │ +
544 }
│ │ │ │ +
│ │ │ │ +
545
│ │ │ │ +
546 template<typename T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
548 GlobalIndexList& globalIndices,
│ │ │ │ +
549 BoolList& booleans)
│ │ │ │ +
550 : iterators_(remoteIndices.beginModify(), globalIndices.beginModify(),
│ │ │ │ +
551 booleans.beginModify(), remoteIndices.end())
│ │ │ │ +
552 { }
│ │ │ │ +
│ │ │ │ +
553
│ │ │ │ +
554 template<typename T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
556 : iterators_()
│ │ │ │ +
557 {}
│ │ │ │
│ │ │ │
558
│ │ │ │ -
559 template<class T, int N, class A>
│ │ │ │ +
559 template<typename T>
│ │ │ │
│ │ │ │ - │ │ │ │ + │ │ │ │
561 {
│ │ │ │ -
562 position_+=i;
│ │ │ │ -
563 }
│ │ │ │ -
│ │ │ │ -
564
│ │ │ │ -
565 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
567 {
│ │ │ │ -
568 position_+=i;
│ │ │ │ -
569 }
│ │ │ │ -
│ │ │ │ -
570
│ │ │ │ -
571
│ │ │ │ -
572 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
574 {
│ │ │ │ -
575 // Makes only sense if we reference a common list
│ │ │ │ -
576 assert(list_==(other.list_));
│ │ │ │ -
577 return position_==other.position_ ;
│ │ │ │ -
578 }
│ │ │ │ -
│ │ │ │ -
579
│ │ │ │ -
580
│ │ │ │ -
581 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
583 {
│ │ │ │ -
584 // Makes only sense if we reference a common list
│ │ │ │ -
585 assert(list_==(other.list_));
│ │ │ │ -
586 return position_==other.position_ ;
│ │ │ │ -
587 }
│ │ │ │ -
│ │ │ │ -
588
│ │ │ │ -
589
│ │ │ │ -
590 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
592 {
│ │ │ │ -
593 // Makes only sense if we reference a common list
│ │ │ │ -
594 assert(list_==(other.list_));
│ │ │ │ -
595 return position_==other.position_ ;
│ │ │ │ -
596 }
│ │ │ │ -
│ │ │ │ -
597
│ │ │ │ -
598 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
600 {
│ │ │ │ -
601 ++position_;
│ │ │ │ -
602 }
│ │ │ │ -
│ │ │ │ -
603
│ │ │ │ -
604 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
606 {
│ │ │ │ -
607 ++position_;
│ │ │ │ -
608 }
│ │ │ │ -
│ │ │ │ -
609
│ │ │ │ -
610 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
612 {
│ │ │ │ -
613 --position_;
│ │ │ │ -
614 }
│ │ │ │ -
│ │ │ │ -
615
│ │ │ │ -
616 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
618 {
│ │ │ │ -
619 --position_;
│ │ │ │ -
620 }
│ │ │ │ -
│ │ │ │ -
621
│ │ │ │ -
622 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
624 {
│ │ │ │ -
625 return list_->elementAt(i+position_);
│ │ │ │ -
626 }
│ │ │ │ -
│ │ │ │ -
627
│ │ │ │ -
628 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
630 {
│ │ │ │ -
631 return list_->elementAt(i+position_);
│ │ │ │ -
632 }
│ │ │ │ -
│ │ │ │ -
633
│ │ │ │ -
634 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
636 {
│ │ │ │ -
637 return list_->elementAt(position_);
│ │ │ │ -
638 }
│ │ │ │ -
│ │ │ │ -
639
│ │ │ │ -
640 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
642 {
│ │ │ │ -
643 return list_->elementAt(position_);
│ │ │ │ -
644 }
│ │ │ │ -
│ │ │ │ -
645
│ │ │ │ -
646 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
648 {
│ │ │ │ -
649 // Makes only sense if we reference a common list
│ │ │ │ -
650 assert(list_==(other.list_));
│ │ │ │ -
651 return other.position_ - position_;
│ │ │ │ -
652 }
│ │ │ │ -
│ │ │ │ -
653
│ │ │ │ -
654 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
656 {
│ │ │ │ -
657 // Makes only sense if we reference a common list
│ │ │ │ -
658 assert(list_==(other.list_));
│ │ │ │ -
659 return other.position_ - position_;
│ │ │ │ -
660 }
│ │ │ │ -
│ │ │ │ -
661
│ │ │ │ -
662 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
664 {
│ │ │ │ -
665 list_->size_ -= ++position_ - list_->start_;
│ │ │ │ -
666 // chunk number of the new position.
│ │ │ │ -
667 size_t posChunkStart = position_ / chunkSize_;
│ │ │ │ -
668 // number of chunks to deallocate
│ │ │ │ -
669 size_t chunks = (position_ - list_->start_ + list_->start_ % chunkSize_)
│ │ │ │ -
670 / chunkSize_;
│ │ │ │ -
671 list_->start_ = position_;
│ │ │ │ -
672
│ │ │ │ -
673 // Deallocate memory not needed any more.
│ │ │ │ -
674 for(size_t chunk=0; chunk<chunks; chunk++) {
│ │ │ │ -
675 --posChunkStart;
│ │ │ │ -
676 list_->chunks_[posChunkStart].reset();
│ │ │ │ -
677 }
│ │ │ │ -
678
│ │ │ │ -
679 // Capacity stays the same as the chunks before us
│ │ │ │ -
680 // are still there. They null pointers.
│ │ │ │ -
681 assert(list_->start_+list_->size_<=list_->capacity_);
│ │ │ │ -
682 }
│ │ │ │ -
│ │ │ │ +
562 ++(std::get<0>(iterators_));
│ │ │ │ +
563 ++(std::get<1>(iterators_));
│ │ │ │ +
564 ++(std::get<2>(iterators_));
│ │ │ │ +
565 return *this;
│ │ │ │ +
566 }
│ │ │ │ +
│ │ │ │ +
567
│ │ │ │ +
568 template<typename T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
570 const std::pair<GlobalIndex,Attribute>& global)
│ │ │ │ +
571 {
│ │ │ │ +
572 std::get<0>(iterators_).insert(index);
│ │ │ │ +
573 std::get<1>(iterators_).insert(global);
│ │ │ │ +
574 std::get<2>(iterators_).insert(false);
│ │ │ │ +
575 }
│ │ │ │ +
│ │ │ │ +
576
│ │ │ │ +
577 template<typename T>
│ │ │ │ +
578 inline typename IndicesSyncer<T>::RemoteIndex&
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
580 {
│ │ │ │ +
581 return *(std::get<0>(iterators_));
│ │ │ │ +
582 }
│ │ │ │ +
│ │ │ │ +
583
│ │ │ │ +
584 template<typename T>
│ │ │ │ +
585 inline std::pair<typename IndicesSyncer<T>::GlobalIndex,typename IndicesSyncer<T>::Attribute>&
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
587 {
│ │ │ │ +
588 return *(std::get<1>(iterators_));
│ │ │ │ +
589 }
│ │ │ │ +
│ │ │ │ +
590
│ │ │ │ +
591 template<typename T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
593 {
│ │ │ │ +
594 return *(std::get<2>(iterators_));
│ │ │ │ +
595 }
│ │ │ │ +
│ │ │ │ +
596
│ │ │ │ +
597 template<typename T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
599 GlobalIndexList& globalIndices,
│ │ │ │ +
600 BoolList& booleans)
│ │ │ │ +
601 {
│ │ │ │ +
602 std::get<0>(iterators_) = remoteIndices.beginModify();
│ │ │ │ +
603 std::get<1>(iterators_) = globalIndices.beginModify();
│ │ │ │ +
604 std::get<2>(iterators_) = booleans.beginModify();
│ │ │ │ +
605 }
│ │ │ │ +
│ │ │ │ +
606
│ │ │ │ +
607 template<typename T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
609 {
│ │ │ │ +
610 return std::get<0>(iterators_) != std::get<3>(iterators_);
│ │ │ │ +
611 }
│ │ │ │ +
│ │ │ │ +
612
│ │ │ │ +
613 template<typename T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
615 {
│ │ │ │ +
616 return std::get<0>(iterators_) == std::get<3>(iterators_);
│ │ │ │ +
617 }
│ │ │ │ +
│ │ │ │ +
618
│ │ │ │ +
619 template<typename T>
│ │ │ │ + │ │ │ │ +
621 {
│ │ │ │ +
622 MPI_Datatype type[2] = {MPI_INT, MPI_INT};
│ │ │ │ +
623 int blocklength[2] = {1,1};
│ │ │ │ +
624 MPI_Aint displacement[2];
│ │ │ │ +
625 MPI_Aint base;
│ │ │ │ +
626
│ │ │ │ +
627 // Compute displacement
│ │ │ │ +
628 MessageInformation message;
│ │ │ │ +
629
│ │ │ │ +
630 MPI_Get_address( &(message.publish), displacement);
│ │ │ │ +
631 MPI_Get_address( &(message.pairs), displacement+1);
│ │ │ │ +
632
│ │ │ │ +
633 // Make the displacement relative
│ │ │ │ +
634 MPI_Get_address(&message, &base);
│ │ │ │ +
635 displacement[0] -= base;
│ │ │ │ +
636 displacement[1] -= base;
│ │ │ │ +
637
│ │ │ │ +
638 MPI_Type_create_struct( 2, blocklength, displacement, type, &datatype_);
│ │ │ │ +
639 MPI_Type_commit(&datatype_);
│ │ │ │ +
640 }
│ │ │ │ +
641
│ │ │ │ +
642 template<typename T>
│ │ │ │ +
643 void IndicesSyncer<T>::calculateMessageSizes()
│ │ │ │ +
644 {
│ │ │ │ +
645 auto iEnd = indexSet_.end();
│ │ │ │ +
646 auto collIter = remoteIndices_.template iterator<true>();
│ │ │ │ +
647
│ │ │ │ +
648 for(auto index = indexSet_.begin(); index != iEnd; ++index) {
│ │ │ │ +
649 collIter.advance(index->global(), index->local().attribute());
│ │ │ │ +
650 if(collIter.empty())
│ │ │ │ +
651 break;
│ │ │ │ +
652 int knownRemote=0;
│ │ │ │ +
653 auto end = collIter.end();
│ │ │ │ +
654
│ │ │ │ +
655 // Count the remote indices we know.
│ │ │ │ +
656 for(auto valid = collIter.begin(); valid != end; ++valid) {
│ │ │ │ +
657 ++knownRemote;
│ │ │ │ +
658 }
│ │ │ │ +
659
│ │ │ │ +
660 if(knownRemote>0) {
│ │ │ │ +
661 Dune::dverb<<rank_<<": publishing "<<knownRemote<<" for index "<<index->global()<< " for processes ";
│ │ │ │ +
662
│ │ │ │ +
663 // Update MessageInformation
│ │ │ │ +
664 for(auto valid = collIter.begin(); valid != end; ++valid) {
│ │ │ │ +
665 ++(infoSend_[valid.process()].publish);
│ │ │ │ +
666 (infoSend_[valid.process()].pairs) += knownRemote;
│ │ │ │ +
667 Dune::dverb<<valid.process()<<" ";
│ │ │ │ +
668 Dune::dverb<<"(publish="<<infoSend_[valid.process()].publish<<", pairs="<<infoSend_[valid.process()].pairs
│ │ │ │ +
669 <<") ";
│ │ │ │ +
670 }
│ │ │ │ +
671 Dune::dverb<<std::endl;
│ │ │ │ +
672 }
│ │ │ │ +
673 }
│ │ │ │ +
674
│ │ │ │ +
675 const auto end = infoSend_.end();
│ │ │ │ +
676
│ │ │ │ +
677 // Now determine the buffersizes needed for each neighbour using MPI_Pack_size
│ │ │ │ +
678 MessageInformation dummy;
│ │ │ │ +
679
│ │ │ │ +
680 auto messageIter= infoSend_.begin();
│ │ │ │ +
681 const auto rend = remoteIndices_.end();
│ │ │ │ +
682 int neighbour=0;
│ │ │ │
683
│ │ │ │ -
684 template<class T, int N, class A>
│ │ │ │ - │ │ │ │ -
686 : position_(position), list_(&arrayList)
│ │ │ │ -
687 {}
│ │ │ │ -
688
│ │ │ │ -
689
│ │ │ │ -
690 template<class T, int N, class A>
│ │ │ │ -
691 ConstArrayListIterator<T,N,A>::ConstArrayListIterator(const ArrayList<T,N,A>& arrayList,
│ │ │ │ -
692 size_type position)
│ │ │ │ -
693 : position_(position), list_(&arrayList)
│ │ │ │ -
694 {}
│ │ │ │ +
684 for(auto remote = remoteIndices_.begin(); remote != rend; ++remote, ++neighbour) {
│ │ │ │ +
685 MessageInformation* message;
│ │ │ │ +
686 MessageInformation recv;
│ │ │ │ +
687
│ │ │ │ +
688 if(messageIter != end && messageIter->first==remote->first) {
│ │ │ │ +
689 // We want to send message information to that process
│ │ │ │ +
690 message = const_cast<MessageInformation*>(&(messageIter->second));
│ │ │ │ +
691 ++messageIter;
│ │ │ │ +
692 }else
│ │ │ │ +
693 // We do not want to send information but the other process might.
│ │ │ │ +
694 message = &dummy;
│ │ │ │
695
│ │ │ │ -
696 template<class T, int N, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
698 : position_(other.position_), list_(other.list_)
│ │ │ │ -
699 {}
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
700
│ │ │ │ +
696 sendBufferSizes_[neighbour]=0;
│ │ │ │ +
697 int tsize;
│ │ │ │ +
698 // The number of indices published
│ │ │ │ +
699 MPI_Pack_size(1, MPI_INT,remoteIndices_.communicator(), &tsize);
│ │ │ │ +
700 sendBufferSizes_[neighbour] += tsize;
│ │ │ │
701
│ │ │ │ -
703}
│ │ │ │ -
704#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:491
│ │ │ │ -
iterator begin()
Get an iterator that is positioned at the first element.
Definition arraylist.hh:517
│ │ │ │ -
bool equals(const ArrayListIterator< MemberType, N, A > &other) const
Comares two iterators.
Definition arraylist.hh:573
│ │ │ │ -
void increment()
Increment the iterator.
Definition arraylist.hh:599
│ │ │ │ -
size_type size() const
Get the number of elements in the list.
Definition arraylist.hh:472
│ │ │ │ -
ConstArrayListIterator(const ArrayListIterator< T, N, A > &other)
Definition arraylist.hh:697
│ │ │ │ -
void purge()
Purge the list.
Definition arraylist.hh:541
│ │ │ │ -
void decrement()
decrement the iterator.
Definition arraylist.hh:611
│ │ │ │ -
void eraseToHere()
Erase all entries before the current position and the one at the current position.
Definition arraylist.hh:663
│ │ │ │ -
ArrayList()
Constructs an Array list with one chunk.
Definition arraylist.hh:457
│ │ │ │ -
const_iterator begin() const
Get a random access iterator that is positioned at the first element.
Definition arraylist.hh:523
│ │ │ │ -
void increment()
Increment the iterator.
Definition arraylist.hh:605
│ │ │ │ -
iterator end()
Get a random access iterator positioned after the last element.
Definition arraylist.hh:529
│ │ │ │ -
const_reference elementAt(size_type i) const
Get the value of the list at an arbitrary position.
Definition arraylist.hh:629
│ │ │ │ -
const_reference operator[](size_type i) const
Get the element at specific position.
Definition arraylist.hh:498
│ │ │ │ -
void decrement()
decrement the iterator.
Definition arraylist.hh:617
│ │ │ │ -
void advance(difference_type n)
Definition arraylist.hh:566
│ │ │ │ -
const_iterator end() const
Get a random access iterator positioned after the last element.
Definition arraylist.hh:535
│ │ │ │ -
const_reference dereference() const
Access the element at the current position.
Definition arraylist.hh:641
│ │ │ │ -
void clear()
Delete all entries from the list.
Definition arraylist.hh:464
│ │ │ │ -
reference elementAt(size_type i) const
Get the value of the list at an arbitrary position.
Definition arraylist.hh:623
│ │ │ │ -
bool equals(const ConstArrayListIterator< MemberType, N, A > &other) const
Comares to iterators.
Definition arraylist.hh:591
│ │ │ │ -
void advance(difference_type n)
Definition arraylist.hh:560
│ │ │ │ -
difference_type distanceTo(const ConstArrayListIterator< T, N, A > &other) const
Definition arraylist.hh:655
│ │ │ │ -
reference dereference() const
Access the element at the current position.
Definition arraylist.hh:635
│ │ │ │ -
void push_back(const_reference entry)
Append an entry to the list.
Definition arraylist.hh:478
│ │ │ │ -
difference_type distanceTo(const ArrayListIterator< T, N, A > &other) const
Definition arraylist.hh:647
│ │ │ │ +
702 for(int i=0; i < message->publish; ++i) {
│ │ │ │ +
703 // The global index
│ │ │ │ +
704 MPI_Pack_size(1, MPITraits<GlobalIndex>::getType(), remoteIndices_.communicator(), &tsize);
│ │ │ │ +
705 sendBufferSizes_[neighbour] += tsize;
│ │ │ │ +
706 // The attribute in the local index
│ │ │ │ +
707 MPI_Pack_size(1, MPI_CHAR, remoteIndices_.communicator(), &tsize);
│ │ │ │ +
708 sendBufferSizes_[neighbour] += tsize;
│ │ │ │ +
709 // The number of corresponding remote indices
│ │ │ │ +
710 MPI_Pack_size(1, MPI_INT, remoteIndices_.communicator(), &tsize);
│ │ │ │ +
711 sendBufferSizes_[neighbour] += tsize;
│ │ │ │ +
712 }
│ │ │ │ +
713 for(int i=0; i < message->pairs; ++i) {
│ │ │ │ +
714 // The process of the remote index
│ │ │ │ +
715 MPI_Pack_size(1, MPI_INT, remoteIndices_.communicator(), &tsize);
│ │ │ │ +
716 sendBufferSizes_[neighbour] += tsize;
│ │ │ │ +
717 // The attribute of the remote index
│ │ │ │ +
718 MPI_Pack_size(1, MPI_CHAR, remoteIndices_.communicator(), &tsize);
│ │ │ │ +
719 sendBufferSizes_[neighbour] += tsize;
│ │ │ │ +
720 }
│ │ │ │ +
721
│ │ │ │ +
722 Dune::dverb<<rank_<<": Buffer (neighbour="<<remote->first<<") size is "<< sendBufferSizes_[neighbour]<<" for publish="<<message->publish<<" pairs="<<message->pairs<<std::endl;
│ │ │ │ +
723 }
│ │ │ │ +
724
│ │ │ │ +
725 }
│ │ │ │ +
726
│ │ │ │ +
727 template<typename T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
729 {
│ │ │ │ +
730 DefaultNumberer numberer;
│ │ │ │ +
731 sync(numberer);
│ │ │ │ +
732 }
│ │ │ │ +
│ │ │ │ +
733
│ │ │ │ +
734 template<typename T>
│ │ │ │ +
735 template<typename T1>
│ │ │ │ +
│ │ │ │ +
736 void IndicesSyncer<T>::sync(T1& numberer)
│ │ │ │ +
737 {
│ │ │ │ +
738 // The pointers to the local indices in the remote indices
│ │ │ │ +
739 // will become invalid due to the resorting of the index set.
│ │ │ │ +
740 // Therefore store the corresponding global indices.
│ │ │ │ +
741 // Mark all indices as not added
│ │ │ │ +
742 const auto end = remoteIndices_.end();
│ │ │ │ +
743
│ │ │ │ +
744 // Number of neighbours might change during the syncing.
│ │ │ │ +
745 // save the old neighbours
│ │ │ │ +
746 std::size_t noOldNeighbours = remoteIndices_.neighbours();
│ │ │ │ +
747 int* oldNeighbours = new int[noOldNeighbours];
│ │ │ │ +
748 sendBufferSizes_ = new std::size_t[noOldNeighbours];
│ │ │ │ +
749 std::size_t neighbourI = 0;
│ │ │ │ +
750
│ │ │ │ +
751 for(auto remote = remoteIndices_.begin(); remote != end; ++remote, ++neighbourI) {
│ │ │ │ +
752 oldNeighbours[neighbourI] = remote->first;
│ │ │ │ +
753
│ │ │ │ +
754 // Make sure we only have one remote index list.
│ │ │ │ +
755 assert(remote->second.first==remote->second.second);
│ │ │ │ +
756
│ │ │ │ +
757 RemoteIndexList& rList = *(remote->second.first);
│ │ │ │ +
758
│ │ │ │ +
759 // Store the corresponding global indices.
│ │ │ │ +
760 GlobalIndexList& global = globalMap_[remote->first];
│ │ │ │ +
761 BoolList& added = oldMap_[remote->first];
│ │ │ │ +
762 auto riEnd = rList.end();
│ │ │ │ +
763
│ │ │ │ +
764 for(auto index = rList.begin();
│ │ │ │ +
765 index != riEnd; ++index) {
│ │ │ │ +
766 global.push_back(std::make_pair(index->localIndexPair().global(),
│ │ │ │ +
767 index->localIndexPair().local().attribute()));
│ │ │ │ +
768 added.push_back(true);
│ │ │ │ +
769 }
│ │ │ │ +
770
│ │ │ │ +
771 Iterators iterators(rList, global, added);
│ │ │ │ +
772 iteratorsMap_.insert(std::make_pair(remote->first, iterators));
│ │ │ │ +
773 assert(checkReset(iteratorsMap_[remote->first], rList,global,added));
│ │ │ │ +
774 }
│ │ │ │ +
775
│ │ │ │ +
776 // Exchange indices with each neighbour
│ │ │ │ +
777 calculateMessageSizes();
│ │ │ │ +
778
│ │ │ │ +
779 // Allocate the buffers
│ │ │ │ +
780 receiveBufferSize_=1;
│ │ │ │ +
781 sendBuffers_ = new char*[noOldNeighbours];
│ │ │ │ +
782
│ │ │ │ +
783 for(std::size_t i=0; i<noOldNeighbours; ++i) {
│ │ │ │ +
784 sendBuffers_[i] = new char[sendBufferSizes_[i]];
│ │ │ │ +
785 receiveBufferSize_ = std::max(receiveBufferSize_, static_cast<int>(sendBufferSizes_[i]));
│ │ │ │ +
786 }
│ │ │ │ +
787
│ │ │ │ +
788 receiveBuffer_=new char[receiveBufferSize_];
│ │ │ │ +
789
│ │ │ │ +
790 indexSet_.beginResize();
│ │ │ │ +
791
│ │ │ │ +
792 Dune::dverb<<rank_<<": Neighbours: ";
│ │ │ │ +
793
│ │ │ │ +
794 for(std::size_t i = 0; i<noOldNeighbours; ++i)
│ │ │ │ +
795 Dune::dverb<<oldNeighbours[i]<<" ";
│ │ │ │ +
796
│ │ │ │ +
797 Dune::dverb<<std::endl;
│ │ │ │ +
798
│ │ │ │ +
799 MPI_Request* requests = new MPI_Request[noOldNeighbours];
│ │ │ │ +
800 MPI_Status* statuses = new MPI_Status[noOldNeighbours];
│ │ │ │ +
801
│ │ │ │ +
802 // Pack Message data and start the sends
│ │ │ │ +
803 for(std::size_t i = 0; i<noOldNeighbours; ++i)
│ │ │ │ +
804 packAndSend(oldNeighbours[i], sendBuffers_[i], sendBufferSizes_[i], requests[i]);
│ │ │ │ +
805
│ │ │ │ +
806 // Probe for incoming messages, receive and unpack them
│ │ │ │ +
807 for(std::size_t i = 0; i<noOldNeighbours; ++i)
│ │ │ │ +
808 recvAndUnpack(numberer);
│ │ │ │ +
809 // }else{
│ │ │ │ +
810 // recvAndUnpack(oldNeighbours[i], numberer);
│ │ │ │ +
811 // packAndSend(oldNeighbours[i]);
│ │ │ │ +
812 // }
│ │ │ │ +
813 // }
│ │ │ │ +
814
│ │ │ │ +
815 delete[] receiveBuffer_;
│ │ │ │ +
816
│ │ │ │ +
817 // Wait for the completion of the sends
│ │ │ │ +
818 // Wait for completion of sends
│ │ │ │ +
819 if(MPI_SUCCESS!=MPI_Waitall(noOldNeighbours, requests, statuses)) {
│ │ │ │ +
820 std::cerr<<": MPI_Error occurred while sending message"<<std::endl;
│ │ │ │ +
821 for(std::size_t i=0; i< noOldNeighbours; i++)
│ │ │ │ +
822 if(MPI_SUCCESS!=statuses[i].MPI_ERROR)
│ │ │ │ +
823 std::cerr<<"Destination "<<statuses[i].MPI_SOURCE<<" error code: "<<statuses[i].MPI_ERROR<<std::endl;
│ │ │ │ +
824 }
│ │ │ │ +
825
│ │ │ │ +
826 delete[] statuses;
│ │ │ │ +
827 delete[] requests;
│ │ │ │ +
828
│ │ │ │ +
829 for(std::size_t i=0; i<noOldNeighbours; ++i)
│ │ │ │ +
830 delete[] sendBuffers_[i];
│ │ │ │ +
831
│ │ │ │ +
832 delete[] sendBuffers_;
│ │ │ │ +
833 delete[] sendBufferSizes_;
│ │ │ │ +
834
│ │ │ │ +
835 // No need for the iterator tuples any more
│ │ │ │ +
836 iteratorsMap_.clear();
│ │ │ │ +
837
│ │ │ │ +
838 indexSet_.endResize();
│ │ │ │ +
839
│ │ │ │ +
840 delete[] oldNeighbours;
│ │ │ │ +
841
│ │ │ │ +
842 repairLocalIndexPointers(globalMap_, remoteIndices_, indexSet_);
│ │ │ │ +
843
│ │ │ │ +
844 oldMap_.clear();
│ │ │ │ +
845 globalMap_.clear();
│ │ │ │ +
846
│ │ │ │ +
847 // update the sequence number
│ │ │ │ +
848 remoteIndices_.sourceSeqNo_ = remoteIndices_.destSeqNo_ = indexSet_.seqNo();
│ │ │ │ +
849 }
│ │ │ │ +
│ │ │ │ +
850
│ │ │ │ +
851 template<typename T>
│ │ │ │ +
852 void IndicesSyncer<T>::packAndSend(int destination, char* buffer, std::size_t bufferSize, MPI_Request& request)
│ │ │ │ +
853 {
│ │ │ │ +
854 auto iEnd = indexSet_.end();
│ │ │ │ +
855 int bpos = 0;
│ │ │ │ +
856 int published = 0;
│ │ │ │ +
857 int pairs = 0;
│ │ │ │ +
858
│ │ │ │ +
859 assert(checkReset());
│ │ │ │ +
860
│ │ │ │ +
861 // Pack the number of indices we publish
│ │ │ │ +
862 MPI_Pack(&(infoSend_[destination].publish), 1, MPI_INT, buffer, bufferSize, &bpos,
│ │ │ │ +
863 remoteIndices_.communicator());
│ │ │ │ +
864
│ │ │ │ +
865 for(auto index = indexSet_.begin(); index != iEnd; ++index) {
│ │ │ │ +
866 // Search for corresponding remote indices in all iterator tuples
│ │ │ │ +
867 auto iteratorsEnd = iteratorsMap_.end();
│ │ │ │ +
868
│ │ │ │ +
869 // advance all iterators to a position with global index >= index->global()
│ │ │ │ +
870 for(auto iterators = iteratorsMap_.begin(); iteratorsEnd != iterators; ++iterators) {
│ │ │ │ +
871 while(iterators->second.isNotAtEnd() &&
│ │ │ │ +
872 iterators->second.globalIndexPair().first < index->global())
│ │ │ │ +
873 ++(iterators->second);
│ │ │ │ +
874 assert(!iterators->second.isNotAtEnd() || iterators->second.globalIndexPair().first >= index->global());
│ │ │ │ +
875 }
│ │ │ │ +
876
│ │ │ │ +
877 // Add all remote indices positioned at global which were already present before calling sync
│ │ │ │ +
878 // to the message.
│ │ │ │ +
879 // Count how many remote indices we will send
│ │ │ │ +
880 int indices = 0;
│ │ │ │ +
881 bool knownRemote = false; // Is the remote process supposed to know this index?
│ │ │ │ +
882
│ │ │ │ +
883 for(auto iterators = iteratorsMap_.begin(); iteratorsEnd != iterators; ++iterators)
│ │ │ │ +
884 {
│ │ │ │ +
885 std::pair<GlobalIndex,Attribute> p;
│ │ │ │ +
886 if (iterators->second.isNotAtEnd())
│ │ │ │ +
887 {
│ │ │ │ +
888 p = iterators->second.globalIndexPair();
│ │ │ │ +
889 }
│ │ │ │ +
890
│ │ │ │ +
891 if(iterators->second.isNotAtEnd() && iterators->second.isOld()
│ │ │ │ +
892 && iterators->second.globalIndexPair().first == index->global()) {
│ │ │ │ +
893 indices++;
│ │ │ │ +
894 if(destination == iterators->first)
│ │ │ │ +
895 knownRemote = true;
│ │ │ │ +
896 }
│ │ │ │ +
897 }
│ │ │ │ +
898
│ │ │ │ +
899 if(!knownRemote)
│ │ │ │ +
900 // We do not need to send any indices
│ │ │ │ +
901 continue;
│ │ │ │ +
902
│ │ │ │ +
903 Dune::dverb<<rank_<<": sending "<<indices<<" for index "<<index->global()<<" to "<<destination<<std::endl;
│ │ │ │ +
904
│ │ │ │ +
905
│ │ │ │ +
906 // Pack the global index, the attribute and the number
│ │ │ │ +
907 MPI_Pack(const_cast<GlobalIndex*>(&(index->global())), 1, MPITraits<GlobalIndex>::getType(), buffer, bufferSize, &bpos,
│ │ │ │ +
908 remoteIndices_.communicator());
│ │ │ │ +
909
│ │ │ │ +
910 char attr = index->local().attribute();
│ │ │ │ +
911 MPI_Pack(&attr, 1, MPI_CHAR, buffer, bufferSize, &bpos,
│ │ │ │ +
912 remoteIndices_.communicator());
│ │ │ │ +
913
│ │ │ │ +
914 // Pack the number of remote indices we send.
│ │ │ │ +
915 MPI_Pack(&indices, 1, MPI_INT, buffer, bufferSize, &bpos,
│ │ │ │ +
916 remoteIndices_.communicator());
│ │ │ │ +
917
│ │ │ │ +
918 // Pack the information about the remote indices
│ │ │ │ +
919 for(auto iterators = iteratorsMap_.begin(); iteratorsEnd != iterators; ++iterators)
│ │ │ │ +
920 if(iterators->second.isNotAtEnd() && iterators->second.isOld()
│ │ │ │ +
921 && iterators->second.globalIndexPair().first == index->global()) {
│ │ │ │ +
922 int process = iterators->first;
│ │ │ │ +
923
│ │ │ │ +
924 ++pairs;
│ │ │ │ +
925 assert(pairs <= infoSend_[destination].pairs);
│ │ │ │ +
926 MPI_Pack(&process, 1, MPI_INT, buffer, bufferSize, &bpos,
│ │ │ │ +
927 remoteIndices_.communicator());
│ │ │ │ +
928 char attr2 = iterators->second.remoteIndex().attribute();
│ │ │ │ +
929
│ │ │ │ +
930 MPI_Pack(&attr2, 1, MPI_CHAR, buffer, bufferSize, &bpos,
│ │ │ │ +
931 remoteIndices_.communicator());
│ │ │ │ +
932 --indices;
│ │ │ │ +
933 }
│ │ │ │ +
934 assert(indices==0);
│ │ │ │ +
935 ++published;
│ │ │ │ +
936 Dune::dvverb<<" (publish="<<published<<", pairs="<<pairs<<")"<<std::endl;
│ │ │ │ +
937 assert(published <= infoSend_[destination].publish);
│ │ │ │ +
938 }
│ │ │ │ +
939
│ │ │ │ +
940 // Make sure we send all expected entries
│ │ │ │ +
941 assert(published == infoSend_[destination].publish);
│ │ │ │ +
942 assert(pairs == infoSend_[destination].pairs);
│ │ │ │ +
943 resetIteratorsMap();
│ │ │ │ +
944
│ │ │ │ +
945 Dune::dverb << rank_<<": Sending message of "<<bpos<<" bytes to "<<destination<<std::endl;
│ │ │ │ +
946
│ │ │ │ +
947 MPI_Issend(buffer, bpos, MPI_PACKED, destination, 345, remoteIndices_.communicator(),&request);
│ │ │ │ +
948 }
│ │ │ │ +
949
│ │ │ │ +
950 template<typename T>
│ │ │ │ +
951 inline void IndicesSyncer<T>::insertIntoRemoteIndexList(int process,
│ │ │ │ +
952 const std::pair<GlobalIndex,Attribute>& globalPair,
│ │ │ │ +
953 char attribute)
│ │ │ │ +
954 {
│ │ │ │ +
955 Dune::dverb<<"Inserting from "<<process<<" "<<globalPair.first<<", "<<
│ │ │ │ +
956 globalPair.second<<" "<<attribute<<std::endl;
│ │ │ │ +
957
│ │ │ │ +
958 resetIteratorsMap();
│ │ │ │ +
959
│ │ │ │ +
960 // There might be cases where there no remote indices for that process yet
│ │ │ │ +
961 typename IteratorsMap::iterator found = iteratorsMap_.find(process);
│ │ │ │ +
962
│ │ │ │ +
963 if( found == iteratorsMap_.end() ) {
│ │ │ │ +
964 Dune::dverb<<"Discovered new neighbour "<<process<<std::endl;
│ │ │ │ +
965 RemoteIndexList* rlist = new RemoteIndexList();
│ │ │ │ +
966 remoteIndices_.remoteIndices_.insert(std::make_pair(process,std::make_pair(rlist,rlist)));
│ │ │ │ +
967 Iterators iterators = Iterators(*rlist, globalMap_[process], oldMap_[process]);
│ │ │ │ +
968 found = iteratorsMap_.insert(std::make_pair(process, iterators)).first;
│ │ │ │ +
969 }
│ │ │ │ +
970
│ │ │ │ +
971 Iterators& iterators = found->second;
│ │ │ │ +
972
│ │ │ │ +
973 // Search for the remote index
│ │ │ │ +
974 while(iterators.isNotAtEnd() && iterators.globalIndexPair() < globalPair) {
│ │ │ │ +
975 // Increment all iterators
│ │ │ │ +
976 ++iterators;
│ │ │ │ +
977
│ │ │ │ +
978 }
│ │ │ │ +
979
│ │ │ │ +
980 if(iterators.isAtEnd() || iterators.globalIndexPair() != globalPair) {
│ │ │ │ +
981 // The entry is not yet known
│ │ │ │ +
982 // Insert in the list and do not change the first iterator.
│ │ │ │ +
983 iterators.insert(RemoteIndex(Attribute(attribute)),globalPair);
│ │ │ │ +
984 return;
│ │ │ │ +
985 }
│ │ │ │ +
986
│ │ │ │ +
987 // Global indices match
│ │ │ │ +
988 bool indexIsThere=false;
│ │ │ │ +
989 for(Iterators tmpIterators = iterators;
│ │ │ │ +
990 !tmpIterators.isAtEnd() && tmpIterators.globalIndexPair() == globalPair;
│ │ │ │ +
991 ++tmpIterators)
│ │ │ │ +
992 //entry already exists with the same attribute
│ │ │ │ +
993 if(tmpIterators.globalIndexPair().second == attribute) {
│ │ │ │ +
994 indexIsThere=true;
│ │ │ │ +
995 break;
│ │ │ │ +
996 }
│ │ │ │ +
997
│ │ │ │ +
998 if(!indexIsThere)
│ │ │ │ +
999 // The entry is not yet known
│ │ │ │ +
1000 // Insert in the list and do not change the first iterator.
│ │ │ │ +
1001 iterators.insert(RemoteIndex(Attribute(attribute)),globalPair);
│ │ │ │ +
1002 }
│ │ │ │ +
1003
│ │ │ │ +
1004 template<typename T>
│ │ │ │ +
1005 template<typename T1>
│ │ │ │ +
1006 void IndicesSyncer<T>::recvAndUnpack(T1& numberer)
│ │ │ │ +
1007 {
│ │ │ │ +
1008 const ParallelIndexSet& constIndexSet = indexSet_;
│ │ │ │ +
1009 auto iEnd = constIndexSet.end();
│ │ │ │ +
1010 auto index = constIndexSet.begin();
│ │ │ │ +
1011 int bpos = 0;
│ │ │ │ +
1012 int publish;
│ │ │ │ +
1013
│ │ │ │ +
1014 assert(checkReset());
│ │ │ │ +
1015
│ │ │ │ +
1016 MPI_Status status;
│ │ │ │ +
1017
│ │ │ │ +
1018 // We have to determine the message size and source before the receive
│ │ │ │ +
1019 MPI_Probe(MPI_ANY_SOURCE, 345, remoteIndices_.communicator(), &status);
│ │ │ │ +
1020
│ │ │ │ +
1021 int source=status.MPI_SOURCE;
│ │ │ │ +
1022 int count;
│ │ │ │ +
1023 MPI_Get_count(&status, MPI_PACKED, &count);
│ │ │ │ +
1024
│ │ │ │ +
1025 Dune::dvverb<<rank_<<": Receiving message from "<< source<<" with "<<count<<" bytes"<<std::endl;
│ │ │ │ +
1026
│ │ │ │ +
1027 if(count>receiveBufferSize_) {
│ │ │ │ +
1028 receiveBufferSize_=count;
│ │ │ │ +
1029 delete[] receiveBuffer_;
│ │ │ │ +
1030 receiveBuffer_ = new char[receiveBufferSize_];
│ │ │ │ +
1031 }
│ │ │ │ +
1032
│ │ │ │ +
1033 MPI_Recv(receiveBuffer_, count, MPI_PACKED, source, 345, remoteIndices_.communicator(), &status);
│ │ │ │ +
1034
│ │ │ │ +
1035 // How many global entries were published?
│ │ │ │ +
1036 MPI_Unpack(receiveBuffer_, count, &bpos, &publish, 1, MPI_INT, remoteIndices_.communicator());
│ │ │ │ +
1037
│ │ │ │ +
1038 // Now unpack the remote indices and add them.
│ │ │ │ +
1039 while(publish>0) {
│ │ │ │ +
1040
│ │ │ │ +
1041 // Unpack information about the local index on the source process
│ │ │ │ +
1042 GlobalIndex global; // global index of the current entry
│ │ │ │ +
1043 char sourceAttribute; // Attribute on the source process
│ │ │ │ +
1044 int pairs;
│ │ │ │ +
1045
│ │ │ │ +
1046 MPI_Unpack(receiveBuffer_, count, &bpos, &global, 1, MPITraits<GlobalIndex>::getType(),
│ │ │ │ +
1047 remoteIndices_.communicator());
│ │ │ │ +
1048 MPI_Unpack(receiveBuffer_, count, &bpos, &sourceAttribute, 1, MPI_CHAR,
│ │ │ │ +
1049 remoteIndices_.communicator());
│ │ │ │ +
1050 MPI_Unpack(receiveBuffer_, count, &bpos, &pairs, 1, MPI_INT,
│ │ │ │ +
1051 remoteIndices_.communicator());
│ │ │ │ +
1052
│ │ │ │ +
1053 // Insert the entry on the remote process to our
│ │ │ │ +
1054 // remote index list
│ │ │ │ +
1055 SLList<std::pair<int,Attribute> > sourceAttributeList;
│ │ │ │ +
1056 sourceAttributeList.push_back(std::make_pair(source,Attribute(sourceAttribute)));
│ │ │ │ +
1057#ifndef NDEBUG
│ │ │ │ +
1058 bool foundSelf = false;
│ │ │ │ +
1059#endif
│ │ │ │ +
1060 Attribute myAttribute=Attribute();
│ │ │ │ +
1061
│ │ │ │ +
1062 // Unpack the remote indices
│ │ │ │ +
1063 for(; pairs>0; --pairs) {
│ │ │ │ +
1064 // Unpack the process id that knows the index
│ │ │ │ +
1065 int process;
│ │ │ │ +
1066 char attribute;
│ │ │ │ +
1067 MPI_Unpack(receiveBuffer_, count, &bpos, &process, 1, MPI_INT,
│ │ │ │ +
1068 remoteIndices_.communicator());
│ │ │ │ +
1069 // Unpack the attribute
│ │ │ │ +
1070 MPI_Unpack(receiveBuffer_, count, &bpos, &attribute, 1, MPI_CHAR,
│ │ │ │ +
1071 remoteIndices_.communicator());
│ │ │ │ +
1072
│ │ │ │ +
1073 if(process==rank_) {
│ │ │ │ +
1074#ifndef NDEBUG
│ │ │ │ +
1075 foundSelf=true;
│ │ │ │ +
1076#endif
│ │ │ │ +
1077 myAttribute=Attribute(attribute);
│ │ │ │ +
1078 // Now we know the local attribute of the global index
│ │ │ │ +
1079 //Only add the index if it is unknown.
│ │ │ │ +
1080 // Do we know that global index already?
│ │ │ │ +
1081 auto pos = std::lower_bound(index, iEnd, IndexPair(global));
│ │ │ │ +
1082
│ │ │ │ +
1083 if(pos == iEnd || pos->global() != global) {
│ │ │ │ +
1084 // no entry with this global index
│ │ │ │ +
1085 indexSet_.add(global,
│ │ │ │ +
1086 ParallelLocalIndex<Attribute>(numberer(global),
│ │ │ │ +
1087 myAttribute, true));
│ │ │ │ +
1088 Dune::dvverb << "Adding "<<global<<" "<<myAttribute<<std::endl;
│ │ │ │ +
1089 continue;
│ │ │ │ +
1090 }
│ │ │ │ +
1091
│ │ │ │ +
1092 // because of above the global indices match. Add only if the attribute is different
│ │ │ │ +
1093 bool indexIsThere = false;
│ │ │ │ +
1094 index=pos;
│ │ │ │ +
1095
│ │ │ │ +
1096 for(; pos->global()==global; ++pos)
│ │ │ │ +
1097 if(pos->local().attribute() == myAttribute) {
│ │ │ │ +
1098 Dune::dvverb<<"found "<<global<<" "<<myAttribute<<std::endl;
│ │ │ │ +
1099 indexIsThere = true;
│ │ │ │ +
1100 break;
│ │ │ │ +
1101 }
│ │ │ │ +
1102
│ │ │ │ +
1103 if(!indexIsThere) {
│ │ │ │ +
1104 indexSet_.add(global,
│ │ │ │ +
1105 ParallelLocalIndex<Attribute>(numberer(global),
│ │ │ │ +
1106 myAttribute, true));
│ │ │ │ +
1107 Dune::dvverb << "Adding "<<global<<" "<<myAttribute<<std::endl;
│ │ │ │ +
1108 }
│ │ │ │ +
1109
│ │ │ │ +
1110 }else{
│ │ │ │ +
1111 sourceAttributeList.push_back(std::make_pair(process,Attribute(attribute)));
│ │ │ │ +
1112 }
│ │ │ │ +
1113 }
│ │ │ │ +
1114 assert(foundSelf);
│ │ │ │ +
1115 // Insert remote indices
│ │ │ │ +
1116 typedef typename SLList<std::pair<int,Attribute> >::const_iterator Iter;
│ │ │ │ +
1117 for(Iter i=sourceAttributeList.begin(), end=sourceAttributeList.end();
│ │ │ │ +
1118 i!=end; ++i)
│ │ │ │ +
1119 insertIntoRemoteIndexList(i->first, std::make_pair(global, myAttribute),
│ │ │ │ +
1120 i->second);
│ │ │ │ +
1121 --publish;
│ │ │ │ +
1122 }
│ │ │ │ +
1123
│ │ │ │ +
1124 resetIteratorsMap();
│ │ │ │ +
1125 }
│ │ │ │ +
1126
│ │ │ │ +
1127 template<typename T>
│ │ │ │ +
1128 void IndicesSyncer<T>::resetIteratorsMap(){
│ │ │ │ +
1129
│ │ │ │ +
1130 // Reset iterators in all tuples.
│ │ │ │ +
1131 const auto remoteEnd = remoteIndices_.remoteIndices_.end();
│ │ │ │ +
1132 auto iterators = iteratorsMap_.begin();
│ │ │ │ +
1133 auto global = globalMap_.begin();
│ │ │ │ +
1134 auto added = oldMap_.begin();
│ │ │ │ +
1135
│ │ │ │ +
1136 for(auto remote = remoteIndices_.remoteIndices_.begin();
│ │ │ │ +
1137 remote != remoteEnd; ++remote, ++global, ++added, ++iterators) {
│ │ │ │ +
1138 iterators->second.reset(*(remote->second.first), global->second, added->second);
│ │ │ │ +
1139 }
│ │ │ │ +
1140 }
│ │ │ │ +
1141
│ │ │ │ +
1142 template<typename T>
│ │ │ │ +
1143 bool IndicesSyncer<T>::checkReset(const Iterators& iterators, RemoteIndexList& rList, GlobalIndexList& gList,
│ │ │ │ +
1144 BoolList& bList){
│ │ │ │ +
1145
│ │ │ │ +
1146 if(std::get<0>(iterators.iterators_) != rList.begin())
│ │ │ │ +
1147 return false;
│ │ │ │ +
1148 if(std::get<1>(iterators.iterators_) != gList.begin())
│ │ │ │ +
1149 return false;
│ │ │ │ +
1150 if(std::get<2>(iterators.iterators_) != bList.begin())
│ │ │ │ +
1151 return false;
│ │ │ │ +
1152 return true;
│ │ │ │ +
1153 }
│ │ │ │ +
1154
│ │ │ │ +
1155
│ │ │ │ +
1156 template<typename T>
│ │ │ │ +
1157 bool IndicesSyncer<T>::checkReset(){
│ │ │ │ +
1158
│ │ │ │ +
1159 // Reset iterators in all tuples.
│ │ │ │ +
1160 const auto remoteEnd = remoteIndices_.remoteIndices_.end();
│ │ │ │ +
1161 auto iterators = iteratorsMap_.begin();
│ │ │ │ +
1162 auto global = globalMap_.begin();
│ │ │ │ +
1163 auto added = oldMap_.begin();
│ │ │ │ +
1164 bool ret = true;
│ │ │ │ +
1165
│ │ │ │ +
1166 for(auto remote = remoteIndices_.remoteIndices_.begin();
│ │ │ │ +
1167 remote != remoteEnd; ++remote, ++global, ++added, ++iterators) {
│ │ │ │ +
1168 if(!checkReset(iterators->second, *(remote->second.first), global->second,
│ │ │ │ +
1169 added->second))
│ │ │ │ +
1170 ret=false;
│ │ │ │ +
1171 }
│ │ │ │ +
1172 return ret;
│ │ │ │ +
1173 }
│ │ │ │ +
1174}
│ │ │ │ +
1175
│ │ │ │ +
1176#endif
│ │ │ │ +
1177#endif
│ │ │ │ +
Provides a map between global and local indices.
│ │ │ │ +
Classes describing a distributed indexset.
│ │ │ │ +
Implements a singly linked list together with the necessary iterators.
│ │ │ │ +
Standard Dune debug streams.
│ │ │ │ +
void push_back(const MemberType &item)
Add a new entry to the end of the list.
Definition sllist.hh:643
│ │ │ │ +
SLListIterator< T, A > iterator
The mutable iterator of the list.
Definition sllist.hh:69
│ │ │ │ +
iterator end()
Get an iterator pointing to the end of the list.
Definition sllist.hh:774
│ │ │ │ +
ModifyIterator beginModify()
Get an iterator capable of deleting and inserting elements.
Definition sllist.hh:787
│ │ │ │ +
SLListConstIterator< RemoteIndex, Allocator > const_iterator
The constant iterator of the list.
Definition sllist.hh:74
│ │ │ │ +
SLListModifyIterator< T, A > ModifyIterator
The type of the iterator capable of deletion and insertion.
Definition sllist.hh:103
│ │ │ │ +
iterator begin()
Get an iterator pointing to the first element in the list.
Definition sllist.hh:762
│ │ │ │ +
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:637
│ │ │ │ +
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:237
│ │ │ │ +
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:259
│ │ │ │ +
Iterators()
Default constructor.
Definition indicessyncer.hh:555
│ │ │ │ +
Dune::RemoteIndices< ParallelIndexSet > RemoteIndices
Type of the remote indices.
Definition indicessyncer.hh:59
│ │ │ │ +
bool isOld() const
Was this entry already in the remote index list before the sync process?
Definition indicessyncer.hh:592
│ │ │ │ +
int publish
The number of indices we publish for the other process.
Definition indicessyncer.hh:126
│ │ │ │ +
void repairLocalIndexPointers(std::map< int, SLList< std::pair< typename T::GlobalIndex, typename T::LocalIndex::Attribute >, A > > &globalMap, RemoteIndices< T, A1 > &remoteIndices, const T &indexSet)
Repair the pointers to the local indices in the remote indices.
Definition indicessyncer.hh:487
│ │ │ │ +
bool isAtEnd() const
Are we at the end of the list?
Definition indicessyncer.hh:614
│ │ │ │ +
ParallelIndexSet::GlobalIndex GlobalIndex
Type of the global index used in the index set.
Definition indicessyncer.hh:51
│ │ │ │ +
int pairs
The number of pairs (attribute and process number) we publish to the neighbour process.
Definition indicessyncer.hh:131
│ │ │ │ +
Attribute & attribute() const
│ │ │ │ +
Iterators & operator++()
Increment all iteraors.
Definition indicessyncer.hh:560
│ │ │ │ +
ParallelIndexSet::LocalIndex::Attribute Attribute
Type of the attribute used in the index set.
Definition indicessyncer.hh:54
│ │ │ │ +
std::pair< GlobalIndex, Attribute > & globalIndexPair() const
Get the global index of the remote index at current position.
Definition indicessyncer.hh:586
│ │ │ │ +
IndicesSyncer(ParallelIndexSet &indexSet, RemoteIndices &remoteIndices)
Constructor.
Definition indicessyncer.hh:536
│ │ │ │ +
void reset(RemoteIndexList &remoteIndices, GlobalIndexList &globalIndices, BoolList &booleans)
Reset all the underlying iterators.
Definition indicessyncer.hh:598
│ │ │ │ +
std::size_t operator()(const GlobalIndex &global)
Provide the local index, always std::numeric_limits<size_t>::max()
Definition indicessyncer.hh:145
│ │ │ │ +
T ParallelIndexSet
The type of the index set.
Definition indicessyncer.hh:45
│ │ │ │ +
bool isNotAtEnd() const
Are we not at the end of the list?
Definition indicessyncer.hh:608
│ │ │ │ +
TG GlobalIndex
the type of the global index. This type has to provide at least a operator< for sorting.
Definition indexset.hh:226
│ │ │ │ +
void storeGlobalIndicesOfRemoteIndices(std::map< int, SLList< std::pair< typename T::GlobalIndex, typename T::LocalIndex::Attribute >, A > > &globalMap, const RemoteIndices< T, A1 > &remoteIndices)
Stores the corresponding global indices of the remote index information.
Definition indicessyncer.hh:461
│ │ │ │ +
void sync()
Sync the index set.
Definition indicessyncer.hh:728
│ │ │ │ +
int seqNo() const
Get the internal sequence number.
│ │ │ │ +
ParallelIndexSet::IndexPair IndexPair
The type of the index pair.
Definition indicessyncer.hh:48
│ │ │ │ +
RemoteIndex & remoteIndex() const
Get the remote index at current position.
Definition indicessyncer.hh:579
│ │ │ │ +
MessageInformation()
Definition indicessyncer.hh:122
│ │ │ │ +
void insert(const RemoteIndex &index, const std::pair< GlobalIndex, Attribute > &global)
Insert a new remote index to the underlying remote index list.
Definition indicessyncer.hh:569
│ │ │ │ +
DVVerbType dvverb(std::cout)
stream for very verbose output.
Definition stdstreams.hh:95
│ │ │ │ +
DVerbType dverb(std::cout)
Singleton of verbose debug stream.
Definition stdstreams.hh:116
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
A random access iterator for the Dune::ArrayList class.
Definition arraylist.hh:255
│ │ │ │ -
size_type position()
Definition arraylist.hh:331
│ │ │ │ -
A::value_type MemberType
The member type.
Definition arraylist.hh:263
│ │ │ │ -
ArrayListIterator()
Standard constructor.
Definition arraylist.hh:340
│ │ │ │ -
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:370
│ │ │ │ -
static constexpr int chunkSize_
The number of elements in one chunk of the list.
Definition arraylist.hh:394
│ │ │ │ -
typename A::value_type & reference
Definition arraylist.hh:385
│ │ │ │ -
ConstArrayListIterator()
Definition arraylist.hh:431
│ │ │ │ -
A::value_type MemberType
The member type.
Definition arraylist.hh:379
│ │ │ │ -
A::difference_type difference_type
Definition arraylist.hh:381
│ │ │ │ -
typename A::value_type const & const_reference
Definition arraylist.hh:387
│ │ │ │ -
A::size_type size_type
Definition arraylist.hh:383
│ │ │ │ -
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:434
│ │ │ │ +
static MPI_Datatype getType()
Definition mpitraits.hh:48
│ │ │ │ +
A pair consisting of a global and local index.
Definition indexset.hh:85
│ │ │ │ +
Class for recomputing missing indices of a distributed index set.
Definition indicessyncer.hh:41
│ │ │ │ +
An index present on the local process with an additional attribute flag.
Definition plocalindex.hh:49
│ │ │ │ +
The indices present on remote processes.
Definition remoteindices.hh:189
│ │ │ │ +
MPI_Comm communicator() const
Get the mpi communicator used.
Definition remoteindices.hh:1696
│ │ │ │ +
const_iterator end() const
Get an iterator over all remote index lists.
Definition remoteindices.hh:1529
│ │ │ │ +
int neighbours() const
Get the number of processors we share indices with.
Definition remoteindices.hh:1446
│ │ │ │ +
typename std::allocator_traits< A >::template rebind_alloc< RemoteIndex > Allocator
The type of the allocator for the remote index list.
Definition remoteindices.hh:237
│ │ │ │ +
const_iterator begin() const
Get an iterator over all remote index lists.
Definition remoteindices.hh:1522
│ │ │ │ +
Information about an index residing on another processor.
Definition remoteindices.hh:73
│ │ │ │ +
A mutable iterator for the SLList.
Definition sllist.hh:271
│ │ │ │ +
A single linked list.
Definition sllist.hh:44
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,700 +7,1209 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -arraylist.hh │ │ │ │ │ + * parallel │ │ │ │ │ +indicessyncer.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 (C) 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_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; │ │ │ │ │ + 5#ifndef DUNE_INDICESSYNCER_HH │ │ │ │ │ + 6#define DUNE_INDICESSYNCER_HH │ │ │ │ │ + 7 │ │ │ │ │ + 8#include "indexset.hh" │ │ │ │ │ + 9#include "remoteindices.hh" │ │ │ │ │ + 10#include │ │ │ │ │ + 11#include │ │ │ │ │ + 12#include │ │ │ │ │ + 13#include │ │ │ │ │ + 14#include │ │ │ │ │ + 15#include │ │ │ │ │ + 16#include │ │ │ │ │ + 17#include │ │ │ │ │ + 18#include │ │ │ │ │ + 19 │ │ │ │ │ + 20#if HAVE_MPI │ │ │ │ │ + 21namespace Dune │ │ │ │ │ + 22{ │ │ │ │ │ + 39 template │ │ │ │ │ +40 class IndicesSyncer │ │ │ │ │ + 41 { │ │ │ │ │ + 42 public: │ │ │ │ │ + 43 │ │ │ │ │ +45 typedef T ParallelIndexSet; │ │ │ │ │ + 46 │ │ │ │ │ +48 typedef typename ParallelIndexSet::IndexPair IndexPair; │ │ │ │ │ + 49 │ │ │ │ │ +51 typedef typename ParallelIndexSet::GlobalIndex GlobalIndex; │ │ │ │ │ + 52 │ │ │ │ │ +54 typedef typename ParallelIndexSet::LocalIndex::Attribute Attribute; │ │ │ │ │ + 55 │ │ │ │ │ +59 typedef Dune::RemoteIndices RemoteIndices; │ │ │ │ │ + 60 │ │ │ │ │ + 70 IndicesSyncer(ParallelIndexSet& indexSet, │ │ │ │ │ + 71 RemoteIndices& remoteIndices); │ │ │ │ │ + 72 │ │ │ │ │ + 82 void sync(); │ │ │ │ │ + 83 │ │ │ │ │ + 94 template │ │ │ │ │ + 95 void sync(T1& numberer); │ │ │ │ │ + 96 │ │ │ │ │ + 97 private: │ │ │ │ │ + 98 │ │ │ │ │ + 100 ParallelIndexSet& indexSet_; │ │ │ │ │ 101 │ │ │ │ │ -105 typedef ArrayListIterator iterator; │ │ │ │ │ - 106 │ │ │ │ │ -110 typedef ConstArrayListIterator const_iterator; │ │ │ │ │ - 111 │ │ │ │ │ -115 typedef std::size_t size_type; │ │ │ │ │ + 103 RemoteIndices& remoteIndices_; │ │ │ │ │ + 104 │ │ │ │ │ + 106 char** sendBuffers_; │ │ │ │ │ + 107 │ │ │ │ │ + 109 char* receiveBuffer_; │ │ │ │ │ + 110 │ │ │ │ │ + 112 std::size_t* sendBufferSizes_; │ │ │ │ │ + 113 │ │ │ │ │ + 115 int receiveBufferSize_; // int because of MPI │ │ │ │ │ 116 │ │ │ │ │ -120 typedef std::ptrdiff_t difference_type; │ │ │ │ │ - 121 │ │ │ │ │ -126 iterator begin(); │ │ │ │ │ - 127 │ │ │ │ │ -133 const_iterator begin() const; │ │ │ │ │ - 134 │ │ │ │ │ -139 iterator end(); │ │ │ │ │ - 140 │ │ │ │ │ -145 const_iterator end() const; │ │ │ │ │ - 146 │ │ │ │ │ -151 inline void push_back(const_reference entry); │ │ │ │ │ - 152 │ │ │ │ │ -158 inline reference operator[](size_type i); │ │ │ │ │ - 159 │ │ │ │ │ -165 inline const_reference operator[](size_type i) const; │ │ │ │ │ - 166 │ │ │ │ │ -171 inline size_type size() const; │ │ │ │ │ - 172 │ │ │ │ │ -180 inline void purge(); │ │ │ │ │ - 181 │ │ │ │ │ -185 inline void clear(); │ │ │ │ │ -189 ArrayList(); │ │ │ │ │ - 190 │ │ │ │ │ - 191 private: │ │ │ │ │ - 192 │ │ │ │ │ - 196 using SmartPointerAllocator = typename std::allocator_traits::template │ │ │ │ │ -rebind_alloc< std::shared_ptr< std::array > >; │ │ │ │ │ + 120 struct MessageInformation │ │ │ │ │ + 121 { │ │ │ │ │ +122 MessageInformation() │ │ │ │ │ + 123 : publish(), pairs() │ │ │ │ │ + 124 {} │ │ │ │ │ +126 int publish; │ │ │ │ │ +131 int pairs; │ │ │ │ │ + 132 }; │ │ │ │ │ + 133 │ │ │ │ │ + 137 class DefaultNumberer │ │ │ │ │ + 138 { │ │ │ │ │ + 139 public: │ │ │ │ │ +145 std::size_t operator()([[maybe_unused]] const GlobalIndex& global) │ │ │ │ │ + 146 { │ │ │ │ │ + 147 return std::numeric_limits::max(); │ │ │ │ │ + 148 } │ │ │ │ │ + 149 }; │ │ │ │ │ + 150 │ │ │ │ │ + 152 MPI_Datatype datatype_; │ │ │ │ │ + 153 │ │ │ │ │ + 155 int rank_; │ │ │ │ │ + 156 │ │ │ │ │ + 161 typedef SLList, typename RemoteIndices:: │ │ │ │ │ +Allocator> GlobalIndexList; │ │ │ │ │ + 162 │ │ │ │ │ + 164 typedef typename GlobalIndexList::ModifyIterator GlobalIndexModifier; │ │ │ │ │ + 165 │ │ │ │ │ + 169 typedef typename SLList:: │ │ │ │ │ +iterator │ │ │ │ │ + 170 GlobalIndexIterator; │ │ │ │ │ + 171 │ │ │ │ │ + 173 typedef std::map GlobalIndicesMap; │ │ │ │ │ + 174 │ │ │ │ │ + 183 GlobalIndicesMap globalMap_; │ │ │ │ │ + 184 │ │ │ │ │ + 188 typedef SLList BoolList; │ │ │ │ │ + 189 │ │ │ │ │ + 193 typedef typename BoolList::iterator BoolIterator; │ │ │ │ │ + 194 │ │ │ │ │ + 196 typedef typename BoolList::ModifyIterator BoolListModifier; │ │ │ │ │ 197 │ │ │ │ │ - 201 using ArrayAllocator = typename std::allocator_traits::template │ │ │ │ │ -rebind_alloc< std::array >; │ │ │ │ │ - 202 │ │ │ │ │ - 206 friend class ArrayListIterator; │ │ │ │ │ - 207 friend class ConstArrayListIterator; │ │ │ │ │ - 208 │ │ │ │ │ - 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 { │ │ │ │ │ + 199 typedef std::map BoolMap; │ │ │ │ │ + 200 │ │ │ │ │ + 205 BoolMap oldMap_; │ │ │ │ │ + 206 │ │ │ │ │ + 208 std::map infoSend_; │ │ │ │ │ + 209 │ │ │ │ │ + 211 typedef typename RemoteIndices::RemoteIndexList RemoteIndexList; │ │ │ │ │ + 212 │ │ │ │ │ + 214 typedef typename RemoteIndexList::ModifyIterator RemoteIndexModifier; │ │ │ │ │ + 215 │ │ │ │ │ + 217 typedef Dune::RemoteIndex RemoteIndex; │ │ │ │ │ + 218 │ │ │ │ │ + 220 typedef typename RemoteIndexList::iterator RemoteIndexIterator; │ │ │ │ │ + 221 │ │ │ │ │ + 223 typedef typename RemoteIndexList::const_iterator ConstRemoteIndexIterator; │ │ │ │ │ + 224 │ │ │ │ │ + 226 typedef std:: │ │ │ │ │ +tuple IteratorTuple; │ │ │ │ │ + 228 │ │ │ │ │ + 236 class Iterators │ │ │ │ │ + 237 { │ │ │ │ │ + 238 friend class IndicesSyncer; │ │ │ │ │ + 239 public: │ │ │ │ │ + 249 Iterators(RemoteIndexList& remoteIndices, GlobalIndexList& globalIndices, │ │ │ │ │ + 250 BoolList& booleans); │ │ │ │ │ + 251 │ │ │ │ │ + 255 Iterators(); │ │ │ │ │ 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 │ │ │ │ │ -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 │ │ │ │ │ - 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 │ │ │ │ │ - 309 inline reference elementAt(size_type i) const; │ │ │ │ │ - 310 │ │ │ │ │ - 315 inline reference dereference() const; │ │ │ │ │ + 260 Iterators& operator++(); │ │ │ │ │ + 261 │ │ │ │ │ + 267 void insert(const RemoteIndex& index, │ │ │ │ │ + 268 const std::pair& global); │ │ │ │ │ + 269 │ │ │ │ │ + 274 RemoteIndex& remoteIndex() const; │ │ │ │ │ + 275 │ │ │ │ │ + 280 std::pair& globalIndexPair() const; │ │ │ │ │ + 281 │ │ │ │ │ +282 Attribute& attribute() const; │ │ │ │ │ + 283 │ │ │ │ │ + 289 bool isOld() const; │ │ │ │ │ + 290 │ │ │ │ │ + 300 void reset(RemoteIndexList& remoteIndices, GlobalIndexList& globalIndices, │ │ │ │ │ + 301 BoolList& booleans); │ │ │ │ │ + 302 │ │ │ │ │ + 308 bool isNotAtEnd() const; │ │ │ │ │ + 309 │ │ │ │ │ + 315 bool isAtEnd() const; │ │ │ │ │ 316 │ │ │ │ │ - 328 inline void eraseToHere(); │ │ │ │ │ + 317 private: │ │ │ │ │ + 327 IteratorTuple iterators_; │ │ │ │ │ + 328 }; │ │ │ │ │ 329 │ │ │ │ │ -331 inline size_type position(){return position_;} │ │ │ │ │ + 331 typedef std::map IteratorsMap; │ │ │ │ │ 332 │ │ │ │ │ - 334 inline void advance(difference_type n); │ │ │ │ │ - 335 │ │ │ │ │ - 337 inline difference_type distanceTo(const ArrayListIterator& other) │ │ │ │ │ -const; │ │ │ │ │ - 338 │ │ │ │ │ -340 inline ArrayListIterator() : position_(0), list_(nullptr) │ │ │ │ │ - 341 {} │ │ │ │ │ - 342 │ │ │ │ │ - 343 private: │ │ │ │ │ - 349 inline ArrayListIterator(ArrayList& arrayList, size_type position); │ │ │ │ │ - 350 │ │ │ │ │ - 354 size_type position_; │ │ │ │ │ -358 ArrayList* list_; │ │ │ │ │ - 359 }; │ │ │ │ │ - 360 │ │ │ │ │ - 364 template │ │ │ │ │ -365 class ConstArrayListIterator │ │ │ │ │ - 366 : public RandomAccessIteratorFacade, │ │ │ │ │ - 367 const typename A::value_type, │ │ │ │ │ - 368 typename A::value_type const&, │ │ │ │ │ - 369 typename A::difference_type> │ │ │ │ │ - 370 { │ │ │ │ │ - 371 │ │ │ │ │ - 372 friend class ArrayList; │ │ │ │ │ - 373 friend class ArrayListIterator; │ │ │ │ │ - 374 │ │ │ │ │ - 375 public: │ │ │ │ │ -379 typedef typename A::value_type MemberType; │ │ │ │ │ - 380 │ │ │ │ │ -381 typedef typename A::difference_type difference_type; │ │ │ │ │ - 382 │ │ │ │ │ -383 typedef typename A::size_type size_type; │ │ │ │ │ - 384 │ │ │ │ │ -385 using reference = typename A::value_type &; │ │ │ │ │ - 386 │ │ │ │ │ -387 using const_reference = typename A::value_type const&; │ │ │ │ │ - 388 │ │ │ │ │ -394 constexpr static int chunkSize_ = (N > 0) ? N : 1; │ │ │ │ │ - 395 │ │ │ │ │ -401 inline bool equals(const ConstArrayListIterator& other) │ │ │ │ │ -const; │ │ │ │ │ - 402 │ │ │ │ │ -406 inline void increment(); │ │ │ │ │ + 344 IteratorsMap iteratorsMap_; │ │ │ │ │ + 345 │ │ │ │ │ + 347 void calculateMessageSizes(); │ │ │ │ │ + 348 │ │ │ │ │ + 356 void packAndSend(int destination, char* buffer, std::size_t bufferSize, │ │ │ │ │ +MPI_Request& req); │ │ │ │ │ + 357 │ │ │ │ │ + 362 template │ │ │ │ │ + 363 void recvAndUnpack(T1& numberer); │ │ │ │ │ + 364 │ │ │ │ │ + 368 void registerMessageDatatype(); │ │ │ │ │ + 369 │ │ │ │ │ + 373 void insertIntoRemoteIndexList(int process, │ │ │ │ │ + 374 const std::pair& global, │ │ │ │ │ + 375 char attribute); │ │ │ │ │ + 376 │ │ │ │ │ + 380 void resetIteratorsMap(); │ │ │ │ │ + 381 │ │ │ │ │ + 386 bool checkReset(); │ │ │ │ │ + 387 │ │ │ │ │ + 396 bool checkReset(const Iterators& iterators, RemoteIndexList& rlist, │ │ │ │ │ +GlobalIndexList& gList, │ │ │ │ │ + 397 BoolList& bList); │ │ │ │ │ + 398 }; │ │ │ │ │ + 399 │ │ │ │ │ + 400 template │ │ │ │ │ +401 bool operator<(const IndexPair >& i1, │ │ │ │ │ + 402 const std::pair& i2) │ │ │ │ │ + 403 { │ │ │ │ │ + 404 return i1.global() < i2.first || │ │ │ │ │ + 405 (i1.global() == i2.first && i1.local().attribute() │ │ │ │ │ +409 bool operator<(const std::pair& i1, │ │ │ │ │ + 410 const IndexPair >& i2) │ │ │ │ │ + 411 { │ │ │ │ │ + 412 return i1.first < i2.global() || │ │ │ │ │ + 413 (i1.first == i2.global() && i1.second& │ │ │ │ │ -other) const; │ │ │ │ │ - 418 │ │ │ │ │ -423 inline const_reference elementAt(size_type i) const; │ │ │ │ │ - 424 │ │ │ │ │ -429 inline const_reference dereference() const; │ │ │ │ │ - 430 │ │ │ │ │ -431 inline ConstArrayListIterator() : position_(0), list_(nullptr) │ │ │ │ │ - 432 {} │ │ │ │ │ - 433 │ │ │ │ │ -434 inline ConstArrayListIterator(const ArrayListIterator& other); │ │ │ │ │ - 435 │ │ │ │ │ - 436 private: │ │ │ │ │ - 437 │ │ │ │ │ - 443 inline ConstArrayListIterator(const ArrayList& arrayList, size_type │ │ │ │ │ -position); │ │ │ │ │ - 444 │ │ │ │ │ - 448 size_type position_; │ │ │ │ │ - 452 const ArrayList* list_; │ │ │ │ │ - 453 }; │ │ │ │ │ - 454 │ │ │ │ │ - 455 │ │ │ │ │ - 456 template │ │ │ │ │ -457 ArrayList::ArrayList() │ │ │ │ │ - 458 : capacity_(0), size_(0), start_(0) │ │ │ │ │ - 459 { │ │ │ │ │ - 460 chunks_.reserve(100); │ │ │ │ │ - 461 } │ │ │ │ │ - 462 │ │ │ │ │ - 463 template │ │ │ │ │ -464 void ArrayList::clear(){ │ │ │ │ │ - 465 capacity_=0; │ │ │ │ │ - 466 size_=0; │ │ │ │ │ - 467 start_=0; │ │ │ │ │ - 468 chunks_.clear(); │ │ │ │ │ - 469 } │ │ │ │ │ - 470 │ │ │ │ │ - 471 template │ │ │ │ │ -472 size_t ArrayList::size() const │ │ │ │ │ - 473 { │ │ │ │ │ - 474 return size_; │ │ │ │ │ + 416 template │ │ │ │ │ +417 bool operator==(const IndexPair >& i1, │ │ │ │ │ + 418 const std::pair& i2) │ │ │ │ │ + 419 { │ │ │ │ │ + 420 return (i1.global() == i2.first && i1.local().attribute()==i2.second); │ │ │ │ │ + 421 } │ │ │ │ │ + 422 │ │ │ │ │ + 423 template │ │ │ │ │ +424 bool operator!=(const IndexPair >& i1, │ │ │ │ │ + 425 const std::pair& i2) │ │ │ │ │ + 426 { │ │ │ │ │ + 427 return (i1.global() != i2.first || i1.local().attribute()!=i2.second); │ │ │ │ │ + 428 } │ │ │ │ │ + 429 │ │ │ │ │ + 430 template │ │ │ │ │ +431 bool operator==(const std::pair& i2, │ │ │ │ │ + 432 const IndexPair >& i1) │ │ │ │ │ + 433 { │ │ │ │ │ + 434 return (i1.global() == i2.first && i1.local().attribute()==i2.second); │ │ │ │ │ + 435 } │ │ │ │ │ + 436 │ │ │ │ │ + 437 template │ │ │ │ │ +438 bool operator!=(const std::pair& i2, │ │ │ │ │ + 439 const IndexPair >& i1) │ │ │ │ │ + 440 { │ │ │ │ │ + 441 return (i1.global() != i2.first || i1.local().attribute()!=i2.second); │ │ │ │ │ + 442 } │ │ │ │ │ + 443 │ │ │ │ │ + 460 template │ │ │ │ │ +461 void storeGlobalIndicesOfRemoteIndices(std::map,A> >& │ │ │ │ │ +globalMap, │ │ │ │ │ + 462 const RemoteIndices& remoteIndices) │ │ │ │ │ + 463 { │ │ │ │ │ + 464 for(auto remote = remoteIndices.begin(), end =remoteIndices.end(); remote │ │ │ │ │ +!= end; ++remote) { │ │ │ │ │ + 465 typedef typename RemoteIndices::RemoteIndexList RemoteIndexList; │ │ │ │ │ + 466 typedef SLList,A> GlobalIndexList; │ │ │ │ │ + 467 GlobalIndexList& global = globalMap[remote->first]; │ │ │ │ │ + 468 RemoteIndexList& rList = *(remote->second.first); │ │ │ │ │ + 469 │ │ │ │ │ + 470 for(auto index = rList.begin(), riEnd = rList.end(); │ │ │ │ │ + 471 index != riEnd; ++index) { │ │ │ │ │ + 472 global.push_back(std::make_pair(index->localIndexPair().global(), │ │ │ │ │ + 473 index->localIndexPair().local().attribute())); │ │ │ │ │ + 474 } │ │ │ │ │ 475 } │ │ │ │ │ - 476 │ │ │ │ │ - 477 template │ │ │ │ │ -478 void ArrayList::push_back(const_reference entry) │ │ │ │ │ - 479 { │ │ │ │ │ - 480 size_t index=start_+size_; │ │ │ │ │ - 481 if(index==capacity_) │ │ │ │ │ - 482 { │ │ │ │ │ - 483 chunks_.push_back(std::make_shared >()); │ │ │ │ │ - 484 capacity_ += chunkSize_; │ │ │ │ │ - 485 } │ │ │ │ │ - 486 elementAt(index)=entry; │ │ │ │ │ - 487 ++size_; │ │ │ │ │ - 488 } │ │ │ │ │ - 489 │ │ │ │ │ - 490 template │ │ │ │ │ -491 typename ArrayList::reference ArrayList::operator[](size_type │ │ │ │ │ -i) │ │ │ │ │ + 476 } │ │ │ │ │ + 477 │ │ │ │ │ + 486 template │ │ │ │ │ +487 inline void repairLocalIndexPointers(std::map,A> >& globalMap, │ │ │ │ │ + 490 RemoteIndices& remoteIndices, │ │ │ │ │ + 491 const T& indexSet) │ │ │ │ │ 492 { │ │ │ │ │ - 493 return elementAt(start_+i); │ │ │ │ │ - 494 } │ │ │ │ │ - 495 │ │ │ │ │ - 496 │ │ │ │ │ - 497 template │ │ │ │ │ -498 typename ArrayList::const_reference ArrayList::operator[] │ │ │ │ │ -(size_type i) const │ │ │ │ │ - 499 { │ │ │ │ │ - 500 return elementAt(start_+i); │ │ │ │ │ - 501 } │ │ │ │ │ - 502 │ │ │ │ │ - 503 template │ │ │ │ │ - 504 typename ArrayList::reference ArrayList::elementAt(size_type │ │ │ │ │ -i) │ │ │ │ │ - 505 { │ │ │ │ │ - 506 return chunks_[i/chunkSize_]->operator[](i%chunkSize_); │ │ │ │ │ - 507 } │ │ │ │ │ - 508 │ │ │ │ │ - 509 │ │ │ │ │ - 510 template │ │ │ │ │ - 511 typename ArrayList::const_reference ArrayList::elementAt │ │ │ │ │ -(size_type i) const │ │ │ │ │ - 512 { │ │ │ │ │ - 513 return chunks_[i/chunkSize_]->operator[](i%chunkSize_); │ │ │ │ │ - 514 } │ │ │ │ │ - 515 │ │ │ │ │ - 516 template │ │ │ │ │ -517 ArrayListIterator ArrayList::begin() │ │ │ │ │ - 518 { │ │ │ │ │ - 519 return ArrayListIterator(*this, start_); │ │ │ │ │ + 493 assert(globalMap.size()==static_cast(remoteIndices.neighbours │ │ │ │ │ +())); │ │ │ │ │ + 494 // Repair pointers to index set in remote indices. │ │ │ │ │ + 495 auto global = globalMap.begin(); │ │ │ │ │ + 496 auto end = remoteIndices.remoteIndices_.end(); │ │ │ │ │ + 497 │ │ │ │ │ + 498 for(auto remote = remoteIndices.remoteIndices_.begin(); remote != end; │ │ │ │ │ +++remote, ++global) { │ │ │ │ │ + 499 assert(remote->first==global->first); │ │ │ │ │ + 500 assert(remote->second.first->size() == global->second.size()); │ │ │ │ │ + 501 │ │ │ │ │ + 502 auto riEnd = remote->second.first->end(); │ │ │ │ │ + 503 auto rIndex = remote->second.first->begin(); │ │ │ │ │ + 504 auto gIndex = global->second.begin(); │ │ │ │ │ + 505 auto index = indexSet.begin(); │ │ │ │ │ + 506 │ │ │ │ │ + 507 assert(rIndex==riEnd || gIndex != global->second.end()); │ │ │ │ │ + 508 while(rIndex != riEnd) { │ │ │ │ │ + 509 // Search for the index in the set. │ │ │ │ │ + 510 assert(gIndex != global->second.end()); │ │ │ │ │ + 511 │ │ │ │ │ + 512 while(!(index->global() == gIndex->first │ │ │ │ │ + 513 && index->local().attribute() == gIndex->second)) { │ │ │ │ │ + 514 ++index; │ │ │ │ │ + 515 // this is only needed for ALU, where there may exist │ │ │ │ │ + 516 // more entries with the same global index in the remote index set │ │ │ │ │ + 517 // than in the index set │ │ │ │ │ + 518 if (index->global() > gIndex->first) { │ │ │ │ │ + 519 index=indexSet.begin(); │ │ │ │ │ 520 } │ │ │ │ │ - 521 │ │ │ │ │ - 522 template │ │ │ │ │ -523 ConstArrayListIterator ArrayList::begin() const │ │ │ │ │ - 524 { │ │ │ │ │ - 525 return ConstArrayListIterator(*this, start_); │ │ │ │ │ - 526 } │ │ │ │ │ - 527 │ │ │ │ │ - 528 template │ │ │ │ │ -529 ArrayListIterator ArrayList::end() │ │ │ │ │ - 530 { │ │ │ │ │ - 531 return ArrayListIterator(*this, start_+size_); │ │ │ │ │ - 532 } │ │ │ │ │ - 533 │ │ │ │ │ - 534 template │ │ │ │ │ -535 ConstArrayListIterator ArrayList::end() const │ │ │ │ │ - 536 { │ │ │ │ │ - 537 return ConstArrayListIterator(*this, start_+size_); │ │ │ │ │ - 538 } │ │ │ │ │ - 539 │ │ │ │ │ - 540 template │ │ │ │ │ -541 void ArrayList::purge() │ │ │ │ │ - 542 { │ │ │ │ │ - 543 // Distance to copy to the left. │ │ │ │ │ - 544 size_t distance = start_/chunkSize_; │ │ │ │ │ - 545 if(distance>0) { │ │ │ │ │ - 546 // Number of chunks with entries in it; │ │ │ │ │ - 547 size_t chunks = ((start_%chunkSize_ + size_)/chunkSize_ ); │ │ │ │ │ - 548 │ │ │ │ │ - 549 // Copy chunks to the left. │ │ │ │ │ - 550 std::copy(chunks_.begin()+distance, │ │ │ │ │ - 551 chunks_.begin()+(distance+chunks), chunks_.begin()); │ │ │ │ │ - 552 │ │ │ │ │ - 553 // Calculate new parameters │ │ │ │ │ - 554 start_ = start_ % chunkSize_; │ │ │ │ │ - 555 //capacity += distance * chunkSize_; │ │ │ │ │ - 556 } │ │ │ │ │ - 557 } │ │ │ │ │ + 521 } │ │ │ │ │ + 522 │ │ │ │ │ + 523 assert(index != indexSet.end() && *index == *gIndex); │ │ │ │ │ + 524 │ │ │ │ │ + 525 rIndex->localIndex_ = &(*index); │ │ │ │ │ + 526 ++index; │ │ │ │ │ + 527 ++rIndex; │ │ │ │ │ + 528 ++gIndex; │ │ │ │ │ + 529 } │ │ │ │ │ + 530 } │ │ │ │ │ + 531 remoteIndices.sourceSeqNo_ = remoteIndices.source_->seqNo(); │ │ │ │ │ + 532 remoteIndices.destSeqNo_ = remoteIndices.target_->seqNo(); │ │ │ │ │ + 533 } │ │ │ │ │ + 534 │ │ │ │ │ + 535 template │ │ │ │ │ +536 IndicesSyncer::IndicesSyncer(ParallelIndexSet& indexSet, │ │ │ │ │ + 537 RemoteIndices& remoteIndices) │ │ │ │ │ + 538 : indexSet_(indexSet), remoteIndices_(remoteIndices) │ │ │ │ │ + 539 { │ │ │ │ │ + 540 // index sets must match. │ │ │ │ │ + 541 assert(remoteIndices.source_ == remoteIndices.target_); │ │ │ │ │ + 542 assert(remoteIndices.source_ == &indexSet); │ │ │ │ │ + 543 MPI_Comm_rank(remoteIndices_.communicator(), &rank_); │ │ │ │ │ + 544 } │ │ │ │ │ + 545 │ │ │ │ │ + 546 template │ │ │ │ │ +547 IndicesSyncer::Iterators::Iterators(RemoteIndexList& remoteIndices, │ │ │ │ │ + 548 GlobalIndexList& globalIndices, │ │ │ │ │ + 549 BoolList& booleans) │ │ │ │ │ + 550 : iterators_(remoteIndices.beginModify(), globalIndices.beginModify(), │ │ │ │ │ + 551 booleans.beginModify(), remoteIndices.end()) │ │ │ │ │ + 552 { } │ │ │ │ │ + 553 │ │ │ │ │ + 554 template │ │ │ │ │ +555 IndicesSyncer::Iterators::Iterators() │ │ │ │ │ + 556 : iterators_() │ │ │ │ │ + 557 {} │ │ │ │ │ 558 │ │ │ │ │ - 559 template │ │ │ │ │ -560 void ArrayListIterator::advance(difference_type i) │ │ │ │ │ + 559 template │ │ │ │ │ +560 inline typename IndicesSyncer::Iterators& IndicesSyncer::Iterators:: │ │ │ │ │ +operator++() │ │ │ │ │ 561 { │ │ │ │ │ - 562 position_+=i; │ │ │ │ │ - 563 } │ │ │ │ │ - 564 │ │ │ │ │ - 565 template │ │ │ │ │ -566 void ConstArrayListIterator::advance(difference_type i) │ │ │ │ │ - 567 { │ │ │ │ │ - 568 position_+=i; │ │ │ │ │ - 569 } │ │ │ │ │ - 570 │ │ │ │ │ - 571 │ │ │ │ │ - 572 template │ │ │ │ │ -573 bool ArrayListIterator::equals(const │ │ │ │ │ -ArrayListIterator& other) const │ │ │ │ │ - 574 { │ │ │ │ │ - 575 // Makes only sense if we reference a common list │ │ │ │ │ - 576 assert(list_==(other.list_)); │ │ │ │ │ - 577 return position_==other.position_ ; │ │ │ │ │ - 578 } │ │ │ │ │ - 579 │ │ │ │ │ - 580 │ │ │ │ │ - 581 template │ │ │ │ │ -582 bool ArrayListIterator::equals(const │ │ │ │ │ -ConstArrayListIterator& other) const │ │ │ │ │ - 583 { │ │ │ │ │ - 584 // Makes only sense if we reference a common list │ │ │ │ │ - 585 assert(list_==(other.list_)); │ │ │ │ │ - 586 return position_==other.position_ ; │ │ │ │ │ - 587 } │ │ │ │ │ - 588 │ │ │ │ │ - 589 │ │ │ │ │ - 590 template │ │ │ │ │ -591 bool ConstArrayListIterator::equals(const │ │ │ │ │ -ConstArrayListIterator& other) const │ │ │ │ │ - 592 { │ │ │ │ │ - 593 // Makes only sense if we reference a common list │ │ │ │ │ - 594 assert(list_==(other.list_)); │ │ │ │ │ - 595 return position_==other.position_ ; │ │ │ │ │ - 596 } │ │ │ │ │ - 597 │ │ │ │ │ - 598 template │ │ │ │ │ -599 void ArrayListIterator::increment() │ │ │ │ │ - 600 { │ │ │ │ │ - 601 ++position_; │ │ │ │ │ - 602 } │ │ │ │ │ - 603 │ │ │ │ │ - 604 template │ │ │ │ │ -605 void ConstArrayListIterator::increment() │ │ │ │ │ - 606 { │ │ │ │ │ - 607 ++position_; │ │ │ │ │ - 608 } │ │ │ │ │ - 609 │ │ │ │ │ - 610 template │ │ │ │ │ -611 void ArrayListIterator::decrement() │ │ │ │ │ - 612 { │ │ │ │ │ - 613 --position_; │ │ │ │ │ - 614 } │ │ │ │ │ - 615 │ │ │ │ │ - 616 template │ │ │ │ │ -617 void ConstArrayListIterator::decrement() │ │ │ │ │ - 618 { │ │ │ │ │ - 619 --position_; │ │ │ │ │ - 620 } │ │ │ │ │ - 621 │ │ │ │ │ - 622 template │ │ │ │ │ -623 typename ArrayListIterator::reference ArrayListIterator:: │ │ │ │ │ -elementAt(size_type i) const │ │ │ │ │ - 624 { │ │ │ │ │ - 625 return list_->elementAt(i+position_); │ │ │ │ │ - 626 } │ │ │ │ │ - 627 │ │ │ │ │ - 628 template │ │ │ │ │ -629 typename ConstArrayListIterator::const_reference │ │ │ │ │ -ConstArrayListIterator::elementAt(size_type i) const │ │ │ │ │ - 630 { │ │ │ │ │ - 631 return list_->elementAt(i+position_); │ │ │ │ │ - 632 } │ │ │ │ │ - 633 │ │ │ │ │ - 634 template │ │ │ │ │ -635 typename ArrayListIterator::reference ArrayListIterator:: │ │ │ │ │ -dereference() const │ │ │ │ │ - 636 { │ │ │ │ │ - 637 return list_->elementAt(position_); │ │ │ │ │ - 638 } │ │ │ │ │ - 639 │ │ │ │ │ - 640 template │ │ │ │ │ -641 typename ConstArrayListIterator::const_reference │ │ │ │ │ -ConstArrayListIterator::dereference() const │ │ │ │ │ - 642 { │ │ │ │ │ - 643 return list_->elementAt(position_); │ │ │ │ │ - 644 } │ │ │ │ │ - 645 │ │ │ │ │ - 646 template │ │ │ │ │ -647 typename ArrayListIterator::difference_type │ │ │ │ │ -ArrayListIterator::distanceTo(const ArrayListIterator& other) │ │ │ │ │ -const │ │ │ │ │ - 648 { │ │ │ │ │ - 649 // Makes only sense if we reference a common list │ │ │ │ │ - 650 assert(list_==(other.list_)); │ │ │ │ │ - 651 return other.position_ - position_; │ │ │ │ │ - 652 } │ │ │ │ │ - 653 │ │ │ │ │ - 654 template │ │ │ │ │ -655 typename ConstArrayListIterator::difference_type │ │ │ │ │ -ConstArrayListIterator::distanceTo(const ConstArrayListIterator& │ │ │ │ │ -other) const │ │ │ │ │ - 656 { │ │ │ │ │ - 657 // Makes only sense if we reference a common list │ │ │ │ │ - 658 assert(list_==(other.list_)); │ │ │ │ │ - 659 return other.position_ - position_; │ │ │ │ │ - 660 } │ │ │ │ │ - 661 │ │ │ │ │ - 662 template │ │ │ │ │ -663 void ArrayListIterator::eraseToHere() │ │ │ │ │ - 664 { │ │ │ │ │ - 665 list_->size_ -= ++position_ - list_->start_; │ │ │ │ │ - 666 // chunk number of the new position. │ │ │ │ │ - 667 size_t posChunkStart = position_ / chunkSize_; │ │ │ │ │ - 668 // number of chunks to deallocate │ │ │ │ │ - 669 size_t chunks = (position_ - list_->start_ + list_->start_ % chunkSize_) │ │ │ │ │ - 670 / chunkSize_; │ │ │ │ │ - 671 list_->start_ = position_; │ │ │ │ │ - 672 │ │ │ │ │ - 673 // Deallocate memory not needed any more. │ │ │ │ │ - 674 for(size_t chunk=0; chunkchunks_[posChunkStart].reset(); │ │ │ │ │ - 677 } │ │ │ │ │ - 678 │ │ │ │ │ - 679 // Capacity stays the same as the chunks before us │ │ │ │ │ - 680 // are still there. They null pointers. │ │ │ │ │ - 681 assert(list_->start_+list_->size_<=list_->capacity_); │ │ │ │ │ - 682 } │ │ │ │ │ + 562 ++(std::get<0>(iterators_)); │ │ │ │ │ + 563 ++(std::get<1>(iterators_)); │ │ │ │ │ + 564 ++(std::get<2>(iterators_)); │ │ │ │ │ + 565 return *this; │ │ │ │ │ + 566 } │ │ │ │ │ + 567 │ │ │ │ │ + 568 template │ │ │ │ │ +569 inline void IndicesSyncer::Iterators::insert(const RemoteIndex & index, │ │ │ │ │ + 570 const std::pair& global) │ │ │ │ │ + 571 { │ │ │ │ │ + 572 std::get<0>(iterators_).insert(index); │ │ │ │ │ + 573 std::get<1>(iterators_).insert(global); │ │ │ │ │ + 574 std::get<2>(iterators_).insert(false); │ │ │ │ │ + 575 } │ │ │ │ │ + 576 │ │ │ │ │ + 577 template │ │ │ │ │ + 578 inline typename IndicesSyncer::RemoteIndex& │ │ │ │ │ +579 IndicesSyncer::Iterators::remoteIndex() const │ │ │ │ │ + 580 { │ │ │ │ │ + 581 return *(std::get<0>(iterators_)); │ │ │ │ │ + 582 } │ │ │ │ │ + 583 │ │ │ │ │ + 584 template │ │ │ │ │ + 585 inline std::pair::GlobalIndex,typename │ │ │ │ │ +IndicesSyncer::Attribute>& │ │ │ │ │ +586 IndicesSyncer::Iterators::globalIndexPair() const │ │ │ │ │ + 587 { │ │ │ │ │ + 588 return *(std::get<1>(iterators_)); │ │ │ │ │ + 589 } │ │ │ │ │ + 590 │ │ │ │ │ + 591 template │ │ │ │ │ +592 inline bool IndicesSyncer::Iterators::isOld() const │ │ │ │ │ + 593 { │ │ │ │ │ + 594 return *(std::get<2>(iterators_)); │ │ │ │ │ + 595 } │ │ │ │ │ + 596 │ │ │ │ │ + 597 template │ │ │ │ │ +598 inline void IndicesSyncer::Iterators::reset(RemoteIndexList& │ │ │ │ │ +remoteIndices, │ │ │ │ │ + 599 GlobalIndexList& globalIndices, │ │ │ │ │ + 600 BoolList& booleans) │ │ │ │ │ + 601 { │ │ │ │ │ + 602 std::get<0>(iterators_) = remoteIndices.beginModify(); │ │ │ │ │ + 603 std::get<1>(iterators_) = globalIndices.beginModify(); │ │ │ │ │ + 604 std::get<2>(iterators_) = booleans.beginModify(); │ │ │ │ │ + 605 } │ │ │ │ │ + 606 │ │ │ │ │ + 607 template │ │ │ │ │ +608 inline bool IndicesSyncer::Iterators::isNotAtEnd() const │ │ │ │ │ + 609 { │ │ │ │ │ + 610 return std::get<0>(iterators_) != std::get<3>(iterators_); │ │ │ │ │ + 611 } │ │ │ │ │ + 612 │ │ │ │ │ + 613 template │ │ │ │ │ +614 inline bool IndicesSyncer::Iterators::isAtEnd() const │ │ │ │ │ + 615 { │ │ │ │ │ + 616 return std::get<0>(iterators_) == std::get<3>(iterators_); │ │ │ │ │ + 617 } │ │ │ │ │ + 618 │ │ │ │ │ + 619 template │ │ │ │ │ + 620 void IndicesSyncer::registerMessageDatatype() │ │ │ │ │ + 621 { │ │ │ │ │ + 622 MPI_Datatype type[2] = {MPI_INT, MPI_INT}; │ │ │ │ │ + 623 int blocklength[2] = {1,1}; │ │ │ │ │ + 624 MPI_Aint displacement[2]; │ │ │ │ │ + 625 MPI_Aint base; │ │ │ │ │ + 626 │ │ │ │ │ + 627 // Compute displacement │ │ │ │ │ + 628 MessageInformation message; │ │ │ │ │ + 629 │ │ │ │ │ + 630 MPI_Get_address( &(message.publish), displacement); │ │ │ │ │ + 631 MPI_Get_address( &(message.pairs), displacement+1); │ │ │ │ │ + 632 │ │ │ │ │ + 633 // Make the displacement relative │ │ │ │ │ + 634 MPI_Get_address(&message, &base); │ │ │ │ │ + 635 displacement[0] -= base; │ │ │ │ │ + 636 displacement[1] -= base; │ │ │ │ │ + 637 │ │ │ │ │ + 638 MPI_Type_create_struct( 2, blocklength, displacement, type, &datatype_); │ │ │ │ │ + 639 MPI_Type_commit(&datatype_); │ │ │ │ │ + 640 } │ │ │ │ │ + 641 │ │ │ │ │ + 642 template │ │ │ │ │ + 643 void IndicesSyncer::calculateMessageSizes() │ │ │ │ │ + 644 { │ │ │ │ │ + 645 auto iEnd = indexSet_.end(); │ │ │ │ │ + 646 auto collIter = remoteIndices_.template iterator(); │ │ │ │ │ + 647 │ │ │ │ │ + 648 for(auto index = indexSet_.begin(); index != iEnd; ++index) { │ │ │ │ │ + 649 collIter.advance(index->global(), index->local().attribute()); │ │ │ │ │ + 650 if(collIter.empty()) │ │ │ │ │ + 651 break; │ │ │ │ │ + 652 int knownRemote=0; │ │ │ │ │ + 653 auto end = collIter.end(); │ │ │ │ │ + 654 │ │ │ │ │ + 655 // Count the remote indices we know. │ │ │ │ │ + 656 for(auto valid = collIter.begin(); valid != end; ++valid) { │ │ │ │ │ + 657 ++knownRemote; │ │ │ │ │ + 658 } │ │ │ │ │ + 659 │ │ │ │ │ + 660 if(knownRemote>0) { │ │ │ │ │ + 661 Dune::dverb<global()<< " for processes "; │ │ │ │ │ + 662 │ │ │ │ │ + 663 // Update MessageInformation │ │ │ │ │ + 664 for(auto valid = collIter.begin(); valid != end; ++valid) { │ │ │ │ │ + 665 ++(infoSend_[valid.process()].publish); │ │ │ │ │ + 666 (infoSend_[valid.process()].pairs) += knownRemote; │ │ │ │ │ + 667 Dune::dverb< │ │ │ │ │ - 685 ArrayListIterator::ArrayListIterator(ArrayList& arrayList, │ │ │ │ │ -size_type position) │ │ │ │ │ - 686 : position_(position), list_(&arrayList) │ │ │ │ │ - 687 {} │ │ │ │ │ - 688 │ │ │ │ │ - 689 │ │ │ │ │ - 690 template │ │ │ │ │ - 691 ConstArrayListIterator::ConstArrayListIterator(const │ │ │ │ │ -ArrayList& arrayList, │ │ │ │ │ - 692 size_type position) │ │ │ │ │ - 693 : position_(position), list_(&arrayList) │ │ │ │ │ - 694 {} │ │ │ │ │ + 684 for(auto remote = remoteIndices_.begin(); remote != rend; ++remote, │ │ │ │ │ +++neighbour) { │ │ │ │ │ + 685 MessageInformation* message; │ │ │ │ │ + 686 MessageInformation recv; │ │ │ │ │ + 687 │ │ │ │ │ + 688 if(messageIter != end && messageIter->first==remote->first) { │ │ │ │ │ + 689 // We want to send message information to that process │ │ │ │ │ + 690 message = const_cast(&(messageIter->second)); │ │ │ │ │ + 691 ++messageIter; │ │ │ │ │ + 692 }else │ │ │ │ │ + 693 // We do not want to send information but the other process might. │ │ │ │ │ + 694 message = &dummy; │ │ │ │ │ 695 │ │ │ │ │ - 696 template │ │ │ │ │ -697 ConstArrayListIterator::ConstArrayListIterator(const │ │ │ │ │ -ArrayListIterator& other) │ │ │ │ │ - 698 : position_(other.position_), list_(other.list_) │ │ │ │ │ - 699 {} │ │ │ │ │ - 700 │ │ │ │ │ + 696 sendBufferSizes_[neighbour]=0; │ │ │ │ │ + 697 int tsize; │ │ │ │ │ + 698 // The number of indices published │ │ │ │ │ + 699 MPI_Pack_size(1, MPI_INT,remoteIndices_.communicator(), &tsize); │ │ │ │ │ + 700 sendBufferSizes_[neighbour] += tsize; │ │ │ │ │ 701 │ │ │ │ │ - 703} │ │ │ │ │ - 704#endif │ │ │ │ │ -iteratorfacades.hh │ │ │ │ │ -This file implements iterator facade classes for writing stl conformant │ │ │ │ │ -iterators. │ │ │ │ │ -Dune::ArrayList::operator[] │ │ │ │ │ -reference operator[](size_type i) │ │ │ │ │ -Get the element at specific position. │ │ │ │ │ -Definition arraylist.hh:491 │ │ │ │ │ -Dune::ArrayList::begin │ │ │ │ │ -iterator begin() │ │ │ │ │ -Get an iterator that is positioned at the first element. │ │ │ │ │ -Definition arraylist.hh:517 │ │ │ │ │ -Dune::ArrayListIterator::equals │ │ │ │ │ -bool equals(const ArrayListIterator< MemberType, N, A > &other) const │ │ │ │ │ -Comares two iterators. │ │ │ │ │ -Definition arraylist.hh:573 │ │ │ │ │ -Dune::ArrayListIterator::increment │ │ │ │ │ -void increment() │ │ │ │ │ -Increment the iterator. │ │ │ │ │ -Definition arraylist.hh:599 │ │ │ │ │ -Dune::ArrayList::size │ │ │ │ │ -size_type size() const │ │ │ │ │ -Get the number of elements in the list. │ │ │ │ │ -Definition arraylist.hh:472 │ │ │ │ │ -Dune::ConstArrayListIterator::ConstArrayListIterator │ │ │ │ │ -ConstArrayListIterator(const ArrayListIterator< T, N, A > &other) │ │ │ │ │ -Definition arraylist.hh:697 │ │ │ │ │ -Dune::ArrayList::purge │ │ │ │ │ -void purge() │ │ │ │ │ -Purge the list. │ │ │ │ │ -Definition arraylist.hh:541 │ │ │ │ │ -Dune::ArrayListIterator::decrement │ │ │ │ │ -void decrement() │ │ │ │ │ -decrement the iterator. │ │ │ │ │ -Definition arraylist.hh:611 │ │ │ │ │ -Dune::ArrayListIterator::eraseToHere │ │ │ │ │ -void eraseToHere() │ │ │ │ │ -Erase all entries before the current position and the one at the current │ │ │ │ │ -position. │ │ │ │ │ -Definition arraylist.hh:663 │ │ │ │ │ -Dune::ArrayList::ArrayList │ │ │ │ │ -ArrayList() │ │ │ │ │ -Constructs an Array list with one chunk. │ │ │ │ │ -Definition arraylist.hh:457 │ │ │ │ │ -Dune::ArrayList::begin │ │ │ │ │ -const_iterator begin() const │ │ │ │ │ -Get a random access iterator that is positioned at the first element. │ │ │ │ │ -Definition arraylist.hh:523 │ │ │ │ │ -Dune::ConstArrayListIterator::increment │ │ │ │ │ -void increment() │ │ │ │ │ -Increment the iterator. │ │ │ │ │ -Definition arraylist.hh:605 │ │ │ │ │ -Dune::ArrayList::end │ │ │ │ │ + 702 for(int i=0; i < message->publish; ++i) { │ │ │ │ │ + 703 // The global index │ │ │ │ │ + 704 MPI_Pack_size(1, MPITraits::getType(), │ │ │ │ │ +remoteIndices_.communicator(), &tsize); │ │ │ │ │ + 705 sendBufferSizes_[neighbour] += tsize; │ │ │ │ │ + 706 // The attribute in the local index │ │ │ │ │ + 707 MPI_Pack_size(1, MPI_CHAR, remoteIndices_.communicator(), &tsize); │ │ │ │ │ + 708 sendBufferSizes_[neighbour] += tsize; │ │ │ │ │ + 709 // The number of corresponding remote indices │ │ │ │ │ + 710 MPI_Pack_size(1, MPI_INT, remoteIndices_.communicator(), &tsize); │ │ │ │ │ + 711 sendBufferSizes_[neighbour] += tsize; │ │ │ │ │ + 712 } │ │ │ │ │ + 713 for(int i=0; i < message->pairs; ++i) { │ │ │ │ │ + 714 // The process of the remote index │ │ │ │ │ + 715 MPI_Pack_size(1, MPI_INT, remoteIndices_.communicator(), &tsize); │ │ │ │ │ + 716 sendBufferSizes_[neighbour] += tsize; │ │ │ │ │ + 717 // The attribute of the remote index │ │ │ │ │ + 718 MPI_Pack_size(1, MPI_CHAR, remoteIndices_.communicator(), &tsize); │ │ │ │ │ + 719 sendBufferSizes_[neighbour] += tsize; │ │ │ │ │ + 720 } │ │ │ │ │ + 721 │ │ │ │ │ + 722 Dune::dverb< │ │ │ │ │ + 852 void IndicesSyncer::packAndSend(int destination, char* buffer, std:: │ │ │ │ │ +size_t bufferSize, MPI_Request& request) │ │ │ │ │ + 853 { │ │ │ │ │ + 854 auto iEnd = indexSet_.end(); │ │ │ │ │ + 855 int bpos = 0; │ │ │ │ │ + 856 int published = 0; │ │ │ │ │ + 857 int pairs = 0; │ │ │ │ │ + 858 │ │ │ │ │ + 859 assert(checkReset()); │ │ │ │ │ + 860 │ │ │ │ │ + 861 // Pack the number of indices we publish │ │ │ │ │ + 862 MPI_Pack(&(infoSend_[destination].publish), 1, MPI_INT, buffer, │ │ │ │ │ +bufferSize, &bpos, │ │ │ │ │ + 863 remoteIndices_.communicator()); │ │ │ │ │ + 864 │ │ │ │ │ + 865 for(auto index = indexSet_.begin(); index != iEnd; ++index) { │ │ │ │ │ + 866 // Search for corresponding remote indices in all iterator tuples │ │ │ │ │ + 867 auto iteratorsEnd = iteratorsMap_.end(); │ │ │ │ │ + 868 │ │ │ │ │ + 869 // advance all iterators to a position with global index >= index->global │ │ │ │ │ +() │ │ │ │ │ + 870 for(auto iterators = iteratorsMap_.begin(); iteratorsEnd != iterators; │ │ │ │ │ +++iterators) { │ │ │ │ │ + 871 while(iterators->second.isNotAtEnd() && │ │ │ │ │ + 872 iterators->second.globalIndexPair().first < index->global()) │ │ │ │ │ + 873 ++(iterators->second); │ │ │ │ │ + 874 assert(!iterators->second.isNotAtEnd() || iterators- │ │ │ │ │ +>second.globalIndexPair().first >= index->global()); │ │ │ │ │ + 875 } │ │ │ │ │ + 876 │ │ │ │ │ + 877 // Add all remote indices positioned at global which were already present │ │ │ │ │ +before calling sync │ │ │ │ │ + 878 // to the message. │ │ │ │ │ + 879 // Count how many remote indices we will send │ │ │ │ │ + 880 int indices = 0; │ │ │ │ │ + 881 bool knownRemote = false; // Is the remote process supposed to know this │ │ │ │ │ +index? │ │ │ │ │ + 882 │ │ │ │ │ + 883 for(auto iterators = iteratorsMap_.begin(); iteratorsEnd != iterators; │ │ │ │ │ +++iterators) │ │ │ │ │ + 884 { │ │ │ │ │ + 885 std::pair p; │ │ │ │ │ + 886 if (iterators->second.isNotAtEnd()) │ │ │ │ │ + 887 { │ │ │ │ │ + 888 p = iterators->second.globalIndexPair(); │ │ │ │ │ + 889 } │ │ │ │ │ + 890 │ │ │ │ │ + 891 if(iterators->second.isNotAtEnd() && iterators->second.isOld() │ │ │ │ │ + 892 && iterators->second.globalIndexPair().first == index->global()) { │ │ │ │ │ + 893 indices++; │ │ │ │ │ + 894 if(destination == iterators->first) │ │ │ │ │ + 895 knownRemote = true; │ │ │ │ │ + 896 } │ │ │ │ │ + 897 } │ │ │ │ │ + 898 │ │ │ │ │ + 899 if(!knownRemote) │ │ │ │ │ + 900 // We do not need to send any indices │ │ │ │ │ + 901 continue; │ │ │ │ │ + 902 │ │ │ │ │ + 903 Dune::dverb<global │ │ │ │ │ +()<<" to "<(&(index->global())), 1, │ │ │ │ │ +MPITraits::getType(), buffer, bufferSize, &bpos, │ │ │ │ │ + 908 remoteIndices_.communicator()); │ │ │ │ │ + 909 │ │ │ │ │ + 910 char attr = index->local().attribute(); │ │ │ │ │ + 911 MPI_Pack(&attr, 1, MPI_CHAR, buffer, bufferSize, &bpos, │ │ │ │ │ + 912 remoteIndices_.communicator()); │ │ │ │ │ + 913 │ │ │ │ │ + 914 // Pack the number of remote indices we send. │ │ │ │ │ + 915 MPI_Pack(&indices, 1, MPI_INT, buffer, bufferSize, &bpos, │ │ │ │ │ + 916 remoteIndices_.communicator()); │ │ │ │ │ + 917 │ │ │ │ │ + 918 // Pack the information about the remote indices │ │ │ │ │ + 919 for(auto iterators = iteratorsMap_.begin(); iteratorsEnd != iterators; │ │ │ │ │ +++iterators) │ │ │ │ │ + 920 if(iterators->second.isNotAtEnd() && iterators->second.isOld() │ │ │ │ │ + 921 && iterators->second.globalIndexPair().first == index->global()) { │ │ │ │ │ + 922 int process = iterators->first; │ │ │ │ │ + 923 │ │ │ │ │ + 924 ++pairs; │ │ │ │ │ + 925 assert(pairs <= infoSend_[destination].pairs); │ │ │ │ │ + 926 MPI_Pack(&process, 1, MPI_INT, buffer, bufferSize, &bpos, │ │ │ │ │ + 927 remoteIndices_.communicator()); │ │ │ │ │ + 928 char attr2 = iterators->second.remoteIndex().attribute(); │ │ │ │ │ + 929 │ │ │ │ │ + 930 MPI_Pack(&attr2, 1, MPI_CHAR, buffer, bufferSize, &bpos, │ │ │ │ │ + 931 remoteIndices_.communicator()); │ │ │ │ │ + 932 --indices; │ │ │ │ │ + 933 } │ │ │ │ │ + 934 assert(indices==0); │ │ │ │ │ + 935 ++published; │ │ │ │ │ + 936 Dune::dvverb<<" (publish="< │ │ │ │ │ + 951 inline void IndicesSyncer::insertIntoRemoteIndexList(int process, │ │ │ │ │ + 952 const std::pair& globalPair, │ │ │ │ │ + 953 char attribute) │ │ │ │ │ + 954 { │ │ │ │ │ + 955 Dune::dverb<<"Inserting from "<second; │ │ │ │ │ + 972 │ │ │ │ │ + 973 // Search for the remote index │ │ │ │ │ + 974 while(iterators.isNotAtEnd() && iterators.globalIndexPair() < globalPair) │ │ │ │ │ +{ │ │ │ │ │ + 975 // Increment all iterators │ │ │ │ │ + 976 ++iterators; │ │ │ │ │ + 977 │ │ │ │ │ + 978 } │ │ │ │ │ + 979 │ │ │ │ │ + 980 if(iterators.isAtEnd() || iterators.globalIndexPair() != globalPair) { │ │ │ │ │ + 981 // The entry is not yet known │ │ │ │ │ + 982 // Insert in the list and do not change the first iterator. │ │ │ │ │ + 983 iterators.insert(RemoteIndex(Attribute(attribute)),globalPair); │ │ │ │ │ + 984 return; │ │ │ │ │ + 985 } │ │ │ │ │ + 986 │ │ │ │ │ + 987 // Global indices match │ │ │ │ │ + 988 bool indexIsThere=false; │ │ │ │ │ + 989 for(Iterators tmpIterators = iterators; │ │ │ │ │ + 990 !tmpIterators.isAtEnd() && tmpIterators.globalIndexPair() == globalPair; │ │ │ │ │ + 991 ++tmpIterators) │ │ │ │ │ + 992 //entry already exists with the same attribute │ │ │ │ │ + 993 if(tmpIterators.globalIndexPair().second == attribute) { │ │ │ │ │ + 994 indexIsThere=true; │ │ │ │ │ + 995 break; │ │ │ │ │ + 996 } │ │ │ │ │ + 997 │ │ │ │ │ + 998 if(!indexIsThere) │ │ │ │ │ + 999 // The entry is not yet known │ │ │ │ │ + 1000 // Insert in the list and do not change the first iterator. │ │ │ │ │ + 1001 iterators.insert(RemoteIndex(Attribute(attribute)),globalPair); │ │ │ │ │ + 1002 } │ │ │ │ │ + 1003 │ │ │ │ │ + 1004 template │ │ │ │ │ + 1005 template │ │ │ │ │ + 1006 void IndicesSyncer::recvAndUnpack(T1& numberer) │ │ │ │ │ + 1007 { │ │ │ │ │ + 1008 const ParallelIndexSet& constIndexSet = indexSet_; │ │ │ │ │ + 1009 auto iEnd = constIndexSet.end(); │ │ │ │ │ + 1010 auto index = constIndexSet.begin(); │ │ │ │ │ + 1011 int bpos = 0; │ │ │ │ │ + 1012 int publish; │ │ │ │ │ + 1013 │ │ │ │ │ + 1014 assert(checkReset()); │ │ │ │ │ + 1015 │ │ │ │ │ + 1016 MPI_Status status; │ │ │ │ │ + 1017 │ │ │ │ │ + 1018 // We have to determine the message size and source before the receive │ │ │ │ │ + 1019 MPI_Probe(MPI_ANY_SOURCE, 345, remoteIndices_.communicator(), &status); │ │ │ │ │ + 1020 │ │ │ │ │ + 1021 int source=status.MPI_SOURCE; │ │ │ │ │ + 1022 int count; │ │ │ │ │ + 1023 MPI_Get_count(&status, MPI_PACKED, &count); │ │ │ │ │ + 1024 │ │ │ │ │ + 1025 Dune::dvverb<receiveBufferSize_) { │ │ │ │ │ + 1028 receiveBufferSize_=count; │ │ │ │ │ + 1029 delete[] receiveBuffer_; │ │ │ │ │ + 1030 receiveBuffer_ = new char[receiveBufferSize_]; │ │ │ │ │ + 1031 } │ │ │ │ │ + 1032 │ │ │ │ │ + 1033 MPI_Recv(receiveBuffer_, count, MPI_PACKED, source, 345, │ │ │ │ │ +remoteIndices_.communicator(), &status); │ │ │ │ │ + 1034 │ │ │ │ │ + 1035 // How many global entries were published? │ │ │ │ │ + 1036 MPI_Unpack(receiveBuffer_, count, &bpos, &publish, 1, MPI_INT, │ │ │ │ │ +remoteIndices_.communicator()); │ │ │ │ │ + 1037 │ │ │ │ │ + 1038 // Now unpack the remote indices and add them. │ │ │ │ │ + 1039 while(publish>0) { │ │ │ │ │ + 1040 │ │ │ │ │ + 1041 // Unpack information about the local index on the source process │ │ │ │ │ + 1042 GlobalIndex global; // global index of the current entry │ │ │ │ │ + 1043 char sourceAttribute; // Attribute on the source process │ │ │ │ │ + 1044 int pairs; │ │ │ │ │ + 1045 │ │ │ │ │ + 1046 MPI_Unpack(receiveBuffer_, count, &bpos, &global, 1, │ │ │ │ │ +MPITraits::getType(), │ │ │ │ │ + 1047 remoteIndices_.communicator()); │ │ │ │ │ + 1048 MPI_Unpack(receiveBuffer_, count, &bpos, &sourceAttribute, 1, MPI_CHAR, │ │ │ │ │ + 1049 remoteIndices_.communicator()); │ │ │ │ │ + 1050 MPI_Unpack(receiveBuffer_, count, &bpos, &pairs, 1, MPI_INT, │ │ │ │ │ + 1051 remoteIndices_.communicator()); │ │ │ │ │ + 1052 │ │ │ │ │ + 1053 // Insert the entry on the remote process to our │ │ │ │ │ + 1054 // remote index list │ │ │ │ │ + 1055 SLList > sourceAttributeList; │ │ │ │ │ + 1056 sourceAttributeList.push_back(std::make_pair(source,Attribute │ │ │ │ │ +(sourceAttribute))); │ │ │ │ │ + 1057#ifndef NDEBUG │ │ │ │ │ + 1058 bool foundSelf = false; │ │ │ │ │ + 1059#endif │ │ │ │ │ + 1060 Attribute myAttribute=Attribute(); │ │ │ │ │ + 1061 │ │ │ │ │ + 1062 // Unpack the remote indices │ │ │ │ │ + 1063 for(; pairs>0; --pairs) { │ │ │ │ │ + 1064 // Unpack the process id that knows the index │ │ │ │ │ + 1065 int process; │ │ │ │ │ + 1066 char attribute; │ │ │ │ │ + 1067 MPI_Unpack(receiveBuffer_, count, &bpos, &process, 1, MPI_INT, │ │ │ │ │ + 1068 remoteIndices_.communicator()); │ │ │ │ │ + 1069 // Unpack the attribute │ │ │ │ │ + 1070 MPI_Unpack(receiveBuffer_, count, &bpos, &attribute, 1, MPI_CHAR, │ │ │ │ │ + 1071 remoteIndices_.communicator()); │ │ │ │ │ + 1072 │ │ │ │ │ + 1073 if(process==rank_) { │ │ │ │ │ + 1074#ifndef NDEBUG │ │ │ │ │ + 1075 foundSelf=true; │ │ │ │ │ + 1076#endif │ │ │ │ │ + 1077 myAttribute=Attribute(attribute); │ │ │ │ │ + 1078 // Now we know the local attribute of the global index │ │ │ │ │ + 1079 //Only add the index if it is unknown. │ │ │ │ │ + 1080 // Do we know that global index already? │ │ │ │ │ + 1081 auto pos = std::lower_bound(index, iEnd, IndexPair(global)); │ │ │ │ │ + 1082 │ │ │ │ │ + 1083 if(pos == iEnd || pos->global() != global) { │ │ │ │ │ + 1084 // no entry with this global index │ │ │ │ │ + 1085 indexSet_.add(global, │ │ │ │ │ + 1086 ParallelLocalIndex(numberer(global), │ │ │ │ │ + 1087 myAttribute, true)); │ │ │ │ │ + 1088 Dune::dvverb << "Adding "<global()==global; ++pos) │ │ │ │ │ + 1097 if(pos->local().attribute() == myAttribute) { │ │ │ │ │ + 1098 Dune::dvverb<<"found "<(numberer(global), │ │ │ │ │ + 1106 myAttribute, true)); │ │ │ │ │ + 1107 Dune::dvverb << "Adding "< >::const_iterator Iter; │ │ │ │ │ + 1117 for(Iter i=sourceAttributeList.begin(), end=sourceAttributeList.end(); │ │ │ │ │ + 1118 i!=end; ++i) │ │ │ │ │ + 1119 insertIntoRemoteIndexList(i->first, std::make_pair(global, myAttribute), │ │ │ │ │ + 1120 i->second); │ │ │ │ │ + 1121 --publish; │ │ │ │ │ + 1122 } │ │ │ │ │ + 1123 │ │ │ │ │ + 1124 resetIteratorsMap(); │ │ │ │ │ + 1125 } │ │ │ │ │ + 1126 │ │ │ │ │ + 1127 template │ │ │ │ │ + 1128 void IndicesSyncer::resetIteratorsMap(){ │ │ │ │ │ + 1129 │ │ │ │ │ + 1130 // Reset iterators in all tuples. │ │ │ │ │ + 1131 const auto remoteEnd = remoteIndices_.remoteIndices_.end(); │ │ │ │ │ + 1132 auto iterators = iteratorsMap_.begin(); │ │ │ │ │ + 1133 auto global = globalMap_.begin(); │ │ │ │ │ + 1134 auto added = oldMap_.begin(); │ │ │ │ │ + 1135 │ │ │ │ │ + 1136 for(auto remote = remoteIndices_.remoteIndices_.begin(); │ │ │ │ │ + 1137 remote != remoteEnd; ++remote, ++global, ++added, ++iterators) { │ │ │ │ │ + 1138 iterators->second.reset(*(remote->second.first), global->second, added- │ │ │ │ │ +>second); │ │ │ │ │ + 1139 } │ │ │ │ │ + 1140 } │ │ │ │ │ + 1141 │ │ │ │ │ + 1142 template │ │ │ │ │ + 1143 bool IndicesSyncer::checkReset(const Iterators& iterators, │ │ │ │ │ +RemoteIndexList& rList, GlobalIndexList& gList, │ │ │ │ │ + 1144 BoolList& bList){ │ │ │ │ │ + 1145 │ │ │ │ │ + 1146 if(std::get<0>(iterators.iterators_) != rList.begin()) │ │ │ │ │ + 1147 return false; │ │ │ │ │ + 1148 if(std::get<1>(iterators.iterators_) != gList.begin()) │ │ │ │ │ + 1149 return false; │ │ │ │ │ + 1150 if(std::get<2>(iterators.iterators_) != bList.begin()) │ │ │ │ │ + 1151 return false; │ │ │ │ │ + 1152 return true; │ │ │ │ │ + 1153 } │ │ │ │ │ + 1154 │ │ │ │ │ + 1155 │ │ │ │ │ + 1156 template │ │ │ │ │ + 1157 bool IndicesSyncer::checkReset(){ │ │ │ │ │ + 1158 │ │ │ │ │ + 1159 // Reset iterators in all tuples. │ │ │ │ │ + 1160 const auto remoteEnd = remoteIndices_.remoteIndices_.end(); │ │ │ │ │ + 1161 auto iterators = iteratorsMap_.begin(); │ │ │ │ │ + 1162 auto global = globalMap_.begin(); │ │ │ │ │ + 1163 auto added = oldMap_.begin(); │ │ │ │ │ + 1164 bool ret = true; │ │ │ │ │ + 1165 │ │ │ │ │ + 1166 for(auto remote = remoteIndices_.remoteIndices_.begin(); │ │ │ │ │ + 1167 remote != remoteEnd; ++remote, ++global, ++added, ++iterators) { │ │ │ │ │ + 1168 if(!checkReset(iterators->second, *(remote->second.first), global- │ │ │ │ │ +>second, │ │ │ │ │ + 1169 added->second)) │ │ │ │ │ + 1170 ret=false; │ │ │ │ │ + 1171 } │ │ │ │ │ + 1172 return ret; │ │ │ │ │ + 1173 } │ │ │ │ │ + 1174} │ │ │ │ │ + 1175 │ │ │ │ │ + 1176#endif │ │ │ │ │ + 1177#endif │ │ │ │ │ +indexset.hh │ │ │ │ │ +Provides a map between global and local indices. │ │ │ │ │ +remoteindices.hh │ │ │ │ │ +Classes describing a distributed indexset. │ │ │ │ │ +sllist.hh │ │ │ │ │ +Implements a singly linked list together with the necessary iterators. │ │ │ │ │ +stdstreams.hh │ │ │ │ │ +Standard Dune debug streams. │ │ │ │ │ +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::iterator │ │ │ │ │ +SLListIterator< T, A > iterator │ │ │ │ │ +The mutable iterator of the list. │ │ │ │ │ +Definition sllist.hh:69 │ │ │ │ │ +Dune::SLList::end │ │ │ │ │ iterator end() │ │ │ │ │ -Get a random access iterator positioned after the last element. │ │ │ │ │ -Definition arraylist.hh:529 │ │ │ │ │ -Dune::ConstArrayListIterator::elementAt │ │ │ │ │ -const_reference elementAt(size_type i) const │ │ │ │ │ -Get the value of the list at an arbitrary position. │ │ │ │ │ -Definition arraylist.hh:629 │ │ │ │ │ -Dune::ArrayList::operator[] │ │ │ │ │ -const_reference operator[](size_type i) const │ │ │ │ │ -Get the element at specific position. │ │ │ │ │ -Definition arraylist.hh:498 │ │ │ │ │ -Dune::ConstArrayListIterator::decrement │ │ │ │ │ -void decrement() │ │ │ │ │ -decrement the iterator. │ │ │ │ │ -Definition arraylist.hh:617 │ │ │ │ │ -Dune::ConstArrayListIterator::advance │ │ │ │ │ -void advance(difference_type n) │ │ │ │ │ -Definition arraylist.hh:566 │ │ │ │ │ -Dune::ArrayList::end │ │ │ │ │ -const_iterator end() const │ │ │ │ │ -Get a random access iterator positioned after the last element. │ │ │ │ │ -Definition arraylist.hh:535 │ │ │ │ │ -Dune::ConstArrayListIterator::dereference │ │ │ │ │ -const_reference dereference() const │ │ │ │ │ -Access the element at the current position. │ │ │ │ │ -Definition arraylist.hh:641 │ │ │ │ │ -Dune::ArrayList::clear │ │ │ │ │ -void clear() │ │ │ │ │ -Delete all entries from the list. │ │ │ │ │ -Definition arraylist.hh:464 │ │ │ │ │ -Dune::ArrayListIterator::elementAt │ │ │ │ │ -reference elementAt(size_type i) const │ │ │ │ │ -Get the value of the list at an arbitrary position. │ │ │ │ │ -Definition arraylist.hh:623 │ │ │ │ │ -Dune::ConstArrayListIterator::equals │ │ │ │ │ -bool equals(const ConstArrayListIterator< MemberType, N, A > &other) const │ │ │ │ │ -Comares to iterators. │ │ │ │ │ -Definition arraylist.hh:591 │ │ │ │ │ -Dune::ArrayListIterator::advance │ │ │ │ │ -void advance(difference_type n) │ │ │ │ │ -Definition arraylist.hh:560 │ │ │ │ │ -Dune::ConstArrayListIterator::distanceTo │ │ │ │ │ -difference_type distanceTo(const ConstArrayListIterator< T, N, A > &other) │ │ │ │ │ -const │ │ │ │ │ -Definition arraylist.hh:655 │ │ │ │ │ -Dune::ArrayListIterator::dereference │ │ │ │ │ -reference dereference() const │ │ │ │ │ -Access the element at the current position. │ │ │ │ │ -Definition arraylist.hh:635 │ │ │ │ │ -Dune::ArrayList::push_back │ │ │ │ │ -void push_back(const_reference entry) │ │ │ │ │ -Append an entry to the list. │ │ │ │ │ -Definition arraylist.hh:478 │ │ │ │ │ -Dune::ArrayListIterator::distanceTo │ │ │ │ │ -difference_type distanceTo(const ArrayListIterator< T, N, A > &other) const │ │ │ │ │ -Definition arraylist.hh:647 │ │ │ │ │ +Get an iterator pointing to the end of the list. │ │ │ │ │ +Definition sllist.hh:774 │ │ │ │ │ +Dune::SLList::beginModify │ │ │ │ │ +ModifyIterator beginModify() │ │ │ │ │ +Get an iterator capable of deleting and inserting elements. │ │ │ │ │ +Definition sllist.hh:787 │ │ │ │ │ +Dune::SLList<_RemoteIndex,_Allocator_>::const_iterator │ │ │ │ │ +SLListConstIterator< RemoteIndex, Allocator > const_iterator │ │ │ │ │ +The constant iterator of the list. │ │ │ │ │ +Definition sllist.hh:74 │ │ │ │ │ +Dune::SLList::ModifyIterator │ │ │ │ │ +SLListModifyIterator< T, A > ModifyIterator │ │ │ │ │ +The type of the iterator capable of deletion and insertion. │ │ │ │ │ +Definition sllist.hh:103 │ │ │ │ │ +Dune::SLList::begin │ │ │ │ │ +iterator begin() │ │ │ │ │ +Get an iterator pointing to the first element in the list. │ │ │ │ │ +Definition sllist.hh:762 │ │ │ │ │ +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:637 │ │ │ │ │ +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:237 │ │ │ │ │ +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:259 │ │ │ │ │ +Dune::IndicesSyncer::Iterators::Iterators │ │ │ │ │ +Iterators() │ │ │ │ │ +Default constructor. │ │ │ │ │ +Definition indicessyncer.hh:555 │ │ │ │ │ +Dune::IndicesSyncer::RemoteIndices │ │ │ │ │ +Dune::RemoteIndices< ParallelIndexSet > RemoteIndices │ │ │ │ │ +Type of the remote indices. │ │ │ │ │ +Definition indicessyncer.hh:59 │ │ │ │ │ +Dune::IndicesSyncer::Iterators::isOld │ │ │ │ │ +bool isOld() const │ │ │ │ │ +Was this entry already in the remote index list before the sync process? │ │ │ │ │ +Definition indicessyncer.hh:592 │ │ │ │ │ +Dune::IndicesSyncer::MessageInformation::publish │ │ │ │ │ +int publish │ │ │ │ │ +The number of indices we publish for the other process. │ │ │ │ │ +Definition indicessyncer.hh:126 │ │ │ │ │ +Dune::repairLocalIndexPointers │ │ │ │ │ +void repairLocalIndexPointers(std::map< int, SLList< std::pair< typename T:: │ │ │ │ │ +GlobalIndex, typename T::LocalIndex::Attribute >, A > > &globalMap, │ │ │ │ │ +RemoteIndices< T, A1 > &remoteIndices, const T &indexSet) │ │ │ │ │ +Repair the pointers to the local indices in the remote indices. │ │ │ │ │ +Definition indicessyncer.hh:487 │ │ │ │ │ +Dune::IndicesSyncer::Iterators::isAtEnd │ │ │ │ │ +bool isAtEnd() const │ │ │ │ │ +Are we at the end of the list? │ │ │ │ │ +Definition indicessyncer.hh:614 │ │ │ │ │ +Dune::IndicesSyncer::GlobalIndex │ │ │ │ │ +ParallelIndexSet::GlobalIndex GlobalIndex │ │ │ │ │ +Type of the global index used in the index set. │ │ │ │ │ +Definition indicessyncer.hh:51 │ │ │ │ │ +Dune::IndicesSyncer::MessageInformation::pairs │ │ │ │ │ +int pairs │ │ │ │ │ +The number of pairs (attribute and process number) we publish to the neighbour │ │ │ │ │ +process. │ │ │ │ │ +Definition indicessyncer.hh:131 │ │ │ │ │ +Dune::IndicesSyncer::Iterators::attribute │ │ │ │ │ +Attribute & attribute() const │ │ │ │ │ +Dune::IndicesSyncer::Iterators::operator++ │ │ │ │ │ +Iterators & operator++() │ │ │ │ │ +Increment all iteraors. │ │ │ │ │ +Definition indicessyncer.hh:560 │ │ │ │ │ +Dune::IndicesSyncer::Attribute │ │ │ │ │ +ParallelIndexSet::LocalIndex::Attribute Attribute │ │ │ │ │ +Type of the attribute used in the index set. │ │ │ │ │ +Definition indicessyncer.hh:54 │ │ │ │ │ +Dune::IndicesSyncer::Iterators::globalIndexPair │ │ │ │ │ +std::pair< GlobalIndex, Attribute > & globalIndexPair() const │ │ │ │ │ +Get the global index of the remote index at current position. │ │ │ │ │ +Definition indicessyncer.hh:586 │ │ │ │ │ +Dune::IndicesSyncer::IndicesSyncer │ │ │ │ │ +IndicesSyncer(ParallelIndexSet &indexSet, RemoteIndices &remoteIndices) │ │ │ │ │ +Constructor. │ │ │ │ │ +Definition indicessyncer.hh:536 │ │ │ │ │ +Dune::IndicesSyncer::Iterators::reset │ │ │ │ │ +void reset(RemoteIndexList &remoteIndices, GlobalIndexList &globalIndices, │ │ │ │ │ +BoolList &booleans) │ │ │ │ │ +Reset all the underlying iterators. │ │ │ │ │ +Definition indicessyncer.hh:598 │ │ │ │ │ +Dune::IndicesSyncer::DefaultNumberer::operator() │ │ │ │ │ +std::size_t operator()(const GlobalIndex &global) │ │ │ │ │ +Provide the local index, always std::numeric_limits::max() │ │ │ │ │ +Definition indicessyncer.hh:145 │ │ │ │ │ +Dune::IndicesSyncer::ParallelIndexSet │ │ │ │ │ +T ParallelIndexSet │ │ │ │ │ +The type of the index set. │ │ │ │ │ +Definition indicessyncer.hh:45 │ │ │ │ │ +Dune::IndicesSyncer::Iterators::isNotAtEnd │ │ │ │ │ +bool isNotAtEnd() const │ │ │ │ │ +Are we not at the end of the list? │ │ │ │ │ +Definition indicessyncer.hh:608 │ │ │ │ │ +Dune::ParallelIndexSet::GlobalIndex │ │ │ │ │ +TG GlobalIndex │ │ │ │ │ +the type of the global index. This type has to provide at least a operator< for │ │ │ │ │ +sorting. │ │ │ │ │ +Definition indexset.hh:226 │ │ │ │ │ +Dune::storeGlobalIndicesOfRemoteIndices │ │ │ │ │ +void storeGlobalIndicesOfRemoteIndices(std::map< int, SLList< std::pair< │ │ │ │ │ +typename T::GlobalIndex, typename T::LocalIndex::Attribute >, A > > &globalMap, │ │ │ │ │ +const RemoteIndices< T, A1 > &remoteIndices) │ │ │ │ │ +Stores the corresponding global indices of the remote index information. │ │ │ │ │ +Definition indicessyncer.hh:461 │ │ │ │ │ +Dune::IndicesSyncer::sync │ │ │ │ │ +void sync() │ │ │ │ │ +Sync the index set. │ │ │ │ │ +Definition indicessyncer.hh:728 │ │ │ │ │ +Dune::ParallelIndexSet::seqNo │ │ │ │ │ +int seqNo() const │ │ │ │ │ +Get the internal sequence number. │ │ │ │ │ +Dune::IndicesSyncer::IndexPair │ │ │ │ │ +ParallelIndexSet::IndexPair IndexPair │ │ │ │ │ +The type of the index pair. │ │ │ │ │ +Definition indicessyncer.hh:48 │ │ │ │ │ +Dune::IndicesSyncer::Iterators::remoteIndex │ │ │ │ │ +RemoteIndex & remoteIndex() const │ │ │ │ │ +Get the remote index at current position. │ │ │ │ │ +Definition indicessyncer.hh:579 │ │ │ │ │ +Dune::IndicesSyncer::MessageInformation::MessageInformation │ │ │ │ │ +MessageInformation() │ │ │ │ │ +Definition indicessyncer.hh:122 │ │ │ │ │ +Dune::IndicesSyncer::Iterators::insert │ │ │ │ │ +void insert(const RemoteIndex &index, const std::pair< GlobalIndex, Attribute > │ │ │ │ │ +&global) │ │ │ │ │ +Insert a new remote index to the underlying remote index list. │ │ │ │ │ +Definition indicessyncer.hh:569 │ │ │ │ │ +Dune::dvverb │ │ │ │ │ +DVVerbType dvverb(std::cout) │ │ │ │ │ +stream for very verbose output. │ │ │ │ │ +Definition stdstreams.hh:95 │ │ │ │ │ +Dune::dverb │ │ │ │ │ +DVerbType dverb(std::cout) │ │ │ │ │ +Singleton of verbose debug stream. │ │ │ │ │ +Definition stdstreams.hh:116 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::ArrayListIterator │ │ │ │ │ -A random access iterator for the Dune::ArrayList class. │ │ │ │ │ -Definition arraylist.hh:255 │ │ │ │ │ -Dune::ArrayListIterator::position │ │ │ │ │ -size_type position() │ │ │ │ │ -Definition arraylist.hh:331 │ │ │ │ │ -Dune::ArrayListIterator::MemberType │ │ │ │ │ -A::value_type MemberType │ │ │ │ │ -The member type. │ │ │ │ │ -Definition arraylist.hh:263 │ │ │ │ │ -Dune::ArrayListIterator::ArrayListIterator │ │ │ │ │ -ArrayListIterator() │ │ │ │ │ -Standard constructor. │ │ │ │ │ -Definition arraylist.hh:340 │ │ │ │ │ -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:370 │ │ │ │ │ -Dune::ConstArrayListIterator::chunkSize_ │ │ │ │ │ -static constexpr int chunkSize_ │ │ │ │ │ -The number of elements in one chunk of the list. │ │ │ │ │ -Definition arraylist.hh:394 │ │ │ │ │ -Dune::ConstArrayListIterator::reference │ │ │ │ │ -typename A::value_type & reference │ │ │ │ │ -Definition arraylist.hh:385 │ │ │ │ │ -Dune::ConstArrayListIterator::ConstArrayListIterator │ │ │ │ │ -ConstArrayListIterator() │ │ │ │ │ -Definition arraylist.hh:431 │ │ │ │ │ -Dune::ConstArrayListIterator::MemberType │ │ │ │ │ -A::value_type MemberType │ │ │ │ │ -The member type. │ │ │ │ │ -Definition arraylist.hh:379 │ │ │ │ │ -Dune::ConstArrayListIterator::difference_type │ │ │ │ │ -A::difference_type difference_type │ │ │ │ │ -Definition arraylist.hh:381 │ │ │ │ │ -Dune::ConstArrayListIterator::const_reference │ │ │ │ │ -typename A::value_type const & const_reference │ │ │ │ │ -Definition arraylist.hh:387 │ │ │ │ │ -Dune::ConstArrayListIterator::size_type │ │ │ │ │ -A::size_type size_type │ │ │ │ │ -Definition arraylist.hh:383 │ │ │ │ │ -Dune::ArrayList │ │ │ │ │ -A dynamically growing random access list. │ │ │ │ │ -Definition arraylist.hh:62 │ │ │ │ │ -Dune::ArrayList::value_type │ │ │ │ │ -T value_type │ │ │ │ │ -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:434 │ │ │ │ │ +Dune::MPITraits::getType │ │ │ │ │ +static MPI_Datatype getType() │ │ │ │ │ +Definition mpitraits.hh:48 │ │ │ │ │ +Dune::IndexPair │ │ │ │ │ +A pair consisting of a global and local index. │ │ │ │ │ +Definition indexset.hh:85 │ │ │ │ │ +Dune::IndicesSyncer │ │ │ │ │ +Class for recomputing missing indices of a distributed index set. │ │ │ │ │ +Definition indicessyncer.hh:41 │ │ │ │ │ +Dune::ParallelLocalIndex │ │ │ │ │ +An index present on the local process with an additional attribute flag. │ │ │ │ │ +Definition plocalindex.hh:49 │ │ │ │ │ +Dune::RemoteIndices │ │ │ │ │ +The indices present on remote processes. │ │ │ │ │ +Definition remoteindices.hh:189 │ │ │ │ │ +Dune::RemoteIndices::communicator │ │ │ │ │ +MPI_Comm communicator() const │ │ │ │ │ +Get the mpi communicator used. │ │ │ │ │ +Definition remoteindices.hh:1696 │ │ │ │ │ +Dune::RemoteIndices::end │ │ │ │ │ +const_iterator end() const │ │ │ │ │ +Get an iterator over all remote index lists. │ │ │ │ │ +Definition remoteindices.hh:1529 │ │ │ │ │ +Dune::RemoteIndices::neighbours │ │ │ │ │ +int neighbours() const │ │ │ │ │ +Get the number of processors we share indices with. │ │ │ │ │ +Definition remoteindices.hh:1446 │ │ │ │ │ +Dune::RemoteIndices::Allocator │ │ │ │ │ +typename std::allocator_traits< A >::template rebind_alloc< RemoteIndex > │ │ │ │ │ +Allocator │ │ │ │ │ +The type of the allocator for the remote index list. │ │ │ │ │ +Definition remoteindices.hh:237 │ │ │ │ │ +Dune::RemoteIndices::begin │ │ │ │ │ +const_iterator begin() const │ │ │ │ │ +Get an iterator over all remote index lists. │ │ │ │ │ +Definition remoteindices.hh:1522 │ │ │ │ │ +Dune::RemoteIndex │ │ │ │ │ +Information about an index residing on another processor. │ │ │ │ │ +Definition remoteindices.hh:73 │ │ │ │ │ +Dune::SLListIterator │ │ │ │ │ +A mutable iterator for the SLList. │ │ │ │ │ +Definition sllist.hh:271 │ │ │ │ │ +Dune::SLList │ │ │ │ │ +A single linked list. │ │ │ │ │ +Definition sllist.hh:44 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00059.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: version.hh File Reference │ │ │ │ +dune-common: mpipack.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,781 +65,51 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Macros
│ │ │ │ -
version.hh File Reference
│ │ │ │ +Classes | │ │ │ │ +Namespaces
│ │ │ │ +
mpipack.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

Various macros to work with Dune module version numbers. │ │ │ │ +

See MPI_Pack. │ │ │ │ More...

│ │ │ │ - │ │ │ │ +
#include <vector>
│ │ │ │ +#include <mpi.h>
│ │ │ │ +#include <dune/common/parallel/mpicommunication.hh>
│ │ │ │ +#include <dune/common/parallel/mpidata.hh>
│ │ │ │ +
│ │ │ │

Go to the source code of this file.

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

│ │ │ │ -Macros

#define DUNE_VERSION_JOIN(module, type)   module ## _VERSION_ ## type
 Constructs the preprocessor name used in config.h to hold version numbers.
 
#define DUNE_VERSION_EQUAL(module, major, minor)
 True if 'module' has the version major.minor.
 
#define DUNE_VERSION_EQUAL_REV(module, major, minor, revision)
 True if 'module' has the version major.minor.revision.
 
#define DUNE_VERSION_GTE(module, major, minor)
 True if 'module' has the version major.minor or greater.
 
#define DUNE_VERSION_LT(module, major, minor)    ! DUNE_VERSION_GTE(module,major,minor)
 True if 'module' has a version less than major.minor.
 
#define DUNE_VERSION_NEWER(module, major, minor)    DUNE_VERSION_GTE(module,major,minor)
 True if 'module' has the version major.minor or newer.
 
#define DUNE_VERSION_GT(module, major, minor)
 True if 'module' has a version greater than major.minor.
 
#define DUNE_VERSION_LTE(module, major, minor)    ! DUNE_VERSION_GT(module,major,minor)
 True if 'module' has a version less than or equal to major.minor.
 
#define DUNE_VERSION_GTE_REV(module, major, minor, revision)
 True if 'module' has the version major.minor.revision or greater.
 
#define DUNE_VERSION_LT_REV(module, major, minor, revision)    ! DUNE_VERSION_GTE_REV(module,major,minor,revision)
 True if 'module' has a version lower than major.minor.revision.
 
#define DUNE_VERSION_NEWER_REV(module, major, minor, revision)    DUNE_VERSION_GTE_REV(module,major,minor,revision)
 True if 'module' has the version major.minor.revision or newer.
 
#define DUNE_VERSION_GT_REV(module, major, minor, revision)
 True if 'module' has a greater version than major.minor.revision.
 
#define DUNE_VERSION_LTE_REV(module, major, minor, revision)    ! DUNE_VERSION_GT_REV(module,major,minor,revision)
 True if 'module' has a version lower or equal to major.minor.revision.
 
#define DUNE_VERSION_ID(major, minor, revision)    ((unsigned int)((major << 24) + (minor << 16) + revision))
 Compute a unique uint id from the major, minor, and revision numbers.
 
#define DUNE_MODULE_VERSION_ID(module)    DUNE_VERSION_ID( DUNE_VERSION_JOIN(module,MAJOR), DUNE_VERSION_JOIN(module,MINOR), DUNE_VERSION_JOIN(module,REVISION) )
 Compute a unique uint id for the given module.
 

│ │ │ │ +Classes

class  Dune::MPIPack
 
struct  Dune::MPIData< P, std::enable_if_t< std::is_same< std::remove_const_t< P >, MPIPack >::value > >
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ +Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │

Detailed Description

│ │ │ │ -

Various macros to work with Dune module version numbers.

│ │ │ │ -

Macro Definition Documentation

│ │ │ │ - │ │ │ │ -

◆ DUNE_MODULE_VERSION_ID

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_MODULE_VERSION_ID( module)    DUNE_VERSION_ID( DUNE_VERSION_JOIN(module,MAJOR), DUNE_VERSION_JOIN(module,MINOR), DUNE_VERSION_JOIN(module,REVISION) )
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

Compute a unique uint id for the given module.

│ │ │ │ -

For the DUNE core modules you need to use the following module names:

    │ │ │ │ -
  • DUNE_COMMON for dune-common
  • │ │ │ │ -
  • DUNE_GRID for dune-grid
  • │ │ │ │ -
  • DUNE_GEOMETRY for dune-geometry
  • │ │ │ │ -
  • DUNE_ISTL for dune-istl
  • │ │ │ │ -
  • DUNE_LOCALFUNCTIONS for dune-localfunctions
  • │ │ │ │ -
│ │ │ │ -

For external DUNE modules, you should capitalize the name and replace '-' by underscores. For example for the module foo-bar you need to use FOO_BAR as module name in the context of this macro.

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

◆ DUNE_VERSION_EQUAL

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_VERSION_EQUAL( module,
 major,
 minor 
)
│ │ │ │ -
│ │ │ │ -Value:
((DUNE_VERSION_JOIN(module,MAJOR) == major) && \
│ │ │ │ -
(DUNE_VERSION_JOIN(module,MINOR) == minor))
│ │ │ │ -
#define DUNE_VERSION_JOIN(module, type)
Constructs the preprocessor name used in config.h to hold version numbers.
Definition version.hh:28
│ │ │ │ -
│ │ │ │ -

True if 'module' has the version major.minor.

│ │ │ │ -

For the DUNE core modules you need to use the following module names:

    │ │ │ │ -
  • DUNE_COMMON for dune-common
  • │ │ │ │ -
  • DUNE_GRID for dune-grid
  • │ │ │ │ -
  • DUNE_GEOMETRY for dune-geometry
  • │ │ │ │ -
  • DUNE_ISTL for dune-istl
  • │ │ │ │ -
  • DUNE_LOCALFUNCTIONS for dune-localfunctions
  • │ │ │ │ -
│ │ │ │ -

For external DUNE modules, you should capitalize the name and replace '-' by underscores. For example for the module foo-bar you need to use FOO_BAR as module name in the context of this macro.

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

◆ DUNE_VERSION_EQUAL_REV

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_VERSION_EQUAL_REV( module,
 major,
 minor,
 revision 
)
│ │ │ │ -
│ │ │ │ -Value:
( DUNE_VERSION_EQUAL(module,major,minor) && \
│ │ │ │ -
(DUNE_VERSION_JOIN(module,REVISION) == revision))
│ │ │ │ -
#define DUNE_VERSION_EQUAL(module, major, minor)
True if 'module' has the version major.minor.
Definition version.hh:44
│ │ │ │ -
│ │ │ │ -

True if 'module' has the version major.minor.revision.

│ │ │ │ -

For the DUNE core modules you need to use the following module names:

    │ │ │ │ -
  • DUNE_COMMON for dune-common
  • │ │ │ │ -
  • DUNE_GRID for dune-grid
  • │ │ │ │ -
  • DUNE_GEOMETRY for dune-geometry
  • │ │ │ │ -
  • DUNE_ISTL for dune-istl
  • │ │ │ │ -
  • DUNE_LOCALFUNCTIONS for dune-localfunctions
  • │ │ │ │ -
│ │ │ │ -

For external DUNE modules, you should capitalize the name and replace '-' by underscores. For example for the module foo-bar you need to use FOO_BAR as module name in the context of this macro.

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

◆ DUNE_VERSION_GT

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_VERSION_GT( module,
 major,
 minor 
)
│ │ │ │ -
│ │ │ │ -Value:
((DUNE_VERSION_JOIN(module,MAJOR) > major) \
│ │ │ │ -
|| ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN(module,MINOR) > minor)))
│ │ │ │ -
│ │ │ │ -

True if 'module' has a version greater than major.minor.

│ │ │ │ -

For the DUNE core modules you need to use the following module names:

    │ │ │ │ -
  • DUNE_COMMON for dune-common
  • │ │ │ │ -
  • DUNE_GRID for dune-grid
  • │ │ │ │ -
  • DUNE_GEOMETRY for dune-geometry
  • │ │ │ │ -
  • DUNE_ISTL for dune-istl
  • │ │ │ │ -
  • DUNE_LOCALFUNCTIONS for dune-localfunctions
  • │ │ │ │ -
│ │ │ │ -

For external DUNE modules, you should capitalize the name and replace '-' by underscores. For example for the module foo-bar you need to use FOO_BAR as module name in the context of this macro.

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

◆ DUNE_VERSION_GT_REV

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_VERSION_GT_REV( module,
 major,
 minor,
 revision 
)
│ │ │ │ -
│ │ │ │ -Value:
((DUNE_VERSION_JOIN(module,MAJOR) > major) \
│ │ │ │ -
|| ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN(module,MINOR) > minor)) \
│ │ │ │ -
|| ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN(module,MINOR) == minor) \
│ │ │ │ -
&& (DUNE_VERSION_JOIN(module,REVISION) > revision)))
│ │ │ │ -
│ │ │ │ -

True if 'module' has a greater version than major.minor.revision.

│ │ │ │ -

For the DUNE core modules you need to use the following module names:

    │ │ │ │ -
  • DUNE_COMMON for dune-common
  • │ │ │ │ -
  • DUNE_GRID for dune-grid
  • │ │ │ │ -
  • DUNE_GEOMETRY for dune-geometry
  • │ │ │ │ -
  • DUNE_ISTL for dune-istl
  • │ │ │ │ -
  • DUNE_LOCALFUNCTIONS for dune-localfunctions
  • │ │ │ │ -
│ │ │ │ -

For external DUNE modules, you should capitalize the name and replace '-' by underscores. For example for the module foo-bar you need to use FOO_BAR as module name in the context of this macro.

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

◆ DUNE_VERSION_GTE

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_VERSION_GTE( module,
 major,
 minor 
)
│ │ │ │ -
│ │ │ │ -Value:
((DUNE_VERSION_JOIN(module,MAJOR) > major) \
│ │ │ │ -
|| ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN(module,MINOR) >= minor)))
│ │ │ │ -
│ │ │ │ -

True if 'module' has the version major.minor or greater.

│ │ │ │ -

For the DUNE core modules you need to use the following module names:

    │ │ │ │ -
  • DUNE_COMMON for dune-common
  • │ │ │ │ -
  • DUNE_GRID for dune-grid
  • │ │ │ │ -
  • DUNE_GEOMETRY for dune-geometry
  • │ │ │ │ -
  • DUNE_ISTL for dune-istl
  • │ │ │ │ -
  • DUNE_LOCALFUNCTIONS for dune-localfunctions
  • │ │ │ │ -
│ │ │ │ -

For external DUNE modules, you should capitalize the name and replace '-' by underscores. For example for the module foo-bar you need to use FOO_BAR as module name in the context of this macro.

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

◆ DUNE_VERSION_GTE_REV

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_VERSION_GTE_REV( module,
 major,
 minor,
 revision 
)
│ │ │ │ -
│ │ │ │ -Value:
((DUNE_VERSION_JOIN(module,MAJOR) > major) \
│ │ │ │ -
|| ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN(module,MINOR) > minor)) \
│ │ │ │ -
|| ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN(module,MINOR) == minor) \
│ │ │ │ -
&& (DUNE_VERSION_JOIN(module,REVISION) >= revision)))
│ │ │ │ -
│ │ │ │ -

True if 'module' has the version major.minor.revision or greater.

│ │ │ │ -

For the DUNE core modules you need to use the following module names:

    │ │ │ │ -
  • DUNE_COMMON for dune-common
  • │ │ │ │ -
  • DUNE_GRID for dune-grid
  • │ │ │ │ -
  • DUNE_GEOMETRY for dune-geometry
  • │ │ │ │ -
  • DUNE_ISTL for dune-istl
  • │ │ │ │ -
  • DUNE_LOCALFUNCTIONS for dune-localfunctions
  • │ │ │ │ -
│ │ │ │ -

For external DUNE modules, you should capitalize the name and replace '-' by underscores. For example for the module foo-bar you need to use FOO_BAR as module name in the context of this macro.

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

◆ DUNE_VERSION_ID

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_VERSION_ID( major,
 minor,
 revision 
)    ((unsigned int)((major << 24) + (minor << 16) + revision))
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

Compute a unique uint id from the major, minor, and revision numbers.

│ │ │ │ -

For the DUNE core modules you need to use the following module names:

    │ │ │ │ -
  • DUNE_COMMON for dune-common
  • │ │ │ │ -
  • DUNE_GRID for dune-grid
  • │ │ │ │ -
  • DUNE_GEOMETRY for dune-geometry
  • │ │ │ │ -
  • DUNE_ISTL for dune-istl
  • │ │ │ │ -
  • DUNE_LOCALFUNCTIONS for dune-localfunctions
  • │ │ │ │ -
│ │ │ │ -

For external DUNE modules, you should capitalize the name and replace '-' by underscores. For example for the module foo-bar you need to use FOO_BAR as module name in the context of this macro.

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

◆ DUNE_VERSION_JOIN

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_VERSION_JOIN( module,
 type 
)   module ## _VERSION_ ## type
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

Constructs the preprocessor name used in config.h to hold version numbers.

│ │ │ │ -

For the DUNE core modules you need to use the following module names:

    │ │ │ │ -
  • DUNE_COMMON for dune-common
  • │ │ │ │ -
  • DUNE_GRID for dune-grid
  • │ │ │ │ -
  • DUNE_GEOMETRY for dune-geometry
  • │ │ │ │ -
  • DUNE_ISTL for dune-istl
  • │ │ │ │ -
  • DUNE_LOCALFUNCTIONS for dune-localfunctions
  • │ │ │ │ -
│ │ │ │ -

For external DUNE modules, you should capitalize the name and replace '-' by underscores. For example for the module foo-bar you need to use FOO_BAR as module name in the context of this macro.

│ │ │ │ -
Parameters
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
moduleThe name of the Dune module
typeThe version number type, one of MAJOR, MINOR, or REVISION
│ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ DUNE_VERSION_LT

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_VERSION_LT( module,
 major,
 minor 
)    ! DUNE_VERSION_GTE(module,major,minor)
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

True if 'module' has a version less than major.minor.

│ │ │ │ -

For the DUNE core modules you need to use the following module names:

    │ │ │ │ -
  • DUNE_COMMON for dune-common
  • │ │ │ │ -
  • DUNE_GRID for dune-grid
  • │ │ │ │ -
  • DUNE_GEOMETRY for dune-geometry
  • │ │ │ │ -
  • DUNE_ISTL for dune-istl
  • │ │ │ │ -
  • DUNE_LOCALFUNCTIONS for dune-localfunctions
  • │ │ │ │ -
│ │ │ │ -

For external DUNE modules, you should capitalize the name and replace '-' by underscores. For example for the module foo-bar you need to use FOO_BAR as module name in the context of this macro.

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

◆ DUNE_VERSION_LT_REV

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_VERSION_LT_REV( module,
 major,
 minor,
 revision 
)    ! DUNE_VERSION_GTE_REV(module,major,minor,revision)
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

True if 'module' has a version lower than major.minor.revision.

│ │ │ │ -

For the DUNE core modules you need to use the following module names:

    │ │ │ │ -
  • DUNE_COMMON for dune-common
  • │ │ │ │ -
  • DUNE_GRID for dune-grid
  • │ │ │ │ -
  • DUNE_GEOMETRY for dune-geometry
  • │ │ │ │ -
  • DUNE_ISTL for dune-istl
  • │ │ │ │ -
  • DUNE_LOCALFUNCTIONS for dune-localfunctions
  • │ │ │ │ -
│ │ │ │ -

For external DUNE modules, you should capitalize the name and replace '-' by underscores. For example for the module foo-bar you need to use FOO_BAR as module name in the context of this macro.

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

◆ DUNE_VERSION_LTE

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_VERSION_LTE( module,
 major,
 minor 
)    ! DUNE_VERSION_GT(module,major,minor)
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

True if 'module' has a version less than or equal to major.minor.

│ │ │ │ -

For the DUNE core modules you need to use the following module names:

    │ │ │ │ -
  • DUNE_COMMON for dune-common
  • │ │ │ │ -
  • DUNE_GRID for dune-grid
  • │ │ │ │ -
  • DUNE_GEOMETRY for dune-geometry
  • │ │ │ │ -
  • DUNE_ISTL for dune-istl
  • │ │ │ │ -
  • DUNE_LOCALFUNCTIONS for dune-localfunctions
  • │ │ │ │ -
│ │ │ │ -

For external DUNE modules, you should capitalize the name and replace '-' by underscores. For example for the module foo-bar you need to use FOO_BAR as module name in the context of this macro.

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

◆ DUNE_VERSION_LTE_REV

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_VERSION_LTE_REV( module,
 major,
 minor,
 revision 
)    ! DUNE_VERSION_GT_REV(module,major,minor,revision)
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

True if 'module' has a version lower or equal to major.minor.revision.

│ │ │ │ -

For the DUNE core modules you need to use the following module names:

    │ │ │ │ -
  • DUNE_COMMON for dune-common
  • │ │ │ │ -
  • DUNE_GRID for dune-grid
  • │ │ │ │ -
  • DUNE_GEOMETRY for dune-geometry
  • │ │ │ │ -
  • DUNE_ISTL for dune-istl
  • │ │ │ │ -
  • DUNE_LOCALFUNCTIONS for dune-localfunctions
  • │ │ │ │ -
│ │ │ │ -

For external DUNE modules, you should capitalize the name and replace '-' by underscores. For example for the module foo-bar you need to use FOO_BAR as module name in the context of this macro.

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

◆ DUNE_VERSION_NEWER

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_VERSION_NEWER( module,
 major,
 minor 
)    DUNE_VERSION_GTE(module,major,minor)
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

True if 'module' has the version major.minor or newer.

│ │ │ │ -
Note
Deprecated, use DUNE_VERSION_GTE instead.
│ │ │ │ -

For the DUNE core modules you need to use the following module names:

    │ │ │ │ -
  • DUNE_COMMON for dune-common
  • │ │ │ │ -
  • DUNE_GRID for dune-grid
  • │ │ │ │ -
  • DUNE_GEOMETRY for dune-geometry
  • │ │ │ │ -
  • DUNE_ISTL for dune-istl
  • │ │ │ │ -
  • DUNE_LOCALFUNCTIONS for dune-localfunctions
  • │ │ │ │ -
│ │ │ │ -

For external DUNE modules, you should capitalize the name and replace '-' by underscores. For example for the module foo-bar you need to use FOO_BAR as module name in the context of this macro.

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

◆ DUNE_VERSION_NEWER_REV

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_VERSION_NEWER_REV( module,
 major,
 minor,
 revision 
)    DUNE_VERSION_GTE_REV(module,major,minor,revision)
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

True if 'module' has the version major.minor.revision or newer.

│ │ │ │ -
Note
Deprecated, use DUNE_VERSION_GTE_REV instead.
│ │ │ │ -

For the DUNE core modules you need to use the following module names:

    │ │ │ │ -
  • DUNE_COMMON for dune-common
  • │ │ │ │ -
  • DUNE_GRID for dune-grid
  • │ │ │ │ -
  • DUNE_GEOMETRY for dune-geometry
  • │ │ │ │ -
  • DUNE_ISTL for dune-istl
  • │ │ │ │ -
  • DUNE_LOCALFUNCTIONS for dune-localfunctions
  • │ │ │ │ -
│ │ │ │ -

For external DUNE modules, you should capitalize the name and replace '-' by underscores. For example for the module foo-bar you need to use FOO_BAR as module name in the context of this macro.

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

See MPI_Pack.

│ │ │ │ +

This Wrapper class takes care of the memory management and provides methods to pack and unpack objects. All objects that can be used for MPI communication can also be packed and unpacked to/from MPIPack.

│ │ │ │ +
Author
Nils-Arne Dreier
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,345 +6,37 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Macros │ │ │ │ │ -version.hh File Reference │ │ │ │ │ -Various macros to work with Dune module version numbers. More... │ │ │ │ │ + * parallel │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +mpipack.hh File Reference │ │ │ │ │ +Common » Parallel_Communication │ │ │ │ │ +See MPI_Pack. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ - Macros │ │ │ │ │ -#define DUNE_VERSION_JOIN(module, type)   module ## _VERSION_ ## type │ │ │ │ │ -  Constructs the preprocessor name used in config.h to hold version numbers. │ │ │ │ │ + Classes │ │ │ │ │ + class  Dune::MPIPack │ │ │ │ │   │ │ │ │ │ -#define DUNE_VERSION_EQUAL(module, major, minor) │ │ │ │ │ -  True if 'module' has the version major.minor. │ │ │ │ │ +struct  Dune::MPIData<_P,_std::enable_if_t<_std::is_same<_std::remove_const_t< │ │ │ │ │ + P_>,_MPIPack_>::value_>_> │ │ │ │ │   │ │ │ │ │ -#define DUNE_VERSION_EQUAL_REV(module, major, minor, revision) │ │ │ │ │ -  True if 'module' has the version major.minor.revision. │ │ │ │ │ -  │ │ │ │ │ -#define DUNE_VERSION_GTE(module, major, minor) │ │ │ │ │ -  True if 'module' has the version major.minor or greater. │ │ │ │ │ -  │ │ │ │ │ -#define DUNE_VERSION_LT(module, major, minor)    ! DUNE_VERSION_GTE(module,major,minor) │ │ │ │ │ -  True if 'module' has a version less than major.minor. │ │ │ │ │ -  │ │ │ │ │ -#define DUNE_VERSION_NEWER(module, major, minor)    DUNE_VERSION_GTE(module,major,minor) │ │ │ │ │ -  True if 'module' has the version major.minor or newer. │ │ │ │ │ -  │ │ │ │ │ -#define DUNE_VERSION_GT(module, major, minor) │ │ │ │ │ -  True if 'module' has a version greater than major.minor. │ │ │ │ │ -  │ │ │ │ │ -#define DUNE_VERSION_LTE(module, major, minor)    ! DUNE_VERSION_GT(module,major,minor) │ │ │ │ │ -  True if 'module' has a version less than or equal to major.minor. │ │ │ │ │ -  │ │ │ │ │ -#define DUNE_VERSION_GTE_REV(module, major, minor, revision) │ │ │ │ │ -  True if 'module' has the version major.minor.revision or greater. │ │ │ │ │ -  │ │ │ │ │ -#define DUNE_VERSION_LT_REV(module, major, minor, revision)    ! DUNE_VERSION_GTE_REV │ │ │ │ │ - (module,major,minor,revision) │ │ │ │ │ -  True if 'module' has a version lower than major.minor.revision. │ │ │ │ │ -  │ │ │ │ │ -#define DUNE_VERSION_NEWER_REV(module, major, minor, revision)    DUNE_VERSION_GTE_REV │ │ │ │ │ - (module,major,minor,revision) │ │ │ │ │ -  True if 'module' has the version major.minor.revision or newer. │ │ │ │ │ -  │ │ │ │ │ -#define DUNE_VERSION_GT_REV(module, major, minor, revision) │ │ │ │ │ -  True if 'module' has a greater version than major.minor.revision. │ │ │ │ │ -  │ │ │ │ │ -#define DUNE_VERSION_LTE_REV(module, major, minor, revision)    ! DUNE_VERSION_GT_REV │ │ │ │ │ - (module,major,minor,revision) │ │ │ │ │ -  True if 'module' has a version lower or equal to major.minor.revision. │ │ │ │ │ -  │ │ │ │ │ -#define DUNE_VERSION_ID(major, minor, revision)    ((unsigned int)((major << 24) + (minor │ │ │ │ │ - << 16) + revision)) │ │ │ │ │ -  Compute a unique uint id from the major, minor, and revision numbers. │ │ │ │ │ -  │ │ │ │ │ -#define DUNE_MODULE_VERSION_ID(module)    DUNE_VERSION_ID( DUNE_VERSION_JOIN │ │ │ │ │ - (module,MAJOR), DUNE_VERSION_JOIN(module,MINOR), DUNE_VERSION_JOIN │ │ │ │ │ - (module,REVISION) ) │ │ │ │ │ -  Compute a unique uint id for the given module. │ │ │ │ │ + Namespaces │ │ │ │ │ +namespace  Dune │ │ │ │ │ +  Dune namespace. │ │ │ │ │   │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Various macros to work with Dune module version numbers. │ │ │ │ │ -***** Macro Definition Documentation ***** │ │ │ │ │ -***** ◆ DUNE_MODULE_VERSION_ID ***** │ │ │ │ │ -#define (  module )     DUNE_VERSION_ID( DUNE_VERSION_JOIN(module,MAJOR), DUNE_VERSION_JOIN │ │ │ │ │ -DUNE_MODULE_VERSION_ID (module,MINOR), DUNE_VERSION_JOIN(module,REVISION) ) │ │ │ │ │ -Compute a unique uint id for the given module. │ │ │ │ │ -For the DUNE core modules you need to use the following module names: │ │ │ │ │ - * DUNE_COMMON for dune-common │ │ │ │ │ - * DUNE_GRID for dune-grid │ │ │ │ │ - * DUNE_GEOMETRY for dune-geometry │ │ │ │ │ - * DUNE_ISTL for dune-istl │ │ │ │ │ - * DUNE_LOCALFUNCTIONS for dune-localfunctions │ │ │ │ │ -For external DUNE modules, you should capitalize the name and replace '-' by │ │ │ │ │ -underscores. For example for the module foo-bar you need to use FOO_BAR as │ │ │ │ │ -module name in the context of this macro. │ │ │ │ │ -***** ◆ DUNE_VERSION_EQUAL ***** │ │ │ │ │ -#define DUNE_VERSION_EQUAL (  module, │ │ │ │ │ -  major, │ │ │ │ │ -  minor  │ │ │ │ │ - ) │ │ │ │ │ -Value: │ │ │ │ │ -((DUNE_VERSION_JOIN(module,MAJOR) == major) && \ │ │ │ │ │ -(DUNE_VERSION_JOIN(module,MINOR) == minor)) │ │ │ │ │ -DUNE_VERSION_JOIN │ │ │ │ │ -#define DUNE_VERSION_JOIN(module, type) │ │ │ │ │ -Constructs the preprocessor name used in config.h to hold version numbers. │ │ │ │ │ -Definition version.hh:28 │ │ │ │ │ -True if 'module' has the version major.minor. │ │ │ │ │ -For the DUNE core modules you need to use the following module names: │ │ │ │ │ - * DUNE_COMMON for dune-common │ │ │ │ │ - * DUNE_GRID for dune-grid │ │ │ │ │ - * DUNE_GEOMETRY for dune-geometry │ │ │ │ │ - * DUNE_ISTL for dune-istl │ │ │ │ │ - * DUNE_LOCALFUNCTIONS for dune-localfunctions │ │ │ │ │ -For external DUNE modules, you should capitalize the name and replace '-' by │ │ │ │ │ -underscores. For example for the module foo-bar you need to use FOO_BAR as │ │ │ │ │ -module name in the context of this macro. │ │ │ │ │ -***** ◆ DUNE_VERSION_EQUAL_REV ***** │ │ │ │ │ -#define DUNE_VERSION_EQUAL_REV (  module, │ │ │ │ │ -  major, │ │ │ │ │ -  minor, │ │ │ │ │ -  revision  │ │ │ │ │ - ) │ │ │ │ │ -Value: │ │ │ │ │ -( DUNE_VERSION_EQUAL(module,major,minor) && \ │ │ │ │ │ -(DUNE_VERSION_JOIN(module,REVISION) == revision)) │ │ │ │ │ -DUNE_VERSION_EQUAL │ │ │ │ │ -#define DUNE_VERSION_EQUAL(module, major, minor) │ │ │ │ │ -True if 'module' has the version major.minor. │ │ │ │ │ -Definition version.hh:44 │ │ │ │ │ -True if 'module' has the version major.minor.revision. │ │ │ │ │ -For the DUNE core modules you need to use the following module names: │ │ │ │ │ - * DUNE_COMMON for dune-common │ │ │ │ │ - * DUNE_GRID for dune-grid │ │ │ │ │ - * DUNE_GEOMETRY for dune-geometry │ │ │ │ │ - * DUNE_ISTL for dune-istl │ │ │ │ │ - * DUNE_LOCALFUNCTIONS for dune-localfunctions │ │ │ │ │ -For external DUNE modules, you should capitalize the name and replace '-' by │ │ │ │ │ -underscores. For example for the module foo-bar you need to use FOO_BAR as │ │ │ │ │ -module name in the context of this macro. │ │ │ │ │ -***** ◆ DUNE_VERSION_GT ***** │ │ │ │ │ -#define DUNE_VERSION_GT (  module, │ │ │ │ │ -  major, │ │ │ │ │ -  minor  │ │ │ │ │ - ) │ │ │ │ │ -Value: │ │ │ │ │ -((DUNE_VERSION_JOIN(module,MAJOR) > major) \ │ │ │ │ │ -|| ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN │ │ │ │ │ -(module,MINOR) > minor))) │ │ │ │ │ -True if 'module' has a version greater than major.minor. │ │ │ │ │ -For the DUNE core modules you need to use the following module names: │ │ │ │ │ - * DUNE_COMMON for dune-common │ │ │ │ │ - * DUNE_GRID for dune-grid │ │ │ │ │ - * DUNE_GEOMETRY for dune-geometry │ │ │ │ │ - * DUNE_ISTL for dune-istl │ │ │ │ │ - * DUNE_LOCALFUNCTIONS for dune-localfunctions │ │ │ │ │ -For external DUNE modules, you should capitalize the name and replace '-' by │ │ │ │ │ -underscores. For example for the module foo-bar you need to use FOO_BAR as │ │ │ │ │ -module name in the context of this macro. │ │ │ │ │ -***** ◆ DUNE_VERSION_GT_REV ***** │ │ │ │ │ -#define DUNE_VERSION_GT_REV (  module, │ │ │ │ │ -  major, │ │ │ │ │ -  minor, │ │ │ │ │ -  revision  │ │ │ │ │ - ) │ │ │ │ │ -Value: │ │ │ │ │ -((DUNE_VERSION_JOIN(module,MAJOR) > major) \ │ │ │ │ │ -|| ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN │ │ │ │ │ -(module,MINOR) > minor)) \ │ │ │ │ │ -|| ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN │ │ │ │ │ -(module,MINOR) == minor) \ │ │ │ │ │ -&& (DUNE_VERSION_JOIN(module,REVISION) > revision))) │ │ │ │ │ -True if 'module' has a greater version than major.minor.revision. │ │ │ │ │ -For the DUNE core modules you need to use the following module names: │ │ │ │ │ - * DUNE_COMMON for dune-common │ │ │ │ │ - * DUNE_GRID for dune-grid │ │ │ │ │ - * DUNE_GEOMETRY for dune-geometry │ │ │ │ │ - * DUNE_ISTL for dune-istl │ │ │ │ │ - * DUNE_LOCALFUNCTIONS for dune-localfunctions │ │ │ │ │ -For external DUNE modules, you should capitalize the name and replace '-' by │ │ │ │ │ -underscores. For example for the module foo-bar you need to use FOO_BAR as │ │ │ │ │ -module name in the context of this macro. │ │ │ │ │ -***** ◆ DUNE_VERSION_GTE ***** │ │ │ │ │ -#define DUNE_VERSION_GTE (  module, │ │ │ │ │ -  major, │ │ │ │ │ -  minor  │ │ │ │ │ - ) │ │ │ │ │ -Value: │ │ │ │ │ -((DUNE_VERSION_JOIN(module,MAJOR) > major) \ │ │ │ │ │ -|| ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN │ │ │ │ │ -(module,MINOR) >= minor))) │ │ │ │ │ -True if 'module' has the version major.minor or greater. │ │ │ │ │ -For the DUNE core modules you need to use the following module names: │ │ │ │ │ - * DUNE_COMMON for dune-common │ │ │ │ │ - * DUNE_GRID for dune-grid │ │ │ │ │ - * DUNE_GEOMETRY for dune-geometry │ │ │ │ │ - * DUNE_ISTL for dune-istl │ │ │ │ │ - * DUNE_LOCALFUNCTIONS for dune-localfunctions │ │ │ │ │ -For external DUNE modules, you should capitalize the name and replace '-' by │ │ │ │ │ -underscores. For example for the module foo-bar you need to use FOO_BAR as │ │ │ │ │ -module name in the context of this macro. │ │ │ │ │ -***** ◆ DUNE_VERSION_GTE_REV ***** │ │ │ │ │ -#define DUNE_VERSION_GTE_REV (  module, │ │ │ │ │ -  major, │ │ │ │ │ -  minor, │ │ │ │ │ -  revision  │ │ │ │ │ - ) │ │ │ │ │ -Value: │ │ │ │ │ -((DUNE_VERSION_JOIN(module,MAJOR) > major) \ │ │ │ │ │ -|| ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN │ │ │ │ │ -(module,MINOR) > minor)) \ │ │ │ │ │ -|| ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN │ │ │ │ │ -(module,MINOR) == minor) \ │ │ │ │ │ -&& (DUNE_VERSION_JOIN(module,REVISION) >= revision))) │ │ │ │ │ -True if 'module' has the version major.minor.revision or greater. │ │ │ │ │ -For the DUNE core modules you need to use the following module names: │ │ │ │ │ - * DUNE_COMMON for dune-common │ │ │ │ │ - * DUNE_GRID for dune-grid │ │ │ │ │ - * DUNE_GEOMETRY for dune-geometry │ │ │ │ │ - * DUNE_ISTL for dune-istl │ │ │ │ │ - * DUNE_LOCALFUNCTIONS for dune-localfunctions │ │ │ │ │ -For external DUNE modules, you should capitalize the name and replace '-' by │ │ │ │ │ -underscores. For example for the module foo-bar you need to use FOO_BAR as │ │ │ │ │ -module name in the context of this macro. │ │ │ │ │ -***** ◆ DUNE_VERSION_ID ***** │ │ │ │ │ -#define (  major, │ │ │ │ │ -DUNE_VERSION_ID │ │ │ │ │ -  minor, │ │ │ │ │ -  revision  │ │ │ │ │ - )     ((unsigned int)((major << 24) + (minor << 16) + │ │ │ │ │ - revision)) │ │ │ │ │ -Compute a unique uint id from the major, minor, and revision numbers. │ │ │ │ │ -For the DUNE core modules you need to use the following module names: │ │ │ │ │ - * DUNE_COMMON for dune-common │ │ │ │ │ - * DUNE_GRID for dune-grid │ │ │ │ │ - * DUNE_GEOMETRY for dune-geometry │ │ │ │ │ - * DUNE_ISTL for dune-istl │ │ │ │ │ - * DUNE_LOCALFUNCTIONS for dune-localfunctions │ │ │ │ │ -For external DUNE modules, you should capitalize the name and replace '-' by │ │ │ │ │ -underscores. For example for the module foo-bar you need to use FOO_BAR as │ │ │ │ │ -module name in the context of this macro. │ │ │ │ │ -***** ◆ DUNE_VERSION_JOIN ***** │ │ │ │ │ -#define DUNE_VERSION_JOIN (  module, │ │ │ │ │ -  type  │ │ │ │ │ - )    module ## _VERSION_ ## type │ │ │ │ │ -Constructs the preprocessor name used in config.h to hold version numbers. │ │ │ │ │ -For the DUNE core modules you need to use the following module names: │ │ │ │ │ - * DUNE_COMMON for dune-common │ │ │ │ │ - * DUNE_GRID for dune-grid │ │ │ │ │ - * DUNE_GEOMETRY for dune-geometry │ │ │ │ │ - * DUNE_ISTL for dune-istl │ │ │ │ │ - * DUNE_LOCALFUNCTIONS for dune-localfunctions │ │ │ │ │ -For external DUNE modules, you should capitalize the name and replace '-' by │ │ │ │ │ -underscores. For example for the module foo-bar you need to use FOO_BAR as │ │ │ │ │ -module name in the context of this macro. │ │ │ │ │ - Parameters │ │ │ │ │ - module The name of the Dune module │ │ │ │ │ - type The version number type, one of MAJOR, MINOR, or REVISION │ │ │ │ │ -***** ◆ DUNE_VERSION_LT ***** │ │ │ │ │ -#define DUNE_VERSION_LT (  module, │ │ │ │ │ -  major, │ │ │ │ │ -  minor  │ │ │ │ │ - )     ! DUNE_VERSION_GTE(module,major,minor) │ │ │ │ │ -True if 'module' has a version less than major.minor. │ │ │ │ │ -For the DUNE core modules you need to use the following module names: │ │ │ │ │ - * DUNE_COMMON for dune-common │ │ │ │ │ - * DUNE_GRID for dune-grid │ │ │ │ │ - * DUNE_GEOMETRY for dune-geometry │ │ │ │ │ - * DUNE_ISTL for dune-istl │ │ │ │ │ - * DUNE_LOCALFUNCTIONS for dune-localfunctions │ │ │ │ │ -For external DUNE modules, you should capitalize the name and replace '-' by │ │ │ │ │ -underscores. For example for the module foo-bar you need to use FOO_BAR as │ │ │ │ │ -module name in the context of this macro. │ │ │ │ │ -***** ◆ DUNE_VERSION_LT_REV ***** │ │ │ │ │ -#define DUNE_VERSION_LT_REV (  module, │ │ │ │ │ -  major, │ │ │ │ │ -  minor, │ │ │ │ │ -  revision  │ │ │ │ │ - )     ! DUNE_VERSION_GTE_REV │ │ │ │ │ - (module,major,minor,revision) │ │ │ │ │ -True if 'module' has a version lower than major.minor.revision. │ │ │ │ │ -For the DUNE core modules you need to use the following module names: │ │ │ │ │ - * DUNE_COMMON for dune-common │ │ │ │ │ - * DUNE_GRID for dune-grid │ │ │ │ │ - * DUNE_GEOMETRY for dune-geometry │ │ │ │ │ - * DUNE_ISTL for dune-istl │ │ │ │ │ - * DUNE_LOCALFUNCTIONS for dune-localfunctions │ │ │ │ │ -For external DUNE modules, you should capitalize the name and replace '-' by │ │ │ │ │ -underscores. For example for the module foo-bar you need to use FOO_BAR as │ │ │ │ │ -module name in the context of this macro. │ │ │ │ │ -***** ◆ DUNE_VERSION_LTE ***** │ │ │ │ │ -#define DUNE_VERSION_LTE (  module, │ │ │ │ │ -  major, │ │ │ │ │ -  minor  │ │ │ │ │ - )     ! DUNE_VERSION_GT(module,major,minor) │ │ │ │ │ -True if 'module' has a version less than or equal to major.minor. │ │ │ │ │ -For the DUNE core modules you need to use the following module names: │ │ │ │ │ - * DUNE_COMMON for dune-common │ │ │ │ │ - * DUNE_GRID for dune-grid │ │ │ │ │ - * DUNE_GEOMETRY for dune-geometry │ │ │ │ │ - * DUNE_ISTL for dune-istl │ │ │ │ │ - * DUNE_LOCALFUNCTIONS for dune-localfunctions │ │ │ │ │ -For external DUNE modules, you should capitalize the name and replace '-' by │ │ │ │ │ -underscores. For example for the module foo-bar you need to use FOO_BAR as │ │ │ │ │ -module name in the context of this macro. │ │ │ │ │ -***** ◆ DUNE_VERSION_LTE_REV ***** │ │ │ │ │ -#define DUNE_VERSION_LTE_REV (  module, │ │ │ │ │ -  major, │ │ │ │ │ -  minor, │ │ │ │ │ -  revision  │ │ │ │ │ - )     ! DUNE_VERSION_GT_REV │ │ │ │ │ - (module,major,minor,revision) │ │ │ │ │ -True if 'module' has a version lower or equal to major.minor.revision. │ │ │ │ │ -For the DUNE core modules you need to use the following module names: │ │ │ │ │ - * DUNE_COMMON for dune-common │ │ │ │ │ - * DUNE_GRID for dune-grid │ │ │ │ │ - * DUNE_GEOMETRY for dune-geometry │ │ │ │ │ - * DUNE_ISTL for dune-istl │ │ │ │ │ - * DUNE_LOCALFUNCTIONS for dune-localfunctions │ │ │ │ │ -For external DUNE modules, you should capitalize the name and replace '-' by │ │ │ │ │ -underscores. For example for the module foo-bar you need to use FOO_BAR as │ │ │ │ │ -module name in the context of this macro. │ │ │ │ │ -***** ◆ DUNE_VERSION_NEWER ***** │ │ │ │ │ -#define DUNE_VERSION_NEWER (  module, │ │ │ │ │ -  major, │ │ │ │ │ -  minor  │ │ │ │ │ - )     DUNE_VERSION_GTE(module,major,minor) │ │ │ │ │ -True if 'module' has the version major.minor or newer. │ │ │ │ │ - Note │ │ │ │ │ - Deprecated, use DUNE_VERSION_GTE instead. │ │ │ │ │ -For the DUNE core modules you need to use the following module names: │ │ │ │ │ - * DUNE_COMMON for dune-common │ │ │ │ │ - * DUNE_GRID for dune-grid │ │ │ │ │ - * DUNE_GEOMETRY for dune-geometry │ │ │ │ │ - * DUNE_ISTL for dune-istl │ │ │ │ │ - * DUNE_LOCALFUNCTIONS for dune-localfunctions │ │ │ │ │ -For external DUNE modules, you should capitalize the name and replace '-' by │ │ │ │ │ -underscores. For example for the module foo-bar you need to use FOO_BAR as │ │ │ │ │ -module name in the context of this macro. │ │ │ │ │ -***** ◆ DUNE_VERSION_NEWER_REV ***** │ │ │ │ │ -#define DUNE_VERSION_NEWER_REV (  module, │ │ │ │ │ -  major, │ │ │ │ │ -  minor, │ │ │ │ │ -  revision  │ │ │ │ │ - )     DUNE_VERSION_GTE_REV │ │ │ │ │ - (module,major,minor,revision) │ │ │ │ │ -True if 'module' has the version major.minor.revision or newer. │ │ │ │ │ - Note │ │ │ │ │ - Deprecated, use DUNE_VERSION_GTE_REV instead. │ │ │ │ │ -For the DUNE core modules you need to use the following module names: │ │ │ │ │ - * DUNE_COMMON for dune-common │ │ │ │ │ - * DUNE_GRID for dune-grid │ │ │ │ │ - * DUNE_GEOMETRY for dune-geometry │ │ │ │ │ - * DUNE_ISTL for dune-istl │ │ │ │ │ - * DUNE_LOCALFUNCTIONS for dune-localfunctions │ │ │ │ │ -For external DUNE modules, you should capitalize the name and replace '-' by │ │ │ │ │ -underscores. For example for the module foo-bar you need to use FOO_BAR as │ │ │ │ │ -module name in the context of this macro. │ │ │ │ │ +See MPI_Pack. │ │ │ │ │ +This Wrapper class takes care of the memory management and provides methods to │ │ │ │ │ +pack and unpack objects. All objects that can be used for MPI communication can │ │ │ │ │ +also be packed and unpacked to/from MPIPack. │ │ │ │ │ + Author │ │ │ │ │ + Nils-Arne Dreier │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00059_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: version.hh Source File │ │ │ │ +dune-common: mpipack.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,111 +70,283 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
version.hh
│ │ │ │ +
mpipack.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 (C) 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_VERSION_HH
│ │ │ │ -
6#define DUNE_VERSION_HH
│ │ │ │ -
7
│ │ │ │ -
28#define DUNE_VERSION_JOIN(module,type) module ## _VERSION_ ## type
│ │ │ │ +
20#ifndef DUNE_COMMON_PARALLEL_MPIPACK_HH
│ │ │ │ +
21#define DUNE_COMMON_PARALLEL_MPIPACK_HH
│ │ │ │ +
22
│ │ │ │ +
23#include <vector>
│ │ │ │ +
24#if HAVE_MPI
│ │ │ │ +
25#include <mpi.h>
│ │ │ │ + │ │ │ │ + │ │ │ │ +
28
│ │ │ │
29
│ │ │ │ -
│ │ │ │ -
44#define DUNE_VERSION_EQUAL(module,major,minor) \
│ │ │ │ -
45 ((DUNE_VERSION_JOIN(module,MAJOR) == major) && \
│ │ │ │ -
46 (DUNE_VERSION_JOIN(module,MINOR) == minor))
│ │ │ │ -
│ │ │ │ -
47
│ │ │ │ -
│ │ │ │ -
62#define DUNE_VERSION_EQUAL_REV(module,major,minor,revision) \
│ │ │ │ -
63 ( DUNE_VERSION_EQUAL(module,major,minor) && \
│ │ │ │ -
64 (DUNE_VERSION_JOIN(module,REVISION) == revision))
│ │ │ │ -
│ │ │ │ -
65
│ │ │ │ -
│ │ │ │ -
80#define DUNE_VERSION_GTE(module,major,minor) \
│ │ │ │ -
81 ((DUNE_VERSION_JOIN(module,MAJOR) > major) \
│ │ │ │ -
82 || ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN(module,MINOR) >= minor)))
│ │ │ │ -
│ │ │ │ -
83
│ │ │ │ -
│ │ │ │ -
98#define DUNE_VERSION_LT(module,major,minor) \
│ │ │ │ -
99 ! DUNE_VERSION_GTE(module,major,minor)
│ │ │ │ -
│ │ │ │ -
100
│ │ │ │ -
│ │ │ │ -
116#define DUNE_VERSION_NEWER(module,major,minor) \
│ │ │ │ -
117 DUNE_VERSION_GTE(module,major,minor)
│ │ │ │ -
│ │ │ │ -
118
│ │ │ │ -
│ │ │ │ -
133#define DUNE_VERSION_GT(module,major,minor) \
│ │ │ │ -
134 ((DUNE_VERSION_JOIN(module,MAJOR) > major) \
│ │ │ │ -
135 || ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN(module,MINOR) > minor)))
│ │ │ │ -
│ │ │ │ -
136
│ │ │ │ -
│ │ │ │ -
151#define DUNE_VERSION_LTE(module,major,minor) \
│ │ │ │ -
152 ! DUNE_VERSION_GT(module,major,minor)
│ │ │ │ -
│ │ │ │ -
153
│ │ │ │ -
│ │ │ │ -
168#define DUNE_VERSION_GTE_REV(module,major,minor,revision) \
│ │ │ │ -
169 ((DUNE_VERSION_JOIN(module,MAJOR) > major) \
│ │ │ │ -
170 || ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN(module,MINOR) > minor)) \
│ │ │ │ -
171 || ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN(module,MINOR) == minor) \
│ │ │ │ -
172 && (DUNE_VERSION_JOIN(module,REVISION) >= revision)))
│ │ │ │ -
│ │ │ │ -
173
│ │ │ │ -
│ │ │ │ -
188#define DUNE_VERSION_LT_REV(module,major,minor,revision) \
│ │ │ │ -
189 ! DUNE_VERSION_GTE_REV(module,major,minor,revision)
│ │ │ │ -
│ │ │ │ -
190
│ │ │ │ -
│ │ │ │ -
206#define DUNE_VERSION_NEWER_REV(module,major,minor,revision) \
│ │ │ │ -
207 DUNE_VERSION_GTE_REV(module,major,minor,revision)
│ │ │ │ +
30namespace Dune {
│ │ │ │ +
31
│ │ │ │ +
│ │ │ │ +
32 class MPIPack {
│ │ │ │ +
33 std::vector<char> _buffer;
│ │ │ │ +
34 int _position;
│ │ │ │ +
35 MPI_Comm _comm;
│ │ │ │ +
36
│ │ │ │ +
37 friend struct MPIData<MPIPack>;
│ │ │ │ +
38 friend struct MPIData<const MPIPack>;
│ │ │ │ +
39 public:
│ │ │ │ +
│ │ │ │ +
40 MPIPack(Communication<MPI_Comm> comm, std::size_t size = 0)
│ │ │ │ +
41 : _buffer(size)
│ │ │ │ +
42 , _position(0)
│ │ │ │ +
43 , _comm(comm)
│ │ │ │ +
44 {}
│ │ │ │ +
│ │ │ │ +
45
│ │ │ │ +
46 // Its not valid to copy a MPIPack but you can move it
│ │ │ │ +
47 MPIPack(const MPIPack&) = delete;
│ │ │ │ +
48 MPIPack& operator = (const MPIPack& other) = delete;
│ │ │ │ +
49 MPIPack(MPIPack&&) = default;
│ │ │ │ +
50 MPIPack& operator = (MPIPack&& other) = default;
│ │ │ │ +
51
│ │ │ │ +
57 template<class T>
│ │ │ │ +
│ │ │ │ +
58 void pack(const T& data){
│ │ │ │ +
59 auto mpidata = getMPIData(data);
│ │ │ │ +
60 int size = getPackSize(mpidata.size(), _comm, mpidata.type());
│ │ │ │ +
61 constexpr bool has_static_size = decltype(getMPIData(std::declval<T&>()))::static_size;
│ │ │ │ +
62 if(!has_static_size)
│ │ │ │ +
63 size += getPackSize(1, _comm, MPI_INT);
│ │ │ │ +
64 if (_position + size > 0 && size_t(_position + size) > _buffer.size()) // resize buffer if necessary
│ │ │ │ +
65 _buffer.resize(_position + size);
│ │ │ │ +
66 if(!has_static_size){
│ │ │ │ +
67 int size = mpidata.size();
│ │ │ │ +
68 MPI_Pack(&size, 1, MPI_INT, _buffer.data(), _buffer.size(),
│ │ │ │ +
69 &_position, _comm);
│ │ │ │ +
70 }
│ │ │ │ +
71 MPI_Pack(mpidata.ptr(), mpidata.size(),
│ │ │ │ +
72 mpidata.type(), _buffer.data(), _buffer.size(),
│ │ │ │ +
73 &_position, _comm);
│ │ │ │ +
74 }
│ │ │ │ +
│ │ │ │ +
75
│ │ │ │ +
80 template<class T>
│ │ │ │ +
│ │ │ │ +
81 auto /*void*/ unpack(T& data)
│ │ │ │ +
82 -> std::enable_if_t<decltype(getMPIData(data))::static_size, void>
│ │ │ │ +
83 {
│ │ │ │ +
84 auto mpidata = getMPIData(data);
│ │ │ │ +
85 MPI_Unpack(_buffer.data(), _buffer.size(), &_position,
│ │ │ │ +
86 mpidata.ptr(), mpidata.size(),
│ │ │ │ +
87 mpidata.type(), _comm);
│ │ │ │ +
88 }
│ │ │ │ +
│ │ │ │ +
89
│ │ │ │ +
94 template<class T>
│ │ │ │ +
│ │ │ │ +
95 auto /*void*/ unpack(T& data)
│ │ │ │ +
96 -> std::enable_if_t<!decltype(getMPIData(data))::static_size, void>
│ │ │ │ +
97 {
│ │ │ │ +
98 auto mpidata = getMPIData(data);
│ │ │ │ +
99 int size = 0;
│ │ │ │ +
100 MPI_Unpack(_buffer.data(), _buffer.size(), &_position,
│ │ │ │ +
101 &size, 1,
│ │ │ │ +
102 MPI_INT, _comm);
│ │ │ │ +
103 mpidata.resize(size);
│ │ │ │ +
104 MPI_Unpack(_buffer.data(), _buffer.size(), &_position,
│ │ │ │ +
105 mpidata.ptr(), mpidata.size(),
│ │ │ │ +
106 mpidata.type(), _comm);
│ │ │ │ +
107 }
│ │ │ │ +
│ │ │ │ +
108
│ │ │ │ +
109
│ │ │ │ +
111 template<typename T>
│ │ │ │ +
│ │ │ │ +
112 friend MPIPack& operator << (MPIPack& p, const T& t){
│ │ │ │ +
113 p.pack(t);
│ │ │ │ +
114 return p;
│ │ │ │ +
115 }
│ │ │ │ +
│ │ │ │ +
116
│ │ │ │ +
118 template<typename T>
│ │ │ │ +
│ │ │ │ +
119 friend MPIPack& operator >> (MPIPack& p, T& t){
│ │ │ │ +
120 p.unpack(t);
│ │ │ │ +
121 return p;
│ │ │ │ +
122 }
│ │ │ │ +
│ │ │ │ +
123
│ │ │ │ +
125 template<typename T>
│ │ │ │ +
│ │ │ │ +
126 MPIPack& read(T& t){
│ │ │ │ +
127 unpack(t);
│ │ │ │ +
128 return *this;
│ │ │ │ +
129 }
│ │ │ │ +
│ │ │ │ +
130
│ │ │ │ +
132 template<typename T>
│ │ │ │ +
│ │ │ │ +
133 MPIPack& write(const T& t){
│ │ │ │ +
134 pack(t);
│ │ │ │ +
135 return *this;
│ │ │ │ +
136 }
│ │ │ │ +
│ │ │ │ +
137
│ │ │ │ +
│ │ │ │ +
141 void resize(size_t size){
│ │ │ │ +
142 _buffer.resize(size);
│ │ │ │ +
143 }
│ │ │ │ +
│ │ │ │ +
144
│ │ │ │ +
│ │ │ │ +
147 void enlarge(int s) {
│ │ │ │ +
148 _buffer.resize(_buffer.size() + s);
│ │ │ │ +
149 }
│ │ │ │ +
│ │ │ │ +
150
│ │ │ │ +
│ │ │ │ +
153 size_t size() const {
│ │ │ │ +
154 return _buffer.size();
│ │ │ │ +
155 }
│ │ │ │ +
│ │ │ │ +
156
│ │ │ │ +
│ │ │ │ +
160 void seek(int p){
│ │ │ │ +
161 _position = p;
│ │ │ │ +
162 }
│ │ │ │ +
│ │ │ │ +
163
│ │ │ │ +
│ │ │ │ +
167 int tell() const{
│ │ │ │ +
168 return _position;
│ │ │ │ +
169 }
│ │ │ │ +
│ │ │ │ +
170
│ │ │ │ +
│ │ │ │ +
173 bool eof() const{
│ │ │ │ +
174 return std::size_t(_position)==_buffer.size();
│ │ │ │ +
175 }
│ │ │ │ +
│ │ │ │ +
176
│ │ │ │ +
│ │ │ │ +
180 static int getPackSize(int len, const MPI_Comm& comm, const MPI_Datatype& dt){
│ │ │ │ +
181 int size;
│ │ │ │ +
182 MPI_Pack_size(len, dt, comm, &size);
│ │ │ │ +
183 return size;
│ │ │ │ +
184 }
│ │ │ │ +
│ │ │ │ +
185
│ │ │ │ +
│ │ │ │ +
186 friend bool operator==(const MPIPack& a, const MPIPack& b) {
│ │ │ │ +
187 return a._buffer == b._buffer && a._comm == b._comm;
│ │ │ │ +
188 }
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
189 friend bool operator!=(const MPIPack& a, const MPIPack& b) {
│ │ │ │ +
190 return !(a==b);
│ │ │ │ +
191 }
│ │ │ │ +
│ │ │ │ +
192
│ │ │ │ +
193 };
│ │ │ │ +
│ │ │ │ +
194
│ │ │ │ +
195 template<class P>
│ │ │ │ +
│ │ │ │ +
196 struct MPIData<P, std::enable_if_t<std::is_same<std::remove_const_t<P>, MPIPack>::value>> {
│ │ │ │ +
197 protected:
│ │ │ │ +
198 friend auto getMPIData<P>(P& t);
│ │ │ │ +
│ │ │ │ +
199 MPIData(P& t) :
│ │ │ │ +
200 data_(t)
│ │ │ │ +
201 {}
│ │ │ │ +
│ │ │ │ +
202 public:
│ │ │ │ +
203 static constexpr bool static_size = std::is_const<P>::value;
│ │ │ │ +
204
│ │ │ │ +
│ │ │ │ +
205 void* ptr() {
│ │ │ │ +
206 return (void*) data_._buffer.data();
│ │ │ │ +
207 }
│ │ │ │
│ │ │ │
208
│ │ │ │ -
│ │ │ │ -
223#define DUNE_VERSION_GT_REV(module,major,minor,revision) \
│ │ │ │ -
224 ((DUNE_VERSION_JOIN(module,MAJOR) > major) \
│ │ │ │ -
225 || ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN(module,MINOR) > minor)) \
│ │ │ │ -
226 || ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN(module,MINOR) == minor) \
│ │ │ │ -
227 && (DUNE_VERSION_JOIN(module,REVISION) > revision)))
│ │ │ │ -
│ │ │ │ -
228
│ │ │ │ -
│ │ │ │ -
243#define DUNE_VERSION_LTE_REV(module,major,minor,revision) \
│ │ │ │ -
244 ! DUNE_VERSION_GT_REV(module,major,minor,revision)
│ │ │ │ -
│ │ │ │ -
245
│ │ │ │ -
│ │ │ │ -
260#define DUNE_VERSION_ID(major,minor,revision) \
│ │ │ │ -
261 ((unsigned int)((major << 24) + (minor << 16) + revision))
│ │ │ │ -
│ │ │ │ -
262
│ │ │ │ -
│ │ │ │ -
277#define DUNE_MODULE_VERSION_ID(module) \
│ │ │ │ -
278 DUNE_VERSION_ID( DUNE_VERSION_JOIN(module,MAJOR), DUNE_VERSION_JOIN(module,MINOR), DUNE_VERSION_JOIN(module,REVISION) )
│ │ │ │ -
│ │ │ │ -
279
│ │ │ │ -
280#endif
│ │ │ │ +
│ │ │ │ +
209 int size() {
│ │ │ │ +
210 return data_.size();
│ │ │ │ +
211 }
│ │ │ │ +
│ │ │ │ +
212
│ │ │ │ +
│ │ │ │ +
213 MPI_Datatype type() const{
│ │ │ │ +
214 return MPI_PACKED;
│ │ │ │ +
215 }
│ │ │ │ +
│ │ │ │ +
216
│ │ │ │ +
│ │ │ │ +
217 void resize(int size){
│ │ │ │ +
218 data_.resize(size);
│ │ │ │ +
219 }
│ │ │ │ +
│ │ │ │ +
220 protected:
│ │ │ │ + │ │ │ │ +
222 };
│ │ │ │ +
│ │ │ │ +
223
│ │ │ │ +
224} // end namespace Dune
│ │ │ │ +
225
│ │ │ │ +
226#endif
│ │ │ │ +
227#endif
│ │ │ │ +
Interface class to translate objects to a MPI_Datatype, void* and size used for MPI calls.
│ │ │ │ +
Implements an utility class that provides MPI's collective communication methods.
│ │ │ │ +
STL namespace.
│ │ │ │ +
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ +
auto getMPIData(T &t)
Definition mpidata.hh:43
│ │ │ │ +
Collective communication interface and sequential default implementation.
Definition communication.hh:100
│ │ │ │ +
Definition mpidata.hh:50
│ │ │ │ +
T & data_
Definition mpidata.hh:53
│ │ │ │ +
int size() const
Definition mpidata.hh:67
│ │ │ │ +
static constexpr bool static_size
Definition mpidata.hh:65
│ │ │ │ +
Definition mpipack.hh:32
│ │ │ │ +
void enlarge(int s)
Enlarges the internal buffer.
Definition mpipack.hh:147
│ │ │ │ +
friend MPIPack & operator>>(MPIPack &p, T &t)
Unpacks data from the object.
Definition mpipack.hh:119
│ │ │ │ +
friend MPIPack & operator<<(MPIPack &p, const T &t)
Packs the data into the object. Enlarges the internal buffer if necessary.
Definition mpipack.hh:112
│ │ │ │ +
friend bool operator!=(const MPIPack &a, const MPIPack &b)
Definition mpipack.hh:189
│ │ │ │ +
size_t size() const
Returns the size of the internal buffer.
Definition mpipack.hh:153
│ │ │ │ +
MPIPack & operator=(const MPIPack &other)=delete
│ │ │ │ +
MPIPack(Communication< MPI_Comm > comm, std::size_t size=0)
Definition mpipack.hh:40
│ │ │ │ +
void pack(const T &data)
Packs the data into the object. Enlarges the internal buffer if necessary.
Definition mpipack.hh:58
│ │ │ │ +
auto unpack(T &data) -> std::enable_if_t<!decltype(getMPIData(data))::static_size, void >
Unpacks data from the object.
Definition mpipack.hh:95
│ │ │ │ +
auto unpack(T &data) -> std::enable_if_t< decltype(getMPIData(data))::static_size, void >
Unpacks data from the object.
Definition mpipack.hh:81
│ │ │ │ +
friend bool operator==(const MPIPack &a, const MPIPack &b)
Definition mpipack.hh:186
│ │ │ │ +
MPIPack(const MPIPack &)=delete
│ │ │ │ +
void seek(int p)
Sets the position in the buffer where the next pack/unpack operation should take place.
Definition mpipack.hh:160
│ │ │ │ +
bool eof() const
Checks whether the end of the buffer is reached.
Definition mpipack.hh:173
│ │ │ │ +
void resize(size_t size)
Resizes the internal buffer.
Definition mpipack.hh:141
│ │ │ │ +
int tell() const
Gets the position in the buffer where the next pack/unpack operation should take place.
Definition mpipack.hh:167
│ │ │ │ +
MPIPack(MPIPack &&)=default
│ │ │ │ +
MPIPack & read(T &t)
Unpacks data from the object.
Definition mpipack.hh:126
│ │ │ │ +
static int getPackSize(int len, const MPI_Comm &comm, const MPI_Datatype &dt)
Returns the size of the data needed to store the data in an MPIPack. See MPI_Pack_size.
Definition mpipack.hh:180
│ │ │ │ +
MPIPack & write(const T &t)
Packs the data into the object. Enlarges the internal buffer if necessary.
Definition mpipack.hh:133
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,82 +7,325 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -version.hh │ │ │ │ │ + * parallel │ │ │ │ │ +mpipack.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 (C) 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_VERSION_HH │ │ │ │ │ - 6#define DUNE_VERSION_HH │ │ │ │ │ - 7 │ │ │ │ │ -28#define DUNE_VERSION_JOIN(module,type) module ## _VERSION_ ## type │ │ │ │ │ + 20#ifndef DUNE_COMMON_PARALLEL_MPIPACK_HH │ │ │ │ │ + 21#define DUNE_COMMON_PARALLEL_MPIPACK_HH │ │ │ │ │ + 22 │ │ │ │ │ + 23#include │ │ │ │ │ + 24#if HAVE_MPI │ │ │ │ │ + 25#include │ │ │ │ │ + 26#include │ │ │ │ │ + 27#include │ │ │ │ │ + 28 │ │ │ │ │ 29 │ │ │ │ │ -44#define DUNE_VERSION_EQUAL(module,major,minor) \ │ │ │ │ │ - 45 ((DUNE_VERSION_JOIN(module,MAJOR) == major) && \ │ │ │ │ │ - 46 (DUNE_VERSION_JOIN(module,MINOR) == minor)) │ │ │ │ │ - 47 │ │ │ │ │ -62#define DUNE_VERSION_EQUAL_REV(module,major,minor,revision) \ │ │ │ │ │ - 63 ( DUNE_VERSION_EQUAL(module,major,minor) && \ │ │ │ │ │ - 64 (DUNE_VERSION_JOIN(module,REVISION) == revision)) │ │ │ │ │ - 65 │ │ │ │ │ -80#define DUNE_VERSION_GTE(module,major,minor) \ │ │ │ │ │ - 81 ((DUNE_VERSION_JOIN(module,MAJOR) > major) \ │ │ │ │ │ - 82 || ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN │ │ │ │ │ -(module,MINOR) >= minor))) │ │ │ │ │ - 83 │ │ │ │ │ -98#define DUNE_VERSION_LT(module,major,minor) \ │ │ │ │ │ - 99 ! DUNE_VERSION_GTE(module,major,minor) │ │ │ │ │ - 100 │ │ │ │ │ -116#define DUNE_VERSION_NEWER(module,major,minor) \ │ │ │ │ │ - 117 DUNE_VERSION_GTE(module,major,minor) │ │ │ │ │ - 118 │ │ │ │ │ -133#define DUNE_VERSION_GT(module,major,minor) \ │ │ │ │ │ - 134 ((DUNE_VERSION_JOIN(module,MAJOR) > major) \ │ │ │ │ │ - 135 || ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN │ │ │ │ │ -(module,MINOR) > minor))) │ │ │ │ │ - 136 │ │ │ │ │ -151#define DUNE_VERSION_LTE(module,major,minor) \ │ │ │ │ │ - 152 ! DUNE_VERSION_GT(module,major,minor) │ │ │ │ │ - 153 │ │ │ │ │ -168#define DUNE_VERSION_GTE_REV(module,major,minor,revision) \ │ │ │ │ │ - 169 ((DUNE_VERSION_JOIN(module,MAJOR) > major) \ │ │ │ │ │ - 170 || ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN │ │ │ │ │ -(module,MINOR) > minor)) \ │ │ │ │ │ - 171 || ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN │ │ │ │ │ -(module,MINOR) == minor) \ │ │ │ │ │ - 172 && (DUNE_VERSION_JOIN(module,REVISION) >= revision))) │ │ │ │ │ - 173 │ │ │ │ │ -188#define DUNE_VERSION_LT_REV(module,major,minor,revision) \ │ │ │ │ │ - 189 ! DUNE_VERSION_GTE_REV(module,major,minor,revision) │ │ │ │ │ - 190 │ │ │ │ │ -206#define DUNE_VERSION_NEWER_REV(module,major,minor,revision) \ │ │ │ │ │ - 207 DUNE_VERSION_GTE_REV(module,major,minor,revision) │ │ │ │ │ + 30namespace Dune { │ │ │ │ │ + 31 │ │ │ │ │ +32 class MPIPack { │ │ │ │ │ + 33 std::vector _buffer; │ │ │ │ │ + 34 int _position; │ │ │ │ │ +35 MPI_Comm _comm; │ │ │ │ │ + 36 │ │ │ │ │ + 37 friend struct MPIData; │ │ │ │ │ + 38 friend struct MPIData; │ │ │ │ │ + 39 public: │ │ │ │ │ +40 MPIPack(Communication comm, std::size_t size = 0) │ │ │ │ │ + 41 : _buffer(size) │ │ │ │ │ + 42 , _position(0) │ │ │ │ │ + 43 , _comm(comm) │ │ │ │ │ + 44 {} │ │ │ │ │ + 45 │ │ │ │ │ + 46 // Its not valid to copy a MPIPack but you can move it │ │ │ │ │ +47 MPIPack(const MPIPack&) = delete; │ │ │ │ │ +48 MPIPack& operator_=(const MPIPack& other) = delete; │ │ │ │ │ +49 MPIPack(MPIPack&&) = default; │ │ │ │ │ +50 MPIPack& operator_=(MPIPack&& other) = default; │ │ │ │ │ + 51 │ │ │ │ │ + 57 template │ │ │ │ │ +58 void pack(const T& data){ │ │ │ │ │ + 59 auto mpidata = getMPIData(data); │ │ │ │ │ + 60 int size = getPackSize(mpidata.size(), _comm, mpidata.type()); │ │ │ │ │ + 61 constexpr bool has_static_size = decltype(getMPIData(std::declval())):: │ │ │ │ │ +static_size; │ │ │ │ │ + 62 if(!has_static_size) │ │ │ │ │ + 63 size += getPackSize(1, _comm, MPI_INT); │ │ │ │ │ + 64 if (_position + size > 0 && size_t(_position + size) > _buffer.size()) / │ │ │ │ │ +/ resize buffer if necessary │ │ │ │ │ + 65 _buffer.resize(_position + size); │ │ │ │ │ + 66 if(!has_static_size){ │ │ │ │ │ + 67 int size = mpidata.size(); │ │ │ │ │ + 68 MPI_Pack(&size, 1, MPI_INT, _buffer.data(), _buffer.size(), │ │ │ │ │ + 69 &_position, _comm); │ │ │ │ │ + 70 } │ │ │ │ │ + 71 MPI_Pack(mpidata.ptr(), mpidata.size(), │ │ │ │ │ + 72 mpidata.type(), _buffer.data(), _buffer.size(), │ │ │ │ │ + 73 &_position, _comm); │ │ │ │ │ + 74 } │ │ │ │ │ + 75 │ │ │ │ │ + 80 template │ │ │ │ │ +81 auto /*void*/ unpack(T& data) │ │ │ │ │ + 82 -> std::enable_if_t │ │ │ │ │ + 83 { │ │ │ │ │ + 84 auto mpidata = getMPIData(data); │ │ │ │ │ + 85 MPI_Unpack(_buffer.data(), _buffer.size(), &_position, │ │ │ │ │ + 86 mpidata.ptr(), mpidata.size(), │ │ │ │ │ + 87 mpidata.type(), _comm); │ │ │ │ │ + 88 } │ │ │ │ │ + 89 │ │ │ │ │ + 94 template │ │ │ │ │ +95 auto /*void*/ unpack(T& data) │ │ │ │ │ + 96 -> std::enable_if_t │ │ │ │ │ + 97 { │ │ │ │ │ + 98 auto mpidata = getMPIData(data); │ │ │ │ │ + 99 int size = 0; │ │ │ │ │ + 100 MPI_Unpack(_buffer.data(), _buffer.size(), &_position, │ │ │ │ │ + 101 &size, 1, │ │ │ │ │ + 102 MPI_INT, _comm); │ │ │ │ │ + 103 mpidata.resize(size); │ │ │ │ │ + 104 MPI_Unpack(_buffer.data(), _buffer.size(), &_position, │ │ │ │ │ + 105 mpidata.ptr(), mpidata.size(), │ │ │ │ │ + 106 mpidata.type(), _comm); │ │ │ │ │ + 107 } │ │ │ │ │ + 108 │ │ │ │ │ + 109 │ │ │ │ │ + 111 template │ │ │ │ │ +112 friend MPIPack& operator_<<(MPIPack& p, const T& t){ │ │ │ │ │ + 113 p.pack(t); │ │ │ │ │ + 114 return p; │ │ │ │ │ + 115 } │ │ │ │ │ + 116 │ │ │ │ │ + 118 template │ │ │ │ │ +119 friend MPIPack& operator_>>(MPIPack& p, T& t){ │ │ │ │ │ + 120 p.unpack(t); │ │ │ │ │ + 121 return p; │ │ │ │ │ + 122 } │ │ │ │ │ + 123 │ │ │ │ │ + 125 template │ │ │ │ │ +126 MPIPack& read(T& t){ │ │ │ │ │ + 127 unpack(t); │ │ │ │ │ + 128 return *this; │ │ │ │ │ + 129 } │ │ │ │ │ + 130 │ │ │ │ │ + 132 template │ │ │ │ │ +133 MPIPack& write(const T& t){ │ │ │ │ │ + 134 pack(t); │ │ │ │ │ + 135 return *this; │ │ │ │ │ + 136 } │ │ │ │ │ + 137 │ │ │ │ │ +141 void resize(size_t size){ │ │ │ │ │ + 142 _buffer.resize(size); │ │ │ │ │ + 143 } │ │ │ │ │ + 144 │ │ │ │ │ +147 void enlarge(int s) { │ │ │ │ │ + 148 _buffer.resize(_buffer.size() + s); │ │ │ │ │ + 149 } │ │ │ │ │ + 150 │ │ │ │ │ +153 size_t size() const { │ │ │ │ │ + 154 return _buffer.size(); │ │ │ │ │ + 155 } │ │ │ │ │ + 156 │ │ │ │ │ +160 void seek(int p){ │ │ │ │ │ + 161 _position = p; │ │ │ │ │ + 162 } │ │ │ │ │ + 163 │ │ │ │ │ +167 int tell() const{ │ │ │ │ │ + 168 return _position; │ │ │ │ │ + 169 } │ │ │ │ │ + 170 │ │ │ │ │ +173 bool eof() const{ │ │ │ │ │ + 174 return std::size_t(_position)==_buffer.size(); │ │ │ │ │ + 175 } │ │ │ │ │ + 176 │ │ │ │ │ +180 static int getPackSize(int len, const MPI_Comm& comm, const MPI_Datatype& │ │ │ │ │ +dt){ │ │ │ │ │ + 181 int size; │ │ │ │ │ + 182 MPI_Pack_size(len, dt, comm, &size); │ │ │ │ │ + 183 return size; │ │ │ │ │ + 184 } │ │ │ │ │ + 185 │ │ │ │ │ +186 friend bool operator==(const MPIPack& a, const MPIPack& b) { │ │ │ │ │ + 187 return a._buffer == b._buffer && a._comm == b._comm; │ │ │ │ │ + 188 } │ │ │ │ │ +189 friend bool operator!=(const MPIPack& a, const MPIPack& b) { │ │ │ │ │ + 190 return !(a==b); │ │ │ │ │ + 191 } │ │ │ │ │ + 192 │ │ │ │ │ + 193 }; │ │ │ │ │ + 194 │ │ │ │ │ + 195 template │ │ │ │ │ +196 struct MPIData, │ │ │ │ │ +MPIPack>::value>> { │ │ │ │ │ + 197 protected: │ │ │ │ │ +198 friend auto getMPIData

(P& t); │ │ │ │ │ +199 MPIData(P& t) : │ │ │ │ │ + 200 data_(t) │ │ │ │ │ + 201 {} │ │ │ │ │ + 202 public: │ │ │ │ │ +203 static constexpr bool static_size = std::is_const

::value; │ │ │ │ │ + 204 │ │ │ │ │ +205 void* ptr() { │ │ │ │ │ + 206 return (void*) data_._buffer.data(); │ │ │ │ │ + 207 } │ │ │ │ │ 208 │ │ │ │ │ -223#define DUNE_VERSION_GT_REV(module,major,minor,revision) \ │ │ │ │ │ - 224 ((DUNE_VERSION_JOIN(module,MAJOR) > major) \ │ │ │ │ │ - 225 || ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN │ │ │ │ │ -(module,MINOR) > minor)) \ │ │ │ │ │ - 226 || ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN │ │ │ │ │ -(module,MINOR) == minor) \ │ │ │ │ │ - 227 && (DUNE_VERSION_JOIN(module,REVISION) > revision))) │ │ │ │ │ - 228 │ │ │ │ │ -243#define DUNE_VERSION_LTE_REV(module,major,minor,revision) \ │ │ │ │ │ - 244 ! DUNE_VERSION_GT_REV(module,major,minor,revision) │ │ │ │ │ - 245 │ │ │ │ │ -260#define DUNE_VERSION_ID(major,minor,revision) \ │ │ │ │ │ - 261 ((unsigned int)((major << 24) + (minor << 16) + revision)) │ │ │ │ │ - 262 │ │ │ │ │ -277#define DUNE_MODULE_VERSION_ID(module) \ │ │ │ │ │ - 278 DUNE_VERSION_ID( DUNE_VERSION_JOIN(module,MAJOR), DUNE_VERSION_JOIN │ │ │ │ │ -(module,MINOR), DUNE_VERSION_JOIN(module,REVISION) ) │ │ │ │ │ - 279 │ │ │ │ │ - 280#endif │ │ │ │ │ +209 int size() { │ │ │ │ │ + 210 return data_.size(); │ │ │ │ │ + 211 } │ │ │ │ │ + 212 │ │ │ │ │ +213 MPI_Datatype type() const{ │ │ │ │ │ + 214 return MPI_PACKED; │ │ │ │ │ + 215 } │ │ │ │ │ + 216 │ │ │ │ │ +217 void resize(int size){ │ │ │ │ │ + 218 data_.resize(size); │ │ │ │ │ + 219 } │ │ │ │ │ + 220 protected: │ │ │ │ │ +221 P& data_; │ │ │ │ │ + 222 }; │ │ │ │ │ + 223 │ │ │ │ │ + 224} // end namespace Dune │ │ │ │ │ + 225 │ │ │ │ │ + 226#endif │ │ │ │ │ + 227#endif │ │ │ │ │ +mpidata.hh │ │ │ │ │ +Interface class to translate objects to a MPI_Datatype, void* and size used for │ │ │ │ │ +MPI calls. │ │ │ │ │ +mpicommunication.hh │ │ │ │ │ +Implements an utility class that provides MPI's collective communication │ │ │ │ │ +methods. │ │ │ │ │ +std │ │ │ │ │ +STL namespace. │ │ │ │ │ +Dune │ │ │ │ │ +Dune namespace. │ │ │ │ │ +Definition alignedallocator.hh:13 │ │ │ │ │ +Dune::getMPIData │ │ │ │ │ +auto getMPIData(T &t) │ │ │ │ │ +Definition mpidata.hh:43 │ │ │ │ │ +Dune::Communication │ │ │ │ │ +Collective communication interface and sequential default implementation. │ │ │ │ │ +Definition communication.hh:100 │ │ │ │ │ +Dune::MPIData │ │ │ │ │ +Definition mpidata.hh:50 │ │ │ │ │ +Dune::MPIData::data_ │ │ │ │ │ +T & data_ │ │ │ │ │ +Definition mpidata.hh:53 │ │ │ │ │ +Dune::MPIData::size │ │ │ │ │ +int size() const │ │ │ │ │ +Definition mpidata.hh:67 │ │ │ │ │ +Dune::MPIData::static_size │ │ │ │ │ +static constexpr bool static_size │ │ │ │ │ +Definition mpidata.hh:65 │ │ │ │ │ +Dune::MPIPack │ │ │ │ │ +Definition mpipack.hh:32 │ │ │ │ │ +Dune::MPIPack::enlarge │ │ │ │ │ +void enlarge(int s) │ │ │ │ │ +Enlarges the internal buffer. │ │ │ │ │ +Definition mpipack.hh:147 │ │ │ │ │ +Dune::MPIPack::operator>> │ │ │ │ │ +friend MPIPack & operator>>(MPIPack &p, T &t) │ │ │ │ │ +Unpacks data from the object. │ │ │ │ │ +Definition mpipack.hh:119 │ │ │ │ │ +Dune::MPIPack::operator<< │ │ │ │ │ +friend MPIPack & operator<<(MPIPack &p, const T &t) │ │ │ │ │ +Packs the data into the object. Enlarges the internal buffer if necessary. │ │ │ │ │ +Definition mpipack.hh:112 │ │ │ │ │ +Dune::MPIPack::operator!= │ │ │ │ │ +friend bool operator!=(const MPIPack &a, const MPIPack &b) │ │ │ │ │ +Definition mpipack.hh:189 │ │ │ │ │ +Dune::MPIPack::size │ │ │ │ │ +size_t size() const │ │ │ │ │ +Returns the size of the internal buffer. │ │ │ │ │ +Definition mpipack.hh:153 │ │ │ │ │ +Dune::MPIPack::operator= │ │ │ │ │ +MPIPack & operator=(const MPIPack &other)=delete │ │ │ │ │ +Dune::MPIPack::MPIPack │ │ │ │ │ +MPIPack(Communication< MPI_Comm > comm, std::size_t size=0) │ │ │ │ │ +Definition mpipack.hh:40 │ │ │ │ │ +Dune::MPIPack::pack │ │ │ │ │ +void pack(const T &data) │ │ │ │ │ +Packs the data into the object. Enlarges the internal buffer if necessary. │ │ │ │ │ +Definition mpipack.hh:58 │ │ │ │ │ +Dune::MPIPack::unpack │ │ │ │ │ +auto unpack(T &data) -> std::enable_if_t │ │ │ │ │ +Unpacks data from the object. │ │ │ │ │ +Definition mpipack.hh:95 │ │ │ │ │ +Dune::MPIPack::unpack │ │ │ │ │ +auto unpack(T &data) -> std::enable_if_t< decltype(getMPIData(data)):: │ │ │ │ │ +static_size, void > │ │ │ │ │ +Unpacks data from the object. │ │ │ │ │ +Definition mpipack.hh:81 │ │ │ │ │ +Dune::MPIPack::operator== │ │ │ │ │ +friend bool operator==(const MPIPack &a, const MPIPack &b) │ │ │ │ │ +Definition mpipack.hh:186 │ │ │ │ │ +Dune::MPIPack::MPIPack │ │ │ │ │ +MPIPack(const MPIPack &)=delete │ │ │ │ │ +Dune::MPIPack::seek │ │ │ │ │ +void seek(int p) │ │ │ │ │ +Sets the position in the buffer where the next pack/unpack operation should │ │ │ │ │ +take place. │ │ │ │ │ +Definition mpipack.hh:160 │ │ │ │ │ +Dune::MPIPack::eof │ │ │ │ │ +bool eof() const │ │ │ │ │ +Checks whether the end of the buffer is reached. │ │ │ │ │ +Definition mpipack.hh:173 │ │ │ │ │ +Dune::MPIPack::resize │ │ │ │ │ +void resize(size_t size) │ │ │ │ │ +Resizes the internal buffer. │ │ │ │ │ +Definition mpipack.hh:141 │ │ │ │ │ +Dune::MPIPack::tell │ │ │ │ │ +int tell() const │ │ │ │ │ +Gets the position in the buffer where the next pack/unpack operation should │ │ │ │ │ +take place. │ │ │ │ │ +Definition mpipack.hh:167 │ │ │ │ │ +Dune::MPIPack::MPIPack │ │ │ │ │ +MPIPack(MPIPack &&)=default │ │ │ │ │ +Dune::MPIPack::read │ │ │ │ │ +MPIPack & read(T &t) │ │ │ │ │ +Unpacks data from the object. │ │ │ │ │ +Definition mpipack.hh:126 │ │ │ │ │ +Dune::MPIPack::getPackSize │ │ │ │ │ +static int getPackSize(int len, const MPI_Comm &comm, const MPI_Datatype &dt) │ │ │ │ │ +Returns the size of the data needed to store the data in an MPIPack. See │ │ │ │ │ +MPI_Pack_size. │ │ │ │ │ +Definition mpipack.hh:180 │ │ │ │ │ +Dune::MPIPack::write │ │ │ │ │ +MPIPack & write(const T &t) │ │ │ │ │ +Packs the data into the object. Enlarges the internal buffer if necessary. │ │ │ │ │ +Definition mpipack.hh:133 │ │ │ │ │ +Dune::MPIData<_P,_std::enable_if_t<_std::is_same<_std::remove_const_t<_P_>, │ │ │ │ │ +MPIPack_>::value_>_>::type │ │ │ │ │ +MPI_Datatype type() const │ │ │ │ │ +Definition mpipack.hh:213 │ │ │ │ │ +Dune::MPIData<_P,_std::enable_if_t<_std::is_same<_std::remove_const_t<_P_>, │ │ │ │ │ +MPIPack_>::value_>_>::MPIData │ │ │ │ │ +MPIData(P &t) │ │ │ │ │ +Definition mpipack.hh:199 │ │ │ │ │ +Dune::MPIData<_P,_std::enable_if_t<_std::is_same<_std::remove_const_t<_P_>, │ │ │ │ │ +MPIPack_>::value_>_>::size │ │ │ │ │ +int size() │ │ │ │ │ +Definition mpipack.hh:209 │ │ │ │ │ +Dune::MPIData<_P,_std::enable_if_t<_std::is_same<_std::remove_const_t<_P_>, │ │ │ │ │ +MPIPack_>::value_>_>::ptr │ │ │ │ │ +void * ptr() │ │ │ │ │ +Definition mpipack.hh:205 │ │ │ │ │ +Dune::MPIData<_P,_std::enable_if_t<_std::is_same<_std::remove_const_t<_P_>, │ │ │ │ │ +MPIPack_>::value_>_>::data_ │ │ │ │ │ +P & data_ │ │ │ │ │ +Definition mpipack.hh:221 │ │ │ │ │ +Dune::MPIData<_P,_std::enable_if_t<_std::is_same<_std::remove_const_t<_P_>, │ │ │ │ │ +MPIPack_>::value_>_>::resize │ │ │ │ │ +void resize(int size) │ │ │ │ │ +Definition mpipack.hh:217 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00062.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: fmatrix.hh File Reference │ │ │ │ +dune-common: collectivecommunication.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,111 +65,24 @@ │ │ │ │

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
│ │ │ │ -Classes | │ │ │ │ -Namespaces | │ │ │ │ -Functions
│ │ │ │ - │ │ │ │ +
collectivecommunication.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ - │ │ │ │ -

Implements a matrix constructed from a given type representing a field and compile-time given number of rows and columns. │ │ │ │ -More...

│ │ │ │ -
#include <cmath>
│ │ │ │ -#include <cstddef>
│ │ │ │ -#include <iostream>
│ │ │ │ -#include <algorithm>
│ │ │ │ -#include <initializer_list>
│ │ │ │ -#include <dune/common/boundschecking.hh>
│ │ │ │ -#include <dune/common/exceptions.hh>
│ │ │ │ -#include <dune/common/fvector.hh>
│ │ │ │ -#include <dune/common/densematrix.hh>
│ │ │ │ -#include <dune/common/precision.hh>
│ │ │ │ -#include <dune/common/promotiontraits.hh>
│ │ │ │ -#include <dune/common/typetraits.hh>
│ │ │ │ -#include <dune/common/matrixconcepts.hh>
│ │ │ │ -#include "fmatrixev.hh"
│ │ │ │ +
#include <dune/common/parallel/communication.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

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

│ │ │ │ -Classes

struct  Dune::DenseMatVecTraits< FieldMatrix< K, ROWS, COLS > >
 
struct  Dune::FieldTraits< FieldMatrix< K, ROWS, COLS > >
 
class  Dune::FieldMatrix< K, ROWS, COLS >
 A dense n x m matrix. More...
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::FMatrixHelp
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Functions

template<typename K >
static K Dune::FMatrixHelp::invertMatrix (const FieldMatrix< K, 1, 1 > &matrix, FieldMatrix< K, 1, 1 > &inverse)
 invert scalar without changing the original matrix
 
template<typename K >
static K Dune::FMatrixHelp::invertMatrix_retTransposed (const FieldMatrix< K, 1, 1 > &matrix, FieldMatrix< K, 1, 1 > &inverse)
 invert scalar without changing the original matrix
 
template<typename K >
static K Dune::FMatrixHelp::invertMatrix (const FieldMatrix< K, 2, 2 > &matrix, FieldMatrix< K, 2, 2 > &inverse)
 invert 2x2 Matrix without changing the original matrix
 
template<typename K >
static K Dune::FMatrixHelp::invertMatrix_retTransposed (const FieldMatrix< K, 2, 2 > &matrix, FieldMatrix< K, 2, 2 > &inverse)
 
template<typename K >
static K Dune::FMatrixHelp::invertMatrix (const FieldMatrix< K, 3, 3 > &matrix, FieldMatrix< K, 3, 3 > &inverse)
 invert 3x3 Matrix without changing the original matrix
 
template<typename K >
static K Dune::FMatrixHelp::invertMatrix_retTransposed (const FieldMatrix< K, 3, 3 > &matrix, FieldMatrix< K, 3, 3 > &inverse)
 invert 3x3 Matrix without changing the original matrix
 
template<class K , int m, int n, int p>
static void Dune::FMatrixHelp::multMatrix (const FieldMatrix< K, m, n > &A, const FieldMatrix< K, n, p > &B, FieldMatrix< K, m, p > &ret)
 calculates ret = A * B
 
template<typename K , int rows, int cols>
static void Dune::FMatrixHelp::multTransposedMatrix (const FieldMatrix< K, rows, cols > &matrix, FieldMatrix< K, cols, cols > &ret)
 calculates ret= A_t*A
 
template<typename K , int rows, int cols>
static void Dune::FMatrixHelp::multAssignTransposed (const FieldMatrix< K, rows, cols > &matrix, const FieldVector< K, rows > &x, FieldVector< K, cols > &ret)
 calculates ret = matrix^T * x
 
template<typename K , int rows, int cols>
static FieldVector< K, rows > Dune::FMatrixHelp::mult (const FieldMatrix< K, rows, cols > &matrix, const FieldVector< K, cols > &x)
 calculates ret = matrix * x
 
template<typename K , int rows, int cols>
static FieldVector< K, cols > Dune::FMatrixHelp::multTransposed (const FieldMatrix< K, rows, cols > &matrix, const FieldVector< K, rows > &x)
 calculates ret = matrix^T * x
 
│ │ │ │ -

Detailed Description

│ │ │ │ -

Implements a matrix constructed from a given type representing a field and compile-time given number of rows and columns.

│ │ │ │ -
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,119 +6,14 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Functions │ │ │ │ │ -fmatrix.hh File Reference │ │ │ │ │ -Common » Dense_Matrix_and_Vector_Template_Library │ │ │ │ │ -Implements a matrix constructed from a given type representing a field and │ │ │ │ │ -compile-time given number of rows and columns. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include "fmatrixev.hh" │ │ │ │ │ + * parallel │ │ │ │ │ +collectivecommunication.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ - Classes │ │ │ │ │ -struct  Dune::DenseMatVecTraits<_FieldMatrix<_K,_ROWS,_COLS_>_> │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::FieldTraits<_FieldMatrix<_K,_ROWS,_COLS_>_> │ │ │ │ │ -  │ │ │ │ │ - class  Dune::FieldMatrix<_K,_ROWS,_COLS_> │ │ │ │ │ -  A dense n x m matrix. More... │ │ │ │ │ -  │ │ │ │ │ - Namespaces │ │ │ │ │ -namespace  Dune │ │ │ │ │ -  Dune namespace. │ │ │ │ │ -  │ │ │ │ │ -namespace  Dune::FMatrixHelp │ │ │ │ │ -  │ │ │ │ │ - Functions │ │ │ │ │ -template │ │ │ │ │ - static K Dune::FMatrixHelp::invertMatrix (const │ │ │ │ │ - FieldMatrix< K, 1, 1 > &matrix, FieldMatrix< K, │ │ │ │ │ - 1, 1 > &inverse) │ │ │ │ │ -  invert scalar without changing the original │ │ │ │ │ - matrix │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - static K Dune::FMatrixHelp::invertMatrix_retTransposed │ │ │ │ │ - (const FieldMatrix< K, 1, 1 > &matrix, │ │ │ │ │ - FieldMatrix< K, 1, 1 > &inverse) │ │ │ │ │ -  invert scalar without changing the original │ │ │ │ │ - matrix │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - static K Dune::FMatrixHelp::invertMatrix (const │ │ │ │ │ - FieldMatrix< K, 2, 2 > &matrix, FieldMatrix< K, │ │ │ │ │ - 2, 2 > &inverse) │ │ │ │ │ -  invert 2x2 Matrix without changing the original │ │ │ │ │ - matrix │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - static K Dune::FMatrixHelp::invertMatrix_retTransposed │ │ │ │ │ - (const FieldMatrix< K, 2, 2 > &matrix, │ │ │ │ │ - FieldMatrix< K, 2, 2 > &inverse) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - static K Dune::FMatrixHelp::invertMatrix (const │ │ │ │ │ - FieldMatrix< K, 3, 3 > &matrix, FieldMatrix< K, │ │ │ │ │ - 3, 3 > &inverse) │ │ │ │ │ -  invert 3x3 Matrix without changing the original │ │ │ │ │ - matrix │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - static K Dune::FMatrixHelp::invertMatrix_retTransposed │ │ │ │ │ - (const FieldMatrix< K, 3, 3 > &matrix, │ │ │ │ │ - FieldMatrix< K, 3, 3 > &inverse) │ │ │ │ │ -  invert 3x3 Matrix without changing the original │ │ │ │ │ - matrix │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - static void Dune::FMatrixHelp::multMatrix (const │ │ │ │ │ - FieldMatrix< K, m, n > &A, const FieldMatrix< K, │ │ │ │ │ - n, p > &B, FieldMatrix< K, m, p > &ret) │ │ │ │ │ -  calculates ret = A * B │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - static void Dune::FMatrixHelp::multTransposedMatrix (const │ │ │ │ │ - FieldMatrix< K, rows, cols > &matrix, │ │ │ │ │ - FieldMatrix< K, cols, cols > &ret) │ │ │ │ │ -  calculates ret= A_t*A │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - static void Dune::FMatrixHelp::multAssignTransposed (const │ │ │ │ │ - FieldMatrix< K, rows, cols > &matrix, const │ │ │ │ │ - FieldVector< K, rows > &x, FieldVector< K, cols │ │ │ │ │ - > &ret) │ │ │ │ │ -  calculates ret = matrix^T * x │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -static FieldVector< K, rows > Dune::FMatrixHelp::mult (const FieldMatrix< K, │ │ │ │ │ - rows, cols > &matrix, const FieldVector< K, cols │ │ │ │ │ - > &x) │ │ │ │ │ -  calculates ret = matrix * x │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -static FieldVector< K, cols > Dune::FMatrixHelp::multTransposed (const │ │ │ │ │ - FieldMatrix< K, rows, cols > &matrix, const │ │ │ │ │ - FieldVector< K, rows > &x) │ │ │ │ │ -  calculates ret = matrix^T * x │ │ │ │ │ -  │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -Implements a matrix constructed from a given type representing a field and │ │ │ │ │ -compile-time given number of rows and columns. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00062_source.html │ │ │ │ @@ -22,10431 +22,291 @@ │ │ │ │ 00000150: 656e 743d 2244 6f78 7967 656e 2031 2e39 ent="Doxygen 1.9 │ │ │ │ 00000160: 2e38 222f 3e0a 3c6d 6574 6120 6e61 6d65 .8"/>..dune-common: │ │ │ │ -000001c0: 666d 6174 7269 782e 6868 2053 6f75 7263 fmatrix.hh Sourc │ │ │ │ -000001d0: 6520 4669 6c65 3c2f 7469 746c 653e 0a3c e File.< │ │ │ │ -000001e0: 6c69 6e6b 2068 7265 663d 2274 6162 732e link href="tabs. │ │ │ │ -000001f0: 6373 7322 2072 656c 3d22 7374 796c 6573 css" rel="styles │ │ │ │ -00000200: 6865 6574 2220 7479 7065 3d22 7465 7874 heet" type="text │ │ │ │ -00000210: 2f63 7373 222f 3e0a 3c73 6372 6970 7420 /css"/>. │ │ │ │ -00000250: 0a3c 7363 7269 7074 2074 7970 653d 2274 ..< │ │ │ │ -00000290: 6c69 6e6b 2068 7265 663d 2273 6561 7263 link href="searc │ │ │ │ -000002a0: 682f 7365 6172 6368 2e63 7373 2220 7265 h/search.css" re │ │ │ │ -000002b0: 6c3d 2273 7479 6c65 7368 6565 7422 2074 l="stylesheet" t │ │ │ │ -000002c0: 7970 653d 2274 6578 742f 6373 7322 2f3e ype="text/css"/> │ │ │ │ -000002d0: 0a3c 7363 7269 7074 2074 7970 653d 2274 ...../* │ │ │ │ -00000690: 406c 6963 656e 7365 206d 6167 6e65 743a @license magnet: │ │ │ │ -000006a0: 3f78 743d 7572 6e3a 6274 6968 3a64 3364 ?xt=urn:btih:d3d │ │ │ │ -000006b0: 3961 3961 3635 3935 3532 3166 3936 3636 9a9a6595521f9666 │ │ │ │ -000006c0: 6135 6539 3463 6338 3330 6461 6238 3362 a5e94cc830dab83b │ │ │ │ -000006d0: 3635 3639 3926 616d 703b 646e 3d65 7870 65699&dn=exp │ │ │ │ -000006e0: 6174 2e74 7874 204d 4954 202a 2f0a 2428 at.txt MIT */.$( │ │ │ │ -000006f0: 6675 6e63 7469 6f6e 2829 207b 0a20 2069 function() {. i │ │ │ │ -00000700: 6e69 744d 656e 7528 2727 2c74 7275 652c nitMenu('',true, │ │ │ │ -00000710: 6661 6c73 652c 2773 6561 7263 682e 7068 false,'search.ph │ │ │ │ -00000720: 7027 2c27 5365 6172 6368 2729 3b0a 2020 p','Search');. │ │ │ │ -00000730: 2428 646f 6375 6d65 6e74 292e 7265 6164 $(document).read │ │ │ │ -00000740: 7928 6675 6e63 7469 6f6e 2829 207b 2069 y(function() { i │ │ │ │ -00000750: 6e69 745f 7365 6172 6368 2829 3b20 7d29 nit_search(); }) │ │ │ │ -00000760: 3b0a 7d29 3b0a 2f2a 2040 6c69 6365 6e73 ;.});./* @licens │ │ │ │ -00000770: 652d 656e 6420 2a2f 0a3c 2f73 6372 6970 e-end */..
../* │ │ │ │ -000007c0: 406c 6963 656e 7365 206d 6167 6e65 743a @license magnet: │ │ │ │ -000007d0: 3f78 743d 7572 6e3a 6274 6968 3a64 3364 ?xt=urn:btih:d3d │ │ │ │ -000007e0: 3961 3961 3635 3935 3532 3166 3936 3636 9a9a6595521f9666 │ │ │ │ -000007f0: 6135 6539 3463 6338 3330 6461 6238 3362 a5e94cc830dab83b │ │ │ │ -00000800: 3635 3639 3926 616d 703b 646e 3d65 7870 65699&dn=exp │ │ │ │ -00000810: 6174 2e74 7874 204d 4954 202a 2f0a 2428 at.txt MIT */.$( │ │ │ │ -00000820: 646f 6375 6d65 6e74 292e 7265 6164 7928 document).ready( │ │ │ │ -00000830: 6675 6e63 7469 6f6e 2829 207b 2069 6e69 function() { ini │ │ │ │ -00000840: 745f 636f 6465 666f 6c64 2830 293b 207d t_codefold(0); } │ │ │ │ -00000850: 293b 0a2f 2a20 406c 6963 656e 7365 2d65 );./* @license-e │ │ │ │ -00000860: 6e64 202a 2f0a 3c2f 7363 7269 7074 3e0a nd */.. │ │ │ │ -00000870: 3c21 2d2d 2077 696e 646f 7720 7368 6f77 .
.
.....
.
.< │ │ │ │ -00000a10: 6469 7620 6964 3d22 5352 5265 7375 6c74 div id="SRResult │ │ │ │ -00000a20: 7322 3e3c 2f64 6976 3e0a 3c64 6976 2063 s">
.
Loa │ │ │ │ -00000a50: 6469 6e67 2e2e 2e3c 2f64 6976 3e0a 3c64 ding...
.Searching...< │ │ │ │ -00000a90: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
No Ma │ │ │ │ -00000ac0: 7463 6865 733c 2f64 6976 3e0a 3c2f 6469 tches
..
. │ │ │ │ -00000ae0: 0a3c 2f64 6976 3e0a 0a3c 6469 7620 6964 ...
. < │ │ │ │ -00000b10: 756c 3e0a 3c6c 6920 636c 6173 733d 226e ul>.
  • dune< │ │ │ │ -00000b70: 2f6c 693e 3c6c 6920 636c 6173 733d 226e /li>
  • common
  • ..
    .
    . < │ │ │ │ -00000c10: 6469 7620 636c 6173 733d 2268 6561 6465 div class="heade │ │ │ │ -00000c20: 7274 6974 6c65 223e 3c64 6976 2063 6c61 rtitle">
    fmatr │ │ │ │ -00000c40: 6978 2e68 683c 2f64 6976 3e3c 2f64 6976 ix.hh
    ..
    .Go to the doc │ │ │ │ -00000ca0: 756d 656e 7461 7469 6f6e 206f 6620 7468 umentation of th │ │ │ │ -00000cb0: 6973 2066 696c 652e 3c2f 613e 3c64 6976 is file.
    1< │ │ │ │ -00000d20: 2f73 7061 6e3e 3c73 7061 6e20 636c 6173 /span>// - │ │ │ │ -00000d40: 2a2d 2074 6162 2d77 6964 7468 3a20 343b *- tab-width: 4; │ │ │ │ -00000d50: 2069 6e64 656e 742d 7461 6273 2d6d 6f64 indent-tabs-mod │ │ │ │ -00000d60: 653a 206e 696c 3b20 632d 6261 7369 632d e: nil; c-basic- │ │ │ │ -00000d70: 6f66 6673 6574 3a20 3220 2d2a 2d3c 2f73 offset: 2 -*-
    .
    2< │ │ │ │ -00000de0: 7370 616e 2063 6c61 7373 3d22 636f 6d6d span class="comm │ │ │ │ -00000df0: 656e 7422 3e2f 2f20 7669 3a20 7365 7420 ent">// vi: set │ │ │ │ -00000e00: 6574 2074 733d 3420 7377 3d32 2073 7473 et ts=4 sw=2 sts │ │ │ │ -00000e10: 3d32 3a3c 2f73 7061 6e3e 3c2f 6469 763e =2:
    │ │ │ │ -00000e20: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -00000e50: 3c2f 613e 3c73 7061 6e20 636c 6173 733d 3// SP │ │ │ │ -00000e90: 4458 2d46 696c 6543 6f70 7972 6967 6874 DX-FileCopyright │ │ │ │ -00000ea0: 496e 666f 3a20 436f 7079 7269 6768 7420 Info: Copyright │ │ │ │ -00000eb0: 2843 2920 4455 4e45 2050 726f 6a65 6374 (C) DUNE Project │ │ │ │ -00000ec0: 2063 6f6e 7472 6962 7574 6f72 732c 2073 contributors, s │ │ │ │ -00000ed0: 6565 2066 696c 6520 4c49 4345 4e53 452e ee file LICENSE. │ │ │ │ -00000ee0: 6d64 2069 6e20 6d6f 6475 6c65 2072 6f6f md in module roo │ │ │ │ -00000ef0: 743c 2f73 7061 6e3e 3c2f 6469 763e 0a3c t
    .< │ │ │ │ -00000f00: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -00000f10: 3e3c 6120 6964 3d22 6c30 3030 3034 2220 > 4// SPDX │ │ │ │ -00000f70: 2d4c 6963 656e 7365 2d49 6465 6e74 6966 -License-Identif │ │ │ │ -00000f80: 6965 723a 204c 6963 656e 7365 5265 662d ier: LicenseRef- │ │ │ │ -00000f90: 4750 4c2d 322e 302d 6f6e 6c79 2d77 6974 GPL-2.0-only-wit │ │ │ │ -00000fa0: 682d 4455 4e45 2d65 7863 6570 7469 6f6e h-DUNE-exception │ │ │ │ -00000fb0: 3c2f 7370 616e 3e3c 2f64 6976 3e0a 3c64
    . │ │ │ │ -00000fd0: 3c61 2069 643d 226c 3030 3030 3522 206e 5#if │ │ │ │ -00001030: 6e64 6566 2044 554e 455f 464d 4154 5249 ndef DUNE_FMATRI │ │ │ │ -00001040: 585f 4848 3c2f 7370 616e 3e3c 2f64 6976 X_HH
    .
    6< │ │ │ │ -000010a0: 2f73 7061 6e3e 3c73 7061 6e20 636c 6173 /span>#define DUNE_FM │ │ │ │ -000010d0: 4154 5249 585f 4848 3c2f 7370 616e 3e3c ATRIX_HH< │ │ │ │ -000010e0: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -00001130: 2020 373c 2f73 7061 6e3e 203c 2f64 6976 7
    .
    8< │ │ │ │ -00001190: 2f73 7061 6e3e 3c73 7061 6e20 636c 6173 /span>#include <cm │ │ │ │ -000011c0: 6174 6826 6774 3b3c 2f73 7061 6e3e 3c2f ath>.
    │ │ │ │ -00001220: 2039 3c2f 7370 616e 3e3c 7370 616e 2063 9#include < │ │ │ │ -00001250: 3b63 7374 6464 6566 2667 743b 3c2f 7370 ;cstddef>
    .
    10#includ │ │ │ │ -000012e0: 6520 266c 743b 696f 7374 7265 616d 2667 e <iostream&g │ │ │ │ -000012f0: 743b 3c2f 7370 616e 3e3c 2f64 6976 3e0a t;
    . │ │ │ │ -00001300: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65 .
    │ │ │ │ -000013e0: 2020 3132 3c2f 7370 616e 3e3c 7370 616e 12#include & │ │ │ │ -00001410: 6c74 3b69 6e69 7469 616c 697a 6572 5f6c lt;initializer_l │ │ │ │ -00001420: 6973 7426 6774 3b3c 2f73 7061 6e3e 3c2f ist>.
    │ │ │ │ -00001480: 3133 3c2f 7370 616e 3e20 3c2f 6469 763e 13
    │ │ │ │ -00001490: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -000014c0: 3c2f 613e 3c73 7061 6e20 636c 6173 733d 14 │ │ │ │ -00001500: 2369 6e63 6c75 6465 2026 6c74 3b3c 6120 #include < │ │ │ │ -00001530: 6475 6e65 2f63 6f6d 6d6f 6e2f 626f 756e dune/common/boun │ │ │ │ -00001540: 6473 6368 6563 6b69 6e67 2e68 683c 2f61 dschecking.hh>.
    15 │ │ │ │ -000015b0: 3c2f 7370 616e 3e3c 7370 616e 2063 6c61 #include << │ │ │ │ -000015e0: 6120 636c 6173 733d 2263 6f64 6522 2068 a class="code" h │ │ │ │ -000015f0: 7265 663d 2261 3030 3131 332e 6874 6d6c ref="a00113.html │ │ │ │ -00001600: 223e 6475 6e65 2f63 6f6d 6d6f 6e2f 6578 ">dune/common/ex │ │ │ │ -00001610: 6365 7074 696f 6e73 2e68 683c 2f61 3e26 ceptions.hh& │ │ │ │ -00001620: 6774 3b3c 2f73 7061 6e3e 3c2f 6469 763e gt;
    │ │ │ │ -00001630: 0a3c 6469 7620 636c 6173 733d 226c 696e ..
    < │ │ │ │ -00001730: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -00001740: 6e6f 223e 2020 2031 373c 2f73 7061 6e3e no"> 17 │ │ │ │ -00001750: 3c73 7061 6e20 636c 6173 733d 2270 7265 #incl │ │ │ │ -00001770: 7564 6520 266c 743b 3c61 2063 6c61 7373 ude <dune/ │ │ │ │ -000017a0: 636f 6d6d 6f6e 2f64 656e 7365 6d61 7472 common/densematr │ │ │ │ -000017b0: 6978 2e68 683c 2f61 3e26 6774 3b3c 2f73 ix.hh>
    .
    18< │ │ │ │ -00001820: 7370 616e 2063 6c61 7373 3d22 7072 6570 span class="prep │ │ │ │ -00001830: 726f 6365 7373 6f72 223e 2369 6e63 6c75 rocessor">#inclu │ │ │ │ -00001840: 6465 2026 6c74 3b3c 6120 636c 6173 733d de <dune/c │ │ │ │ -00001870: 6f6d 6d6f 6e2f 7072 6563 6973 696f 6e2e ommon/precision. │ │ │ │ -00001880: 6868 3c2f 613e 2667 743b 3c2f 7370 616e hh>
    .
    │ │ │ │ -000018e0: 2020 2031 393c 2f73 7061 6e3e 3c73 7061 19#include │ │ │ │ -00001910: 266c 743b 3c61 2063 6c61 7373 3d22 636f <dune/comm │ │ │ │ -00001940: 6f6e 2f70 726f 6d6f 7469 6f6e 7472 6169 on/promotiontrai │ │ │ │ -00001950: 7473 2e68 683c 2f61 3e26 6774 3b3c 2f73 ts.hh>
    .
    20< │ │ │ │ -000019c0: 7370 616e 2063 6c61 7373 3d22 7072 6570 span class="prep │ │ │ │ -000019d0: 726f 6365 7373 6f72 223e 2369 6e63 6c75 rocessor">#inclu │ │ │ │ -000019e0: 6465 2026 6c74 3b3c 6120 636c 6173 733d de <dune/c │ │ │ │ -00001a10: 6f6d 6d6f 6e2f 7479 7065 7472 6169 7473 ommon/typetraits │ │ │ │ -00001a20: 2e68 683c 2f61 3e26 6774 3b3c 2f73 7061 .hh>
    ..
    22 │ │ │ │ -00001b60: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -00001bb0: 2020 3233 3c2f 7370 616e 3e3c 7370 616e 23namespace Dune
    │ │ │ │ -00001c20: 0a3c 6469 7620 636c 6173 733d 226c 696e ..< │ │ │ │ -00001c90: 6120 6964 3d22 6c30 3030 3235 2220 6e61 a id="l00025" na │ │ │ │ -00001ca0: 6d65 3d22 6c30 3030 3235 223e 3c2f 613e me="l00025"> │ │ │ │ -00001cb0: 3c73 7061 6e20 636c 6173 733d 226c 696e 25
    .
    26 < │ │ │ │ -00001d30: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -00001d40: 6f72 6422 3e6e 616d 6573 7061 6365 203c ord">namespace < │ │ │ │ -00001d50: 2f73 7061 6e3e 496d 706c 3c2f 6469 763e /span>Impl
    │ │ │ │ -00001d60: 0a3c 6469 7620 636c 6173 733d 226c 696e ..< │ │ │ │ -00001dc0: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -00001dd0: 3e3c 6120 6964 3d22 6c30 3030 3238 2220 > 28
    .
    29 │ │ │ │ -00001e70: 2020 203c 7370 616e 2063 6c61 7373 3d22 templat │ │ │ │ -00001e90: 653c 2f73 7061 6e3e 266c 743b 3c73 7061 e<class M │ │ │ │ -00001ec0: 2667 743b 3c2f 6469 763e 0a3c 6469 7620 >
    .
    30 │ │ │ │ -00001f20: 2020 203c 7370 616e 2063 6c61 7373 3d22 class < │ │ │ │ -00001f40: 2f73 7061 6e3e 436f 6c75 6d6e 5665 6374 /span>ColumnVect │ │ │ │ -00001f50: 6f72 5669 6577 3c2f 6469 763e 0a3c 6469 orView
    .< │ │ │ │ -00001f70: 6120 6964 3d22 6c30 3030 3331 2220 6e61 a id="l00031" na │ │ │ │ -00001f80: 6d65 3d22 6c30 3030 3331 223e 3c2f 613e me="l00031"> │ │ │ │ -00001f90: 3c73 7061 6e20 636c 6173 733d 226c 696e 31 {
    .< │ │ │ │ -00001fd0: 6120 6964 3d22 6c30 3030 3332 2220 6e61 a id="l00032" na │ │ │ │ -00001fe0: 6d65 3d22 6c30 3030 3332 223e 3c2f 613e me="l00032"> │ │ │ │ -00001ff0: 3c73 7061 6e20 636c 6173 733d 226c 696e 32 publi │ │ │ │ -00002030: 633c 2f73 7061 6e3e 3a3c 2f64 6976 3e0a c:
    . │ │ │ │ -00002040: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65 .
    < │ │ │ │ -000020d0: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -000020e0: 6e6f 223e 2020 2033 343c 2f73 7061 6e3e no"> 34 │ │ │ │ -000020f0: 2020 2020 2020 3c73 7061 6e20 636c 6173 usin │ │ │ │ -00002110: 6720 3c2f 7370 616e 3e76 616c 7565 5f74 g value_t │ │ │ │ -00002120: 7970 6520 3d20 3c73 7061 6e20 636c 6173 ype = type │ │ │ │ -00002140: 6e61 6d65 3c2f 7370 616e 3e20 4d3a 3a76 name M::v │ │ │ │ -00002150: 616c 7565 5f74 7970 653b 3c2f 6469 763e alue_type;
    │ │ │ │ -00002160: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -00002190: 3c2f 613e 3c73 7061 6e20 636c 6173 733d 35 using si │ │ │ │ -000021e0: 7a65 5f74 7970 6520 3d20 3c73 7061 6e20 ze_type = │ │ │ │ -00002200: 7479 7065 6e61 6d65 3c2f 7370 616e 3e20 typename │ │ │ │ -00002210: 4d3a 3a73 697a 655f 7479 7065 3b3c 2f64 M::size_type;.
    3 │ │ │ │ -00002270: 363c 2f73 7061 6e3e 203c 2f64 6976 3e0a 6
    . │ │ │ │ -00002280: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    .
    │ │ │ │ -00002380: 2020 2033 383c 2f73 7061 6e3e 2020 2020 38 │ │ │ │ -00002390: 2020 2020 6d61 7472 6978 5f28 6d61 7472 matrix_(matr │ │ │ │ -000023a0: 6978 292c 3c2f 6469 763e 0a3c 6469 7620 ix),
    .
    39 │ │ │ │ -00002400: 2020 2020 2020 2063 6f6c 5f28 636f 6c29 col_(col) │ │ │ │ -00002410: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -00002460: 2020 3430 3c2f 7370 616e 3e20 2020 2020 40 │ │ │ │ -00002470: 207b 7d3c 2f64 6976 3e0a 3c64 6976 2063 {}
    .
    41 < │ │ │ │ -000024d0: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -00002520: 2034 323c 2f73 7061 6e3e 2020 2020 2020 42 │ │ │ │ -00002530: 3c73 7061 6e20 636c 6173 733d 226b 6579 constexpr< │ │ │ │ -00002550: 2f73 7061 6e3e 2073 697a 655f 7479 7065 /span> size_type │ │ │ │ -00002560: 204e 2028 293c 7370 616e 2063 6c61 7373 N () cons │ │ │ │ -00002580: 7420 3c2f 7370 616e 3e7b 3c2f 6469 763e t {
    │ │ │ │ -00002590: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -000025c0: 3c2f 613e 3c73 7061 6e20 636c 6173 733d 43 return matrix_.N() │ │ │ │ -00002620: 3b3c 2f64 6976 3e0a 3c64 6976 2063 6c61 ;
    .
    │ │ │ │ -00002670: 2020 2034 343c 2f73 7061 6e3e 2020 2020 44 │ │ │ │ -00002680: 2020 7d3c 2f64 6976 3e0a 3c64 6976 2063 }
    .
    45 < │ │ │ │ -000026e0: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -00002730: 2034 363c 2f73 7061 6e3e 2020 2020 2020 46 │ │ │ │ -00002740: 3c73 7061 6e20 636c 6173 733d 226b 6579 template<c │ │ │ │ -00002780: 6c61 7373 203c 2f73 7061 6e3e 4d5f 203d lass M_ = │ │ │ │ -00002790: 204d 2c3c 2f64 6976 3e0a 3c64 6976 2063 M,
    .
    47 │ │ │ │ -000027f0: 2020 2020 2020 7374 643a 3a65 6e61 626c std::enabl │ │ │ │ -00002800: 655f 6966 5f74 266c 743b 7374 643a 3a69 e_if_t<std::i │ │ │ │ -00002810: 735f 7361 6d65 5f76 266c 743b 4d5f 2c4d s_same_v<M_,M │ │ │ │ -00002820: 2667 743b 2061 6e64 206e 6f74 2073 7464 > and not std │ │ │ │ -00002830: 3a3a 6973 5f63 6f6e 7374 5f76 266c 743b ::is_const_v< │ │ │ │ -00002840: 4d5f 2667 743b 2c20 3c73 7061 6e20 636c M_>, int> │ │ │ │ -00002870: 203d 2030 2667 743b 3c2f 6469 763e 0a3c = 0>
    .< │ │ │ │ -00002880: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -00002890: 3e3c 6120 6964 3d22 6c30 3030 3438 2220 > 48
    c │ │ │ │ -000028f0: 6f6e 7374 6578 7072 3c2f 7370 616e 3e20 onstexpr │ │ │ │ -00002900: 7661 6c75 655f 7479 7065 2661 6d70 3b20 value_type& │ │ │ │ -00002910: 6f70 6572 6174 6f72 5b5d 2028 7369 7a65 operator[] (size │ │ │ │ -00002920: 5f74 7970 6520 726f 7729 207b 3c2f 6469 _type row) {.
    49 │ │ │ │ -00002980: 3c2f 7370 616e 3e20 2020 2020 2020 203c < │ │ │ │ -00002990: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -000029a0: 6f72 6466 6c6f 7722 3e72 6574 7572 6e3c ordflow">return< │ │ │ │ -000029b0: 2f73 7061 6e3e 206d 6174 7269 785f 5b72 /span> matrix_[r │ │ │ │ -000029c0: 6f77 5d5b 636f 6c5f 5d3b 3c2f 6469 763e ow][col_];
    │ │ │ │ -000029d0: 0a3c 6469 7620 636c 6173 733d 226c 696e ..
    53 │ │ │ │ -00002be0: 2020 2020 203c 7370 616e 2063 6c61 7373 r │ │ │ │ -00002c00: 6574 7572 6e3c 2f73 7061 6e3e 206d 6174 eturn mat │ │ │ │ -00002c10: 7269 785f 5b72 6f77 5d5b 636f 6c5f 5d3b rix_[row][col_]; │ │ │ │ -00002c20: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -00002c70: 2020 3534 3c2f 7370 616e 3e20 2020 2020 54 │ │ │ │ -00002c80: 207d 3c2f 6469 763e 0a3c 6469 7620 636c }
    .
    55 .
    │ │ │ │ -00002d30: 3536 3c2f 7370 616e 3e20 2020 203c 7370 56 protected:
    .
    57 │ │ │ │ -00002dc0: 2020 2020 204d 2661 6d70 3b20 6d61 7472 M& matr │ │ │ │ -00002dd0: 6978 5f3b 3c2f 6469 763e 0a3c 6469 7620 ix_;
    .
    58 │ │ │ │ -00002e30: 2020 2020 203c 7370 616e 2063 6c61 7373 const │ │ │ │ -00002e50: 3c2f 7370 616e 3e20 7369 7a65 5f74 7970 size_typ │ │ │ │ -00002e60: 6520 636f 6c5f 3b3c 2f64 6976 3e0a 3c64 e col_;
    . │ │ │ │ -00002e80: 3c61 2069 643d 226c 3030 3035 3922 206e 59
    };
    .< │ │ │ │ -00002ed0: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -00002ee0: 3e3c 6120 6964 3d22 6c30 3030 3630 2220 > 60
    .
    61 │ │ │ │ -00002f80: 207d 3c2f 6469 763e 0a3c 6469 7620 636c }
    .
    62 .
    │ │ │ │ -00003030: 3633 3c2f 7370 616e 3e20 203c 7370 616e 63 template │ │ │ │ -00003060: 266c 743b 3c73 7061 6e20 636c 6173 733d <typena │ │ │ │ -00003080: 6d65 3c2f 7370 616e 3e20 4d26 6774 3b3c me M>< │ │ │ │ -00003090: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -000030e0: 2036 343c 2f73 7061 6e3e 2020 3c73 7061 64 struct │ │ │ │ -00003110: 4669 656c 6454 7261 6974 7326 6c74 3b20 FieldTraits< │ │ │ │ -00003120: 496d 706c 3a3a 436f 6c75 6d6e 5665 6374 Impl::ColumnVect │ │ │ │ -00003130: 6f72 5669 6577 266c 743b 4d26 6774 3b20 orView<M> │ │ │ │ -00003140: 2667 743b 3c2f 6469 763e 0a3c 6469 7620 >
    .
    65 │ │ │ │ -000031a0: 207b 3c2f 6469 763e 0a3c 6469 7620 636c {
    ..
    │ │ │ │ -00003370: 2020 3637 3c2f 7370 616e 3e20 2020 203c 67 < │ │ │ │ -00003380: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -00003390: 6f72 6422 3e75 7369 6e67 203c 2f73 7061 ord">using real_type │ │ │ │ -00003400: 3d20 3c73 7061 6e20 636c 6173 733d 226b = typename │ │ │ │ -00003420: 3c2f 7370 616e 3e20 3c61 2063 6c61 7373 FieldTra │ │ │ │ -00003480: 6974 7326 6c74 3b4d 2667 743b 3a3a 7265 its<M>::re │ │ │ │ -00003490: 616c 5f74 7970 653c 2f61 3e3b 3c2f 6469 al_type;.
    68 │ │ │ │ -000034f0: 3c2f 7370 616e 3e20 207d 3b3c 2f64 6976 };
    .
    69< │ │ │ │ -00003550: 2f73 7061 6e3e 203c 2f64 6976 3e0a 3c64 /span>
    . │ │ │ │ -00003570: 3c61 2069 643d 226c 3030 3038 3122 206e 81 templa │ │ │ │ -000035d0: 7465 3c2f 7370 616e 3e26 6c74 3b20 3c73 te< class │ │ │ │ -00003600: 204b 2c20 3c73 7061 6e20 636c 6173 733d K, in │ │ │ │ -00003620: 743c 2f73 7061 6e3e 2052 4f57 532c 203c t ROWS, < │ │ │ │ -00003630: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -00003640: 6f72 6474 7970 6522 3e69 6e74 3c2f 7370 ordtype">int COLS = ROWS │ │ │ │ -00003660: 2667 743b 203c 7370 616e 2063 6c61 7373 > class │ │ │ │ -00003680: 203c 2f73 7061 6e3e 4669 656c 644d 6174 FieldMat │ │ │ │ -00003690: 7269 783b 3c2f 6469 763e 0a3c 6469 7620 rix;
    .
    82 │ │ │ │ -000036f0: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -00003740: 2020 3833 3c2f 7370 616e 3e20 3c2f 6469 83 .
    84 │ │ │ │ -000037a0: 3c2f 7370 616e 3e20 203c 7370 616e 2063 t │ │ │ │ -000037c0: 656d 706c 6174 653c 2f73 7061 6e3e 266c emplate&l │ │ │ │ -000037d0: 743b 203c 7370 616e 2063 6c61 7373 3d22 t; class K, int RO │ │ │ │ -00003820: 5753 2c20 3c73 7061 6e20 636c 6173 733d WS, in │ │ │ │ -00003840: 743c 2f73 7061 6e3e 2043 4f4c 5320 2667 t COLS &g │ │ │ │ -00003850: 743b 3c2f 6469 763e 0a3c 6469 7620 636c t;
    .
    . │ │ │ │ -000038a0: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65 .
    86< │ │ │ │ -00003a30: 2f73 7061 6e3e 2020 7b3c 2f64 6976 3e0a /span> {
    . │ │ │ │ -00003a40: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65 .< │ │ │ │ -00003bd0: 6120 6964 3d22 6c30 3030 3838 2220 6e61 a id="l00088" na │ │ │ │ -00003be0: 6d65 3d22 6c30 3030 3838 223e 3c2f 613e me="l00088"> │ │ │ │ -00003bf0: 3c73 7061 6e20 636c 6173 733d 226c 696e 88
    .
    89 │ │ │ │ -00003c70: 203c 7370 616e 2063 6c61 7373 3d22 636f // each r │ │ │ │ -00003c90: 6f77 2069 7320 696d 706c 656d 656e 7465 ow is implemente │ │ │ │ -00003ca0: 6420 6279 2061 2066 6965 6c64 2076 6563 d by a field vec │ │ │ │ -00003cb0: 746f 723c 2f73 7061 6e3e 3c2f 6469 763e tor
    │ │ │ │ -00003cc0: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -00003cf0: 3c2f 613e 3c73 7061 6e20 636c 6173 733d │ │ │ │ -00003d50: 2039 303c 2f61 3e3c 2f73 7061 6e3e 2020 90 │ │ │ │ -00003d60: 2020 3c73 7061 6e20 636c 6173 733d 226b typedef< │ │ │ │ -00003d80: 2f73 7061 6e3e 203c 6120 636c 6173 733d /span> FieldVector&l │ │ │ │ -00003dc0: 743b 4b2c 434f 4c53 2667 743b 3c2f 613e t;K,COLS> │ │ │ │ -00003dd0: 203c 6120 636c 6173 733d 2263 6f64 6520 row_type;.
    │ │ │ │ -00003e80: 3931 3c2f 7370 616e 3e20 3c2f 6469 763e 91
    │ │ │ │ -00003e90: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -00003ec0: 3c2f 613e 3c73 7061 6e20 636c 6173 733d │ │ │ │ -00003f20: 2039 323c 2f61 3e3c 2f73 7061 6e3e 2020 92 │ │ │ │ -00003f30: 2020 3c73 7061 6e20 636c 6173 733d 226b typedef< │ │ │ │ -00003f50: 2f73 7061 6e3e 203c 6120 636c 6173 733d /span> row_type │ │ │ │ -00003f90: 2661 6d70 3b3c 6120 636c 6173 733d 2263 &row_referen │ │ │ │ -00003ff0: 6365 3c2f 613e 3b3c 2f64 6976 3e0a 3c64 ce;
    . │ │ │ │ -00004010: 3c61 2069 643d 226c 3030 3039 3322 206e 93 │ │ │ │ -00004090: 3c2f 613e 3c2f 7370 616e 3e20 2020 203c < │ │ │ │ -000040a0: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -000040b0: 6f72 6422 3e74 7970 6564 6566 3c2f 7370 ord">typedef const< │ │ │ │ -000040e0: 2f73 7061 6e3e 203c 6120 636c 6173 733d /span> row_type │ │ │ │ -00004120: 2661 6d70 3b3c 6120 636c 6173 733d 2263 &const_row_r │ │ │ │ -00004180: 6566 6572 656e 6365 3c2f 613e 3b3c 2f64 eference;.
    9 │ │ │ │ -000041e0: 343c 2f73 7061 6e3e 203c 2f64 6976 3e0a 4
    . │ │ │ │ -000041f0: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    < │ │ │ │ -00004220: 2f61 3e3c 7370 616e 2063 6c61 7373 3d22 /a> │ │ │ │ -00004280: 3935 3c2f 613e 3c2f 7370 616e 3e20 2020 95 │ │ │ │ -00004290: 203c 7370 616e 2063 6c61 7373 3d22 6b65 typedef std::array │ │ │ │ -000042c0: 266c 743b 726f 775f 7479 7065 2c52 4f57 <row_type,ROW │ │ │ │ -000042d0: 5326 6774 3b20 3c61 2063 6c61 7373 3d22 S> container_ │ │ │ │ -00004330: 7479 7065 3c2f 613e 3b3c 2f64 6976 3e0a type;
    . │ │ │ │ -00004340: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65 . │ │ │ │ -00004480: 3c61 2069 643d 226c 3030 3039 3722 206e 97 │ │ │ │ -00004500: 3c2f 613e 3c2f 7370 616e 3e20 2020 203c < │ │ │ │ -00004510: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -00004520: 6f72 6422 3e74 7970 6564 6566 3c2f 7370 ord">typedef typena │ │ │ │ -00004550: 6d65 3c2f 7370 616e 3e20 636f 6e74 6169 me contai │ │ │ │ -00004560: 6e65 725f 7479 7065 3a3a 7369 7a65 5f74 ner_type::size_t │ │ │ │ -00004570: 7970 6520 3c61 2063 6c61 7373 3d22 636f ype size_type;
    .
    98 } │ │ │ │ -00004630: 3b3c 2f64 6976 3e0a 3c2f 6469 763e 0a3c ;
    .
    .< │ │ │ │ -00004640: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -00004650: 3e3c 6120 6964 3d22 6c30 3030 3939 2220 > 99
    .
    100 │ │ │ │ -000046f0: 203c 7370 616e 2063 6c61 7373 3d22 6b65 template< │ │ │ │ -00004710: 2f73 7061 6e3e 266c 743b 203c 7370 616e /span>< class K, │ │ │ │ -00004740: 203c 7370 616e 2063 6c61 7373 3d22 6b65 int ROWS, int │ │ │ │ -00004790: 2043 4f4c 5320 2667 743b 3c2f 6469 763e COLS >
    │ │ │ │ -000047a0: 0a3c 6469 7620 636c 6173 733d 2266 6f6c .
    .
    │ │ │ │ -00004830: 3c61 2063 6c61 7373 3d22 6c69 6e65 2220 101 struc │ │ │ │ -00004880: 7420 3c2f 7370 616e 3e3c 6120 636c 6173 t FieldTrait │ │ │ │ -000048c0: 733c 2f61 3e26 6c74 3b20 3c61 2063 6c61 s< FieldMatri │ │ │ │ -00004900: 783c 2f61 3e26 6c74 3b4b 2c52 4f57 532c x<K,ROWS, │ │ │ │ -00004910: 434f 4c53 2667 743b 2026 6774 3b3c 2f64 COLS> >.
    10 │ │ │ │ -00004970: 323c 2f73 7061 6e3e 2020 7b3c 2f64 6976 2 {
    .
    │ │ │ │ -00004a10: 2031 3033 3c2f 613e 3c2f 7370 616e 3e20 103 │ │ │ │ -00004a20: 2020 203c 7370 616e 2063 6c61 7373 3d22 typedef │ │ │ │ -00004a40: 3c2f 7370 616e 3e20 3c73 7061 6e20 636c ty │ │ │ │ -00004a60: 7065 6e61 6d65 3c2f 7370 616e 3e20 3c61 pename Fi │ │ │ │ -00004ac0: 656c 6454 7261 6974 7326 6c74 3b4b 2667 eldTraits<K&g │ │ │ │ -00004ad0: 743b 3a3a 6669 656c 645f 7479 7065 3c2f t;::field_type field_type;
    .
    104< │ │ │ │ -00004be0: 2f73 7061 6e3e 2020 2020 3c73 7061 6e20 /span> │ │ │ │ -00004c00: 7479 7065 6465 663c 2f73 7061 6e3e 203c typedef < │ │ │ │ -00004c10: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -00004c20: 6f72 6422 3e74 7970 656e 616d 653c 2f73 ord">typename FieldTraits │ │ │ │ -00004c90: 266c 743b 4b26 6774 3b3a 3a72 6561 6c5f <K>::real_ │ │ │ │ -00004ca0: 7479 7065 3c2f 613e 203c 6120 636c 6173 type real_ty │ │ │ │ -00004d00: 7065 3c2f 613e 3b3c 2f64 6976 3e0a 3c64 pe;
    . │ │ │ │ -00004d20: 3c61 2069 643d 226c 3030 3130 3522 206e 105 };
    ..
    10 │ │ │ │ -00004dc0: 363c 2f73 7061 6e3e 203c 2f64 6976 3e0a 6
    . │ │ │ │ -00004dd0: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    < │ │ │ │ -00004e00: 2f61 3e3c 7370 616e 2063 6c61 7373 3d22 /a> 115 temp │ │ │ │ -00004e40: 6c61 7465 3c2f 7370 616e 3e26 6c74 3b3c late<< │ │ │ │ -00004e50: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -00004e60: 6f72 6422 3e63 6c61 7373 3c2f 7370 616e ord">class K, i │ │ │ │ -00004e90: 6e74 3c2f 7370 616e 3e20 524f 5753 2c20 nt ROWS, │ │ │ │ -00004ea0: 3c73 7061 6e20 636c 6173 733d 226b 6579 int COLS>.
    .
    116< │ │ │ │ -00004f90: 2f73 7061 6e3e 2020 3c73 7061 6e20 636c /span> cl │ │ │ │ -00004fb0: 6173 7320 3c2f 7370 616e 3e3c 6120 636c ass FieldMatr │ │ │ │ -00004ff0: 6978 3c2f 613e 203a 203c 7370 616e 2063 ix : p │ │ │ │ -00005010: 7562 6c69 633c 2f73 7061 6e3e 203c 6120 ublic DenseMa │ │ │ │ -00005050: 7472 6978 3c2f 613e 266c 743b 2046 6965 trix< Fie │ │ │ │ -00005060: 6c64 4d61 7472 6978 266c 743b 4b2c 524f ldMatrix<K,RO │ │ │ │ -00005070: 5753 2c43 4f4c 5326 6774 3b20 2667 743b WS,COLS> > │ │ │ │ -00005080: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -000050d0: 2031 3137 3c2f 7370 616e 3e20 207b 3c2f 117 {.
    1 │ │ │ │ -00005130: 3138 3c2f 7370 616e 3e20 2020 2073 7464 18 std │ │ │ │ -00005140: 3a3a 6172 7261 7926 6c74 3b20 4669 656c ::array< Fiel │ │ │ │ -00005150: 6456 6563 746f 7226 6c74 3b4b 2c43 4f4c dVector<K,COL │ │ │ │ -00005160: 5326 6774 3b2c 2052 4f57 5320 2667 743b S>, ROWS > │ │ │ │ -00005170: 205f 6461 7461 3b3c 2f64 6976 3e0a 3c64 _data;
    . │ │ │ │ -00005190: 3c61 2069 643d 226c 3030 3131 3922 206e 119 type │ │ │ │ -000051f0: 6465 663c 2f73 7061 6e3e 203c 6120 636c def DenseMatr │ │ │ │ -00005230: 6978 266c 743b 2046 6965 6c64 4d61 7472 ix< FieldMatr │ │ │ │ -00005240: 6978 266c 743b 4b2c 524f 5753 2c43 4f4c ix<K,ROWS,COL │ │ │ │ -00005250: 5326 6774 3b3c 2f61 3e20 2667 743b 203c S> > < │ │ │ │ -00005260: 6120 636c 6173 733d 2263 6f64 6520 686c a class="code hl │ │ │ │ -00005270: 5f63 6c61 7373 2220 6872 6566 3d22 6130 _class" href="a0 │ │ │ │ -00005280: 3134 3030 2e68 746d 6c22 3e42 6173 653c 1400.html">Base< │ │ │ │ -00005290: 2f61 3e3b 3c2f 6469 763e 0a3c 6469 7620 /a>;
    .
    120 │ │ │ │ -000052f0: 203c 7370 616e 2063 6c61 7373 3d22 6b65 public:
    .
    < │ │ │ │ -00005350: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -00005360: 6e6f 223e 2020 3132 313c 2f73 7061 6e3e no"> 121 │ │ │ │ -00005370: 203c 2f64 6976 3e0a 3c64 6976 2063 6c61
    .
    │ │ │ │ -000053c0: 3c61 2063 6c61 7373 3d22 6c69 6e65 2220 123 c │ │ │ │ -00005430: 6f6e 7374 6578 7072 3c2f 7370 616e 3e20 onstexpr │ │ │ │ -00005440: 3c73 7061 6e20 636c 6173 733d 226b 6579 static in │ │ │ │ -00005480: 743c 2f73 7061 6e3e 203c 6120 636c 6173 t rows = ROWS;
    │ │ │ │ -000054f0: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -00005520: 3c2f 613e 3c73 7061 6e20 636c 6173 733d │ │ │ │ -00005580: 3132 353c 2f61 3e3c 2f73 7061 6e3e 2020 125 │ │ │ │ -00005590: 2020 3c73 7061 6e20 636c 6173 733d 226b constexp │ │ │ │ -000055b0: 723c 2f73 7061 6e3e 203c 7370 616e 2063 r s │ │ │ │ -000055d0: 7461 7469 633c 2f73 7061 6e3e 203c 7370 tatic int cols = CO │ │ │ │ -00005660: 4c53 3b3c 2f64 6976 3e0a 3c64 6976 2063 LS;
    .
    126 < │ │ │ │ -000056c0: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>..
    128 typedef │ │ │ │ -00005940: 203c 7370 616e 2063 6c61 7373 3d22 6b65 typename< │ │ │ │ -00005960: 2f73 7061 6e3e 203c 6120 636c 6173 733d /span> Base::row_typ │ │ │ │ -000059a0: 653c 2f61 3e20 3c61 2063 6c61 7373 3d22 e row_type;
    .
    129 < │ │ │ │ -00005a60: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>..< │ │ │ │ -00005c00: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -00005c10: 3e3c 6120 6964 3d22 6c30 3031 3331 2220 > 13 │ │ │ │ -00005c90: 313c 2f61 3e3c 2f73 7061 6e3e 2020 2020 1 │ │ │ │ -00005ca0: 3c73 7061 6e20 636c 6173 733d 226b 6579 typedef typen │ │ │ │ -00005ce0: 616d 653c 2f73 7061 6e3e 203c 6120 636c ame Base::con │ │ │ │ -00005d20: 7374 5f72 6f77 5f72 6566 6572 656e 6365 st_row_reference │ │ │ │ -00005d30: 3c2f 613e 203c 6120 636c 6173 733d 2263 const_row_r │ │ │ │ -00005d90: 6566 6572 656e 6365 3c2f 613e 3b3c 2f64 eference;.
    13 │ │ │ │ -00005df0: 323c 2f73 7061 6e3e 203c 2f64 6976 3e0a 2
    . │ │ │ │ -00005e00: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    . │ │ │ │ -00005e90: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    < │ │ │ │ -00005ec0: 2f61 3e3c 7370 616e 2063 6c61 7373 3d22 /a> 1 │ │ │ │ -00005f20: 3336 3c2f 613e 3c2f 7370 616e 3e20 2020 36 │ │ │ │ -00005f30: 203c 7370 616e 2063 6c61 7373 3d22 6b65 constexpr │ │ │ │ -00005f50: 3c2f 7370 616e 3e20 3c61 2063 6c61 7373 FieldMa │ │ │ │ -00005fb0: 7472 6978 3c2f 613e 2829 203d 203c 7370 trix() = default;
    .< │ │ │ │ -00006000: 6120 6964 3d22 6c30 3031 3337 2220 6e61 a id="l00137" na │ │ │ │ -00006010: 6d65 3d22 6c30 3031 3337 223e 3c2f 613e me="l00137"> │ │ │ │ -00006020: 3c73 7061 6e20 636c 6173 733d 226c 696e 137
    .
    .< │ │ │ │ -00006090: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -000060a0: 3e3c 6120 6964 3d22 6c30 3031 3430 2220 > 14 │ │ │ │ -00006120: 303c 2f61 3e3c 2f73 7061 6e3e 2020 2020 0 │ │ │ │ -00006130: 3c61 2063 6c61 7373 3d22 636f 6465 2068 FieldMatrix │ │ │ │ -00006190: 2873 7464 3a3a 696e 6974 6961 6c69 7a65 (std::initialize │ │ │ │ -000061a0: 725f 6c69 7374 266c 743b 3c61 2063 6c61 r_list<Dune::Fiel │ │ │ │ -000061e0: 6456 6563 746f 7226 6c74 3b4b 2c20 636f dVector<K, co │ │ │ │ -000061f0: 6c73 2667 743b 3c2f 613e 2026 6774 3b20 ls> > │ │ │ │ -00006200: 3c73 7061 6e20 636c 6173 733d 226b 6579 const &l) {.
    141 │ │ │ │ -00006280: 3c2f 7370 616e 3e20 2020 2020 2061 7373 ass │ │ │ │ -00006290: 6572 7428 6c2e 7369 7a65 2829 203d 3d20 ert(l.size() == │ │ │ │ -000062a0: 3c61 2063 6c61 7373 3d22 636f 6465 2068 rows); // Actually, t │ │ │ │ -00006320: 6869 7320 6973 206e 6f74 206e 6565 6465 his is not neede │ │ │ │ -00006330: 6420 616e 7920 6d6f 7265 213c 2f73 7061 d any more!
    .
    142 │ │ │ │ -000063a0: 2020 2073 7464 3a3a 636f 7079 5f6e 286c std::copy_n(l │ │ │ │ -000063b0: 2e62 6567 696e 2829 2c20 7374 643a 3a6d .begin(), std::m │ │ │ │ -000063c0: 696e 283c 7370 616e 2063 6c61 7373 3d22 in(static_ │ │ │ │ -000063e0: 6361 7374 266c 743b 3c2f 7370 616e 3e73 cast<s │ │ │ │ -000063f0: 7464 3a3a 7369 7a65 5f74 3c73 7061 6e20 td::size_t │ │ │ │ -00006410: 2667 743b 3c2f 7370 616e 3e28 524f 5753 >(ROWS │ │ │ │ -00006420: 292c 3c2f 6469 763e 0a3c 6469 7620 636c ),
    .
    143 │ │ │ │ -00006480: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ │ -00006490: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ │ -000064a0: 2020 206c 2e73 697a 6528 2929 2c3c 2f64 l.size()),.
    14 │ │ │ │ -00006500: 343c 2f73 7061 6e3e 2020 2020 2020 2020 4 │ │ │ │ -00006510: 2020 2020 2020 2020 205f 6461 7461 2e62 _data.b │ │ │ │ -00006520: 6567 696e 2829 293b 3c2f 6469 763e 0a3c egin());
    .< │ │ │ │ -00006530: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -00006540: 3e3c 6120 6964 3d22 6c30 3031 3435 2220 > 145 }
    .< │ │ │ │ -00006590: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -000065e0: 3134 363c 2f73 7061 6e3e 203c 2f64 6976 146
    .
    147< │ │ │ │ -00006640: 2f73 7061 6e3e 2020 2020 3c73 7061 6e20 /span> │ │ │ │ -00006660: 7465 6d70 6c61 7465 3c2f 7370 616e 3e20 template │ │ │ │ -00006670: 266c 743b 3c73 7061 6e20 636c 6173 733d <class │ │ │ │ -00006690: 3c2f 7370 616e 3e54 2c3c 2f64 6976 3e0a T,
    . │ │ │ │ -000066a0: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    . │ │ │ │ -00006780: 3c64 6976 2063 6c61 7373 3d22 666f 6c64
    .
    149 FieldMat │ │ │ │ -000068c0: 7269 783c 2f61 3e28 5420 3c73 7061 6e20 rix(T │ │ │ │ -000068e0: 636f 6e73 743c 2f73 7061 6e3e 2661 6d70 const& │ │ │ │ -000068f0: 3b20 7268 7329 3c2f 6469 763e 0a3c 6469 ; rhs)
    .< │ │ │ │ -00006910: 6120 6964 3d22 6c30 3031 3530 2220 6e61 a id="l00150" na │ │ │ │ -00006920: 6d65 3d22 6c30 3031 3530 223e 3c2f 613e me="l00150"> │ │ │ │ -00006930: 3c73 7061 6e20 636c 6173 733d 226c 696e 150 {
    .< │ │ │ │ -00006970: 6120 6964 3d22 6c30 3031 3531 2220 6e61 a id="l00151" na │ │ │ │ -00006980: 6d65 3d22 6c30 3031 3531 223e 3c2f 613e me="l00151"> │ │ │ │ -00006990: 3c73 7061 6e20 636c 6173 733d 226c 696e 151 *th │ │ │ │ -000069d0: 6973 3c2f 7370 616e 3e20 3d20 7268 733b is = rhs; │ │ │ │ -000069e0: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -00006a30: 2031 3532 3c2f 7370 616e 3e20 2020 207d 152 } │ │ │ │ -00006a40: 3c2f 6469 763e 0a3c 2f64 6976 3e0a 3c64
    .
    . │ │ │ │ -00006a60: 3c61 2069 643d 226c 3030 3135 3322 206e 153
    .
    154 │ │ │ │ -00006b00: 2020 3c73 7061 6e20 636c 6173 733d 226b using Base::opera │ │ │ │ -00006b30: 746f 723d 3b3c 2f64 6976 3e0a 3c64 6976 tor=;
    .
    < │ │ │ │ -00006b70: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -00006b80: 6e6f 223e 2020 3135 353c 2f73 7061 6e3e no"> 155 │ │ │ │ -00006b90: 203c 2f64 6976 3e0a 3c64 6976 2063 6c61
    .
    │ │ │ │ -00006be0: 3c61 2063 6c61 7373 3d22 6c69 6e65 2220 157 FieldMatrix │ │ │ │ -00006c70: 3c2f 613e 2661 6d70 3b20 3c61 2063 6c61 & opera │ │ │ │ -00006cd0: 746f 723d 3c2f 613e 283c 7370 616e 2063 tor=(c │ │ │ │ -00006cf0: 6f6e 7374 3c2f 7370 616e 3e20 3c61 2063 onst FieldMat │ │ │ │ -00006d30: 7269 783c 2f61 3e26 616d 703b 2920 3d20 rix&) = │ │ │ │ -00006d40: 3c73 7061 6e20 636c 6173 733d 226b 6579 defaul │ │ │ │ -00006d60: 743c 2f73 7061 6e3e 3b3c 2f64 6976 3e0a t;
    . │ │ │ │ -00006d70: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    .
    < │ │ │ │ -00006e00: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -00006e10: 6e6f 223e 2020 3136 303c 2f73 7061 6e3e no"> 160 │ │ │ │ -00006e20: 2020 2020 3c73 7061 6e20 636c 6173 733d templa │ │ │ │ -00006e40: 7465 3c2f 7370 616e 3e26 6c74 3b3c 7370 te<typename T>
    .< │ │ │ │ -00006e80: 6469 7620 636c 6173 733d 2266 6f6c 646f div class="foldo │ │ │ │ -00006e90: 7065 6e22 2069 643d 2266 6f6c 646f 7065 pen" id="foldope │ │ │ │ -00006ea0: 6e30 3031 3631 2220 6461 7461 2d73 7461 n00161" data-sta │ │ │ │ -00006eb0: 7274 3d22 7b22 2064 6174 612d 656e 643d rt="{" data-end= │ │ │ │ -00006ec0: 227d 223e 0a3c 6469 7620 636c 6173 733d "}">..
    │ │ │ │ -000070d0: 2020 3136 323c 2f73 7061 6e3e 2020 2020 162 │ │ │ │ -000070e0: 7b3c 2f64 6976 3e0a 3c64 6976 2063 6c61 {
    .
    │ │ │ │ -00007130: 2020 3136 333c 2f73 7061 6e3e 2020 2020 163 │ │ │ │ -00007140: 2020 5f64 6174 6120 3d20 782e 5f64 6174 _data = x._dat │ │ │ │ -00007150: 613b 3c2f 6469 763e 0a3c 6469 7620 636c a;
    .
    164 │ │ │ │ -000071b0: 2020 203c 7370 616e 2063 6c61 7373 3d22 ret │ │ │ │ -000071d0: 7572 6e3c 2f73 7061 6e3e 202a 3c73 7061 urn *this;.
    1 │ │ │ │ -00007250: 3635 3c2f 7370 616e 3e20 2020 207d 3c2f 65 }.
    .
    < │ │ │ │ -000072a0: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -000072b0: 6e6f 223e 2020 3136 363c 2f73 7061 6e3e no"> 166 │ │ │ │ -000072c0: 203c 2f64 6976 3e0a 3c64 6976 2063 6c61
    .
    │ │ │ │ -00007310: 2020 3136 383c 2f73 7061 6e3e 2020 2020 168 │ │ │ │ -00007320: 3c73 7061 6e20 636c 6173 733d 226b 6579 template < │ │ │ │ -00007360: 7479 7065 6e61 6d65 3c2f 7370 616e 3e20 typename │ │ │ │ -00007370: 542c 203c 7370 616e 2063 6c61 7373 3d22 T, int │ │ │ │ -00007390: 3c2f 7370 616e 3e20 726f 7773 2c20 3c73 rows, int cols>
    .
    │ │ │ │ -00007460: 2031 3639 3c2f 613e 3c2f 7370 616e 3e20 169 │ │ │ │ -00007470: 2020 203c 6120 636c 6173 733d 2263 6f64 F │ │ │ │ -000074a0: 6965 6c64 4d61 7472 6978 3c2f 613e 2661 ieldMatrix&a │ │ │ │ -000074b0: 6d70 3b20 3c61 2063 6c61 7373 3d22 636f mp; operator=(F │ │ │ │ -00007540: 6965 6c64 4d61 7472 6978 266c 743b 542c ieldMatrix<T, │ │ │ │ -00007550: 726f 7773 2c63 6f6c 7326 6774 3b3c 2f61 rows,cols> const&) = delete │ │ │ │ -000075b0: 3b3c 2f64 6976 3e0a 3c64 6976 2063 6c61 ;
    .
    │ │ │ │ -00007600: 2020 3137 303c 2f73 7061 6e3e 203c 2f64 170 .
    ..
    │ │ │ │ -00007820: 2031 3733 3c2f 7370 616e 3e3c 7370 616e 173 {..< │ │ │ │ -00007910: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -00007920: 3e3c 6120 6964 3d22 6c30 3031 3735 2220 > 175 for( < │ │ │ │ -00007990: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -000079a0: 6f72 6474 7970 6522 3e69 6e74 3c2f 7370 ordtype">int i = 0; i < │ │ │ │ -000079c0: 3b20 524f 5753 3b20 2b2b 6920 293c 2f64 ; ROWS; ++i ).
    17 │ │ │ │ -00007a20: 363c 2f73 7061 6e3e 2020 2020 2020 2020 6 │ │ │ │ -00007a30: 3c73 7061 6e20 636c 6173 733d 226b 6579 for( │ │ │ │ -00007a70: 696e 743c 2f73 7061 6e3e 206a 203d 2030 int j = 0 │ │ │ │ -00007a80: 3b20 6a20 266c 743b 2043 4f4c 533b 202b ; j < COLS; + │ │ │ │ -00007a90: 2b6a 2029 3c2f 6469 763e 0a3c 6469 7620 +j )
    .
    177 │ │ │ │ -00007af0: 2020 2020 2020 2020 2041 545b 6a5d 5b69 AT[j][i │ │ │ │ -00007b00: 5d20 3d20 282a 3c73 7061 6e20 636c 6173 ] = (*this │ │ │ │ -00007b20: 3c2f 7370 616e 3e29 5b69 5d5b 6a5d 3b3c )[i][j];< │ │ │ │ -00007b30: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -00007b80: 3137 383c 2f73 7061 6e3e 2020 2020 2020 178 │ │ │ │ -00007b90: 3c73 7061 6e20 636c 6173 733d 226b 6579 return │ │ │ │ -00007bb0: 3c2f 7370 616e 3e20 4154 3b3c 2f64 6976 AT;
    .
    179< │ │ │ │ -00007c10: 2f73 7061 6e3e 2020 2020 7d3c 2f64 6976 /span> }
    .
    .
    180 .
    1 │ │ │ │ -00007cd0: 3832 3c2f 7370 616e 3e20 2020 203c 7370 82 template <cla │ │ │ │ -00007d20: 7373 3c2f 7370 616e 3e20 4f74 6865 7253 ss OtherS │ │ │ │ -00007d30: 6361 6c61 7226 6774 3b3c 2f64 6976 3e0a calar>
    . │ │ │ │ -00007d40: 3c64 6976 2063 6c61 7373 3d22 666f 6c64
    .
    < │ │ │ │ -00007dd0: 6120 636c 6173 733d 226c 696e 6522 2068 a class="line" h │ │ │ │ -00007de0: 7265 663d 2261 3031 3430 382e 6874 6d6c ref="a01408.html │ │ │ │ -00007df0: 2361 6536 3033 3366 3231 3764 3264 6531 #ae6033f217d2de1 │ │ │ │ -00007e00: 6337 6330 6464 6431 3038 3435 3966 6638 c7c0ddd108459ff8 │ │ │ │ -00007e10: 6163 223e 2020 3138 333c 2f61 3e3c 2f73 ac"> 183 fr │ │ │ │ -00007e40: 6965 6e64 3c2f 7370 616e 3e20 3c73 7061 iend auto ope │ │ │ │ -00007ec0: 7261 746f 722b 203c 2f61 3e28 203c 7370 rator+ ( const │ │ │ │ -00007ef0: 3c61 2063 6c61 7373 3d22 636f 6465 2068 Fiel │ │ │ │ -00007f20: 644d 6174 7269 783c 2f61 3e26 616d 703b dMatrix& │ │ │ │ -00007f30: 206d 6174 7269 7841 2c3c 2f64 6976 3e0a matrixA,
    . │ │ │ │ -00007f40: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    . │ │ │ │ -00008040: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65 . │ │ │ │ -000080a0: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    │ │ │ │ -00008190: 0a3c 6469 7620 636c 6173 733d 226c 696e ..< │ │ │ │ -00008200: 6120 6964 3d22 6c30 3031 3838 2220 6e61 a id="l00188" na │ │ │ │ -00008210: 6d65 3d22 6c30 3031 3838 223e 3c2f 613e me="l00188"> │ │ │ │ -00008220: 3c73 7061 6e20 636c 6173 733d 226c 696e 188 for (siz │ │ │ │ -000082c0: 655f 7479 7065 3c2f 613e 2069 203d 2030 e_type i = 0 │ │ │ │ -000082d0: 3b20 6920 266c 743b 2052 4f57 533b 202b ; i < ROWS; + │ │ │ │ -000082e0: 2b69 293c 2f64 6976 3e0a 3c64 6976 2063 +i)
    .
    189 │ │ │ │ -00008340: 2020 2020 2020 3c73 7061 6e20 636c 6173 │ │ │ │ -00008360: 666f 723c 2f73 7061 6e3e 2028 3c61 2063 for (size │ │ │ │ -000083c0: 5f74 7970 653c 2f61 3e20 6a20 3d20 303b _type j = 0; │ │ │ │ -000083d0: 206a 2026 6c74 3b20 434f 4c53 3b20 2b2b j < COLS; ++ │ │ │ │ -000083e0: 6a29 3c2f 6469 763e 0a3c 6469 7620 636c j)
    .
    190 │ │ │ │ -00008440: 2020 2020 2020 2072 6573 756c 745b 695d result[i] │ │ │ │ -00008450: 5b6a 5d20 3d20 6d61 7472 6978 415b 695d [j] = matrixA[i] │ │ │ │ -00008460: 5b6a 5d20 2b20 6d61 7472 6978 425b 695d [j] + matrixB[i] │ │ │ │ -00008470: 5b6a 5d3b 3c2f 6469 763e 0a3c 6469 7620 [j];
    .
    191 │ │ │ │ -000084d0: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -00008520: 2031 3932 3c2f 7370 616e 3e20 2020 2020 192 │ │ │ │ -00008530: 203c 7370 616e 2063 6c61 7373 3d22 6b65 retur │ │ │ │ -00008550: 6e3c 2f73 7061 6e3e 2072 6573 756c 743b n result; │ │ │ │ -00008560: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -000085b0: 2031 3933 3c2f 7370 616e 3e20 2020 207d 193 } │ │ │ │ -000085c0: 3c2f 6469 763e 0a3c 2f64 6976 3e0a 3c64
    .
    . │ │ │ │ -000085e0: 3c61 2069 643d 226c 3030 3139 3422 206e 194
    .
    196 │ │ │ │ -00008680: 2020 3c73 7061 6e20 636c 6173 733d 226b template │ │ │ │ -000086a0: 3c2f 7370 616e 3e20 266c 743b 3c73 7061 <class O │ │ │ │ -000086d0: 7468 6572 5363 616c 6172 2667 743b 3c2f therScalar>.
    .
    < │ │ │ │ -00008760: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -00008770: 6e6f 223e 3c61 2063 6c61 7373 3d22 6c69 no"> 197 friend │ │ │ │ -000087f0: 203c 7370 616e 2063 6c61 7373 3d22 6b65 auto operator- │ │ │ │ -00008870: 2820 3c73 7061 6e20 636c 6173 733d 226b ( const FieldMatrix │ │ │ │ -000088d0: 2661 6d70 3b20 6d61 7472 6978 412c 3c2f & matrixA,.
    1 │ │ │ │ -00008930: 3938 3c2f 7370 616e 3e20 2020 2020 2020 98 │ │ │ │ -00008940: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ │ -00008950: 2020 2020 203c 7370 616e 2063 6c61 7373 const │ │ │ │ -00008970: 3c2f 7370 616e 3e20 3c61 2063 6c61 7373 FieldMatrix& │ │ │ │ -000089b0: 6c74 3b4f 7468 6572 5363 616c 6172 2c52 lt;OtherScalar,R │ │ │ │ -000089c0: 4f57 532c 434f 4c53 2667 743b 3c2f 613e OWS,COLS> │ │ │ │ -000089d0: 2661 6d70 3b20 6d61 7472 6978 4229 3c2f & matrixB).
    1 │ │ │ │ -00008a30: 3939 3c2f 7370 616e 3e20 2020 207b 3c2f 99 {.
    2 │ │ │ │ -00008a90: 3030 3c2f 7370 616e 3e20 2020 2020 203c 00 < │ │ │ │ -00008aa0: 6120 636c 6173 733d 2263 6f64 6520 686c a class="code hl │ │ │ │ -00008ab0: 5f63 6c61 7373 2220 6872 6566 3d22 6130 _class" href="a0 │ │ │ │ -00008ac0: 3134 3038 2e68 746d 6c22 3e46 6965 6c64 1408.html">Field │ │ │ │ -00008ad0: 4d61 7472 6978 266c 743b 7479 7065 6e61 Matrix<typena │ │ │ │ -00008ae0: 6d65 2050 726f 6d6f 7469 6f6e 5472 6169 me PromotionTrai │ │ │ │ -00008af0: 7473 266c 743b 4b2c 4f74 6865 7253 6361 ts<K,OtherSca │ │ │ │ -00008b00: 6c61 7226 6774 3b3a 3a50 726f 6d6f 7465 lar>::Promote │ │ │ │ -00008b10: 6454 7970 653c 2f61 3e2c 524f 5753 2c43 dType,ROWS,C │ │ │ │ -00008b20: 4f4c 5326 6774 3b20 7265 7375 6c74 3b3c OLS> result;< │ │ │ │ -00008b30: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -00008b80: 3230 313c 2f73 7061 6e3e 203c 2f64 6976 201
    .
    202< │ │ │ │ -00008be0: 2f73 7061 6e3e 2020 2020 2020 3c73 7061 /span> for │ │ │ │ -00008c10: 2028 3c61 2063 6c61 7373 3d22 636f 6465 (size_type │ │ │ │ -00008c70: 6920 3d20 303b 2069 2026 6c74 3b20 524f i = 0; i < RO │ │ │ │ -00008c80: 5753 3b20 2b2b 6929 3c2f 6469 763e 0a3c WS; ++i)
    .< │ │ │ │ -00008c90: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -00008ca0: 3e3c 6120 6964 3d22 6c30 3032 3033 2220 > 203 for │ │ │ │ -00008d10: 283c 6120 636c 6173 733d 2263 6f64 6520 (size_type j │ │ │ │ -00008d70: 203d 2030 3b20 6a20 266c 743b 2043 4f4c = 0; j < COL │ │ │ │ -00008d80: 533b 202b 2b6a 293c 2f64 6976 3e0a 3c64 S; ++j)
    . │ │ │ │ -00008da0: 3c61 2069 643d 226c 3030 3230 3422 206e 204 resu │ │ │ │ -00008df0: 6c74 5b69 5d5b 6a5d 203d 206d 6174 7269 lt[i][j] = matri │ │ │ │ -00008e00: 7841 5b69 5d5b 6a5d 202d 206d 6174 7269 xA[i][j] - matri │ │ │ │ -00008e10: 7842 5b69 5d5b 6a5d 3b3c 2f64 6976 3e0a xB[i][j];
    . │ │ │ │ -00008e20: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65 .
    < │ │ │ │ -00008eb0: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -00008ec0: 6e6f 223e 2020 3230 363c 2f73 7061 6e3e no"> 206 │ │ │ │ -00008ed0: 2020 2020 2020 3c73 7061 6e20 636c 6173 │ │ │ │ -00008ef0: 7265 7475 726e 3c2f 7370 616e 3e20 7265 return re │ │ │ │ -00008f00: 7375 6c74 3b3c 2f64 6976 3e0a 3c64 6976 sult;
    .
    < │ │ │ │ -00008f40: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -00008f50: 6e6f 223e 2020 3230 373c 2f73 7061 6e3e no"> 207 │ │ │ │ -00008f60: 2020 2020 7d3c 2f64 6976 3e0a 3c2f 6469 }
    ..
    208 │ │ │ │ -00008fc0: 3c2f 7370 616e 3e20 3c2f 6469 763e 0a3c
    .< │ │ │ │ -00008fd0: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -00008fe0: 3e3c 6120 6964 3d22 6c30 3032 3130 2220 > 210 tem │ │ │ │ -00009040: 706c 6174 653c 2f73 7061 6e3e 2026 6c74 plate < │ │ │ │ -00009050: 3b3c 7370 616e 2063 6c61 7373 3d22 6b65 ;class
    Scalar,
    .
    211< │ │ │ │ -000090d0: 2f73 7061 6e3e 2020 2020 2020 2020 2020 /span> │ │ │ │ -000090e0: 2020 2020 7374 643a 3a65 6e61 626c 655f std::enable_ │ │ │ │ -000090f0: 6966 5f74 266c 743b 4973 4e75 6d62 6572 if_t<IsNumber │ │ │ │ -00009100: 266c 743b 5363 616c 6172 2667 743b 3a3a <Scalar>:: │ │ │ │ -00009110: 7661 6c75 652c 203c 7370 616e 2063 6c61 value, int> │ │ │ │ -00009140: 3d20 3026 6774 3b3c 2f64 6976 3e0a 3c64 = 0>
    ..
    212 frie │ │ │ │ -00009250: 6e64 3c2f 7370 616e 3e20 3c73 7061 6e20 nd │ │ │ │ -00009270: 6175 746f 3c2f 7370 616e 3e20 3c61 2063 auto opera │ │ │ │ -000092d0: 746f 722a 203c 2f61 3e28 203c 7370 616e tor* ( const FieldM │ │ │ │ -00009330: 6174 7269 783c 2f61 3e26 616d 703b 206d atrix& m │ │ │ │ -00009340: 6174 7269 782c 2053 6361 6c61 7220 7363 atrix, Scalar sc │ │ │ │ -00009350: 616c 6172 293c 2f64 6976 3e0a 3c64 6976 alar)
    .
    < │ │ │ │ -00009390: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -000093a0: 6e6f 223e 2020 3231 333c 2f73 7061 6e3e no"> 213 │ │ │ │ -000093b0: 2020 2020 7b3c 2f64 6976 3e0a 3c64 6976 {
    .
    < │ │ │ │ -000093f0: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -00009400: 6e6f 223e 2020 3231 343c 2f73 7061 6e3e no"> 214 │ │ │ │ -00009410: 2020 2020 2020 3c61 2063 6c61 7373 3d22 FieldMatrix< │ │ │ │ -00009450: 3b74 7970 656e 616d 6520 5072 6f6d 6f74 ;typename Promot │ │ │ │ -00009460: 696f 6e54 7261 6974 7326 6c74 3b4b 2c53 ionTraits<K,S │ │ │ │ -00009470: 6361 6c61 7226 6774 3b3a 3a50 726f 6d6f calar>::Promo │ │ │ │ -00009480: 7465 6454 7970 653c 2f61 3e2c 524f 5753 tedType,ROWS │ │ │ │ -00009490: 2c43 4f4c 5326 6774 3b20 7265 7375 6c74 ,COLS> result │ │ │ │ -000094a0: 3b3c 2f64 6976 3e0a 3c64 6976 2063 6c61 ;
    .
    │ │ │ │ -000094f0: 2020 3231 353c 2f73 7061 6e3e 203c 2f64 215 .
    21 │ │ │ │ -00009550: 363c 2f73 7061 6e3e 2020 2020 2020 3c73 6 for (size_type i = 0; i < │ │ │ │ -000095f0: 524f 5753 3b20 2b2b 6929 3c2f 6469 763e ROWS; ++i)
    │ │ │ │ -00009600: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -00009630: 3c2f 613e 3c73 7061 6e20 636c 6173 733d 217 for (size_type │ │ │ │ -000096e0: 206a 203d 2030 3b20 6a20 266c 743b 2043 j = 0; j < C │ │ │ │ -000096f0: 4f4c 533b 202b 2b6a 293c 2f64 6976 3e0a OLS; ++j)
    . │ │ │ │ -00009700: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    .
    219 < │ │ │ │ -000097e0: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -00009830: 3232 303c 2f73 7061 6e3e 2020 2020 2020 220 │ │ │ │ -00009840: 3c73 7061 6e20 636c 6173 733d 226b 6579 return │ │ │ │ -00009860: 3c2f 7370 616e 3e20 7265 7375 6c74 3b3c result;< │ │ │ │ -00009870: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -000098c0: 3232 313c 2f73 7061 6e3e 2020 2020 7d3c 221 }< │ │ │ │ -000098d0: 2f64 6976 3e0a 3c2f 6469 763e 0a3c 6469 /div>.
    .< │ │ │ │ -000098f0: 6120 6964 3d22 6c30 3032 3232 2220 6e61 a id="l00222" na │ │ │ │ -00009900: 6d65 3d22 6c30 3032 3232 223e 3c2f 613e me="l00222"> │ │ │ │ -00009910: 3c73 7061 6e20 636c 6173 733d 226c 696e 222
    .
    224 │ │ │ │ -00009990: 203c 7370 616e 2063 6c61 7373 3d22 6b65 template< │ │ │ │ -000099b0: 2f73 7061 6e3e 2026 6c74 3b3c 7370 616e /span> <class Sc │ │ │ │ -000099e0: 616c 6172 2c3c 2f64 6976 3e0a 3c64 6976 alar,
    .
    < │ │ │ │ -00009a20: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -00009a30: 6e6f 223e 2020 3232 353c 2f73 7061 6e3e no"> 225 │ │ │ │ -00009a40: 2020 2020 2020 2020 2020 2020 2020 7374 st │ │ │ │ -00009a50: 643a 3a65 6e61 626c 655f 6966 5f74 266c d::enable_if_t&l │ │ │ │ -00009a60: 743b 4973 4e75 6d62 6572 266c 743b 5363 t;IsNumber<Sc │ │ │ │ -00009a70: 616c 6172 2667 743b 3a3a 7661 6c75 652c alar>::value, │ │ │ │ -00009a80: 203c 7370 616e 2063 6c61 7373 3d22 6b65 int> = 0> │ │ │ │ -00009ab0: 3b3c 2f64 6976 3e0a 3c64 6976 2063 6c61 ;
    .
    .< │ │ │ │ -00009b00: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -00009b10: 3e3c 6120 6964 3d22 6c30 3032 3236 2220 > 22 │ │ │ │ -00009b90: 363c 2f61 3e3c 2f73 7061 6e3e 2020 2020 6 │ │ │ │ -00009ba0: 3c73 7061 6e20 636c 6173 733d 226b 6579 friend auto operator* < │ │ │ │ -00009c40: 2f61 3e28 2053 6361 6c61 7220 7363 616c /a>( Scalar scal │ │ │ │ -00009c50: 6172 2c20 3c73 7061 6e20 636c 6173 733d ar, const< │ │ │ │ -00009c70: 2f73 7061 6e3e 203c 6120 636c 6173 733d /span> FieldMatrix& matrix)< │ │ │ │ -00009cc0: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -00009d10: 3232 373c 2f73 7061 6e3e 2020 2020 7b3c 227 {< │ │ │ │ -00009d20: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>..
    229< │ │ │ │ -00009e60: 2f73 7061 6e3e 203c 2f64 6976 3e0a 3c64 /span>
    . │ │ │ │ -00009e80: 3c61 2069 643d 226c 3030 3233 3022 206e 230 for (si │ │ │ │ -00009f40: 7a65 5f74 7970 653c 2f61 3e20 6920 3d20 ze_type i = │ │ │ │ -00009f50: 303b 2069 2026 6c74 3b20 524f 5753 3b20 0; i < ROWS; │ │ │ │ -00009f60: 2b2b 6929 3c2f 6469 763e 0a3c 6469 7620 ++i)
    .
    231 │ │ │ │ -00009fc0: 2020 2020 2020 203c 7370 616e 2063 6c61 for (siz │ │ │ │ -0000a040: 655f 7479 7065 3c2f 613e 206a 203d 2030 e_type j = 0 │ │ │ │ -0000a050: 3b20 6a20 266c 743b 2043 4f4c 533b 202b ; j < COLS; + │ │ │ │ -0000a060: 2b6a 293c 2f64 6976 3e0a 3c64 6976 2063 +j)
    .
    232 │ │ │ │ -0000a0c0: 2020 2020 2020 2020 7265 7375 6c74 5b69 result[i │ │ │ │ -0000a0d0: 5d5b 6a5d 203d 2073 6361 6c61 7220 2a20 ][j] = scalar * │ │ │ │ -0000a0e0: 6d61 7472 6978 5b69 5d5b 6a5d 3b3c 2f64 matrix[i][j];.
    23 │ │ │ │ -0000a140: 333c 2f73 7061 6e3e 203c 2f64 6976 3e0a 3
    . │ │ │ │ -0000a150: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    . │ │ │ │ -0000a1e0: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65 . │ │ │ │ -0000a240: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -0000a290: 2032 3336 3c2f 7370 616e 3e20 3c2f 6469 236 .
    238 │ │ │ │ -0000a2f0: 3c2f 7370 616e 3e20 2020 203c 7370 616e template │ │ │ │ -0000a320: 2026 6c74 3b3c 7370 616e 2063 6c61 7373 <class │ │ │ │ -0000a340: 203c 2f73 7061 6e3e 5363 616c 6172 2c3c Scalar,< │ │ │ │ -0000a350: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -0000a3a0: 3233 393c 2f73 7061 6e3e 2020 2020 2020 239 │ │ │ │ -0000a3b0: 2020 2020 2020 2020 7374 643a 3a65 6e61 std::ena │ │ │ │ -0000a3c0: 626c 655f 6966 5f74 266c 743b 4973 4e75 ble_if_t<IsNu │ │ │ │ -0000a3d0: 6d62 6572 266c 743b 5363 616c 6172 2667 mber<Scalar&g │ │ │ │ -0000a3e0: 743b 3a3a 7661 6c75 652c 203c 7370 616e t;::value, int& │ │ │ │ -0000a410: 6774 3b20 3d20 3026 6774 3b3c 2f64 6976 gt; = 0>
    .
    .
    240< │ │ │ │ -0000a500: 2f73 7061 6e3e 2020 2020 3c73 7061 6e20 /span> │ │ │ │ -0000a520: 6672 6965 6e64 3c2f 7370 616e 3e20 3c73 friend auto │ │ │ │ -0000a550: 3c61 2063 6c61 7373 3d22 636f 6465 2068 o │ │ │ │ -0000a5a0: 7065 7261 746f 722f 203c 2f61 3e28 203c perator/ ( < │ │ │ │ -0000a5b0: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -0000a5c0: 6f72 6422 3e63 6f6e 7374 3c2f 7370 616e ord">const Fi │ │ │ │ -0000a600: 656c 644d 6174 7269 783c 2f61 3e26 616d eldMatrix&am │ │ │ │ -0000a610: 703b 206d 6174 7269 782c 2053 6361 6c61 p; matrix, Scala │ │ │ │ -0000a620: 7220 7363 616c 6172 293c 2f64 6976 3e0a r scalar)
    . │ │ │ │ -0000a630: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65 . │ │ │ │ -0000a690: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65 .
    < │ │ │ │ -0000a7b0: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -0000a7c0: 6e6f 223e 2020 3234 333c 2f73 7061 6e3e no"> 243 │ │ │ │ -0000a7d0: 203c 2f64 6976 3e0a 3c64 6976 2063 6c61
    .
    │ │ │ │ -0000a820: 2020 3234 343c 2f73 7061 6e3e 2020 2020 244 │ │ │ │ -0000a830: 2020 3c73 7061 6e20 636c 6173 733d 226b for< │ │ │ │ -0000a850: 2f73 7061 6e3e 2028 3c61 2063 6c61 7373 /span> (size_typ │ │ │ │ -0000a8b0: 653c 2f61 3e20 6920 3d20 303b 2069 2026 e i = 0; i & │ │ │ │ -0000a8c0: 6c74 3b20 524f 5753 3b20 2b2b 6929 3c2f lt; ROWS; ++i).
    2 │ │ │ │ -0000a920: 3435 3c2f 7370 616e 3e20 2020 2020 2020 45 │ │ │ │ -0000a930: 203c 7370 616e 2063 6c61 7373 3d22 6b65 for (size_type │ │ │ │ -0000a9b0: 3c2f 613e 206a 203d 2030 3b20 6a20 266c j = 0; j &l │ │ │ │ -0000a9c0: 743b 2043 4f4c 533b 202b 2b6a 293c 2f64 t; COLS; ++j).
    24 │ │ │ │ -0000aa20: 363c 2f73 7061 6e3e 2020 2020 2020 2020 6 │ │ │ │ -0000aa30: 2020 7265 7375 6c74 5b69 5d5b 6a5d 203d result[i][j] = │ │ │ │ -0000aa40: 206d 6174 7269 785b 695d 5b6a 5d20 2f20 matrix[i][j] / │ │ │ │ -0000aa50: 7363 616c 6172 3b3c 2f64 6976 3e0a 3c64 scalar;
    . │ │ │ │ -0000aa70: 3c61 2069 643d 226c 3030 3234 3722 206e 247
    .
    248 │ │ │ │ -0000ab10: 2020 2020 3c73 7061 6e20 636c 6173 733d re │ │ │ │ -0000ab30: 7475 726e 3c2f 7370 616e 3e20 7265 7375 turn resu │ │ │ │ -0000ab40: 6c74 3b3c 2f64 6976 3e0a 3c64 6976 2063 lt;
    .
    249 │ │ │ │ -0000aba0: 2020 7d3c 2f64 6976 3e0a 3c2f 6469 763e }
    .
    │ │ │ │ -0000abb0: 0a3c 6469 7620 636c 6173 733d 226c 696e ..< │ │ │ │ -0000ac20: 6120 6964 3d22 6c30 3032 3533 2220 6e61 a id="l00253" na │ │ │ │ -0000ac30: 6d65 3d22 6c30 3032 3533 223e 3c2f 613e me="l00253"> │ │ │ │ -0000ac40: 3c73 7061 6e20 636c 6173 733d 226c 696e 253 templ │ │ │ │ -0000ac80: 6174 653c 2f73 7061 6e3e 2026 6c74 3b3c ate << │ │ │ │ -0000ac90: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -0000aca0: 6f72 6422 3e63 6c61 7373 3c2f 7370 616e ord">class OtherScalar, < │ │ │ │ -0000acc0: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -0000acd0: 6f72 6474 7970 6522 3e69 6e74 3c2f 7370 ordtype">int otherCols> │ │ │ │ -0000acf0: 3b3c 2f64 6976 3e0a 3c64 6976 2063 6c61 ;
    ..
    │ │ │ │ -0000af40: 2020 3235 353c 2f73 7061 6e3e 2020 2020 255 │ │ │ │ -0000af50: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ │ -0000af60: 2020 2020 2020 2020 3c73 7061 6e20 636c co │ │ │ │ -0000af80: 6e73 743c 2f73 7061 6e3e 203c 6120 636c nst FieldMatr │ │ │ │ -0000afc0: 6978 266c 743b 4f74 6865 7253 6361 6c61 ix<OtherScala │ │ │ │ -0000afd0: 722c 2043 4f4c 532c 206f 7468 6572 436f r, COLS, otherCo │ │ │ │ -0000afe0: 6c73 2667 743b 3c2f 613e 2661 6d70 3b20 ls>& │ │ │ │ -0000aff0: 6d61 7472 6978 4229 3c2f 6469 763e 0a3c matrixB)
    .< │ │ │ │ -0000b000: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -0000b010: 3e3c 6120 6964 3d22 6c30 3032 3536 2220 > 256 {
    .< │ │ │ │ -0000b060: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -0000b070: 3e3c 6120 6964 3d22 6c30 3032 3537 2220 > 257 FieldMatrix │ │ │ │ -0000b0f0: 266c 743b 7479 7065 6e61 6d65 2050 726f <typename Pro │ │ │ │ -0000b100: 6d6f 7469 6f6e 5472 6169 7473 266c 743b motionTraits< │ │ │ │ -0000b110: 4b2c 4f74 6865 7253 6361 6c61 7226 6774 K,OtherScalar> │ │ │ │ -0000b120: 3b3a 3a50 726f 6d6f 7465 6454 7970 653c ;::PromotedType< │ │ │ │ -0000b130: 2f61 3e2c 524f 5753 2c6f 7468 6572 436f /a>,ROWS,otherCo │ │ │ │ -0000b140: 6c73 2667 743b 2072 6573 756c 743b 3c2f ls> result;.
    2 │ │ │ │ -0000b1a0: 3538 3c2f 7370 616e 3e20 3c2f 6469 763e 58
    │ │ │ │ -0000b1b0: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -0000b1e0: 3c2f 613e 3c73 7061 6e20 636c 6173 733d 259 for │ │ │ │ -0000b230: 283c 6120 636c 6173 733d 2263 6f64 6520 (size_type i │ │ │ │ -0000b290: 203d 2030 3b20 6920 266c 743b 206d 6174 = 0; i < mat │ │ │ │ -0000b2a0: 7269 7841 2e3c 6120 636c 6173 733d 2263 rixA.mat_rows(); ++i)
    │ │ │ │ -0000b310: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -0000b340: 3c2f 613e 3c73 7061 6e20 636c 6173 733d 260 for (size_type │ │ │ │ -0000b3f0: 206a 203d 2030 3b20 6a20 266c 743b 206d j = 0; j < m │ │ │ │ -0000b400: 6174 7269 7842 2e3c 6120 636c 6173 733d atrixB.mat_cols │ │ │ │ -0000b460: 3c2f 613e 2829 3b20 2b2b 6a29 3c2f 6469 (); ++j).
    261 │ │ │ │ -0000b4c0: 3c2f 7370 616e 3e20 2020 2020 2020 207b { │ │ │ │ -0000b4d0: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -0000b520: 2032 3632 3c2f 7370 616e 3e20 2020 2020 262 │ │ │ │ -0000b530: 2020 2020 2072 6573 756c 745b 695d 5b6a result[i][j │ │ │ │ -0000b540: 5d20 3d20 303b 3c2f 6469 763e 0a3c 6469 ] = 0;
    .< │ │ │ │ -0000b560: 6120 6964 3d22 6c30 3032 3633 2220 6e61 a id="l00263" na │ │ │ │ -0000b570: 6d65 3d22 6c30 3032 3633 223e 3c2f 613e me="l00263"> │ │ │ │ -0000b580: 3c73 7061 6e20 636c 6173 733d 226c 696e 263 for │ │ │ │ -0000b5d0: 283c 6120 636c 6173 733d 2263 6f64 6520 (size_type k │ │ │ │ -0000b630: 203d 2030 3b20 6b20 266c 743b 206d 6174 = 0; k < mat │ │ │ │ -0000b640: 7269 7841 2e3c 6120 636c 6173 733d 2263 rixA.mat_cols(); ++k)
    │ │ │ │ -0000b6b0: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -0000b6e0: 3c2f 613e 3c73 7061 6e20 636c 6173 733d 264 │ │ │ │ -0000b710: 2072 6573 756c 745b 695d 5b6a 5d20 2b3d result[i][j] += │ │ │ │ -0000b720: 206d 6174 7269 7841 5b69 5d5b 6b5d 202a matrixA[i][k] * │ │ │ │ -0000b730: 206d 6174 7269 7842 5b6b 5d5b 6a5d 3b3c matrixB[k][j];< │ │ │ │ -0000b740: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -0000b790: 3236 353c 2f73 7061 6e3e 2020 2020 2020 265 │ │ │ │ -0000b7a0: 2020 7d3c 2f64 6976 3e0a 3c64 6976 2063 }
    .
    266 < │ │ │ │ -0000b800: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -0000b850: 3236 373c 2f73 7061 6e3e 2020 2020 2020 267 │ │ │ │ -0000b860: 3c73 7061 6e20 636c 6173 733d 226b 6579 return │ │ │ │ -0000b880: 3c2f 7370 616e 3e20 7265 7375 6c74 3b3c result;< │ │ │ │ -0000b890: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -0000b8e0: 3236 383c 2f73 7061 6e3e 2020 2020 7d3c 268 }< │ │ │ │ -0000b8f0: 2f64 6976 3e0a 3c2f 6469 763e 0a3c 6469 /div>.
    .< │ │ │ │ -0000b910: 6120 6964 3d22 6c30 3032 3639 2220 6e61 a id="l00269" na │ │ │ │ -0000b920: 6d65 3d22 6c30 3032 3639 223e 3c2f 613e me="l00269"> │ │ │ │ -0000b930: 3c73 7061 6e20 636c 6173 733d 226c 696e 269
    .
    276 │ │ │ │ -0000b9b0: 203c 7370 616e 2063 6c61 7373 3d22 6b65 template< │ │ │ │ -0000b9d0: 2f73 7061 6e3e 2026 6c74 3b3c 7370 616e /span> <class Ot │ │ │ │ -0000ba00: 6865 724d 6174 7269 782c 2073 7464 3a3a herMatrix, std:: │ │ │ │ -0000ba10: 656e 6162 6c65 5f69 665f 7426 6c74 3b3c enable_if_t<< │ │ │ │ -0000ba20: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -0000ba70: 3237 373c 2f73 7061 6e3e 2020 2020 2020 277 │ │ │ │ -0000ba80: 496d 706c 3a3a 4973 5374 6174 6963 5369 Impl::IsStaticSi │ │ │ │ -0000ba90: 7a65 4d61 7472 6978 5f76 266c 743b 4f74 zeMatrix_v<Ot │ │ │ │ -0000baa0: 6865 724d 6174 7269 7826 6774 3b3c 2f64 herMatrix>.
    27 │ │ │ │ -0000bb00: 383c 2f73 7061 6e3e 2020 2020 2020 616e 8 an │ │ │ │ -0000bb10: 6420 6e6f 7420 496d 706c 3a3a 4973 4669 d not Impl::IsFi │ │ │ │ -0000bb20: 656c 644d 6174 7269 785f 7626 6c74 3b4f eldMatrix_v<O │ │ │ │ -0000bb30: 7468 6572 4d61 7472 6978 2667 743b 3c2f therMatrix>.
    2 │ │ │ │ -0000bb90: 3739 3c2f 7370 616e 3e20 2020 2020 202c 79 , │ │ │ │ -0000bba0: 203c 7370 616e 2063 6c61 7373 3d22 6b65 int> = 0> │ │ │ │ -0000bbd0: 3b3c 2f64 6976 3e0a 3c64 6976 2063 6c61 ;
    ..
    │ │ │ │ -0000be20: 2020 3238 313c 2f73 7061 6e3e 2020 2020 281 │ │ │ │ -0000be30: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ │ -0000be40: 2020 2020 2020 2020 3c73 7061 6e20 636c co │ │ │ │ -0000be60: 6e73 743c 2f73 7061 6e3e 204f 7468 6572 nst Other │ │ │ │ -0000be70: 4d61 7472 6978 2661 6d70 3b20 6d61 7472 Matrix& matr │ │ │ │ -0000be80: 6978 4229 3c2f 6469 763e 0a3c 6469 7620 ixB)
    .
    282 │ │ │ │ -0000bee0: 2020 207b 3c2f 6469 763e 0a3c 6469 7620 {
    .
    283 │ │ │ │ -0000bf40: 2020 2020 203c 7370 616e 2063 6c61 7373 using │ │ │ │ -0000bf60: 203c 2f73 7061 6e3e 4669 656c 6420 3d20 Field = │ │ │ │ -0000bf70: 3c73 7061 6e20 636c 6173 733d 226b 6579 typename PromotionT │ │ │ │ -0000bff0: 7261 6974 7326 6c74 3b4b 2c20 7479 7065 raits<K, type │ │ │ │ -0000c000: 6e61 6d65 204f 7468 6572 4d61 7472 6978 name OtherMatrix │ │ │ │ -0000c010: 3a3a 6669 656c 645f 7479 7065 2667 743b ::field_type> │ │ │ │ -0000c020: 3a3a 5072 6f6d 6f74 6564 5479 7065 3c2f ::PromotedType;
    ..
    285 │ │ │ │ -0000c160: 2020 2020 3c73 7061 6e20 636c 6173 733d fo │ │ │ │ -0000c180: 723c 2f73 7061 6e3e 2028 7374 643a 3a73 r (std::s │ │ │ │ -0000c190: 697a 655f 7420 6a3d 303b 206a 266c 743b ize_t j=0; j< │ │ │ │ -0000c1a0: 3c61 2063 6c61 7373 3d22 636f 6465 2068 rows; ++j)< │ │ │ │ -0000c200: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -0000c250: 3238 363c 2f73 7061 6e3e 2020 2020 2020 286 │ │ │ │ -0000c260: 2020 6d61 7472 6978 422e 3c61 2063 6c61 matrixB.mtv(matrixA[j], r │ │ │ │ -0000c2d0: 6573 756c 745b 6a5d 293b 3c2f 6469 763e esult[j]);
    │ │ │ │ -0000c2e0: 0a3c 6469 7620 636c 6173 733d 226c 696e . │ │ │ │ -0000c370: 0a3c 6469 7620 636c 6173 733d 226c 696e . │ │ │ │ -0000c3d0: 0a3c 2f64 6976 3e0a 3c64 6976 2063 6c61 .
    .
    │ │ │ │ -0000c420: 2020 3238 393c 2f73 7061 6e3e 203c 2f64 289 .
    29 │ │ │ │ -0000c480: 363c 2f73 7061 6e3e 2020 2020 3c73 7061 6 template <clas │ │ │ │ -0000c4d0: 7320 3c2f 7370 616e 3e4f 7468 6572 4d61 s OtherMa │ │ │ │ -0000c4e0: 7472 6978 2c20 7374 643a 3a65 6e61 626c trix, std::enabl │ │ │ │ -0000c4f0: 655f 6966 5f74 266c 743b 3c2f 6469 763e e_if_t<
    │ │ │ │ -0000c500: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -0000c530: 3c2f 613e 3c73 7061 6e20 636c 6173 733d 297 Impl: │ │ │ │ -0000c560: 3a49 7353 7461 7469 6353 697a 654d 6174 :IsStaticSizeMat │ │ │ │ -0000c570: 7269 785f 7626 6c74 3b4f 7468 6572 4d61 rix_v<OtherMa │ │ │ │ -0000c580: 7472 6978 2667 743b 3c2f 6469 763e 0a3c trix>
    .< │ │ │ │ -0000c590: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -0000c5a0: 3e3c 6120 6964 3d22 6c30 3032 3938 2220 > 298 and not │ │ │ │ -0000c5f0: 2049 6d70 6c3a 3a49 7346 6965 6c64 4d61 Impl::IsFieldMa │ │ │ │ -0000c600: 7472 6978 5f76 266c 743b 4f74 6865 724d trix_v<OtherM │ │ │ │ -0000c610: 6174 7269 7826 6774 3b3c 2f64 6976 3e0a atrix>
    . │ │ │ │ -0000c620: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    < │ │ │ │ -0000c650: 2f61 3e3c 7370 616e 2063 6c61 7373 3d22 /a> 299 , int │ │ │ │ -0000c6a0: 2667 743b 203d 2030 2667 743b 3c2f 6469 > = 0>.
    .
    300 │ │ │ │ -0000c790: 3c2f 7370 616e 3e20 2020 203c 7370 616e friend < │ │ │ │ -0000c7c0: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -0000c7d0: 6f72 6422 3e61 7574 6f3c 2f73 7061 6e3e ord">auto │ │ │ │ -0000c7e0: 203c 6120 636c 6173 733d 2263 6f64 6520 │ │ │ │ -0000c830: 6f70 6572 6174 6f72 2a20 3c2f 613e 2820 operator* ( │ │ │ │ -0000c840: 3c73 7061 6e20 636c 6173 733d 226b 6579 const OtherMatrix&a │ │ │ │ -0000c870: 6d70 3b20 6d61 7472 6978 412c 3c2f 6469 mp; matrixA,.
    301 │ │ │ │ -0000c8d0: 3c2f 7370 616e 3e20 2020 2020 2020 2020 │ │ │ │ -0000c8e0: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ │ -0000c8f0: 2020 203c 7370 616e 2063 6c61 7373 3d22 const FieldMatrix& matrixB)< │ │ │ │ -0000c960: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -0000c9b0: 3330 323c 2f73 7061 6e3e 2020 2020 7b3c 302 {< │ │ │ │ -0000c9c0: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -0000ca10: 3330 333c 2f73 7061 6e3e 2020 2020 2020 303 │ │ │ │ -0000ca20: 3c73 7061 6e20 636c 6173 733d 226b 6579 using Field = typename │ │ │ │ -0000ca70: 203c 6120 636c 6173 733d 2263 6f64 6520 PromotionTraits │ │ │ │ -0000cad0: 266c 743b 4b2c 2074 7970 656e 616d 6520 <K, typename │ │ │ │ -0000cae0: 4f74 6865 724d 6174 7269 783a 3a66 6965 OtherMatrix::fie │ │ │ │ -0000caf0: 6c64 5f74 7970 6526 6774 3b3a 3a50 726f ld_type>::Pro │ │ │ │ -0000cb00: 6d6f 7465 6454 7970 653c 2f61 3e3b 3c2f motedType;.
    3 │ │ │ │ -0000cb60: 3034 3c2f 7370 616e 3e20 2020 2020 203c 04 < │ │ │ │ -0000cb70: 6120 636c 6173 733d 2263 6f64 6520 686c a class="code hl │ │ │ │ -0000cb80: 5f63 6c61 7373 2220 6872 6566 3d22 6130 _class" href="a0 │ │ │ │ -0000cb90: 3134 3038 2e68 746d 6c22 3e44 756e 653a 1408.html">Dune: │ │ │ │ -0000cba0: 3a46 6965 6c64 4d61 7472 6978 266c 743b :FieldMatrix< │ │ │ │ -0000cbb0: 4669 656c 642c 204f 7468 6572 4d61 7472 Field, OtherMatr │ │ │ │ -0000cbc0: 6978 3a3a 726f 7773 2c20 636f 6c73 2667 ix::rows, cols&g │ │ │ │ -0000cbd0: 743b 3c2f 613e 2072 6573 756c 743b 3c2f t; result;.
    3 │ │ │ │ -0000cc30: 3035 3c2f 7370 616e 3e20 2020 2020 203c 05 < │ │ │ │ -0000cc40: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -0000cc50: 6f72 6466 6c6f 7722 3e66 6f72 3c2f 7370 ordflow">for (std::size_t │ │ │ │ -0000cc70: 206a 3d30 3b20 6a26 6c74 3b3c 6120 636c j=0; j<cols │ │ │ │ -0000ccd0: 3c2f 613e 3b20 2b2b 6a29 3c2f 6469 763e ; ++j)
    │ │ │ │ -0000cce0: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -0000cd10: 3c2f 613e 3c73 7061 6e20 636c 6173 733d 306 {.
    307 │ │ │ │ -0000cd90: 3c2f 7370 616e 3e20 2020 2020 2020 203c < │ │ │ │ -0000cda0: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -0000cdb0: 6f72 6422 3e61 7574 6f3c 2f73 7061 6e3e ord">auto │ │ │ │ -0000cdc0: 2042 5f6a 203d 2049 6d70 6c3a 3a43 6f6c B_j = Impl::Col │ │ │ │ -0000cdd0: 756d 6e56 6563 746f 7256 6965 7728 6d61 umnVectorView(ma │ │ │ │ -0000cde0: 7472 6978 422c 206a 293b 3c2f 6469 763e trixB, j);
    │ │ │ │ -0000cdf0: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -0000ce20: 3c2f 613e 3c73 7061 6e20 636c 6173 733d 308 auto r │ │ │ │ -0000ce70: 6573 756c 745f 6a20 3d20 496d 706c 3a3a esult_j = Impl:: │ │ │ │ -0000ce80: 436f 6c75 6d6e 5665 6374 6f72 5669 6577 ColumnVectorView │ │ │ │ -0000ce90: 2872 6573 756c 742c 206a 293b 3c2f 6469 (result, j);.
    309 │ │ │ │ -0000cef0: 3c2f 7370 616e 3e20 2020 2020 2020 206d m │ │ │ │ -0000cf00: 6174 7269 7841 2e6d 7628 425f 6a2c 2072 atrixA.mv(B_j, r │ │ │ │ -0000cf10: 6573 756c 745f 6a29 3b3c 2f64 6976 3e0a esult_j);
    . │ │ │ │ -0000cf20: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65 .
    311< │ │ │ │ -0000cfd0: 2f73 7061 6e3e 2020 2020 2020 3c73 7061 /span> return result;
    .
    312< │ │ │ │ -0000d060: 2f73 7061 6e3e 2020 2020 7d3c 2f64 6976 /span> }
    .
    .
    313 .
    3 │ │ │ │ -0000d120: 3135 3c2f 7370 616e 3e20 2020 203c 7370 15 template< │ │ │ │ -0000d170: 696e 743c 2f73 7061 6e3e 206c 2667 743b int l> │ │ │ │ -0000d180: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    .< │ │ │ │ -0000d1e0: 6120 6964 3d22 6c30 3033 3136 2220 6e61 a id="l00316" na │ │ │ │ -0000d1f0: 6d65 3d22 6c30 3033 3136 223e 3c2f 613e me="l00316"> │ │ │ │ -0000d200: 3c73 7061 6e20 636c 6173 733d 226c 696e 316< │ │ │ │ -0000d260: 2f61 3e3c 2f73 7061 6e3e 2020 2020 3c61 /a> FieldM │ │ │ │ -0000d2a0: 6174 7269 7826 6c74 3b4b 2c6c 2c63 6f6c atrix<K,l,col │ │ │ │ -0000d2b0: 7326 6774 3b3c 2f61 3e20 3c61 2063 6c61 s> leftm │ │ │ │ -0000d310: 756c 7469 706c 7961 6e79 3c2f 613e 2028 ultiplyany ( │ │ │ │ -0000d320: 3c73 7061 6e20 636c 6173 733d 226b 6579 const F │ │ │ │ -0000d370: 6965 6c64 4d61 7472 6978 266c 743b 4b2c ieldMatrix<K, │ │ │ │ -0000d380: 6c2c 726f 7773 2667 743b 3c2f 613e 2661 l,rows>&a │ │ │ │ -0000d390: 6d70 3b20 3c61 2063 6c61 7373 3d22 636f mp; M) const.
    3 │ │ │ │ -0000d460: 3137 3c2f 7370 616e 3e3c 7370 616e 2063 17 │ │ │ │ -0000d480: 2020 203c 2f73 7061 6e3e 7b3c 2f64 6976 {
    . │ │ │ │ -0000d540: 0a3c 6469 7620 636c 6173 733d 226c 696e ..< │ │ │ │ -0000d5b0: 6120 6964 3d22 6c30 3033 3230 2220 6e61 a id="l00320" na │ │ │ │ -0000d5c0: 6d65 3d22 6c30 3033 3230 223e 3c2f 613e me="l00320"> │ │ │ │ -0000d5d0: 3c73 7061 6e20 636c 6173 733d 226c 696e 320 for (siz │ │ │ │ -0000d670: 655f 7479 7065 3c2f 613e 2069 3d30 3b20 e_type i=0; │ │ │ │ -0000d680: 6926 6c74 3b6c 3b20 692b 2b29 207b 3c2f i<l; i++) {.
    3 │ │ │ │ -0000d6e0: 3231 3c2f 7370 616e 3e20 2020 2020 2020 21 │ │ │ │ -0000d6f0: 203c 7370 616e 2063 6c61 7373 3d22 6b65 for (size_type │ │ │ │ -0000d770: 3c2f 613e 206a 3d30 3b20 6a26 6c74 3b3c j=0; j<< │ │ │ │ -0000d780: 6120 636c 6173 733d 2263 6f64 6520 686c a class="code hl │ │ │ │ -0000d790: 5f76 6172 6961 626c 6522 2068 7265 663d _variable" href= │ │ │ │ -0000d7a0: 2261 3031 3430 382e 6874 6d6c 2361 6332 "a01408.html#ac2 │ │ │ │ -0000d7b0: 3831 3666 3164 3036 3766 3533 3333 3636 816f1d067f533366 │ │ │ │ -0000d7c0: 3239 3763 3035 3366 3037 3039 3962 223e 297c053f07099b"> │ │ │ │ -0000d7d0: 636f 6c73 3c2f 613e 3b20 6a2b 2b29 207b cols; j++) { │ │ │ │ -0000d7e0: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -0000d830: 2033 3232 3c2f 7370 616e 3e20 2020 2020 322 │ │ │ │ -0000d840: 2020 2020 2043 5b69 5d5b 6a5d 203d 2030 C[i][j] = 0 │ │ │ │ -0000d850: 3b3c 2f64 6976 3e0a 3c64 6976 2063 6c61 ;
    .
    │ │ │ │ -0000d8a0: 2020 3332 333c 2f73 7061 6e3e 2020 2020 323 │ │ │ │ -0000d8b0: 2020 2020 2020 3c73 7061 6e20 636c 6173 │ │ │ │ -0000d8d0: 666f 723c 2f73 7061 6e3e 2028 3c61 2063 for (size │ │ │ │ -0000d930: 5f74 7970 653c 2f61 3e20 6b3d 303b 206b _type k=0; k │ │ │ │ -0000d940: 266c 743b 3c61 2063 6c61 7373 3d22 636f <rows; k │ │ │ │ -0000d9a0: 2b2b 293c 2f64 6976 3e0a 3c64 6976 2063 ++)
    .
    324 │ │ │ │ -0000da00: 2020 2020 2020 2020 2020 435b 695d 5b6a C[i][j │ │ │ │ -0000da10: 5d20 2b3d 203c 6120 636c 6173 733d 2263 ] += M[i][k │ │ │ │ -0000da70: 5d2a 282a 3c73 7061 6e20 636c 6173 733d ]*(*this)[k][j];.
    32 │ │ │ │ -0000daf0: 353c 2f73 7061 6e3e 2020 2020 2020 2020 5 │ │ │ │ -0000db00: 7d3c 2f64 6976 3e0a 3c64 6976 2063 6c61 }
    .
    │ │ │ │ -0000db50: 2020 3332 363c 2f73 7061 6e3e 2020 2020 326 │ │ │ │ -0000db60: 2020 7d3c 2f64 6976 3e0a 3c64 6976 2063 }
    .
    327 │ │ │ │ -0000dbc0: 2020 2020 3c73 7061 6e20 636c 6173 733d re │ │ │ │ -0000dbe0: 7475 726e 3c2f 7370 616e 3e20 433b 3c2f turn C;.
    3 │ │ │ │ -0000dc40: 3238 3c2f 7370 616e 3e20 2020 207d 3c2f 28 }.
    .
    < │ │ │ │ -0000dc90: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -0000dca0: 6e6f 223e 2020 3332 393c 2f73 7061 6e3e no"> 329 │ │ │ │ -0000dcb0: 203c 2f64 6976 3e0a 3c64 6976 2063 6c61
    .
    │ │ │ │ -0000dd00: 2020 3333 303c 2f73 7061 6e3e 2020 2020 330 │ │ │ │ -0000dd10: 3c73 7061 6e20 636c 6173 733d 226b 6579 using Base::rightm │ │ │ │ -0000dd90: 756c 7469 706c 793c 2f61 3e3b 3c2f 6469 ultiply;.
    331 │ │ │ │ -0000ddf0: 3c2f 7370 616e 3e20 3c2f 6469 763e 0a3c
    .< │ │ │ │ -0000de00: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -0000de10: 3e3c 6120 6964 3d22 6c30 3033 3333 2220 > 333 tem │ │ │ │ -0000de70: 706c 6174 653c 2f73 7061 6e3e 2026 6c74 plate < │ │ │ │ -0000de80: 3b3c 7370 616e 2063 6c61 7373 3d22 6b65 ;int r, int c& │ │ │ │ -0000ded0: 6774 3b3c 2f64 6976 3e0a 3c64 6976 2063 gt;
    .
    . │ │ │ │ -0000df20: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    < │ │ │ │ -0000df50: 2f61 3e3c 7370 616e 2063 6c61 7373 3d22 /a> 3 │ │ │ │ -0000dfb0: 3334 3c2f 613e 3c2f 7370 616e 3e20 2020 34 │ │ │ │ -0000dfc0: 203c 6120 636c 6173 733d 2263 6f64 6520 Fie │ │ │ │ -0000dff0: 6c64 4d61 7472 6978 3c2f 613e 2661 6d70 ldMatrix& │ │ │ │ -0000e000: 3b20 3c61 2063 6c61 7373 3d22 636f 6465 ; rightmultiply │ │ │ │ -0000e060: 3c2f 613e 2028 3c73 7061 6e20 636c 6173 (cons │ │ │ │ -0000e080: 743c 2f73 7061 6e3e 203c 6120 636c 6173 t FieldMatrix │ │ │ │ -0000e0c0: 266c 743b 4b2c 722c 6326 6774 3b3c 2f61 <K,r,c>& M).
    3 │ │ │ │ -0000e180: 3335 3c2f 7370 616e 3e20 2020 207b 3c2f 35 {.
    3 │ │ │ │ -0000e1e0: 3336 3c2f 7370 616e 3e20 2020 2020 203c 36 < │ │ │ │ -0000e1f0: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -0000e200: 6f72 6422 3e73 7461 7469 635f 6173 7365 ord">static_asse │ │ │ │ -0000e210: 7274 3c2f 7370 616e 3e28 7220 3d3d 2063 rt(r == c │ │ │ │ -0000e220: 2c20 3c73 7061 6e20 636c 6173 733d 2273 , &q │ │ │ │ -0000e240: 756f 743b 4361 6e6e 6f74 2072 6967 6874 uot;Cannot right │ │ │ │ -0000e250: 6d75 6c74 6970 6c79 2077 6974 6820 6e6f multiply with no │ │ │ │ -0000e260: 6e2d 7371 7561 7265 206d 6174 7269 7826 n-square matrix& │ │ │ │ -0000e270: 7175 6f74 3b3c 2f73 7061 6e3e 293b 3c2f quot;);.
    3 │ │ │ │ -0000e2d0: 3337 3c2f 7370 616e 3e20 2020 2020 203c 37 < │ │ │ │ -0000e2e0: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -0000e2f0: 6f72 6422 3e73 7461 7469 635f 6173 7365 ord">static_asse │ │ │ │ -0000e300: 7274 3c2f 7370 616e 3e28 7220 3d3d 203c rt(r == < │ │ │ │ -0000e310: 6120 636c 6173 733d 2263 6f64 6520 686c a class="code hl │ │ │ │ -0000e320: 5f76 6172 6961 626c 6522 2068 7265 663d _variable" href= │ │ │ │ -0000e330: 2261 3031 3430 382e 6874 6d6c 2361 6332 "a01408.html#ac2 │ │ │ │ -0000e340: 3831 3666 3164 3036 3766 3533 3333 3636 816f1d067f533366 │ │ │ │ -0000e350: 3239 3763 3035 3366 3037 3039 3962 223e 297c053f07099b"> │ │ │ │ -0000e360: 636f 6c73 3c2f 613e 2c20 3c73 7061 6e20 cols, "Size │ │ │ │ -0000e390: 206d 6973 6d61 7463 6826 7175 6f74 3b3c mismatch"< │ │ │ │ -0000e3a0: 2f73 7061 6e3e 293b 3c2f 6469 763e 0a3c /span>);
    .< │ │ │ │ -0000e3b0: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -0000e3c0: 3e3c 6120 6964 3d22 6c30 3033 3338 2220 > 338 FieldMatrix │ │ │ │ -0000e440: 266c 743b 4b2c 726f 7773 2c63 6f6c 7326 <K,rows,cols& │ │ │ │ -0000e450: 6774 3b3c 2f61 3e20 4328 2a3c 7370 616e gt; C(*this);.
    3 │ │ │ │ -0000e4d0: 3339 3c2f 7370 616e 3e20 3c2f 6469 763e 39
    │ │ │ │ -0000e4e0: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -0000e510: 3c2f 613e 3c73 7061 6e20 636c 6173 733d 340 for │ │ │ │ -0000e560: 283c 6120 636c 6173 733d 2263 6f64 6520 (size_type i │ │ │ │ -0000e5c0: 3d30 3b20 6926 6c74 3b3c 6120 636c 6173 =0; i<rows; i++)
    .< │ │ │ │ -0000e630: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -0000e640: 3e3c 6120 6964 3d22 6c30 3033 3431 2220 > 341 for │ │ │ │ -0000e6b0: 283c 6120 636c 6173 733d 2263 6f64 6520 (size_type j │ │ │ │ -0000e710: 3d30 3b20 6a26 6c74 3b3c 6120 636c 6173 =0; j<cols; j++) {
    │ │ │ │ -0000e780: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -0000e7b0: 3c2f 613e 3c73 7061 6e20 636c 6173 733d 342 ( │ │ │ │ -0000e7e0: 2a74 6869 7329 5b69 5d5b 6a5d 203d 2030 *this)[i][j] = 0 │ │ │ │ -0000e7f0: 3b3c 2f64 6976 3e0a 3c64 6976 2063 6c61 ;
    .
    │ │ │ │ -0000e840: 2020 3334 333c 2f73 7061 6e3e 2020 2020 343 │ │ │ │ -0000e850: 2020 2020 2020 3c73 7061 6e20 636c 6173 │ │ │ │ -0000e870: 666f 723c 2f73 7061 6e3e 2028 3c61 2063 for (size │ │ │ │ -0000e8d0: 5f74 7970 653c 2f61 3e20 6b3d 303b 206b _type k=0; k │ │ │ │ -0000e8e0: 266c 743b 3c61 2063 6c61 7373 3d22 636f <cols; k │ │ │ │ -0000e940: 2b2b 293c 2f64 6976 3e0a 3c64 6976 2063 ++)
    .
    344 │ │ │ │ -0000e9a0: 2020 2020 2020 2020 2020 282a 3c73 7061 (*this)[i │ │ │ │ -0000e9d0: 5d5b 6a5d 202b 3d20 435b 695d 5b6b 5d2a ][j] += C[i][k]* │ │ │ │ -0000e9e0: 3c61 2063 6c61 7373 3d22 636f 6465 2068 M[k][j];.
    34 │ │ │ │ -0000ea90: 353c 2f73 7061 6e3e 2020 2020 2020 2020 5 │ │ │ │ -0000eaa0: 7d3c 2f64 6976 3e0a 3c64 6976 2063 6c61 }
    .
    │ │ │ │ -0000eaf0: 2020 3334 363c 2f73 7061 6e3e 2020 2020 346 │ │ │ │ -0000eb00: 2020 3c73 7061 6e20 636c 6173 733d 226b retu │ │ │ │ -0000eb20: 726e 3c2f 7370 616e 3e20 2a3c 7370 616e rn *this;.
    34 │ │ │ │ -0000eba0: 373c 2f73 7061 6e3e 2020 2020 7d3c 2f64 7 }.
    .
    348 │ │ │ │ -0000ec10: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -0000ec60: 2033 3530 3c2f 7370 616e 3e20 2020 203c 350 < │ │ │ │ -0000ec70: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -0000ec80: 6f72 6422 3e74 656d 706c 6174 653c 2f73 ord">template<int l&g │ │ │ │ -0000ecc0: 743b 3c2f 6469 763e 0a3c 6469 7620 636c t;
    ..
    │ │ │ │ -0000efa0: 2020 3335 323c 2f73 7061 6e3e 3c73 7061 352 {.
    3 │ │ │ │ -0000f020: 3533 3c2f 7370 616e 3e20 2020 2020 203c 53 < │ │ │ │ -0000f030: 6120 636c 6173 733d 2263 6f64 6520 686c a class="code hl │ │ │ │ -0000f040: 5f63 6c61 7373 2220 6872 6566 3d22 6130 _class" href="a0 │ │ │ │ -0000f050: 3134 3038 2e68 746d 6c22 3e46 6965 6c64 1408.html">Field │ │ │ │ -0000f060: 4d61 7472 6978 266c 743b 4b2c 726f 7773 Matrix<K,rows │ │ │ │ -0000f070: 2c6c 2667 743b 3c2f 613e 2043 3b3c 2f64 ,l> C;.
    35 │ │ │ │ -0000f0d0: 343c 2f73 7061 6e3e 203c 2f64 6976 3e0a 4
    . │ │ │ │ -0000f0e0: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    . │ │ │ │ -0000f230: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    < │ │ │ │ -0000f260: 2f61 3e3c 7370 616e 2063 6c61 7373 3d22 /a> 356 for │ │ │ │ -0000f2b0: 2028 3c61 2063 6c61 7373 3d22 636f 6465 (size_type │ │ │ │ -0000f310: 6a3d 303b 206a 266c 743b 6c3b 206a 2b2b j=0; j<l; j++ │ │ │ │ -0000f320: 2920 7b3c 2f64 6976 3e0a 3c64 6976 2063 ) {
    .
    357 │ │ │ │ -0000f380: 2020 2020 2020 2020 435b 695d 5b6a 5d20 C[i][j] │ │ │ │ -0000f390: 3d20 303b 3c2f 6469 763e 0a3c 6469 7620 = 0;
    .
    358 │ │ │ │ -0000f3f0: 2020 2020 2020 2020 203c 7370 616e 2063 for (< │ │ │ │ -0000f420: 6120 636c 6173 733d 2263 6f64 6520 686c a class="code hl │ │ │ │ -0000f430: 5f74 7970 6564 6566 2220 6872 6566 3d22 _typedef" href=" │ │ │ │ -0000f440: 6130 3134 3038 2e68 746d 6c23 6133 3966 a01408.html#a39f │ │ │ │ -0000f450: 3061 6561 3935 3264 3061 3130 6362 6335 0aea952d0a10cbc5 │ │ │ │ -0000f460: 6263 6135 3863 3465 3939 3266 3122 3e73 bca58c4e992f1">s │ │ │ │ -0000f470: 697a 655f 7479 7065 3c2f 613e 206b 3d30 ize_type k=0 │ │ │ │ -0000f480: 3b20 6b26 6c74 3b3c 6120 636c 6173 733d ; k<cols │ │ │ │ -0000f4e0: 3b20 6b2b 2b29 3c2f 6469 763e 0a3c 6469 ; k++)
    .< │ │ │ │ -0000f500: 6120 6964 3d22 6c30 3033 3539 2220 6e61 a id="l00359" na │ │ │ │ -0000f510: 6d65 3d22 6c30 3033 3539 223e 3c2f 613e me="l00359"> │ │ │ │ -0000f520: 3c73 7061 6e20 636c 6173 733d 226c 696e 359 C[i │ │ │ │ -0000f550: 5d5b 6a5d 202b 3d20 282a 3c73 7061 6e20 ][j] += (* │ │ │ │ -0000f570: 7468 6973 3c2f 7370 616e 3e29 5b69 5d5b this)[i][ │ │ │ │ -0000f580: 6b5d 2a3c 6120 636c 6173 733d 2263 6f64 k]*M[k][j]; │ │ │ │ -0000f5e0: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -0000f630: 2033 3630 3c2f 7370 616e 3e20 2020 2020 360 │ │ │ │ -0000f640: 2020 207d 3c2f 6469 763e 0a3c 6469 7620 }
    .
    361 │ │ │ │ -0000f6a0: 2020 2020 207d 3c2f 6469 763e 0a3c 6469 }
    .< │ │ │ │ -0000f6c0: 6120 6964 3d22 6c30 3033 3632 2220 6e61 a id="l00362" na │ │ │ │ -0000f6d0: 6d65 3d22 6c30 3033 3632 223e 3c2f 613e me="l00362"> │ │ │ │ -0000f6e0: 3c73 7061 6e20 636c 6173 733d 226c 696e 362 return C │ │ │ │ -0000f730: 3b3c 2f64 6976 3e0a 3c64 6976 2063 6c61 ;
    .
    │ │ │ │ -0000f780: 2020 3336 333c 2f73 7061 6e3e 2020 2020 363 │ │ │ │ -0000f790: 7d3c 2f64 6976 3e0a 3c2f 6469 763e 0a3c }
    .
    .< │ │ │ │ -0000f7a0: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -0000f7b0: 3e3c 6120 6964 3d22 6c30 3033 3634 2220 > 364
    .
    365 │ │ │ │ -0000f850: 2020 203c 7370 616e 2063 6c61 7373 3d22 // make │ │ │ │ -0000f870: 2074 6869 7320 7468 696e 6720 6120 6d61 this thing a ma │ │ │ │ -0000f880: 7472 6978 3c2f 7370 616e 3e3c 2f64 6976 trix
    .
    │ │ │ │ -0000f920: 2033 3636 3c2f 613e 3c2f 7370 616e 3e20 366 │ │ │ │ -0000f930: 2020 203c 7370 616e 2063 6c61 7373 3d22 static< │ │ │ │ -0000f950: 2f73 7061 6e3e 203c 7370 616e 2063 6c61 /span> con │ │ │ │ -0000f970: 7374 6578 7072 3c2f 7370 616e 3e20 3c61 stexpr si │ │ │ │ -0000f9d0: 7a65 5f74 7970 653c 2f61 3e20 3c61 2063 ze_type mat │ │ │ │ -0000fa30: 5f72 6f77 733c 2f61 3e28 2920 7b20 3c73 _rows() { return ROWS; }.
    367 stati │ │ │ │ -0000fb30: 633c 2f73 7061 6e3e 203c 7370 616e 2063 c c │ │ │ │ -0000fb50: 6f6e 7374 6578 7072 3c2f 7370 616e 3e20 onstexpr │ │ │ │ -0000fb60: 3c61 2063 6c61 7373 3d22 636f 6465 2068 │ │ │ │ -0000fbb0: 7369 7a65 5f74 7970 653c 2f61 3e20 3c61 size_type m │ │ │ │ -0000fc10: 6174 5f63 6f6c 733c 2f61 3e28 2920 7b20 at_cols() { │ │ │ │ -0000fc20: 3c73 7061 6e20 636c 6173 733d 226b 6579 return │ │ │ │ -0000fc40: 3c2f 7370 616e 3e20 434f 4c53 3b20 7d3c COLS; }< │ │ │ │ -0000fc50: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -0000fca0: 3336 383c 2f73 7061 6e3e 203c 2f64 6976 368
    .
    . │ │ │ │ -0000fea0: 0a3c 6469 7620 636c 6173 733d 226c 696e . │ │ │ │ -0000ff00: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -0000ff30: 3c2f 613e 3c73 7061 6e20 636c 6173 733d 371 DUNE_ │ │ │ │ -0000ffb0: 4153 5345 5254 5f42 4f55 4e44 533c 2f61 ASSERT_BOUNDS(i < ROWS);< │ │ │ │ -0000ffd0: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -00010020: 3337 323c 2f73 7061 6e3e 2020 2020 2020 372 │ │ │ │ -00010030: 3c73 7061 6e20 636c 6173 733d 226b 6579 return │ │ │ │ -00010050: 3c2f 7370 616e 3e20 5f64 6174 615b 695d _data[i] │ │ │ │ -00010060: 3b3c 2f64 6976 3e0a 3c64 6976 2063 6c61 ;
    .
    │ │ │ │ -000100b0: 2020 3337 333c 2f73 7061 6e3e 2020 2020 373 │ │ │ │ -000100c0: 7d3c 2f64 6976 3e0a 3c2f 6469 763e 0a3c }
    .
    .< │ │ │ │ -000100d0: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -000100e0: 3e3c 6120 6964 3d22 6c30 3033 3734 2220 > 374
    .
    │ │ │ │ -00010170: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -000101a0: 3c2f 613e 3c73 7061 6e20 636c 6173 733d │ │ │ │ -00010200: 3337 353c 2f61 3e3c 2f73 7061 6e3e 2020 375 │ │ │ │ -00010210: 2020 3c61 2063 6c61 7373 3d22 636f 6465 co │ │ │ │ -00010240: 6e73 745f 726f 775f 7265 6665 7265 6e63 nst_row_referenc │ │ │ │ -00010250: 653c 2f61 3e20 3c61 2063 6c61 7373 3d22 e mat_acces │ │ │ │ -000102b0: 733c 2f61 3e20 2820 3c61 2063 6c61 7373 s ( size_typ │ │ │ │ -00010310: 653c 2f61 3e20 6920 293c 7370 616e 2063 e i ) │ │ │ │ -00010330: 636f 6e73 743c 2f73 7061 6e3e 3c2f 6469 const.
    376 │ │ │ │ -00010390: 3c2f 7370 616e 3e3c 7370 616e 2063 6c61 │ │ │ │ -000103b0: 203c 2f73 7061 6e3e 7b3c 2f64 6976 3e0a {
    . │ │ │ │ -000103c0: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    < │ │ │ │ -000103f0: 2f61 3e3c 7370 616e 2063 6c61 7373 3d22 /a> 377 DUNE_A │ │ │ │ -00010470: 5353 4552 545f 424f 554e 4453 3c2f 613e SSERT_BOUNDS │ │ │ │ -00010480: 2869 2026 6c74 3b20 524f 5753 293b 3c2f (i < ROWS);.
    3 │ │ │ │ -000104e0: 3738 3c2f 7370 616e 3e20 2020 2020 203c 78 < │ │ │ │ -000104f0: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -00010500: 6f72 6466 6c6f 7722 3e72 6574 7572 6e3c ordflow">return< │ │ │ │ -00010510: 2f73 7061 6e3e 205f 6461 7461 5b69 5d3b /span> _data[i]; │ │ │ │ -00010520: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -00010570: 2033 3739 3c2f 7370 616e 3e20 2020 207d 379 } │ │ │ │ -00010580: 3c2f 6469 763e 0a3c 2f64 6976 3e0a 3c64
    .
    . │ │ │ │ -000105a0: 3c61 2069 643d 226c 3030 3338 3022 206e 380 };
    ..
    38 │ │ │ │ -00010640: 313c 2f73 7061 6e3e 203c 2f64 6976 3e0a 1
    . │ │ │ │ -00010650: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    . │ │ │ │ -00010710: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    < │ │ │ │ -00010740: 2f61 3e3c 7370 616e 2063 6c61 7373 3d22 /a> 385 template&l │ │ │ │ -00010770: 743b 636c 6173 7320 4b26 6774 3b3c 2f64 t;class K>.
    38 │ │ │ │ -000107d0: 363c 2f73 7061 6e3e 2020 3c73 7061 6e20 6 │ │ │ │ -000107f0: 636c 6173 7320 3c2f 7370 616e 3e46 6965 class Fie │ │ │ │ -00010800: 6c64 4d61 7472 6978 266c 743b 4b2c 312c ldMatrix<K,1, │ │ │ │ -00010810: 3126 6774 3b20 3a20 3c73 7061 6e20 636c 1> : pu │ │ │ │ -00010830: 626c 6963 3c2f 7370 616e 3e20 4465 6e73 blic Dens │ │ │ │ -00010840: 654d 6174 7269 7826 6c74 3b20 4669 656c eMatrix< Fiel │ │ │ │ -00010850: 644d 6174 7269 7826 6c74 3b4b 2c31 2c31 dMatrix<K,1,1 │ │ │ │ -00010860: 2667 743b 2026 6774 3b3c 2f64 6976 3e0a > >
    . │ │ │ │ -00010870: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    . │ │ │ │ -000108e0: 3c61 2069 643d 226c 3030 3338 3822 206e 388 FieldVecto │ │ │ │ -00010930: 7226 6c74 3b4b 2c31 2667 743b 205f 6461 r<K,1> _da │ │ │ │ -00010940: 7461 3b3c 2f64 6976 3e0a 3c64 6976 2063 ta;
    .
    389 │ │ │ │ -000109a0: 2020 3c73 7061 6e20 636c 6173 733d 226b typedef< │ │ │ │ -000109c0: 2f73 7061 6e3e 2044 656e 7365 4d61 7472 /span> DenseMatr │ │ │ │ -000109d0: 6978 266c 743b 2046 6965 6c64 4d61 7472 ix< FieldMatr │ │ │ │ -000109e0: 6978 266c 743b 4b2c 312c 3126 6774 3b20 ix<K,1,1> │ │ │ │ -000109f0: 2667 743b 2042 6173 653b 3c2f 6469 763e > Base;
    │ │ │ │ -00010a00: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -00010a30: 3c2f 613e 3c73 7061 6e20 636c 6173 733d 390 pub │ │ │ │ -00010a70: 6c69 633c 2f73 7061 6e3e 3a3c 2f64 6976 lic:
    .
    391< │ │ │ │ -00010ad0: 2f73 7061 6e3e 2020 2020 3c73 7061 6e20 /span> │ │ │ │ -00010af0: 2f2f 2073 7461 6e64 6172 6420 636f 6e73 // standard cons │ │ │ │ -00010b00: 7472 7563 746f 7220 616e 6420 6576 6572 tructor and ever │ │ │ │ -00010b10: 7974 6869 6e67 2069 7320 7375 6666 6963 ything is suffic │ │ │ │ -00010b20: 6965 6e74 202e 2e2e 3c2f 7370 616e 3e3c ient ...< │ │ │ │ -00010b30: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -00010b80: 3339 323c 2f73 7061 6e3e 203c 2f64 6976 392
    .
    393< │ │ │ │ -00010be0: 2f73 7061 6e3e 2020 2020 3c73 7061 6e20 /span> │ │ │ │ -00010c00: 2f2f 3d3d 3d3d 3d20 7479 7065 2064 6566 //===== type def │ │ │ │ -00010c10: 696e 6974 696f 6e73 2061 6e64 2063 6f6e initions and con │ │ │ │ -00010c20: 7374 616e 7473 3c2f 7370 616e 3e3c 2f64 stants.
    39 │ │ │ │ -00010c80: 343c 2f73 7061 6e3e 203c 2f64 6976 3e0a 4
    . │ │ │ │ -00010c90: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    .
    < │ │ │ │ -00010e30: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -00010e40: 6e6f 223e 2020 3339 373c 2f73 7061 6e3e no"> 397 │ │ │ │ -00010e50: 203c 2f64 6976 3e0a 3c64 6976 2063 6c61
    .
    │ │ │ │ -00010ea0: 2020 3430 303c 2f73 7061 6e3e 2020 2020 400 │ │ │ │ -00010eb0: 3c73 7061 6e20 636c 6173 733d 226b 6579 constexpr< │ │ │ │ -00010ed0: 2f73 7061 6e3e 203c 7370 616e 2063 6c61 /span> sta │ │ │ │ -00010ef0: 7469 633c 2f73 7061 6e3e 203c 7370 616e tic int │ │ │ │ -00010f20: 3c61 2063 6c61 7373 3d22 636f 6465 2068 blocklevel │ │ │ │ -00010f80: 3d20 313b 3c2f 6469 763e 0a3c 6469 7620 = 1;
    .
    401 │ │ │ │ -00010fe0: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -00011030: 2034 3032 3c2f 7370 616e 3e20 2020 203c 402 < │ │ │ │ -00011040: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -00011050: 6f72 6422 3e74 7970 6564 6566 3c2f 7370 ord">typedef typena │ │ │ │ -00011080: 6d65 3c2f 7370 616e 3e20 3c61 2063 6c61 me Base:: │ │ │ │ -000110e0: 726f 775f 7479 7065 3c2f 613e 203c 6120 row_type row │ │ │ │ -00011140: 5f74 7970 653c 2f61 3e3b 3c2f 6469 763e _type;
    │ │ │ │ -00011150: 0a3c 6469 7620 636c 6173 733d 226c 696e ..< │ │ │ │ -000111c0: 6120 6964 3d22 6c30 3034 3034 2220 6e61 a id="l00404" na │ │ │ │ -000111d0: 6d65 3d22 6c30 3034 3034 223e 3c2f 613e me="l00404"> │ │ │ │ -000111e0: 3c73 7061 6e20 636c 6173 733d 226c 696e 404 typed │ │ │ │ -00011220: 6566 3c2f 7370 616e 3e20 3c73 7061 6e20 ef │ │ │ │ -00011240: 7479 7065 6e61 6d65 3c2f 7370 616e 3e20 typename │ │ │ │ -00011250: 3c61 2063 6c61 7373 3d22 636f 6465 2068 │ │ │ │ -000112a0: 4261 7365 3a3a 726f 775f 7265 6665 7265 Base::row_refere │ │ │ │ -000112b0: 6e63 653c 2f61 3e20 3c61 2063 6c61 7373 nce row_refe │ │ │ │ -00011310: 7265 6e63 653c 2f61 3e3b 3c2f 6469 763e rence;
    │ │ │ │ -00011320: 0a3c 6469 7620 636c 6173 733d 226c 696e . │ │ │ │ -000114a0: 0a3c 6469 7620 636c 6173 733d 226c 696e ..< │ │ │ │ -00011510: 6120 6964 3d22 6c30 3034 3039 2220 6e61 a id="l00409" na │ │ │ │ -00011520: 6d65 3d22 6c30 3034 3039 223e 3c2f 613e me="l00409"> │ │ │ │ -00011530: 3c73 7061 6e20 636c 6173 733d 226c 696e 409 const │ │ │ │ -00011570: 6578 7072 3c2f 7370 616e 3e20 3c73 7061 expr static │ │ │ │ -000115a0: 3c73 7061 6e20 636c 6173 733d 226b 6579 int rows = │ │ │ │ -00011620: 2031 3b3c 2f64 6976 3e0a 3c64 6976 2063 1;
    .
    412 │ │ │ │ -00011680: 2020 3c73 7061 6e20 636c 6173 733d 226b constexp │ │ │ │ -000116a0: 723c 2f73 7061 6e3e 203c 7370 616e 2063 r s │ │ │ │ -000116c0: 7461 7469 633c 2f73 7061 6e3e 203c 7370 tatic int cols = 1; │ │ │ │ -00011750: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -000117a0: 2034 3133 3c2f 7370 616e 3e20 3c2f 6469 413 .
    414 │ │ │ │ -00011800: 3c2f 7370 616e 3e20 2020 203c 7370 616e //===== constru │ │ │ │ -00011830: 6374 6f72 733c 2f73 7061 6e3e 3c2f 6469 ctors.
    417 │ │ │ │ -00011890: 3c2f 7370 616e 3e20 2020 203c 7370 616e constexpr FieldMatrix() = default; │ │ │ │ -00011950: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -000119a0: 2034 3138 3c2f 7370 616e 3e20 3c2f 6469 418 .
    421 │ │ │ │ -00011a00: 3c2f 7370 616e 3e20 2020 203c 6120 636c Fiel │ │ │ │ -00011a60: 644d 6174 7269 783c 2f61 3e28 7374 643a dMatrix(std: │ │ │ │ -00011a70: 3a69 6e69 7469 616c 697a 6572 5f6c 6973 :initializer_lis │ │ │ │ -00011a80: 7426 6c74 3b3c 6120 636c 6173 733d 2263 t<Dune::FieldVect │ │ │ │ -00011ac0: 6f72 266c 743b 4b2c 2031 2667 743b 3c2f or<K, 1>> con │ │ │ │ -00011af0: 7374 3c2f 7370 616e 3e20 2661 6d70 3b6c st &l │ │ │ │ -00011b00: 293c 2f64 6976 3e0a 3c64 6976 2063 6c61 )
    .
    │ │ │ │ -00011b50: 2020 3432 323c 2f73 7061 6e3e 2020 2020 422 │ │ │ │ -00011b60: 7b3c 2f64 6976 3e0a 3c64 6976 2063 6c61 {
    .
    │ │ │ │ -00011bb0: 2020 3432 333c 2f73 7061 6e3e 2020 2020 423 │ │ │ │ -00011bc0: 2020 7374 643a 3a63 6f70 795f 6e28 6c2e std::copy_n(l. │ │ │ │ -00011bd0: 6265 6769 6e28 292c 2073 7464 3a3a 6d69 begin(), std::mi │ │ │ │ -00011be0: 6e28 3c73 7061 6e20 636c 6173 733d 226b n(static_c │ │ │ │ -00011c00: 6173 7426 6c74 3b3c 2f73 7061 6e3e 2073 ast< s │ │ │ │ -00011c10: 7464 3a3a 7369 7a65 5f74 203c 7370 616e td::size_t >( 1 │ │ │ │ -00011c40: 292c 206c 2e73 697a 6528 2929 2c20 2661 ), l.size()), &a │ │ │ │ -00011c50: 6d70 3b5f 6461 7461 293b 3c2f 6469 763e mp;_data);
    │ │ │ │ -00011c60: 0a3c 6469 7620 636c 6173 733d 226c 696e . │ │ │ │ -00011cc0: 0a3c 6469 7620 636c 6173 733d 226c 696e ..< │ │ │ │ -00011d30: 6120 6964 3d22 6c30 3034 3236 2220 6e61 a id="l00426" na │ │ │ │ -00011d40: 6d65 3d22 6c30 3034 3236 223e 3c2f 613e me="l00426"> │ │ │ │ -00011d50: 3c73 7061 6e20 636c 6173 733d 226c 696e 426 templ │ │ │ │ -00011d90: 6174 653c 2f73 7061 6e3e 2026 6c74 3b3c ate << │ │ │ │ -00011da0: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -00011db0: 6f72 6422 3e63 6c61 7373 203c 2f73 7061 ord">class T,
    .
    427 │ │ │ │ -00011e20: 2020 2020 2020 2020 2020 2020 203c 7370 typename = std::enable │ │ │ │ -00011e60: 5f69 665f 7426 6c74 3b48 6173 4465 6e73 _if_t<HasDens │ │ │ │ -00011e70: 654d 6174 7269 7841 7373 6967 6e65 7226 eMatrixAssigner& │ │ │ │ -00011e80: 6c74 3b46 6965 6c64 4d61 7472 6978 2c20 lt;FieldMatrix, │ │ │ │ -00011e90: 5426 6774 3b3a 3a76 616c 7565 2667 743b T>::value> │ │ │ │ -00011ea0: 2667 743b 3c2f 6469 763e 0a3c 6469 7620 >
    ..
    429 │ │ │ │ -00011ff0: 207b 3c2f 6469 763e 0a3c 6469 7620 636c {
    .
    430 │ │ │ │ -00012050: 2020 202a 3c73 7061 6e20 636c 6173 733d *this = rhs;.
    431 │ │ │ │ -000120d0: 3c2f 7370 616e 3e20 2020 207d 3c2f 6469 }.
    432 │ │ │ │ -00012130: 3c2f 7370 616e 3e20 3c2f 6469 763e 0a3c
    .< │ │ │ │ -00012140: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -00012150: 3e3c 6120 6964 3d22 6c30 3034 3333 2220 > 433 usi │ │ │ │ -000121b0: 6e67 203c 2f73 7061 6e3e 4261 7365 3a3a ng Base:: │ │ │ │ -000121c0: 6f70 6572 6174 6f72 3d3b 3c2f 6469 763e operator=;
    │ │ │ │ -000121d0: 0a3c 6469 7620 636c 6173 733d 226c 696e ..< │ │ │ │ -00012240: 6120 6964 3d22 6c30 3034 3336 2220 6e61 a id="l00436" na │ │ │ │ -00012250: 6d65 3d22 6c30 3034 3336 223e 3c2f 613e me="l00436"> │ │ │ │ -00012260: 3c73 7061 6e20 636c 6173 733d 226c 696e 436 FieldMatrix │ │ │ │ -00012290: 266c 743b 4b2c 2031 2c20 3126 6774 3b20 <K, 1, 1> │ │ │ │ -000122a0: 3c61 2063 6c61 7373 3d22 636f 6465 2068 transposed( │ │ │ │ -00012300: 293c 7370 616e 2063 6c61 7373 3d22 6b65 ) const
    .
    437< │ │ │ │ -00012380: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -00012390: 6f72 6422 3e20 2020 203c 2f73 7061 6e3e ord"> │ │ │ │ -000123a0: 7b3c 2f64 6976 3e0a 3c64 6976 2063 6c61 {
    .
    │ │ │ │ -000123f0: 2020 3433 383c 2f73 7061 6e3e 2020 2020 438 │ │ │ │ -00012400: 2020 3c73 7061 6e20 636c 6173 733d 226b retu │ │ │ │ -00012420: 726e 3c2f 7370 616e 3e20 2a3c 7370 616e rn *this;.
    43 │ │ │ │ -000124a0: 393c 2f73 7061 6e3e 2020 2020 7d3c 2f64 9 }.
    44 │ │ │ │ -00012500: 303c 2f73 7061 6e3e 203c 2f64 6976 3e0a 0
    . │ │ │ │ -00012510: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    .
    443 │ │ │ │ -00012620: 2020 203c 7370 616e 2063 6c61 7373 3d22 friend< │ │ │ │ -00012640: 2f73 7061 6e3e 203c 7370 616e 2063 6c61 /span> aut │ │ │ │ -00012660: 6f3c 2f73 7061 6e3e 203c 6120 636c 6173 o operator │ │ │ │ -000126c0: 2b20 3c2f 613e 2820 3c73 7061 6e20 636c + ( co │ │ │ │ -000126e0: 6e73 743c 2f73 7061 6e3e 203c 6120 636c nst Fiel │ │ │ │ -00012740: 644d 6174 7269 783c 2f61 3e26 616d 703b dMatrix& │ │ │ │ -00012750: 206d 6174 7269 7841 2c3c 2f64 6976 3e0a matrixA,
    . │ │ │ │ -00012760: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65 .
    445 │ │ │ │ -00012880: 2020 7b3c 2f64 6976 3e0a 3c64 6976 2063 {
    .
    446 │ │ │ │ -000128e0: 2020 2020 3c73 7061 6e20 636c 6173 733d re │ │ │ │ -00012900: 7475 726e 3c2f 7370 616e 3e20 4669 656c turn Fiel │ │ │ │ -00012910: 644d 6174 7269 7826 6c74 3b74 7970 656e dMatrix<typen │ │ │ │ -00012920: 616d 6520 5072 6f6d 6f74 696f 6e54 7261 ame PromotionTra │ │ │ │ -00012930: 6974 7326 6c74 3b4b 2c4f 7468 6572 5363 its<K,OtherSc │ │ │ │ -00012940: 616c 6172 2667 743b 3a3a 5072 6f6d 6f74 alar>::Promot │ │ │ │ -00012950: 6564 5479 7065 2c31 2c31 2667 743b 7b6d edType,1,1>{m │ │ │ │ -00012960: 6174 7269 7841 5b30 5d5b 305d 202b 206d atrixA[0][0] + m │ │ │ │ -00012970: 6174 7269 7842 5b30 5d5b 305d 7d3b 3c2f atrixB[0][0]};.
    4 │ │ │ │ -000129d0: 3437 3c2f 7370 616e 3e20 2020 207d 3c2f 47 }.
    4 │ │ │ │ -00012a30: 3438 3c2f 7370 616e 3e20 3c2f 6469 763e 48
    │ │ │ │ -00012a40: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -00012a70: 3c2f 613e 3c73 7061 6e20 636c 6173 733d 450 t │ │ │ │ -00012ab0: 656d 706c 6174 653c 2f73 7061 6e3e 2026 emplate & │ │ │ │ -00012ac0: 6c74 3b3c 7370 616e 2063 6c61 7373 3d22 lt;class < │ │ │ │ -00012ae0: 2f73 7061 6e3e 3c61 2063 6c61 7373 3d22 /span>Scalar,
    .
    451 │ │ │ │ -00012ba0: 2020 2020 2020 2020 2020 2073 7464 3a3a std:: │ │ │ │ -00012bb0: 656e 6162 6c65 5f69 665f 7426 6c74 3b49 enable_if_t<I │ │ │ │ -00012bc0: 734e 756d 6265 7226 6c74 3b53 6361 6c61 sNumber<Scala │ │ │ │ -00012bd0: 7226 6774 3b3a 3a76 616c 7565 2c20 3c73 r>::value, int> = 0>.
    4 │ │ │ │ -00012c60: 3532 3c2f 7370 616e 3e20 2020 203c 7370 52 friend │ │ │ │ -00012c90: 203c 7370 616e 2063 6c61 7373 3d22 6b65 auto operator+ │ │ │ │ -00012d10: 2820 3c73 7061 6e20 636c 6173 733d 226b ( const FieldMatri │ │ │ │ -00012d90: 783c 2f61 3e26 616d 703b 206d 6174 7269 x& matri │ │ │ │ -00012da0: 782c 3c2f 6469 763e 0a3c 6469 7620 636c x,
    .
    453 │ │ │ │ -00012e00: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ │ -00012e10: 2020 2020 2020 2020 203c 7370 616e 2063 c │ │ │ │ -00012e30: 6f6e 7374 3c2f 7370 616e 3e20 5363 616c onst Scal │ │ │ │ -00012e40: 6172 2661 6d70 3b20 7363 616c 6172 293c ar& scalar)< │ │ │ │ -00012e50: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -00012ea0: 3435 343c 2f73 7061 6e3e 2020 2020 7b3c 454 {< │ │ │ │ -00012eb0: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -00012f00: 3435 353c 2f73 7061 6e3e 2020 2020 2020 455 │ │ │ │ -00012f10: 3c73 7061 6e20 636c 6173 733d 226b 6579 return │ │ │ │ -00012f30: 3c2f 7370 616e 3e20 4669 656c 644d 6174 FieldMat │ │ │ │ -00012f40: 7269 7826 6c74 3b74 7970 656e 616d 6520 rix<typename │ │ │ │ -00012f50: 5072 6f6d 6f74 696f 6e54 7261 6974 7326 PromotionTraits& │ │ │ │ -00012f60: 6c74 3b4b 2c53 6361 6c61 7226 6774 3b3a lt;K,Scalar>: │ │ │ │ -00012f70: 3a50 726f 6d6f 7465 6454 7970 652c 312c :PromotedType,1, │ │ │ │ -00012f80: 3126 6774 3b7b 6d61 7472 6978 5b30 5d5b 1>{matrix[0][ │ │ │ │ -00012f90: 305d 202b 2073 6361 6c61 727d 3b3c 2f64 0] + scalar};.
    45 │ │ │ │ -00012ff0: 363c 2f73 7061 6e3e 2020 2020 7d3c 2f64 6 }.
    45 │ │ │ │ -00013050: 373c 2f73 7061 6e3e 203c 2f64 6976 3e0a 7
    . │ │ │ │ -00013060: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65 .
    │ │ │ │ -000131b0: 2020 3436 303c 2f73 7061 6e3e 2020 2020 460 │ │ │ │ -000131c0: 2020 2020 2020 2020 2020 7374 643a 3a65 std::e │ │ │ │ -000131d0: 6e61 626c 655f 6966 5f74 266c 743b 4973 nable_if_t<Is │ │ │ │ -000131e0: 4e75 6d62 6572 266c 743b 5363 616c 6172 Number<Scalar │ │ │ │ -000131f0: 2667 743b 3a3a 7661 6c75 652c 203c 7370 >::value, int> = 0>.
    46 │ │ │ │ -00013280: 313c 2f73 7061 6e3e 2020 2020 3c73 7061 1 friend │ │ │ │ -000132b0: 3c73 7061 6e20 636c 6173 733d 226b 6579 auto operator+ ( │ │ │ │ -00013330: 203c 7370 616e 2063 6c61 7373 3d22 6b65 const Scalar& │ │ │ │ -00013360: 7363 616c 6172 2c3c 2f64 6976 3e0a 3c64 scalar,
    . │ │ │ │ -00013380: 3c61 2069 643d 226c 3030 3436 3222 206e 462 │ │ │ │ -000133d0: 2020 2020 2020 2020 2020 2020 2020 3c73 const │ │ │ │ -00013400: 203c 6120 636c 6173 733d 2263 6f64 6520 FieldMatrix& matrix).
    4 │ │ │ │ -000134c0: 3633 3c2f 7370 616e 3e20 2020 207b 3c2f 63 {.
    4 │ │ │ │ -00013520: 3634 3c2f 7370 616e 3e20 2020 2020 203c 64 < │ │ │ │ -00013530: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -00013540: 6f72 6466 6c6f 7722 3e72 6574 7572 6e3c ordflow">return< │ │ │ │ -00013550: 2f73 7061 6e3e 2046 6965 6c64 4d61 7472 /span> FieldMatr │ │ │ │ -00013560: 6978 266c 743b 7479 7065 6e61 6d65 2050 ix<typename P │ │ │ │ -00013570: 726f 6d6f 7469 6f6e 5472 6169 7473 266c romotionTraits&l │ │ │ │ -00013580: 743b 5363 616c 6172 2c4b 2667 743b 3a3a t;Scalar,K>:: │ │ │ │ -00013590: 5072 6f6d 6f74 6564 5479 7065 2c31 2c31 PromotedType,1,1 │ │ │ │ -000135a0: 2667 743b 7b73 6361 6c61 7220 2b20 6d61 >{scalar + ma │ │ │ │ -000135b0: 7472 6978 5b30 5d5b 305d 7d3b 3c2f 6469 trix[0][0]};.
    465 │ │ │ │ -00013610: 3c2f 7370 616e 3e20 2020 207d 3c2f 6469 }.
    466 │ │ │ │ -00013670: 3c2f 7370 616e 3e20 3c2f 6469 763e 0a3c
    .< │ │ │ │ -00013680: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -00013690: 3e3c 6120 6964 3d22 6c30 3034 3638 2220 > 468 tem │ │ │ │ -000136f0: 706c 6174 653c 2f73 7061 6e3e 2026 6c74 plate < │ │ │ │ -00013700: 3b3c 7370 616e 2063 6c61 7373 3d22 6b65 ;class OtherScalar& │ │ │ │ -00013730: 6774 3b3c 2f64 6976 3e0a 3c64 6976 2063 gt;
    .
    469 │ │ │ │ -00013790: 2020 3c73 7061 6e20 636c 6173 733d 226b friend auto │ │ │ │ -000137d0: 3c2f 7370 616e 3e20 3c61 2063 6c61 7373 operator- │ │ │ │ -00013830: 203c 2f61 3e28 203c 7370 616e 2063 6c61 ( con │ │ │ │ -00013850: 7374 3c2f 7370 616e 3e20 3c61 2063 6c61 st Field │ │ │ │ -000138b0: 4d61 7472 6978 3c2f 613e 2661 6d70 3b20 Matrix& │ │ │ │ -000138c0: 6d61 7472 6978 412c 3c2f 6469 763e 0a3c matrixA,
    .< │ │ │ │ -000138d0: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -000138e0: 3e3c 6120 6964 3d22 6c30 3034 3730 2220 > 470 │ │ │ │ -00013930: 2020 2020 2020 2020 2020 2020 2020 203c < │ │ │ │ -00013940: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -00013950: 6f72 6422 3e63 6f6e 7374 3c2f 7370 616e ord">const FieldMatrix< │ │ │ │ -00013970: 3b4f 7468 6572 5363 616c 6172 2c31 2c31 ;OtherScalar,1,1 │ │ │ │ -00013980: 2667 743b 2661 6d70 3b20 6d61 7472 6978 >& matrix │ │ │ │ -00013990: 4229 3c2f 6469 763e 0a3c 6469 7620 636c B)
    .
    471 │ │ │ │ -000139f0: 207b 3c2f 6469 763e 0a3c 6469 7620 636c {
    .
    472 │ │ │ │ -00013a50: 2020 203c 7370 616e 2063 6c61 7373 3d22 ret │ │ │ │ -00013a70: 7572 6e3c 2f73 7061 6e3e 2046 6965 6c64 urn Field │ │ │ │ -00013a80: 4d61 7472 6978 266c 743b 7479 7065 6e61 Matrix<typena │ │ │ │ -00013a90: 6d65 2050 726f 6d6f 7469 6f6e 5472 6169 me PromotionTrai │ │ │ │ -00013aa0: 7473 266c 743b 4b2c 4f74 6865 7253 6361 ts<K,OtherSca │ │ │ │ -00013ab0: 6c61 7226 6774 3b3a 3a50 726f 6d6f 7465 lar>::Promote │ │ │ │ -00013ac0: 6454 7970 652c 312c 3126 6774 3b7b 6d61 dType,1,1>{ma │ │ │ │ -00013ad0: 7472 6978 415b 305d 5b30 5d20 2d20 6d61 trixA[0][0] - ma │ │ │ │ -00013ae0: 7472 6978 425b 305d 5b30 5d7d 3b3c 2f64 trixB[0][0]};.
    47 │ │ │ │ -00013b40: 333c 2f73 7061 6e3e 2020 2020 7d3c 2f64 3 }.
    47 │ │ │ │ -00013ba0: 343c 2f73 7061 6e3e 203c 2f64 6976 3e0a 4
    . │ │ │ │ -00013bb0: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    .
    │ │ │ │ -00013d00: 2020 3437 373c 2f73 7061 6e3e 2020 2020 477 │ │ │ │ -00013d10: 2020 2020 2020 2020 2020 7374 643a 3a65 std::e │ │ │ │ -00013d20: 6e61 626c 655f 6966 5f74 266c 743b 4973 nable_if_t<Is │ │ │ │ -00013d30: 4e75 6d62 6572 266c 743b 5363 616c 6172 Number<Scalar │ │ │ │ -00013d40: 2667 743b 3a3a 7661 6c75 652c 203c 7370 >::value, int> = 0>.
    47 │ │ │ │ -00013dd0: 383c 2f73 7061 6e3e 2020 2020 3c73 7061 8 friend │ │ │ │ -00013e00: 3c73 7061 6e20 636c 6173 733d 226b 6579 auto operator- ( │ │ │ │ -00013e80: 203c 7370 616e 2063 6c61 7373 3d22 6b65 const FieldMatrix │ │ │ │ -00013f00: 3c2f 613e 2661 6d70 3b20 6d61 7472 6978 & matrix │ │ │ │ -00013f10: 2c3c 2f64 6976 3e0a 3c64 6976 2063 6c61 ,
    .
    │ │ │ │ -00013f60: 2020 3437 393c 2f73 7061 6e3e 2020 2020 479 │ │ │ │ -00013f70: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ │ -00013f80: 2020 2020 2020 2020 3c73 7061 6e20 636c co │ │ │ │ -00013fa0: 6e73 743c 2f73 7061 6e3e 2053 6361 6c61 nst Scala │ │ │ │ -00013fb0: 7226 616d 703b 2073 6361 6c61 7229 3c2f r& scalar).
    4 │ │ │ │ -00014010: 3830 3c2f 7370 616e 3e20 2020 207b 3c2f 80 {.
    4 │ │ │ │ -00014070: 3831 3c2f 7370 616e 3e20 2020 2020 203c 81 < │ │ │ │ -00014080: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -00014090: 6f72 6466 6c6f 7722 3e72 6574 7572 6e3c ordflow">return< │ │ │ │ -000140a0: 2f73 7061 6e3e 2046 6965 6c64 4d61 7472 /span> FieldMatr │ │ │ │ -000140b0: 6978 266c 743b 7479 7065 6e61 6d65 2050 ix<typename P │ │ │ │ -000140c0: 726f 6d6f 7469 6f6e 5472 6169 7473 266c romotionTraits&l │ │ │ │ -000140d0: 743b 4b2c 5363 616c 6172 2667 743b 3a3a t;K,Scalar>:: │ │ │ │ -000140e0: 5072 6f6d 6f74 6564 5479 7065 2c31 2c31 PromotedType,1,1 │ │ │ │ -000140f0: 2667 743b 7b6d 6174 7269 785b 305d 5b30 >{matrix[0][0 │ │ │ │ -00014100: 5d20 2d20 7363 616c 6172 7d3b 3c2f 6469 ] - scalar};.
    482 │ │ │ │ -00014160: 3c2f 7370 616e 3e20 2020 207d 3c2f 6469 }.
    483 │ │ │ │ -000141c0: 3c2f 7370 616e 3e20 3c2f 6469 763e 0a3c
    .< │ │ │ │ -000141d0: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -000141e0: 3e3c 6120 6964 3d22 6c30 3034 3835 2220 > 485 tem │ │ │ │ -00014240: 706c 6174 653c 2f73 7061 6e3e 2026 6c74 plate < │ │ │ │ -00014250: 3b3c 7370 616e 2063 6c61 7373 3d22 6b65 ;class Scalar, │ │ │ │ -000142d0: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -00014320: 2034 3836 3c2f 7370 616e 3e20 2020 2020 486 │ │ │ │ -00014330: 2020 2020 2020 2020 2073 7464 3a3a 656e std::en │ │ │ │ -00014340: 6162 6c65 5f69 665f 7426 6c74 3b49 734e able_if_t<IsN │ │ │ │ -00014350: 756d 6265 7226 6c74 3b53 6361 6c61 7226 umber<Scalar& │ │ │ │ -00014360: 6774 3b3a 3a76 616c 7565 2c20 3c73 7061 gt;::value, int │ │ │ │ -00014390: 2667 743b 203d 2030 2667 743b 3c2f 6469 > = 0>.
    487 │ │ │ │ -000143f0: 3c2f 7370 616e 3e20 2020 203c 7370 616e friend < │ │ │ │ -00014420: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -00014430: 6f72 6422 3e61 7574 6f3c 2f73 7061 6e3e ord">auto │ │ │ │ -00014440: 203c 6120 636c 6173 733d 2263 6f64 6520 │ │ │ │ -00014490: 6f70 6572 6174 6f72 2d20 3c2f 613e 2820 operator- ( │ │ │ │ -000144a0: 3c73 7061 6e20 636c 6173 733d 226b 6579 const Scalar& s │ │ │ │ -000144d0: 6361 6c61 722c 3c2f 6469 763e 0a3c 6469 calar,
    .< │ │ │ │ -000144f0: 6120 6964 3d22 6c30 3034 3838 2220 6e61 a id="l00488" na │ │ │ │ -00014500: 6d65 3d22 6c30 3034 3838 223e 3c2f 613e me="l00488"> │ │ │ │ -00014510: 3c73 7061 6e20 636c 6173 733d 226c 696e 488 │ │ │ │ -00014540: 2020 2020 2020 2020 2020 2020 203c 7370 const │ │ │ │ -00014570: 3c61 2063 6c61 7373 3d22 636f 6465 2068 FieldMatrix │ │ │ │ -000145d0: 2661 6d70 3b20 6d61 7472 6978 293c 2f64 & matrix).
    48 │ │ │ │ -00014630: 393c 2f73 7061 6e3e 2020 2020 7b3c 2f64 9 {.
    49 │ │ │ │ -00014690: 303c 2f73 7061 6e3e 2020 2020 2020 3c73 0 return FieldMatri │ │ │ │ -000146d0: 7826 6c74 3b74 7970 656e 616d 6520 5072 x<typename Pr │ │ │ │ -000146e0: 6f6d 6f74 696f 6e54 7261 6974 7326 6c74 omotionTraits< │ │ │ │ -000146f0: 3b53 6361 6c61 722c 4b26 6774 3b3a 3a50 ;Scalar,K>::P │ │ │ │ -00014700: 726f 6d6f 7465 6454 7970 652c 312c 3126 romotedType,1,1& │ │ │ │ -00014710: 6774 3b7b 7363 616c 6172 202d 206d 6174 gt;{scalar - mat │ │ │ │ -00014720: 7269 785b 305d 5b30 5d7d 3b3c 2f64 6976 rix[0][0]};
    .
    491< │ │ │ │ -00014780: 2f73 7061 6e3e 2020 2020 7d3c 2f64 6976 /span> }
    .
    492< │ │ │ │ -000147e0: 2f73 7061 6e3e 203c 2f64 6976 3e0a 3c64 /span>
    . │ │ │ │ -00014800: 3c61 2069 643d 226c 3030 3439 3422 206e 494 temp │ │ │ │ -00014860: 6c61 7465 3c2f 7370 616e 3e20 266c 743b late < │ │ │ │ -00014870: 3c73 7061 6e20 636c 6173 733d 226b 6579 class Scalar,< │ │ │ │ -000148f0: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -00014940: 3439 353c 2f73 7061 6e3e 2020 2020 2020 495 │ │ │ │ -00014950: 2020 2020 2020 2020 7374 643a 3a65 6e61 std::ena │ │ │ │ -00014960: 626c 655f 6966 5f74 266c 743b 4973 4e75 ble_if_t<IsNu │ │ │ │ -00014970: 6d62 6572 266c 743b 5363 616c 6172 2667 mber<Scalar&g │ │ │ │ -00014980: 743b 3a3a 7661 6c75 652c 203c 7370 616e t;::value, int& │ │ │ │ -000149b0: 6774 3b20 3d20 3026 6774 3b3c 2f64 6976 gt; = 0>
    .
    496< │ │ │ │ -00014a10: 2f73 7061 6e3e 2020 2020 3c73 7061 6e20 /span> │ │ │ │ -00014a30: 6672 6965 6e64 3c2f 7370 616e 3e20 3c73 friend auto │ │ │ │ -00014a60: 3c61 2063 6c61 7373 3d22 636f 6465 2068 o │ │ │ │ -00014ab0: 7065 7261 746f 722a 203c 2f61 3e28 203c perator* ( < │ │ │ │ -00014ac0: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -00014ad0: 6f72 6422 3e63 6f6e 7374 3c2f 7370 616e ord">const FieldMatrix& matrix, │ │ │ │ -00014b50: 5363 616c 6172 2073 6361 6c61 7229 3c2f Scalar scalar).
    4 │ │ │ │ -00014bb0: 3937 3c2f 7370 616e 3e20 2020 207b 3c2f 97 {.
    4 │ │ │ │ -00014c10: 3938 3c2f 7370 616e 3e20 2020 2020 203c 98 < │ │ │ │ -00014c20: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -00014c30: 6f72 6466 6c6f 7722 3e72 6574 7572 6e3c ordflow">return< │ │ │ │ -00014c40: 2f73 7061 6e3e 2046 6965 6c64 4d61 7472 /span> FieldMatr │ │ │ │ -00014c50: 6978 266c 743b 7479 7065 6e61 6d65 2050 ix<typename P │ │ │ │ -00014c60: 726f 6d6f 7469 6f6e 5472 6169 7473 266c romotionTraits&l │ │ │ │ -00014c70: 743b 4b2c 5363 616c 6172 2667 743b 3a3a t;K,Scalar>:: │ │ │ │ -00014c80: 5072 6f6d 6f74 6564 5479 7065 2c31 2c31 PromotedType,1,1 │ │ │ │ -00014c90: 2667 743b 207b 6d61 7472 6978 5b30 5d5b > {matrix[0][ │ │ │ │ -00014ca0: 305d 202a 2073 6361 6c61 727d 3b3c 2f64 0] * scalar};.
    49 │ │ │ │ -00014d00: 393c 2f73 7061 6e3e 2020 2020 7d3c 2f64 9 }.
    50 │ │ │ │ -00014d60: 303c 2f73 7061 6e3e 203c 2f64 6976 3e0a 0
    . │ │ │ │ -00014d70: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    .
    │ │ │ │ -00014ec0: 2020 3530 333c 2f73 7061 6e3e 2020 2020 503 │ │ │ │ -00014ed0: 2020 2020 2020 2020 2020 7374 643a 3a65 std::e │ │ │ │ -00014ee0: 6e61 626c 655f 6966 5f74 266c 743b 4973 nable_if_t<Is │ │ │ │ -00014ef0: 4e75 6d62 6572 266c 743b 5363 616c 6172 Number<Scalar │ │ │ │ -00014f00: 2667 743b 3a3a 7661 6c75 652c 203c 7370 >::value, int> = 0>.
    50 │ │ │ │ -00014f90: 343c 2f73 7061 6e3e 2020 2020 3c73 7061 4 friend │ │ │ │ -00014fc0: 3c73 7061 6e20 636c 6173 733d 226b 6579 auto operator* ( │ │ │ │ -00015040: 2053 6361 6c61 7220 7363 616c 6172 2c20 Scalar scalar, │ │ │ │ -00015050: 3c73 7061 6e20 636c 6173 733d 226b 6579 const FieldMatrix< │ │ │ │ -000150d0: 2f61 3e26 616d 703b 206d 6174 7269 7829 /a>& matrix) │ │ │ │ -000150e0: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -00015130: 2035 3035 3c2f 7370 616e 3e20 2020 207b 505 { │ │ │ │ -00015140: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -00015190: 2035 3036 3c2f 7370 616e 3e20 2020 2020 506 │ │ │ │ -000151a0: 203c 7370 616e 2063 6c61 7373 3d22 6b65 retur │ │ │ │ -000151c0: 6e3c 2f73 7061 6e3e 2046 6965 6c64 4d61 n FieldMa │ │ │ │ -000151d0: 7472 6978 266c 743b 7479 7065 6e61 6d65 trix<typename │ │ │ │ -000151e0: 2050 726f 6d6f 7469 6f6e 5472 6169 7473 PromotionTraits │ │ │ │ -000151f0: 266c 743b 4b2c 5363 616c 6172 2667 743b <K,Scalar> │ │ │ │ -00015200: 3a3a 5072 6f6d 6f74 6564 5479 7065 2c31 ::PromotedType,1 │ │ │ │ -00015210: 2c31 2667 743b 207b 7363 616c 6172 202a ,1> {scalar * │ │ │ │ -00015220: 206d 6174 7269 785b 305d 5b30 5d7d 3b3c matrix[0][0]};< │ │ │ │ -00015230: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -00015280: 3530 373c 2f73 7061 6e3e 2020 2020 7d3c 507 }< │ │ │ │ -00015290: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -000152e0: 3530 383c 2f73 7061 6e3e 203c 2f64 6976 508
    .
    510< │ │ │ │ -00015340: 2f73 7061 6e3e 2020 2020 3c73 7061 6e20 /span> │ │ │ │ -00015360: 7465 6d70 6c61 7465 3c2f 7370 616e 3e20 template │ │ │ │ -00015370: 266c 743b 3c73 7061 6e20 636c 6173 733d <class │ │ │ │ -00015390: 3c2f 7370 616e 3e3c 6120 636c 6173 733d Scalar,
    .
    511 │ │ │ │ -00015450: 2020 2020 2020 2020 2020 2020 7374 643a std: │ │ │ │ -00015460: 3a65 6e61 626c 655f 6966 5f74 266c 743b :enable_if_t< │ │ │ │ -00015470: 4973 4e75 6d62 6572 266c 743b 5363 616c IsNumber<Scal │ │ │ │ -00015480: 6172 2667 743b 3a3a 7661 6c75 652c 203c ar>::value, < │ │ │ │ -00015490: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -000154a0: 6f72 6474 7970 6522 3e69 6e74 3c2f 7370 ordtype">int> = 0>< │ │ │ │ -000154c0: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -00015510: 3531 323c 2f73 7061 6e3e 2020 2020 3c73 512 friend auto operator/ ( const FieldMatr │ │ │ │ -00015640: 6978 3c2f 613e 2661 6d70 3b20 6d61 7472 ix& matr │ │ │ │ -00015650: 6978 2c20 5363 616c 6172 2073 6361 6c61 ix, Scalar scala │ │ │ │ -00015660: 7229 3c2f 6469 763e 0a3c 6469 7620 636c r)
    .
    513 │ │ │ │ -000156c0: 207b 3c2f 6469 763e 0a3c 6469 7620 636c {
    .
    514 │ │ │ │ -00015720: 2020 203c 7370 616e 2063 6c61 7373 3d22 ret │ │ │ │ -00015740: 7572 6e3c 2f73 7061 6e3e 2046 6965 6c64 urn Field │ │ │ │ -00015750: 4d61 7472 6978 266c 743b 7479 7065 6e61 Matrix<typena │ │ │ │ -00015760: 6d65 2050 726f 6d6f 7469 6f6e 5472 6169 me PromotionTrai │ │ │ │ -00015770: 7473 266c 743b 4b2c 5363 616c 6172 2667 ts<K,Scalar&g │ │ │ │ -00015780: 743b 3a3a 5072 6f6d 6f74 6564 5479 7065 t;::PromotedType │ │ │ │ -00015790: 2c31 2c31 2667 743b 207b 6d61 7472 6978 ,1,1> {matrix │ │ │ │ -000157a0: 5b30 5d5b 305d 202f 2073 6361 6c61 727d [0][0] / scalar} │ │ │ │ -000157b0: 3b3c 2f64 6976 3e0a 3c64 6976 2063 6c61 ;
    .
    │ │ │ │ -00015800: 2020 3531 353c 2f73 7061 6e3e 2020 2020 515 │ │ │ │ -00015810: 7d3c 2f64 6976 3e0a 3c64 6976 2063 6c61 }
    .
    │ │ │ │ -00015860: 2020 3531 363c 2f73 7061 6e3e 203c 2f64 516 .
    51 │ │ │ │ -000158c0: 373c 2f73 7061 6e3e 2020 2020 3c73 7061 7 //===== solve< │ │ │ │ -000158f0: 2f73 7061 6e3e 3c2f 6469 763e 0a3c 6469 /span>
    .< │ │ │ │ -00015910: 6120 6964 3d22 6c30 3035 3138 2220 6e61 a id="l00518" na │ │ │ │ -00015920: 6d65 3d22 6c30 3035 3138 223e 3c2f 613e me="l00518"> │ │ │ │ -00015930: 3c73 7061 6e20 636c 6173 733d 226c 696e 518
    .
    521 │ │ │ │ -000159b0: 203c 7370 616e 2063 6c61 7373 3d22 6b65 template< │ │ │ │ -000159d0: 2f73 7061 6e3e 2026 6c74 3b3c 7370 616e /span> <class Ot │ │ │ │ -00015a00: 6865 7253 6361 6c61 722c 203c 7370 616e herScalar, int │ │ │ │ -00015a30: 6f74 6865 7243 6f6c 7326 6774 3b3c 2f64 otherCols>.
    52 │ │ │ │ -00015a90: 323c 2f73 7061 6e3e 2020 2020 3c73 7061 2 friend │ │ │ │ -00015ac0: 3c73 7061 6e20 636c 6173 733d 226b 6579 auto operator* ( │ │ │ │ -00015b40: 203c 7370 616e 2063 6c61 7373 3d22 6b65 const FieldMatrix │ │ │ │ -00015bc0: 3c2f 613e 2661 6d70 3b20 6d61 7472 6978 & matrix │ │ │ │ -00015bd0: 412c 3c2f 6469 763e 0a3c 6469 7620 636c A,
    .
    523 │ │ │ │ -00015c30: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ │ -00015c40: 2020 2020 2020 2020 203c 7370 616e 2063 c │ │ │ │ -00015c60: 6f6e 7374 3c2f 7370 616e 3e20 4669 656c onst Fiel │ │ │ │ -00015c70: 644d 6174 7269 7826 6c74 3b4f 7468 6572 dMatrix<Other │ │ │ │ -00015c80: 5363 616c 6172 2c20 312c 206f 7468 6572 Scalar, 1, other │ │ │ │ -00015c90: 436f 6c73 2667 743b 2661 6d70 3b20 6d61 Cols>& ma │ │ │ │ -00015ca0: 7472 6978 4229 3c2f 6469 763e 0a3c 6469 trixB)
    .< │ │ │ │ -00015cc0: 6120 6964 3d22 6c30 3035 3234 2220 6e61 a id="l00524" na │ │ │ │ -00015cd0: 6d65 3d22 6c30 3035 3234 223e 3c2f 613e me="l00524"> │ │ │ │ -00015ce0: 3c73 7061 6e20 636c 6173 733d 226c 696e 524 {
    .< │ │ │ │ -00015d20: 6120 6964 3d22 6c30 3035 3235 2220 6e61 a id="l00525" na │ │ │ │ -00015d30: 6d65 3d22 6c30 3035 3235 223e 3c2f 613e me="l00525"> │ │ │ │ -00015d40: 3c73 7061 6e20 636c 6173 733d 226c 696e 525 FieldMatr │ │ │ │ -00015d70: 6978 266c 743b 7479 7065 6e61 6d65 2050 ix<typename P │ │ │ │ -00015d80: 726f 6d6f 7469 6f6e 5472 6169 7473 266c romotionTraits&l │ │ │ │ -00015d90: 743b 4b2c 4f74 6865 7253 6361 6c61 7226 t;K,OtherScalar& │ │ │ │ -00015da0: 6774 3b3a 3a50 726f 6d6f 7465 6454 7970 gt;::PromotedTyp │ │ │ │ -00015db0: 652c 312c 6f74 6865 7243 6f6c 7326 6774 e,1,otherCols> │ │ │ │ -00015dc0: 3b20 7265 7375 6c74 3b3c 2f64 6976 3e0a ; result;
    . │ │ │ │ -00015dd0: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65 .
    < │ │ │ │ -00015e60: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -00015e70: 6e6f 223e 2020 3532 373c 2f73 7061 6e3e no"> 527 │ │ │ │ -00015e80: 2020 2020 2020 3c73 7061 6e20 636c 6173 │ │ │ │ -00015ea0: 666f 723c 2f73 7061 6e3e 2028 3c61 2063 for (size │ │ │ │ -00015f00: 5f74 7970 653c 2f61 3e20 6a20 3d20 303b _type j = 0; │ │ │ │ -00015f10: 206a 2026 6c74 3b20 6d61 7472 6978 422e j < matrixB. │ │ │ │ -00015f20: 6d61 745f 636f 6c73 2829 3b20 2b2b 6a29 mat_cols(); ++j) │ │ │ │ -00015f30: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -00015f80: 2035 3238 3c2f 7370 616e 3e20 2020 2020 528 │ │ │ │ -00015f90: 2020 2072 6573 756c 745b 305d 5b6a 5d20 result[0][j] │ │ │ │ -00015fa0: 3d20 6d61 7472 6978 415b 305d 5b30 5d20 = matrixA[0][0] │ │ │ │ -00015fb0: 2a20 6d61 7472 6978 425b 305d 5b6a 5d3b * matrixB[0][j]; │ │ │ │ -00015fc0: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -00016010: 2035 3239 3c2f 7370 616e 3e20 3c2f 6469 529 .
    530 │ │ │ │ -00016070: 3c2f 7370 616e 3e20 2020 2020 203c 7370 return result;.
    531 │ │ │ │ -00016100: 3c2f 7370 616e 3e20 2020 207d 3c2f 6469 }.
    532 │ │ │ │ -00016160: 3c2f 7370 616e 3e20 3c2f 6469 763e 0a3c
    .< │ │ │ │ -00016170: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -00016180: 3e3c 6120 6964 3d22 6c30 3035 3339 2220 > 539 tem │ │ │ │ -000161e0: 706c 6174 653c 2f73 7061 6e3e 2026 6c74 plate < │ │ │ │ -000161f0: 3b3c 7370 616e 2063 6c61 7373 3d22 6b65 ;class
    OtherMatrix, │ │ │ │ -00016220: 2073 7464 3a3a 656e 6162 6c65 5f69 665f std::enable_if_ │ │ │ │ -00016230: 7426 6c74 3b3c 2f64 6976 3e0a 3c64 6976 t<
    .
    < │ │ │ │ -00016270: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -00016280: 6e6f 223e 2020 3534 303c 2f73 7061 6e3e no"> 540 │ │ │ │ -00016290: 2020 2020 2020 496d 706c 3a3a 4973 5374 Impl::IsSt │ │ │ │ -000162a0: 6174 6963 5369 7a65 4d61 7472 6978 5f76 aticSizeMatrix_v │ │ │ │ -000162b0: 266c 743b 4f74 6865 724d 6174 7269 7826 <OtherMatrix& │ │ │ │ -000162c0: 6774 3b3c 2f64 6976 3e0a 3c64 6976 2063 gt;
    .
    541 │ │ │ │ -00016320: 2020 2020 616e 6420 6e6f 7420 496d 706c and not Impl │ │ │ │ -00016330: 3a3a 4973 4669 656c 644d 6174 7269 785f ::IsFieldMatrix_ │ │ │ │ -00016340: 7626 6c74 3b4f 7468 6572 4d61 7472 6978 v<OtherMatrix │ │ │ │ -00016350: 2667 743b 3c2f 6469 763e 0a3c 6469 7620 >
    .
    542 │ │ │ │ -000163b0: 2020 2020 2061 6e64 2028 4f74 6865 724d and (OtherM │ │ │ │ -000163c0: 6174 7269 783a 3a72 6f77 733d 3d31 293c atrix::rows==1)< │ │ │ │ -000163d0: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -00016420: 3534 333c 2f73 7061 6e3e 2020 2020 2020 543 │ │ │ │ -00016430: 2c20 3c73 7061 6e20 636c 6173 733d 226b , int< │ │ │ │ -00016450: 2f73 7061 6e3e 2667 743b 203d 2030 2667 /span>> = 0&g │ │ │ │ -00016460: 743b 3c2f 6469 763e 0a3c 6469 7620 636c t;
    .
    544 │ │ │ │ -000164c0: 203c 7370 616e 2063 6c61 7373 3d22 6b65 friend auto< │ │ │ │ -00016500: 2f73 7061 6e3e 203c 6120 636c 6173 733d /span> operator* │ │ │ │ -00016560: 3c2f 613e 2820 3c73 7061 6e20 636c 6173 ( cons │ │ │ │ -00016580: 743c 2f73 7061 6e3e 203c 6120 636c 6173 t FieldM │ │ │ │ -000165e0: 6174 7269 783c 2f61 3e26 616d 703b 206d atrix& m │ │ │ │ -000165f0: 6174 7269 7841 2c3c 2f64 6976 3e0a 3c64 atrixA,
    . │ │ │ │ -00016610: 3c61 2069 643d 226c 3030 3534 3522 206e 545 │ │ │ │ -00016660: 2020 2020 2020 2020 2020 2020 2020 3c73 const │ │ │ │ -00016690: 204f 7468 6572 4d61 7472 6978 2661 6d70 OtherMatrix& │ │ │ │ -000166a0: 3b20 6d61 7472 6978 4229 3c2f 6469 763e ; matrixB)
    │ │ │ │ -000166b0: 0a3c 6469 7620 636c 6173 733d 226c 696e . │ │ │ │ -00016710: 0a3c 6469 7620 636c 6173 733d 226c 696e .. │ │ │ │ -00016860: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65 . │ │ │ │ -00016930: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65 .
    < │ │ │ │ -00016a60: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -00016a70: 6e6f 223e 2020 3535 303c 2f73 7061 6e3e no"> 550 │ │ │ │ -00016a80: 2020 2020 2020 2020 6d61 7472 6978 422e matrixB. │ │ │ │ -00016a90: 6d74 7628 6d61 7472 6978 415b 6a5d 2c20 mtv(matrixA[j], │ │ │ │ -00016aa0: 7265 7375 6c74 5b6a 5d29 3b3c 2f64 6976 result[j]);
    .
    551< │ │ │ │ -00016b00: 2f73 7061 6e3e 2020 2020 2020 3c73 7061 /span> return result;
    .
    552< │ │ │ │ -00016b90: 2f73 7061 6e3e 2020 2020 7d3c 2f64 6976 /span> }
    .
    553< │ │ │ │ -00016bf0: 2f73 7061 6e3e 203c 2f64 6976 3e0a 3c64 /span>
    . │ │ │ │ -00016c10: 3c61 2069 643d 226c 3030 3536 3022 206e 560 temp │ │ │ │ -00016c70: 6c61 7465 3c2f 7370 616e 3e20 266c 743b late < │ │ │ │ -00016c80: 3c73 7061 6e20 636c 6173 733d 226b 6579 class OtherMatrix, │ │ │ │ -00016cb0: 7374 643a 3a65 6e61 626c 655f 6966 5f74 std::enable_if_t │ │ │ │ -00016cc0: 266c 743b 3c2f 6469 763e 0a3c 6469 7620 <
    .
    561 │ │ │ │ -00016d20: 2020 2020 2049 6d70 6c3a 3a49 7353 7461 Impl::IsSta │ │ │ │ -00016d30: 7469 6353 697a 654d 6174 7269 785f 7626 ticSizeMatrix_v& │ │ │ │ -00016d40: 6c74 3b4f 7468 6572 4d61 7472 6978 2667 lt;OtherMatrix&g │ │ │ │ -00016d50: 743b 3c2f 6469 763e 0a3c 6469 7620 636c t;
    .
    562 │ │ │ │ -00016db0: 2020 2061 6e64 206e 6f74 2049 6d70 6c3a and not Impl: │ │ │ │ -00016dc0: 3a49 7346 6965 6c64 4d61 7472 6978 5f76 :IsFieldMatrix_v │ │ │ │ -00016dd0: 266c 743b 4f74 6865 724d 6174 7269 7826 <OtherMatrix& │ │ │ │ -00016de0: 6774 3b3c 2f64 6976 3e0a 3c64 6976 2063 gt;
    .
    563 │ │ │ │ -00016e40: 2020 2020 616e 6420 284f 7468 6572 4d61 and (OtherMa │ │ │ │ -00016e50: 7472 6978 3a3a 636f 6c73 3d3d 3129 3c2f trix::cols==1).
    5 │ │ │ │ -00016eb0: 3634 3c2f 7370 616e 3e20 2020 2020 202c 64 , │ │ │ │ -00016ec0: 203c 7370 616e 2063 6c61 7373 3d22 6b65 int> = 0> │ │ │ │ -00016ef0: 3b3c 2f64 6976 3e0a 3c64 6976 2063 6c61 ;
    ..
    │ │ │ │ -00017080: 2020 3536 363c 2f73 7061 6e3e 2020 2020 566 │ │ │ │ -00017090: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ │ -000170a0: 2020 2020 2020 2020 3c73 7061 6e20 636c co │ │ │ │ -000170c0: 6e73 743c 2f73 7061 6e3e 203c 6120 636c nst Fiel │ │ │ │ -00017120: 644d 6174 7269 783c 2f61 3e26 616d 703b dMatrix& │ │ │ │ -00017130: 206d 6174 7269 7842 293c 2f64 6976 3e0a matrixB)
    . │ │ │ │ -00017140: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    . │ │ │ │ -000171a0: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    .< │ │ │ │ -000172f0: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -00017300: 3e3c 6120 6964 3d22 6c30 3035 3639 2220 > 569 Dune::Field │ │ │ │ -00017380: 4d61 7472 6978 266c 743b 4669 656c 642c Matrix<Field, │ │ │ │ -00017390: 204f 7468 6572 4d61 7472 6978 3a3a 726f OtherMatrix::ro │ │ │ │ -000173a0: 7773 2c20 636f 6c73 2667 743b 3c2f 613e ws, cols> │ │ │ │ -000173b0: 2072 6573 756c 743b 3c2f 6469 763e 0a3c result;
    .< │ │ │ │ -000173c0: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -000173d0: 3e3c 6120 6964 3d22 6c30 3035 3730 2220 > 570 for (s │ │ │ │ -00017440: 7464 3a3a 7369 7a65 5f74 206a 3d30 3b20 td::size_t j=0; │ │ │ │ -00017450: 6a26 6c74 3b3c 6120 636c 6173 733d 2263 j<cols; │ │ │ │ -000174b0: 2b2b 6a29 3c2f 6469 763e 0a3c 6469 7620 ++j)
    .
    571 │ │ │ │ -00017510: 2020 2020 207b 3c2f 6469 763e 0a3c 6469 {
    .< │ │ │ │ -00017530: 6120 6964 3d22 6c30 3035 3732 2220 6e61 a id="l00572" na │ │ │ │ -00017540: 6d65 3d22 6c30 3035 3732 223e 3c2f 613e me="l00572"> │ │ │ │ -00017550: 3c73 7061 6e20 636c 6173 733d 226c 696e 572 a │ │ │ │ -00017590: 7574 6f3c 2f73 7061 6e3e 2042 5f6a 203d uto B_j = │ │ │ │ -000175a0: 2049 6d70 6c3a 3a43 6f6c 756d 6e56 6563 Impl::ColumnVec │ │ │ │ -000175b0: 746f 7256 6965 7728 6d61 7472 6978 422c torView(matrixB, │ │ │ │ -000175c0: 206a 293b 3c2f 6469 763e 0a3c 6469 7620 j);
    .
    573 │ │ │ │ -00017620: 2020 2020 2020 203c 7370 616e 2063 6c61 aut │ │ │ │ -00017640: 6f3c 2f73 7061 6e3e 2072 6573 756c 745f o result_ │ │ │ │ -00017650: 6a20 3d20 496d 706c 3a3a 436f 6c75 6d6e j = Impl::Column │ │ │ │ -00017660: 5665 6374 6f72 5669 6577 2872 6573 756c VectorView(resul │ │ │ │ -00017670: 742c 206a 293b 3c2f 6469 763e 0a3c 6469 t, j);
    .< │ │ │ │ -00017690: 6120 6964 3d22 6c30 3035 3734 2220 6e61 a id="l00574" na │ │ │ │ -000176a0: 6d65 3d22 6c30 3035 3734 223e 3c2f 613e me="l00574"> │ │ │ │ -000176b0: 3c73 7061 6e20 636c 6173 733d 226c 696e 574 matrixA │ │ │ │ -000176e0: 2e6d 7628 425f 6a2c 2072 6573 756c 745f .mv(B_j, result_ │ │ │ │ -000176f0: 6a29 3b3c 2f64 6976 3e0a 3c64 6976 2063 j);
    .
    575 │ │ │ │ -00017750: 2020 2020 7d3c 2f64 6976 3e0a 3c64 6976 }
    .
    < │ │ │ │ -00017790: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -000177a0: 6e6f 223e 2020 3537 363c 2f73 7061 6e3e no"> 576 │ │ │ │ -000177b0: 2020 2020 2020 3c73 7061 6e20 636c 6173 │ │ │ │ -000177d0: 7265 7475 726e 3c2f 7370 616e 3e20 7265 return re │ │ │ │ -000177e0: 7375 6c74 3b3c 2f64 6976 3e0a 3c64 6976 sult;
    .
    < │ │ │ │ -00017820: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -00017830: 6e6f 223e 2020 3537 373c 2f73 7061 6e3e no"> 577 │ │ │ │ -00017840: 2020 2020 7d3c 2f64 6976 3e0a 3c64 6976 }
    .
    < │ │ │ │ -00017880: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -00017890: 6e6f 223e 2020 3537 383c 2f73 7061 6e3e no"> 578 │ │ │ │ -000178a0: 203c 2f64 6976 3e0a 3c64 6976 2063 6c61
    .
    │ │ │ │ -000178f0: 2020 3538 303c 2f73 7061 6e3e 2020 2020 580 │ │ │ │ -00017900: 3c73 7061 6e20 636c 6173 733d 226b 6579 template<int l& │ │ │ │ -00017950: 6774 3b3c 2f64 6976 3e0a 3c64 6976 2063 gt;
    .
    581 │ │ │ │ -000179b0: 2020 4669 656c 644d 6174 7269 7826 6c74 FieldMatrix< │ │ │ │ -000179c0: 3b4b 2c6c 2c31 2667 743b 203c 6120 636c ;K,l,1> left │ │ │ │ -00017a20: 6d75 6c74 6970 6c79 616e 793c 2f61 3e20 multiplyany │ │ │ │ -00017a30: 283c 7370 616e 2063 6c61 7373 3d22 6b65 (const FieldMatrix& │ │ │ │ -00017a60: 6c74 3b4b 2c6c 2c31 2667 743b 2661 6d70 lt;K,l,1>& │ │ │ │ -00017a70: 3b20 3c61 2063 6c61 7373 3d22 636f 6465 ; M) │ │ │ │ -00017ae0: 636f 6e73 743c 2f73 7061 6e3e 3c2f 6469 const.
    582 │ │ │ │ -00017b40: 3c2f 7370 616e 3e3c 7370 616e 2063 6c61 │ │ │ │ -00017b60: 203c 2f73 7061 6e3e 7b3c 2f64 6976 3e0a {
    . │ │ │ │ -00017b70: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    .
    < │ │ │ │ -00017c20: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -00017c30: 6e6f 223e 2020 3538 343c 2f73 7061 6e3e no"> 584 │ │ │ │ -00017c40: 2020 2020 2020 3c73 7061 6e20 636c 6173 │ │ │ │ -00017c60: 666f 723c 2f73 7061 6e3e 2028 3c61 2063 for (size │ │ │ │ -00017cc0: 5f74 7970 653c 2f61 3e20 6a3d 303b 206a _type j=0; j │ │ │ │ -00017cd0: 266c 743b 6c3b 206a 2b2b 293c 2f64 6976 <l; j++)
    .
    585< │ │ │ │ -00017d30: 2f73 7061 6e3e 2020 2020 2020 2020 435b /span> C[ │ │ │ │ -00017d40: 6a5d 5b30 5d20 3d20 3c61 2063 6c61 7373 j][0] = M[j │ │ │ │ -00017da0: 5d5b 305d 2a28 2a3c 7370 616e 2063 6c61 ][0]*(*thi │ │ │ │ -00017dc0: 733c 2f73 7061 6e3e 295b 305d 5b30 5d3b s)[0][0]; │ │ │ │ -00017dd0: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -00017e20: 2035 3836 3c2f 7370 616e 3e20 2020 2020 586 │ │ │ │ -00017e30: 203c 7370 616e 2063 6c61 7373 3d22 6b65 retur │ │ │ │ -00017e50: 6e3c 2f73 7061 6e3e 2043 3b3c 2f64 6976 n C;
    .
    587< │ │ │ │ -00017eb0: 2f73 7061 6e3e 2020 2020 7d3c 2f64 6976 /span> }
    .
    588< │ │ │ │ -00017f10: 2f73 7061 6e3e 203c 2f64 6976 3e0a 3c64 /span>
    . │ │ │ │ -00017f30: 3c61 2069 643d 226c 3030 3539 3022 206e 590 FieldMatr │ │ │ │ -00017fd0: 6978 3c2f 613e 2661 6d70 3b20 3c61 2063 ix& rig │ │ │ │ -00018030: 6874 6d75 6c74 6970 6c79 3c2f 613e 2028 htmultiply ( │ │ │ │ -00018040: 3c73 7061 6e20 636c 6173 733d 226b 6579 const FieldMatrix< │ │ │ │ -000180c0: 2f61 3e26 616d 703b 203c 6120 636c 6173 /a>& M) │ │ │ │ -00018120: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -00018170: 2035 3931 3c2f 7370 616e 3e20 2020 207b 591 { │ │ │ │ -00018180: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -000181d0: 2035 3932 3c2f 7370 616e 3e20 2020 2020 592 │ │ │ │ -000181e0: 205f 6461 7461 5b30 5d20 2a3d 203c 6120 _data[0] *= M< │ │ │ │ -00018240: 2f61 3e5b 305d 5b30 5d3b 3c2f 6469 763e /a>[0][0];
    │ │ │ │ -00018250: 0a3c 6469 7620 636c 6173 733d 226c 696e ..< │ │ │ │ -00018310: 6120 6964 3d22 6c30 3035 3934 2220 6e61 a id="l00594" na │ │ │ │ -00018320: 6d65 3d22 6c30 3035 3934 223e 3c2f 613e me="l00594"> │ │ │ │ -00018330: 3c73 7061 6e20 636c 6173 733d 226c 696e 594 }
    .< │ │ │ │ -00018370: 6120 6964 3d22 6c30 3035 3935 2220 6e61 a id="l00595" na │ │ │ │ -00018380: 6d65 3d22 6c30 3035 3935 223e 3c2f 613e me="l00595"> │ │ │ │ -00018390: 3c73 7061 6e20 636c 6173 733d 226c 696e 595
    .
    597 │ │ │ │ -00018410: 203c 7370 616e 2063 6c61 7373 3d22 6b65 template< │ │ │ │ -00018430: 2f73 7061 6e3e 266c 743b 3c73 7061 6e20 /span><int l │ │ │ │ -00018460: 2667 743b 3c2f 6469 763e 0a3c 6469 7620 >
    .
    598 │ │ │ │ -000184c0: 2020 2046 6965 6c64 4d61 7472 6978 266c FieldMatrix&l │ │ │ │ -000184d0: 743b 4b2c 312c 6c26 6774 3b20 3c61 2063 t;K,1,l> rig │ │ │ │ -00018530: 6874 6d75 6c74 6970 6c79 616e 793c 2f61 htmultiplyany (const FieldMatri │ │ │ │ -00018570: 7826 6c74 3b4b 2c31 2c6c 2667 743b 2661 x<K,1,l>&a │ │ │ │ -00018580: 6d70 3b20 3c61 2063 6c61 7373 3d22 636f mp; M) const.
    5 │ │ │ │ -00018650: 3939 3c2f 7370 616e 3e3c 7370 616e 2063 99 │ │ │ │ -00018670: 2020 203c 2f73 7061 6e3e 7b3c 2f64 6976 {
    .
    600< │ │ │ │ -000186d0: 2f73 7061 6e3e 2020 2020 2020 4669 656c /span> Fiel │ │ │ │ -000186e0: 644d 6174 7269 7826 6c74 3b4b 2c31 2c6c dMatrix<K,1,l │ │ │ │ -000186f0: 2667 743b 2043 3b3c 2f64 6976 3e0a 3c64 > C;
    . │ │ │ │ -00018710: 3c61 2069 643d 226c 3030 3630 3122 206e 601
    .
    602 │ │ │ │ -000187b0: 2020 2020 3c73 7061 6e20 636c 6173 733d fo │ │ │ │ -000187d0: 723c 2f73 7061 6e3e 2028 3c61 2063 6c61 r (size_t │ │ │ │ -00018830: 7970 653c 2f61 3e20 6a3d 303b 206a 266c ype j=0; j&l │ │ │ │ -00018840: 743b 6c3b 206a 2b2b 293c 2f64 6976 3e0a t;l; j++)
    . │ │ │ │ -00018850: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    < │ │ │ │ -00018880: 2f61 3e3c 7370 616e 2063 6c61 7373 3d22 /a> 603 C[0] │ │ │ │ -000188b0: 5b6a 5d20 3d20 3c61 2063 6c61 7373 3d22 [j] = M[0][ │ │ │ │ -00018910: 6a5d 2a5f 6461 7461 5b30 5d3b 3c2f 6469 j]*_data[0];.
    604 │ │ │ │ -00018970: 3c2f 7370 616e 3e20 2020 2020 203c 7370 return C;
    . │ │ │ │ -000189c0: 3c61 2069 643d 226c 3030 3630 3522 206e 605 }
    . │ │ │ │ -00018a20: 3c61 2069 643d 226c 3030 3630 3622 206e 606
    .
    607 │ │ │ │ -00018ac0: 2020 3c73 7061 6e20 636c 6173 733d 2263 // make │ │ │ │ -00018ae0: 7468 6973 2074 6869 6e67 2061 206d 6174 this thing a mat │ │ │ │ -00018af0: 7269 783c 2f73 7061 6e3e 3c2f 6469 763e rix
    │ │ │ │ -00018b00: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -00018b30: 3c2f 613e 3c73 7061 6e20 636c 6173 733d 608 s │ │ │ │ -00018b70: 7461 7469 633c 2f73 7061 6e3e 203c 7370 tatic constexpr size_type mat_rows( │ │ │ │ -00018c60: 2920 7b20 3c73 7061 6e20 636c 6173 733d ) { re │ │ │ │ -00018c80: 7475 726e 3c2f 7370 616e 3e20 313b 207d turn 1; } │ │ │ │ -00018c90: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -00018ce0: 2036 3039 3c2f 7370 616e 3e20 2020 203c 609 < │ │ │ │ -00018cf0: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -00018d00: 6f72 6422 3e73 7461 7469 633c 2f73 7061 ord">static constex │ │ │ │ -00018d30: 7072 3c2f 7370 616e 3e20 3c61 2063 6c61 pr size_t │ │ │ │ -00018d90: 7970 653c 2f61 3e20 3c61 2063 6c61 7373 ype mat_col │ │ │ │ -00018df0: 733c 2f61 3e28 2920 7b20 3c73 7061 6e20 s() { return 1; }
    .< │ │ │ │ -00018e40: 6120 6964 3d22 6c30 3036 3130 2220 6e61 a id="l00610" na │ │ │ │ -00018e50: 6d65 3d22 6c30 3036 3130 223e 3c2f 613e me="l00610"> │ │ │ │ -00018e60: 3c73 7061 6e20 636c 6173 733d 226c 696e 610
    ..
    < │ │ │ │ -00019050: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -00019060: 6e6f 223e 2020 3631 323c 2f73 7061 6e3e no"> 612 │ │ │ │ -00019070: 2020 2020 7b3c 2f64 6976 3e0a 3c64 6976 {
    .
    < │ │ │ │ -000190b0: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -000190c0: 6e6f 223e 2020 3631 333c 2f73 7061 6e3e no"> 613 │ │ │ │ -000190d0: 2020 2020 2020 3c61 2063 6c61 7373 3d22 DUNE_ASSER │ │ │ │ -00019130: 545f 424f 554e 4453 3c2f 613e 2869 203d T_BOUNDS(i = │ │ │ │ -00019140: 3d20 3029 3b3c 2f64 6976 3e0a 3c64 6976 = 0);
    .
    < │ │ │ │ -00019180: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -00019190: 6e6f 223e 2020 3631 343c 2f73 7061 6e3e no"> 614 │ │ │ │ -000191a0: 2020 2020 2020 3c73 7061 6e20 636c 6173 │ │ │ │ -000191c0: 7265 7475 726e 3c2f 7370 616e 3e20 5f64 return _d │ │ │ │ -000191d0: 6174 613b 3c2f 6469 763e 0a3c 6469 7620 ata;
    .
    615 │ │ │ │ -00019230: 2020 207d 3c2f 6469 763e 0a3c 6469 7620 }
    .
    616 │ │ │ │ -00019290: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -000192e0: 2036 3137 3c2f 7370 616e 3e20 2020 203c 617 < │ │ │ │ -000192f0: 6120 636c 6173 733d 2263 6f64 6520 686c a class="code hl │ │ │ │ -00019300: 5f74 7970 6564 6566 2220 6872 6566 3d22 _typedef" href=" │ │ │ │ -00019310: 6130 3134 3038 2e68 746d 6c23 6132 3930 a01408.html#a290 │ │ │ │ -00019320: 6430 6236 3937 3131 6439 6538 6166 3137 d0b69711d9e8af17 │ │ │ │ -00019330: 3833 6263 3533 3232 6664 6334 6522 3e63 83bc5322fdc4e">c │ │ │ │ -00019340: 6f6e 7374 5f72 6f77 5f72 6566 6572 656e onst_row_referen │ │ │ │ -00019350: 6365 3c2f 613e 203c 6120 636c 6173 733d ce mat_acce │ │ │ │ -000193b0: 7373 3c2f 613e 2028 5b5b 6d61 7962 655f ss ([[maybe_ │ │ │ │ -000193c0: 756e 7573 6564 5d5d 203c 6120 636c 6173 unused]] size_ty │ │ │ │ -00019420: 7065 3c2f 613e 2069 293c 7370 616e 2063 pe i) │ │ │ │ -00019440: 636f 6e73 743c 2f73 7061 6e3e 3c2f 6469 const.
    618 │ │ │ │ -000194a0: 3c2f 7370 616e 3e3c 7370 616e 2063 6c61 │ │ │ │ -000194c0: 203c 2f73 7061 6e3e 7b3c 2f64 6976 3e0a {
    . │ │ │ │ -000194d0: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    . │ │ │ │ -000195a0: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    .< │ │ │ │ -00019630: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -00019640: 3e3c 6120 6964 3d22 6c30 3036 3231 2220 > 621 }
    .< │ │ │ │ -00019690: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -000196a0: 3e3c 6120 6964 3d22 6c30 3036 3232 2220 > 622
    .
    624 │ │ │ │ -00019740: 2020 203c 6120 636c 6173 733d 2263 6f64 FieldMatrix< │ │ │ │ -000197a0: 2f61 3e26 616d 703b 203c 6120 636c 6173 /a>& operat │ │ │ │ -00019800: 6f72 2b3d 203c 2f61 3e28 3c73 7061 6e20 or+= ( │ │ │ │ -00019820: 636f 6e73 743c 2f73 7061 6e3e 204b 2661 const K&a │ │ │ │ -00019830: 6d70 3b20 6b29 3c2f 6469 763e 0a3c 6469 mp; k)
    .< │ │ │ │ -00019850: 6120 6964 3d22 6c30 3036 3235 2220 6e61 a id="l00625" na │ │ │ │ -00019860: 6d65 3d22 6c30 3036 3235 223e 3c2f 613e me="l00625"> │ │ │ │ -00019870: 3c73 7061 6e20 636c 6173 733d 226c 696e 625 {
    .< │ │ │ │ -000198b0: 6120 6964 3d22 6c30 3036 3236 2220 6e61 a id="l00626" na │ │ │ │ -000198c0: 6d65 3d22 6c30 3036 3236 223e 3c2f 613e me="l00626"> │ │ │ │ -000198d0: 3c73 7061 6e20 636c 6173 733d 226c 696e 626 _data[0] │ │ │ │ -00019900: 2b3d 206b 3b3c 2f64 6976 3e0a 3c64 6976 += k;
    .
    < │ │ │ │ -00019940: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -00019950: 6e6f 223e 2020 3632 373c 2f73 7061 6e3e no"> 627 │ │ │ │ -00019960: 2020 2020 2020 3c73 7061 6e20 636c 6173 │ │ │ │ -00019980: 7265 7475 726e 3c2f 7370 616e 3e20 282a return (* │ │ │ │ -00019990: 3c73 7061 6e20 636c 6173 733d 226b 6579 this);
    .
    628 │ │ │ │ -00019a10: 2020 7d3c 2f64 6976 3e0a 3c64 6976 2063 }
    .
    629 < │ │ │ │ -00019a70: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -00019ac0: 3633 313c 2f73 7061 6e3e 2020 2020 3c61 631 F │ │ │ │ -00019b20: 6965 6c64 4d61 7472 6978 3c2f 613e 2661 ieldMatrix&a │ │ │ │ -00019b30: 6d70 3b20 3c61 2063 6c61 7373 3d22 636f mp; operator-= │ │ │ │ -00019b90: 3c2f 613e 283c 7370 616e 2063 6c61 7373 (const │ │ │ │ -00019bb0: 3c2f 7370 616e 3e20 4b26 616d 703b 206b K& k │ │ │ │ -00019bc0: 293c 2f64 6976 3e0a 3c64 6976 2063 6c61 )
    .
    │ │ │ │ -00019c10: 2020 3633 323c 2f73 7061 6e3e 2020 2020 632 │ │ │ │ -00019c20: 7b3c 2f64 6976 3e0a 3c64 6976 2063 6c61 {
    .
    │ │ │ │ -00019c70: 2020 3633 333c 2f73 7061 6e3e 2020 2020 633 │ │ │ │ -00019c80: 2020 5f64 6174 615b 305d 202d 3d20 6b3b _data[0] -= k; │ │ │ │ -00019c90: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -00019ce0: 2036 3334 3c2f 7370 616e 3e20 2020 2020 634 │ │ │ │ -00019cf0: 203c 7370 616e 2063 6c61 7373 3d22 6b65 retur │ │ │ │ -00019d10: 6e3c 2f73 7061 6e3e 2028 2a3c 7370 616e n (*this);.
    6 │ │ │ │ -00019d90: 3335 3c2f 7370 616e 3e20 2020 207d 3c2f 35 }.
    6 │ │ │ │ -00019df0: 3336 3c2f 7370 616e 3e20 3c2f 6469 763e 36
    │ │ │ │ -00019e00: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -00019e30: 3c2f 613e 3c73 7061 6e20 636c 6173 733d 638 FieldM │ │ │ │ -00019eb0: 6174 7269 783c 2f61 3e26 616d 703b 203c atrix& < │ │ │ │ -00019ec0: 6120 636c 6173 733d 2263 6f64 6520 686c a class="code hl │ │ │ │ -00019ed0: 5f66 756e 6374 696f 6e22 2068 7265 663d _function" href= │ │ │ │ -00019ee0: 2261 3031 3430 302e 6874 6d6c 2361 3732 "a01400.html#a72 │ │ │ │ -00019ef0: 3162 3262 6334 6432 3239 3538 6561 3562 1b2bc4d22958ea5b │ │ │ │ -00019f00: 3037 6165 3535 3935 6636 3239 3537 223e 07ae5595f62957"> │ │ │ │ -00019f10: 6f70 6572 6174 6f72 2a3d 203c 2f61 3e28 operator*= ( │ │ │ │ -00019f20: 3c73 7061 6e20 636c 6173 733d 226b 6579 const K& k).
    639 │ │ │ │ -00019fa0: 3c2f 7370 616e 3e20 2020 207b 3c2f 6469 {.
    640 │ │ │ │ -0001a000: 3c2f 7370 616e 3e20 2020 2020 205f 6461 _da │ │ │ │ -0001a010: 7461 5b30 5d20 2a3d 206b 3b3c 2f64 6976 ta[0] *= k;
    .
    641< │ │ │ │ -0001a070: 2f73 7061 6e3e 2020 2020 2020 3c73 7061 /span> return (*this │ │ │ │ -0001a0c0: 3c2f 7370 616e 3e29 3b3c 2f64 6976 3e0a );
    . │ │ │ │ -0001a0d0: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    . │ │ │ │ -0001a130: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65 .
    < │ │ │ │ -0001a1c0: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -0001a1d0: 6e6f 223e 2020 3634 353c 2f73 7061 6e3e no"> 645 │ │ │ │ -0001a1e0: 2020 2020 3c61 2063 6c61 7373 3d22 636f FieldMatrix │ │ │ │ -0001a240: 3c2f 613e 2661 6d70 3b20 3c61 2063 6c61 & opera │ │ │ │ -0001a2a0: 746f 722f 3d20 3c2f 613e 283c 7370 616e tor/= (const K& │ │ │ │ -0001a2d0: 616d 703b 206b 293c 2f64 6976 3e0a 3c64 amp; k)
    . │ │ │ │ -0001a2f0: 3c61 2069 643d 226c 3030 3634 3622 206e 646 {
    . │ │ │ │ -0001a350: 3c61 2069 643d 226c 3030 3634 3722 206e 647 _data[0] │ │ │ │ -0001a3a0: 202f 3d20 6b3b 3c2f 6469 763e 0a3c 6469 /= k;
    .< │ │ │ │ -0001a3c0: 6120 6964 3d22 6c30 3036 3438 2220 6e61 a id="l00648" na │ │ │ │ -0001a3d0: 6d65 3d22 6c30 3036 3438 223e 3c2f 613e me="l00648"> │ │ │ │ -0001a3e0: 3c73 7061 6e20 636c 6173 733d 226c 696e 648 return ( │ │ │ │ -0001a430: 2a3c 7370 616e 2063 6c61 7373 3d22 6b65 *this);
    .
    649 │ │ │ │ -0001a4b0: 2020 207d 3c2f 6469 763e 0a3c 6469 7620 }
    .
    650 │ │ │ │ -0001a510: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -0001a560: 2036 3531 3c2f 7370 616e 3e20 2020 203c 651 < │ │ │ │ -0001a570: 7370 616e 2063 6c61 7373 3d22 636f 6d6d span class="comm │ │ │ │ -0001a580: 656e 7422 3e2f 2f3d 3d3d 3d3d 2063 6f6e ent">//===== con │ │ │ │ -0001a590: 7665 7273 696f 6e20 6f70 6572 6174 6f72 version operator │ │ │ │ -0001a5a0: 3c2f 7370 616e 3e3c 2f64 6976 3e0a 3c64
    . │ │ │ │ -0001a5c0: 3c61 2069 643d 226c 3030 3635 3222 206e 652
    .
    653 │ │ │ │ -0001a660: 2020 3c73 7061 6e20 636c 6173 733d 226b operator │ │ │ │ -0001a680: 3c2f 7370 616e 3e20 3c73 7061 6e20 636c co │ │ │ │ -0001a6a0: 6e73 743c 2f73 7061 6e3e 204b 2661 6d70 nst K& │ │ │ │ -0001a6b0: 3b20 2829 203c 7370 616e 2063 6c61 7373 ; () const │ │ │ │ -0001a6d0: 3c2f 7370 616e 3e20 7b20 3c73 7061 6e20 { return _data[0]; }.
    65 │ │ │ │ -0001a760: 343c 2f73 7061 6e3e 203c 2f64 6976 3e0a 4
    . │ │ │ │ -0001a770: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    .< │ │ │ │ -0001a7d0: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -0001a7e0: 3e3c 6120 6964 3d22 6c30 3036 3536 2220 > 656
    .
    658 │ │ │ │ -0001a880: 203c 7370 616e 2063 6c61 7373 3d22 6b65 template< │ │ │ │ -0001a8a0: 2f73 7061 6e3e 266c 743b 3c73 7061 6e20 /span>< │ │ │ │ -0001a8c0: 7479 7065 6e61 6d65 3c2f 7370 616e 3e20 typename │ │ │ │ -0001a8d0: 4b26 6774 3b3c 2f64 6976 3e0a 3c64 6976 K>
    .
    < │ │ │ │ -0001a910: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -0001a920: 6e6f 223e 2020 3635 393c 2f73 7061 6e3e no"> 659 │ │ │ │ -0001a930: 2020 7374 643a 3a6f 7374 7265 616d 2661 std::ostream&a │ │ │ │ -0001a940: 6d70 3b20 3c61 2063 6c61 7373 3d22 636f mp; operator&l │ │ │ │ -0001a9a0: 743b 266c 743b 203c 2f61 3e28 7374 643a t;< (std: │ │ │ │ -0001a9b0: 3a6f 7374 7265 616d 2661 6d70 3b20 732c :ostream& s, │ │ │ │ -0001a9c0: 203c 7370 616e 2063 6c61 7373 3d22 6b65 const FieldMatrix& │ │ │ │ -0001a9f0: 6c74 3b4b 2c31 2c31 2667 743b 2661 6d70 lt;K,1,1>& │ │ │ │ -0001aa00: 3b20 6129 3c2f 6469 763e 0a3c 6469 7620 ; a)
    .
    660 │ │ │ │ -0001aa60: 207b 3c2f 6469 763e 0a3c 6469 7620 636c {
    .
    661 │ │ │ │ -0001aac0: 2073 2026 6c74 3b26 6c74 3b20 615b 305d s << a[0] │ │ │ │ -0001aad0: 5b30 5d3b 3c2f 6469 763e 0a3c 6469 7620 [0];
    .
    662 │ │ │ │ -0001ab30: 2020 203c 7370 616e 2063 6c61 7373 3d22 ret │ │ │ │ -0001ab50: 7572 6e3c 2f73 7061 6e3e 2073 3b3c 2f64 urn s;.
    66 │ │ │ │ -0001abb0: 333c 2f73 7061 6e3e 2020 7d3c 2f64 6976 3 }
    .
    664< │ │ │ │ -0001ac10: 2f73 7061 6e3e 203c 2f64 6976 3e0a 3c64 /span>
    . │ │ │ │ -0001ac30: 3c61 2069 643d 226c 3030 3636 3522 206e 665#en │ │ │ │ -0001ac90: 6469 6620 3c2f 7370 616e 3e3c 7370 616e dif // DOXYGEN
    .
    666 .
    .
    667< │ │ │ │ -0001ade0: 2f73 7061 6e3e 2020 3c73 7061 6e20 636c /span> na │ │ │ │ -0001ae00: 6d65 7370 6163 6520 3c2f 7370 616e 3e46 mespace F │ │ │ │ -0001ae10: 4d61 7472 6978 4865 6c70 207b 3c2f 6469 MatrixHelp {.
    668 │ │ │ │ -0001ae70: 3c2f 7370 616e 3e20 3c2f 6469 763e 0a3c
    .< │ │ │ │ -0001ae80: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -0001ae90: 3e3c 6120 6964 3d22 6c30 3036 3730 2220 > 670 tem │ │ │ │ -0001aef0: 706c 6174 653c 2f73 7061 6e3e 2026 6c74 plate < │ │ │ │ -0001af00: 3b3c 7370 616e 2063 6c61 7373 3d22 6b65 ;typename< │ │ │ │ -0001af20: 2f73 7061 6e3e 204b 2667 743b 3c2f 6469 /span> K>.
    .
    671< │ │ │ │ -0001b010: 2f73 7061 6e3e 2020 2020 3c73 7061 6e20 /span> │ │ │ │ -0001b030: 7374 6174 6963 3c2f 7370 616e 3e20 3c73 static inline K invertMatri │ │ │ │ -0001b0c0: 783c 2f61 3e20 283c 7370 616e 2063 6c61 x (con │ │ │ │ -0001b0e0: 7374 3c2f 7370 616e 3e20 3c61 2063 6c61 st FieldMatri │ │ │ │ -0001b120: 7826 6c74 3b4b 2c31 2c31 2667 743b 3c2f x<K,1,1> &matrix, │ │ │ │ -0001b140: 3c61 2063 6c61 7373 3d22 636f 6465 2068 Fiel │ │ │ │ -0001b170: 644d 6174 7269 7826 6c74 3b4b 2c31 2c31 dMatrix<K,1,1 │ │ │ │ -0001b180: 2667 743b 3c2f 613e 2026 616d 703b 696e > &in │ │ │ │ -0001b190: 7665 7273 6529 3c2f 6469 763e 0a3c 6469 verse)
    .< │ │ │ │ -0001b1b0: 6120 6964 3d22 6c30 3036 3732 2220 6e61 a id="l00672" na │ │ │ │ -0001b1c0: 6d65 3d22 6c30 3036 3732 223e 3c2f 613e me="l00672"> │ │ │ │ -0001b1d0: 3c73 7061 6e20 636c 6173 733d 226c 696e 672 {
    .< │ │ │ │ -0001b210: 6120 6964 3d22 6c30 3036 3733 2220 6e61 a id="l00673" na │ │ │ │ -0001b220: 6d65 3d22 6c30 3036 3733 223e 3c2f 613e me="l00673"> │ │ │ │ -0001b230: 3c73 7061 6e20 636c 6173 733d 226c 696e 673 usi │ │ │ │ -0001b270: 6e67 203c 2f73 7061 6e3e 7265 616c 5f74 ng real_t │ │ │ │ -0001b280: 7970 6520 3d20 3c73 7061 6e20 636c 6173 ype = type │ │ │ │ -0001b2a0: 6e61 6d65 3c2f 7370 616e 3e20 3c61 2063 name Fiel │ │ │ │ -0001b300: 6454 7261 6974 7326 6c74 3b4b 2667 743b dTraits<K> │ │ │ │ -0001b310: 3a3a 7265 616c 5f74 7970 653c 2f61 3e3b ::real_type; │ │ │ │ -0001b320: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -0001b370: 2036 3734 3c2f 7370 616e 3e20 2020 2020 674 │ │ │ │ -0001b380: 2069 6e76 6572 7365 5b30 5d5b 305d 203d inverse[0][0] = │ │ │ │ -0001b390: 2072 6561 6c5f 7479 7065 2831 2e30 292f real_type(1.0)/ │ │ │ │ -0001b3a0: 6d61 7472 6978 5b30 5d5b 305d 3b3c 2f64 matrix[0][0];.
    67 │ │ │ │ -0001b400: 353c 2f73 7061 6e3e 2020 2020 2020 3c73 5 return matrix[0][ │ │ │ │ -0001b440: 305d 3b3c 2f64 6976 3e0a 3c64 6976 2063 0];
    .
    676 │ │ │ │ -0001b4a0: 2020 7d3c 2f64 6976 3e0a 3c2f 6469 763e }
    .
    │ │ │ │ -0001b4b0: 0a3c 6469 7620 636c 6173 733d 226c 696e ..< │ │ │ │ -0001b520: 6120 6964 3d22 6c30 3036 3739 2220 6e61 a id="l00679" na │ │ │ │ -0001b530: 6d65 3d22 6c30 3036 3739 223e 3c2f 613e me="l00679"> │ │ │ │ -0001b540: 3c73 7061 6e20 636c 6173 733d 226c 696e 679 templ │ │ │ │ -0001b580: 6174 653c 2f73 7061 6e3e 2026 6c74 3b3c ate << │ │ │ │ -0001b590: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -0001b5a0: 6f72 6422 3e74 7970 656e 616d 653c 2f73 ord">typename K>
    │ │ │ │ -0001b5c0: 0a3c 6469 7620 636c 6173 733d 2266 6f6c .
    .
    < │ │ │ │ -0001b650: 6120 636c 6173 733d 226c 696e 6522 2068 a class="line" h │ │ │ │ -0001b660: 7265 663d 2261 3030 3433 362e 6874 6d6c ref="a00436.html │ │ │ │ -0001b670: 2361 3637 3135 3538 3135 6230 3334 3737 #a67155815b03477 │ │ │ │ -0001b680: 3331 3239 6432 3162 6665 3339 3932 6630 3129d21bfe3992f0 │ │ │ │ -0001b690: 6236 223e 2020 3638 303c 2f61 3e3c 2f73 b6"> 680 st │ │ │ │ -0001b6c0: 6174 6963 3c2f 7370 616e 3e20 3c73 7061 atic inline │ │ │ │ -0001b6f0: 4b20 3c61 2063 6c61 7373 3d22 636f 6465 K invertMatrix_ │ │ │ │ -0001b750: 7265 7454 7261 6e73 706f 7365 643c 2f61 retTransposed (const FieldMatrix< │ │ │ │ -0001b7c0: 3b4b 2c31 2c31 2667 743b 3c2f 613e 2026 ;K,1,1> & │ │ │ │ -0001b7d0: 616d 703b 6d61 7472 6978 2c20 3c61 2063 amp;matrix, FieldMat │ │ │ │ -0001b810: 7269 7826 6c74 3b4b 2c31 2c31 2667 743b rix<K,1,1> │ │ │ │ -0001b820: 3c2f 613e 2026 616d 703b 696e 7665 7273 &invers │ │ │ │ -0001b830: 6529 3c2f 6469 763e 0a3c 6469 7620 636c e)
    .
    681 │ │ │ │ -0001b890: 207b 3c2f 6469 763e 0a3c 6469 7620 636c {
    .
    682 │ │ │ │ -0001b8f0: 2020 203c 7370 616e 2063 6c61 7373 3d22 ret │ │ │ │ -0001b910: 7572 6e3c 2f73 7061 6e3e 203c 6120 636c urn inve │ │ │ │ -0001b970: 7274 4d61 7472 6978 3c2f 613e 286d 6174 rtMatrix(mat │ │ │ │ -0001b980: 7269 782c 696e 7665 7273 6529 3b3c 2f64 rix,inverse);.
    68 │ │ │ │ -0001b9e0: 333c 2f73 7061 6e3e 2020 2020 7d3c 2f64 3 }.
    .
    684 │ │ │ │ -0001ba50: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -0001baa0: 2036 3835 3c2f 7370 616e 3e20 3c2f 6469 685 .
    687 │ │ │ │ -0001bb00: 3c2f 7370 616e 3e20 2020 203c 7370 616e template │ │ │ │ -0001bb30: 2026 6c74 3b3c 7370 616e 2063 6c61 7373 <typen │ │ │ │ -0001bb50: 616d 653c 2f73 7061 6e3e 204b 2667 743b ame K> │ │ │ │ -0001bb60: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    .< │ │ │ │ -0001bbc0: 6120 6964 3d22 6c30 3036 3838 2220 6e61 a id="l00688" na │ │ │ │ -0001bbd0: 6d65 3d22 6c30 3036 3838 223e 3c2f 613e me="l00688"> │ │ │ │ -0001bbe0: 3c73 7061 6e20 636c 6173 733d 226c 696e 688< │ │ │ │ -0001bc40: 2f61 3e3c 2f73 7061 6e3e 2020 2020 3c73 /a> static inline K invertM │ │ │ │ -0001bcf0: 6174 7269 783c 2f61 3e20 283c 7370 616e atrix (const FieldM │ │ │ │ -0001bd50: 6174 7269 7826 6c74 3b4b 2c32 2c32 2667 atrix<K,2,2&g │ │ │ │ -0001bd60: 743b 3c2f 613e 2026 616d 703b 6d61 7472 t; &matr │ │ │ │ -0001bd70: 6978 2c20 3c61 2063 6c61 7373 3d22 636f ix, │ │ │ │ -0001bda0: 4669 656c 644d 6174 7269 7826 6c74 3b4b FieldMatrix<K │ │ │ │ -0001bdb0: 2c32 2c32 2667 743b 3c2f 613e 2026 616d ,2,2> &am │ │ │ │ -0001bdc0: 703b 696e 7665 7273 6529 3c2f 6469 763e p;inverse)
    │ │ │ │ -0001bdd0: 0a3c 6469 7620 636c 6173 733d 226c 696e . │ │ │ │ -0001be30: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -0001be60: 3c2f 613e 3c73 7061 6e20 636c 6173 733d 690 using re │ │ │ │ -0001beb0: 616c 5f74 7970 6520 3d20 3c73 7061 6e20 al_type = │ │ │ │ -0001bed0: 7479 7065 6e61 6d65 3c2f 7370 616e 3e20 typename │ │ │ │ -0001bee0: 3c61 2063 6c61 7373 3d22 636f 6465 2068 │ │ │ │ -0001bf30: 4669 656c 6454 7261 6974 7326 6c74 3b4b FieldTraits<K │ │ │ │ -0001bf40: 2667 743b 3a3a 7265 616c 5f74 7970 653c >::real_type< │ │ │ │ -0001bf50: 2f61 3e3b 3c2f 6469 763e 0a3c 6469 7620 /a>;
    .
    691 │ │ │ │ -0001bfb0: 2020 2020 203c 7370 616e 2063 6c61 7373 // co │ │ │ │ -0001bfd0: 6465 2067 656e 6572 6174 6564 2062 7920 de generated by │ │ │ │ -0001bfe0: 6d61 706c 653c 2f73 7061 6e3e 3c2f 6469 maple.
    692 │ │ │ │ -0001c040: 3c2f 7370 616e 3e20 2020 2020 204b 2064 K d │ │ │ │ -0001c050: 6574 203d 2028 6d61 7472 6978 5b30 5d5b et = (matrix[0][ │ │ │ │ -0001c060: 305d 2a6d 6174 7269 785b 315d 5b31 5d20 0]*matrix[1][1] │ │ │ │ -0001c070: 2d20 6d61 7472 6978 5b30 5d5b 315d 2a6d - matrix[0][1]*m │ │ │ │ -0001c080: 6174 7269 785b 315d 5b30 5d29 3b3c 2f64 atrix[1][0]);.
    69 │ │ │ │ -0001c0e0: 333c 2f73 7061 6e3e 2020 2020 2020 4b20 3 K │ │ │ │ -0001c0f0: 6465 745f 3120 3d20 7265 616c 5f74 7970 det_1 = real_typ │ │ │ │ -0001c100: 6528 312e 3029 2f64 6574 3b3c 2f64 6976 e(1.0)/det;
    .
    694< │ │ │ │ -0001c160: 2f73 7061 6e3e 2020 2020 2020 696e 7665 /span> inve │ │ │ │ -0001c170: 7273 655b 305d 5b30 5d20 3d20 2020 6d61 rse[0][0] = ma │ │ │ │ -0001c180: 7472 6978 5b31 5d5b 315d 202a 2064 6574 trix[1][1] * det │ │ │ │ -0001c190: 5f31 3b3c 2f64 6976 3e0a 3c64 6976 2063 _1;
    .
    695 │ │ │ │ -0001c1f0: 2020 2020 696e 7665 7273 655b 305d 5b31 inverse[0][1 │ │ │ │ -0001c200: 5d20 3d20 2d20 6d61 7472 6978 5b30 5d5b ] = - matrix[0][ │ │ │ │ -0001c210: 315d 202a 2064 6574 5f31 3b3c 2f64 6976 1] * det_1;
    .
    696< │ │ │ │ -0001c270: 2f73 7061 6e3e 2020 2020 2020 696e 7665 /span> inve │ │ │ │ -0001c280: 7273 655b 315d 5b30 5d20 3d20 2d20 6d61 rse[1][0] = - ma │ │ │ │ -0001c290: 7472 6978 5b31 5d5b 305d 202a 2064 6574 trix[1][0] * det │ │ │ │ -0001c2a0: 5f31 3b3c 2f64 6976 3e0a 3c64 6976 2063 _1;
    .
    697 │ │ │ │ -0001c300: 2020 2020 696e 7665 7273 655b 315d 5b31 inverse[1][1 │ │ │ │ -0001c310: 5d20 3d20 2020 6d61 7472 6978 5b30 5d5b ] = matrix[0][ │ │ │ │ -0001c320: 305d 202a 2064 6574 5f31 3b3c 2f64 6976 0] * det_1;
    .
    698< │ │ │ │ -0001c380: 2f73 7061 6e3e 2020 2020 2020 3c73 7061 /span> return det;
    .< │ │ │ │ -0001c3c0: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -0001c3d0: 3e3c 6120 6964 3d22 6c30 3036 3939 2220 > 699 }
    .< │ │ │ │ -0001c420: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -0001c470: 3730 303c 2f73 7061 6e3e 203c 2f64 6976 700
    .
    703< │ │ │ │ -0001c4d0: 2f73 7061 6e3e 2020 2020 3c73 7061 6e20 /span> │ │ │ │ -0001c4f0: 7465 6d70 6c61 7465 3c2f 7370 616e 3e20 template │ │ │ │ -0001c500: 266c 743b 3c73 7061 6e20 636c 6173 733d <typena │ │ │ │ -0001c520: 6d65 3c2f 7370 616e 3e20 4b26 6774 3b3c me K>< │ │ │ │ -0001c530: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.. │ │ │ │ -0001c820: 3c61 2069 643d 226c 3030 3730 3622 206e 706 us │ │ │ │ -0001c880: 696e 6720 3c2f 7370 616e 3e72 6561 6c5f ing real_ │ │ │ │ -0001c890: 7479 7065 203d 203c 7370 616e 2063 6c61 type = typ │ │ │ │ -0001c8b0: 656e 616d 653c 2f73 7061 6e3e 203c 6120 ename Fie │ │ │ │ -0001c910: 6c64 5472 6169 7473 266c 743b 4b26 6774 ldTraits<K> │ │ │ │ -0001c920: 3b3a 3a72 6561 6c5f 7479 7065 3c2f 613e ;::real_type │ │ │ │ -0001c930: 3b3c 2f64 6976 3e0a 3c64 6976 2063 6c61 ;
    .
    │ │ │ │ -0001c980: 2020 3730 373c 2f73 7061 6e3e 2020 2020 707 │ │ │ │ -0001c990: 2020 3c73 7061 6e20 636c 6173 733d 2263 // code │ │ │ │ -0001c9b0: 6765 6e65 7261 7465 6420 6279 206d 6170 generated by map │ │ │ │ -0001c9c0: 6c65 3c2f 7370 616e 3e3c 2f64 6976 3e0a le
    . │ │ │ │ -0001c9d0: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    │ │ │ │ -0001ca70: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -0001caa0: 3c2f 613e 3c73 7061 6e20 636c 6173 733d 709 K det │ │ │ │ -0001cad0: 5f31 203d 2072 6561 6c5f 7479 7065 2831 _1 = real_type(1 │ │ │ │ -0001cae0: 2e30 292f 6465 743b 3c2f 6469 763e 0a3c .0)/det;
    .< │ │ │ │ -0001caf0: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -0001cb00: 3e3c 6120 6964 3d22 6c30 3037 3130 2220 > 710 inverse │ │ │ │ -0001cb50: 5b30 5d5b 305d 203d 2020 206d 6174 7269 [0][0] = matri │ │ │ │ -0001cb60: 785b 315d 5b31 5d20 2a20 6465 745f 313b x[1][1] * det_1; │ │ │ │ -0001cb70: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -0001cbc0: 2037 3131 3c2f 7370 616e 3e20 2020 2020 711 │ │ │ │ -0001cbd0: 2069 6e76 6572 7365 5b31 5d5b 305d 203d inverse[1][0] = │ │ │ │ -0001cbe0: 202d 206d 6174 7269 785b 305d 5b31 5d20 - matrix[0][1] │ │ │ │ -0001cbf0: 2a20 6465 745f 313b 3c2f 6469 763e 0a3c * det_1;
    .< │ │ │ │ -0001cc00: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -0001cc10: 3e3c 6120 6964 3d22 6c30 3037 3132 2220 > 712 inverse │ │ │ │ -0001cc60: 5b30 5d5b 315d 203d 202d 206d 6174 7269 [0][1] = - matri │ │ │ │ -0001cc70: 785b 315d 5b30 5d20 2a20 6465 745f 313b x[1][0] * det_1; │ │ │ │ -0001cc80: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -0001ccd0: 2037 3133 3c2f 7370 616e 3e20 2020 2020 713 │ │ │ │ -0001cce0: 2069 6e76 6572 7365 5b31 5d5b 315d 203d inverse[1][1] = │ │ │ │ -0001ccf0: 2020 206d 6174 7269 785b 305d 5b30 5d20 matrix[0][0] │ │ │ │ -0001cd00: 2a20 6465 745f 313b 3c2f 6469 763e 0a3c * det_1;
    .< │ │ │ │ -0001cd10: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -0001cd20: 3e3c 6120 6964 3d22 6c30 3037 3134 2220 > 714 return │ │ │ │ -0001cd90: 2064 6574 3b3c 2f64 6976 3e0a 3c64 6976 det;
    .
    < │ │ │ │ -0001cdd0: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -0001cde0: 6e6f 223e 2020 3731 353c 2f73 7061 6e3e no"> 715 │ │ │ │ -0001cdf0: 2020 2020 7d3c 2f64 6976 3e0a 3c2f 6469 }
    ..
    716 │ │ │ │ -0001ce50: 3c2f 7370 616e 3e20 3c2f 6469 763e 0a3c
    .< │ │ │ │ -0001ce60: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -0001ce70: 3e3c 6120 6964 3d22 6c30 3037 3138 2220 > 718 tem │ │ │ │ -0001ced0: 706c 6174 653c 2f73 7061 6e3e 2026 6c74 plate < │ │ │ │ -0001cee0: 3b3c 7370 616e 2063 6c61 7373 3d22 6b65 ;typename< │ │ │ │ -0001cf00: 2f73 7061 6e3e 204b 2667 743b 3c2f 6469 /span> K>.
    .
    719< │ │ │ │ -0001cff0: 2f73 7061 6e3e 2020 2020 3c73 7061 6e20 /span> │ │ │ │ -0001d010: 7374 6174 6963 3c2f 7370 616e 3e20 3c73 static inline K invertMatri │ │ │ │ -0001d0a0: 783c 2f61 3e20 283c 7370 616e 2063 6c61 x (con │ │ │ │ -0001d0c0: 7374 3c2f 7370 616e 3e20 3c61 2063 6c61 st FieldMatri │ │ │ │ -0001d100: 7826 6c74 3b4b 2c33 2c33 2667 743b 3c2f x<K,3,3> &matrix, │ │ │ │ -0001d120: 3c61 2063 6c61 7373 3d22 636f 6465 2068 Fiel │ │ │ │ -0001d150: 644d 6174 7269 7826 6c74 3b4b 2c33 2c33 dMatrix<K,3,3 │ │ │ │ -0001d160: 2667 743b 3c2f 613e 2026 616d 703b 696e > &in │ │ │ │ -0001d170: 7665 7273 6529 3c2f 6469 763e 0a3c 6469 verse)
    .< │ │ │ │ -0001d190: 6120 6964 3d22 6c30 3037 3230 2220 6e61 a id="l00720" na │ │ │ │ -0001d1a0: 6d65 3d22 6c30 3037 3230 223e 3c2f 613e me="l00720"> │ │ │ │ -0001d1b0: 3c73 7061 6e20 636c 6173 733d 226c 696e 720 {
    .< │ │ │ │ -0001d1f0: 6120 6964 3d22 6c30 3037 3231 2220 6e61 a id="l00721" na │ │ │ │ -0001d200: 6d65 3d22 6c30 3037 3231 223e 3c2f 613e me="l00721"> │ │ │ │ -0001d210: 3c73 7061 6e20 636c 6173 733d 226c 696e 721 usi │ │ │ │ -0001d250: 6e67 203c 2f73 7061 6e3e 7265 616c 5f74 ng real_t │ │ │ │ -0001d260: 7970 6520 3d20 3c73 7061 6e20 636c 6173 ype = type │ │ │ │ -0001d280: 6e61 6d65 3c2f 7370 616e 3e20 3c61 2063 name Fiel │ │ │ │ -0001d2e0: 6454 7261 6974 7326 6c74 3b4b 2667 743b dTraits<K> │ │ │ │ -0001d2f0: 3a3a 7265 616c 5f74 7970 653c 2f61 3e3b ::real_type; │ │ │ │ -0001d300: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -0001d350: 2037 3232 3c2f 7370 616e 3e20 2020 2020 722 │ │ │ │ -0001d360: 203c 7370 616e 2063 6c61 7373 3d22 636f // code g │ │ │ │ -0001d380: 656e 6572 6174 6564 2062 7920 6d61 706c enerated by mapl │ │ │ │ -0001d390: 653c 2f73 7061 6e3e 3c2f 6469 763e 0a3c e
    .< │ │ │ │ -0001d3a0: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -0001d3b0: 3e3c 6120 6964 3d22 6c30 3037 3233 2220 > 723 K t4 = │ │ │ │ -0001d400: 206d 6174 7269 785b 305d 5b30 5d20 2a20 matrix[0][0] * │ │ │ │ -0001d410: 6d61 7472 6978 5b31 5d5b 315d 3b3c 2f64 matrix[1][1];.
    72 │ │ │ │ -0001d470: 343c 2f73 7061 6e3e 2020 2020 2020 4b20 4 K │ │ │ │ -0001d480: 7436 2020 3d20 6d61 7472 6978 5b30 5d5b t6 = matrix[0][ │ │ │ │ -0001d490: 305d 202a 206d 6174 7269 785b 315d 5b32 0] * matrix[1][2 │ │ │ │ -0001d4a0: 5d3b 3c2f 6469 763e 0a3c 6469 7620 636c ];
    .
    725 │ │ │ │ -0001d500: 2020 204b 2074 3820 203d 206d 6174 7269 K t8 = matri │ │ │ │ -0001d510: 785b 305d 5b31 5d20 2a20 6d61 7472 6978 x[0][1] * matrix │ │ │ │ -0001d520: 5b31 5d5b 305d 3b3c 2f64 6976 3e0a 3c64 [1][0];
    . │ │ │ │ -0001d540: 3c61 2069 643d 226c 3030 3732 3622 206e 726
    K t10 = │ │ │ │ -0001d590: 6d61 7472 6978 5b30 5d5b 325d 202a 206d matrix[0][2] * m │ │ │ │ -0001d5a0: 6174 7269 785b 315d 5b30 5d3b 3c2f 6469 atrix[1][0];.
    727 │ │ │ │ -0001d600: 3c2f 7370 616e 3e20 2020 2020 204b 2074 K t │ │ │ │ -0001d610: 3132 203d 206d 6174 7269 785b 305d 5b31 12 = matrix[0][1 │ │ │ │ -0001d620: 5d20 2a20 6d61 7472 6978 5b32 5d5b 305d ] * matrix[2][0] │ │ │ │ -0001d630: 3b3c 2f64 6976 3e0a 3c64 6976 2063 6c61 ;
    .
    │ │ │ │ -0001d680: 2020 3732 383c 2f73 7061 6e3e 2020 2020 728 │ │ │ │ -0001d690: 2020 4b20 7431 3420 3d20 6d61 7472 6978 K t14 = matrix │ │ │ │ -0001d6a0: 5b30 5d5b 325d 202a 206d 6174 7269 785b [0][2] * matrix[ │ │ │ │ -0001d6b0: 325d 5b30 5d3b 3c2f 6469 763e 0a3c 6469 2][0];
    .< │ │ │ │ -0001d6d0: 6120 6964 3d22 6c30 3037 3239 2220 6e61 a id="l00729" na │ │ │ │ -0001d6e0: 6d65 3d22 6c30 3037 3239 223e 3c2f 613e me="l00729"> │ │ │ │ -0001d6f0: 3c73 7061 6e20 636c 6173 733d 226c 696e 729
    .
    730 │ │ │ │ -0001d770: 2020 204b 2064 6574 203d 2028 7434 2a6d K det = (t4*m │ │ │ │ -0001d780: 6174 7269 785b 325d 5b32 5d2d 7436 2a6d atrix[2][2]-t6*m │ │ │ │ -0001d790: 6174 7269 785b 325d 5b31 5d2d 7438 2a6d atrix[2][1]-t8*m │ │ │ │ -0001d7a0: 6174 7269 785b 325d 5b32 5d2b 3c2f 6469 atrix[2][2]+.
    731 │ │ │ │ -0001d800: 3c2f 7370 616e 3e20 2020 2020 2020 2020 │ │ │ │ -0001d810: 2020 2020 2020 7431 302a 6d61 7472 6978 t10*matrix │ │ │ │ -0001d820: 5b32 5d5b 315d 2b74 3132 2a6d 6174 7269 [2][1]+t12*matri │ │ │ │ -0001d830: 785b 315d 5b32 5d2d 7431 342a 6d61 7472 x[1][2]-t14*matr │ │ │ │ -0001d840: 6978 5b31 5d5b 315d 293b 3c2f 6469 763e ix[1][1]);
    │ │ │ │ -0001d850: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -0001d880: 3c2f 613e 3c73 7061 6e20 636c 6173 733d 732 K t17 │ │ │ │ -0001d8b0: 203d 2072 6561 6c5f 7479 7065 2831 2e30 = real_type(1.0 │ │ │ │ -0001d8c0: 292f 6465 743b 3c2f 6469 763e 0a3c 6469 )/det;
    .< │ │ │ │ -0001d8e0: 6120 6964 3d22 6c30 3037 3333 2220 6e61 a id="l00733" na │ │ │ │ -0001d8f0: 6d65 3d22 6c30 3037 3333 223e 3c2f 613e me="l00733"> │ │ │ │ -0001d900: 3c73 7061 6e20 636c 6173 733d 226c 696e 733
    .
    734 │ │ │ │ -0001d980: 2020 2069 6e76 6572 7365 5b30 5d5b 305d inverse[0][0] │ │ │ │ -0001d990: 203d 2020 286d 6174 7269 785b 315d 5b31 = (matrix[1][1 │ │ │ │ -0001d9a0: 5d20 2a20 6d61 7472 6978 5b32 5d5b 325d ] * matrix[2][2] │ │ │ │ -0001d9b0: 202d 206d 6174 7269 785b 315d 5b32 5d20 - matrix[1][2] │ │ │ │ -0001d9c0: 2a20 6d61 7472 6978 5b32 5d5b 315d 292a * matrix[2][1])* │ │ │ │ -0001d9d0: 7431 373b 3c2f 6469 763e 0a3c 6469 7620 t17;
    .
    735 │ │ │ │ -0001da30: 2020 2020 2069 6e76 6572 7365 5b30 5d5b inverse[0][ │ │ │ │ -0001da40: 315d 203d 202d 286d 6174 7269 785b 305d 1] = -(matrix[0] │ │ │ │ -0001da50: 5b31 5d20 2a20 6d61 7472 6978 5b32 5d5b [1] * matrix[2][ │ │ │ │ -0001da60: 325d 202d 206d 6174 7269 785b 305d 5b32 2] - matrix[0][2 │ │ │ │ -0001da70: 5d20 2a20 6d61 7472 6978 5b32 5d5b 315d ] * matrix[2][1] │ │ │ │ -0001da80: 292a 7431 373b 3c2f 6469 763e 0a3c 6469 )*t17;
    .< │ │ │ │ -0001daa0: 6120 6964 3d22 6c30 3037 3336 2220 6e61 a id="l00736" na │ │ │ │ -0001dab0: 6d65 3d22 6c30 3037 3336 223e 3c2f 613e me="l00736"> │ │ │ │ -0001dac0: 3c73 7061 6e20 636c 6173 733d 226c 696e 736 inverse[0 │ │ │ │ -0001daf0: 5d5b 325d 203d 2020 286d 6174 7269 785b ][2] = (matrix[ │ │ │ │ -0001db00: 305d 5b31 5d20 2a20 6d61 7472 6978 5b31 0][1] * matrix[1 │ │ │ │ -0001db10: 5d5b 325d 202d 206d 6174 7269 785b 305d ][2] - matrix[0] │ │ │ │ -0001db20: 5b32 5d20 2a20 6d61 7472 6978 5b31 5d5b [2] * matrix[1][ │ │ │ │ -0001db30: 315d 292a 7431 373b 3c2f 6469 763e 0a3c 1])*t17;
    .< │ │ │ │ -0001db40: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -0001db50: 3e3c 6120 6964 3d22 6c30 3037 3337 2220 > 737 inverse │ │ │ │ -0001dba0: 5b31 5d5b 305d 203d 202d 286d 6174 7269 [1][0] = -(matri │ │ │ │ -0001dbb0: 785b 315d 5b30 5d20 2a20 6d61 7472 6978 x[1][0] * matrix │ │ │ │ -0001dbc0: 5b32 5d5b 325d 202d 206d 6174 7269 785b [2][2] - matrix[ │ │ │ │ -0001dbd0: 315d 5b32 5d20 2a20 6d61 7472 6978 5b32 1][2] * matrix[2 │ │ │ │ -0001dbe0: 5d5b 305d 292a 7431 373b 3c2f 6469 763e ][0])*t17;
    │ │ │ │ -0001dbf0: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -0001dc20: 3c2f 613e 3c73 7061 6e20 636c 6173 733d 738 inver │ │ │ │ -0001dc50: 7365 5b31 5d5b 315d 203d 2020 286d 6174 se[1][1] = (mat │ │ │ │ -0001dc60: 7269 785b 305d 5b30 5d20 2a20 6d61 7472 rix[0][0] * matr │ │ │ │ -0001dc70: 6978 5b32 5d5b 325d 202d 2074 3134 2920 ix[2][2] - t14) │ │ │ │ -0001dc80: 2a20 7431 373b 3c2f 6469 763e 0a3c 6469 * t17;
    .< │ │ │ │ -0001dca0: 6120 6964 3d22 6c30 3037 3339 2220 6e61 a id="l00739" na │ │ │ │ -0001dcb0: 6d65 3d22 6c30 3037 3339 223e 3c2f 613e me="l00739"> │ │ │ │ -0001dcc0: 3c73 7061 6e20 636c 6173 733d 226c 696e 739 inverse[1 │ │ │ │ -0001dcf0: 5d5b 325d 203d 202d 2874 362d 7431 3029 ][2] = -(t6-t10) │ │ │ │ -0001dd00: 202a 2074 3137 3b3c 2f64 6976 3e0a 3c64 * t17;
    . │ │ │ │ -0001dd20: 3c61 2069 643d 226c 3030 3734 3022 206e 740 inverse[ │ │ │ │ -0001dd70: 325d 5b30 5d20 3d20 2028 6d61 7472 6978 2][0] = (matrix │ │ │ │ -0001dd80: 5b31 5d5b 305d 202a 206d 6174 7269 785b [1][0] * matrix[ │ │ │ │ -0001dd90: 325d 5b31 5d20 2d20 6d61 7472 6978 5b31 2][1] - matrix[1 │ │ │ │ -0001dda0: 5d5b 315d 202a 206d 6174 7269 785b 325d ][1] * matrix[2] │ │ │ │ -0001ddb0: 5b30 5d29 202a 2074 3137 3b3c 2f64 6976 [0]) * t17;
    .
    741< │ │ │ │ -0001de10: 2f73 7061 6e3e 2020 2020 2020 696e 7665 /span> inve │ │ │ │ -0001de20: 7273 655b 325d 5b31 5d20 3d20 2d28 6d61 rse[2][1] = -(ma │ │ │ │ -0001de30: 7472 6978 5b30 5d5b 305d 202a 206d 6174 trix[0][0] * mat │ │ │ │ -0001de40: 7269 785b 325d 5b31 5d20 2d20 7431 3229 rix[2][1] - t12) │ │ │ │ -0001de50: 202a 2074 3137 3b3c 2f64 6976 3e0a 3c64 * t17;
    . │ │ │ │ -0001de70: 3c61 2069 643d 226c 3030 3734 3222 206e 742 inverse[ │ │ │ │ -0001dec0: 325d 5b32 5d20 3d20 2028 7434 2d74 3829 2][2] = (t4-t8) │ │ │ │ -0001ded0: 202a 2074 3137 3b3c 2f64 6976 3e0a 3c64 * t17;
    . │ │ │ │ -0001def0: 3c61 2069 643d 226c 3030 3734 3322 206e 743
    .
    744 │ │ │ │ -0001df90: 2020 2020 3c73 7061 6e20 636c 6173 733d re │ │ │ │ -0001dfb0: 7475 726e 3c2f 7370 616e 3e20 6465 743b turn det; │ │ │ │ -0001dfc0: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -0001e010: 2037 3435 3c2f 7370 616e 3e20 2020 207d 745 } │ │ │ │ -0001e020: 3c2f 6469 763e 0a3c 2f64 6976 3e0a 3c64
    .
    . │ │ │ │ -0001e040: 3c61 2069 643d 226c 3030 3734 3622 206e 746
    .
    748 │ │ │ │ -0001e0e0: 2020 3c73 7061 6e20 636c 6173 733d 226b template │ │ │ │ -0001e100: 3c2f 7370 616e 3e20 266c 743b 3c73 7061 <typename K>
    ..
    749 stati │ │ │ │ -0001e240: 633c 2f73 7061 6e3e 203c 7370 616e 2063 c i │ │ │ │ -0001e260: 6e6c 696e 653c 2f73 7061 6e3e 204b 203c nline K < │ │ │ │ -0001e270: 6120 636c 6173 733d 2263 6f64 6520 686c a class="code hl │ │ │ │ -0001e280: 5f66 756e 6374 696f 6e22 2068 7265 663d _function" href= │ │ │ │ -0001e290: 2261 3030 3433 362e 6874 6d6c 2361 3637 "a00436.html#a67 │ │ │ │ -0001e2a0: 3135 3538 3135 6230 3334 3737 3331 3239 155815b034773129 │ │ │ │ -0001e2b0: 6432 3162 6665 3339 3932 6630 6236 223e d21bfe3992f0b6"> │ │ │ │ -0001e2c0: 696e 7665 7274 4d61 7472 6978 5f72 6574 invertMatrix_ret │ │ │ │ -0001e2d0: 5472 616e 7370 6f73 6564 3c2f 613e 2028 Transposed ( │ │ │ │ -0001e2e0: 3c73 7061 6e20 636c 6173 733d 226b 6579 const F │ │ │ │ -0001e330: 6965 6c64 4d61 7472 6978 266c 743b 4b2c ieldMatrix<K, │ │ │ │ -0001e340: 332c 3326 6774 3b3c 2f61 3e20 2661 6d70 3,3> & │ │ │ │ -0001e350: 3b6d 6174 7269 782c 203c 6120 636c 6173 ;matrix, FieldMatrix │ │ │ │ -0001e390: 266c 743b 4b2c 332c 3326 6774 3b3c 2f61 <K,3,3> &inverse)< │ │ │ │ -0001e3b0: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -0001e400: 3735 303c 2f73 7061 6e3e 2020 2020 7b3c 750 {< │ │ │ │ -0001e410: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -0001e460: 3735 313c 2f73 7061 6e3e 2020 2020 2020 751 │ │ │ │ -0001e470: 3c73 7061 6e20 636c 6173 733d 226b 6579 using real_type = < │ │ │ │ -0001e4a0: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -0001e4b0: 6f72 6422 3e74 7970 656e 616d 653c 2f73 ord">typename FieldTraits │ │ │ │ -0001e520: 266c 743b 4b26 6774 3b3a 3a72 6561 6c5f <K>::real_ │ │ │ │ -0001e530: 7479 7065 3c2f 613e 3b3c 2f64 6976 3e0a type;
    . │ │ │ │ -0001e540: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    .
    │ │ │ │ -0001e620: 2020 3735 333c 2f73 7061 6e3e 2020 2020 753 │ │ │ │ -0001e630: 2020 4b20 7434 2020 3d20 6d61 7472 6978 K t4 = matrix │ │ │ │ -0001e640: 5b30 5d5b 305d 202a 206d 6174 7269 785b [0][0] * matrix[ │ │ │ │ -0001e650: 315d 5b31 5d3b 3c2f 6469 763e 0a3c 6469 1][1];
    .< │ │ │ │ -0001e670: 6120 6964 3d22 6c30 3037 3534 2220 6e61 a id="l00754" na │ │ │ │ -0001e680: 6d65 3d22 6c30 3037 3534 223e 3c2f 613e me="l00754"> │ │ │ │ -0001e690: 3c73 7061 6e20 636c 6173 733d 226c 696e 754 K t6 = m │ │ │ │ -0001e6c0: 6174 7269 785b 305d 5b30 5d20 2a20 6d61 atrix[0][0] * ma │ │ │ │ -0001e6d0: 7472 6978 5b31 5d5b 325d 3b3c 2f64 6976 trix[1][2];
    .
    755< │ │ │ │ -0001e730: 2f73 7061 6e3e 2020 2020 2020 4b20 7438 /span> K t8 │ │ │ │ -0001e740: 2020 3d20 6d61 7472 6978 5b30 5d5b 315d = matrix[0][1] │ │ │ │ -0001e750: 202a 206d 6174 7269 785b 315d 5b30 5d3b * matrix[1][0]; │ │ │ │ -0001e760: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -0001e7b0: 2037 3536 3c2f 7370 616e 3e20 2020 2020 756 │ │ │ │ -0001e7c0: 204b 2074 3130 203d 206d 6174 7269 785b K t10 = matrix[ │ │ │ │ -0001e7d0: 305d 5b32 5d20 2a20 6d61 7472 6978 5b31 0][2] * matrix[1 │ │ │ │ -0001e7e0: 5d5b 305d 3b3c 2f64 6976 3e0a 3c64 6976 ][0];
    .
    < │ │ │ │ -0001e820: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -0001e830: 6e6f 223e 2020 3735 373c 2f73 7061 6e3e no"> 757 │ │ │ │ -0001e840: 2020 2020 2020 4b20 7431 3220 3d20 6d61 K t12 = ma │ │ │ │ -0001e850: 7472 6978 5b30 5d5b 315d 202a 206d 6174 trix[0][1] * mat │ │ │ │ -0001e860: 7269 785b 325d 5b30 5d3b 3c2f 6469 763e rix[2][0];
    │ │ │ │ -0001e870: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -0001e8a0: 3c2f 613e 3c73 7061 6e20 636c 6173 733d 758 K t14 │ │ │ │ -0001e8d0: 203d 206d 6174 7269 785b 305d 5b32 5d20 = matrix[0][2] │ │ │ │ -0001e8e0: 2a20 6d61 7472 6978 5b32 5d5b 305d 3b3c * matrix[2][0];< │ │ │ │ -0001e8f0: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -0001e940: 3735 393c 2f73 7061 6e3e 203c 2f64 6976 759
    .
    760< │ │ │ │ -0001e9a0: 2f73 7061 6e3e 2020 2020 2020 4b20 6465 /span> K de │ │ │ │ -0001e9b0: 7420 3d20 2874 342a 6d61 7472 6978 5b32 t = (t4*matrix[2 │ │ │ │ -0001e9c0: 5d5b 325d 2d74 362a 6d61 7472 6978 5b32 ][2]-t6*matrix[2 │ │ │ │ -0001e9d0: 5d5b 315d 2d74 382a 6d61 7472 6978 5b32 ][1]-t8*matrix[2 │ │ │ │ -0001e9e0: 5d5b 325d 2b3c 2f64 6976 3e0a 3c64 6976 ][2]+
    .
    < │ │ │ │ -0001ea20: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -0001ea30: 6e6f 223e 2020 3736 313c 2f73 7061 6e3e no"> 761 │ │ │ │ -0001ea40: 2020 2020 2020 2020 2020 2020 2020 2074 t │ │ │ │ -0001ea50: 3130 2a6d 6174 7269 785b 325d 5b31 5d2b 10*matrix[2][1]+ │ │ │ │ -0001ea60: 7431 322a 6d61 7472 6978 5b31 5d5b 325d t12*matrix[1][2] │ │ │ │ -0001ea70: 2d74 3134 2a6d 6174 7269 785b 315d 5b31 -t14*matrix[1][1 │ │ │ │ -0001ea80: 5d29 3b3c 2f64 6976 3e0a 3c64 6976 2063 ]);
    .
    762 │ │ │ │ -0001eae0: 2020 2020 4b20 7431 3720 3d20 7265 616c K t17 = real │ │ │ │ -0001eaf0: 5f74 7970 6528 312e 3029 2f64 6574 3b3c _type(1.0)/det;< │ │ │ │ -0001eb00: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -0001eb50: 3736 333c 2f73 7061 6e3e 203c 2f64 6976 763
    .
    764< │ │ │ │ -0001ebb0: 2f73 7061 6e3e 2020 2020 2020 696e 7665 /span> inve │ │ │ │ -0001ebc0: 7273 655b 305d 5b30 5d20 3d20 2028 6d61 rse[0][0] = (ma │ │ │ │ -0001ebd0: 7472 6978 5b31 5d5b 315d 202a 206d 6174 trix[1][1] * mat │ │ │ │ -0001ebe0: 7269 785b 325d 5b32 5d20 2d20 6d61 7472 rix[2][2] - matr │ │ │ │ -0001ebf0: 6978 5b31 5d5b 325d 202a 206d 6174 7269 ix[1][2] * matri │ │ │ │ -0001ec00: 785b 325d 5b31 5d29 2a74 3137 3b3c 2f64 x[2][1])*t17;.
    76 │ │ │ │ -0001ec60: 353c 2f73 7061 6e3e 2020 2020 2020 696e 5 in │ │ │ │ -0001ec70: 7665 7273 655b 315d 5b30 5d20 3d20 2d28 verse[1][0] = -( │ │ │ │ -0001ec80: 6d61 7472 6978 5b30 5d5b 315d 202a 206d matrix[0][1] * m │ │ │ │ -0001ec90: 6174 7269 785b 325d 5b32 5d20 2d20 6d61 atrix[2][2] - ma │ │ │ │ -0001eca0: 7472 6978 5b30 5d5b 325d 202a 206d 6174 trix[0][2] * mat │ │ │ │ -0001ecb0: 7269 785b 325d 5b31 5d29 2a74 3137 3b3c rix[2][1])*t17;< │ │ │ │ -0001ecc0: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -0001ed10: 3736 363c 2f73 7061 6e3e 2020 2020 2020 766 │ │ │ │ -0001ed20: 696e 7665 7273 655b 325d 5b30 5d20 3d20 inverse[2][0] = │ │ │ │ -0001ed30: 2028 6d61 7472 6978 5b30 5d5b 315d 202a (matrix[0][1] * │ │ │ │ -0001ed40: 206d 6174 7269 785b 315d 5b32 5d20 2d20 matrix[1][2] - │ │ │ │ -0001ed50: 6d61 7472 6978 5b30 5d5b 325d 202a 206d matrix[0][2] * m │ │ │ │ -0001ed60: 6174 7269 785b 315d 5b31 5d29 2a74 3137 atrix[1][1])*t17 │ │ │ │ -0001ed70: 3b3c 2f64 6976 3e0a 3c64 6976 2063 6c61 ;
    .
    │ │ │ │ -0001edc0: 2020 3736 373c 2f73 7061 6e3e 2020 2020 767 │ │ │ │ -0001edd0: 2020 696e 7665 7273 655b 305d 5b31 5d20 inverse[0][1] │ │ │ │ -0001ede0: 3d20 2d28 6d61 7472 6978 5b31 5d5b 305d = -(matrix[1][0] │ │ │ │ -0001edf0: 202a 206d 6174 7269 785b 325d 5b32 5d20 * matrix[2][2] │ │ │ │ -0001ee00: 2d20 6d61 7472 6978 5b31 5d5b 325d 202a - matrix[1][2] * │ │ │ │ -0001ee10: 206d 6174 7269 785b 325d 5b30 5d29 2a74 matrix[2][0])*t │ │ │ │ -0001ee20: 3137 3b3c 2f64 6976 3e0a 3c64 6976 2063 17;
    .
    768 │ │ │ │ -0001ee80: 2020 2020 696e 7665 7273 655b 315d 5b31 inverse[1][1 │ │ │ │ -0001ee90: 5d20 3d20 2028 6d61 7472 6978 5b30 5d5b ] = (matrix[0][ │ │ │ │ -0001eea0: 305d 202a 206d 6174 7269 785b 325d 5b32 0] * matrix[2][2 │ │ │ │ -0001eeb0: 5d20 2d20 7431 3429 202a 2074 3137 3b3c ] - t14) * t17;< │ │ │ │ -0001eec0: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -0001ef10: 3736 393c 2f73 7061 6e3e 2020 2020 2020 769 │ │ │ │ -0001ef20: 696e 7665 7273 655b 325d 5b31 5d20 3d20 inverse[2][1] = │ │ │ │ -0001ef30: 2d28 7436 2d74 3130 2920 2a20 7431 373b -(t6-t10) * t17; │ │ │ │ -0001ef40: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -0001ef90: 2037 3730 3c2f 7370 616e 3e20 2020 2020 770 │ │ │ │ -0001efa0: 2069 6e76 6572 7365 5b30 5d5b 325d 203d inverse[0][2] = │ │ │ │ -0001efb0: 2020 286d 6174 7269 785b 315d 5b30 5d20 (matrix[1][0] │ │ │ │ -0001efc0: 2a20 6d61 7472 6978 5b32 5d5b 315d 202d * matrix[2][1] - │ │ │ │ -0001efd0: 206d 6174 7269 785b 315d 5b31 5d20 2a20 matrix[1][1] * │ │ │ │ -0001efe0: 6d61 7472 6978 5b32 5d5b 305d 2920 2a20 matrix[2][0]) * │ │ │ │ -0001eff0: 7431 373b 3c2f 6469 763e 0a3c 6469 7620 t17;
    .
    771 │ │ │ │ -0001f050: 2020 2020 2069 6e76 6572 7365 5b31 5d5b inverse[1][ │ │ │ │ -0001f060: 325d 203d 202d 286d 6174 7269 785b 305d 2] = -(matrix[0] │ │ │ │ -0001f070: 5b30 5d20 2a20 6d61 7472 6978 5b32 5d5b [0] * matrix[2][ │ │ │ │ -0001f080: 315d 202d 2074 3132 2920 2a20 7431 373b 1] - t12) * t17; │ │ │ │ -0001f090: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -0001f0e0: 2037 3732 3c2f 7370 616e 3e20 2020 2020 772 │ │ │ │ -0001f0f0: 2069 6e76 6572 7365 5b32 5d5b 325d 203d inverse[2][2] = │ │ │ │ -0001f100: 2020 2874 342d 7438 2920 2a20 7431 373b (t4-t8) * t17; │ │ │ │ -0001f110: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -0001f160: 2037 3733 3c2f 7370 616e 3e20 3c2f 6469 773 .
    774 │ │ │ │ -0001f1c0: 3c2f 7370 616e 3e20 2020 2020 203c 7370 return det;
    . │ │ │ │ -0001f200: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    . │ │ │ │ -0001f260: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -0001f2b0: 2037 3736 3c2f 7370 616e 3e20 3c2f 6469 776 .
    778 │ │ │ │ -0001f310: 3c2f 7370 616e 3e20 2020 203c 7370 616e template │ │ │ │ -0001f340: 266c 743b 203c 7370 616e 2063 6c61 7373 < class │ │ │ │ -0001f360: 3c2f 7370 616e 3e20 4b2c 203c 7370 616e K, int │ │ │ │ -0001f390: 6d2c 203c 7370 616e 2063 6c61 7373 3d22 m, int │ │ │ │ -0001f3b0: 3c2f 7370 616e 3e20 6e2c 203c 7370 616e n, int │ │ │ │ -0001f3e0: 7020 2667 743b 3c2f 6469 763e 0a3c 6469 p >
    ..
    │ │ │ │ -0001f4c0: 2020 3737 393c 2f61 3e3c 2f73 7061 6e3e 779 │ │ │ │ -0001f4d0: 2020 2020 3c73 7061 6e20 636c 6173 733d static │ │ │ │ -0001f4f0: 3c2f 7370 616e 3e20 3c73 7061 6e20 636c in │ │ │ │ -0001f510: 6c69 6e65 3c2f 7370 616e 3e20 3c73 7061 line void multMatrix ( const< │ │ │ │ -0001f5c0: 2f73 7061 6e3e 203c 6120 636c 6173 733d /span> FieldMatrix&l │ │ │ │ -0001f600: 743b 204b 2c20 6d2c 206e 2026 6774 3b3c t; K, m, n >< │ │ │ │ -0001f610: 2f61 3e20 2661 6d70 3b41 2c3c 2f64 6976 /a> &A,
    .
    780< │ │ │ │ -0001f670: 2f73 7061 6e3e 2020 2020 2020 2020 2020 /span> │ │ │ │ -0001f680: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ │ -0001f690: 2020 2020 2020 2020 2020 3c73 7061 6e20 │ │ │ │ -0001f6b0: 636f 6e73 743c 2f73 7061 6e3e 203c 6120 const FieldMa │ │ │ │ -0001f6f0: 7472 6978 266c 743b 204b 2c20 6e2c 2070 trix< K, n, p │ │ │ │ -0001f700: 2026 6774 3b3c 2f61 3e20 2661 6d70 3b42 > &B │ │ │ │ -0001f710: 2c3c 2f64 6976 3e0a 3c64 6976 2063 6c61 ,
    .
    │ │ │ │ -0001f760: 2020 3738 313c 2f73 7061 6e3e 2020 2020 781 │ │ │ │ -0001f770: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ │ -0001f780: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ │ -0001f790: 3c61 2063 6c61 7373 3d22 636f 6465 2068 Fiel │ │ │ │ -0001f7c0: 644d 6174 7269 7826 6c74 3b20 4b2c 206d dMatrix< K, m │ │ │ │ -0001f7d0: 2c20 7020 2667 743b 3c2f 613e 2026 616d , p > &am │ │ │ │ -0001f7e0: 703b 7265 7420 293c 2f64 6976 3e0a 3c64 p;ret )
    . │ │ │ │ -0001f800: 3c61 2069 643d 226c 3030 3738 3222 206e 782 {
    . │ │ │ │ -0001f860: 3c61 2069 643d 226c 3030 3738 3322 206e 783 ty │ │ │ │ -0001f8c0: 7065 6465 663c 2f73 7061 6e3e 203c 7370 pedef typename F │ │ │ │ -0001f920: 6965 6c64 4d61 7472 6978 266c 743b 204b ieldMatrix< K │ │ │ │ -0001f930: 2c20 6d2c 2070 2026 6774 3b3c 2f61 3e20 , m, p > │ │ │ │ -0001f940: 3a3a 2073 697a 655f 7479 7065 2073 697a :: size_type siz │ │ │ │ -0001f950: 655f 7479 7065 3b3c 2f64 6976 3e0a 3c64 e_type;
    . │ │ │ │ -0001f970: 3c61 2069 643d 226c 3030 3738 3422 206e 784
    .
    785 │ │ │ │ -0001fa10: 2020 2020 3c73 7061 6e20 636c 6173 733d fo │ │ │ │ -0001fa30: 723c 2f73 7061 6e3e 2820 7369 7a65 5f74 r( size_t │ │ │ │ -0001fa40: 7970 6520 6920 3d20 303b 2069 2026 6c74 ype i = 0; i < │ │ │ │ -0001fa50: 3b20 6d3b 202b 2b69 2029 3c2f 6469 763e ; m; ++i )
    │ │ │ │ -0001fa60: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -0001fa90: 3c2f 613e 3c73 7061 6e20 636c 6173 733d 786 {.
    787 │ │ │ │ -0001fb10: 3c2f 7370 616e 3e20 2020 2020 2020 203c < │ │ │ │ -0001fb20: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -0001fb30: 6f72 6466 6c6f 7722 3e66 6f72 3c2f 7370 ordflow">for( size_type j │ │ │ │ -0001fb50: 203d 2030 3b20 6a20 266c 743b 2070 3b20 = 0; j < p; │ │ │ │ -0001fb60: 2b2b 6a20 293c 2f64 6976 3e0a 3c64 6976 ++j )
    .
    < │ │ │ │ -0001fba0: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -0001fbb0: 6e6f 223e 2020 3738 383c 2f73 7061 6e3e no"> 788 │ │ │ │ -0001fbc0: 2020 2020 2020 2020 7b3c 2f64 6976 3e0a {
    . │ │ │ │ -0001fbd0: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    .
    < │ │ │ │ -0001fc80: 7370 616e 2063 6c61 7373 3d22 6c69 6e65 span class="line │ │ │ │ -0001fc90: 6e6f 223e 2020 3739 303c 2f73 7061 6e3e no"> 790 │ │ │ │ -0001fca0: 2020 2020 2020 2020 2020 3c73 7061 6e20 for( │ │ │ │ -0001fcd0: 7369 7a65 5f74 7970 6520 6b20 3d20 303b size_type k = 0; │ │ │ │ -0001fce0: 206b 2026 6c74 3b20 6e3b 202b 2b6b 2029 k < n; ++k ) │ │ │ │ -0001fcf0: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -0001fd40: 2037 3931 3c2f 7370 616e 3e20 2020 2020 791 │ │ │ │ -0001fd50: 2020 2020 2020 2072 6574 5b20 6920 5d5b ret[ i ][ │ │ │ │ -0001fd60: 206a 205d 202b 3d20 415b 2069 205d 5b20 j ] += A[ i ][ │ │ │ │ -0001fd70: 6b20 5d20 2a20 425b 206b 205d 5b20 6a20 k ] * B[ k ][ j │ │ │ │ -0001fd80: 5d3b 3c2f 6469 763e 0a3c 6469 7620 636c ];
    .
    792 │ │ │ │ -0001fde0: 2020 2020 207d 3c2f 6469 763e 0a3c 6469 }
    .< │ │ │ │ -0001fe00: 6120 6964 3d22 6c30 3037 3933 2220 6e61 a id="l00793" na │ │ │ │ -0001fe10: 6d65 3d22 6c30 3037 3933 223e 3c2f 613e me="l00793"> │ │ │ │ -0001fe20: 3c73 7061 6e20 636c 6173 733d 226c 696e 793 }
    .< │ │ │ │ -0001fe50: 6469 7620 636c 6173 733d 226c 696e 6522 div class="line" │ │ │ │ -0001fe60: 3e3c 6120 6964 3d22 6c30 3037 3934 2220 > 794 }
    .< │ │ │ │ -0001feb0: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -0001ff00: 3739 353c 2f73 7061 6e3e 203c 2f64 6976 795
    .
    797< │ │ │ │ -0001ff60: 2f73 7061 6e3e 2020 2020 3c73 7061 6e20 /span> │ │ │ │ -0001ff80: 7465 6d70 6c61 7465 3c2f 7370 616e 3e20 template │ │ │ │ -0001ff90: 266c 743b 3c73 7061 6e20 636c 6173 733d <typena │ │ │ │ -0001ffb0: 6d65 3c2f 7370 616e 3e20 4b2c 203c 7370 me K, int rows, int col │ │ │ │ -00020010: 7326 6774 3b3c 2f64 6976 3e0a 3c64 6976 s>
    .
    .
    │ │ │ │ -000200f0: 2037 3938 3c2f 613e 3c2f 7370 616e 3e20 798 │ │ │ │ -00020100: 2020 203c 7370 616e 2063 6c61 7373 3d22 static< │ │ │ │ -00020120: 2f73 7061 6e3e 203c 7370 616e 2063 6c61 /span> inl │ │ │ │ -00020140: 696e 653c 2f73 7061 6e3e 203c 7370 616e ine void │ │ │ │ -00020170: 203c 6120 636c 6173 733d 2263 6f64 6520 multTransposed │ │ │ │ -000201d0: 4d61 7472 6978 3c2f 613e 283c 7370 616e Matrix(const FieldM │ │ │ │ -00020230: 6174 7269 7826 6c74 3b4b 2c72 6f77 732c atrix<K,rows, │ │ │ │ -00020240: 636f 6c73 2667 743b 3c2f 613e 2026 616d cols> &am │ │ │ │ -00020250: 703b 6d61 7472 6978 2c20 3c61 2063 6c61 p;matrix, FieldMatri │ │ │ │ -00020290: 7826 6c74 3b4b 2c63 6f6c 732c 636f 6c73 x<K,cols,cols │ │ │ │ -000202a0: 2667 743b 3c2f 613e 2661 6d70 3b20 7265 >& re │ │ │ │ -000202b0: 7429 3c2f 6469 763e 0a3c 6469 7620 636c t)
    .
    799 │ │ │ │ -00020310: 207b 3c2f 6469 763e 0a3c 6469 7620 636c {
    .
    800 │ │ │ │ -00020370: 2020 203c 7370 616e 2063 6c61 7373 3d22 typedef │ │ │ │ -00020390: 3c2f 7370 616e 3e20 3c73 7061 6e20 636c ty │ │ │ │ -000203b0: 7065 6e61 6d65 3c2f 7370 616e 3e20 3c61 pename Fi │ │ │ │ -00020410: 656c 644d 6174 7269 7826 6c74 3b4b 2c72 eldMatrix<K,r │ │ │ │ -00020420: 6f77 732c 636f 6c73 2667 743b 3a3a 7369 ows,cols>::si │ │ │ │ -00020430: 7a65 5f74 7970 653c 2f61 3e20 7369 7a65 ze_type size │ │ │ │ -00020440: 5f74 7970 653b 3c2f 6469 763e 0a3c 6469 _type;
    .< │ │ │ │ -00020460: 6120 6964 3d22 6c30 3038 3031 2220 6e61 a id="l00801" na │ │ │ │ -00020470: 6d65 3d22 6c30 3038 3031 223e 3c2f 613e me="l00801"> │ │ │ │ -00020480: 3c73 7061 6e20 636c 6173 733d 226c 696e 801
    .
    802 │ │ │ │ -00020500: 2020 203c 7370 616e 2063 6c61 7373 3d22 for │ │ │ │ -00020520: 3c2f 7370 616e 3e28 7369 7a65 5f74 7970 (size_typ │ │ │ │ -00020530: 6520 693d 303b 2069 266c 743b 636f 6c73 e i=0; i<cols │ │ │ │ -00020540: 3b20 692b 2b29 3c2f 6469 763e 0a3c 6469 ; i++)
    .< │ │ │ │ -00020560: 6120 6964 3d22 6c30 3038 3033 2220 6e61 a id="l00803" na │ │ │ │ -00020570: 6d65 3d22 6c30 3038 3033 223e 3c2f 613e me="l00803"> │ │ │ │ -00020580: 3c73 7061 6e20 636c 6173 733d 226c 696e 803 for(si │ │ │ │ -000205d0: 7a65 5f74 7970 6520 6a3d 303b 206a 266c ze_type j=0; j&l │ │ │ │ -000205e0: 743b 636f 6c73 3b20 6a2b 2b29 3c2f 6469 t;cols; j++).
    804 │ │ │ │ -00020640: 3c2f 7370 616e 3e20 2020 2020 2020 207b { │ │ │ │ -00020650: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -000206a0: 2038 3035 3c2f 7370 616e 3e20 2020 2020 805 │ │ │ │ -000206b0: 2020 2020 2072 6574 5b69 5d5b 6a5d 3d30 ret[i][j]=0 │ │ │ │ -000206c0: 2e30 3b3c 2f64 6976 3e0a 3c64 6976 2063 .0;
    .
    806 │ │ │ │ -00020720: 2020 2020 2020 2020 3c73 7061 6e20 636c for(siz │ │ │ │ -00020750: 655f 7479 7065 206b 3d30 3b20 6b26 6c74 e_type k=0; k< │ │ │ │ -00020760: 3b72 6f77 733b 206b 2b2b 293c 2f64 6976 ;rows; k++)
    .
    807< │ │ │ │ -000207c0: 2f73 7061 6e3e 2020 2020 2020 2020 2020 /span> │ │ │ │ -000207d0: 2020 7265 745b 695d 5b6a 5d2b 3d6d 6174 ret[i][j]+=mat │ │ │ │ -000207e0: 7269 785b 6b5d 5b69 5d2a 6d61 7472 6978 rix[k][i]*matrix │ │ │ │ -000207f0: 5b6b 5d5b 6a5d 3b3c 2f64 6976 3e0a 3c64 [k][j];
    . │ │ │ │ -00020810: 3c61 2069 643d 226c 3030 3830 3822 206e 808 }
    .
    809< │ │ │ │ -000208b0: 2f73 7061 6e3e 2020 2020 7d3c 2f64 6976 /span> }
    .
    .
    810 .
    8 │ │ │ │ -00020970: 3131 3c2f 7370 616e 3e20 2020 203c 7370 11 using │ │ │ │ -000209a0: 3c61 2063 6c61 7373 3d22 636f 6465 2068 Dune::DenseMatr │ │ │ │ -00020a00: 6978 4865 6c70 3a3a 6d75 6c74 4173 7369 ixHelp::multAssi │ │ │ │ -00020a10: 676e 3c2f 613e 3b3c 2f64 6976 3e0a 3c64 gn;
    . │ │ │ │ -00020a30: 3c61 2069 643d 226c 3030 3831 3222 206e 812
    .
    814 │ │ │ │ -00020ad0: 2020 3c73 7061 6e20 636c 6173 733d 226b template │ │ │ │ -00020af0: 3c2f 7370 616e 3e20 266c 743b 3c73 7061 <typename K, i │ │ │ │ -00020b40: 6e74 3c2f 7370 616e 3e20 726f 7773 2c20 nt rows, │ │ │ │ -00020b50: 3c73 7061 6e20 636c 6173 733d 226b 6579 int cols>.
    .
    815 │ │ │ │ -00020c60: 3c2f 7370 616e 3e20 2020 203c 7370 616e static < │ │ │ │ -00020c90: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -00020ca0: 6f72 6422 3e69 6e6c 696e 653c 2f73 7061 ord">inline voi │ │ │ │ -00020cd0: 643c 2f73 7061 6e3e 203c 6120 636c 6173 d multAs │ │ │ │ -00020d30: 7369 676e 5472 616e 7370 6f73 6564 3c2f signTransposed( const< │ │ │ │ -00020d60: 2f73 7061 6e3e 203c 6120 636c 6173 733d /span> FieldMatrix&l │ │ │ │ -00020da0: 743b 4b2c 726f 7773 2c63 6f6c 7326 6774 t;K,rows,cols> │ │ │ │ -00020db0: 3b3c 2f61 3e20 2661 6d70 3b6d 6174 7269 ; &matri │ │ │ │ -00020dc0: 782c 203c 7370 616e 2063 6c61 7373 3d22 x, const FieldVector< │ │ │ │ -00020e20: 3b4b 2c72 6f77 7326 6774 3b3c 2f61 3e20 ;K,rows> │ │ │ │ -00020e30: 2661 6d70 3b20 782c 203c 6120 636c 6173 & x, FieldVector │ │ │ │ -00020e70: 266c 743b 4b2c 636f 6c73 2667 743b 3c2f <K,cols> & ret).
    81 │ │ │ │ -00020ee0: 363c 2f73 7061 6e3e 2020 2020 7b3c 2f64 6 {.
    81 │ │ │ │ -00020f40: 373c 2f73 7061 6e3e 2020 2020 2020 3c73 7 typedef typenam │ │ │ │ -00020f90: 653c 2f73 7061 6e3e 203c 6120 636c 6173 e FieldMa │ │ │ │ -00020ff0: 7472 6978 266c 743b 4b2c 726f 7773 2c63 trix<K,rows,c │ │ │ │ -00021000: 6f6c 7326 6774 3b3a 3a73 697a 655f 7479 ols>::size_ty │ │ │ │ -00021010: 7065 3c2f 613e 2073 697a 655f 7479 7065 pe size_type │ │ │ │ -00021020: 3b3c 2f64 6976 3e0a 3c64 6976 2063 6c61 ;
    .
    │ │ │ │ -00021070: 2020 3831 383c 2f73 7061 6e3e 203c 2f64 818 .
    81 │ │ │ │ -000210d0: 393c 2f73 7061 6e3e 2020 2020 2020 3c73 9 for(size_type i=0 │ │ │ │ -00021110: 3b20 6926 6c74 3b63 6f6c 733b 202b 2b69 ; i<cols; ++i │ │ │ │ -00021120: 293c 2f64 6976 3e0a 3c64 6976 2063 6c61 )
    .
    │ │ │ │ -00021170: 2020 3832 303c 2f73 7061 6e3e 2020 2020 820 │ │ │ │ -00021180: 2020 7b3c 2f64 6976 3e0a 3c64 6976 2063 {
    .
    821 │ │ │ │ -000211e0: 2020 2020 2020 7265 745b 695d 203d 2030 ret[i] = 0 │ │ │ │ -000211f0: 2e30 3b3c 2f64 6976 3e0a 3c64 6976 2063 .0;
    .
    822 │ │ │ │ -00021250: 2020 2020 2020 3c73 7061 6e20 636c 6173 │ │ │ │ -00021270: 666f 723c 2f73 7061 6e3e 2873 697a 655f for(size_ │ │ │ │ -00021280: 7479 7065 206a 3d30 3b20 6a26 6c74 3b72 type j=0; j<r │ │ │ │ -00021290: 6f77 733b 202b 2b6a 293c 2f64 6976 3e0a ows; ++j)
    . │ │ │ │ -000212a0: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    │ │ │ │ -00021320: 0a3c 6469 7620 636c 6173 733d 226c 696e .
    │ │ │ │ -00021350: 3c2f 613e 3c73 7061 6e20 636c 6173 733d 824 }.
    825 │ │ │ │ -000213d0: 3c2f 7370 616e 3e20 2020 207d 3c2f 6469 }.
    .
    826 < │ │ │ │ -00021440: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -00021490: 3832 383c 2f73 7061 6e3e 2020 2020 3c73 828 template <ty │ │ │ │ -000214e0: 7065 6e61 6d65 3c2f 7370 616e 3e20 4b2c pename K, │ │ │ │ -000214f0: 203c 7370 616e 2063 6c61 7373 3d22 6b65 int rows, int │ │ │ │ -00021540: 2063 6f6c 7326 6774 3b3c 2f64 6976 3e0a cols>
    . │ │ │ │ -00021550: 3c64 6976 2063 6c61 7373 3d22 666f 6c64
    .
    829 sta │ │ │ │ -00021650: 7469 633c 2f73 7061 6e3e 203c 7370 616e tic inline < │ │ │ │ -00021680: 6120 636c 6173 733d 2263 6f64 6520 686c a class="code hl │ │ │ │ -00021690: 5f63 6c61 7373 2220 6872 6566 3d22 6130 _class" href="a0 │ │ │ │ -000216a0: 3134 3132 2e68 746d 6c22 3e46 6965 6c64 1412.html">Field │ │ │ │ -000216b0: 5665 6374 6f72 266c 743b 4b2c 726f 7773 Vector<K,rows │ │ │ │ -000216c0: 2667 743b 3c2f 613e 203c 6120 636c 6173 > mult(const FieldMatrix< │ │ │ │ -00021780: 3b4b 2c72 6f77 732c 636f 6c73 2667 743b ;K,rows,cols> │ │ │ │ -00021790: 3c2f 613e 2026 616d 703b 6d61 7472 6978 &matrix │ │ │ │ -000217a0: 2c20 3c73 7061 6e20 636c 6173 733d 226b , const FieldVector< │ │ │ │ -00021800: 4b2c 636f 6c73 2667 743b 3c2f 613e 2026 K,cols> & │ │ │ │ -00021810: 616d 703b 2078 293c 2f64 6976 3e0a 3c64 amp; x)
    . │ │ │ │ -00021830: 3c61 2069 643d 226c 3030 3833 3022 206e 830 {
    . │ │ │ │ -00021890: 3c61 2069 643d 226c 3030 3833 3122 206e 831 FieldVector& │ │ │ │ -00021910: 6c74 3b4b 2c72 6f77 7326 6774 3b3c 2f61 lt;K,rows> ret;
    .< │ │ │ │ -00021940: 6120 6964 3d22 6c30 3038 3332 2220 6e61 a id="l00832" na │ │ │ │ -00021950: 6d65 3d22 6c30 3038 3332 223e 3c2f 613e me="l00832"> │ │ │ │ -00021960: 3c73 7061 6e20 636c 6173 733d 226c 696e 832 multAssig │ │ │ │ -00021990: 6e28 6d61 7472 6978 2c78 2c72 6574 293b n(matrix,x,ret); │ │ │ │ -000219a0: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -000219f0: 2038 3333 3c2f 7370 616e 3e20 2020 2020 833 │ │ │ │ -00021a00: 203c 7370 616e 2063 6c61 7373 3d22 6b65 retur │ │ │ │ -00021a20: 6e3c 2f73 7061 6e3e 2072 6574 3b3c 2f64 n ret;.
    83 │ │ │ │ -00021a80: 343c 2f73 7061 6e3e 2020 2020 7d3c 2f64 4 }.
    .
    835 │ │ │ │ -00021af0: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    │ │ │ │ -00021b40: 2038 3337 3c2f 7370 616e 3e20 2020 203c 837 < │ │ │ │ -00021b50: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -00021b60: 6f72 6422 3e74 656d 706c 6174 653c 2f73 ord">template <t │ │ │ │ -00021b90: 7970 656e 616d 653c 2f73 7061 6e3e 204b ypename K │ │ │ │ -00021ba0: 2c20 3c73 7061 6e20 636c 6173 733d 226b , int< │ │ │ │ -00021bc0: 2f73 7061 6e3e 2072 6f77 732c 203c 7370 /span> rows, int cols>
    │ │ │ │ -00021c00: 0a3c 6469 7620 636c 6173 733d 2266 6f6c .
    .
    < │ │ │ │ -00021c90: 6120 636c 6173 733d 226c 696e 6522 2068 a class="line" h │ │ │ │ -00021ca0: 7265 663d 2261 3030 3433 362e 6874 6d6c ref="a00436.html │ │ │ │ -00021cb0: 2361 3635 3937 3633 6262 6564 3437 6439 #a659763bbed47d9 │ │ │ │ -00021cc0: 3362 3061 3033 6439 6463 3264 3439 6336 3b0a03d9dc2d49c6 │ │ │ │ -00021cd0: 6630 223e 2020 3833 383c 2f61 3e3c 2f73 f0"> 838 st │ │ │ │ -00021d00: 6174 6963 3c2f 7370 616e 3e20 3c73 7061 atic inline │ │ │ │ -00021d30: 3c61 2063 6c61 7373 3d22 636f 6465 2068 Fiel │ │ │ │ -00021d60: 6456 6563 746f 7226 6c74 3b4b 2c63 6f6c dVector<K,col │ │ │ │ -00021d70: 7326 6774 3b3c 2f61 3e20 3c61 2063 6c61 s> multT │ │ │ │ -00021dd0: 7261 6e73 706f 7365 643c 2f61 3e28 3c73 ransposed(const │ │ │ │ -00021e00: 203c 6120 636c 6173 733d 2263 6f64 6520 Fie │ │ │ │ -00021e30: 6c64 4d61 7472 6978 266c 743b 4b2c 726f ldMatrix<K,ro │ │ │ │ -00021e40: 7773 2c63 6f6c 7326 6774 3b3c 2f61 3e20 ws,cols> │ │ │ │ -00021e50: 2661 6d70 3b6d 6174 7269 782c 203c 7370 &matrix, const │ │ │ │ -00021e80: 3c61 2063 6c61 7373 3d22 636f 6465 2068 Fiel │ │ │ │ -00021eb0: 6456 6563 746f 7226 6c74 3b4b 2c72 6f77 dVector<K,row │ │ │ │ -00021ec0: 7326 6774 3b3c 2f61 3e20 2661 6d70 3b20 s> & │ │ │ │ -00021ed0: 7829 3c2f 6469 763e 0a3c 6469 7620 636c x)
    .
    839 │ │ │ │ -00021f30: 207b 3c2f 6469 763e 0a3c 6469 7620 636c {
    .
    840 │ │ │ │ -00021f90: 2020 203c 6120 636c 6173 733d 2263 6f64 F │ │ │ │ -00021fc0: 6965 6c64 5665 6374 6f72 266c 743b 4b2c ieldVector<K, │ │ │ │ -00021fd0: 636f 6c73 2667 743b 3c2f 613e 2072 6574 cols> ret │ │ │ │ -00021fe0: 3b3c 2f64 6976 3e0a 3c64 6976 2063 6c61 ;
    .
    │ │ │ │ -00022030: 2020 3834 313c 2f73 7061 6e3e 2020 2020 841 │ │ │ │ -00022040: 2020 3c61 2063 6c61 7373 3d22 636f 6465 multAssignTra │ │ │ │ -000220a0: 6e73 706f 7365 643c 2f61 3e28 206d 6174 nsposed( mat │ │ │ │ -000220b0: 7269 782c 2078 2c20 7265 7420 293b 3c2f rix, x, ret );.
    8 │ │ │ │ -00022110: 3432 3c2f 7370 616e 3e20 2020 2020 203c 42 < │ │ │ │ -00022120: 7370 616e 2063 6c61 7373 3d22 6b65 7977 span class="keyw │ │ │ │ -00022130: 6f72 6466 6c6f 7722 3e72 6574 7572 6e3c ordflow">return< │ │ │ │ -00022140: 2f73 7061 6e3e 2072 6574 3b3c 2f64 6976 /span> ret;
    .
    843< │ │ │ │ -000221a0: 2f73 7061 6e3e 2020 2020 7d3c 2f64 6976 /span> }
    .
    .
    844 .
    8 │ │ │ │ -00022260: 3435 3c2f 7370 616e 3e20 207d 203c 7370 45 } // end namesp │ │ │ │ -00022290: 6163 6520 464d 6174 7269 7848 656c 703c ace FMatrixHelp< │ │ │ │ -000222a0: 2f73 7061 6e3e 3c2f 6469 763e 0a3c 2f64 /span>
    ..
    84 │ │ │ │ -00022300: 363c 2f73 7061 6e3e 203c 2f64 6976 3e0a 6
    . │ │ │ │ -00022310: 3c64 6976 2063 6c61 7373 3d22 6c69 6e65
    .
    850 < │ │ │ │ -000223f0: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    │ │ │ │ -00022440: 3835 313c 2f73 7061 6e3e 3c73 7061 6e20 851#include &q │ │ │ │ -00022470: 756f 743b 3c61 2063 6c61 7373 3d22 636f uot;fmatrixev │ │ │ │ -000224a0: 2e68 683c 2f61 3e26 7175 6f74 3b3c 2f73 .hh"
    .
    852< │ │ │ │ -00022510: 7370 616e 2063 6c61 7373 3d22 7072 6570 span class="prep │ │ │ │ -00022520: 726f 6365 7373 6f72 223e 2365 6e64 6966 rocessor">#endif │ │ │ │ -00022530: 3c2f 7370 616e 3e3c 2f64 6976 3e0a 3c64
    .
    Comput │ │ │ │ -000225c0: 6520 7479 7065 206f 6620 7468 6520 7265 e type of the re │ │ │ │ -000225d0: 7375 6c74 206f 6620 616e 2061 7269 7468 sult of an arith │ │ │ │ -000225e0: 6d65 7469 6320 6f70 6572 6174 696f 6e20 metic operation │ │ │ │ -000225f0: 696e 766f 6c76 696e 6720 7477 6f20 6469 involving two di │ │ │ │ -00022600: 6666 6572 656e 7420 6e75 6d62 6572 2074 fferent number t │ │ │ │ -00022610: 7970 6573 2e3c 2f64 6976 3e3c 2f64 6976 ypes.
    .
    t │ │ │ │ -00022670: 7970 6574 7261 6974 732e 6868 3c2f 613e ypetraits.hh │ │ │ │ -00022680: 3c2f 6469 763e 3c64 6976 2063 6c61 7373
    Traits │ │ │ │ -000226a0: 666f 7220 7479 7065 2063 6f6e 7665 7273 for type convers │ │ │ │ -000226b0: 696f 6e73 2061 6e64 2074 7970 6520 696e ions and type in │ │ │ │ -000226c0: 666f 726d 6174 696f 6e2e 3c2f 6469 763e formation.
    │ │ │ │ -000226d0: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    A │ │ │ │ -00022750: 6665 7720 636f 6d6d 6f6e 2065 7863 6570 few common excep │ │ │ │ -00022760: 7469 6f6e 2063 6c61 7373 6573 2e3c 2f64 tion classes.
    . │ │ │ │ -000227f0: 5661 7269 6f75 7320 7072 6563 6973 696f Various precisio │ │ │ │ -00022800: 6e20 7365 7474 696e 6773 2066 6f72 2063 n settings for c │ │ │ │ -00022810: 616c 6375 6c61 7469 6f6e 7320 7769 7468 alculations with │ │ │ │ -00022820: 2046 6965 6c64 4d61 7472 6978 2061 6e64 FieldMatrix and │ │ │ │ -00022830: 2046 6965 6c64 5665 6374 6f72 2e3c 2f64 FieldVector.
    .< │ │ │ │ -000228b0: 6469 7620 636c 6173 733d 2274 7464 6f63 div class="ttdoc │ │ │ │ -000228c0: 223e 496d 706c 656d 656e 7473 2061 206d ">Implements a m │ │ │ │ -000228d0: 6174 7269 7820 636f 6e73 7472 7563 7465 atrix constructe │ │ │ │ -000228e0: 6420 6672 6f6d 2061 2067 6976 656e 2074 d from a given t │ │ │ │ -000228f0: 7970 6520 7265 7072 6573 656e 7469 6e67 ype representing │ │ │ │ -00022900: 2061 2066 6965 6c64 2061 6e64 2061 2063 a field and a c │ │ │ │ -00022910: 6f6d 7069 6c65 2d74 696d 6520 6769 7665 ompile-time give │ │ │ │ -00022920: 6e20 6e75 6d62 652e 2e2e 3c2f 6469 763e n numbe...
    │ │ │ │ -00022930: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .. │ │ │ │ -00022a40: 3c64 6976 2063 6c61 7373 3d22 7474 6e61
    matrix │ │ │ │ -00022a70: 636f 6e63 6570 7473 2e68 683c 2f61 3e3c concepts.hh< │ │ │ │ -00022a80: 2f64 6976 3e3c 2f64 6976 3e0a 3c64 6976 /div>
    .
    < │ │ │ │ -00022ab0: 6469 7620 636c 6173 733d 2274 746e 616d div class="ttnam │ │ │ │ -00022ac0: 6522 3e3c 6120 6872 6566 3d22 6130 3032 e">boundsc │ │ │ │ -00022ae0: 6865 636b 696e 672e 6868 3c2f 613e 3c2f hecking.hh
    Macro for │ │ │ │ -00022b10: 2077 7261 7070 696e 6720 626f 756e 6461 wrapping bounda │ │ │ │ -00022b20: 7279 2063 6865 636b 732e 3c2f 6469 763e ry checks.
    │ │ │ │ -00022b30: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    Eig │ │ │ │ -00022bb0: 656e 7661 6c75 6520 636f 6d70 7574 6174 envalue computat │ │ │ │ -00022bc0: 696f 6e73 2066 6f72 2074 6865 2046 6965 ions for the Fie │ │ │ │ -00022bd0: 6c64 4d61 7472 6978 2063 6c61 7373 2e3c ldMatrix class.< │ │ │ │ -00022be0: 2f64 6976 3e3c 2f64 6976 3e0a 3c64 6976 /div>
    .
    # │ │ │ │ -00022cb0: 6465 6669 6e65 2044 554e 455f 4153 5345 define DUNE_ASSE │ │ │ │ -00022cc0: 5254 5f42 4f55 4e44 5328 636f 6e64 293c RT_BOUNDS(cond)< │ │ │ │ -00022cd0: 2f64 6976 3e3c 6469 7620 636c 6173 733d /div>
    If DUNE_ │ │ │ │ -00022cf0: 4348 4543 4b5f 424f 554e 4453 2069 7320 CHECK_BOUNDS is │ │ │ │ -00022d00: 6465 6669 6e65 643a 2063 6865 636b 2069 defined: check i │ │ │ │ -00022d10: 6620 636f 6e64 6974 696f 6e20 636f 6e64 f condition cond │ │ │ │ -00022d20: 2068 6f6c 6473 3b20 6f74 6865 7277 6973 holds; otherwis │ │ │ │ -00022d30: 652c 2064 6f20 6e6f 7468 696e 672e 3c2f e, do nothing.
    Defini │ │ │ │ -00022d60: 7469 6f6e 3c2f 623e 2062 6f75 6e64 7363 tion boundsc │ │ │ │ -00022d70: 6865 636b 696e 672e 6868 3a33 303c 2f64 hecking.hh:30
    .
    │ │ │ │ -00022dd0: 3c64 6976 2063 6c61 7373 3d22 7474 6e61 std::ostream &a │ │ │ │ -00022e60: 6d70 3b20 6f70 6572 6174 6f72 266c 743b mp; operator< │ │ │ │ -00022e70: 266c 743b 2873 7464 3a3a 6f73 7472 6561 <(std::ostrea │ │ │ │ -00022e80: 6d20 2661 6d70 3b73 2c20 636f 6e73 7420 m &s, const │ │ │ │ -00022e90: 6269 6775 6e73 6967 6e65 6469 6e74 266c bigunsignedint&l │ │ │ │ -00022ea0: 743b 206b 2026 6774 3b20 2661 6d70 3b78 t; k > &x │ │ │ │ -00022eb0: 293c 2f64 6976 3e3c 6469 7620 636c 6173 )
    Def │ │ │ │ -00022ed0: 696e 6974 696f 6e3c 2f62 3e20 6269 6775 inition bigu │ │ │ │ -00022ee0: 6e73 6967 6e65 6469 6e74 2e68 683a 3237 nsignedint.hh:27 │ │ │ │ -00022ef0: 383c 2f64 6976 3e3c 2f64 6976 3e0a 3c64 8
    .typename Overlo │ │ │ │ -00022fd0: 6164 733a 3a53 6361 6c61 7254 7970 6526 ads::ScalarType& │ │ │ │ -00022fe0: 6c74 3b20 7374 643a 3a64 6563 6179 5f74 lt; std::decay_t │ │ │ │ -00022ff0: 266c 743b 2056 2026 6774 3b20 2667 743b < V > > │ │ │ │ -00023000: 3a3a 7479 7065 2053 6361 6c61 723c 2f64 ::type Scalar
    Element ty │ │ │ │ -00023030: 7065 206f 6620 736f 6d65 2053 494d 4420 pe of some SIMD │ │ │ │ -00023040: 7479 7065 2e3c 2f64 6976 3e3c 6469 7620 type.
    Definition │ │ │ │ -00023070: 7369 6d64 2f69 6e74 6572 6661 6365 2e68 simd/interface.h │ │ │ │ -00023080: 683a 3233 353c 2f64 6976 3e3c 2f64 6976 h:235
    .
    │ │ │ │ -00023100: 4475 6e65 206e 616d 6573 7061 6365 2e3c Dune namespace.< │ │ │ │ -00023110: 2f64 6976 3e3c 6469 7620 636c 6173 733d /div>
    Defin │ │ │ │ -00023130: 6974 696f 6e3c 2f62 3e20 616c 6967 6e65 ition aligne │ │ │ │ -00023140: 6461 6c6c 6f63 6174 6f72 2e68 683a 3133 dallocator.hh:13 │ │ │ │ -00023150: 3c2f 6469 763e 3c2f 6469 763e 0a3c 6469
    . │ │ │ │ -000232d0: 6361 6c63 756c 6174 6573 2072 6574 203d calculates ret = │ │ │ │ -000232e0: 206d 6174 7269 7820 2a20 783c 2f64 6976 matrix * x
    < │ │ │ │ -00023330: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    < │ │ │ │ -00023390: 6120 6872 6566 3d22 6130 3034 3336 2e68 a href="a00436.h │ │ │ │ -000233a0: 746d 6c23 6136 3539 3736 3362 6265 6434 tml#a659763bbed4 │ │ │ │ -000233b0: 3764 3933 6230 6130 3364 3964 6332 6434 7d93b0a03d9dc2d4 │ │ │ │ -000233c0: 3963 3666 3022 3e44 756e 653a 3a46 4d61 9c6f0">Dune::FMa │ │ │ │ -000233d0: 7472 6978 4865 6c70 3a3a 6d75 6c74 5472 trixHelp::multTr │ │ │ │ -000233e0: 616e 7370 6f73 6564 3c2f 613e 3c2f 6469 ansposed
    static Fie │ │ │ │ -00023410: 6c64 5665 6374 6f72 266c 743b 204b 2c20 ldVector< K, │ │ │ │ -00023420: 636f 6c73 2026 6774 3b20 6d75 6c74 5472 cols > multTr │ │ │ │ -00023430: 616e 7370 6f73 6564 2863 6f6e 7374 2046 ansposed(const F │ │ │ │ -00023440: 6965 6c64 4d61 7472 6978 266c 743b 204b ieldMatrix< K │ │ │ │ -00023450: 2c20 726f 7773 2c20 636f 6c73 2026 6774 , rows, cols > │ │ │ │ -00023460: 3b20 2661 6d70 3b6d 6174 7269 782c 2063 ; &matrix, c │ │ │ │ -00023470: 6f6e 7374 2046 6965 6c64 5665 6374 6f72 onst FieldVector │ │ │ │ -00023480: 266c 743b 204b 2c20 726f 7773 2026 6774 < K, rows > │ │ │ │ -00023490: 3b20 2661 6d70 3b78 293c 2f64 6976 3e3c ; &x)
    < │ │ │ │ -000234a0: 6469 7620 636c 6173 733d 2274 7464 6f63 div class="ttdoc │ │ │ │ -000234b0: 223e 6361 6c63 756c 6174 6573 2072 6574 ">calculates ret │ │ │ │ -000234c0: 203d 206d 6174 7269 785e 5420 2a20 783c = matrix^T * x< │ │ │ │ -000234d0: 2f64 6976 3e3c 6469 7620 636c 6173 733d /div>
    Defin │ │ │ │ -000234f0: 6974 696f 6e3c 2f62 3e20 666d 6174 7269 ition fmatri │ │ │ │ -00023500: 782e 6868 3a38 3338 3c2f 6469 763e 3c2f x.hh:838
    .
    static K invert │ │ │ │ -00023600: 4d61 7472 6978 5f72 6574 5472 616e 7370 Matrix_retTransp │ │ │ │ -00023610: 6f73 6564 2863 6f6e 7374 2046 6965 6c64 osed(const Field │ │ │ │ -00023620: 4d61 7472 6978 266c 743b 204b 2c20 312c Matrix< K, 1, │ │ │ │ -00023630: 2031 2026 6774 3b20 2661 6d70 3b6d 6174 1 > &mat │ │ │ │ -00023640: 7269 782c 2046 6965 6c64 4d61 7472 6978 rix, FieldMatrix │ │ │ │ -00023650: 266c 743b 204b 2c20 312c 2031 2026 6774 < K, 1, 1 > │ │ │ │ -00023660: 3b20 2661 6d70 3b69 6e76 6572 7365 293c ; &inverse)< │ │ │ │ -00023670: 2f64 6976 3e3c 6469 7620 636c 6173 733d /div>
    invert s │ │ │ │ -00023690: 6361 6c61 7220 7769 7468 6f75 7420 6368 calar without ch │ │ │ │ -000236a0: 616e 6769 6e67 2074 6865 206f 7269 6769 anging the origi │ │ │ │ -000236b0: 6e61 6c20 6d61 7472 6978 3c2f 6469 763e nal matrix
    │ │ │ │ -000236c0: 3c64 6976 2063 6c61 7373 3d22 7474 6465
    Definition │ │ │ │ -000236e0: 3c2f 623e 2066 6d61 7472 6978 2e68 683a fmatrix.hh: │ │ │ │ -000236f0: 3638 303c 2f64 6976 3e3c 2f64 6976 3e0a 680
    . │ │ │ │ -00023700: 3c64 6976 2063 6c61 7373 3d22 7474 6322
    stat │ │ │ │ -000237d0: 6963 2076 6f69 6420 6d75 6c74 4d61 7472 ic void multMatr │ │ │ │ -000237e0: 6978 2863 6f6e 7374 2046 6965 6c64 4d61 ix(const FieldMa │ │ │ │ -000237f0: 7472 6978 266c 743b 204b 2c20 6d2c 206e trix< K, m, n │ │ │ │ -00023800: 2026 6774 3b20 2661 6d70 3b41 2c20 636f > &A, co │ │ │ │ -00023810: 6e73 7420 4669 656c 644d 6174 7269 7826 nst FieldMatrix& │ │ │ │ -00023820: 6c74 3b20 4b2c 206e 2c20 7020 2667 743b lt; K, n, p > │ │ │ │ -00023830: 2026 616d 703b 422c 2046 6965 6c64 4d61 &B, FieldMa │ │ │ │ -00023840: 7472 6978 266c 743b 204b 2c20 6d2c 2070 trix< K, m, p │ │ │ │ -00023850: 2026 6774 3b20 2661 6d70 3b72 6574 293c > &ret)< │ │ │ │ -00023860: 2f64 6976 3e3c 6469 7620 636c 6173 733d /div>
    calculat │ │ │ │ -00023880: 6573 2072 6574 203d 2041 202a 2042 3c2f es ret = A * B
    Defini │ │ │ │ -000238b0: 7469 6f6e 3c2f 623e 2066 6d61 7472 6978 tion fmatrix │ │ │ │ -000238c0: 2e68 683a 3737 393c 2f64 6976 3e3c 2f64 .hh:779
    .
    static K inver │ │ │ │ -000239b0: 744d 6174 7269 7828 636f 6e73 7420 4669 tMatrix(const Fi │ │ │ │ -000239c0: 656c 644d 6174 7269 7826 6c74 3b20 4b2c eldMatrix< K, │ │ │ │ -000239d0: 2031 2c20 3120 2667 743b 2026 616d 703b 1, 1 > & │ │ │ │ -000239e0: 6d61 7472 6978 2c20 4669 656c 644d 6174 matrix, FieldMat │ │ │ │ -000239f0: 7269 7826 6c74 3b20 4b2c 2031 2c20 3120 rix< K, 1, 1 │ │ │ │ -00023a00: 2667 743b 2026 616d 703b 696e 7665 7273 > &invers │ │ │ │ -00023a10: 6529 3c2f 6469 763e 3c64 6976 2063 6c61 e)
    inver │ │ │ │ -00023a30: 7420 7363 616c 6172 2077 6974 686f 7574 t scalar without │ │ │ │ -00023a40: 2063 6861 6e67 696e 6720 7468 6520 6f72 changing the or │ │ │ │ -00023a50: 6967 696e 616c 206d 6174 7269 783c 2f64 iginal matrix
    Definit │ │ │ │ -00023a80: 696f 6e3c 2f62 3e20 666d 6174 7269 782e ion fmatrix. │ │ │ │ -00023a90: 6868 3a36 3731 3c2f 6469 763e 3c2f 6469 hh:671
    .
    Dune::FMatri │ │ │ │ -00023b40: 7848 656c 703a 3a6d 756c 743c 2f61 3e3c xHelp::mult< │ │ │ │ -00023b50: 2f64 6976 3e3c 6469 7620 636c 6173 733d /div>
    static │ │ │ │ -00023b70: 4669 656c 6456 6563 746f 7226 6c74 3b20 FieldVector< │ │ │ │ -00023b80: 4b2c 2072 6f77 7320 2667 743b 206d 756c K, rows > mul │ │ │ │ -00023b90: 7428 636f 6e73 7420 4669 656c 644d 6174 t(const FieldMat │ │ │ │ -00023ba0: 7269 7826 6c74 3b20 4b2c 2072 6f77 732c rix< K, rows, │ │ │ │ -00023bb0: 2063 6f6c 7320 2667 743b 2026 616d 703b cols > & │ │ │ │ -00023bc0: 6d61 7472 6978 2c20 636f 6e73 7420 4669 matrix, const Fi │ │ │ │ -00023bd0: 656c 6456 6563 746f 7226 6c74 3b20 4b2c eldVector< K, │ │ │ │ -00023be0: 2063 6f6c 7320 2667 743b 2026 616d 703b cols > & │ │ │ │ -00023bf0: 7829 3c2f 6469 763e 3c64 6976 2063 6c61 x)
    calcu │ │ │ │ -00023c10: 6c61 7465 7320 7265 7420 3d20 6d61 7472 lates ret = matr │ │ │ │ -00023c20: 6978 202a 2078 3c2f 6469 763e 3c64 6976 ix * x
    < │ │ │ │ -00023c40: 623e 4465 6669 6e69 7469 6f6e 3c2f 623e b>Definition │ │ │ │ -00023c50: 2066 6d61 7472 6978 2e68 683a 3832 393c fmatrix.hh:829< │ │ │ │ -00023c60: 2f64 6976 3e3c 2f64 6976 3e0a 3c64 6976 /div>
    .
    static void mu │ │ │ │ -00023d50: 6c74 5472 616e 7370 6f73 6564 4d61 7472 ltTransposedMatr │ │ │ │ -00023d60: 6978 2863 6f6e 7374 2046 6965 6c64 4d61 ix(const FieldMa │ │ │ │ -00023d70: 7472 6978 266c 743b 204b 2c20 726f 7773 trix< K, rows │ │ │ │ -00023d80: 2c20 636f 6c73 2026 6774 3b20 2661 6d70 , cols > & │ │ │ │ -00023d90: 3b6d 6174 7269 782c 2046 6965 6c64 4d61 ;matrix, FieldMa │ │ │ │ -00023da0: 7472 6978 266c 743b 204b 2c20 636f 6c73 trix< K, cols │ │ │ │ -00023db0: 2c20 636f 6c73 2026 6774 3b20 2661 6d70 , cols > & │ │ │ │ -00023dc0: 3b72 6574 293c 2f64 6976 3e3c 6469 7620 ;ret)
    ca │ │ │ │ -00023de0: 6c63 756c 6174 6573 2072 6574 3d20 415f lculates ret= A_ │ │ │ │ -00023df0: 742a 413c 2f64 6976 3e3c 6469 7620 636c t*A
    D │ │ │ │ -00023e10: 6566 696e 6974 696f 6e3c 2f62 3e20 666d efinition fm │ │ │ │ -00023e20: 6174 7269 782e 6868 3a37 3938 3c2f 6469 atrix.hh:798
    .
    s │ │ │ │ -00023f10: 7461 7469 6320 766f 6964 206d 756c 7441 tatic void multA │ │ │ │ -00023f20: 7373 6967 6e54 7261 6e73 706f 7365 6428 ssignTransposed( │ │ │ │ -00023f30: 636f 6e73 7420 4669 656c 644d 6174 7269 const FieldMatri │ │ │ │ -00023f40: 7826 6c74 3b20 4b2c 2072 6f77 732c 2063 x< K, rows, c │ │ │ │ -00023f50: 6f6c 7320 2667 743b 2026 616d 703b 6d61 ols > &ma │ │ │ │ -00023f60: 7472 6978 2c20 636f 6e73 7420 4669 656c trix, const Fiel │ │ │ │ -00023f70: 6456 6563 746f 7226 6c74 3b20 4b2c 2072 dVector< K, r │ │ │ │ -00023f80: 6f77 7320 2667 743b 2026 616d 703b 782c ows > &x, │ │ │ │ -00023f90: 2046 6965 6c64 5665 6374 6f72 266c 743b FieldVector< │ │ │ │ -00023fa0: 204b 2c20 636f 6c73 2026 6774 3b20 2661 K, cols > &a │ │ │ │ -00023fb0: 6d70 3b72 6574 293c 2f64 6976 3e3c 6469 mp;ret)
    │ │ │ │ -00023fd0: 6361 6c63 756c 6174 6573 2072 6574 203d calculates ret = │ │ │ │ -00023fe0: 206d 6174 7269 785e 5420 2a20 783c 2f64 matrix^T * x
    Definit │ │ │ │ -00024010: 696f 6e3c 2f62 3e20 666d 6174 7269 782e ion fmatrix. │ │ │ │ -00024020: 6868 3a38 3135 3c2f 6469 763e 3c2f 6469 hh:815
    .
    A │ │ │ │ -000240b0: 6465 6e73 6520 6e20 7820 6d20 6d61 7472 dense n x m matr │ │ │ │ -000240c0: 6978 2e3c 2f64 6976 3e3c 6469 7620 636c ix.
    D │ │ │ │ -000240e0: 6566 696e 6974 696f 6e3c 2f62 3e20 6465 efinition de │ │ │ │ -000240f0: 6e73 656d 6174 7269 782e 6868 3a31 3430 nsematrix.hh:140 │ │ │ │ -00024100: 3c2f 6469 763e 3c2f 6469 763e 0a3c 6469
    .void mtv(const │ │ │ │ -000241e0: 2058 2026 616d 703b 782c 2059 2026 616d X &x, Y &am │ │ │ │ -000241f0: 703b 7929 2063 6f6e 7374 3c2f 6469 763e p;y) const
    │ │ │ │ -00024200: 3c64 6976 2063 6c61 7373 3d22 7474 646f
    y = A^T x
    Definiti │ │ │ │ -00024240: 6f6e 3c2f 623e 2064 656e 7365 6d61 7472 on densematr │ │ │ │ -00024250: 6978 2e68 683a 3338 373c 2f64 6976 3e3c ix.hh:387
    < │ │ │ │ -00024260: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    < │ │ │ │ -000242c0: 6120 6872 6566 3d22 6130 3134 3030 2e68 a href="a01400.h │ │ │ │ -000242d0: 746d 6c23 6135 6434 3339 3561 6563 3163 tml#a5d4395aec1c │ │ │ │ -000242e0: 6330 3538 3065 6439 3635 3165 3962 3030 c0580ed9651e9b00 │ │ │ │ -000242f0: 3433 3462 3722 3e44 756e 653a 3a44 656e 434b7">Dune::Den │ │ │ │ -00024300: 7365 4d61 7472 6978 266c 743b 2046 6965 seMatrix< Fie │ │ │ │ -00024310: 6c64 4d61 7472 6978 266c 743b 204b 2c20 ldMatrix< K, │ │ │ │ -00024320: 524f 5753 2c20 434f 4c53 2026 6774 3b20 ROWS, COLS > │ │ │ │ -00024330: 2667 743b 3a3a 4d3c 2f61 3e3c 2f64 6976 >::M
    constexpr s │ │ │ │ -00024360: 697a 655f 7479 7065 204d 2829 2063 6f6e ize_type M() con │ │ │ │ -00024370: 7374 3c2f 6469 763e 3c64 6976 2063 6c61 st
    numbe │ │ │ │ -00024390: 7220 6f66 2063 6f6c 756d 6e73 3c2f 6469 r of columns
    Definiti │ │ │ │ -000243c0: 6f6e 3c2f 623e 2064 656e 7365 6d61 7472 on densematr │ │ │ │ -000243d0: 6978 2e68 683a 3730 333c 2f64 6976 3e3c ix.hh:703
    < │ │ │ │ -000243e0: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    < │ │ │ │ -00024440: 6120 6872 6566 3d22 6130 3134 3030 2e68 a href="a01400.h │ │ │ │ -00024450: 746d 6c23 6136 3563 3861 6638 6538 6666 tml#a65c8af8e8ff │ │ │ │ -00024460: 3232 3135 3563 3238 3663 3961 3765 6230 22155c286c9a7eb0 │ │ │ │ -00024470: 3335 3438 3222 3e44 756e 653a 3a44 656e 35482">Dune::Den │ │ │ │ -00024480: 7365 4d61 7472 6978 266c 743b 2046 6965 seMatrix< Fie │ │ │ │ -00024490: 6c64 4d61 7472 6978 266c 743b 204b 2c20 ldMatrix< K, │ │ │ │ -000244a0: 524f 5753 2c20 434f 4c53 2026 6774 3b20 ROWS, COLS > │ │ │ │ -000244b0: 2667 743b 3a3a 7269 6768 746d 756c 7469 >::rightmulti │ │ │ │ -000244c0: 706c 793c 2f61 3e3c 2f64 6976 3e3c 6469 ply
    FieldMatrix< │ │ │ │ -000244f0: 204b 2c20 524f 5753 2c20 434f 4c53 2026 K, ROWS, COLS & │ │ │ │ -00024500: 6774 3b20 2661 6d70 3b20 7269 6768 746d gt; & rightm │ │ │ │ -00024510: 756c 7469 706c 7928 636f 6e73 7420 4465 ultiply(const De │ │ │ │ -00024520: 6e73 654d 6174 7269 7826 6c74 3b20 4d32 nseMatrix< M2 │ │ │ │ -00024530: 2026 6774 3b20 2661 6d70 3b4d 293c 2f64 > &M)
    Multiplies │ │ │ │ -00024560: 204d 2066 726f 6d20 7468 6520 7269 6768 M from the righ │ │ │ │ -00024570: 7420 746f 2074 6869 7320 6d61 7472 6978 t to this matrix │ │ │ │ -00024580: 2e3c 2f64 6976 3e3c 6469 7620 636c 6173 .
    Def │ │ │ │ -000245a0: 696e 6974 696f 6e3c 2f62 3e20 6465 6e73 inition dens │ │ │ │ -000245b0: 656d 6174 7269 782e 6868 3a36 3435 3c2f ematrix.hh:645
    .
    │ │ │ │ -00024610: 3c64 6976 2063 6c61 7373 3d22 7474 6e61 < │ │ │ │ -000246b0: 6469 7620 636c 6173 733d 2274 7464 6563 div class="ttdec │ │ │ │ -000246c0: 6922 3e64 6572 6976 6564 5f74 7970 6520 i">derived_type │ │ │ │ -000246d0: 2661 6d70 3b20 6f70 6572 6174 6f72 2f3d & operator/= │ │ │ │ -000246e0: 2863 6f6e 7374 2066 6965 6c64 5f74 7970 (const field_typ │ │ │ │ -000246f0: 6520 2661 6d70 3b6b 293c 2f64 6976 3e3c e &k)
    < │ │ │ │ -00024700: 6469 7620 636c 6173 733d 2274 7464 6f63 div class="ttdoc │ │ │ │ -00024710: 223e 7665 6374 6f72 2073 7061 6365 2064 ">vector space d │ │ │ │ -00024720: 6976 6973 696f 6e20 6279 2073 6361 6c61 ivision by scala │ │ │ │ -00024730: 723c 2f64 6976 3e3c 6469 7620 636c 6173 r
    Def │ │ │ │ -00024750: 696e 6974 696f 6e3c 2f62 3e20 6465 6e73 inition dens │ │ │ │ -00024760: 656d 6174 7269 782e 6868 3a33 3239 3c2f ematrix.hh:329
    .
    │ │ │ │ -000247c0: 3c64 6976 2063 6c61 7373 3d22 7474 6e61 < │ │ │ │ -00024860: 6469 7620 636c 6173 733d 2274 7464 6563 div class="ttdec │ │ │ │ -00024870: 6922 3e64 6572 6976 6564 5f74 7970 6520 i">derived_type │ │ │ │ -00024880: 2661 6d70 3b20 6f70 6572 6174 6f72 2a3d & operator*= │ │ │ │ -00024890: 2863 6f6e 7374 2066 6965 6c64 5f74 7970 (const field_typ │ │ │ │ -000248a0: 6520 2661 6d70 3b6b 293c 2f64 6976 3e3c e &k)
    < │ │ │ │ -000248b0: 6469 7620 636c 6173 733d 2274 7464 6f63 div class="ttdoc │ │ │ │ -000248c0: 223e 7665 6374 6f72 2073 7061 6365 206d ">vector space m │ │ │ │ -000248d0: 756c 7469 706c 6963 6174 696f 6e20 7769 ultiplication wi │ │ │ │ -000248e0: 7468 2073 6361 6c61 723c 2f64 6976 3e3c th scalar
    < │ │ │ │ -000248f0: 6469 7620 636c 6173 733d 2274 7464 6566 div class="ttdef │ │ │ │ -00024900: 223e 3c62 3e44 6566 696e 6974 696f 6e3c ">Definition< │ │ │ │ -00024910: 2f62 3e20 6465 6e73 656d 6174 7269 782e /b> densematrix. │ │ │ │ -00024920: 6868 3a33 3231 3c2f 6469 763e 3c2f 6469 hh:321
    .
    deriv │ │ │ │ -00024a30: 6564 5f74 7970 6520 2661 6d70 3b20 6f70 ed_type & op │ │ │ │ -00024a40: 6572 6174 6f72 2d3d 2863 6f6e 7374 2044 erator-=(const D │ │ │ │ -00024a50: 656e 7365 4d61 7472 6978 266c 743b 204f enseMatrix< O │ │ │ │ -00024a60: 7468 6572 2026 6774 3b20 2661 6d70 3b78 ther > &x │ │ │ │ -00024a70: 293c 2f64 6976 3e3c 6469 7620 636c 6173 )
    vector │ │ │ │ -00024a90: 2073 7061 6365 2073 7562 7472 6163 7469 space subtracti │ │ │ │ -00024aa0: 6f6e 3c2f 6469 763e 3c64 6976 2063 6c61 on
    De │ │ │ │ -00024ac0: 6669 6e69 7469 6f6e 3c2f 623e 2064 656e finition den │ │ │ │ -00024ad0: 7365 6d61 7472 6978 2e68 683a 3331 323c sematrix.hh:312< │ │ │ │ -00024ae0: 2f64 6976 3e3c 2f64 6976 3e0a 3c64 6976 /div>
    .
    │ │ │ │ -00024bd0: 3c64 6976 2063 6c61 7373 3d22 7474 6465
    static const │ │ │ │ -00024bf0: 6578 7072 2069 6e74 2062 6c6f 636b 6c65 expr int blockle │ │ │ │ -00024c00: 7665 6c3c 2f64 6976 3e3c 6469 7620 636c vel
    The │ │ │ │ -00024c20: 6e75 6d62 6572 206f 6620 626c 6f63 6b20 number of block │ │ │ │ -00024c30: 6c65 7665 6c73 2077 6520 636f 6e74 6169 levels we contai │ │ │ │ -00024c40: 6e2e 2054 6869 7320 6973 2074 6865 206c n. This is the l │ │ │ │ -00024c50: 6561 662c 2074 6861 7420 6973 2c20 312e eaf, that is, 1. │ │ │ │ -00024c60: 3c2f 6469 763e 3c64 6976 2063 6c61 7373
    Defi │ │ │ │ -00024c80: 6e69 7469 6f6e 3c2f 623e 2064 656e 7365 nition dense │ │ │ │ -00024c90: 6d61 7472 6978 2e68 683a 3137 383c 2f64 matrix.hh:178
    .
    │ │ │ │ -00024da0: 5472 6169 7473 3a3a 726f 775f 7479 7065 Traits::row_type │ │ │ │ -00024db0: 2072 6f77 5f74 7970 653c 2f64 6976 3e3c row_type
    < │ │ │ │ -00024dc0: 6469 7620 636c 6173 733d 2274 7464 6f63 div class="ttdoc │ │ │ │ -00024dd0: 223e 5468 6520 7479 7065 2075 7365 6420 ">The type used │ │ │ │ -00024de0: 746f 2072 6570 7265 7365 6e74 2061 2072 to represent a r │ │ │ │ -00024df0: 6f77 2028 6d75 7374 2066 756c 6669 6c6c ow (must fulfill │ │ │ │ -00024e00: 2074 6865 2044 756e 653a 3a44 656e 7365 the Dune::Dense │ │ │ │ -00024e10: 5665 6374 6f72 2069 6e74 6572 6661 6365 Vector interface │ │ │ │ -00024e20: 293c 2f64 6976 3e3c 6469 7620 636c 6173 )
    Def │ │ │ │ -00024e40: 696e 6974 696f 6e3c 2f62 3e20 6465 6e73 inition dens │ │ │ │ -00024e50: 656d 6174 7269 782e 6868 3a31 3639 3c2f ematrix.hh:169
    .
    │ │ │ │ -00024eb0: 3c64 6976 2063 6c61 7373 3d22 7474 6e61 Traits::size_t │ │ │ │ -00024f70: 7970 6520 7369 7a65 5f74 7970 653c 2f64 ype size_type
    The type u │ │ │ │ -00024fa0: 7365 6420 666f 7220 7468 6520 696e 6465 sed for the inde │ │ │ │ -00024fb0: 7820 6163 6365 7373 2061 6e64 2073 697a x access and siz │ │ │ │ -00024fc0: 6520 6f70 6572 6174 696f 6e2e 3c2f 6469 e operation.
    Definiti │ │ │ │ -00024ff0: 6f6e 3c2f 623e 2064 656e 7365 6d61 7472 on densematr │ │ │ │ -00025000: 6978 2e68 683a 3136 363c 2f64 6976 3e3c ix.hh:166
    < │ │ │ │ -00025010: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    < │ │ │ │ -00025070: 6120 6872 6566 3d22 6130 3134 3030 2e68 a href="a01400.h │ │ │ │ -00025080: 746d 6c23 6164 3839 3134 6266 3431 3434 tml#ad8914bf4144 │ │ │ │ -00025090: 3936 3765 3130 3931 6534 6530 3231 3565 967e1091e4e0215e │ │ │ │ -000250a0: 6665 3330 3522 3e44 756e 653a 3a44 656e fe305">Dune::Den │ │ │ │ -000250b0: 7365 4d61 7472 6978 266c 743b 2046 6965 seMatrix< Fie │ │ │ │ -000250c0: 6c64 4d61 7472 6978 266c 743b 204b 2c20 ldMatrix< K, │ │ │ │ -000250d0: 524f 5753 2c20 434f 4c53 2026 6774 3b20 ROWS, COLS > │ │ │ │ -000250e0: 2667 743b 3a3a 636f 6e73 745f 726f 775f >::const_row_ │ │ │ │ -000250f0: 7265 6665 7265 6e63 653c 2f61 3e3c 2f64 reference
    Traits::c │ │ │ │ -00025120: 6f6e 7374 5f72 6f77 5f72 6566 6572 656e onst_row_referen │ │ │ │ -00025130: 6365 2063 6f6e 7374 5f72 6f77 5f72 6566 ce const_row_ref │ │ │ │ -00025140: 6572 656e 6365 3c2f 6469 763e 3c64 6976 erence
    T │ │ │ │ -00025160: 6865 2074 7970 6520 7573 6564 2074 6f20 he type used to │ │ │ │ -00025170: 7265 7072 6573 656e 7420 6120 7265 6665 represent a refe │ │ │ │ -00025180: 7265 6e63 6520 746f 2061 2063 6f6e 7374 rence to a const │ │ │ │ -00025190: 616e 7420 726f 7720 2875 7375 616c 6c79 ant row (usually │ │ │ │ -000251a0: 2063 6f6e 7374 2072 6f77 5f74 7970 6520 const row_type │ │ │ │ -000251b0: 2661 6d70 3b29 3c2f 6469 763e 3c64 6976 &)
    < │ │ │ │ -000251d0: 623e 4465 6669 6e69 7469 6f6e 3c2f 623e b>Definition │ │ │ │ -000251e0: 2064 656e 7365 6d61 7472 6978 2e68 683a densematrix.hh: │ │ │ │ -000251f0: 3137 353c 2f64 6976 3e3c 2f64 6976 3e0a 175
    . │ │ │ │ -00025200: 3c64 6976 2063 6c61 7373 3d22 7474 6322
    Trait │ │ │ │ -00025300: 733a 3a72 6f77 5f72 6566 6572 656e 6365 s::row_reference │ │ │ │ -00025310: 2072 6f77 5f72 6566 6572 656e 6365 3c2f row_reference
    The type │ │ │ │ -00025340: 7573 6564 2074 6f20 7265 7072 6573 656e used to represen │ │ │ │ -00025350: 7420 6120 7265 6665 7265 6e63 6520 746f t a reference to │ │ │ │ -00025360: 2061 2072 6f77 2028 7573 7561 6c6c 7920 a row (usually │ │ │ │ -00025370: 726f 775f 7479 7065 2026 616d 703b 293c row_type &)< │ │ │ │ -00025380: 2f64 6976 3e3c 6469 7620 636c 6173 733d /div>
    Defin │ │ │ │ -000253a0: 6974 696f 6e3c 2f62 3e20 6465 6e73 656d ition densem │ │ │ │ -000253b0: 6174 7269 782e 6868 3a31 3732 3c2f 6469 atrix.hh:172
    .derived_type &a │ │ │ │ -000254d0: 6d70 3b20 6f70 6572 6174 6f72 2b3d 2863 mp; operator+=(c │ │ │ │ -000254e0: 6f6e 7374 2044 656e 7365 4d61 7472 6978 onst DenseMatrix │ │ │ │ -000254f0: 266c 743b 204f 7468 6572 2026 6774 3b20 < Other > │ │ │ │ -00025500: 2661 6d70 3b78 293c 2f64 6976 3e3c 6469 &x)
    │ │ │ │ -00025520: 7665 6374 6f72 2073 7061 6365 2061 6464 vector space add │ │ │ │ -00025530: 6974 696f 6e3c 2f64 6976 3e3c 6469 7620 ition
    Definition │ │ │ │ -00025560: 6465 6e73 656d 6174 7269 782e 6868 3a32 densematrix.hh:2 │ │ │ │ -00025570: 3839 3c2f 6469 763e 3c2f 6469 763e 0a3c 89
    .< │ │ │ │ -00025580: 6469 7620 636c 6173 733d 2274 7463 2220 div class="ttc" │ │ │ │ -00025590: 6964 3d22 6161 3031 3430 385f 6874 6d6c id="aa01408_html │ │ │ │ -000255a0: 223e 3c64 6976 2063 6c61 7373 3d22 7474 ">
    A dens │ │ │ │ -00025600: 6520 6e20 7820 6d20 6d61 7472 6978 2e3c e n x m matrix.< │ │ │ │ -00025610: 2f64 6976 3e3c 6469 7620 636c 6173 733d /div>
    Defin │ │ │ │ -00025630: 6974 696f 6e3c 2f62 3e20 666d 6174 7269 ition fmatri │ │ │ │ -00025640: 782e 6868 3a31 3137 3c2f 6469 763e 3c2f x.hh:117
    .
    s │ │ │ │ -00025720: 7461 7469 6320 636f 6e73 7465 7870 7220 tatic constexpr │ │ │ │ -00025730: 7369 7a65 5f74 7970 6520 6d61 745f 636f size_type mat_co │ │ │ │ -00025740: 6c73 2829 3c2f 6469 763e 3c64 6976 2063 ls()
    │ │ │ │ -00025760: 4465 6669 6e69 7469 6f6e 3c2f 623e 2066 Definition f │ │ │ │ -00025770: 6d61 7472 6978 2e68 683a 3336 373c 2f64 matrix.hh:367
    .
    < │ │ │ │ -000257d0: 6469 7620 636c 6173 733d 2274 746e 616d div class="ttnam │ │ │ │ -000257e0: 6522 3e3c 6120 6872 6566 3d22 6130 3134 e">Dune: │ │ │ │ -00025820: 3a46 6965 6c64 4d61 7472 6978 3a3a 4669 :FieldMatrix::Fi │ │ │ │ -00025830: 656c 644d 6174 7269 783c 2f61 3e3c 2f64 eldMatrix
    constexpr │ │ │ │ -00025860: 2046 6965 6c64 4d61 7472 6978 2829 3d64 FieldMatrix()=d │ │ │ │ -00025870: 6566 6175 6c74 3c2f 6469 763e 3c64 6976 efault
    D │ │ │ │ -00025890: 6566 6175 6c74 2063 6f6e 7374 7275 6374 efault construct │ │ │ │ -000258a0: 6f72 2e3c 2f64 6976 3e3c 2f64 6976 3e0a or.
    . │ │ │ │ -000258b0: 3c64 6976 2063 6c61 7373 3d22 7474 6322
    Base::const │ │ │ │ -00025990: 5f72 6f77 5f72 6566 6572 656e 6365 2063 _row_reference c │ │ │ │ -000259a0: 6f6e 7374 5f72 6f77 5f72 6566 6572 656e onst_row_referen │ │ │ │ -000259b0: 6365 3c2f 6469 763e 3c64 6976 2063 6c61 ce
    De │ │ │ │ -000259d0: 6669 6e69 7469 6f6e 3c2f 623e 2066 6d61 finition fma │ │ │ │ -000259e0: 7472 6978 2e68 683a 3133 313c 2f64 6976 trix.hh:131
    .< │ │ │ │ -00025ab0: 6469 7620 636c 6173 733d 2274 7464 6563 div class="ttdec │ │ │ │ -00025ac0: 6922 3e46 6965 6c64 4d61 7472 6978 2026 i">FieldMatrix & │ │ │ │ -00025ad0: 616d 703b 206f 7065 7261 746f 723d 2863 amp; operator=(c │ │ │ │ -00025ae0: 6f6e 7374 2046 6965 6c64 4d61 7472 6978 onst FieldMatrix │ │ │ │ -00025af0: 266c 743b 2054 2c20 524f 5753 2c20 434f < T, ROWS, CO │ │ │ │ -00025b00: 4c53 2026 6774 3b20 2661 6d70 3b78 293c LS > &x)< │ │ │ │ -00025b10: 2f64 6976 3e3c 6469 7620 636c 6173 733d /div>
    copy ass │ │ │ │ -00025b30: 6967 6e6d 656e 7420 6672 6f6d 2046 6965 ignment from Fie │ │ │ │ -00025b40: 6c64 4d61 7472 6978 206f 7665 7220 6120 ldMatrix over a │ │ │ │ -00025b50: 6469 6666 6572 656e 7420 6669 656c 643c different field< │ │ │ │ -00025b60: 2f64 6976 3e3c 6469 7620 636c 6173 733d /div>
    Defin │ │ │ │ -00025b80: 6974 696f 6e3c 2f62 3e20 666d 6174 7269 ition fmatri │ │ │ │ -00025b90: 782e 6868 3a31 3631 3c2f 6469 763e 3c2f x.hh:161
    .
    Dune::Fiel │ │ │ │ -00025c40: 644d 6174 7269 783a 3a72 6967 6874 6d75 dMatrix::rightmu │ │ │ │ -00025c50: 6c74 6970 6c79 616e 793c 2f61 3e3c 2f64 ltiplyany
    FieldMatr │ │ │ │ -00025c80: 6978 266c 743b 204b 2c20 726f 7773 2c20 ix< K, rows, │ │ │ │ -00025c90: 6c20 2667 743b 2072 6967 6874 6d75 6c74 l > rightmult │ │ │ │ -00025ca0: 6970 6c79 616e 7928 636f 6e73 7420 4669 iplyany(const Fi │ │ │ │ -00025cb0: 656c 644d 6174 7269 7826 6c74 3b20 4b2c eldMatrix< K, │ │ │ │ -00025cc0: 2063 6f6c 732c 206c 2026 6774 3b20 2661 cols, l > &a │ │ │ │ -00025cd0: 6d70 3b4d 2920 636f 6e73 743c 2f64 6976 mp;M) const
    Multiplies M │ │ │ │ -00025d00: 2066 726f 6d20 7468 6520 7269 6768 7420 from the right │ │ │ │ -00025d10: 746f 2074 6869 7320 6d61 7472 6978 2c20 to this matrix, │ │ │ │ -00025d20: 7468 6973 206d 6174 7269 7820 6973 206e this matrix is n │ │ │ │ -00025d30: 6f74 206d 6f64 6966 6965 642e 3c2f 6469 ot modified.
    Definiti │ │ │ │ -00025d60: 6f6e 3c2f 623e 2066 6d61 7472 6978 2e68 on fmatrix.h │ │ │ │ -00025d70: 683a 3335 313c 2f64 6976 3e3c 2f64 6976 h:351
    .
    . │ │ │ │ -00025f60: 3c64 6976 2063 6c61 7373 3d22 7474 6465
    Base::size_t │ │ │ │ -00025f80: 7970 6520 7369 7a65 5f74 7970 653c 2f64 ype size_type
    Definit │ │ │ │ -00025fb0: 696f 6e3c 2f62 3e20 666d 6174 7269 782e ion fmatrix. │ │ │ │ -00025fc0: 6868 3a31 3237 3c2f 6469 763e 3c2f 6469 hh:127
    .
    │ │ │ │ -00026090: 3c64 6976 2063 6c61 7373 3d22 7474 6465
    FieldMatrix& │ │ │ │ -000260b0: 6c74 3b20 4b2c 206c 2c20 636f 6c73 2026 lt; K, l, cols & │ │ │ │ -000260c0: 6774 3b20 6c65 6674 6d75 6c74 6970 6c79 gt; leftmultiply │ │ │ │ -000260d0: 616e 7928 636f 6e73 7420 4669 656c 644d any(const FieldM │ │ │ │ -000260e0: 6174 7269 7826 6c74 3b20 4b2c 206c 2c20 atrix< K, l, │ │ │ │ -000260f0: 726f 7773 2026 6774 3b20 2661 6d70 3b4d rows > &M │ │ │ │ -00026100: 2920 636f 6e73 743c 2f64 6976 3e3c 6469 ) const
    │ │ │ │ -00026120: 4d75 6c74 6970 6c69 6573 204d 2066 726f Multiplies M fro │ │ │ │ -00026130: 6d20 7468 6520 6c65 6674 2074 6f20 7468 m the left to th │ │ │ │ -00026140: 6973 206d 6174 7269 782c 2074 6869 7320 is matrix, this │ │ │ │ -00026150: 6d61 7472 6978 2069 7320 6e6f 7420 6d6f matrix is not mo │ │ │ │ -00026160: 6469 6669 6564 2e3c 2f64 6976 3e3c 6469 dified.
    │ │ │ │ -00026180: 3c62 3e44 6566 696e 6974 696f 6e3c 2f62 Definition fmatrix.hh:316 │ │ │ │ -000261a0: 3c2f 6469 763e 3c2f 6469 763e 0a3c 6469
    . │ │ │ │ -00026310: 3c64 6976 2063 6c61 7373 3d22 7474 6465
    Definition │ │ │ │ -00026330: 3c2f 623e 2066 6d61 7472 6978 2e68 683a fmatrix.hh: │ │ │ │ -00026340: 3333 343c 2f64 6976 3e3c 2f64 6976 3e0a 334
    . │ │ │ │ -00026350: 3c64 6976 2063 6c61 7373 3d22 7474 6322 . │ │ │ │ -00026480: 3c64 6976 2063 6c61 7373 3d22 7474 6322
    frien │ │ │ │ -00026550: 6420 6175 746f 206f 7065 7261 746f 722a d auto operator* │ │ │ │ -00026560: 2863 6f6e 7374 2046 6965 6c64 4d61 7472 (const FieldMatr │ │ │ │ -00026570: 6978 2026 616d 703b 6d61 7472 6978 2c20 ix &matrix, │ │ │ │ -00026580: 5363 616c 6172 2073 6361 6c61 7229 3c2f Scalar scalar)
    vector sp │ │ │ │ -000265b0: 6163 6520 6d75 6c74 6970 6c69 6361 7469 ace multiplicati │ │ │ │ -000265c0: 6f6e 2077 6974 6820 7363 616c 6172 3c2f on with scalar
    Defini │ │ │ │ -000265f0: 7469 6f6e 3c2f 623e 2066 6d61 7472 6978 tion fmatrix │ │ │ │ -00026600: 2e68 683a 3231 323c 2f64 6976 3e3c 2f64 .hh:212
    .
    F │ │ │ │ -000266e0: 6965 6c64 4d61 7472 6978 2026 616d 703b ieldMatrix & │ │ │ │ -000266f0: 206f 7065 7261 746f 723d 2846 6965 6c64 operator=(Field │ │ │ │ -00026700: 4d61 7472 6978 266c 743b 2054 2c20 726f Matrix< T, ro │ │ │ │ -00026710: 7773 2c20 636f 6c73 2026 6774 3b20 636f ws, cols > co │ │ │ │ -00026720: 6e73 7420 2661 6d70 3b29 3d64 656c 6574 nst &)=delet │ │ │ │ -00026730: 653c 2f64 6976 3e3c 6469 7620 636c 6173 e
    no cop │ │ │ │ -00026750: 7920 6173 7369 676e 6d65 6e74 2066 726f y assignment fro │ │ │ │ -00026760: 6d20 4669 656c 644d 6174 7269 7820 6f66 m FieldMatrix of │ │ │ │ -00026770: 2064 6966 6665 7265 6e74 2073 697a 653c different size< │ │ │ │ -00026780: 2f64 6976 3e3c 2f64 6976 3e0a 3c64 6976 /div>
    .
    Base: │ │ │ │ -00026860: 3a72 6f77 5f72 6566 6572 656e 6365 2072 :row_reference r │ │ │ │ -00026870: 6f77 5f72 6566 6572 656e 6365 3c2f 6469 ow_reference
    Definiti │ │ │ │ -000268a0: 6f6e 3c2f 623e 2066 6d61 7472 6978 2e68 on fmatrix.h │ │ │ │ -000268b0: 683a 3133 303c 2f64 6976 3e3c 2f64 6976 h:130
    .
    ro │ │ │ │ -00026990: 775f 7265 6665 7265 6e63 6520 6d61 745f w_reference mat_ │ │ │ │ -000269a0: 6163 6365 7373 2873 697a 655f 7479 7065 access(size_type │ │ │ │ -000269b0: 2069 293c 2f64 6976 3e3c 6469 7620 636c i)
    D │ │ │ │ -000269d0: 6566 696e 6974 696f 6e3c 2f62 3e20 666d efinition fm │ │ │ │ -000269e0: 6174 7269 782e 6868 3a33 3639 3c2f 6469 atrix.hh:369
    .
    s │ │ │ │ -00026ac0: 7461 7469 6320 636f 6e73 7465 7870 7220 tatic constexpr │ │ │ │ -00026ad0: 696e 7420 726f 7773 3c2f 6469 763e 3c64 int rows
    The number of r │ │ │ │ -00026b00: 6f77 732e 3c2f 6469 763e 3c64 6976 2063 ows.
    │ │ │ │ -00026b20: 4465 6669 6e69 7469 6f6e 3c2f 623e 2066 Definition f │ │ │ │ -00026b30: 6d61 7472 6978 2e68 683a 3132 333c 2f64 matrix.hh:123
    .
    < │ │ │ │ -00026b90: 6469 7620 636c 6173 733d 2274 746e 616d div class="ttnam │ │ │ │ -00026ba0: 6522 3e3c 6120 6872 6566 3d22 6130 3134 e">Dune: │ │ │ │ -00026be0: 3a46 6965 6c64 4d61 7472 6978 3a3a 7472 :FieldMatrix::tr │ │ │ │ -00026bf0: 616e 7370 6f73 6564 3c2f 613e 3c2f 6469 ansposed
    FieldMatri │ │ │ │ -00026c20: 7826 6c74 3b20 4b2c 2043 4f4c 532c 2052 x< K, COLS, R │ │ │ │ -00026c30: 4f57 5320 2667 743b 2074 7261 6e73 706f OWS > transpo │ │ │ │ -00026c40: 7365 6428 2920 636f 6e73 743c 2f64 6976 sed() const
    Return trans │ │ │ │ -00026c70: 706f 7365 6420 6f66 2074 6865 206d 6174 posed of the mat │ │ │ │ -00026c80: 7269 7820 6173 2046 6965 6c64 4d61 7472 rix as FieldMatr │ │ │ │ -00026c90: 6978 2e3c 2f64 6976 3e3c 6469 7620 636c ix.
    D │ │ │ │ -00026cb0: 6566 696e 6974 696f 6e3c 2f62 3e20 666d efinition fm │ │ │ │ -00026cc0: 6174 7269 782e 6868 3a31 3732 3c2f 6469 atrix.hh:172
    .< │ │ │ │ -00026d90: 6469 7620 636c 6173 733d 2274 7464 6563 div class="ttdec │ │ │ │ -00026da0: 6922 3e73 7461 7469 6320 636f 6e73 7465 i">static conste │ │ │ │ -00026db0: 7870 7220 7369 7a65 5f74 7970 6520 6d61 xpr size_type ma │ │ │ │ -00026dc0: 745f 726f 7773 2829 3c2f 6469 763e 3c64 t_rows()
    Definition fmatrix.hh:36 │ │ │ │ -00026e00: 363c 2f64 6976 3e3c 2f64 6976 3e0a 3c64 6
    .
    Field │ │ │ │ -00026ee0: 4d61 7472 6978 2873 7464 3a3a 696e 6974 Matrix(std::init │ │ │ │ -00026ef0: 6961 6c69 7a65 725f 6c69 7374 266c 743b ializer_list< │ │ │ │ -00026f00: 2044 756e 653a 3a46 6965 6c64 5665 6374 Dune::FieldVect │ │ │ │ -00026f10: 6f72 266c 743b 204b 2c20 636f 6c73 2026 or< K, cols & │ │ │ │ -00026f20: 6774 3b20 2667 743b 2063 6f6e 7374 2026 gt; > const & │ │ │ │ -00026f30: 616d 703b 6c29 3c2f 6469 763e 3c64 6976 amp;l)
    C │ │ │ │ -00026f50: 6f6e 7374 7275 6374 6f72 2069 6e69 7469 onstructor initi │ │ │ │ -00026f60: 616c 697a 696e 6720 7468 6520 6d61 7472 alizing the matr │ │ │ │ -00026f70: 6978 2066 726f 6d20 6120 6c69 7374 206f ix from a list o │ │ │ │ -00026f80: 6620 7665 6374 6f72 2e3c 2f64 6976 3e3c f vector.
    < │ │ │ │ -00026f90: 6469 7620 636c 6173 733d 2274 7464 6566 div class="ttdef │ │ │ │ -00026fa0: 223e 3c62 3e44 6566 696e 6974 696f 6e3c ">Definition< │ │ │ │ -00026fb0: 2f62 3e20 666d 6174 7269 782e 6868 3a31 /b> fmatrix.hh:1 │ │ │ │ -00026fc0: 3430 3c2f 6469 763e 3c2f 6469 763e 0a3c 40
    .< │ │ │ │ -00026fd0: 6469 7620 636c 6173 733d 2274 7463 2220 div class="ttc" │ │ │ │ -00026fe0: 6964 3d22 6161 3031 3430 385f 6874 6d6c id="aa01408_html │ │ │ │ -00026ff0: 5f61 6332 3831 3666 3164 3036 3766 3533 _ac2816f1d067f53 │ │ │ │ -00027000: 3333 3636 3239 3763 3035 3366 3037 3039 3366297c053f0709 │ │ │ │ -00027010: 3962 223e 3c64 6976 2063 6c61 7373 3d22 9b">
    static cons │ │ │ │ -000270a0: 7465 7870 7220 696e 7420 636f 6c73 3c2f texpr int cols
    The numbe │ │ │ │ -000270d0: 7220 6f66 2063 6f6c 756d 6e73 2e3c 2f64 r of columns.
    Definit │ │ │ │ -00027100: 696f 6e3c 2f62 3e20 666d 6174 7269 782e ion fmatrix. │ │ │ │ -00027110: 6868 3a31 3235 3c2f 6469 763e 3c2f 6469 hh:125
    .
    fr │ │ │ │ -000271f0: 6965 6e64 2061 7574 6f20 6f70 6572 6174 iend auto operat │ │ │ │ -00027200: 6f72 2f28 636f 6e73 7420 4669 656c 644d or/(const FieldM │ │ │ │ -00027210: 6174 7269 7820 2661 6d70 3b6d 6174 7269 atrix &matri │ │ │ │ -00027220: 782c 2053 6361 6c61 7220 7363 616c 6172 x, Scalar scalar │ │ │ │ -00027230: 293c 2f64 6976 3e3c 6469 7620 636c 6173 )
    vector │ │ │ │ -00027250: 2073 7061 6365 2064 6976 6973 696f 6e20 space division │ │ │ │ -00027260: 6279 2073 6361 6c61 723c 2f64 6976 3e3c by scalar
    < │ │ │ │ -00027270: 6469 7620 636c 6173 733d 2274 7464 6566 div class="ttdef │ │ │ │ -00027280: 223e 3c62 3e44 6566 696e 6974 696f 6e3c ">Definition< │ │ │ │ -00027290: 2f62 3e20 666d 6174 7269 782e 6868 3a32 /b> fmatrix.hh:2 │ │ │ │ -000272a0: 3430 3c2f 6469 763e 3c2f 6469 763e 0a3c 40
    .< │ │ │ │ -000272b0: 6469 7620 636c 6173 733d 2274 7463 2220 div class="ttc" │ │ │ │ -000272c0: 6964 3d22 6161 3031 3430 385f 6874 6d6c id="aa01408_html │ │ │ │ -000272d0: 5f61 6536 3033 3366 3231 3764 3264 6531 _ae6033f217d2de1 │ │ │ │ -000272e0: 6337 6330 6464 6431 3038 3435 3966 6638 c7c0ddd108459ff8 │ │ │ │ -000272f0: 6163 223e 3c64 6976 2063 6c61 7373 3d22 ac">
    friend │ │ │ │ -00027380: 2061 7574 6f20 6f70 6572 6174 6f72 2b28 auto operator+( │ │ │ │ -00027390: 636f 6e73 7420 4669 656c 644d 6174 7269 const FieldMatri │ │ │ │ -000273a0: 7820 2661 6d70 3b6d 6174 7269 7841 2c20 x &matrixA, │ │ │ │ -000273b0: 636f 6e73 7420 4669 656c 644d 6174 7269 const FieldMatri │ │ │ │ -000273c0: 7826 6c74 3b20 4f74 6865 7253 6361 6c61 x< OtherScala │ │ │ │ -000273d0: 722c 2052 4f57 532c 2043 4f4c 5320 2667 r, ROWS, COLS &g │ │ │ │ -000273e0: 743b 2026 616d 703b 6d61 7472 6978 4229 t; &matrixB) │ │ │ │ -000273f0: 3c2f 6469 763e 3c64 6976 2063 6c61 7373
    vector │ │ │ │ -00027410: 7370 6163 6520 6164 6469 7469 6f6e 20e2 space addition . │ │ │ │ -00027420: 8093 2074 776f 2d61 7267 756d 656e 7420 .. two-argument │ │ │ │ -00027430: 7665 7273 696f 6e3c 2f64 6976 3e3c 6469 version
    │ │ │ │ -00027450: 3c62 3e44 6566 696e 6974 696f 6e3c 2f62 Definition fmatrix.hh:183 │ │ │ │ -00027470: 3c2f 6469 763e 3c2f 6469 763e 0a3c 6469
    .
    Du │ │ │ │ -00027510: 6e65 3a3a 4669 656c 644d 6174 7269 783a ne::FieldMatrix: │ │ │ │ -00027520: 3a6f 7065 7261 746f 723d 3c2f 613e 3c2f :operator=
    FieldMat │ │ │ │ -00027550: 7269 7820 2661 6d70 3b20 6f70 6572 6174 rix & operat │ │ │ │ -00027560: 6f72 3d28 636f 6e73 7420 4669 656c 644d or=(const FieldM │ │ │ │ -00027570: 6174 7269 7820 2661 6d70 3b29 3d64 6566 atrix &)=def │ │ │ │ -00027580: 6175 6c74 3c2f 6469 763e 3c64 6976 2063 ault
    cop │ │ │ │ -000275a0: 7920 6173 7369 676e 6d65 6e74 206f 7065 y assignment ope │ │ │ │ -000275b0: 7261 746f 723c 2f64 6976 3e3c 2f64 6976 rator
    .
    vect │ │ │ │ -00027720: 6f72 2073 7061 6365 2073 7562 7472 6163 or space subtrac │ │ │ │ -00027730: 7469 6f6e 20e2 8093 2074 776f 2d61 7267 tion ... two-arg │ │ │ │ -00027740: 756d 656e 7420 7665 7273 696f 6e3c 2f64 ument version
    Definit │ │ │ │ -00027770: 696f 6e3c 2f62 3e20 666d 6174 7269 782e ion fmatrix. │ │ │ │ -00027780: 6868 3a31 3937 3c2f 6469 763e 3c2f 6469 hh:197
    .
    c │ │ │ │ -00027860: 6f6e 7374 5f72 6f77 5f72 6566 6572 656e onst_row_referen │ │ │ │ -00027870: 6365 206d 6174 5f61 6363 6573 7328 7369 ce mat_access(si │ │ │ │ -00027880: 7a65 5f74 7970 6520 6929 2063 6f6e 7374 ze_type i) const │ │ │ │ -00027890: 3c2f 6469 763e 3c64 6976 2063 6c61 7373
    Defi │ │ │ │ -000278b0: 6e69 7469 6f6e 3c2f 623e 2066 6d61 7472 nition fmatr │ │ │ │ -000278c0: 6978 2e68 683a 3337 353c 2f64 6976 3e3c ix.hh:375
    < │ │ │ │ -000278d0: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    vector space ou │ │ │ │ -00027960: 7420 6f66 2061 2074 656e 736f 7220 7072 t of a tensor pr │ │ │ │ -00027970: 6f64 7563 7420 6f66 2066 6965 6c64 732e oduct of fields. │ │ │ │ -00027980: 3c2f 6469 763e 3c64 6976 2063 6c61 7373
    Defi │ │ │ │ -000279a0: 6e69 7469 6f6e 3c2f 623e 2066 7665 6374 nition fvect │ │ │ │ -000279b0: 6f72 2e68 683a 3935 3c2f 6469 763e 3c2f or.hh:95
    .
    Dune::Dens │ │ │ │ -00027a60: 654d 6174 5665 6354 7261 6974 7326 6c74 eMatVecTraits< │ │ │ │ -00027a70: 3b20 4669 656c 644d 6174 7269 7826 6c74 ; FieldMatrix< │ │ │ │ -00027a80: 3b20 4b2c 2052 4f57 532c 2043 4f4c 5320 ; K, ROWS, COLS │ │ │ │ -00027a90: 2667 743b 2026 6774 3b3a 3a63 6f6e 7461 > >::conta │ │ │ │ -00027aa0: 696e 6572 5f74 7970 653c 2f61 3e3c 2f64 iner_type
    std::arra │ │ │ │ -00027ad0: 7926 6c74 3b20 726f 775f 7479 7065 2c20 y< row_type, │ │ │ │ -00027ae0: 524f 5753 2026 6774 3b20 636f 6e74 6169 ROWS > contai │ │ │ │ -00027af0: 6e65 725f 7479 7065 3c2f 6469 763e 3c64 ner_type
    Definition fmatrix.hh:95 │ │ │ │ -00027b30: 3c2f 6469 763e 3c2f 6469 763e 0a3c 6469
    . │ │ │ │ -00027cb0: 0a3c 6469 7620 636c 6173 733d 2274 7463 .. │ │ │ │ -00027e00: 3c64 6976 2063 6c61 7373 3d22 7474 6322
    Dune::DenseMatV │ │ │ │ -00027ea0: 6563 5472 6169 7473 266c 743b 2046 6965 ecTraits< Fie │ │ │ │ -00027eb0: 6c64 4d61 7472 6978 266c 743b 204b 2c20 ldMatrix< K, │ │ │ │ -00027ec0: 524f 5753 2c20 434f 4c53 2026 6774 3b20 ROWS, COLS > │ │ │ │ -00027ed0: 2667 743b 3a3a 636f 6e73 745f 726f 775f >::const_row_ │ │ │ │ -00027ee0: 7265 6665 7265 6e63 653c 2f61 3e3c 2f64 reference
    const row │ │ │ │ -00027f10: 5f74 7970 6520 2661 6d70 3b20 636f 6e73 _type & cons │ │ │ │ -00027f20: 745f 726f 775f 7265 6665 7265 6e63 653c t_row_reference< │ │ │ │ -00027f30: 2f64 6976 3e3c 6469 7620 636c 6173 733d /div>
    Defin │ │ │ │ -00027f50: 6974 696f 6e3c 2f62 3e20 666d 6174 7269 ition fmatri │ │ │ │ -00027f60: 782e 6868 3a39 333c 2f64 6976 3e3c 2f64 x.hh:93
    .
    │ │ │ │ -00028070: 4669 656c 6456 6563 746f 7226 6c74 3b20 FieldVector< │ │ │ │ -00028080: 4b2c 2043 4f4c 5320 2667 743b 2072 6f77 K, COLS > row │ │ │ │ -00028090: 5f74 7970 653c 2f64 6976 3e3c 6469 7620 _type
    Definition │ │ │ │ -000280c0: 666d 6174 7269 782e 6868 3a39 303c 2f64 fmatrix.hh:90
    .
    < │ │ │ │ -00028120: 6469 7620 636c 6173 733d 2274 746e 616d div class="ttnam │ │ │ │ -00028130: 6522 3e3c 6120 6872 6566 3d22 6130 3137 e">Dune: │ │ │ │ -00028170: 3a44 656e 7365 4d61 7456 6563 5472 6169 :DenseMatVecTrai │ │ │ │ -00028180: 7473 266c 743b 2046 6965 6c64 4d61 7472 ts< FieldMatr │ │ │ │ -00028190: 6978 266c 743b 204b 2c20 524f 5753 2c20 ix< K, ROWS, │ │ │ │ -000281a0: 434f 4c53 2026 6774 3b20 2667 743b 3a3a COLS > >:: │ │ │ │ -000281b0: 7369 7a65 5f74 7970 653c 2f61 3e3c 2f64 size_type
    container │ │ │ │ -000281e0: 5f74 7970 653a 3a73 697a 655f 7479 7065 _type::size_type │ │ │ │ -000281f0: 2073 697a 655f 7479 7065 3c2f 6469 763e size_type
    │ │ │ │ -00028200: 3c64 6976 2063 6c61 7373 3d22 7474 6465
    Definition │ │ │ │ -00028220: 3c2f 623e 2066 6d61 7472 6978 2e68 683a fmatrix.hh: │ │ │ │ -00028230: 3937 3c2f 6469 763e 3c2f 6469 763e 0a3c 97
    .< │ │ │ │ -00028240: 6469 7620 636c 6173 733d 2274 7463 2220 div class="ttc" │ │ │ │ -00028250: 6964 3d22 6161 3031 3733 325f 6874 6d6c id="aa01732_html │ │ │ │ -00028260: 5f61 6366 3564 3334 6637 3736 3561 3931 _acf5d34f7765a91 │ │ │ │ -00028270: 6137 3837 3661 6436 6664 3663 3637 6434 a7876ad6fd6c67d4 │ │ │ │ -00028280: 3131 223e 3c64 6976 2063 6c61 7373 3d22 11">
    │ │ │ │ -00028340: 726f 775f 7479 7065 2026 616d 703b 2072 row_type & r │ │ │ │ -00028350: 6f77 5f72 6566 6572 656e 6365 3c2f 6469 ow_reference
    Definiti │ │ │ │ -00028380: 6f6e 3c2f 623e 2066 6d61 7472 6978 2e68 on fmatrix.h │ │ │ │ -00028390: 683a 3932 3c2f 6469 763e 3c2f 6469 763e h:92
    │ │ │ │ -000283a0: 0a3c 6469 7620 636c 6173 733d 2274 7463 .
    Dune::FieldTra │ │ │ │ -00028440: 6974 7326 6c74 3b20 4669 656c 644d 6174 its< FieldMat │ │ │ │ -00028450: 7269 7826 6c74 3b20 4b2c 2052 4f57 532c rix< K, ROWS, │ │ │ │ -00028460: 2043 4f4c 5320 2667 743b 2026 6774 3b3a COLS > >: │ │ │ │ -00028470: 3a66 6965 6c64 5f74 7970 653c 2f61 3e3c :field_type< │ │ │ │ -00028480: 2f64 6976 3e3c 6469 7620 636c 6173 733d /div>
    FieldTr │ │ │ │ -000284a0: 6169 7473 266c 743b 204b 2026 6774 3b3a aits< K >: │ │ │ │ -000284b0: 3a66 6965 6c64 5f74 7970 6520 6669 656c :field_type fiel │ │ │ │ -000284c0: 645f 7479 7065 3c2f 6469 763e 3c64 6976 d_type
    < │ │ │ │ -000284e0: 623e 4465 6669 6e69 7469 6f6e 3c2f 623e b>Definition │ │ │ │ -000284f0: 2066 6d61 7472 6978 2e68 683a 3130 333c fmatrix.hh:103< │ │ │ │ -00028500: 2f64 6976 3e3c 2f64 6976 3e0a 3c64 6976 /div>
    .
    < │ │ │ │ -000285f0: 6469 7620 636c 6173 733d 2274 7464 6563 div class="ttdec │ │ │ │ -00028600: 6922 3e46 6965 6c64 5472 6169 7473 266c i">FieldTraits&l │ │ │ │ -00028610: 743b 204b 2026 6774 3b3a 3a72 6561 6c5f t; K >::real_ │ │ │ │ -00028620: 7479 7065 2072 6561 6c5f 7479 7065 3c2f type real_type
    Defini │ │ │ │ -00028650: 7469 6f6e 3c2f 623e 2066 6d61 7472 6978 tion fmatrix │ │ │ │ -00028660: 2e68 683a 3130 343c 2f64 6976 3e3c 2f64 .hh:104
    .
    < │ │ │ │ -000286f0: 623e 4465 6669 6e69 7469 6f6e 3c2f 623e b>Definition │ │ │ │ -00028700: 2066 7472 6169 7473 2e68 683a 3236 3c2f ftraits.hh:26
    .
    │ │ │ │ -00028760: 3c64 6976 2063 6c61 7373 3d22 7474 6e61
    Dune │ │ │ │ -000287b0: 3a3a 4669 656c 6454 7261 6974 733a 3a66 ::FieldTraits::f │ │ │ │ -000287c0: 6965 6c64 5f74 7970 653c 2f61 3e3c 2f64 ield_type
    T field_t │ │ │ │ -000287f0: 7970 653c 2f64 6976 3e3c 6469 7620 636c ype
    expo │ │ │ │ -00028810: 7274 2074 6865 2074 7970 6520 7265 7072 rt the type repr │ │ │ │ -00028820: 6573 656e 7469 6e67 2074 6865 2066 6965 esenting the fie │ │ │ │ -00028830: 6c64 3c2f 6469 763e 3c64 6976 2063 6c61 ld
    De │ │ │ │ -00028850: 6669 6e69 7469 6f6e 3c2f 623e 2066 7472 finition ftr │ │ │ │ -00028860: 6169 7473 2e68 683a 3238 3c2f 6469 763e aits.hh:28
    │ │ │ │ -00028870: 3c2f 6469 763e 0a3c 6469 7620 636c 6173
    .
    T real_type
    export the │ │ │ │ -00028970: 2074 7970 6520 7265 7072 6573 656e 7469 type representi │ │ │ │ -00028980: 6e67 2074 6865 2072 6561 6c20 7479 7065 ng the real type │ │ │ │ -00028990: 206f 6620 7468 6520 6669 656c 643c 2f64 of the field
    Definit │ │ │ │ -000289c0: 696f 6e3c 2f62 3e20 6674 7261 6974 732e ion ftraits. │ │ │ │ -000289d0: 6868 3a33 303c 2f64 6976 3e3c 2f64 6976 hh:30
    .
    │ │ │ │ -00028a50: 3c64 6976 2063 6c61 7373 3d22 7474 6465
    Definition │ │ │ │ -00028a70: 3c2f 623e 206d 6174 7665 6374 7261 6974 matvectrait │ │ │ │ -00028a80: 732e 6868 3a33 313c 2f64 6976 3e3c 2f64 s.hh:31
    .
    Dune::Promo │ │ │ │ -00028b30: 7469 6f6e 5472 6169 7473 3a3a 5072 6f6d tionTraits::Prom │ │ │ │ -00028b40: 6f74 6564 5479 7065 3c2f 613e 3c2f 6469 otedType
    decltype(s │ │ │ │ -00028b70: 7464 3a3a 6465 636c 7661 6c26 6c74 3b20 td::declval< │ │ │ │ -00028b80: 5431 2026 6774 3b28 292b 7374 643a 3a64 T1 >()+std::d │ │ │ │ -00028b90: 6563 6c76 616c 266c 743b 2054 3220 2667 eclval< T2 &g │ │ │ │ -00028ba0: 743b 2829 2920 5072 6f6d 6f74 6564 5479 t;()) PromotedTy │ │ │ │ -00028bb0: 7065 3c2f 6469 763e 3c64 6976 2063 6c61 pe
    De │ │ │ │ -00028bd0: 6669 6e69 7469 6f6e 3c2f 623e 2070 726f finition pro │ │ │ │ -00028be0: 6d6f 7469 6f6e 7472 6169 7473 2e68 683a motiontraits.hh: │ │ │ │ -00028bf0: 3238 3c2f 6469 763e 3c2f 6469 763e 0a3c 28
    .< │ │ │ │ -00028c00: 2f64 6976 3e3c 212d 2d20 6672 6167 6d65 /div>
    ..
    .Gen │ │ │ │ -00028c80: 6572 6174 6564 2062 7926 2331 3630 3b3c erated by < │ │ │ │ -00028c90: 6120 6872 6566 3d22 6874 7470 733a 2f2f a href="https:// │ │ │ │ -00028ca0: 7777 772e 646f 7879 6765 6e2e 6f72 672f www.doxygen.org/ │ │ │ │ -00028cb0: 696e 6465 782e 6874 6d6c 223e 3c69 6d67 index.html">d
│ │ │ │ -00028d00: 6f78 7967 656e 222f 3e3c 2f61 3e20 312e  oxygen 1. │ │ │ │ -00028d10: 392e 380a 3c2f 736d 616c 6c3e 3c2f 6164 9.8...< │ │ │ │ -00028d30: 2f68 746d 6c3e 0a /html>. │ │ │ │ +000001c0: 636f 6c6c 6563 7469 7665 636f 6d6d 756e collectivecommun │ │ │ │ +000001d0: 6963 6174 696f 6e2e 6868 2053 6f75 7263 ication.hh Sourc │ │ │ │ +000001e0: 6520 4669 6c65 3c2f 7469 746c 653e 0a3c e File.< │ │ │ │ +000001f0: 6c69 6e6b 2068 7265 663d 2274 6162 732e link href="tabs. │ │ │ │ +00000200: 6373 7322 2072 656c 3d22 7374 796c 6573 css" rel="styles │ │ │ │ +00000210: 6865 6574 2220 7479 7065 3d22 7465 7874 heet" type="text │ │ │ │ +00000220: 2f63 7373 222f 3e0a 3c73 6372 6970 7420 /css"/>. │ │ │ │ +00000260: 0a3c 7363 7269 7074 2074 7970 653d 2274 ..< │ │ │ │ +000002a0: 6c69 6e6b 2068 7265 663d 2273 6561 7263 link href="searc │ │ │ │ +000002b0: 682f 7365 6172 6368 2e63 7373 2220 7265 h/search.css" re │ │ │ │ +000002c0: 6c3d 2273 7479 6c65 7368 6565 7422 2074 l="stylesheet" t │ │ │ │ +000002d0: 7970 653d 2274 6578 742f 6373 7322 2f3e ype="text/css"/> │ │ │ │ +000002e0: 0a3c 7363 7269 7074 2074 7970 653d 2274 ...../* │ │ │ │ +000006a0: 406c 6963 656e 7365 206d 6167 6e65 743a @license magnet: │ │ │ │ +000006b0: 3f78 743d 7572 6e3a 6274 6968 3a64 3364 ?xt=urn:btih:d3d │ │ │ │ +000006c0: 3961 3961 3635 3935 3532 3166 3936 3636 9a9a6595521f9666 │ │ │ │ +000006d0: 6135 6539 3463 6338 3330 6461 6238 3362 a5e94cc830dab83b │ │ │ │ +000006e0: 3635 3639 3926 616d 703b 646e 3d65 7870 65699&dn=exp │ │ │ │ +000006f0: 6174 2e74 7874 204d 4954 202a 2f0a 2428 at.txt MIT */.$( │ │ │ │ +00000700: 6675 6e63 7469 6f6e 2829 207b 0a20 2069 function() {. i │ │ │ │ +00000710: 6e69 744d 656e 7528 2727 2c74 7275 652c nitMenu('',true, │ │ │ │ +00000720: 6661 6c73 652c 2773 6561 7263 682e 7068 false,'search.ph │ │ │ │ +00000730: 7027 2c27 5365 6172 6368 2729 3b0a 2020 p','Search');. │ │ │ │ +00000740: 2428 646f 6375 6d65 6e74 292e 7265 6164 $(document).read │ │ │ │ +00000750: 7928 6675 6e63 7469 6f6e 2829 207b 2069 y(function() { i │ │ │ │ +00000760: 6e69 745f 7365 6172 6368 2829 3b20 7d29 nit_search(); }) │ │ │ │ +00000770: 3b0a 7d29 3b0a 2f2a 2040 6c69 6365 6e73 ;.});./* @licens │ │ │ │ +00000780: 652d 656e 6420 2a2f 0a3c 2f73 6372 6970 e-end */..
    ../* │ │ │ │ +000007d0: 406c 6963 656e 7365 206d 6167 6e65 743a @license magnet: │ │ │ │ +000007e0: 3f78 743d 7572 6e3a 6274 6968 3a64 3364 ?xt=urn:btih:d3d │ │ │ │ +000007f0: 3961 3961 3635 3935 3532 3166 3936 3636 9a9a6595521f9666 │ │ │ │ +00000800: 6135 6539 3463 6338 3330 6461 6238 3362 a5e94cc830dab83b │ │ │ │ +00000810: 3635 3639 3926 616d 703b 646e 3d65 7870 65699&dn=exp │ │ │ │ +00000820: 6174 2e74 7874 204d 4954 202a 2f0a 2428 at.txt MIT */.$( │ │ │ │ +00000830: 646f 6375 6d65 6e74 292e 7265 6164 7928 document).ready( │ │ │ │ +00000840: 6675 6e63 7469 6f6e 2829 207b 2069 6e69 function() { ini │ │ │ │ +00000850: 745f 636f 6465 666f 6c64 2830 293b 207d t_codefold(0); } │ │ │ │ +00000860: 293b 0a2f 2a20 406c 6963 656e 7365 2d65 );./* @license-e │ │ │ │ +00000870: 6e64 202a 2f0a 3c2f 7363 7269 7074 3e0a nd */.. │ │ │ │ +00000880: 3c21 2d2d 2077 696e 646f 7720 7368 6f77 .
    .
    .....
    .
    .< │ │ │ │ +00000a20: 6469 7620 6964 3d22 5352 5265 7375 6c74 div id="SRResult │ │ │ │ +00000a30: 7322 3e3c 2f64 6976 3e0a 3c64 6976 2063 s">
    .
    Loa │ │ │ │ +00000a60: 6469 6e67 2e2e 2e3c 2f64 6976 3e0a 3c64 ding...
    .Searching...< │ │ │ │ +00000aa0: 2f64 6976 3e0a 3c64 6976 2063 6c61 7373 /div>.
    No Ma │ │ │ │ +00000ad0: 7463 6865 733c 2f64 6976 3e0a 3c2f 6469 tches
    ..
    .
    │ │ │ │ +00000af0: 0a3c 2f64 6976 3e0a 0a3c 6469 7620 6964 .
    ..
    . < │ │ │ │ +00000b20: 756c 3e0a 3c6c 6920 636c 6173 733d 226e ul>.
  • dune< │ │ │ │ +00000b80: 2f6c 693e 3c6c 6920 636c 6173 733d 226e /li>
  • common
  • paralle │ │ │ │ +00000c40: 6c3c 2f61 3e3c 2f6c 693e 2020 3c2f 756c l
  • .
    .
    < │ │ │ │ +00000c60: 212d 2d20 746f 7020 2d2d 3e0a 3c64 6976 !-- top -->.
    │ │ │ │ +00000c80: 0a20 203c 6469 7620 636c 6173 733d 2268 .
    c │ │ │ │ +00000cb0: 6f6c 6c65 6374 6976 6563 6f6d 6d75 6e69 ollectivecommuni │ │ │ │ +00000cc0: 6361 7469 6f6e 2e68 683c 2f64 6976 3e3c cation.hh
    < │ │ │ │ +00000cd0: 2f64 6976 3e0a 3c2f 6469 763e 3c21 2d2d /div>.
    .
    │ │ │ │ +00000d00: 0a3c 6120 6872 6566 3d22 6130 3030 3632 .Go to the │ │ │ │ +00000d20: 2064 6f63 756d 656e 7461 7469 6f6e 206f documentation o │ │ │ │ +00000d30: 6620 7468 6973 2066 696c 652e 3c2f 613e f this file. │ │ │ │ +00000d40: 3c64 6976 2063 6c61 7373 3d22 6672 6167
    │ │ │ │ +00000da0: 2020 313c 2f73 7061 6e3e 3c73 7061 6e20 1 │ │ │ │ +00000dc0: 2f2f 2053 5044 582d 4669 6c65 436f 7079 // SPDX-FileCopy │ │ │ │ +00000dd0: 7269 6768 7449 6e66 6f3a 2043 6f70 7972 rightInfo: Copyr │ │ │ │ +00000de0: 6967 6874 2028 4329 2044 554e 4520 5072 ight (C) DUNE Pr │ │ │ │ +00000df0: 6f6a 6563 7420 636f 6e74 7269 6275 746f oject contributo │ │ │ │ +00000e00: 7273 2c20 7365 6520 6669 6c65 204c 4943 rs, see file LIC │ │ │ │ +00000e10: 454e 5345 2e6d 6420 696e 206d 6f64 756c ENSE.md in modul │ │ │ │ +00000e20: 6520 726f 6f74 3c2f 7370 616e 3e3c 2f64 e root.
    │ │ │ │ +00000e80: 323c 2f73 7061 6e3e 3c73 7061 6e20 636c 2// │ │ │ │ +00000ea0: 2053 5044 582d 4c69 6365 6e73 652d 4964 SPDX-License-Id │ │ │ │ +00000eb0: 656e 7469 6669 6572 3a20 4c69 6365 6e73 entifier: Licens │ │ │ │ +00000ec0: 6552 6566 2d47 504c 2d32 2e30 2d6f 6e6c eRef-GPL-2.0-onl │ │ │ │ +00000ed0: 792d 7769 7468 2d44 554e 452d 6578 6365 y-with-DUNE-exce │ │ │ │ +00000ee0: 7074 696f 6e3c 2f73 7061 6e3e 3c2f 6469 ption.
    3 │ │ │ │ +00000f40: 3c2f 7370 616e 3e3c 7370 616e 2063 6c61 // │ │ │ │ +00000f60: 5769 6c6c 2062 6520 7265 6d6f 7665 6420 Will be removed │ │ │ │ +00000f70: 6166 7465 7220 7468 6520 322e 3720 7265 after the 2.7 re │ │ │ │ +00000f80: 6c65 6173 653c 2f73 7061 6e3e 3c2f 6469 lease.
    4 │ │ │ │ +00000fe0: 3c2f 7370 616e 3e3c 7370 616e 2063 6c61 #warning " │ │ │ │ +00001010: 3b44 6570 7265 6361 7465 6420 6865 6164 ;Deprecated head │ │ │ │ +00001020: 6572 2c20 7573 6520 2369 6e63 6c75 6465 er, use #include │ │ │ │ +00001030: 2026 6c74 3b64 756e 652f 636f 6d6d 6f6e <dune/common │ │ │ │ +00001040: 2f70 6172 616c 6c65 6c2f 636f 6d6d 756e /parallel/commun │ │ │ │ +00001050: 6963 6174 696f 6e2e 6868 2667 743b 2069 ication.hh> i │ │ │ │ +00001060: 6e73 7465 6164 2126 7175 6f74 3b3c 2f73 nstead!"
    .
    5< │ │ │ │ +000010d0: 7370 616e 2063 6c61 7373 3d22 7072 6570 span class="prep │ │ │ │ +000010e0: 726f 6365 7373 6f72 223e 2369 6e63 6c75 rocessor">#inclu │ │ │ │ +000010f0: 6465 2026 6c74 3b3c 6120 636c 6173 733d de <dune/c │ │ │ │ +00001120: 6f6d 6d6f 6e2f 7061 7261 6c6c 656c 2f63 ommon/parallel/c │ │ │ │ +00001130: 6f6d 6d75 6e69 6361 7469 6f6e 2e68 683c ommunication.hh< │ │ │ │ +00001140: 2f61 3e26 6774 3b3c 2f73 7061 6e3e 3c2f /a>>.
    I │ │ │ │ +000011d0: 6d70 6c65 6d65 6e74 7320 616e 2075 7469 mplements an uti │ │ │ │ +000011e0: 6c69 7479 2063 6c61 7373 2074 6861 7420 lity class that │ │ │ │ +000011f0: 7072 6f76 6964 6573 2063 6f6c 6c65 6374 provides collect │ │ │ │ +00001200: 6976 6520 636f 6d6d 756e 6963 6174 696f ive communicatio │ │ │ │ +00001210: 6e20 6d65 7468 6f64 7320 666f 7220 7365 n methods for se │ │ │ │ +00001220: 7175 656e 7469 616c 2070 726f 6772 616d quential program │ │ │ │ +00001230: 732e 3c2f 6469 763e 3c2f 6469 763e 0a3c s.
    .< │ │ │ │ +00001240: 2f64 6976 3e3c 212d 2d20 6672 6167 6d65 /div>
    ..
    .Gen │ │ │ │ +000012c0: 6572 6174 6564 2062 7926 2331 3630 3b3c erated by < │ │ │ │ +000012d0: 6120 6872 6566 3d22 6874 7470 733a 2f2f a href="https:// │ │ │ │ +000012e0: 7777 772e 646f 7879 6765 6e2e 6f72 672f www.doxygen.org/ │ │ │ │ +000012f0: 696e 6465 782e 6874 6d6c 223e 3c69 6d67 index.html">d
│ │ │ │ +00001340: 6f78 7967 656e 222f 3e3c 2f61 3e20 312e  oxygen 1. │ │ │ │ +00001350: 392e 380a 3c2f 736d 616c 6c3e 3c2f 6164 9.8...< │ │ │ │ +00001370: 2f68 746d 6c3e 0a /html>. │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,1064 +7,23 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -fmatrix.hh │ │ │ │ │ + * parallel │ │ │ │ │ +collectivecommunication.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 (C) DUNE Project contributors, see file │ │ │ │ │ + 1// SPDX-FileCopyrightInfo: Copyright (C) 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_FMATRIX_HH │ │ │ │ │ - 6#define DUNE_FMATRIX_HH │ │ │ │ │ - 7 │ │ │ │ │ - 8#include │ │ │ │ │ - 9#include │ │ │ │ │ - 10#include │ │ │ │ │ - 11#include │ │ │ │ │ - 12#include │ │ │ │ │ - 13 │ │ │ │ │ - 14#include │ │ │ │ │ - 15#include │ │ │ │ │ - 16#include │ │ │ │ │ - 17#include │ │ │ │ │ - 18#include │ │ │ │ │ - 19#include │ │ │ │ │ - 20#include │ │ │ │ │ - 21#include │ │ │ │ │ - 22 │ │ │ │ │ - 23namespace Dune │ │ │ │ │ - 24{ │ │ │ │ │ - 25 │ │ │ │ │ - 26 namespace Impl │ │ │ │ │ - 27 { │ │ │ │ │ - 28 │ │ │ │ │ - 29 template │ │ │ │ │ - 30 class ColumnVectorView │ │ │ │ │ - 31 { │ │ │ │ │ - 32 public: │ │ │ │ │ - 33 │ │ │ │ │ - 34 using value_type = typename M::value_type; │ │ │ │ │ - 35 using size_type = typename M::size_type; │ │ │ │ │ - 36 │ │ │ │ │ - 37 constexpr ColumnVectorView(M& matrix, size_type col) : │ │ │ │ │ - 38 matrix_(matrix), │ │ │ │ │ - 39 col_(col) │ │ │ │ │ - 40 {} │ │ │ │ │ - 41 │ │ │ │ │ - 42 constexpr size_type N () const { │ │ │ │ │ - 43 return matrix_.N(); │ │ │ │ │ - 44 } │ │ │ │ │ - 45 │ │ │ │ │ - 46 template and not std::is_const_v, int> = │ │ │ │ │ -0> │ │ │ │ │ - 48 constexpr value_type& operator[] (size_type row) { │ │ │ │ │ - 49 return matrix_[row][col_]; │ │ │ │ │ - 50 } │ │ │ │ │ - 51 │ │ │ │ │ - 52 constexpr const value_type& operator[] (size_type row) const { │ │ │ │ │ - 53 return matrix_[row][col_]; │ │ │ │ │ - 54 } │ │ │ │ │ - 55 │ │ │ │ │ - 56 protected: │ │ │ │ │ - 57 M& matrix_; │ │ │ │ │ - 58 const size_type col_; │ │ │ │ │ - 59 }; │ │ │ │ │ - 60 │ │ │ │ │ - 61 } │ │ │ │ │ - 62 │ │ │ │ │ - 63 template │ │ │ │ │ - 64 struct FieldTraits< Impl::ColumnVectorView > │ │ │ │ │ - 65 { │ │ │ │ │ - 66 using field_type = typename FieldTraits::field_type; │ │ │ │ │ - 67 using real_type = typename FieldTraits::real_type; │ │ │ │ │ - 68 }; │ │ │ │ │ - 69 │ │ │ │ │ - 81 template< class K, int ROWS, int COLS = ROWS > class FieldMatrix; │ │ │ │ │ - 82 │ │ │ │ │ - 83 │ │ │ │ │ - 84 template< class K, int ROWS, int COLS > │ │ │ │ │ -85 struct DenseMatVecTraits< FieldMatrix > │ │ │ │ │ - 86 { │ │ │ │ │ -87 typedef FieldMatrix derived_type; │ │ │ │ │ - 88 │ │ │ │ │ - 89 // each row is implemented by a field vector │ │ │ │ │ -90 typedef FieldVector row_type; │ │ │ │ │ - 91 │ │ │ │ │ -92 typedef row_type &row_reference; │ │ │ │ │ -93 typedef const row_type &const_row_reference; │ │ │ │ │ - 94 │ │ │ │ │ -95 typedef std::array container_type; │ │ │ │ │ -96 typedef K value_type; │ │ │ │ │ -97 typedef typename container_type::size_type size_type; │ │ │ │ │ - 98 }; │ │ │ │ │ - 99 │ │ │ │ │ - 100 template< class K, int ROWS, int COLS > │ │ │ │ │ -101 struct FieldTraits< FieldMatrix > │ │ │ │ │ - 102 { │ │ │ │ │ -103 typedef typename FieldTraits::field_type field_type; │ │ │ │ │ -104 typedef typename FieldTraits::real_type real_type; │ │ │ │ │ - 105 }; │ │ │ │ │ - 106 │ │ │ │ │ - 115 template │ │ │ │ │ -116 class FieldMatrix : public DenseMatrix< FieldMatrix > │ │ │ │ │ - 117 { │ │ │ │ │ - 118 std::array< FieldVector, ROWS > _data; │ │ │ │ │ - 119 typedef DenseMatrix<_FieldMatrix > Base; │ │ │ │ │ - 120 public: │ │ │ │ │ - 121 │ │ │ │ │ -123 constexpr static int rows = ROWS; │ │ │ │ │ -125 constexpr static int cols = COLS; │ │ │ │ │ - 126 │ │ │ │ │ -127 typedef typename Base::size_type size_type; │ │ │ │ │ -128 typedef typename Base::row_type row_type; │ │ │ │ │ - 129 │ │ │ │ │ -130 typedef typename Base::row_reference row_reference; │ │ │ │ │ -131 typedef typename Base::const_row_reference const_row_reference; │ │ │ │ │ - 132 │ │ │ │ │ - 133 //===== constructors │ │ │ │ │ -136 constexpr FieldMatrix() = default; │ │ │ │ │ - 137 │ │ │ │ │ -140 FieldMatrix(std::initializer_list > const &l) { │ │ │ │ │ - 141 assert(l.size() == rows); // Actually, this is not needed any more! │ │ │ │ │ - 142 std::copy_n(l.begin(), std::min(static_cast(ROWS), │ │ │ │ │ - 143 l.size()), │ │ │ │ │ - 144 _data.begin()); │ │ │ │ │ - 145 } │ │ │ │ │ - 146 │ │ │ │ │ - 147 template :: │ │ │ │ │ -value>> │ │ │ │ │ -149 FieldMatrix(T const& rhs) │ │ │ │ │ - 150 { │ │ │ │ │ - 151 *this = rhs; │ │ │ │ │ - 152 } │ │ │ │ │ - 153 │ │ │ │ │ - 154 using Base::operator=; │ │ │ │ │ - 155 │ │ │ │ │ -157 FieldMatrix& operator=(const FieldMatrix&) = default; │ │ │ │ │ - 158 │ │ │ │ │ - 160 template │ │ │ │ │ -161 FieldMatrix& operator=(const FieldMatrix& x) │ │ │ │ │ - 162 { │ │ │ │ │ - 163 _data = x._data; │ │ │ │ │ - 164 return *this; │ │ │ │ │ - 165 } │ │ │ │ │ - 166 │ │ │ │ │ - 168 template │ │ │ │ │ -169 FieldMatrix& operator=(FieldMatrix const&) = delete; │ │ │ │ │ - 170 │ │ │ │ │ -172 FieldMatrix transposed() const │ │ │ │ │ - 173 { │ │ │ │ │ - 174 Dune::FieldMatrix AT; │ │ │ │ │ - 175 for( int i = 0; i < ROWS; ++i ) │ │ │ │ │ - 176 for( int j = 0; j < COLS; ++j ) │ │ │ │ │ - 177 AT[j][i] = (*this)[i][j]; │ │ │ │ │ - 178 return AT; │ │ │ │ │ - 179 } │ │ │ │ │ - 180 │ │ │ │ │ - 182 template │ │ │ │ │ -183 friend auto operator+( const FieldMatrix& matrixA, │ │ │ │ │ - 184 const FieldMatrix& matrixB) │ │ │ │ │ - 185 { │ │ │ │ │ - 186 FieldMatrix:: │ │ │ │ │ -PromotedType,ROWS,COLS> result; │ │ │ │ │ - 187 │ │ │ │ │ - 188 for (size_type i = 0; i < ROWS; ++i) │ │ │ │ │ - 189 for (size_type j = 0; j < COLS; ++j) │ │ │ │ │ - 190 result[i][j] = matrixA[i][j] + matrixB[i][j]; │ │ │ │ │ - 191 │ │ │ │ │ - 192 return result; │ │ │ │ │ - 193 } │ │ │ │ │ - 194 │ │ │ │ │ - 196 template │ │ │ │ │ -197 friend auto operator-( const FieldMatrix& matrixA, │ │ │ │ │ - 198 const FieldMatrix& matrixB) │ │ │ │ │ - 199 { │ │ │ │ │ - 200 FieldMatrix:: │ │ │ │ │ -PromotedType,ROWS,COLS> result; │ │ │ │ │ - 201 │ │ │ │ │ - 202 for (size_type i = 0; i < ROWS; ++i) │ │ │ │ │ - 203 for (size_type j = 0; j < COLS; ++j) │ │ │ │ │ - 204 result[i][j] = matrixA[i][j] - matrixB[i][j]; │ │ │ │ │ - 205 │ │ │ │ │ - 206 return result; │ │ │ │ │ - 207 } │ │ │ │ │ - 208 │ │ │ │ │ - 210 template ::value, int> = 0> │ │ │ │ │ -212 friend auto operator*( const FieldMatrix& matrix, Scalar scalar) │ │ │ │ │ - 213 { │ │ │ │ │ - 214 FieldMatrix::PromotedType,ROWS,COLS> │ │ │ │ │ -result; │ │ │ │ │ - 215 │ │ │ │ │ - 216 for (size_type i = 0; i < ROWS; ++i) │ │ │ │ │ - 217 for (size_type j = 0; j < COLS; ++j) │ │ │ │ │ - 218 result[i][j] = matrix[i][j] * scalar; │ │ │ │ │ - 219 │ │ │ │ │ - 220 return result; │ │ │ │ │ - 221 } │ │ │ │ │ - 222 │ │ │ │ │ - 224 template ::value, int> = 0> │ │ │ │ │ -226 friend auto operator*( Scalar scalar, const FieldMatrix& matrix) │ │ │ │ │ - 227 { │ │ │ │ │ - 228 FieldMatrix::PromotedType,ROWS,COLS> │ │ │ │ │ -result; │ │ │ │ │ - 229 │ │ │ │ │ - 230 for (size_type i = 0; i < ROWS; ++i) │ │ │ │ │ - 231 for (size_type j = 0; j < COLS; ++j) │ │ │ │ │ - 232 result[i][j] = scalar * matrix[i][j]; │ │ │ │ │ - 233 │ │ │ │ │ - 234 return result; │ │ │ │ │ - 235 } │ │ │ │ │ - 236 │ │ │ │ │ - 238 template ::value, int> = 0> │ │ │ │ │ -240 friend auto operator/( const FieldMatrix& matrix, Scalar scalar) │ │ │ │ │ - 241 { │ │ │ │ │ - 242 FieldMatrix::PromotedType,ROWS,COLS> │ │ │ │ │ -result; │ │ │ │ │ - 243 │ │ │ │ │ - 244 for (size_type i = 0; i < ROWS; ++i) │ │ │ │ │ - 245 for (size_type j = 0; j < COLS; ++j) │ │ │ │ │ - 246 result[i][j] = matrix[i][j] / scalar; │ │ │ │ │ - 247 │ │ │ │ │ - 248 return result; │ │ │ │ │ - 249 } │ │ │ │ │ - 250 │ │ │ │ │ - 253 template │ │ │ │ │ -254 friend auto operator*( const FieldMatrix& matrixA, │ │ │ │ │ - 255 const FieldMatrix& matrixB) │ │ │ │ │ - 256 { │ │ │ │ │ - 257 FieldMatrix:: │ │ │ │ │ -PromotedType,ROWS,otherCols> result; │ │ │ │ │ - 258 │ │ │ │ │ - 259 for (size_type i = 0; i < matrixA.mat_rows(); ++i) │ │ │ │ │ - 260 for (size_type j = 0; j < matrixB.mat_cols(); ++j) │ │ │ │ │ - 261 { │ │ │ │ │ - 262 result[i][j] = 0; │ │ │ │ │ - 263 for (size_type k = 0; k < matrixA.mat_cols(); ++k) │ │ │ │ │ - 264 result[i][j] += matrixA[i][k] * matrixB[k][j]; │ │ │ │ │ - 265 } │ │ │ │ │ - 266 │ │ │ │ │ - 267 return result; │ │ │ │ │ - 268 } │ │ │ │ │ - 269 │ │ │ │ │ - 276 template │ │ │ │ │ - 278 and not Impl::IsFieldMatrix_v │ │ │ │ │ - 279 , int> = 0> │ │ │ │ │ -280 friend auto operator*( const FieldMatrix& matrixA, │ │ │ │ │ - 281 const OtherMatrix& matrixB) │ │ │ │ │ - 282 { │ │ │ │ │ - 283 using Field = typename PromotionTraits::PromotedType; │ │ │ │ │ - 284 Dune::FieldMatrix result; │ │ │ │ │ - 285 for (std::size_t j=0; j │ │ │ │ │ - 298 and not Impl::IsFieldMatrix_v │ │ │ │ │ - 299 , int> = 0> │ │ │ │ │ -300 friend auto operator*( const OtherMatrix& matrixA, │ │ │ │ │ - 301 const FieldMatrix& matrixB) │ │ │ │ │ - 302 { │ │ │ │ │ - 303 using Field = typename PromotionTraits::PromotedType; │ │ │ │ │ - 304 Dune::FieldMatrix result; │ │ │ │ │ - 305 for (std::size_t j=0; j │ │ │ │ │ -316 FieldMatrix leftmultiplyany (const FieldMatrix& M) │ │ │ │ │ -const │ │ │ │ │ - 317 { │ │ │ │ │ - 318 FieldMatrix C; │ │ │ │ │ - 319 │ │ │ │ │ - 320 for (size_type i=0; i │ │ │ │ │ -334 FieldMatrix& rightmultiply (const FieldMatrix& M) │ │ │ │ │ - 335 { │ │ │ │ │ - 336 static_assert(r == c, "Cannot rightmultiply with non-square matrix"); │ │ │ │ │ - 337 static_assert(r == cols, "Size mismatch"); │ │ │ │ │ - 338 FieldMatrix C(*this); │ │ │ │ │ - 339 │ │ │ │ │ - 340 for (size_type i=0; i │ │ │ │ │ -351 FieldMatrix rightmultiplyany (const FieldMatrix& M) │ │ │ │ │ -const │ │ │ │ │ - 352 { │ │ │ │ │ - 353 FieldMatrix C; │ │ │ │ │ - 354 │ │ │ │ │ - 355 for (size_type i=0; i │ │ │ │ │ - 386 class FieldMatrix : public DenseMatrix< FieldMatrix > │ │ │ │ │ - 387 { │ │ │ │ │ - 388 FieldVector _data; │ │ │ │ │ - 389 typedef DenseMatrix< FieldMatrix > Base; │ │ │ │ │ - 390 public: │ │ │ │ │ - 391 // standard constructor and everything is sufficient ... │ │ │ │ │ - 392 │ │ │ │ │ - 393 //===== type definitions and constants │ │ │ │ │ - 394 │ │ │ │ │ - 396 typedef typename Base::size_type size_type; │ │ │ │ │ - 397 │ │ │ │ │ - 400 constexpr static int blocklevel = 1; │ │ │ │ │ - 401 │ │ │ │ │ - 402 typedef typename Base::row_type row_type; │ │ │ │ │ - 403 │ │ │ │ │ - 404 typedef typename Base::row_reference row_reference; │ │ │ │ │ - 405 typedef typename Base::const_row_reference const_row_reference; │ │ │ │ │ - 406 │ │ │ │ │ - 409 constexpr static int rows = 1; │ │ │ │ │ - 412 constexpr static int cols = 1; │ │ │ │ │ - 413 │ │ │ │ │ - 414 //===== constructors │ │ │ │ │ - 417 constexpr FieldMatrix() = default; │ │ │ │ │ - 418 │ │ │ │ │ - 421 FieldMatrix(std::initializer_list> const &l) │ │ │ │ │ - 422 { │ │ │ │ │ - 423 std::copy_n(l.begin(), std::min(static_cast< std::size_t >( 1 ), l.size │ │ │ │ │ -()), &_data); │ │ │ │ │ - 424 } │ │ │ │ │ - 425 │ │ │ │ │ - 426 template :: │ │ │ │ │ -value>> │ │ │ │ │ - 428 FieldMatrix(T const& rhs) │ │ │ │ │ - 429 { │ │ │ │ │ - 430 *this = rhs; │ │ │ │ │ - 431 } │ │ │ │ │ - 432 │ │ │ │ │ - 433 using Base::operator=; │ │ │ │ │ - 434 │ │ │ │ │ - 436 FieldMatrix transposed() const │ │ │ │ │ - 437 { │ │ │ │ │ - 438 return *this; │ │ │ │ │ - 439 } │ │ │ │ │ - 440 │ │ │ │ │ - 442 template │ │ │ │ │ - 443 friend auto operator+( const FieldMatrix& matrixA, │ │ │ │ │ - 444 const FieldMatrix& matrixB) │ │ │ │ │ - 445 { │ │ │ │ │ - 446 return FieldMatrix:: │ │ │ │ │ -PromotedType,1,1>{matrixA[0][0] + matrixB[0][0]}; │ │ │ │ │ - 447 } │ │ │ │ │ - 448 │ │ │ │ │ - 450 template ::value, int> = 0> │ │ │ │ │ - 452 friend auto operator+( const FieldMatrix& matrix, │ │ │ │ │ - 453 const Scalar& scalar) │ │ │ │ │ - 454 { │ │ │ │ │ - 455 return FieldMatrix::PromotedType,1,1> │ │ │ │ │ -{matrix[0][0] + scalar}; │ │ │ │ │ - 456 } │ │ │ │ │ - 457 │ │ │ │ │ - 459 template ::value, int> = 0> │ │ │ │ │ - 461 friend auto operator+( const Scalar& scalar, │ │ │ │ │ - 462 const FieldMatrix& matrix) │ │ │ │ │ - 463 { │ │ │ │ │ - 464 return FieldMatrix::PromotedType,1,1> │ │ │ │ │ -{scalar + matrix[0][0]}; │ │ │ │ │ - 465 } │ │ │ │ │ - 466 │ │ │ │ │ - 468 template │ │ │ │ │ - 469 friend auto operator-( const FieldMatrix& matrixA, │ │ │ │ │ - 470 const FieldMatrix& matrixB) │ │ │ │ │ - 471 { │ │ │ │ │ - 472 return FieldMatrix:: │ │ │ │ │ -PromotedType,1,1>{matrixA[0][0] - matrixB[0][0]}; │ │ │ │ │ - 473 } │ │ │ │ │ - 474 │ │ │ │ │ - 476 template ::value, int> = 0> │ │ │ │ │ - 478 friend auto operator-( const FieldMatrix& matrix, │ │ │ │ │ - 479 const Scalar& scalar) │ │ │ │ │ - 480 { │ │ │ │ │ - 481 return FieldMatrix::PromotedType,1,1> │ │ │ │ │ -{matrix[0][0] - scalar}; │ │ │ │ │ - 482 } │ │ │ │ │ - 483 │ │ │ │ │ - 485 template ::value, int> = 0> │ │ │ │ │ - 487 friend auto operator-( const Scalar& scalar, │ │ │ │ │ - 488 const FieldMatrix& matrix) │ │ │ │ │ - 489 { │ │ │ │ │ - 490 return FieldMatrix::PromotedType,1,1> │ │ │ │ │ -{scalar - matrix[0][0]}; │ │ │ │ │ - 491 } │ │ │ │ │ - 492 │ │ │ │ │ - 494 template ::value, int> = 0> │ │ │ │ │ - 496 friend auto operator*( const FieldMatrix& matrix, Scalar scalar) │ │ │ │ │ - 497 { │ │ │ │ │ - 498 return FieldMatrix::PromotedType,1,1> │ │ │ │ │ -{matrix[0][0] * scalar}; │ │ │ │ │ - 499 } │ │ │ │ │ - 500 │ │ │ │ │ - 502 template ::value, int> = 0> │ │ │ │ │ - 504 friend auto operator*( Scalar scalar, const FieldMatrix& matrix) │ │ │ │ │ - 505 { │ │ │ │ │ - 506 return FieldMatrix::PromotedType,1,1> │ │ │ │ │ -{scalar * matrix[0][0]}; │ │ │ │ │ - 507 } │ │ │ │ │ - 508 │ │ │ │ │ - 510 template ::value, int> = 0> │ │ │ │ │ - 512 friend auto operator/( const FieldMatrix& matrix, Scalar scalar) │ │ │ │ │ - 513 { │ │ │ │ │ - 514 return FieldMatrix::PromotedType,1,1> │ │ │ │ │ -{matrix[0][0] / scalar}; │ │ │ │ │ - 515 } │ │ │ │ │ - 516 │ │ │ │ │ - 517 //===== solve │ │ │ │ │ - 518 │ │ │ │ │ - 521 template │ │ │ │ │ - 522 friend auto operator*( const FieldMatrix& matrixA, │ │ │ │ │ - 523 const FieldMatrix& matrixB) │ │ │ │ │ - 524 { │ │ │ │ │ - 525 FieldMatrix:: │ │ │ │ │ -PromotedType,1,otherCols> result; │ │ │ │ │ - 526 │ │ │ │ │ - 527 for (size_type j = 0; j < matrixB.mat_cols(); ++j) │ │ │ │ │ - 528 result[0][j] = matrixA[0][0] * matrixB[0][j]; │ │ │ │ │ - 529 │ │ │ │ │ - 530 return result; │ │ │ │ │ - 531 } │ │ │ │ │ - 532 │ │ │ │ │ - 539 template │ │ │ │ │ - 541 and not Impl::IsFieldMatrix_v │ │ │ │ │ - 542 and (OtherMatrix::rows==1) │ │ │ │ │ - 543 , int> = 0> │ │ │ │ │ - 544 friend auto operator*( const FieldMatrix& matrixA, │ │ │ │ │ - 545 const OtherMatrix& matrixB) │ │ │ │ │ - 546 { │ │ │ │ │ - 547 using Field = typename PromotionTraits::PromotedType; │ │ │ │ │ - 548 Dune::FieldMatrix result; │ │ │ │ │ - 549 for (std::size_t j=0; j │ │ │ │ │ - 562 and not Impl::IsFieldMatrix_v │ │ │ │ │ - 563 and (OtherMatrix::cols==1) │ │ │ │ │ - 564 , int> = 0> │ │ │ │ │ - 565 friend auto operator*( const OtherMatrix& matrixA, │ │ │ │ │ - 566 const FieldMatrix& matrixB) │ │ │ │ │ - 567 { │ │ │ │ │ - 568 using Field = typename PromotionTraits::PromotedType; │ │ │ │ │ - 569 Dune::FieldMatrix result; │ │ │ │ │ - 570 for (std::size_t j=0; j │ │ │ │ │ - 581 FieldMatrix leftmultiplyany (const FieldMatrix& M) const │ │ │ │ │ - 582 { │ │ │ │ │ - 583 FieldMatrix C; │ │ │ │ │ - 584 for (size_type j=0; j │ │ │ │ │ - 598 FieldMatrix rightmultiplyany (const FieldMatrix& M) const │ │ │ │ │ - 599 { │ │ │ │ │ - 600 FieldMatrix C; │ │ │ │ │ - 601 │ │ │ │ │ - 602 for (size_type j=0; j │ │ │ │ │ - 659 std::ostream& operator<<(std::ostream& s, const FieldMatrix& a) │ │ │ │ │ - 660 { │ │ │ │ │ - 661 s << a[0][0]; │ │ │ │ │ - 662 return s; │ │ │ │ │ - 663 } │ │ │ │ │ - 664 │ │ │ │ │ - 665#endif // DOXYGEN │ │ │ │ │ - 666 │ │ │ │ │ -667 namespace FMatrixHelp { │ │ │ │ │ - 668 │ │ │ │ │ - 670 template │ │ │ │ │ -671 static inline K invertMatrix (const FieldMatrix &matrix, │ │ │ │ │ -FieldMatrix &inverse) │ │ │ │ │ - 672 { │ │ │ │ │ - 673 using real_type = typename FieldTraits::real_type; │ │ │ │ │ - 674 inverse[0][0] = real_type(1.0)/matrix[0][0]; │ │ │ │ │ - 675 return matrix[0][0]; │ │ │ │ │ - 676 } │ │ │ │ │ - 677 │ │ │ │ │ - 679 template │ │ │ │ │ -680 static inline K invertMatrix_retTransposed (const FieldMatrix │ │ │ │ │ -&matrix, FieldMatrix &inverse) │ │ │ │ │ - 681 { │ │ │ │ │ - 682 return invertMatrix(matrix,inverse); │ │ │ │ │ - 683 } │ │ │ │ │ - 684 │ │ │ │ │ - 685 │ │ │ │ │ - 687 template │ │ │ │ │ -688 static inline K invertMatrix (const FieldMatrix &matrix, │ │ │ │ │ -FieldMatrix &inverse) │ │ │ │ │ - 689 { │ │ │ │ │ - 690 using real_type = typename FieldTraits::real_type; │ │ │ │ │ - 691 // code generated by maple │ │ │ │ │ - 692 K det = (matrix[0][0]*matrix[1][1] - matrix[0][1]*matrix[1][0]); │ │ │ │ │ - 693 K det_1 = real_type(1.0)/det; │ │ │ │ │ - 694 inverse[0][0] = matrix[1][1] * det_1; │ │ │ │ │ - 695 inverse[0][1] = - matrix[0][1] * det_1; │ │ │ │ │ - 696 inverse[1][0] = - matrix[1][0] * det_1; │ │ │ │ │ - 697 inverse[1][1] = matrix[0][0] * det_1; │ │ │ │ │ - 698 return det; │ │ │ │ │ - 699 } │ │ │ │ │ - 700 │ │ │ │ │ - 703 template │ │ │ │ │ -704 static inline K invertMatrix_retTransposed (const FieldMatrix │ │ │ │ │ -&matrix, FieldMatrix &inverse) │ │ │ │ │ - 705 { │ │ │ │ │ - 706 using real_type = typename FieldTraits::real_type; │ │ │ │ │ - 707 // code generated by maple │ │ │ │ │ - 708 K det = (matrix[0][0]*matrix[1][1] - matrix[0][1]*matrix[1][0]); │ │ │ │ │ - 709 K det_1 = real_type(1.0)/det; │ │ │ │ │ - 710 inverse[0][0] = matrix[1][1] * det_1; │ │ │ │ │ - 711 inverse[1][0] = - matrix[0][1] * det_1; │ │ │ │ │ - 712 inverse[0][1] = - matrix[1][0] * det_1; │ │ │ │ │ - 713 inverse[1][1] = matrix[0][0] * det_1; │ │ │ │ │ - 714 return det; │ │ │ │ │ - 715 } │ │ │ │ │ - 716 │ │ │ │ │ - 718 template │ │ │ │ │ -719 static inline K invertMatrix (const FieldMatrix &matrix, │ │ │ │ │ -FieldMatrix &inverse) │ │ │ │ │ - 720 { │ │ │ │ │ - 721 using real_type = typename FieldTraits::real_type; │ │ │ │ │ - 722 // code generated by maple │ │ │ │ │ - 723 K t4 = matrix[0][0] * matrix[1][1]; │ │ │ │ │ - 724 K t6 = matrix[0][0] * matrix[1][2]; │ │ │ │ │ - 725 K t8 = matrix[0][1] * matrix[1][0]; │ │ │ │ │ - 726 K t10 = matrix[0][2] * matrix[1][0]; │ │ │ │ │ - 727 K t12 = matrix[0][1] * matrix[2][0]; │ │ │ │ │ - 728 K t14 = matrix[0][2] * matrix[2][0]; │ │ │ │ │ - 729 │ │ │ │ │ - 730 K det = (t4*matrix[2][2]-t6*matrix[2][1]-t8*matrix[2][2]+ │ │ │ │ │ - 731 t10*matrix[2][1]+t12*matrix[1][2]-t14*matrix[1][1]); │ │ │ │ │ - 732 K t17 = real_type(1.0)/det; │ │ │ │ │ - 733 │ │ │ │ │ - 734 inverse[0][0] = (matrix[1][1] * matrix[2][2] - matrix[1][2] * matrix[2] │ │ │ │ │ -[1])*t17; │ │ │ │ │ - 735 inverse[0][1] = -(matrix[0][1] * matrix[2][2] - matrix[0][2] * matrix[2] │ │ │ │ │ -[1])*t17; │ │ │ │ │ - 736 inverse[0][2] = (matrix[0][1] * matrix[1][2] - matrix[0][2] * matrix[1] │ │ │ │ │ -[1])*t17; │ │ │ │ │ - 737 inverse[1][0] = -(matrix[1][0] * matrix[2][2] - matrix[1][2] * matrix[2] │ │ │ │ │ -[0])*t17; │ │ │ │ │ - 738 inverse[1][1] = (matrix[0][0] * matrix[2][2] - t14) * t17; │ │ │ │ │ - 739 inverse[1][2] = -(t6-t10) * t17; │ │ │ │ │ - 740 inverse[2][0] = (matrix[1][0] * matrix[2][1] - matrix[1][1] * matrix[2] │ │ │ │ │ -[0]) * t17; │ │ │ │ │ - 741 inverse[2][1] = -(matrix[0][0] * matrix[2][1] - t12) * t17; │ │ │ │ │ - 742 inverse[2][2] = (t4-t8) * t17; │ │ │ │ │ - 743 │ │ │ │ │ - 744 return det; │ │ │ │ │ - 745 } │ │ │ │ │ - 746 │ │ │ │ │ - 748 template │ │ │ │ │ -749 static inline K invertMatrix_retTransposed (const FieldMatrix │ │ │ │ │ -&matrix, FieldMatrix &inverse) │ │ │ │ │ - 750 { │ │ │ │ │ - 751 using real_type = typename FieldTraits::real_type; │ │ │ │ │ - 752 // code generated by maple │ │ │ │ │ - 753 K t4 = matrix[0][0] * matrix[1][1]; │ │ │ │ │ - 754 K t6 = matrix[0][0] * matrix[1][2]; │ │ │ │ │ - 755 K t8 = matrix[0][1] * matrix[1][0]; │ │ │ │ │ - 756 K t10 = matrix[0][2] * matrix[1][0]; │ │ │ │ │ - 757 K t12 = matrix[0][1] * matrix[2][0]; │ │ │ │ │ - 758 K t14 = matrix[0][2] * matrix[2][0]; │ │ │ │ │ - 759 │ │ │ │ │ - 760 K det = (t4*matrix[2][2]-t6*matrix[2][1]-t8*matrix[2][2]+ │ │ │ │ │ - 761 t10*matrix[2][1]+t12*matrix[1][2]-t14*matrix[1][1]); │ │ │ │ │ - 762 K t17 = real_type(1.0)/det; │ │ │ │ │ - 763 │ │ │ │ │ - 764 inverse[0][0] = (matrix[1][1] * matrix[2][2] - matrix[1][2] * matrix[2] │ │ │ │ │ -[1])*t17; │ │ │ │ │ - 765 inverse[1][0] = -(matrix[0][1] * matrix[2][2] - matrix[0][2] * matrix[2] │ │ │ │ │ -[1])*t17; │ │ │ │ │ - 766 inverse[2][0] = (matrix[0][1] * matrix[1][2] - matrix[0][2] * matrix[1] │ │ │ │ │ -[1])*t17; │ │ │ │ │ - 767 inverse[0][1] = -(matrix[1][0] * matrix[2][2] - matrix[1][2] * matrix[2] │ │ │ │ │ -[0])*t17; │ │ │ │ │ - 768 inverse[1][1] = (matrix[0][0] * matrix[2][2] - t14) * t17; │ │ │ │ │ - 769 inverse[2][1] = -(t6-t10) * t17; │ │ │ │ │ - 770 inverse[0][2] = (matrix[1][0] * matrix[2][1] - matrix[1][1] * matrix[2] │ │ │ │ │ -[0]) * t17; │ │ │ │ │ - 771 inverse[1][2] = -(matrix[0][0] * matrix[2][1] - t12) * t17; │ │ │ │ │ - 772 inverse[2][2] = (t4-t8) * t17; │ │ │ │ │ - 773 │ │ │ │ │ - 774 return det; │ │ │ │ │ - 775 } │ │ │ │ │ - 776 │ │ │ │ │ - 778 template< class K, int m, int n, int p > │ │ │ │ │ -779 static inline void multMatrix ( const FieldMatrix<_K,_m,_n_> &A, │ │ │ │ │ - 780 const FieldMatrix<_K,_n,_p_> &B, │ │ │ │ │ - 781 FieldMatrix<_K,_m,_p_> &ret ) │ │ │ │ │ - 782 { │ │ │ │ │ - 783 typedef typename FieldMatrix<_K,_m,_p_> :: size_type size_type; │ │ │ │ │ - 784 │ │ │ │ │ - 785 for( size_type i = 0; i < m; ++i ) │ │ │ │ │ - 786 { │ │ │ │ │ - 787 for( size_type j = 0; j < p; ++j ) │ │ │ │ │ - 788 { │ │ │ │ │ - 789 ret[ i ][ j ] = K( 0 ); │ │ │ │ │ - 790 for( size_type k = 0; k < n; ++k ) │ │ │ │ │ - 791 ret[ i ][ j ] += A[ i ][ k ] * B[ k ][ j ]; │ │ │ │ │ - 792 } │ │ │ │ │ - 793 } │ │ │ │ │ - 794 } │ │ │ │ │ - 795 │ │ │ │ │ - 797 template │ │ │ │ │ -798 static inline void multTransposedMatrix(const FieldMatrix │ │ │ │ │ -&matrix, FieldMatrix& ret) │ │ │ │ │ - 799 { │ │ │ │ │ - 800 typedef typename FieldMatrix::size_type size_type; │ │ │ │ │ - 801 │ │ │ │ │ - 802 for(size_type i=0; i │ │ │ │ │ -815 static inline void multAssignTransposed( const FieldMatrix │ │ │ │ │ -&matrix, const FieldVector & x, FieldVector & ret) │ │ │ │ │ - 816 { │ │ │ │ │ - 817 typedef typename FieldMatrix::size_type size_type; │ │ │ │ │ - 818 │ │ │ │ │ - 819 for(size_type i=0; i │ │ │ │ │ -829 static inline FieldVector mult(const FieldMatrix │ │ │ │ │ -&matrix, const FieldVector & x) │ │ │ │ │ - 830 { │ │ │ │ │ - 831 FieldVector ret; │ │ │ │ │ - 832 multAssign(matrix,x,ret); │ │ │ │ │ - 833 return ret; │ │ │ │ │ - 834 } │ │ │ │ │ - 835 │ │ │ │ │ - 837 template │ │ │ │ │ -838 static inline FieldVector multTransposed(const │ │ │ │ │ -FieldMatrix &matrix, const FieldVector & x) │ │ │ │ │ - 839 { │ │ │ │ │ - 840 FieldVector ret; │ │ │ │ │ - 841 multAssignTransposed( matrix, x, ret ); │ │ │ │ │ - 842 return ret; │ │ │ │ │ - 843 } │ │ │ │ │ - 844 │ │ │ │ │ - 845 } // end namespace FMatrixHelp │ │ │ │ │ - 846 │ │ │ │ │ - 849} // end namespace │ │ │ │ │ - 850 │ │ │ │ │ - 851#include "fmatrixev.hh" │ │ │ │ │ - 852#endif │ │ │ │ │ -promotiontraits.hh │ │ │ │ │ -Compute type of the result of an arithmetic operation involving two different │ │ │ │ │ -number types. │ │ │ │ │ -typetraits.hh │ │ │ │ │ -Traits for type conversions and type information. │ │ │ │ │ -exceptions.hh │ │ │ │ │ -A few common exception classes. │ │ │ │ │ -precision.hh │ │ │ │ │ -Various precision settings for calculations with FieldMatrix and FieldVector. │ │ │ │ │ -densematrix.hh │ │ │ │ │ -Implements a matrix constructed from a given type representing a field and a │ │ │ │ │ -compile-time given numbe... │ │ │ │ │ -fvector.hh │ │ │ │ │ -Implements a vector constructed from a given type representing a field and a │ │ │ │ │ -compile-time given size. │ │ │ │ │ -matrixconcepts.hh │ │ │ │ │ -boundschecking.hh │ │ │ │ │ -Macro for wrapping boundary checks. │ │ │ │ │ -fmatrixev.hh │ │ │ │ │ -Eigenvalue computations for the FieldMatrix class. │ │ │ │ │ -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 │ │ │ │ │ -Dune::operator<< │ │ │ │ │ -std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x) │ │ │ │ │ -Definition bigunsignedint.hh:278 │ │ │ │ │ -Dune::Simd::Scalar │ │ │ │ │ -typename Overloads::ScalarType< std::decay_t< V > >::type Scalar │ │ │ │ │ -Element type of some SIMD type. │ │ │ │ │ -Definition simd/interface.hh:235 │ │ │ │ │ -Dune │ │ │ │ │ -Dune namespace. │ │ │ │ │ -Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::DenseMatrixHelp::multAssign │ │ │ │ │ -static void multAssign(const DenseMatrix< MAT > &matrix, const DenseVector< V1 │ │ │ │ │ -> &x, DenseVector< V2 > &ret) │ │ │ │ │ -calculates ret = matrix * x │ │ │ │ │ -Definition densematrix.hh:1169 │ │ │ │ │ -Dune::FMatrixHelp::multTransposed │ │ │ │ │ -static FieldVector< K, cols > multTransposed(const FieldMatrix< K, rows, cols > │ │ │ │ │ -&matrix, const FieldVector< K, rows > &x) │ │ │ │ │ -calculates ret = matrix^T * x │ │ │ │ │ -Definition fmatrix.hh:838 │ │ │ │ │ -Dune::FMatrixHelp::invertMatrix_retTransposed │ │ │ │ │ -static K invertMatrix_retTransposed(const FieldMatrix< K, 1, 1 > &matrix, │ │ │ │ │ -FieldMatrix< K, 1, 1 > &inverse) │ │ │ │ │ -invert scalar without changing the original matrix │ │ │ │ │ -Definition fmatrix.hh:680 │ │ │ │ │ -Dune::FMatrixHelp::multMatrix │ │ │ │ │ -static void multMatrix(const FieldMatrix< K, m, n > &A, const FieldMatrix< K, │ │ │ │ │ -n, p > &B, FieldMatrix< K, m, p > &ret) │ │ │ │ │ -calculates ret = A * B │ │ │ │ │ -Definition fmatrix.hh:779 │ │ │ │ │ -Dune::FMatrixHelp::invertMatrix │ │ │ │ │ -static K invertMatrix(const FieldMatrix< K, 1, 1 > &matrix, FieldMatrix< K, 1, │ │ │ │ │ -1 > &inverse) │ │ │ │ │ -invert scalar without changing the original matrix │ │ │ │ │ -Definition fmatrix.hh:671 │ │ │ │ │ -Dune::FMatrixHelp::mult │ │ │ │ │ -static FieldVector< K, rows > mult(const FieldMatrix< K, rows, cols > &matrix, │ │ │ │ │ -const FieldVector< K, cols > &x) │ │ │ │ │ -calculates ret = matrix * x │ │ │ │ │ -Definition fmatrix.hh:829 │ │ │ │ │ -Dune::FMatrixHelp::multTransposedMatrix │ │ │ │ │ -static void multTransposedMatrix(const FieldMatrix< K, rows, cols > &matrix, │ │ │ │ │ -FieldMatrix< K, cols, cols > &ret) │ │ │ │ │ -calculates ret= A_t*A │ │ │ │ │ -Definition fmatrix.hh:798 │ │ │ │ │ -Dune::FMatrixHelp::multAssignTransposed │ │ │ │ │ -static void multAssignTransposed(const FieldMatrix< K, rows, cols > &matrix, │ │ │ │ │ -const FieldVector< K, rows > &x, FieldVector< K, cols > &ret) │ │ │ │ │ -calculates ret = matrix^T * x │ │ │ │ │ -Definition fmatrix.hh:815 │ │ │ │ │ -Dune::DenseMatrix │ │ │ │ │ -A dense n x m matrix. │ │ │ │ │ -Definition densematrix.hh:140 │ │ │ │ │ -Dune::DenseMatrix::mtv │ │ │ │ │ -void mtv(const X &x, Y &y) const │ │ │ │ │ -y = A^T x │ │ │ │ │ -Definition densematrix.hh:387 │ │ │ │ │ -Dune::DenseMatrix<_FieldMatrix<_K,_ROWS,_COLS_>_>::M │ │ │ │ │ -constexpr size_type M() const │ │ │ │ │ -number of columns │ │ │ │ │ -Definition densematrix.hh:703 │ │ │ │ │ -Dune::DenseMatrix<_FieldMatrix<_K,_ROWS,_COLS_>_>::rightmultiply │ │ │ │ │ -FieldMatrix< K, ROWS, COLS > & rightmultiply(const DenseMatrix< M2 > &M) │ │ │ │ │ -Multiplies M from the right to this matrix. │ │ │ │ │ -Definition densematrix.hh:645 │ │ │ │ │ -Dune::DenseMatrix<_FieldMatrix<_K,_ROWS,_COLS_>_>::operator/= │ │ │ │ │ -derived_type & operator/=(const field_type &k) │ │ │ │ │ -vector space division by scalar │ │ │ │ │ -Definition densematrix.hh:329 │ │ │ │ │ -Dune::DenseMatrix<_FieldMatrix<_K,_ROWS,_COLS_>_>::operator*= │ │ │ │ │ -derived_type & operator*=(const field_type &k) │ │ │ │ │ -vector space multiplication with scalar │ │ │ │ │ -Definition densematrix.hh:321 │ │ │ │ │ -Dune::DenseMatrix<_FieldMatrix<_K,_ROWS,_COLS_>_>::operator-= │ │ │ │ │ -derived_type & operator-=(const DenseMatrix< Other > &x) │ │ │ │ │ -vector space subtraction │ │ │ │ │ -Definition densematrix.hh:312 │ │ │ │ │ -Dune::DenseMatrix<_FieldMatrix<_K,_ROWS,_COLS_>_>::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<_FieldMatrix<_K,_ROWS,_COLS_>_>::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<_FieldMatrix<_K,_ROWS,_COLS_>_>::size_type │ │ │ │ │ -Traits::size_type size_type │ │ │ │ │ -The type used for the index access and size operation. │ │ │ │ │ -Definition densematrix.hh:166 │ │ │ │ │ -Dune::DenseMatrix<_FieldMatrix<_K,_ROWS,_COLS_>_>::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<_FieldMatrix<_K,_ROWS,_COLS_>_>::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::DenseMatrix<_FieldMatrix<_K,_ROWS,_COLS_>_>::operator+= │ │ │ │ │ -derived_type & operator+=(const DenseMatrix< Other > &x) │ │ │ │ │ -vector space addition │ │ │ │ │ -Definition densematrix.hh:289 │ │ │ │ │ -Dune::FieldMatrix │ │ │ │ │ -A dense n x m matrix. │ │ │ │ │ -Definition fmatrix.hh:117 │ │ │ │ │ -Dune::FieldMatrix::mat_cols │ │ │ │ │ -static constexpr size_type mat_cols() │ │ │ │ │ -Definition fmatrix.hh:367 │ │ │ │ │ -Dune::FieldMatrix::FieldMatrix │ │ │ │ │ -constexpr FieldMatrix()=default │ │ │ │ │ -Default constructor. │ │ │ │ │ -Dune::FieldMatrix::const_row_reference │ │ │ │ │ -Base::const_row_reference const_row_reference │ │ │ │ │ -Definition fmatrix.hh:131 │ │ │ │ │ -Dune::FieldMatrix::operator= │ │ │ │ │ -FieldMatrix & operator=(const FieldMatrix< T, ROWS, COLS > &x) │ │ │ │ │ -copy assignment from FieldMatrix over a different field │ │ │ │ │ -Definition fmatrix.hh:161 │ │ │ │ │ -Dune::FieldMatrix::rightmultiplyany │ │ │ │ │ -FieldMatrix< K, rows, l > rightmultiplyany(const FieldMatrix< K, cols, l > &M) │ │ │ │ │ -const │ │ │ │ │ -Multiplies M from the right to this matrix, this matrix is not modified. │ │ │ │ │ -Definition fmatrix.hh:351 │ │ │ │ │ -Dune::FieldMatrix::row_type │ │ │ │ │ -Base::row_type row_type │ │ │ │ │ -Definition fmatrix.hh:128 │ │ │ │ │ -Dune::FieldMatrix::size_type │ │ │ │ │ -Base::size_type size_type │ │ │ │ │ -Definition fmatrix.hh:127 │ │ │ │ │ -Dune::FieldMatrix::leftmultiplyany │ │ │ │ │ -FieldMatrix< K, l, cols > leftmultiplyany(const FieldMatrix< K, l, rows > &M) │ │ │ │ │ -const │ │ │ │ │ -Multiplies M from the left to this matrix, this matrix is not modified. │ │ │ │ │ -Definition fmatrix.hh:316 │ │ │ │ │ -Dune::FieldMatrix::rightmultiply │ │ │ │ │ -FieldMatrix & rightmultiply(const FieldMatrix< K, r, c > &M) │ │ │ │ │ -Multiplies M from the right to this matrix. │ │ │ │ │ -Definition fmatrix.hh:334 │ │ │ │ │ -Dune::FieldMatrix::FieldMatrix │ │ │ │ │ -FieldMatrix(T const &rhs) │ │ │ │ │ -Definition fmatrix.hh:149 │ │ │ │ │ -Dune::FieldMatrix::operator* │ │ │ │ │ -friend auto operator*(const FieldMatrix &matrix, Scalar scalar) │ │ │ │ │ -vector space multiplication with scalar │ │ │ │ │ -Definition fmatrix.hh:212 │ │ │ │ │ -Dune::FieldMatrix::operator= │ │ │ │ │ -FieldMatrix & operator=(FieldMatrix< T, rows, cols > const &)=delete │ │ │ │ │ -no copy assignment from FieldMatrix of different size │ │ │ │ │ -Dune::FieldMatrix::row_reference │ │ │ │ │ -Base::row_reference row_reference │ │ │ │ │ -Definition fmatrix.hh:130 │ │ │ │ │ -Dune::FieldMatrix::mat_access │ │ │ │ │ -row_reference mat_access(size_type i) │ │ │ │ │ -Definition fmatrix.hh:369 │ │ │ │ │ -Dune::FieldMatrix::rows │ │ │ │ │ -static constexpr int rows │ │ │ │ │ -The number of rows. │ │ │ │ │ -Definition fmatrix.hh:123 │ │ │ │ │ -Dune::FieldMatrix::transposed │ │ │ │ │ -FieldMatrix< K, COLS, ROWS > transposed() const │ │ │ │ │ -Return transposed of the matrix as FieldMatrix. │ │ │ │ │ -Definition fmatrix.hh:172 │ │ │ │ │ -Dune::FieldMatrix::mat_rows │ │ │ │ │ -static constexpr size_type mat_rows() │ │ │ │ │ -Definition fmatrix.hh:366 │ │ │ │ │ -Dune::FieldMatrix::FieldMatrix │ │ │ │ │ -FieldMatrix(std::initializer_list< Dune::FieldVector< K, cols > > const &l) │ │ │ │ │ -Constructor initializing the matrix from a list of vector. │ │ │ │ │ -Definition fmatrix.hh:140 │ │ │ │ │ -Dune::FieldMatrix::cols │ │ │ │ │ -static constexpr int cols │ │ │ │ │ -The number of columns. │ │ │ │ │ -Definition fmatrix.hh:125 │ │ │ │ │ -Dune::FieldMatrix::operator/ │ │ │ │ │ -friend auto operator/(const FieldMatrix &matrix, Scalar scalar) │ │ │ │ │ -vector space division by scalar │ │ │ │ │ -Definition fmatrix.hh:240 │ │ │ │ │ -Dune::FieldMatrix::operator+ │ │ │ │ │ -friend auto operator+(const FieldMatrix &matrixA, const FieldMatrix< │ │ │ │ │ -OtherScalar, ROWS, COLS > &matrixB) │ │ │ │ │ -vector space addition – two-argument version │ │ │ │ │ -Definition fmatrix.hh:183 │ │ │ │ │ -Dune::FieldMatrix::operator= │ │ │ │ │ -FieldMatrix & operator=(const FieldMatrix &)=default │ │ │ │ │ -copy assignment operator │ │ │ │ │ -Dune::FieldMatrix::operator- │ │ │ │ │ -friend auto operator-(const FieldMatrix &matrixA, const FieldMatrix< │ │ │ │ │ -OtherScalar, ROWS, COLS > &matrixB) │ │ │ │ │ -vector space subtraction – two-argument version │ │ │ │ │ -Definition fmatrix.hh:197 │ │ │ │ │ -Dune::FieldMatrix::mat_access │ │ │ │ │ -const_row_reference mat_access(size_type i) const │ │ │ │ │ -Definition fmatrix.hh:375 │ │ │ │ │ -Dune::FieldVector │ │ │ │ │ -vector space out of a tensor product of fields. │ │ │ │ │ -Definition fvector.hh:95 │ │ │ │ │ -Dune::DenseMatVecTraits<_FieldMatrix<_K,_ROWS,_COLS_>_>::container_type │ │ │ │ │ -std::array< row_type, ROWS > container_type │ │ │ │ │ -Definition fmatrix.hh:95 │ │ │ │ │ -Dune::DenseMatVecTraits<_FieldMatrix<_K,_ROWS,_COLS_>_>::derived_type │ │ │ │ │ -FieldMatrix< K, ROWS, COLS > derived_type │ │ │ │ │ -Definition fmatrix.hh:87 │ │ │ │ │ -Dune::DenseMatVecTraits<_FieldMatrix<_K,_ROWS,_COLS_>_>::value_type │ │ │ │ │ -K value_type │ │ │ │ │ -Definition fmatrix.hh:96 │ │ │ │ │ -Dune::DenseMatVecTraits<_FieldMatrix<_K,_ROWS,_COLS_>_>::const_row_reference │ │ │ │ │ -const row_type & const_row_reference │ │ │ │ │ -Definition fmatrix.hh:93 │ │ │ │ │ -Dune::DenseMatVecTraits<_FieldMatrix<_K,_ROWS,_COLS_>_>::row_type │ │ │ │ │ -FieldVector< K, COLS > row_type │ │ │ │ │ -Definition fmatrix.hh:90 │ │ │ │ │ -Dune::DenseMatVecTraits<_FieldMatrix<_K,_ROWS,_COLS_>_>::size_type │ │ │ │ │ -container_type::size_type size_type │ │ │ │ │ -Definition fmatrix.hh:97 │ │ │ │ │ -Dune::DenseMatVecTraits<_FieldMatrix<_K,_ROWS,_COLS_>_>::row_reference │ │ │ │ │ -row_type & row_reference │ │ │ │ │ -Definition fmatrix.hh:92 │ │ │ │ │ -Dune::FieldTraits<_FieldMatrix<_K,_ROWS,_COLS_>_>::field_type │ │ │ │ │ -FieldTraits< K >::field_type field_type │ │ │ │ │ -Definition fmatrix.hh:103 │ │ │ │ │ -Dune::FieldTraits<_FieldMatrix<_K,_ROWS,_COLS_>_>::real_type │ │ │ │ │ -FieldTraits< K >::real_type real_type │ │ │ │ │ -Definition fmatrix.hh:104 │ │ │ │ │ -Dune::FieldTraits │ │ │ │ │ -Definition ftraits.hh:26 │ │ │ │ │ -Dune::FieldTraits::field_type │ │ │ │ │ -T field_type │ │ │ │ │ -export the type representing the field │ │ │ │ │ -Definition ftraits.hh:28 │ │ │ │ │ -Dune::FieldTraits::real_type │ │ │ │ │ -T real_type │ │ │ │ │ -export the type representing the real type of the field │ │ │ │ │ -Definition ftraits.hh:30 │ │ │ │ │ -Dune::DenseMatVecTraits │ │ │ │ │ -Definition matvectraits.hh:31 │ │ │ │ │ -Dune::PromotionTraits::PromotedType │ │ │ │ │ -decltype(std::declval< T1 >()+std::declval< T2 >()) PromotedType │ │ │ │ │ -Definition promotiontraits.hh:28 │ │ │ │ │ + 2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ + 3// Will be removed after the 2.7 release │ │ │ │ │ + 4#warning "Deprecated header, use #include instead!" │ │ │ │ │ + 5#include │ │ │ │ │ +communication.hh │ │ │ │ │ +Implements an utility class that provides collective communication methods for │ │ │ │ │ +sequential programs. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00065.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: poolallocator.hh File Reference │ │ │ │ +dune-common: mpi_collective_benchmark.cc File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,91 +65,330 @@ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ -Classes | │ │ │ │ -Namespaces | │ │ │ │ -Functions
    │ │ │ │ -
    poolallocator.hh File Reference
    │ │ │ │ +Functions | │ │ │ │ +Variables
    │ │ │ │ +
    mpi_collective_benchmark.cc File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ - │ │ │ │ -

    An stl-compliant pool allocator. │ │ │ │ -More...

    │ │ │ │ -
    #include <numeric>
    │ │ │ │ -#include <typeinfo>
    │ │ │ │ +
    #include <config.h>
    │ │ │ │ #include <iostream>
    │ │ │ │ -#include <cassert>
    │ │ │ │ -#include <new>
    │ │ │ │ -
    │ │ │ │ -

    Go to the source code of this file.

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

    │ │ │ │ -Classes

    class  Dune::Pool< T, s >
     A memory pool of objects. More...
     
    class  Dune::PoolAllocator< T, s >
     An allocator managing a pool of objects for reuse. More...
     
    struct  Dune::PoolAllocator< T, s >::rebind< U >
     Rebind the allocator to another type. More...
     
    class  Dune::PoolAllocator< void, s >
     
    struct  Dune::PoolAllocator< void, s >::rebind< U >
     
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

    │ │ │ │ -Namespaces

    namespace  Dune
     Dune namespace.
     
    namespace  std
     STL namespace.
     
    │ │ │ │ +#include <iomanip>
    │ │ │ │ +#include <thread>
    │ │ │ │ +#include <dune/common/parallel/mpihelper.hh>
    │ │ │ │ +#include <dune/common/timer.hh>
    │ │ │ │ +#include <dune/common/parametertree.hh>
    │ │ │ │ +#include <dune/common/parametertreeparser.hh>
    │ │ │ │ +
    │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

    │ │ │ │ Functions

    template<typename T1 , std::size_t t1, typename T2 , std::size_t t2>
    bool Dune::operator== (const PoolAllocator< T1, t1 > &, const PoolAllocator< T2, t2 > &)
     
    template<typename T1 , std::size_t t1, typename T2 , std::size_t t2>
    bool Dune::operator!= (const PoolAllocator< T1, t1 > &, const PoolAllocator< T2, t2 > &)
     
    template<typename T , std::size_t t1, std::size_t t2>
    bool Dune::operator== (const PoolAllocator< T, t1 > &p1, const PoolAllocator< T, t2 > &p2)
     
    template<typename T , std::size_t t1, std::size_t t2>
    bool Dune::operator!= (const PoolAllocator< T, t1 > &p1, const PoolAllocator< T, t2 > &p2)
     
    template<typename T , std::size_t t1, std::size_t t2>
    bool Dune::operator== (const PoolAllocator< void, t1 > &, const PoolAllocator< T, t2 > &)
     
    template<typename T , std::size_t t1, std::size_t t2>
    bool Dune::operator!= (const PoolAllocator< void, t1 > &, const PoolAllocator< T, t2 > &)
     
    template<std::size_t t1, std::size_t t2>
    bool Dune::operator== (const PoolAllocator< void, t1 > &p1, const PoolAllocator< void, t2 > &p2)
     
    template<std::size_t t1, std::size_t t2>
    bool Dune::operator!= (const PoolAllocator< void, t1 > &p1, const PoolAllocator< void, t2 > &p2)
     
    template<class CC >
    void communicate (CC &cc)
     
    template<class CC >
    Dune::Future< void > startCommunication (CC &cc)
     
    template<class CC >
    double runBlocking (CC &cc)
     
    template<class CC >
    double runNonblockingWait (CC &cc)
     
    std::tuple< double, double > runNonblockingSleep (decltype(Dune::MPIHelper::getCommunication())&cc, std::chrono::duration< double > wait_time)
     
    std::tuple< double, double > runNonblockingActive (decltype(Dune::MPIHelper::getCommunication())&cc, std::chrono::duration< double > wait_time)
     
    std::tuple< double, double > determineOverlap (std::function< std::tuple< double, double >(std::chrono::duration< double >)> fun)
     
    void printHeader ()
     
    void run (int s)
     
    int main (int argc, char **argv)
     
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

    │ │ │ │ +Variables

    Dune::ParameterTree options
     Benchmark for measure the possible overlap of computation and communication at MPI collective communications.
     
    std::vector< std::string > all_methods
     
    │ │ │ │ -

    Detailed Description

    │ │ │ │ -

    An stl-compliant pool allocator.

    │ │ │ │ -

    This file implements the classes Pool and PoolAllocator providing memory allocation for objects in chunks.

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

    Function Documentation

    │ │ │ │ + │ │ │ │ +

    ◆ communicate()

    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ +template<class CC >
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    void communicate (CC & cc)
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +

    ◆ determineOverlap()

    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    std::tuple< double, double > determineOverlap (std::function< std::tuple< double, double >(std::chrono::duration< double >)> fun)
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +

    ◆ main()

    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    int main (int argc,
    char ** argv 
    )
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +

    ◆ printHeader()

    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    void printHeader ()
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +

    ◆ run()

    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    void run (int s)
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +

    ◆ runBlocking()

    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ +template<class CC >
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    double runBlocking (CC & cc)
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +

    ◆ runNonblockingActive()

    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    std::tuple< double, double > runNonblockingActive (decltype(Dune::MPIHelper::getCommunication())& cc,
    std::chrono::duration< double > wait_time 
    )
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +

    ◆ runNonblockingSleep()

    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    std::tuple< double, double > runNonblockingSleep (decltype(Dune::MPIHelper::getCommunication())& cc,
    std::chrono::duration< double > wait_time 
    )
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +

    ◆ runNonblockingWait()

    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ +template<class CC >
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    double runNonblockingWait (CC & cc)
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +

    ◆ startCommunication()

    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ +template<class CC >
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    Dune::Future< void > startCommunication (CC & cc)
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ +

    Variable Documentation

    │ │ │ │ + │ │ │ │ +

    ◆ all_methods

    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    std::vector<std::string> all_methods
    │ │ │ │ +
    │ │ │ │ +Initial value:
    = {"allreduce",
    │ │ │ │ +
    "barrier",
    │ │ │ │ +
    "broadcast",
    │ │ │ │ +
    "gather",
    │ │ │ │ +
    "allgather",
    │ │ │ │ +
    "scatter"}
    │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +

    ◆ options

    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    Dune::ParameterTree options
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +

    Benchmark for measure the possible overlap of computation and communication at MPI collective communications.

    │ │ │ │ +

    This benchmark is inspired by the sandia micro benchmark: W. Lawry, C. Wilson, A. Maccabe, R. Brightwell. COMB: A Portable Benchmark Suite for Assessing MPI Overlap. In Proceedings of the IEEE International Conference on Cluster Computing (CLUSTER 2002), p. 472, 2002. http://www.cs.sandia.gov/smb/overhead.html

    │ │ │ │ +

    The following communication times are measured: Blocking: Blocking call. E.g. MPI_Allreduce Nonblocking_wait (NB_Wait): Nonblocking (e.g. MPI_Iallreduce) call directly followed by MPI_Wait. Nonblocking_sleep (NB_Sleep): Nonblocking call followed by a busy wait until the work time has passed. Then MPI_Wait. Nonblocking_active (NB_active): Nonblocking call followed by a basy wait where in every iteration MPI_Test is called until the work time has passed. The MPI_wait.

    │ │ │ │ +

    The overhead is computed as the time for the Nonblocking call plus the time for MPI_Wait. The iteration time is the time for the whole communication. The available part of the communication time(avail(%)) is computed as 1-(overhead/base_t), where base_t is the time for calling the method with wait time = 0. The overhead is determined by increasing the work time successive until it is the dominant factor in the iteration time. Then the overhead is computed as iter_t-work_t.

    │ │ │ │ +

    Usage: mpirun ./mpi_collective_benchmark [options]

    │ │ │ │ +

    options: -method: default: allreduce. possible methods: allreduce, barrier, broadcast, gather, allgather, scatter -iterations: default: 10000. Number of iterations for measure the time for one communication -allMethods: default:0. If 1 iterates over all available methods -startSize: default: n, where n is the size of MPI_COMM_WORLD. runs the benchmark for different communicator sizes, starting with startSize. After every run the size is doubled. Finally one run is made for the whole communicator. -verbose: default: 0. If 1 prints intermediate information while determining the overhead. -threshold: default: 2. The threshold when the work time is the dominant factor in the iteration time. (Similar to the threshold in the sandia benchmark) -nohdr: default: 0. Suppress output of the header.

    │ │ │ │ +

    options can be set either in the options.ini file or can be pass at the command-line (-key value).

    │ │ │ │ +

    To get a good 'available' value for the NB_sleep communication, some MPI implementation need to spawn an extra thread. With MPICH you can activate this by setting the environment variable MPI_ASYNC_PROGRESS to 1, with IntelMPI the variable is called I_MPI_ASYNC_PROGRESS. (https://software.intel.com/en-us/mpi-developer-reference-linux-asynchronous-progress-control)

    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,79 +6,147 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Functions │ │ │ │ │ -poolallocator.hh File Reference │ │ │ │ │ -An stl-compliant pool allocator. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ + * parallel │ │ │ │ │ + * benchmark │ │ │ │ │ +Functions | Variables │ │ │ │ │ +mpi_collective_benchmark.cc File Reference │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -Go_to_the_source_code_of_this_file. │ │ │ │ │ - Classes │ │ │ │ │ - class  Dune::Pool<_T,_s_> │ │ │ │ │ -  A memory pool of objects. More... │ │ │ │ │ -  │ │ │ │ │ - class  Dune::PoolAllocator<_T,_s_> │ │ │ │ │ -  An allocator managing a pool of objects for reuse. More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::PoolAllocator<_T,_s_>::rebind<_U_> │ │ │ │ │ -  Rebind the allocator to another type. More... │ │ │ │ │ -  │ │ │ │ │ - class  Dune::PoolAllocator<_void,_s_> │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::PoolAllocator<_void,_s_>::rebind<_U_> │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ + Functions │ │ │ │ │ +template │ │ │ │ │ + void communicate (CC &cc) │ │ │ │ │   │ │ │ │ │ - Namespaces │ │ │ │ │ -namespace  Dune │ │ │ │ │ -  Dune namespace. │ │ │ │ │ +template │ │ │ │ │ + Dune::Future< void > startCommunication (CC &cc) │ │ │ │ │   │ │ │ │ │ -namespace  std │ │ │ │ │ -  STL namespace. │ │ │ │ │ +template │ │ │ │ │ + double runBlocking (CC &cc) │ │ │ │ │   │ │ │ │ │ - Functions │ │ │ │ │ -template │ │ │ │ │ -bool Dune::operator== (const PoolAllocator< T1, t1 > &, const PoolAllocator< │ │ │ │ │ - T2, t2 > &) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool Dune::operator!= (const PoolAllocator< T1, t1 > &, const PoolAllocator< │ │ │ │ │ - T2, t2 > &) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool Dune::operator== (const PoolAllocator< T, t1 > &p1, const PoolAllocator< │ │ │ │ │ - T, t2 > &p2) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool Dune::operator!= (const PoolAllocator< T, t1 > &p1, const PoolAllocator< │ │ │ │ │ - T, t2 > &p2) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool Dune::operator== (const PoolAllocator< void, t1 > &, const PoolAllocator< │ │ │ │ │ - T, t2 > &) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool Dune::operator!= (const PoolAllocator< void, t1 > &, const PoolAllocator< │ │ │ │ │ - T, t2 > &) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool Dune::operator== (const PoolAllocator< void, t1 > &p1, const │ │ │ │ │ - PoolAllocator< void, t2 > &p2) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool Dune::operator!= (const PoolAllocator< void, t1 > &p1, const │ │ │ │ │ - PoolAllocator< void, t2 > &p2) │ │ │ │ │ -  │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -An stl-compliant pool allocator. │ │ │ │ │ -This file implements the classes Pool and PoolAllocator providing memory │ │ │ │ │ -allocation for objects in chunks. │ │ │ │ │ - Author │ │ │ │ │ - Markus Blatt │ │ │ │ │ +template │ │ │ │ │ + double runNonblockingWait (CC &cc) │ │ │ │ │ +  │ │ │ │ │ +std::tuple< double, double > runNonblockingSleep (decltype(Dune::MPIHelper:: │ │ │ │ │ + getCommunication())&cc, std::chrono::duration< │ │ │ │ │ + double > wait_time) │ │ │ │ │ +  │ │ │ │ │ +std::tuple< double, double > runNonblockingActive (decltype(Dune::MPIHelper:: │ │ │ │ │ + getCommunication())&cc, std::chrono::duration< │ │ │ │ │ + double > wait_time) │ │ │ │ │ +  │ │ │ │ │ +std::tuple< double, double > determineOverlap (std::function< std::tuple< │ │ │ │ │ + double, double >(std::chrono::duration< double │ │ │ │ │ + >)> fun) │ │ │ │ │ +  │ │ │ │ │ + void printHeader () │ │ │ │ │ +  │ │ │ │ │ + void run (int s) │ │ │ │ │ +  │ │ │ │ │ + int main (int argc, char **argv) │ │ │ │ │ +  │ │ │ │ │ + Variables │ │ │ │ │ + Dune::ParameterTree options │ │ │ │ │ + Benchmark for measure the possible overlap of │ │ │ │ │ +  computation and communication at MPI collective │ │ │ │ │ + communications. │ │ │ │ │ +  │ │ │ │ │ +std::vector< std::string > all_methods │ │ │ │ │ +  │ │ │ │ │ +***** Function Documentation ***** │ │ │ │ │ +***** ◆ communicate() ***** │ │ │ │ │ +template │ │ │ │ │ +void communicate ( CC & cc ) │ │ │ │ │ +***** ◆ determineOverlap() ***** │ │ │ │ │ +std::tuple< double, double > ( std::function< std::tuple< double, double fun ) │ │ │ │ │ +determineOverlap >(std::chrono::duration< double >)>  │ │ │ │ │ +***** ◆ main() ***** │ │ │ │ │ +int main ( int  argc, │ │ │ │ │ + char ** argv  │ │ │ │ │ + ) │ │ │ │ │ +***** ◆ printHeader() ***** │ │ │ │ │ +void printHeader ( ) │ │ │ │ │ +***** ◆ run() ***** │ │ │ │ │ +void run ( int s ) │ │ │ │ │ +***** ◆ runBlocking() ***** │ │ │ │ │ +template │ │ │ │ │ +double runBlocking ( CC & cc ) │ │ │ │ │ +***** ◆ runNonblockingActive() ***** │ │ │ │ │ +std::tuple< double, double > ( decltype(Dune::MPIHelper:: cc, │ │ │ │ │ +runNonblockingActive getCommunication())&  │ │ │ │ │ + std::chrono::duration< double > wait_time  │ │ │ │ │ + ) │ │ │ │ │ +***** ◆ runNonblockingSleep() ***** │ │ │ │ │ +std::tuple< double, double > ( decltype(Dune::MPIHelper:: cc, │ │ │ │ │ +runNonblockingSleep getCommunication())&  │ │ │ │ │ + std::chrono::duration< double > wait_time  │ │ │ │ │ + ) │ │ │ │ │ +***** ◆ runNonblockingWait() ***** │ │ │ │ │ +template │ │ │ │ │ +double runNonblockingWait ( CC & cc ) │ │ │ │ │ +***** ◆ startCommunication() ***** │ │ │ │ │ +template │ │ │ │ │ +Dune::Future< void > startCommunication ( CC & cc ) │ │ │ │ │ +***** Variable Documentation ***** │ │ │ │ │ +***** ◆ all_methods ***** │ │ │ │ │ +std::vector all_methods │ │ │ │ │ +Initial value: │ │ │ │ │ += {"allreduce", │ │ │ │ │ +"barrier", │ │ │ │ │ +"broadcast", │ │ │ │ │ +"gather", │ │ │ │ │ +"allgather", │ │ │ │ │ +"scatter"} │ │ │ │ │ +***** ◆ options ***** │ │ │ │ │ +Dune::ParameterTree options │ │ │ │ │ +Benchmark for measure the possible overlap of computation and communication at │ │ │ │ │ +MPI collective communications. │ │ │ │ │ +This benchmark is inspired by the sandia micro benchmark: W. Lawry, C. Wilson, │ │ │ │ │ +A. Maccabe, R. Brightwell. COMB: A Portable Benchmark Suite for Assessing MPI │ │ │ │ │ +Overlap. In Proceedings of the IEEE International Conference on Cluster │ │ │ │ │ +Computing (CLUSTER 2002), p. 472, 2002. http://www.cs.sandia.gov/smb/ │ │ │ │ │ +overhead.html │ │ │ │ │ +The following communication times are measured: Blocking: Blocking call. E.g. │ │ │ │ │ +MPI_Allreduce Nonblocking_wait (NB_Wait): Nonblocking (e.g. MPI_Iallreduce) │ │ │ │ │ +call directly followed by MPI_Wait. Nonblocking_sleep (NB_Sleep): Nonblocking │ │ │ │ │ +call followed by a busy wait until the work time has passed. Then MPI_Wait. │ │ │ │ │ +Nonblocking_active (NB_active): Nonblocking call followed by a basy wait where │ │ │ │ │ +in every iteration MPI_Test is called until the work time has passed. The │ │ │ │ │ +MPI_wait. │ │ │ │ │ +The overhead is computed as the time for the Nonblocking call plus the time for │ │ │ │ │ +MPI_Wait. The iteration time is the time for the whole communication. The │ │ │ │ │ +available part of the communication time(avail(%)) is computed as 1-(overhead/ │ │ │ │ │ +base_t), where base_t is the time for calling the method with wait time = 0. │ │ │ │ │ +The overhead is determined by increasing the work time successive until it is │ │ │ │ │ +the dominant factor in the iteration time. Then the overhead is computed as │ │ │ │ │ +iter_t-work_t. │ │ │ │ │ +Usage: mpirun ./mpi_collective_benchmark [options] │ │ │ │ │ +options: -method: default: allreduce. possible methods: allreduce, barrier, │ │ │ │ │ +broadcast, gather, allgather, scatter -iterations: default: 10000. Number of │ │ │ │ │ +iterations for measure the time for one communication -allMethods: default:0. │ │ │ │ │ +If 1 iterates over all available methods -startSize: default: n, where n is the │ │ │ │ │ +size of MPI_COMM_WORLD. runs the benchmark for different communicator sizes, │ │ │ │ │ +starting with startSize. After every run the size is doubled. Finally one run │ │ │ │ │ +is made for the whole communicator. -verbose: default: 0. If 1 prints │ │ │ │ │ +intermediate information while determining the overhead. -threshold: default: │ │ │ │ │ +2. The threshold when the work time is the dominant factor in the iteration │ │ │ │ │ +time. (Similar to the threshold in the sandia benchmark) -nohdr: default: 0. │ │ │ │ │ +Suppress output of the header. │ │ │ │ │ +options can be set either in the options.ini file or can be pass at the │ │ │ │ │ +command-line (-key value). │ │ │ │ │ +To get a good 'available' value for the NB_sleep communication, some MPI │ │ │ │ │ +implementation need to spawn an extra thread. With MPICH you can activate this │ │ │ │ │ +by setting the environment variable MPI_ASYNC_PROGRESS to 1, with IntelMPI the │ │ │ │ │ +variable is called I_MPI_ASYNC_PROGRESS. (https://software.intel.com/en-us/mpi- │ │ │ │ │ +developer-reference-linux-asynchronous-progress-control) │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00068.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: keywords.hh File Reference │ │ │ │ +dune-common: communication.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,68 +65,71 @@ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ -Macros
    │ │ │ │ -
    keywords.hh File Reference
    │ │ │ │ +Classes | │ │ │ │ +Namespaces | │ │ │ │ +Typedefs | │ │ │ │ +Functions
    │ │ │ │ +
    communication.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ -

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

    Implements an utility class that provides collective communication methods for sequential programs. │ │ │ │ More...

    │ │ │ │ - │ │ │ │ +
    #include <iostream>
    │ │ │ │ +#include <complex>
    │ │ │ │ +#include <algorithm>
    │ │ │ │ +#include <vector>
    │ │ │ │ +#include <dune/common/binaryfunctions.hh>
    │ │ │ │ +#include <dune/common/exceptions.hh>
    │ │ │ │ +#include <dune/common/parallel/future.hh>
    │ │ │ │ +
    │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ -Macros

    #define DUNE_INLINE_VARIABLE   inline
     
    #define DUNE_GENERALIZED_CONSTEXPR   constexpr
     

    │ │ │ │ +Classes

    struct  Dune::No_Comm
     
    class  Dune::Communication< Communicator >
     Collective communication interface and sequential default implementation. More...
     
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

    │ │ │ │ +Namespaces

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

    │ │ │ │ +Typedefs

    template<class T >
    using Dune::CollectiveCommunication = Communication< T >
     
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

    │ │ │ │ +Functions

    bool Dune::operator== (const No_Comm &, const No_Comm &)
     Comparison operator for MPI compatibility.
     
    bool Dune::operator!= (const No_Comm &, const No_Comm &)
     Comparison operator for MPI compatibility.
     
    │ │ │ │

    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.

    │ │ │ │ -

    Macro Definition Documentation

    │ │ │ │ - │ │ │ │ -

    ◆ DUNE_GENERALIZED_CONSTEXPR

    │ │ │ │ - │ │ │ │ -
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
    #define DUNE_GENERALIZED_CONSTEXPR   constexpr
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -

    ◆ DUNE_INLINE_VARIABLE

    │ │ │ │ - │ │ │ │ -
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
    #define DUNE_INLINE_VARIABLE   inline
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    │ │ │ │ -
    │ │ │ │ -
    │ │ │ │ +

    Implements an utility class that provides collective communication methods for sequential programs.

    │ │ │ │ +

    An abstraction to the basic methods of parallel communication, following the message-passing paradigm.

    │ │ │ │ +
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,31 +6,51 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Macros │ │ │ │ │ -keywords.hh File Reference │ │ │ │ │ -Common » Utilities » C++_utilities_and_backports │ │ │ │ │ -Definitions of several macros that conditionally make C++ syntax available. │ │ │ │ │ -More... │ │ │ │ │ + * parallel │ │ │ │ │ +Classes | Namespaces | Typedefs | Functions │ │ │ │ │ +communication.hh File Reference │ │ │ │ │ +Common » Parallel_Communication │ │ │ │ │ +Implements an utility class that provides collective communication methods for │ │ │ │ │ +sequential programs. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ - Macros │ │ │ │ │ -#define DUNE_INLINE_VARIABLE   inline │ │ │ │ │ + Classes │ │ │ │ │ +struct  Dune::No_Comm │ │ │ │ │   │ │ │ │ │ -#define DUNE_GENERALIZED_CONSTEXPR   constexpr │ │ │ │ │ + class  Dune::Communication<_Communicator_> │ │ │ │ │ +  Collective communication interface and sequential default │ │ │ │ │ + implementation. More... │ │ │ │ │ +  │ │ │ │ │ + Namespaces │ │ │ │ │ +namespace  Dune │ │ │ │ │ +  Dune namespace. │ │ │ │ │ +  │ │ │ │ │ + Typedefs │ │ │ │ │ +template │ │ │ │ │ +using Dune::CollectiveCommunication = Communication< T > │ │ │ │ │ +  │ │ │ │ │ + Functions │ │ │ │ │ +bool Dune::operator== (const No_Comm &, const No_Comm &) │ │ │ │ │ +  Comparison operator for MPI compatibility. │ │ │ │ │ +  │ │ │ │ │ +bool Dune::operator!= (const No_Comm &, const No_Comm &) │ │ │ │ │ +  Comparison operator for MPI compatibility. │ │ │ │ │   │ │ │ │ │ ***** 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. │ │ │ │ │ -***** Macro Definition Documentation ***** │ │ │ │ │ -***** ◆ DUNE_GENERALIZED_CONSTEXPR ***** │ │ │ │ │ -#define DUNE_GENERALIZED_CONSTEXPR   constexpr │ │ │ │ │ -***** ◆ DUNE_INLINE_VARIABLE ***** │ │ │ │ │ -#define DUNE_INLINE_VARIABLE   inline │ │ │ │ │ +Implements an utility class that provides collective communication methods for │ │ │ │ │ +sequential programs. │ │ │ │ │ +An abstraction to the basic methods of parallel communication, following the │ │ │ │ │ +message-passing paradigm. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00068_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: keywords.hh Source File │ │ │ │ +dune-common: communication.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,43 +70,417 @@ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    keywords.hh
    │ │ │ │ +
    communication.hh
    │ │ │ │
    │ │ │ │
    │ │ │ │ -Go to the documentation of this file.
    1// SPDX-FileCopyrightInfo: Copyright (C) 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_KEYWORDS_HH
    │ │ │ │ -
    4#define DUNE_COMMON_KEYWORDS_HH
    │ │ │ │ -
    5
    │ │ │ │ -
    18#if __cpp_inline_variables >= 201606
    │ │ │ │ -
    19#define DUNE_INLINE_VARIABLE inline
    │ │ │ │ -
    20#else
    │ │ │ │ +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 (C) 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_PARALLEL_COMMUNICATION_HH
    │ │ │ │ +
    6#define DUNE_COMMON_PARALLEL_COMMUNICATION_HH
    │ │ │ │ +
    14#include <iostream>
    │ │ │ │ +
    15#include <complex>
    │ │ │ │ +
    16#include <algorithm>
    │ │ │ │ +
    17#include <vector>
    │ │ │ │ +
    18
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │
    22
    │ │ │ │ -
    25#define DUNE_INLINE_VARIABLE
    │ │ │ │ -
    26#endif
    │ │ │ │ -
    27
    │ │ │ │ -
    28
    │ │ │ │ -
    29#if __cpp_constexpr >= 201304
    │ │ │ │ -
    30#define DUNE_GENERALIZED_CONSTEXPR constexpr
    │ │ │ │ -
    31#else
    │ │ │ │ -
    33
    │ │ │ │ -
    36#define DUNE_GENERALIZED_CONSTEXPR
    │ │ │ │ -
    37#endif
    │ │ │ │ -
    38
    │ │ │ │ -
    39
    │ │ │ │ -
    40#endif // DUNE_COMMON_KEYWORDS_HH
    │ │ │ │ +
    42namespace Dune
    │ │ │ │ +
    43{
    │ │ │ │ +
    44
    │ │ │ │ +
    45 /* define some type that definitely differs from MPI_Comm */
    │ │ │ │ +
    46 struct No_Comm {};
    │ │ │ │ +
    47
    │ │ │ │ +
    │ │ │ │ +
    52 inline bool operator==(const No_Comm&, const No_Comm&)
    │ │ │ │ +
    53 {
    │ │ │ │ +
    54 return true;
    │ │ │ │ +
    55 }
    │ │ │ │ +
    │ │ │ │ +
    56
    │ │ │ │ +
    │ │ │ │ +
    61 inline bool operator!=(const No_Comm&, const No_Comm&)
    │ │ │ │ +
    62 {
    │ │ │ │ +
    63 return false;
    │ │ │ │ +
    64 }
    │ │ │ │ +
    │ │ │ │ +
    65
    │ │ │ │ +
    98 template<typename Communicator>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    100 {
    │ │ │ │ +
    101 public:
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    104 {}
    │ │ │ │ +
    │ │ │ │ +
    105
    │ │ │ │ +
    │ │ │ │ +
    110 Communication (const Communicator&)
    │ │ │ │ +
    111 {}
    │ │ │ │ +
    │ │ │ │ +
    112
    │ │ │ │ +
    │ │ │ │ +
    114 int rank () const
    │ │ │ │ +
    115 {
    │ │ │ │ +
    116 return 0;
    │ │ │ │ +
    117 }
    │ │ │ │ +
    │ │ │ │ +
    118
    │ │ │ │ +
    │ │ │ │ +
    120 operator No_Comm() const
    │ │ │ │ +
    121 {
    │ │ │ │ +
    122 return {};
    │ │ │ │ +
    123 }
    │ │ │ │ +
    │ │ │ │ +
    124
    │ │ │ │ +
    │ │ │ │ +
    126 int size () const
    │ │ │ │ +
    127 {
    │ │ │ │ +
    128 return 1;
    │ │ │ │ +
    129 }
    │ │ │ │ +
    │ │ │ │ +
    130
    │ │ │ │ +
    134 template<class T>
    │ │ │ │ +
    │ │ │ │ +
    135 int send([[maybe_unused]] const T& data,
    │ │ │ │ +
    136 [[maybe_unused]] int dest_rank,
    │ │ │ │ +
    137 [[maybe_unused]] int tag)
    │ │ │ │ +
    138 {
    │ │ │ │ +
    139 DUNE_THROW(ParallelError, "This method is not supported in sequential programs");
    │ │ │ │ +
    140 }
    │ │ │ │ +
    │ │ │ │ +
    141
    │ │ │ │ +
    145 template<class T>
    │ │ │ │ +
    │ │ │ │ +
    146 PseudoFuture<T> isend([[maybe_unused]] const T&& data,
    │ │ │ │ +
    147 [[maybe_unused]] int dest_rank,
    │ │ │ │ +
    148 [[maybe_unused]] int tag)
    │ │ │ │ +
    149 {
    │ │ │ │ +
    150 DUNE_THROW(ParallelError, "This method is not supported in sequential programs");
    │ │ │ │ +
    151 }
    │ │ │ │ +
    │ │ │ │ +
    152
    │ │ │ │ +
    156 template<class T>
    │ │ │ │ +
    │ │ │ │ +
    157 T recv([[maybe_unused]] T&& data,
    │ │ │ │ +
    158 [[maybe_unused]] int source_rank,
    │ │ │ │ +
    159 [[maybe_unused]] int tag,
    │ │ │ │ +
    160 [[maybe_unused]] void* status = 0)
    │ │ │ │ +
    161 {
    │ │ │ │ +
    162 DUNE_THROW(ParallelError, "This method is not supported in sequential programs");
    │ │ │ │ +
    163 }
    │ │ │ │ +
    │ │ │ │ +
    164
    │ │ │ │ +
    168 template<class T>
    │ │ │ │ +
    │ │ │ │ +
    169 PseudoFuture<T> irecv([[maybe_unused]] T&& data,
    │ │ │ │ +
    170 [[maybe_unused]] int source_rank,
    │ │ │ │ +
    171 [[maybe_unused]] int tag)
    │ │ │ │ +
    172 {
    │ │ │ │ +
    173 DUNE_THROW(ParallelError, "This method is not supported in sequential programs");
    │ │ │ │ +
    174 }
    │ │ │ │ +
    │ │ │ │ +
    175
    │ │ │ │ +
    176 template<class T>
    │ │ │ │ +
    │ │ │ │ +
    177 T rrecv([[maybe_unused]] T&& data,
    │ │ │ │ +
    178 [[maybe_unused]] int source_rank,
    │ │ │ │ +
    179 [[maybe_unused]] int tag,
    │ │ │ │ +
    180 [[maybe_unused]] void* status = 0) const
    │ │ │ │ +
    181 {
    │ │ │ │ +
    182 DUNE_THROW(ParallelError, "This method is not supported in sequential programs");
    │ │ │ │ +
    183 }
    │ │ │ │ +
    │ │ │ │ +
    187 template<typename T>
    │ │ │ │ +
    │ │ │ │ +
    188 T sum (const T& in) const
    │ │ │ │ +
    189 {
    │ │ │ │ +
    190 return in;
    │ │ │ │ +
    191 }
    │ │ │ │ +
    │ │ │ │ +
    192
    │ │ │ │ +
    198 template<typename T>
    │ │ │ │ +
    │ │ │ │ +
    199 int sum ([[maybe_unused]] T* inout, [[maybe_unused]] int len) const
    │ │ │ │ +
    200 {
    │ │ │ │ +
    201 return 0;
    │ │ │ │ +
    202 }
    │ │ │ │ +
    │ │ │ │ +
    203
    │ │ │ │ +
    207 template<typename T>
    │ │ │ │ +
    │ │ │ │ +
    208 T prod (const T& in) const
    │ │ │ │ +
    209 {
    │ │ │ │ +
    210 return in;
    │ │ │ │ +
    211 }
    │ │ │ │ +
    │ │ │ │ +
    212
    │ │ │ │ +
    218 template<typename T>
    │ │ │ │ +
    │ │ │ │ +
    219 int prod ([[maybe_unused]] T* inout, [[maybe_unused]] int len) const
    │ │ │ │ +
    220 {
    │ │ │ │ +
    221 return 0;
    │ │ │ │ +
    222 }
    │ │ │ │ +
    │ │ │ │ +
    223
    │ │ │ │ +
    227 template<typename T>
    │ │ │ │ +
    │ │ │ │ +
    228 T min (const T& in) const
    │ │ │ │ +
    229 {
    │ │ │ │ +
    230 return in;
    │ │ │ │ +
    231 }
    │ │ │ │ +
    │ │ │ │ +
    232
    │ │ │ │ +
    238 template<typename T>
    │ │ │ │ +
    │ │ │ │ +
    239 int min ([[maybe_unused]] T* inout, [[maybe_unused]] int len) const
    │ │ │ │ +
    240 {
    │ │ │ │ +
    241 return 0;
    │ │ │ │ +
    242 }
    │ │ │ │ +
    │ │ │ │ +
    243
    │ │ │ │ +
    247 template<typename T>
    │ │ │ │ +
    │ │ │ │ +
    248 T max (const T& in) const
    │ │ │ │ +
    249 {
    │ │ │ │ +
    250 return in;
    │ │ │ │ +
    251 }
    │ │ │ │ +
    │ │ │ │ +
    252
    │ │ │ │ +
    258 template<typename T>
    │ │ │ │ +
    │ │ │ │ +
    259 int max ([[maybe_unused]] T* inout, [[maybe_unused]] int len) const
    │ │ │ │ +
    260 {
    │ │ │ │ +
    261 return 0;
    │ │ │ │ +
    262 }
    │ │ │ │ +
    │ │ │ │ +
    263
    │ │ │ │ +
    │ │ │ │ +
    267 int barrier () const
    │ │ │ │ +
    268 {
    │ │ │ │ +
    269 return 0;
    │ │ │ │ +
    270 }
    │ │ │ │ +
    │ │ │ │ +
    271
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    276 {
    │ │ │ │ +
    277 return {true}; // return a valid future
    │ │ │ │ +
    278 }
    │ │ │ │ +
    │ │ │ │ +
    279
    │ │ │ │ +
    283 template<typename T>
    │ │ │ │ +
    │ │ │ │ +
    284 int broadcast ([[maybe_unused]] T* inout,
    │ │ │ │ +
    285 [[maybe_unused]] int len,
    │ │ │ │ +
    286 [[maybe_unused]] int root) const
    │ │ │ │ +
    287 {
    │ │ │ │ +
    288 return 0;
    │ │ │ │ +
    289 }
    │ │ │ │ +
    │ │ │ │ +
    290
    │ │ │ │ +
    294 template<class T>
    │ │ │ │ +
    │ │ │ │ +
    295 PseudoFuture<T> ibroadcast(T&& data, int root) const{
    │ │ │ │ +
    296 return {std::forward<T>(data)};
    │ │ │ │ +
    297 }
    │ │ │ │ +
    │ │ │ │ +
    298
    │ │ │ │ +
    299
    │ │ │ │ +
    312 template<typename T>
    │ │ │ │ +
    │ │ │ │ +
    313 int gather (const T* in, T* out, int len, [[maybe_unused]] int root) const // note out must have same size as in
    │ │ │ │ +
    314 {
    │ │ │ │ +
    315 for (int i=0; i<len; i++)
    │ │ │ │ +
    316 out[i] = in[i];
    │ │ │ │ +
    317 return 0;
    │ │ │ │ +
    318 }
    │ │ │ │ +
    │ │ │ │ +
    319
    │ │ │ │ +
    323 template<class TIN, class TOUT = std::vector<TIN>>
    │ │ │ │ +
    │ │ │ │ +
    324 PseudoFuture<TOUT> igather(TIN&& data_in, TOUT&& data_out, int root){
    │ │ │ │ +
    325 *(data_out.begin()) = std::forward<TIN>(data_in);
    │ │ │ │ +
    326 return {std::forward<TOUT>(data_out)};
    │ │ │ │ +
    327 }
    │ │ │ │ +
    │ │ │ │ +
    328
    │ │ │ │ +
    329
    │ │ │ │ +
    349 template<typename T>
    │ │ │ │ +
    │ │ │ │ +
    350 int gatherv (const T* in,
    │ │ │ │ +
    351 int sendDataLen,
    │ │ │ │ +
    352 T* out,
    │ │ │ │ +
    353 [[maybe_unused]] int* recvDataLen,
    │ │ │ │ +
    354 int* displ,
    │ │ │ │ +
    355 [[maybe_unused]] int root) const
    │ │ │ │ +
    356 {
    │ │ │ │ +
    357 for (int i=*displ; i<sendDataLen; i++)
    │ │ │ │ +
    358 out[i] = in[i];
    │ │ │ │ +
    359 return 0;
    │ │ │ │ +
    360 }
    │ │ │ │ +
    │ │ │ │ +
    361
    │ │ │ │ +
    375 template<typename T>
    │ │ │ │ +
    │ │ │ │ +
    376 int scatter (const T* sendData, T* recvData, int len, [[maybe_unused]] int root) const // note out must have same size as in
    │ │ │ │ +
    377 {
    │ │ │ │ +
    378 for (int i=0; i<len; i++)
    │ │ │ │ +
    379 recvData[i] = sendData[i];
    │ │ │ │ +
    380 return 0;
    │ │ │ │ +
    381 }
    │ │ │ │ +
    │ │ │ │ +
    382
    │ │ │ │ +
    386 template<class TIN, class TOUT = TIN>
    │ │ │ │ +
    │ │ │ │ +
    387 PseudoFuture<TOUT> iscatter(TIN&& data_in, TOUT&& data_out, int root){
    │ │ │ │ +
    388 data_out = *(std::forward<TIN>(data_in).begin());
    │ │ │ │ +
    389 return {std::forward<TOUT>(data_out)};
    │ │ │ │ +
    390 }
    │ │ │ │ +
    │ │ │ │ +
    391
    │ │ │ │ +
    410 template<typename T>
    │ │ │ │ +
    │ │ │ │ +
    411 int scatterv (const T* sendData,int* sendDataLen, int* displ, T* recvData,
    │ │ │ │ +
    412 [[maybe_unused]] int recvDataLen, [[maybe_unused]] int root) const
    │ │ │ │ +
    413 {
    │ │ │ │ +
    414 for (int i=*displ; i<*sendDataLen; i++)
    │ │ │ │ +
    415 recvData[i] = sendData[i];
    │ │ │ │ +
    416 return 0;
    │ │ │ │ +
    417 }
    │ │ │ │ +
    │ │ │ │ +
    418
    │ │ │ │ +
    432 template<typename T>
    │ │ │ │ +
    │ │ │ │ +
    433 int allgather(const T* sbuf, int count, T* rbuf) const
    │ │ │ │ +
    434 {
    │ │ │ │ +
    435 for(const T* end=sbuf+count; sbuf < end; ++sbuf, ++rbuf)
    │ │ │ │ +
    436 *rbuf=*sbuf;
    │ │ │ │ +
    437 return 0;
    │ │ │ │ +
    438 }
    │ │ │ │ +
    │ │ │ │ +
    439
    │ │ │ │ +
    444 template<class TIN, class TOUT = TIN>
    │ │ │ │ +
    │ │ │ │ +
    445 PseudoFuture<TOUT> iallgather(TIN&& data_in, TOUT&& data_out){
    │ │ │ │ +
    446 return {std::forward<TOUT>(data_out)};
    │ │ │ │ +
    447 }
    │ │ │ │ +
    │ │ │ │ +
    448
    │ │ │ │ +
    465 template<typename T>
    │ │ │ │ +
    │ │ │ │ +
    466 int allgatherv (const T* in, int sendDataLen, T* out, [[maybe_unused]] int* recvDataLen, int* displ) const
    │ │ │ │ +
    467 {
    │ │ │ │ +
    468 for (int i=*displ; i<sendDataLen; i++)
    │ │ │ │ +
    469 out[i] = in[i];
    │ │ │ │ +
    470 return 0;
    │ │ │ │ +
    471 }
    │ │ │ │ +
    │ │ │ │ +
    472
    │ │ │ │ +
    485 template<typename BinaryFunction, typename Type>
    │ │ │ │ +
    │ │ │ │ +
    486 int allreduce([[maybe_unused]] Type* inout, [[maybe_unused]] int len) const
    │ │ │ │ +
    487 {
    │ │ │ │ +
    488 return 0;
    │ │ │ │ +
    489 }
    │ │ │ │ +
    │ │ │ │ +
    490
    │ │ │ │ +
    495 template<class BinaryFunction, class TIN, class TOUT = TIN>
    │ │ │ │ +
    │ │ │ │ +
    496 PseudoFuture<TOUT> iallreduce(TIN&& data_in, TOUT&& data_out){
    │ │ │ │ +
    497 data_out = std::forward<TIN>(data_in);
    │ │ │ │ +
    498 return {std::forward<TOUT>(data_out)};
    │ │ │ │ +
    499 }
    │ │ │ │ +
    │ │ │ │ +
    500
    │ │ │ │ +
    505 template<class BinaryFunction, class T>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    507 return {std::forward<T>(data)};
    │ │ │ │ +
    508 }
    │ │ │ │ +
    │ │ │ │ +
    509
    │ │ │ │ +
    510
    │ │ │ │ +
    524 template<typename BinaryFunction, typename Type>
    │ │ │ │ +
    │ │ │ │ +
    525 int allreduce(const Type* in, Type* out, int len) const
    │ │ │ │ +
    526 {
    │ │ │ │ +
    527 std::copy(in, in+len, out);
    │ │ │ │ +
    528 return 0;
    │ │ │ │ +
    529 }
    │ │ │ │ +
    │ │ │ │ +
    530
    │ │ │ │ +
    531 };
    │ │ │ │ +
    │ │ │ │ +
    532
    │ │ │ │ +
    538 template<class T>
    │ │ │ │ + │ │ │ │ +
    540 [[deprecated("CollectiveCommunication is deprecated. Use Communication instead.")]]
    │ │ │ │ + │ │ │ │ +
    542}
    │ │ │ │ +
    543
    │ │ │ │ +
    544#endif
    │ │ │ │ + │ │ │ │ +
    A few common exception classes.
    │ │ │ │ +
    helper classes to provide unique types for standard functions
    │ │ │ │ +
    #define DUNE_THROW(E, m)
    Definition exceptions.hh:218
    │ │ │ │ +
    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:237
    │ │ │ │ +
    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:259
    │ │ │ │ +
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ +
    Default exception if an error in the parallel communication of the program occurred.
    Definition exceptions.hh:287
    │ │ │ │ +
    Definition communication.hh:46
    │ │ │ │ +
    Collective communication interface and sequential default implementation.
    Definition communication.hh:100
    │ │ │ │ +
    PseudoFuture< TOUT > iallreduce(TIN &&data_in, TOUT &&data_out)
    Compute something over all processes nonblocking.
    Definition communication.hh:496
    │ │ │ │ +
    int send(const T &data, int dest_rank, int tag)
    Sends the data to the dest_rank.
    Definition communication.hh:135
    │ │ │ │ +
    int allreduce(const Type *in, Type *out, int len) const
    Compute something over all processes for each component of an array and return the result in every pr...
    Definition communication.hh:525
    │ │ │ │ +
    T max(const T &in) const
    Compute the maximum of the argument over all processes and return the result in every process....
    Definition communication.hh:248
    │ │ │ │ +
    int rank() const
    Return rank, is between 0 and size()-1.
    Definition communication.hh:114
    │ │ │ │ +
    T sum(const T &in) const
    Compute the sum of the argument over all processes and return the result in every process....
    Definition communication.hh:188
    │ │ │ │ +
    int scatterv(const T *sendData, int *sendDataLen, int *displ, T *recvData, int recvDataLen, int root) const
    Scatter arrays of variable length from a root to all other tasks.
    Definition communication.hh:411
    │ │ │ │ +
    int prod(T *inout, int len) const
    Compute the product over all processes for each component of an array and return the result in every ...
    Definition communication.hh:219
    │ │ │ │ +
    T recv(T &&data, int source_rank, int tag, void *status=0)
    Receives the data from the source_rank.
    Definition communication.hh:157
    │ │ │ │ +
    PseudoFuture< T > isend(const T &&data, int dest_rank, int tag)
    Sends the data to the dest_rank nonblocking.
    Definition communication.hh:146
    │ │ │ │ +
    PseudoFuture< void > ibarrier() const
    Nonblocking barrier.
    Definition communication.hh:275
    │ │ │ │ +
    int allreduce(Type *inout, int len) const
    Compute something over all processes for each component of an array and return the result in every pr...
    Definition communication.hh:486
    │ │ │ │ +
    int size() const
    Number of processes in set, is greater than 0.
    Definition communication.hh:126
    │ │ │ │ +
    int sum(T *inout, int len) const
    Compute the sum over all processes for each component of an array and return the result in every proc...
    Definition communication.hh:199
    │ │ │ │ +
    int allgatherv(const T *in, int sendDataLen, T *out, int *recvDataLen, int *displ) const
    Gathers data of variable length from all tasks and distribute it to all.
    Definition communication.hh:466
    │ │ │ │ +
    T min(const T &in) const
    Compute the minimum of the argument over all processes and return the result in every process....
    Definition communication.hh:228
    │ │ │ │ +
    PseudoFuture< T > irecv(T &&data, int source_rank, int tag)
    Receives the data from the source_rank nonblocking.
    Definition communication.hh:169
    │ │ │ │ +
    int gatherv(const T *in, int sendDataLen, T *out, int *recvDataLen, int *displ, int root) const
    Gather arrays of variable size on root task.
    Definition communication.hh:350
    │ │ │ │ +
    PseudoFuture< T > ibroadcast(T &&data, int root) const
    Distribute an array from the process with rank root to all other processes nonblocking.
    Definition communication.hh:295
    │ │ │ │ +
    int allgather(const T *sbuf, int count, T *rbuf) const
    Gathers data from all tasks and distribute it to all.
    Definition communication.hh:433
    │ │ │ │ +
    int scatter(const T *sendData, T *recvData, int len, int root) const
    Scatter array from a root to all other task.
    Definition communication.hh:376
    │ │ │ │ +
    int gather(const T *in, T *out, int len, int root) const
    Gather arrays on root task.
    Definition communication.hh:313
    │ │ │ │ +
    PseudoFuture< T > iallreduce(T &&data)
    Compute something over all processes nonblocking and in-place.
    Definition communication.hh:506
    │ │ │ │ +
    Communication(const Communicator &)
    Constructor with a given communicator.
    Definition communication.hh:110
    │ │ │ │ +
    int max(T *inout, int len) const
    Compute the maximum over all processes for each component of an array and return the result in every ...
    Definition communication.hh:259
    │ │ │ │ +
    T prod(const T &in) const
    Compute the product of the argument over all processes and return the result in every process....
    Definition communication.hh:208
    │ │ │ │ +
    int broadcast(T *inout, int len, int root) const
    Distribute an array from the process with rank root to all other processes.
    Definition communication.hh:284
    │ │ │ │ +
    T rrecv(T &&data, int source_rank, int tag, void *status=0) const
    Definition communication.hh:177
    │ │ │ │ +
    PseudoFuture< TOUT > iscatter(TIN &&data_in, TOUT &&data_out, int root)
    Scatter array from a root to all other task nonblocking.
    Definition communication.hh:387
    │ │ │ │ +
    int min(T *inout, int len) const
    Compute the minimum over all processes for each component of an array and return the result in every ...
    Definition communication.hh:239
    │ │ │ │ +
    int barrier() const
    Wait until all processes have arrived at this point in the program.
    Definition communication.hh:267
    │ │ │ │ +
    PseudoFuture< TOUT > igather(TIN &&data_in, TOUT &&data_out, int root)
    Gather arrays on root task nonblocking.
    Definition communication.hh:324
    │ │ │ │ +
    PseudoFuture< TOUT > iallgather(TIN &&data_in, TOUT &&data_out)
    Gathers data from all tasks and distribute it to all nonblocking.
    Definition communication.hh:445
    │ │ │ │ +
    Communication()
    Construct default object.
    Definition communication.hh:103
    │ │ │ │ +
    A wrapper-class for a object which is ready immediately.
    Definition future.hh:122
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,35 +7,482 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -keywords.hh │ │ │ │ │ + * parallel │ │ │ │ │ +communication.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ - 1// SPDX-FileCopyrightInfo: Copyright (C) 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 (C) 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_KEYWORDS_HH │ │ │ │ │ - 4#define DUNE_COMMON_KEYWORDS_HH │ │ │ │ │ - 5 │ │ │ │ │ - 18#if __cpp_inline_variables >= 201606 │ │ │ │ │ -19#define DUNE_INLINE_VARIABLE inline │ │ │ │ │ - 20#else │ │ │ │ │ + 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ + 5#ifndef DUNE_COMMON_PARALLEL_COMMUNICATION_HH │ │ │ │ │ + 6#define DUNE_COMMON_PARALLEL_COMMUNICATION_HH │ │ │ │ │ + 14#include │ │ │ │ │ + 15#include │ │ │ │ │ + 16#include │ │ │ │ │ + 17#include │ │ │ │ │ + 18 │ │ │ │ │ + 19#include │ │ │ │ │ + 20#include │ │ │ │ │ + 21#include │ │ │ │ │ 22 │ │ │ │ │ - 25#define DUNE_INLINE_VARIABLE │ │ │ │ │ - 26#endif │ │ │ │ │ - 27 │ │ │ │ │ - 28 │ │ │ │ │ - 29#if __cpp_constexpr >= 201304 │ │ │ │ │ -30#define DUNE_GENERALIZED_CONSTEXPR constexpr │ │ │ │ │ - 31#else │ │ │ │ │ - 33 │ │ │ │ │ - 36#define DUNE_GENERALIZED_CONSTEXPR │ │ │ │ │ - 37#endif │ │ │ │ │ - 38 │ │ │ │ │ - 39 │ │ │ │ │ - 40#endif // DUNE_COMMON_KEYWORDS_HH │ │ │ │ │ + 42namespace Dune │ │ │ │ │ + 43{ │ │ │ │ │ + 44 │ │ │ │ │ + 45 /* define some type that definitely differs from MPI_Comm */ │ │ │ │ │ +46 struct No_Comm {}; │ │ │ │ │ + 47 │ │ │ │ │ +52 inline bool operator==(const No_Comm&, const No_Comm&) │ │ │ │ │ + 53 { │ │ │ │ │ + 54 return true; │ │ │ │ │ + 55 } │ │ │ │ │ + 56 │ │ │ │ │ +61 inline bool operator!=(const No_Comm&, const No_Comm&) │ │ │ │ │ + 62 { │ │ │ │ │ + 63 return false; │ │ │ │ │ + 64 } │ │ │ │ │ + 65 │ │ │ │ │ + 98 template │ │ │ │ │ +99 class Communication │ │ │ │ │ + 100 { │ │ │ │ │ + 101 public: │ │ │ │ │ +103 Communication() │ │ │ │ │ + 104 {} │ │ │ │ │ + 105 │ │ │ │ │ +110 Communication (const Communicator&) │ │ │ │ │ + 111 {} │ │ │ │ │ + 112 │ │ │ │ │ +114 int rank () const │ │ │ │ │ + 115 { │ │ │ │ │ + 116 return 0; │ │ │ │ │ + 117 } │ │ │ │ │ + 118 │ │ │ │ │ +120 operator No_Comm() const │ │ │ │ │ + 121 { │ │ │ │ │ + 122 return {}; │ │ │ │ │ + 123 } │ │ │ │ │ + 124 │ │ │ │ │ +126 int size () const │ │ │ │ │ + 127 { │ │ │ │ │ + 128 return 1; │ │ │ │ │ + 129 } │ │ │ │ │ + 130 │ │ │ │ │ + 134 template │ │ │ │ │ +135 int send([[maybe_unused]] const T& data, │ │ │ │ │ + 136 [[maybe_unused]] int dest_rank, │ │ │ │ │ + 137 [[maybe_unused]] int tag) │ │ │ │ │ + 138 { │ │ │ │ │ + 139 DUNE_THROW(ParallelError, "This method is not supported in sequential │ │ │ │ │ +programs"); │ │ │ │ │ + 140 } │ │ │ │ │ + 141 │ │ │ │ │ + 145 template │ │ │ │ │ +146 PseudoFuture isend([[maybe_unused]] const T&& data, │ │ │ │ │ + 147 [[maybe_unused]] int dest_rank, │ │ │ │ │ + 148 [[maybe_unused]] int tag) │ │ │ │ │ + 149 { │ │ │ │ │ + 150 DUNE_THROW(ParallelError, "This method is not supported in sequential │ │ │ │ │ +programs"); │ │ │ │ │ + 151 } │ │ │ │ │ + 152 │ │ │ │ │ + 156 template │ │ │ │ │ +157 T recv([[maybe_unused]] T&& data, │ │ │ │ │ + 158 [[maybe_unused]] int source_rank, │ │ │ │ │ + 159 [[maybe_unused]] int tag, │ │ │ │ │ + 160 [[maybe_unused]] void* status = 0) │ │ │ │ │ + 161 { │ │ │ │ │ + 162 DUNE_THROW(ParallelError, "This method is not supported in sequential │ │ │ │ │ +programs"); │ │ │ │ │ + 163 } │ │ │ │ │ + 164 │ │ │ │ │ + 168 template │ │ │ │ │ +169 PseudoFuture irecv([[maybe_unused]] T&& data, │ │ │ │ │ + 170 [[maybe_unused]] int source_rank, │ │ │ │ │ + 171 [[maybe_unused]] int tag) │ │ │ │ │ + 172 { │ │ │ │ │ + 173 DUNE_THROW(ParallelError, "This method is not supported in sequential │ │ │ │ │ +programs"); │ │ │ │ │ + 174 } │ │ │ │ │ + 175 │ │ │ │ │ + 176 template │ │ │ │ │ +177 T rrecv([[maybe_unused]] T&& data, │ │ │ │ │ + 178 [[maybe_unused]] int source_rank, │ │ │ │ │ + 179 [[maybe_unused]] int tag, │ │ │ │ │ + 180 [[maybe_unused]] void* status = 0) const │ │ │ │ │ + 181 { │ │ │ │ │ + 182 DUNE_THROW(ParallelError, "This method is not supported in sequential │ │ │ │ │ +programs"); │ │ │ │ │ + 183 } │ │ │ │ │ + 187 template │ │ │ │ │ +188 T sum (const T& in) const │ │ │ │ │ + 189 { │ │ │ │ │ + 190 return in; │ │ │ │ │ + 191 } │ │ │ │ │ + 192 │ │ │ │ │ + 198 template │ │ │ │ │ +199 int sum ([[maybe_unused]] T* inout, [[maybe_unused]] int len) const │ │ │ │ │ + 200 { │ │ │ │ │ + 201 return 0; │ │ │ │ │ + 202 } │ │ │ │ │ + 203 │ │ │ │ │ + 207 template │ │ │ │ │ +208 T prod (const T& in) const │ │ │ │ │ + 209 { │ │ │ │ │ + 210 return in; │ │ │ │ │ + 211 } │ │ │ │ │ + 212 │ │ │ │ │ + 218 template │ │ │ │ │ +219 int prod ([[maybe_unused]] T* inout, [[maybe_unused]] int len) const │ │ │ │ │ + 220 { │ │ │ │ │ + 221 return 0; │ │ │ │ │ + 222 } │ │ │ │ │ + 223 │ │ │ │ │ + 227 template │ │ │ │ │ +228 T min (const T& in) const │ │ │ │ │ + 229 { │ │ │ │ │ + 230 return in; │ │ │ │ │ + 231 } │ │ │ │ │ + 232 │ │ │ │ │ + 238 template │ │ │ │ │ +239 int min ([[maybe_unused]] T* inout, [[maybe_unused]] int len) const │ │ │ │ │ + 240 { │ │ │ │ │ + 241 return 0; │ │ │ │ │ + 242 } │ │ │ │ │ + 243 │ │ │ │ │ + 247 template │ │ │ │ │ +248 T max (const T& in) const │ │ │ │ │ + 249 { │ │ │ │ │ + 250 return in; │ │ │ │ │ + 251 } │ │ │ │ │ + 252 │ │ │ │ │ + 258 template │ │ │ │ │ +259 int max ([[maybe_unused]] T* inout, [[maybe_unused]] int len) const │ │ │ │ │ + 260 { │ │ │ │ │ + 261 return 0; │ │ │ │ │ + 262 } │ │ │ │ │ + 263 │ │ │ │ │ +267 int barrier () const │ │ │ │ │ + 268 { │ │ │ │ │ + 269 return 0; │ │ │ │ │ + 270 } │ │ │ │ │ + 271 │ │ │ │ │ +275 PseudoFuture ibarrier () const │ │ │ │ │ + 276 { │ │ │ │ │ + 277 return {true}; // return a valid future │ │ │ │ │ + 278 } │ │ │ │ │ + 279 │ │ │ │ │ + 283 template │ │ │ │ │ +284 int broadcast ([[maybe_unused]] T* inout, │ │ │ │ │ + 285 [[maybe_unused]] int len, │ │ │ │ │ + 286 [[maybe_unused]] int root) const │ │ │ │ │ + 287 { │ │ │ │ │ + 288 return 0; │ │ │ │ │ + 289 } │ │ │ │ │ + 290 │ │ │ │ │ + 294 template │ │ │ │ │ +295 PseudoFuture ibroadcast(T&& data, int root) const{ │ │ │ │ │ + 296 return {std::forward(data)}; │ │ │ │ │ + 297 } │ │ │ │ │ + 298 │ │ │ │ │ + 299 │ │ │ │ │ + 312 template │ │ │ │ │ +313 int gather (const T* in, T* out, int len, [[maybe_unused]] int root) const │ │ │ │ │ +// note out must have same size as in │ │ │ │ │ + 314 { │ │ │ │ │ + 315 for (int i=0; i> │ │ │ │ │ +324 PseudoFuture igather(TIN&& data_in, TOUT&& data_out, int root){ │ │ │ │ │ + 325 *(data_out.begin()) = std::forward(data_in); │ │ │ │ │ + 326 return {std::forward(data_out)}; │ │ │ │ │ + 327 } │ │ │ │ │ + 328 │ │ │ │ │ + 329 │ │ │ │ │ + 349 template │ │ │ │ │ +350 int gatherv (const T* in, │ │ │ │ │ + 351 int sendDataLen, │ │ │ │ │ + 352 T* out, │ │ │ │ │ + 353 [[maybe_unused]] int* recvDataLen, │ │ │ │ │ + 354 int* displ, │ │ │ │ │ + 355 [[maybe_unused]] int root) const │ │ │ │ │ + 356 { │ │ │ │ │ + 357 for (int i=*displ; i │ │ │ │ │ +376 int scatter (const T* sendData, T* recvData, int len, [[maybe_unused]] int │ │ │ │ │ +root) const // note out must have same size as in │ │ │ │ │ + 377 { │ │ │ │ │ + 378 for (int i=0; i │ │ │ │ │ +387 PseudoFuture iscatter(TIN&& data_in, TOUT&& data_out, int root){ │ │ │ │ │ + 388 data_out = *(std::forward(data_in).begin()); │ │ │ │ │ + 389 return {std::forward(data_out)}; │ │ │ │ │ + 390 } │ │ │ │ │ + 391 │ │ │ │ │ + 410 template │ │ │ │ │ +411 int scatterv (const T* sendData,int* sendDataLen, int* displ, T* recvData, │ │ │ │ │ + 412 [[maybe_unused]] int recvDataLen, [[maybe_unused]] int root) const │ │ │ │ │ + 413 { │ │ │ │ │ + 414 for (int i=*displ; i<*sendDataLen; i++) │ │ │ │ │ + 415 recvData[i] = sendData[i]; │ │ │ │ │ + 416 return 0; │ │ │ │ │ + 417 } │ │ │ │ │ + 418 │ │ │ │ │ + 432 template │ │ │ │ │ +433 int allgather(const T* sbuf, int count, T* rbuf) const │ │ │ │ │ + 434 { │ │ │ │ │ + 435 for(const T* end=sbuf+count; sbuf < end; ++sbuf, ++rbuf) │ │ │ │ │ + 436 *rbuf=*sbuf; │ │ │ │ │ + 437 return 0; │ │ │ │ │ + 438 } │ │ │ │ │ + 439 │ │ │ │ │ + 444 template │ │ │ │ │ +445 PseudoFuture iallgather(TIN&& data_in, TOUT&& data_out){ │ │ │ │ │ + 446 return {std::forward(data_out)}; │ │ │ │ │ + 447 } │ │ │ │ │ + 448 │ │ │ │ │ + 465 template │ │ │ │ │ +466 int allgatherv (const T* in, int sendDataLen, T* out, [[maybe_unused]] int* │ │ │ │ │ +recvDataLen, int* displ) const │ │ │ │ │ + 467 { │ │ │ │ │ + 468 for (int i=*displ; i │ │ │ │ │ +486 int allreduce([[maybe_unused]] Type* inout, [[maybe_unused]] int len) const │ │ │ │ │ + 487 { │ │ │ │ │ + 488 return 0; │ │ │ │ │ + 489 } │ │ │ │ │ + 490 │ │ │ │ │ + 495 template │ │ │ │ │ +496 PseudoFuture iallreduce(TIN&& data_in, TOUT&& data_out){ │ │ │ │ │ + 497 data_out = std::forward(data_in); │ │ │ │ │ + 498 return {std::forward(data_out)}; │ │ │ │ │ + 499 } │ │ │ │ │ + 500 │ │ │ │ │ + 505 template │ │ │ │ │ +506 PseudoFuture iallreduce(T&& data){ │ │ │ │ │ + 507 return {std::forward(data)}; │ │ │ │ │ + 508 } │ │ │ │ │ + 509 │ │ │ │ │ + 510 │ │ │ │ │ + 524 template │ │ │ │ │ +525 int allreduce(const Type* in, Type* out, int len) const │ │ │ │ │ + 526 { │ │ │ │ │ + 527 std::copy(in, in+len, out); │ │ │ │ │ + 528 return 0; │ │ │ │ │ + 529 } │ │ │ │ │ + 530 │ │ │ │ │ + 531 }; │ │ │ │ │ + 532 │ │ │ │ │ + 538 template │ │ │ │ │ +539 using CollectiveCommunication │ │ │ │ │ + 540 [[deprecated("CollectiveCommunication is deprecated. Use Communication │ │ │ │ │ +instead.")]] │ │ │ │ │ + 541 = Communication; │ │ │ │ │ + 542} │ │ │ │ │ + 543 │ │ │ │ │ + 544#endif │ │ │ │ │ +future.hh │ │ │ │ │ +exceptions.hh │ │ │ │ │ +A few common exception classes. │ │ │ │ │ +binaryfunctions.hh │ │ │ │ │ +helper classes to provide unique types for standard functions │ │ │ │ │ +DUNE_THROW │ │ │ │ │ +#define DUNE_THROW(E, m) │ │ │ │ │ +Definition exceptions.hh:218 │ │ │ │ │ +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:237 │ │ │ │ │ +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:259 │ │ │ │ │ +Dune │ │ │ │ │ +Dune namespace. │ │ │ │ │ +Definition alignedallocator.hh:13 │ │ │ │ │ +Dune::ParallelError │ │ │ │ │ +Default exception if an error in the parallel communication of the program │ │ │ │ │ +occurred. │ │ │ │ │ +Definition exceptions.hh:287 │ │ │ │ │ +Dune::No_Comm │ │ │ │ │ +Definition communication.hh:46 │ │ │ │ │ +Dune::Communication │ │ │ │ │ +Collective communication interface and sequential default implementation. │ │ │ │ │ +Definition communication.hh:100 │ │ │ │ │ +Dune::Communication::iallreduce │ │ │ │ │ +PseudoFuture< TOUT > iallreduce(TIN &&data_in, TOUT &&data_out) │ │ │ │ │ +Compute something over all processes nonblocking. │ │ │ │ │ +Definition communication.hh:496 │ │ │ │ │ +Dune::Communication::send │ │ │ │ │ +int send(const T &data, int dest_rank, int tag) │ │ │ │ │ +Sends the data to the dest_rank. │ │ │ │ │ +Definition communication.hh:135 │ │ │ │ │ +Dune::Communication::allreduce │ │ │ │ │ +int allreduce(const Type *in, Type *out, int len) const │ │ │ │ │ +Compute something over all processes for each component of an array and return │ │ │ │ │ +the result in every pr... │ │ │ │ │ +Definition communication.hh:525 │ │ │ │ │ +Dune::Communication::max │ │ │ │ │ +T max(const T &in) const │ │ │ │ │ +Compute the maximum of the argument over all processes and return the result in │ │ │ │ │ +every process.... │ │ │ │ │ +Definition communication.hh:248 │ │ │ │ │ +Dune::Communication::rank │ │ │ │ │ +int rank() const │ │ │ │ │ +Return rank, is between 0 and size()-1. │ │ │ │ │ +Definition communication.hh:114 │ │ │ │ │ +Dune::Communication::sum │ │ │ │ │ +T sum(const T &in) const │ │ │ │ │ +Compute the sum of the argument over all processes and return the result in │ │ │ │ │ +every process.... │ │ │ │ │ +Definition communication.hh:188 │ │ │ │ │ +Dune::Communication::scatterv │ │ │ │ │ +int scatterv(const T *sendData, int *sendDataLen, int *displ, T *recvData, int │ │ │ │ │ +recvDataLen, int root) const │ │ │ │ │ +Scatter arrays of variable length from a root to all other tasks. │ │ │ │ │ +Definition communication.hh:411 │ │ │ │ │ +Dune::Communication::prod │ │ │ │ │ +int prod(T *inout, int len) const │ │ │ │ │ +Compute the product over all processes for each component of an array and │ │ │ │ │ +return the result in every ... │ │ │ │ │ +Definition communication.hh:219 │ │ │ │ │ +Dune::Communication::recv │ │ │ │ │ +T recv(T &&data, int source_rank, int tag, void *status=0) │ │ │ │ │ +Receives the data from the source_rank. │ │ │ │ │ +Definition communication.hh:157 │ │ │ │ │ +Dune::Communication::isend │ │ │ │ │ +PseudoFuture< T > isend(const T &&data, int dest_rank, int tag) │ │ │ │ │ +Sends the data to the dest_rank nonblocking. │ │ │ │ │ +Definition communication.hh:146 │ │ │ │ │ +Dune::Communication::ibarrier │ │ │ │ │ +PseudoFuture< void > ibarrier() const │ │ │ │ │ +Nonblocking barrier. │ │ │ │ │ +Definition communication.hh:275 │ │ │ │ │ +Dune::Communication::allreduce │ │ │ │ │ +int allreduce(Type *inout, int len) const │ │ │ │ │ +Compute something over all processes for each component of an array and return │ │ │ │ │ +the result in every pr... │ │ │ │ │ +Definition communication.hh:486 │ │ │ │ │ +Dune::Communication::size │ │ │ │ │ +int size() const │ │ │ │ │ +Number of processes in set, is greater than 0. │ │ │ │ │ +Definition communication.hh:126 │ │ │ │ │ +Dune::Communication::sum │ │ │ │ │ +int sum(T *inout, int len) const │ │ │ │ │ +Compute the sum over all processes for each component of an array and return │ │ │ │ │ +the result in every proc... │ │ │ │ │ +Definition communication.hh:199 │ │ │ │ │ +Dune::Communication::allgatherv │ │ │ │ │ +int allgatherv(const T *in, int sendDataLen, T *out, int *recvDataLen, int │ │ │ │ │ +*displ) const │ │ │ │ │ +Gathers data of variable length from all tasks and distribute it to all. │ │ │ │ │ +Definition communication.hh:466 │ │ │ │ │ +Dune::Communication::min │ │ │ │ │ +T min(const T &in) const │ │ │ │ │ +Compute the minimum of the argument over all processes and return the result in │ │ │ │ │ +every process.... │ │ │ │ │ +Definition communication.hh:228 │ │ │ │ │ +Dune::Communication::irecv │ │ │ │ │ +PseudoFuture< T > irecv(T &&data, int source_rank, int tag) │ │ │ │ │ +Receives the data from the source_rank nonblocking. │ │ │ │ │ +Definition communication.hh:169 │ │ │ │ │ +Dune::Communication::gatherv │ │ │ │ │ +int gatherv(const T *in, int sendDataLen, T *out, int *recvDataLen, int *displ, │ │ │ │ │ +int root) const │ │ │ │ │ +Gather arrays of variable size on root task. │ │ │ │ │ +Definition communication.hh:350 │ │ │ │ │ +Dune::Communication::ibroadcast │ │ │ │ │ +PseudoFuture< T > ibroadcast(T &&data, int root) const │ │ │ │ │ +Distribute an array from the process with rank root to all other processes │ │ │ │ │ +nonblocking. │ │ │ │ │ +Definition communication.hh:295 │ │ │ │ │ +Dune::Communication::allgather │ │ │ │ │ +int allgather(const T *sbuf, int count, T *rbuf) const │ │ │ │ │ +Gathers data from all tasks and distribute it to all. │ │ │ │ │ +Definition communication.hh:433 │ │ │ │ │ +Dune::Communication::scatter │ │ │ │ │ +int scatter(const T *sendData, T *recvData, int len, int root) const │ │ │ │ │ +Scatter array from a root to all other task. │ │ │ │ │ +Definition communication.hh:376 │ │ │ │ │ +Dune::Communication::gather │ │ │ │ │ +int gather(const T *in, T *out, int len, int root) const │ │ │ │ │ +Gather arrays on root task. │ │ │ │ │ +Definition communication.hh:313 │ │ │ │ │ +Dune::Communication::iallreduce │ │ │ │ │ +PseudoFuture< T > iallreduce(T &&data) │ │ │ │ │ +Compute something over all processes nonblocking and in-place. │ │ │ │ │ +Definition communication.hh:506 │ │ │ │ │ +Dune::Communication::Communication │ │ │ │ │ +Communication(const Communicator &) │ │ │ │ │ +Constructor with a given communicator. │ │ │ │ │ +Definition communication.hh:110 │ │ │ │ │ +Dune::Communication::max │ │ │ │ │ +int max(T *inout, int len) const │ │ │ │ │ +Compute the maximum over all processes for each component of an array and │ │ │ │ │ +return the result in every ... │ │ │ │ │ +Definition communication.hh:259 │ │ │ │ │ +Dune::Communication::prod │ │ │ │ │ +T prod(const T &in) const │ │ │ │ │ +Compute the product of the argument over all processes and return the result in │ │ │ │ │ +every process.... │ │ │ │ │ +Definition communication.hh:208 │ │ │ │ │ +Dune::Communication::broadcast │ │ │ │ │ +int broadcast(T *inout, int len, int root) const │ │ │ │ │ +Distribute an array from the process with rank root to all other processes. │ │ │ │ │ +Definition communication.hh:284 │ │ │ │ │ +Dune::Communication::rrecv │ │ │ │ │ +T rrecv(T &&data, int source_rank, int tag, void *status=0) const │ │ │ │ │ +Definition communication.hh:177 │ │ │ │ │ +Dune::Communication::iscatter │ │ │ │ │ +PseudoFuture< TOUT > iscatter(TIN &&data_in, TOUT &&data_out, int root) │ │ │ │ │ +Scatter array from a root to all other task nonblocking. │ │ │ │ │ +Definition communication.hh:387 │ │ │ │ │ +Dune::Communication::min │ │ │ │ │ +int min(T *inout, int len) const │ │ │ │ │ +Compute the minimum over all processes for each component of an array and │ │ │ │ │ +return the result in every ... │ │ │ │ │ +Definition communication.hh:239 │ │ │ │ │ +Dune::Communication::barrier │ │ │ │ │ +int barrier() const │ │ │ │ │ +Wait until all processes have arrived at this point in the program. │ │ │ │ │ +Definition communication.hh:267 │ │ │ │ │ +Dune::Communication::igather │ │ │ │ │ +PseudoFuture< TOUT > igather(TIN &&data_in, TOUT &&data_out, int root) │ │ │ │ │ +Gather arrays on root task nonblocking. │ │ │ │ │ +Definition communication.hh:324 │ │ │ │ │ +Dune::Communication::iallgather │ │ │ │ │ +PseudoFuture< TOUT > iallgather(TIN &&data_in, TOUT &&data_out) │ │ │ │ │ +Gathers data from all tasks and distribute it to all nonblocking. │ │ │ │ │ +Definition communication.hh:445 │ │ │ │ │ +Dune::Communication::Communication │ │ │ │ │ +Communication() │ │ │ │ │ +Construct default object. │ │ │ │ │ +Definition communication.hh:103 │ │ │ │ │ +Dune::PseudoFuture │ │ │ │ │ +A wrapper-class for a object which is ready immediately. │ │ │ │ │ +Definition future.hh:122 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00071.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: debugstream.hh File Reference │ │ │ │ +dune-common: power.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -71,63 +71,42 @@ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ Classes | │ │ │ │ -Namespaces | │ │ │ │ -Typedefs
    │ │ │ │ -
    debugstream.hh File Reference
    │ │ │ │ +Namespaces
    │ │ │ │ +
    power.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ -

    Defines several output streams for messages of different importance. │ │ │ │ +

    Various implementations of the power function for run-time and static arguments. │ │ │ │ More...

    │ │ │ │ -
    #include <iostream>
    │ │ │ │ -#include <stack>
    │ │ │ │ -#include <dune/common/exceptions.hh>
    │ │ │ │ +
    #include <dune/common/math.hh>
    │ │ │ │
    │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ Classes

    struct  Dune::greater_or_equal< current, threshold >
     Greater or equal template test. More...
    struct  Dune::StaticPower< b, p >
     Calculates b^p at compile time. More...
     
    struct  Dune::common_bits< current, mask >
     activate if current and mask have common bits switched on. More...
     
    class  Dune::DebugStreamError
     standard exception for the debugstream More...
     
    class  Dune::StreamWrap
     
    class  Dune::DebugStreamState
     Intermediate class to implement tie-operation of DebugStream. More...
     
    class  Dune::DebugStream< thislevel, dlevel, alevel, activator >
     Generic class to implement debug output streams. More...
    struct  Dune::Power< p >
     Compute power for a run-time base and a compile-time integer exponent. More...
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

    │ │ │ │ Namespaces

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

    │ │ │ │ -Typedefs

    typedef unsigned int Dune::DebugLevel
     Type for debug levels.
     
    │ │ │ │

    Detailed Description

    │ │ │ │ -

    Defines several output streams for messages of different importance.

    │ │ │ │ -

    This file implements the class DebugStream to support output in a variety of debug levels. Additionally, template parameters control if the output operation is really performed so that unused debug levels can be deactivated

    │ │ │ │ +

    Various implementations of the power function for run-time and static arguments.

    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,49 +6,31 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Typedefs │ │ │ │ │ -debugstream.hh File Reference │ │ │ │ │ -Common » Debug_output │ │ │ │ │ -Defines several output streams for messages of different importance. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +power.hh File Reference │ │ │ │ │ +Various implementations of the power function for run-time and static │ │ │ │ │ +arguments. More... │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -struct  Dune::greater_or_equal<_current,_threshold_> │ │ │ │ │ -  Greater or equal template test. More... │ │ │ │ │ +struct  Dune::StaticPower<_b,_p_> │ │ │ │ │ +  Calculates b^p at compile time. More... │ │ │ │ │   │ │ │ │ │ -struct  Dune::common_bits<_current,_mask_> │ │ │ │ │ -  activate if current and mask have common bits switched on. More... │ │ │ │ │ -  │ │ │ │ │ - class  Dune::DebugStreamError │ │ │ │ │ -  standard exception for the debugstream More... │ │ │ │ │ -  │ │ │ │ │ - class  Dune::StreamWrap │ │ │ │ │ -  │ │ │ │ │ - class  Dune::DebugStreamState │ │ │ │ │ -  Intermediate class to implement tie-operation of DebugStream. More... │ │ │ │ │ -  │ │ │ │ │ - class  Dune::DebugStream<_thislevel,_dlevel,_alevel,_activator_> │ │ │ │ │ -  Generic class to implement debug output streams. More... │ │ │ │ │ +struct  Dune::Power<_p_> │ │ │ │ │ +  Compute power for a run-time base and a compile-time integer exponent. │ │ │ │ │ + More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ - Typedefs │ │ │ │ │ -typedef unsigned int Dune::DebugLevel │ │ │ │ │ -  Type for debug levels. │ │ │ │ │ -  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Defines several output streams for messages of different importance. │ │ │ │ │ -This file implements the class DebugStream to support output in a variety of │ │ │ │ │ -debug levels. Additionally, template parameters control if the output operation │ │ │ │ │ -is really performed so that unused debug levels can be deactivated │ │ │ │ │ +Various implementations of the power function for run-time and static │ │ │ │ │ +arguments. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00071_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: debugstream.hh Source File │ │ │ │ +dune-common: power.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,333 +74,63 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    debugstream.hh
    │ │ │ │ +
    power.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 (C) 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_DEBUGSTREAM_HH
    │ │ │ │ -
    7#define DUNE_DEBUGSTREAM_HH
    │ │ │ │ -
    8
    │ │ │ │ -
    13#include <iostream>
    │ │ │ │ -
    14#include <stack>
    │ │ │ │ +
    5#ifndef DUNE_COMMON_POWER_HH
    │ │ │ │ +
    6#define DUNE_COMMON_POWER_HH
    │ │ │ │ +
    7
    │ │ │ │ +
    8#warning The header power.hh is deprecated. Use power from math.hh instead.
    │ │ │ │ +
    9
    │ │ │ │ +
    14#include <dune/common/math.hh>
    │ │ │ │
    15
    │ │ │ │ - │ │ │ │ +
    16namespace Dune {
    │ │ │ │
    17
    │ │ │ │ -
    18namespace Dune {
    │ │ │ │ -
    19
    │ │ │ │ -
    118 typedef unsigned int DebugLevel;
    │ │ │ │ -
    119
    │ │ │ │ -
    129 template <DebugLevel current, DebugLevel threshold>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    131 constexpr static bool value = (current >= threshold);
    │ │ │ │ -
    132 };
    │ │ │ │ -
    │ │ │ │ -
    133
    │ │ │ │ -
    134
    │ │ │ │ -
    141 template <DebugLevel current, DebugLevel mask>
    │ │ │ │ -
    │ │ │ │ -
    142 struct common_bits {
    │ │ │ │ -
    143 constexpr static bool value = ((current & mask) != 0);
    │ │ │ │ -
    144 };
    │ │ │ │ -
    │ │ │ │ -
    145
    │ │ │ │ -
    146
    │ │ │ │ -
    148 class DebugStreamError : public IOError {};
    │ │ │ │ -
    149
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    151 public:
    │ │ │ │ -
    152 StreamWrap(std::ostream& _out) : out(_out) { }
    │ │ │ │ -
    153 std::ostream& out;
    │ │ │ │ - │ │ │ │ -
    155 };
    │ │ │ │ -
    │ │ │ │ -
    156
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    159 // !!! should be protected somehow but that won't be easy
    │ │ │ │ -
    160 public:
    │ │ │ │ - │ │ │ │ -
    163
    │ │ │ │ - │ │ │ │ -
    166
    │ │ │ │ -
    168 bool _tied;
    │ │ │ │ -
    169
    │ │ │ │ -
    171 unsigned int _tied_streams;
    │ │ │ │ -
    172 };
    │ │ │ │ -
    │ │ │ │ -
    173
    │ │ │ │ -
    188 template <DebugLevel thislevel = 1,
    │ │ │ │ -
    189 DebugLevel dlevel = 1,
    │ │ │ │ -
    190 DebugLevel alevel = 1,
    │ │ │ │ -
    191 template<DebugLevel, DebugLevel> class activator = greater_or_equal>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    193 public:
    │ │ │ │ -
    │ │ │ │ -
    199 DebugStream(std::ostream& out = std::cerr) {
    │ │ │ │ -
    200 // start a new list of streams
    │ │ │ │ -
    201 current = new StreamWrap(out);
    │ │ │ │ -
    202 current->next = 0;
    │ │ │ │ -
    203
    │ │ │ │ -
    204 // check if we are above the default activation level
    │ │ │ │ -
    205 _active = activator<thislevel,alevel>::value;
    │ │ │ │ -
    206
    │ │ │ │ -
    207 // we're not tied to another DebugStream
    │ │ │ │ -
    208 _tied = false;
    │ │ │ │ -
    209
    │ │ │ │ -
    210 // no child streams yet
    │ │ │ │ -
    211 _tied_streams = 0;
    │ │ │ │ -
    212 }
    │ │ │ │ -
    │ │ │ │ -
    213
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    220 std::ostream& fallback = std::cerr)
    │ │ │ │ -
    221 {
    │ │ │ │ -
    222 // start a new list of streams
    │ │ │ │ -
    223 current = new StreamWrap(fallback);
    │ │ │ │ -
    224 current->next = 0;
    │ │ │ │ -
    225
    │ │ │ │ -
    226 // check if we are above the default activation level
    │ │ │ │ -
    227 _active = activator<thislevel,alevel>::value;
    │ │ │ │ -
    228 _tied_streams = 0;
    │ │ │ │ -
    229
    │ │ │ │ -
    230 // tie to the provided stream
    │ │ │ │ -
    231 _tied = true;
    │ │ │ │ -
    232 tiedstate = &master;
    │ │ │ │ -
    233 tiedstate->_tied_streams++;
    │ │ │ │ -
    234 }
    │ │ │ │ -
    │ │ │ │ -
    235
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    244 {
    │ │ │ │ -
    245 // untie
    │ │ │ │ -
    246 if (_tied)
    │ │ │ │ -
    247 tiedstate->_tied_streams--;
    │ │ │ │ -
    248 else {
    │ │ │ │ -
    249 // check if somebody still ties to us...
    │ │ │ │ -
    250 if (_tied_streams != 0)
    │ │ │ │ -
    251 {
    │ │ │ │ -
    252 std::cerr << "DebugStream destructor is called while other streams are still tied to it. Terminating!" << std::endl;
    │ │ │ │ -
    253 std::terminate();
    │ │ │ │ -
    254 }
    │ │ │ │ -
    255 }
    │ │ │ │ -
    256
    │ │ │ │ -
    257 // remove ostream-stack
    │ │ │ │ -
    258 while (current != 0) {
    │ │ │ │ -
    259 StreamWrap *s = current;
    │ │ │ │ - │ │ │ │ -
    261 delete s;
    │ │ │ │ -
    262 }
    │ │ │ │ -
    263 }
    │ │ │ │ -
    │ │ │ │ -
    264
    │ │ │ │ -
    266 template <class T>
    │ │ │ │ -
    │ │ │ │ -
    267 DebugStream& operator<<(const T data) {
    │ │ │ │ -
    268 // remove the following code if stream wasn't compiled active
    │ │ │ │ -
    269 if (activator<thislevel, dlevel>::value) {
    │ │ │ │ -
    270 if (! _tied) {
    │ │ │ │ -
    271 if (_active)
    │ │ │ │ -
    272 current->out << data;
    │ │ │ │ -
    273 } else {
    │ │ │ │ -
    274 if (_active && tiedstate->_active)
    │ │ │ │ -
    275 tiedstate->current->out << data;
    │ │ │ │ -
    276 }
    │ │ │ │ -
    277 }
    │ │ │ │ -
    278
    │ │ │ │ -
    279 return *this;
    │ │ │ │ -
    280 }
    │ │ │ │ -
    │ │ │ │ -
    281
    │ │ │ │ -
    │ │ │ │ -
    289 DebugStream& operator<<(const int data) {
    │ │ │ │ -
    290 // remove the following code if stream wasn't compiled active
    │ │ │ │ -
    291 if (activator<thislevel, dlevel>::value) {
    │ │ │ │ -
    292 if (! _tied) {
    │ │ │ │ -
    293 if (_active)
    │ │ │ │ -
    294 current->out << data;
    │ │ │ │ -
    295 } else {
    │ │ │ │ -
    296 if (_active && tiedstate->_active)
    │ │ │ │ -
    297 tiedstate->current->out << data;
    │ │ │ │ -
    298 }
    │ │ │ │ -
    299 }
    │ │ │ │ -
    300
    │ │ │ │ -
    301 return *this;
    │ │ │ │ -
    302 }
    │ │ │ │ -
    │ │ │ │ -
    303
    │ │ │ │ -
    │ │ │ │ -
    305 DebugStream& operator<<(std::ostream& (*f)(std::ostream&)) {
    │ │ │ │ -
    306 if (activator<thislevel, dlevel>::value) {
    │ │ │ │ -
    307 if (! _tied) {
    │ │ │ │ -
    308 if (_active)
    │ │ │ │ -
    309 f(current->out);
    │ │ │ │ -
    310 } else {
    │ │ │ │ -
    311 if (_active && tiedstate->_active)
    │ │ │ │ -
    312 f(tiedstate->current->out);
    │ │ │ │ -
    313 }
    │ │ │ │ -
    314 }
    │ │ │ │ -
    315
    │ │ │ │ -
    316 return *this;
    │ │ │ │ -
    317 }
    │ │ │ │ -
    │ │ │ │ -
    318
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    321 if (activator<thislevel, dlevel>::value) {
    │ │ │ │ -
    322 if (! _tied) {
    │ │ │ │ -
    323 if (_active)
    │ │ │ │ -
    324 current->out.flush();
    │ │ │ │ -
    325 } else {
    │ │ │ │ -
    326 if (_active && tiedstate->_active)
    │ │ │ │ -
    327 tiedstate->current->out.flush();
    │ │ │ │ -
    328 }
    │ │ │ │ -
    329 }
    │ │ │ │ -
    330
    │ │ │ │ -
    331 return *this;
    │ │ │ │ -
    332 }
    │ │ │ │ -
    │ │ │ │ -
    333
    │ │ │ │ -
    │ │ │ │ -
    335 void push(bool b) {
    │ │ │ │ -
    336 // are we at all active?
    │ │ │ │ -
    337 if (activator<thislevel,alevel>::value) {
    │ │ │ │ -
    338 _actstack.push(_active);
    │ │ │ │ -
    339 _active = b;
    │ │ │ │ -
    340 } else {
    │ │ │ │ -
    341 // stay off
    │ │ │ │ -
    342 _actstack.push(false);
    │ │ │ │ -
    343 }
    │ │ │ │ -
    344 }
    │ │ │ │ -
    │ │ │ │ -
    345
    │ │ │ │ -
    │ │ │ │ -
    349 void pop() {
    │ │ │ │ -
    350 if (_actstack.empty())
    │ │ │ │ -
    351 DUNE_THROW(DebugStreamError, "No previous activation setting!");
    │ │ │ │ -
    352
    │ │ │ │ -
    353 _active = _actstack.top();
    │ │ │ │ -
    354 _actstack.pop();
    │ │ │ │ -
    355 }
    │ │ │ │ -
    │ │ │ │ -
    356
    │ │ │ │ -
    │ │ │ │ -
    363 bool active() const {
    │ │ │ │ -
    364 return activator<thislevel, dlevel>::value && _active;
    │ │ │ │ -
    365 }
    │ │ │ │ -
    │ │ │ │ -
    366
    │ │ │ │ -
    │ │ │ │ -
    371 void attach(std::ostream& stream) {
    │ │ │ │ -
    372 if (_tied)
    │ │ │ │ -
    373 DUNE_THROW(DebugStreamError, "Cannot attach to a tied stream!");
    │ │ │ │ -
    374
    │ │ │ │ -
    375 StreamWrap* newcurr = new StreamWrap(stream);
    │ │ │ │ -
    376 newcurr->next = current;
    │ │ │ │ -
    377 current = newcurr;
    │ │ │ │ -
    378 }
    │ │ │ │ -
    │ │ │ │ -
    379
    │ │ │ │ -
    │ │ │ │ -
    383 void detach() {
    │ │ │ │ -
    384 if (current->next == 0)
    │ │ │ │ -
    385 DUNE_THROW(DebugStreamError, "Cannot detach initial stream!");
    │ │ │ │ -
    386 if (_tied)
    │ │ │ │ -
    387 DUNE_THROW(DebugStreamError, "Cannot detach a tied stream!");
    │ │ │ │ -
    388
    │ │ │ │ -
    389 StreamWrap* old = current;
    │ │ │ │ - │ │ │ │ -
    391 delete old;
    │ │ │ │ -
    392 }
    │ │ │ │ -
    │ │ │ │ -
    393
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    398 if (to._tied)
    │ │ │ │ -
    399 DUNE_THROW(DebugStreamError, "Cannot tie to an already tied stream!");
    │ │ │ │ -
    400 if (_tied)
    │ │ │ │ -
    401 DUNE_THROW(DebugStreamError, "Stream already tied: untie first!");
    │ │ │ │ -
    402
    │ │ │ │ -
    403 _tied = true;
    │ │ │ │ -
    404 tiedstate = &to;
    │ │ │ │ -
    405
    │ │ │ │ -
    406 // tell master class
    │ │ │ │ -
    407 tiedstate->_tied_streams++;
    │ │ │ │ -
    408 }
    │ │ │ │ -
    │ │ │ │ -
    409
    │ │ │ │ -
    │ │ │ │ -
    413 void untie() {
    │ │ │ │ -
    414 if(! _tied)
    │ │ │ │ -
    415 DUNE_THROW(DebugStreamError, "Cannot untie, stream is not tied!");
    │ │ │ │ -
    416
    │ │ │ │ -
    417 tiedstate->_tied_streams--;
    │ │ │ │ -
    418 _tied = false;
    │ │ │ │ -
    419 tiedstate = 0;
    │ │ │ │ -
    420 }
    │ │ │ │ -
    │ │ │ │ -
    421
    │ │ │ │ -
    422 private:
    │ │ │ │ -
    424 DebugStreamState* tiedstate;
    │ │ │ │ -
    425
    │ │ │ │ -
    430 std::stack<bool> _actstack;
    │ │ │ │ -
    431 };
    │ │ │ │ -
    │ │ │ │ -
    432
    │ │ │ │ -
    434}
    │ │ │ │ -
    435
    │ │ │ │ -
    436
    │ │ │ │ -
    437#endif
    │ │ │ │ -
    A few common exception classes.
    │ │ │ │ -
    StreamWrap(std::ostream &_out)
    Definition debugstream.hh:152
    │ │ │ │ -
    DebugStream(std::ostream &out=std::cerr)
    Create a DebugStream and set initial output stream.
    Definition debugstream.hh:199
    │ │ │ │ -
    void untie()
    Untie stream.
    Definition debugstream.hh:413
    │ │ │ │ -
    DebugStream & flush()
    pass on flush to underlying output stream
    Definition debugstream.hh:320
    │ │ │ │ -
    void attach(std::ostream &stream)
    set output to a different stream.
    Definition debugstream.hh:371
    │ │ │ │ -
    void detach()
    detach current output stream and restore to previous stream
    Definition debugstream.hh:383
    │ │ │ │ -
    static constexpr bool value
    Definition debugstream.hh:143
    │ │ │ │ -
    std::ostream & out
    Definition debugstream.hh:153
    │ │ │ │ -
    void pop()
    restore previously set activation flag
    Definition debugstream.hh:349
    │ │ │ │ -
    bool active() const
    reports if this stream will produce output
    Definition debugstream.hh:363
    │ │ │ │ -
    bool _active
    flag to switch output during runtime
    Definition debugstream.hh:165
    │ │ │ │ -
    unsigned int _tied_streams
    how many streams are tied to this state
    Definition debugstream.hh:171
    │ │ │ │ -
    void tie(DebugStreamState &to)
    Tie a stream to this one.
    Definition debugstream.hh:397
    │ │ │ │ -
    void push(bool b)
    set activation flag and store old value
    Definition debugstream.hh:335
    │ │ │ │ -
    unsigned int DebugLevel
    Type for debug levels.
    Definition debugstream.hh:118
    │ │ │ │ -
    bool _tied
    are we tied to another DebugStream?
    Definition debugstream.hh:168
    │ │ │ │ -
    StreamWrap * current
    current output stream and link to possibly pushed old output streams
    Definition debugstream.hh:162
    │ │ │ │ -
    DebugStream & operator<<(const T data)
    Generic types are passed on to current output stream.
    Definition debugstream.hh:267
    │ │ │ │ -
    static constexpr bool value
    Definition debugstream.hh:131
    │ │ │ │ -
    ~DebugStream()
    Destroy stream.
    Definition debugstream.hh:243
    │ │ │ │ -
    DebugStream(DebugStreamState &master, std::ostream &fallback=std::cerr)
    Create a DebugStream and directly tie to another DebugStream.
    Definition debugstream.hh:219
    │ │ │ │ -
    DebugStream & operator<<(const int data)
    explicit specialization so that enums can be printed
    Definition debugstream.hh:289
    │ │ │ │ -
    DebugStream & operator<<(std::ostream &(*f)(std::ostream &))
    pass on manipulators to underlying output stream
    Definition debugstream.hh:305
    │ │ │ │ -
    StreamWrap * next
    Definition debugstream.hh:154
    │ │ │ │ -
    #define DUNE_THROW(E, m)
    Definition exceptions.hh:218
    │ │ │ │ +
    26 template <int b, int p>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    28 {
    │ │ │ │ +
    30 static constexpr int power = Dune::power(b,p);
    │ │ │ │ +
    31 };
    │ │ │ │ +
    │ │ │ │ +
    32
    │ │ │ │ +
    33
    │ │ │ │ +
    40 template <int p>
    │ │ │ │ +
    │ │ │ │ +
    41 struct Power
    │ │ │ │ +
    42 {
    │ │ │ │ +
    43 template <typename T>
    │ │ │ │ +
    │ │ │ │ +
    44 static constexpr auto eval(const T & a)
    │ │ │ │ +
    45 {
    │ │ │ │ +
    46 return power(a,p);
    │ │ │ │ +
    47 }
    │ │ │ │ +
    │ │ │ │ +
    48 };
    │ │ │ │ +
    │ │ │ │ +
    49
    │ │ │ │ +
    50}
    │ │ │ │ +
    51
    │ │ │ │ +
    52#endif
    │ │ │ │ +
    Some useful basic math stuff.
    │ │ │ │ +
    static constexpr int power
    power stores b^p
    Definition power.hh:30
    │ │ │ │ +
    static constexpr auto eval(const T &a)
    Definition power.hh:44
    │ │ │ │
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ -
    Greater or equal template test.
    Definition debugstream.hh:130
    │ │ │ │ -
    activate if current and mask have common bits switched on.
    Definition debugstream.hh:142
    │ │ │ │ -
    standard exception for the debugstream
    Definition debugstream.hh:148
    │ │ │ │ -
    Definition debugstream.hh:150
    │ │ │ │ -
    Intermediate class to implement tie-operation of DebugStream.
    Definition debugstream.hh:158
    │ │ │ │ -
    Generic class to implement debug output streams.
    Definition debugstream.hh:192
    │ │ │ │ -
    Default exception class for I/O errors.
    Definition exceptions.hh:231
    │ │ │ │ +
    constexpr Base power(Base m, Exponent p)
    Power method for integer exponents.
    Definition math.hh:75
    │ │ │ │ +
    Calculates b^p at compile time.
    Definition power.hh:28
    │ │ │ │ +
    Compute power for a run-time base and a compile-time integer exponent.
    Definition power.hh:42
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,377 +7,68 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -debugstream.hh │ │ │ │ │ +power.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 (C) 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_DEBUGSTREAM_HH │ │ │ │ │ - 7#define DUNE_DEBUGSTREAM_HH │ │ │ │ │ - 8 │ │ │ │ │ - 13#include │ │ │ │ │ - 14#include │ │ │ │ │ + 5#ifndef DUNE_COMMON_POWER_HH │ │ │ │ │ + 6#define DUNE_COMMON_POWER_HH │ │ │ │ │ + 7 │ │ │ │ │ + 8#warning The header power.hh is deprecated. Use power from math.hh instead. │ │ │ │ │ + 9 │ │ │ │ │ + 14#include │ │ │ │ │ 15 │ │ │ │ │ - 16#include │ │ │ │ │ + 16namespace Dune { │ │ │ │ │ 17 │ │ │ │ │ - 18namespace Dune { │ │ │ │ │ - 19 │ │ │ │ │ -118 typedef unsigned int DebugLevel; │ │ │ │ │ - 119 │ │ │ │ │ - 129 template │ │ │ │ │ -130 struct greater_or_equal { │ │ │ │ │ -131 constexpr static bool value = (current >= threshold); │ │ │ │ │ - 132 }; │ │ │ │ │ - 133 │ │ │ │ │ - 134 │ │ │ │ │ - 141 template │ │ │ │ │ -142 struct common_bits { │ │ │ │ │ -143 constexpr static bool value = ((current & mask) != 0); │ │ │ │ │ - 144 }; │ │ │ │ │ - 145 │ │ │ │ │ - 146 │ │ │ │ │ -148 class DebugStreamError : public IOError {}; │ │ │ │ │ - 149 │ │ │ │ │ -150 class StreamWrap { │ │ │ │ │ - 151 public: │ │ │ │ │ -152 StreamWrap(std::ostream& _out) : out(_out) { } │ │ │ │ │ -153 std::ostream& out; │ │ │ │ │ -154 StreamWrap *next; │ │ │ │ │ - 155 }; │ │ │ │ │ - 156 │ │ │ │ │ -158 class DebugStreamState { │ │ │ │ │ - 159 // !!! should be protected somehow but that won't be easy │ │ │ │ │ - 160 public: │ │ │ │ │ -162 StreamWrap* current; │ │ │ │ │ - 163 │ │ │ │ │ -165 bool _active; │ │ │ │ │ - 166 │ │ │ │ │ -168 bool _tied; │ │ │ │ │ - 169 │ │ │ │ │ -171 unsigned int _tied_streams; │ │ │ │ │ - 172 }; │ │ │ │ │ - 173 │ │ │ │ │ - 188 template class activator = greater_or_equal> │ │ │ │ │ -192 class DebugStream : public DebugStreamState { │ │ │ │ │ - 193 public: │ │ │ │ │ -199 DebugStream(std::ostream& out = std::cerr) { │ │ │ │ │ - 200 // start a new list of streams │ │ │ │ │ - 201 current = new StreamWrap(out); │ │ │ │ │ - 202 current->next = 0; │ │ │ │ │ - 203 │ │ │ │ │ - 204 // check if we are above the default activation level │ │ │ │ │ - 205 _active = activator::value; │ │ │ │ │ - 206 │ │ │ │ │ - 207 // we're not tied to another DebugStream │ │ │ │ │ - 208 _tied = false; │ │ │ │ │ - 209 │ │ │ │ │ - 210 // no child streams yet │ │ │ │ │ - 211 _tied_streams = 0; │ │ │ │ │ - 212 } │ │ │ │ │ - 213 │ │ │ │ │ -219 DebugStream (DebugStreamState& master, │ │ │ │ │ - 220 std::ostream& fallback = std::cerr) │ │ │ │ │ - 221 { │ │ │ │ │ - 222 // start a new list of streams │ │ │ │ │ - 223 current = new StreamWrap(fallback); │ │ │ │ │ - 224 current->next = 0; │ │ │ │ │ - 225 │ │ │ │ │ - 226 // check if we are above the default activation level │ │ │ │ │ - 227 _active = activator::value; │ │ │ │ │ - 228 _tied_streams = 0; │ │ │ │ │ - 229 │ │ │ │ │ - 230 // tie to the provided stream │ │ │ │ │ - 231 _tied = true; │ │ │ │ │ - 232 tiedstate = &master; │ │ │ │ │ - 233 tiedstate->_tied_streams++; │ │ │ │ │ - 234 } │ │ │ │ │ - 235 │ │ │ │ │ -243 ~DebugStream() │ │ │ │ │ - 244 { │ │ │ │ │ - 245 // untie │ │ │ │ │ - 246 if (_tied) │ │ │ │ │ - 247 tiedstate->_tied_streams--; │ │ │ │ │ - 248 else { │ │ │ │ │ - 249 // check if somebody still ties to us... │ │ │ │ │ - 250 if (_tied_streams != 0) │ │ │ │ │ - 251 { │ │ │ │ │ - 252 std::cerr << "DebugStream destructor is called while other streams are │ │ │ │ │ -still tied to it. Terminating!" << std::endl; │ │ │ │ │ - 253 std::terminate(); │ │ │ │ │ - 254 } │ │ │ │ │ - 255 } │ │ │ │ │ - 256 │ │ │ │ │ - 257 // remove ostream-stack │ │ │ │ │ - 258 while (current != 0) { │ │ │ │ │ - 259 StreamWrap *s = current; │ │ │ │ │ - 260 current = current->next; │ │ │ │ │ - 261 delete s; │ │ │ │ │ - 262 } │ │ │ │ │ - 263 } │ │ │ │ │ - 264 │ │ │ │ │ - 266 template │ │ │ │ │ -267 DebugStream& operator<<(const T data) { │ │ │ │ │ - 268 // remove the following code if stream wasn't compiled active │ │ │ │ │ - 269 if (activator::value) { │ │ │ │ │ - 270 if (! _tied) { │ │ │ │ │ - 271 if (_active) │ │ │ │ │ - 272 current->out << data; │ │ │ │ │ - 273 } else { │ │ │ │ │ - 274 if (_active && tiedstate->_active) │ │ │ │ │ - 275 tiedstate->current->out << data; │ │ │ │ │ - 276 } │ │ │ │ │ - 277 } │ │ │ │ │ - 278 │ │ │ │ │ - 279 return *this; │ │ │ │ │ - 280 } │ │ │ │ │ - 281 │ │ │ │ │ -289 DebugStream& operator<<(const int data) { │ │ │ │ │ - 290 // remove the following code if stream wasn't compiled active │ │ │ │ │ - 291 if (activator::value) { │ │ │ │ │ - 292 if (! _tied) { │ │ │ │ │ - 293 if (_active) │ │ │ │ │ - 294 current->out << data; │ │ │ │ │ - 295 } else { │ │ │ │ │ - 296 if (_active && tiedstate->_active) │ │ │ │ │ - 297 tiedstate->current->out << data; │ │ │ │ │ - 298 } │ │ │ │ │ - 299 } │ │ │ │ │ - 300 │ │ │ │ │ - 301 return *this; │ │ │ │ │ - 302 } │ │ │ │ │ - 303 │ │ │ │ │ -305 DebugStream& operator<<(std::ostream& (*f)(std::ostream&)) { │ │ │ │ │ - 306 if (activator::value) { │ │ │ │ │ - 307 if (! _tied) { │ │ │ │ │ - 308 if (_active) │ │ │ │ │ - 309 f(current->out); │ │ │ │ │ - 310 } else { │ │ │ │ │ - 311 if (_active && tiedstate->_active) │ │ │ │ │ - 312 f(tiedstate->current->out); │ │ │ │ │ - 313 } │ │ │ │ │ - 314 } │ │ │ │ │ - 315 │ │ │ │ │ - 316 return *this; │ │ │ │ │ - 317 } │ │ │ │ │ - 318 │ │ │ │ │ -320 DebugStream& flush() { │ │ │ │ │ - 321 if (activator::value) { │ │ │ │ │ - 322 if (! _tied) { │ │ │ │ │ - 323 if (_active) │ │ │ │ │ - 324 current->out.flush(); │ │ │ │ │ - 325 } else { │ │ │ │ │ - 326 if (_active && tiedstate->_active) │ │ │ │ │ - 327 tiedstate->current->out.flush(); │ │ │ │ │ - 328 } │ │ │ │ │ - 329 } │ │ │ │ │ - 330 │ │ │ │ │ - 331 return *this; │ │ │ │ │ - 332 } │ │ │ │ │ - 333 │ │ │ │ │ -335 void push(bool b) { │ │ │ │ │ - 336 // are we at all active? │ │ │ │ │ - 337 if (activator::value) { │ │ │ │ │ - 338 _actstack.push(_active); │ │ │ │ │ - 339 _active = b; │ │ │ │ │ - 340 } else { │ │ │ │ │ - 341 // stay off │ │ │ │ │ - 342 _actstack.push(false); │ │ │ │ │ - 343 } │ │ │ │ │ - 344 } │ │ │ │ │ - 345 │ │ │ │ │ -349 void pop() { │ │ │ │ │ - 350 if (_actstack.empty()) │ │ │ │ │ - 351 DUNE_THROW(DebugStreamError, "No previous activation setting!"); │ │ │ │ │ - 352 │ │ │ │ │ - 353 _active = _actstack.top(); │ │ │ │ │ - 354 _actstack.pop(); │ │ │ │ │ - 355 } │ │ │ │ │ - 356 │ │ │ │ │ -363 bool active() const { │ │ │ │ │ - 364 return activator::value && _active; │ │ │ │ │ - 365 } │ │ │ │ │ - 366 │ │ │ │ │ -371 void attach(std::ostream& stream) { │ │ │ │ │ - 372 if (_tied) │ │ │ │ │ - 373 DUNE_THROW(DebugStreamError, "Cannot attach to a tied stream!"); │ │ │ │ │ - 374 │ │ │ │ │ - 375 StreamWrap* newcurr = new StreamWrap(stream); │ │ │ │ │ - 376 newcurr->next = current; │ │ │ │ │ - 377 current = newcurr; │ │ │ │ │ - 378 } │ │ │ │ │ - 379 │ │ │ │ │ -383 void detach() { │ │ │ │ │ - 384 if (current->next == 0) │ │ │ │ │ - 385 DUNE_THROW(DebugStreamError, "Cannot detach initial stream!"); │ │ │ │ │ - 386 if (_tied) │ │ │ │ │ - 387 DUNE_THROW(DebugStreamError, "Cannot detach a tied stream!"); │ │ │ │ │ - 388 │ │ │ │ │ - 389 StreamWrap* old = current; │ │ │ │ │ - 390 current = current->next; │ │ │ │ │ - 391 delete old; │ │ │ │ │ - 392 } │ │ │ │ │ - 393 │ │ │ │ │ -397 void tie(DebugStreamState& to) { │ │ │ │ │ - 398 if (to._tied) │ │ │ │ │ - 399 DUNE_THROW(DebugStreamError, "Cannot tie to an already tied stream!"); │ │ │ │ │ - 400 if (_tied) │ │ │ │ │ - 401 DUNE_THROW(DebugStreamError, "Stream already tied: untie first!"); │ │ │ │ │ - 402 │ │ │ │ │ - 403 _tied = true; │ │ │ │ │ - 404 tiedstate = &to; │ │ │ │ │ - 405 │ │ │ │ │ - 406 // tell master class │ │ │ │ │ - 407 tiedstate->_tied_streams++; │ │ │ │ │ - 408 } │ │ │ │ │ - 409 │ │ │ │ │ -413 void untie() { │ │ │ │ │ - 414 if(! _tied) │ │ │ │ │ - 415 DUNE_THROW(DebugStreamError, "Cannot untie, stream is not tied!"); │ │ │ │ │ - 416 │ │ │ │ │ - 417 tiedstate->_tied_streams--; │ │ │ │ │ - 418 _tied = false; │ │ │ │ │ - 419 tiedstate = 0; │ │ │ │ │ - 420 } │ │ │ │ │ - 421 │ │ │ │ │ - 422 private: │ │ │ │ │ - 424 DebugStreamState* tiedstate; │ │ │ │ │ - 425 │ │ │ │ │ - 430 std::stack _actstack; │ │ │ │ │ - 431 }; │ │ │ │ │ - 432 │ │ │ │ │ - 434} │ │ │ │ │ - 435 │ │ │ │ │ - 436 │ │ │ │ │ - 437#endif │ │ │ │ │ -exceptions.hh │ │ │ │ │ -A few common exception classes. │ │ │ │ │ -Dune::StreamWrap::StreamWrap │ │ │ │ │ -StreamWrap(std::ostream &_out) │ │ │ │ │ -Definition debugstream.hh:152 │ │ │ │ │ -Dune::DebugStream::DebugStream │ │ │ │ │ -DebugStream(std::ostream &out=std::cerr) │ │ │ │ │ -Create a DebugStream and set initial output stream. │ │ │ │ │ -Definition debugstream.hh:199 │ │ │ │ │ -Dune::DebugStream::untie │ │ │ │ │ -void untie() │ │ │ │ │ -Untie stream. │ │ │ │ │ -Definition debugstream.hh:413 │ │ │ │ │ -Dune::DebugStream::flush │ │ │ │ │ -DebugStream & flush() │ │ │ │ │ -pass on flush to underlying output stream │ │ │ │ │ -Definition debugstream.hh:320 │ │ │ │ │ -Dune::DebugStream::attach │ │ │ │ │ -void attach(std::ostream &stream) │ │ │ │ │ -set output to a different stream. │ │ │ │ │ -Definition debugstream.hh:371 │ │ │ │ │ -Dune::DebugStream::detach │ │ │ │ │ -void detach() │ │ │ │ │ -detach current output stream and restore to previous stream │ │ │ │ │ -Definition debugstream.hh:383 │ │ │ │ │ -Dune::common_bits::value │ │ │ │ │ -static constexpr bool value │ │ │ │ │ -Definition debugstream.hh:143 │ │ │ │ │ -Dune::StreamWrap::out │ │ │ │ │ -std::ostream & out │ │ │ │ │ -Definition debugstream.hh:153 │ │ │ │ │ -Dune::DebugStream::pop │ │ │ │ │ -void pop() │ │ │ │ │ -restore previously set activation flag │ │ │ │ │ -Definition debugstream.hh:349 │ │ │ │ │ -Dune::DebugStream::active │ │ │ │ │ -bool active() const │ │ │ │ │ -reports if this stream will produce output │ │ │ │ │ -Definition debugstream.hh:363 │ │ │ │ │ -Dune::DebugStreamState::_active │ │ │ │ │ -bool _active │ │ │ │ │ -flag to switch output during runtime │ │ │ │ │ -Definition debugstream.hh:165 │ │ │ │ │ -Dune::DebugStreamState::_tied_streams │ │ │ │ │ -unsigned int _tied_streams │ │ │ │ │ -how many streams are tied to this state │ │ │ │ │ -Definition debugstream.hh:171 │ │ │ │ │ -Dune::DebugStream::tie │ │ │ │ │ -void tie(DebugStreamState &to) │ │ │ │ │ -Tie a stream to this one. │ │ │ │ │ -Definition debugstream.hh:397 │ │ │ │ │ -Dune::DebugStream::push │ │ │ │ │ -void push(bool b) │ │ │ │ │ -set activation flag and store old value │ │ │ │ │ -Definition debugstream.hh:335 │ │ │ │ │ -Dune::DebugLevel │ │ │ │ │ -unsigned int DebugLevel │ │ │ │ │ -Type for debug levels. │ │ │ │ │ -Definition debugstream.hh:118 │ │ │ │ │ -Dune::DebugStreamState::_tied │ │ │ │ │ -bool _tied │ │ │ │ │ -are we tied to another DebugStream? │ │ │ │ │ -Definition debugstream.hh:168 │ │ │ │ │ -Dune::DebugStreamState::current │ │ │ │ │ -StreamWrap * current │ │ │ │ │ -current output stream and link to possibly pushed old output streams │ │ │ │ │ -Definition debugstream.hh:162 │ │ │ │ │ -Dune::DebugStream::operator<< │ │ │ │ │ -DebugStream & operator<<(const T data) │ │ │ │ │ -Generic types are passed on to current output stream. │ │ │ │ │ -Definition debugstream.hh:267 │ │ │ │ │ -Dune::greater_or_equal::value │ │ │ │ │ -static constexpr bool value │ │ │ │ │ -Definition debugstream.hh:131 │ │ │ │ │ -Dune::DebugStream::~DebugStream │ │ │ │ │ -~DebugStream() │ │ │ │ │ -Destroy stream. │ │ │ │ │ -Definition debugstream.hh:243 │ │ │ │ │ -Dune::DebugStream::DebugStream │ │ │ │ │ -DebugStream(DebugStreamState &master, std::ostream &fallback=std::cerr) │ │ │ │ │ -Create a DebugStream and directly tie to another DebugStream. │ │ │ │ │ -Definition debugstream.hh:219 │ │ │ │ │ -Dune::DebugStream::operator<< │ │ │ │ │ -DebugStream & operator<<(const int data) │ │ │ │ │ -explicit specialization so that enums can be printed │ │ │ │ │ -Definition debugstream.hh:289 │ │ │ │ │ -Dune::DebugStream::operator<< │ │ │ │ │ -DebugStream & operator<<(std::ostream &(*f)(std::ostream &)) │ │ │ │ │ -pass on manipulators to underlying output stream │ │ │ │ │ -Definition debugstream.hh:305 │ │ │ │ │ -Dune::StreamWrap::next │ │ │ │ │ -StreamWrap * next │ │ │ │ │ -Definition debugstream.hh:154 │ │ │ │ │ -DUNE_THROW │ │ │ │ │ -#define DUNE_THROW(E, m) │ │ │ │ │ -Definition exceptions.hh:218 │ │ │ │ │ + 26 template │ │ │ │ │ +27 struct StaticPower │ │ │ │ │ + 28 { │ │ │ │ │ +30 static constexpr int power = Dune::power(b,p); │ │ │ │ │ + 31 }; │ │ │ │ │ + 32 │ │ │ │ │ + 33 │ │ │ │ │ + 40 template │ │ │ │ │ +41 struct Power │ │ │ │ │ + 42 { │ │ │ │ │ + 43 template │ │ │ │ │ +44 static constexpr auto eval(const T & a) │ │ │ │ │ + 45 { │ │ │ │ │ + 46 return power(a,p); │ │ │ │ │ + 47 } │ │ │ │ │ + 48 }; │ │ │ │ │ + 49 │ │ │ │ │ + 50} │ │ │ │ │ + 51 │ │ │ │ │ + 52#endif │ │ │ │ │ +math.hh │ │ │ │ │ +Some useful basic math stuff. │ │ │ │ │ +Dune::StaticPower::power │ │ │ │ │ +static constexpr int power │ │ │ │ │ +power stores b^p │ │ │ │ │ +Definition power.hh:30 │ │ │ │ │ +Dune::Power::eval │ │ │ │ │ +static constexpr auto eval(const T &a) │ │ │ │ │ +Definition power.hh:44 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::greater_or_equal │ │ │ │ │ -Greater or equal template test. │ │ │ │ │ -Definition debugstream.hh:130 │ │ │ │ │ -Dune::common_bits │ │ │ │ │ -activate if current and mask have common bits switched on. │ │ │ │ │ -Definition debugstream.hh:142 │ │ │ │ │ -Dune::DebugStreamError │ │ │ │ │ -standard exception for the debugstream │ │ │ │ │ -Definition debugstream.hh:148 │ │ │ │ │ -Dune::StreamWrap │ │ │ │ │ -Definition debugstream.hh:150 │ │ │ │ │ -Dune::DebugStreamState │ │ │ │ │ -Intermediate class to implement tie-operation of DebugStream. │ │ │ │ │ -Definition debugstream.hh:158 │ │ │ │ │ -Dune::DebugStream │ │ │ │ │ -Generic class to implement debug output streams. │ │ │ │ │ -Definition debugstream.hh:192 │ │ │ │ │ -Dune::IOError │ │ │ │ │ -Default exception class for I/O errors. │ │ │ │ │ -Definition exceptions.hh:231 │ │ │ │ │ +Dune::power │ │ │ │ │ +constexpr Base power(Base m, Exponent p) │ │ │ │ │ +Power method for integer exponents. │ │ │ │ │ +Definition math.hh:75 │ │ │ │ │ +Dune::StaticPower │ │ │ │ │ +Calculates b^p at compile time. │ │ │ │ │ +Definition power.hh:28 │ │ │ │ │ +Dune::Power │ │ │ │ │ +Compute power for a run-time base and a compile-time integer exponent. │ │ │ │ │ +Definition power.hh:42 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00074.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: debugalign.cc File Reference │ │ │ │ +dune-common: documentation.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,46 +70,46 @@ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ +Classes | │ │ │ │ Namespaces | │ │ │ │ -Functions
    │ │ │ │ -
    debugalign.cc File Reference
    │ │ │ │ +Enumerations
    │ │ │ │ +
    documentation.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ -
    #include <config.h>
    │ │ │ │ -#include <cstddef>
    │ │ │ │ -#include <cstdlib>
    │ │ │ │ -#include <functional>
    │ │ │ │ -#include <ios>
    │ │ │ │ -#include <iostream>
    │ │ │ │ -#include <utility>
    │ │ │ │ -#include <dune/common/debugalign.hh>
    │ │ │ │ -
    │ │ │ │ + │ │ │ │ +

    Documentation related stuff. │ │ │ │ +More...

    │ │ │ │ + │ │ │ │ +

    Go to the source code of this file.

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

    │ │ │ │ +Classes

    struct  Dune::ImplementationDefined
     Dummy struct used for documentation purposes. More...
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

    │ │ │ │ Namespaces

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

    │ │ │ │ -Functions

    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
     

    │ │ │ │ +Enumerations

    enum  { Dune::implementationDefined │ │ │ │ + }
     
    │ │ │ │ -
    │ │ │ │ +

    Detailed Description

    │ │ │ │ +

    Documentation related stuff.

    │ │ │ │ +
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,37 +6,27 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Namespaces | Functions │ │ │ │ │ -debugalign.cc File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces | Enumerations │ │ │ │ │ +documentation.hh File Reference │ │ │ │ │ +Documentation related stuff. More... │ │ │ │ │ +Go_to_the_source_code_of_this_file. │ │ │ │ │ + Classes │ │ │ │ │ +struct  Dune::ImplementationDefined │ │ │ │ │ +  Dummy struct used for documentation purposes. More... │ │ │ │ │ +  │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ - Functions │ │ │ │ │ - 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 │ │ │ │ │ + Enumerations │ │ │ │ │ +enum  { Dune::implementationDefined } │ │ │ │ │   │ │ │ │ │ +***** Detailed Description ***** │ │ │ │ │ +Documentation related stuff. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00077.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: scalarvectorview.hh File Reference │ │ │ │ +dune-common: iteratorrange.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,39 +70,34 @@ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ +Classes | │ │ │ │ Namespaces
    │ │ │ │ -
    scalarvectorview.hh File Reference
    │ │ │ │ +
    iteratorrange.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ -

    Implements a scalar vector view wrapper around an existing scalar. │ │ │ │ -More...

    │ │ │ │ -
    #include <cstddef>
    │ │ │ │ -#include <type_traits>
    │ │ │ │ -#include <istream>
    │ │ │ │ -#include <dune/common/densevector.hh>
    │ │ │ │ -#include <dune/common/fvector.hh>
    │ │ │ │ -#include <dune/common/typetraits.hh>
    │ │ │ │ -#include <dune/common/matvectraits.hh>
    │ │ │ │ -
    │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ +Classes

    class  Dune::IteratorRange< Iterator >
     Simple range between a begin and an end iterator. More...
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

    │ │ │ │ Namespaces

    namespace  Dune
     Dune namespace.
     
    │ │ │ │ -

    Detailed Description

    │ │ │ │ -

    Implements a scalar vector view wrapper around an existing scalar.

    │ │ │ │ -
    │ │ │ │ +
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,28 +6,21 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Namespaces │ │ │ │ │ -scalarvectorview.hh File Reference │ │ │ │ │ -Common » Dense_Matrix_and_Vector_Template_Library │ │ │ │ │ -Implements a scalar vector view wrapper around an existing scalar. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +iteratorrange.hh File Reference │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ + Classes │ │ │ │ │ +class  Dune::IteratorRange<_Iterator_> │ │ │ │ │ +  Simple range between a begin and an end iterator. More... │ │ │ │ │ +  │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -Implements a scalar vector view wrapper around an existing scalar. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00077_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: scalarvectorview.hh Source File │ │ │ │ +dune-common: iteratorrange.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,194 +74,84 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    scalarvectorview.hh
    │ │ │ │ +
    iteratorrange.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 (C) 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_SCALARVECTORVIEW_HH
    │ │ │ │ -
    6#define DUNE_COMMON_SCALARVECTORVIEW_HH
    │ │ │ │ +
    5#ifndef DUNE_COMMON_ITERATORRANGE_HH
    │ │ │ │ +
    6#define DUNE_COMMON_ITERATORRANGE_HH
    │ │ │ │
    7
    │ │ │ │ -
    8#include <cstddef>
    │ │ │ │ -
    9#include <type_traits>
    │ │ │ │ -
    10#include <istream>
    │ │ │ │ +
    8namespace Dune {
    │ │ │ │ +
    9
    │ │ │ │
    11
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
    16
    │ │ │ │ -
    17namespace Dune {
    │ │ │ │ -
    18
    │ │ │ │ -
    19namespace Impl {
    │ │ │ │ -
    20
    │ │ │ │ -
    35 template<class K>
    │ │ │ │ -
    36 class ScalarVectorView :
    │ │ │ │ -
    37 public DenseVector<ScalarVectorView<K>>
    │ │ │ │ -
    38 {
    │ │ │ │ -
    39 K* dataP_;
    │ │ │ │ -
    40 using Base = DenseVector<ScalarVectorView<K>>;
    │ │ │ │ -
    41
    │ │ │ │ -
    42 template <class>
    │ │ │ │ -
    43 friend class ScalarVectorView;
    │ │ │ │ -
    44 public:
    │ │ │ │ -
    45
    │ │ │ │ -
    47 constexpr static int dimension = 1;
    │ │ │ │ -
    48
    │ │ │ │ -
    50 using size_type = typename Base::size_type;
    │ │ │ │ -
    51
    │ │ │ │ -
    53 using reference = std::decay_t<K>&;
    │ │ │ │ -
    54
    │ │ │ │ -
    56 using const_reference = const K&;
    │ │ │ │ -
    57
    │ │ │ │ -
    58 //===== construction
    │ │ │ │ -
    59
    │ │ │ │ -
    61 constexpr ScalarVectorView ()
    │ │ │ │ -
    62 : dataP_(nullptr)
    │ │ │ │ -
    63 {}
    │ │ │ │ -
    64
    │ │ │ │ -
    66 ScalarVectorView (K* p) :
    │ │ │ │ -
    67 dataP_(p)
    │ │ │ │ -
    68 {}
    │ │ │ │ -
    69
    │ │ │ │ -
    71 ScalarVectorView (const ScalarVectorView &other) :
    │ │ │ │ -
    72 Base(),
    │ │ │ │ -
    73 dataP_(other.dataP_)
    │ │ │ │ -
    74 {}
    │ │ │ │ -
    75
    │ │ │ │ -
    77 ScalarVectorView (ScalarVectorView &&other) :
    │ │ │ │ -
    78 Base(),
    │ │ │ │ -
    79 dataP_( other.dataP_ )
    │ │ │ │ -
    80 {}
    │ │ │ │ -
    81
    │ │ │ │ -
    83 ScalarVectorView& operator= (const ScalarVectorView& other)
    │ │ │ │ -
    84 {
    │ │ │ │ -
    85 assert(dataP_);
    │ │ │ │ -
    86 assert(other.dataP_);
    │ │ │ │ -
    87 *dataP_ = *(other.dataP_);
    │ │ │ │ -
    88 return *this;
    │ │ │ │ -
    89 }
    │ │ │ │ -
    90
    │ │ │ │ -
    91 template<class KK>
    │ │ │ │ -
    92 ScalarVectorView& operator= (const ScalarVectorView<KK>& other)
    │ │ │ │ -
    93 {
    │ │ │ │ -
    94 assert(dataP_);
    │ │ │ │ -
    95 assert(other.dataP_);
    │ │ │ │ -
    96 *dataP_ = *(other.dataP_);
    │ │ │ │ -
    97 return *this;
    │ │ │ │ -
    98 }
    │ │ │ │ -
    99
    │ │ │ │ -
    101 template<typename T,
    │ │ │ │ -
    102 std::enable_if_t<std::is_convertible<T, K>::value, int> = 0>
    │ │ │ │ -
    103 inline ScalarVectorView& operator= (const T& k)
    │ │ │ │ -
    104 {
    │ │ │ │ -
    105 *dataP_ = k;
    │ │ │ │ -
    106 return *this;
    │ │ │ │ -
    107 }
    │ │ │ │ -
    108
    │ │ │ │ -
    110 static constexpr size_type size ()
    │ │ │ │ -
    111 {
    │ │ │ │ -
    112 return 1;
    │ │ │ │ -
    113 }
    │ │ │ │ -
    114
    │ │ │ │ -
    116 K& operator[] ([[maybe_unused]] size_type i)
    │ │ │ │ -
    117 {
    │ │ │ │ -
    118 DUNE_ASSERT_BOUNDS(i == 0);
    │ │ │ │ -
    119 return *dataP_;
    │ │ │ │ -
    120 }
    │ │ │ │ -
    121
    │ │ │ │ -
    123 const K& operator[] ([[maybe_unused]] size_type i) const
    │ │ │ │ -
    124 {
    │ │ │ │ -
    125 DUNE_ASSERT_BOUNDS(i == 0);
    │ │ │ │ -
    126 return *dataP_;
    │ │ │ │ -
    127 }
    │ │ │ │ -
    128 }; // class ScalarVectorView
    │ │ │ │ -
    129
    │ │ │ │ -
    130} // namespace Impl
    │ │ │ │ -
    131
    │ │ │ │ -
    132
    │ │ │ │ -
    133 template< class K>
    │ │ │ │ -
    134 struct DenseMatVecTraits< Impl::ScalarVectorView<K> >
    │ │ │ │ -
    135 {
    │ │ │ │ -
    136 using derived_type = Impl::ScalarVectorView<K>;
    │ │ │ │ -
    137 using value_type = std::remove_const_t<K>;
    │ │ │ │ -
    138 using size_type = std::size_t;
    │ │ │ │ -
    139 };
    │ │ │ │ -
    140
    │ │ │ │ -
    141 template< class K >
    │ │ │ │ -
    142 struct FieldTraits< Impl::ScalarVectorView<K> > : public FieldTraits<std::remove_const_t<K>> {};
    │ │ │ │ -
    143
    │ │ │ │ -
    144 template<class K>
    │ │ │ │ -
    145 struct AutonomousValueType<Impl::ScalarVectorView<K>>
    │ │ │ │ -
    146 {
    │ │ │ │ -
    147 using type = FieldVector<std::remove_const_t<K>,1>;
    │ │ │ │ -
    148 };
    │ │ │ │ -
    149
    │ │ │ │ -
    150namespace Impl {
    │ │ │ │ -
    151
    │ │ │ │ -
    163 template<class K>
    │ │ │ │ -
    164 inline std::istream &operator>> ( std::istream &in, ScalarVectorView<K> &v )
    │ │ │ │ -
    165 {
    │ │ │ │ -
    166 K w;
    │ │ │ │ -
    167 if(in >> w)
    │ │ │ │ -
    168 v = w;
    │ │ │ │ -
    169 return in;
    │ │ │ │ -
    170 }
    │ │ │ │ -
    171
    │ │ │ │ -
    172
    │ │ │ │ -
    174 template<class T,
    │ │ │ │ -
    175 std::enable_if_t<IsNumber<T>::value, int> = 0>
    │ │ │ │ -
    176 auto asVector(T& t)
    │ │ │ │ -
    177 {
    │ │ │ │ -
    178 return ScalarVectorView<T>{&t};
    │ │ │ │ -
    179 }
    │ │ │ │ -
    180
    │ │ │ │ -
    182 template<class T,
    │ │ │ │ -
    183 std::enable_if_t<IsNumber<T>::value, int> = 0>
    │ │ │ │ -
    184 auto asVector(const T& t)
    │ │ │ │ -
    185 {
    │ │ │ │ -
    186 return ScalarVectorView<const T>{&t};
    │ │ │ │ -
    187 }
    │ │ │ │ -
    188
    │ │ │ │ -
    190 template<class T,
    │ │ │ │ -
    191 std::enable_if_t<not IsNumber<T>::value, int> = 0>
    │ │ │ │ -
    192 T& asVector(T& t)
    │ │ │ │ -
    193 {
    │ │ │ │ -
    194 return t;
    │ │ │ │ -
    195 }
    │ │ │ │ -
    196
    │ │ │ │ -
    198 template<class T,
    │ │ │ │ -
    199 std::enable_if_t<not IsNumber<T>::value, int> = 0>
    │ │ │ │ -
    200 const T& asVector(const T& t)
    │ │ │ │ -
    201 {
    │ │ │ │ -
    202 return t;
    │ │ │ │ -
    203 }
    │ │ │ │ -
    204
    │ │ │ │ -
    205} // end namespace Impl
    │ │ │ │ -
    206
    │ │ │ │ -
    207} // end namespace Dune
    │ │ │ │ -
    208
    │ │ │ │ -
    209#endif // DUNE_COMMON_SCALARVECTORVIEW_HH
    │ │ │ │ -
    Traits for type conversions and type information.
    │ │ │ │ -
    Documentation of the traits classes you need to write for each implementation of DenseVector or Dense...
    │ │ │ │ -
    Implements a vector constructed from a given type representing a field and a compile-time given size.
    │ │ │ │ -
    Implements the dense vector interface, with an exchangeable storage class.
    │ │ │ │ -
    Stream & operator>>(Stream &stream, std::tuple< Ts... > &t)
    Read a std::tuple.
    Definition streamoperators.hh:43
    │ │ │ │ -
    #define DUNE_ASSERT_BOUNDS(cond)
    If DUNE_CHECK_BOUNDS is defined: check if condition cond holds; otherwise, do nothing.
    Definition boundschecking.hh:30
    │ │ │ │ +
    20 template<typename Iterator>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    22 {
    │ │ │ │ +
    23
    │ │ │ │ +
    24 public:
    │ │ │ │ +
    25
    │ │ │ │ +
    27 typedef Iterator iterator;
    │ │ │ │ +
    28
    │ │ │ │ +
    30
    │ │ │ │ +
    33 typedef Iterator const_iterator;
    │ │ │ │ +
    34
    │ │ │ │ +
    │ │ │ │ +
    36 IteratorRange(const Iterator& begin, const Iterator& end)
    │ │ │ │ +
    37 : _begin(begin)
    │ │ │ │ +
    38 , _end(end)
    │ │ │ │ +
    39 {}
    │ │ │ │ +
    │ │ │ │ +
    40
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    43 {}
    │ │ │ │ +
    │ │ │ │ +
    44
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    47 {
    │ │ │ │ +
    48 return _begin;
    │ │ │ │ +
    49 }
    │ │ │ │ +
    │ │ │ │ +
    50
    │ │ │ │ +
    │ │ │ │ +
    52 iterator end() const
    │ │ │ │ +
    53 {
    │ │ │ │ +
    54 return _end;
    │ │ │ │ +
    55 }
    │ │ │ │ +
    │ │ │ │ +
    56
    │ │ │ │ +
    57 private:
    │ │ │ │ +
    58
    │ │ │ │ +
    59 Iterator _begin;
    │ │ │ │ +
    60 Iterator _end;
    │ │ │ │ +
    61
    │ │ │ │ +
    62 };
    │ │ │ │ +
    │ │ │ │ +
    63
    │ │ │ │ +
    64}
    │ │ │ │ +
    65
    │ │ │ │ +
    66#endif // DUNE_COMMON_ITERATORRANGE_HH
    │ │ │ │
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ -
    size_type size() const
    size method
    Definition densevector.hh:336
    │ │ │ │ -
    Traits::size_type size_type
    The type used for the index access and size operation.
    Definition densevector.hh:259
    │ │ │ │ -
    T type
    Definition typetraits.hh:501
    │ │ │ │ +
    Simple range between a begin and an end iterator.
    Definition iteratorrange.hh:22
    │ │ │ │ +
    iterator begin() const
    Returns an iterator pointing to the begin of the range.
    Definition iteratorrange.hh:46
    │ │ │ │ +
    Iterator const_iterator
    The iterator belonging to this range.
    Definition iteratorrange.hh:33
    │ │ │ │ +
    iterator end() const
    Returns an iterator pointing past the end of the range.
    Definition iteratorrange.hh:52
    │ │ │ │ +
    IteratorRange()
    Default constructor, relies on iterators being default-constructible.
    Definition iteratorrange.hh:42
    │ │ │ │ +
    Iterator iterator
    The iterator belonging to this range.
    Definition iteratorrange.hh:27
    │ │ │ │ +
    IteratorRange(const Iterator &begin, const Iterator &end)
    Constructs an iterator range on [begin,end).
    Definition iteratorrange.hh:36
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,215 +7,92 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -scalarvectorview.hh │ │ │ │ │ +iteratorrange.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 (C) 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_SCALARVECTORVIEW_HH │ │ │ │ │ - 6#define DUNE_COMMON_SCALARVECTORVIEW_HH │ │ │ │ │ + 5#ifndef DUNE_COMMON_ITERATORRANGE_HH │ │ │ │ │ + 6#define DUNE_COMMON_ITERATORRANGE_HH │ │ │ │ │ 7 │ │ │ │ │ - 8#include │ │ │ │ │ - 9#include │ │ │ │ │ - 10#include │ │ │ │ │ + 8namespace Dune { │ │ │ │ │ + 9 │ │ │ │ │ 11 │ │ │ │ │ - 12#include │ │ │ │ │ - 13#include │ │ │ │ │ - 14#include │ │ │ │ │ - 15#include │ │ │ │ │ - 16 │ │ │ │ │ - 17namespace Dune { │ │ │ │ │ - 18 │ │ │ │ │ - 19namespace Impl { │ │ │ │ │ - 20 │ │ │ │ │ - 35 template │ │ │ │ │ - 36 class ScalarVectorView : │ │ │ │ │ - 37 public DenseVector> │ │ │ │ │ - 38 { │ │ │ │ │ - 39 K* dataP_; │ │ │ │ │ - 40 using Base = DenseVector>; │ │ │ │ │ - 41 │ │ │ │ │ - 42 template │ │ │ │ │ - 43 friend class ScalarVectorView; │ │ │ │ │ - 44 public: │ │ │ │ │ - 45 │ │ │ │ │ - 47 constexpr static int dimension = 1; │ │ │ │ │ - 48 │ │ │ │ │ - 50 using size_type = typename Base::size_type; │ │ │ │ │ - 51 │ │ │ │ │ - 53 using reference = std::decay_t&; │ │ │ │ │ - 54 │ │ │ │ │ - 56 using const_reference = const K&; │ │ │ │ │ - 57 │ │ │ │ │ - 58 //===== construction │ │ │ │ │ - 59 │ │ │ │ │ - 61 constexpr ScalarVectorView () │ │ │ │ │ - 62 : dataP_(nullptr) │ │ │ │ │ - 63 {} │ │ │ │ │ - 64 │ │ │ │ │ - 66 ScalarVectorView (K* p) : │ │ │ │ │ - 67 dataP_(p) │ │ │ │ │ - 68 {} │ │ │ │ │ - 69 │ │ │ │ │ - 71 ScalarVectorView (const ScalarVectorView &other) : │ │ │ │ │ - 72 Base(), │ │ │ │ │ - 73 dataP_(other.dataP_) │ │ │ │ │ - 74 {} │ │ │ │ │ - 75 │ │ │ │ │ - 77 ScalarVectorView (ScalarVectorView &&other) : │ │ │ │ │ - 78 Base(), │ │ │ │ │ - 79 dataP_( other.dataP_ ) │ │ │ │ │ - 80 {} │ │ │ │ │ - 81 │ │ │ │ │ - 83 ScalarVectorView& operator= (const ScalarVectorView& other) │ │ │ │ │ - 84 { │ │ │ │ │ - 85 assert(dataP_); │ │ │ │ │ - 86 assert(other.dataP_); │ │ │ │ │ - 87 *dataP_ = *(other.dataP_); │ │ │ │ │ - 88 return *this; │ │ │ │ │ - 89 } │ │ │ │ │ - 90 │ │ │ │ │ - 91 template │ │ │ │ │ - 92 ScalarVectorView& operator= (const ScalarVectorView& other) │ │ │ │ │ - 93 { │ │ │ │ │ - 94 assert(dataP_); │ │ │ │ │ - 95 assert(other.dataP_); │ │ │ │ │ - 96 *dataP_ = *(other.dataP_); │ │ │ │ │ - 97 return *this; │ │ │ │ │ - 98 } │ │ │ │ │ - 99 │ │ │ │ │ - 101 template::value, int> = 0> │ │ │ │ │ - 103 inline ScalarVectorView& operator= (const T& k) │ │ │ │ │ - 104 { │ │ │ │ │ - 105 *dataP_ = k; │ │ │ │ │ - 106 return *this; │ │ │ │ │ - 107 } │ │ │ │ │ - 108 │ │ │ │ │ - 110 static constexpr size_type size () │ │ │ │ │ - 111 { │ │ │ │ │ - 112 return 1; │ │ │ │ │ - 113 } │ │ │ │ │ - 114 │ │ │ │ │ - 116 K& operator[] ([[maybe_unused]] size_type i) │ │ │ │ │ - 117 { │ │ │ │ │ - 118 DUNE_ASSERT_BOUNDS(i == 0); │ │ │ │ │ - 119 return *dataP_; │ │ │ │ │ - 120 } │ │ │ │ │ - 121 │ │ │ │ │ - 123 const K& operator[] ([[maybe_unused]] size_type i) const │ │ │ │ │ - 124 { │ │ │ │ │ - 125 DUNE_ASSERT_BOUNDS(i == 0); │ │ │ │ │ - 126 return *dataP_; │ │ │ │ │ - 127 } │ │ │ │ │ - 128 }; // class ScalarVectorView │ │ │ │ │ - 129 │ │ │ │ │ - 130} // namespace Impl │ │ │ │ │ - 131 │ │ │ │ │ - 132 │ │ │ │ │ - 133 template< class K> │ │ │ │ │ - 134 struct DenseMatVecTraits< Impl::ScalarVectorView > │ │ │ │ │ - 135 { │ │ │ │ │ - 136 using derived_type = Impl::ScalarVectorView; │ │ │ │ │ - 137 using value_type = std::remove_const_t; │ │ │ │ │ - 138 using size_type = std::size_t; │ │ │ │ │ - 139 }; │ │ │ │ │ - 140 │ │ │ │ │ - 141 template< class K > │ │ │ │ │ - 142 struct FieldTraits< Impl::ScalarVectorView > : public FieldTraits> {}; │ │ │ │ │ - 143 │ │ │ │ │ - 144 template │ │ │ │ │ - 145 struct AutonomousValueType> │ │ │ │ │ - 146 { │ │ │ │ │ - 147 using type = FieldVector,1>; │ │ │ │ │ - 148 }; │ │ │ │ │ - 149 │ │ │ │ │ - 150namespace Impl { │ │ │ │ │ - 151 │ │ │ │ │ - 163 template │ │ │ │ │ - 164 inline std::istream &operator>>( std::istream &in, ScalarVectorView &v │ │ │ │ │ -) │ │ │ │ │ - 165 { │ │ │ │ │ - 166 K w; │ │ │ │ │ - 167 if(in >> w) │ │ │ │ │ - 168 v = w; │ │ │ │ │ - 169 return in; │ │ │ │ │ - 170 } │ │ │ │ │ - 171 │ │ │ │ │ - 172 │ │ │ │ │ - 174 template::value, int> = 0> │ │ │ │ │ - 176 auto asVector(T& t) │ │ │ │ │ - 177 { │ │ │ │ │ - 178 return ScalarVectorView{&t}; │ │ │ │ │ - 179 } │ │ │ │ │ - 180 │ │ │ │ │ - 182 template::value, int> = 0> │ │ │ │ │ - 184 auto asVector(const T& t) │ │ │ │ │ - 185 { │ │ │ │ │ - 186 return ScalarVectorView{&t}; │ │ │ │ │ - 187 } │ │ │ │ │ - 188 │ │ │ │ │ - 190 template::value, int> = 0> │ │ │ │ │ - 192 T& asVector(T& t) │ │ │ │ │ - 193 { │ │ │ │ │ - 194 return t; │ │ │ │ │ - 195 } │ │ │ │ │ - 196 │ │ │ │ │ - 198 template::value, int> = 0> │ │ │ │ │ - 200 const T& asVector(const T& t) │ │ │ │ │ - 201 { │ │ │ │ │ - 202 return t; │ │ │ │ │ - 203 } │ │ │ │ │ - 204 │ │ │ │ │ - 205} // end namespace Impl │ │ │ │ │ - 206 │ │ │ │ │ - 207} // end namespace Dune │ │ │ │ │ - 208 │ │ │ │ │ - 209#endif // DUNE_COMMON_SCALARVECTORVIEW_HH │ │ │ │ │ -typetraits.hh │ │ │ │ │ -Traits for type conversions and type information. │ │ │ │ │ -matvectraits.hh │ │ │ │ │ -Documentation of the traits classes you need to write for each implementation │ │ │ │ │ -of DenseVector or Dense... │ │ │ │ │ -fvector.hh │ │ │ │ │ -Implements a vector constructed from a given type representing a field and a │ │ │ │ │ -compile-time given size. │ │ │ │ │ -densevector.hh │ │ │ │ │ -Implements the dense vector interface, with an exchangeable storage class. │ │ │ │ │ -Dune::operator>> │ │ │ │ │ -Stream & operator>>(Stream &stream, std::tuple< Ts... > &t) │ │ │ │ │ -Read a std::tuple. │ │ │ │ │ -Definition streamoperators.hh:43 │ │ │ │ │ -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 │ │ │ │ │ + 20 template │ │ │ │ │ +21 class IteratorRange │ │ │ │ │ + 22 { │ │ │ │ │ + 23 │ │ │ │ │ + 24 public: │ │ │ │ │ + 25 │ │ │ │ │ +27 typedef Iterator iterator; │ │ │ │ │ + 28 │ │ │ │ │ + 30 │ │ │ │ │ +33 typedef Iterator const_iterator; │ │ │ │ │ + 34 │ │ │ │ │ +36 IteratorRange(const Iterator& begin, const Iterator& end) │ │ │ │ │ + 37 : _begin(begin) │ │ │ │ │ + 38 , _end(end) │ │ │ │ │ + 39 {} │ │ │ │ │ + 40 │ │ │ │ │ +42 IteratorRange() │ │ │ │ │ + 43 {} │ │ │ │ │ + 44 │ │ │ │ │ +46 iterator begin() const │ │ │ │ │ + 47 { │ │ │ │ │ + 48 return _begin; │ │ │ │ │ + 49 } │ │ │ │ │ + 50 │ │ │ │ │ +52 iterator end() const │ │ │ │ │ + 53 { │ │ │ │ │ + 54 return _end; │ │ │ │ │ + 55 } │ │ │ │ │ + 56 │ │ │ │ │ + 57 private: │ │ │ │ │ + 58 │ │ │ │ │ + 59 Iterator _begin; │ │ │ │ │ + 60 Iterator _end; │ │ │ │ │ + 61 │ │ │ │ │ + 62 }; │ │ │ │ │ + 63 │ │ │ │ │ + 64} │ │ │ │ │ + 65 │ │ │ │ │ + 66#endif // DUNE_COMMON_ITERATORRANGE_HH │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::DenseVector<_ScalarVectorView<_K_>_>::size │ │ │ │ │ -size_type size() const │ │ │ │ │ -size method │ │ │ │ │ -Definition densevector.hh:336 │ │ │ │ │ -Dune::DenseVector<_ScalarVectorView<_K_>_>::size_type │ │ │ │ │ -Traits::size_type size_type │ │ │ │ │ -The type used for the index access and size operation. │ │ │ │ │ -Definition densevector.hh:259 │ │ │ │ │ -Dune::AutonomousValueType::type │ │ │ │ │ -T type │ │ │ │ │ -Definition typetraits.hh:501 │ │ │ │ │ +Dune::IteratorRange │ │ │ │ │ +Simple range between a begin and an end iterator. │ │ │ │ │ +Definition iteratorrange.hh:22 │ │ │ │ │ +Dune::IteratorRange::begin │ │ │ │ │ +iterator begin() const │ │ │ │ │ +Returns an iterator pointing to the begin of the range. │ │ │ │ │ +Definition iteratorrange.hh:46 │ │ │ │ │ +Dune::IteratorRange::const_iterator │ │ │ │ │ +Iterator const_iterator │ │ │ │ │ +The iterator belonging to this range. │ │ │ │ │ +Definition iteratorrange.hh:33 │ │ │ │ │ +Dune::IteratorRange::end │ │ │ │ │ +iterator end() const │ │ │ │ │ +Returns an iterator pointing past the end of the range. │ │ │ │ │ +Definition iteratorrange.hh:52 │ │ │ │ │ +Dune::IteratorRange::IteratorRange │ │ │ │ │ +IteratorRange() │ │ │ │ │ +Default constructor, relies on iterators being default-constructible. │ │ │ │ │ +Definition iteratorrange.hh:42 │ │ │ │ │ +Dune::IteratorRange::iterator │ │ │ │ │ +Iterator iterator │ │ │ │ │ +The iterator belonging to this range. │ │ │ │ │ +Definition iteratorrange.hh:27 │ │ │ │ │ +Dune::IteratorRange::IteratorRange │ │ │ │ │ +IteratorRange(const Iterator &begin, const Iterator &end) │ │ │ │ │ +Constructs an iterator range on [begin,end). │ │ │ │ │ +Definition iteratorrange.hh:36 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00080.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: hash.hh File Reference │ │ │ │ +dune-common: path.cc File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,180 +70,59 @@ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ -Classes | │ │ │ │ Namespaces | │ │ │ │ -Macros | │ │ │ │ Functions
    │ │ │ │ -
    hash.hh File Reference
    │ │ │ │ +
    path.cc File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ -

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

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

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

    Go to the source code of this file.

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

    │ │ │ │ -Classes

    struct  Dune::hash< T >
     Functor for hashing objects of type T. More...
     
    │ │ │ │ +
    #include <algorithm>
    │ │ │ │ +#include <iterator>
    │ │ │ │ +#include <string>
    │ │ │ │ +#include <dune/common/exceptions.hh>
    │ │ │ │ +#include <dune/common/stringutility.hh>
    │ │ │ │ +#include <dune/common/path.hh>
    │ │ │ │ +
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

    │ │ │ │ Namespaces

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

    │ │ │ │ -Macros

    #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

    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.
     
    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
     
    │ │ │ │

    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_DEFINE_HASH( template_args,
     type 
    )
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -

    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.
    │ │ │ │ -
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -

    ◆ 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.

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

    Utilities for handling filesystem paths.

    │ │ │ │ +
    Author
    Jö Fahlke jorri.nosp@m.t@jo.nosp@m.rrit..nosp@m.de
    │ │ │ │ +
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── encoding │ │ │ │ │ @@ -1 +1 @@ │ │ │ │ │ -us-ascii │ │ │ │ │ +utf-8 │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,131 +6,48 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Macros | Functions │ │ │ │ │ -hash.hh File Reference │ │ │ │ │ -Support for calculating hash values of objects. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -Go_to_the_source_code_of_this_file. │ │ │ │ │ - Classes │ │ │ │ │ -struct  Dune::hash<_T_> │ │ │ │ │ -  Functor for hashing objects of type T. More... │ │ │ │ │ -  │ │ │ │ │ +Namespaces | Functions │ │ │ │ │ +path.cc File Reference │ │ │ │ │ +Common » Utilities » Filesystem_Paths │ │ │ │ │ +Utilities for handling filesystem paths. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ - Macros │ │ │ │ │ -#define DUNE_DEFINE_HASH(template_args, type) │ │ │ │ │ -  Defines the required struct specialization to make type hashable via │ │ │ │ │ - Dune::hash. │ │ │ │ │ + Functions │ │ │ │ │ +std::string Dune::concatPaths (const std::string &base, const std::string &p) │ │ │ │ │ +  concatenate two paths │ │ │ │ │   │ │ │ │ │ -#define DUNE_HASH_TEMPLATE_ARGS(...) │ │ │ │ │ -  Wrapper macro for the template arguments in DUNE_DEFINE_HASH. │ │ │ │ │ +std::string Dune::processPath (const std::string &p) │ │ │ │ │ +  sanitize a path for further processing │ │ │ │ │   │ │ │ │ │ -#define DUNE_HASH_TYPE(...) │ │ │ │ │ -  Wrapper macro for the type to be hashed in DUNE_DEFINE_HASH. │ │ │ │ │ + bool Dune::pathIndicatesDirectory (const std::string &p) │ │ │ │ │ +  check whether the given path indicates that it is a directory │ │ │ │ │   │ │ │ │ │ - Functions │ │ │ │ │ -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. │ │ │ │ │ +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 │ │ │ │ │   │ │ │ │ │ ***** 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_DEFINE_HASH (  template_args, │ │ │ │ │ -  type  │ │ │ │ │ - ) │ │ │ │ │ -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 │ │ │ │ │ -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 │ │ │ │ │ - specialization, wrapped in a call to │ │ │ │ │ - template_args 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. │ │ │ │ │ +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/a00083.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: concept.hh File Reference │ │ │ │ +dune-common: iteratorfacades.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -73,87 +73,98 @@ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ Classes | │ │ │ │ Namespaces | │ │ │ │ Functions
    │ │ │ │ -
    concept.hh File Reference
    │ │ │ │ +
    iteratorfacades.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ -

    Infrastructure for concepts. │ │ │ │ +

    This file implements iterator facade classes for writing stl conformant iterators. │ │ │ │ More...

    │ │ │ │ -
    #include <type_traits>
    │ │ │ │ -#include <utility>
    │ │ │ │ -#include <tuple>
    │ │ │ │ -#include <dune/common/typeutilities.hh>
    │ │ │ │ -#include <dune/common/typelist.hh>
    │ │ │ │ -#include <dune/common/tupleutility.hh>
    │ │ │ │ -#include <dune/common/std/type_traits.hh>
    │ │ │ │ +
    #include <iterator>
    │ │ │ │ +#include <type_traits>
    │ │ │ │ +#include "typetraits.hh"
    │ │ │ │
    │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ Classes

    struct  Dune::Concept::Refines< BaseConcepts >
     Base class for refined concepts. More...
    class  Dune::ForwardIteratorFacade< T, V, R, D >
     Base class for stl conformant forward iterators. More...
     
    class  Dune::BidirectionalIteratorFacade< T, V, R, D >
     Facade class for stl conformant bidirectional iterators. More...
     
    class  Dune::RandomAccessIteratorFacade< T, V, R, D >
     Base class for stl conformant forward iterators. 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 () -> typename Impl::TupleEntriesModelHelper< C, Tuple >::Result
     
    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 ()
     
    template<class T1 , class V1 , class R1 , class D , class T2 , class V2 , class R2 >
    EnableIfInterOperable< T1, T2, bool >::type Dune::operator== (const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
     Checks for equality.
     
    template<class T1 , class V1 , class R1 , class D , class T2 , class V2 , class R2 >
    EnableIfInterOperable< T1, T2, bool >::type Dune::operator!= (const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
     Checks for inequality.
     
    template<class T1 , class V1 , class R1 , class D , class T2 , class V2 , class R2 >
    std::enable_if< std::is_convertible< T2, T1 >::value, bool >::type Dune::operator== (const BidirectionalIteratorFacade< T1, V1, R1, D > &lhs, const BidirectionalIteratorFacade< T2, V2, R2, D > &rhs)
     Checks for equality.
     
    template<class T1 , class V1 , class R1 , class D , class T2 , class V2 , class R2 >
    std::enable_if< std::is_convertible< T1, T2 >::value &&!std::is_convertible< T2, T1 >::value, bool >::type Dune::operator== (const BidirectionalIteratorFacade< T1, V1, R1, D > &lhs, const BidirectionalIteratorFacade< T2, V2, R2, D > &rhs)
     Checks for equality.
     
    template<class T1 , class V1 , class R1 , class D , class T2 , class V2 , class R2 >
    EnableIfInterOperable< T1, T2, bool >::type Dune::operator!= (const BidirectionalIteratorFacade< T1, V1, R1, D > &lhs, const BidirectionalIteratorFacade< T2, V2, R2, D > &rhs)
     Checks for inequality.
     
    template<class T1 , class V1 , class R1 , class D , class T2 , class V2 , class R2 >
    EnableIfInterOperable< T1, T2, bool >::type Dune::operator== (const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
     Checks for equality.
     
    template<class T1 , class V1 , class R1 , class D , class T2 , class V2 , class R2 >
    EnableIfInterOperable< T1, T2, bool >::type Dune::operator!= (const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
     Checks for inequality.
     
    template<class T1 , class V1 , class R1 , class D , class T2 , class V2 , class R2 >
    EnableIfInterOperable< T1, T2, bool >::type Dune::operator< (const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
     Comparison operator.
     
    template<class T1 , class V1 , class R1 , class D , class T2 , class V2 , class R2 >
    EnableIfInterOperable< T1, T2, bool >::type Dune::operator<= (const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
     Comparison operator.
     
    template<class T1 , class V1 , class R1 , class D , class T2 , class V2 , class R2 >
    EnableIfInterOperable< T1, T2, bool >::type Dune::operator> (const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
     Comparison operator.
     
    template<class T1 , class V1 , class R1 , class D , class T2 , class V2 , class R2 >
    EnableIfInterOperable< T1, T2, bool >::type Dune::operator>= (const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
     Comparison operator.
     
    template<class T1 , class V1 , class R1 , class D , class T2 , class V2 , class R2 >
    EnableIfInterOperable< T1, T2, D >::type Dune::operator- (const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
     Calculates the difference between two pointers.
     
    │ │ │ │

    Detailed Description

    │ │ │ │ -

    Infrastructure for concepts.

    │ │ │ │ +

    This file implements iterator facade classes for writing stl conformant iterators.

    │ │ │ │ +

    With using these facades writing iterators for arbitrary containers becomes much less cumbersome as only few functions have to be implemented. All other functions needed by the stl are provided by the facades using the Barton-Nackman trick (also known as curiously recurring template pattern.

    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,80 +7,136 @@ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ Classes | Namespaces | Functions │ │ │ │ │ -concept.hh File Reference │ │ │ │ │ -Infrastructure for concepts. More... │ │ │ │ │ +iteratorfacades.hh File Reference │ │ │ │ │ +This file implements iterator facade classes for writing stl conformant │ │ │ │ │ +iterators. More... │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +#include "typetraits.hh" │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -struct  Dune::Concept::Refines<_BaseConcepts_> │ │ │ │ │ -  Base class for refined concepts. More... │ │ │ │ │ +class  Dune::ForwardIteratorFacade<_T,_V,_R,_D_> │ │ │ │ │ +  Base class for stl conformant forward iterators. More... │ │ │ │ │ +  │ │ │ │ │ +class  Dune::BidirectionalIteratorFacade<_T,_V,_R,_D_> │ │ │ │ │ +  Facade class for stl conformant bidirectional iterators. More... │ │ │ │ │ +  │ │ │ │ │ +class  Dune::RandomAccessIteratorFacade<_T,_V,_R,_D_> │ │ │ │ │ +  Base class for stl conformant forward iterators. 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 () -> typename Impl:: │ │ │ │ │ - TupleEntriesModelHelper< C, Tuple >::Result │ │ │ │ │ -  │ │ │ │ │ -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 () │ │ │ │ │ +template │ │ │ │ │ + EnableIfInterOperable< T1, T2, bool >::type Dune::operator== (const │ │ │ │ │ + ForwardIteratorFacade< T1, │ │ │ │ │ + V1, R1, D > &lhs, const │ │ │ │ │ + ForwardIteratorFacade< T2, │ │ │ │ │ + V2, R2, D > &rhs) │ │ │ │ │ +  Checks for equality. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + EnableIfInterOperable< T1, T2, bool >::type Dune::operator!= (const │ │ │ │ │ + ForwardIteratorFacade< T1, │ │ │ │ │ + V1, R1, D > &lhs, const │ │ │ │ │ + ForwardIteratorFacade< T2, │ │ │ │ │ + V2, R2, D > &rhs) │ │ │ │ │ +  Checks for inequality. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + std::enable_if< std::is_convertible< T2, T1 >::value, Dune::operator== (const │ │ │ │ │ + bool >::type BidirectionalIteratorFacade< │ │ │ │ │ + T1, V1, R1, D > &lhs, const │ │ │ │ │ + BidirectionalIteratorFacade< │ │ │ │ │ + T2, V2, R2, D > &rhs) │ │ │ │ │ +  Checks for equality. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + std::enable_if< std::is_convertible< T1, T2 >::value Dune::operator== (const │ │ │ │ │ + &&!std::is_convertible< T2, T1 >::value, bool >::type BidirectionalIteratorFacade< │ │ │ │ │ + T1, V1, R1, D > &lhs, const │ │ │ │ │ + BidirectionalIteratorFacade< │ │ │ │ │ + T2, V2, R2, D > &rhs) │ │ │ │ │ +  Checks for equality. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + EnableIfInterOperable< T1, T2, bool >::type Dune::operator!= (const │ │ │ │ │ + BidirectionalIteratorFacade< │ │ │ │ │ + T1, V1, R1, D > &lhs, const │ │ │ │ │ + BidirectionalIteratorFacade< │ │ │ │ │ + T2, V2, R2, D > &rhs) │ │ │ │ │ +  Checks for inequality. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + EnableIfInterOperable< T1, T2, bool >::type Dune::operator== (const │ │ │ │ │ + RandomAccessIteratorFacade< │ │ │ │ │ + T1, V1, R1, D > &lhs, const │ │ │ │ │ + RandomAccessIteratorFacade< │ │ │ │ │ + T2, V2, R2, D > &rhs) │ │ │ │ │ +  Checks for equality. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + EnableIfInterOperable< T1, T2, bool >::type Dune::operator!= (const │ │ │ │ │ + RandomAccessIteratorFacade< │ │ │ │ │ + T1, V1, R1, D > &lhs, const │ │ │ │ │ + RandomAccessIteratorFacade< │ │ │ │ │ + T2, V2, R2, D > &rhs) │ │ │ │ │ +  Checks for inequality. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + EnableIfInterOperable< T1, T2, bool >::type Dune::operator< (const │ │ │ │ │ + RandomAccessIteratorFacade< │ │ │ │ │ + T1, V1, R1, D > &lhs, const │ │ │ │ │ + RandomAccessIteratorFacade< │ │ │ │ │ + T2, V2, R2, D > &rhs) │ │ │ │ │ +  Comparison operator. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + EnableIfInterOperable< T1, T2, bool >::type Dune::operator<= (const │ │ │ │ │ + RandomAccessIteratorFacade< │ │ │ │ │ + T1, V1, R1, D > &lhs, const │ │ │ │ │ + RandomAccessIteratorFacade< │ │ │ │ │ + T2, V2, R2, D > &rhs) │ │ │ │ │ +  Comparison operator. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + EnableIfInterOperable< T1, T2, bool >::type Dune::operator> (const │ │ │ │ │ + RandomAccessIteratorFacade< │ │ │ │ │ + T1, V1, R1, D > &lhs, const │ │ │ │ │ + RandomAccessIteratorFacade< │ │ │ │ │ + T2, V2, R2, D > &rhs) │ │ │ │ │ +  Comparison operator. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + EnableIfInterOperable< T1, T2, bool >::type Dune::operator>= (const │ │ │ │ │ + RandomAccessIteratorFacade< │ │ │ │ │ + T1, V1, R1, D > &lhs, const │ │ │ │ │ + RandomAccessIteratorFacade< │ │ │ │ │ + T2, V2, R2, D > &rhs) │ │ │ │ │ +  Comparison operator. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + EnableIfInterOperable< T1, T2, D >::type Dune::operator- (const │ │ │ │ │ + RandomAccessIteratorFacade< │ │ │ │ │ + T1, V1, R1, D > &lhs, const │ │ │ │ │ + RandomAccessIteratorFacade< │ │ │ │ │ + T2, V2, R2, D > &rhs) │ │ │ │ │ +  Calculates the difference │ │ │ │ │ + between two pointers. │ │ │ │ │   │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Infrastructure for concepts. │ │ │ │ │ +This file implements iterator facade classes for writing stl conformant │ │ │ │ │ +iterators. │ │ │ │ │ +With using these facades writing iterators for arbitrary containers becomes │ │ │ │ │ +much less cumbersome as only few functions have to be implemented. All other │ │ │ │ │ +functions needed by the stl are provided by the facades using the Barton- │ │ │ │ │ +Nackman trick (also known as curiously recurring template pattern. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00083_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: concept.hh Source File │ │ │ │ +dune-common: iteratorfacades.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,336 +74,507 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    concept.hh
    │ │ │ │ +
    iteratorfacades.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 (C) 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_CONCEPT_HH
    │ │ │ │ -
    6#define DUNE_COMMON_CONCEPT_HH
    │ │ │ │ +
    5#ifndef DUNE_ITERATORFACADES_HH
    │ │ │ │ +
    6#define DUNE_ITERATORFACADES_HH
    │ │ │ │
    7
    │ │ │ │ -
    8#include <type_traits>
    │ │ │ │ -
    9#include <utility>
    │ │ │ │ -
    10#include <tuple>
    │ │ │ │ -
    11
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
    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
    │ │ │ │ -
    61namespace Impl {
    │ │ │ │ -
    62
    │ │ │ │ -
    63 // #############################################################################
    │ │ │ │ -
    64 // # All functions following here are implementation details
    │ │ │ │ -
    65 // # for the models() function below.
    │ │ │ │ -
    66 // #############################################################################
    │ │ │ │ -
    67
    │ │ │ │ -
    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
    │ │ │ │ -
    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
    │ │ │ │ -
    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
    │ │ │ │ -
    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
    │ │ │ │ -
    191namespace Concept {
    │ │ │ │ -
    192
    │ │ │ │ -
    193#ifndef DOXYGEN
    │ │ │ │ -
    194
    │ │ │ │ -
    195namespace Impl {
    │ │ │ │ +
    8#include <iterator>
    │ │ │ │ +
    9#include <type_traits>
    │ │ │ │ +
    10
    │ │ │ │ +
    11#include "typetraits.hh"
    │ │ │ │ +
    12
    │ │ │ │ +
    13namespace Dune
    │ │ │ │ +
    14{
    │ │ │ │ +
    139 template<class T, class V, class R = V&, class D = std::ptrdiff_t>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    141 {
    │ │ │ │ +
    142
    │ │ │ │ +
    143 public:
    │ │ │ │ +
    144 /* type aliases required by C++ for iterators */
    │ │ │ │ +
    145 using iterator_category = std::forward_iterator_tag;
    │ │ │ │ +
    146 using value_type = typename std::remove_const<V>::type;
    │ │ │ │ + │ │ │ │ +
    148 using pointer = V*;
    │ │ │ │ +
    149 using reference = R;
    │ │ │ │ +
    150
    │ │ │ │ +
    175 typedef T DerivedType;
    │ │ │ │ +
    176
    │ │ │ │ +
    180 typedef V Value;
    │ │ │ │ +
    181
    │ │ │ │ +
    185 typedef V* Pointer;
    │ │ │ │ +
    186
    │ │ │ │ +
    190 typedef D DifferenceType;
    │ │ │ │ +
    191
    │ │ │ │ +
    195 typedef R Reference;
    │ │ │ │
    196
    │ │ │ │ -
    197 // #############################################################################
    │ │ │ │ -
    198 // # All functions following here are implementation details for the
    │ │ │ │ -
    199 // # for the tupleEntriesModel() function below.
    │ │ │ │ -
    200 // #############################################################################
    │ │ │ │ -
    201
    │ │ │ │ -
    202 template<class C, class Tuple>
    │ │ │ │ -
    203 struct TupleEntriesModelHelper
    │ │ │ │ -
    204 {
    │ │ │ │ -
    205 template<class Accumulated, class T>
    │ │ │ │ -
    206 struct AccumulateFunctor
    │ │ │ │ -
    207 {
    │ │ │ │ -
    208 using type = typename std::integral_constant<bool, Accumulated::value and models<C, T>()>;
    │ │ │ │ -
    209 };
    │ │ │ │ -
    210 using Result = typename ReduceTuple<AccumulateFunctor, Tuple, std::true_type>::type;
    │ │ │ │ -
    211 };
    │ │ │ │ -
    212
    │ │ │ │ -
    213} // namespace Dune::Concept::Impl
    │ │ │ │ -
    214
    │ │ │ │ -
    215#endif // DOXYGEN
    │ │ │ │ -
    216
    │ │ │ │ -
    217
    │ │ │ │ -
    218// #############################################################################
    │ │ │ │ -
    219// # The method tupleEntriesModel() does the actual check if the types in a tuple
    │ │ │ │ -
    220// # model a concept using the implementation details above.
    │ │ │ │ -
    221// #############################################################################
    │ │ │ │ -
    222
    │ │ │ │ -
    223template<class C, class Tuple>
    │ │ │ │ -
    │ │ │ │ -
    224constexpr auto tupleEntriesModel()
    │ │ │ │ -
    225 -> typename Impl::TupleEntriesModelHelper<C, Tuple>::Result
    │ │ │ │ -
    226{
    │ │ │ │ -
    227 return {};
    │ │ │ │ -
    228}
    │ │ │ │ -
    │ │ │ │ -
    229
    │ │ │ │ -
    230// #############################################################################
    │ │ │ │ -
    231// # The following require*() functions are just helpers that allow to
    │ │ │ │ -
    232// # propagate a failed check as substitution failure. This is useful
    │ │ │ │ -
    233// # inside of a concept definition.
    │ │ │ │ -
    234// #############################################################################
    │ │ │ │ -
    235
    │ │ │ │ -
    236// Helper function for use in concept definitions.
    │ │ │ │ -
    237// If the passed value b is not true, the concept will to be satisfied.
    │ │ │ │ -
    238template<bool b, typename std::enable_if<b, int>::type = 0>
    │ │ │ │ -
    │ │ │ │ -
    239constexpr bool requireTrue()
    │ │ │ │ -
    240{
    │ │ │ │ -
    241 return true;
    │ │ │ │ -
    242}
    │ │ │ │ -
    │ │ │ │ -
    243
    │ │ │ │ -
    244// Helper function for use in concept definitions.
    │ │ │ │ -
    245template<class C, class... T, typename std::enable_if<models<C, T...>(), int>::type = 0>
    │ │ │ │ -
    │ │ │ │ -
    246constexpr bool requireConcept()
    │ │ │ │ -
    247{
    │ │ │ │ -
    248 return true;
    │ │ │ │ -
    249}
    │ │ │ │ -
    │ │ │ │ -
    250
    │ │ │ │ -
    251// Helper function for use in concept definitions.
    │ │ │ │ -
    252// This allows to avoid using decltype
    │ │ │ │ -
    253template<class C, class... T, typename std::enable_if<models<C, T...>(), int>::type = 0>
    │ │ │ │ -
    │ │ │ │ -
    254constexpr bool requireConcept(T&&... /*t*/)
    │ │ │ │ -
    255{
    │ │ │ │ -
    256 return true;
    │ │ │ │ -
    257}
    │ │ │ │ -
    │ │ │ │ -
    258
    │ │ │ │ -
    259// Helper function for use in concept definitions.
    │ │ │ │ -
    260// This checks if the concept given as first type is modelled by all types in the tuple passed as argument
    │ │ │ │ -
    261template<class C, class Tuple, typename std::enable_if<tupleEntriesModel<C, Tuple>(), int>::type = 0>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    263{
    │ │ │ │ -
    264 return true;
    │ │ │ │ -
    265}
    │ │ │ │ -
    │ │ │ │ -
    266
    │ │ │ │ -
    267// Helper function for use in concept definitions.
    │ │ │ │ -
    268// If the first passed type is not convertible to the second, the concept will not be satisfied.
    │ │ │ │ -
    269template<class From, class To,
    │ │ │ │ -
    270 typename std::enable_if< std::is_convertible<From, To>::value, int>::type = 0>
    │ │ │ │ -
    │ │ │ │ -
    271constexpr bool requireConvertible()
    │ │ │ │ -
    272{
    │ │ │ │ -
    273 return true;
    │ │ │ │ -
    274}
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    199 {
    │ │ │ │ +
    200 return static_cast<DerivedType const*>(this)->dereference();
    │ │ │ │ +
    201 }
    │ │ │ │ +
    │ │ │ │ +
    202
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    204 {
    │ │ │ │ +
    205 return &(static_cast<const DerivedType *>(this)->dereference());
    │ │ │ │ +
    206 }
    │ │ │ │ +
    │ │ │ │ +
    207
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    210 {
    │ │ │ │ +
    211 static_cast<DerivedType *>(this)->increment();
    │ │ │ │ +
    212 return *static_cast<DerivedType *>(this);
    │ │ │ │ +
    213 }
    │ │ │ │
    │ │ │ │ +
    214
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    217 {
    │ │ │ │ +
    218 DerivedType tmp(static_cast<DerivedType const&>(*this));
    │ │ │ │ +
    219 this->operator++();
    │ │ │ │ +
    220 return tmp;
    │ │ │ │ +
    221 }
    │ │ │ │ +
    │ │ │ │ +
    222 };
    │ │ │ │ +
    │ │ │ │ +
    223
    │ │ │ │ +
    234 template<class T1, class V1, class R1, class D,
    │ │ │ │ +
    235 class T2, class V2, class R2>
    │ │ │ │ +
    236 inline typename EnableIfInterOperable<T1,T2,bool>::type
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ +
    239 {
    │ │ │ │ +
    240 if(std::is_convertible<T2,T1>::value)
    │ │ │ │ +
    241 return static_cast<const T1&>(lhs).equals(static_cast<const T2&>(rhs));
    │ │ │ │ +
    242 else
    │ │ │ │ +
    243 return static_cast<const T2&>(rhs).equals(static_cast<const T1&>(lhs));
    │ │ │ │ +
    244 }
    │ │ │ │ +
    │ │ │ │ +
    245
    │ │ │ │ +
    256 template<class T1, class V1, class R1, class D,
    │ │ │ │ +
    257 class T2, class V2, class R2>
    │ │ │ │ +
    258 inline typename EnableIfInterOperable<T1,T2,bool>::type
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ +
    261 {
    │ │ │ │ +
    262 if(std::is_convertible<T2,T1>::value)
    │ │ │ │ +
    263 return !static_cast<const T1&>(lhs).equals(static_cast<const T2&>(rhs));
    │ │ │ │ +
    264 else
    │ │ │ │ +
    265 return !static_cast<const T2&>(rhs).equals(static_cast<const T1&>(lhs));
    │ │ │ │ +
    266 }
    │ │ │ │ +
    │ │ │ │ +
    267
    │ │ │ │ +
    272 template<class T, class V, class R = V&, class D = std::ptrdiff_t>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    274 {
    │ │ │ │
    275
    │ │ │ │ -
    276// Helper function for use in concept definitions.
    │ │ │ │ -
    277// If passed argument is not convertible to the first passed type, the concept will not be satisfied.
    │ │ │ │ -
    278template<class To, class From,
    │ │ │ │ -
    279 typename std::enable_if< std::is_convertible<From, To>::value, int>::type = 0>
    │ │ │ │ -
    │ │ │ │ -
    280constexpr bool requireConvertible(const From&)
    │ │ │ │ -
    281{
    │ │ │ │ -
    282 return true;
    │ │ │ │ -
    283}
    │ │ │ │ -
    │ │ │ │ -
    284
    │ │ │ │ -
    285// Helper function for use in concept definitions.
    │ │ │ │ -
    286// This will always evaluate to true. If just allow
    │ │ │ │ -
    287// to turn a type into an expression. The failure happens
    │ │ │ │ -
    288// already during substitution for the type argument.
    │ │ │ │ -
    289template<typename T>
    │ │ │ │ -
    │ │ │ │ -
    290constexpr bool requireType()
    │ │ │ │ -
    291{
    │ │ │ │ -
    292 return true;
    │ │ │ │ -
    293}
    │ │ │ │ -
    │ │ │ │ -
    294
    │ │ │ │ -
    295// Helper function for use in concept definitions.
    │ │ │ │ -
    296// If first passed type is not a base class of second type, the concept will not be satisfied.
    │ │ │ │ -
    297template<class Base, class Derived,
    │ │ │ │ -
    298 typename std::enable_if< std::is_base_of<Base, Derived>::value, int>::type = 0>
    │ │ │ │ -
    │ │ │ │ -
    299constexpr bool requireBaseOf()
    │ │ │ │ -
    300{
    │ │ │ │ -
    301 return true;
    │ │ │ │ -
    302}
    │ │ │ │ -
    │ │ │ │ -
    303
    │ │ │ │ -
    304// Helper function for use in concept definitions.
    │ │ │ │ -
    305// If first passed type is not a base class of first arguments type, the concept will not be satisfied.
    │ │ │ │ -
    306template<class Base, class Derived,
    │ │ │ │ -
    307 typename std::enable_if< std::is_base_of<Base, Derived>::value, int>::type = 0>
    │ │ │ │ -
    │ │ │ │ -
    308constexpr bool requireBaseOf(const Derived&)
    │ │ │ │ -
    309{
    │ │ │ │ -
    310 return true;
    │ │ │ │ -
    311}
    │ │ │ │ -
    │ │ │ │ -
    312
    │ │ │ │ -
    313// Helper function for use in concept definitions.
    │ │ │ │ -
    314// If the passed types are not the same, the concept will not be satisfied.
    │ │ │ │ -
    315template<class A, class B,
    │ │ │ │ -
    316 typename std::enable_if< std::is_same<A, B>::value, int>::type = 0>
    │ │ │ │ -
    │ │ │ │ -
    317constexpr bool requireSameType()
    │ │ │ │ -
    318{
    │ │ │ │ -
    319 return true;
    │ │ │ │ -
    320}
    │ │ │ │ -
    │ │ │ │ -
    321
    │ │ │ │ -
    322
    │ │ │ │ -
    323
    │ │ │ │ -
    324} // namespace Dune::Concept
    │ │ │ │ +
    276 public:
    │ │ │ │ +
    277 /* type aliases required by C++ for iterators */
    │ │ │ │ +
    278 using iterator_category = std::bidirectional_iterator_tag;
    │ │ │ │ +
    279 using value_type = typename std::remove_const<V>::type;
    │ │ │ │ + │ │ │ │ +
    281 using pointer = V*;
    │ │ │ │ +
    282 using reference = R;
    │ │ │ │ +
    283
    │ │ │ │ +
    309 typedef T DerivedType;
    │ │ │ │ +
    310
    │ │ │ │ +
    314 typedef V Value;
    │ │ │ │ +
    315
    │ │ │ │ +
    319 typedef V* Pointer;
    │ │ │ │ +
    320
    │ │ │ │ +
    324 typedef D DifferenceType;
    │ │ │ │
    325
    │ │ │ │ -
    328} // namespace Dune
    │ │ │ │ -
    329
    │ │ │ │ +
    329 typedef R Reference;
    │ │ │ │
    330
    │ │ │ │ -
    331
    │ │ │ │ -
    332
    │ │ │ │ -
    333#endif // DUNE_COMMON_CONCEPT_HH
    │ │ │ │ - │ │ │ │ - │ │ │ │ -
    Utilities for type computations, constraining overloads, ...
    │ │ │ │ -
    Contains utility classes which can be used with std::tuple.
    │ │ │ │ -
    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
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    333 {
    │ │ │ │ +
    334 return static_cast<DerivedType const*>(this)->dereference();
    │ │ │ │ +
    335 }
    │ │ │ │ +
    │ │ │ │ +
    336
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    338 {
    │ │ │ │ +
    339 return &(static_cast<const DerivedType *>(this)->dereference());
    │ │ │ │ +
    340 }
    │ │ │ │ +
    │ │ │ │ +
    341
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    344 {
    │ │ │ │ +
    345 static_cast<DerivedType *>(this)->increment();
    │ │ │ │ +
    346 return *static_cast<DerivedType *>(this);
    │ │ │ │ +
    347 }
    │ │ │ │ +
    │ │ │ │ +
    348
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    351 {
    │ │ │ │ +
    352 DerivedType tmp(static_cast<DerivedType const&>(*this));
    │ │ │ │ +
    353 this->operator++();
    │ │ │ │ +
    354 return tmp;
    │ │ │ │ +
    355 }
    │ │ │ │ +
    │ │ │ │ +
    356
    │ │ │ │ +
    357
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    360 {
    │ │ │ │ +
    361 static_cast<DerivedType *>(this)->decrement();
    │ │ │ │ +
    362 return *static_cast<DerivedType *>(this);
    │ │ │ │ +
    363 }
    │ │ │ │ +
    │ │ │ │ +
    364
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    367 {
    │ │ │ │ +
    368 DerivedType tmp(static_cast<DerivedType const&>(*this));
    │ │ │ │ +
    369 this->operator--();
    │ │ │ │ +
    370 return tmp;
    │ │ │ │ +
    371 }
    │ │ │ │ +
    │ │ │ │ +
    372 };
    │ │ │ │ +
    │ │ │ │ +
    373
    │ │ │ │ +
    381 template<class T1, class V1, class R1, class D,
    │ │ │ │ +
    382 class T2, class V2, class R2>
    │ │ │ │ +
    383 inline typename std::enable_if<std::is_convertible<T2,T1>::value,bool>::type
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ +
    386 {
    │ │ │ │ +
    387 return static_cast<const T1&>(lhs).equals(static_cast<const T2&>(rhs));
    │ │ │ │ +
    388 }
    │ │ │ │ +
    │ │ │ │ +
    389
    │ │ │ │ +
    398 template<class T1, class V1, class R1, class D,
    │ │ │ │ +
    399 class T2, class V2, class R2>
    │ │ │ │ +
    400 inline
    │ │ │ │ +
    401 typename std::enable_if<std::is_convertible<T1,T2>::value && !std::is_convertible<T2,T1>::value,
    │ │ │ │ +
    402 bool>::type
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ +
    405 {
    │ │ │ │ +
    406 return static_cast<const T2&>(rhs).equals(static_cast<const T1&>(lhs));
    │ │ │ │ +
    407 }
    │ │ │ │ +
    │ │ │ │ +
    408
    │ │ │ │ +
    419 template<class T1, class V1, class R1, class D,
    │ │ │ │ +
    420 class T2, class V2, class R2>
    │ │ │ │ +
    421 inline typename EnableIfInterOperable<T1,T2,bool>::type
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ +
    424 {
    │ │ │ │ +
    425 return !(lhs == rhs);
    │ │ │ │ +
    426 }
    │ │ │ │ +
    │ │ │ │ +
    427
    │ │ │ │ +
    432 template<class T, class V, class R = V&, class D = std::ptrdiff_t>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    434 {
    │ │ │ │ +
    435
    │ │ │ │ +
    436 public:
    │ │ │ │ +
    437 /* type aliases required by C++ for iterators */
    │ │ │ │ +
    438 using iterator_category = std::random_access_iterator_tag;
    │ │ │ │ +
    439 using value_type = typename std::remove_const<V>::type;
    │ │ │ │ + │ │ │ │ +
    441 using pointer = V*;
    │ │ │ │ +
    442 using reference = R;
    │ │ │ │ +
    443
    │ │ │ │ +
    477 typedef T DerivedType;
    │ │ │ │ +
    478
    │ │ │ │ +
    482 typedef V Value;
    │ │ │ │ +
    483
    │ │ │ │ +
    487 typedef V* Pointer;
    │ │ │ │ +
    488
    │ │ │ │ +
    492 typedef D DifferenceType;
    │ │ │ │ +
    493
    │ │ │ │ +
    497 typedef R Reference;
    │ │ │ │ +
    498
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    501 {
    │ │ │ │ +
    502 return static_cast<DerivedType const*>(this)->dereference();
    │ │ │ │ +
    503 }
    │ │ │ │ +
    │ │ │ │ +
    504
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    506 {
    │ │ │ │ +
    507 return &(static_cast<const DerivedType *>(this)->dereference());
    │ │ │ │ +
    508 }
    │ │ │ │ +
    │ │ │ │ +
    509
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    516 {
    │ │ │ │ +
    517 return static_cast<const DerivedType *>(this)->elementAt(n);
    │ │ │ │ +
    518 }
    │ │ │ │ +
    │ │ │ │ +
    519
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    522 {
    │ │ │ │ +
    523 static_cast<DerivedType *>(this)->increment();
    │ │ │ │ +
    524 return *static_cast<DerivedType *>(this);
    │ │ │ │ +
    525 }
    │ │ │ │ +
    │ │ │ │ +
    526
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    529 {
    │ │ │ │ +
    530 DerivedType tmp(static_cast<DerivedType const&>(*this));
    │ │ │ │ +
    531 this->operator++();
    │ │ │ │ +
    532 return tmp;
    │ │ │ │ +
    533 }
    │ │ │ │ +
    │ │ │ │ +
    534
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    536 {
    │ │ │ │ +
    537 static_cast<DerivedType *>(this)->advance(n);
    │ │ │ │ +
    538 return *static_cast<DerivedType *>(this);
    │ │ │ │ +
    539 }
    │ │ │ │ +
    │ │ │ │ +
    540
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    542 {
    │ │ │ │ +
    543 DerivedType tmp(static_cast<DerivedType const&>(*this));
    │ │ │ │ +
    544 tmp.advance(n);
    │ │ │ │ +
    545 return tmp;
    │ │ │ │ +
    546 }
    │ │ │ │ +
    │ │ │ │ +
    547
    │ │ │ │ +
    548
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    551 {
    │ │ │ │ +
    552 static_cast<DerivedType *>(this)->decrement();
    │ │ │ │ +
    553 return *static_cast<DerivedType *>(this);
    │ │ │ │ +
    554 }
    │ │ │ │ +
    │ │ │ │ +
    555
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    558 {
    │ │ │ │ +
    559 DerivedType tmp(static_cast<DerivedType const&>(*this));
    │ │ │ │ +
    560 this->operator--();
    │ │ │ │ +
    561 return tmp;
    │ │ │ │ +
    562 }
    │ │ │ │ +
    │ │ │ │ +
    563
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    565 {
    │ │ │ │ +
    566 static_cast<DerivedType *>(this)->advance(-n);
    │ │ │ │ +
    567 return *static_cast<DerivedType *>(this);
    │ │ │ │ +
    568 }
    │ │ │ │ +
    │ │ │ │ +
    569
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    571 {
    │ │ │ │ +
    572 DerivedType tmp(static_cast<DerivedType const&>(*this));
    │ │ │ │ +
    573 tmp.advance(-n);
    │ │ │ │ +
    574 return tmp;
    │ │ │ │ +
    575 }
    │ │ │ │ +
    │ │ │ │ +
    576
    │ │ │ │ +
    577
    │ │ │ │ +
    578 };
    │ │ │ │ +
    │ │ │ │ +
    579
    │ │ │ │ +
    590 template<class T1, class V1, class R1, class D,
    │ │ │ │ +
    591 class T2, class V2, class R2>
    │ │ │ │ +
    592 inline typename EnableIfInterOperable<T1,T2,bool>::type
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ +
    595 {
    │ │ │ │ +
    596 if(std::is_convertible<T2,T1>::value)
    │ │ │ │ +
    597 return static_cast<const T1&>(lhs).equals(static_cast<const T2&>(rhs));
    │ │ │ │ +
    598 else
    │ │ │ │ +
    599 return static_cast<const T2&>(rhs).equals(static_cast<const T1&>(lhs));
    │ │ │ │ +
    600 }
    │ │ │ │ +
    │ │ │ │ +
    601
    │ │ │ │ +
    612 template<class T1, class V1, class R1, class D,
    │ │ │ │ +
    613 class T2, class V2, class R2>
    │ │ │ │ +
    614 inline typename EnableIfInterOperable<T1,T2,bool>::type
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ +
    617 {
    │ │ │ │ +
    618 if(std::is_convertible<T2,T1>::value)
    │ │ │ │ +
    619 return !static_cast<const T1&>(lhs).equals(static_cast<const T2&>(rhs));
    │ │ │ │ +
    620 else
    │ │ │ │ +
    621 return !static_cast<const T2&>(rhs).equals(static_cast<const T1&>(lhs));
    │ │ │ │ +
    622 }
    │ │ │ │ +
    │ │ │ │ +
    623
    │ │ │ │ +
    634 template<class T1, class V1, class R1, class D,
    │ │ │ │ +
    635 class T2, class V2, class R2>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    639 {
    │ │ │ │ +
    640 if(std::is_convertible<T2,T1>::value)
    │ │ │ │ +
    641 return static_cast<const T1&>(lhs).distanceTo(static_cast<const T2&>(rhs))>0;
    │ │ │ │ +
    642 else
    │ │ │ │ +
    643 return static_cast<const T2&>(rhs).distanceTo(static_cast<const T1&>(lhs))<0;
    │ │ │ │ +
    644 }
    │ │ │ │ +
    │ │ │ │ +
    645
    │ │ │ │ +
    646
    │ │ │ │ +
    657 template<class T1, class V1, class R1, class D,
    │ │ │ │ +
    658 class T2, class V2, class R2>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    662 {
    │ │ │ │ +
    663 if(std::is_convertible<T2,T1>::value)
    │ │ │ │ +
    664 return static_cast<const T1&>(lhs).distanceTo(static_cast<const T2&>(rhs))>=0;
    │ │ │ │ +
    665 else
    │ │ │ │ +
    666 return static_cast<const T2&>(rhs).distanceTo(static_cast<const T1&>(lhs))<=0;
    │ │ │ │ +
    667 }
    │ │ │ │ +
    │ │ │ │ +
    668
    │ │ │ │ +
    669
    │ │ │ │ +
    680 template<class T1, class V1, class R1, class D,
    │ │ │ │ +
    681 class T2, class V2, class R2>
    │ │ │ │ +
    682 inline typename EnableIfInterOperable<T1,T2,bool>::type
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ +
    685 {
    │ │ │ │ +
    686 if(std::is_convertible<T2,T1>::value)
    │ │ │ │ +
    687 return static_cast<const T1&>(lhs).distanceTo(static_cast<const T2&>(rhs))<0;
    │ │ │ │ +
    688 else
    │ │ │ │ +
    689 return static_cast<const T2&>(rhs).distanceTo(static_cast<const T1&>(lhs))>0;
    │ │ │ │ +
    690 }
    │ │ │ │ +
    │ │ │ │ +
    691
    │ │ │ │ +
    702 template<class T1, class V1, class R1, class D,
    │ │ │ │ +
    703 class T2, class V2, class R2>
    │ │ │ │ +
    704 inline typename EnableIfInterOperable<T1,T2,bool>::type
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ +
    707 {
    │ │ │ │ +
    708 if(std::is_convertible<T2,T1>::value)
    │ │ │ │ +
    709 return static_cast<const T1&>(lhs).distanceTo(static_cast<const T2&>(rhs))<=0;
    │ │ │ │ +
    710 else
    │ │ │ │ +
    711 return static_cast<const T2&>(rhs).distanceTo(static_cast<const T1&>(lhs))>=0;
    │ │ │ │ +
    712 }
    │ │ │ │ +
    │ │ │ │ +
    713
    │ │ │ │ +
    724 template<class T1, class V1, class R1, class D,
    │ │ │ │ +
    725 class T2, class V2, class R2>
    │ │ │ │ +
    726 inline typename EnableIfInterOperable<T1,T2,D>::type
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ +
    729 {
    │ │ │ │ +
    730 if(std::is_convertible<T2,T1>::value)
    │ │ │ │ +
    731 return -static_cast<const T1&>(lhs).distanceTo(static_cast<const T2&>(rhs));
    │ │ │ │ +
    732 else
    │ │ │ │ +
    733 return static_cast<const T2&>(rhs).distanceTo(static_cast<const T1&>(lhs));
    │ │ │ │ +
    734 }
    │ │ │ │ +
    │ │ │ │ +
    735
    │ │ │ │ +
    737}
    │ │ │ │ +
    738#endif
    │ │ │ │ +
    Traits for type conversions and type information.
    │ │ │ │ +
    bigunsignedint< k > operator-(const bigunsignedint< k > &x, std::uintmax_t y)
    Definition bigunsignedint.hh:542
    │ │ │ │ +
    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:637
    │ │ │ │ +
    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:683
    │ │ │ │ +
    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:660
    │ │ │ │ +
    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:237
    │ │ │ │ +
    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:705
    │ │ │ │ +
    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:259
    │ │ │ │
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ -
    constexpr bool requireConcept()
    Definition concept.hh:246
    │ │ │ │ -
    constexpr bool requireTrue()
    Definition concept.hh:239
    │ │ │ │ -
    constexpr bool requireSameType()
    Definition concept.hh:317
    │ │ │ │ -
    constexpr auto tupleEntriesModel() -> typename Impl::TupleEntriesModelHelper< C, Tuple >::Result
    Definition concept.hh:224
    │ │ │ │ -
    constexpr bool requireConceptForTupleEntries()
    Definition concept.hh:262
    │ │ │ │ -
    constexpr bool requireBaseOf()
    Definition concept.hh:299
    │ │ │ │ -
    constexpr bool requireConvertible()
    Definition concept.hh:271
    │ │ │ │ -
    constexpr bool requireType()
    Definition concept.hh:290
    │ │ │ │ -
    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
    │ │ │ │ +
    Base class for stl conformant forward iterators.
    Definition iteratorfacades.hh:141
    │ │ │ │ +
    std::forward_iterator_tag iterator_category
    Definition iteratorfacades.hh:145
    │ │ │ │ +
    V * pointer
    Definition iteratorfacades.hh:148
    │ │ │ │ +
    DerivedType & operator++()
    Preincrement operator.
    Definition iteratorfacades.hh:209
    │ │ │ │ +
    D DifferenceType
    The type of the difference between two positions.
    Definition iteratorfacades.hh:190
    │ │ │ │ +
    R Reference
    The type of the reference to the values accessed.
    Definition iteratorfacades.hh:195
    │ │ │ │ +
    Pointer operator->() const
    Definition iteratorfacades.hh:203
    │ │ │ │ +
    T DerivedType
    The type of derived iterator.
    Definition iteratorfacades.hh:175
    │ │ │ │ +
    V Value
    The type of value accessed through the iterator.
    Definition iteratorfacades.hh:180
    │ │ │ │ +
    typename std::remove_const< V >::type value_type
    Definition iteratorfacades.hh:146
    │ │ │ │ +
    DerivedType operator++(int)
    Postincrement operator.
    Definition iteratorfacades.hh:216
    │ │ │ │ +
    V * Pointer
    The pointer to the Value.
    Definition iteratorfacades.hh:185
    │ │ │ │ +
    D difference_type
    Definition iteratorfacades.hh:147
    │ │ │ │ +
    Reference operator*() const
    Dereferencing operator.
    Definition iteratorfacades.hh:198
    │ │ │ │ +
    R reference
    Definition iteratorfacades.hh:149
    │ │ │ │ +
    Facade class for stl conformant bidirectional iterators.
    Definition iteratorfacades.hh:274
    │ │ │ │ +
    V * pointer
    Definition iteratorfacades.hh:281
    │ │ │ │ +
    typename std::remove_const< V >::type value_type
    Definition iteratorfacades.hh:279
    │ │ │ │ +
    Reference operator*() const
    Dereferencing operator.
    Definition iteratorfacades.hh:332
    │ │ │ │ +
    D difference_type
    Definition iteratorfacades.hh:280
    │ │ │ │ +
    T DerivedType
    The type of derived iterator.
    Definition iteratorfacades.hh:309
    │ │ │ │ +
    DerivedType & operator--()
    Preincrement operator.
    Definition iteratorfacades.hh:359
    │ │ │ │ +
    Pointer operator->() const
    Definition iteratorfacades.hh:337
    │ │ │ │ +
    DerivedType & operator++()
    Preincrement operator.
    Definition iteratorfacades.hh:343
    │ │ │ │ +
    V * Pointer
    The pointer to the Value.
    Definition iteratorfacades.hh:319
    │ │ │ │ +
    R Reference
    The type of the reference to the values accessed.
    Definition iteratorfacades.hh:329
    │ │ │ │ +
    DerivedType operator++(int)
    Postincrement operator.
    Definition iteratorfacades.hh:350
    │ │ │ │ +
    std::bidirectional_iterator_tag iterator_category
    Definition iteratorfacades.hh:278
    │ │ │ │ +
    D DifferenceType
    The type of the difference between two positions.
    Definition iteratorfacades.hh:324
    │ │ │ │ +
    DerivedType operator--(int)
    Postincrement operator.
    Definition iteratorfacades.hh:366
    │ │ │ │ +
    R reference
    Definition iteratorfacades.hh:282
    │ │ │ │ +
    V Value
    The type of value accessed through the iterator.
    Definition iteratorfacades.hh:314
    │ │ │ │ +
    Base class for stl conformant forward iterators.
    Definition iteratorfacades.hh:434
    │ │ │ │ +
    typename std::remove_const< V >::type value_type
    Definition iteratorfacades.hh:439
    │ │ │ │ +
    D difference_type
    Definition iteratorfacades.hh:440
    │ │ │ │ +
    DerivedType operator--(int)
    Postdecrement operator.
    Definition iteratorfacades.hh:557
    │ │ │ │ +
    V * pointer
    Definition iteratorfacades.hh:441
    │ │ │ │ +
    std::random_access_iterator_tag iterator_category
    Definition iteratorfacades.hh:438
    │ │ │ │ +
    Reference operator*() const
    Dereferencing operator.
    Definition iteratorfacades.hh:500
    │ │ │ │ +
    DerivedType & operator++()
    Preincrement operator.
    Definition iteratorfacades.hh:521
    │ │ │ │ +
    R reference
    Definition iteratorfacades.hh:442
    │ │ │ │ +
    Pointer operator->() const
    Definition iteratorfacades.hh:505
    │ │ │ │ +
    D DifferenceType
    The type of the difference between two positions.
    Definition iteratorfacades.hh:492
    │ │ │ │ +
    DerivedType & operator--()
    Predecrement operator.
    Definition iteratorfacades.hh:550
    │ │ │ │ +
    DerivedType & operator-=(DifferenceType n)
    Definition iteratorfacades.hh:564
    │ │ │ │ +
    DerivedType operator+(DifferenceType n) const
    Definition iteratorfacades.hh:541
    │ │ │ │ +
    Reference operator[](DifferenceType n) const
    Get the element n positions from the current one.
    Definition iteratorfacades.hh:515
    │ │ │ │ +
    T DerivedType
    The type of derived iterator.
    Definition iteratorfacades.hh:477
    │ │ │ │ +
    V * Pointer
    The pointer to the Value.
    Definition iteratorfacades.hh:487
    │ │ │ │ +
    DerivedType operator-(DifferenceType n) const
    Definition iteratorfacades.hh:570
    │ │ │ │ +
    DerivedType operator++(int)
    Postincrement operator.
    Definition iteratorfacades.hh:528
    │ │ │ │ +
    V Value
    The type of value accessed through the iterator.
    Definition iteratorfacades.hh:482
    │ │ │ │ +
    DerivedType & operator+=(DifferenceType n)
    Definition iteratorfacades.hh:535
    │ │ │ │ +
    R Reference
    The type of the reference to the values accessed.
    Definition iteratorfacades.hh:497
    │ │ │ │ +
    Enable typedef if two types are interoperable.
    Definition typetraits.hh:81
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,362 +7,617 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -concept.hh │ │ │ │ │ +iteratorfacades.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 (C) 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_CONCEPT_HH │ │ │ │ │ - 6#define DUNE_COMMON_CONCEPT_HH │ │ │ │ │ + 5#ifndef DUNE_ITERATORFACADES_HH │ │ │ │ │ + 6#define DUNE_ITERATORFACADES_HH │ │ │ │ │ 7 │ │ │ │ │ - 8#include │ │ │ │ │ - 9#include │ │ │ │ │ - 10#include │ │ │ │ │ - 11 │ │ │ │ │ - 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 │ │ │ │ │ - 61namespace Impl { │ │ │ │ │ - 62 │ │ │ │ │ - 63 / │ │ │ │ │ -/ ############################################################################# │ │ │ │ │ - 64 // # All functions following here are implementation details │ │ │ │ │ - 65 // # for the models() function below. │ │ │ │ │ - 66 / │ │ │ │ │ -/ ############################################################################# │ │ │ │ │ - 67 │ │ │ │ │ - 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 │ │ │ │ │ - 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 │ │ │ │ │ - 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 │ │ │ │ │ - 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 │ │ │ │ │ - 191namespace Concept { │ │ │ │ │ - 192 │ │ │ │ │ - 193#ifndef DOXYGEN │ │ │ │ │ - 194 │ │ │ │ │ - 195namespace Impl { │ │ │ │ │ + 8#include │ │ │ │ │ + 9#include │ │ │ │ │ + 10 │ │ │ │ │ + 11#include "typetraits.hh" │ │ │ │ │ + 12 │ │ │ │ │ + 13namespace Dune │ │ │ │ │ + 14{ │ │ │ │ │ + 139 template │ │ │ │ │ +140 class ForwardIteratorFacade │ │ │ │ │ + 141 { │ │ │ │ │ + 142 │ │ │ │ │ + 143 public: │ │ │ │ │ + 144 /* type aliases required by C++ for iterators */ │ │ │ │ │ +145 using iterator_category = std::forward_iterator_tag; │ │ │ │ │ +146 using value_type = typename std::remove_const::type; │ │ │ │ │ +147 using difference_type = D; │ │ │ │ │ +148 using pointer = V*; │ │ │ │ │ +149 using reference = R; │ │ │ │ │ + 150 │ │ │ │ │ +175 typedef T DerivedType; │ │ │ │ │ + 176 │ │ │ │ │ +180 typedef V Value; │ │ │ │ │ + 181 │ │ │ │ │ +185 typedef V* Pointer; │ │ │ │ │ + 186 │ │ │ │ │ +190 typedef D DifferenceType; │ │ │ │ │ + 191 │ │ │ │ │ +195 typedef R Reference; │ │ │ │ │ 196 │ │ │ │ │ - 197 / │ │ │ │ │ -/ ############################################################################# │ │ │ │ │ - 198 // # All functions following here are implementation details for the │ │ │ │ │ - 199 // # for the tupleEntriesModel() function below. │ │ │ │ │ - 200 / │ │ │ │ │ -/ ############################################################################# │ │ │ │ │ - 201 │ │ │ │ │ - 202 template │ │ │ │ │ - 203 struct TupleEntriesModelHelper │ │ │ │ │ +198 Reference operator*() const │ │ │ │ │ + 199 { │ │ │ │ │ + 200 return static_cast(this)->dereference(); │ │ │ │ │ + 201 } │ │ │ │ │ + 202 │ │ │ │ │ +203 Pointer operator->() const │ │ │ │ │ 204 { │ │ │ │ │ - 205 template │ │ │ │ │ - 206 struct AccumulateFunctor │ │ │ │ │ - 207 { │ │ │ │ │ - 208 using type = typename std::integral_constant()>; │ │ │ │ │ - 209 }; │ │ │ │ │ - 210 using Result = typename ReduceTuple::type; │ │ │ │ │ - 211 }; │ │ │ │ │ - 212 │ │ │ │ │ - 213} // namespace Dune::Concept::Impl │ │ │ │ │ + 205 return &(static_cast(this)->dereference()); │ │ │ │ │ + 206 } │ │ │ │ │ + 207 │ │ │ │ │ +209 DerivedType& operator++() │ │ │ │ │ + 210 { │ │ │ │ │ + 211 static_cast(this)->increment(); │ │ │ │ │ + 212 return *static_cast(this); │ │ │ │ │ + 213 } │ │ │ │ │ 214 │ │ │ │ │ - 215#endif // DOXYGEN │ │ │ │ │ - 216 │ │ │ │ │ - 217 │ │ │ │ │ - 218/ │ │ │ │ │ -/ ############################################################################# │ │ │ │ │ - 219// # The method tupleEntriesModel() does the actual check if the types in a │ │ │ │ │ -tuple │ │ │ │ │ - 220// # model a concept using the implementation details above. │ │ │ │ │ - 221/ │ │ │ │ │ -/ ############################################################################# │ │ │ │ │ - 222 │ │ │ │ │ - 223template │ │ │ │ │ -224constexpr auto tupleEntriesModel() │ │ │ │ │ - 225 -> typename Impl::TupleEntriesModelHelper::Result │ │ │ │ │ - 226{ │ │ │ │ │ - 227 return {}; │ │ │ │ │ - 228} │ │ │ │ │ - 229 │ │ │ │ │ - 230/ │ │ │ │ │ -/ ############################################################################# │ │ │ │ │ - 231// # The following require*() functions are just helpers that allow to │ │ │ │ │ - 232// # propagate a failed check as substitution failure. This is useful │ │ │ │ │ - 233// # inside of a concept definition. │ │ │ │ │ - 234/ │ │ │ │ │ -/ ############################################################################# │ │ │ │ │ - 235 │ │ │ │ │ - 236// Helper function for use in concept definitions. │ │ │ │ │ - 237// If the passed value b is not true, the concept will to be satisfied. │ │ │ │ │ - 238template::type = 0> │ │ │ │ │ -239constexpr bool requireTrue() │ │ │ │ │ - 240{ │ │ │ │ │ - 241 return true; │ │ │ │ │ - 242} │ │ │ │ │ - 243 │ │ │ │ │ - 244// Helper function for use in concept definitions. │ │ │ │ │ - 245template(), │ │ │ │ │ -int>::type = 0> │ │ │ │ │ -246constexpr bool requireConcept() │ │ │ │ │ - 247{ │ │ │ │ │ - 248 return true; │ │ │ │ │ - 249} │ │ │ │ │ - 250 │ │ │ │ │ - 251// Helper function for use in concept definitions. │ │ │ │ │ - 252// This allows to avoid using decltype │ │ │ │ │ - 253template(), │ │ │ │ │ -int>::type = 0> │ │ │ │ │ -254constexpr bool requireConcept(T&&... /*t*/) │ │ │ │ │ - 255{ │ │ │ │ │ - 256 return true; │ │ │ │ │ - 257} │ │ │ │ │ - 258 │ │ │ │ │ - 259// Helper function for use in concept definitions. │ │ │ │ │ - 260// This checks if the concept given as first type is modelled by all types │ │ │ │ │ -in the tuple passed as argument │ │ │ │ │ - 261template(), int>::type = 0> │ │ │ │ │ -262constexpr bool requireConceptForTupleEntries() │ │ │ │ │ - 263{ │ │ │ │ │ - 264 return true; │ │ │ │ │ - 265} │ │ │ │ │ - 266 │ │ │ │ │ - 267// Helper function for use in concept definitions. │ │ │ │ │ - 268// If the first passed type is not convertible to the second, the concept │ │ │ │ │ -will not be satisfied. │ │ │ │ │ - 269template::value, int>::type │ │ │ │ │ -= 0> │ │ │ │ │ -271constexpr bool requireConvertible() │ │ │ │ │ - 272{ │ │ │ │ │ - 273 return true; │ │ │ │ │ - 274} │ │ │ │ │ +216 DerivedType operator++(int) │ │ │ │ │ + 217 { │ │ │ │ │ + 218 DerivedType tmp(static_cast(*this)); │ │ │ │ │ + 219 this->operator++(); │ │ │ │ │ + 220 return tmp; │ │ │ │ │ + 221 } │ │ │ │ │ + 222 }; │ │ │ │ │ + 223 │ │ │ │ │ + 234 template │ │ │ │ │ + 236 inline typename EnableIfInterOperable::type │ │ │ │ │ +237 operator==(const ForwardIteratorFacade& lhs, │ │ │ │ │ + 238 const ForwardIteratorFacade& rhs) │ │ │ │ │ + 239 { │ │ │ │ │ + 240 if(std::is_convertible::value) │ │ │ │ │ + 241 return static_cast(lhs).equals(static_cast(rhs)); │ │ │ │ │ + 242 else │ │ │ │ │ + 243 return static_cast(rhs).equals(static_cast(lhs)); │ │ │ │ │ + 244 } │ │ │ │ │ + 245 │ │ │ │ │ + 256 template │ │ │ │ │ + 258 inline typename EnableIfInterOperable::type │ │ │ │ │ +259 operator!=(const ForwardIteratorFacade& lhs, │ │ │ │ │ + 260 const ForwardIteratorFacade& rhs) │ │ │ │ │ + 261 { │ │ │ │ │ + 262 if(std::is_convertible::value) │ │ │ │ │ + 263 return !static_cast(lhs).equals(static_cast(rhs)); │ │ │ │ │ + 264 else │ │ │ │ │ + 265 return !static_cast(rhs).equals(static_cast(lhs)); │ │ │ │ │ + 266 } │ │ │ │ │ + 267 │ │ │ │ │ + 272 template │ │ │ │ │ +273 class BidirectionalIteratorFacade │ │ │ │ │ + 274 { │ │ │ │ │ 275 │ │ │ │ │ - 276// Helper function for use in concept definitions. │ │ │ │ │ - 277// If passed argument is not convertible to the first passed type, the │ │ │ │ │ -concept will not be satisfied. │ │ │ │ │ - 278template::value, int>::type │ │ │ │ │ -= 0> │ │ │ │ │ -280constexpr bool requireConvertible(const From&) │ │ │ │ │ - 281{ │ │ │ │ │ - 282 return true; │ │ │ │ │ - 283} │ │ │ │ │ - 284 │ │ │ │ │ - 285// Helper function for use in concept definitions. │ │ │ │ │ - 286// This will always evaluate to true. If just allow │ │ │ │ │ - 287// to turn a type into an expression. The failure happens │ │ │ │ │ - 288// already during substitution for the type argument. │ │ │ │ │ - 289template │ │ │ │ │ -290constexpr bool requireType() │ │ │ │ │ - 291{ │ │ │ │ │ - 292 return true; │ │ │ │ │ - 293} │ │ │ │ │ - 294 │ │ │ │ │ - 295// Helper function for use in concept definitions. │ │ │ │ │ - 296// If first passed type is not a base class of second type, the concept │ │ │ │ │ -will not be satisfied. │ │ │ │ │ - 297template::value, int>::type │ │ │ │ │ -= 0> │ │ │ │ │ -299constexpr bool requireBaseOf() │ │ │ │ │ - 300{ │ │ │ │ │ - 301 return true; │ │ │ │ │ - 302} │ │ │ │ │ - 303 │ │ │ │ │ - 304// Helper function for use in concept definitions. │ │ │ │ │ - 305// If first passed type is not a base class of first arguments type, the │ │ │ │ │ -concept will not be satisfied. │ │ │ │ │ - 306template::value, int>::type │ │ │ │ │ -= 0> │ │ │ │ │ -308constexpr bool requireBaseOf(const Derived&) │ │ │ │ │ - 309{ │ │ │ │ │ - 310 return true; │ │ │ │ │ - 311} │ │ │ │ │ - 312 │ │ │ │ │ - 313// Helper function for use in concept definitions. │ │ │ │ │ - 314// If the passed types are not the same, the concept will not be satisfied. │ │ │ │ │ - 315template::value, int>::type = 0> │ │ │ │ │ -317constexpr bool requireSameType() │ │ │ │ │ - 318{ │ │ │ │ │ - 319 return true; │ │ │ │ │ - 320} │ │ │ │ │ - 321 │ │ │ │ │ - 322 │ │ │ │ │ - 323 │ │ │ │ │ - 324} // namespace Dune::Concept │ │ │ │ │ + 276 public: │ │ │ │ │ + 277 /* type aliases required by C++ for iterators */ │ │ │ │ │ +278 using iterator_category = std::bidirectional_iterator_tag; │ │ │ │ │ +279 using value_type = typename std::remove_const::type; │ │ │ │ │ +280 using difference_type = D; │ │ │ │ │ +281 using pointer = V*; │ │ │ │ │ +282 using reference = R; │ │ │ │ │ + 283 │ │ │ │ │ +309 typedef T DerivedType; │ │ │ │ │ + 310 │ │ │ │ │ +314 typedef V Value; │ │ │ │ │ + 315 │ │ │ │ │ +319 typedef V* Pointer; │ │ │ │ │ + 320 │ │ │ │ │ +324 typedef D DifferenceType; │ │ │ │ │ 325 │ │ │ │ │ - 328} // namespace Dune │ │ │ │ │ - 329 │ │ │ │ │ +329 typedef R Reference; │ │ │ │ │ 330 │ │ │ │ │ - 331 │ │ │ │ │ - 332 │ │ │ │ │ - 333#endif // DUNE_COMMON_CONCEPT_HH │ │ │ │ │ -type_traits.hh │ │ │ │ │ -typelist.hh │ │ │ │ │ -typeutilities.hh │ │ │ │ │ -Utilities for type computations, constraining overloads, ... │ │ │ │ │ -tupleutility.hh │ │ │ │ │ -Contains utility classes which can be used with std::tuple. │ │ │ │ │ -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 │ │ │ │ │ +332 Reference operator*() const │ │ │ │ │ + 333 { │ │ │ │ │ + 334 return static_cast(this)->dereference(); │ │ │ │ │ + 335 } │ │ │ │ │ + 336 │ │ │ │ │ +337 Pointer operator->() const │ │ │ │ │ + 338 { │ │ │ │ │ + 339 return &(static_cast(this)->dereference()); │ │ │ │ │ + 340 } │ │ │ │ │ + 341 │ │ │ │ │ +343 DerivedType& operator++() │ │ │ │ │ + 344 { │ │ │ │ │ + 345 static_cast(this)->increment(); │ │ │ │ │ + 346 return *static_cast(this); │ │ │ │ │ + 347 } │ │ │ │ │ + 348 │ │ │ │ │ +350 DerivedType operator++(int) │ │ │ │ │ + 351 { │ │ │ │ │ + 352 DerivedType tmp(static_cast(*this)); │ │ │ │ │ + 353 this->operator++(); │ │ │ │ │ + 354 return tmp; │ │ │ │ │ + 355 } │ │ │ │ │ + 356 │ │ │ │ │ + 357 │ │ │ │ │ +359 DerivedType& operator--() │ │ │ │ │ + 360 { │ │ │ │ │ + 361 static_cast(this)->decrement(); │ │ │ │ │ + 362 return *static_cast(this); │ │ │ │ │ + 363 } │ │ │ │ │ + 364 │ │ │ │ │ +366 DerivedType operator--(int) │ │ │ │ │ + 367 { │ │ │ │ │ + 368 DerivedType tmp(static_cast(*this)); │ │ │ │ │ + 369 this->operator--(); │ │ │ │ │ + 370 return tmp; │ │ │ │ │ + 371 } │ │ │ │ │ + 372 }; │ │ │ │ │ + 373 │ │ │ │ │ + 381 template │ │ │ │ │ + 383 inline typename std::enable_if::value,bool>:: │ │ │ │ │ +type │ │ │ │ │ +384 operator==(const BidirectionalIteratorFacade& lhs, │ │ │ │ │ + 385 const BidirectionalIteratorFacade& rhs) │ │ │ │ │ + 386 { │ │ │ │ │ + 387 return static_cast(lhs).equals(static_cast(rhs)); │ │ │ │ │ + 388 } │ │ │ │ │ + 389 │ │ │ │ │ + 398 template │ │ │ │ │ + 400 inline │ │ │ │ │ + 401 typename std::enable_if::value && !std:: │ │ │ │ │ +is_convertible::value, │ │ │ │ │ + 402 bool>::type │ │ │ │ │ +403 operator==(const BidirectionalIteratorFacade& lhs, │ │ │ │ │ + 404 const BidirectionalIteratorFacade& rhs) │ │ │ │ │ + 405 { │ │ │ │ │ + 406 return static_cast(rhs).equals(static_cast(lhs)); │ │ │ │ │ + 407 } │ │ │ │ │ + 408 │ │ │ │ │ + 419 template │ │ │ │ │ + 421 inline typename EnableIfInterOperable::type │ │ │ │ │ +422 operator!=(const BidirectionalIteratorFacade& lhs, │ │ │ │ │ + 423 const BidirectionalIteratorFacade& rhs) │ │ │ │ │ + 424 { │ │ │ │ │ + 425 return !(lhs == rhs); │ │ │ │ │ + 426 } │ │ │ │ │ + 427 │ │ │ │ │ + 432 template │ │ │ │ │ +433 class RandomAccessIteratorFacade │ │ │ │ │ + 434 { │ │ │ │ │ + 435 │ │ │ │ │ + 436 public: │ │ │ │ │ + 437 /* type aliases required by C++ for iterators */ │ │ │ │ │ +438 using iterator_category = std::random_access_iterator_tag; │ │ │ │ │ +439 using value_type = typename std::remove_const::type; │ │ │ │ │ +440 using difference_type = D; │ │ │ │ │ +441 using pointer = V*; │ │ │ │ │ +442 using reference = R; │ │ │ │ │ + 443 │ │ │ │ │ +477 typedef T DerivedType; │ │ │ │ │ + 478 │ │ │ │ │ +482 typedef V Value; │ │ │ │ │ + 483 │ │ │ │ │ +487 typedef V* Pointer; │ │ │ │ │ + 488 │ │ │ │ │ +492 typedef D DifferenceType; │ │ │ │ │ + 493 │ │ │ │ │ +497 typedef R Reference; │ │ │ │ │ + 498 │ │ │ │ │ +500 Reference operator*() const │ │ │ │ │ + 501 { │ │ │ │ │ + 502 return static_cast(this)->dereference(); │ │ │ │ │ + 503 } │ │ │ │ │ + 504 │ │ │ │ │ +505 Pointer operator->() const │ │ │ │ │ + 506 { │ │ │ │ │ + 507 return &(static_cast(this)->dereference()); │ │ │ │ │ + 508 } │ │ │ │ │ + 509 │ │ │ │ │ +515 Reference operator[](DifferenceType n) const │ │ │ │ │ + 516 { │ │ │ │ │ + 517 return static_cast(this)->elementAt(n); │ │ │ │ │ + 518 } │ │ │ │ │ + 519 │ │ │ │ │ +521 DerivedType& operator++() │ │ │ │ │ + 522 { │ │ │ │ │ + 523 static_cast(this)->increment(); │ │ │ │ │ + 524 return *static_cast(this); │ │ │ │ │ + 525 } │ │ │ │ │ + 526 │ │ │ │ │ +528 DerivedType operator++(int) │ │ │ │ │ + 529 { │ │ │ │ │ + 530 DerivedType tmp(static_cast(*this)); │ │ │ │ │ + 531 this->operator++(); │ │ │ │ │ + 532 return tmp; │ │ │ │ │ + 533 } │ │ │ │ │ + 534 │ │ │ │ │ +535 DerivedType& operator+=(DifferenceType n) │ │ │ │ │ + 536 { │ │ │ │ │ + 537 static_cast(this)->advance(n); │ │ │ │ │ + 538 return *static_cast(this); │ │ │ │ │ + 539 } │ │ │ │ │ + 540 │ │ │ │ │ +541 DerivedType operator+(DifferenceType n) const │ │ │ │ │ + 542 { │ │ │ │ │ + 543 DerivedType tmp(static_cast(*this)); │ │ │ │ │ + 544 tmp.advance(n); │ │ │ │ │ + 545 return tmp; │ │ │ │ │ + 546 } │ │ │ │ │ + 547 │ │ │ │ │ + 548 │ │ │ │ │ +550 DerivedType& operator--() │ │ │ │ │ + 551 { │ │ │ │ │ + 552 static_cast(this)->decrement(); │ │ │ │ │ + 553 return *static_cast(this); │ │ │ │ │ + 554 } │ │ │ │ │ + 555 │ │ │ │ │ +557 DerivedType operator--(int) │ │ │ │ │ + 558 { │ │ │ │ │ + 559 DerivedType tmp(static_cast(*this)); │ │ │ │ │ + 560 this->operator--(); │ │ │ │ │ + 561 return tmp; │ │ │ │ │ + 562 } │ │ │ │ │ + 563 │ │ │ │ │ +564 DerivedType& operator-=(DifferenceType n) │ │ │ │ │ + 565 { │ │ │ │ │ + 566 static_cast(this)->advance(-n); │ │ │ │ │ + 567 return *static_cast(this); │ │ │ │ │ + 568 } │ │ │ │ │ + 569 │ │ │ │ │ +570 DerivedType operator-(DifferenceType n) const │ │ │ │ │ + 571 { │ │ │ │ │ + 572 DerivedType tmp(static_cast(*this)); │ │ │ │ │ + 573 tmp.advance(-n); │ │ │ │ │ + 574 return tmp; │ │ │ │ │ + 575 } │ │ │ │ │ + 576 │ │ │ │ │ + 577 │ │ │ │ │ + 578 }; │ │ │ │ │ + 579 │ │ │ │ │ + 590 template │ │ │ │ │ + 592 inline typename EnableIfInterOperable::type │ │ │ │ │ +593 operator==(const RandomAccessIteratorFacade& lhs, │ │ │ │ │ + 594 const RandomAccessIteratorFacade& rhs) │ │ │ │ │ + 595 { │ │ │ │ │ + 596 if(std::is_convertible::value) │ │ │ │ │ + 597 return static_cast(lhs).equals(static_cast(rhs)); │ │ │ │ │ + 598 else │ │ │ │ │ + 599 return static_cast(rhs).equals(static_cast(lhs)); │ │ │ │ │ + 600 } │ │ │ │ │ + 601 │ │ │ │ │ + 612 template │ │ │ │ │ + 614 inline typename EnableIfInterOperable::type │ │ │ │ │ +615 operator!=(const RandomAccessIteratorFacade& lhs, │ │ │ │ │ + 616 const RandomAccessIteratorFacade& rhs) │ │ │ │ │ + 617 { │ │ │ │ │ + 618 if(std::is_convertible::value) │ │ │ │ │ + 619 return !static_cast(lhs).equals(static_cast(rhs)); │ │ │ │ │ + 620 else │ │ │ │ │ + 621 return !static_cast(rhs).equals(static_cast(lhs)); │ │ │ │ │ + 622 } │ │ │ │ │ + 623 │ │ │ │ │ + 634 template │ │ │ │ │ +636 inline typename EnableIfInterOperable::type │ │ │ │ │ + 637 operator<(const RandomAccessIteratorFacade& lhs, │ │ │ │ │ + 638 const RandomAccessIteratorFacade& rhs) │ │ │ │ │ + 639 { │ │ │ │ │ + 640 if(std::is_convertible::value) │ │ │ │ │ + 641 return static_cast(lhs).distanceTo(static_cast │ │ │ │ │ +(rhs))>0; │ │ │ │ │ + 642 else │ │ │ │ │ + 643 return static_cast(rhs).distanceTo(static_cast │ │ │ │ │ +(lhs))<0; │ │ │ │ │ + 644 } │ │ │ │ │ + 645 │ │ │ │ │ + 646 │ │ │ │ │ + 657 template │ │ │ │ │ +659 inline typename EnableIfInterOperable::type │ │ │ │ │ + 660 operator<=(const RandomAccessIteratorFacade& lhs, │ │ │ │ │ + 661 const RandomAccessIteratorFacade& rhs) │ │ │ │ │ + 662 { │ │ │ │ │ + 663 if(std::is_convertible::value) │ │ │ │ │ + 664 return static_cast(lhs).distanceTo(static_cast │ │ │ │ │ +(rhs))>=0; │ │ │ │ │ + 665 else │ │ │ │ │ + 666 return static_cast(rhs).distanceTo(static_cast │ │ │ │ │ +(lhs))<=0; │ │ │ │ │ + 667 } │ │ │ │ │ + 668 │ │ │ │ │ + 669 │ │ │ │ │ + 680 template │ │ │ │ │ + 682 inline typename EnableIfInterOperable::type │ │ │ │ │ +683 operator>(const RandomAccessIteratorFacade& lhs, │ │ │ │ │ + 684 const RandomAccessIteratorFacade& rhs) │ │ │ │ │ + 685 { │ │ │ │ │ + 686 if(std::is_convertible::value) │ │ │ │ │ + 687 return static_cast(lhs).distanceTo(static_cast │ │ │ │ │ +(rhs))<0; │ │ │ │ │ + 688 else │ │ │ │ │ + 689 return static_cast(rhs).distanceTo(static_cast │ │ │ │ │ +(lhs))>0; │ │ │ │ │ + 690 } │ │ │ │ │ + 691 │ │ │ │ │ + 702 template │ │ │ │ │ + 704 inline typename EnableIfInterOperable::type │ │ │ │ │ +705 operator>=(const RandomAccessIteratorFacade& lhs, │ │ │ │ │ + 706 const RandomAccessIteratorFacade& rhs) │ │ │ │ │ + 707 { │ │ │ │ │ + 708 if(std::is_convertible::value) │ │ │ │ │ + 709 return static_cast(lhs).distanceTo(static_cast │ │ │ │ │ +(rhs))<=0; │ │ │ │ │ + 710 else │ │ │ │ │ + 711 return static_cast(rhs).distanceTo(static_cast │ │ │ │ │ +(lhs))>=0; │ │ │ │ │ + 712 } │ │ │ │ │ + 713 │ │ │ │ │ + 724 template │ │ │ │ │ + 726 inline typename EnableIfInterOperable::type │ │ │ │ │ +727 operator-(const RandomAccessIteratorFacade& lhs, │ │ │ │ │ + 728 const RandomAccessIteratorFacade& rhs) │ │ │ │ │ + 729 { │ │ │ │ │ + 730 if(std::is_convertible::value) │ │ │ │ │ + 731 return -static_cast(lhs).distanceTo(static_cast │ │ │ │ │ +(rhs)); │ │ │ │ │ + 732 else │ │ │ │ │ + 733 return static_cast(rhs).distanceTo(static_cast │ │ │ │ │ +(lhs)); │ │ │ │ │ + 734 } │ │ │ │ │ + 735 │ │ │ │ │ + 737} │ │ │ │ │ + 738#endif │ │ │ │ │ +typetraits.hh │ │ │ │ │ +Traits for type conversions and type information. │ │ │ │ │ +Dune::operator- │ │ │ │ │ +bigunsignedint< k > operator-(const bigunsignedint< k > &x, std::uintmax_t y) │ │ │ │ │ +Definition bigunsignedint.hh:542 │ │ │ │ │ +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:637 │ │ │ │ │ +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:683 │ │ │ │ │ +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:660 │ │ │ │ │ +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:237 │ │ │ │ │ +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:705 │ │ │ │ │ +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:259 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::Concept::requireConcept │ │ │ │ │ -constexpr bool requireConcept() │ │ │ │ │ -Definition concept.hh:246 │ │ │ │ │ -Dune::Concept::requireTrue │ │ │ │ │ -constexpr bool requireTrue() │ │ │ │ │ -Definition concept.hh:239 │ │ │ │ │ -Dune::Concept::requireSameType │ │ │ │ │ -constexpr bool requireSameType() │ │ │ │ │ -Definition concept.hh:317 │ │ │ │ │ -Dune::Concept::tupleEntriesModel │ │ │ │ │ -constexpr auto tupleEntriesModel() -> typename Impl::TupleEntriesModelHelper< │ │ │ │ │ -C, Tuple >::Result │ │ │ │ │ -Definition concept.hh:224 │ │ │ │ │ -Dune::Concept::requireConceptForTupleEntries │ │ │ │ │ -constexpr bool requireConceptForTupleEntries() │ │ │ │ │ -Definition concept.hh:262 │ │ │ │ │ -Dune::Concept::requireBaseOf │ │ │ │ │ -constexpr bool requireBaseOf() │ │ │ │ │ -Definition concept.hh:299 │ │ │ │ │ -Dune::Concept::requireConvertible │ │ │ │ │ -constexpr bool requireConvertible() │ │ │ │ │ -Definition concept.hh:271 │ │ │ │ │ -Dune::Concept::requireType │ │ │ │ │ -constexpr bool requireType() │ │ │ │ │ -Definition concept.hh:290 │ │ │ │ │ -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 │ │ │ │ │ +Dune::ForwardIteratorFacade │ │ │ │ │ +Base class for stl conformant forward iterators. │ │ │ │ │ +Definition iteratorfacades.hh:141 │ │ │ │ │ +Dune::ForwardIteratorFacade::iterator_category │ │ │ │ │ +std::forward_iterator_tag iterator_category │ │ │ │ │ +Definition iteratorfacades.hh:145 │ │ │ │ │ +Dune::ForwardIteratorFacade::pointer │ │ │ │ │ +V * pointer │ │ │ │ │ +Definition iteratorfacades.hh:148 │ │ │ │ │ +Dune::ForwardIteratorFacade::operator++ │ │ │ │ │ +DerivedType & operator++() │ │ │ │ │ +Preincrement operator. │ │ │ │ │ +Definition iteratorfacades.hh:209 │ │ │ │ │ +Dune::ForwardIteratorFacade::DifferenceType │ │ │ │ │ +D DifferenceType │ │ │ │ │ +The type of the difference between two positions. │ │ │ │ │ +Definition iteratorfacades.hh:190 │ │ │ │ │ +Dune::ForwardIteratorFacade::Reference │ │ │ │ │ +R Reference │ │ │ │ │ +The type of the reference to the values accessed. │ │ │ │ │ +Definition iteratorfacades.hh:195 │ │ │ │ │ +Dune::ForwardIteratorFacade::operator-> │ │ │ │ │ +Pointer operator->() const │ │ │ │ │ +Definition iteratorfacades.hh:203 │ │ │ │ │ +Dune::ForwardIteratorFacade::DerivedType │ │ │ │ │ +T DerivedType │ │ │ │ │ +The type of derived iterator. │ │ │ │ │ +Definition iteratorfacades.hh:175 │ │ │ │ │ +Dune::ForwardIteratorFacade::Value │ │ │ │ │ +V Value │ │ │ │ │ +The type of value accessed through the iterator. │ │ │ │ │ +Definition iteratorfacades.hh:180 │ │ │ │ │ +Dune::ForwardIteratorFacade::value_type │ │ │ │ │ +typename std::remove_const< V >::type value_type │ │ │ │ │ +Definition iteratorfacades.hh:146 │ │ │ │ │ +Dune::ForwardIteratorFacade::operator++ │ │ │ │ │ +DerivedType operator++(int) │ │ │ │ │ +Postincrement operator. │ │ │ │ │ +Definition iteratorfacades.hh:216 │ │ │ │ │ +Dune::ForwardIteratorFacade::Pointer │ │ │ │ │ +V * Pointer │ │ │ │ │ +The pointer to the Value. │ │ │ │ │ +Definition iteratorfacades.hh:185 │ │ │ │ │ +Dune::ForwardIteratorFacade::difference_type │ │ │ │ │ +D difference_type │ │ │ │ │ +Definition iteratorfacades.hh:147 │ │ │ │ │ +Dune::ForwardIteratorFacade::operator* │ │ │ │ │ +Reference operator*() const │ │ │ │ │ +Dereferencing operator. │ │ │ │ │ +Definition iteratorfacades.hh:198 │ │ │ │ │ +Dune::ForwardIteratorFacade::reference │ │ │ │ │ +R reference │ │ │ │ │ +Definition iteratorfacades.hh:149 │ │ │ │ │ +Dune::BidirectionalIteratorFacade │ │ │ │ │ +Facade class for stl conformant bidirectional iterators. │ │ │ │ │ +Definition iteratorfacades.hh:274 │ │ │ │ │ +Dune::BidirectionalIteratorFacade::pointer │ │ │ │ │ +V * pointer │ │ │ │ │ +Definition iteratorfacades.hh:281 │ │ │ │ │ +Dune::BidirectionalIteratorFacade::value_type │ │ │ │ │ +typename std::remove_const< V >::type value_type │ │ │ │ │ +Definition iteratorfacades.hh:279 │ │ │ │ │ +Dune::BidirectionalIteratorFacade::operator* │ │ │ │ │ +Reference operator*() const │ │ │ │ │ +Dereferencing operator. │ │ │ │ │ +Definition iteratorfacades.hh:332 │ │ │ │ │ +Dune::BidirectionalIteratorFacade::difference_type │ │ │ │ │ +D difference_type │ │ │ │ │ +Definition iteratorfacades.hh:280 │ │ │ │ │ +Dune::BidirectionalIteratorFacade::DerivedType │ │ │ │ │ +T DerivedType │ │ │ │ │ +The type of derived iterator. │ │ │ │ │ +Definition iteratorfacades.hh:309 │ │ │ │ │ +Dune::BidirectionalIteratorFacade::operator-- │ │ │ │ │ +DerivedType & operator--() │ │ │ │ │ +Preincrement operator. │ │ │ │ │ +Definition iteratorfacades.hh:359 │ │ │ │ │ +Dune::BidirectionalIteratorFacade::operator-> │ │ │ │ │ +Pointer operator->() const │ │ │ │ │ +Definition iteratorfacades.hh:337 │ │ │ │ │ +Dune::BidirectionalIteratorFacade::operator++ │ │ │ │ │ +DerivedType & operator++() │ │ │ │ │ +Preincrement operator. │ │ │ │ │ +Definition iteratorfacades.hh:343 │ │ │ │ │ +Dune::BidirectionalIteratorFacade::Pointer │ │ │ │ │ +V * Pointer │ │ │ │ │ +The pointer to the Value. │ │ │ │ │ +Definition iteratorfacades.hh:319 │ │ │ │ │ +Dune::BidirectionalIteratorFacade::Reference │ │ │ │ │ +R Reference │ │ │ │ │ +The type of the reference to the values accessed. │ │ │ │ │ +Definition iteratorfacades.hh:329 │ │ │ │ │ +Dune::BidirectionalIteratorFacade::operator++ │ │ │ │ │ +DerivedType operator++(int) │ │ │ │ │ +Postincrement operator. │ │ │ │ │ +Definition iteratorfacades.hh:350 │ │ │ │ │ +Dune::BidirectionalIteratorFacade::iterator_category │ │ │ │ │ +std::bidirectional_iterator_tag iterator_category │ │ │ │ │ +Definition iteratorfacades.hh:278 │ │ │ │ │ +Dune::BidirectionalIteratorFacade::DifferenceType │ │ │ │ │ +D DifferenceType │ │ │ │ │ +The type of the difference between two positions. │ │ │ │ │ +Definition iteratorfacades.hh:324 │ │ │ │ │ +Dune::BidirectionalIteratorFacade::operator-- │ │ │ │ │ +DerivedType operator--(int) │ │ │ │ │ +Postincrement operator. │ │ │ │ │ +Definition iteratorfacades.hh:366 │ │ │ │ │ +Dune::BidirectionalIteratorFacade::reference │ │ │ │ │ +R reference │ │ │ │ │ +Definition iteratorfacades.hh:282 │ │ │ │ │ +Dune::BidirectionalIteratorFacade::Value │ │ │ │ │ +V Value │ │ │ │ │ +The type of value accessed through the iterator. │ │ │ │ │ +Definition iteratorfacades.hh:314 │ │ │ │ │ +Dune::RandomAccessIteratorFacade │ │ │ │ │ +Base class for stl conformant forward iterators. │ │ │ │ │ +Definition iteratorfacades.hh:434 │ │ │ │ │ +Dune::RandomAccessIteratorFacade::value_type │ │ │ │ │ +typename std::remove_const< V >::type value_type │ │ │ │ │ +Definition iteratorfacades.hh:439 │ │ │ │ │ +Dune::RandomAccessIteratorFacade::difference_type │ │ │ │ │ +D difference_type │ │ │ │ │ +Definition iteratorfacades.hh:440 │ │ │ │ │ +Dune::RandomAccessIteratorFacade::operator-- │ │ │ │ │ +DerivedType operator--(int) │ │ │ │ │ +Postdecrement operator. │ │ │ │ │ +Definition iteratorfacades.hh:557 │ │ │ │ │ +Dune::RandomAccessIteratorFacade::pointer │ │ │ │ │ +V * pointer │ │ │ │ │ +Definition iteratorfacades.hh:441 │ │ │ │ │ +Dune::RandomAccessIteratorFacade::iterator_category │ │ │ │ │ +std::random_access_iterator_tag iterator_category │ │ │ │ │ +Definition iteratorfacades.hh:438 │ │ │ │ │ +Dune::RandomAccessIteratorFacade::operator* │ │ │ │ │ +Reference operator*() const │ │ │ │ │ +Dereferencing operator. │ │ │ │ │ +Definition iteratorfacades.hh:500 │ │ │ │ │ +Dune::RandomAccessIteratorFacade::operator++ │ │ │ │ │ +DerivedType & operator++() │ │ │ │ │ +Preincrement operator. │ │ │ │ │ +Definition iteratorfacades.hh:521 │ │ │ │ │ +Dune::RandomAccessIteratorFacade::reference │ │ │ │ │ +R reference │ │ │ │ │ +Definition iteratorfacades.hh:442 │ │ │ │ │ +Dune::RandomAccessIteratorFacade::operator-> │ │ │ │ │ +Pointer operator->() const │ │ │ │ │ +Definition iteratorfacades.hh:505 │ │ │ │ │ +Dune::RandomAccessIteratorFacade::DifferenceType │ │ │ │ │ +D DifferenceType │ │ │ │ │ +The type of the difference between two positions. │ │ │ │ │ +Definition iteratorfacades.hh:492 │ │ │ │ │ +Dune::RandomAccessIteratorFacade::operator-- │ │ │ │ │ +DerivedType & operator--() │ │ │ │ │ +Predecrement operator. │ │ │ │ │ +Definition iteratorfacades.hh:550 │ │ │ │ │ +Dune::RandomAccessIteratorFacade::operator-= │ │ │ │ │ +DerivedType & operator-=(DifferenceType n) │ │ │ │ │ +Definition iteratorfacades.hh:564 │ │ │ │ │ +Dune::RandomAccessIteratorFacade::operator+ │ │ │ │ │ +DerivedType operator+(DifferenceType n) const │ │ │ │ │ +Definition iteratorfacades.hh:541 │ │ │ │ │ +Dune::RandomAccessIteratorFacade::operator[] │ │ │ │ │ +Reference operator[](DifferenceType n) const │ │ │ │ │ +Get the element n positions from the current one. │ │ │ │ │ +Definition iteratorfacades.hh:515 │ │ │ │ │ +Dune::RandomAccessIteratorFacade::DerivedType │ │ │ │ │ +T DerivedType │ │ │ │ │ +The type of derived iterator. │ │ │ │ │ +Definition iteratorfacades.hh:477 │ │ │ │ │ +Dune::RandomAccessIteratorFacade::Pointer │ │ │ │ │ +V * Pointer │ │ │ │ │ +The pointer to the Value. │ │ │ │ │ +Definition iteratorfacades.hh:487 │ │ │ │ │ +Dune::RandomAccessIteratorFacade::operator- │ │ │ │ │ +DerivedType operator-(DifferenceType n) const │ │ │ │ │ +Definition iteratorfacades.hh:570 │ │ │ │ │ +Dune::RandomAccessIteratorFacade::operator++ │ │ │ │ │ +DerivedType operator++(int) │ │ │ │ │ +Postincrement operator. │ │ │ │ │ +Definition iteratorfacades.hh:528 │ │ │ │ │ +Dune::RandomAccessIteratorFacade::Value │ │ │ │ │ +V Value │ │ │ │ │ +The type of value accessed through the iterator. │ │ │ │ │ +Definition iteratorfacades.hh:482 │ │ │ │ │ +Dune::RandomAccessIteratorFacade::operator+= │ │ │ │ │ +DerivedType & operator+=(DifferenceType n) │ │ │ │ │ +Definition iteratorfacades.hh:535 │ │ │ │ │ +Dune::RandomAccessIteratorFacade::Reference │ │ │ │ │ +R Reference │ │ │ │ │ +The type of the reference to the values accessed. │ │ │ │ │ +Definition iteratorfacades.hh:497 │ │ │ │ │ +Dune::EnableIfInterOperable │ │ │ │ │ +Enable typedef if two types are interoperable. │ │ │ │ │ +Definition typetraits.hh:81 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00086.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: bitsetvector.hh File Reference │ │ │ │ +dune-common: stdthread.cc File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,60 +70,36 @@ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ -Classes | │ │ │ │ -Namespaces
    │ │ │ │ -
    bitsetvector.hh File Reference
    │ │ │ │ +Namespaces | │ │ │ │ +Functions
    │ │ │ │ +
    stdthread.cc File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ - │ │ │ │ -

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

    │ │ │ │ -
    #include <vector>
    │ │ │ │ -#include <bitset>
    │ │ │ │ +
    #include <cstdlib>
    │ │ │ │ #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

    class  Dune::BitSetVectorConstReference< block_size, Alloc >
     A proxy class that acts as a const reference to a single bitset in a BitSetVector. More...
     
    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::const_reference< BitSetVectorReference< block_size, Alloc > >
     
    struct  Dune::const_reference< BitSetVectorConstReference< block_size, Alloc > >
     
    struct  Dune::mutable_reference< BitSetVectorReference< block_size, Alloc > >
     
    struct  Dune::mutable_reference< BitSetVectorConstReference< block_size, Alloc > >
     
    class  Dune::BitSetVector< block_size, Allocator >
     A dynamic array of blocks of booleans. More...
     
    │ │ │ │ +#include <mutex>
    │ │ │ │ +#include <ostream>
    │ │ │ │ +#include <dune/common/stdthread.hh>
    │ │ │ │ +
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ +

    │ │ │ │ Namespaces

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

    │ │ │ │ +Functions

    void Dune::doAssertCallOnce (const char *file, int line, const char *function)
     
    │ │ │ │ -

    Detailed Description

    │ │ │ │ -

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

    │ │ │ │ -
    │ │ │ │ +
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,50 +6,24 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -bitsetvector.hh File Reference │ │ │ │ │ -Efficient implementation of a dynamic array of static arrays of booleans. │ │ │ │ │ -More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Namespaces | Functions │ │ │ │ │ +stdthread.cc File Reference │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -Go_to_the_source_code_of_this_file. │ │ │ │ │ - Classes │ │ │ │ │ - class  Dune::BitSetVectorConstReference<_block_size,_Alloc_> │ │ │ │ │ -  A proxy class that acts as a const reference to a single bitset in a │ │ │ │ │ - BitSetVector. More... │ │ │ │ │ -  │ │ │ │ │ - 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::const_reference<_BitSetVectorReference<_block_size,_Alloc_>_> │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::const_reference<_BitSetVectorConstReference<_block_size,_Alloc_> │ │ │ │ │ - > │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::mutable_reference<_BitSetVectorReference<_block_size,_Alloc_>_> │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::mutable_reference<_BitSetVectorConstReference<_block_size,_Alloc │ │ │ │ │ - >_> │ │ │ │ │ -  │ │ │ │ │ - class  Dune::BitSetVector<_block_size,_Allocator_> │ │ │ │ │ -  A dynamic array of blocks of booleans. More... │ │ │ │ │ -  │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -Efficient implementation of a dynamic array of static arrays of booleans. │ │ │ │ │ + Functions │ │ │ │ │ +void Dune::doAssertCallOnce (const char *file, int line, const char *function) │ │ │ │ │ +  │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00089.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: singleton.hh File Reference │ │ │ │ +dune-common: exceptions.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -71,40 +71,81 @@ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ Classes | │ │ │ │ -Namespaces
    │ │ │ │ -
    singleton.hh File Reference
    │ │ │ │ +Namespaces | │ │ │ │ +Macros | │ │ │ │ +Functions
    │ │ │ │ +
    exceptions.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ -

    Useful wrapper for creating singletons. │ │ │ │ +

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

    │ │ │ │ -
    #include <dune/common/visibility.hh>
    │ │ │ │ +
    #include <exception>
    │ │ │ │ +#include <string>
    │ │ │ │ +#include <sstream>
    │ │ │ │
    │ │ │ │

    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::Exception
     Base class for Dune-Exceptions. More...
     
    struct  Dune::ExceptionHook
     Base class to add a hook to the Dune::Exception. More...
     
    class  Dune::IOError
     Default exception class for I/O errors. More...
     
    class  Dune::MathError
     Default exception class for mathematical errors. More...
     
    class  Dune::RangeError
     Default exception class for range errors. More...
     
    class  Dune::NotImplemented
     Default exception for dummy implementations. More...
     
    class  Dune::SystemError
     Default exception class for OS errors. More...
     
    class  Dune::OutOfMemoryError
     Default exception if memory allocation fails. 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::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

    std::ostream & Dune::operator<< (std::ostream &stream, const Exception &e)
     
    │ │ │ │

    Detailed Description

    │ │ │ │ -

    Useful wrapper for creating singletons.

    │ │ │ │ -

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

    │ │ │ │ +

    A few common exception classes.

    │ │ │ │ +

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

    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,26 +6,65 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -singleton.hh File Reference │ │ │ │ │ -Useful wrapper for creating singletons. More... │ │ │ │ │ -#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 │ │ │ │ │ -class  Dune::Singleton<_T_> │ │ │ │ │ -  An adapter to turn a class into a singleton. More... │ │ │ │ │ + class  Dune::Exception │ │ │ │ │ +  Base class for Dune-Exceptions. More... │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::ExceptionHook │ │ │ │ │ +  Base class to add a hook to the Dune::Exception. More... │ │ │ │ │ +  │ │ │ │ │ + class  Dune::IOError │ │ │ │ │ +  Default exception class for I/O errors. More... │ │ │ │ │ +  │ │ │ │ │ + class  Dune::MathError │ │ │ │ │ +  Default exception class for mathematical errors. More... │ │ │ │ │ +  │ │ │ │ │ + class  Dune::RangeError │ │ │ │ │ +  Default exception class for range errors. More... │ │ │ │ │ +  │ │ │ │ │ + class  Dune::NotImplemented │ │ │ │ │ +  Default exception for dummy implementations. More... │ │ │ │ │ +  │ │ │ │ │ + class  Dune::SystemError │ │ │ │ │ +  Default exception class for OS errors. More... │ │ │ │ │ +  │ │ │ │ │ + class  Dune::OutOfMemoryError │ │ │ │ │ +  Default exception if memory allocation fails. 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::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 │ │ │ │ │ +std::ostream & Dune::operator<< (std::ostream &stream, const Exception &e) │ │ │ │ │ +  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Useful wrapper for creating singletons. │ │ │ │ │ -Inspired by the article CodeGuru:_A_Leak-Free_Singleton_class │ │ │ │ │ +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/a00089_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: singleton.hh Source File │ │ │ │ +dune-common: exceptions.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,62 +74,119 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    singleton.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 (C) 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
    │ │ │ │ -
    7
    │ │ │ │ - │ │ │ │ -
    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 };
    │ │ │ │ -
    │ │ │ │ +
    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
    │ │ │ │ +
    73 /* forward declarations */
    │ │ │ │ +
    74 class Exception;
    │ │ │ │ +
    75 struct ExceptionHook;
    │ │ │ │
    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
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    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 {
    │ │ │ │ +
    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
    │ │ │ │ +
    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
    │ │ │ │ -
    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
    │ │ │ │ +
    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 {} │ │ │ │ │ @@ -7,68 +7,153 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -singleton.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 (C) 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 │ │ │ │ │ - 7 │ │ │ │ │ - 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 }; │ │ │ │ │ + 5 │ │ │ │ │ + 6#ifndef DUNE_EXCEPTIONS_HH │ │ │ │ │ + 7#define DUNE_EXCEPTIONS_HH │ │ │ │ │ + 8 │ │ │ │ │ + 9#include │ │ │ │ │ + 10#include │ │ │ │ │ + 11#include │ │ │ │ │ + 12 │ │ │ │ │ + 13namespace Dune { │ │ │ │ │ + 14 │ │ │ │ │ + 73 /* forward declarations */ │ │ │ │ │ + 74 class Exception; │ │ │ │ │ + 75 struct ExceptionHook; │ │ │ │ │ 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 │ │ │ │ │ +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 { │ │ │ │ │ + 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 │ │ │ │ │ +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::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 │ │ │ │ │ +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/a00092.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: parametertree.hh File Reference │ │ │ │ +dune-common: fmatrixev.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,70 +70,66 @@ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ -Classes | │ │ │ │ -Namespaces
    │ │ │ │ -
    parametertree.hh File Reference
    │ │ │ │ +Namespaces | │ │ │ │ +Functions
    │ │ │ │ +
    fmatrixev.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ -

    A hierarchical structure of string parameters. │ │ │ │ +

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

    │ │ │ │ -
    #include <array>
    │ │ │ │ -#include <cstddef>
    │ │ │ │ +
    #include <algorithm>
    │ │ │ │ #include <iostream>
    │ │ │ │ -#include <istream>
    │ │ │ │ -#include <iterator>
    │ │ │ │ -#include <locale>
    │ │ │ │ -#include <map>
    │ │ │ │ -#include <ostream>
    │ │ │ │ -#include <sstream>
    │ │ │ │ -#include <string>
    │ │ │ │ -#include <typeinfo>
    │ │ │ │ -#include <vector>
    │ │ │ │ -#include <algorithm>
    │ │ │ │ -#include <bitset>
    │ │ │ │ -#include <dune/common/exceptions.hh>
    │ │ │ │ -#include <dune/common/fvector.hh>
    │ │ │ │ -#include <dune/common/classname.hh>
    │ │ │ │ +#include <cmath>
    │ │ │ │ +#include <cassert>
    │ │ │ │ +#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.

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

    │ │ │ │ -Classes

    class  Dune::ParameterTree
     Hierarchical structure of string parameters. More...
     
    struct  Dune::ParameterTree::Parser< std::basic_string< char, traits, Allocator > >
     
    struct  Dune::ParameterTree::Parser< bool >
     
    struct  Dune::ParameterTree::Parser< bool >::ToLower
     
    struct  Dune::ParameterTree::Parser< FieldVector< T, n > >
     
    struct  Dune::ParameterTree::Parser< std::array< T, n > >
     
    struct  Dune::ParameterTree::Parser< std::bitset< n > >
     
    struct  Dune::ParameterTree::Parser< std::vector< T, A > >
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ +

    │ │ │ │ Namespaces

    namespace  Dune
     Dune namespace.
     
    namespace  Dune::FMatrixHelp
     
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

    │ │ │ │ +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

    │ │ │ │ -

    A hierarchical structure of string parameters.

    │ │ │ │ +

    Eigenvalue computations for the FieldMatrix class.

    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,56 +6,60 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -parametertree.hh File Reference │ │ │ │ │ -A hierarchical structure of string parameters. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Namespaces | Functions │ │ │ │ │ +fmatrixev.hh File Reference │ │ │ │ │ +Eigenvalue computations for the FieldMatrix class. More... │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ - Classes │ │ │ │ │ - class  Dune::ParameterTree │ │ │ │ │ -  Hierarchical structure of string parameters. More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::ParameterTree::Parser<_std::basic_string<_char,_traits, │ │ │ │ │ - Allocator_>_> │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::ParameterTree::Parser<_bool_> │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::ParameterTree::Parser<_bool_>::ToLower │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::ParameterTree::Parser<_FieldVector<_T,_n_>_> │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::ParameterTree::Parser<_std::array<_T,_n_>_> │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::ParameterTree::Parser<_std::bitset<_n_>_> │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::ParameterTree::Parser<_std::vector<_T,_A_>_> │ │ │ │ │ -  │ │ │ │ │ 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 │ │ │ │ │ +  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -A hierarchical structure of string parameters. │ │ │ │ │ +Eigenvalue computations for the FieldMatrix class. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00092_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: parametertree.hh Source File │ │ │ │ +dune-common: fmatrixev.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,345 +74,640 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    parametertree.hh
    │ │ │ │ +
    fmatrixev.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 (C) 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_PARAMETERTREE_HH
    │ │ │ │ -
    6#define DUNE_PARAMETERTREE_HH
    │ │ │ │ +
    5#ifndef DUNE_FMATRIXEIGENVALUES_HH
    │ │ │ │ +
    6#define DUNE_FMATRIXEIGENVALUES_HH
    │ │ │ │
    7
    │ │ │ │ -
    12#include <array>
    │ │ │ │ -
    13#include <cstddef>
    │ │ │ │ -
    14#include <iostream>
    │ │ │ │ -
    15#include <istream>
    │ │ │ │ -
    16#include <iterator>
    │ │ │ │ -
    17#include <locale>
    │ │ │ │ -
    18#include <map>
    │ │ │ │ -
    19#include <ostream>
    │ │ │ │ -
    20#include <sstream>
    │ │ │ │ -
    21#include <string>
    │ │ │ │ -
    22#include <typeinfo>
    │ │ │ │ -
    23#include <vector>
    │ │ │ │ -
    24#include <algorithm>
    │ │ │ │ -
    25#include <bitset>
    │ │ │ │ -
    26
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ +
    12#include <algorithm>
    │ │ │ │ +
    13#include <iostream>
    │ │ │ │ +
    14#include <cmath>
    │ │ │ │ +
    15#include <cassert>
    │ │ │ │ +
    16
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    20#include <dune/common/math.hh>
    │ │ │ │ +
    21
    │ │ │ │ +
    22namespace Dune {
    │ │ │ │ +
    23
    │ │ │ │ +
    29 namespace FMatrixHelp {
    │ │ │ │
    30
    │ │ │ │ -
    31namespace Dune {
    │ │ │ │ -
    32
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    37 {
    │ │ │ │ -
    38 // class providing a single static parse() function, used by the
    │ │ │ │ -
    39 // generic get() method
    │ │ │ │ -
    40 template<typename T>
    │ │ │ │ -
    41 struct Parser;
    │ │ │ │ -
    42
    │ │ │ │ -
    43 public:
    │ │ │ │ -
    44
    │ │ │ │ -
    47 typedef std::vector<std::string> KeyVector;
    │ │ │ │ +
    31#if HAVE_LAPACK
    │ │ │ │ +
    32 // defined in fmatrixev.cc
    │ │ │ │ +
    33 extern void eigenValuesLapackCall(
    │ │ │ │ +
    34 const char* jobz, const char* uplo, const long
    │ │ │ │ +
    35 int* n, double* a, const long int* lda, double* w,
    │ │ │ │ +
    36 double* work, const long int* lwork, long int* info);
    │ │ │ │ +
    37
    │ │ │ │ +
    38 extern void eigenValuesNonsymLapackCall(
    │ │ │ │ +
    39 const char* jobvl, const char* jobvr, const long
    │ │ │ │ +
    40 int* n, double* a, const long int* lda, double* wr, double* wi, double* vl,
    │ │ │ │ +
    41 const long int* ldvl, double* vr, const long int* ldvr, double* work,
    │ │ │ │ +
    42 const long int* lwork, long int* info);
    │ │ │ │ +
    43
    │ │ │ │ +
    44 extern void eigenValuesLapackCall(
    │ │ │ │ +
    45 const char* jobz, const char* uplo, const long
    │ │ │ │ +
    46 int* n, float* a, const long int* lda, float* w,
    │ │ │ │ +
    47 float* work, const long int* lwork, long int* info);
    │ │ │ │
    48
    │ │ │ │ - │ │ │ │ -
    52
    │ │ │ │ -
    53
    │ │ │ │ -
    61 bool hasKey(const std::string& key) const;
    │ │ │ │ -
    62
    │ │ │ │ -
    63
    │ │ │ │ -
    71 bool hasSub(const std::string& sub) const;
    │ │ │ │ -
    72
    │ │ │ │ -
    73
    │ │ │ │ -
    82 std::string& operator[] (const std::string& key);
    │ │ │ │ -
    83
    │ │ │ │ -
    84
    │ │ │ │ -
    94 const std::string& operator[] (const std::string& key) const;
    │ │ │ │ -
    95
    │ │ │ │ -
    96
    │ │ │ │ -
    104 void report(std::ostream& stream = std::cout,
    │ │ │ │ -
    105 const std::string& prefix = "") const;
    │ │ │ │ -
    106
    │ │ │ │ -
    107
    │ │ │ │ -
    113 ParameterTree& sub(const std::string& sub);
    │ │ │ │ -
    114
    │ │ │ │ -
    115
    │ │ │ │ -
    122 const ParameterTree& sub(const std::string& sub, bool fail_if_missing = false) const;
    │ │ │ │ -
    123
    │ │ │ │ -
    124
    │ │ │ │ -
    133 std::string get(const std::string& key, const std::string& defaultValue) const;
    │ │ │ │ -
    134
    │ │ │ │ -
    145 std::string get(const std::string& key, const char* defaultValue) const;
    │ │ │ │ +
    49 extern void eigenValuesNonsymLapackCall(
    │ │ │ │ +
    50 const char* jobvl, const char* jobvr, const long
    │ │ │ │ +
    51 int* n, float* a, const long int* lda, float* wr, float* wi, float* vl,
    │ │ │ │ +
    52 const long int* ldvl, float* vr, const long int* ldvr, float* work,
    │ │ │ │ +
    53 const long int* lwork, long int* info);
    │ │ │ │ +
    54
    │ │ │ │ +
    55#endif
    │ │ │ │ +
    56
    │ │ │ │ +
    57 namespace Impl {
    │ │ │ │ +
    58 //internal tag to activate/disable code for eigenvector calculation at compile time
    │ │ │ │ +
    59 enum Jobs { OnlyEigenvalues=0, EigenvaluesEigenvectors=1 };
    │ │ │ │ +
    60
    │ │ │ │ +
    61 //internal dummy used if only eigenvalues are to be calculated
    │ │ │ │ +
    62 template<typename K, int dim>
    │ │ │ │ +
    63 using EVDummy = FieldMatrix<K, dim, dim>;
    │ │ │ │ +
    64
    │ │ │ │ +
    65 //compute the cross-product of two vectors
    │ │ │ │ +
    66 template<typename K>
    │ │ │ │ +
    67 inline FieldVector<K,3> crossProduct(const FieldVector<K,3>& vec0, const FieldVector<K,3>& vec1) {
    │ │ │ │ +
    68 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]};
    │ │ │ │ +
    69 }
    │ │ │ │ +
    70
    │ │ │ │ +
    71 template <typename K>
    │ │ │ │ +
    72 static void eigenValues2dImpl(const FieldMatrix<K, 2, 2>& matrix,
    │ │ │ │ +
    73 FieldVector<K, 2>& eigenvalues)
    │ │ │ │ +
    74 {
    │ │ │ │ +
    75 using std::sqrt;
    │ │ │ │ +
    76 const K p = 0.5 * (matrix[0][0] + matrix [1][1]);
    │ │ │ │ +
    77 const K p2 = p - matrix[1][1];
    │ │ │ │ +
    78 K q = p2 * p2 + matrix[1][0] * matrix[0][1];
    │ │ │ │ +
    79 if( q < 0 && q > -1e-14 ) q = 0;
    │ │ │ │ +
    80 if (q < 0)
    │ │ │ │ +
    81 {
    │ │ │ │ +
    82 std::cout << matrix << std::endl;
    │ │ │ │ +
    83 // Complex eigenvalues are either caused by non-symmetric matrices or by round-off errors
    │ │ │ │ +
    84 DUNE_THROW(MathError, "Complex eigenvalue detected (which this implementation cannot handle).");
    │ │ │ │ +
    85 }
    │ │ │ │ +
    86
    │ │ │ │ +
    87 // get square root
    │ │ │ │ +
    88 q = sqrt(q);
    │ │ │ │ +
    89
    │ │ │ │ +
    90 // store eigenvalues in ascending order
    │ │ │ │ +
    91 eigenvalues[0] = p - q;
    │ │ │ │ +
    92 eigenvalues[1] = p + q;
    │ │ │ │ +
    93 }
    │ │ │ │ +
    94
    │ │ │ │ +
    95 /*
    │ │ │ │ +
    96 This implementation was adapted from the pseudo-code (Python?) implementation found on
    │ │ │ │ +
    97 http://en.wikipedia.org/wiki/Eigenvalue_algorithm (retrieved late August 2014).
    │ │ │ │ +
    98 Wikipedia claims to have taken it from
    │ │ │ │ +
    99 Smith, Oliver K. (April 1961), Eigenvalues of a symmetric 3 × 3 matrix.,
    │ │ │ │ +
    100 Communications of the ACM 4 (4): 168, doi:10.1145/355578.366316
    │ │ │ │ +
    101 */
    │ │ │ │ +
    102 template <typename K>
    │ │ │ │ +
    103 static K eigenValues3dImpl(const FieldMatrix<K, 3, 3>& matrix,
    │ │ │ │ +
    104 FieldVector<K, 3>& eigenvalues)
    │ │ │ │ +
    105 {
    │ │ │ │ +
    106 using std::sqrt;
    │ │ │ │ +
    107 using std::acos;
    │ │ │ │ +
    108 using real_type = typename FieldTraits<K>::real_type;
    │ │ │ │ +
    109 const K pi = MathematicalConstants<K>::pi();
    │ │ │ │ +
    110 K p1 = matrix[0][1]*matrix[0][1] + matrix[0][2]*matrix[0][2] + matrix[1][2]*matrix[1][2];
    │ │ │ │ +
    111
    │ │ │ │ +
    112 if (p1 <= std::numeric_limits<K>::epsilon()) {
    │ │ │ │ +
    113 // A is diagonal.
    │ │ │ │ +
    114 eigenvalues[0] = matrix[0][0];
    │ │ │ │ +
    115 eigenvalues[1] = matrix[1][1];
    │ │ │ │ +
    116 eigenvalues[2] = matrix[2][2];
    │ │ │ │ +
    117 std::sort(eigenvalues.begin(), eigenvalues.end());
    │ │ │ │ +
    118
    │ │ │ │ +
    119 return 0.0;
    │ │ │ │ +
    120 }
    │ │ │ │ +
    121 else
    │ │ │ │ +
    122 {
    │ │ │ │ +
    123 // q = trace(A)/3
    │ │ │ │ +
    124 K q = 0;
    │ │ │ │ +
    125 for (int i=0; i<3; i++)
    │ │ │ │ +
    126 q += matrix[i][i] / 3.0;
    │ │ │ │ +
    127
    │ │ │ │ +
    128 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;
    │ │ │ │ +
    129 K p = sqrt(p2 / 6);
    │ │ │ │ +
    130 // B = (1 / p) * (A - q * I); // I is the identity matrix
    │ │ │ │ +
    131 FieldMatrix<K,3,3> B;
    │ │ │ │ +
    132 for (int i=0; i<3; i++)
    │ │ │ │ +
    133 for (int j=0; j<3; j++)
    │ │ │ │ +
    134 B[i][j] = (real_type(1.0)/p) * (matrix[i][j] - q*(i==j));
    │ │ │ │ +
    135
    │ │ │ │ +
    136 K r = B.determinant() / 2.0;
    │ │ │ │ +
    137
    │ │ │ │ +
    138 /*In exact arithmetic for a symmetric matrix -1 <= r <= 1
    │ │ │ │ +
    139 but computation error can leave it slightly outside this range.
    │ │ │ │ +
    140 acos(z) function requires |z| <= 1, but will fail silently
    │ │ │ │ +
    141 and return NaN if the input is larger than 1 in magnitude.
    │ │ │ │ +
    142 Thus r is clamped to [-1,1].*/
    │ │ │ │ +
    143 using std::clamp;
    │ │ │ │ +
    144 r = clamp<K>(r, -1.0, 1.0);
    │ │ │ │ +
    145 K phi = acos(r) / 3.0;
    │ │ │ │
    146
    │ │ │ │ -
    147
    │ │ │ │ -
    157 template<typename T>
    │ │ │ │ -
    │ │ │ │ -
    158 T get(const std::string& key, const T& defaultValue) const {
    │ │ │ │ -
    159 if(hasKey(key))
    │ │ │ │ -
    160 return get<T>(key);
    │ │ │ │ -
    161 else
    │ │ │ │ -
    162 return defaultValue;
    │ │ │ │ -
    163 }
    │ │ │ │ -
    │ │ │ │ -
    164
    │ │ │ │ -
    173 template <class T>
    │ │ │ │ -
    │ │ │ │ -
    174 T get(const std::string& key) const {
    │ │ │ │ -
    175 if(not hasKey(key))
    │ │ │ │ -
    176 DUNE_THROW(Dune::RangeError, "Key '" << key
    │ │ │ │ -
    177 << "' not found in ParameterTree (prefix " + prefix_ + ")");
    │ │ │ │ -
    178 try {
    │ │ │ │ -
    179 return Parser<T>::parse((*this)[key]);
    │ │ │ │ -
    180 }
    │ │ │ │ -
    181 catch(const RangeError& e) {
    │ │ │ │ -
    182 // rethrow the error and add more information
    │ │ │ │ -
    183 DUNE_THROW(RangeError, "Cannot parse value \"" << (*this)[key]
    │ │ │ │ -
    184 << "\" for key \"" << prefix_ << "." << key << "\""
    │ │ │ │ -
    185 << e.what());
    │ │ │ │ -
    186 }
    │ │ │ │ -
    187 }
    │ │ │ │ -
    │ │ │ │ +
    147 // the eigenvalues satisfy eig[2] <= eig[1] <= eig[0]
    │ │ │ │ +
    148 eigenvalues[2] = q + 2 * p * cos(phi);
    │ │ │ │ +
    149 eigenvalues[0] = q + 2 * p * cos(phi + (2*pi/3));
    │ │ │ │ +
    150 eigenvalues[1] = 3 * q - eigenvalues[0] - eigenvalues[2]; // since trace(matrix) = eig1 + eig2 + eig3
    │ │ │ │ +
    151
    │ │ │ │ +
    152 return r;
    │ │ │ │ +
    153 }
    │ │ │ │ +
    154 }
    │ │ │ │ +
    155
    │ │ │ │ +
    156 //see https://www.geometrictools.com/Documentation/RobustEigenSymmetric3x3.pdf
    │ │ │ │ +
    157 //Robustly compute a right-handed orthonormal set {u, v, evec0}.
    │ │ │ │ +
    158 template<typename K>
    │ │ │ │ +
    159 void orthoComp(const FieldVector<K,3>& evec0, FieldVector<K,3>& u, FieldVector<K,3>& v) {
    │ │ │ │ +
    160 using std::abs;
    │ │ │ │ +
    161 if(abs(evec0[0]) > abs(evec0[1])) {
    │ │ │ │ +
    162 //The component of maximum absolute value is either evec0[0] or evec0[2].
    │ │ │ │ +
    163 FieldVector<K,2> temp = {evec0[0], evec0[2]};
    │ │ │ │ +
    164 auto L = 1.0 / temp.two_norm();
    │ │ │ │ +
    165 u = L * FieldVector<K,3>({-evec0[2], 0.0, evec0[0]});
    │ │ │ │ +
    166 }
    │ │ │ │ +
    167 else {
    │ │ │ │ +
    168 //The component of maximum absolute value is either evec0[1] or evec0[2].
    │ │ │ │ +
    169 FieldVector<K,2> temp = {evec0[1], evec0[2]};
    │ │ │ │ +
    170 auto L = 1.0 / temp.two_norm();
    │ │ │ │ +
    171 u = L * FieldVector<K,3>({0.0, evec0[2], -evec0[1]});
    │ │ │ │ +
    172 }
    │ │ │ │ +
    173 v = crossProduct(evec0, u);
    │ │ │ │ +
    174 }
    │ │ │ │ +
    175
    │ │ │ │ +
    176 //see https://www.geometrictools.com/Documentation/RobustEigenSymmetric3x3.pdf
    │ │ │ │ +
    177 template<typename K>
    │ │ │ │ +
    178 void eig0(const FieldMatrix<K,3,3>& matrix, K eval0, FieldVector<K,3>& evec0) {
    │ │ │ │ +
    179 /* Compute a unit-length eigenvector for eigenvalue[i0]. The
    │ │ │ │ +
    180 matrix is rank 2, so two of the rows are linearly independent.
    │ │ │ │ +
    181 For a robust computation of the eigenvector, select the two
    │ │ │ │ +
    182 rows whose cross product has largest length of all pairs of
    │ │ │ │ +
    183 rows. */
    │ │ │ │ +
    184 using Vector = FieldVector<K,3>;
    │ │ │ │ +
    185 Vector row0 = {matrix[0][0]-eval0, matrix[0][1], matrix[0][2]};
    │ │ │ │ +
    186 Vector row1 = {matrix[1][0], matrix[1][1]-eval0, matrix[1][2]};
    │ │ │ │ +
    187 Vector row2 = {matrix[2][0], matrix[2][1], matrix[2][2]-eval0};
    │ │ │ │
    188
    │ │ │ │ -
    196 const KeyVector& getValueKeys() const;
    │ │ │ │ -
    197
    │ │ │ │ -
    198
    │ │ │ │ -
    206 const KeyVector& getSubKeys() const;
    │ │ │ │ -
    207
    │ │ │ │ -
    208 protected:
    │ │ │ │ -
    209
    │ │ │ │ -
    210 static const ParameterTree empty_;
    │ │ │ │ -
    211
    │ │ │ │ -
    212 std::string prefix_;
    │ │ │ │ -
    213
    │ │ │ │ - │ │ │ │ - │ │ │ │ -
    216
    │ │ │ │ -
    217 std::map<std::string, std::string> values_;
    │ │ │ │ -
    218 std::map<std::string, ParameterTree> subs_;
    │ │ │ │ -
    219
    │ │ │ │ -
    220 static std::string ltrim(const std::string& s);
    │ │ │ │ -
    221 static std::string rtrim(const std::string& s);
    │ │ │ │ -
    222 static std::vector<std::string> split(const std::string & s);
    │ │ │ │ -
    223
    │ │ │ │ -
    224 // parse into a fixed-size range of iterators
    │ │ │ │ -
    225 template<class Iterator>
    │ │ │ │ -
    │ │ │ │ -
    226 static void parseRange(const std::string &str,
    │ │ │ │ -
    227 Iterator it, const Iterator &end)
    │ │ │ │ -
    228 {
    │ │ │ │ -
    229 typedef typename std::iterator_traits<Iterator>::value_type Value;
    │ │ │ │ -
    230 std::istringstream s(str);
    │ │ │ │ -
    231 // make sure we are in locale "C"
    │ │ │ │ -
    232 s.imbue(std::locale::classic());
    │ │ │ │ -
    233 std::size_t n = 0;
    │ │ │ │ -
    234 for(; it != end; ++it, ++n) {
    │ │ │ │ -
    235 s >> *it;
    │ │ │ │ -
    236 if(!s)
    │ │ │ │ -
    237 DUNE_THROW(RangeError, "as a range of items of type "
    │ │ │ │ -
    238 << className<Value>()
    │ │ │ │ -
    239 << " (" << n << " items were extracted successfully)");
    │ │ │ │ -
    240 }
    │ │ │ │ -
    241 Value dummy;
    │ │ │ │ -
    242 s >> dummy;
    │ │ │ │ -
    243 // now extraction should have failed, and eof should be set
    │ │ │ │ -
    244 if(not s.fail() or not s.eof())
    │ │ │ │ -
    245 DUNE_THROW(RangeError, "as a range of "
    │ │ │ │ -
    246 << n << " items of type "
    │ │ │ │ -
    247 << className<Value>() << " (more items than the range can hold)");
    │ │ │ │ -
    248 }
    │ │ │ │ -
    │ │ │ │ -
    249 };
    │ │ │ │ -
    │ │ │ │ -
    250
    │ │ │ │ -
    251 template<typename T>
    │ │ │ │ -
    252 struct ParameterTree::Parser {
    │ │ │ │ -
    253 static T parse(const std::string& str) {
    │ │ │ │ -
    254 T val;
    │ │ │ │ -
    255 std::istringstream s(str);
    │ │ │ │ -
    256 // make sure we are in locale "C"
    │ │ │ │ -
    257 s.imbue(std::locale::classic());
    │ │ │ │ -
    258 s >> val;
    │ │ │ │ -
    259 if(!s)
    │ │ │ │ -
    260 DUNE_THROW(RangeError, " as a " << className<T>());
    │ │ │ │ -
    261 char dummy;
    │ │ │ │ -
    262 s >> dummy;
    │ │ │ │ -
    263 // now extraction should have failed, and eof should be set
    │ │ │ │ -
    264 if ((! s.fail()) || (! s.eof()))
    │ │ │ │ -
    265 DUNE_THROW(RangeError, " as a " << className<T>());
    │ │ │ │ -
    266 return val;
    │ │ │ │ -
    267 }
    │ │ │ │ -
    268 };
    │ │ │ │ -
    269
    │ │ │ │ -
    270 // "How do I convert a string into a wstring in C++?" "Why, that very simple
    │ │ │ │ -
    271 // son. You just need a these hundred lines of code."
    │ │ │ │ -
    272 // Instead im going to restrict myself to string with charT=char here.
    │ │ │ │ -
    273 template<typename traits, typename Allocator>
    │ │ │ │ -
    │ │ │ │ -
    274 struct ParameterTree::Parser<std::basic_string<char, traits, Allocator> > {
    │ │ │ │ -
    275 static std::basic_string<char, traits, Allocator>
    │ │ │ │ -
    │ │ │ │ -
    276 parse(const std::string& str) {
    │ │ │ │ -
    277 std::string trimmed = ltrim(rtrim(str));
    │ │ │ │ -
    278 return std::basic_string<char, traits, Allocator>(trimmed.begin(),
    │ │ │ │ -
    279 trimmed.end());
    │ │ │ │ -
    280 }
    │ │ │ │ -
    │ │ │ │ -
    281 };
    │ │ │ │ -
    │ │ │ │ -
    282
    │ │ │ │ -
    283 template<>
    │ │ │ │ -
    │ │ │ │ -
    284 struct ParameterTree::Parser< bool > {
    │ │ │ │ -
    │ │ │ │ -
    285 struct ToLower {
    │ │ │ │ -
    │ │ │ │ -
    286 char operator()(char c)
    │ │ │ │ -
    287 {
    │ │ │ │ -
    288 return std::tolower(c, std::locale::classic());
    │ │ │ │ -
    289 }
    │ │ │ │ -
    │ │ │ │ -
    290 };
    │ │ │ │ -
    │ │ │ │ -
    291
    │ │ │ │ -
    292 static bool
    │ │ │ │ -
    │ │ │ │ -
    293 parse(const std::string& str) {
    │ │ │ │ -
    294 std::string ret = str;
    │ │ │ │ -
    295
    │ │ │ │ -
    296 std::transform(ret.begin(), ret.end(), ret.begin(), ToLower());
    │ │ │ │ -
    297
    │ │ │ │ -
    298 if (ret == "yes" || ret == "true")
    │ │ │ │ -
    299 return true;
    │ │ │ │ -
    300
    │ │ │ │ -
    301 if (ret == "no" || ret == "false")
    │ │ │ │ -
    302 return false;
    │ │ │ │ -
    303
    │ │ │ │ -
    304 return (Parser<int>::parse(ret) != 0);
    │ │ │ │ -
    305 }
    │ │ │ │ -
    │ │ │ │ -
    306 };
    │ │ │ │ -
    │ │ │ │ -
    307
    │ │ │ │ -
    308 template<typename T, int n>
    │ │ │ │ -
    │ │ │ │ -
    309 struct ParameterTree::Parser<FieldVector<T, n> > {
    │ │ │ │ -
    310 static FieldVector<T, n>
    │ │ │ │ -
    │ │ │ │ -
    311 parse(const std::string& str) {
    │ │ │ │ - │ │ │ │ -
    313 parseRange(str, val.begin(), val.end());
    │ │ │ │ -
    314 return val;
    │ │ │ │ -
    315 }
    │ │ │ │ -
    │ │ │ │ -
    316 };
    │ │ │ │ -
    │ │ │ │ -
    317
    │ │ │ │ -
    318 template<typename T, std::size_t n>
    │ │ │ │ -
    │ │ │ │ -
    319 struct ParameterTree::Parser<std::array<T, n> > {
    │ │ │ │ -
    320 static std::array<T, n>
    │ │ │ │ -
    │ │ │ │ -
    321 parse(const std::string& str) {
    │ │ │ │ -
    322 std::array<T, n> val;
    │ │ │ │ -
    323 parseRange(str, val.begin(), val.end());
    │ │ │ │ -
    324 return val;
    │ │ │ │ -
    325 }
    │ │ │ │ -
    │ │ │ │ -
    326 };
    │ │ │ │ -
    │ │ │ │ -
    327
    │ │ │ │ -
    328 template<std::size_t n>
    │ │ │ │ -
    │ │ │ │ -
    329 struct ParameterTree::Parser<std::bitset<n> > {
    │ │ │ │ -
    330 static std::bitset<n>
    │ │ │ │ -
    │ │ │ │ -
    331 parse(const std::string& str) {
    │ │ │ │ -
    332 std::bitset<n> val;
    │ │ │ │ -
    333 std::vector<std::string> sub = split(str);
    │ │ │ │ -
    334 if (sub.size() != n)
    │ │ │ │ -
    335 DUNE_THROW(RangeError, "as a bitset<" << n << "> "
    │ │ │ │ -
    336 << "because of unmatching size " << sub.size());
    │ │ │ │ -
    337 for (std::size_t i=0; i<n; ++i) {
    │ │ │ │ -
    338 val[i] = ParameterTree::Parser<bool>::parse(sub[i]);
    │ │ │ │ -
    339 }
    │ │ │ │ -
    340 return val;
    │ │ │ │ -
    341 }
    │ │ │ │ -
    │ │ │ │ -
    342 };
    │ │ │ │ -
    │ │ │ │ -
    343
    │ │ │ │ -
    344 template<typename T, typename A>
    │ │ │ │ -
    │ │ │ │ -
    345 struct ParameterTree::Parser<std::vector<T, A> > {
    │ │ │ │ -
    346 static std::vector<T, A>
    │ │ │ │ -
    │ │ │ │ -
    347 parse(const std::string& str) {
    │ │ │ │ -
    348 std::vector<std::string> sub = split(str);
    │ │ │ │ -
    349 std::vector<T, A> vec;
    │ │ │ │ -
    350 for (unsigned int i=0; i<sub.size(); ++i) {
    │ │ │ │ -
    351 T val = ParameterTree::Parser<T>::parse(sub[i]);
    │ │ │ │ -
    352 vec.push_back(val);
    │ │ │ │ -
    353 }
    │ │ │ │ -
    354 return vec;
    │ │ │ │ -
    355 }
    │ │ │ │ -
    │ │ │ │ -
    356 };
    │ │ │ │ -
    │ │ │ │ +
    189 Vector r0xr1 = crossProduct(row0, row1);
    │ │ │ │ +
    190 Vector r0xr2 = crossProduct(row0, row2);
    │ │ │ │ +
    191 Vector r1xr2 = crossProduct(row1, row2);
    │ │ │ │ +
    192 auto d0 = r0xr1.two_norm();
    │ │ │ │ +
    193 auto d1 = r0xr2.two_norm();
    │ │ │ │ +
    194 auto d2 = r1xr2.two_norm();
    │ │ │ │ +
    195
    │ │ │ │ +
    196 auto dmax = d0 ;
    │ │ │ │ +
    197 int imax = 0;
    │ │ │ │ +
    198 if(d1>dmax) {
    │ │ │ │ +
    199 dmax = d1;
    │ │ │ │ +
    200 imax = 1;
    │ │ │ │ +
    201 }
    │ │ │ │ +
    202 if(d2>dmax)
    │ │ │ │ +
    203 imax = 2;
    │ │ │ │ +
    204
    │ │ │ │ +
    205 if(imax == 0)
    │ │ │ │ +
    206 evec0 = r0xr1 / d0;
    │ │ │ │ +
    207 else if(imax == 1)
    │ │ │ │ +
    208 evec0 = r0xr2 / d1;
    │ │ │ │ +
    209 else
    │ │ │ │ +
    210 evec0 = r1xr2 / d2;
    │ │ │ │ +
    211 }
    │ │ │ │ +
    212
    │ │ │ │ +
    213 //see https://www.geometrictools.com/Documentation/RobustEigenSymmetric3x3.pdf
    │ │ │ │ +
    214 template<typename K>
    │ │ │ │ +
    215 void eig1(const FieldMatrix<K,3,3>& matrix, const FieldVector<K,3>& evec0, FieldVector<K,3>& evec1, K eval1) {
    │ │ │ │ +
    216 using Vector = FieldVector<K,3>;
    │ │ │ │ +
    217
    │ │ │ │ +
    218 //Robustly compute a right-handed orthonormal set {u, v, evec0}.
    │ │ │ │ +
    219 Vector u,v;
    │ │ │ │ +
    220 orthoComp(evec0, u, v);
    │ │ │ │ +
    221
    │ │ │ │ +
    222 /* Let e be eval1 and let E be a corresponding eigenvector which
    │ │ │ │ +
    223 is a solution to the linear system (A - e*I)*E = 0. The matrix
    │ │ │ │ +
    224 (A - e*I) is 3x3, not invertible (so infinitely many
    │ │ │ │ +
    225 solutions), and has rank 2 when eval1 and eval are different.
    │ │ │ │ +
    226 It has rank 1 when eval1 and eval2 are equal. Numerically, it
    │ │ │ │ +
    227 is difficult to compute robustly the rank of a matrix. Instead,
    │ │ │ │ +
    228 the 3x3 linear system is reduced to a 2x2 system as follows.
    │ │ │ │ +
    229 Define the 3x2 matrix J = [u,v] whose columns are the u and v
    │ │ │ │ +
    230 computed previously. Define the 2x1 vector X = J*E. The 2x2
    │ │ │ │ +
    231 system is 0 = M * X = (J^T * (A - e*I) * J) * X where J^T is
    │ │ │ │ +
    232 the transpose of J and M = J^T * (A - e*I) * J is a 2x2 matrix.
    │ │ │ │ +
    233 The system may be written as
    │ │ │ │ +
    234 +- -++- -+ +- -+
    │ │ │ │ +
    235 | U^T*A*U - e U^T*A*V || x0 | = e * | x0 |
    │ │ │ │ +
    236 | V^T*A*U V^T*A*V - e || x1 | | x1 |
    │ │ │ │ +
    237 +- -++ -+ +- -+
    │ │ │ │ +
    238 where X has row entries x0 and x1. */
    │ │ │ │ +
    239
    │ │ │ │ +
    240 Vector Au, Av;
    │ │ │ │ +
    241 matrix.mv(u, Au);
    │ │ │ │ +
    242 matrix.mv(v, Av);
    │ │ │ │ +
    243
    │ │ │ │ +
    244 auto m00 = u.dot(Au) - eval1;
    │ │ │ │ +
    245 auto m01 = u.dot(Av);
    │ │ │ │ +
    246 auto m11 = v.dot(Av) - eval1;
    │ │ │ │ +
    247
    │ │ │ │ +
    248 /* For robustness, choose the largest-length row of M to compute
    │ │ │ │ +
    249 the eigenvector. The 2-tuple of coefficients of U and V in the
    │ │ │ │ +
    250 assignments to eigenvector[1] lies on a circle, and U and V are
    │ │ │ │ +
    251 unit length and perpendicular, so eigenvector[1] is unit length
    │ │ │ │ +
    252 (within numerical tolerance). */
    │ │ │ │ +
    253 using std::abs, std::sqrt, std::max;
    │ │ │ │ +
    254 auto absM00 = abs(m00);
    │ │ │ │ +
    255 auto absM01 = abs(m01);
    │ │ │ │ +
    256 auto absM11 = abs(m11);
    │ │ │ │ +
    257 if(absM00 >= absM11) {
    │ │ │ │ +
    258 auto maxAbsComp = max(absM00, absM01);
    │ │ │ │ +
    259 if(maxAbsComp > 0.0) {
    │ │ │ │ +
    260 if(absM00 >= absM01) {
    │ │ │ │ +
    261 m01 /= m00;
    │ │ │ │ +
    262 m00 = 1.0 / sqrt(1.0 + m01*m01);
    │ │ │ │ +
    263 m01 *= m00;
    │ │ │ │ +
    264 }
    │ │ │ │ +
    265 else {
    │ │ │ │ +
    266 m00 /= m01;
    │ │ │ │ +
    267 m01 = 1.0 / sqrt(1.0 + m00*m00);
    │ │ │ │ +
    268 m00 *= m01;
    │ │ │ │ +
    269 }
    │ │ │ │ +
    270 evec1 = m01*u - m00*v;
    │ │ │ │ +
    271 }
    │ │ │ │ +
    272 else
    │ │ │ │ +
    273 evec1 = u;
    │ │ │ │ +
    274 }
    │ │ │ │ +
    275 else {
    │ │ │ │ +
    276 auto maxAbsComp = max(absM11, absM01);
    │ │ │ │ +
    277 if(maxAbsComp > 0.0) {
    │ │ │ │ +
    278 if(absM11 >= absM01) {
    │ │ │ │ +
    279 m01 /= m11;
    │ │ │ │ +
    280 m11 = 1.0 / sqrt(1.0 + m01*m01);
    │ │ │ │ +
    281 m01 *= m11;
    │ │ │ │ +
    282 }
    │ │ │ │ +
    283 else {
    │ │ │ │ +
    284 m11 /= m01;
    │ │ │ │ +
    285 m01 = 1.0 / sqrt(1.0 + m11*m11);
    │ │ │ │ +
    286 m11 *= m01;
    │ │ │ │ +
    287 }
    │ │ │ │ +
    288 evec1 = m11*u - m01*v;
    │ │ │ │ +
    289 }
    │ │ │ │ +
    290 else
    │ │ │ │ +
    291 evec1 = u;
    │ │ │ │ +
    292 }
    │ │ │ │ +
    293 }
    │ │ │ │ +
    294
    │ │ │ │ +
    295 // 1d specialization
    │ │ │ │ +
    296 template<Jobs Tag, typename K>
    │ │ │ │ +
    297 static void eigenValuesVectorsImpl(const FieldMatrix<K, 1, 1>& matrix,
    │ │ │ │ +
    298 FieldVector<K, 1>& eigenValues,
    │ │ │ │ +
    299 FieldMatrix<K, 1, 1>& eigenVectors)
    │ │ │ │ +
    300 {
    │ │ │ │ +
    301 eigenValues[0] = matrix[0][0];
    │ │ │ │ +
    302 if constexpr(Tag==EigenvaluesEigenvectors)
    │ │ │ │ +
    303 eigenVectors[0] = {1.0};
    │ │ │ │ +
    304 }
    │ │ │ │ +
    305
    │ │ │ │ +
    306
    │ │ │ │ +
    307 // 2d specialization
    │ │ │ │ +
    308 template <Jobs Tag, typename K>
    │ │ │ │ +
    309 static void eigenValuesVectorsImpl(const FieldMatrix<K, 2, 2>& matrix,
    │ │ │ │ +
    310 FieldVector<K, 2>& eigenValues,
    │ │ │ │ +
    311 FieldMatrix<K, 2, 2>& eigenVectors)
    │ │ │ │ +
    312 {
    │ │ │ │ +
    313 // Compute eigen values
    │ │ │ │ +
    314 Impl::eigenValues2dImpl(matrix, eigenValues);
    │ │ │ │ +
    315
    │ │ │ │ +
    316 // Compute eigenvectors by exploiting the Cayley–Hamilton theorem.
    │ │ │ │ +
    317 // If λ_1, λ_2 are the eigenvalues, then (A - λ_1I )(A - λ_2I ) = (A - λ_2I )(A - λ_1I ) = 0,
    │ │ │ │ +
    318 // so the columns of (A - λ_2I ) are annihilated by (A - λ_1I ) and vice versa.
    │ │ │ │ +
    319 // Assuming neither matrix is zero, the columns of each must include eigenvectors
    │ │ │ │ +
    320 // for the other eigenvalue. (If either matrix is zero, then A is a multiple of the
    │ │ │ │ +
    321 // identity and any non-zero vector is an eigenvector.)
    │ │ │ │ +
    322 // From: https://en.wikipedia.org/wiki/Eigenvalue_algorithm#2x2_matrices
    │ │ │ │ +
    323 if constexpr(Tag==EigenvaluesEigenvectors) {
    │ │ │ │ +
    324
    │ │ │ │ +
    325 // Special casing for multiples of the identity
    │ │ │ │ +
    326 FieldMatrix<K,2,2> temp = matrix;
    │ │ │ │ +
    327 temp[0][0] -= eigenValues[0];
    │ │ │ │ +
    328 temp[1][1] -= eigenValues[0];
    │ │ │ │ +
    329 if(temp.infinity_norm() <= 1e-14) {
    │ │ │ │ +
    330 eigenVectors[0] = {1.0, 0.0};
    │ │ │ │ +
    331 eigenVectors[1] = {0.0, 1.0};
    │ │ │ │ +
    332 }
    │ │ │ │ +
    333 else {
    │ │ │ │ +
    334 // The columns of A - λ_2I are eigenvectors for λ_1, or zero.
    │ │ │ │ +
    335 // Take the column with the larger norm to avoid zero columns.
    │ │ │ │ +
    336 FieldVector<K,2> ev0 = {matrix[0][0]-eigenValues[1], matrix[1][0]};
    │ │ │ │ +
    337 FieldVector<K,2> ev1 = {matrix[0][1], matrix[1][1]-eigenValues[1]};
    │ │ │ │ +
    338 eigenVectors[0] = (ev0.two_norm2() >= ev1.two_norm2()) ? ev0/ev0.two_norm() : ev1/ev1.two_norm();
    │ │ │ │ +
    339
    │ │ │ │ +
    340 // The columns of A - λ_1I are eigenvectors for λ_2, or zero.
    │ │ │ │ +
    341 // Take the column with the larger norm to avoid zero columns.
    │ │ │ │ +
    342 ev0 = {matrix[0][0]-eigenValues[0], matrix[1][0]};
    │ │ │ │ +
    343 ev1 = {matrix[0][1], matrix[1][1]-eigenValues[0]};
    │ │ │ │ +
    344 eigenVectors[1] = (ev0.two_norm2() >= ev1.two_norm2()) ? ev0/ev0.two_norm() : ev1/ev1.two_norm();
    │ │ │ │ +
    345 }
    │ │ │ │ +
    346 }
    │ │ │ │ +
    347 }
    │ │ │ │ +
    348
    │ │ │ │ +
    349 // 3d specialization
    │ │ │ │ +
    350 template <Jobs Tag, typename K>
    │ │ │ │ +
    351 static void eigenValuesVectorsImpl(const FieldMatrix<K, 3, 3>& matrix,
    │ │ │ │ +
    352 FieldVector<K, 3>& eigenValues,
    │ │ │ │ +
    353 FieldMatrix<K, 3, 3>& eigenVectors)
    │ │ │ │ +
    354 {
    │ │ │ │ +
    355 using Vector = FieldVector<K,3>;
    │ │ │ │ +
    356 using Matrix = FieldMatrix<K,3,3>;
    │ │ │ │
    357
    │ │ │ │ -
    358} // end namespace Dune
    │ │ │ │ -
    359
    │ │ │ │ -
    360#endif // DUNE_PARAMETERTREE_HH
    │ │ │ │ -
    A free function to provide the demangled class name of a given object or type as a string.
    │ │ │ │ -
    A few common exception classes.
    │ │ │ │ -
    Implements a vector constructed from a given type representing a field and a compile-time given size.
    │ │ │ │ -
    const char * what() const noexcept override
    output internal message buffer
    Definition exceptions.cc:37
    │ │ │ │ +
    358 //compute eigenvalues
    │ │ │ │ +
    359 /* Precondition the matrix by factoring out the maximum absolute
    │ │ │ │ +
    360 value of the components. This guards against floating-point
    │ │ │ │ +
    361 overflow when computing the eigenvalues.*/
    │ │ │ │ +
    362 using std::isnormal;
    │ │ │ │ +
    363 K maxAbsElement = (isnormal(matrix.infinity_norm())) ? matrix.infinity_norm() : K(1.0);
    │ │ │ │ +
    364 Matrix scaledMatrix = matrix / maxAbsElement;
    │ │ │ │ +
    365 K r = Impl::eigenValues3dImpl(scaledMatrix, eigenValues);
    │ │ │ │ +
    366
    │ │ │ │ +
    367 if constexpr(Tag==EigenvaluesEigenvectors) {
    │ │ │ │ +
    368 K offDiagNorm = Vector{scaledMatrix[0][1],scaledMatrix[0][2],scaledMatrix[1][2]}.two_norm2();
    │ │ │ │ +
    369 if (offDiagNorm <= std::numeric_limits<K>::epsilon())
    │ │ │ │ +
    370 {
    │ │ │ │ +
    371 eigenValues = {scaledMatrix[0][0], scaledMatrix[1][1], scaledMatrix[2][2]};
    │ │ │ │ +
    372 eigenVectors = {{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}};
    │ │ │ │ +
    373
    │ │ │ │ +
    374 // Use bubble sort to jointly sort eigenvalues and eigenvectors
    │ │ │ │ +
    375 // such that eigenvalues are ascending
    │ │ │ │ +
    376 if (eigenValues[0] > eigenValues[1])
    │ │ │ │ +
    377 {
    │ │ │ │ +
    378 std::swap(eigenValues[0], eigenValues[1]);
    │ │ │ │ +
    379 std::swap(eigenVectors[0], eigenVectors[1]);
    │ │ │ │ +
    380 }
    │ │ │ │ +
    381 if (eigenValues[1] > eigenValues[2])
    │ │ │ │ +
    382 {
    │ │ │ │ +
    383 std::swap(eigenValues[1], eigenValues[2]);
    │ │ │ │ +
    384 std::swap(eigenVectors[1], eigenVectors[2]);
    │ │ │ │ +
    385 }
    │ │ │ │ +
    386 if (eigenValues[0] > eigenValues[1])
    │ │ │ │ +
    387 {
    │ │ │ │ +
    388 std::swap(eigenValues[0], eigenValues[1]);
    │ │ │ │ +
    389 std::swap(eigenVectors[0], eigenVectors[1]);
    │ │ │ │ +
    390 }
    │ │ │ │ +
    391 }
    │ │ │ │ +
    392 else {
    │ │ │ │ +
    393 /*Compute the eigenvectors so that the set
    │ │ │ │ +
    394 [evec[0], evec[1], evec[2]] is right handed and
    │ │ │ │ +
    395 orthonormal. */
    │ │ │ │ +
    396
    │ │ │ │ +
    397 Matrix evec(0.0);
    │ │ │ │ +
    398 Vector eval(eigenValues);
    │ │ │ │ +
    399 if(r >= 0) {
    │ │ │ │ +
    400 Impl::eig0(scaledMatrix, eval[2], evec[2]);
    │ │ │ │ +
    401 Impl::eig1(scaledMatrix, evec[2], evec[1], eval[1]);
    │ │ │ │ +
    402 evec[0] = Impl::crossProduct(evec[1], evec[2]);
    │ │ │ │ +
    403 }
    │ │ │ │ +
    404 else {
    │ │ │ │ +
    405 Impl::eig0(scaledMatrix, eval[0], evec[0]);
    │ │ │ │ +
    406 Impl::eig1(scaledMatrix, evec[0], evec[1], eval[1]);
    │ │ │ │ +
    407 evec[2] = Impl::crossProduct(evec[0], evec[1]);
    │ │ │ │ +
    408 }
    │ │ │ │ +
    409 //sort eval/evec-pairs in ascending order
    │ │ │ │ +
    410 using EVPair = std::pair<K, Vector>;
    │ │ │ │ +
    411 std::vector<EVPair> pairs;
    │ │ │ │ +
    412 for(std::size_t i=0; i<=2; ++i)
    │ │ │ │ +
    413 pairs.push_back(EVPair(eval[i], evec[i]));
    │ │ │ │ +
    414 auto comp = [](EVPair x, EVPair y){ return x.first < y.first; };
    │ │ │ │ +
    415 std::sort(pairs.begin(), pairs.end(), comp);
    │ │ │ │ +
    416 for(std::size_t i=0; i<=2; ++i){
    │ │ │ │ +
    417 eigenValues[i] = pairs[i].first;
    │ │ │ │ +
    418 eigenVectors[i] = pairs[i].second;
    │ │ │ │ +
    419 }
    │ │ │ │ +
    420 }
    │ │ │ │ +
    421 }
    │ │ │ │ +
    422 //The preconditioning scaled the matrix, which scales the eigenvalues. Revert the scaling.
    │ │ │ │ +
    423 eigenValues *= maxAbsElement;
    │ │ │ │ +
    424 }
    │ │ │ │ +
    425
    │ │ │ │ +
    426 // forwarding to LAPACK with corresponding tag
    │ │ │ │ +
    427 template <Jobs Tag, int dim, typename K>
    │ │ │ │ +
    428 static void eigenValuesVectorsLapackImpl(const FieldMatrix<K, dim, dim>& matrix,
    │ │ │ │ +
    429 FieldVector<K, dim>& eigenValues,
    │ │ │ │ +
    430 FieldMatrix<K, dim, dim>& eigenVectors)
    │ │ │ │ +
    431 {
    │ │ │ │ +
    432 {
    │ │ │ │ +
    433#if HAVE_LAPACK
    │ │ │ │ +
    434 /*Lapack uses a proprietary tag to determine whether both eigenvalues and
    │ │ │ │ +
    435 -vectors ('v') or only eigenvalues ('n') should be calculated */
    │ │ │ │ +
    436 const char jobz = "nv"[Tag];
    │ │ │ │ +
    437
    │ │ │ │ +
    438 const long int N = dim ;
    │ │ │ │ +
    439 const char uplo = 'u'; // use upper triangular matrix
    │ │ │ │ +
    440
    │ │ │ │ +
    441 // length of matrix vector, LWORK >= max(1,3*N-1)
    │ │ │ │ +
    442 const long int lwork = 3*N -1 ;
    │ │ │ │ +
    443
    │ │ │ │ +
    444 constexpr bool isKLapackType = std::is_same_v<K,double> || std::is_same_v<K,float>;
    │ │ │ │ +
    445 using LapackNumType = std::conditional_t<isKLapackType, K, double>;
    │ │ │ │ +
    446
    │ │ │ │ +
    447 // matrix to put into dsyev
    │ │ │ │ +
    448 LapackNumType matrixVector[dim * dim];
    │ │ │ │ +
    449
    │ │ │ │ +
    450 // copy matrix
    │ │ │ │ +
    451 int row = 0;
    │ │ │ │ +
    452 for(int i=0; i<dim; ++i)
    │ │ │ │ +
    453 {
    │ │ │ │ +
    454 for(int j=0; j<dim; ++j, ++row)
    │ │ │ │ +
    455 {
    │ │ │ │ +
    456 matrixVector[ row ] = matrix[ i ][ j ];
    │ │ │ │ +
    457 }
    │ │ │ │ +
    458 }
    │ │ │ │ +
    459
    │ │ │ │ +
    460 // working memory
    │ │ │ │ +
    461 LapackNumType workSpace[lwork];
    │ │ │ │ +
    462
    │ │ │ │ +
    463 // return value information
    │ │ │ │ +
    464 long int info = 0;
    │ │ │ │ +
    465 LapackNumType* ev;
    │ │ │ │ +
    466 if constexpr (isKLapackType){
    │ │ │ │ +
    467 ev = &eigenValues[0];
    │ │ │ │ +
    468 }else{
    │ │ │ │ +
    469 ev = new LapackNumType[dim];
    │ │ │ │ +
    470 }
    │ │ │ │ +
    471
    │ │ │ │ +
    472 // call LAPACK routine (see fmatrixev.cc)
    │ │ │ │ +
    473 eigenValuesLapackCall(&jobz, &uplo, &N, &matrixVector[0], &N,
    │ │ │ │ +
    474 ev, &workSpace[0], &lwork, &info);
    │ │ │ │ +
    475
    │ │ │ │ +
    476 if constexpr (!isKLapackType){
    │ │ │ │ +
    477 for(size_t i=0;i<dim;++i)
    │ │ │ │ +
    478 eigenValues[i] = ev[i];
    │ │ │ │ +
    479 delete[] ev;
    │ │ │ │ +
    480 }
    │ │ │ │ +
    481
    │ │ │ │ +
    482 // restore eigenvectors matrix
    │ │ │ │ +
    483 if (Tag==Jobs::EigenvaluesEigenvectors){
    │ │ │ │ +
    484 row = 0;
    │ │ │ │ +
    485 for(int i=0; i<dim; ++i)
    │ │ │ │ +
    486 {
    │ │ │ │ +
    487 for(int j=0; j<dim; ++j, ++row)
    │ │ │ │ +
    488 {
    │ │ │ │ +
    489 eigenVectors[ i ][ j ] = matrixVector[ row ];
    │ │ │ │ +
    490 }
    │ │ │ │ +
    491 }
    │ │ │ │ +
    492 }
    │ │ │ │ +
    493
    │ │ │ │ +
    494 if( info != 0 )
    │ │ │ │ +
    495 {
    │ │ │ │ +
    496 std::cerr << "For matrix " << matrix << " eigenvalue calculation failed! " << std::endl;
    │ │ │ │ +
    497 DUNE_THROW(InvalidStateException,"eigenValues: Eigenvalue calculation failed!");
    │ │ │ │ +
    498 }
    │ │ │ │ +
    499#else
    │ │ │ │ +
    500 DUNE_THROW(NotImplemented,"LAPACK not found!");
    │ │ │ │ +
    501#endif
    │ │ │ │ +
    502 }
    │ │ │ │ +
    503 }
    │ │ │ │ +
    504
    │ │ │ │ +
    505 // generic specialization
    │ │ │ │ +
    506 template <Jobs Tag, int dim, typename K>
    │ │ │ │ +
    507 static void eigenValuesVectorsImpl(const FieldMatrix<K, dim, dim>& matrix,
    │ │ │ │ +
    508 FieldVector<K, dim>& eigenValues,
    │ │ │ │ +
    509 FieldMatrix<K, dim, dim>& eigenVectors)
    │ │ │ │ +
    510 {
    │ │ │ │ +
    511 eigenValuesVectorsLapackImpl<Tag>(matrix,eigenValues,eigenVectors);
    │ │ │ │ +
    512 }
    │ │ │ │ +
    513 } //namespace Impl
    │ │ │ │ +
    514
    │ │ │ │ +
    522 template <int dim, typename K>
    │ │ │ │ +
    │ │ │ │ +
    523 static void eigenValues(const FieldMatrix<K, dim, dim>& matrix,
    │ │ │ │ + │ │ │ │ +
    525 {
    │ │ │ │ + │ │ │ │ +
    527 Impl::eigenValuesVectorsImpl<Impl::Jobs::OnlyEigenvalues>(matrix, eigenValues, dummy);
    │ │ │ │ +
    528 }
    │ │ │ │ +
    │ │ │ │ +
    529
    │ │ │ │ +
    538 template <int dim, typename K>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ +
    541 FieldMatrix<K, dim, dim>& eigenVectors)
    │ │ │ │ +
    542 {
    │ │ │ │ +
    543 Impl::eigenValuesVectorsImpl<Impl::Jobs::EigenvaluesEigenvectors>(matrix, eigenValues, eigenVectors);
    │ │ │ │ +
    544 }
    │ │ │ │ +
    │ │ │ │ +
    545
    │ │ │ │ +
    553 template <int dim, typename K>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ +
    556 {
    │ │ │ │ + │ │ │ │ +
    558 Impl::eigenValuesVectorsLapackImpl<Impl::Jobs::EigenvaluesEigenvectors>(matrix, eigenValues, dummy);
    │ │ │ │ +
    559 }
    │ │ │ │ +
    │ │ │ │ +
    560
    │ │ │ │ +
    569 template <int dim, typename K>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ +
    572 FieldMatrix<K, dim, dim>& eigenVectors)
    │ │ │ │ +
    573 {
    │ │ │ │ +
    574 Impl::eigenValuesVectorsLapackImpl<Impl::Jobs::EigenvaluesEigenvectors>(matrix, eigenValues, eigenVectors);
    │ │ │ │ +
    575 }
    │ │ │ │ +
    │ │ │ │ +
    576
    │ │ │ │ +
    584 template <int dim, typename K, class C>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ +
    587 {
    │ │ │ │ +
    588#if HAVE_LAPACK
    │ │ │ │ +
    589 {
    │ │ │ │ +
    590 const long int N = dim ;
    │ │ │ │ +
    591 const char jobvl = 'n';
    │ │ │ │ +
    592 const char jobvr = 'n';
    │ │ │ │ +
    593
    │ │ │ │ +
    594 constexpr bool isKLapackType = std::is_same_v<K,double> || std::is_same_v<K,float>;
    │ │ │ │ +
    595 using LapackNumType = std::conditional_t<isKLapackType, K, double>;
    │ │ │ │ +
    596
    │ │ │ │ +
    597 // matrix to put into dgeev
    │ │ │ │ +
    598 LapackNumType matrixVector[dim * dim];
    │ │ │ │ +
    599
    │ │ │ │ +
    600 // copy matrix
    │ │ │ │ +
    601 int row = 0;
    │ │ │ │ +
    602 for(int i=0; i<dim; ++i)
    │ │ │ │ +
    603 {
    │ │ │ │ +
    604 for(int j=0; j<dim; ++j, ++row)
    │ │ │ │ +
    605 {
    │ │ │ │ +
    606 matrixVector[ row ] = matrix[ i ][ j ];
    │ │ │ │ +
    607 }
    │ │ │ │ +
    608 }
    │ │ │ │ +
    609
    │ │ │ │ +
    610 // working memory
    │ │ │ │ +
    611 LapackNumType eigenR[dim];
    │ │ │ │ +
    612 LapackNumType eigenI[dim];
    │ │ │ │ +
    613 LapackNumType work[3*dim];
    │ │ │ │ +
    614
    │ │ │ │ +
    615 // return value information
    │ │ │ │ +
    616 long int info = 0;
    │ │ │ │ +
    617 const long int lwork = 3*dim;
    │ │ │ │ +
    618
    │ │ │ │ +
    619 // call LAPACK routine (see fmatrixev_ext.cc)
    │ │ │ │ +
    620 eigenValuesNonsymLapackCall(&jobvl, &jobvr, &N, &matrixVector[0], &N,
    │ │ │ │ +
    621 &eigenR[0], &eigenI[0], nullptr, &N, nullptr, &N, &work[0],
    │ │ │ │ +
    622 &lwork, &info);
    │ │ │ │ +
    623
    │ │ │ │ +
    624 if( info != 0 )
    │ │ │ │ +
    625 {
    │ │ │ │ +
    626 std::cerr << "For matrix " << matrix << " eigenvalue calculation failed! " << std::endl;
    │ │ │ │ +
    627 DUNE_THROW(InvalidStateException,"eigenValues: Eigenvalue calculation failed!");
    │ │ │ │ +
    628 }
    │ │ │ │ +
    629 for (int i=0; i<N; ++i) {
    │ │ │ │ +
    630 eigenValues[i].real = eigenR[i];
    │ │ │ │ +
    631 eigenValues[i].imag = eigenI[i];
    │ │ │ │ +
    632 }
    │ │ │ │ +
    633 }
    │ │ │ │ +
    634#else
    │ │ │ │ +
    635 DUNE_THROW(NotImplemented,"LAPACK not found!");
    │ │ │ │ +
    636#endif
    │ │ │ │ +
    637 }
    │ │ │ │ +
    │ │ │ │ +
    638 } // end namespace FMatrixHelp
    │ │ │ │ +
    639
    │ │ │ │ +
    642} // end namespace Dune
    │ │ │ │ +
    643#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 ...
    │ │ │ │
    #define DUNE_THROW(E, m)
    Definition exceptions.hh:218
    │ │ │ │ -
    STL namespace.
    │ │ │ │
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ +
    auto max(const AlignedNumber< T, align > &a, const AlignedNumber< T, align > &b)
    Definition debugalign.hh:425
    │ │ │ │ +
    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:585
    │ │ │ │ +
    static void eigenValues(const FieldMatrix< K, dim, dim > &matrix, FieldVector< K, dim > &eigenValues)
    calculates the eigenvalues of a symmetric field matrix
    Definition fmatrixev.hh:523
    │ │ │ │ +
    static void eigenValuesLapack(const FieldMatrix< K, dim, dim > &matrix, FieldVector< K, dim > &eigenValues)
    calculates the eigenvalues of a symmetric field matrix
    Definition fmatrixev.hh:554
    │ │ │ │ +
    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:539
    │ │ │ │ +
    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:570
    │ │ │ │ +
    A dense n x m matrix.
    Definition fmatrix.hh:117
    │ │ │ │
    vector space out of a tensor product of fields.
    Definition fvector.hh:95
    │ │ │ │ -
    Iterator begin()
    begin iterator
    Definition densevector.hh:347
    │ │ │ │ -
    Iterator end()
    end iterator
    Definition densevector.hh:353
    │ │ │ │ -
    Default exception class for range errors.
    Definition exceptions.hh:254
    │ │ │ │ -
    Hierarchical structure of string parameters.
    Definition parametertree.hh:37
    │ │ │ │ -
    KeyVector valueKeys_
    Definition parametertree.hh:214
    │ │ │ │ -
    std::map< std::string, ParameterTree > subs_
    Definition parametertree.hh:218
    │ │ │ │ -
    static const ParameterTree empty_
    Definition parametertree.hh:210
    │ │ │ │ -
    static std::string rtrim(const std::string &s)
    Definition parametertree.cc:210
    │ │ │ │ -
    std::string get(const std::string &key, const std::string &defaultValue) const
    get value as string
    Definition parametertree.cc:185
    │ │ │ │ -
    static std::string ltrim(const std::string &s)
    Definition parametertree.cc:201
    │ │ │ │ -
    void report(std::ostream &stream=std::cout, const std::string &prefix="") const
    print distinct substructure to stream
    Definition parametertree.cc:29
    │ │ │ │ -
    std::vector< std::string > KeyVector
    storage for key lists
    Definition parametertree.hh:47
    │ │ │ │ -
    static void parseRange(const std::string &str, Iterator it, const Iterator &end)
    Definition parametertree.hh:226
    │ │ │ │ -
    ParameterTree()
    Create new empty ParameterTree.
    Definition parametertree.cc:24
    │ │ │ │ -
    std::string & operator[](const std::string &key)
    get value reference for key
    Definition parametertree.cc:150
    │ │ │ │ -
    KeyVector subKeys_
    Definition parametertree.hh:215
    │ │ │ │ -
    ParameterTree & sub(const std::string &sub)
    get substructure by name
    Definition parametertree.cc:103
    │ │ │ │ -
    bool hasKey(const std::string &key) const
    test for key
    Definition parametertree.cc:48
    │ │ │ │ -
    const KeyVector & getSubKeys() const
    get substructure keys
    Definition parametertree.cc:240
    │ │ │ │ -
    T get(const std::string &key) const
    Get value.
    Definition parametertree.hh:174
    │ │ │ │ -
    bool hasSub(const std::string &sub) const
    test for substructure
    Definition parametertree.cc:76
    │ │ │ │ -
    std::map< std::string, std::string > values_
    Definition parametertree.hh:217
    │ │ │ │ -
    T get(const std::string &key, const T &defaultValue) const
    get value converted to a certain type
    Definition parametertree.hh:158
    │ │ │ │ -
    std::string prefix_
    Definition parametertree.hh:212
    │ │ │ │ -
    static std::vector< std::string > split(const std::string &s)
    Definition parametertree.cc:219
    │ │ │ │ -
    const KeyVector & getValueKeys() const
    get value keys
    Definition parametertree.cc:235
    │ │ │ │ -
    static std::basic_string< char, traits, Allocator > parse(const std::string &str)
    Definition parametertree.hh:276
    │ │ │ │ -
    static bool parse(const std::string &str)
    Definition parametertree.hh:293
    │ │ │ │ -
    char operator()(char c)
    Definition parametertree.hh:286
    │ │ │ │ -
    static FieldVector< T, n > parse(const std::string &str)
    Definition parametertree.hh:311
    │ │ │ │ -
    static std::array< T, n > parse(const std::string &str)
    Definition parametertree.hh:321
    │ │ │ │ -
    static std::bitset< n > parse(const std::string &str)
    Definition parametertree.hh:331
    │ │ │ │ -
    static std::vector< T, A > parse(const std::string &str)
    Definition parametertree.hh:347
    │ │ │ │ +
    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
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── encoding │ │ │ │ │ @@ -1 +1 @@ │ │ │ │ │ -us-ascii │ │ │ │ │ +utf-8 │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,406 +7,712 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -parametertree.hh │ │ │ │ │ +fmatrixev.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 (C) 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_PARAMETERTREE_HH │ │ │ │ │ - 6#define DUNE_PARAMETERTREE_HH │ │ │ │ │ + 5#ifndef DUNE_FMATRIXEIGENVALUES_HH │ │ │ │ │ + 6#define DUNE_FMATRIXEIGENVALUES_HH │ │ │ │ │ 7 │ │ │ │ │ - 12#include │ │ │ │ │ - 13#include │ │ │ │ │ - 14#include │ │ │ │ │ - 15#include │ │ │ │ │ - 16#include │ │ │ │ │ - 17#include │ │ │ │ │ - 18#include │ │ │ │ │ - 19#include │ │ │ │ │ - 20#include │ │ │ │ │ - 21#include │ │ │ │ │ - 22#include │ │ │ │ │ - 23#include │ │ │ │ │ - 24#include │ │ │ │ │ - 25#include │ │ │ │ │ - 26 │ │ │ │ │ - 27#include │ │ │ │ │ - 28#include │ │ │ │ │ - 29#include │ │ │ │ │ + 12#include │ │ │ │ │ + 13#include │ │ │ │ │ + 14#include │ │ │ │ │ + 15#include │ │ │ │ │ + 16 │ │ │ │ │ + 17#include │ │ │ │ │ + 18#include │ │ │ │ │ + 19#include │ │ │ │ │ + 20#include │ │ │ │ │ + 21 │ │ │ │ │ + 22namespace Dune { │ │ │ │ │ + 23 │ │ │ │ │ + 29 namespace FMatrixHelp { │ │ │ │ │ 30 │ │ │ │ │ - 31namespace Dune { │ │ │ │ │ - 32 │ │ │ │ │ -36 class ParameterTree │ │ │ │ │ - 37 { │ │ │ │ │ - 38 // class providing a single static parse() function, used by the │ │ │ │ │ - 39 // generic get() method │ │ │ │ │ - 40 template │ │ │ │ │ - 41 struct Parser; │ │ │ │ │ - 42 │ │ │ │ │ - 43 public: │ │ │ │ │ - 44 │ │ │ │ │ -47 typedef std::vector KeyVector; │ │ │ │ │ + 31#if HAVE_LAPACK │ │ │ │ │ + 32 // defined in fmatrixev.cc │ │ │ │ │ + 33 extern void eigenValuesLapackCall( │ │ │ │ │ + 34 const char* jobz, const char* uplo, const long │ │ │ │ │ + 35 int* n, double* a, const long int* lda, double* w, │ │ │ │ │ + 36 double* work, const long int* lwork, long int* info); │ │ │ │ │ + 37 │ │ │ │ │ + 38 extern void eigenValuesNonsymLapackCall( │ │ │ │ │ + 39 const char* jobvl, const char* jobvr, const long │ │ │ │ │ + 40 int* n, double* a, const long int* lda, double* wr, double* wi, double* vl, │ │ │ │ │ + 41 const long int* ldvl, double* vr, const long int* ldvr, double* work, │ │ │ │ │ + 42 const long int* lwork, long int* info); │ │ │ │ │ + 43 │ │ │ │ │ + 44 extern void eigenValuesLapackCall( │ │ │ │ │ + 45 const char* jobz, const char* uplo, const long │ │ │ │ │ + 46 int* n, float* a, const long int* lda, float* w, │ │ │ │ │ + 47 float* work, const long int* lwork, long int* info); │ │ │ │ │ 48 │ │ │ │ │ - 51 ParameterTree(); │ │ │ │ │ - 52 │ │ │ │ │ - 53 │ │ │ │ │ - 61 bool hasKey(const std::string& key) const; │ │ │ │ │ - 62 │ │ │ │ │ - 63 │ │ │ │ │ - 71 bool hasSub(const std::string& sub) const; │ │ │ │ │ - 72 │ │ │ │ │ - 73 │ │ │ │ │ - 82 std::string& operator[](const std::string& key); │ │ │ │ │ - 83 │ │ │ │ │ - 84 │ │ │ │ │ - 94 const std::string& operator[](const std::string& key) const; │ │ │ │ │ - 95 │ │ │ │ │ - 96 │ │ │ │ │ - 104 void report(std::ostream& stream = std::cout, │ │ │ │ │ - 105 const std::string& prefix = "") const; │ │ │ │ │ - 106 │ │ │ │ │ - 107 │ │ │ │ │ - 113 ParameterTree& sub(const std::string& sub); │ │ │ │ │ - 114 │ │ │ │ │ - 115 │ │ │ │ │ - 122 const ParameterTree& sub(const std::string& sub, bool fail_if_missing = │ │ │ │ │ -false) const; │ │ │ │ │ - 123 │ │ │ │ │ - 124 │ │ │ │ │ - 133 std::string get(const std::string& key, const std::string& defaultValue) │ │ │ │ │ -const; │ │ │ │ │ - 134 │ │ │ │ │ - 145 std::string get(const std::string& key, const char* defaultValue) const; │ │ │ │ │ + 49 extern void eigenValuesNonsymLapackCall( │ │ │ │ │ + 50 const char* jobvl, const char* jobvr, const long │ │ │ │ │ + 51 int* n, float* a, const long int* lda, float* wr, float* wi, float* vl, │ │ │ │ │ + 52 const long int* ldvl, float* vr, const long int* ldvr, float* work, │ │ │ │ │ + 53 const long int* lwork, long int* info); │ │ │ │ │ + 54 │ │ │ │ │ + 55#endif │ │ │ │ │ + 56 │ │ │ │ │ + 57 namespace Impl { │ │ │ │ │ + 58 //internal tag to activate/disable code for eigenvector calculation at │ │ │ │ │ +compile time │ │ │ │ │ + 59 enum Jobs { OnlyEigenvalues=0, EigenvaluesEigenvectors=1 }; │ │ │ │ │ + 60 │ │ │ │ │ + 61 //internal dummy used if only eigenvalues are to be calculated │ │ │ │ │ + 62 template │ │ │ │ │ + 63 using EVDummy = FieldMatrix; │ │ │ │ │ + 64 │ │ │ │ │ + 65 //compute the cross-product of two vectors │ │ │ │ │ + 66 template │ │ │ │ │ + 67 inline FieldVector crossProduct(const FieldVector& vec0, const │ │ │ │ │ +FieldVector& vec1) { │ │ │ │ │ + 68 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]}; │ │ │ │ │ + 69 } │ │ │ │ │ + 70 │ │ │ │ │ + 71 template │ │ │ │ │ + 72 static void eigenValues2dImpl(const FieldMatrix& matrix, │ │ │ │ │ + 73 FieldVector& eigenvalues) │ │ │ │ │ + 74 { │ │ │ │ │ + 75 using std::sqrt; │ │ │ │ │ + 76 const K p = 0.5 * (matrix[0][0] + matrix [1][1]); │ │ │ │ │ + 77 const K p2 = p - matrix[1][1]; │ │ │ │ │ + 78 K q = p2 * p2 + matrix[1][0] * matrix[0][1]; │ │ │ │ │ + 79 if( q < 0 && q > -1e-14 ) q = 0; │ │ │ │ │ + 80 if (q < 0) │ │ │ │ │ + 81 { │ │ │ │ │ + 82 std::cout << matrix << std::endl; │ │ │ │ │ + 83 // Complex eigenvalues are either caused by non-symmetric matrices or by │ │ │ │ │ +round-off errors │ │ │ │ │ + 84 DUNE_THROW(MathError, "Complex eigenvalue detected (which this │ │ │ │ │ +implementation cannot handle)."); │ │ │ │ │ + 85 } │ │ │ │ │ + 86 │ │ │ │ │ + 87 // get square root │ │ │ │ │ + 88 q = sqrt(q); │ │ │ │ │ + 89 │ │ │ │ │ + 90 // store eigenvalues in ascending order │ │ │ │ │ + 91 eigenvalues[0] = p - q; │ │ │ │ │ + 92 eigenvalues[1] = p + q; │ │ │ │ │ + 93 } │ │ │ │ │ + 94 │ │ │ │ │ + 95 /* │ │ │ │ │ + 96 This implementation was adapted from the pseudo-code (Python?) │ │ │ │ │ +implementation found on │ │ │ │ │ + 97 http://en.wikipedia.org/wiki/Eigenvalue_algorithm (retrieved late August │ │ │ │ │ +2014). │ │ │ │ │ + 98 Wikipedia claims to have taken it from │ │ │ │ │ + 99 Smith, Oliver K. (April 1961), Eigenvalues of a symmetric 3 × 3 matrix., │ │ │ │ │ + 100 Communications of the ACM 4 (4): 168, doi:10.1145/355578.366316 │ │ │ │ │ + 101 */ │ │ │ │ │ + 102 template │ │ │ │ │ + 103 static K eigenValues3dImpl(const FieldMatrix& matrix, │ │ │ │ │ + 104 FieldVector& eigenvalues) │ │ │ │ │ + 105 { │ │ │ │ │ + 106 using std::sqrt; │ │ │ │ │ + 107 using std::acos; │ │ │ │ │ + 108 using real_type = typename FieldTraits::real_type; │ │ │ │ │ + 109 const K pi = MathematicalConstants::pi(); │ │ │ │ │ + 110 K p1 = matrix[0][1]*matrix[0][1] + matrix[0][2]*matrix[0][2] + matrix[1] │ │ │ │ │ +[2]*matrix[1][2]; │ │ │ │ │ + 111 │ │ │ │ │ + 112 if (p1 <= std::numeric_limits::epsilon()) { │ │ │ │ │ + 113 // A is diagonal. │ │ │ │ │ + 114 eigenvalues[0] = matrix[0][0]; │ │ │ │ │ + 115 eigenvalues[1] = matrix[1][1]; │ │ │ │ │ + 116 eigenvalues[2] = matrix[2][2]; │ │ │ │ │ + 117 std::sort(eigenvalues.begin(), eigenvalues.end()); │ │ │ │ │ + 118 │ │ │ │ │ + 119 return 0.0; │ │ │ │ │ + 120 } │ │ │ │ │ + 121 else │ │ │ │ │ + 122 { │ │ │ │ │ + 123 // q = trace(A)/3 │ │ │ │ │ + 124 K q = 0; │ │ │ │ │ + 125 for (int i=0; i<3; i++) │ │ │ │ │ + 126 q += matrix[i][i] / 3.0; │ │ │ │ │ + 127 │ │ │ │ │ + 128 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; │ │ │ │ │ + 129 K p = sqrt(p2 / 6); │ │ │ │ │ + 130 // B = (1 / p) * (A - q * I); // I is the identity matrix │ │ │ │ │ + 131 FieldMatrix B; │ │ │ │ │ + 132 for (int i=0; i<3; i++) │ │ │ │ │ + 133 for (int j=0; j<3; j++) │ │ │ │ │ + 134 B[i][j] = (real_type(1.0)/p) * (matrix[i][j] - q*(i==j)); │ │ │ │ │ + 135 │ │ │ │ │ + 136 K r = B.determinant() / 2.0; │ │ │ │ │ + 137 │ │ │ │ │ + 138 /*In exact arithmetic for a symmetric matrix -1 <= r <= 1 │ │ │ │ │ + 139 but computation error can leave it slightly outside this range. │ │ │ │ │ + 140 acos(z) function requires |z| <= 1, but will fail silently │ │ │ │ │ + 141 and return NaN if the input is larger than 1 in magnitude. │ │ │ │ │ + 142 Thus r is clamped to [-1,1].*/ │ │ │ │ │ + 143 using std::clamp; │ │ │ │ │ + 144 r = clamp(r, -1.0, 1.0); │ │ │ │ │ + 145 K phi = acos(r) / 3.0; │ │ │ │ │ 146 │ │ │ │ │ - 147 │ │ │ │ │ - 157 template │ │ │ │ │ -158 T get(const std::string& key, const T& defaultValue) const { │ │ │ │ │ - 159 if(hasKey(key)) │ │ │ │ │ - 160 return get(key); │ │ │ │ │ - 161 else │ │ │ │ │ - 162 return defaultValue; │ │ │ │ │ - 163 } │ │ │ │ │ - 164 │ │ │ │ │ - 173 template │ │ │ │ │ -174 T get(const std::string& key) const { │ │ │ │ │ - 175 if(not hasKey(key)) │ │ │ │ │ - 176 DUNE_THROW(Dune::RangeError, "Key '" << key │ │ │ │ │ - 177 << "' not found in ParameterTree (prefix " + prefix_ + ")"); │ │ │ │ │ - 178 try { │ │ │ │ │ - 179 return Parser::parse((*this)[key]); │ │ │ │ │ - 180 } │ │ │ │ │ - 181 catch(const RangeError& e) { │ │ │ │ │ - 182 // rethrow the error and add more information │ │ │ │ │ - 183 DUNE_THROW(RangeError, "Cannot parse value \"" << (*this)[key] │ │ │ │ │ - 184 << "\" for key \"" << prefix_ << "." << key << "\"" │ │ │ │ │ - 185 << e.what()); │ │ │ │ │ - 186 } │ │ │ │ │ - 187 } │ │ │ │ │ + 147 // the eigenvalues satisfy eig[2] <= eig[1] <= eig[0] │ │ │ │ │ + 148 eigenvalues[2] = q + 2 * p * cos(phi); │ │ │ │ │ + 149 eigenvalues[0] = q + 2 * p * cos(phi + (2*pi/3)); │ │ │ │ │ + 150 eigenvalues[1] = 3 * q - eigenvalues[0] - eigenvalues[2]; // since trace │ │ │ │ │ +(matrix) = eig1 + eig2 + eig3 │ │ │ │ │ + 151 │ │ │ │ │ + 152 return r; │ │ │ │ │ + 153 } │ │ │ │ │ + 154 } │ │ │ │ │ + 155 │ │ │ │ │ + 156 //see https://www.geometrictools.com/Documentation/ │ │ │ │ │ +RobustEigenSymmetric3x3.pdf │ │ │ │ │ + 157 //Robustly compute a right-handed orthonormal set {u, v, evec0}. │ │ │ │ │ + 158 template │ │ │ │ │ + 159 void orthoComp(const FieldVector& evec0, FieldVector& u, │ │ │ │ │ +FieldVector& v) { │ │ │ │ │ + 160 using std::abs; │ │ │ │ │ + 161 if(abs(evec0[0]) > abs(evec0[1])) { │ │ │ │ │ + 162 //The component of maximum absolute value is either evec0[0] or evec0[2]. │ │ │ │ │ + 163 FieldVector temp = {evec0[0], evec0[2]}; │ │ │ │ │ + 164 auto L = 1.0 / temp.two_norm(); │ │ │ │ │ + 165 u = L * FieldVector({-evec0[2], 0.0, evec0[0]}); │ │ │ │ │ + 166 } │ │ │ │ │ + 167 else { │ │ │ │ │ + 168 //The component of maximum absolute value is either evec0[1] or evec0[2]. │ │ │ │ │ + 169 FieldVector temp = {evec0[1], evec0[2]}; │ │ │ │ │ + 170 auto L = 1.0 / temp.two_norm(); │ │ │ │ │ + 171 u = L * FieldVector({0.0, evec0[2], -evec0[1]}); │ │ │ │ │ + 172 } │ │ │ │ │ + 173 v = crossProduct(evec0, u); │ │ │ │ │ + 174 } │ │ │ │ │ + 175 │ │ │ │ │ + 176 //see https://www.geometrictools.com/Documentation/ │ │ │ │ │ +RobustEigenSymmetric3x3.pdf │ │ │ │ │ + 177 template │ │ │ │ │ + 178 void eig0(const FieldMatrix& matrix, K eval0, FieldVector& │ │ │ │ │ +evec0) { │ │ │ │ │ + 179 /* Compute a unit-length eigenvector for eigenvalue[i0]. The │ │ │ │ │ + 180 matrix is rank 2, so two of the rows are linearly independent. │ │ │ │ │ + 181 For a robust computation of the eigenvector, select the two │ │ │ │ │ + 182 rows whose cross product has largest length of all pairs of │ │ │ │ │ + 183 rows. */ │ │ │ │ │ + 184 using Vector = FieldVector; │ │ │ │ │ + 185 Vector row0 = {matrix[0][0]-eval0, matrix[0][1], matrix[0][2]}; │ │ │ │ │ + 186 Vector row1 = {matrix[1][0], matrix[1][1]-eval0, matrix[1][2]}; │ │ │ │ │ + 187 Vector row2 = {matrix[2][0], matrix[2][1], matrix[2][2]-eval0}; │ │ │ │ │ 188 │ │ │ │ │ - 196 const KeyVector& getValueKeys() const; │ │ │ │ │ - 197 │ │ │ │ │ - 198 │ │ │ │ │ - 206 const KeyVector& getSubKeys() const; │ │ │ │ │ - 207 │ │ │ │ │ - 208 protected: │ │ │ │ │ - 209 │ │ │ │ │ -210 static const ParameterTree empty_; │ │ │ │ │ - 211 │ │ │ │ │ -212 std::string prefix_; │ │ │ │ │ - 213 │ │ │ │ │ -214 KeyVector valueKeys_; │ │ │ │ │ -215 KeyVector subKeys_; │ │ │ │ │ - 216 │ │ │ │ │ -217 std::map values_; │ │ │ │ │ -218 std::map subs_; │ │ │ │ │ - 219 │ │ │ │ │ - 220 static std::string ltrim(const std::string& s); │ │ │ │ │ - 221 static std::string rtrim(const std::string& s); │ │ │ │ │ - 222 static std::vector split(const std::string & s); │ │ │ │ │ - 223 │ │ │ │ │ - 224 // parse into a fixed-size range of iterators │ │ │ │ │ - 225 template │ │ │ │ │ -226 static void parseRange(const std::string &str, │ │ │ │ │ - 227 Iterator it, const Iterator &end) │ │ │ │ │ - 228 { │ │ │ │ │ - 229 typedef typename std::iterator_traits::value_type Value; │ │ │ │ │ - 230 std::istringstream s(str); │ │ │ │ │ - 231 // make sure we are in locale "C" │ │ │ │ │ - 232 s.imbue(std::locale::classic()); │ │ │ │ │ - 233 std::size_t n = 0; │ │ │ │ │ - 234 for(; it != end; ++it, ++n) { │ │ │ │ │ - 235 s >> *it; │ │ │ │ │ - 236 if(!s) │ │ │ │ │ - 237 DUNE_THROW(RangeError, "as a range of items of type " │ │ │ │ │ - 238 << className() │ │ │ │ │ - 239 << " (" << n << " items were extracted successfully)"); │ │ │ │ │ - 240 } │ │ │ │ │ - 241 Value dummy; │ │ │ │ │ - 242 s >> dummy; │ │ │ │ │ - 243 // now extraction should have failed, and eof should be set │ │ │ │ │ - 244 if(not s.fail() or not s.eof()) │ │ │ │ │ - 245 DUNE_THROW(RangeError, "as a range of " │ │ │ │ │ - 246 << n << " items of type " │ │ │ │ │ - 247 << className() << " (more items than the range can hold)"); │ │ │ │ │ - 248 } │ │ │ │ │ - 249 }; │ │ │ │ │ - 250 │ │ │ │ │ - 251 template │ │ │ │ │ - 252 struct ParameterTree::Parser { │ │ │ │ │ - 253 static T parse(const std::string& str) { │ │ │ │ │ - 254 T val; │ │ │ │ │ - 255 std::istringstream s(str); │ │ │ │ │ - 256 // make sure we are in locale "C" │ │ │ │ │ - 257 s.imbue(std::locale::classic()); │ │ │ │ │ - 258 s >> val; │ │ │ │ │ - 259 if(!s) │ │ │ │ │ - 260 DUNE_THROW(RangeError, " as a " << className()); │ │ │ │ │ - 261 char dummy; │ │ │ │ │ - 262 s >> dummy; │ │ │ │ │ - 263 // now extraction should have failed, and eof should be set │ │ │ │ │ - 264 if ((! s.fail()) || (! s.eof())) │ │ │ │ │ - 265 DUNE_THROW(RangeError, " as a " << className()); │ │ │ │ │ - 266 return val; │ │ │ │ │ - 267 } │ │ │ │ │ - 268 }; │ │ │ │ │ - 269 │ │ │ │ │ - 270 // "How do I convert a string into a wstring in C++?" "Why, that very │ │ │ │ │ -simple │ │ │ │ │ - 271 // son. You just need a these hundred lines of code." │ │ │ │ │ - 272 // Instead im going to restrict myself to string with charT=char here. │ │ │ │ │ - 273 template │ │ │ │ │ -274 struct ParameterTree::Parser > { │ │ │ │ │ - 275 static std::basic_string │ │ │ │ │ -276 parse(const std::string& str) { │ │ │ │ │ - 277 std::string trimmed = ltrim(rtrim(str)); │ │ │ │ │ - 278 return std::basic_string(trimmed.begin(), │ │ │ │ │ - 279 trimmed.end()); │ │ │ │ │ - 280 } │ │ │ │ │ - 281 }; │ │ │ │ │ - 282 │ │ │ │ │ - 283 template<> │ │ │ │ │ -284 struct ParameterTree::Parser< bool > { │ │ │ │ │ -285 struct ToLower { │ │ │ │ │ -286 char operator()(char c) │ │ │ │ │ - 287 { │ │ │ │ │ - 288 return std::tolower(c, std::locale::classic()); │ │ │ │ │ + 189 Vector r0xr1 = crossProduct(row0, row1); │ │ │ │ │ + 190 Vector r0xr2 = crossProduct(row0, row2); │ │ │ │ │ + 191 Vector r1xr2 = crossProduct(row1, row2); │ │ │ │ │ + 192 auto d0 = r0xr1.two_norm(); │ │ │ │ │ + 193 auto d1 = r0xr2.two_norm(); │ │ │ │ │ + 194 auto d2 = r1xr2.two_norm(); │ │ │ │ │ + 195 │ │ │ │ │ + 196 auto dmax = d0 ; │ │ │ │ │ + 197 int imax = 0; │ │ │ │ │ + 198 if(d1>dmax) { │ │ │ │ │ + 199 dmax = d1; │ │ │ │ │ + 200 imax = 1; │ │ │ │ │ + 201 } │ │ │ │ │ + 202 if(d2>dmax) │ │ │ │ │ + 203 imax = 2; │ │ │ │ │ + 204 │ │ │ │ │ + 205 if(imax == 0) │ │ │ │ │ + 206 evec0 = r0xr1 / d0; │ │ │ │ │ + 207 else if(imax == 1) │ │ │ │ │ + 208 evec0 = r0xr2 / d1; │ │ │ │ │ + 209 else │ │ │ │ │ + 210 evec0 = r1xr2 / d2; │ │ │ │ │ + 211 } │ │ │ │ │ + 212 │ │ │ │ │ + 213 //see https://www.geometrictools.com/Documentation/ │ │ │ │ │ +RobustEigenSymmetric3x3.pdf │ │ │ │ │ + 214 template │ │ │ │ │ + 215 void eig1(const FieldMatrix& matrix, const FieldVector& evec0, │ │ │ │ │ +FieldVector& evec1, K eval1) { │ │ │ │ │ + 216 using Vector = FieldVector; │ │ │ │ │ + 217 │ │ │ │ │ + 218 //Robustly compute a right-handed orthonormal set {u, v, evec0}. │ │ │ │ │ + 219 Vector u,v; │ │ │ │ │ + 220 orthoComp(evec0, u, v); │ │ │ │ │ + 221 │ │ │ │ │ + 222 /* Let e be eval1 and let E be a corresponding eigenvector which │ │ │ │ │ + 223 is a solution to the linear system (A - e*I)*E = 0. The matrix │ │ │ │ │ + 224 (A - e*I) is 3x3, not invertible (so infinitely many │ │ │ │ │ + 225 solutions), and has rank 2 when eval1 and eval are different. │ │ │ │ │ + 226 It has rank 1 when eval1 and eval2 are equal. Numerically, it │ │ │ │ │ + 227 is difficult to compute robustly the rank of a matrix. Instead, │ │ │ │ │ + 228 the 3x3 linear system is reduced to a 2x2 system as follows. │ │ │ │ │ + 229 Define the 3x2 matrix J = [u,v] whose columns are the u and v │ │ │ │ │ + 230 computed previously. Define the 2x1 vector X = J*E. The 2x2 │ │ │ │ │ + 231 system is 0 = M * X = (J^T * (A - e*I) * J) * X where J^T is │ │ │ │ │ + 232 the transpose of J and M = J^T * (A - e*I) * J is a 2x2 matrix. │ │ │ │ │ + 233 The system may be written as │ │ │ │ │ + 234 +- -++- -+ +- -+ │ │ │ │ │ + 235 | U^T*A*U - e U^T*A*V || x0 | = e * | x0 | │ │ │ │ │ + 236 | V^T*A*U V^T*A*V - e || x1 | | x1 | │ │ │ │ │ + 237 +- -++ -+ +- -+ │ │ │ │ │ + 238 where X has row entries x0 and x1. */ │ │ │ │ │ + 239 │ │ │ │ │ + 240 Vector Au, Av; │ │ │ │ │ + 241 matrix.mv(u, Au); │ │ │ │ │ + 242 matrix.mv(v, Av); │ │ │ │ │ + 243 │ │ │ │ │ + 244 auto m00 = u.dot(Au) - eval1; │ │ │ │ │ + 245 auto m01 = u.dot(Av); │ │ │ │ │ + 246 auto m11 = v.dot(Av) - eval1; │ │ │ │ │ + 247 │ │ │ │ │ + 248 /* For robustness, choose the largest-length row of M to compute │ │ │ │ │ + 249 the eigenvector. The 2-tuple of coefficients of U and V in the │ │ │ │ │ + 250 assignments to eigenvector[1] lies on a circle, and U and V are │ │ │ │ │ + 251 unit length and perpendicular, so eigenvector[1] is unit length │ │ │ │ │ + 252 (within numerical tolerance). */ │ │ │ │ │ + 253 using std::abs, std::sqrt, std::max; │ │ │ │ │ + 254 auto absM00 = abs(m00); │ │ │ │ │ + 255 auto absM01 = abs(m01); │ │ │ │ │ + 256 auto absM11 = abs(m11); │ │ │ │ │ + 257 if(absM00 >= absM11) { │ │ │ │ │ + 258 auto maxAbsComp = max(absM00, absM01); │ │ │ │ │ + 259 if(maxAbsComp > 0.0) { │ │ │ │ │ + 260 if(absM00 >= absM01) { │ │ │ │ │ + 261 m01 /= m00; │ │ │ │ │ + 262 m00 = 1.0 / sqrt(1.0 + m01*m01); │ │ │ │ │ + 263 m01 *= m00; │ │ │ │ │ + 264 } │ │ │ │ │ + 265 else { │ │ │ │ │ + 266 m00 /= m01; │ │ │ │ │ + 267 m01 = 1.0 / sqrt(1.0 + m00*m00); │ │ │ │ │ + 268 m00 *= m01; │ │ │ │ │ + 269 } │ │ │ │ │ + 270 evec1 = m01*u - m00*v; │ │ │ │ │ + 271 } │ │ │ │ │ + 272 else │ │ │ │ │ + 273 evec1 = u; │ │ │ │ │ + 274 } │ │ │ │ │ + 275 else { │ │ │ │ │ + 276 auto maxAbsComp = max(absM11, absM01); │ │ │ │ │ + 277 if(maxAbsComp > 0.0) { │ │ │ │ │ + 278 if(absM11 >= absM01) { │ │ │ │ │ + 279 m01 /= m11; │ │ │ │ │ + 280 m11 = 1.0 / sqrt(1.0 + m01*m01); │ │ │ │ │ + 281 m01 *= m11; │ │ │ │ │ + 282 } │ │ │ │ │ + 283 else { │ │ │ │ │ + 284 m11 /= m01; │ │ │ │ │ + 285 m01 = 1.0 / sqrt(1.0 + m11*m11); │ │ │ │ │ + 286 m11 *= m01; │ │ │ │ │ + 287 } │ │ │ │ │ + 288 evec1 = m11*u - m01*v; │ │ │ │ │ 289 } │ │ │ │ │ - 290 }; │ │ │ │ │ - 291 │ │ │ │ │ - 292 static bool │ │ │ │ │ -293 parse(const std::string& str) { │ │ │ │ │ - 294 std::string ret = str; │ │ │ │ │ - 295 │ │ │ │ │ - 296 std::transform(ret.begin(), ret.end(), ret.begin(), ToLower()); │ │ │ │ │ - 297 │ │ │ │ │ - 298 if (ret == "yes" || ret == "true") │ │ │ │ │ - 299 return true; │ │ │ │ │ - 300 │ │ │ │ │ - 301 if (ret == "no" || ret == "false") │ │ │ │ │ - 302 return false; │ │ │ │ │ - 303 │ │ │ │ │ - 304 return (Parser::parse(ret) != 0); │ │ │ │ │ - 305 } │ │ │ │ │ - 306 }; │ │ │ │ │ - 307 │ │ │ │ │ - 308 template │ │ │ │ │ -309 struct ParameterTree::Parser > { │ │ │ │ │ - 310 static FieldVector │ │ │ │ │ -311 parse(const std::string& str) { │ │ │ │ │ - 312 FieldVector val; │ │ │ │ │ - 313 parseRange(str, val.begin(), val.end()); │ │ │ │ │ - 314 return val; │ │ │ │ │ - 315 } │ │ │ │ │ - 316 }; │ │ │ │ │ - 317 │ │ │ │ │ - 318 template │ │ │ │ │ -319 struct ParameterTree::Parser > { │ │ │ │ │ - 320 static std::array │ │ │ │ │ -321 parse(const std::string& str) { │ │ │ │ │ - 322 std::array val; │ │ │ │ │ - 323 parseRange(str, val.begin(), val.end()); │ │ │ │ │ - 324 return val; │ │ │ │ │ - 325 } │ │ │ │ │ - 326 }; │ │ │ │ │ - 327 │ │ │ │ │ - 328 template │ │ │ │ │ -329 struct ParameterTree::Parser > { │ │ │ │ │ - 330 static std::bitset │ │ │ │ │ -331 parse(const std::string& str) { │ │ │ │ │ - 332 std::bitset val; │ │ │ │ │ - 333 std::vector sub = split(str); │ │ │ │ │ - 334 if (sub.size() != n) │ │ │ │ │ - 335 DUNE_THROW(RangeError, "as a bitset<" << n << "> " │ │ │ │ │ - 336 << "because of unmatching size " << sub.size()); │ │ │ │ │ - 337 for (std::size_t i=0; i::parse(sub[i]); │ │ │ │ │ - 339 } │ │ │ │ │ - 340 return val; │ │ │ │ │ - 341 } │ │ │ │ │ - 342 }; │ │ │ │ │ - 343 │ │ │ │ │ - 344 template │ │ │ │ │ -345 struct ParameterTree::Parser > { │ │ │ │ │ - 346 static std::vector │ │ │ │ │ -347 parse(const std::string& str) { │ │ │ │ │ - 348 std::vector sub = split(str); │ │ │ │ │ - 349 std::vector vec; │ │ │ │ │ - 350 for (unsigned int i=0; i::parse(sub[i]); │ │ │ │ │ - 352 vec.push_back(val); │ │ │ │ │ - 353 } │ │ │ │ │ - 354 return vec; │ │ │ │ │ - 355 } │ │ │ │ │ - 356 }; │ │ │ │ │ + 290 else │ │ │ │ │ + 291 evec1 = u; │ │ │ │ │ + 292 } │ │ │ │ │ + 293 } │ │ │ │ │ + 294 │ │ │ │ │ + 295 // 1d specialization │ │ │ │ │ + 296 template │ │ │ │ │ + 297 static void eigenValuesVectorsImpl(const FieldMatrix& matrix, │ │ │ │ │ + 298 FieldVector& eigenValues, │ │ │ │ │ + 299 FieldMatrix& eigenVectors) │ │ │ │ │ + 300 { │ │ │ │ │ + 301 eigenValues[0] = matrix[0][0]; │ │ │ │ │ + 302 if constexpr(Tag==EigenvaluesEigenvectors) │ │ │ │ │ + 303 eigenVectors[0] = {1.0}; │ │ │ │ │ + 304 } │ │ │ │ │ + 305 │ │ │ │ │ + 306 │ │ │ │ │ + 307 // 2d specialization │ │ │ │ │ + 308 template │ │ │ │ │ + 309 static void eigenValuesVectorsImpl(const FieldMatrix& matrix, │ │ │ │ │ + 310 FieldVector& eigenValues, │ │ │ │ │ + 311 FieldMatrix& eigenVectors) │ │ │ │ │ + 312 { │ │ │ │ │ + 313 // Compute eigen values │ │ │ │ │ + 314 Impl::eigenValues2dImpl(matrix, eigenValues); │ │ │ │ │ + 315 │ │ │ │ │ + 316 // Compute eigenvectors by exploiting the Cayley–Hamilton theorem. │ │ │ │ │ + 317 // If λ_1, λ_2 are the eigenvalues, then (A - λ_1I )(A - λ_2I ) = (A - │ │ │ │ │ +λ_2I )(A - λ_1I ) = 0, │ │ │ │ │ + 318 // so the columns of (A - λ_2I ) are annihilated by (A - λ_1I ) and vice │ │ │ │ │ +versa. │ │ │ │ │ + 319 // Assuming neither matrix is zero, the columns of each must include │ │ │ │ │ +eigenvectors │ │ │ │ │ + 320 // for the other eigenvalue. (If either matrix is zero, then A is a │ │ │ │ │ +multiple of the │ │ │ │ │ + 321 // identity and any non-zero vector is an eigenvector.) │ │ │ │ │ + 322 // From: https://en.wikipedia.org/wiki/Eigenvalue_algorithm#2x2_matrices │ │ │ │ │ + 323 if constexpr(Tag==EigenvaluesEigenvectors) { │ │ │ │ │ + 324 │ │ │ │ │ + 325 // Special casing for multiples of the identity │ │ │ │ │ + 326 FieldMatrix temp = matrix; │ │ │ │ │ + 327 temp[0][0] -= eigenValues[0]; │ │ │ │ │ + 328 temp[1][1] -= eigenValues[0]; │ │ │ │ │ + 329 if(temp.infinity_norm() <= 1e-14) { │ │ │ │ │ + 330 eigenVectors[0] = {1.0, 0.0}; │ │ │ │ │ + 331 eigenVectors[1] = {0.0, 1.0}; │ │ │ │ │ + 332 } │ │ │ │ │ + 333 else { │ │ │ │ │ + 334 // The columns of A - λ_2I are eigenvectors for λ_1, or zero. │ │ │ │ │ + 335 // Take the column with the larger norm to avoid zero columns. │ │ │ │ │ + 336 FieldVector ev0 = {matrix[0][0]-eigenValues[1], matrix[1][0]}; │ │ │ │ │ + 337 FieldVector ev1 = {matrix[0][1], matrix[1][1]-eigenValues[1]}; │ │ │ │ │ + 338 eigenVectors[0] = (ev0.two_norm2() >= ev1.two_norm2()) ? ev0/ev0.two_norm │ │ │ │ │ +() : ev1/ev1.two_norm(); │ │ │ │ │ + 339 │ │ │ │ │ + 340 // The columns of A - λ_1I are eigenvectors for λ_2, or zero. │ │ │ │ │ + 341 // Take the column with the larger norm to avoid zero columns. │ │ │ │ │ + 342 ev0 = {matrix[0][0]-eigenValues[0], matrix[1][0]}; │ │ │ │ │ + 343 ev1 = {matrix[0][1], matrix[1][1]-eigenValues[0]}; │ │ │ │ │ + 344 eigenVectors[1] = (ev0.two_norm2() >= ev1.two_norm2()) ? ev0/ev0.two_norm │ │ │ │ │ +() : ev1/ev1.two_norm(); │ │ │ │ │ + 345 } │ │ │ │ │ + 346 } │ │ │ │ │ + 347 } │ │ │ │ │ + 348 │ │ │ │ │ + 349 // 3d specialization │ │ │ │ │ + 350 template │ │ │ │ │ + 351 static void eigenValuesVectorsImpl(const FieldMatrix& matrix, │ │ │ │ │ + 352 FieldVector& eigenValues, │ │ │ │ │ + 353 FieldMatrix& eigenVectors) │ │ │ │ │ + 354 { │ │ │ │ │ + 355 using Vector = FieldVector; │ │ │ │ │ + 356 using Matrix = FieldMatrix; │ │ │ │ │ 357 │ │ │ │ │ - 358} // end namespace Dune │ │ │ │ │ - 359 │ │ │ │ │ - 360#endif // DUNE_PARAMETERTREE_HH │ │ │ │ │ -classname.hh │ │ │ │ │ -A free function to provide the demangled class name of a given object or type │ │ │ │ │ -as a string. │ │ │ │ │ + 358 //compute eigenvalues │ │ │ │ │ + 359 /* Precondition the matrix by factoring out the maximum absolute │ │ │ │ │ + 360 value of the components. This guards against floating-point │ │ │ │ │ + 361 overflow when computing the eigenvalues.*/ │ │ │ │ │ + 362 using std::isnormal; │ │ │ │ │ + 363 K maxAbsElement = (isnormal(matrix.infinity_norm())) ? │ │ │ │ │ +matrix.infinity_norm() : K(1.0); │ │ │ │ │ + 364 Matrix scaledMatrix = matrix / maxAbsElement; │ │ │ │ │ + 365 K r = Impl::eigenValues3dImpl(scaledMatrix, eigenValues); │ │ │ │ │ + 366 │ │ │ │ │ + 367 if constexpr(Tag==EigenvaluesEigenvectors) { │ │ │ │ │ + 368 K offDiagNorm = Vector{scaledMatrix[0][1],scaledMatrix[0][2],scaledMatrix │ │ │ │ │ +[1][2]}.two_norm2(); │ │ │ │ │ + 369 if (offDiagNorm <= std::numeric_limits::epsilon()) │ │ │ │ │ + 370 { │ │ │ │ │ + 371 eigenValues = {scaledMatrix[0][0], scaledMatrix[1][1], scaledMatrix[2] │ │ │ │ │ +[2]}; │ │ │ │ │ + 372 eigenVectors = {{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}}; │ │ │ │ │ + 373 │ │ │ │ │ + 374 // Use bubble sort to jointly sort eigenvalues and eigenvectors │ │ │ │ │ + 375 // such that eigenvalues are ascending │ │ │ │ │ + 376 if (eigenValues[0] > eigenValues[1]) │ │ │ │ │ + 377 { │ │ │ │ │ + 378 std::swap(eigenValues[0], eigenValues[1]); │ │ │ │ │ + 379 std::swap(eigenVectors[0], eigenVectors[1]); │ │ │ │ │ + 380 } │ │ │ │ │ + 381 if (eigenValues[1] > eigenValues[2]) │ │ │ │ │ + 382 { │ │ │ │ │ + 383 std::swap(eigenValues[1], eigenValues[2]); │ │ │ │ │ + 384 std::swap(eigenVectors[1], eigenVectors[2]); │ │ │ │ │ + 385 } │ │ │ │ │ + 386 if (eigenValues[0] > eigenValues[1]) │ │ │ │ │ + 387 { │ │ │ │ │ + 388 std::swap(eigenValues[0], eigenValues[1]); │ │ │ │ │ + 389 std::swap(eigenVectors[0], eigenVectors[1]); │ │ │ │ │ + 390 } │ │ │ │ │ + 391 } │ │ │ │ │ + 392 else { │ │ │ │ │ + 393 /*Compute the eigenvectors so that the set │ │ │ │ │ + 394 [evec[0], evec[1], evec[2]] is right handed and │ │ │ │ │ + 395 orthonormal. */ │ │ │ │ │ + 396 │ │ │ │ │ + 397 Matrix evec(0.0); │ │ │ │ │ + 398 Vector eval(eigenValues); │ │ │ │ │ + 399 if(r >= 0) { │ │ │ │ │ + 400 Impl::eig0(scaledMatrix, eval[2], evec[2]); │ │ │ │ │ + 401 Impl::eig1(scaledMatrix, evec[2], evec[1], eval[1]); │ │ │ │ │ + 402 evec[0] = Impl::crossProduct(evec[1], evec[2]); │ │ │ │ │ + 403 } │ │ │ │ │ + 404 else { │ │ │ │ │ + 405 Impl::eig0(scaledMatrix, eval[0], evec[0]); │ │ │ │ │ + 406 Impl::eig1(scaledMatrix, evec[0], evec[1], eval[1]); │ │ │ │ │ + 407 evec[2] = Impl::crossProduct(evec[0], evec[1]); │ │ │ │ │ + 408 } │ │ │ │ │ + 409 //sort eval/evec-pairs in ascending order │ │ │ │ │ + 410 using EVPair = std::pair; │ │ │ │ │ + 411 std::vector pairs; │ │ │ │ │ + 412 for(std::size_t i=0; i<=2; ++i) │ │ │ │ │ + 413 pairs.push_back(EVPair(eval[i], evec[i])); │ │ │ │ │ + 414 auto comp = [](EVPair x, EVPair y){ return x.first < y.first; }; │ │ │ │ │ + 415 std::sort(pairs.begin(), pairs.end(), comp); │ │ │ │ │ + 416 for(std::size_t i=0; i<=2; ++i){ │ │ │ │ │ + 417 eigenValues[i] = pairs[i].first; │ │ │ │ │ + 418 eigenVectors[i] = pairs[i].second; │ │ │ │ │ + 419 } │ │ │ │ │ + 420 } │ │ │ │ │ + 421 } │ │ │ │ │ + 422 //The preconditioning scaled the matrix, which scales the eigenvalues. │ │ │ │ │ +Revert the scaling. │ │ │ │ │ + 423 eigenValues *= maxAbsElement; │ │ │ │ │ + 424 } │ │ │ │ │ + 425 │ │ │ │ │ + 426 // forwarding to LAPACK with corresponding tag │ │ │ │ │ + 427 template │ │ │ │ │ + 428 static void eigenValuesVectorsLapackImpl(const FieldMatrix& │ │ │ │ │ +matrix, │ │ │ │ │ + 429 FieldVector& eigenValues, │ │ │ │ │ + 430 FieldMatrix& eigenVectors) │ │ │ │ │ + 431 { │ │ │ │ │ + 432 { │ │ │ │ │ + 433#if HAVE_LAPACK │ │ │ │ │ + 434 /*Lapack uses a proprietary tag to determine whether both eigenvalues and │ │ │ │ │ + 435 -vectors ('v') or only eigenvalues ('n') should be calculated */ │ │ │ │ │ + 436 const char jobz = "nv"[Tag]; │ │ │ │ │ + 437 │ │ │ │ │ + 438 const long int N = dim ; │ │ │ │ │ + 439 const char uplo = 'u'; // use upper triangular matrix │ │ │ │ │ + 440 │ │ │ │ │ + 441 // length of matrix vector, LWORK >= max(1,3*N-1) │ │ │ │ │ + 442 const long int lwork = 3*N -1 ; │ │ │ │ │ + 443 │ │ │ │ │ + 444 constexpr bool isKLapackType = std::is_same_v || std:: │ │ │ │ │ +is_same_v; │ │ │ │ │ + 445 using LapackNumType = std::conditional_t; │ │ │ │ │ + 446 │ │ │ │ │ + 447 // matrix to put into dsyev │ │ │ │ │ + 448 LapackNumType matrixVector[dim * dim]; │ │ │ │ │ + 449 │ │ │ │ │ + 450 // copy matrix │ │ │ │ │ + 451 int row = 0; │ │ │ │ │ + 452 for(int i=0; i │ │ │ │ │ + 507 static void eigenValuesVectorsImpl(const FieldMatrix& matrix, │ │ │ │ │ + 508 FieldVector& eigenValues, │ │ │ │ │ + 509 FieldMatrix& eigenVectors) │ │ │ │ │ + 510 { │ │ │ │ │ + 511 eigenValuesVectorsLapackImpl(matrix,eigenValues,eigenVectors); │ │ │ │ │ + 512 } │ │ │ │ │ + 513 } //namespace Impl │ │ │ │ │ + 514 │ │ │ │ │ + 522 template │ │ │ │ │ +523 static void eigenValues(const FieldMatrix& matrix, │ │ │ │ │ + 524 FieldVector& eigenValues) │ │ │ │ │ + 525 { │ │ │ │ │ + 526 Impl::EVDummy dummy; │ │ │ │ │ + 527 Impl::eigenValuesVectorsImpl(matrix, │ │ │ │ │ +eigenValues, dummy); │ │ │ │ │ + 528 } │ │ │ │ │ + 529 │ │ │ │ │ + 538 template │ │ │ │ │ +539 static void eigenValuesVectors(const FieldMatrix& matrix, │ │ │ │ │ + 540 FieldVector& eigenValues, │ │ │ │ │ + 541 FieldMatrix& eigenVectors) │ │ │ │ │ + 542 { │ │ │ │ │ + 543 Impl::eigenValuesVectorsImpl(matrix, │ │ │ │ │ +eigenValues, eigenVectors); │ │ │ │ │ + 544 } │ │ │ │ │ + 545 │ │ │ │ │ + 553 template │ │ │ │ │ +554 static void eigenValuesLapack(const FieldMatrix& matrix, │ │ │ │ │ + 555 FieldVector& eigenValues) │ │ │ │ │ + 556 { │ │ │ │ │ + 557 Impl::EVDummy dummy; │ │ │ │ │ + 558 Impl::eigenValuesVectorsLapackImpl │ │ │ │ │ +(matrix, eigenValues, dummy); │ │ │ │ │ + 559 } │ │ │ │ │ + 560 │ │ │ │ │ + 569 template │ │ │ │ │ +570 static void eigenValuesVectorsLapack(const FieldMatrix& │ │ │ │ │ +matrix, │ │ │ │ │ + 571 FieldVector& eigenValues, │ │ │ │ │ + 572 FieldMatrix& eigenVectors) │ │ │ │ │ + 573 { │ │ │ │ │ + 574 Impl::eigenValuesVectorsLapackImpl │ │ │ │ │ +(matrix, eigenValues, eigenVectors); │ │ │ │ │ + 575 } │ │ │ │ │ + 576 │ │ │ │ │ + 584 template │ │ │ │ │ +585 static void eigenValuesNonSym(const FieldMatrix& matrix, │ │ │ │ │ + 586 FieldVector& eigenValues) │ │ │ │ │ + 587 { │ │ │ │ │ + 588#if HAVE_LAPACK │ │ │ │ │ + 589 { │ │ │ │ │ + 590 const long int N = dim ; │ │ │ │ │ + 591 const char jobvl = 'n'; │ │ │ │ │ + 592 const char jobvr = 'n'; │ │ │ │ │ + 593 │ │ │ │ │ + 594 constexpr bool isKLapackType = std::is_same_v || std:: │ │ │ │ │ +is_same_v; │ │ │ │ │ + 595 using LapackNumType = std::conditional_t; │ │ │ │ │ + 596 │ │ │ │ │ + 597 // matrix to put into dgeev │ │ │ │ │ + 598 LapackNumType matrixVector[dim * dim]; │ │ │ │ │ + 599 │ │ │ │ │ + 600 // copy matrix │ │ │ │ │ + 601 int row = 0; │ │ │ │ │ + 602 for(int i=0; i &a, const AlignedNumber< T, align > │ │ │ │ │ +&b) │ │ │ │ │ +Definition debugalign.hh:425 │ │ │ │ │ +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:585 │ │ │ │ │ +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:523 │ │ │ │ │ +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:554 │ │ │ │ │ +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:539 │ │ │ │ │ +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:570 │ │ │ │ │ +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:95 │ │ │ │ │ -Dune::DenseVector::begin │ │ │ │ │ -Iterator begin() │ │ │ │ │ -begin iterator │ │ │ │ │ -Definition densevector.hh:347 │ │ │ │ │ -Dune::DenseVector::end │ │ │ │ │ -Iterator end() │ │ │ │ │ -end iterator │ │ │ │ │ -Definition densevector.hh:353 │ │ │ │ │ -Dune::RangeError │ │ │ │ │ -Default exception class for range errors. │ │ │ │ │ -Definition exceptions.hh:254 │ │ │ │ │ -Dune::ParameterTree │ │ │ │ │ -Hierarchical structure of string parameters. │ │ │ │ │ -Definition parametertree.hh:37 │ │ │ │ │ -Dune::ParameterTree::valueKeys_ │ │ │ │ │ -KeyVector valueKeys_ │ │ │ │ │ -Definition parametertree.hh:214 │ │ │ │ │ -Dune::ParameterTree::subs_ │ │ │ │ │ -std::map< std::string, ParameterTree > subs_ │ │ │ │ │ -Definition parametertree.hh:218 │ │ │ │ │ -Dune::ParameterTree::empty_ │ │ │ │ │ -static const ParameterTree empty_ │ │ │ │ │ -Definition parametertree.hh:210 │ │ │ │ │ -Dune::ParameterTree::rtrim │ │ │ │ │ -static std::string rtrim(const std::string &s) │ │ │ │ │ -Definition parametertree.cc:210 │ │ │ │ │ -Dune::ParameterTree::get │ │ │ │ │ -std::string get(const std::string &key, const std::string &defaultValue) const │ │ │ │ │ -get value as string │ │ │ │ │ -Definition parametertree.cc:185 │ │ │ │ │ -Dune::ParameterTree::ltrim │ │ │ │ │ -static std::string ltrim(const std::string &s) │ │ │ │ │ -Definition parametertree.cc:201 │ │ │ │ │ -Dune::ParameterTree::report │ │ │ │ │ -void report(std::ostream &stream=std::cout, const std::string &prefix="") const │ │ │ │ │ -print distinct substructure to stream │ │ │ │ │ -Definition parametertree.cc:29 │ │ │ │ │ -Dune::ParameterTree::KeyVector │ │ │ │ │ -std::vector< std::string > KeyVector │ │ │ │ │ -storage for key lists │ │ │ │ │ -Definition parametertree.hh:47 │ │ │ │ │ -Dune::ParameterTree::parseRange │ │ │ │ │ -static void parseRange(const std::string &str, Iterator it, const Iterator │ │ │ │ │ -&end) │ │ │ │ │ -Definition parametertree.hh:226 │ │ │ │ │ -Dune::ParameterTree::ParameterTree │ │ │ │ │ -ParameterTree() │ │ │ │ │ -Create new empty ParameterTree. │ │ │ │ │ -Definition parametertree.cc:24 │ │ │ │ │ -Dune::ParameterTree::operator[] │ │ │ │ │ -std::string & operator[](const std::string &key) │ │ │ │ │ -get value reference for key │ │ │ │ │ -Definition parametertree.cc:150 │ │ │ │ │ -Dune::ParameterTree::subKeys_ │ │ │ │ │ -KeyVector subKeys_ │ │ │ │ │ -Definition parametertree.hh:215 │ │ │ │ │ -Dune::ParameterTree::sub │ │ │ │ │ -ParameterTree & sub(const std::string &sub) │ │ │ │ │ -get substructure by name │ │ │ │ │ -Definition parametertree.cc:103 │ │ │ │ │ -Dune::ParameterTree::hasKey │ │ │ │ │ -bool hasKey(const std::string &key) const │ │ │ │ │ -test for key │ │ │ │ │ -Definition parametertree.cc:48 │ │ │ │ │ -Dune::ParameterTree::getSubKeys │ │ │ │ │ -const KeyVector & getSubKeys() const │ │ │ │ │ -get substructure keys │ │ │ │ │ -Definition parametertree.cc:240 │ │ │ │ │ -Dune::ParameterTree::get │ │ │ │ │ -T get(const std::string &key) const │ │ │ │ │ -Get value. │ │ │ │ │ -Definition parametertree.hh:174 │ │ │ │ │ -Dune::ParameterTree::hasSub │ │ │ │ │ -bool hasSub(const std::string &sub) const │ │ │ │ │ -test for substructure │ │ │ │ │ -Definition parametertree.cc:76 │ │ │ │ │ -Dune::ParameterTree::values_ │ │ │ │ │ -std::map< std::string, std::string > values_ │ │ │ │ │ -Definition parametertree.hh:217 │ │ │ │ │ -Dune::ParameterTree::get │ │ │ │ │ -T get(const std::string &key, const T &defaultValue) const │ │ │ │ │ -get value converted to a certain type │ │ │ │ │ -Definition parametertree.hh:158 │ │ │ │ │ -Dune::ParameterTree::prefix_ │ │ │ │ │ -std::string prefix_ │ │ │ │ │ -Definition parametertree.hh:212 │ │ │ │ │ -Dune::ParameterTree::split │ │ │ │ │ -static std::vector< std::string > split(const std::string &s) │ │ │ │ │ -Definition parametertree.cc:219 │ │ │ │ │ -Dune::ParameterTree::getValueKeys │ │ │ │ │ -const KeyVector & getValueKeys() const │ │ │ │ │ -get value keys │ │ │ │ │ -Definition parametertree.cc:235 │ │ │ │ │ -Dune::ParameterTree::Parser<_std::basic_string<_char,_traits,_Allocator_>_>:: │ │ │ │ │ -parse │ │ │ │ │ -static std::basic_string< char, traits, Allocator > parse(const std::string │ │ │ │ │ -&str) │ │ │ │ │ -Definition parametertree.hh:276 │ │ │ │ │ -Dune::ParameterTree::Parser<_bool_>::parse │ │ │ │ │ -static bool parse(const std::string &str) │ │ │ │ │ -Definition parametertree.hh:293 │ │ │ │ │ -Dune::ParameterTree::Parser<_bool_>::ToLower::operator() │ │ │ │ │ -char operator()(char c) │ │ │ │ │ -Definition parametertree.hh:286 │ │ │ │ │ -Dune::ParameterTree::Parser<_FieldVector<_T,_n_>_>::parse │ │ │ │ │ -static FieldVector< T, n > parse(const std::string &str) │ │ │ │ │ -Definition parametertree.hh:311 │ │ │ │ │ -Dune::ParameterTree::Parser<_std::array<_T,_n_>_>::parse │ │ │ │ │ -static std::array< T, n > parse(const std::string &str) │ │ │ │ │ -Definition parametertree.hh:321 │ │ │ │ │ -Dune::ParameterTree::Parser<_std::bitset<_n_>_>::parse │ │ │ │ │ -static std::bitset< n > parse(const std::string &str) │ │ │ │ │ -Definition parametertree.hh:331 │ │ │ │ │ -Dune::ParameterTree::Parser<_std::vector<_T,_A_>_>::parse │ │ │ │ │ -static std::vector< T, A > parse(const std::string &str) │ │ │ │ │ -Definition parametertree.hh:347 │ │ │ │ │ +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/a00095.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: classname.hh File Reference │ │ │ │ +dune-common: dynmatrixev.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -72,47 +72,44 @@ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ Namespaces | │ │ │ │ Functions
    │ │ │ │ -
    classname.hh File Reference
    │ │ │ │ +
    dynmatrixev.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ -

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

    utility functions to compute eigenvalues for dense matrices. │ │ │ │ More...

    │ │ │ │ -
    #include <cstdlib>
    │ │ │ │ +
    #include <algorithm>
    │ │ │ │ #include <memory>
    │ │ │ │ -#include <string>
    │ │ │ │ -#include <typeinfo>
    │ │ │ │ -#include <type_traits>
    │ │ │ │ +#include "dynmatrix.hh"
    │ │ │ │ +#include "fmatrixev.hh"
    │ │ │ │
    │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ Namespaces

    namespace  Dune
     Dune namespace.
     
    namespace  Dune::DynamicMatrixHelp
     
    │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

    │ │ │ │ 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<typename K , class C >
    static void Dune::DynamicMatrixHelp::eigenValuesNonSym (const DynamicMatrix< K > &matrix, DynamicVector< C > &eigenValues, std::vector< DynamicVector< K > > *eigenVectors=nullptr)
     calculates the eigenvalues of a symmetric field matrix
     
    │ │ │ │

    Detailed Description

    │ │ │ │ -

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

    │ │ │ │ +

    utility functions to compute eigenvalues for dense matrices.

    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,35 +7,32 @@ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ 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 │ │ │ │ │ +dynmatrixev.hh File Reference │ │ │ │ │ +utility functions to compute eigenvalues for dense matrices. More... │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +#include "dynmatrix.hh" │ │ │ │ │ +#include "fmatrixev.hh" │ │ │ │ │ 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::DynamicMatrixHelp │ │ │ │ │   │ │ │ │ │ -template │ │ │ │ │ -std::string Dune::className (T &&v) │ │ │ │ │ -  Provide the demangled class name of a given object as a string. │ │ │ │ │ + Functions │ │ │ │ │ +template │ │ │ │ │ +static void Dune::DynamicMatrixHelp::eigenValuesNonSym (const DynamicMatrix< K │ │ │ │ │ + > &matrix, DynamicVector< C > &eigenValues, std::vector< │ │ │ │ │ + DynamicVector< K > > *eigenVectors=nullptr) │ │ │ │ │ +  calculates the eigenvalues of a symmetric field matrix │ │ │ │ │   │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -A free function to provide the demangled class name of a given object or type │ │ │ │ │ -as a string. │ │ │ │ │ +utility functions to compute eigenvalues for dense matrices. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00095_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: classname.hh Source File │ │ │ │ +dune-common: dynmatrixev.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,95 +74,123 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    classname.hh
    │ │ │ │ +
    dynmatrixev.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 (C) 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_DYNMATRIXEIGENVALUES_HH
    │ │ │ │ +
    6#define DUNE_DYNMATRIXEIGENVALUES_HH
    │ │ │ │
    7
    │ │ │ │ -
    13#include <cstdlib>
    │ │ │ │ -
    14#include <memory>
    │ │ │ │ -
    15#include <string>
    │ │ │ │ -
    16#include <typeinfo>
    │ │ │ │ -
    17#include <type_traits>
    │ │ │ │ -
    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
    │ │ │ │ +
    8#include <algorithm>
    │ │ │ │ +
    9#include <memory>
    │ │ │ │ +
    10
    │ │ │ │ +
    11#include "dynmatrix.hh"
    │ │ │ │ +
    12#include "fmatrixev.hh"
    │ │ │ │ +
    13
    │ │ │ │ +
    22namespace Dune {
    │ │ │ │
    23
    │ │ │ │ -
    24namespace Dune {
    │ │ │ │ +
    │ │ │ │ +
    24 namespace DynamicMatrixHelp {
    │ │ │ │
    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>
    │ │ │ │ -
    │ │ │ │ -
    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
    │ │ │ │ +
    26#if HAVE_LAPACK
    │ │ │ │ +
    27 using Dune::FMatrixHelp::eigenValuesNonsymLapackCall;
    │ │ │ │ +
    28#endif
    │ │ │ │ +
    29
    │ │ │ │ +
    38 template <typename K, class C>
    │ │ │ │ +
    │ │ │ │ +
    39 static void eigenValuesNonSym(const DynamicMatrix<K>& matrix,
    │ │ │ │ +
    40 DynamicVector<C>& eigenValues,
    │ │ │ │ +
    41 std::vector<DynamicVector<K>>* eigenVectors = nullptr
    │ │ │ │ +
    42 )
    │ │ │ │ +
    43 {
    │ │ │ │ +
    44
    │ │ │ │ +
    45#if HAVE_LAPACK
    │ │ │ │ +
    46 {
    │ │ │ │ +
    47 const long int N = matrix.rows();
    │ │ │ │ +
    48 const char jobvl = 'n';
    │ │ │ │ +
    49 const char jobvr = eigenVectors ? 'v' : 'n';
    │ │ │ │ +
    50
    │ │ │ │ +
    51
    │ │ │ │ +
    52 // matrix to put into dgeev
    │ │ │ │ +
    53 auto matrixVector = std::make_unique<double[]>(N*N);
    │ │ │ │ +
    54
    │ │ │ │ +
    55 // copy matrix
    │ │ │ │ +
    56 int row = 0;
    │ │ │ │ +
    57 for(int i=0; i<N; ++i)
    │ │ │ │ +
    58 {
    │ │ │ │ +
    59 for(int j=0; j<N; ++j, ++row)
    │ │ │ │ +
    60 {
    │ │ │ │ +
    61 matrixVector[ row ] = matrix[ i ][ j ];
    │ │ │ │ +
    62 }
    │ │ │ │ +
    63 }
    │ │ │ │ +
    64
    │ │ │ │ +
    65 // working memory
    │ │ │ │ +
    66 auto eigenR = std::make_unique<double[]>(N);
    │ │ │ │ +
    67 auto eigenI = std::make_unique<double[]>(N);
    │ │ │ │ +
    68
    │ │ │ │ +
    69 const long int lwork = eigenVectors ? 4*N : 3*N;
    │ │ │ │ +
    70 auto work = std::make_unique<double[]>(lwork);
    │ │ │ │ +
    71 auto vr = eigenVectors ? std::make_unique<double[]>(N*N) : std::unique_ptr<double[]>{};
    │ │ │ │ +
    72
    │ │ │ │ +
    73 // return value information
    │ │ │ │ +
    74 long int info = 0;
    │ │ │ │ +
    75
    │ │ │ │ +
    76 // call LAPACK routine (see fmatrixev_ext.cc)
    │ │ │ │ +
    77 eigenValuesNonsymLapackCall(&jobvl, &jobvr, &N, matrixVector.get(), &N,
    │ │ │ │ +
    78 eigenR.get(), eigenI.get(), nullptr, &N, vr.get(), &N, work.get(),
    │ │ │ │ +
    79 &lwork, &info);
    │ │ │ │ +
    80
    │ │ │ │ +
    81 if( info != 0 )
    │ │ │ │ +
    82 {
    │ │ │ │ +
    83 std::cerr << "For matrix " << matrix << " eigenvalue calculation failed! " << std::endl;
    │ │ │ │ +
    84 DUNE_THROW(InvalidStateException,"eigenValues: Eigenvalue calculation failed!");
    │ │ │ │ +
    85 }
    │ │ │ │ +
    86
    │ │ │ │ +
    87 eigenValues.resize(N);
    │ │ │ │ +
    88 for (int i=0; i<N; ++i)
    │ │ │ │ +
    89 eigenValues[i] = std::complex<double>(eigenR[i], eigenI[i]);
    │ │ │ │ +
    90
    │ │ │ │ +
    91 if (eigenVectors) {
    │ │ │ │ +
    92 eigenVectors->resize(N);
    │ │ │ │ +
    93 for (int i = 0; i < N; ++i) {
    │ │ │ │ +
    94 auto& v = (*eigenVectors)[i];
    │ │ │ │ +
    95 v.resize(N);
    │ │ │ │ +
    96 std::copy(vr.get() + N*i, vr.get() + N*(i+1), &v[0]);
    │ │ │ │ +
    97 }
    │ │ │ │ +
    98 }
    │ │ │ │ +
    99 }
    │ │ │ │ +
    100#else // #if HAVE_LAPACK
    │ │ │ │ +
    101 DUNE_THROW(NotImplemented,"LAPACK not found!");
    │ │ │ │ +
    102#endif
    │ │ │ │ +
    103 }
    │ │ │ │ +
    │ │ │ │ +
    104 }
    │ │ │ │ +
    │ │ │ │ +
    105
    │ │ │ │ +
    106}
    │ │ │ │ +
    108#endif
    │ │ │ │ +
    Eigenvalue computations for the FieldMatrix class.
    │ │ │ │ +
    This file implements a dense matrix with dynamic numbers of rows and columns.
    │ │ │ │ +
    #define DUNE_THROW(E, m)
    Definition exceptions.hh:218
    │ │ │ │
    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
    │ │ │ │ +
    static void eigenValuesNonSym(const DynamicMatrix< K > &matrix, DynamicVector< C > &eigenValues, std::vector< DynamicVector< K > > *eigenVectors=nullptr)
    calculates the eigenvalues of a symmetric field matrix
    Definition dynmatrixev.hh:39
    │ │ │ │ +
    constexpr size_type rows() const
    number of rows
    Definition densematrix.hh:709
    │ │ │ │ +
    Construct a matrix with a dynamic size.
    Definition dynmatrix.hh:61
    │ │ │ │ +
    Construct a vector with a dynamic size.
    Definition dynvector.hh:59
    │ │ │ │ +
    void resize(size_type n, value_type c=value_type())
    Definition dynvector.hh:141
    │ │ │ │ +
    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
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,92 +7,142 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -classname.hh │ │ │ │ │ +dynmatrixev.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 (C) 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_DYNMATRIXEIGENVALUES_HH │ │ │ │ │ + 6#define DUNE_DYNMATRIXEIGENVALUES_HH │ │ │ │ │ 7 │ │ │ │ │ - 13#include │ │ │ │ │ - 14#include │ │ │ │ │ - 15#include │ │ │ │ │ - 16#include │ │ │ │ │ - 17#include │ │ │ │ │ - 18 │ │ │ │ │ - 19#if __has_include() && !DISABLE_CXA_DEMANGLE │ │ │ │ │ - 20#define HAVE_CXA_DEMANGLE 1 │ │ │ │ │ - 21#include │ │ │ │ │ - 22#endif // #if HAVE_CXA_DEMANGLE │ │ │ │ │ + 8#include │ │ │ │ │ + 9#include │ │ │ │ │ + 10 │ │ │ │ │ + 11#include "dynmatrix.hh" │ │ │ │ │ + 12#include "fmatrixev.hh" │ │ │ │ │ + 13 │ │ │ │ │ + 22namespace Dune { │ │ │ │ │ 23 │ │ │ │ │ - 24namespace Dune { │ │ │ │ │ +24 namespace DynamicMatrixHelp { │ │ │ │ │ 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 │ │ │ │ │ + 26#if HAVE_LAPACK │ │ │ │ │ + 27 using Dune::FMatrixHelp::eigenValuesNonsymLapackCall; │ │ │ │ │ + 28#endif │ │ │ │ │ + 29 │ │ │ │ │ + 38 template │ │ │ │ │ +39 static void eigenValuesNonSym(const DynamicMatrix& matrix, │ │ │ │ │ + 40 DynamicVector& eigenValues, │ │ │ │ │ + 41 std::vector>* eigenVectors = nullptr │ │ │ │ │ + 42 ) │ │ │ │ │ + 43 { │ │ │ │ │ + 44 │ │ │ │ │ + 45#if HAVE_LAPACK │ │ │ │ │ + 46 { │ │ │ │ │ + 47 const long int N = matrix.rows(); │ │ │ │ │ + 48 const char jobvl = 'n'; │ │ │ │ │ + 49 const char jobvr = eigenVectors ? 'v' : 'n'; │ │ │ │ │ + 50 │ │ │ │ │ + 51 │ │ │ │ │ + 52 // matrix to put into dgeev │ │ │ │ │ + 53 auto matrixVector = std::make_unique(N*N); │ │ │ │ │ + 54 │ │ │ │ │ + 55 // copy matrix │ │ │ │ │ + 56 int row = 0; │ │ │ │ │ + 57 for(int i=0; i(N); │ │ │ │ │ + 67 auto eigenI = std::make_unique(N); │ │ │ │ │ + 68 │ │ │ │ │ + 69 const long int lwork = eigenVectors ? 4*N : 3*N; │ │ │ │ │ + 70 auto work = std::make_unique(lwork); │ │ │ │ │ + 71 auto vr = eigenVectors ? std::make_unique(N*N) : std:: │ │ │ │ │ +unique_ptr{}; │ │ │ │ │ + 72 │ │ │ │ │ + 73 // return value information │ │ │ │ │ + 74 long int info = 0; │ │ │ │ │ + 75 │ │ │ │ │ + 76 // call LAPACK routine (see fmatrixev_ext.cc) │ │ │ │ │ + 77 eigenValuesNonsymLapackCall(&jobvl, &jobvr, &N, matrixVector.get(), &N, │ │ │ │ │ + 78 eigenR.get(), eigenI.get(), nullptr, &N, vr.get(), &N, work.get(), │ │ │ │ │ + 79 &lwork, &info); │ │ │ │ │ + 80 │ │ │ │ │ + 81 if( info != 0 ) │ │ │ │ │ + 82 { │ │ │ │ │ + 83 std::cerr << "For matrix " << matrix << " eigenvalue calculation failed! " │ │ │ │ │ +<< std::endl; │ │ │ │ │ + 84 DUNE_THROW(InvalidStateException,"eigenValues: Eigenvalue calculation │ │ │ │ │ +failed!"); │ │ │ │ │ + 85 } │ │ │ │ │ + 86 │ │ │ │ │ + 87 eigenValues.resize(N); │ │ │ │ │ + 88 for (int i=0; i(eigenR[i], eigenI[i]); │ │ │ │ │ + 90 │ │ │ │ │ + 91 if (eigenVectors) { │ │ │ │ │ + 92 eigenVectors->resize(N); │ │ │ │ │ + 93 for (int i = 0; i < N; ++i) { │ │ │ │ │ + 94 auto& v = (*eigenVectors)[i]; │ │ │ │ │ + 95 v.resize(N); │ │ │ │ │ + 96 std::copy(vr.get() + N*i, vr.get() + N*(i+1), &v[0]); │ │ │ │ │ + 97 } │ │ │ │ │ + 98 } │ │ │ │ │ + 99 } │ │ │ │ │ + 100#else // #if HAVE_LAPACK │ │ │ │ │ + 101 DUNE_THROW(NotImplemented,"LAPACK not found!"); │ │ │ │ │ + 102#endif │ │ │ │ │ + 103 } │ │ │ │ │ + 104 } │ │ │ │ │ + 105 │ │ │ │ │ + 106} │ │ │ │ │ + 108#endif │ │ │ │ │ +fmatrixev.hh │ │ │ │ │ +Eigenvalue computations for the FieldMatrix class. │ │ │ │ │ +dynmatrix.hh │ │ │ │ │ +This file implements a dense matrix with dynamic numbers of rows and columns. │ │ │ │ │ +DUNE_THROW │ │ │ │ │ +#define DUNE_THROW(E, m) │ │ │ │ │ +Definition exceptions.hh:218 │ │ │ │ │ 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 │ │ │ │ │ +Dune::DynamicMatrixHelp::eigenValuesNonSym │ │ │ │ │ +static void eigenValuesNonSym(const DynamicMatrix< K > &matrix, DynamicVector< │ │ │ │ │ +C > &eigenValues, std::vector< DynamicVector< K > > *eigenVectors=nullptr) │ │ │ │ │ +calculates the eigenvalues of a symmetric field matrix │ │ │ │ │ +Definition dynmatrixev.hh:39 │ │ │ │ │ +Dune::DenseMatrix::rows │ │ │ │ │ +constexpr size_type rows() const │ │ │ │ │ +number of rows │ │ │ │ │ +Definition densematrix.hh:709 │ │ │ │ │ +Dune::DynamicMatrix │ │ │ │ │ +Construct a matrix with a dynamic size. │ │ │ │ │ +Definition dynmatrix.hh:61 │ │ │ │ │ +Dune::DynamicVector │ │ │ │ │ +Construct a vector with a dynamic size. │ │ │ │ │ +Definition dynvector.hh:59 │ │ │ │ │ +Dune::DynamicVector::resize │ │ │ │ │ +void resize(size_type n, value_type c=value_type()) │ │ │ │ │ +Definition dynvector.hh:141 │ │ │ │ │ +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 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00098.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: referencehelper.hh File Reference │ │ │ │ +dune-common: propertymap.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,59 +70,78 @@ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ +Classes | │ │ │ │ Namespaces | │ │ │ │ -Typedefs | │ │ │ │ -Functions | │ │ │ │ -Variables
    │ │ │ │ -
    referencehelper.hh File Reference
    │ │ │ │ +Functions
    │ │ │ │ +
    propertymap.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ -
    #include <type_traits>
    │ │ │ │ -#include <functional>
    │ │ │ │ +
    #include <cstddef>
    │ │ │ │ +#include <iterator>
    │ │ │ │ +#include <type_traits>
    │ │ │ │
    │ │ │ │

    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...
     
    struct  Dune::ReadWritePropertyMapTag
     Tag for the category of readable and writable property maps. More...
     
    struct  Dune::LvaluePropertyMapTag
     Tag for the category of lvalue property maps. More...
     
    struct  Dune::PropertyMapTraits< T * >
     
    struct  Dune::PropertyMapTraits< const T * >
     
    struct  Dune::RAPropertyMapHelper< Reference, PropertyMap >
     
    class  Dune::IteratorPropertyMap< RAI, IM, T, R >
     Adapter to turn a random access iterator into a property map. 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...
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

    │ │ │ │ Namespaces

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

    │ │ │ │ -Typedefs

    template<class T >
    using Dune::ResolveRef_t = std::remove_reference_t< decltype(Dune::resolveRef(std::declval< T & >()))>
     Type trait to resolve std::reference_wrapper.
     
    │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

    │ │ │ │ Functions

    template<class T >
    constexpr T & Dune::resolveRef (T &gf) noexcept
     Helper function to resolve std::reference_wrapper.
     
    template<class T >
    const auto & Dune::resolveRef (T &&gf)=delete
     
    template<class T >
    constexpr T & Dune::resolveRef (std::reference_wrapper< T > gf) noexcept
     Helper function to resolve std::reference_wrapper.
     
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

    │ │ │ │ -Variables

    template<class T >
    constexpr bool Dune::IsReferenceWrapper_v = Impl::IsReferenceWrapper<T>::value
     Helper to detect if given type is a std::reference_wrapper.
     
    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)
     
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,42 +6,67 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Namespaces | Typedefs | Functions | Variables │ │ │ │ │ -referencehelper.hh File Reference │ │ │ │ │ +Classes | Namespaces | Functions │ │ │ │ │ +propertymap.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ 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... │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::ReadWritePropertyMapTag │ │ │ │ │ +  Tag for the category of readable and writable property maps. More... │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::LvaluePropertyMapTag │ │ │ │ │ +  Tag for the category of lvalue property maps. More... │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::PropertyMapTraits<_T_*_> │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::PropertyMapTraits<_const_T_*_> │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::RAPropertyMapHelper<_Reference,_PropertyMap_> │ │ │ │ │ +  │ │ │ │ │ + class  Dune::IteratorPropertyMap<_RAI,_IM,_T,_R_> │ │ │ │ │ +  Adapter to turn a random access iterator into a property map. 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... │ │ │ │ │ +  │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ - Typedefs │ │ │ │ │ -template │ │ │ │ │ -using Dune::ResolveRef_t = std::remove_reference_t< decltype(Dune::resolveRef │ │ │ │ │ - (std::declval< T & >()))> │ │ │ │ │ -  Type trait to resolve std::reference_wrapper. │ │ │ │ │ -  │ │ │ │ │ Functions │ │ │ │ │ -template │ │ │ │ │ -constexpr T & Dune::resolveRef (T &gf) noexcept │ │ │ │ │ -  Helper function to resolve std::reference_wrapper. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - const auto & Dune::resolveRef (T &&gf)=delete │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -constexpr T & Dune::resolveRef (std::reference_wrapper< T > gf) noexcept │ │ │ │ │ -  Helper function to resolve std::reference_wrapper. │ │ │ │ │ -  │ │ │ │ │ - Variables │ │ │ │ │ -template │ │ │ │ │ -constexpr bool Dune::IsReferenceWrapper_v = Impl::IsReferenceWrapper::value │ │ │ │ │ -  Helper to detect if given type is a std::reference_wrapper. │ │ │ │ │ +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) │ │ │ │ │   │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00098_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: referencehelper.hh Source File │ │ │ │ +dune-common: propertymap.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,92 +74,307 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    referencehelper.hh
    │ │ │ │ +
    propertymap.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 (C) 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_REFERENCE_HELPER_HH
    │ │ │ │ -
    6#define DUNE_COMMON_REFERENCE_HELPER_HH
    │ │ │ │ +
    5#ifndef DUNE_PROPERTYMAP_HH
    │ │ │ │ +
    6#define DUNE_PROPERTYMAP_HH
    │ │ │ │
    7
    │ │ │ │ -
    8#include <type_traits>
    │ │ │ │ -
    9#include <functional>
    │ │ │ │ -
    10
    │ │ │ │ +
    8#include <cstddef>
    │ │ │ │ +
    9#include <iterator>
    │ │ │ │ +
    10#include <type_traits>
    │ │ │ │
    11
    │ │ │ │ -
    12
    │ │ │ │ -
    13namespace Dune {
    │ │ │ │ +
    12namespace Dune
    │ │ │ │ +
    13{
    │ │ │ │
    14
    │ │ │ │ -
    15namespace Impl {
    │ │ │ │ -
    16
    │ │ │ │ -
    17 template<class T>
    │ │ │ │ -
    18 class IsReferenceWrapper : public std::false_type {};
    │ │ │ │ -
    19
    │ │ │ │ -
    20 template<class T>
    │ │ │ │ -
    21 class IsReferenceWrapper<std::reference_wrapper<T>> : public std::true_type {};
    │ │ │ │ -
    22
    │ │ │ │ -
    23 template<class T>
    │ │ │ │ -
    24 class IsReferenceWrapper<const std::reference_wrapper<T>> : public std::true_type {};
    │ │ │ │ -
    25
    │ │ │ │ -
    26} // namespace Dune::Impl
    │ │ │ │ -
    27
    │ │ │ │ -
    28
    │ │ │ │ -
    34template<class T>
    │ │ │ │ -
    35constexpr bool IsReferenceWrapper_v = Impl::IsReferenceWrapper<T>::value;
    │ │ │ │ -
    36
    │ │ │ │ -
    37
    │ │ │ │ -
    46template<class T>
    │ │ │ │ -
    │ │ │ │ -
    47constexpr T& resolveRef(T& gf) noexcept
    │ │ │ │ -
    48{
    │ │ │ │ -
    49 return gf;
    │ │ │ │ -
    50}
    │ │ │ │ +
    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
    │ │ │ │ -
    52
    │ │ │ │ -
    53// There's no overload for non std::reference_wrapper r-values,
    │ │ │ │ -
    54// because this may lead to undefined behavior whenever the
    │ │ │ │ -
    55// return value is stored.
    │ │ │ │ -
    56// Notice that deleting the overload is not necessary, but
    │ │ │ │ -
    57// helps to document that it is missing on purpose. It also
    │ │ │ │ -
    58// leads to nicer error messages.
    │ │ │ │ -
    59template<class T>
    │ │ │ │ -
    60const auto& resolveRef(T&& gf) = delete;
    │ │ │ │ -
    61
    │ │ │ │ -
    62
    │ │ │ │ -
    81template<class T>
    │ │ │ │ -
    │ │ │ │ -
    82constexpr T& resolveRef(std::reference_wrapper<T> gf) noexcept
    │ │ │ │ -
    83{
    │ │ │ │ -
    84 return gf.get();
    │ │ │ │ -
    85}
    │ │ │ │ -
    │ │ │ │ -
    86
    │ │ │ │ -
    87
    │ │ │ │ -
    88
    │ │ │ │ -
    99template<class T>
    │ │ │ │ -
    100using ResolveRef_t = std::remove_reference_t<decltype(Dune::resolveRef(std::declval<T&>()))>;
    │ │ │ │ -
    101
    │ │ │ │ -
    102
    │ │ │ │ -
    103} // namespace Dune
    │ │ │ │ -
    104
    │ │ │ │ -
    105
    │ │ │ │ -
    106
    │ │ │ │ -
    107#endif // DUNE_COMMON_REFERENCE_HELPER_HH
    │ │ │ │ -
    constexpr bool IsReferenceWrapper_v
    Helper to detect if given type is a std::reference_wrapper.
    Definition referencehelper.hh:35
    │ │ │ │ -
    constexpr T & resolveRef(T &gf) noexcept
    Helper function to resolve std::reference_wrapper.
    Definition referencehelper.hh:47
    │ │ │ │ -
    STL namespace.
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ +
    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> >
    │ │ │ │ +
    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;
    │ │ │ │ +
    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
    │ │ │ │
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ -
    std::remove_reference_t< decltype(Dune::resolveRef(std::declval< T & >()))> ResolveRef_t
    Type trait to resolve std::reference_wrapper.
    Definition referencehelper.hh:100
    │ │ │ │ +
    void put(const RAPropertyMapHelper< Reference, PropertyMap > &pmap, const Key &key, const Value &value)
    Definition propertymap.hh:92
    │ │ │ │ +
    Reference get(const RAPropertyMapHelper< Reference, PropertyMap > &pmap, const Key &key)
    Definition propertymap.hh:84
    │ │ │ │ +
    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
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,100 +7,369 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -referencehelper.hh │ │ │ │ │ +propertymap.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 (C) 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_REFERENCE_HELPER_HH │ │ │ │ │ - 6#define DUNE_COMMON_REFERENCE_HELPER_HH │ │ │ │ │ + 5#ifndef DUNE_PROPERTYMAP_HH │ │ │ │ │ + 6#define DUNE_PROPERTYMAP_HH │ │ │ │ │ 7 │ │ │ │ │ - 8#include │ │ │ │ │ - 9#include │ │ │ │ │ - 10 │ │ │ │ │ + 8#include │ │ │ │ │ + 9#include │ │ │ │ │ + 10#include │ │ │ │ │ 11 │ │ │ │ │ - 12 │ │ │ │ │ - 13namespace Dune { │ │ │ │ │ + 12namespace Dune │ │ │ │ │ + 13{ │ │ │ │ │ 14 │ │ │ │ │ - 15namespace Impl { │ │ │ │ │ - 16 │ │ │ │ │ - 17 template │ │ │ │ │ - 18 class IsReferenceWrapper : public std::false_type {}; │ │ │ │ │ - 19 │ │ │ │ │ - 20 template │ │ │ │ │ - 21 class IsReferenceWrapper> : public std::true_type │ │ │ │ │ -{}; │ │ │ │ │ - 22 │ │ │ │ │ - 23 template │ │ │ │ │ - 24 class IsReferenceWrapper> : public std:: │ │ │ │ │ -true_type {}; │ │ │ │ │ - 25 │ │ │ │ │ - 26} // namespace Dune::Impl │ │ │ │ │ - 27 │ │ │ │ │ - 28 │ │ │ │ │ - 34template │ │ │ │ │ -35constexpr bool IsReferenceWrapper_v = Impl::IsReferenceWrapper::value; │ │ │ │ │ - 36 │ │ │ │ │ - 37 │ │ │ │ │ - 46template │ │ │ │ │ -47constexpr T& resolveRef(T& gf) noexcept │ │ │ │ │ - 48{ │ │ │ │ │ - 49 return gf; │ │ │ │ │ - 50} │ │ │ │ │ + 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 │ │ │ │ │ - 52 │ │ │ │ │ - 53// There's no overload for non std::reference_wrapper r-values, │ │ │ │ │ - 54// because this may lead to undefined behavior whenever the │ │ │ │ │ - 55// return value is stored. │ │ │ │ │ - 56// Notice that deleting the overload is not necessary, but │ │ │ │ │ - 57// helps to document that it is missing on purpose. It also │ │ │ │ │ - 58// leads to nicer error messages. │ │ │ │ │ - 59template │ │ │ │ │ -60const auto& resolveRef(T&& gf) = delete; │ │ │ │ │ - 61 │ │ │ │ │ - 62 │ │ │ │ │ - 81template │ │ │ │ │ -82constexpr T& resolveRef(std::reference_wrapper gf) noexcept │ │ │ │ │ - 83{ │ │ │ │ │ - 84 return gf.get(); │ │ │ │ │ - 85} │ │ │ │ │ - 86 │ │ │ │ │ - 87 │ │ │ │ │ - 88 │ │ │ │ │ - 99template │ │ │ │ │ -100using ResolveRef_t = std::remove_reference_t()))>; │ │ │ │ │ - 101 │ │ │ │ │ - 102 │ │ │ │ │ - 103} // namespace Dune │ │ │ │ │ - 104 │ │ │ │ │ - 105 │ │ │ │ │ - 106 │ │ │ │ │ - 107#endif // DUNE_COMMON_REFERENCE_HELPER_HH │ │ │ │ │ -Dune::IsReferenceWrapper_v │ │ │ │ │ -constexpr bool IsReferenceWrapper_v │ │ │ │ │ -Helper to detect if given type is a std::reference_wrapper. │ │ │ │ │ -Definition referencehelper.hh:35 │ │ │ │ │ -Dune::resolveRef │ │ │ │ │ -constexpr T & resolveRef(T &gf) noexcept │ │ │ │ │ -Helper function to resolve std::reference_wrapper. │ │ │ │ │ -Definition referencehelper.hh:47 │ │ │ │ │ -std │ │ │ │ │ -STL namespace. │ │ │ │ │ +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 > │ │ │ │ │ + 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; │ │ │ │ │ + 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 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::ResolveRef_t │ │ │ │ │ -std::remove_reference_t< decltype(Dune::resolveRef(std::declval< T & >()))> │ │ │ │ │ -ResolveRef_t │ │ │ │ │ -Type trait to resolve std::reference_wrapper. │ │ │ │ │ -Definition referencehelper.hh:100 │ │ │ │ │ +Dune::put │ │ │ │ │ +void put(const RAPropertyMapHelper< Reference, PropertyMap > &pmap, const Key │ │ │ │ │ +&key, const Value &value) │ │ │ │ │ +Definition propertymap.hh:92 │ │ │ │ │ +Dune::get │ │ │ │ │ +Reference get(const RAPropertyMapHelper< Reference, PropertyMap > &pmap, const │ │ │ │ │ +Key &key) │ │ │ │ │ +Definition propertymap.hh:84 │ │ │ │ │ +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 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00101.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: path.cc File Reference │ │ │ │ +dune-common: ios_state.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,59 +70,41 @@ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ -Namespaces | │ │ │ │ -Functions
    │ │ │ │ -
    path.cc File Reference
    │ │ │ │ +Classes | │ │ │ │ +Namespaces
    │ │ │ │ +
    ios_state.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ -

    Utilities for handling filesystem paths. │ │ │ │ +

    Utility class for storing and resetting stream attributes. │ │ │ │ More...

    │ │ │ │ -
    #include <algorithm>
    │ │ │ │ -#include <iterator>
    │ │ │ │ -#include <string>
    │ │ │ │ -#include <dune/common/exceptions.hh>
    │ │ │ │ -#include <dune/common/stringutility.hh>
    │ │ │ │ -#include <dune/common/path.hh>
    │ │ │ │ -
    │ │ │ │ +
    #include <ios>
    │ │ │ │ +
    │ │ │ │ +

    Go to the source code of this file.

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

    │ │ │ │ +Classes

    class  Dune::ios_base_all_saver
     Utility class for storing and resetting stream attributes. 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
     
    │ │ │ │

    Detailed Description

    │ │ │ │ -

    Utilities for handling filesystem paths.

    │ │ │ │ -
    Author
    Jö Fahlke jorri.nosp@m.t@jo.nosp@m.rrit..nosp@m.de
    │ │ │ │ +

    Utility class for storing and resetting stream attributes.

    │ │ │ │ +
    Author
    Markus Blatt
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── encoding │ │ │ │ │ @@ -1 +1 @@ │ │ │ │ │ -utf-8 │ │ │ │ │ +us-ascii │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,48 +6,28 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Namespaces | Functions │ │ │ │ │ -path.cc File Reference │ │ │ │ │ -Common » Utilities » Filesystem_Paths │ │ │ │ │ -Utilities for handling filesystem paths. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +ios_state.hh File Reference │ │ │ │ │ +Common │ │ │ │ │ +Utility class for storing and resetting stream attributes. More... │ │ │ │ │ +#include │ │ │ │ │ +Go_to_the_source_code_of_this_file. │ │ │ │ │ + Classes │ │ │ │ │ +class  Dune::ios_base_all_saver │ │ │ │ │ +  Utility class for storing and resetting stream attributes. 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 │ │ │ │ │ -  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Utilities for handling filesystem paths. │ │ │ │ │ +Utility class for storing and resetting stream attributes. │ │ │ │ │ Author │ │ │ │ │ - Jö Fahlke jorri.nosp@m.t@jo.nosp@m.rrit..nosp@m.de │ │ │ │ │ + Markus Blatt │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00104.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: power.hh File Reference │ │ │ │ +dune-common: classname.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,43 +70,49 @@ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ -Classes | │ │ │ │ -Namespaces
    │ │ │ │ -
    power.hh File Reference
    │ │ │ │ +Namespaces | │ │ │ │ +Functions
    │ │ │ │ +
    classname.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ -

    Various implementations of the power function for run-time and static arguments. │ │ │ │ +

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

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

    Go to the source code of this file.

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

    │ │ │ │ -Classes

    struct  Dune::StaticPower< b, p >
     Calculates b^p at compile time. More...
     
    struct  Dune::Power< p >
     Compute power for a run-time base and a compile-time integer exponent. More...
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ +

    │ │ │ │ Namespaces

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

    │ │ │ │ +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.
     
    │ │ │ │

    Detailed Description

    │ │ │ │ -

    Various implementations of the power function for run-time and static arguments.

    │ │ │ │ +

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

    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,31 +6,36 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -power.hh File Reference │ │ │ │ │ -Various implementations of the power function for run-time and static │ │ │ │ │ -arguments. More... │ │ │ │ │ -#include │ │ │ │ │ +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 │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ - Classes │ │ │ │ │ -struct  Dune::StaticPower<_b,_p_> │ │ │ │ │ -  Calculates b^p at compile time. More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::Power<_p_> │ │ │ │ │ -  Compute power for a run-time base and a compile-time integer exponent. │ │ │ │ │ - More... │ │ │ │ │ -  │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ + Functions │ │ │ │ │ +template │ │ │ │ │ +std::string Dune::className () │ │ │ │ │ +  Provide the demangled class name of a type T as a string. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +std::string Dune::className (T &&v) │ │ │ │ │ +  Provide the demangled class name of a given object as a string. │ │ │ │ │ +  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Various implementations of the power function for run-time and static │ │ │ │ │ -arguments. │ │ │ │ │ +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/a00104_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: power.hh Source File │ │ │ │ +dune-common: classname.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,63 +74,95 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    power.hh
    │ │ │ │ +
    classname.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 (C) 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_POWER_HH
    │ │ │ │ -
    6#define DUNE_COMMON_POWER_HH
    │ │ │ │ +
    5#ifndef DUNE_CLASSNAME_HH
    │ │ │ │ +
    6#define DUNE_CLASSNAME_HH
    │ │ │ │
    7
    │ │ │ │ -
    8#warning The header power.hh is deprecated. Use power from math.hh instead.
    │ │ │ │ -
    9
    │ │ │ │ -
    14#include <dune/common/math.hh>
    │ │ │ │ -
    15
    │ │ │ │ -
    16namespace Dune {
    │ │ │ │ -
    17
    │ │ │ │ -
    26 template <int b, int p>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    28 {
    │ │ │ │ -
    30 static constexpr int power = Dune::power(b,p);
    │ │ │ │ -
    31 };
    │ │ │ │ -
    │ │ │ │ -
    32
    │ │ │ │ -
    33
    │ │ │ │ -
    40 template <int p>
    │ │ │ │ -
    │ │ │ │ -
    41 struct Power
    │ │ │ │ -
    42 {
    │ │ │ │ -
    43 template <typename T>
    │ │ │ │ -
    │ │ │ │ -
    44 static constexpr auto eval(const T & a)
    │ │ │ │ -
    45 {
    │ │ │ │ -
    46 return power(a,p);
    │ │ │ │ -
    47 }
    │ │ │ │ -
    │ │ │ │ -
    48 };
    │ │ │ │ -
    │ │ │ │ -
    49
    │ │ │ │ -
    50}
    │ │ │ │ -
    51
    │ │ │ │ -
    52#endif
    │ │ │ │ -
    Some useful basic math stuff.
    │ │ │ │ -
    static constexpr int power
    power stores b^p
    Definition power.hh:30
    │ │ │ │ -
    static constexpr auto eval(const T &a)
    Definition power.hh:44
    │ │ │ │ +
    13#include <cstdlib>
    │ │ │ │ +
    14#include <memory>
    │ │ │ │ +
    15#include <string>
    │ │ │ │ +
    16#include <typeinfo>
    │ │ │ │ +
    17#include <type_traits>
    │ │ │ │ +
    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>
    │ │ │ │ +
    │ │ │ │ +
    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
    │ │ │ │ -
    constexpr Base power(Base m, Exponent p)
    Power method for integer exponents.
    Definition math.hh:75
    │ │ │ │ -
    Calculates b^p at compile time.
    Definition power.hh:28
    │ │ │ │ -
    Compute power for a run-time base and a compile-time integer exponent.
    Definition power.hh:42
    │ │ │ │ +
    std::string className()
    Provide the demangled class name of a type T as a string.
    Definition classname.hh:47
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,68 +7,92 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -power.hh │ │ │ │ │ +classname.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 (C) 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_POWER_HH │ │ │ │ │ - 6#define DUNE_COMMON_POWER_HH │ │ │ │ │ + 5#ifndef DUNE_CLASSNAME_HH │ │ │ │ │ + 6#define DUNE_CLASSNAME_HH │ │ │ │ │ 7 │ │ │ │ │ - 8#warning The header power.hh is deprecated. Use power from math.hh instead. │ │ │ │ │ - 9 │ │ │ │ │ - 14#include │ │ │ │ │ - 15 │ │ │ │ │ - 16namespace Dune { │ │ │ │ │ - 17 │ │ │ │ │ - 26 template │ │ │ │ │ -27 struct StaticPower │ │ │ │ │ - 28 { │ │ │ │ │ -30 static constexpr int power = Dune::power(b,p); │ │ │ │ │ - 31 }; │ │ │ │ │ - 32 │ │ │ │ │ - 33 │ │ │ │ │ - 40 template │ │ │ │ │ -41 struct Power │ │ │ │ │ - 42 { │ │ │ │ │ - 43 template │ │ │ │ │ -44 static constexpr auto eval(const T & a) │ │ │ │ │ - 45 { │ │ │ │ │ - 46 return power(a,p); │ │ │ │ │ - 47 } │ │ │ │ │ - 48 }; │ │ │ │ │ - 49 │ │ │ │ │ - 50} │ │ │ │ │ - 51 │ │ │ │ │ - 52#endif │ │ │ │ │ -math.hh │ │ │ │ │ -Some useful basic math stuff. │ │ │ │ │ -Dune::StaticPower::power │ │ │ │ │ -static constexpr int power │ │ │ │ │ -power stores b^p │ │ │ │ │ -Definition power.hh:30 │ │ │ │ │ -Dune::Power::eval │ │ │ │ │ -static constexpr auto eval(const T &a) │ │ │ │ │ -Definition power.hh:44 │ │ │ │ │ + 13#include │ │ │ │ │ + 14#include │ │ │ │ │ + 15#include │ │ │ │ │ + 16#include │ │ │ │ │ + 17#include │ │ │ │ │ + 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::power │ │ │ │ │ -constexpr Base power(Base m, Exponent p) │ │ │ │ │ -Power method for integer exponents. │ │ │ │ │ -Definition math.hh:75 │ │ │ │ │ -Dune::StaticPower │ │ │ │ │ -Calculates b^p at compile time. │ │ │ │ │ -Definition power.hh:28 │ │ │ │ │ -Dune::Power │ │ │ │ │ -Compute power for a run-time base and a compile-time integer exponent. │ │ │ │ │ -Definition power.hh:42 │ │ │ │ │ +Dune::className │ │ │ │ │ +std::string className() │ │ │ │ │ +Provide the demangled class name of a type T as a string. │ │ │ │ │ +Definition classname.hh:47 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00107.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: filledarray.hh File Reference │ │ │ │ +dune-common: precision.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,42 +70,40 @@ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ -Namespaces | │ │ │ │ -Functions
    │ │ │ │ -
    filledarray.hh File Reference
    │ │ │ │ +Classes | │ │ │ │ +Namespaces
    │ │ │ │ +
    precision.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ -

    Utility to generate an array with a certain value. │ │ │ │ +

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

    │ │ │ │ -
    #include <array>
    │ │ │ │ -#include <cstddef>
    │ │ │ │ +
    #include <stdlib.h>
    │ │ │ │
    │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ +Classes

    class  Dune::FMatrixPrecision< ctype >
     Precisions for calculations with FieldMatrix and FieldVector. More...
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

    │ │ │ │ Namespaces

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

    │ │ │ │ -Functions

    template<std::size_t n, class T >
    constexpr std::array< T, n > Dune::filledArray (const T &t)
     Return an array filled with the provided value.
     
    │ │ │ │

    Detailed Description

    │ │ │ │ -

    Utility to generate an array with a certain value.

    │ │ │ │ +

    Various precision settings for calculations with FieldMatrix and FieldVector.

    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,27 +6,26 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Namespaces | Functions │ │ │ │ │ -filledarray.hh File Reference │ │ │ │ │ -Utility to generate an array with a certain value. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +precision.hh File Reference │ │ │ │ │ +Various precision settings for calculations with FieldMatrix and FieldVector. │ │ │ │ │ +More... │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ + Classes │ │ │ │ │ +class  Dune::FMatrixPrecision<_ctype_> │ │ │ │ │ +  Precisions for calculations with FieldMatrix and FieldVector. More... │ │ │ │ │ +  │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ - Functions │ │ │ │ │ -template │ │ │ │ │ -constexpr std::array< T, n > Dune::filledArray (const T &t) │ │ │ │ │ -  Return an array filled with the provided value. │ │ │ │ │ -  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Utility to generate an array with a certain value. │ │ │ │ │ +Various precision settings for calculations with FieldMatrix and FieldVector. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00107_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: filledarray.hh Source File │ │ │ │ +dune-common: precision.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,48 +74,62 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    filledarray.hh
    │ │ │ │ +
    precision.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 (C) 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_FILLED_ARRAY_HH
    │ │ │ │ -
    7#define DUNE_COMMON_FILLED_ARRAY_HH
    │ │ │ │ -
    8
    │ │ │ │ -
    13#include <array>
    │ │ │ │ -
    14#include <cstddef>
    │ │ │ │ +
    5#ifndef DUNE_PRECISION_HH
    │ │ │ │ +
    6#define DUNE_PRECISION_HH
    │ │ │ │ +
    7
    │ │ │ │ +
    12#include <stdlib.h>
    │ │ │ │ +
    13
    │ │ │ │ +
    14namespace Dune {
    │ │ │ │
    15
    │ │ │ │ -
    16namespace Dune
    │ │ │ │ -
    17{
    │ │ │ │ -
    24
    │ │ │ │ -
    32 template<std::size_t n, class T>
    │ │ │ │ -
    │ │ │ │ -
    33 constexpr std::array<T, n> filledArray(const T& t)
    │ │ │ │ -
    34 {
    │ │ │ │ -
    35 std::array<T, n> arr{};
    │ │ │ │ -
    36 // this is constexpr in c++17, `arr.fill(t)` is not
    │ │ │ │ -
    37 for(auto &el : arr)
    │ │ │ │ -
    38 el = t;
    │ │ │ │ -
    39 return arr;
    │ │ │ │ -
    40 }
    │ │ │ │ -
    │ │ │ │ -
    41
    │ │ │ │ -
    44} // end namespace Dune
    │ │ │ │ -
    45
    │ │ │ │ -
    46#endif // DUNE_COMMON_FILLED_ARRAY_HH
    │ │ │ │ -
    constexpr std::array< T, n > filledArray(const T &t)
    Return an array filled with the provided value.
    Definition filledarray.hh:33
    │ │ │ │ +
    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;
    │ │ │ │ +
    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
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,47 +7,62 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -filledarray.hh │ │ │ │ │ +precision.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 (C) 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_FILLED_ARRAY_HH │ │ │ │ │ - 7#define DUNE_COMMON_FILLED_ARRAY_HH │ │ │ │ │ - 8 │ │ │ │ │ - 13#include │ │ │ │ │ - 14#include │ │ │ │ │ + 5#ifndef DUNE_PRECISION_HH │ │ │ │ │ + 6#define DUNE_PRECISION_HH │ │ │ │ │ + 7 │ │ │ │ │ + 12#include │ │ │ │ │ + 13 │ │ │ │ │ + 14namespace Dune { │ │ │ │ │ 15 │ │ │ │ │ - 16namespace Dune │ │ │ │ │ - 17{ │ │ │ │ │ - 24 │ │ │ │ │ - 32 template │ │ │ │ │ -33 constexpr std::array filledArray(const T& t) │ │ │ │ │ - 34 { │ │ │ │ │ - 35 std::array arr{}; │ │ │ │ │ - 36 // this is constexpr in c++17, `arr.fill(t)` is not │ │ │ │ │ - 37 for(auto &el : arr) │ │ │ │ │ - 38 el = t; │ │ │ │ │ - 39 return arr; │ │ │ │ │ - 40 } │ │ │ │ │ - 41 │ │ │ │ │ - 44} // end namespace Dune │ │ │ │ │ - 45 │ │ │ │ │ - 46#endif // DUNE_COMMON_FILLED_ARRAY_HH │ │ │ │ │ -Dune::filledArray │ │ │ │ │ -constexpr std::array< T, n > filledArray(const T &t) │ │ │ │ │ -Return an array filled with the provided value. │ │ │ │ │ -Definition filledarray.hh:33 │ │ │ │ │ + 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; │ │ │ │ │ + 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 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00110.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: streamoperators.hh File Reference │ │ │ │ +dune-common: matvectraits.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,52 +70,38 @@ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ -Namespaces | │ │ │ │ -Functions
    │ │ │ │ -
    streamoperators.hh File Reference
    │ │ │ │ +Classes | │ │ │ │ +Namespaces
    │ │ │ │ +
    matvectraits.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ -

    Implementation of stream operators for std::array and std::tuple. │ │ │ │ +

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

    │ │ │ │ -
    #include <array>
    │ │ │ │ -#include <tuple>
    │ │ │ │ -#include <utility>
    │ │ │ │ -#include <dune/common/hybridutilities.hh>
    │ │ │ │ -
    │ │ │ │ + │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ +Classes

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

    │ │ │ │ Namespaces

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

    │ │ │ │ -Functions

    template<typename Stream , typename... Ts>
    Stream & Dune::operator<< (Stream &stream, const std::tuple< Ts... > &t)
     Print a std::tuple.
     
    template<typename Stream , typename... Ts>
    Stream & Dune::operator>> (Stream &stream, std::tuple< Ts... > &t)
     Read a std::tuple.
     
    template<typename Stream , typename T , std::size_t N>
    Stream & Dune::operator<< (Stream &stream, const std::array< T, N > &a)
     Print a std::array.
     
    │ │ │ │

    Detailed Description

    │ │ │ │ -

    Implementation of stream operators for std::array and std::tuple.

    │ │ │ │ +

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

    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,37 +6,25 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Namespaces | Functions │ │ │ │ │ -streamoperators.hh File Reference │ │ │ │ │ -Implementation of stream operators for std::array and std::tuple. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +matvectraits.hh File Reference │ │ │ │ │ +Documentation of the traits classes you need to write for each implementation │ │ │ │ │ +of DenseVector or DenseMatrix. More... │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ + Classes │ │ │ │ │ +struct  Dune::DenseMatVecTraits<_T_> │ │ │ │ │ +  │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ - Functions │ │ │ │ │ -template │ │ │ │ │ -Stream & Dune::operator<< (Stream &stream, const std::tuple< Ts... > &t) │ │ │ │ │ -  Print a std::tuple. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -Stream & Dune::operator>> (Stream &stream, std::tuple< Ts... > &t) │ │ │ │ │ -  Read a std::tuple. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -Stream & Dune::operator<< (Stream &stream, const std::array< T, N > &a) │ │ │ │ │ -  Print a std::array. │ │ │ │ │ -  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Implementation of stream operators for std::array and std::tuple. │ │ │ │ │ +Documentation of the traits classes you need to write for each implementation │ │ │ │ │ +of DenseVector or DenseMatrix. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00110_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: streamoperators.hh Source File │ │ │ │ +dune-common: matvectraits.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,83 +74,37 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    streamoperators.hh
    │ │ │ │ +
    matvectraits.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 (C) 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_STREAMOPERATORS_HH
    │ │ │ │ -
    7#define DUNE_STREAMOPERATORS_HH
    │ │ │ │ -
    8
    │ │ │ │ -
    13#include <array>
    │ │ │ │ -
    14#include <tuple>
    │ │ │ │ -
    15#include <utility>
    │ │ │ │ -
    16
    │ │ │ │ - │ │ │ │ -
    18
    │ │ │ │ -
    19namespace Dune
    │ │ │ │ -
    20{
    │ │ │ │ -
    27 template<typename Stream, typename... Ts>
    │ │ │ │ -
    │ │ │ │ -
    28 inline Stream& operator<<(Stream& stream, const std::tuple<Ts...>& t)
    │ │ │ │ -
    29 {
    │ │ │ │ -
    30 stream<<"[";
    │ │ │ │ -
    31 if(sizeof...(Ts)>0)
    │ │ │ │ -
    32 {
    │ │ │ │ -
    33 Hybrid::forEach(std::make_index_sequence<sizeof...(Ts)-1>{},
    │ │ │ │ -
    34 [&](auto i){stream<<std::get<i>(t)<<",";});
    │ │ │ │ -
    35 stream<<std::get<sizeof...(Ts)-1>(t);
    │ │ │ │ -
    36 }
    │ │ │ │ -
    37 stream<<"]";
    │ │ │ │ -
    38 return stream;
    │ │ │ │ -
    39 }
    │ │ │ │ -
    │ │ │ │ -
    40
    │ │ │ │ -
    42 template<typename Stream, typename... Ts>
    │ │ │ │ -
    │ │ │ │ -
    43 inline Stream& operator>>(Stream& stream, std::tuple<Ts...>& t)
    │ │ │ │ -
    44 {
    │ │ │ │ -
    45 Hybrid::forEach(std::make_index_sequence<sizeof...(Ts)>{},
    │ │ │ │ -
    46 [&](auto i){stream>>std::get<i>(t);});
    │ │ │ │ -
    47 return stream;
    │ │ │ │ -
    48 }
    │ │ │ │ -
    │ │ │ │ -
    49
    │ │ │ │ -
    51 template<typename Stream, typename T, std::size_t N>
    │ │ │ │ -
    │ │ │ │ -
    52 inline Stream& operator<<(Stream& stream, const std::array<T,N>& a)
    │ │ │ │ -
    53 {
    │ │ │ │ -
    54 stream<<"[";
    │ │ │ │ -
    55 if(N>0)
    │ │ │ │ -
    56 {
    │ │ │ │ -
    57 for(std::size_t i=0; i<N-1; ++i)
    │ │ │ │ -
    58 stream<<a[i]<<",";
    │ │ │ │ -
    59 stream<<a[N-1];
    │ │ │ │ -
    60 }
    │ │ │ │ -
    61 stream<<"]";
    │ │ │ │ -
    62 return stream;
    │ │ │ │ -
    63 }
    │ │ │ │ -
    │ │ │ │ -
    64
    │ │ │ │ -
    67} // end namespace Dune
    │ │ │ │ -
    68
    │ │ │ │ -
    69#endif
    │ │ │ │ - │ │ │ │ -
    Stream & operator>>(Stream &stream, std::tuple< Ts... > &t)
    Read a std::tuple.
    Definition streamoperators.hh:43
    │ │ │ │ -
    constexpr void forEach(Range &&range, F &&f)
    Range based for loop.
    Definition hybridutilities.hh:268
    │ │ │ │ -
    std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x)
    Definition bigunsignedint.hh:278
    │ │ │ │ +
    5#ifndef DUNE_MATVECTRAITS_HH
    │ │ │ │ +
    6#define DUNE_MATVECTRAITS_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
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,83 +7,36 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -streamoperators.hh │ │ │ │ │ +matvectraits.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 (C) 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_STREAMOPERATORS_HH │ │ │ │ │ - 7#define DUNE_STREAMOPERATORS_HH │ │ │ │ │ - 8 │ │ │ │ │ - 13#include │ │ │ │ │ - 14#include │ │ │ │ │ - 15#include │ │ │ │ │ - 16 │ │ │ │ │ - 17#include │ │ │ │ │ - 18 │ │ │ │ │ - 19namespace Dune │ │ │ │ │ - 20{ │ │ │ │ │ - 27 template │ │ │ │ │ -28 inline Stream& operator<<(Stream& stream, const std::tuple& t) │ │ │ │ │ - 29 { │ │ │ │ │ - 30 stream<<"["; │ │ │ │ │ - 31 if(sizeof...(Ts)>0) │ │ │ │ │ - 32 { │ │ │ │ │ - 33 Hybrid::forEach(std::make_index_sequence{}, │ │ │ │ │ - 34 [&](auto i){stream<(t)<<",";}); │ │ │ │ │ - 35 stream<(t); │ │ │ │ │ - 36 } │ │ │ │ │ - 37 stream<<"]"; │ │ │ │ │ - 38 return stream; │ │ │ │ │ - 39 } │ │ │ │ │ - 40 │ │ │ │ │ - 42 template │ │ │ │ │ -43 inline Stream& operator>>(Stream& stream, std::tuple& t) │ │ │ │ │ - 44 { │ │ │ │ │ - 45 Hybrid::forEach(std::make_index_sequence{}, │ │ │ │ │ - 46 [&](auto i){stream>>std::get(t);}); │ │ │ │ │ - 47 return stream; │ │ │ │ │ - 48 } │ │ │ │ │ - 49 │ │ │ │ │ - 51 template │ │ │ │ │ -52 inline Stream& operator<<(Stream& stream, const std::array& a) │ │ │ │ │ - 53 { │ │ │ │ │ - 54 stream<<"["; │ │ │ │ │ - 55 if(N>0) │ │ │ │ │ - 56 { │ │ │ │ │ - 57 for(std::size_t i=0; i> │ │ │ │ │ -Stream & operator>>(Stream &stream, std::tuple< Ts... > &t) │ │ │ │ │ -Read a std::tuple. │ │ │ │ │ -Definition streamoperators.hh:43 │ │ │ │ │ -Dune::Hybrid::forEach │ │ │ │ │ -constexpr void forEach(Range &&range, F &&f) │ │ │ │ │ -Range based for loop. │ │ │ │ │ -Definition hybridutilities.hh:268 │ │ │ │ │ -Dune::operator<< │ │ │ │ │ -std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x) │ │ │ │ │ -Definition bigunsignedint.hh:278 │ │ │ │ │ + 5#ifndef DUNE_MATVECTRAITS_HH │ │ │ │ │ + 6#define DUNE_MATVECTRAITS_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 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00113.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: exceptions.hh File Reference │ │ │ │ +dune-common: math.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,78 +74,193 @@ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ Classes | │ │ │ │ Namespaces | │ │ │ │ Macros | │ │ │ │ Functions
    │ │ │ │ -
    exceptions.hh File Reference
    │ │ │ │ +
    math.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ -

    A few common exception classes. │ │ │ │ +

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

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

    Go to the source code of this file.

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

    │ │ │ │ Classes

    class  Dune::Exception
     Base class for Dune-Exceptions. More...
    struct  Dune::StandardMathematicalConstants< T >
     Standard implementation of MathematicalConstants. More...
     
    struct  Dune::ExceptionHook
     Base class to add a hook to the Dune::Exception. More...
    struct  Dune::MathematicalConstants< Field >
     Provides commonly used mathematical constants. More...
     
    class  Dune::IOError
     Default exception class for I/O errors. More...
    struct  Dune::Factorial< m >
     
    class  Dune::MathError
     Default exception class for mathematical errors. More...
    struct  Dune::Factorial< 0 >
     end of recursion of factorial via specialization More...
     
    class  Dune::RangeError
     Default exception class for range errors. More...
    struct  Dune::MathOverloads::ADLTag
     Tag to make sure the functions in this namespace can be found by ADL. More...
     
    class  Dune::NotImplemented
     Default exception for dummy implementations. More...
     
    class  Dune::SystemError
     Default exception class for OS errors. More...
     
    class  Dune::OutOfMemoryError
     Default exception if memory allocation fails. 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::ParallelError
     Default exception if an error in the parallel communication of the program occurred. 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_THROW(E, m)
     
    #define DUNE_COMMON_MATH_ISFUNCTION(function, stdfunction)
     
    #define DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR(function)
     
    │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

    │ │ │ │ Functions

    std::ostream & Dune::operator<< (std::ostream &stream, const Exception &e)
     
    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

    │ │ │ │ -

    A few common exception classes.

    │ │ │ │ -

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

    │ │ │ │ -
    │ │ │ │ +

    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 {} │ │ │ │ │ @@ -7,64 +7,155 @@ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ Classes | Namespaces | Macros | Functions │ │ │ │ │ -exceptions.hh File Reference │ │ │ │ │ -Common » Exception_handling │ │ │ │ │ -A few common exception classes. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +math.hh File Reference │ │ │ │ │ +Some useful basic math stuff. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ - class  Dune::Exception │ │ │ │ │ -  Base class for Dune-Exceptions. More... │ │ │ │ │ +struct  Dune::StandardMathematicalConstants<_T_> │ │ │ │ │ +  Standard implementation of MathematicalConstants. More... │ │ │ │ │   │ │ │ │ │ -struct  Dune::ExceptionHook │ │ │ │ │ -  Base class to add a hook to the Dune::Exception. More... │ │ │ │ │ +struct  Dune::MathematicalConstants<_Field_> │ │ │ │ │ +  Provides commonly used mathematical constants. More... │ │ │ │ │   │ │ │ │ │ - class  Dune::IOError │ │ │ │ │ -  Default exception class for I/O errors. More... │ │ │ │ │ +struct  Dune::Factorial<_m_> │ │ │ │ │   │ │ │ │ │ - class  Dune::MathError │ │ │ │ │ -  Default exception class for mathematical errors. More... │ │ │ │ │ +struct  Dune::Factorial<_0_> │ │ │ │ │ +  end of recursion of factorial via specialization More... │ │ │ │ │   │ │ │ │ │ - class  Dune::RangeError │ │ │ │ │ -  Default exception class for range errors. More... │ │ │ │ │ +struct  Dune::MathOverloads::ADLTag │ │ │ │ │ +  Tag to make sure the functions in this namespace can be found by ADL. │ │ │ │ │ + More... │ │ │ │ │   │ │ │ │ │ - class  Dune::NotImplemented │ │ │ │ │ -  Default exception for dummy implementations. More... │ │ │ │ │ -  │ │ │ │ │ - class  Dune::SystemError │ │ │ │ │ -  Default exception class for OS errors. More... │ │ │ │ │ -  │ │ │ │ │ - class  Dune::OutOfMemoryError │ │ │ │ │ -  Default exception if memory allocation fails. 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::ParallelError │ │ │ │ │ -  Default exception if an error in the parallel communication of the │ │ │ │ │ - program occurred. 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_THROW(E, m) │ │ │ │ │ +#define DUNE_COMMON_MATH_ISFUNCTION(function, stdfunction) │ │ │ │ │ +  │ │ │ │ │ +#define DUNE_COMMON_MATH_ISFUNCTION_FUNCTOR(function) │ │ │ │ │   │ │ │ │ │ Functions │ │ │ │ │ -std::ostream & Dune::operator<< (std::ostream &stream, const Exception &e) │ │ │ │ │ +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 ***** │ │ │ │ │ -A few common exception classes. │ │ │ │ │ -This file defines a common framework for generating exception subclasses and to │ │ │ │ │ -throw them in a simple manner │ │ │ │ │ +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/a00113_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: exceptions.hh Source File │ │ │ │ +dune-common: math.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,119 +74,373 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    exceptions.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 (C) 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_EXCEPTIONS_HH
    │ │ │ │ -
    7#define DUNE_EXCEPTIONS_HH
    │ │ │ │ -
    8
    │ │ │ │ -
    9#include <exception>
    │ │ │ │ -
    10#include <string>
    │ │ │ │ -
    11#include <sstream>
    │ │ │ │ -
    12
    │ │ │ │ -
    13namespace Dune {
    │ │ │ │ -
    14
    │ │ │ │ -
    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 };
    │ │ │ │ +
    5#ifndef DUNE_MATH_HH
    │ │ │ │ +
    6#define DUNE_MATH_HH
    │ │ │ │ +
    7
    │ │ │ │ +
    12#include <cmath>
    │ │ │ │ +
    13#include <complex>
    │ │ │ │ +
    14#include <limits>
    │ │ │ │ +
    15#include <type_traits>
    │ │ │ │ +
    16
    │ │ │ │ + │ │ │ │ +
    18
    │ │ │ │ +
    19namespace Dune
    │ │ │ │ +
    20{
    │ │ │ │ +
    21
    │ │ │ │ +
    32 template< class T >
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    34 {
    │ │ │ │ +
    │ │ │ │ +
    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
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    174 {
    │ │ │ │ -
    175 virtual ~ExceptionHook() {}
    │ │ │ │ -
    176 virtual void operator () () = 0;
    │ │ │ │ -
    177 };
    │ │ │ │ -
    │ │ │ │ -
    178
    │ │ │ │ -
    │ │ │ │ -
    179 inline std::ostream& operator<<(std::ostream &stream, const Exception &e)
    │ │ │ │ -
    180 {
    │ │ │ │ -
    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 {};
    │ │ │ │ +
    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
    │ │ │ │ -
    263 class NotImplemented : public Exception {};
    │ │ │ │ +
    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
    │ │ │ │ -
    271 class SystemError : public Exception {};
    │ │ │ │ -
    272
    │ │ │ │ -
    276 class OutOfMemoryError : public SystemError {};
    │ │ │ │ +
    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
    │ │ │ │ -
    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
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    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
    │ │ │ │ -
    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
    │ │ │ │ +
    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)
    Definition fvector.hh:604
    │ │ │ │ +
    bool isInf(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag)
    Definition fvector.hh:594
    │ │ │ │ +
    auto isFinite(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag)
    Definition fvector.hh:584
    │ │ │ │ +
    bool isUnordered(const FieldVector< K, 1 > &b, const FieldVector< K, 1 > &c, PriorityTag< 2 >, ADLTag)
    Definition fvector.hh:614
    │ │ │ │ +
    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 {} │ │ │ │ │ @@ -7,153 +7,387 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -exceptions.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 (C) 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_EXCEPTIONS_HH │ │ │ │ │ - 7#define DUNE_EXCEPTIONS_HH │ │ │ │ │ - 8 │ │ │ │ │ - 9#include │ │ │ │ │ - 10#include │ │ │ │ │ - 11#include │ │ │ │ │ - 12 │ │ │ │ │ - 13namespace Dune { │ │ │ │ │ - 14 │ │ │ │ │ - 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 }; │ │ │ │ │ + 5#ifndef DUNE_MATH_HH │ │ │ │ │ + 6#define DUNE_MATH_HH │ │ │ │ │ + 7 │ │ │ │ │ + 12#include │ │ │ │ │ + 13#include │ │ │ │ │ + 14#include │ │ │ │ │ + 15#include │ │ │ │ │ + 16 │ │ │ │ │ + 17#include │ │ │ │ │ + 18 │ │ │ │ │ + 19namespace Dune │ │ │ │ │ + 20{ │ │ │ │ │ + 21 │ │ │ │ │ + 32 template< class T > │ │ │ │ │ +33 struct StandardMathematicalConstants │ │ │ │ │ + 34 { │ │ │ │ │ +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 │ │ │ │ │ -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 { │ │ │ │ │ - 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 {}; │ │ │ │ │ + 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 │ │ │ │ │ -263 class NotImplemented : public Exception {}; │ │ │ │ │ + 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 │ │ │ │ │ -271 class SystemError : public Exception {}; │ │ │ │ │ - 272 │ │ │ │ │ -276 class OutOfMemoryError : public SystemError {}; │ │ │ │ │ + 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 │ │ │ │ │ -281 class InvalidStateException : public Exception {}; │ │ │ │ │ +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 │ │ │ │ │ -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 │ │ │ │ │ +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::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 │ │ │ │ │ +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) │ │ │ │ │ +Definition fvector.hh:604 │ │ │ │ │ +Dune::MathOverloads::isInf │ │ │ │ │ +bool isInf(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag) │ │ │ │ │ +Definition fvector.hh:594 │ │ │ │ │ +Dune::MathOverloads::isFinite │ │ │ │ │ +auto isFinite(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag) │ │ │ │ │ +Definition fvector.hh:584 │ │ │ │ │ +Dune::MathOverloads::isUnordered │ │ │ │ │ +bool isUnordered(const FieldVector< K, 1 > &b, const FieldVector< K, 1 > &c, │ │ │ │ │ +PriorityTag< 2 >, ADLTag) │ │ │ │ │ +Definition fvector.hh:614 │ │ │ │ │ +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/a00116.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: parametertree.cc File Reference │ │ │ │ +dune-common: enumset.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -69,27 +69,73 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    parametertree.cc File Reference
    │ │ │ │ +
    │ │ │ │ +Classes | │ │ │ │ +Namespaces | │ │ │ │ +Functions
    │ │ │ │ +
    enumset.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ -
    #include <cstdlib>
    │ │ │ │ -#include <iostream>
    │ │ │ │ -#include <ostream>
    │ │ │ │ -#include <string>
    │ │ │ │ -#include <sstream>
    │ │ │ │ -#include <fstream>
    │ │ │ │ -#include <set>
    │ │ │ │ -#include <algorithm>
    │ │ │ │ -#include <dune/common/exceptions.hh>
    │ │ │ │ -#include <dune/common/parametertree.hh>
    │ │ │ │ + │ │ │ │ +

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

    │ │ │ │ +
    #include <iostream>
    │ │ │ │ +
    │ │ │ │ +

    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...
     
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

    │ │ │ │ +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 > &)
     
    │ │ │ │ +

    Detailed Description

    │ │ │ │ +

    Classes for building sets out of enumeration values.

    │ │ │ │ +
    Author
    Markus Blatt
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,21 +6,60 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -parametertree.cc File Reference │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces | Functions │ │ │ │ │ +enumset.hh File Reference │ │ │ │ │ +Classes for building sets out of enumeration values. More... │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#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... │ │ │ │ │ +  │ │ │ │ │ + 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 > &) │ │ │ │ │ +  │ │ │ │ │ +***** 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/a00119.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: parameterizedobject.hh File Reference │ │ │ │ +dune-common: debugstream.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -71,37 +71,63 @@ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ Classes | │ │ │ │ -Namespaces
    │ │ │ │ -
    parameterizedobject.hh File Reference
    │ │ │ │ +Namespaces | │ │ │ │ +Typedefs
    │ │ │ │ +
    debugstream.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ -
    #include <functional>
    │ │ │ │ -#include <map>
    │ │ │ │ -#include <memory>
    │ │ │ │ -#include <dune/common/exceptions.hh>
    │ │ │ │ -#include <dune/common/typeutilities.hh>
    │ │ │ │ + │ │ │ │ +

    Defines several output streams for messages of different importance. │ │ │ │ +More...

    │ │ │ │ +
    #include <iostream>
    │ │ │ │ +#include <stack>
    │ │ │ │ +#include <dune/common/exceptions.hh>
    │ │ │ │
    │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ Classes

    class  Dune::ParameterizedObjectFactory< TypeT(Args...), KeyT >
    struct  Dune::greater_or_equal< current, threshold >
     Greater or equal template test. More...
     
    struct  Dune::common_bits< current, mask >
     activate if current and mask have common bits switched on. More...
     
    class  Dune::DebugStreamError
     standard exception for the debugstream More...
     
    class  Dune::StreamWrap
     
    class  Dune::DebugStreamState
     Intermediate class to implement tie-operation of DebugStream. More...
     
    class  Dune::DebugStream< thislevel, dlevel, alevel, activator >
     Generic class to implement debug output streams. More...
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ +

    │ │ │ │ Namespaces

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

    │ │ │ │ +Typedefs

    typedef unsigned int Dune::DebugLevel
     Type for debug levels.
     
    │ │ │ │ -
    │ │ │ │ +

    Detailed Description

    │ │ │ │ +

    Defines several output streams for messages of different importance.

    │ │ │ │ +

    This file implements the class DebugStream to support output in a variety of debug levels. Additionally, template parameters control if the output operation is really performed so that unused debug levels can be deactivated

    │ │ │ │ +
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,25 +6,49 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -parameterizedobject.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces | Typedefs │ │ │ │ │ +debugstream.hh File Reference │ │ │ │ │ +Common » Debug_output │ │ │ │ │ +Defines several output streams for messages of different importance. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class  Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_> │ │ │ │ │ +struct  Dune::greater_or_equal<_current,_threshold_> │ │ │ │ │ +  Greater or equal template test. More... │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::common_bits<_current,_mask_> │ │ │ │ │ +  activate if current and mask have common bits switched on. More... │ │ │ │ │ +  │ │ │ │ │ + class  Dune::DebugStreamError │ │ │ │ │ +  standard exception for the debugstream More... │ │ │ │ │ +  │ │ │ │ │ + class  Dune::StreamWrap │ │ │ │ │ +  │ │ │ │ │ + class  Dune::DebugStreamState │ │ │ │ │ +  Intermediate class to implement tie-operation of DebugStream. More... │ │ │ │ │ +  │ │ │ │ │ + class  Dune::DebugStream<_thislevel,_dlevel,_alevel,_activator_> │ │ │ │ │ +  Generic class to implement debug output streams. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ + Typedefs │ │ │ │ │ +typedef unsigned int Dune::DebugLevel │ │ │ │ │ +  Type for debug levels. │ │ │ │ │ +  │ │ │ │ │ +***** Detailed Description ***** │ │ │ │ │ +Defines several output streams for messages of different importance. │ │ │ │ │ +This file implements the class DebugStream to support output in a variety of │ │ │ │ │ +debug levels. Additionally, template parameters control if the output operation │ │ │ │ │ +is really performed so that unused debug levels can be deactivated │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00119_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: parameterizedobject.hh Source File │ │ │ │ +dune-common: debugstream.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,178 +74,333 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    parameterizedobject.hh
    │ │ │ │ +
    debugstream.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 (C) 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 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 }
    │ │ │ │ -
    │ │ │ │ +
    5
    │ │ │ │ +
    6#ifndef DUNE_DEBUGSTREAM_HH
    │ │ │ │ +
    7#define DUNE_DEBUGSTREAM_HH
    │ │ │ │ +
    8
    │ │ │ │ +
    13#include <iostream>
    │ │ │ │ +
    14#include <stack>
    │ │ │ │ +
    15
    │ │ │ │ + │ │ │ │ +
    17
    │ │ │ │ +
    18namespace Dune {
    │ │ │ │ +
    19
    │ │ │ │ +
    118 typedef unsigned int DebugLevel;
    │ │ │ │ +
    119
    │ │ │ │ +
    129 template <DebugLevel current, DebugLevel threshold>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    131 constexpr static bool value = (current >= threshold);
    │ │ │ │ +
    132 };
    │ │ │ │ +
    │ │ │ │ +
    133
    │ │ │ │ +
    134
    │ │ │ │ +
    141 template <DebugLevel current, DebugLevel mask>
    │ │ │ │ +
    │ │ │ │ +
    142 struct common_bits {
    │ │ │ │ +
    143 constexpr static bool value = ((current & mask) != 0);
    │ │ │ │ +
    144 };
    │ │ │ │ +
    │ │ │ │ +
    145
    │ │ │ │ +
    146
    │ │ │ │ +
    148 class DebugStreamError : public IOError {};
    │ │ │ │
    149
    │ │ │ │ -
    │ │ │ │ -
    150 bool contains(Key const& key) const
    │ │ │ │ -
    151 {
    │ │ │ │ -
    152 return registry_.count(key);
    │ │ │ │ -
    153 }
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    151 public:
    │ │ │ │ +
    152 StreamWrap(std::ostream& _out) : out(_out) { }
    │ │ │ │ +
    153 std::ostream& out;
    │ │ │ │ + │ │ │ │ +
    155 };
    │ │ │ │
    │ │ │ │ -
    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 }
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    159 // !!! should be protected somehow but that won't be easy
    │ │ │ │ +
    160 public:
    │ │ │ │ + │ │ │ │ +
    163
    │ │ │ │ + │ │ │ │ +
    166
    │ │ │ │ +
    168 bool _tied;
    │ │ │ │ +
    169
    │ │ │ │ +
    171 unsigned int _tied_streams;
    │ │ │ │ +
    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, ...
    │ │ │ │ +
    188 template <DebugLevel thislevel = 1,
    │ │ │ │ +
    189 DebugLevel dlevel = 1,
    │ │ │ │ +
    190 DebugLevel alevel = 1,
    │ │ │ │ +
    191 template<DebugLevel, DebugLevel> class activator = greater_or_equal>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    193 public:
    │ │ │ │ +
    │ │ │ │ +
    199 DebugStream(std::ostream& out = std::cerr) {
    │ │ │ │ +
    200 // start a new list of streams
    │ │ │ │ +
    201 current = new StreamWrap(out);
    │ │ │ │ +
    202 current->next = 0;
    │ │ │ │ +
    203
    │ │ │ │ +
    204 // check if we are above the default activation level
    │ │ │ │ +
    205 _active = activator<thislevel,alevel>::value;
    │ │ │ │ +
    206
    │ │ │ │ +
    207 // we're not tied to another DebugStream
    │ │ │ │ +
    208 _tied = false;
    │ │ │ │ +
    209
    │ │ │ │ +
    210 // no child streams yet
    │ │ │ │ +
    211 _tied_streams = 0;
    │ │ │ │ +
    212 }
    │ │ │ │ +
    │ │ │ │ +
    213
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    220 std::ostream& fallback = std::cerr)
    │ │ │ │ +
    221 {
    │ │ │ │ +
    222 // start a new list of streams
    │ │ │ │ +
    223 current = new StreamWrap(fallback);
    │ │ │ │ +
    224 current->next = 0;
    │ │ │ │ +
    225
    │ │ │ │ +
    226 // check if we are above the default activation level
    │ │ │ │ +
    227 _active = activator<thislevel,alevel>::value;
    │ │ │ │ +
    228 _tied_streams = 0;
    │ │ │ │ +
    229
    │ │ │ │ +
    230 // tie to the provided stream
    │ │ │ │ +
    231 _tied = true;
    │ │ │ │ +
    232 tiedstate = &master;
    │ │ │ │ +
    233 tiedstate->_tied_streams++;
    │ │ │ │ +
    234 }
    │ │ │ │ +
    │ │ │ │ +
    235
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    244 {
    │ │ │ │ +
    245 // untie
    │ │ │ │ +
    246 if (_tied)
    │ │ │ │ +
    247 tiedstate->_tied_streams--;
    │ │ │ │ +
    248 else {
    │ │ │ │ +
    249 // check if somebody still ties to us...
    │ │ │ │ +
    250 if (_tied_streams != 0)
    │ │ │ │ +
    251 {
    │ │ │ │ +
    252 std::cerr << "DebugStream destructor is called while other streams are still tied to it. Terminating!" << std::endl;
    │ │ │ │ +
    253 std::terminate();
    │ │ │ │ +
    254 }
    │ │ │ │ +
    255 }
    │ │ │ │ +
    256
    │ │ │ │ +
    257 // remove ostream-stack
    │ │ │ │ +
    258 while (current != 0) {
    │ │ │ │ +
    259 StreamWrap *s = current;
    │ │ │ │ + │ │ │ │ +
    261 delete s;
    │ │ │ │ +
    262 }
    │ │ │ │ +
    263 }
    │ │ │ │ +
    │ │ │ │ +
    264
    │ │ │ │ +
    266 template <class T>
    │ │ │ │ +
    │ │ │ │ +
    267 DebugStream& operator<<(const T data) {
    │ │ │ │ +
    268 // remove the following code if stream wasn't compiled active
    │ │ │ │ +
    269 if (activator<thislevel, dlevel>::value) {
    │ │ │ │ +
    270 if (! _tied) {
    │ │ │ │ +
    271 if (_active)
    │ │ │ │ +
    272 current->out << data;
    │ │ │ │ +
    273 } else {
    │ │ │ │ +
    274 if (_active && tiedstate->_active)
    │ │ │ │ +
    275 tiedstate->current->out << data;
    │ │ │ │ +
    276 }
    │ │ │ │ +
    277 }
    │ │ │ │ +
    278
    │ │ │ │ +
    279 return *this;
    │ │ │ │ +
    280 }
    │ │ │ │ +
    │ │ │ │ +
    281
    │ │ │ │ +
    │ │ │ │ +
    289 DebugStream& operator<<(const int data) {
    │ │ │ │ +
    290 // remove the following code if stream wasn't compiled active
    │ │ │ │ +
    291 if (activator<thislevel, dlevel>::value) {
    │ │ │ │ +
    292 if (! _tied) {
    │ │ │ │ +
    293 if (_active)
    │ │ │ │ +
    294 current->out << data;
    │ │ │ │ +
    295 } else {
    │ │ │ │ +
    296 if (_active && tiedstate->_active)
    │ │ │ │ +
    297 tiedstate->current->out << data;
    │ │ │ │ +
    298 }
    │ │ │ │ +
    299 }
    │ │ │ │ +
    300
    │ │ │ │ +
    301 return *this;
    │ │ │ │ +
    302 }
    │ │ │ │ +
    │ │ │ │ +
    303
    │ │ │ │ +
    │ │ │ │ +
    305 DebugStream& operator<<(std::ostream& (*f)(std::ostream&)) {
    │ │ │ │ +
    306 if (activator<thislevel, dlevel>::value) {
    │ │ │ │ +
    307 if (! _tied) {
    │ │ │ │ +
    308 if (_active)
    │ │ │ │ +
    309 f(current->out);
    │ │ │ │ +
    310 } else {
    │ │ │ │ +
    311 if (_active && tiedstate->_active)
    │ │ │ │ +
    312 f(tiedstate->current->out);
    │ │ │ │ +
    313 }
    │ │ │ │ +
    314 }
    │ │ │ │ +
    315
    │ │ │ │ +
    316 return *this;
    │ │ │ │ +
    317 }
    │ │ │ │ +
    │ │ │ │ +
    318
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    321 if (activator<thislevel, dlevel>::value) {
    │ │ │ │ +
    322 if (! _tied) {
    │ │ │ │ +
    323 if (_active)
    │ │ │ │ +
    324 current->out.flush();
    │ │ │ │ +
    325 } else {
    │ │ │ │ +
    326 if (_active && tiedstate->_active)
    │ │ │ │ +
    327 tiedstate->current->out.flush();
    │ │ │ │ +
    328 }
    │ │ │ │ +
    329 }
    │ │ │ │ +
    330
    │ │ │ │ +
    331 return *this;
    │ │ │ │ +
    332 }
    │ │ │ │ +
    │ │ │ │ +
    333
    │ │ │ │ +
    │ │ │ │ +
    335 void push(bool b) {
    │ │ │ │ +
    336 // are we at all active?
    │ │ │ │ +
    337 if (activator<thislevel,alevel>::value) {
    │ │ │ │ +
    338 _actstack.push(_active);
    │ │ │ │ +
    339 _active = b;
    │ │ │ │ +
    340 } else {
    │ │ │ │ +
    341 // stay off
    │ │ │ │ +
    342 _actstack.push(false);
    │ │ │ │ +
    343 }
    │ │ │ │ +
    344 }
    │ │ │ │ +
    │ │ │ │ +
    345
    │ │ │ │ +
    │ │ │ │ +
    349 void pop() {
    │ │ │ │ +
    350 if (_actstack.empty())
    │ │ │ │ +
    351 DUNE_THROW(DebugStreamError, "No previous activation setting!");
    │ │ │ │ +
    352
    │ │ │ │ +
    353 _active = _actstack.top();
    │ │ │ │ +
    354 _actstack.pop();
    │ │ │ │ +
    355 }
    │ │ │ │ +
    │ │ │ │ +
    356
    │ │ │ │ +
    │ │ │ │ +
    363 bool active() const {
    │ │ │ │ +
    364 return activator<thislevel, dlevel>::value && _active;
    │ │ │ │ +
    365 }
    │ │ │ │ +
    │ │ │ │ +
    366
    │ │ │ │ +
    │ │ │ │ +
    371 void attach(std::ostream& stream) {
    │ │ │ │ +
    372 if (_tied)
    │ │ │ │ +
    373 DUNE_THROW(DebugStreamError, "Cannot attach to a tied stream!");
    │ │ │ │ +
    374
    │ │ │ │ +
    375 StreamWrap* newcurr = new StreamWrap(stream);
    │ │ │ │ +
    376 newcurr->next = current;
    │ │ │ │ +
    377 current = newcurr;
    │ │ │ │ +
    378 }
    │ │ │ │ +
    │ │ │ │ +
    379
    │ │ │ │ +
    │ │ │ │ +
    383 void detach() {
    │ │ │ │ +
    384 if (current->next == 0)
    │ │ │ │ +
    385 DUNE_THROW(DebugStreamError, "Cannot detach initial stream!");
    │ │ │ │ +
    386 if (_tied)
    │ │ │ │ +
    387 DUNE_THROW(DebugStreamError, "Cannot detach a tied stream!");
    │ │ │ │ +
    388
    │ │ │ │ +
    389 StreamWrap* old = current;
    │ │ │ │ + │ │ │ │ +
    391 delete old;
    │ │ │ │ +
    392 }
    │ │ │ │ +
    │ │ │ │ +
    393
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    398 if (to._tied)
    │ │ │ │ +
    399 DUNE_THROW(DebugStreamError, "Cannot tie to an already tied stream!");
    │ │ │ │ +
    400 if (_tied)
    │ │ │ │ +
    401 DUNE_THROW(DebugStreamError, "Stream already tied: untie first!");
    │ │ │ │ +
    402
    │ │ │ │ +
    403 _tied = true;
    │ │ │ │ +
    404 tiedstate = &to;
    │ │ │ │ +
    405
    │ │ │ │ +
    406 // tell master class
    │ │ │ │ +
    407 tiedstate->_tied_streams++;
    │ │ │ │ +
    408 }
    │ │ │ │ +
    │ │ │ │ +
    409
    │ │ │ │ +
    │ │ │ │ +
    413 void untie() {
    │ │ │ │ +
    414 if(! _tied)
    │ │ │ │ +
    415 DUNE_THROW(DebugStreamError, "Cannot untie, stream is not tied!");
    │ │ │ │ +
    416
    │ │ │ │ +
    417 tiedstate->_tied_streams--;
    │ │ │ │ +
    418 _tied = false;
    │ │ │ │ +
    419 tiedstate = 0;
    │ │ │ │ +
    420 }
    │ │ │ │ +
    │ │ │ │ +
    421
    │ │ │ │ +
    422 private:
    │ │ │ │ +
    424 DebugStreamState* tiedstate;
    │ │ │ │ +
    425
    │ │ │ │ +
    430 std::stack<bool> _actstack;
    │ │ │ │ +
    431 };
    │ │ │ │ +
    │ │ │ │ +
    432
    │ │ │ │ +
    434}
    │ │ │ │ +
    435
    │ │ │ │ +
    436
    │ │ │ │ +
    437#endif
    │ │ │ │ +
    A few common exception classes.
    │ │ │ │ +
    StreamWrap(std::ostream &_out)
    Definition debugstream.hh:152
    │ │ │ │ +
    DebugStream(std::ostream &out=std::cerr)
    Create a DebugStream and set initial output stream.
    Definition debugstream.hh:199
    │ │ │ │ +
    void untie()
    Untie stream.
    Definition debugstream.hh:413
    │ │ │ │ +
    DebugStream & flush()
    pass on flush to underlying output stream
    Definition debugstream.hh:320
    │ │ │ │ +
    void attach(std::ostream &stream)
    set output to a different stream.
    Definition debugstream.hh:371
    │ │ │ │ +
    void detach()
    detach current output stream and restore to previous stream
    Definition debugstream.hh:383
    │ │ │ │ +
    static constexpr bool value
    Definition debugstream.hh:143
    │ │ │ │ +
    std::ostream & out
    Definition debugstream.hh:153
    │ │ │ │ +
    void pop()
    restore previously set activation flag
    Definition debugstream.hh:349
    │ │ │ │ +
    bool active() const
    reports if this stream will produce output
    Definition debugstream.hh:363
    │ │ │ │ +
    bool _active
    flag to switch output during runtime
    Definition debugstream.hh:165
    │ │ │ │ +
    unsigned int _tied_streams
    how many streams are tied to this state
    Definition debugstream.hh:171
    │ │ │ │ +
    void tie(DebugStreamState &to)
    Tie a stream to this one.
    Definition debugstream.hh:397
    │ │ │ │ +
    void push(bool b)
    set activation flag and store old value
    Definition debugstream.hh:335
    │ │ │ │ +
    unsigned int DebugLevel
    Type for debug levels.
    Definition debugstream.hh:118
    │ │ │ │ +
    bool _tied
    are we tied to another DebugStream?
    Definition debugstream.hh:168
    │ │ │ │ +
    StreamWrap * current
    current output stream and link to possibly pushed old output streams
    Definition debugstream.hh:162
    │ │ │ │ +
    DebugStream & operator<<(const T data)
    Generic types are passed on to current output stream.
    Definition debugstream.hh:267
    │ │ │ │ +
    static constexpr bool value
    Definition debugstream.hh:131
    │ │ │ │ +
    ~DebugStream()
    Destroy stream.
    Definition debugstream.hh:243
    │ │ │ │ +
    DebugStream(DebugStreamState &master, std::ostream &fallback=std::cerr)
    Create a DebugStream and directly tie to another DebugStream.
    Definition debugstream.hh:219
    │ │ │ │ +
    DebugStream & operator<<(const int data)
    explicit specialization so that enums can be printed
    Definition debugstream.hh:289
    │ │ │ │ +
    DebugStream & operator<<(std::ostream &(*f)(std::ostream &))
    pass on manipulators to underlying output stream
    Definition debugstream.hh:305
    │ │ │ │ +
    StreamWrap * next
    Definition debugstream.hh:154
    │ │ │ │
    #define DUNE_THROW(E, m)
    Definition exceptions.hh:218
    │ │ │ │
    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
    │ │ │ │ +
    Greater or equal template test.
    Definition debugstream.hh:130
    │ │ │ │ +
    activate if current and mask have common bits switched on.
    Definition debugstream.hh:142
    │ │ │ │ +
    standard exception for the debugstream
    Definition debugstream.hh:148
    │ │ │ │ +
    Definition debugstream.hh:150
    │ │ │ │ +
    Intermediate class to implement tie-operation of DebugStream.
    Definition debugstream.hh:158
    │ │ │ │ +
    Generic class to implement debug output streams.
    Definition debugstream.hh:192
    │ │ │ │ +
    Default exception class for I/O errors.
    Definition exceptions.hh:231
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,202 +7,377 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -parameterizedobject.hh │ │ │ │ │ +debugstream.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 (C) 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 │ │ │ │ │ - 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 {}; │ │ │ │ │ - 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 } │ │ │ │ │ + 5 │ │ │ │ │ + 6#ifndef DUNE_DEBUGSTREAM_HH │ │ │ │ │ + 7#define DUNE_DEBUGSTREAM_HH │ │ │ │ │ + 8 │ │ │ │ │ + 13#include │ │ │ │ │ + 14#include │ │ │ │ │ + 15 │ │ │ │ │ + 16#include │ │ │ │ │ + 17 │ │ │ │ │ + 18namespace Dune { │ │ │ │ │ + 19 │ │ │ │ │ +118 typedef unsigned int DebugLevel; │ │ │ │ │ + 119 │ │ │ │ │ + 129 template │ │ │ │ │ +130 struct greater_or_equal { │ │ │ │ │ +131 constexpr static bool value = (current >= threshold); │ │ │ │ │ + 132 }; │ │ │ │ │ + 133 │ │ │ │ │ + 134 │ │ │ │ │ + 141 template │ │ │ │ │ +142 struct common_bits { │ │ │ │ │ +143 constexpr static bool value = ((current & mask) != 0); │ │ │ │ │ + 144 }; │ │ │ │ │ + 145 │ │ │ │ │ + 146 │ │ │ │ │ +148 class DebugStreamError : public IOError {}; │ │ │ │ │ 149 │ │ │ │ │ -150 bool contains(Key const& key) const │ │ │ │ │ - 151 { │ │ │ │ │ - 152 return registry_.count(key); │ │ │ │ │ - 153 } │ │ │ │ │ - 154 │ │ │ │ │ - 155 private: │ │ │ │ │ +150 class StreamWrap { │ │ │ │ │ + 151 public: │ │ │ │ │ +152 StreamWrap(std::ostream& _out) : out(_out) { } │ │ │ │ │ +153 std::ostream& out; │ │ │ │ │ +154 StreamWrap *next; │ │ │ │ │ + 155 }; │ │ │ │ │ 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 } │ │ │ │ │ +158 class DebugStreamState { │ │ │ │ │ + 159 // !!! should be protected somehow but that won't be easy │ │ │ │ │ + 160 public: │ │ │ │ │ +162 StreamWrap* current; │ │ │ │ │ + 163 │ │ │ │ │ +165 bool _active; │ │ │ │ │ + 166 │ │ │ │ │ +168 bool _tied; │ │ │ │ │ + 169 │ │ │ │ │ +171 unsigned int _tied_streams; │ │ │ │ │ + 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 │ │ │ │ │ + 188 template class activator = greater_or_equal> │ │ │ │ │ +192 class DebugStream : public DebugStreamState { │ │ │ │ │ + 193 public: │ │ │ │ │ +199 DebugStream(std::ostream& out = std::cerr) { │ │ │ │ │ + 200 // start a new list of streams │ │ │ │ │ + 201 current = new StreamWrap(out); │ │ │ │ │ + 202 current->next = 0; │ │ │ │ │ + 203 │ │ │ │ │ + 204 // check if we are above the default activation level │ │ │ │ │ + 205 _active = activator::value; │ │ │ │ │ + 206 │ │ │ │ │ + 207 // we're not tied to another DebugStream │ │ │ │ │ + 208 _tied = false; │ │ │ │ │ + 209 │ │ │ │ │ + 210 // no child streams yet │ │ │ │ │ + 211 _tied_streams = 0; │ │ │ │ │ + 212 } │ │ │ │ │ + 213 │ │ │ │ │ +219 DebugStream (DebugStreamState& master, │ │ │ │ │ + 220 std::ostream& fallback = std::cerr) │ │ │ │ │ + 221 { │ │ │ │ │ + 222 // start a new list of streams │ │ │ │ │ + 223 current = new StreamWrap(fallback); │ │ │ │ │ + 224 current->next = 0; │ │ │ │ │ + 225 │ │ │ │ │ + 226 // check if we are above the default activation level │ │ │ │ │ + 227 _active = activator::value; │ │ │ │ │ + 228 _tied_streams = 0; │ │ │ │ │ + 229 │ │ │ │ │ + 230 // tie to the provided stream │ │ │ │ │ + 231 _tied = true; │ │ │ │ │ + 232 tiedstate = &master; │ │ │ │ │ + 233 tiedstate->_tied_streams++; │ │ │ │ │ + 234 } │ │ │ │ │ + 235 │ │ │ │ │ +243 ~DebugStream() │ │ │ │ │ + 244 { │ │ │ │ │ + 245 // untie │ │ │ │ │ + 246 if (_tied) │ │ │ │ │ + 247 tiedstate->_tied_streams--; │ │ │ │ │ + 248 else { │ │ │ │ │ + 249 // check if somebody still ties to us... │ │ │ │ │ + 250 if (_tied_streams != 0) │ │ │ │ │ + 251 { │ │ │ │ │ + 252 std::cerr << "DebugStream destructor is called while other streams are │ │ │ │ │ +still tied to it. Terminating!" << std::endl; │ │ │ │ │ + 253 std::terminate(); │ │ │ │ │ + 254 } │ │ │ │ │ + 255 } │ │ │ │ │ + 256 │ │ │ │ │ + 257 // remove ostream-stack │ │ │ │ │ + 258 while (current != 0) { │ │ │ │ │ + 259 StreamWrap *s = current; │ │ │ │ │ + 260 current = current->next; │ │ │ │ │ + 261 delete s; │ │ │ │ │ + 262 } │ │ │ │ │ + 263 } │ │ │ │ │ + 264 │ │ │ │ │ + 266 template │ │ │ │ │ +267 DebugStream& operator<<(const T data) { │ │ │ │ │ + 268 // remove the following code if stream wasn't compiled active │ │ │ │ │ + 269 if (activator::value) { │ │ │ │ │ + 270 if (! _tied) { │ │ │ │ │ + 271 if (_active) │ │ │ │ │ + 272 current->out << data; │ │ │ │ │ + 273 } else { │ │ │ │ │ + 274 if (_active && tiedstate->_active) │ │ │ │ │ + 275 tiedstate->current->out << data; │ │ │ │ │ + 276 } │ │ │ │ │ + 277 } │ │ │ │ │ + 278 │ │ │ │ │ + 279 return *this; │ │ │ │ │ + 280 } │ │ │ │ │ + 281 │ │ │ │ │ +289 DebugStream& operator<<(const int data) { │ │ │ │ │ + 290 // remove the following code if stream wasn't compiled active │ │ │ │ │ + 291 if (activator::value) { │ │ │ │ │ + 292 if (! _tied) { │ │ │ │ │ + 293 if (_active) │ │ │ │ │ + 294 current->out << data; │ │ │ │ │ + 295 } else { │ │ │ │ │ + 296 if (_active && tiedstate->_active) │ │ │ │ │ + 297 tiedstate->current->out << data; │ │ │ │ │ + 298 } │ │ │ │ │ + 299 } │ │ │ │ │ + 300 │ │ │ │ │ + 301 return *this; │ │ │ │ │ + 302 } │ │ │ │ │ + 303 │ │ │ │ │ +305 DebugStream& operator<<(std::ostream& (*f)(std::ostream&)) { │ │ │ │ │ + 306 if (activator::value) { │ │ │ │ │ + 307 if (! _tied) { │ │ │ │ │ + 308 if (_active) │ │ │ │ │ + 309 f(current->out); │ │ │ │ │ + 310 } else { │ │ │ │ │ + 311 if (_active && tiedstate->_active) │ │ │ │ │ + 312 f(tiedstate->current->out); │ │ │ │ │ + 313 } │ │ │ │ │ + 314 } │ │ │ │ │ + 315 │ │ │ │ │ + 316 return *this; │ │ │ │ │ + 317 } │ │ │ │ │ + 318 │ │ │ │ │ +320 DebugStream& flush() { │ │ │ │ │ + 321 if (activator::value) { │ │ │ │ │ + 322 if (! _tied) { │ │ │ │ │ + 323 if (_active) │ │ │ │ │ + 324 current->out.flush(); │ │ │ │ │ + 325 } else { │ │ │ │ │ + 326 if (_active && tiedstate->_active) │ │ │ │ │ + 327 tiedstate->current->out.flush(); │ │ │ │ │ + 328 } │ │ │ │ │ + 329 } │ │ │ │ │ + 330 │ │ │ │ │ + 331 return *this; │ │ │ │ │ + 332 } │ │ │ │ │ + 333 │ │ │ │ │ +335 void push(bool b) { │ │ │ │ │ + 336 // are we at all active? │ │ │ │ │ + 337 if (activator::value) { │ │ │ │ │ + 338 _actstack.push(_active); │ │ │ │ │ + 339 _active = b; │ │ │ │ │ + 340 } else { │ │ │ │ │ + 341 // stay off │ │ │ │ │ + 342 _actstack.push(false); │ │ │ │ │ + 343 } │ │ │ │ │ + 344 } │ │ │ │ │ + 345 │ │ │ │ │ +349 void pop() { │ │ │ │ │ + 350 if (_actstack.empty()) │ │ │ │ │ + 351 DUNE_THROW(DebugStreamError, "No previous activation setting!"); │ │ │ │ │ + 352 │ │ │ │ │ + 353 _active = _actstack.top(); │ │ │ │ │ + 354 _actstack.pop(); │ │ │ │ │ + 355 } │ │ │ │ │ + 356 │ │ │ │ │ +363 bool active() const { │ │ │ │ │ + 364 return activator::value && _active; │ │ │ │ │ + 365 } │ │ │ │ │ + 366 │ │ │ │ │ +371 void attach(std::ostream& stream) { │ │ │ │ │ + 372 if (_tied) │ │ │ │ │ + 373 DUNE_THROW(DebugStreamError, "Cannot attach to a tied stream!"); │ │ │ │ │ + 374 │ │ │ │ │ + 375 StreamWrap* newcurr = new StreamWrap(stream); │ │ │ │ │ + 376 newcurr->next = current; │ │ │ │ │ + 377 current = newcurr; │ │ │ │ │ + 378 } │ │ │ │ │ + 379 │ │ │ │ │ +383 void detach() { │ │ │ │ │ + 384 if (current->next == 0) │ │ │ │ │ + 385 DUNE_THROW(DebugStreamError, "Cannot detach initial stream!"); │ │ │ │ │ + 386 if (_tied) │ │ │ │ │ + 387 DUNE_THROW(DebugStreamError, "Cannot detach a tied stream!"); │ │ │ │ │ + 388 │ │ │ │ │ + 389 StreamWrap* old = current; │ │ │ │ │ + 390 current = current->next; │ │ │ │ │ + 391 delete old; │ │ │ │ │ + 392 } │ │ │ │ │ + 393 │ │ │ │ │ +397 void tie(DebugStreamState& to) { │ │ │ │ │ + 398 if (to._tied) │ │ │ │ │ + 399 DUNE_THROW(DebugStreamError, "Cannot tie to an already tied stream!"); │ │ │ │ │ + 400 if (_tied) │ │ │ │ │ + 401 DUNE_THROW(DebugStreamError, "Stream already tied: untie first!"); │ │ │ │ │ + 402 │ │ │ │ │ + 403 _tied = true; │ │ │ │ │ + 404 tiedstate = &to; │ │ │ │ │ + 405 │ │ │ │ │ + 406 // tell master class │ │ │ │ │ + 407 tiedstate->_tied_streams++; │ │ │ │ │ + 408 } │ │ │ │ │ + 409 │ │ │ │ │ +413 void untie() { │ │ │ │ │ + 414 if(! _tied) │ │ │ │ │ + 415 DUNE_THROW(DebugStreamError, "Cannot untie, stream is not tied!"); │ │ │ │ │ + 416 │ │ │ │ │ + 417 tiedstate->_tied_streams--; │ │ │ │ │ + 418 _tied = false; │ │ │ │ │ + 419 tiedstate = 0; │ │ │ │ │ + 420 } │ │ │ │ │ + 421 │ │ │ │ │ + 422 private: │ │ │ │ │ + 424 DebugStreamState* tiedstate; │ │ │ │ │ + 425 │ │ │ │ │ + 430 std::stack _actstack; │ │ │ │ │ + 431 }; │ │ │ │ │ + 432 │ │ │ │ │ + 434} │ │ │ │ │ + 435 │ │ │ │ │ + 436 │ │ │ │ │ + 437#endif │ │ │ │ │ exceptions.hh │ │ │ │ │ A few common exception classes. │ │ │ │ │ -typeutilities.hh │ │ │ │ │ -Utilities for type computations, constraining overloads, ... │ │ │ │ │ +Dune::StreamWrap::StreamWrap │ │ │ │ │ +StreamWrap(std::ostream &_out) │ │ │ │ │ +Definition debugstream.hh:152 │ │ │ │ │ +Dune::DebugStream::DebugStream │ │ │ │ │ +DebugStream(std::ostream &out=std::cerr) │ │ │ │ │ +Create a DebugStream and set initial output stream. │ │ │ │ │ +Definition debugstream.hh:199 │ │ │ │ │ +Dune::DebugStream::untie │ │ │ │ │ +void untie() │ │ │ │ │ +Untie stream. │ │ │ │ │ +Definition debugstream.hh:413 │ │ │ │ │ +Dune::DebugStream::flush │ │ │ │ │ +DebugStream & flush() │ │ │ │ │ +pass on flush to underlying output stream │ │ │ │ │ +Definition debugstream.hh:320 │ │ │ │ │ +Dune::DebugStream::attach │ │ │ │ │ +void attach(std::ostream &stream) │ │ │ │ │ +set output to a different stream. │ │ │ │ │ +Definition debugstream.hh:371 │ │ │ │ │ +Dune::DebugStream::detach │ │ │ │ │ +void detach() │ │ │ │ │ +detach current output stream and restore to previous stream │ │ │ │ │ +Definition debugstream.hh:383 │ │ │ │ │ +Dune::common_bits::value │ │ │ │ │ +static constexpr bool value │ │ │ │ │ +Definition debugstream.hh:143 │ │ │ │ │ +Dune::StreamWrap::out │ │ │ │ │ +std::ostream & out │ │ │ │ │ +Definition debugstream.hh:153 │ │ │ │ │ +Dune::DebugStream::pop │ │ │ │ │ +void pop() │ │ │ │ │ +restore previously set activation flag │ │ │ │ │ +Definition debugstream.hh:349 │ │ │ │ │ +Dune::DebugStream::active │ │ │ │ │ +bool active() const │ │ │ │ │ +reports if this stream will produce output │ │ │ │ │ +Definition debugstream.hh:363 │ │ │ │ │ +Dune::DebugStreamState::_active │ │ │ │ │ +bool _active │ │ │ │ │ +flag to switch output during runtime │ │ │ │ │ +Definition debugstream.hh:165 │ │ │ │ │ +Dune::DebugStreamState::_tied_streams │ │ │ │ │ +unsigned int _tied_streams │ │ │ │ │ +how many streams are tied to this state │ │ │ │ │ +Definition debugstream.hh:171 │ │ │ │ │ +Dune::DebugStream::tie │ │ │ │ │ +void tie(DebugStreamState &to) │ │ │ │ │ +Tie a stream to this one. │ │ │ │ │ +Definition debugstream.hh:397 │ │ │ │ │ +Dune::DebugStream::push │ │ │ │ │ +void push(bool b) │ │ │ │ │ +set activation flag and store old value │ │ │ │ │ +Definition debugstream.hh:335 │ │ │ │ │ +Dune::DebugLevel │ │ │ │ │ +unsigned int DebugLevel │ │ │ │ │ +Type for debug levels. │ │ │ │ │ +Definition debugstream.hh:118 │ │ │ │ │ +Dune::DebugStreamState::_tied │ │ │ │ │ +bool _tied │ │ │ │ │ +are we tied to another DebugStream? │ │ │ │ │ +Definition debugstream.hh:168 │ │ │ │ │ +Dune::DebugStreamState::current │ │ │ │ │ +StreamWrap * current │ │ │ │ │ +current output stream and link to possibly pushed old output streams │ │ │ │ │ +Definition debugstream.hh:162 │ │ │ │ │ +Dune::DebugStream::operator<< │ │ │ │ │ +DebugStream & operator<<(const T data) │ │ │ │ │ +Generic types are passed on to current output stream. │ │ │ │ │ +Definition debugstream.hh:267 │ │ │ │ │ +Dune::greater_or_equal::value │ │ │ │ │ +static constexpr bool value │ │ │ │ │ +Definition debugstream.hh:131 │ │ │ │ │ +Dune::DebugStream::~DebugStream │ │ │ │ │ +~DebugStream() │ │ │ │ │ +Destroy stream. │ │ │ │ │ +Definition debugstream.hh:243 │ │ │ │ │ +Dune::DebugStream::DebugStream │ │ │ │ │ +DebugStream(DebugStreamState &master, std::ostream &fallback=std::cerr) │ │ │ │ │ +Create a DebugStream and directly tie to another DebugStream. │ │ │ │ │ +Definition debugstream.hh:219 │ │ │ │ │ +Dune::DebugStream::operator<< │ │ │ │ │ +DebugStream & operator<<(const int data) │ │ │ │ │ +explicit specialization so that enums can be printed │ │ │ │ │ +Definition debugstream.hh:289 │ │ │ │ │ +Dune::DebugStream::operator<< │ │ │ │ │ +DebugStream & operator<<(std::ostream &(*f)(std::ostream &)) │ │ │ │ │ +pass on manipulators to underlying output stream │ │ │ │ │ +Definition debugstream.hh:305 │ │ │ │ │ +Dune::StreamWrap::next │ │ │ │ │ +StreamWrap * next │ │ │ │ │ +Definition debugstream.hh:154 │ │ │ │ │ DUNE_THROW │ │ │ │ │ #define DUNE_THROW(E, m) │ │ │ │ │ Definition exceptions.hh:218 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -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 │ │ │ │ │ +Dune::greater_or_equal │ │ │ │ │ +Greater or equal template test. │ │ │ │ │ +Definition debugstream.hh:130 │ │ │ │ │ +Dune::common_bits │ │ │ │ │ +activate if current and mask have common bits switched on. │ │ │ │ │ +Definition debugstream.hh:142 │ │ │ │ │ +Dune::DebugStreamError │ │ │ │ │ +standard exception for the debugstream │ │ │ │ │ +Definition debugstream.hh:148 │ │ │ │ │ +Dune::StreamWrap │ │ │ │ │ +Definition debugstream.hh:150 │ │ │ │ │ +Dune::DebugStreamState │ │ │ │ │ +Intermediate class to implement tie-operation of DebugStream. │ │ │ │ │ +Definition debugstream.hh:158 │ │ │ │ │ +Dune::DebugStream │ │ │ │ │ +Generic class to implement debug output streams. │ │ │ │ │ +Definition debugstream.hh:192 │ │ │ │ │ +Dune::IOError │ │ │ │ │ +Default exception class for I/O errors. │ │ │ │ │ +Definition exceptions.hh:231 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00122.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: to_unique_ptr.hh File Reference │ │ │ │ +dune-common: assertandreturn.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,43 +70,27 @@ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ -Namespaces | │ │ │ │ -Typedefs | │ │ │ │ -Functions
    │ │ │ │ -
    to_unique_ptr.hh File Reference
    │ │ │ │ +Macros
    │ │ │ │ +
    assertandreturn.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ -
    #include <memory>
    │ │ │ │ +
    #include <cassert>
    │ │ │ │
    │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ -Namespaces

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

    │ │ │ │ -Typedefs

    template<class T >
    using Dune::ToUniquePtr = std::unique_ptr< T >
     Alias for std::unique_ptr introduced as transition wrapper.
     
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

    │ │ │ │ -Functions

    template<class T , class... Args>
    std::unique_ptr< T > Dune::makeToUnique (Args &&... args)
     Alias for std::make_unique introduced as transition wrapper.
     

    │ │ │ │ +Macros

    #define DUNE_ASSERT_AND_RETURN(C, X)   (!(C) ? throw [&](){assert(!#C);return 0;}() : 0), X
     Asserts a condition and return on success in constexpr context.
     
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,29 +6,19 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Namespaces | Typedefs | Functions │ │ │ │ │ -to_unique_ptr.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ +Macros │ │ │ │ │ +assertandreturn.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ - Namespaces │ │ │ │ │ -namespace  Dune │ │ │ │ │ -  Dune namespace. │ │ │ │ │ -  │ │ │ │ │ - Typedefs │ │ │ │ │ -template │ │ │ │ │ -using Dune::ToUniquePtr = std::unique_ptr< T > │ │ │ │ │ -  Alias for std::unique_ptr introduced as transition wrapper. │ │ │ │ │ -  │ │ │ │ │ - Functions │ │ │ │ │ -template │ │ │ │ │ -std::unique_ptr< T > Dune::makeToUnique (Args &&... args) │ │ │ │ │ -  Alias for std::make_unique introduced as transition │ │ │ │ │ - wrapper. │ │ │ │ │ + Macros │ │ │ │ │ +#define DUNE_ASSERT_AND_RETURN(C, X)   (!(C) ? throw [&](){assert(!#C);return 0;}() : │ │ │ │ │ + 0), X │ │ │ │ │ +  Asserts a condition and return on success in constexpr context. │ │ │ │ │   │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00122_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: to_unique_ptr.hh Source File │ │ │ │ +dune-common: assertandreturn.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,48 +74,36 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    to_unique_ptr.hh
    │ │ │ │ +
    assertandreturn.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 (C) 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_TO_UNIQUE_PTR_HH
    │ │ │ │ -
    7#define DUNE_TO_UNIQUE_PTR_HH
    │ │ │ │ -
    8
    │ │ │ │ -
    9#warning to_unique_ptr.hh and ToUniquePtr are deprecated. Use std::unique_ptr or std::shared_ptr instead.
    │ │ │ │ -
    10
    │ │ │ │ -
    11#include <memory>
    │ │ │ │ -
    12
    │ │ │ │ -
    13namespace Dune
    │ │ │ │ -
    14{
    │ │ │ │ -
    17 template <class T>
    │ │ │ │ -
    18 using ToUniquePtr [[deprecated]] = std::unique_ptr<T>;
    │ │ │ │ -
    19
    │ │ │ │ -
    22 template <class T, class... Args>
    │ │ │ │ -
    │ │ │ │ -
    23 [[deprecated]] std::unique_ptr<T> makeToUnique (Args&&... args)
    │ │ │ │ -
    24 {
    │ │ │ │ -
    25 return std::make_unique(std::forward<Args>(args)...);
    │ │ │ │ -
    26 }
    │ │ │ │ -
    │ │ │ │ -
    27
    │ │ │ │ -
    28} // end namespace Dune
    │ │ │ │ -
    29
    │ │ │ │ -
    30#endif // DUNE_TO_UNIQUE_PTR_HH
    │ │ │ │ -
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ -
    std::unique_ptr< T > makeToUnique(Args &&... args)
    Alias for std::make_unique introduced as transition wrapper.
    Definition to_unique_ptr.hh:23
    │ │ │ │ -
    std::unique_ptr< T > ToUniquePtr
    Alias for std::unique_ptr introduced as transition wrapper.
    Definition to_unique_ptr.hh:18
    │ │ │ │ +
    5#ifndef DUNE_COMMON_ASSERTANDRETURN_HH
    │ │ │ │ +
    6#define DUNE_COMMON_ASSERTANDRETURN_HH
    │ │ │ │ +
    7
    │ │ │ │ +
    8#include <cassert>
    │ │ │ │ +
    9
    │ │ │ │ +
    11
    │ │ │ │ +
    19#ifdef NDEBUG
    │ │ │ │ +
    20 #define DUNE_ASSERT_AND_RETURN(C,X) X
    │ │ │ │ +
    21#else
    │ │ │ │ +
    22 #define DUNE_ASSERT_AND_RETURN(C,X) (!(C) ? throw [&](){assert(!#C);return 0;}() : 0), X
    │ │ │ │ +
    23#endif
    │ │ │ │ +
    24
    │ │ │ │ +
    25
    │ │ │ │ +
    26
    │ │ │ │ +
    27#endif // DUNE_COMMON_ASSERTANDRETURN_HH
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,51 +7,33 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -to_unique_ptr.hh │ │ │ │ │ +assertandreturn.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 (C) 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_TO_UNIQUE_PTR_HH │ │ │ │ │ - 7#define DUNE_TO_UNIQUE_PTR_HH │ │ │ │ │ - 8 │ │ │ │ │ - 9#warning to_unique_ptr.hh and ToUniquePtr are deprecated. Use std::unique_ptr │ │ │ │ │ -or std::shared_ptr instead. │ │ │ │ │ - 10 │ │ │ │ │ - 11#include │ │ │ │ │ - 12 │ │ │ │ │ - 13namespace Dune │ │ │ │ │ - 14{ │ │ │ │ │ - 17 template │ │ │ │ │ -18 using ToUniquePtr [[deprecated]] = std::unique_ptr; │ │ │ │ │ - 19 │ │ │ │ │ - 22 template │ │ │ │ │ -23 [[deprecated]] std::unique_ptr makeToUnique (Args&&... args) │ │ │ │ │ - 24 { │ │ │ │ │ - 25 return std::make_unique(std::forward(args)...); │ │ │ │ │ - 26 } │ │ │ │ │ - 27 │ │ │ │ │ - 28} // end namespace Dune │ │ │ │ │ - 29 │ │ │ │ │ - 30#endif // DUNE_TO_UNIQUE_PTR_HH │ │ │ │ │ -Dune │ │ │ │ │ -Dune namespace. │ │ │ │ │ -Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::makeToUnique │ │ │ │ │ -std::unique_ptr< T > makeToUnique(Args &&... args) │ │ │ │ │ -Alias for std::make_unique introduced as transition wrapper. │ │ │ │ │ -Definition to_unique_ptr.hh:23 │ │ │ │ │ -Dune::ToUniquePtr │ │ │ │ │ -std::unique_ptr< T > ToUniquePtr │ │ │ │ │ -Alias for std::unique_ptr introduced as transition wrapper. │ │ │ │ │ -Definition to_unique_ptr.hh:18 │ │ │ │ │ + 5#ifndef DUNE_COMMON_ASSERTANDRETURN_HH │ │ │ │ │ + 6#define DUNE_COMMON_ASSERTANDRETURN_HH │ │ │ │ │ + 7 │ │ │ │ │ + 8#include │ │ │ │ │ + 9 │ │ │ │ │ + 11 │ │ │ │ │ + 19#ifdef NDEBUG │ │ │ │ │ + 20 #define DUNE_ASSERT_AND_RETURN(C,X) X │ │ │ │ │ + 21#else │ │ │ │ │ +22 #define DUNE_ASSERT_AND_RETURN(C,X) (!(C) ? throw [&](){assert(!#C);return │ │ │ │ │ +0;}() : 0), X │ │ │ │ │ + 23#endif │ │ │ │ │ + 24 │ │ │ │ │ + 25 │ │ │ │ │ + 26 │ │ │ │ │ + 27#endif // DUNE_COMMON_ASSERTANDRETURN_HH │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00125.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: dotproduct.hh File Reference │ │ │ │ +dune-common: debugalign.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -72,53 +72,378 @@ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ Classes | │ │ │ │ Namespaces | │ │ │ │ -Functions
    │ │ │ │ -
    dotproduct.hh File Reference
    │ │ │ │ +Macros | │ │ │ │ +Typedefs | │ │ │ │ +Functions | │ │ │ │ +Variables
    │ │ │ │ +
    debugalign.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"
    │ │ │ │ +
    #include <algorithm>
    │ │ │ │ +#include <cassert>
    │ │ │ │ +#include <cmath>
    │ │ │ │ +#include <complex>
    │ │ │ │ +#include <cstddef>
    │ │ │ │ +#include <cstdint>
    │ │ │ │ +#include <cstdlib>
    │ │ │ │ +#include <functional>
    │ │ │ │ +#include <istream>
    │ │ │ │ +#include <ostream>
    │ │ │ │ +#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>
    │ │ │ │
    │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ Classes

    struct  Dune::IsVector< T, class >
    class  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::IsVector< T, std::void_t< typename T::field_type > >
    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

    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.
     
    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
     
    │ │ │ │ -

    Detailed Description

    │ │ │ │ -

    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
    │ │ │ │ -
    │ │ │ │ +

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

    Provides the TupleVector class that augments std::tuple by operator[]. │ │ │ │ +

    Simple base class templates for functions. │ │ │ │ More...

    │ │ │ │ -
    #include <tuple>
    │ │ │ │ -#include <utility>
    │ │ │ │ -#include <dune/common/indices.hh>
    │ │ │ │ -#include <dune/common/typetraits.hh>
    │ │ │ │ -#include <dune/common/std/type_traits.hh>
    │ │ │ │ +
    #include <utility>
    │ │ │ │ +#include <dune/common/deprecated.hh>
    │ │ │ │ +#include "typetraits.hh"
    │ │ │ │
    │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ Classes

    class  Dune::TupleVector< T >
     A class augmenting std::tuple by element access via operator[]. More...
    class  Dune::Function< Domain, Range >
     Base class template for function classes. More...
     
    struct  Dune::Function< Domain, Range >::Traits
     Traits class containing raw types. More...
     
    class  Dune::VirtualFunction< DomainType, RangeType >
     Virtual base class template for function classes. More...
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

    │ │ │ │ Namespaces

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

    │ │ │ │ +Macros

    #define DUNE_FUNCTION_HH
     
    │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

    │ │ │ │ Functions

    template<class... T>
    constexpr auto Dune::makeTupleVector (T &&... t)
     
    template<typename Domain , typename Range , typename F >
    Impl::LambdaVirtualFunction< Domain, Range, std::decay_t< F > > Dune::makeVirtualFunction (F &&f)
     make VirtualFunction out of a function object
     
    │ │ │ │

    Detailed Description

    │ │ │ │ -

    Provides the TupleVector class that augments std::tuple by operator[].

    │ │ │ │ -
    Author
    Carsten Gräser
    │ │ │ │ -
    │ │ │ │ +

    Simple base class templates for functions.

    │ │ │ │ +

    Macro Definition Documentation

    │ │ │ │ + │ │ │ │ +

    ◆ DUNE_FUNCTION_HH

    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    #define DUNE_FUNCTION_HH
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── encoding │ │ │ │ │ @@ -1 +1 @@ │ │ │ │ │ -utf-8 │ │ │ │ │ +us-ascii │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,35 +6,47 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Functions │ │ │ │ │ -tuplevector.hh File Reference │ │ │ │ │ -Provides the TupleVector class that augments std::tuple by operator[]. More... │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces | Macros | Functions │ │ │ │ │ +function.hh File Reference │ │ │ │ │ +Common │ │ │ │ │ +Simple base class templates for functions. More... │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include "typetraits.hh" │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class  Dune::TupleVector<_T_> │ │ │ │ │ -  A class augmenting std::tuple by element access via operator[]. More... │ │ │ │ │ + class  Dune::Function<_Domain,_Range_> │ │ │ │ │ +  Base class template for function classes. More... │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::Function<_Domain,_Range_>::Traits │ │ │ │ │ +  Traits class containing raw types. More... │ │ │ │ │ +  │ │ │ │ │ + class  Dune::VirtualFunction<_DomainType,_RangeType_> │ │ │ │ │ +  Virtual base class template for function classes. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ + Macros │ │ │ │ │ +#define DUNE_FUNCTION_HH │ │ │ │ │ +  │ │ │ │ │ Functions │ │ │ │ │ -template │ │ │ │ │ -constexpr auto Dune::makeTupleVector (T &&... t) │ │ │ │ │ +template │ │ │ │ │ +Impl::LambdaVirtualFunction< Domain, │ │ │ │ │ + Range, std::decay_t< F > > Dune::makeVirtualFunction (F &&f) │ │ │ │ │ +  make VirtualFunction out of a function │ │ │ │ │ + object │ │ │ │ │   │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Provides the TupleVector class that augments std::tuple by operator[]. │ │ │ │ │ - Author │ │ │ │ │ - Carsten Gräser │ │ │ │ │ +Simple base class templates for functions. │ │ │ │ │ +***** Macro Definition Documentation ***** │ │ │ │ │ +***** ◆ DUNE_FUNCTION_HH ***** │ │ │ │ │ +#define DUNE_FUNCTION_HH │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00128_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: tuplevector.hh Source File │ │ │ │ +dune-common: function.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,120 +74,143 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    tuplevector.hh
    │ │ │ │ +
    function.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 (C) 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_TUPLEVECTOR_HH
    │ │ │ │ -
    6#define DUNE_COMMON_TUPLEVECTOR_HH
    │ │ │ │ -
    7
    │ │ │ │ -
    8#include <tuple>
    │ │ │ │ -
    9#include <utility>
    │ │ │ │ +
    5#ifndef DUNE_FUNCTION_HH_SILENCE_DEPRECATION
    │ │ │ │ +
    6#warning This file is deprecated after Dune 2.7! Use C++ function objects and std::function stuff instead!
    │ │ │ │ +
    7#else // !DUNE_FUNCTION_HH_SILENCE_DEPRECATION
    │ │ │ │ +
    8#undef DUNE_FUNCTION_HH_SILENCE_DEPRECATION
    │ │ │ │ +
    9#endif // !DUNE_FUNCTION_HH_SILENCE_DEPRECATION
    │ │ │ │
    10
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
    14
    │ │ │ │ +
    11#ifndef DUNE_FUNCTION_HH
    │ │ │ │ +
    12#define DUNE_FUNCTION_HH
    │ │ │ │ +
    13
    │ │ │ │ +
    14#include <utility>
    │ │ │ │
    15
    │ │ │ │ -
    16
    │ │ │ │ -
    23namespace Dune
    │ │ │ │ -
    24{
    │ │ │ │ -
    25
    │ │ │ │ -
    26
    │ │ │ │ -
    27
    │ │ │ │ -
    33template<class... T>
    │ │ │ │ -
    │ │ │ │ -
    34class TupleVector : public std::tuple<T...>
    │ │ │ │ -
    35{
    │ │ │ │ -
    36 using Base = std::tuple<T...>;
    │ │ │ │ -
    37
    │ │ │ │ -
    38 template<class... TT>
    │ │ │ │ -
    39 using TupleConstructorDetector = decltype(Base(std::declval<TT&&>()...));
    │ │ │ │ -
    40
    │ │ │ │ -
    41 template<class... TT>
    │ │ │ │ -
    42 using hasTupleConstructor = Dune::Std::is_detected<TupleConstructorDetector, TT...>;
    │ │ │ │ -
    43
    │ │ │ │ + │ │ │ │ +
    17#include "typetraits.hh"
    │ │ │ │ +
    18
    │ │ │ │ +
    19namespace Dune {
    │ │ │ │ +
    20
    │ │ │ │ +
    36 template <class Domain, class Range>
    │ │ │ │ +
    │ │ │ │ +
    37 class
    │ │ │ │ +
    38 [[deprecated("Dune::Function is deprecated after Dune 2.7. Use C++ "
    │ │ │ │ +
    39 "function objects instead!")]]
    │ │ │ │ + │ │ │ │ +
    41 {
    │ │ │ │ +
    42 typedef typename std::remove_cv<typename std::remove_reference< Domain >::type >::type RawDomainType;
    │ │ │ │ +
    43 typedef typename std::remove_cv<typename std::remove_reference< Range >::type >::type RawRangeType;
    │ │ │ │
    44
    │ │ │ │ -
    45public:
    │ │ │ │ +
    45 public:
    │ │ │ │
    46
    │ │ │ │ -
    53 template<class... TT,
    │ │ │ │ -
    54 std::enable_if_t<hasTupleConstructor<TT...>::value, int> = 0>
    │ │ │ │ -
    │ │ │ │ -
    55 constexpr TupleVector(TT&&... tt) :
    │ │ │ │ -
    56 Base(std::forward<TT>(tt)...)
    │ │ │ │ -
    57 {}
    │ │ │ │ -
    │ │ │ │ -
    58
    │ │ │ │ -
    │ │ │ │ -
    61 constexpr TupleVector()
    │ │ │ │ -
    62 {}
    │ │ │ │ -
    │ │ │ │ -
    63
    │ │ │ │ -
    66 template<std::size_t i>
    │ │ │ │ -
    │ │ │ │ -
    67 constexpr decltype(auto) operator[](const Dune::index_constant<i>&) const
    │ │ │ │ -
    68 {
    │ │ │ │ -
    69 return std::get<i>(*this);
    │ │ │ │ -
    70 }
    │ │ │ │ -
    │ │ │ │ -
    71
    │ │ │ │ -
    74 template<std::size_t i>
    │ │ │ │ -
    │ │ │ │ -
    75 decltype(auto) operator[](const Dune::index_constant<i>&)
    │ │ │ │ -
    76 {
    │ │ │ │ -
    77 return std::get<i>(*this);
    │ │ │ │ -
    78 }
    │ │ │ │ -
    │ │ │ │ -
    79
    │ │ │ │ -
    │ │ │ │ -
    81 static constexpr std::size_t size()
    │ │ │ │ -
    82 {
    │ │ │ │ -
    83 return std::tuple_size<Base>::value;
    │ │ │ │ -
    84 }
    │ │ │ │ -
    │ │ │ │ -
    85};
    │ │ │ │ -
    │ │ │ │ -
    86
    │ │ │ │ -
    87
    │ │ │ │ -
    88
    │ │ │ │ -
    89template<class... T>
    │ │ │ │ -
    │ │ │ │ -
    90constexpr auto makeTupleVector(T&&... t)
    │ │ │ │ -
    91{
    │ │ │ │ -
    92 // The std::decay_t<T> is is a slight simplification,
    │ │ │ │ -
    93 // because std::reference_wrapper needs special care.
    │ │ │ │ -
    94 return TupleVector<std::decay_t<T>...>(std::forward<T>(t)...);
    │ │ │ │ -
    95}
    │ │ │ │ -
    │ │ │ │ -
    96
    │ │ │ │ -
    97
    │ │ │ │ -
    98
    │ │ │ │ -
    99} // namespace Dune
    │ │ │ │ -
    100
    │ │ │ │ -
    101#endif // DUNE_COMMON_TUPLEVECTOR_HH
    │ │ │ │ -
    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:30
    │ │ │ │ -
    typename detected_or< nonesuch, Op, Args... >::value_t is_detected
    Detects whether Op<Args...> is valid.
    Definition type_traits.hh:141
    │ │ │ │ -
    STL namespace.
    │ │ │ │ +
    48 typedef RawRangeType RangeType;
    │ │ │ │ +
    49
    │ │ │ │ +
    51 typedef RawDomainType DomainType;
    │ │ │ │ +
    52
    │ │ │ │ +
    │ │ │ │ +
    54 struct Traits
    │ │ │ │ +
    55 {
    │ │ │ │ +
    56 typedef RawDomainType DomainType;
    │ │ │ │ +
    57 typedef RawRangeType RangeType;
    │ │ │ │ +
    58 };
    │ │ │ │ +
    │ │ │ │ +
    59
    │ │ │ │ +
    66 void evaluate(const typename Traits::DomainType& x, typename Traits::RangeType& y) const;
    │ │ │ │ +
    67 }; // end of Function class
    │ │ │ │ +
    │ │ │ │ +
    68
    │ │ │ │ +
    69
    │ │ │ │ +
    70
    │ │ │ │ + │ │ │ │ +
    82 template <class DomainType, class RangeType>
    │ │ │ │ +
    │ │ │ │ +
    83 class
    │ │ │ │ +
    84 [[deprecated("Dune::VirtualFunction is deprecated after Dune 2.7. Use C++ "
    │ │ │ │ +
    85 "function objects and std::function instead!")]]
    │ │ │ │ + │ │ │ │ +
    87 {
    │ │ │ │ +
    88 public:
    │ │ │ │ + │ │ │ │ +
    90
    │ │ │ │ +
    91 virtual ~VirtualFunction() {}
    │ │ │ │ +
    98 virtual void evaluate(const typename Traits::DomainType& x, typename Traits::RangeType& y) const = 0;
    │ │ │ │ +
    99 }; // end of VirtualFunction class
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    101
    │ │ │ │ +
    102 namespace Impl {
    │ │ │ │ +
    103
    │ │ │ │ + │ │ │ │ +
    105 template<typename Domain, typename Range, typename F>
    │ │ │ │ +
    106 class LambdaVirtualFunction final
    │ │ │ │ +
    107 : public VirtualFunction<Domain, Range>
    │ │ │ │ +
    108 {
    │ │ │ │ +
    109 public:
    │ │ │ │ +
    110 LambdaVirtualFunction(F&& f)
    │ │ │ │ +
    111 : f_(std::move(f))
    │ │ │ │ +
    112 {}
    │ │ │ │ +
    113
    │ │ │ │ +
    114 LambdaVirtualFunction(const F& f)
    │ │ │ │ +
    115 : f_(f)
    │ │ │ │ +
    116 {}
    │ │ │ │ +
    117
    │ │ │ │ +
    118 void evaluate(const Domain& x, Range& y) const override
    │ │ │ │ +
    119 {
    │ │ │ │ +
    120 y = f_(x);
    │ │ │ │ +
    121 }
    │ │ │ │ +
    122
    │ │ │ │ +
    123 private:
    │ │ │ │ +
    124 const F f_;
    │ │ │ │ +
    125 };
    │ │ │ │ + │ │ │ │ +
    127
    │ │ │ │ +
    128 } /* namespace Impl */
    │ │ │ │ +
    129
    │ │ │ │ +
    149 template<typename Domain, typename Range, typename F>
    │ │ │ │ +
    150 [[deprecated("Dune::LambdaVirtualFunction is deprecated after Dune 2.7. "
    │ │ │ │ +
    151 "Use std::function instead!")]]
    │ │ │ │ +
    152 Impl::LambdaVirtualFunction< Domain, Range, std::decay_t<F> >
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    154 {
    │ │ │ │ +
    155 return {std::forward<F>(f)};
    │ │ │ │ +
    156 }
    │ │ │ │ +
    │ │ │ │ +
    157
    │ │ │ │ +
    160} // end namespace
    │ │ │ │ +
    161
    │ │ │ │ +
    162#endif
    │ │ │ │ +
    Definition of the DUNE_NO_DEPRECATED_* macros.
    │ │ │ │ +
    Traits for type conversions and type information.
    │ │ │ │ +
    Impl::LambdaVirtualFunction< Domain, Range, std::decay_t< F > > makeVirtualFunction(F &&f)
    make VirtualFunction out of a function object
    Definition function.hh:153
    │ │ │ │ +
    #define DUNE_NO_DEPRECATED_END
    Ignore deprecation warnings (end)
    Definition deprecated.hh:38
    │ │ │ │ +
    #define DUNE_NO_DEPRECATED_BEGIN
    Ignore deprecation warnings (start)
    Definition deprecated.hh:32
    │ │ │ │
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ -
    constexpr auto makeTupleVector(T &&... t)
    Definition tuplevector.hh:90
    │ │ │ │ -
    A class augmenting std::tuple by element access via operator[].
    Definition tuplevector.hh:35
    │ │ │ │ -
    static constexpr std::size_t size()
    Number of elements of the tuple.
    Definition tuplevector.hh:81
    │ │ │ │ -
    constexpr TupleVector(TT &&... tt)
    Construct from a set of arguments.
    Definition tuplevector.hh:55
    │ │ │ │ -
    constexpr TupleVector()
    Default constructor.
    Definition tuplevector.hh:61
    │ │ │ │ +
    Base class template for function classes.
    Definition function.hh:41
    │ │ │ │ +
    RawDomainType DomainType
    Raw type of output variable with removed reference and constness.
    Definition function.hh:51
    │ │ │ │ +
    void evaluate(const typename Traits::DomainType &x, typename Traits::RangeType &y) const
    Function evaluation.
    │ │ │ │ +
    RawRangeType RangeType
    Raw type of input variable with removed reference and constness.
    Definition function.hh:48
    │ │ │ │ +
    Traits class containing raw types.
    Definition function.hh:55
    │ │ │ │ +
    RawDomainType DomainType
    Definition function.hh:56
    │ │ │ │ +
    RawRangeType RangeType
    Definition function.hh:57
    │ │ │ │ +
    Virtual base class template for function classes.
    Definition function.hh:87
    │ │ │ │ +
    Function< constDomainType &, RangeType & >::Traits Traits
    Definition function.hh:89
    │ │ │ │ +
    virtual ~VirtualFunction()
    Definition function.hh:91
    │ │ │ │ +
    virtual void evaluate(const typename Traits::DomainType &x, typename Traits::RangeType &y) const =0
    Function evaluation.
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,126 +7,176 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -tuplevector.hh │ │ │ │ │ +function.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 (C) 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_TUPLEVECTOR_HH │ │ │ │ │ - 6#define DUNE_COMMON_TUPLEVECTOR_HH │ │ │ │ │ - 7 │ │ │ │ │ - 8#include │ │ │ │ │ - 9#include │ │ │ │ │ + 5#ifndef DUNE_FUNCTION_HH_SILENCE_DEPRECATION │ │ │ │ │ + 6#warning This file is deprecated after Dune 2.7! Use C++ function objects and │ │ │ │ │ +std::function stuff instead! │ │ │ │ │ + 7#else // !DUNE_FUNCTION_HH_SILENCE_DEPRECATION │ │ │ │ │ + 8#undef DUNE_FUNCTION_HH_SILENCE_DEPRECATION │ │ │ │ │ + 9#endif // !DUNE_FUNCTION_HH_SILENCE_DEPRECATION │ │ │ │ │ 10 │ │ │ │ │ - 11#include │ │ │ │ │ - 12#include │ │ │ │ │ - 13#include │ │ │ │ │ - 14 │ │ │ │ │ + 11#ifndef DUNE_FUNCTION_HH │ │ │ │ │ +12#define DUNE_FUNCTION_HH │ │ │ │ │ + 13 │ │ │ │ │ + 14#include │ │ │ │ │ 15 │ │ │ │ │ - 16 │ │ │ │ │ - 23namespace Dune │ │ │ │ │ - 24{ │ │ │ │ │ - 25 │ │ │ │ │ - 26 │ │ │ │ │ - 27 │ │ │ │ │ - 33template │ │ │ │ │ -34class TupleVector : public std::tuple │ │ │ │ │ - 35{ │ │ │ │ │ - 36 using Base = std::tuple; │ │ │ │ │ - 37 │ │ │ │ │ - 38 template │ │ │ │ │ - 39 using TupleConstructorDetector = decltype(Base(std::declval()...)); │ │ │ │ │ - 40 │ │ │ │ │ - 41 template │ │ │ │ │ - 42 using hasTupleConstructor = Dune::Std:: │ │ │ │ │ -is_detected; │ │ │ │ │ - 43 │ │ │ │ │ + 16#include │ │ │ │ │ + 17#include "typetraits.hh" │ │ │ │ │ + 18 │ │ │ │ │ + 19namespace Dune { │ │ │ │ │ + 20 │ │ │ │ │ + 36 template │ │ │ │ │ +37 class │ │ │ │ │ + 38 [[deprecated("Dune::Function is deprecated after Dune 2.7. Use C++ " │ │ │ │ │ + 39 "function objects instead!")]] │ │ │ │ │ + 40 Function │ │ │ │ │ + 41 { │ │ │ │ │ + 42 typedef typename std::remove_cv:: │ │ │ │ │ +type >::type RawDomainType; │ │ │ │ │ + 43 typedef typename std::remove_cv:: │ │ │ │ │ +type >::type RawRangeType; │ │ │ │ │ 44 │ │ │ │ │ - 45public: │ │ │ │ │ + 45 public: │ │ │ │ │ 46 │ │ │ │ │ - 53 template::value, int> = 0> │ │ │ │ │ -55 constexpr TupleVector(TT&&... tt) : │ │ │ │ │ - 56 Base(std::forward(tt)...) │ │ │ │ │ - 57 {} │ │ │ │ │ - 58 │ │ │ │ │ -61 constexpr TupleVector() │ │ │ │ │ - 62 {} │ │ │ │ │ - 63 │ │ │ │ │ - 66 template │ │ │ │ │ -67 constexpr decltype(auto) operator[](const Dune::index_constant&) const │ │ │ │ │ - 68 { │ │ │ │ │ - 69 return std::get(*this); │ │ │ │ │ - 70 } │ │ │ │ │ - 71 │ │ │ │ │ - 74 template │ │ │ │ │ -75 decltype(auto) operator[](const Dune::index_constant&) │ │ │ │ │ - 76 { │ │ │ │ │ - 77 return std::get(*this); │ │ │ │ │ - 78 } │ │ │ │ │ - 79 │ │ │ │ │ -81 static constexpr std::size_t size() │ │ │ │ │ - 82 { │ │ │ │ │ - 83 return std::tuple_size::value; │ │ │ │ │ - 84 } │ │ │ │ │ - 85}; │ │ │ │ │ - 86 │ │ │ │ │ - 87 │ │ │ │ │ - 88 │ │ │ │ │ - 89template │ │ │ │ │ -90constexpr auto makeTupleVector(T&&... t) │ │ │ │ │ - 91{ │ │ │ │ │ - 92 // The std::decay_t is is a slight simplification, │ │ │ │ │ - 93 // because std::reference_wrapper needs special care. │ │ │ │ │ - 94 return TupleVector...>(std::forward(t)...); │ │ │ │ │ - 95} │ │ │ │ │ - 96 │ │ │ │ │ - 97 │ │ │ │ │ - 98 │ │ │ │ │ - 99} // namespace Dune │ │ │ │ │ - 100 │ │ │ │ │ - 101#endif // DUNE_COMMON_TUPLEVECTOR_HH │ │ │ │ │ +48 typedef RawRangeType RangeType; │ │ │ │ │ + 49 │ │ │ │ │ +51 typedef RawDomainType DomainType; │ │ │ │ │ + 52 │ │ │ │ │ +54 struct Traits │ │ │ │ │ + 55 { │ │ │ │ │ +56 typedef RawDomainType DomainType; │ │ │ │ │ +57 typedef RawRangeType RangeType; │ │ │ │ │ + 58 }; │ │ │ │ │ + 59 │ │ │ │ │ +66 void evaluate(const typename Traits::DomainType& x, typename Traits:: │ │ │ │ │ +RangeType& y) const; │ │ │ │ │ + 67 }; // end of Function class │ │ │ │ │ + 68 │ │ │ │ │ + 69 │ │ │ │ │ + 70 │ │ │ │ │ + 71 DUNE_NO_DEPRECATED_BEGIN │ │ │ │ │ + 82 template │ │ │ │ │ +83 class │ │ │ │ │ + 84 [[deprecated("Dune::VirtualFunction is deprecated after Dune 2.7. Use C++ " │ │ │ │ │ + 85 "function objects and std::function instead!")]] │ │ │ │ │ + 86 VirtualFunction : public Function │ │ │ │ │ + 87 { │ │ │ │ │ + 88 public: │ │ │ │ │ +89 typedef typename Function::Traits Traits; │ │ │ │ │ + 90 │ │ │ │ │ +91 virtual ~VirtualFunction() {} │ │ │ │ │ +98 virtual void evaluate(const typename Traits::DomainType& x, typename │ │ │ │ │ +Traits::RangeType& y) const = 0; │ │ │ │ │ + 99 }; // end of VirtualFunction class │ │ │ │ │ + 100 DUNE_NO_DEPRECATED_END │ │ │ │ │ + 101 │ │ │ │ │ + 102 namespace Impl { │ │ │ │ │ + 103 │ │ │ │ │ + 104 DUNE_NO_DEPRECATED_BEGIN │ │ │ │ │ + 105 template │ │ │ │ │ + 106 class LambdaVirtualFunction final │ │ │ │ │ + 107 : public VirtualFunction │ │ │ │ │ + 108 { │ │ │ │ │ + 109 public: │ │ │ │ │ + 110 LambdaVirtualFunction(F&& f) │ │ │ │ │ + 111 : f_(std::move(f)) │ │ │ │ │ + 112 {} │ │ │ │ │ + 113 │ │ │ │ │ + 114 LambdaVirtualFunction(const F& f) │ │ │ │ │ + 115 : f_(f) │ │ │ │ │ + 116 {} │ │ │ │ │ + 117 │ │ │ │ │ + 118 void evaluate(const Domain& x, Range& y) const override │ │ │ │ │ + 119 { │ │ │ │ │ + 120 y = f_(x); │ │ │ │ │ + 121 } │ │ │ │ │ + 122 │ │ │ │ │ + 123 private: │ │ │ │ │ + 124 const F f_; │ │ │ │ │ + 125 }; │ │ │ │ │ + 126 DUNE_NO_DEPRECATED_END │ │ │ │ │ + 127 │ │ │ │ │ + 128 } /* namespace Impl */ │ │ │ │ │ + 129 │ │ │ │ │ + 149 template │ │ │ │ │ + 150 [[deprecated("Dune::LambdaVirtualFunction is deprecated after Dune 2.7. " │ │ │ │ │ + 151 "Use std::function instead!")]] │ │ │ │ │ + 152 Impl::LambdaVirtualFunction< Domain, Range, std::decay_t > │ │ │ │ │ +153 makeVirtualFunction(F&& f) │ │ │ │ │ + 154 { │ │ │ │ │ + 155 return {std::forward(f)}; │ │ │ │ │ + 156 } │ │ │ │ │ + 157 │ │ │ │ │ + 160} // end namespace │ │ │ │ │ + 161 │ │ │ │ │ + 162#endif │ │ │ │ │ +deprecated.hh │ │ │ │ │ +Definition of the DUNE_NO_DEPRECATED_* macros. │ │ │ │ │ typetraits.hh │ │ │ │ │ Traits for type conversions and type information. │ │ │ │ │ -indices.hh │ │ │ │ │ -type_traits.hh │ │ │ │ │ -Dune::index_constant │ │ │ │ │ -std::integral_constant< std::size_t, i > index_constant │ │ │ │ │ -An index constant with value i. │ │ │ │ │ -Definition indices.hh:30 │ │ │ │ │ -Dune::Std::is_detected │ │ │ │ │ -typename detected_or< nonesuch, Op, Args... >::value_t is_detected │ │ │ │ │ -Detects whether Op is valid. │ │ │ │ │ -Definition type_traits.hh:141 │ │ │ │ │ -std │ │ │ │ │ -STL namespace. │ │ │ │ │ +Dune::makeVirtualFunction │ │ │ │ │ +Impl::LambdaVirtualFunction< Domain, Range, std::decay_t< F > > │ │ │ │ │ +makeVirtualFunction(F &&f) │ │ │ │ │ +make VirtualFunction out of a function object │ │ │ │ │ +Definition function.hh:153 │ │ │ │ │ +DUNE_NO_DEPRECATED_END │ │ │ │ │ +#define DUNE_NO_DEPRECATED_END │ │ │ │ │ +Ignore deprecation warnings (end) │ │ │ │ │ +Definition deprecated.hh:38 │ │ │ │ │ +DUNE_NO_DEPRECATED_BEGIN │ │ │ │ │ +#define DUNE_NO_DEPRECATED_BEGIN │ │ │ │ │ +Ignore deprecation warnings (start) │ │ │ │ │ +Definition deprecated.hh:32 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::makeTupleVector │ │ │ │ │ -constexpr auto makeTupleVector(T &&... t) │ │ │ │ │ -Definition tuplevector.hh:90 │ │ │ │ │ -Dune::TupleVector │ │ │ │ │ -A class augmenting std::tuple by element access via operator[]. │ │ │ │ │ -Definition tuplevector.hh:35 │ │ │ │ │ -Dune::TupleVector::size │ │ │ │ │ -static constexpr std::size_t size() │ │ │ │ │ -Number of elements of the tuple. │ │ │ │ │ -Definition tuplevector.hh:81 │ │ │ │ │ -Dune::TupleVector::TupleVector │ │ │ │ │ -constexpr TupleVector(TT &&... tt) │ │ │ │ │ -Construct from a set of arguments. │ │ │ │ │ -Definition tuplevector.hh:55 │ │ │ │ │ -Dune::TupleVector::TupleVector │ │ │ │ │ -constexpr TupleVector() │ │ │ │ │ -Default constructor. │ │ │ │ │ -Definition tuplevector.hh:61 │ │ │ │ │ +Dune::Function │ │ │ │ │ +Base class template for function classes. │ │ │ │ │ +Definition function.hh:41 │ │ │ │ │ +Dune::Function::DomainType │ │ │ │ │ +RawDomainType DomainType │ │ │ │ │ +Raw type of output variable with removed reference and constness. │ │ │ │ │ +Definition function.hh:51 │ │ │ │ │ +Dune::Function::evaluate │ │ │ │ │ +void evaluate(const typename Traits::DomainType &x, typename Traits::RangeType │ │ │ │ │ +&y) const │ │ │ │ │ +Function evaluation. │ │ │ │ │ +Dune::Function::RangeType │ │ │ │ │ +RawRangeType RangeType │ │ │ │ │ +Raw type of input variable with removed reference and constness. │ │ │ │ │ +Definition function.hh:48 │ │ │ │ │ +Dune::Function::Traits │ │ │ │ │ +Traits class containing raw types. │ │ │ │ │ +Definition function.hh:55 │ │ │ │ │ +Dune::Function::Traits::DomainType │ │ │ │ │ +RawDomainType DomainType │ │ │ │ │ +Definition function.hh:56 │ │ │ │ │ +Dune::Function::Traits::RangeType │ │ │ │ │ +RawRangeType RangeType │ │ │ │ │ +Definition function.hh:57 │ │ │ │ │ +Dune::VirtualFunction │ │ │ │ │ +Virtual base class template for function classes. │ │ │ │ │ +Definition function.hh:87 │ │ │ │ │ +Dune::VirtualFunction::Traits │ │ │ │ │ +Function< constDomainType &, RangeType & >::Traits Traits │ │ │ │ │ +Definition function.hh:89 │ │ │ │ │ +Dune::VirtualFunction::~VirtualFunction │ │ │ │ │ +virtual ~VirtualFunction() │ │ │ │ │ +Definition function.hh:91 │ │ │ │ │ +Dune::VirtualFunction::evaluate │ │ │ │ │ +virtual void evaluate(const typename Traits::DomainType &x, typename Traits:: │ │ │ │ │ +RangeType &y) const =0 │ │ │ │ │ +Function evaluation. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00131.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: bigunsignedint.hh File Reference │ │ │ │ +dune-common: path.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,97 +70,56 @@ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ -Classes | │ │ │ │ Namespaces | │ │ │ │ -Macros | │ │ │ │ Functions
    │ │ │ │ -
    bigunsignedint.hh File Reference
    │ │ │ │ +
    path.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ -

    Portable very large unsigned integers. │ │ │ │ +

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

    │ │ │ │ -
    #include <algorithm>
    │ │ │ │ -#include <iostream>
    │ │ │ │ -#include <limits>
    │ │ │ │ -#include <cstdint>
    │ │ │ │ -#include <cstdlib>
    │ │ │ │ -#include <type_traits>
    │ │ │ │ -#include <dune/common/exceptions.hh>
    │ │ │ │ -#include <dune/common/hash.hh>
    │ │ │ │ +
    #include <string>
    │ │ │ │
    │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ -Classes

    class  Dune::bigunsignedint< k >
     Portable very large unsigned integers. More...
     
    struct  Dune::IsNumber< bigunsignedint< k > >
     Declare big unsigned int is a number. More...
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

    │ │ │ │ Namespaces

    namespace  Dune
     Dune namespace.
     
    namespace  std
     STL namespace.
     
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │

    │ │ │ │ -Macros

    #define DUNE_BINOP(OP)
     
    │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

    │ │ │ │ Functions

    template<int k>
    std::ostream & Dune::operator<< (std::ostream &s, const bigunsignedint< k > &x)
     
    template<int k>
    bigunsignedint< k > Dune::operator+ (const bigunsignedint< k > &x, std::uintmax_t y)
     
    template<int k>
    bigunsignedint< k > Dune::operator- (const bigunsignedint< k > &x, std::uintmax_t y)
     
    template<int k>
    bigunsignedint< k > Dune::operator* (const bigunsignedint< k > &x, std::uintmax_t y)
     
    template<int k>
    bigunsignedint< k > Dune::operator/ (const bigunsignedint< k > &x, std::uintmax_t y)
     
    template<int k>
    bigunsignedint< k > Dune::operator% (const bigunsignedint< k > &x, std::uintmax_t y)
     
    template<int k>
    bigunsignedint< k > Dune::operator+ (std::uintmax_t x, const bigunsignedint< k > &y)
     
    template<int k>
    bigunsignedint< k > Dune::operator- (std::uintmax_t x, const bigunsignedint< k > &y)
     
    template<int k>
    bigunsignedint< k > Dune::operator* (std::uintmax_t x, const bigunsignedint< k > &y)
     
    template<int k>
    bigunsignedint< k > Dune::operator/ (std::uintmax_t x, const bigunsignedint< k > &y)
     
    template<int k>
    bigunsignedint< k > Dune::operator% (std::uintmax_t x, const bigunsignedint< k > &y)
     
    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
     
    │ │ │ │

    Detailed Description

    │ │ │ │ -

    Portable very large unsigned integers.

    │ │ │ │ -
    Author
    Peter Bastian
    │ │ │ │ +

    Utilities for handling filesystem paths.

    │ │ │ │ +
    Author
    Jö Fahlke jorri.nosp@m.t@jo.nosp@m.rrit..nosp@m.de
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── encoding │ │ │ │ │ @@ -1 +1 @@ │ │ │ │ │ -us-ascii │ │ │ │ │ +utf-8 │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,88 +6,44 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Macros | Functions │ │ │ │ │ -bigunsignedint.hh File Reference │ │ │ │ │ -Portable very large unsigned integers. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Namespaces | Functions │ │ │ │ │ +path.hh File Reference │ │ │ │ │ +Common » Utilities » Filesystem_Paths │ │ │ │ │ +Utilities for handling filesystem paths. More... │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ - Classes │ │ │ │ │ - class  Dune::bigunsignedint<_k_> │ │ │ │ │ -  Portable very large unsigned integers. More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::IsNumber<_bigunsignedint<_k_>_> │ │ │ │ │ -  Declare big unsigned int is a number. More... │ │ │ │ │ -  │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -namespace  std │ │ │ │ │ -  STL namespace. │ │ │ │ │ + Functions │ │ │ │ │ +std::string Dune::concatPaths (const std::string &base, const std::string &p) │ │ │ │ │ +  concatenate two paths │ │ │ │ │   │ │ │ │ │ - Macros │ │ │ │ │ -#define DUNE_BINOP(OP) │ │ │ │ │ +std::string Dune::processPath (const std::string &p) │ │ │ │ │ +  sanitize a path for further processing │ │ │ │ │   │ │ │ │ │ - Functions │ │ │ │ │ -template │ │ │ │ │ - std::ostream & Dune::operator<< (std::ostream &s, const bigunsignedint< k │ │ │ │ │ - > &x) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bigunsignedint< k > Dune::operator+ (const bigunsignedint< k > &x, std:: │ │ │ │ │ - uintmax_t y) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bigunsignedint< k > Dune::operator- (const bigunsignedint< k > &x, std:: │ │ │ │ │ - uintmax_t y) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bigunsignedint< k > Dune::operator* (const bigunsignedint< k > &x, std:: │ │ │ │ │ - uintmax_t y) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bigunsignedint< k > Dune::operator/ (const bigunsignedint< k > &x, std:: │ │ │ │ │ - uintmax_t y) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bigunsignedint< k > Dune::operator% (const bigunsignedint< k > &x, std:: │ │ │ │ │ - uintmax_t y) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bigunsignedint< k > Dune::operator+ (std::uintmax_t x, const bigunsignedint< k │ │ │ │ │ - > &y) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bigunsignedint< k > Dune::operator- (std::uintmax_t x, const bigunsignedint< k │ │ │ │ │ - > &y) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bigunsignedint< k > Dune::operator* (std::uintmax_t x, const bigunsignedint< k │ │ │ │ │ - > &y) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bigunsignedint< k > Dune::operator/ (std::uintmax_t x, const bigunsignedint< k │ │ │ │ │ - > &y) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bigunsignedint< k > Dune::operator% (std::uintmax_t x, const bigunsignedint< k │ │ │ │ │ - > &y) │ │ │ │ │ + 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 │ │ │ │ │   │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Portable very large unsigned integers. │ │ │ │ │ +Utilities for handling filesystem paths. │ │ │ │ │ Author │ │ │ │ │ - Peter Bastian │ │ │ │ │ + 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/a00131_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: bigunsignedint.hh Source File │ │ │ │ +dune-common: path.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,799 +74,54 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    bigunsignedint.hh
    │ │ │ │ +
    path.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 (C) 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_BIGUNSIGNEDINT_HH
    │ │ │ │ -
    7#define DUNE_BIGUNSIGNEDINT_HH
    │ │ │ │ -
    8
    │ │ │ │ -
    9#include <algorithm>
    │ │ │ │ -
    10#include <iostream>
    │ │ │ │ -
    11#include <limits>
    │ │ │ │ -
    12#include <cstdint>
    │ │ │ │ -
    13#include <cstdlib>
    │ │ │ │ -
    14#include <type_traits>
    │ │ │ │ - │ │ │ │ -
    16#include <dune/common/hash.hh>
    │ │ │ │ -
    17
    │ │ │ │ -
    24namespace Dune
    │ │ │ │ -
    25{
    │ │ │ │ -
    26#if HAVE_MPI
    │ │ │ │ -
    27 template<class K>
    │ │ │ │ -
    28 struct MPITraits;
    │ │ │ │ -
    29#endif
    │ │ │ │ -
    30
    │ │ │ │ -
    36 namespace Impl {
    │ │ │ │ -
    37
    │ │ │ │ -
    38 // numeric_limits_helper provides std::numeric_limits access to the internals
    │ │ │ │ -
    39 // of bigunsignedint. Previously, the correct specialization of std::numeric_limits
    │ │ │ │ -
    40 // was a friend of bigunsignedint, but that creates problems on recent versions
    │ │ │ │ -
    41 // of clang with the alternative libc++ library, because that library declares the
    │ │ │ │ -
    42 // base template of std::numeric_limits as a class and clang subsequently complains
    │ │ │ │ -
    43 // if the friend declaration uses 'struct'. Unfortunately, libstdc++ uses a struct,
    │ │ │ │ -
    44 // making it impossible to keep clang happy for both standard libraries.
    │ │ │ │ -
    45 // So we move the access helper functionality into a custom struct and simply let
    │ │ │ │ -
    46 // the numeric_limits specialization inherit from the helper.
    │ │ │ │ -
    47
    │ │ │ │ -
    48 template<typename T>
    │ │ │ │ -
    49 struct numeric_limits_helper
    │ │ │ │ -
    50 {
    │ │ │ │ -
    51
    │ │ │ │ -
    52 protected:
    │ │ │ │ -
    53
    │ │ │ │ -
    54 static std::uint16_t& digit(T& big_unsigned_int, std::size_t i)
    │ │ │ │ -
    55 {
    │ │ │ │ -
    56 return big_unsigned_int.digit[i];
    │ │ │ │ -
    57 }
    │ │ │ │ -
    58
    │ │ │ │ -
    59 };
    │ │ │ │ -
    60
    │ │ │ │ -
    61 }
    │ │ │ │ -
    62
    │ │ │ │ -
    72 template<int k>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    74 public:
    │ │ │ │ -
    75
    │ │ │ │ -
    76 // unsigned short is 16 bits wide, n is the number of digits needed
    │ │ │ │ -
    77 constexpr static int bits = std::numeric_limits<std::uint16_t>::digits;
    │ │ │ │ -
    78 constexpr static int n = k/bits+(k%bits!=0);
    │ │ │ │ -
    79 constexpr static int hexdigits = 4;
    │ │ │ │ -
    80 constexpr static int bitmask = 0xFFFF;
    │ │ │ │ -
    81 constexpr static int compbitmask = 0xFFFF0000;
    │ │ │ │ -
    82 constexpr static int overflowmask = 0x1;
    │ │ │ │ -
    83
    │ │ │ │ - │ │ │ │ -
    86
    │ │ │ │ -
    88 template<typename Signed>
    │ │ │ │ -
    89 bigunsignedint (Signed x, typename std::enable_if<std::is_integral<Signed>::value && std::is_signed<Signed>::value>::type* = 0);
    │ │ │ │ -
    90
    │ │ │ │ -
    92 bigunsignedint (std::uintmax_t x);
    │ │ │ │ -
    93
    │ │ │ │ -
    95 void print (std::ostream& s) const ;
    │ │ │ │ -
    96
    │ │ │ │ - │ │ │ │ - │ │ │ │ -
    100
    │ │ │ │ - │ │ │ │ - │ │ │ │ -
    104
    │ │ │ │ - │ │ │ │ - │ │ │ │ -
    108
    │ │ │ │ - │ │ │ │ -
    111
    │ │ │ │ - │ │ │ │ - │ │ │ │ -
    117
    │ │ │ │ - │ │ │ │ - │ │ │ │ -
    123
    │ │ │ │ - │ │ │ │ - │ │ │ │ -
    127
    │ │ │ │ - │ │ │ │ - │ │ │ │ -
    131
    │ │ │ │ - │ │ │ │ - │ │ │ │ -
    135
    │ │ │ │ - │ │ │ │ -
    138
    │ │ │ │ -
    139
    │ │ │ │ -
    141 bigunsignedint<k> operator<< (int i) const;
    │ │ │ │ -
    142
    │ │ │ │ -
    144 bigunsignedint<k> operator>> (int i) const;
    │ │ │ │ -
    145
    │ │ │ │ -
    146
    │ │ │ │ -
    148 bool operator< (const bigunsignedint<k>& x) const;
    │ │ │ │ -
    149
    │ │ │ │ -
    151 bool operator<= (const bigunsignedint<k>& x) const;
    │ │ │ │ +
    5#ifndef DUNE_COMMON_PATH_HH
    │ │ │ │ +
    6#define DUNE_COMMON_PATH_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 bool operator> (const bigunsignedint<k>& x) const;
    │ │ │ │ -
    155
    │ │ │ │ -
    157 bool operator>= (const bigunsignedint<k>& x) const;
    │ │ │ │ -
    158
    │ │ │ │ -
    160 bool operator== (const bigunsignedint<k>& x) const;
    │ │ │ │ +
    154
    │ │ │ │ +
    160 std::string prettyPath(const std::string& p);
    │ │ │ │
    161
    │ │ │ │ -
    163 bool operator!= (const bigunsignedint<k>& x) const;
    │ │ │ │ -
    164
    │ │ │ │ -
    165
    │ │ │ │ -
    167 // operator unsigned int () const;
    │ │ │ │ -
    168 std::uint_least32_t touint() const;
    │ │ │ │ -
    174 double todouble() const;
    │ │ │ │ -
    175
    │ │ │ │ -
    176 friend class bigunsignedint<k/2>;
    │ │ │ │ -
    177 friend struct Impl::numeric_limits_helper< bigunsignedint<k> >;
    │ │ │ │ -
    178
    │ │ │ │ -
    │ │ │ │ -
    179 inline friend std::size_t hash_value(const bigunsignedint& arg)
    │ │ │ │ -
    180 {
    │ │ │ │ -
    181 return hash_range(arg.digit,arg.digit + arg.n);
    │ │ │ │ -
    182 }
    │ │ │ │ -
    │ │ │ │ +
    163
    │ │ │ │ +
    179 std::string relativePath(const std::string& newbase, const std::string& p);
    │ │ │ │ +
    180
    │ │ │ │ +
    182}
    │ │ │ │
    183
    │ │ │ │ -
    184 private:
    │ │ │ │ -
    185 std::uint16_t digit[n];
    │ │ │ │ -
    186#if HAVE_MPI
    │ │ │ │ -
    187 friend struct MPITraits<bigunsignedint<k> >;
    │ │ │ │ -
    188#endif
    │ │ │ │ -
    189 inline void assign(std::uintmax_t x);
    │ │ │ │ -
    190
    │ │ │ │ -
    191
    │ │ │ │ -
    192 } ;
    │ │ │ │ -
    │ │ │ │ -
    193
    │ │ │ │ -
    194 // Constructors
    │ │ │ │ -
    195 template<int k>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    197 {
    │ │ │ │ -
    198 assign(0u);
    │ │ │ │ -
    199 }
    │ │ │ │ -
    │ │ │ │ -
    200
    │ │ │ │ -
    201 template<int k>
    │ │ │ │ -
    202 template<typename Signed>
    │ │ │ │ -
    │ │ │ │ -
    203 bigunsignedint<k>::bigunsignedint (Signed y, typename std::enable_if<std::is_integral<Signed>::value && std::is_signed<Signed>::value>::type*)
    │ │ │ │ -
    204 {
    │ │ │ │ -
    205 if (y < 0)
    │ │ │ │ -
    206 DUNE_THROW(Dune::Exception, "Trying to construct a Dune::bigunsignedint from a negative integer: " << y);
    │ │ │ │ -
    207 assign(y);
    │ │ │ │ -
    208 }
    │ │ │ │ -
    │ │ │ │ -
    209
    │ │ │ │ -
    210 template<int k>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    212 {
    │ │ │ │ -
    213 assign(x);
    │ │ │ │ -
    214 }
    │ │ │ │ -
    │ │ │ │ -
    215 template<int k>
    │ │ │ │ -
    216 void bigunsignedint<k>::assign(std::uintmax_t x)
    │ │ │ │ -
    217 {
    │ │ │ │ -
    218 static const int no=std::min(static_cast<int>(n),
    │ │ │ │ -
    219 static_cast<int>(std::numeric_limits<std::uintmax_t>::digits/bits));
    │ │ │ │ -
    220
    │ │ │ │ -
    221 for(int i=0; i<no; ++i) {
    │ │ │ │ -
    222 digit[i] = (x&bitmask);
    │ │ │ │ -
    223 x=x>>bits;
    │ │ │ │ -
    224 }
    │ │ │ │ -
    225 for (unsigned int i=no; i<n; i++) digit[i]=0;
    │ │ │ │ -
    226 }
    │ │ │ │ -
    227
    │ │ │ │ -
    228 // export
    │ │ │ │ -
    229 template<int k>
    │ │ │ │ -
    │ │ │ │ -
    230 inline std::uint_least32_t bigunsignedint<k>::touint () const
    │ │ │ │ -
    231 {
    │ │ │ │ -
    232 return (digit[1]<<bits)+digit[0];
    │ │ │ │ -
    233 }
    │ │ │ │ -
    │ │ │ │ -
    234
    │ │ │ │ -
    235 template<int k>
    │ │ │ │ -
    │ │ │ │ -
    236 inline double bigunsignedint<k>::todouble() const
    │ │ │ │ -
    237 {
    │ │ │ │ -
    238 int firstInZeroRange=n;
    │ │ │ │ -
    239 for(int i=n-1; i>=0; --i)
    │ │ │ │ -
    240 if(digit[i]!=0)
    │ │ │ │ -
    241 break;
    │ │ │ │ -
    242 else
    │ │ │ │ -
    243 --firstInZeroRange;
    │ │ │ │ -
    244 int representableDigits=std::numeric_limits<double>::digits/bits;
    │ │ │ │ -
    245 int lastInRepresentableRange=0;
    │ │ │ │ -
    246 if(representableDigits<firstInZeroRange)
    │ │ │ │ -
    247 lastInRepresentableRange=firstInZeroRange-representableDigits;
    │ │ │ │ -
    248 double val=0;
    │ │ │ │ -
    249 for(int i=firstInZeroRange-1; i>=lastInRepresentableRange; --i)
    │ │ │ │ -
    250 val =val*(1<<bits)+digit[i];
    │ │ │ │ -
    251 return val*(1<<(bits*lastInRepresentableRange));
    │ │ │ │ -
    252 }
    │ │ │ │ -
    │ │ │ │ -
    253 // print
    │ │ │ │ -
    254 template<int k>
    │ │ │ │ -
    │ │ │ │ -
    255 inline void bigunsignedint<k>::print (std::ostream& s) const
    │ │ │ │ -
    256 {
    │ │ │ │ -
    257 bool leading=false;
    │ │ │ │ -
    258
    │ │ │ │ -
    259 // print from left to right
    │ │ │ │ -
    260 for (int i=n-1; i>=0; i--)
    │ │ │ │ -
    261 for (int d=hexdigits-1; d>=0; d--)
    │ │ │ │ -
    262 {
    │ │ │ │ -
    263 // extract one hex digit
    │ │ │ │ -
    264 int current = (digit[i]>>(d*4))&0xF;
    │ │ │ │ -
    265 if (current!=0)
    │ │ │ │ -
    266 {
    │ │ │ │ -
    267 // s.setf(std::ios::noshowbase);
    │ │ │ │ -
    268 s << std::hex << current;
    │ │ │ │ -
    269 leading = false;
    │ │ │ │ -
    270 }
    │ │ │ │ -
    271 else if (!leading) s << std::hex << current;
    │ │ │ │ -
    272 }
    │ │ │ │ -
    273 if (leading) s << "0";
    │ │ │ │ -
    274 s << std::dec;
    │ │ │ │ -
    275 }
    │ │ │ │ -
    │ │ │ │ -
    276
    │ │ │ │ -
    277 template <int k>
    │ │ │ │ -
    │ │ │ │ -
    278 inline std::ostream& operator<< (std::ostream& s, const bigunsignedint<k>& x)
    │ │ │ │ -
    279 {
    │ │ │ │ -
    280 x.print(s);
    │ │ │ │ -
    281 return s;
    │ │ │ │ -
    282 }
    │ │ │ │ -
    │ │ │ │ -
    283
    │ │ │ │ -
    │ │ │ │ -
    284 #define DUNE_BINOP(OP) \
    │ │ │ │ -
    285 template <int k> \
    │ │ │ │ -
    286 inline bigunsignedint<k> bigunsignedint<k>::operator OP (const bigunsignedint<k> &x) const \
    │ │ │ │ -
    287 { \
    │ │ │ │ -
    288 auto temp = *this; \
    │ │ │ │ -
    289 temp OP##= x; \
    │ │ │ │ -
    290 return temp; \
    │ │ │ │ -
    291 }
    │ │ │ │ -
    │ │ │ │ -
    292
    │ │ │ │ -
    293 DUNE_BINOP(+)
    │ │ │ │ -
    294 DUNE_BINOP(-)
    │ │ │ │ -
    295 DUNE_BINOP(*)
    │ │ │ │ -
    296 DUNE_BINOP(/)
    │ │ │ │ -
    297 DUNE_BINOP(%)
    │ │ │ │ -
    298 DUNE_BINOP(&)
    │ │ │ │ -
    299 DUNE_BINOP(^)
    │ │ │ │ -
    300 DUNE_BINOP(|)
    │ │ │ │ -
    301
    │ │ │ │ -
    302 #undef DUNE_BINOP
    │ │ │ │ -
    303
    │ │ │ │ -
    304 template <int k>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    306 {
    │ │ │ │ -
    307 std::uint_fast32_t overflow=0;
    │ │ │ │ -
    308
    │ │ │ │ -
    309 for (unsigned int i=0; i<n; i++)
    │ │ │ │ -
    310 {
    │ │ │ │ -
    311 std::uint_fast32_t sum = static_cast<std::uint_fast32_t>(digit[i]) + static_cast<std::uint_fast32_t>(x.digit[i]) + overflow;
    │ │ │ │ -
    312 digit[i] = sum&bitmask;
    │ │ │ │ -
    313 overflow = (sum>>bits)&overflowmask;
    │ │ │ │ -
    314 }
    │ │ │ │ -
    315 return *this;
    │ │ │ │ -
    316 }
    │ │ │ │ -
    │ │ │ │ -
    317
    │ │ │ │ -
    318 template <int k>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    320 {
    │ │ │ │ -
    321 std::int_fast32_t overflow=0;
    │ │ │ │ -
    322
    │ │ │ │ -
    323 for (unsigned int i=0; i<n; i++)
    │ │ │ │ -
    324 {
    │ │ │ │ -
    325 std::int_fast32_t diff = static_cast<std::int_fast32_t>(digit[i]) - static_cast<std::int_fast32_t>(x.digit[i]) - overflow;
    │ │ │ │ -
    326 if (diff>=0)
    │ │ │ │ -
    327 {
    │ │ │ │ -
    328 digit[i] = static_cast<std::uint16_t>(diff);
    │ │ │ │ -
    329 overflow = 0;
    │ │ │ │ -
    330 }
    │ │ │ │ -
    331 else
    │ │ │ │ -
    332 {
    │ │ │ │ -
    333 digit[i] = static_cast<std::uint16_t>(diff+bitmask+1);
    │ │ │ │ -
    334 overflow = 1;
    │ │ │ │ -
    335 }
    │ │ │ │ -
    336 }
    │ │ │ │ -
    337 return *this;
    │ │ │ │ -
    338 }
    │ │ │ │ -
    │ │ │ │ -
    339
    │ │ │ │ -
    340 template <int k>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    342 {
    │ │ │ │ -
    343 bigunsignedint<2*k> finalproduct(0);
    │ │ │ │ -
    344
    │ │ │ │ -
    345 for (unsigned int m=0; m<n; m++) // digit in right factor
    │ │ │ │ -
    346 {
    │ │ │ │ -
    347 bigunsignedint<2*k> singleproduct(0);
    │ │ │ │ -
    348 std::uint_fast32_t overflow(0);
    │ │ │ │ -
    349 for (unsigned int i=0; i<n; i++)
    │ │ │ │ -
    350 {
    │ │ │ │ -
    351 std::uint_fast32_t digitproduct = static_cast<std::uint_fast32_t>(digit[i])*static_cast<std::uint_fast32_t>(x.digit[m])+overflow;
    │ │ │ │ -
    352 singleproduct.digit[i+m] = static_cast<std::uint16_t>(digitproduct&bitmask);
    │ │ │ │ -
    353 overflow = (digitproduct>>bits)&bitmask;
    │ │ │ │ -
    354 }
    │ │ │ │ -
    355 finalproduct = finalproduct+singleproduct;
    │ │ │ │ -
    356 }
    │ │ │ │ -
    357
    │ │ │ │ -
    358 for (unsigned int i=0; i<n; i++) digit[i] = finalproduct.digit[i];
    │ │ │ │ -
    359 return *this;
    │ │ │ │ -
    360 }
    │ │ │ │ -
    │ │ │ │ -
    361
    │ │ │ │ -
    362 template <int k>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    364 {
    │ │ │ │ -
    365 std::uint_fast32_t overflow=1;
    │ │ │ │ -
    366
    │ │ │ │ -
    367 for (unsigned int i=0; i<n; i++)
    │ │ │ │ -
    368 {
    │ │ │ │ -
    369 std::uint_fast32_t sum = static_cast<std::uint_fast32_t>(digit[i]) + overflow;
    │ │ │ │ -
    370 digit[i] = sum&bitmask;
    │ │ │ │ -
    371 overflow = (sum>>bits)&overflowmask;
    │ │ │ │ -
    372 }
    │ │ │ │ -
    373 return *this;
    │ │ │ │ -
    374 }
    │ │ │ │ -
    │ │ │ │ -
    375
    │ │ │ │ -
    376 template <int k>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    378 {
    │ │ │ │ -
    379 if(x==0)
    │ │ │ │ -
    380 DUNE_THROW(Dune::MathError, "division by zero!");
    │ │ │ │ -
    381
    │ │ │ │ -
    382 // better slow than nothing
    │ │ │ │ -
    383 bigunsignedint<k> result(0);
    │ │ │ │ -
    384
    │ │ │ │ -
    385 while (*this>=x)
    │ │ │ │ -
    386 {
    │ │ │ │ -
    387 ++result;
    │ │ │ │ -
    388 *this -= x;
    │ │ │ │ -
    389 }
    │ │ │ │ -
    390
    │ │ │ │ -
    391 *this = result;
    │ │ │ │ -
    392 return *this;
    │ │ │ │ -
    393 }
    │ │ │ │ -
    │ │ │ │ -
    394
    │ │ │ │ -
    395 template <int k>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    397 {
    │ │ │ │ -
    398 // better slow than nothing
    │ │ │ │ -
    399 while (*this>=x)
    │ │ │ │ -
    400 {
    │ │ │ │ -
    401 *this -= x;
    │ │ │ │ -
    402 }
    │ │ │ │ -
    403
    │ │ │ │ -
    404 return *this;
    │ │ │ │ -
    405 }
    │ │ │ │ -
    │ │ │ │ -
    406
    │ │ │ │ -
    407 template <int k>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    409 {
    │ │ │ │ -
    410 for (unsigned int i=0; i<n; i++)
    │ │ │ │ -
    411 digit[i] = digit[i]&x.digit[i];
    │ │ │ │ -
    412 return *this;
    │ │ │ │ -
    413 }
    │ │ │ │ -
    │ │ │ │ -
    414
    │ │ │ │ -
    415 template <int k>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    417 {
    │ │ │ │ -
    418 for (unsigned int i=0; i<n; i++)
    │ │ │ │ -
    419 digit[i] = digit[i]^x.digit[i];
    │ │ │ │ -
    420 return *this;
    │ │ │ │ -
    421 }
    │ │ │ │ -
    │ │ │ │ -
    422
    │ │ │ │ -
    423 template <int k>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    425 {
    │ │ │ │ -
    426 for (unsigned int i=0; i<n; i++)
    │ │ │ │ -
    427 digit[i] = digit[i]|x.digit[i];
    │ │ │ │ -
    428 return *this;
    │ │ │ │ -
    429 }
    │ │ │ │ -
    │ │ │ │ -
    430
    │ │ │ │ -
    431 template <int k>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    433 {
    │ │ │ │ -
    434 bigunsignedint<k> result;
    │ │ │ │ -
    435 for (unsigned int i=0; i<n; i++)
    │ │ │ │ -
    436 result.digit[i] = ~digit[i];
    │ │ │ │ -
    437 return result;
    │ │ │ │ -
    438 }
    │ │ │ │ -
    439
    │ │ │ │ -
    440 template <int k>
    │ │ │ │ - │ │ │ │ -
    442 {
    │ │ │ │ -
    443 bigunsignedint<k> result(0);
    │ │ │ │ -
    444
    │ │ │ │ -
    445 // multiples of bits
    │ │ │ │ -
    446 int j=shift/bits;
    │ │ │ │ -
    447 for (int i=n-1-j; i>=0; i--)
    │ │ │ │ -
    448 result.digit[i+j] = digit[i];
    │ │ │ │ -
    449
    │ │ │ │ -
    450 // remainder
    │ │ │ │ -
    451 j=shift%bits;
    │ │ │ │ -
    452 for (int i=n-1; i>=0; i--)
    │ │ │ │ -
    453 {
    │ │ │ │ -
    454 unsigned int temp = result.digit[i];
    │ │ │ │ -
    455 temp = temp<<j;
    │ │ │ │ -
    456 result.digit[i] = static_cast<std::uint16_t>(temp&bitmask);
    │ │ │ │ -
    457 temp = temp>>bits;
    │ │ │ │ -
    458 if (i+1<(int)n)
    │ │ │ │ -
    459 result.digit[i+1] = result.digit[i+1]|temp;
    │ │ │ │ -
    460 }
    │ │ │ │ -
    461
    │ │ │ │ -
    462 return result;
    │ │ │ │ -
    463 }
    │ │ │ │ -
    │ │ │ │ -
    464
    │ │ │ │ -
    465 template <int k>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    467 {
    │ │ │ │ -
    468 bigunsignedint<k> result(0);
    │ │ │ │ -
    469
    │ │ │ │ -
    470 // multiples of bits
    │ │ │ │ -
    471 int j=shift/bits;
    │ │ │ │ -
    472 for (unsigned int i=0; i<n-j; i++)
    │ │ │ │ -
    473 result.digit[i] = digit[i+j];
    │ │ │ │ -
    474
    │ │ │ │ -
    475 // remainder
    │ │ │ │ -
    476 j=shift%bits;
    │ │ │ │ -
    477 for (unsigned int i=0; i<n; i++)
    │ │ │ │ -
    478 {
    │ │ │ │ -
    479 std::uint_fast32_t temp = result.digit[i];
    │ │ │ │ -
    480 temp = temp<<(bits-j);
    │ │ │ │ -
    481 result.digit[i] = static_cast<std::uint16_t>((temp&compbitmask)>>bits);
    │ │ │ │ -
    482 if (i>0)
    │ │ │ │ -
    483 result.digit[i-1] = result.digit[i-1] | (temp&bitmask);
    │ │ │ │ -
    484 }
    │ │ │ │ -
    485
    │ │ │ │ -
    486 return result;
    │ │ │ │ -
    487 }
    │ │ │ │ -
    │ │ │ │ -
    488
    │ │ │ │ -
    489 template <int k>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    491 {
    │ │ │ │ -
    492 for (unsigned int i=0; i<n; i++)
    │ │ │ │ -
    493 if (digit[i]!=x.digit[i]) return true;
    │ │ │ │ -
    494 return false;
    │ │ │ │ -
    495 }
    │ │ │ │ -
    │ │ │ │ -
    496
    │ │ │ │ -
    497 template <int k>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    499 {
    │ │ │ │ -
    500 return !((*this)!=x);
    │ │ │ │ -
    501 }
    │ │ │ │ -
    │ │ │ │ -
    502
    │ │ │ │ -
    503 template <int k>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    505 {
    │ │ │ │ -
    506 for (int i=n-1; i>=0; i--)
    │ │ │ │ -
    507 if (digit[i]<x.digit[i]) return true;
    │ │ │ │ -
    508 else if (digit[i]>x.digit[i]) return false;
    │ │ │ │ -
    509 return false;
    │ │ │ │ -
    510 }
    │ │ │ │ -
    │ │ │ │ -
    511
    │ │ │ │ -
    512 template <int k>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    514 {
    │ │ │ │ -
    515 for (int i=n-1; i>=0; i--)
    │ │ │ │ -
    516 if (digit[i]<x.digit[i]) return true;
    │ │ │ │ -
    517 else if (digit[i]>x.digit[i]) return false;
    │ │ │ │ -
    518 return true;
    │ │ │ │ -
    519 }
    │ │ │ │ -
    │ │ │ │ -
    520
    │ │ │ │ -
    521 template <int k>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    523 {
    │ │ │ │ -
    524 return !((*this)<=x);
    │ │ │ │ -
    525 }
    │ │ │ │ -
    │ │ │ │ -
    526
    │ │ │ │ -
    527 template <int k>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    529 {
    │ │ │ │ -
    530 return !((*this)<x);
    │ │ │ │ -
    531 }
    │ │ │ │ -
    │ │ │ │ -
    532
    │ │ │ │ -
    533
    │ │ │ │ -
    534 template <int k>
    │ │ │ │ -
    │ │ │ │ -
    535 inline bigunsignedint<k> operator+ (const bigunsignedint<k>& x, std::uintmax_t y)
    │ │ │ │ -
    536 {
    │ │ │ │ -
    537 bigunsignedint<k> temp(y);
    │ │ │ │ -
    538 return x+temp;
    │ │ │ │ -
    539 }
    │ │ │ │ -
    │ │ │ │ -
    540
    │ │ │ │ -
    541 template <int k>
    │ │ │ │ -
    │ │ │ │ -
    542 inline bigunsignedint<k> operator- (const bigunsignedint<k>& x, std::uintmax_t y)
    │ │ │ │ -
    543 {
    │ │ │ │ -
    544 bigunsignedint<k> temp(y);
    │ │ │ │ -
    545 return x-temp;
    │ │ │ │ -
    546 }
    │ │ │ │ -
    │ │ │ │ -
    547
    │ │ │ │ -
    548 template <int k>
    │ │ │ │ -
    │ │ │ │ -
    549 inline bigunsignedint<k> operator* (const bigunsignedint<k>& x, std::uintmax_t y)
    │ │ │ │ -
    550 {
    │ │ │ │ -
    551 bigunsignedint<k> temp(y);
    │ │ │ │ -
    552 return x*temp;
    │ │ │ │ -
    553 }
    │ │ │ │ -
    │ │ │ │ -
    554
    │ │ │ │ -
    555 template <int k>
    │ │ │ │ -
    │ │ │ │ -
    556 inline bigunsignedint<k> operator/ (const bigunsignedint<k>& x, std::uintmax_t y)
    │ │ │ │ -
    557 {
    │ │ │ │ -
    558 bigunsignedint<k> temp(y);
    │ │ │ │ -
    559 return x/temp;
    │ │ │ │ -
    560 }
    │ │ │ │ -
    │ │ │ │ -
    561
    │ │ │ │ -
    562 template <int k>
    │ │ │ │ -
    │ │ │ │ -
    563 inline bigunsignedint<k> operator% (const bigunsignedint<k>& x, std::uintmax_t y)
    │ │ │ │ -
    564 {
    │ │ │ │ -
    565 bigunsignedint<k> temp(y);
    │ │ │ │ -
    566 return x%temp;
    │ │ │ │ -
    567 }
    │ │ │ │ -
    │ │ │ │ -
    568
    │ │ │ │ -
    569 template <int k>
    │ │ │ │ -
    │ │ │ │ -
    570 inline bigunsignedint<k> operator+ (std::uintmax_t x, const bigunsignedint<k>& y)
    │ │ │ │ -
    571 {
    │ │ │ │ -
    572 bigunsignedint<k> temp(x);
    │ │ │ │ -
    573 return temp+y;
    │ │ │ │ -
    574 }
    │ │ │ │ -
    │ │ │ │ -
    575
    │ │ │ │ -
    576 template <int k>
    │ │ │ │ -
    │ │ │ │ -
    577 inline bigunsignedint<k> operator- (std::uintmax_t x, const bigunsignedint<k>& y)
    │ │ │ │ -
    578 {
    │ │ │ │ -
    579 bigunsignedint<k> temp(x);
    │ │ │ │ -
    580 return temp-y;
    │ │ │ │ -
    581 }
    │ │ │ │ -
    │ │ │ │ -
    582
    │ │ │ │ -
    583 template <int k>
    │ │ │ │ -
    │ │ │ │ -
    584 inline bigunsignedint<k> operator* (std::uintmax_t x, const bigunsignedint<k>& y)
    │ │ │ │ -
    585 {
    │ │ │ │ -
    586 bigunsignedint<k> temp(x);
    │ │ │ │ -
    587 return temp*y;
    │ │ │ │ -
    588 }
    │ │ │ │ -
    │ │ │ │ -
    589
    │ │ │ │ -
    590 template <int k>
    │ │ │ │ -
    │ │ │ │ -
    591 inline bigunsignedint<k> operator/ (std::uintmax_t x, const bigunsignedint<k>& y)
    │ │ │ │ -
    592 {
    │ │ │ │ -
    593 bigunsignedint<k> temp(x);
    │ │ │ │ -
    594 return temp/y;
    │ │ │ │ -
    595 }
    │ │ │ │ -
    │ │ │ │ -
    596
    │ │ │ │ -
    597 template <int k>
    │ │ │ │ -
    │ │ │ │ -
    598 inline bigunsignedint<k> operator% (std::uintmax_t x, const bigunsignedint<k>& y)
    │ │ │ │ -
    599 {
    │ │ │ │ -
    600 bigunsignedint<k> temp(x);
    │ │ │ │ -
    601 return temp%y;
    │ │ │ │ -
    602 }
    │ │ │ │ -
    │ │ │ │ -
    603
    │ │ │ │ -
    604 // Forward declare type-trait for numbers
    │ │ │ │ -
    605 template<class T> struct IsNumber;
    │ │ │ │ -
    606
    │ │ │ │ -
    608 template <int k>
    │ │ │ │ -
    609 struct IsNumber<bigunsignedint<k>> : public std::true_type {};
    │ │ │ │ -
    610
    │ │ │ │ -
    612}
    │ │ │ │ -
    613
    │ │ │ │ -
    614namespace std
    │ │ │ │ -
    615{
    │ │ │ │ -
    616 template<int k>
    │ │ │ │ -
    617 struct numeric_limits<Dune::bigunsignedint<k> >
    │ │ │ │ -
    618 : private Dune::Impl::numeric_limits_helper<Dune::bigunsignedint<k> > // for access to internal state of bigunsignedint
    │ │ │ │ -
    619 {
    │ │ │ │ -
    620 public:
    │ │ │ │ -
    621 static const bool is_specialized = true;
    │ │ │ │ -
    622
    │ │ │ │ -
    623 static Dune::bigunsignedint<k> min()
    │ │ │ │ -
    624 {
    │ │ │ │ -
    625 return static_cast<Dune::bigunsignedint<k> >(0);
    │ │ │ │ -
    626 }
    │ │ │ │ -
    627
    │ │ │ │ - │ │ │ │ -
    629 {
    │ │ │ │ - │ │ │ │ -
    631 for(std::size_t i=0; i < Dune::bigunsignedint<k>::n; ++i)
    │ │ │ │ -
    632 // access internal state via the helper base class
    │ │ │ │ -
    633 Dune::Impl::numeric_limits_helper<Dune::bigunsignedint<k> >::
    │ │ │ │ -
    634 digit(max_,i)=std::numeric_limits<std::uint16_t>::max();
    │ │ │ │ -
    635 return max_;
    │ │ │ │ -
    636 }
    │ │ │ │ -
    637
    │ │ │ │ -
    638
    │ │ │ │ -
    639 static const int digits = Dune::bigunsignedint<k>::bits *
    │ │ │ │ - │ │ │ │ -
    641 static const bool is_signed = false;
    │ │ │ │ -
    642 static const bool is_integer = true;
    │ │ │ │ -
    643 static const bool is_exact = true;
    │ │ │ │ -
    644 static const int radix = 2;
    │ │ │ │ -
    645
    │ │ │ │ -
    646 static Dune::bigunsignedint<k> epsilon()
    │ │ │ │ -
    647 {
    │ │ │ │ -
    648 return static_cast<Dune::bigunsignedint<k> >(0);
    │ │ │ │ -
    649 }
    │ │ │ │ -
    650
    │ │ │ │ -
    651 static Dune::bigunsignedint<k> round_error()
    │ │ │ │ -
    652 {
    │ │ │ │ -
    653 return static_cast<Dune::bigunsignedint<k> >(0);
    │ │ │ │ -
    654 }
    │ │ │ │ -
    655
    │ │ │ │ -
    656 static const int min_exponent = 0;
    │ │ │ │ -
    657 static const int min_exponent10 = 0;
    │ │ │ │ -
    658 static const int max_exponent = 0;
    │ │ │ │ -
    659 static const int max_exponent10 = 0;
    │ │ │ │ -
    660
    │ │ │ │ -
    661 static const bool has_infinity = false;
    │ │ │ │ -
    662 static const bool has_quiet_NaN = false;
    │ │ │ │ -
    663 static const bool has_signaling_NaN = false;
    │ │ │ │ -
    664
    │ │ │ │ -
    665 static const float_denorm_style has_denorm = denorm_absent;
    │ │ │ │ -
    666 static const bool has_denorm_loss = false;
    │ │ │ │ -
    667
    │ │ │ │ -
    668 static Dune::bigunsignedint<k> infinity() noexcept
    │ │ │ │ -
    669 {
    │ │ │ │ -
    670 return static_cast<Dune::bigunsignedint<k> >(0);
    │ │ │ │ -
    671 }
    │ │ │ │ -
    672
    │ │ │ │ -
    673 static Dune::bigunsignedint<k> quiet_NaN() noexcept
    │ │ │ │ -
    674 {
    │ │ │ │ -
    675 return static_cast<Dune::bigunsignedint<k> >(0);
    │ │ │ │ -
    676 }
    │ │ │ │ -
    677
    │ │ │ │ -
    678 static Dune::bigunsignedint<k> signaling_NaN() noexcept
    │ │ │ │ -
    679 {
    │ │ │ │ -
    680 return static_cast<Dune::bigunsignedint<k> >(0);
    │ │ │ │ -
    681 }
    │ │ │ │ -
    682
    │ │ │ │ -
    683 static Dune::bigunsignedint<k> denorm_min() noexcept
    │ │ │ │ -
    684 {
    │ │ │ │ -
    685 return static_cast<Dune::bigunsignedint<k> >(0);
    │ │ │ │ -
    686 }
    │ │ │ │ -
    687
    │ │ │ │ -
    688 static const bool is_iec559 = false;
    │ │ │ │ -
    689 static const bool is_bounded = true;
    │ │ │ │ -
    690 static const bool is_modulo = true;
    │ │ │ │ -
    691
    │ │ │ │ -
    692 static const bool traps = false;
    │ │ │ │ -
    693 static const bool tinyness_before = false;
    │ │ │ │ -
    694 static const float_round_style round_style = round_toward_zero;
    │ │ │ │ -
    695
    │ │ │ │ -
    696 };
    │ │ │ │ -
    697
    │ │ │ │ -
    698}
    │ │ │ │ -
    699
    │ │ │ │ - │ │ │ │ -
    701
    │ │ │ │ -
    702#endif
    │ │ │ │ -
    Support for calculating hash values of objects.
    │ │ │ │ -
    #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
    │ │ │ │ -
    A few common exception classes.
    │ │ │ │ -
    bigunsignedint< k > & operator/=(const bigunsignedint< k > &x)
    Definition bigunsignedint.hh:377
    │ │ │ │ -
    bigunsignedint< k > operator*(const bigunsignedint< k > &x, std::uintmax_t y)
    Definition bigunsignedint.hh:549
    │ │ │ │ -
    bigunsignedint< k > operator<<(int i) const
    left shift
    Definition bigunsignedint.hh:441
    │ │ │ │ -
    bigunsignedint< k > & operator+=(const bigunsignedint< k > &x)
    Definition bigunsignedint.hh:305
    │ │ │ │ -
    bigunsignedint< k > & operator^=(const bigunsignedint< k > &x)
    Definition bigunsignedint.hh:416
    │ │ │ │ -
    std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x)
    Definition bigunsignedint.hh:278
    │ │ │ │ -
    bool operator<=(const bigunsignedint< k > &x) const
    less than or equal
    Definition bigunsignedint.hh:513
    │ │ │ │ -
    void print(std::ostream &s) const
    Print number in hex notation.
    Definition bigunsignedint.hh:255
    │ │ │ │ -
    bool operator<(const bigunsignedint< k > &x) const
    less than
    Definition bigunsignedint.hh:504
    │ │ │ │ -
    bigunsignedint< k > operator/(const bigunsignedint< k > &x, std::uintmax_t y)
    Definition bigunsignedint.hh:556
    │ │ │ │ -
    bool operator==(const bigunsignedint< k > &x) const
    equal
    Definition bigunsignedint.hh:498
    │ │ │ │ -
    bool operator!=(const bigunsignedint< k > &x) const
    not equal
    Definition bigunsignedint.hh:490
    │ │ │ │ -
    bigunsignedint()
    Construct uninitialized.
    Definition bigunsignedint.hh:196
    │ │ │ │ -
    bigunsignedint< k > & operator&=(const bigunsignedint< k > &x)
    Definition bigunsignedint.hh:408
    │ │ │ │ -
    bigunsignedint< k > operator-(const bigunsignedint< k > &x, std::uintmax_t y)
    Definition bigunsignedint.hh:542
    │ │ │ │ -
    bool operator>=(const bigunsignedint< k > &x) const
    greater or equal
    Definition bigunsignedint.hh:528
    │ │ │ │ -
    bigunsignedint< k > operator>>(int i) const
    right shift
    Definition bigunsignedint.hh:466
    │ │ │ │ -
    bigunsignedint< k > operator+(const bigunsignedint< k > &x, std::uintmax_t y)
    Definition bigunsignedint.hh:535
    │ │ │ │ -
    bigunsignedint< k > operator~() const
    bitwise complement
    Definition bigunsignedint.hh:432
    │ │ │ │ -
    bigunsignedint< k > & operator++()
    prefix increment
    Definition bigunsignedint.hh:363
    │ │ │ │ -
    bigunsignedint< k > & operator|=(const bigunsignedint< k > &x)
    Definition bigunsignedint.hh:424
    │ │ │ │ -
    bigunsignedint< k > operator%(const bigunsignedint< k > &x, std::uintmax_t y)
    Definition bigunsignedint.hh:563
    │ │ │ │ -
    bigunsignedint< k > & operator%=(const bigunsignedint< k > &x)
    Definition bigunsignedint.hh:396
    │ │ │ │ -
    double todouble() const
    Convert to a double.
    Definition bigunsignedint.hh:236
    │ │ │ │ -
    bigunsignedint< k > & operator-=(const bigunsignedint< k > &x)
    Definition bigunsignedint.hh:319
    │ │ │ │ -
    bool operator>(const bigunsignedint< k > &x) const
    greater than
    Definition bigunsignedint.hh:522
    │ │ │ │ -
    bigunsignedint< k > & operator*=(const bigunsignedint< k > &x)
    Definition bigunsignedint.hh:341
    │ │ │ │ -
    std::uint_least32_t touint() const
    export to other types
    Definition bigunsignedint.hh:230
    │ │ │ │ -
    #define DUNE_BINOP(OP)
    Definition bigunsignedint.hh:284
    │ │ │ │ -
    #define DUNE_THROW(E, m)
    Definition exceptions.hh:218
    │ │ │ │ -
    STL namespace.
    │ │ │ │ +
    184#endif // DUNE_COMMON_PATH_HH
    │ │ │ │ +
    std::string processPath(const std::string &p)
    sanitize a path for further processing
    Definition path.cc:41
    │ │ │ │ +
    bool pathIndicatesDirectory(const std::string &p)
    check whether the given path indicates that it is a directory
    Definition path.cc:115
    │ │ │ │ +
    std::string prettyPath(const std::string &p, bool isDirectory)
    pretty print path
    Definition path.cc:126
    │ │ │ │ +
    std::string relativePath(const std::string &newbase, const std::string &p)
    compute a relative path between two paths
    Definition path.cc:153
    │ │ │ │ +
    std::string concatPaths(const std::string &base, const std::string &p)
    concatenate two paths
    Definition path.cc:32
    │ │ │ │
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ -
    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 assign(T &dst, const T &src, bool mask)
    masked Simd assignment (scalar version)
    Definition simd.hh:447
    │ │ │ │ -
    auto max(const AlignedNumber< T, align > &a, const AlignedNumber< T, align > &b)
    Definition debugalign.hh:425
    │ │ │ │ -
    A traits class describing the mapping of types onto MPI_Datatypes.
    Definition mpitraits.hh:41
    │ │ │ │ -
    Portable very large unsigned integers.
    Definition bigunsignedint.hh:73
    │ │ │ │ -
    static constexpr int overflowmask
    Definition bigunsignedint.hh:82
    │ │ │ │ -
    bigunsignedint< k > operator|(const bigunsignedint< k > &x) const
    bitwise or
    │ │ │ │ -
    static constexpr int hexdigits
    Definition bigunsignedint.hh:79
    │ │ │ │ -
    bigunsignedint< k > operator^(const bigunsignedint< k > &x) const
    bitwise exor
    │ │ │ │ -
    bigunsignedint< k > operator*(const bigunsignedint< k > &x) const
    multiply
    │ │ │ │ -
    bigunsignedint< k > operator%(const bigunsignedint< k > &x) const
    │ │ │ │ -
    static constexpr int n
    Definition bigunsignedint.hh:78
    │ │ │ │ -
    bigunsignedint< k > operator-(const bigunsignedint< k > &x) const
    subtract
    │ │ │ │ -
    static constexpr int compbitmask
    Definition bigunsignedint.hh:81
    │ │ │ │ -
    bigunsignedint< k > operator&(const bigunsignedint< k > &x) const
    bitwise and
    │ │ │ │ -
    static constexpr int bits
    Definition bigunsignedint.hh:77
    │ │ │ │ -
    bigunsignedint< k > operator/(const bigunsignedint< k > &x) const
    │ │ │ │ -
    bigunsignedint< k > operator+(const bigunsignedint< k > &x) const
    add
    │ │ │ │ -
    friend std::size_t hash_value(const bigunsignedint &arg)
    Definition bigunsignedint.hh:179
    │ │ │ │ -
    static constexpr int bitmask
    Definition bigunsignedint.hh:80
    │ │ │ │ -
    Whether this type acts as a scalar in the context of (hierarchically blocked) containers.
    Definition typetraits.hh:194
    │ │ │ │ -
    Base class for Dune-Exceptions.
    Definition exceptions.hh:96
    │ │ │ │ -
    Default exception class for mathematical errors.
    Definition exceptions.hh:241
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,895 +7,68 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -bigunsignedint.hh │ │ │ │ │ +path.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 (C) 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_BIGUNSIGNEDINT_HH │ │ │ │ │ - 7#define DUNE_BIGUNSIGNEDINT_HH │ │ │ │ │ - 8 │ │ │ │ │ - 9#include │ │ │ │ │ - 10#include │ │ │ │ │ - 11#include │ │ │ │ │ - 12#include │ │ │ │ │ - 13#include │ │ │ │ │ - 14#include │ │ │ │ │ - 15#include │ │ │ │ │ - 16#include │ │ │ │ │ - 17 │ │ │ │ │ - 24namespace Dune │ │ │ │ │ - 25{ │ │ │ │ │ - 26#if HAVE_MPI │ │ │ │ │ - 27 template │ │ │ │ │ - 28 struct MPITraits; │ │ │ │ │ - 29#endif │ │ │ │ │ - 30 │ │ │ │ │ - 36 namespace Impl { │ │ │ │ │ - 37 │ │ │ │ │ - 38 // numeric_limits_helper provides std::numeric_limits access to the │ │ │ │ │ -internals │ │ │ │ │ - 39 // of bigunsignedint. Previously, the correct specialization of std:: │ │ │ │ │ -numeric_limits │ │ │ │ │ - 40 // was a friend of bigunsignedint, but that creates problems on recent │ │ │ │ │ -versions │ │ │ │ │ - 41 // of clang with the alternative libc++ library, because that library │ │ │ │ │ -declares the │ │ │ │ │ - 42 // base template of std::numeric_limits as a class and clang subsequently │ │ │ │ │ -complains │ │ │ │ │ - 43 // if the friend declaration uses 'struct'. Unfortunately, libstdc++ uses a │ │ │ │ │ -struct, │ │ │ │ │ - 44 // making it impossible to keep clang happy for both standard libraries. │ │ │ │ │ - 45 // So we move the access helper functionality into a custom struct and │ │ │ │ │ -simply let │ │ │ │ │ - 46 // the numeric_limits specialization inherit from the helper. │ │ │ │ │ - 47 │ │ │ │ │ - 48 template │ │ │ │ │ - 49 struct numeric_limits_helper │ │ │ │ │ - 50 { │ │ │ │ │ - 51 │ │ │ │ │ - 52 protected: │ │ │ │ │ - 53 │ │ │ │ │ - 54 static std::uint16_t& digit(T& big_unsigned_int, std::size_t i) │ │ │ │ │ - 55 { │ │ │ │ │ - 56 return big_unsigned_int.digit[i]; │ │ │ │ │ - 57 } │ │ │ │ │ - 58 │ │ │ │ │ - 59 }; │ │ │ │ │ - 60 │ │ │ │ │ - 61 } │ │ │ │ │ - 62 │ │ │ │ │ - 72 template │ │ │ │ │ -73 class bigunsignedint { │ │ │ │ │ - 74 public: │ │ │ │ │ - 75 │ │ │ │ │ - 76 // unsigned short is 16 bits wide, n is the number of digits needed │ │ │ │ │ -77 constexpr static int bits = std::numeric_limits::digits; │ │ │ │ │ -78 constexpr static int n = k/bits+(k%bits!=0); │ │ │ │ │ -79 constexpr static int hexdigits = 4; │ │ │ │ │ -80 constexpr static int bitmask = 0xFFFF; │ │ │ │ │ -81 constexpr static int compbitmask = 0xFFFF0000; │ │ │ │ │ -82 constexpr static int overflowmask = 0x1; │ │ │ │ │ - 83 │ │ │ │ │ - 85 bigunsignedint (); │ │ │ │ │ - 86 │ │ │ │ │ - 88 template │ │ │ │ │ - 89 bigunsignedint (Signed x, typename std::enable_if::value && std::is_signed::value>::type* = 0); │ │ │ │ │ - 90 │ │ │ │ │ - 92 bigunsignedint (std::uintmax_t x); │ │ │ │ │ - 93 │ │ │ │ │ - 95 void print (std::ostream& s) const ; │ │ │ │ │ - 96 │ │ │ │ │ -98 bigunsignedint operator+(const bigunsignedint& x) const; │ │ │ │ │ - 99 bigunsignedint& operator+=(const bigunsignedint& x); │ │ │ │ │ - 100 │ │ │ │ │ -102 bigunsignedint operator-(const bigunsignedint& x) const; │ │ │ │ │ - 103 bigunsignedint& operator-=(const bigunsignedint& x); │ │ │ │ │ - 104 │ │ │ │ │ -106 bigunsignedint operator*(const bigunsignedint& x) const; │ │ │ │ │ - 107 bigunsignedint& operator*=(const bigunsignedint& x); │ │ │ │ │ - 108 │ │ │ │ │ - 110 bigunsignedint& operator++(); │ │ │ │ │ - 111 │ │ │ │ │ -115 bigunsignedint operator/(const bigunsignedint& x) const; │ │ │ │ │ - 116 bigunsignedint& operator/=(const bigunsignedint& x); │ │ │ │ │ - 117 │ │ │ │ │ -121 bigunsignedint operator%(const bigunsignedint& x) const; │ │ │ │ │ - 122 bigunsignedint& operator%=(const bigunsignedint& x); │ │ │ │ │ - 123 │ │ │ │ │ -125 bigunsignedint operator&(const bigunsignedint& x) const; │ │ │ │ │ - 126 bigunsignedint& operator&=(const bigunsignedint& x); │ │ │ │ │ - 127 │ │ │ │ │ -129 bigunsignedint operator^(const bigunsignedint& x) const; │ │ │ │ │ - 130 bigunsignedint& operator^=(const bigunsignedint& x); │ │ │ │ │ - 131 │ │ │ │ │ -133 bigunsignedint operator|(const bigunsignedint& x) const; │ │ │ │ │ - 134 bigunsignedint& operator|=(const bigunsignedint& x); │ │ │ │ │ - 135 │ │ │ │ │ - 137 bigunsignedint operator~() const; │ │ │ │ │ - 138 │ │ │ │ │ - 139 │ │ │ │ │ - 141 bigunsignedint operator<<(int i) const; │ │ │ │ │ - 142 │ │ │ │ │ - 144 bigunsignedint operator>>(int i) const; │ │ │ │ │ - 145 │ │ │ │ │ - 146 │ │ │ │ │ - 148 bool operator<(const bigunsignedint& x) const; │ │ │ │ │ - 149 │ │ │ │ │ - 151 bool operator<=(const bigunsignedint& x) const; │ │ │ │ │ + 5#ifndef DUNE_COMMON_PATH_HH │ │ │ │ │ + 6#define DUNE_COMMON_PATH_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 bool operator>(const bigunsignedint& x) const; │ │ │ │ │ - 155 │ │ │ │ │ - 157 bool operator>=(const bigunsignedint& x) const; │ │ │ │ │ - 158 │ │ │ │ │ - 160 bool operator==(const bigunsignedint& x) const; │ │ │ │ │ + 154 │ │ │ │ │ + 160 std::string prettyPath(const std::string& p); │ │ │ │ │ 161 │ │ │ │ │ - 163 bool operator!=(const bigunsignedint& x) const; │ │ │ │ │ - 164 │ │ │ │ │ - 165 │ │ │ │ │ - 167 // operator unsigned int () const; │ │ │ │ │ - 168 std::uint_least32_t touint() const; │ │ │ │ │ -174 double todouble() const; │ │ │ │ │ - 175 │ │ │ │ │ - 176 friend class bigunsignedint; │ │ │ │ │ - 177 friend struct Impl::numeric_limits_helper< bigunsignedint >; │ │ │ │ │ - 178 │ │ │ │ │ -179 inline friend std::size_t hash_value(const bigunsignedint& arg) │ │ │ │ │ - 180 { │ │ │ │ │ - 181 return hash_range(arg.digit,arg.digit + arg.n); │ │ │ │ │ - 182 } │ │ │ │ │ + 163 │ │ │ │ │ + 179 std::string relativePath(const std::string& newbase, const std::string& │ │ │ │ │ +p); │ │ │ │ │ + 180 │ │ │ │ │ + 182} │ │ │ │ │ 183 │ │ │ │ │ - 184 private: │ │ │ │ │ -185 std::uint16_t digit[n]; │ │ │ │ │ - 186#if HAVE_MPI │ │ │ │ │ - 187 friend struct MPITraits >; │ │ │ │ │ - 188#endif │ │ │ │ │ - 189 inline void assign(std::uintmax_t x); │ │ │ │ │ - 190 │ │ │ │ │ - 191 │ │ │ │ │ - 192 } ; │ │ │ │ │ - 193 │ │ │ │ │ - 194 // Constructors │ │ │ │ │ - 195 template │ │ │ │ │ -196 bigunsignedint::bigunsignedint () │ │ │ │ │ - 197 { │ │ │ │ │ - 198 assign(0u); │ │ │ │ │ - 199 } │ │ │ │ │ - 200 │ │ │ │ │ - 201 template │ │ │ │ │ - 202 template │ │ │ │ │ -203 bigunsignedint::bigunsignedint (Signed y, typename std::enable_if::value && std::is_signed::value>::type*) │ │ │ │ │ - 204 { │ │ │ │ │ - 205 if (y < 0) │ │ │ │ │ - 206 DUNE_THROW(Dune::Exception, "Trying to construct a Dune::bigunsignedint │ │ │ │ │ -from a negative integer: " << y); │ │ │ │ │ - 207 assign(y); │ │ │ │ │ - 208 } │ │ │ │ │ - 209 │ │ │ │ │ - 210 template │ │ │ │ │ -211 bigunsignedint::bigunsignedint (std::uintmax_t x) │ │ │ │ │ - 212 { │ │ │ │ │ - 213 assign(x); │ │ │ │ │ - 214 } │ │ │ │ │ - 215 template │ │ │ │ │ - 216 void bigunsignedint::assign(std::uintmax_t x) │ │ │ │ │ - 217 { │ │ │ │ │ - 218 static const int no=std::min(static_cast(n), │ │ │ │ │ - 219 static_cast(std::numeric_limits::digits/bits)); │ │ │ │ │ - 220 │ │ │ │ │ - 221 for(int i=0; i>bits; │ │ │ │ │ - 224 } │ │ │ │ │ - 225 for (unsigned int i=no; i │ │ │ │ │ -230 inline std::uint_least32_t bigunsignedint::touint () const │ │ │ │ │ - 231 { │ │ │ │ │ - 232 return (digit[1]< │ │ │ │ │ -236 inline double bigunsignedint::todouble() const │ │ │ │ │ - 237 { │ │ │ │ │ - 238 int firstInZeroRange=n; │ │ │ │ │ - 239 for(int i=n-1; i>=0; --i) │ │ │ │ │ - 240 if(digit[i]!=0) │ │ │ │ │ - 241 break; │ │ │ │ │ - 242 else │ │ │ │ │ - 243 --firstInZeroRange; │ │ │ │ │ - 244 int representableDigits=std::numeric_limits::digits/bits; │ │ │ │ │ - 245 int lastInRepresentableRange=0; │ │ │ │ │ - 246 if(representableDigits=lastInRepresentableRange; --i) │ │ │ │ │ - 250 val =val*(1< │ │ │ │ │ -255 inline void bigunsignedint::print (std::ostream& s) const │ │ │ │ │ - 256 { │ │ │ │ │ - 257 bool leading=false; │ │ │ │ │ - 258 │ │ │ │ │ - 259 // print from left to right │ │ │ │ │ - 260 for (int i=n-1; i>=0; i--) │ │ │ │ │ - 261 for (int d=hexdigits-1; d>=0; d--) │ │ │ │ │ - 262 { │ │ │ │ │ - 263 // extract one hex digit │ │ │ │ │ - 264 int current = (digit[i]>>(d*4))&0xF; │ │ │ │ │ - 265 if (current!=0) │ │ │ │ │ - 266 { │ │ │ │ │ - 267 // s.setf(std::ios::noshowbase); │ │ │ │ │ - 268 s << std::hex << current; │ │ │ │ │ - 269 leading = false; │ │ │ │ │ - 270 } │ │ │ │ │ - 271 else if (!leading) s << std::hex << current; │ │ │ │ │ - 272 } │ │ │ │ │ - 273 if (leading) s << "0"; │ │ │ │ │ - 274 s << std::dec; │ │ │ │ │ - 275 } │ │ │ │ │ - 276 │ │ │ │ │ - 277 template │ │ │ │ │ -278 inline std::ostream& operator<<(std::ostream& s, const bigunsignedint& │ │ │ │ │ -x) │ │ │ │ │ - 279 { │ │ │ │ │ - 280 x.print(s); │ │ │ │ │ - 281 return s; │ │ │ │ │ - 282 } │ │ │ │ │ - 283 │ │ │ │ │ -284 #define DUNE_BINOP(OP) \ │ │ │ │ │ - 285 template \ │ │ │ │ │ - 286 inline bigunsignedint bigunsignedint::operator OP (const │ │ │ │ │ -bigunsignedint &x) const \ │ │ │ │ │ - 287 { \ │ │ │ │ │ - 288 auto temp = *this; \ │ │ │ │ │ - 289 temp OP##= x; \ │ │ │ │ │ - 290 return temp; \ │ │ │ │ │ - 291 } │ │ │ │ │ - 292 │ │ │ │ │ - 293 DUNE_BINOP(+) │ │ │ │ │ - 294 DUNE_BINOP(-) │ │ │ │ │ - 295 DUNE_BINOP(*) │ │ │ │ │ - 296 DUNE_BINOP(/) │ │ │ │ │ - 297 DUNE_BINOP(%) │ │ │ │ │ - 298 DUNE_BINOP(&) │ │ │ │ │ - 299 DUNE_BINOP(^) │ │ │ │ │ - 300 DUNE_BINOP(|) │ │ │ │ │ - 301 │ │ │ │ │ - 302 #undef DUNE_BINOP │ │ │ │ │ - 303 │ │ │ │ │ - 304 template │ │ │ │ │ -305 inline bigunsignedint& bigunsignedint::operator+=(const │ │ │ │ │ -bigunsignedint& x) │ │ │ │ │ - 306 { │ │ │ │ │ - 307 std::uint_fast32_t overflow=0; │ │ │ │ │ - 308 │ │ │ │ │ - 309 for (unsigned int i=0; i(digit[i]) + │ │ │ │ │ -static_cast(x.digit[i]) + overflow; │ │ │ │ │ - 312 digit[i] = sum&bitmask; │ │ │ │ │ - 313 overflow = (sum>>bits)&overflowmask; │ │ │ │ │ - 314 } │ │ │ │ │ - 315 return *this; │ │ │ │ │ - 316 } │ │ │ │ │ - 317 │ │ │ │ │ - 318 template │ │ │ │ │ -319 inline bigunsignedint& bigunsignedint::operator-=(const │ │ │ │ │ -bigunsignedint& x) │ │ │ │ │ - 320 { │ │ │ │ │ - 321 std::int_fast32_t overflow=0; │ │ │ │ │ - 322 │ │ │ │ │ - 323 for (unsigned int i=0; i(digit[i]) - │ │ │ │ │ -static_cast(x.digit[i]) - overflow; │ │ │ │ │ - 326 if (diff>=0) │ │ │ │ │ - 327 { │ │ │ │ │ - 328 digit[i] = static_cast(diff); │ │ │ │ │ - 329 overflow = 0; │ │ │ │ │ - 330 } │ │ │ │ │ - 331 else │ │ │ │ │ - 332 { │ │ │ │ │ - 333 digit[i] = static_cast(diff+bitmask+1); │ │ │ │ │ - 334 overflow = 1; │ │ │ │ │ - 335 } │ │ │ │ │ - 336 } │ │ │ │ │ - 337 return *this; │ │ │ │ │ - 338 } │ │ │ │ │ - 339 │ │ │ │ │ - 340 template │ │ │ │ │ -341 inline bigunsignedint& bigunsignedint::operator*=(const │ │ │ │ │ -bigunsignedint& x) │ │ │ │ │ - 342 { │ │ │ │ │ - 343 bigunsignedint<2*k> finalproduct(0); │ │ │ │ │ - 344 │ │ │ │ │ - 345 for (unsigned int m=0; m singleproduct(0); │ │ │ │ │ - 348 std::uint_fast32_t overflow(0); │ │ │ │ │ - 349 for (unsigned int i=0; i(digit │ │ │ │ │ -[i])*static_cast(x.digit[m])+overflow; │ │ │ │ │ - 352 singleproduct.digit[i+m] = static_cast │ │ │ │ │ -(digitproduct&bitmask); │ │ │ │ │ - 353 overflow = (digitproduct>>bits)&bitmask; │ │ │ │ │ - 354 } │ │ │ │ │ - 355 finalproduct = finalproduct+singleproduct; │ │ │ │ │ - 356 } │ │ │ │ │ - 357 │ │ │ │ │ - 358 for (unsigned int i=0; i │ │ │ │ │ -363 inline bigunsignedint& bigunsignedint::operator++() │ │ │ │ │ - 364 { │ │ │ │ │ - 365 std::uint_fast32_t overflow=1; │ │ │ │ │ - 366 │ │ │ │ │ - 367 for (unsigned int i=0; i(digit[i]) + │ │ │ │ │ -overflow; │ │ │ │ │ - 370 digit[i] = sum&bitmask; │ │ │ │ │ - 371 overflow = (sum>>bits)&overflowmask; │ │ │ │ │ - 372 } │ │ │ │ │ - 373 return *this; │ │ │ │ │ - 374 } │ │ │ │ │ - 375 │ │ │ │ │ - 376 template │ │ │ │ │ -377 inline bigunsignedint& bigunsignedint::operator/=(const │ │ │ │ │ -bigunsignedint& x) │ │ │ │ │ - 378 { │ │ │ │ │ - 379 if(x==0) │ │ │ │ │ - 380 DUNE_THROW(Dune::MathError, "division by zero!"); │ │ │ │ │ - 381 │ │ │ │ │ - 382 // better slow than nothing │ │ │ │ │ - 383 bigunsignedint result(0); │ │ │ │ │ - 384 │ │ │ │ │ - 385 while (*this>=x) │ │ │ │ │ - 386 { │ │ │ │ │ - 387 ++result; │ │ │ │ │ - 388 *this -= x; │ │ │ │ │ - 389 } │ │ │ │ │ - 390 │ │ │ │ │ - 391 *this = result; │ │ │ │ │ - 392 return *this; │ │ │ │ │ - 393 } │ │ │ │ │ - 394 │ │ │ │ │ - 395 template │ │ │ │ │ -396 inline bigunsignedint& bigunsignedint::operator%=(const │ │ │ │ │ -bigunsignedint& x) │ │ │ │ │ - 397 { │ │ │ │ │ - 398 // better slow than nothing │ │ │ │ │ - 399 while (*this>=x) │ │ │ │ │ - 400 { │ │ │ │ │ - 401 *this -= x; │ │ │ │ │ - 402 } │ │ │ │ │ - 403 │ │ │ │ │ - 404 return *this; │ │ │ │ │ - 405 } │ │ │ │ │ - 406 │ │ │ │ │ - 407 template │ │ │ │ │ -408 inline bigunsignedint& bigunsignedint::operator&=(const │ │ │ │ │ -bigunsignedint& x) │ │ │ │ │ - 409 { │ │ │ │ │ - 410 for (unsigned int i=0; i │ │ │ │ │ -416 inline bigunsignedint& bigunsignedint::operator^=(const │ │ │ │ │ -bigunsignedint& x) │ │ │ │ │ - 417 { │ │ │ │ │ - 418 for (unsigned int i=0; i │ │ │ │ │ -424 inline bigunsignedint& bigunsignedint::operator|=(const │ │ │ │ │ -bigunsignedint& x) │ │ │ │ │ - 425 { │ │ │ │ │ - 426 for (unsigned int i=0; i │ │ │ │ │ -432 inline bigunsignedint bigunsignedint::operator~() const │ │ │ │ │ - 433 { │ │ │ │ │ - 434 bigunsignedint result; │ │ │ │ │ - 435 for (unsigned int i=0; i │ │ │ │ │ - 441 inline bigunsignedint bigunsignedint::operator<<(int shift) const │ │ │ │ │ - 442 { │ │ │ │ │ - 443 bigunsignedint result(0); │ │ │ │ │ - 444 │ │ │ │ │ - 445 // multiples of bits │ │ │ │ │ - 446 int j=shift/bits; │ │ │ │ │ - 447 for (int i=n-1-j; i>=0; i--) │ │ │ │ │ - 448 result.digit[i+j] = digit[i]; │ │ │ │ │ - 449 │ │ │ │ │ - 450 // remainder │ │ │ │ │ - 451 j=shift%bits; │ │ │ │ │ - 452 for (int i=n-1; i>=0; i--) │ │ │ │ │ - 453 { │ │ │ │ │ - 454 unsigned int temp = result.digit[i]; │ │ │ │ │ - 455 temp = temp<(temp&bitmask); │ │ │ │ │ - 457 temp = temp>>bits; │ │ │ │ │ - 458 if (i+1<(int)n) │ │ │ │ │ - 459 result.digit[i+1] = result.digit[i+1]|temp; │ │ │ │ │ - 460 } │ │ │ │ │ - 461 │ │ │ │ │ - 462 return result; │ │ │ │ │ - 463 } │ │ │ │ │ - 464 │ │ │ │ │ - 465 template │ │ │ │ │ -466 inline bigunsignedint bigunsignedint::operator>>(int shift) const │ │ │ │ │ - 467 { │ │ │ │ │ - 468 bigunsignedint result(0); │ │ │ │ │ - 469 │ │ │ │ │ - 470 // multiples of bits │ │ │ │ │ - 471 int j=shift/bits; │ │ │ │ │ - 472 for (unsigned int i=0; i((temp&compbitmask)>>bits); │ │ │ │ │ - 482 if (i>0) │ │ │ │ │ - 483 result.digit[i-1] = result.digit[i-1] | (temp&bitmask); │ │ │ │ │ - 484 } │ │ │ │ │ - 485 │ │ │ │ │ - 486 return result; │ │ │ │ │ - 487 } │ │ │ │ │ - 488 │ │ │ │ │ - 489 template │ │ │ │ │ -490 inline bool bigunsignedint::operator!=(const bigunsignedint& x) const │ │ │ │ │ - 491 { │ │ │ │ │ - 492 for (unsigned int i=0; i │ │ │ │ │ -498 inline bool bigunsignedint::operator==(const bigunsignedint& x) const │ │ │ │ │ - 499 { │ │ │ │ │ - 500 return !((*this)!=x); │ │ │ │ │ - 501 } │ │ │ │ │ - 502 │ │ │ │ │ - 503 template │ │ │ │ │ -504 inline bool bigunsignedint::operator<(const bigunsignedint& x) const │ │ │ │ │ - 505 { │ │ │ │ │ - 506 for (int i=n-1; i>=0; i--) │ │ │ │ │ - 507 if (digit[i]x.digit[i]) return false; │ │ │ │ │ - 509 return false; │ │ │ │ │ - 510 } │ │ │ │ │ - 511 │ │ │ │ │ - 512 template │ │ │ │ │ -513 inline bool bigunsignedint::operator<=(const bigunsignedint& x) const │ │ │ │ │ - 514 { │ │ │ │ │ - 515 for (int i=n-1; i>=0; i--) │ │ │ │ │ - 516 if (digit[i]x.digit[i]) return false; │ │ │ │ │ - 518 return true; │ │ │ │ │ - 519 } │ │ │ │ │ - 520 │ │ │ │ │ - 521 template │ │ │ │ │ -522 inline bool bigunsignedint::operator>(const bigunsignedint& x) const │ │ │ │ │ - 523 { │ │ │ │ │ - 524 return !((*this)<=x); │ │ │ │ │ - 525 } │ │ │ │ │ - 526 │ │ │ │ │ - 527 template │ │ │ │ │ -528 inline bool bigunsignedint::operator>=(const bigunsignedint& x) const │ │ │ │ │ - 529 { │ │ │ │ │ - 530 return !((*this) │ │ │ │ │ -535 inline bigunsignedint operator+(const bigunsignedint& x, std:: │ │ │ │ │ -uintmax_t y) │ │ │ │ │ - 536 { │ │ │ │ │ - 537 bigunsignedint temp(y); │ │ │ │ │ - 538 return x+temp; │ │ │ │ │ - 539 } │ │ │ │ │ - 540 │ │ │ │ │ - 541 template │ │ │ │ │ -542 inline bigunsignedint operator-(const bigunsignedint& x, std:: │ │ │ │ │ -uintmax_t y) │ │ │ │ │ - 543 { │ │ │ │ │ - 544 bigunsignedint temp(y); │ │ │ │ │ - 545 return x-temp; │ │ │ │ │ - 546 } │ │ │ │ │ - 547 │ │ │ │ │ - 548 template │ │ │ │ │ -549 inline bigunsignedint operator*(const bigunsignedint& x, std:: │ │ │ │ │ -uintmax_t y) │ │ │ │ │ - 550 { │ │ │ │ │ - 551 bigunsignedint temp(y); │ │ │ │ │ - 552 return x*temp; │ │ │ │ │ - 553 } │ │ │ │ │ - 554 │ │ │ │ │ - 555 template │ │ │ │ │ -556 inline bigunsignedint operator/(const bigunsignedint& x, std:: │ │ │ │ │ -uintmax_t y) │ │ │ │ │ - 557 { │ │ │ │ │ - 558 bigunsignedint temp(y); │ │ │ │ │ - 559 return x/temp; │ │ │ │ │ - 560 } │ │ │ │ │ - 561 │ │ │ │ │ - 562 template │ │ │ │ │ -563 inline bigunsignedint operator%(const bigunsignedint& x, std:: │ │ │ │ │ -uintmax_t y) │ │ │ │ │ - 564 { │ │ │ │ │ - 565 bigunsignedint temp(y); │ │ │ │ │ - 566 return x%temp; │ │ │ │ │ - 567 } │ │ │ │ │ - 568 │ │ │ │ │ - 569 template │ │ │ │ │ -570 inline bigunsignedint operator+(std::uintmax_t x, const │ │ │ │ │ -bigunsignedint& y) │ │ │ │ │ - 571 { │ │ │ │ │ - 572 bigunsignedint temp(x); │ │ │ │ │ - 573 return temp+y; │ │ │ │ │ - 574 } │ │ │ │ │ - 575 │ │ │ │ │ - 576 template │ │ │ │ │ -577 inline bigunsignedint operator-(std::uintmax_t x, const │ │ │ │ │ -bigunsignedint& y) │ │ │ │ │ - 578 { │ │ │ │ │ - 579 bigunsignedint temp(x); │ │ │ │ │ - 580 return temp-y; │ │ │ │ │ - 581 } │ │ │ │ │ - 582 │ │ │ │ │ - 583 template │ │ │ │ │ -584 inline bigunsignedint operator*(std::uintmax_t x, const │ │ │ │ │ -bigunsignedint& y) │ │ │ │ │ - 585 { │ │ │ │ │ - 586 bigunsignedint temp(x); │ │ │ │ │ - 587 return temp*y; │ │ │ │ │ - 588 } │ │ │ │ │ - 589 │ │ │ │ │ - 590 template │ │ │ │ │ -591 inline bigunsignedint operator/(std::uintmax_t x, const │ │ │ │ │ -bigunsignedint& y) │ │ │ │ │ - 592 { │ │ │ │ │ - 593 bigunsignedint temp(x); │ │ │ │ │ - 594 return temp/y; │ │ │ │ │ - 595 } │ │ │ │ │ - 596 │ │ │ │ │ - 597 template │ │ │ │ │ -598 inline bigunsignedint operator%(std::uintmax_t x, const │ │ │ │ │ -bigunsignedint& y) │ │ │ │ │ - 599 { │ │ │ │ │ - 600 bigunsignedint temp(x); │ │ │ │ │ - 601 return temp%y; │ │ │ │ │ - 602 } │ │ │ │ │ - 603 │ │ │ │ │ - 604 // Forward declare type-trait for numbers │ │ │ │ │ - 605 template struct IsNumber; │ │ │ │ │ - 606 │ │ │ │ │ - 608 template │ │ │ │ │ -609 struct IsNumber> : public std::true_type {}; │ │ │ │ │ - 610 │ │ │ │ │ - 612} │ │ │ │ │ - 613 │ │ │ │ │ - 614namespace std │ │ │ │ │ - 615{ │ │ │ │ │ - 616 template │ │ │ │ │ - 617 struct numeric_limits > │ │ │ │ │ - 618 : private Dune::Impl::numeric_limits_helper > / │ │ │ │ │ -/ for access to internal state of bigunsignedint │ │ │ │ │ - 619 { │ │ │ │ │ - 620 public: │ │ │ │ │ - 621 static const bool is_specialized = true; │ │ │ │ │ - 622 │ │ │ │ │ - 623 static Dune::bigunsignedint min() │ │ │ │ │ - 624 { │ │ │ │ │ - 625 return static_cast >(0); │ │ │ │ │ - 626 } │ │ │ │ │ - 627 │ │ │ │ │ - 628 static Dune::bigunsignedint max() │ │ │ │ │ - 629 { │ │ │ │ │ - 630 Dune::bigunsignedint max_; │ │ │ │ │ - 631 for(std::size_t i=0; i < Dune::bigunsignedint::n; ++i) │ │ │ │ │ - 632 // access internal state via the helper base class │ │ │ │ │ - 633 Dune::Impl::numeric_limits_helper >:: │ │ │ │ │ - 634 digit(max_,i)=std::numeric_limits::max(); │ │ │ │ │ - 635 return max_; │ │ │ │ │ - 636 } │ │ │ │ │ - 637 │ │ │ │ │ - 638 │ │ │ │ │ - 639 static const int digits = Dune::bigunsignedint::bits * │ │ │ │ │ - 640 Dune::bigunsignedint::n; │ │ │ │ │ - 641 static const bool is_signed = false; │ │ │ │ │ - 642 static const bool is_integer = true; │ │ │ │ │ - 643 static const bool is_exact = true; │ │ │ │ │ - 644 static const int radix = 2; │ │ │ │ │ - 645 │ │ │ │ │ - 646 static Dune::bigunsignedint epsilon() │ │ │ │ │ - 647 { │ │ │ │ │ - 648 return static_cast >(0); │ │ │ │ │ - 649 } │ │ │ │ │ - 650 │ │ │ │ │ - 651 static Dune::bigunsignedint round_error() │ │ │ │ │ - 652 { │ │ │ │ │ - 653 return static_cast >(0); │ │ │ │ │ - 654 } │ │ │ │ │ - 655 │ │ │ │ │ - 656 static const int min_exponent = 0; │ │ │ │ │ - 657 static const int min_exponent10 = 0; │ │ │ │ │ - 658 static const int max_exponent = 0; │ │ │ │ │ - 659 static const int max_exponent10 = 0; │ │ │ │ │ - 660 │ │ │ │ │ - 661 static const bool has_infinity = false; │ │ │ │ │ - 662 static const bool has_quiet_NaN = false; │ │ │ │ │ - 663 static const bool has_signaling_NaN = false; │ │ │ │ │ - 664 │ │ │ │ │ - 665 static const float_denorm_style has_denorm = denorm_absent; │ │ │ │ │ - 666 static const bool has_denorm_loss = false; │ │ │ │ │ - 667 │ │ │ │ │ - 668 static Dune::bigunsignedint infinity() noexcept │ │ │ │ │ - 669 { │ │ │ │ │ - 670 return static_cast >(0); │ │ │ │ │ - 671 } │ │ │ │ │ - 672 │ │ │ │ │ - 673 static Dune::bigunsignedint quiet_NaN() noexcept │ │ │ │ │ - 674 { │ │ │ │ │ - 675 return static_cast >(0); │ │ │ │ │ - 676 } │ │ │ │ │ - 677 │ │ │ │ │ - 678 static Dune::bigunsignedint signaling_NaN() noexcept │ │ │ │ │ - 679 { │ │ │ │ │ - 680 return static_cast >(0); │ │ │ │ │ - 681 } │ │ │ │ │ - 682 │ │ │ │ │ - 683 static Dune::bigunsignedint denorm_min() noexcept │ │ │ │ │ - 684 { │ │ │ │ │ - 685 return static_cast >(0); │ │ │ │ │ - 686 } │ │ │ │ │ - 687 │ │ │ │ │ - 688 static const bool is_iec559 = false; │ │ │ │ │ - 689 static const bool is_bounded = true; │ │ │ │ │ - 690 static const bool is_modulo = true; │ │ │ │ │ - 691 │ │ │ │ │ - 692 static const bool traps = false; │ │ │ │ │ - 693 static const bool tinyness_before = false; │ │ │ │ │ - 694 static const float_round_style round_style = round_toward_zero; │ │ │ │ │ - 695 │ │ │ │ │ - 696 }; │ │ │ │ │ - 697 │ │ │ │ │ - 698} │ │ │ │ │ - 699 │ │ │ │ │ - 700DUNE_DEFINE_HASH(DUNE_HASH_TEMPLATE_ARGS(int k),DUNE_HASH_TYPE(Dune:: │ │ │ │ │ -bigunsignedint)) │ │ │ │ │ - 701 │ │ │ │ │ - 702#endif │ │ │ │ │ -hash.hh │ │ │ │ │ -Support for calculating hash values of objects. │ │ │ │ │ -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 │ │ │ │ │ -exceptions.hh │ │ │ │ │ -A few common exception classes. │ │ │ │ │ -Dune::bigunsignedint::operator/= │ │ │ │ │ -bigunsignedint< k > & operator/=(const bigunsignedint< k > &x) │ │ │ │ │ -Definition bigunsignedint.hh:377 │ │ │ │ │ -Dune::operator* │ │ │ │ │ -bigunsignedint< k > operator*(const bigunsignedint< k > &x, std::uintmax_t y) │ │ │ │ │ -Definition bigunsignedint.hh:549 │ │ │ │ │ -Dune::bigunsignedint::operator<< │ │ │ │ │ -bigunsignedint< k > operator<<(int i) const │ │ │ │ │ -left shift │ │ │ │ │ -Definition bigunsignedint.hh:441 │ │ │ │ │ -Dune::bigunsignedint::operator+= │ │ │ │ │ -bigunsignedint< k > & operator+=(const bigunsignedint< k > &x) │ │ │ │ │ -Definition bigunsignedint.hh:305 │ │ │ │ │ -Dune::bigunsignedint::operator^= │ │ │ │ │ -bigunsignedint< k > & operator^=(const bigunsignedint< k > &x) │ │ │ │ │ -Definition bigunsignedint.hh:416 │ │ │ │ │ -Dune::operator<< │ │ │ │ │ -std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x) │ │ │ │ │ -Definition bigunsignedint.hh:278 │ │ │ │ │ -Dune::bigunsignedint::operator<= │ │ │ │ │ -bool operator<=(const bigunsignedint< k > &x) const │ │ │ │ │ -less than or equal │ │ │ │ │ -Definition bigunsignedint.hh:513 │ │ │ │ │ -Dune::bigunsignedint::print │ │ │ │ │ -void print(std::ostream &s) const │ │ │ │ │ -Print number in hex notation. │ │ │ │ │ -Definition bigunsignedint.hh:255 │ │ │ │ │ -Dune::bigunsignedint::operator< │ │ │ │ │ -bool operator<(const bigunsignedint< k > &x) const │ │ │ │ │ -less than │ │ │ │ │ -Definition bigunsignedint.hh:504 │ │ │ │ │ -Dune::operator/ │ │ │ │ │ -bigunsignedint< k > operator/(const bigunsignedint< k > &x, std::uintmax_t y) │ │ │ │ │ -Definition bigunsignedint.hh:556 │ │ │ │ │ -Dune::bigunsignedint::operator== │ │ │ │ │ -bool operator==(const bigunsignedint< k > &x) const │ │ │ │ │ -equal │ │ │ │ │ -Definition bigunsignedint.hh:498 │ │ │ │ │ -Dune::bigunsignedint::operator!= │ │ │ │ │ -bool operator!=(const bigunsignedint< k > &x) const │ │ │ │ │ -not equal │ │ │ │ │ -Definition bigunsignedint.hh:490 │ │ │ │ │ -Dune::bigunsignedint::bigunsignedint │ │ │ │ │ -bigunsignedint() │ │ │ │ │ -Construct uninitialized. │ │ │ │ │ -Definition bigunsignedint.hh:196 │ │ │ │ │ -Dune::bigunsignedint::operator&= │ │ │ │ │ -bigunsignedint< k > & operator&=(const bigunsignedint< k > &x) │ │ │ │ │ -Definition bigunsignedint.hh:408 │ │ │ │ │ -Dune::operator- │ │ │ │ │ -bigunsignedint< k > operator-(const bigunsignedint< k > &x, std::uintmax_t y) │ │ │ │ │ -Definition bigunsignedint.hh:542 │ │ │ │ │ -Dune::bigunsignedint::operator>= │ │ │ │ │ -bool operator>=(const bigunsignedint< k > &x) const │ │ │ │ │ -greater or equal │ │ │ │ │ -Definition bigunsignedint.hh:528 │ │ │ │ │ -Dune::bigunsignedint::operator>> │ │ │ │ │ -bigunsignedint< k > operator>>(int i) const │ │ │ │ │ -right shift │ │ │ │ │ -Definition bigunsignedint.hh:466 │ │ │ │ │ -Dune::operator+ │ │ │ │ │ -bigunsignedint< k > operator+(const bigunsignedint< k > &x, std::uintmax_t y) │ │ │ │ │ -Definition bigunsignedint.hh:535 │ │ │ │ │ -Dune::bigunsignedint::operator~ │ │ │ │ │ -bigunsignedint< k > operator~() const │ │ │ │ │ -bitwise complement │ │ │ │ │ -Definition bigunsignedint.hh:432 │ │ │ │ │ -Dune::bigunsignedint::operator++ │ │ │ │ │ -bigunsignedint< k > & operator++() │ │ │ │ │ -prefix increment │ │ │ │ │ -Definition bigunsignedint.hh:363 │ │ │ │ │ -Dune::bigunsignedint::operator|= │ │ │ │ │ -bigunsignedint< k > & operator|=(const bigunsignedint< k > &x) │ │ │ │ │ -Definition bigunsignedint.hh:424 │ │ │ │ │ -Dune::operator% │ │ │ │ │ -bigunsignedint< k > operator%(const bigunsignedint< k > &x, std::uintmax_t y) │ │ │ │ │ -Definition bigunsignedint.hh:563 │ │ │ │ │ -Dune::bigunsignedint::operator%= │ │ │ │ │ -bigunsignedint< k > & operator%=(const bigunsignedint< k > &x) │ │ │ │ │ -Definition bigunsignedint.hh:396 │ │ │ │ │ -Dune::bigunsignedint::todouble │ │ │ │ │ -double todouble() const │ │ │ │ │ -Convert to a double. │ │ │ │ │ -Definition bigunsignedint.hh:236 │ │ │ │ │ -Dune::bigunsignedint::operator-= │ │ │ │ │ -bigunsignedint< k > & operator-=(const bigunsignedint< k > &x) │ │ │ │ │ -Definition bigunsignedint.hh:319 │ │ │ │ │ -Dune::bigunsignedint::operator> │ │ │ │ │ -bool operator>(const bigunsignedint< k > &x) const │ │ │ │ │ -greater than │ │ │ │ │ -Definition bigunsignedint.hh:522 │ │ │ │ │ -Dune::bigunsignedint::operator*= │ │ │ │ │ -bigunsignedint< k > & operator*=(const bigunsignedint< k > &x) │ │ │ │ │ -Definition bigunsignedint.hh:341 │ │ │ │ │ -Dune::bigunsignedint::touint │ │ │ │ │ -std::uint_least32_t touint() const │ │ │ │ │ -export to other types │ │ │ │ │ -Definition bigunsignedint.hh:230 │ │ │ │ │ -DUNE_BINOP │ │ │ │ │ -#define DUNE_BINOP(OP) │ │ │ │ │ -Definition bigunsignedint.hh:284 │ │ │ │ │ -DUNE_THROW │ │ │ │ │ -#define DUNE_THROW(E, m) │ │ │ │ │ -Definition exceptions.hh:218 │ │ │ │ │ -std │ │ │ │ │ -STL namespace. │ │ │ │ │ + 184#endif // DUNE_COMMON_PATH_HH │ │ │ │ │ +Dune::processPath │ │ │ │ │ +std::string processPath(const std::string &p) │ │ │ │ │ +sanitize a path for further processing │ │ │ │ │ +Definition path.cc:41 │ │ │ │ │ +Dune::pathIndicatesDirectory │ │ │ │ │ +bool pathIndicatesDirectory(const std::string &p) │ │ │ │ │ +check whether the given path indicates that it is a directory │ │ │ │ │ +Definition path.cc:115 │ │ │ │ │ +Dune::prettyPath │ │ │ │ │ +std::string prettyPath(const std::string &p, bool isDirectory) │ │ │ │ │ +pretty print path │ │ │ │ │ +Definition path.cc:126 │ │ │ │ │ +Dune::relativePath │ │ │ │ │ +std::string relativePath(const std::string &newbase, const std::string &p) │ │ │ │ │ +compute a relative path between two paths │ │ │ │ │ +Definition path.cc:153 │ │ │ │ │ +Dune::concatPaths │ │ │ │ │ +std::string concatPaths(const std::string &base, const std::string &p) │ │ │ │ │ +concatenate two paths │ │ │ │ │ +Definition path.cc:32 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -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::assign │ │ │ │ │ -void assign(T &dst, const T &src, bool mask) │ │ │ │ │ -masked Simd assignment (scalar version) │ │ │ │ │ -Definition simd.hh:447 │ │ │ │ │ -Dune::AlignedNumberImpl::max │ │ │ │ │ -auto max(const AlignedNumber< T, align > &a, const AlignedNumber< T, align > │ │ │ │ │ -&b) │ │ │ │ │ -Definition debugalign.hh:425 │ │ │ │ │ -Dune::MPITraits │ │ │ │ │ -A traits class describing the mapping of types onto MPI_Datatypes. │ │ │ │ │ -Definition mpitraits.hh:41 │ │ │ │ │ -Dune::bigunsignedint │ │ │ │ │ -Portable very large unsigned integers. │ │ │ │ │ -Definition bigunsignedint.hh:73 │ │ │ │ │ -Dune::bigunsignedint::overflowmask │ │ │ │ │ -static constexpr int overflowmask │ │ │ │ │ -Definition bigunsignedint.hh:82 │ │ │ │ │ -Dune::bigunsignedint::operator| │ │ │ │ │ -bigunsignedint< k > operator|(const bigunsignedint< k > &x) const │ │ │ │ │ -bitwise or │ │ │ │ │ -Dune::bigunsignedint::hexdigits │ │ │ │ │ -static constexpr int hexdigits │ │ │ │ │ -Definition bigunsignedint.hh:79 │ │ │ │ │ -Dune::bigunsignedint::operator^ │ │ │ │ │ -bigunsignedint< k > operator^(const bigunsignedint< k > &x) const │ │ │ │ │ -bitwise exor │ │ │ │ │ -Dune::bigunsignedint::operator* │ │ │ │ │ -bigunsignedint< k > operator*(const bigunsignedint< k > &x) const │ │ │ │ │ -multiply │ │ │ │ │ -Dune::bigunsignedint::operator% │ │ │ │ │ -bigunsignedint< k > operator%(const bigunsignedint< k > &x) const │ │ │ │ │ -Dune::bigunsignedint::n │ │ │ │ │ -static constexpr int n │ │ │ │ │ -Definition bigunsignedint.hh:78 │ │ │ │ │ -Dune::bigunsignedint::operator- │ │ │ │ │ -bigunsignedint< k > operator-(const bigunsignedint< k > &x) const │ │ │ │ │ -subtract │ │ │ │ │ -Dune::bigunsignedint::compbitmask │ │ │ │ │ -static constexpr int compbitmask │ │ │ │ │ -Definition bigunsignedint.hh:81 │ │ │ │ │ -Dune::bigunsignedint::operator& │ │ │ │ │ -bigunsignedint< k > operator&(const bigunsignedint< k > &x) const │ │ │ │ │ -bitwise and │ │ │ │ │ -Dune::bigunsignedint::bits │ │ │ │ │ -static constexpr int bits │ │ │ │ │ -Definition bigunsignedint.hh:77 │ │ │ │ │ -Dune::bigunsignedint::operator/ │ │ │ │ │ -bigunsignedint< k > operator/(const bigunsignedint< k > &x) const │ │ │ │ │ -Dune::bigunsignedint::operator+ │ │ │ │ │ -bigunsignedint< k > operator+(const bigunsignedint< k > &x) const │ │ │ │ │ -add │ │ │ │ │ -Dune::bigunsignedint::hash_value │ │ │ │ │ -friend std::size_t hash_value(const bigunsignedint &arg) │ │ │ │ │ -Definition bigunsignedint.hh:179 │ │ │ │ │ -Dune::bigunsignedint::bitmask │ │ │ │ │ -static constexpr int bitmask │ │ │ │ │ -Definition bigunsignedint.hh:80 │ │ │ │ │ -Dune::IsNumber │ │ │ │ │ -Whether this type acts as a scalar in the context of (hierarchically blocked) │ │ │ │ │ -containers. │ │ │ │ │ -Definition typetraits.hh:194 │ │ │ │ │ -Dune::Exception │ │ │ │ │ -Base class for Dune-Exceptions. │ │ │ │ │ -Definition exceptions.hh:96 │ │ │ │ │ -Dune::MathError │ │ │ │ │ -Default exception class for mathematical errors. │ │ │ │ │ -Definition exceptions.hh:241 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00134.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: enumset.hh File Reference │ │ │ │ +dune-common: matrixconcepts.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,72 +70,30 @@ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ -Classes | │ │ │ │ -Namespaces | │ │ │ │ -Functions
    │ │ │ │ -
    enumset.hh File Reference
    │ │ │ │ +Namespaces
    │ │ │ │ +
    matrixconcepts.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ - │ │ │ │ -

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

    │ │ │ │ -
    #include <iostream>
    │ │ │ │ +
    #include <utility>
    │ │ │ │ +#include <type_traits>
    │ │ │ │ +#include <dune/common/std/type_traits.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...
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

    │ │ │ │ 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 > &)
     
    │ │ │ │ -

    Detailed Description

    │ │ │ │ -

    Classes for building sets out of enumeration values.

    │ │ │ │ -
    Author
    Markus Blatt
    │ │ │ │ -
    │ │ │ │ +
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,60 +6,20 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Functions │ │ │ │ │ -enumset.hh File Reference │ │ │ │ │ -Classes for building sets out of enumeration values. More... │ │ │ │ │ -#include │ │ │ │ │ +Namespaces │ │ │ │ │ +matrixconcepts.hh File Reference │ │ │ │ │ +#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... │ │ │ │ │ -  │ │ │ │ │ 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 > &) │ │ │ │ │ -  │ │ │ │ │ -***** 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/a00134_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: enumset.hh Source File │ │ │ │ +dune-common: matrixconcepts.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,190 +74,109 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    enumset.hh
    │ │ │ │ +
    matrixconcepts.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 (C) 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_MATRIXCONCEPTS_HH
    │ │ │ │ +
    6#define DUNE_COMMON_MATRIXCONCEPTS_HH
    │ │ │ │
    7
    │ │ │ │ -
    8#include <iostream>
    │ │ │ │ +
    8
    │ │ │ │
    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 };
    │ │ │ │ -
    │ │ │ │ +
    10#include <utility>
    │ │ │ │ +
    11#include <type_traits>
    │ │ │ │ +
    12
    │ │ │ │ + │ │ │ │ +
    14
    │ │ │ │ +
    15
    │ │ │ │ +
    16
    │ │ │ │ +
    17namespace Dune {
    │ │ │ │ +
    18
    │ │ │ │ +
    19 template<class, int, int>
    │ │ │ │ +
    20 class FieldMatrix;
    │ │ │ │ +
    21
    │ │ │ │ +
    22 template<class>
    │ │ │ │ +
    23 class DynamicMatrix;
    │ │ │ │ +
    24
    │ │ │ │ +
    25}
    │ │ │ │ +
    26
    │ │ │ │ +
    27namespace Dune::Impl {
    │ │ │ │ +
    28
    │ │ │ │ +
    29
    │ │ │ │ +
    30 // Some traits for checking matrix concepts. Currently these are
    │ │ │ │ +
    31 // all technical internal helpers that just serve different headers
    │ │ │ │ +
    32 // to do internal checks and are thus collected here.
    │ │ │ │ +
    33
    │ │ │ │ +
    34 template<class T>
    │ │ │ │ +
    35 using IsMatrixHelper = std::void_t<decltype(std::declval<T>().N(), std::declval<T>().M())>;
    │ │ │ │ +
    36
    │ │ │ │ +
    37 template<class T>
    │ │ │ │ +
    38 struct IsMatrix : public Dune::Std::is_detected<IsMatrixHelper, T> {};
    │ │ │ │ +
    39
    │ │ │ │ +
    40 // Check if T is a matrix by checking for member functions N() and M().
    │ │ │ │ +
    41 template<class T>
    │ │ │ │ +
    42 constexpr bool IsMatrix_v = Impl::IsMatrix<T>::value;
    │ │ │ │ +
    43
    │ │ │ │ +
    44
    │ │ │ │ +
    45
    │ │ │ │ +
    46 template<class T>
    │ │ │ │ +
    47 using IsStaticSizeMatrixHelper = std::void_t<decltype(T::rows, T::cols)>;
    │ │ │ │ +
    48
    │ │ │ │ +
    49 template<class T>
    │ │ │ │ +
    50 struct IsStaticSizeMatrix : public Dune::Std::is_detected<IsStaticSizeMatrixHelper, T> {};
    │ │ │ │ +
    51
    │ │ │ │ +
    52 // Check if T is a statically sized matrix by checking for static members rows and cols.
    │ │ │ │ +
    53 template<class T>
    │ │ │ │ +
    54 constexpr bool IsStaticSizeMatrix_v = Impl::IsStaticSizeMatrix<T>::value;
    │ │ │ │
    55
    │ │ │ │ -
    59 template<typename TA, int item>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    61 {
    │ │ │ │ -
    62 public:
    │ │ │ │ -
    66 typedef TA Type;
    │ │ │ │ +
    56
    │ │ │ │ +
    57
    │ │ │ │ +
    58 template<class T>
    │ │ │ │ +
    59 class IsFieldMatrix : public std::false_type {};
    │ │ │ │ +
    60
    │ │ │ │ +
    61 template< class K, int ROWS, int COLS>
    │ │ │ │ +
    62 class IsFieldMatrix<Dune::FieldMatrix<K, ROWS, COLS>> : public std::true_type {};
    │ │ │ │ +
    63
    │ │ │ │ +
    64 // Check if T is an instance of FieldMatrix
    │ │ │ │ +
    65 template<class T>
    │ │ │ │ +
    66 constexpr bool IsFieldMatrix_v = Impl::IsFieldMatrix<T>::value;
    │ │ │ │
    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 };
    │ │ │ │ -
    │ │ │ │ +
    68
    │ │ │ │ +
    69
    │ │ │ │ +
    70 template<class T>
    │ │ │ │ +
    71 class IsDenseMatrix : public std::false_type {};
    │ │ │ │ +
    72
    │ │ │ │ +
    73 template<class K, int ROWS, int COLS>
    │ │ │ │ +
    74 class IsDenseMatrix<Dune::FieldMatrix<K, ROWS, COLS>> : public std::true_type {};
    │ │ │ │ +
    75
    │ │ │ │ +
    76 template<class K>
    │ │ │ │ +
    77 class IsDenseMatrix<Dune::DynamicMatrix<K>> : public std::true_type {};
    │ │ │ │ +
    78
    │ │ │ │ +
    79 // Check if T is a dense matrix. This is implemented by specialization.
    │ │ │ │ +
    80 template<class T>
    │ │ │ │ +
    81 constexpr bool IsDenseMatrix_v = Impl::IsDenseMatrix<T>::value;
    │ │ │ │ +
    82
    │ │ │ │ +
    83
    │ │ │ │ +
    84
    │ │ │ │ +
    85} // namespace Dune::Impl
    │ │ │ │ +
    86
    │ │ │ │ +
    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>
    │ │ │ │ -
    │ │ │ │ -
    135 inline std::ostream& operator<<(std::ostream& os, const EnumItem<TA,i>&)
    │ │ │ │ -
    136 {
    │ │ │ │ -
    137 return os<<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<<"]";
    │ │ │ │ -
    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
    │ │ │ │ +
    89#endif // DUNE_COMMON_MATRIXCONCEPTS_HH
    │ │ │ │ + │ │ │ │ +
    typename detected_or< nonesuch, Op, Args... >::value_t is_detected
    Detects whether Op<Args...> is valid.
    Definition type_traits.hh:141
    │ │ │ │
    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
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,206 +7,115 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -enumset.hh │ │ │ │ │ +matrixconcepts.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 (C) 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_MATRIXCONCEPTS_HH │ │ │ │ │ + 6#define DUNE_COMMON_MATRIXCONCEPTS_HH │ │ │ │ │ 7 │ │ │ │ │ - 8#include │ │ │ │ │ + 8 │ │ │ │ │ 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 }; │ │ │ │ │ + 10#include │ │ │ │ │ + 11#include │ │ │ │ │ + 12 │ │ │ │ │ + 13#include │ │ │ │ │ + 14 │ │ │ │ │ + 15 │ │ │ │ │ + 16 │ │ │ │ │ + 17namespace Dune { │ │ │ │ │ + 18 │ │ │ │ │ + 19 template │ │ │ │ │ + 20 class FieldMatrix; │ │ │ │ │ + 21 │ │ │ │ │ + 22 template │ │ │ │ │ + 23 class DynamicMatrix; │ │ │ │ │ + 24 │ │ │ │ │ + 25} │ │ │ │ │ + 26 │ │ │ │ │ + 27namespace Dune::Impl { │ │ │ │ │ + 28 │ │ │ │ │ + 29 │ │ │ │ │ + 30 // Some traits for checking matrix concepts. Currently these are │ │ │ │ │ + 31 // all technical internal helpers that just serve different headers │ │ │ │ │ + 32 // to do internal checks and are thus collected here. │ │ │ │ │ + 33 │ │ │ │ │ + 34 template │ │ │ │ │ + 35 using IsMatrixHelper = std::void_t().N(), std:: │ │ │ │ │ +declval().M())>; │ │ │ │ │ + 36 │ │ │ │ │ + 37 template │ │ │ │ │ + 38 struct IsMatrix : public Dune::Std::is_detected {}; │ │ │ │ │ + 39 │ │ │ │ │ + 40 // Check if T is a matrix by checking for member functions N() and M(). │ │ │ │ │ + 41 template │ │ │ │ │ + 42 constexpr bool IsMatrix_v = Impl::IsMatrix::value; │ │ │ │ │ + 43 │ │ │ │ │ + 44 │ │ │ │ │ + 45 │ │ │ │ │ + 46 template │ │ │ │ │ + 47 using IsStaticSizeMatrixHelper = std::void_t; │ │ │ │ │ + 48 │ │ │ │ │ + 49 template │ │ │ │ │ + 50 struct IsStaticSizeMatrix : public Dune::Std:: │ │ │ │ │ +is_detected {}; │ │ │ │ │ + 51 │ │ │ │ │ + 52 // Check if T is a statically sized matrix by checking for static members │ │ │ │ │ +rows and cols. │ │ │ │ │ + 53 template │ │ │ │ │ + 54 constexpr bool IsStaticSizeMatrix_v = Impl::IsStaticSizeMatrix::value; │ │ │ │ │ 55 │ │ │ │ │ - 59 template │ │ │ │ │ -60 class EnumItem │ │ │ │ │ - 61 { │ │ │ │ │ - 62 public: │ │ │ │ │ -66 typedef TA Type; │ │ │ │ │ + 56 │ │ │ │ │ + 57 │ │ │ │ │ + 58 template │ │ │ │ │ + 59 class IsFieldMatrix : public std::false_type {}; │ │ │ │ │ + 60 │ │ │ │ │ + 61 template< class K, int ROWS, int COLS> │ │ │ │ │ + 62 class IsFieldMatrix> : public std:: │ │ │ │ │ +true_type {}; │ │ │ │ │ + 63 │ │ │ │ │ + 64 // Check if T is an instance of FieldMatrix │ │ │ │ │ + 65 template │ │ │ │ │ + 66 constexpr bool IsFieldMatrix_v = Impl::IsFieldMatrix::value; │ │ │ │ │ 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 }; │ │ │ │ │ + 68 │ │ │ │ │ + 69 │ │ │ │ │ + 70 template │ │ │ │ │ + 71 class IsDenseMatrix : public std::false_type {}; │ │ │ │ │ + 72 │ │ │ │ │ + 73 template │ │ │ │ │ + 74 class IsDenseMatrix> : public std:: │ │ │ │ │ +true_type {}; │ │ │ │ │ + 75 │ │ │ │ │ + 76 template │ │ │ │ │ + 77 class IsDenseMatrix> : public std::true_type {}; │ │ │ │ │ + 78 │ │ │ │ │ + 79 // Check if T is a dense matrix. This is implemented by specialization. │ │ │ │ │ + 80 template │ │ │ │ │ + 81 constexpr bool IsDenseMatrix_v = Impl::IsDenseMatrix::value; │ │ │ │ │ + 82 │ │ │ │ │ + 83 │ │ │ │ │ + 84 │ │ │ │ │ + 85} // namespace Dune::Impl │ │ │ │ │ + 86 │ │ │ │ │ + 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); │ │ │ │ │ - 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&) │ │ │ │ │ - 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<<"["< │ │ │ │ │ -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 │ │ │ │ │ + 89#endif // DUNE_COMMON_MATRIXCONCEPTS_HH │ │ │ │ │ +type_traits.hh │ │ │ │ │ +Dune::Std::is_detected │ │ │ │ │ +typename detected_or< nonesuch, Op, Args... >::value_t is_detected │ │ │ │ │ +Detects whether Op is valid. │ │ │ │ │ +Definition type_traits.hh:141 │ │ │ │ │ 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 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00137.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: ftraits.hh File Reference │ │ │ │ +dune-common: tuplevector.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -71,47 +71,51 @@ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ Classes | │ │ │ │ -Namespaces
    │ │ │ │ -
    ftraits.hh File Reference
    │ │ │ │ +Namespaces | │ │ │ │ +Functions
    │ │ │ │ +
    tuplevector.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ -

    Type traits to determine the type of reals (when working with complex numbers) │ │ │ │ +

    Provides the TupleVector class that augments std::tuple by operator[]. │ │ │ │ More...

    │ │ │ │ -
    #include <complex>
    │ │ │ │ -#include <vector>
    │ │ │ │ +
    #include <tuple>
    │ │ │ │ +#include <utility>
    │ │ │ │ +#include <dune/common/indices.hh>
    │ │ │ │ +#include <dune/common/typetraits.hh>
    │ │ │ │ +#include <dune/common/std/type_traits.hh>
    │ │ │ │
    │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ Classes

    struct  Dune::FieldTraits< T >
     
    struct  Dune::FieldTraits< const T >
     
    struct  Dune::FieldTraits< std::complex< T > >
     
    struct  Dune::FieldTraits< T[N] >
     
    struct  Dune::FieldTraits< std::vector< T > >
    class  Dune::TupleVector< T >
     A class augmenting std::tuple by element access via operator[]. More...
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ +

    │ │ │ │ Namespaces

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

    │ │ │ │ +Functions

    template<class... T>
    constexpr auto Dune::makeTupleVector (T &&... t)
     
    │ │ │ │

    Detailed Description

    │ │ │ │ -

    Type traits to determine the type of reals (when working with complex numbers)

    │ │ │ │ +

    Provides the TupleVector class that augments std::tuple by operator[].

    │ │ │ │ +
    Author
    Carsten Gräser
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── encoding │ │ │ │ │ @@ -1 +1 @@ │ │ │ │ │ -us-ascii │ │ │ │ │ +utf-8 │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,34 +6,35 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -ftraits.hh File Reference │ │ │ │ │ -Type traits to determine the type of reals (when working with complex numbers) │ │ │ │ │ -More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces | Functions │ │ │ │ │ +tuplevector.hh File Reference │ │ │ │ │ +Provides the TupleVector class that augments std::tuple by operator[]. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -struct  Dune::FieldTraits<_T_> │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::FieldTraits<_const_T_> │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::FieldTraits<_std::complex<_T_>_> │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::FieldTraits<_T[N]_> │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::FieldTraits<_std::vector<_T_>_> │ │ │ │ │ +class  Dune::TupleVector<_T_> │ │ │ │ │ +  A class augmenting std::tuple by element access via operator[]. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ + Functions │ │ │ │ │ +template │ │ │ │ │ +constexpr auto Dune::makeTupleVector (T &&... t) │ │ │ │ │ +  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Type traits to determine the type of reals (when working with complex numbers) │ │ │ │ │ +Provides the TupleVector class that augments std::tuple by operator[]. │ │ │ │ │ + Author │ │ │ │ │ + Carsten Gräser │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00137_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: ftraits.hh Source File │ │ │ │ +dune-common: tuplevector.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,90 +74,120 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    ftraits.hh
    │ │ │ │ +
    tuplevector.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 (C) 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_FTRAITS_HH
    │ │ │ │ -
    6#define DUNE_FTRAITS_HH
    │ │ │ │ +
    5#ifndef DUNE_COMMON_TUPLEVECTOR_HH
    │ │ │ │ +
    6#define DUNE_COMMON_TUPLEVECTOR_HH
    │ │ │ │
    7
    │ │ │ │ -
    12#include <complex>
    │ │ │ │ -
    13#include <vector>
    │ │ │ │ +
    8#include <tuple>
    │ │ │ │ +
    9#include <utility>
    │ │ │ │ +
    10
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │
    14
    │ │ │ │ -
    15namespace Dune {
    │ │ │ │ +
    15
    │ │ │ │
    16
    │ │ │ │ -
    24 template<class T>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    26 {
    │ │ │ │ -
    28 typedef T field_type;
    │ │ │ │ -
    30 typedef T real_type;
    │ │ │ │ -
    31 };
    │ │ │ │ -
    │ │ │ │ -
    32
    │ │ │ │ -
    33 template<class T>
    │ │ │ │ +
    23namespace Dune
    │ │ │ │ +
    24{
    │ │ │ │ +
    25
    │ │ │ │ +
    26
    │ │ │ │ +
    27
    │ │ │ │ +
    33template<class... T>
    │ │ │ │
    │ │ │ │ -
    34 struct FieldTraits<const T>
    │ │ │ │ -
    35 {
    │ │ │ │ - │ │ │ │ - │ │ │ │ -
    38 };
    │ │ │ │ -
    │ │ │ │ -
    39
    │ │ │ │ -
    40 template<class T>
    │ │ │ │ -
    │ │ │ │ -
    41 struct FieldTraits< std::complex<T> >
    │ │ │ │ -
    42 {
    │ │ │ │ -
    43 typedef std::complex<T> field_type;
    │ │ │ │ -
    44 typedef T real_type;
    │ │ │ │ -
    45 };
    │ │ │ │ -
    │ │ │ │ +
    34class TupleVector : public std::tuple<T...>
    │ │ │ │ +
    35{
    │ │ │ │ +
    36 using Base = std::tuple<T...>;
    │ │ │ │ +
    37
    │ │ │ │ +
    38 template<class... TT>
    │ │ │ │ +
    39 using TupleConstructorDetector = decltype(Base(std::declval<TT&&>()...));
    │ │ │ │ +
    40
    │ │ │ │ +
    41 template<class... TT>
    │ │ │ │ +
    42 using hasTupleConstructor = Dune::Std::is_detected<TupleConstructorDetector, TT...>;
    │ │ │ │ +
    43
    │ │ │ │ +
    44
    │ │ │ │ +
    45public:
    │ │ │ │
    46
    │ │ │ │ -
    47 template<class T, unsigned int N>
    │ │ │ │ -
    │ │ │ │ -
    48 struct FieldTraits< T[N] >
    │ │ │ │ -
    49 {
    │ │ │ │ - │ │ │ │ - │ │ │ │ -
    52 };
    │ │ │ │ -
    │ │ │ │ -
    53
    │ │ │ │ -
    54 template<class T>
    │ │ │ │ -
    │ │ │ │ -
    55 struct FieldTraits< std::vector<T> >
    │ │ │ │ -
    56 {
    │ │ │ │ - │ │ │ │ - │ │ │ │ -
    59 };
    │ │ │ │ -
    │ │ │ │ -
    60
    │ │ │ │ -
    61} // end namespace Dune
    │ │ │ │ -
    62
    │ │ │ │ -
    63#endif // DUNE_FTRAITS_HH
    │ │ │ │ +
    53 template<class... TT,
    │ │ │ │ +
    54 std::enable_if_t<hasTupleConstructor<TT...>::value, int> = 0>
    │ │ │ │ +
    │ │ │ │ +
    55 constexpr TupleVector(TT&&... tt) :
    │ │ │ │ +
    56 Base(std::forward<TT>(tt)...)
    │ │ │ │ +
    57 {}
    │ │ │ │ +
    │ │ │ │ +
    58
    │ │ │ │ +
    │ │ │ │ +
    61 constexpr TupleVector()
    │ │ │ │ +
    62 {}
    │ │ │ │ +
    │ │ │ │ +
    63
    │ │ │ │ +
    66 template<std::size_t i>
    │ │ │ │ +
    │ │ │ │ +
    67 constexpr decltype(auto) operator[](const Dune::index_constant<i>&) const
    │ │ │ │ +
    68 {
    │ │ │ │ +
    69 return std::get<i>(*this);
    │ │ │ │ +
    70 }
    │ │ │ │ +
    │ │ │ │ +
    71
    │ │ │ │ +
    74 template<std::size_t i>
    │ │ │ │ +
    │ │ │ │ +
    75 decltype(auto) operator[](const Dune::index_constant<i>&)
    │ │ │ │ +
    76 {
    │ │ │ │ +
    77 return std::get<i>(*this);
    │ │ │ │ +
    78 }
    │ │ │ │ +
    │ │ │ │ +
    79
    │ │ │ │ +
    │ │ │ │ +
    81 static constexpr std::size_t size()
    │ │ │ │ +
    82 {
    │ │ │ │ +
    83 return std::tuple_size<Base>::value;
    │ │ │ │ +
    84 }
    │ │ │ │ +
    │ │ │ │ +
    85};
    │ │ │ │ +
    │ │ │ │ +
    86
    │ │ │ │ +
    87
    │ │ │ │ +
    88
    │ │ │ │ +
    89template<class... T>
    │ │ │ │ +
    │ │ │ │ +
    90constexpr auto makeTupleVector(T&&... t)
    │ │ │ │ +
    91{
    │ │ │ │ +
    92 // The std::decay_t<T> is is a slight simplification,
    │ │ │ │ +
    93 // because std::reference_wrapper needs special care.
    │ │ │ │ +
    94 return TupleVector<std::decay_t<T>...>(std::forward<T>(t)...);
    │ │ │ │ +
    95}
    │ │ │ │ +
    │ │ │ │ +
    96
    │ │ │ │ +
    97
    │ │ │ │ +
    98
    │ │ │ │ +
    99} // namespace Dune
    │ │ │ │ +
    100
    │ │ │ │ +
    101#endif // DUNE_COMMON_TUPLEVECTOR_HH
    │ │ │ │ + │ │ │ │ + │ │ │ │ +
    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:30
    │ │ │ │ +
    typename detected_or< nonesuch, Op, Args... >::value_t is_detected
    Detects whether Op<Args...> is valid.
    Definition type_traits.hh:141
    │ │ │ │
    STL namespace.
    │ │ │ │
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ -
    Definition ftraits.hh:26
    │ │ │ │ -
    T field_type
    export the type representing the field
    Definition ftraits.hh:28
    │ │ │ │ -
    T real_type
    export the type representing the real type of the field
    Definition ftraits.hh:30
    │ │ │ │ -
    FieldTraits< T >::field_type field_type
    Definition ftraits.hh:36
    │ │ │ │ -
    FieldTraits< T >::real_type real_type
    Definition ftraits.hh:37
    │ │ │ │ -
    T real_type
    Definition ftraits.hh:44
    │ │ │ │ -
    std::complex< T > field_type
    Definition ftraits.hh:43
    │ │ │ │ -
    FieldTraits< T >::field_type field_type
    Definition ftraits.hh:50
    │ │ │ │ -
    FieldTraits< T >::real_type real_type
    Definition ftraits.hh:51
    │ │ │ │ -
    FieldTraits< T >::real_type real_type
    Definition ftraits.hh:58
    │ │ │ │ -
    FieldTraits< T >::field_type field_type
    Definition ftraits.hh:57
    │ │ │ │ +
    constexpr auto makeTupleVector(T &&... t)
    Definition tuplevector.hh:90
    │ │ │ │ +
    A class augmenting std::tuple by element access via operator[].
    Definition tuplevector.hh:35
    │ │ │ │ +
    static constexpr std::size_t size()
    Number of elements of the tuple.
    Definition tuplevector.hh:81
    │ │ │ │ +
    constexpr TupleVector(TT &&... tt)
    Construct from a set of arguments.
    Definition tuplevector.hh:55
    │ │ │ │ +
    constexpr TupleVector()
    Default constructor.
    Definition tuplevector.hh:61
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,102 +7,126 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -ftraits.hh │ │ │ │ │ +tuplevector.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 (C) 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_FTRAITS_HH │ │ │ │ │ - 6#define DUNE_FTRAITS_HH │ │ │ │ │ + 5#ifndef DUNE_COMMON_TUPLEVECTOR_HH │ │ │ │ │ + 6#define DUNE_COMMON_TUPLEVECTOR_HH │ │ │ │ │ 7 │ │ │ │ │ - 12#include │ │ │ │ │ - 13#include │ │ │ │ │ + 8#include │ │ │ │ │ + 9#include │ │ │ │ │ + 10 │ │ │ │ │ + 11#include │ │ │ │ │ + 12#include │ │ │ │ │ + 13#include │ │ │ │ │ 14 │ │ │ │ │ - 15namespace Dune { │ │ │ │ │ + 15 │ │ │ │ │ 16 │ │ │ │ │ - 24 template │ │ │ │ │ -25 struct FieldTraits │ │ │ │ │ - 26 { │ │ │ │ │ -28 typedef T field_type; │ │ │ │ │ -30 typedef T real_type; │ │ │ │ │ - 31 }; │ │ │ │ │ - 32 │ │ │ │ │ - 33 template │ │ │ │ │ -34 struct FieldTraits │ │ │ │ │ - 35 { │ │ │ │ │ -36 typedef typename FieldTraits::field_type field_type; │ │ │ │ │ -37 typedef typename FieldTraits::real_type real_type; │ │ │ │ │ - 38 }; │ │ │ │ │ - 39 │ │ │ │ │ - 40 template │ │ │ │ │ -41 struct FieldTraits< std::complex > │ │ │ │ │ - 42 { │ │ │ │ │ -43 typedef std::complex field_type; │ │ │ │ │ -44 typedef T real_type; │ │ │ │ │ - 45 }; │ │ │ │ │ + 23namespace Dune │ │ │ │ │ + 24{ │ │ │ │ │ + 25 │ │ │ │ │ + 26 │ │ │ │ │ + 27 │ │ │ │ │ + 33template │ │ │ │ │ +34class TupleVector : public std::tuple │ │ │ │ │ + 35{ │ │ │ │ │ + 36 using Base = std::tuple; │ │ │ │ │ + 37 │ │ │ │ │ + 38 template │ │ │ │ │ + 39 using TupleConstructorDetector = decltype(Base(std::declval()...)); │ │ │ │ │ + 40 │ │ │ │ │ + 41 template │ │ │ │ │ + 42 using hasTupleConstructor = Dune::Std:: │ │ │ │ │ +is_detected; │ │ │ │ │ + 43 │ │ │ │ │ + 44 │ │ │ │ │ + 45public: │ │ │ │ │ 46 │ │ │ │ │ - 47 template │ │ │ │ │ -48 struct FieldTraits< T[N] > │ │ │ │ │ - 49 { │ │ │ │ │ -50 typedef typename FieldTraits::field_type field_type; │ │ │ │ │ -51 typedef typename FieldTraits::real_type real_type; │ │ │ │ │ - 52 }; │ │ │ │ │ - 53 │ │ │ │ │ - 54 template │ │ │ │ │ -55 struct FieldTraits< std::vector > │ │ │ │ │ - 56 { │ │ │ │ │ -57 typedef typename FieldTraits::field_type field_type; │ │ │ │ │ -58 typedef typename FieldTraits::real_type real_type; │ │ │ │ │ - 59 }; │ │ │ │ │ - 60 │ │ │ │ │ - 61} // end namespace Dune │ │ │ │ │ - 62 │ │ │ │ │ - 63#endif // DUNE_FTRAITS_HH │ │ │ │ │ + 53 template::value, int> = 0> │ │ │ │ │ +55 constexpr TupleVector(TT&&... tt) : │ │ │ │ │ + 56 Base(std::forward(tt)...) │ │ │ │ │ + 57 {} │ │ │ │ │ + 58 │ │ │ │ │ +61 constexpr TupleVector() │ │ │ │ │ + 62 {} │ │ │ │ │ + 63 │ │ │ │ │ + 66 template │ │ │ │ │ +67 constexpr decltype(auto) operator[](const Dune::index_constant&) const │ │ │ │ │ + 68 { │ │ │ │ │ + 69 return std::get(*this); │ │ │ │ │ + 70 } │ │ │ │ │ + 71 │ │ │ │ │ + 74 template │ │ │ │ │ +75 decltype(auto) operator[](const Dune::index_constant&) │ │ │ │ │ + 76 { │ │ │ │ │ + 77 return std::get(*this); │ │ │ │ │ + 78 } │ │ │ │ │ + 79 │ │ │ │ │ +81 static constexpr std::size_t size() │ │ │ │ │ + 82 { │ │ │ │ │ + 83 return std::tuple_size::value; │ │ │ │ │ + 84 } │ │ │ │ │ + 85}; │ │ │ │ │ + 86 │ │ │ │ │ + 87 │ │ │ │ │ + 88 │ │ │ │ │ + 89template │ │ │ │ │ +90constexpr auto makeTupleVector(T&&... t) │ │ │ │ │ + 91{ │ │ │ │ │ + 92 // The std::decay_t is is a slight simplification, │ │ │ │ │ + 93 // because std::reference_wrapper needs special care. │ │ │ │ │ + 94 return TupleVector...>(std::forward(t)...); │ │ │ │ │ + 95} │ │ │ │ │ + 96 │ │ │ │ │ + 97 │ │ │ │ │ + 98 │ │ │ │ │ + 99} // namespace Dune │ │ │ │ │ + 100 │ │ │ │ │ + 101#endif // DUNE_COMMON_TUPLEVECTOR_HH │ │ │ │ │ +indices.hh │ │ │ │ │ +type_traits.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:30 │ │ │ │ │ +Dune::Std::is_detected │ │ │ │ │ +typename detected_or< nonesuch, Op, Args... >::value_t is_detected │ │ │ │ │ +Detects whether Op is valid. │ │ │ │ │ +Definition type_traits.hh:141 │ │ │ │ │ std │ │ │ │ │ STL namespace. │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::FieldTraits │ │ │ │ │ -Definition ftraits.hh:26 │ │ │ │ │ -Dune::FieldTraits::field_type │ │ │ │ │ -T field_type │ │ │ │ │ -export the type representing the field │ │ │ │ │ -Definition ftraits.hh:28 │ │ │ │ │ -Dune::FieldTraits::real_type │ │ │ │ │ -T real_type │ │ │ │ │ -export the type representing the real type of the field │ │ │ │ │ -Definition ftraits.hh:30 │ │ │ │ │ -Dune::FieldTraits<_const_T_>::field_type │ │ │ │ │ -FieldTraits< T >::field_type field_type │ │ │ │ │ -Definition ftraits.hh:36 │ │ │ │ │ -Dune::FieldTraits<_const_T_>::real_type │ │ │ │ │ -FieldTraits< T >::real_type real_type │ │ │ │ │ -Definition ftraits.hh:37 │ │ │ │ │ -Dune::FieldTraits<_std::complex<_T_>_>::real_type │ │ │ │ │ -T real_type │ │ │ │ │ -Definition ftraits.hh:44 │ │ │ │ │ -Dune::FieldTraits<_std::complex<_T_>_>::field_type │ │ │ │ │ -std::complex< T > field_type │ │ │ │ │ -Definition ftraits.hh:43 │ │ │ │ │ -Dune::FieldTraits<_T[N]_>::field_type │ │ │ │ │ -FieldTraits< T >::field_type field_type │ │ │ │ │ -Definition ftraits.hh:50 │ │ │ │ │ -Dune::FieldTraits<_T[N]_>::real_type │ │ │ │ │ -FieldTraits< T >::real_type real_type │ │ │ │ │ -Definition ftraits.hh:51 │ │ │ │ │ -Dune::FieldTraits<_std::vector<_T_>_>::real_type │ │ │ │ │ -FieldTraits< T >::real_type real_type │ │ │ │ │ -Definition ftraits.hh:58 │ │ │ │ │ -Dune::FieldTraits<_std::vector<_T_>_>::field_type │ │ │ │ │ -FieldTraits< T >::field_type field_type │ │ │ │ │ -Definition ftraits.hh:57 │ │ │ │ │ +Dune::makeTupleVector │ │ │ │ │ +constexpr auto makeTupleVector(T &&... t) │ │ │ │ │ +Definition tuplevector.hh:90 │ │ │ │ │ +Dune::TupleVector │ │ │ │ │ +A class augmenting std::tuple by element access via operator[]. │ │ │ │ │ +Definition tuplevector.hh:35 │ │ │ │ │ +Dune::TupleVector::size │ │ │ │ │ +static constexpr std::size_t size() │ │ │ │ │ +Number of elements of the tuple. │ │ │ │ │ +Definition tuplevector.hh:81 │ │ │ │ │ +Dune::TupleVector::TupleVector │ │ │ │ │ +constexpr TupleVector(TT &&... tt) │ │ │ │ │ +Construct from a set of arguments. │ │ │ │ │ +Definition tuplevector.hh:55 │ │ │ │ │ +Dune::TupleVector::TupleVector │ │ │ │ │ +constexpr TupleVector() │ │ │ │ │ +Default constructor. │ │ │ │ │ +Definition tuplevector.hh:61 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00140.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: documentation.hh File Reference │ │ │ │ +dune-common: scalarvectorview.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,46 +70,39 @@ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ -Classes | │ │ │ │ -Namespaces | │ │ │ │ -Enumerations
    │ │ │ │ -
    documentation.hh File Reference
    │ │ │ │ +Namespaces
    │ │ │ │ +
    scalarvectorview.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ -

    Documentation related stuff. │ │ │ │ +

    Implements a scalar vector view wrapper around an existing scalar. │ │ │ │ More...

    │ │ │ │ - │ │ │ │ +
    #include <cstddef>
    │ │ │ │ +#include <type_traits>
    │ │ │ │ +#include <istream>
    │ │ │ │ +#include <dune/common/densevector.hh>
    │ │ │ │ +#include <dune/common/fvector.hh>
    │ │ │ │ +#include <dune/common/typetraits.hh>
    │ │ │ │ +#include <dune/common/matvectraits.hh>
    │ │ │ │ +
    │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ -Classes

    struct  Dune::ImplementationDefined
     Dummy struct used for documentation purposes. More...
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

    │ │ │ │ Namespaces

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

    │ │ │ │ -Enumerations

    enum  { Dune::implementationDefined │ │ │ │ - }
     
    │ │ │ │

    Detailed Description

    │ │ │ │ -

    Documentation related stuff.

    │ │ │ │ +

    Implements a scalar vector view wrapper around an existing scalar.

    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,27 +6,28 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Enumerations │ │ │ │ │ -documentation.hh File Reference │ │ │ │ │ -Documentation related stuff. More... │ │ │ │ │ +Namespaces │ │ │ │ │ +scalarvectorview.hh File Reference │ │ │ │ │ +Common » Dense_Matrix_and_Vector_Template_Library │ │ │ │ │ +Implements a scalar vector view wrapper around an existing scalar. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ - Classes │ │ │ │ │ -struct  Dune::ImplementationDefined │ │ │ │ │ -  Dummy struct used for documentation purposes. More... │ │ │ │ │ -  │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ - Enumerations │ │ │ │ │ -enum  { Dune::implementationDefined } │ │ │ │ │ -  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Documentation related stuff. │ │ │ │ │ +Implements a scalar vector view wrapper around an existing scalar. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00140_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: documentation.hh Source File │ │ │ │ +dune-common: scalarvectorview.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,38 +74,194 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    documentation.hh
    │ │ │ │ +
    scalarvectorview.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 (C) 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_DOCUMENTATION_HH
    │ │ │ │ -
    7#define DUNE_COMMON_DOCUMENTATION_HH
    │ │ │ │ -
    8
    │ │ │ │ -
    13namespace Dune {
    │ │ │ │ -
    14
    │ │ │ │ - │ │ │ │ -
    43
    │ │ │ │ - │ │ │ │ -
    56
    │ │ │ │ -
    57}
    │ │ │ │ -
    58
    │ │ │ │ +
    5#ifndef DUNE_COMMON_SCALARVECTORVIEW_HH
    │ │ │ │ +
    6#define DUNE_COMMON_SCALARVECTORVIEW_HH
    │ │ │ │ +
    7
    │ │ │ │ +
    8#include <cstddef>
    │ │ │ │ +
    9#include <type_traits>
    │ │ │ │ +
    10#include <istream>
    │ │ │ │ +
    11
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    16
    │ │ │ │ +
    17namespace Dune {
    │ │ │ │ +
    18
    │ │ │ │ +
    19namespace Impl {
    │ │ │ │ +
    20
    │ │ │ │ +
    35 template<class K>
    │ │ │ │ +
    36 class ScalarVectorView :
    │ │ │ │ +
    37 public DenseVector<ScalarVectorView<K>>
    │ │ │ │ +
    38 {
    │ │ │ │ +
    39 K* dataP_;
    │ │ │ │ +
    40 using Base = DenseVector<ScalarVectorView<K>>;
    │ │ │ │ +
    41
    │ │ │ │ +
    42 template <class>
    │ │ │ │ +
    43 friend class ScalarVectorView;
    │ │ │ │ +
    44 public:
    │ │ │ │ +
    45
    │ │ │ │ +
    47 constexpr static int dimension = 1;
    │ │ │ │ +
    48
    │ │ │ │ +
    50 using size_type = typename Base::size_type;
    │ │ │ │ +
    51
    │ │ │ │ +
    53 using reference = std::decay_t<K>&;
    │ │ │ │ +
    54
    │ │ │ │ +
    56 using const_reference = const K&;
    │ │ │ │ +
    57
    │ │ │ │ +
    58 //===== construction
    │ │ │ │
    59
    │ │ │ │ -
    60#endif // DUNE_COMMON_DOCUMENTATION_HH
    │ │ │ │ +
    61 constexpr ScalarVectorView ()
    │ │ │ │ +
    62 : dataP_(nullptr)
    │ │ │ │ +
    63 {}
    │ │ │ │ +
    64
    │ │ │ │ +
    66 ScalarVectorView (K* p) :
    │ │ │ │ +
    67 dataP_(p)
    │ │ │ │ +
    68 {}
    │ │ │ │ +
    69
    │ │ │ │ +
    71 ScalarVectorView (const ScalarVectorView &other) :
    │ │ │ │ +
    72 Base(),
    │ │ │ │ +
    73 dataP_(other.dataP_)
    │ │ │ │ +
    74 {}
    │ │ │ │ +
    75
    │ │ │ │ +
    77 ScalarVectorView (ScalarVectorView &&other) :
    │ │ │ │ +
    78 Base(),
    │ │ │ │ +
    79 dataP_( other.dataP_ )
    │ │ │ │ +
    80 {}
    │ │ │ │ +
    81
    │ │ │ │ +
    83 ScalarVectorView& operator= (const ScalarVectorView& other)
    │ │ │ │ +
    84 {
    │ │ │ │ +
    85 assert(dataP_);
    │ │ │ │ +
    86 assert(other.dataP_);
    │ │ │ │ +
    87 *dataP_ = *(other.dataP_);
    │ │ │ │ +
    88 return *this;
    │ │ │ │ +
    89 }
    │ │ │ │ +
    90
    │ │ │ │ +
    91 template<class KK>
    │ │ │ │ +
    92 ScalarVectorView& operator= (const ScalarVectorView<KK>& other)
    │ │ │ │ +
    93 {
    │ │ │ │ +
    94 assert(dataP_);
    │ │ │ │ +
    95 assert(other.dataP_);
    │ │ │ │ +
    96 *dataP_ = *(other.dataP_);
    │ │ │ │ +
    97 return *this;
    │ │ │ │ +
    98 }
    │ │ │ │ +
    99
    │ │ │ │ +
    101 template<typename T,
    │ │ │ │ +
    102 std::enable_if_t<std::is_convertible<T, K>::value, int> = 0>
    │ │ │ │ +
    103 inline ScalarVectorView& operator= (const T& k)
    │ │ │ │ +
    104 {
    │ │ │ │ +
    105 *dataP_ = k;
    │ │ │ │ +
    106 return *this;
    │ │ │ │ +
    107 }
    │ │ │ │ +
    108
    │ │ │ │ +
    110 static constexpr size_type size ()
    │ │ │ │ +
    111 {
    │ │ │ │ +
    112 return 1;
    │ │ │ │ +
    113 }
    │ │ │ │ +
    114
    │ │ │ │ +
    116 K& operator[] ([[maybe_unused]] size_type i)
    │ │ │ │ +
    117 {
    │ │ │ │ +
    118 DUNE_ASSERT_BOUNDS(i == 0);
    │ │ │ │ +
    119 return *dataP_;
    │ │ │ │ +
    120 }
    │ │ │ │ +
    121
    │ │ │ │ +
    123 const K& operator[] ([[maybe_unused]] size_type i) const
    │ │ │ │ +
    124 {
    │ │ │ │ +
    125 DUNE_ASSERT_BOUNDS(i == 0);
    │ │ │ │ +
    126 return *dataP_;
    │ │ │ │ +
    127 }
    │ │ │ │ +
    128 }; // class ScalarVectorView
    │ │ │ │ +
    129
    │ │ │ │ +
    130} // namespace Impl
    │ │ │ │ +
    131
    │ │ │ │ +
    132
    │ │ │ │ +
    133 template< class K>
    │ │ │ │ +
    134 struct DenseMatVecTraits< Impl::ScalarVectorView<K> >
    │ │ │ │ +
    135 {
    │ │ │ │ +
    136 using derived_type = Impl::ScalarVectorView<K>;
    │ │ │ │ +
    137 using value_type = std::remove_const_t<K>;
    │ │ │ │ +
    138 using size_type = std::size_t;
    │ │ │ │ +
    139 };
    │ │ │ │ +
    140
    │ │ │ │ +
    141 template< class K >
    │ │ │ │ +
    142 struct FieldTraits< Impl::ScalarVectorView<K> > : public FieldTraits<std::remove_const_t<K>> {};
    │ │ │ │ +
    143
    │ │ │ │ +
    144 template<class K>
    │ │ │ │ +
    145 struct AutonomousValueType<Impl::ScalarVectorView<K>>
    │ │ │ │ +
    146 {
    │ │ │ │ +
    147 using type = FieldVector<std::remove_const_t<K>,1>;
    │ │ │ │ +
    148 };
    │ │ │ │ +
    149
    │ │ │ │ +
    150namespace Impl {
    │ │ │ │ +
    151
    │ │ │ │ +
    163 template<class K>
    │ │ │ │ +
    164 inline std::istream &operator>> ( std::istream &in, ScalarVectorView<K> &v )
    │ │ │ │ +
    165 {
    │ │ │ │ +
    166 K w;
    │ │ │ │ +
    167 if(in >> w)
    │ │ │ │ +
    168 v = w;
    │ │ │ │ +
    169 return in;
    │ │ │ │ +
    170 }
    │ │ │ │ +
    171
    │ │ │ │ +
    172
    │ │ │ │ +
    174 template<class T,
    │ │ │ │ +
    175 std::enable_if_t<IsNumber<T>::value, int> = 0>
    │ │ │ │ +
    176 auto asVector(T& t)
    │ │ │ │ +
    177 {
    │ │ │ │ +
    178 return ScalarVectorView<T>{&t};
    │ │ │ │ +
    179 }
    │ │ │ │ +
    180
    │ │ │ │ +
    182 template<class T,
    │ │ │ │ +
    183 std::enable_if_t<IsNumber<T>::value, int> = 0>
    │ │ │ │ +
    184 auto asVector(const T& t)
    │ │ │ │ +
    185 {
    │ │ │ │ +
    186 return ScalarVectorView<const T>{&t};
    │ │ │ │ +
    187 }
    │ │ │ │ +
    188
    │ │ │ │ +
    190 template<class T,
    │ │ │ │ +
    191 std::enable_if_t<not IsNumber<T>::value, int> = 0>
    │ │ │ │ +
    192 T& asVector(T& t)
    │ │ │ │ +
    193 {
    │ │ │ │ +
    194 return t;
    │ │ │ │ +
    195 }
    │ │ │ │ +
    196
    │ │ │ │ +
    198 template<class T,
    │ │ │ │ +
    199 std::enable_if_t<not IsNumber<T>::value, int> = 0>
    │ │ │ │ +
    200 const T& asVector(const T& t)
    │ │ │ │ +
    201 {
    │ │ │ │ +
    202 return t;
    │ │ │ │ +
    203 }
    │ │ │ │ +
    204
    │ │ │ │ +
    205} // end namespace Impl
    │ │ │ │ +
    206
    │ │ │ │ +
    207} // end namespace Dune
    │ │ │ │ +
    208
    │ │ │ │ +
    209#endif // DUNE_COMMON_SCALARVECTORVIEW_HH
    │ │ │ │ +
    Documentation of the traits classes you need to write for each implementation of DenseVector or Dense...
    │ │ │ │ +
    Implements a vector constructed from a given type representing a field and a compile-time given size.
    │ │ │ │ +
    Implements the dense vector interface, with an exchangeable storage class.
    │ │ │ │ +
    Traits for type conversions and type information.
    │ │ │ │ +
    Stream & operator>>(Stream &stream, std::tuple< Ts... > &t)
    Read a std::tuple.
    Definition streamoperators.hh:43
    │ │ │ │ +
    #define DUNE_ASSERT_BOUNDS(cond)
    If DUNE_CHECK_BOUNDS is defined: check if condition cond holds; otherwise, do nothing.
    Definition boundschecking.hh:30
    │ │ │ │
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ -
    @ implementationDefined
    Definition documentation.hh:55
    │ │ │ │ -
    Dummy struct used for documentation purposes.
    Definition documentation.hh:42
    │ │ │ │ +
    size_type size() const
    size method
    Definition densevector.hh:336
    │ │ │ │ +
    Traits::size_type size_type
    The type used for the index access and size operation.
    Definition densevector.hh:259
    │ │ │ │ +
    T type
    Definition typetraits.hh:501
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,40 +7,215 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -documentation.hh │ │ │ │ │ +scalarvectorview.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 (C) 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_DOCUMENTATION_HH │ │ │ │ │ - 7#define DUNE_COMMON_DOCUMENTATION_HH │ │ │ │ │ - 8 │ │ │ │ │ - 13namespace Dune { │ │ │ │ │ - 14 │ │ │ │ │ -42 struct ImplementationDefined {}; │ │ │ │ │ - 43 │ │ │ │ │ -55 enum { implementationDefined }; │ │ │ │ │ - 56 │ │ │ │ │ - 57} │ │ │ │ │ - 58 │ │ │ │ │ + 5#ifndef DUNE_COMMON_SCALARVECTORVIEW_HH │ │ │ │ │ + 6#define DUNE_COMMON_SCALARVECTORVIEW_HH │ │ │ │ │ + 7 │ │ │ │ │ + 8#include │ │ │ │ │ + 9#include │ │ │ │ │ + 10#include │ │ │ │ │ + 11 │ │ │ │ │ + 12#include │ │ │ │ │ + 13#include │ │ │ │ │ + 14#include │ │ │ │ │ + 15#include │ │ │ │ │ + 16 │ │ │ │ │ + 17namespace Dune { │ │ │ │ │ + 18 │ │ │ │ │ + 19namespace Impl { │ │ │ │ │ + 20 │ │ │ │ │ + 35 template │ │ │ │ │ + 36 class ScalarVectorView : │ │ │ │ │ + 37 public DenseVector> │ │ │ │ │ + 38 { │ │ │ │ │ + 39 K* dataP_; │ │ │ │ │ + 40 using Base = DenseVector>; │ │ │ │ │ + 41 │ │ │ │ │ + 42 template │ │ │ │ │ + 43 friend class ScalarVectorView; │ │ │ │ │ + 44 public: │ │ │ │ │ + 45 │ │ │ │ │ + 47 constexpr static int dimension = 1; │ │ │ │ │ + 48 │ │ │ │ │ + 50 using size_type = typename Base::size_type; │ │ │ │ │ + 51 │ │ │ │ │ + 53 using reference = std::decay_t&; │ │ │ │ │ + 54 │ │ │ │ │ + 56 using const_reference = const K&; │ │ │ │ │ + 57 │ │ │ │ │ + 58 //===== construction │ │ │ │ │ 59 │ │ │ │ │ - 60#endif // DUNE_COMMON_DOCUMENTATION_HH │ │ │ │ │ + 61 constexpr ScalarVectorView () │ │ │ │ │ + 62 : dataP_(nullptr) │ │ │ │ │ + 63 {} │ │ │ │ │ + 64 │ │ │ │ │ + 66 ScalarVectorView (K* p) : │ │ │ │ │ + 67 dataP_(p) │ │ │ │ │ + 68 {} │ │ │ │ │ + 69 │ │ │ │ │ + 71 ScalarVectorView (const ScalarVectorView &other) : │ │ │ │ │ + 72 Base(), │ │ │ │ │ + 73 dataP_(other.dataP_) │ │ │ │ │ + 74 {} │ │ │ │ │ + 75 │ │ │ │ │ + 77 ScalarVectorView (ScalarVectorView &&other) : │ │ │ │ │ + 78 Base(), │ │ │ │ │ + 79 dataP_( other.dataP_ ) │ │ │ │ │ + 80 {} │ │ │ │ │ + 81 │ │ │ │ │ + 83 ScalarVectorView& operator= (const ScalarVectorView& other) │ │ │ │ │ + 84 { │ │ │ │ │ + 85 assert(dataP_); │ │ │ │ │ + 86 assert(other.dataP_); │ │ │ │ │ + 87 *dataP_ = *(other.dataP_); │ │ │ │ │ + 88 return *this; │ │ │ │ │ + 89 } │ │ │ │ │ + 90 │ │ │ │ │ + 91 template │ │ │ │ │ + 92 ScalarVectorView& operator= (const ScalarVectorView& other) │ │ │ │ │ + 93 { │ │ │ │ │ + 94 assert(dataP_); │ │ │ │ │ + 95 assert(other.dataP_); │ │ │ │ │ + 96 *dataP_ = *(other.dataP_); │ │ │ │ │ + 97 return *this; │ │ │ │ │ + 98 } │ │ │ │ │ + 99 │ │ │ │ │ + 101 template::value, int> = 0> │ │ │ │ │ + 103 inline ScalarVectorView& operator= (const T& k) │ │ │ │ │ + 104 { │ │ │ │ │ + 105 *dataP_ = k; │ │ │ │ │ + 106 return *this; │ │ │ │ │ + 107 } │ │ │ │ │ + 108 │ │ │ │ │ + 110 static constexpr size_type size () │ │ │ │ │ + 111 { │ │ │ │ │ + 112 return 1; │ │ │ │ │ + 113 } │ │ │ │ │ + 114 │ │ │ │ │ + 116 K& operator[] ([[maybe_unused]] size_type i) │ │ │ │ │ + 117 { │ │ │ │ │ + 118 DUNE_ASSERT_BOUNDS(i == 0); │ │ │ │ │ + 119 return *dataP_; │ │ │ │ │ + 120 } │ │ │ │ │ + 121 │ │ │ │ │ + 123 const K& operator[] ([[maybe_unused]] size_type i) const │ │ │ │ │ + 124 { │ │ │ │ │ + 125 DUNE_ASSERT_BOUNDS(i == 0); │ │ │ │ │ + 126 return *dataP_; │ │ │ │ │ + 127 } │ │ │ │ │ + 128 }; // class ScalarVectorView │ │ │ │ │ + 129 │ │ │ │ │ + 130} // namespace Impl │ │ │ │ │ + 131 │ │ │ │ │ + 132 │ │ │ │ │ + 133 template< class K> │ │ │ │ │ + 134 struct DenseMatVecTraits< Impl::ScalarVectorView > │ │ │ │ │ + 135 { │ │ │ │ │ + 136 using derived_type = Impl::ScalarVectorView; │ │ │ │ │ + 137 using value_type = std::remove_const_t; │ │ │ │ │ + 138 using size_type = std::size_t; │ │ │ │ │ + 139 }; │ │ │ │ │ + 140 │ │ │ │ │ + 141 template< class K > │ │ │ │ │ + 142 struct FieldTraits< Impl::ScalarVectorView > : public FieldTraits> {}; │ │ │ │ │ + 143 │ │ │ │ │ + 144 template │ │ │ │ │ + 145 struct AutonomousValueType> │ │ │ │ │ + 146 { │ │ │ │ │ + 147 using type = FieldVector,1>; │ │ │ │ │ + 148 }; │ │ │ │ │ + 149 │ │ │ │ │ + 150namespace Impl { │ │ │ │ │ + 151 │ │ │ │ │ + 163 template │ │ │ │ │ + 164 inline std::istream &operator>>( std::istream &in, ScalarVectorView &v │ │ │ │ │ +) │ │ │ │ │ + 165 { │ │ │ │ │ + 166 K w; │ │ │ │ │ + 167 if(in >> w) │ │ │ │ │ + 168 v = w; │ │ │ │ │ + 169 return in; │ │ │ │ │ + 170 } │ │ │ │ │ + 171 │ │ │ │ │ + 172 │ │ │ │ │ + 174 template::value, int> = 0> │ │ │ │ │ + 176 auto asVector(T& t) │ │ │ │ │ + 177 { │ │ │ │ │ + 178 return ScalarVectorView{&t}; │ │ │ │ │ + 179 } │ │ │ │ │ + 180 │ │ │ │ │ + 182 template::value, int> = 0> │ │ │ │ │ + 184 auto asVector(const T& t) │ │ │ │ │ + 185 { │ │ │ │ │ + 186 return ScalarVectorView{&t}; │ │ │ │ │ + 187 } │ │ │ │ │ + 188 │ │ │ │ │ + 190 template::value, int> = 0> │ │ │ │ │ + 192 T& asVector(T& t) │ │ │ │ │ + 193 { │ │ │ │ │ + 194 return t; │ │ │ │ │ + 195 } │ │ │ │ │ + 196 │ │ │ │ │ + 198 template::value, int> = 0> │ │ │ │ │ + 200 const T& asVector(const T& t) │ │ │ │ │ + 201 { │ │ │ │ │ + 202 return t; │ │ │ │ │ + 203 } │ │ │ │ │ + 204 │ │ │ │ │ + 205} // end namespace Impl │ │ │ │ │ + 206 │ │ │ │ │ + 207} // end namespace Dune │ │ │ │ │ + 208 │ │ │ │ │ + 209#endif // DUNE_COMMON_SCALARVECTORVIEW_HH │ │ │ │ │ +matvectraits.hh │ │ │ │ │ +Documentation of the traits classes you need to write for each implementation │ │ │ │ │ +of DenseVector or Dense... │ │ │ │ │ +fvector.hh │ │ │ │ │ +Implements a vector constructed from a given type representing a field and a │ │ │ │ │ +compile-time given size. │ │ │ │ │ +densevector.hh │ │ │ │ │ +Implements the dense vector interface, with an exchangeable storage class. │ │ │ │ │ +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_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 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::implementationDefined │ │ │ │ │ -@ implementationDefined │ │ │ │ │ -Definition documentation.hh:55 │ │ │ │ │ -Dune::ImplementationDefined │ │ │ │ │ -Dummy struct used for documentation purposes. │ │ │ │ │ -Definition documentation.hh:42 │ │ │ │ │ +Dune::DenseVector<_ScalarVectorView<_K_>_>::size │ │ │ │ │ +size_type size() const │ │ │ │ │ +size method │ │ │ │ │ +Definition densevector.hh:336 │ │ │ │ │ +Dune::DenseVector<_ScalarVectorView<_K_>_>::size_type │ │ │ │ │ +Traits::size_type size_type │ │ │ │ │ +The type used for the index access and size operation. │ │ │ │ │ +Definition densevector.hh:259 │ │ │ │ │ +Dune::AutonomousValueType::type │ │ │ │ │ +T type │ │ │ │ │ +Definition typetraits.hh:501 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00143.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: unused.hh File Reference │ │ │ │ +dune-common: densematrix.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,31 +70,73 @@ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ -Macros
    │ │ │ │ -
    unused.hh File Reference
    │ │ │ │ +Classes | │ │ │ │ +Namespaces | │ │ │ │ +Functions
    │ │ │ │ +
    densematrix.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ -

    Definition of the DUNE_UNUSED_PARAMETER macro. │ │ │ │ +

    Implements a matrix constructed from a given type representing a field and a compile-time given number of rows and columns. │ │ │ │ More...

    │ │ │ │ - │ │ │ │ +
    #include <cmath>
    │ │ │ │ +#include <cstddef>
    │ │ │ │ +#include <iostream>
    │ │ │ │ +#include <type_traits>
    │ │ │ │ +#include <utility>
    │ │ │ │ +#include <vector>
    │ │ │ │ +#include <dune/common/boundschecking.hh>
    │ │ │ │ +#include <dune/common/classname.hh>
    │ │ │ │ +#include <dune/common/exceptions.hh>
    │ │ │ │ +#include <dune/common/fvector.hh>
    │ │ │ │ +#include <dune/common/math.hh>
    │ │ │ │ +#include <dune/common/precision.hh>
    │ │ │ │ +#include <dune/common/simd/simd.hh>
    │ │ │ │ +#include <dune/common/typetraits.hh>
    │ │ │ │ +#include <dune/common/scalarvectorview.hh>
    │ │ │ │ +
    │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ -Macros

    #define DUNE_UNUSED_PARAMETER(param)   static_cast<void>(param)
     

    │ │ │ │ +Classes

    struct  Dune::FieldTraits< DenseMatrix< M > >
     
    class  Dune::FMatrixError
     Error thrown if operations of a FieldMatrix fail. More...
     
    class  Dune::DenseMatrix< MAT >
     A dense n x m matrix. More...
     
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

    │ │ │ │ +Namespaces

    namespace  Dune
     Dune namespace.
     
    namespace  Dune::DenseMatrixHelp
     
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

    │ │ │ │ +Functions

    template<typename MAT , typename V1 , typename V2 >
    static void Dune::DenseMatrixHelp::multAssign (const DenseMatrix< MAT > &matrix, const DenseVector< V1 > &x, DenseVector< V2 > &ret)
     calculates ret = matrix * x
     
    template<typename MAT >
    std::ostream & Dune::operator<< (std::ostream &s, const DenseMatrix< MAT > &a)
     Sends the matrix to an output stream.
     
    │ │ │ │

    Detailed Description

    │ │ │ │ -

    Definition of the DUNE_UNUSED_PARAMETER macro.

    │ │ │ │ +

    Implements a matrix constructed from a given type representing a field and a compile-time given number of rows and columns.

    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,19 +6,59 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Macros │ │ │ │ │ -unused.hh File Reference │ │ │ │ │ -Definition of the DUNE_UNUSED_PARAMETER macro. More... │ │ │ │ │ +Classes | Namespaces | Functions │ │ │ │ │ +densematrix.hh File Reference │ │ │ │ │ +Common » Dense_Matrix_and_Vector_Template_Library │ │ │ │ │ +Implements a matrix constructed from a given type representing a field and a │ │ │ │ │ +compile-time given number of rows and columns. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ - Macros │ │ │ │ │ -#define DUNE_UNUSED_PARAMETER(param)   static_cast(param) │ │ │ │ │ + Classes │ │ │ │ │ +struct  Dune::FieldTraits<_DenseMatrix<_M_>_> │ │ │ │ │ +  │ │ │ │ │ + class  Dune::FMatrixError │ │ │ │ │ +  Error thrown if operations of a FieldMatrix fail. More... │ │ │ │ │ +  │ │ │ │ │ + class  Dune::DenseMatrix<_MAT_> │ │ │ │ │ +  A dense n x m matrix. More... │ │ │ │ │ +  │ │ │ │ │ + Namespaces │ │ │ │ │ +namespace  Dune │ │ │ │ │ +  Dune namespace. │ │ │ │ │ +  │ │ │ │ │ +namespace  Dune::DenseMatrixHelp │ │ │ │ │ +  │ │ │ │ │ + Functions │ │ │ │ │ +template │ │ │ │ │ + static void Dune::DenseMatrixHelp::multAssign (const DenseMatrix< MAT > │ │ │ │ │ + &matrix, const DenseVector< V1 > &x, DenseVector< V2 > &ret) │ │ │ │ │ +  calculates ret = matrix * x │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +std::ostream & Dune::operator<< (std::ostream &s, const DenseMatrix< MAT > &a) │ │ │ │ │ +  Sends the matrix to an output stream. │ │ │ │ │   │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Definition of the DUNE_UNUSED_PARAMETER macro. │ │ │ │ │ +Implements a matrix constructed from a given type representing a field and a │ │ │ │ │ +compile-time given number of rows and columns. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00143_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: unused.hh Source File │ │ │ │ +dune-common: densematrix.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,26 +74,1304 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    unused.hh
    │ │ │ │ +
    densematrix.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 (C) 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_UNUSED_HH
    │ │ │ │ -
    6#define DUNE_COMMON_UNUSED_HH
    │ │ │ │ +
    5#ifndef DUNE_DENSEMATRIX_HH
    │ │ │ │ +
    6#define DUNE_DENSEMATRIX_HH
    │ │ │ │
    7
    │ │ │ │ -
    21#define DUNE_UNUSED_PARAMETER(param) static_cast<void>(param)
    │ │ │ │ -
    22#endif
    │ │ │ │ +
    8#include <cmath>
    │ │ │ │ +
    9#include <cstddef>
    │ │ │ │ +
    10#include <iostream>
    │ │ │ │ +
    11#include <type_traits>
    │ │ │ │ +
    12#include <utility>
    │ │ │ │ +
    13#include <vector>
    │ │ │ │ +
    14
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    19#include <dune/common/math.hh>
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    24
    │ │ │ │ +
    25namespace Dune
    │ │ │ │ +
    26{
    │ │ │ │ +
    27
    │ │ │ │ +
    28 template<typename M> class DenseMatrix;
    │ │ │ │ +
    29
    │ │ │ │ +
    30 template<typename M>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    32 {
    │ │ │ │ + │ │ │ │ + │ │ │ │ +
    35 };
    │ │ │ │ +
    │ │ │ │ +
    36
    │ │ │ │ +
    37 template<class K, int N, int M> class FieldMatrix;
    │ │ │ │ +
    38 template<class K, int N> class FieldVector;
    │ │ │ │ +
    39
    │ │ │ │ +
    58 template< class DenseMatrix, class RHS >
    │ │ │ │ + │ │ │ │ +
    60
    │ │ │ │ +
    61#ifndef DOXYGEN
    │ │ │ │ +
    62 namespace Impl
    │ │ │ │ +
    63 {
    │ │ │ │ +
    64
    │ │ │ │ +
    65 template< class DenseMatrix, class RHS, class = void >
    │ │ │ │ + │ │ │ │ +
    67 {};
    │ │ │ │ +
    68
    │ │ │ │ +
    69 template< class DenseMatrix, class RHS >
    │ │ │ │ +
    70 class DenseMatrixAssigner< DenseMatrix, RHS, std::enable_if_t< Dune::IsNumber< RHS >::value > >
    │ │ │ │ +
    71 {
    │ │ │ │ +
    72 public:
    │ │ │ │ +
    73 static void apply ( DenseMatrix &denseMatrix, const RHS &rhs )
    │ │ │ │ +
    74 {
    │ │ │ │ +
    75 typedef typename DenseMatrix::field_type field_type;
    │ │ │ │ +
    76 std::fill( denseMatrix.begin(), denseMatrix.end(), static_cast< field_type >( rhs ) );
    │ │ │ │ +
    77 }
    │ │ │ │ +
    78 };
    │ │ │ │ +
    79
    │ │ │ │ +
    80 template< class DenseMatrix, class RHS >
    │ │ │ │ +
    81 class DenseMatrixAssigner< DenseMatrix, RHS, std::enable_if_t< !std::is_same< typename RHS::const_iterator, void >::value
    │ │ │ │ +
    82 && std::is_convertible< typename RHS::const_iterator::value_type, typename DenseMatrix::iterator::value_type >::value > >
    │ │ │ │ +
    83 {
    │ │ │ │ +
    84 public:
    │ │ │ │ +
    85 static void apply ( DenseMatrix &denseMatrix, const RHS &rhs )
    │ │ │ │ +
    86 {
    │ │ │ │ +
    87 DUNE_ASSERT_BOUNDS(rhs.N() == denseMatrix.N());
    │ │ │ │ +
    88 DUNE_ASSERT_BOUNDS(rhs.M() == denseMatrix.M());
    │ │ │ │ +
    89 typename DenseMatrix::iterator tIt = std::begin(denseMatrix);
    │ │ │ │ +
    90 typename RHS::const_iterator sIt = std::begin(rhs);
    │ │ │ │ +
    91 for(; sIt != std::end(rhs); ++tIt, ++sIt)
    │ │ │ │ +
    92 std::copy(std::begin(*sIt), std::end(*sIt), std::begin(*tIt));
    │ │ │ │ +
    93 }
    │ │ │ │ +
    94 };
    │ │ │ │ +
    95
    │ │ │ │ +
    96 } // namespace Impl
    │ │ │ │ +
    97
    │ │ │ │ +
    98
    │ │ │ │ +
    99
    │ │ │ │ +
    100 template< class DenseMatrix, class RHS >
    │ │ │ │ +
    101 struct DenseMatrixAssigner
    │ │ │ │ +
    102 : public Impl::DenseMatrixAssigner< DenseMatrix, RHS >
    │ │ │ │ +
    103 {};
    │ │ │ │ +
    104
    │ │ │ │ +
    105
    │ │ │ │ +
    106 namespace Impl
    │ │ │ │ +
    107 {
    │ │ │ │ +
    108
    │ │ │ │ +
    109 template< class DenseMatrix, class RHS >
    │ │ │ │ +
    110 std::true_type hasDenseMatrixAssigner ( DenseMatrix &, const RHS &, decltype( Dune::DenseMatrixAssigner< DenseMatrix, RHS >::apply( std::declval< DenseMatrix & >(), std::declval< const RHS & >() ) ) * = nullptr );
    │ │ │ │ +
    111
    │ │ │ │ +
    112 std::false_type hasDenseMatrixAssigner ( ... );
    │ │ │ │ +
    113
    │ │ │ │ +
    114 } // namespace Impl
    │ │ │ │ +
    115
    │ │ │ │ +
    116 template< class DenseMatrix, class RHS >
    │ │ │ │ +
    117 struct HasDenseMatrixAssigner
    │ │ │ │ +
    118 : public decltype( Impl::hasDenseMatrixAssigner( std::declval< DenseMatrix & >(), std::declval< const RHS & >() ) )
    │ │ │ │ +
    119 {};
    │ │ │ │ +
    120
    │ │ │ │ +
    121#endif // #ifndef DOXYGEN
    │ │ │ │ +
    122
    │ │ │ │ +
    123
    │ │ │ │ +
    124
    │ │ │ │ +
    126 class FMatrixError : public MathError {};
    │ │ │ │ +
    127
    │ │ │ │ +
    138 template<typename MAT>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    140 {
    │ │ │ │ + │ │ │ │ +
    142
    │ │ │ │ +
    143 // Curiously recurring template pattern
    │ │ │ │ +
    144 constexpr MAT & asImp() { return static_cast<MAT&>(*this); }
    │ │ │ │ +
    145 constexpr const MAT & asImp() const { return static_cast<const MAT&>(*this); }
    │ │ │ │ +
    146
    │ │ │ │ +
    147 template <class>
    │ │ │ │ +
    148 friend class DenseMatrix;
    │ │ │ │ +
    149
    │ │ │ │ +
    150 public:
    │ │ │ │ +
    151 //===== type definitions and constants
    │ │ │ │ +
    152
    │ │ │ │ +
    154 typedef typename Traits::derived_type derived_type;
    │ │ │ │ +
    155
    │ │ │ │ +
    157 typedef typename Traits::value_type value_type;
    │ │ │ │ +
    158
    │ │ │ │ +
    160 typedef typename Traits::value_type field_type;
    │ │ │ │ +
    161
    │ │ │ │ +
    163 typedef typename Traits::value_type block_type;
    │ │ │ │ +
    164
    │ │ │ │ +
    166 typedef typename Traits::size_type size_type;
    │ │ │ │ +
    167
    │ │ │ │ +
    169 typedef typename Traits::row_type row_type;
    │ │ │ │ +
    170
    │ │ │ │ +
    172 typedef typename Traits::row_reference row_reference;
    │ │ │ │ +
    173
    │ │ │ │ +
    175 typedef typename Traits::const_row_reference const_row_reference;
    │ │ │ │ +
    176
    │ │ │ │ +
    178 constexpr static int blocklevel = 1;
    │ │ │ │ +
    179
    │ │ │ │ +
    180 private:
    │ │ │ │ +
    183 using simd_index_type = Simd::Rebind<std::size_t, value_type>;
    │ │ │ │ +
    184
    │ │ │ │ +
    185 public:
    │ │ │ │ +
    186 //===== access to components
    │ │ │ │ +
    187
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    190 {
    │ │ │ │ +
    191 return asImp().mat_access(i);
    │ │ │ │ +
    192 }
    │ │ │ │ +
    │ │ │ │ +
    193
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    195 {
    │ │ │ │ +
    196 return asImp().mat_access(i);
    │ │ │ │ +
    197 }
    │ │ │ │ +
    │ │ │ │ +
    198
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    201 {
    │ │ │ │ +
    202 return rows();
    │ │ │ │ +
    203 }
    │ │ │ │ +
    │ │ │ │ +
    204
    │ │ │ │ +
    205 //===== iterator interface to rows of the matrix
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    213 typedef typename std::remove_reference<row_reference>::type::Iterator ColIterator;
    │ │ │ │ +
    214
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    217 {
    │ │ │ │ +
    218 return Iterator(*this,0);
    │ │ │ │ +
    219 }
    │ │ │ │ +
    │ │ │ │ +
    220
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    223 {
    │ │ │ │ +
    224 return Iterator(*this,rows());
    │ │ │ │ +
    225 }
    │ │ │ │ +
    │ │ │ │ +
    226
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    230 {
    │ │ │ │ +
    231 return Iterator(*this,rows()-1);
    │ │ │ │ +
    232 }
    │ │ │ │ +
    │ │ │ │ +
    233
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    237 {
    │ │ │ │ +
    238 return Iterator(*this,-1);
    │ │ │ │ +
    239 }
    │ │ │ │ +
    │ │ │ │ +
    240
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    248 typedef typename std::remove_reference<const_row_reference>::type::ConstIterator ConstColIterator;
    │ │ │ │ +
    249
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    252 {
    │ │ │ │ +
    253 return ConstIterator(*this,0);
    │ │ │ │ +
    254 }
    │ │ │ │ +
    │ │ │ │ +
    255
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    258 {
    │ │ │ │ +
    259 return ConstIterator(*this,rows());
    │ │ │ │ +
    260 }
    │ │ │ │ +
    │ │ │ │ +
    261
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    265 {
    │ │ │ │ +
    266 return ConstIterator(*this,rows()-1);
    │ │ │ │ +
    267 }
    │ │ │ │ +
    │ │ │ │ +
    268
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    272 {
    │ │ │ │ +
    273 return ConstIterator(*this,-1);
    │ │ │ │ +
    274 }
    │ │ │ │ +
    │ │ │ │ +
    275
    │ │ │ │ +
    276 //===== assignment
    │ │ │ │ +
    277
    │ │ │ │ +
    278 template< class RHS, class = std::enable_if_t< HasDenseMatrixAssigner< MAT, RHS >::value > >
    │ │ │ │ +
    │ │ │ │ +
    279 derived_type &operator= ( const RHS &rhs )
    │ │ │ │ +
    280 {
    │ │ │ │ + │ │ │ │ +
    282 return asImp();
    │ │ │ │ +
    283 }
    │ │ │ │ +
    │ │ │ │ +
    284
    │ │ │ │ +
    285 //===== vector space arithmetic
    │ │ │ │ +
    286
    │ │ │ │ +
    288 template <class Other>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    290 {
    │ │ │ │ +
    291 DUNE_ASSERT_BOUNDS(rows() == x.rows());
    │ │ │ │ +
    292 for (size_type i=0; i<rows(); i++)
    │ │ │ │ +
    293 (*this)[i] += x[i];
    │ │ │ │ +
    294 return asImp();
    │ │ │ │ +
    295 }
    │ │ │ │ +
    │ │ │ │ +
    296
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    299 {
    │ │ │ │ +
    300 MAT result;
    │ │ │ │ +
    301 using idx_type = typename decltype(result)::size_type;
    │ │ │ │ +
    302
    │ │ │ │ +
    303 for (idx_type i = 0; i < rows(); ++i)
    │ │ │ │ +
    304 for (idx_type j = 0; j < cols(); ++j)
    │ │ │ │ +
    305 result[i][j] = - asImp()[i][j];
    │ │ │ │ +
    306
    │ │ │ │ +
    307 return result;
    │ │ │ │ +
    308 }
    │ │ │ │ +
    │ │ │ │ +
    309
    │ │ │ │ +
    311 template <class Other>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    313 {
    │ │ │ │ +
    314 DUNE_ASSERT_BOUNDS(rows() == x.rows());
    │ │ │ │ +
    315 for (size_type i=0; i<rows(); i++)
    │ │ │ │ +
    316 (*this)[i] -= x[i];
    │ │ │ │ +
    317 return asImp();
    │ │ │ │ +
    318 }
    │ │ │ │ +
    │ │ │ │ +
    319
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    322 {
    │ │ │ │ +
    323 for (size_type i=0; i<rows(); i++)
    │ │ │ │ +
    324 (*this)[i] *= k;
    │ │ │ │ +
    325 return asImp();
    │ │ │ │ +
    326 }
    │ │ │ │ +
    │ │ │ │ +
    327
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    330 {
    │ │ │ │ +
    331 for (size_type i=0; i<rows(); i++)
    │ │ │ │ +
    332 (*this)[i] /= k;
    │ │ │ │ +
    333 return asImp();
    │ │ │ │ +
    334 }
    │ │ │ │ +
    │ │ │ │ +
    335
    │ │ │ │ +
    337 template <class Other>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    339 {
    │ │ │ │ +
    340 DUNE_ASSERT_BOUNDS(rows() == x.rows());
    │ │ │ │ +
    341 for( size_type i = 0; i < rows(); ++i )
    │ │ │ │ +
    342 (*this)[ i ].axpy( a, x[ i ] );
    │ │ │ │ +
    343 return asImp();
    │ │ │ │ +
    344 }
    │ │ │ │ +
    │ │ │ │ +
    345
    │ │ │ │ +
    347 template <class Other>
    │ │ │ │ +
    │ │ │ │ +
    348 bool operator== (const DenseMatrix<Other>& x) const
    │ │ │ │ +
    349 {
    │ │ │ │ +
    350 DUNE_ASSERT_BOUNDS(rows() == x.rows());
    │ │ │ │ +
    351 for (size_type i=0; i<rows(); i++)
    │ │ │ │ +
    352 if ((*this)[i]!=x[i])
    │ │ │ │ +
    353 return false;
    │ │ │ │ +
    354 return true;
    │ │ │ │ +
    355 }
    │ │ │ │ +
    │ │ │ │ +
    357 template <class Other>
    │ │ │ │ +
    │ │ │ │ +
    358 bool operator!= (const DenseMatrix<Other>& x) const
    │ │ │ │ +
    359 {
    │ │ │ │ +
    360 return !operator==(x);
    │ │ │ │ +
    361 }
    │ │ │ │ +
    │ │ │ │ +
    362
    │ │ │ │ +
    363
    │ │ │ │ +
    364 //===== linear maps
    │ │ │ │ +
    365
    │ │ │ │ +
    367 template<class X, class Y>
    │ │ │ │ +
    │ │ │ │ +
    368 void mv (const X& x, Y& y) const
    │ │ │ │ +
    369 {
    │ │ │ │ +
    370 auto&& xx = Impl::asVector(x);
    │ │ │ │ +
    371 auto&& yy = Impl::asVector(y);
    │ │ │ │ +
    372 DUNE_ASSERT_BOUNDS((void*)(&x) != (void*)(&y));
    │ │ │ │ +
    373 DUNE_ASSERT_BOUNDS(xx.N() == M());
    │ │ │ │ +
    374 DUNE_ASSERT_BOUNDS(yy.N() == N());
    │ │ │ │ +
    375
    │ │ │ │ +
    376 using y_field_type = typename FieldTraits<Y>::field_type;
    │ │ │ │ +
    377 for (size_type i=0; i<rows(); ++i)
    │ │ │ │ +
    378 {
    │ │ │ │ +
    379 yy[i] = y_field_type(0);
    │ │ │ │ +
    380 for (size_type j=0; j<cols(); j++)
    │ │ │ │ +
    381 yy[i] += (*this)[i][j] * xx[j];
    │ │ │ │ +
    382 }
    │ │ │ │ +
    383 }
    │ │ │ │ +
    │ │ │ │ +
    384
    │ │ │ │ +
    386 template< class X, class Y >
    │ │ │ │ +
    │ │ │ │ +
    387 void mtv ( const X &x, Y &y ) const
    │ │ │ │ +
    388 {
    │ │ │ │ +
    389 auto&& xx = Impl::asVector(x);
    │ │ │ │ +
    390 auto&& yy = Impl::asVector(y);
    │ │ │ │ +
    391 DUNE_ASSERT_BOUNDS((void*)(&x) != (void*)(&y));
    │ │ │ │ +
    392 DUNE_ASSERT_BOUNDS(xx.N() == N());
    │ │ │ │ +
    393 DUNE_ASSERT_BOUNDS(yy.N() == M());
    │ │ │ │ +
    394
    │ │ │ │ +
    395 using y_field_type = typename FieldTraits<Y>::field_type;
    │ │ │ │ +
    396 for(size_type i = 0; i < cols(); ++i)
    │ │ │ │ +
    397 {
    │ │ │ │ +
    398 yy[i] = y_field_type(0);
    │ │ │ │ +
    399 for(size_type j = 0; j < rows(); ++j)
    │ │ │ │ +
    400 yy[i] += (*this)[j][i] * xx[j];
    │ │ │ │ +
    401 }
    │ │ │ │ +
    402 }
    │ │ │ │ +
    │ │ │ │ +
    403
    │ │ │ │ +
    405 template<class X, class Y>
    │ │ │ │ +
    │ │ │ │ +
    406 void umv (const X& x, Y& y) const
    │ │ │ │ +
    407 {
    │ │ │ │ +
    408 auto&& xx = Impl::asVector(x);
    │ │ │ │ +
    409 auto&& yy = Impl::asVector(y);
    │ │ │ │ +
    410 DUNE_ASSERT_BOUNDS(xx.N() == M());
    │ │ │ │ +
    411 DUNE_ASSERT_BOUNDS(yy.N() == N());
    │ │ │ │ +
    412 for (size_type i=0; i<rows(); ++i)
    │ │ │ │ +
    413 for (size_type j=0; j<cols(); j++)
    │ │ │ │ +
    414 yy[i] += (*this)[i][j] * xx[j];
    │ │ │ │ +
    415 }
    │ │ │ │ +
    │ │ │ │ +
    416
    │ │ │ │ +
    418 template<class X, class Y>
    │ │ │ │ +
    │ │ │ │ +
    419 void umtv (const X& x, Y& y) const
    │ │ │ │ +
    420 {
    │ │ │ │ +
    421 auto&& xx = Impl::asVector(x);
    │ │ │ │ +
    422 auto&& yy = Impl::asVector(y);
    │ │ │ │ +
    423 DUNE_ASSERT_BOUNDS(xx.N() == N());
    │ │ │ │ +
    424 DUNE_ASSERT_BOUNDS(yy.N() == M());
    │ │ │ │ +
    425 for(size_type i = 0; i<rows(); ++i)
    │ │ │ │ +
    426 for (size_type j=0; j<cols(); j++)
    │ │ │ │ +
    427 yy[j] += (*this)[i][j]*xx[i];
    │ │ │ │ +
    428 }
    │ │ │ │ +
    │ │ │ │ +
    429
    │ │ │ │ +
    431 template<class X, class Y>
    │ │ │ │ +
    │ │ │ │ +
    432 void umhv (const X& x, Y& y) const
    │ │ │ │ +
    433 {
    │ │ │ │ +
    434 auto&& xx = Impl::asVector(x);
    │ │ │ │ +
    435 auto&& yy = Impl::asVector(y);
    │ │ │ │ +
    436 DUNE_ASSERT_BOUNDS(xx.N() == N());
    │ │ │ │ +
    437 DUNE_ASSERT_BOUNDS(yy.N() == M());
    │ │ │ │ +
    438 for (size_type i=0; i<rows(); i++)
    │ │ │ │ +
    439 for (size_type j=0; j<cols(); j++)
    │ │ │ │ +
    440 yy[j] += conjugateComplex((*this)[i][j])*xx[i];
    │ │ │ │ +
    441 }
    │ │ │ │ +
    │ │ │ │ +
    442
    │ │ │ │ +
    444 template<class X, class Y>
    │ │ │ │ +
    │ │ │ │ +
    445 void mmv (const X& x, Y& y) const
    │ │ │ │ +
    446 {
    │ │ │ │ +
    447 auto&& xx = Impl::asVector(x);
    │ │ │ │ +
    448 auto&& yy = Impl::asVector(y);
    │ │ │ │ +
    449 DUNE_ASSERT_BOUNDS(xx.N() == M());
    │ │ │ │ +
    450 DUNE_ASSERT_BOUNDS(yy.N() == N());
    │ │ │ │ +
    451 for (size_type i=0; i<rows(); i++)
    │ │ │ │ +
    452 for (size_type j=0; j<cols(); j++)
    │ │ │ │ +
    453 yy[i] -= (*this)[i][j] * xx[j];
    │ │ │ │ +
    454 }
    │ │ │ │ +
    │ │ │ │ +
    455
    │ │ │ │ +
    457 template<class X, class Y>
    │ │ │ │ +
    │ │ │ │ +
    458 void mmtv (const X& x, Y& y) const
    │ │ │ │ +
    459 {
    │ │ │ │ +
    460 auto&& xx = Impl::asVector(x);
    │ │ │ │ +
    461 auto&& yy = Impl::asVector(y);
    │ │ │ │ +
    462 DUNE_ASSERT_BOUNDS(xx.N() == N());
    │ │ │ │ +
    463 DUNE_ASSERT_BOUNDS(yy.N() == M());
    │ │ │ │ +
    464 for (size_type i=0; i<rows(); i++)
    │ │ │ │ +
    465 for (size_type j=0; j<cols(); j++)
    │ │ │ │ +
    466 yy[j] -= (*this)[i][j]*xx[i];
    │ │ │ │ +
    467 }
    │ │ │ │ +
    │ │ │ │ +
    468
    │ │ │ │ +
    470 template<class X, class Y>
    │ │ │ │ +
    │ │ │ │ +
    471 void mmhv (const X& x, Y& y) const
    │ │ │ │ +
    472 {
    │ │ │ │ +
    473 auto&& xx = Impl::asVector(x);
    │ │ │ │ +
    474 auto&& yy = Impl::asVector(y);
    │ │ │ │ +
    475 DUNE_ASSERT_BOUNDS(xx.N() == N());
    │ │ │ │ +
    476 DUNE_ASSERT_BOUNDS(yy.N() == M());
    │ │ │ │ +
    477 for (size_type i=0; i<rows(); i++)
    │ │ │ │ +
    478 for (size_type j=0; j<cols(); j++)
    │ │ │ │ +
    479 yy[j] -= conjugateComplex((*this)[i][j])*xx[i];
    │ │ │ │ +
    480 }
    │ │ │ │ +
    │ │ │ │ +
    481
    │ │ │ │ +
    483 template<class X, class Y>
    │ │ │ │ +
    │ │ │ │ +
    484 void usmv (const typename FieldTraits<Y>::field_type & alpha,
    │ │ │ │ +
    485 const X& x, Y& y) const
    │ │ │ │ +
    486 {
    │ │ │ │ +
    487 auto&& xx = Impl::asVector(x);
    │ │ │ │ +
    488 auto&& yy = Impl::asVector(y);
    │ │ │ │ +
    489 DUNE_ASSERT_BOUNDS(xx.N() == M());
    │ │ │ │ +
    490 DUNE_ASSERT_BOUNDS(yy.N() == N());
    │ │ │ │ +
    491 for (size_type i=0; i<rows(); i++)
    │ │ │ │ +
    492 for (size_type j=0; j<cols(); j++)
    │ │ │ │ +
    493 yy[i] += alpha * (*this)[i][j] * xx[j];
    │ │ │ │ +
    494 }
    │ │ │ │ +
    │ │ │ │ +
    495
    │ │ │ │ +
    497 template<class X, class Y>
    │ │ │ │ +
    │ │ │ │ +
    498 void usmtv (const typename FieldTraits<Y>::field_type & alpha,
    │ │ │ │ +
    499 const X& x, Y& y) const
    │ │ │ │ +
    500 {
    │ │ │ │ +
    501 auto&& xx = Impl::asVector(x);
    │ │ │ │ +
    502 auto&& yy = Impl::asVector(y);
    │ │ │ │ +
    503 DUNE_ASSERT_BOUNDS(xx.N() == N());
    │ │ │ │ +
    504 DUNE_ASSERT_BOUNDS(yy.N() == M());
    │ │ │ │ +
    505 for (size_type i=0; i<rows(); i++)
    │ │ │ │ +
    506 for (size_type j=0; j<cols(); j++)
    │ │ │ │ +
    507 yy[j] += alpha*(*this)[i][j]*xx[i];
    │ │ │ │ +
    508 }
    │ │ │ │ +
    │ │ │ │ +
    509
    │ │ │ │ +
    511 template<class X, class Y>
    │ │ │ │ +
    │ │ │ │ +
    512 void usmhv (const typename FieldTraits<Y>::field_type & alpha,
    │ │ │ │ +
    513 const X& x, Y& y) const
    │ │ │ │ +
    514 {
    │ │ │ │ +
    515 auto&& xx = Impl::asVector(x);
    │ │ │ │ +
    516 auto&& yy = Impl::asVector(y);
    │ │ │ │ +
    517 DUNE_ASSERT_BOUNDS(xx.N() == N());
    │ │ │ │ +
    518 DUNE_ASSERT_BOUNDS(yy.N() == M());
    │ │ │ │ +
    519 for (size_type i=0; i<rows(); i++)
    │ │ │ │ +
    520 for (size_type j=0; j<cols(); j++)
    │ │ │ │ +
    521 yy[j] +=
    │ │ │ │ +
    522 alpha*conjugateComplex((*this)[i][j])*xx[i];
    │ │ │ │ +
    523 }
    │ │ │ │ +
    │ │ │ │ +
    524
    │ │ │ │ +
    525 //===== norms
    │ │ │ │ +
    526
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    529 {
    │ │ │ │ +
    530 typename FieldTraits<value_type>::real_type sum=(0.0);
    │ │ │ │ +
    531 for (size_type i=0; i<rows(); ++i) sum += (*this)[i].two_norm2();
    │ │ │ │ +
    532 return fvmeta::sqrt(sum);
    │ │ │ │ +
    533 }
    │ │ │ │ +
    │ │ │ │ +
    534
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    537 {
    │ │ │ │ +
    538 typename FieldTraits<value_type>::real_type sum=(0.0);
    │ │ │ │ +
    539 for (size_type i=0; i<rows(); ++i) sum += (*this)[i].two_norm2();
    │ │ │ │ +
    540 return sum;
    │ │ │ │ +
    541 }
    │ │ │ │ +
    │ │ │ │ +
    542
    │ │ │ │ +
    544 template <typename vt = value_type,
    │ │ │ │ +
    545 typename std::enable_if<!HasNaN<vt>::value, int>::type = 0>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    547 using real_type = typename FieldTraits<vt>::real_type;
    │ │ │ │ +
    548 using std::max;
    │ │ │ │ +
    549
    │ │ │ │ +
    550 real_type norm = 0;
    │ │ │ │ +
    551 for (auto const &x : *this) {
    │ │ │ │ +
    552 real_type const a = x.one_norm();
    │ │ │ │ +
    553 norm = max(a, norm);
    │ │ │ │ +
    554 }
    │ │ │ │ +
    555 return norm;
    │ │ │ │ +
    556 }
    │ │ │ │ +
    │ │ │ │ +
    557
    │ │ │ │ +
    559 template <typename vt = value_type,
    │ │ │ │ +
    560 typename std::enable_if<!HasNaN<vt>::value, int>::type = 0>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    562 using real_type = typename FieldTraits<vt>::real_type;
    │ │ │ │ +
    563 using std::max;
    │ │ │ │ +
    564
    │ │ │ │ +
    565 real_type norm = 0;
    │ │ │ │ +
    566 for (auto const &x : *this) {
    │ │ │ │ +
    567 real_type const a = x.one_norm_real();
    │ │ │ │ +
    568 norm = max(a, norm);
    │ │ │ │ +
    569 }
    │ │ │ │ +
    570 return norm;
    │ │ │ │ +
    571 }
    │ │ │ │ +
    │ │ │ │ +
    572
    │ │ │ │ +
    574 template <typename vt = value_type,
    │ │ │ │ +
    575 typename std::enable_if<HasNaN<vt>::value, int>::type = 0>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    577 using real_type = typename FieldTraits<vt>::real_type;
    │ │ │ │ +
    578 using std::max;
    │ │ │ │ +
    579
    │ │ │ │ +
    580 real_type norm = 0;
    │ │ │ │ +
    581 real_type isNaN = 1;
    │ │ │ │ +
    582 for (auto const &x : *this) {
    │ │ │ │ +
    583 real_type const a = x.one_norm();
    │ │ │ │ +
    584 norm = max(a, norm);
    │ │ │ │ +
    585 isNaN += a;
    │ │ │ │ +
    586 }
    │ │ │ │ +
    587 return norm * (isNaN / isNaN);
    │ │ │ │ +
    588 }
    │ │ │ │ +
    │ │ │ │ +
    589
    │ │ │ │ +
    591 template <typename vt = value_type,
    │ │ │ │ +
    592 typename std::enable_if<HasNaN<vt>::value, int>::type = 0>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    594 using real_type = typename FieldTraits<vt>::real_type;
    │ │ │ │ +
    595 using std::max;
    │ │ │ │ +
    596
    │ │ │ │ +
    597 real_type norm = 0;
    │ │ │ │ +
    598 real_type isNaN = 1;
    │ │ │ │ +
    599 for (auto const &x : *this) {
    │ │ │ │ +
    600 real_type const a = x.one_norm_real();
    │ │ │ │ +
    601 norm = max(a, norm);
    │ │ │ │ +
    602 isNaN += a;
    │ │ │ │ +
    603 }
    │ │ │ │ +
    604 return norm * (isNaN / isNaN);
    │ │ │ │ +
    605 }
    │ │ │ │ +
    │ │ │ │ +
    606
    │ │ │ │ +
    607 //===== solve
    │ │ │ │ +
    608
    │ │ │ │ +
    613 template <class V1, class V2>
    │ │ │ │ +
    614 void solve (V1& x, const V2& b, bool doPivoting = true) const;
    │ │ │ │ +
    615
    │ │ │ │ +
    620 void invert(bool doPivoting = true);
    │ │ │ │ +
    621
    │ │ │ │ +
    623 field_type determinant (bool doPivoting = true) const;
    │ │ │ │ +
    624
    │ │ │ │ +
    626 template<typename M2>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    628 {
    │ │ │ │ +
    629 DUNE_ASSERT_BOUNDS(M.rows() == M.cols());
    │ │ │ │ +
    630 DUNE_ASSERT_BOUNDS(M.rows() == rows());
    │ │ │ │ +
    631 AutonomousValue<MAT> C(asImp());
    │ │ │ │ +
    632
    │ │ │ │ +
    633 for (size_type i=0; i<rows(); i++)
    │ │ │ │ +
    634 for (size_type j=0; j<cols(); j++) {
    │ │ │ │ +
    635 (*this)[i][j] = 0;
    │ │ │ │ +
    636 for (size_type k=0; k<rows(); k++)
    │ │ │ │ +
    637 (*this)[i][j] += M[i][k]*C[k][j];
    │ │ │ │ +
    638 }
    │ │ │ │ +
    639
    │ │ │ │ +
    640 return asImp();
    │ │ │ │ +
    641 }
    │ │ │ │ +
    │ │ │ │ +
    642
    │ │ │ │ +
    644 template<typename M2>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    646 {
    │ │ │ │ +
    647 DUNE_ASSERT_BOUNDS(M.rows() == M.cols());
    │ │ │ │ +
    648 DUNE_ASSERT_BOUNDS(M.cols() == cols());
    │ │ │ │ +
    649 AutonomousValue<MAT> C(asImp());
    │ │ │ │ +
    650
    │ │ │ │ +
    651 for (size_type i=0; i<rows(); i++)
    │ │ │ │ +
    652 for (size_type j=0; j<cols(); j++) {
    │ │ │ │ +
    653 (*this)[i][j] = 0;
    │ │ │ │ +
    654 for (size_type k=0; k<cols(); k++)
    │ │ │ │ +
    655 (*this)[i][j] += C[i][k]*M[k][j];
    │ │ │ │ +
    656 }
    │ │ │ │ +
    657 return asImp();
    │ │ │ │ +
    658 }
    │ │ │ │ +
    │ │ │ │ +
    659
    │ │ │ │ +
    660#if 0
    │ │ │ │ +
    662 template<int l>
    │ │ │ │ +
    663 DenseMatrix<K,l,cols> leftmultiplyany (const FieldMatrix<K,l,rows>& M) const
    │ │ │ │ +
    664 {
    │ │ │ │ + │ │ │ │ +
    666
    │ │ │ │ +
    667 for (size_type i=0; i<l; i++) {
    │ │ │ │ +
    668 for (size_type j=0; j<cols(); j++) {
    │ │ │ │ +
    669 C[i][j] = 0;
    │ │ │ │ +
    670 for (size_type k=0; k<rows(); k++)
    │ │ │ │ +
    671 C[i][j] += M[i][k]*(*this)[k][j];
    │ │ │ │ +
    672 }
    │ │ │ │ +
    673 }
    │ │ │ │ +
    674 return C;
    │ │ │ │ +
    675 }
    │ │ │ │ +
    676
    │ │ │ │ +
    678 template<int l>
    │ │ │ │ +
    679 FieldMatrix<K,rows,l> rightmultiplyany (const FieldMatrix<K,cols,l>& M) const
    │ │ │ │ +
    680 {
    │ │ │ │ +
    681 FieldMatrix<K,rows,l> C;
    │ │ │ │ +
    682
    │ │ │ │ +
    683 for (size_type i=0; i<rows(); i++) {
    │ │ │ │ +
    684 for (size_type j=0; j<l; j++) {
    │ │ │ │ +
    685 C[i][j] = 0;
    │ │ │ │ +
    686 for (size_type k=0; k<cols(); k++)
    │ │ │ │ +
    687 C[i][j] += (*this)[i][k]*M[k][j];
    │ │ │ │ +
    688 }
    │ │ │ │ +
    689 }
    │ │ │ │ +
    690 return C;
    │ │ │ │ +
    691 }
    │ │ │ │ +
    692#endif
    │ │ │ │ +
    693
    │ │ │ │ +
    694 //===== sizes
    │ │ │ │ +
    695
    │ │ │ │ +
    │ │ │ │ +
    697 constexpr size_type N () const
    │ │ │ │ +
    698 {
    │ │ │ │ +
    699 return rows();
    │ │ │ │ +
    700 }
    │ │ │ │ +
    │ │ │ │ +
    701
    │ │ │ │ +
    │ │ │ │ +
    703 constexpr size_type M () const
    │ │ │ │ +
    704 {
    │ │ │ │ +
    705 return cols();
    │ │ │ │ +
    706 }
    │ │ │ │ +
    │ │ │ │ +
    707
    │ │ │ │ +
    │ │ │ │ +
    709 constexpr size_type rows() const
    │ │ │ │ +
    710 {
    │ │ │ │ +
    711 return asImp().mat_rows();
    │ │ │ │ +
    712 }
    │ │ │ │ +
    │ │ │ │ +
    713
    │ │ │ │ +
    │ │ │ │ +
    715 constexpr size_type cols() const
    │ │ │ │ +
    716 {
    │ │ │ │ +
    717 return asImp().mat_cols();
    │ │ │ │ +
    718 }
    │ │ │ │ +
    │ │ │ │ +
    719
    │ │ │ │ +
    720 //===== query
    │ │ │ │ +
    721
    │ │ │ │ +
    │ │ │ │ +
    723 bool exists ([[maybe_unused]] size_type i, [[maybe_unused]] size_type j) const
    │ │ │ │ +
    724 {
    │ │ │ │ +
    725 DUNE_ASSERT_BOUNDS(i >= 0 && i < rows());
    │ │ │ │ +
    726 DUNE_ASSERT_BOUNDS(j >= 0 && j < cols());
    │ │ │ │ +
    727 return true;
    │ │ │ │ +
    728 }
    │ │ │ │ +
    │ │ │ │ +
    729
    │ │ │ │ +
    730 protected:
    │ │ │ │ +
    731
    │ │ │ │ +
    732#ifndef DOXYGEN
    │ │ │ │ +
    733 struct ElimPivot
    │ │ │ │ +
    734 {
    │ │ │ │ +
    735 ElimPivot(std::vector<simd_index_type> & pivot);
    │ │ │ │ +
    736
    │ │ │ │ +
    737 void swap(std::size_t i, simd_index_type j);
    │ │ │ │ +
    738
    │ │ │ │ +
    739 template<typename T>
    │ │ │ │ +
    740 void operator()(const T&, int, int)
    │ │ │ │ +
    741 {}
    │ │ │ │ +
    742
    │ │ │ │ +
    743 std::vector<simd_index_type> & pivot_;
    │ │ │ │ +
    744 };
    │ │ │ │ +
    745
    │ │ │ │ +
    746 template<typename V>
    │ │ │ │ +
    747 struct Elim
    │ │ │ │ +
    748 {
    │ │ │ │ +
    749 Elim(V& rhs);
    │ │ │ │ +
    750
    │ │ │ │ +
    751 void swap(std::size_t i, simd_index_type j);
    │ │ │ │ +
    752
    │ │ │ │ +
    753 void operator()(const typename V::field_type& factor, int k, int i);
    │ │ │ │ +
    754
    │ │ │ │ +
    755 V* rhs_;
    │ │ │ │ +
    756 };
    │ │ │ │ +
    757
    │ │ │ │ +
    758 struct ElimDet
    │ │ │ │ +
    759 {
    │ │ │ │ +
    760 ElimDet(field_type& sign) : sign_(sign)
    │ │ │ │ +
    761 { sign_ = 1; }
    │ │ │ │ +
    762
    │ │ │ │ +
    763 void swap(std::size_t i, simd_index_type j)
    │ │ │ │ +
    764 {
    │ │ │ │ +
    765 sign_ *=
    │ │ │ │ +
    766 Simd::cond(simd_index_type(i) == j, field_type(1), field_type(-1));
    │ │ │ │ +
    767 }
    │ │ │ │ +
    768
    │ │ │ │ +
    769 void operator()(const field_type&, int, int)
    │ │ │ │ +
    770 {}
    │ │ │ │ +
    771
    │ │ │ │ +
    772 field_type& sign_;
    │ │ │ │ +
    773 };
    │ │ │ │ +
    774#endif // DOXYGEN
    │ │ │ │ +
    775
    │ │ │ │ +
    777
    │ │ │ │ +
    815 template<class Func, class Mask>
    │ │ │ │ +
    816 static void luDecomposition(DenseMatrix<MAT>& A, Func func,
    │ │ │ │ +
    817 Mask &nonsingularLanes, bool throwEarly, bool doPivoting);
    │ │ │ │ +
    818 };
    │ │ │ │ +
    │ │ │ │ +
    819
    │ │ │ │ +
    820#ifndef DOXYGEN
    │ │ │ │ +
    821 template<typename MAT>
    │ │ │ │ +
    822 DenseMatrix<MAT>::ElimPivot::ElimPivot(std::vector<simd_index_type> & pivot)
    │ │ │ │ +
    823 : pivot_(pivot)
    │ │ │ │ +
    824 {
    │ │ │ │ +
    825 typedef typename std::vector<size_type>::size_type size_type;
    │ │ │ │ +
    826 for(size_type i=0; i < pivot_.size(); ++i) pivot_[i]=i;
    │ │ │ │ +
    827 }
    │ │ │ │ +
    828
    │ │ │ │ +
    829 template<typename MAT>
    │ │ │ │ +
    830 void DenseMatrix<MAT>::ElimPivot::swap(std::size_t i, simd_index_type j)
    │ │ │ │ +
    831 {
    │ │ │ │ +
    832 pivot_[i] =
    │ │ │ │ +
    833 Simd::cond(Simd::Scalar<simd_index_type>(i) == j, pivot_[i], j);
    │ │ │ │ +
    834 }
    │ │ │ │ +
    835
    │ │ │ │ +
    836 template<typename MAT>
    │ │ │ │ +
    837 template<typename V>
    │ │ │ │ +
    838 DenseMatrix<MAT>::Elim<V>::Elim(V& rhs)
    │ │ │ │ +
    839 : rhs_(&rhs)
    │ │ │ │ +
    840 {}
    │ │ │ │ +
    841
    │ │ │ │ +
    842 template<typename MAT>
    │ │ │ │ +
    843 template<typename V>
    │ │ │ │ +
    844 void DenseMatrix<MAT>::Elim<V>::swap(std::size_t i, simd_index_type j)
    │ │ │ │ +
    845 {
    │ │ │ │ +
    846 using std::swap;
    │ │ │ │ +
    847
    │ │ │ │ +
    848 // see the comment in luDecomposition()
    │ │ │ │ +
    849 for(std::size_t l = 0; l < Simd::lanes(j); ++l)
    │ │ │ │ +
    850 swap(Simd::lane(l, (*rhs_)[ i ]),
    │ │ │ │ +
    851 Simd::lane(l, (*rhs_)[Simd::lane(l, j)]));
    │ │ │ │ +
    852 }
    │ │ │ │ +
    853
    │ │ │ │ +
    854 template<typename MAT>
    │ │ │ │ +
    855 template<typename V>
    │ │ │ │ +
    856 void DenseMatrix<MAT>::
    │ │ │ │ +
    857 Elim<V>::operator()(const typename V::field_type& factor, int k, int i)
    │ │ │ │ +
    858 {
    │ │ │ │ +
    859 (*rhs_)[k] -= factor*(*rhs_)[i];
    │ │ │ │ +
    860 }
    │ │ │ │ +
    861
    │ │ │ │ +
    862 template<typename MAT>
    │ │ │ │ +
    863 template<typename Func, class Mask>
    │ │ │ │ +
    864 inline void DenseMatrix<MAT>::
    │ │ │ │ +
    865 luDecomposition(DenseMatrix<MAT>& A, Func func, Mask &nonsingularLanes,
    │ │ │ │ +
    866 bool throwEarly, bool doPivoting)
    │ │ │ │ +
    867 {
    │ │ │ │ +
    868 using std::max;
    │ │ │ │ +
    869 using std::swap;
    │ │ │ │ +
    870
    │ │ │ │ +
    871 typedef typename FieldTraits<value_type>::real_type real_type;
    │ │ │ │ +
    872
    │ │ │ │ +
    873 // LU decomposition of A in A
    │ │ │ │ +
    874 for (size_type i=0; i<A.rows(); i++) // loop over all rows
    │ │ │ │ +
    875 {
    │ │ │ │ +
    876 real_type pivmax = fvmeta::absreal(A[i][i]);
    │ │ │ │ +
    877
    │ │ │ │ +
    878 if (doPivoting)
    │ │ │ │ +
    879 {
    │ │ │ │ +
    880 // compute maximum of column
    │ │ │ │ +
    881 simd_index_type imax=i;
    │ │ │ │ +
    882 for (size_type k=i+1; k<A.rows(); k++)
    │ │ │ │ +
    883 {
    │ │ │ │ +
    884 auto abs = fvmeta::absreal(A[k][i]);
    │ │ │ │ +
    885 auto mask = abs > pivmax;
    │ │ │ │ +
    886 pivmax = Simd::cond(mask, abs, pivmax);
    │ │ │ │ +
    887 imax = Simd::cond(mask, simd_index_type(k), imax);
    │ │ │ │ +
    888 }
    │ │ │ │ +
    889 // swap rows
    │ │ │ │ +
    890 for (size_type j=0; j<A.rows(); j++)
    │ │ │ │ +
    891 {
    │ │ │ │ +
    892 // This is a swap operation where the second operand is scattered,
    │ │ │ │ +
    893 // and on top of that is also extracted from deep within a
    │ │ │ │ +
    894 // moderately complicated data structure (a DenseMatrix), where we
    │ │ │ │ +
    895 // can't assume much on the memory layout. On intel processors,
    │ │ │ │ +
    896 // the only instruction that might help us here is vgather, but it
    │ │ │ │ +
    897 // is unclear whether that is even faster than a software
    │ │ │ │ +
    898 // implementation, and we would also need vscatter which does not
    │ │ │ │ +
    899 // exist. So break vectorization here and do it manually.
    │ │ │ │ +
    900 for(std::size_t l = 0; l < Simd::lanes(A[i][j]); ++l)
    │ │ │ │ +
    901 swap(Simd::lane(l, A[i][j]),
    │ │ │ │ +
    902 Simd::lane(l, A[Simd::lane(l, imax)][j]));
    │ │ │ │ +
    903 }
    │ │ │ │ +
    904 func.swap(i, imax); // swap the pivot or rhs
    │ │ │ │ +
    905 }
    │ │ │ │ +
    906
    │ │ │ │ +
    907 // singular ?
    │ │ │ │ +
    908 nonsingularLanes = nonsingularLanes && (pivmax != real_type(0));
    │ │ │ │ +
    909 if (throwEarly) {
    │ │ │ │ +
    910 if(!Simd::allTrue(nonsingularLanes))
    │ │ │ │ +
    911 DUNE_THROW(FMatrixError, "matrix is singular");
    │ │ │ │ +
    912 }
    │ │ │ │ +
    913 else { // !throwEarly
    │ │ │ │ +
    914 if(!Simd::anyTrue(nonsingularLanes))
    │ │ │ │ +
    915 return;
    │ │ │ │ +
    916 }
    │ │ │ │ +
    917
    │ │ │ │ +
    918 // eliminate
    │ │ │ │ +
    919 for (size_type k=i+1; k<A.rows(); k++)
    │ │ │ │ +
    920 {
    │ │ │ │ +
    921 // in the simd case, A[i][i] may be close to zero in some lanes. Pray
    │ │ │ │ +
    922 // that the result is no worse than a quiet NaN.
    │ │ │ │ +
    923 field_type factor = A[k][i]/A[i][i];
    │ │ │ │ +
    924 A[k][i] = factor;
    │ │ │ │ +
    925 for (size_type j=i+1; j<A.rows(); j++)
    │ │ │ │ +
    926 A[k][j] -= factor*A[i][j];
    │ │ │ │ +
    927 func(factor, k, i);
    │ │ │ │ +
    928 }
    │ │ │ │ +
    929 }
    │ │ │ │ +
    930 }
    │ │ │ │ +
    931
    │ │ │ │ +
    932 template<typename MAT>
    │ │ │ │ +
    933 template <class V1, class V2>
    │ │ │ │ +
    934 inline void DenseMatrix<MAT>::solve(V1& x, const V2& b, bool doPivoting) const
    │ │ │ │ +
    935 {
    │ │ │ │ +
    936 using real_type = typename FieldTraits<value_type>::real_type;
    │ │ │ │ +
    937 // never mind those ifs, because they get optimized away
    │ │ │ │ +
    938 if (rows()!=cols())
    │ │ │ │ +
    939 DUNE_THROW(FMatrixError, "Can't solve for a " << rows() << "x" << cols() << " matrix!");
    │ │ │ │ +
    940
    │ │ │ │ +
    941 if (rows()==1) {
    │ │ │ │ +
    942
    │ │ │ │ +
    943#ifdef DUNE_FMatrix_WITH_CHECKING
    │ │ │ │ +
    944 if (Simd::anyTrue(fvmeta::absreal((*this)[0][0])
    │ │ │ │ + │ │ │ │ +
    946 DUNE_THROW(FMatrixError,"matrix is singular");
    │ │ │ │ +
    947#endif
    │ │ │ │ +
    948 x[0] = b[0]/(*this)[0][0];
    │ │ │ │ +
    949
    │ │ │ │ +
    950 }
    │ │ │ │ +
    951 else if (rows()==2) {
    │ │ │ │ +
    952
    │ │ │ │ +
    953 field_type detinv = (*this)[0][0]*(*this)[1][1]-(*this)[0][1]*(*this)[1][0];
    │ │ │ │ +
    954#ifdef DUNE_FMatrix_WITH_CHECKING
    │ │ │ │ +
    955 if (Simd::anyTrue(fvmeta::absreal(detinv)
    │ │ │ │ + │ │ │ │ +
    957 DUNE_THROW(FMatrixError,"matrix is singular");
    │ │ │ │ +
    958#endif
    │ │ │ │ +
    959 detinv = real_type(1.0)/detinv;
    │ │ │ │ +
    960
    │ │ │ │ +
    961 x[0] = detinv*((*this)[1][1]*b[0]-(*this)[0][1]*b[1]);
    │ │ │ │ +
    962 x[1] = detinv*((*this)[0][0]*b[1]-(*this)[1][0]*b[0]);
    │ │ │ │ +
    963
    │ │ │ │ +
    964 }
    │ │ │ │ +
    965 else if (rows()==3) {
    │ │ │ │ +
    966
    │ │ │ │ +
    967 field_type d = determinant(doPivoting);
    │ │ │ │ +
    968#ifdef DUNE_FMatrix_WITH_CHECKING
    │ │ │ │ +
    969 if (Simd::anyTrue(fvmeta::absreal(d)
    │ │ │ │ + │ │ │ │ +
    971 DUNE_THROW(FMatrixError,"matrix is singular");
    │ │ │ │ +
    972#endif
    │ │ │ │ +
    973
    │ │ │ │ +
    974 x[0] = (b[0]*(*this)[1][1]*(*this)[2][2] - b[0]*(*this)[2][1]*(*this)[1][2]
    │ │ │ │ +
    975 - b[1] *(*this)[0][1]*(*this)[2][2] + b[1]*(*this)[2][1]*(*this)[0][2]
    │ │ │ │ +
    976 + b[2] *(*this)[0][1]*(*this)[1][2] - b[2]*(*this)[1][1]*(*this)[0][2]) / d;
    │ │ │ │ +
    977
    │ │ │ │ +
    978 x[1] = ((*this)[0][0]*b[1]*(*this)[2][2] - (*this)[0][0]*b[2]*(*this)[1][2]
    │ │ │ │ +
    979 - (*this)[1][0] *b[0]*(*this)[2][2] + (*this)[1][0]*b[2]*(*this)[0][2]
    │ │ │ │ +
    980 + (*this)[2][0] *b[0]*(*this)[1][2] - (*this)[2][0]*b[1]*(*this)[0][2]) / d;
    │ │ │ │ +
    981
    │ │ │ │ +
    982 x[2] = ((*this)[0][0]*(*this)[1][1]*b[2] - (*this)[0][0]*(*this)[2][1]*b[1]
    │ │ │ │ +
    983 - (*this)[1][0] *(*this)[0][1]*b[2] + (*this)[1][0]*(*this)[2][1]*b[0]
    │ │ │ │ +
    984 + (*this)[2][0] *(*this)[0][1]*b[1] - (*this)[2][0]*(*this)[1][1]*b[0]) / d;
    │ │ │ │ +
    985
    │ │ │ │ +
    986 }
    │ │ │ │ +
    987 else {
    │ │ │ │ +
    988
    │ │ │ │ +
    989 V1& rhs = x; // use x to store rhs
    │ │ │ │ +
    990 rhs = b; // copy data
    │ │ │ │ +
    991 Elim<V1> elim(rhs);
    │ │ │ │ +
    992 AutonomousValue<MAT> A(asImp());
    │ │ │ │ +
    993 Simd::Mask<typename FieldTraits<value_type>::real_type>
    │ │ │ │ +
    994 nonsingularLanes(true);
    │ │ │ │ +
    995
    │ │ │ │ +
    996 AutonomousValue<MAT>::luDecomposition(A, elim, nonsingularLanes, true, doPivoting);
    │ │ │ │ +
    997
    │ │ │ │ +
    998 // backsolve
    │ │ │ │ +
    999 for(int i=rows()-1; i>=0; i--) {
    │ │ │ │ +
    1000 for (size_type j=i+1; j<rows(); j++)
    │ │ │ │ +
    1001 rhs[i] -= A[i][j]*x[j];
    │ │ │ │ +
    1002 x[i] = rhs[i]/A[i][i];
    │ │ │ │ +
    1003 }
    │ │ │ │ +
    1004 }
    │ │ │ │ +
    1005 }
    │ │ │ │ +
    1006
    │ │ │ │ +
    1007 template<typename MAT>
    │ │ │ │ +
    1008 inline void DenseMatrix<MAT>::invert(bool doPivoting)
    │ │ │ │ +
    1009 {
    │ │ │ │ +
    1010 using real_type = typename FieldTraits<MAT>::real_type;
    │ │ │ │ +
    1011 using std::swap;
    │ │ │ │ +
    1012
    │ │ │ │ +
    1013 // never mind those ifs, because they get optimized away
    │ │ │ │ +
    1014 if (rows()!=cols())
    │ │ │ │ +
    1015 DUNE_THROW(FMatrixError, "Can't invert a " << rows() << "x" << cols() << " matrix!");
    │ │ │ │ +
    1016
    │ │ │ │ +
    1017 if (rows()==1) {
    │ │ │ │ +
    1018
    │ │ │ │ +
    1019#ifdef DUNE_FMatrix_WITH_CHECKING
    │ │ │ │ +
    1020 if (Simd::anyTrue(fvmeta::absreal((*this)[0][0])
    │ │ │ │ + │ │ │ │ +
    1022 DUNE_THROW(FMatrixError,"matrix is singular");
    │ │ │ │ +
    1023#endif
    │ │ │ │ +
    1024 (*this)[0][0] = real_type( 1 ) / (*this)[0][0];
    │ │ │ │ +
    1025
    │ │ │ │ +
    1026 }
    │ │ │ │ +
    1027 else if (rows()==2) {
    │ │ │ │ +
    1028
    │ │ │ │ +
    1029 field_type detinv = (*this)[0][0]*(*this)[1][1]-(*this)[0][1]*(*this)[1][0];
    │ │ │ │ +
    1030#ifdef DUNE_FMatrix_WITH_CHECKING
    │ │ │ │ +
    1031 if (Simd::anyTrue(fvmeta::absreal(detinv)
    │ │ │ │ + │ │ │ │ +
    1033 DUNE_THROW(FMatrixError,"matrix is singular");
    │ │ │ │ +
    1034#endif
    │ │ │ │ +
    1035 detinv = real_type( 1 ) / detinv;
    │ │ │ │ +
    1036
    │ │ │ │ +
    1037 field_type temp=(*this)[0][0];
    │ │ │ │ +
    1038 (*this)[0][0] = (*this)[1][1]*detinv;
    │ │ │ │ +
    1039 (*this)[0][1] = -(*this)[0][1]*detinv;
    │ │ │ │ +
    1040 (*this)[1][0] = -(*this)[1][0]*detinv;
    │ │ │ │ +
    1041 (*this)[1][1] = temp*detinv;
    │ │ │ │ +
    1042
    │ │ │ │ +
    1043 }
    │ │ │ │ +
    1044 else if (rows()==3)
    │ │ │ │ +
    1045 {
    │ │ │ │ +
    1046 using K = field_type;
    │ │ │ │ +
    1047 // code generated by maple
    │ │ │ │ +
    1048 K t4 = (*this)[0][0] * (*this)[1][1];
    │ │ │ │ +
    1049 K t6 = (*this)[0][0] * (*this)[1][2];
    │ │ │ │ +
    1050 K t8 = (*this)[0][1] * (*this)[1][0];
    │ │ │ │ +
    1051 K t10 = (*this)[0][2] * (*this)[1][0];
    │ │ │ │ +
    1052 K t12 = (*this)[0][1] * (*this)[2][0];
    │ │ │ │ +
    1053 K t14 = (*this)[0][2] * (*this)[2][0];
    │ │ │ │ +
    1054
    │ │ │ │ +
    1055 K det = (t4*(*this)[2][2]-t6*(*this)[2][1]-t8*(*this)[2][2]+
    │ │ │ │ +
    1056 t10*(*this)[2][1]+t12*(*this)[1][2]-t14*(*this)[1][1]);
    │ │ │ │ +
    1057 K t17 = K(1.0)/det;
    │ │ │ │ +
    1058
    │ │ │ │ +
    1059 K matrix01 = (*this)[0][1];
    │ │ │ │ +
    1060 K matrix00 = (*this)[0][0];
    │ │ │ │ +
    1061 K matrix10 = (*this)[1][0];
    │ │ │ │ +
    1062 K matrix11 = (*this)[1][1];
    │ │ │ │ +
    1063
    │ │ │ │ +
    1064 (*this)[0][0] = ((*this)[1][1] * (*this)[2][2] - (*this)[1][2] * (*this)[2][1])*t17;
    │ │ │ │ +
    1065 (*this)[0][1] = -((*this)[0][1] * (*this)[2][2] - (*this)[0][2] * (*this)[2][1])*t17;
    │ │ │ │ +
    1066 (*this)[0][2] = (matrix01 * (*this)[1][2] - (*this)[0][2] * (*this)[1][1])*t17;
    │ │ │ │ +
    1067 (*this)[1][0] = -((*this)[1][0] * (*this)[2][2] - (*this)[1][2] * (*this)[2][0])*t17;
    │ │ │ │ +
    1068 (*this)[1][1] = (matrix00 * (*this)[2][2] - t14) * t17;
    │ │ │ │ +
    1069 (*this)[1][2] = -(t6-t10) * t17;
    │ │ │ │ +
    1070 (*this)[2][0] = (matrix10 * (*this)[2][1] - matrix11 * (*this)[2][0]) * t17;
    │ │ │ │ +
    1071 (*this)[2][1] = -(matrix00 * (*this)[2][1] - t12) * t17;
    │ │ │ │ +
    1072 (*this)[2][2] = (t4-t8) * t17;
    │ │ │ │ +
    1073 }
    │ │ │ │ +
    1074 else {
    │ │ │ │ +
    1075 using std::swap;
    │ │ │ │ +
    1076
    │ │ │ │ +
    1077 AutonomousValue<MAT> A(asImp());
    │ │ │ │ +
    1078 std::vector<simd_index_type> pivot(rows());
    │ │ │ │ +
    1079 Simd::Mask<typename FieldTraits<value_type>::real_type>
    │ │ │ │ +
    1080 nonsingularLanes(true);
    │ │ │ │ +
    1081 AutonomousValue<MAT>::luDecomposition(A, ElimPivot(pivot), nonsingularLanes, true, doPivoting);
    │ │ │ │ +
    1082 auto& L=A;
    │ │ │ │ +
    1083 auto& U=A;
    │ │ │ │ +
    1084
    │ │ │ │ +
    1085 // initialize inverse
    │ │ │ │ +
    1086 *this=field_type();
    │ │ │ │ +
    1087
    │ │ │ │ +
    1088 for(size_type i=0; i<rows(); ++i)
    │ │ │ │ +
    1089 (*this)[i][i]=1;
    │ │ │ │ +
    1090
    │ │ │ │ +
    1091 // L Y = I; multiple right hand sides
    │ │ │ │ +
    1092 for (size_type i=0; i<rows(); i++)
    │ │ │ │ +
    1093 for (size_type j=0; j<i; j++)
    │ │ │ │ +
    1094 for (size_type k=0; k<rows(); k++)
    │ │ │ │ +
    1095 (*this)[i][k] -= L[i][j]*(*this)[j][k];
    │ │ │ │ +
    1096
    │ │ │ │ +
    1097 // U A^{-1} = Y
    │ │ │ │ +
    1098 for (size_type i=rows(); i>0;) {
    │ │ │ │ +
    1099 --i;
    │ │ │ │ +
    1100 for (size_type k=0; k<rows(); k++) {
    │ │ │ │ +
    1101 for (size_type j=i+1; j<rows(); j++)
    │ │ │ │ +
    1102 (*this)[i][k] -= U[i][j]*(*this)[j][k];
    │ │ │ │ +
    1103 (*this)[i][k] /= U[i][i];
    │ │ │ │ +
    1104 }
    │ │ │ │ +
    1105 }
    │ │ │ │ +
    1106
    │ │ │ │ +
    1107 for(size_type i=rows(); i>0; ) {
    │ │ │ │ +
    1108 --i;
    │ │ │ │ +
    1109 for(std::size_t l = 0; l < Simd::lanes((*this)[0][0]); ++l)
    │ │ │ │ +
    1110 {
    │ │ │ │ +
    1111 std::size_t pi = Simd::lane(l, pivot[i]);
    │ │ │ │ +
    1112 if(i!=pi)
    │ │ │ │ +
    1113 for(size_type j=0; j<rows(); ++j)
    │ │ │ │ +
    1114 swap(Simd::lane(l, (*this)[j][pi]),
    │ │ │ │ +
    1115 Simd::lane(l, (*this)[j][ i]));
    │ │ │ │ +
    1116 }
    │ │ │ │ +
    1117 }
    │ │ │ │ +
    1118 }
    │ │ │ │ +
    1119 }
    │ │ │ │ +
    1120
    │ │ │ │ +
    1121 // implementation of the determinant
    │ │ │ │ +
    1122 template<typename MAT>
    │ │ │ │ +
    1123 inline typename DenseMatrix<MAT>::field_type
    │ │ │ │ +
    1124 DenseMatrix<MAT>::determinant(bool doPivoting) const
    │ │ │ │ +
    1125 {
    │ │ │ │ +
    1126 // never mind those ifs, because they get optimized away
    │ │ │ │ +
    1127 if (rows()!=cols())
    │ │ │ │ +
    1128 DUNE_THROW(FMatrixError, "There is no determinant for a " << rows() << "x" << cols() << " matrix!");
    │ │ │ │ +
    1129
    │ │ │ │ +
    1130 if (rows()==1)
    │ │ │ │ +
    1131 return (*this)[0][0];
    │ │ │ │ +
    1132
    │ │ │ │ +
    1133 if (rows()==2)
    │ │ │ │ +
    1134 return (*this)[0][0]*(*this)[1][1] - (*this)[0][1]*(*this)[1][0];
    │ │ │ │ +
    1135
    │ │ │ │ +
    1136 if (rows()==3) {
    │ │ │ │ +
    1137 // code generated by maple
    │ │ │ │ +
    1138 field_type t4 = (*this)[0][0] * (*this)[1][1];
    │ │ │ │ +
    1139 field_type t6 = (*this)[0][0] * (*this)[1][2];
    │ │ │ │ +
    1140 field_type t8 = (*this)[0][1] * (*this)[1][0];
    │ │ │ │ +
    1141 field_type t10 = (*this)[0][2] * (*this)[1][0];
    │ │ │ │ +
    1142 field_type t12 = (*this)[0][1] * (*this)[2][0];
    │ │ │ │ +
    1143 field_type t14 = (*this)[0][2] * (*this)[2][0];
    │ │ │ │ +
    1144
    │ │ │ │ +
    1145 return (t4*(*this)[2][2]-t6*(*this)[2][1]-t8*(*this)[2][2]+
    │ │ │ │ +
    1146 t10*(*this)[2][1]+t12*(*this)[1][2]-t14*(*this)[1][1]);
    │ │ │ │ +
    1147
    │ │ │ │ +
    1148 }
    │ │ │ │ +
    1149
    │ │ │ │ +
    1150 AutonomousValue<MAT> A(asImp());
    │ │ │ │ +
    1151 field_type det;
    │ │ │ │ +
    1152 Simd::Mask<typename FieldTraits<value_type>::real_type>
    │ │ │ │ +
    1153 nonsingularLanes(true);
    │ │ │ │ +
    1154
    │ │ │ │ +
    1155 AutonomousValue<MAT>::luDecomposition(A, ElimDet(det), nonsingularLanes, false, doPivoting);
    │ │ │ │ +
    1156 det = Simd::cond(nonsingularLanes, det, field_type(0));
    │ │ │ │ +
    1157
    │ │ │ │ +
    1158 for (size_type i = 0; i < rows(); ++i)
    │ │ │ │ +
    1159 det *= A[i][i];
    │ │ │ │ +
    1160 return det;
    │ │ │ │ +
    1161 }
    │ │ │ │ +
    1162
    │ │ │ │ +
    1163#endif // DOXYGEN
    │ │ │ │ +
    1164
    │ │ │ │ +
    │ │ │ │ +
    1165 namespace DenseMatrixHelp {
    │ │ │ │ +
    1166
    │ │ │ │ +
    1168 template <typename MAT, typename V1, typename V2>
    │ │ │ │ +
    │ │ │ │ +
    1169 static inline void multAssign(const DenseMatrix<MAT> &matrix, const DenseVector<V1> & x, DenseVector<V2> & ret)
    │ │ │ │ +
    1170 {
    │ │ │ │ +
    1171 DUNE_ASSERT_BOUNDS(x.size() == matrix.cols());
    │ │ │ │ +
    1172 DUNE_ASSERT_BOUNDS(ret.size() == matrix.rows());
    │ │ │ │ +
    1173 typedef typename DenseMatrix<MAT>::size_type size_type;
    │ │ │ │ +
    1174
    │ │ │ │ +
    1175 for(size_type i=0; i<matrix.rows(); ++i)
    │ │ │ │ +
    1176 {
    │ │ │ │ +
    1177 ret[i] = 0.0;
    │ │ │ │ +
    1178 for(size_type j=0; j<matrix.cols(); ++j)
    │ │ │ │ +
    1179 {
    │ │ │ │ +
    1180 ret[i] += matrix[i][j]*x[j];
    │ │ │ │ +
    1181 }
    │ │ │ │ +
    1182 }
    │ │ │ │ +
    1183 }
    │ │ │ │ +
    │ │ │ │ +
    1184
    │ │ │ │ +
    1185#if 0
    │ │ │ │ +
    1187 template <typename K, int rows, int cols>
    │ │ │ │ +
    1188 static inline void multAssignTransposed( const FieldMatrix<K,rows,cols> &matrix, const FieldVector<K,rows> & x, FieldVector<K,cols> & ret)
    │ │ │ │ +
    1189 {
    │ │ │ │ +
    1190 typedef typename FieldMatrix<K,rows,cols>::size_type size_type;
    │ │ │ │ +
    1191
    │ │ │ │ +
    1192 for(size_type i=0; i<cols(); ++i)
    │ │ │ │ +
    1193 {
    │ │ │ │ +
    1194 ret[i] = 0.0;
    │ │ │ │ +
    1195 for(size_type j=0; j<rows(); ++j)
    │ │ │ │ +
    1196 ret[i] += matrix[j][i]*x[j];
    │ │ │ │ +
    1197 }
    │ │ │ │ +
    1198 }
    │ │ │ │ +
    1199
    │ │ │ │ +
    1201 template <typename K, int rows, int cols>
    │ │ │ │ +
    1202 static inline FieldVector<K,rows> mult(const FieldMatrix<K,rows,cols> &matrix, const FieldVector<K,cols> & x)
    │ │ │ │ +
    1203 {
    │ │ │ │ +
    1204 FieldVector<K,rows> ret;
    │ │ │ │ +
    1205 multAssign(matrix,x,ret);
    │ │ │ │ +
    1206 return ret;
    │ │ │ │ +
    1207 }
    │ │ │ │ +
    1208
    │ │ │ │ +
    1210 template <typename K, int rows, int cols>
    │ │ │ │ +
    1211 static inline FieldVector<K,cols> multTransposed(const FieldMatrix<K,rows,cols> &matrix, const FieldVector<K,rows> & x)
    │ │ │ │ +
    1212 {
    │ │ │ │ +
    1213 FieldVector<K,cols> ret;
    │ │ │ │ +
    1214 multAssignTransposed( matrix, x, ret );
    │ │ │ │ +
    1215 return ret;
    │ │ │ │ +
    1216 }
    │ │ │ │ +
    1217#endif
    │ │ │ │ +
    1218
    │ │ │ │ +
    1219 } // end namespace DenseMatrixHelp
    │ │ │ │ +
    │ │ │ │ +
    1220
    │ │ │ │ +
    1222 template<typename MAT>
    │ │ │ │ +
    │ │ │ │ +
    1223 std::ostream& operator<< (std::ostream& s, const DenseMatrix<MAT>& a)
    │ │ │ │ +
    1224 {
    │ │ │ │ +
    1225 for (typename DenseMatrix<MAT>::size_type i=0; i<a.rows(); i++)
    │ │ │ │ +
    1226 s << a[i] << std::endl;
    │ │ │ │ +
    1227 return s;
    │ │ │ │ +
    1228 }
    │ │ │ │ +
    │ │ │ │ +
    1229
    │ │ │ │ +
    1232} // end namespace Dune
    │ │ │ │ +
    1233
    │ │ │ │ +
    1234#endif
    │ │ │ │ +
    A few common exception classes.
    │ │ │ │ +
    A free function to provide the demangled class name of a given object or type as a string.
    │ │ │ │ +
    Various precision settings for calculations with FieldMatrix and FieldVector.
    │ │ │ │ +
    Some useful basic math stuff.
    │ │ │ │ +
    Implements a scalar vector view wrapper around an existing scalar.
    │ │ │ │ +
    Implements a vector constructed from a given type representing a field and a compile-time given size.
    │ │ │ │ +
    Macro for wrapping boundary checks.
    │ │ │ │ +
    Traits for type conversions and type information.
    │ │ │ │ +
    #define DUNE_ASSERT_BOUNDS(cond)
    If DUNE_CHECK_BOUNDS is defined: check if condition cond holds; otherwise, do nothing.
    Definition boundschecking.hh:30
    │ │ │ │ +
    typename AutonomousValueType< T >::type AutonomousValue
    Type free of internal references that T can be converted to.
    Definition typetraits.hh:558
    │ │ │ │ +
    std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x)
    Definition bigunsignedint.hh:278
    │ │ │ │ +
    #define DUNE_THROW(E, m)
    Definition exceptions.hh:218
    │ │ │ │ +
    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
    │ │ │ │ +
    typename Overloads::RebindType< std::decay_t< S >, std::decay_t< V > >::type Rebind
    Construct SIMD type with different scalar type.
    Definition simd/interface.hh:253
    │ │ │ │ +
    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
    │ │ │ │ +
    Mask< V > mask(ADLTag< 0, std::is_same< V, Mask< V > >::value >, const V &v)
    implements Simd::mask()
    Definition defaults.hh:153
    │ │ │ │ +
    STL namespace.
    │ │ │ │ +
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ +
    void swap(T &v1, T &v2, bool mask)
    Definition simd.hh:472
    │ │ │ │ +
    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
    │ │ │ │ +
    static void multAssign(const DenseMatrix< MAT > &matrix, const DenseVector< V1 > &x, DenseVector< V2 > &ret)
    calculates ret = matrix * x
    Definition densematrix.hh:1169
    │ │ │ │ +
    A dense n x m matrix.
    Definition densematrix.hh:140
    │ │ │ │ +
    ConstIterator const_iterator
    typedef for stl compliant access
    Definition densematrix.hh:244
    │ │ │ │ +
    derived_type operator-() const
    Matrix negation.
    Definition densematrix.hh:298
    │ │ │ │ +
    void solve(V1 &x, const V2 &b, bool doPivoting=true) const
    Solve system A x = b.
    │ │ │ │ +
    void mv(const X &x, Y &y) const
    y = A x
    Definition densematrix.hh:368
    │ │ │ │ +
    Traits::value_type field_type
    export the type representing the field
    Definition densematrix.hh:160
    │ │ │ │ +
    derived_type & axpy(const field_type &a, const DenseMatrix< Other > &x)
    vector space axpy operation (*this += a x)
    Definition densematrix.hh:338
    │ │ │ │ +
    ConstIterator beforeEnd() const
    Definition densematrix.hh:264
    │ │ │ │ +
    derived_type & operator=(const RHS &rhs)
    Definition densematrix.hh:279
    │ │ │ │ +
    void mmtv(const X &x, Y &y) const
    y -= A^T x
    Definition densematrix.hh:458
    │ │ │ │ +
    FieldTraits< vt >::real_type infinity_norm_real() const
    simplified infinity norm (uses Manhattan norm for complex values)
    Definition densematrix.hh:561
    │ │ │ │ +
    std::remove_reference< const_row_reference >::type::ConstIterator ConstColIterator
    rename the iterators for easier access
    Definition densematrix.hh:248
    │ │ │ │ +
    ConstIterator beforeBegin() const
    Definition densematrix.hh:271
    │ │ │ │ +
    void invert(bool doPivoting=true)
    Compute inverse.
    │ │ │ │ +
    static void luDecomposition(DenseMatrix< MAT > &A, Func func, Mask &nonsingularLanes, bool throwEarly, bool doPivoting)
    do an LU-Decomposition on matrix A
    │ │ │ │ +
    Traits::value_type block_type
    export the type representing the components
    Definition densematrix.hh:163
    │ │ │ │ +
    void mtv(const X &x, Y &y) const
    y = A^T x
    Definition densematrix.hh:387
    │ │ │ │ +
    constexpr size_type cols() const
    number of columns
    Definition densematrix.hh:715
    │ │ │ │ +
    size_type size() const
    size method (number of rows)
    Definition densematrix.hh:200
    │ │ │ │ +
    constexpr size_type M() const
    number of columns
    Definition densematrix.hh:703
    │ │ │ │ +
    MAT & rightmultiply(const DenseMatrix< M2 > &M)
    Multiplies M from the right to this matrix.
    Definition densematrix.hh:645
    │ │ │ │ +
    Iterator end()
    end iterator
    Definition densematrix.hh:222
    │ │ │ │ +
    Iterator beforeBegin()
    Definition densematrix.hh:236
    │ │ │ │ +
    derived_type & operator/=(const field_type &k)
    vector space division by scalar
    Definition densematrix.hh:329
    │ │ │ │ +
    derived_type & operator*=(const field_type &k)
    vector space multiplication with scalar
    Definition densematrix.hh:321
    │ │ │ │ +
    Iterator beforeEnd()
    Definition densematrix.hh:229
    │ │ │ │ +
    Traits::value_type value_type
    export the type representing the field
    Definition densematrix.hh:157
    │ │ │ │ +
    void usmv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) const
    y += alpha A x
    Definition densematrix.hh:484
    │ │ │ │ +
    void usmhv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) const
    y += alpha A^H x
    Definition densematrix.hh:512
    │ │ │ │ +
    void mmv(const X &x, Y &y) const
    y -= A x
    Definition densematrix.hh:445
    │ │ │ │ +
    constexpr size_type rows() const
    number of rows
    Definition densematrix.hh:709
    │ │ │ │ +
    MAT & leftmultiply(const DenseMatrix< M2 > &M)
    Multiplies M from the left to this matrix.
    Definition densematrix.hh:627
    │ │ │ │ +
    void usmtv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) const
    y += alpha A^T x
    Definition densematrix.hh:498
    │ │ │ │ +
    derived_type & operator-=(const DenseMatrix< Other > &x)
    vector space subtraction
    Definition densematrix.hh:312
    │ │ │ │ +
    bool operator!=(const DenseMatrix< Other > &x) const
    Binary matrix incomparison.
    Definition densematrix.hh:358
    │ │ │ │ +
    void mmhv(const X &x, Y &y) const
    y -= A^H x
    Definition densematrix.hh:471
    │ │ │ │ +
    Traits::derived_type derived_type
    type of derived matrix class
    Definition densematrix.hh:154
    │ │ │ │ +
    row_reference operator[](size_type i)
    random access
    Definition densematrix.hh:189
    │ │ │ │ +
    bool exists(size_type i, size_type j) const
    return true when (i,j) is in pattern
    Definition densematrix.hh:723
    │ │ │ │ +
    Iterator RowIterator
    rename the iterators for easier access
    Definition densematrix.hh:211
    │ │ │ │ +
    static constexpr int blocklevel
    The number of block levels we contain. This is the leaf, that is, 1.
    Definition densematrix.hh:178
    │ │ │ │ +
    FieldTraits< value_type >::real_type frobenius_norm() const
    frobenius norm: sqrt(sum over squared values of entries)
    Definition densematrix.hh:528
    │ │ │ │ +
    void umv(const X &x, Y &y) const
    y += A x
    Definition densematrix.hh:406
    │ │ │ │ +
    DenseIterator< const DenseMatrix, const row_type, const_row_reference > ConstIterator
    Iterator class for sequential access.
    Definition densematrix.hh:242
    │ │ │ │ +
    FieldTraits< vt >::real_type infinity_norm() const
    infinity norm (row sum norm, how to generalize for blocks?)
    Definition densematrix.hh:546
    │ │ │ │ +
    Traits::row_type row_type
    The type used to represent a row (must fulfill the Dune::DenseVector interface)
    Definition densematrix.hh:169
    │ │ │ │ +
    constexpr size_type N() const
    number of rows
    Definition densematrix.hh:697
    │ │ │ │ +
    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
    │ │ │ │ +
    FieldTraits< value_type >::real_type frobenius_norm2() const
    square of frobenius norm, need for block recursion
    Definition densematrix.hh:536
    │ │ │ │ +
    std::remove_reference< row_reference >::type::Iterator ColIterator
    rename the iterators for easier access
    Definition densematrix.hh:213
    │ │ │ │ +
    Traits::row_reference row_reference
    The type used to represent a reference to a row (usually row_type &)
    Definition densematrix.hh:172
    │ │ │ │ +
    bool operator==(const DenseMatrix< Other > &x) const
    Binary matrix comparison.
    Definition densematrix.hh:348
    │ │ │ │ +
    Iterator iterator
    typedef for stl compliant access
    Definition densematrix.hh:209
    │ │ │ │ +
    ConstIterator ConstRowIterator
    rename the iterators for easier access
    Definition densematrix.hh:246
    │ │ │ │ +
    DenseIterator< DenseMatrix, row_type, row_reference > Iterator
    Iterator class for sequential access.
    Definition densematrix.hh:207
    │ │ │ │ +
    void umtv(const X &x, Y &y) const
    y += A^T x
    Definition densematrix.hh:419
    │ │ │ │ +
    ConstIterator begin() const
    begin iterator
    Definition densematrix.hh:251
    │ │ │ │ +
    field_type determinant(bool doPivoting=true) const
    calculates the determinant of this matrix
    │ │ │ │ +
    Iterator begin()
    begin iterator
    Definition densematrix.hh:216
    │ │ │ │ +
    void umhv(const X &x, Y &y) const
    y += A^H x
    Definition densematrix.hh:432
    │ │ │ │ +
    derived_type & operator+=(const DenseMatrix< Other > &x)
    vector space addition
    Definition densematrix.hh:289
    │ │ │ │ +
    ConstIterator end() const
    end iterator
    Definition densematrix.hh:257
    │ │ │ │ +
    const FieldTraits< typenameDenseMatVecTraits< M >::value_type >::real_type real_type
    Definition densematrix.hh:34
    │ │ │ │ +
    const FieldTraits< typenameDenseMatVecTraits< M >::value_type >::field_type field_type
    Definition densematrix.hh:33
    │ │ │ │ +
    A dense n x m matrix.
    Definition fmatrix.hh:117
    │ │ │ │ +
    Base::size_type size_type
    Definition fmatrix.hh:127
    │ │ │ │ +
    vector space out of a tensor product of fields.
    Definition fvector.hh:95
    │ │ │ │ +
    you have to specialize this structure for any type that should be assignable to a DenseMatrix
    Definition densematrix.hh:59
    │ │ │ │ +
    Error thrown if operations of a FieldMatrix fail.
    Definition densematrix.hh:126
    │ │ │ │ +
    Interface for a class of dense vectors over a given field.
    Definition densevector.hh:229
    │ │ │ │ +
    size_type size() const
    size method
    Definition densevector.hh:336
    │ │ │ │ +
    Generic iterator class for dense vector and matrix implementations.
    Definition densevector.hh:131
    │ │ │ │ +
    Default exception class for mathematical errors.
    Definition exceptions.hh:241
    │ │ │ │ +
    Definition ftraits.hh:26
    │ │ │ │ +
    T field_type
    export the type representing the field
    Definition ftraits.hh:28
    │ │ │ │ +
    T real_type
    export the type representing the real type of the field
    Definition ftraits.hh:30
    │ │ │ │ +
    Definition matvectraits.hh:31
    │ │ │ │ +
    static ctype absolute_limit()
    return threshold to declare matrix singular
    Definition precision.hh:28
    │ │ │ │ +
    Include file for users of the SIMD abstraction layer.
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,22 +7,1526 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -unused.hh │ │ │ │ │ +densematrix.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 (C) 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_UNUSED_HH │ │ │ │ │ - 6#define DUNE_COMMON_UNUSED_HH │ │ │ │ │ + 5#ifndef DUNE_DENSEMATRIX_HH │ │ │ │ │ + 6#define DUNE_DENSEMATRIX_HH │ │ │ │ │ 7 │ │ │ │ │ -21#define DUNE_UNUSED_PARAMETER(param) static_cast(param) │ │ │ │ │ - 22#endif │ │ │ │ │ + 8#include │ │ │ │ │ + 9#include │ │ │ │ │ + 10#include │ │ │ │ │ + 11#include │ │ │ │ │ + 12#include │ │ │ │ │ + 13#include │ │ │ │ │ + 14 │ │ │ │ │ + 15#include │ │ │ │ │ + 16#include │ │ │ │ │ + 17#include │ │ │ │ │ + 18#include │ │ │ │ │ + 19#include │ │ │ │ │ + 20#include │ │ │ │ │ + 21#include │ │ │ │ │ + 22#include │ │ │ │ │ + 23#include │ │ │ │ │ + 24 │ │ │ │ │ + 25namespace Dune │ │ │ │ │ + 26{ │ │ │ │ │ + 27 │ │ │ │ │ + 28 template class DenseMatrix; │ │ │ │ │ + 29 │ │ │ │ │ + 30 template │ │ │ │ │ +31 struct FieldTraits< DenseMatrix > │ │ │ │ │ + 32 { │ │ │ │ │ +33 typedef const typename FieldTraits<_typename_DenseMatVecTraits:: │ │ │ │ │ +value_type >::field_type field_type; │ │ │ │ │ +34 typedef const typename FieldTraits<_typename_DenseMatVecTraits:: │ │ │ │ │ +value_type >::real_type real_type; │ │ │ │ │ + 35 }; │ │ │ │ │ + 36 │ │ │ │ │ + 37 template class FieldMatrix; │ │ │ │ │ + 38 template class FieldVector; │ │ │ │ │ + 39 │ │ │ │ │ + 58 template< class DenseMatrix, class RHS > │ │ │ │ │ +59 struct DenseMatrixAssigner; │ │ │ │ │ + 60 │ │ │ │ │ + 61#ifndef DOXYGEN │ │ │ │ │ + 62 namespace Impl │ │ │ │ │ + 63 { │ │ │ │ │ + 64 │ │ │ │ │ + 65 template< class DenseMatrix, class RHS, class = void > │ │ │ │ │ + 66 class DenseMatrixAssigner │ │ │ │ │ + 67 {}; │ │ │ │ │ + 68 │ │ │ │ │ + 69 template< class DenseMatrix, class RHS > │ │ │ │ │ + 70 class DenseMatrixAssigner< DenseMatrix, RHS, std::enable_if_t< Dune:: │ │ │ │ │ +IsNumber< RHS >::value > > │ │ │ │ │ + 71 { │ │ │ │ │ + 72 public: │ │ │ │ │ + 73 static void apply ( DenseMatrix &denseMatrix, const RHS &rhs ) │ │ │ │ │ + 74 { │ │ │ │ │ + 75 typedef typename DenseMatrix::field_type field_type; │ │ │ │ │ + 76 std::fill( denseMatrix.begin(), denseMatrix.end(), static_cast< field_type │ │ │ │ │ +>( rhs ) ); │ │ │ │ │ + 77 } │ │ │ │ │ + 78 }; │ │ │ │ │ + 79 │ │ │ │ │ + 80 template< class DenseMatrix, class RHS > │ │ │ │ │ + 81 class DenseMatrixAssigner< DenseMatrix, RHS, std::enable_if_t< !std:: │ │ │ │ │ +is_same< typename RHS::const_iterator, void >::value │ │ │ │ │ + 82 && std::is_convertible< typename RHS::const_iterator::value_type, typename │ │ │ │ │ +DenseMatrix::iterator::value_type >::value > > │ │ │ │ │ + 83 { │ │ │ │ │ + 84 public: │ │ │ │ │ + 85 static void apply ( DenseMatrix &denseMatrix, const RHS &rhs ) │ │ │ │ │ + 86 { │ │ │ │ │ + 87 DUNE_ASSERT_BOUNDS(rhs.N() == denseMatrix.N()); │ │ │ │ │ + 88 DUNE_ASSERT_BOUNDS(rhs.M() == denseMatrix.M()); │ │ │ │ │ + 89 typename DenseMatrix::iterator tIt = std::begin(denseMatrix); │ │ │ │ │ + 90 typename RHS::const_iterator sIt = std::begin(rhs); │ │ │ │ │ + 91 for(; sIt != std::end(rhs); ++tIt, ++sIt) │ │ │ │ │ + 92 std::copy(std::begin(*sIt), std::end(*sIt), std::begin(*tIt)); │ │ │ │ │ + 93 } │ │ │ │ │ + 94 }; │ │ │ │ │ + 95 │ │ │ │ │ + 96 } // namespace Impl │ │ │ │ │ + 97 │ │ │ │ │ + 98 │ │ │ │ │ + 99 │ │ │ │ │ + 100 template< class DenseMatrix, class RHS > │ │ │ │ │ + 101 struct DenseMatrixAssigner │ │ │ │ │ + 102 : public Impl::DenseMatrixAssigner< DenseMatrix, RHS > │ │ │ │ │ + 103 {}; │ │ │ │ │ + 104 │ │ │ │ │ + 105 │ │ │ │ │ + 106 namespace Impl │ │ │ │ │ + 107 { │ │ │ │ │ + 108 │ │ │ │ │ + 109 template< class DenseMatrix, class RHS > │ │ │ │ │ + 110 std::true_type hasDenseMatrixAssigner ( DenseMatrix &, const RHS &, │ │ │ │ │ +decltype( Dune::DenseMatrixAssigner<_DenseMatrix,_RHS_>::apply( std::declval< │ │ │ │ │ +DenseMatrix & >(), std::declval< const RHS & >() ) ) * = nullptr ); │ │ │ │ │ + 111 │ │ │ │ │ + 112 std::false_type hasDenseMatrixAssigner ( ... ); │ │ │ │ │ + 113 │ │ │ │ │ + 114 } // namespace Impl │ │ │ │ │ + 115 │ │ │ │ │ + 116 template< class DenseMatrix, class RHS > │ │ │ │ │ + 117 struct HasDenseMatrixAssigner │ │ │ │ │ + 118 : public decltype( Impl::hasDenseMatrixAssigner( std::declval< DenseMatrix │ │ │ │ │ +& >(), std::declval< const RHS & >() ) ) │ │ │ │ │ + 119 {}; │ │ │ │ │ + 120 │ │ │ │ │ + 121#endif // #ifndef DOXYGEN │ │ │ │ │ + 122 │ │ │ │ │ + 123 │ │ │ │ │ + 124 │ │ │ │ │ +126 class FMatrixError : public MathError {}; │ │ │ │ │ + 127 │ │ │ │ │ + 138 template │ │ │ │ │ +139 class DenseMatrix │ │ │ │ │ + 140 { │ │ │ │ │ + 141 typedef DenseMatVecTraits Traits; │ │ │ │ │ + 142 │ │ │ │ │ + 143 // Curiously recurring template pattern │ │ │ │ │ + 144 constexpr MAT & asImp() { return static_cast(*this); } │ │ │ │ │ + 145 constexpr const MAT & asImp() const { return static_cast │ │ │ │ │ +(*this); } │ │ │ │ │ + 146 │ │ │ │ │ + 147 template │ │ │ │ │ +148 friend class DenseMatrix; │ │ │ │ │ + 149 │ │ │ │ │ + 150 public: │ │ │ │ │ + 151 //===== type definitions and constants │ │ │ │ │ + 152 │ │ │ │ │ +154 typedef typename Traits::derived_type derived_type; │ │ │ │ │ + 155 │ │ │ │ │ +157 typedef typename Traits::value_type value_type; │ │ │ │ │ + 158 │ │ │ │ │ +160 typedef typename Traits::value_type field_type; │ │ │ │ │ + 161 │ │ │ │ │ +163 typedef typename Traits::value_type block_type; │ │ │ │ │ + 164 │ │ │ │ │ +166 typedef typename Traits::size_type size_type; │ │ │ │ │ + 167 │ │ │ │ │ +169 typedef typename Traits::row_type row_type; │ │ │ │ │ + 170 │ │ │ │ │ +172 typedef typename Traits::row_reference row_reference; │ │ │ │ │ + 173 │ │ │ │ │ +175 typedef typename Traits::const_row_reference const_row_reference; │ │ │ │ │ + 176 │ │ │ │ │ +178 constexpr static int blocklevel = 1; │ │ │ │ │ + 179 │ │ │ │ │ + 180 private: │ │ │ │ │ + 183 using simd_index_type = Simd::Rebind; │ │ │ │ │ + 184 │ │ │ │ │ + 185 public: │ │ │ │ │ + 186 //===== access to components │ │ │ │ │ + 187 │ │ │ │ │ +189 row_reference operator[]( size_type i ) │ │ │ │ │ + 190 { │ │ │ │ │ + 191 return asImp().mat_access(i); │ │ │ │ │ + 192 } │ │ │ │ │ + 193 │ │ │ │ │ +194 const_row_reference operator[]( size_type i ) const │ │ │ │ │ + 195 { │ │ │ │ │ + 196 return asImp().mat_access(i); │ │ │ │ │ + 197 } │ │ │ │ │ + 198 │ │ │ │ │ +200 size_type size() const │ │ │ │ │ + 201 { │ │ │ │ │ + 202 return rows(); │ │ │ │ │ + 203 } │ │ │ │ │ + 204 │ │ │ │ │ + 205 //===== iterator interface to rows of the matrix │ │ │ │ │ +207 typedef DenseIterator Iterator; │ │ │ │ │ +209 typedef Iterator iterator; │ │ │ │ │ +211 typedef Iterator RowIterator; │ │ │ │ │ +213 typedef typename std::remove_reference::type::Iterator │ │ │ │ │ +ColIterator; │ │ │ │ │ + 214 │ │ │ │ │ +216 Iterator begin () │ │ │ │ │ + 217 { │ │ │ │ │ + 218 return Iterator(*this,0); │ │ │ │ │ + 219 } │ │ │ │ │ + 220 │ │ │ │ │ +222 Iterator end () │ │ │ │ │ + 223 { │ │ │ │ │ + 224 return Iterator(*this,rows()); │ │ │ │ │ + 225 } │ │ │ │ │ + 226 │ │ │ │ │ +229 Iterator beforeEnd () │ │ │ │ │ + 230 { │ │ │ │ │ + 231 return Iterator(*this,rows()-1); │ │ │ │ │ + 232 } │ │ │ │ │ + 233 │ │ │ │ │ +236 Iterator beforeBegin () │ │ │ │ │ + 237 { │ │ │ │ │ + 238 return Iterator(*this,-1); │ │ │ │ │ + 239 } │ │ │ │ │ + 240 │ │ │ │ │ +242 typedef DenseIterator │ │ │ │ │ +ConstIterator; │ │ │ │ │ +244 typedef ConstIterator const_iterator; │ │ │ │ │ +246 typedef ConstIterator ConstRowIterator; │ │ │ │ │ +248 typedef typename std::remove_reference::type:: │ │ │ │ │ +ConstIterator ConstColIterator; │ │ │ │ │ + 249 │ │ │ │ │ +251 ConstIterator begin () const │ │ │ │ │ + 252 { │ │ │ │ │ + 253 return ConstIterator(*this,0); │ │ │ │ │ + 254 } │ │ │ │ │ + 255 │ │ │ │ │ +257 ConstIterator end () const │ │ │ │ │ + 258 { │ │ │ │ │ + 259 return ConstIterator(*this,rows()); │ │ │ │ │ + 260 } │ │ │ │ │ + 261 │ │ │ │ │ +264 ConstIterator beforeEnd () const │ │ │ │ │ + 265 { │ │ │ │ │ + 266 return ConstIterator(*this,rows()-1); │ │ │ │ │ + 267 } │ │ │ │ │ + 268 │ │ │ │ │ +271 ConstIterator beforeBegin () const │ │ │ │ │ + 272 { │ │ │ │ │ + 273 return ConstIterator(*this,-1); │ │ │ │ │ + 274 } │ │ │ │ │ + 275 │ │ │ │ │ + 276 //===== assignment │ │ │ │ │ + 277 │ │ │ │ │ + 278 template< class RHS, class = std::enable_if_t< HasDenseMatrixAssigner< │ │ │ │ │ +MAT, RHS >::value > > │ │ │ │ │ +279 derived_type &operator=( const RHS &rhs ) │ │ │ │ │ + 280 { │ │ │ │ │ + 281 DenseMatrixAssigner<_MAT,_RHS_>::apply( asImp(), rhs ); │ │ │ │ │ + 282 return asImp(); │ │ │ │ │ + 283 } │ │ │ │ │ + 284 │ │ │ │ │ + 285 //===== vector space arithmetic │ │ │ │ │ + 286 │ │ │ │ │ + 288 template │ │ │ │ │ +289 derived_type &operator+=(const DenseMatrix& x) │ │ │ │ │ + 290 { │ │ │ │ │ + 291 DUNE_ASSERT_BOUNDS(rows() == x.rows()); │ │ │ │ │ + 292 for (size_type i=0; i │ │ │ │ │ +312 derived_type &operator-=(const DenseMatrix& x) │ │ │ │ │ + 313 { │ │ │ │ │ + 314 DUNE_ASSERT_BOUNDS(rows() == x.rows()); │ │ │ │ │ + 315 for (size_type i=0; i │ │ │ │ │ +338 derived_type &axpy (const field_type &a, const DenseMatrix &x ) │ │ │ │ │ + 339 { │ │ │ │ │ + 340 DUNE_ASSERT_BOUNDS(rows() == x.rows()); │ │ │ │ │ + 341 for( size_type i = 0; i < rows(); ++i ) │ │ │ │ │ + 342 (*this)[ i ].axpy( a, x[ i ] ); │ │ │ │ │ + 343 return asImp(); │ │ │ │ │ + 344 } │ │ │ │ │ + 345 │ │ │ │ │ + 347 template │ │ │ │ │ +348 bool operator==(const DenseMatrix& x) const │ │ │ │ │ + 349 { │ │ │ │ │ + 350 DUNE_ASSERT_BOUNDS(rows() == x.rows()); │ │ │ │ │ + 351 for (size_type i=0; i │ │ │ │ │ +358 bool operator!=(const DenseMatrix& x) const │ │ │ │ │ + 359 { │ │ │ │ │ + 360 return !operator==(x); │ │ │ │ │ + 361 } │ │ │ │ │ + 362 │ │ │ │ │ + 363 │ │ │ │ │ + 364 //===== linear maps │ │ │ │ │ + 365 │ │ │ │ │ + 367 template │ │ │ │ │ +368 void mv (const X& x, Y& y) const │ │ │ │ │ + 369 { │ │ │ │ │ + 370 auto&& xx = Impl::asVector(x); │ │ │ │ │ + 371 auto&& yy = Impl::asVector(y); │ │ │ │ │ + 372 DUNE_ASSERT_BOUNDS((void*)(&x) != (void*)(&y)); │ │ │ │ │ + 373 DUNE_ASSERT_BOUNDS(xx.N() == M()); │ │ │ │ │ + 374 DUNE_ASSERT_BOUNDS(yy.N() == N()); │ │ │ │ │ + 375 │ │ │ │ │ + 376 using y_field_type = typename FieldTraits::field_type; │ │ │ │ │ + 377 for (size_type i=0; i │ │ │ │ │ +387 void mtv ( const X &x, Y &y ) const │ │ │ │ │ + 388 { │ │ │ │ │ + 389 auto&& xx = Impl::asVector(x); │ │ │ │ │ + 390 auto&& yy = Impl::asVector(y); │ │ │ │ │ + 391 DUNE_ASSERT_BOUNDS((void*)(&x) != (void*)(&y)); │ │ │ │ │ + 392 DUNE_ASSERT_BOUNDS(xx.N() == N()); │ │ │ │ │ + 393 DUNE_ASSERT_BOUNDS(yy.N() == M()); │ │ │ │ │ + 394 │ │ │ │ │ + 395 using y_field_type = typename FieldTraits::field_type; │ │ │ │ │ + 396 for(size_type i = 0; i < cols(); ++i) │ │ │ │ │ + 397 { │ │ │ │ │ + 398 yy[i] = y_field_type(0); │ │ │ │ │ + 399 for(size_type j = 0; j < rows(); ++j) │ │ │ │ │ + 400 yy[i] += (*this)[j][i] * xx[j]; │ │ │ │ │ + 401 } │ │ │ │ │ + 402 } │ │ │ │ │ + 403 │ │ │ │ │ + 405 template │ │ │ │ │ +406 void umv (const X& x, Y& y) const │ │ │ │ │ + 407 { │ │ │ │ │ + 408 auto&& xx = Impl::asVector(x); │ │ │ │ │ + 409 auto&& yy = Impl::asVector(y); │ │ │ │ │ + 410 DUNE_ASSERT_BOUNDS(xx.N() == M()); │ │ │ │ │ + 411 DUNE_ASSERT_BOUNDS(yy.N() == N()); │ │ │ │ │ + 412 for (size_type i=0; i │ │ │ │ │ +419 void umtv (const X& x, Y& y) const │ │ │ │ │ + 420 { │ │ │ │ │ + 421 auto&& xx = Impl::asVector(x); │ │ │ │ │ + 422 auto&& yy = Impl::asVector(y); │ │ │ │ │ + 423 DUNE_ASSERT_BOUNDS(xx.N() == N()); │ │ │ │ │ + 424 DUNE_ASSERT_BOUNDS(yy.N() == M()); │ │ │ │ │ + 425 for(size_type i = 0; i │ │ │ │ │ +432 void umhv (const X& x, Y& y) const │ │ │ │ │ + 433 { │ │ │ │ │ + 434 auto&& xx = Impl::asVector(x); │ │ │ │ │ + 435 auto&& yy = Impl::asVector(y); │ │ │ │ │ + 436 DUNE_ASSERT_BOUNDS(xx.N() == N()); │ │ │ │ │ + 437 DUNE_ASSERT_BOUNDS(yy.N() == M()); │ │ │ │ │ + 438 for (size_type i=0; i │ │ │ │ │ +445 void mmv (const X& x, Y& y) const │ │ │ │ │ + 446 { │ │ │ │ │ + 447 auto&& xx = Impl::asVector(x); │ │ │ │ │ + 448 auto&& yy = Impl::asVector(y); │ │ │ │ │ + 449 DUNE_ASSERT_BOUNDS(xx.N() == M()); │ │ │ │ │ + 450 DUNE_ASSERT_BOUNDS(yy.N() == N()); │ │ │ │ │ + 451 for (size_type i=0; i │ │ │ │ │ +458 void mmtv (const X& x, Y& y) const │ │ │ │ │ + 459 { │ │ │ │ │ + 460 auto&& xx = Impl::asVector(x); │ │ │ │ │ + 461 auto&& yy = Impl::asVector(y); │ │ │ │ │ + 462 DUNE_ASSERT_BOUNDS(xx.N() == N()); │ │ │ │ │ + 463 DUNE_ASSERT_BOUNDS(yy.N() == M()); │ │ │ │ │ + 464 for (size_type i=0; i │ │ │ │ │ +471 void mmhv (const X& x, Y& y) const │ │ │ │ │ + 472 { │ │ │ │ │ + 473 auto&& xx = Impl::asVector(x); │ │ │ │ │ + 474 auto&& yy = Impl::asVector(y); │ │ │ │ │ + 475 DUNE_ASSERT_BOUNDS(xx.N() == N()); │ │ │ │ │ + 476 DUNE_ASSERT_BOUNDS(yy.N() == M()); │ │ │ │ │ + 477 for (size_type i=0; i │ │ │ │ │ +484 void usmv (const typename FieldTraits::field_type & alpha, │ │ │ │ │ + 485 const X& x, Y& y) const │ │ │ │ │ + 486 { │ │ │ │ │ + 487 auto&& xx = Impl::asVector(x); │ │ │ │ │ + 488 auto&& yy = Impl::asVector(y); │ │ │ │ │ + 489 DUNE_ASSERT_BOUNDS(xx.N() == M()); │ │ │ │ │ + 490 DUNE_ASSERT_BOUNDS(yy.N() == N()); │ │ │ │ │ + 491 for (size_type i=0; i │ │ │ │ │ +498 void usmtv (const typename FieldTraits::field_type & alpha, │ │ │ │ │ + 499 const X& x, Y& y) const │ │ │ │ │ + 500 { │ │ │ │ │ + 501 auto&& xx = Impl::asVector(x); │ │ │ │ │ + 502 auto&& yy = Impl::asVector(y); │ │ │ │ │ + 503 DUNE_ASSERT_BOUNDS(xx.N() == N()); │ │ │ │ │ + 504 DUNE_ASSERT_BOUNDS(yy.N() == M()); │ │ │ │ │ + 505 for (size_type i=0; i │ │ │ │ │ +512 void usmhv (const typename FieldTraits::field_type & alpha, │ │ │ │ │ + 513 const X& x, Y& y) const │ │ │ │ │ + 514 { │ │ │ │ │ + 515 auto&& xx = Impl::asVector(x); │ │ │ │ │ + 516 auto&& yy = Impl::asVector(y); │ │ │ │ │ + 517 DUNE_ASSERT_BOUNDS(xx.N() == N()); │ │ │ │ │ + 518 DUNE_ASSERT_BOUNDS(yy.N() == M()); │ │ │ │ │ + 519 for (size_type i=0; i::real_type frobenius_norm () const │ │ │ │ │ + 529 { │ │ │ │ │ + 530 typename FieldTraits::real_type sum=(0.0); │ │ │ │ │ + 531 for (size_type i=0; i::real_type frobenius_norm2 () const │ │ │ │ │ + 537 { │ │ │ │ │ + 538 typename FieldTraits::real_type sum=(0.0); │ │ │ │ │ + 539 for (size_type i=0; i::value, int>::type = 0> │ │ │ │ │ +546 typename FieldTraits::real_type infinity_norm() const { │ │ │ │ │ + 547 using real_type = typename FieldTraits::real_type; │ │ │ │ │ + 548 using std::max; │ │ │ │ │ + 549 │ │ │ │ │ + 550 real_type norm = 0; │ │ │ │ │ + 551 for (auto const &x : *this) { │ │ │ │ │ + 552 real_type const a = x.one_norm(); │ │ │ │ │ + 553 norm = max(a, norm); │ │ │ │ │ + 554 } │ │ │ │ │ + 555 return norm; │ │ │ │ │ + 556 } │ │ │ │ │ + 557 │ │ │ │ │ + 559 template ::value, int>::type = 0> │ │ │ │ │ +561 typename FieldTraits::real_type infinity_norm_real() const { │ │ │ │ │ + 562 using real_type = typename FieldTraits::real_type; │ │ │ │ │ + 563 using std::max; │ │ │ │ │ + 564 │ │ │ │ │ + 565 real_type norm = 0; │ │ │ │ │ + 566 for (auto const &x : *this) { │ │ │ │ │ + 567 real_type const a = x.one_norm_real(); │ │ │ │ │ + 568 norm = max(a, norm); │ │ │ │ │ + 569 } │ │ │ │ │ + 570 return norm; │ │ │ │ │ + 571 } │ │ │ │ │ + 572 │ │ │ │ │ + 574 template ::value, int>::type = 0> │ │ │ │ │ +576 typename FieldTraits::real_type infinity_norm() const { │ │ │ │ │ + 577 using real_type = typename FieldTraits::real_type; │ │ │ │ │ + 578 using std::max; │ │ │ │ │ + 579 │ │ │ │ │ + 580 real_type norm = 0; │ │ │ │ │ + 581 real_type isNaN = 1; │ │ │ │ │ + 582 for (auto const &x : *this) { │ │ │ │ │ + 583 real_type const a = x.one_norm(); │ │ │ │ │ + 584 norm = max(a, norm); │ │ │ │ │ + 585 isNaN += a; │ │ │ │ │ + 586 } │ │ │ │ │ + 587 return norm * (isNaN / isNaN); │ │ │ │ │ + 588 } │ │ │ │ │ + 589 │ │ │ │ │ + 591 template ::value, int>::type = 0> │ │ │ │ │ +593 typename FieldTraits::real_type infinity_norm_real() const { │ │ │ │ │ + 594 using real_type = typename FieldTraits::real_type; │ │ │ │ │ + 595 using std::max; │ │ │ │ │ + 596 │ │ │ │ │ + 597 real_type norm = 0; │ │ │ │ │ + 598 real_type isNaN = 1; │ │ │ │ │ + 599 for (auto const &x : *this) { │ │ │ │ │ + 600 real_type const a = x.one_norm_real(); │ │ │ │ │ + 601 norm = max(a, norm); │ │ │ │ │ + 602 isNaN += a; │ │ │ │ │ + 603 } │ │ │ │ │ + 604 return norm * (isNaN / isNaN); │ │ │ │ │ + 605 } │ │ │ │ │ + 606 │ │ │ │ │ + 607 //===== solve │ │ │ │ │ + 608 │ │ │ │ │ + 613 template │ │ │ │ │ +614 void solve (V1& x, const V2& b, bool doPivoting = true) const; │ │ │ │ │ + 615 │ │ │ │ │ +620 void invert(bool doPivoting = true); │ │ │ │ │ + 621 │ │ │ │ │ +623 field_type determinant (bool doPivoting = true) const; │ │ │ │ │ + 624 │ │ │ │ │ + 626 template │ │ │ │ │ +627 MAT& leftmultiply (const DenseMatrix& M) │ │ │ │ │ + 628 { │ │ │ │ │ + 629 DUNE_ASSERT_BOUNDS(M.rows() == M.cols()); │ │ │ │ │ + 630 DUNE_ASSERT_BOUNDS(M.rows() == rows()); │ │ │ │ │ + 631 AutonomousValue C(asImp()); │ │ │ │ │ + 632 │ │ │ │ │ + 633 for (size_type i=0; i │ │ │ │ │ +645 MAT& rightmultiply (const DenseMatrix& M) │ │ │ │ │ + 646 { │ │ │ │ │ + 647 DUNE_ASSERT_BOUNDS(M.rows() == M.cols()); │ │ │ │ │ + 648 DUNE_ASSERT_BOUNDS(M.cols() == cols()); │ │ │ │ │ + 649 AutonomousValue C(asImp()); │ │ │ │ │ + 650 │ │ │ │ │ + 651 for (size_type i=0; i │ │ │ │ │ + 663 DenseMatrix leftmultiplyany (const FieldMatrix& M) │ │ │ │ │ +const │ │ │ │ │ + 664 { │ │ │ │ │ + 665 FieldMatrix C; │ │ │ │ │ + 666 │ │ │ │ │ + 667 for (size_type i=0; i │ │ │ │ │ + 679 FieldMatrix rightmultiplyany (const FieldMatrix& M) │ │ │ │ │ +const │ │ │ │ │ + 680 { │ │ │ │ │ + 681 FieldMatrix C; │ │ │ │ │ + 682 │ │ │ │ │ + 683 for (size_type i=0; i= 0 && i < rows()); │ │ │ │ │ + 726 DUNE_ASSERT_BOUNDS(j >= 0 && j < cols()); │ │ │ │ │ + 727 return true; │ │ │ │ │ + 728 } │ │ │ │ │ + 729 │ │ │ │ │ + 730 protected: │ │ │ │ │ + 731 │ │ │ │ │ + 732#ifndef DOXYGEN │ │ │ │ │ + 733 struct ElimPivot │ │ │ │ │ + 734 { │ │ │ │ │ + 735 ElimPivot(std::vector & pivot); │ │ │ │ │ + 736 │ │ │ │ │ + 737 void swap(std::size_t i, simd_index_type j); │ │ │ │ │ + 738 │ │ │ │ │ + 739 template │ │ │ │ │ + 740 void operator()(const T&, int, int) │ │ │ │ │ + 741 {} │ │ │ │ │ + 742 │ │ │ │ │ + 743 std::vector & pivot_; │ │ │ │ │ + 744 }; │ │ │ │ │ + 745 │ │ │ │ │ + 746 template │ │ │ │ │ + 747 struct Elim │ │ │ │ │ + 748 { │ │ │ │ │ + 749 Elim(V& rhs); │ │ │ │ │ + 750 │ │ │ │ │ + 751 void swap(std::size_t i, simd_index_type j); │ │ │ │ │ + 752 │ │ │ │ │ + 753 void operator()(const typename V::field_type& factor, int k, int i); │ │ │ │ │ + 754 │ │ │ │ │ + 755 V* rhs_; │ │ │ │ │ + 756 }; │ │ │ │ │ + 757 │ │ │ │ │ + 758 struct ElimDet │ │ │ │ │ + 759 { │ │ │ │ │ + 760 ElimDet(field_type& sign) : sign_(sign) │ │ │ │ │ + 761 { sign_ = 1; } │ │ │ │ │ + 762 │ │ │ │ │ + 763 void swap(std::size_t i, simd_index_type j) │ │ │ │ │ + 764 { │ │ │ │ │ + 765 sign_ *= │ │ │ │ │ + 766 Simd::cond(simd_index_type(i) == j, field_type(1), field_type(-1)); │ │ │ │ │ + 767 } │ │ │ │ │ + 768 │ │ │ │ │ + 769 void operator()(const field_type&, int, int) │ │ │ │ │ + 770 {} │ │ │ │ │ + 771 │ │ │ │ │ + 772 field_type& sign_; │ │ │ │ │ + 773 }; │ │ │ │ │ + 774#endif // DOXYGEN │ │ │ │ │ + 775 │ │ │ │ │ + 777 │ │ │ │ │ + 815 template │ │ │ │ │ +816 static void luDecomposition(DenseMatrix& A, Func func, │ │ │ │ │ + 817 Mask &nonsingularLanes, bool throwEarly, bool doPivoting); │ │ │ │ │ + 818 }; │ │ │ │ │ + 819 │ │ │ │ │ + 820#ifndef DOXYGEN │ │ │ │ │ + 821 template │ │ │ │ │ + 822 DenseMatrix::ElimPivot::ElimPivot(std::vector & │ │ │ │ │ +pivot) │ │ │ │ │ + 823 : pivot_(pivot) │ │ │ │ │ + 824 { │ │ │ │ │ + 825 typedef typename std::vector::size_type size_type; │ │ │ │ │ + 826 for(size_type i=0; i < pivot_.size(); ++i) pivot_[i]=i; │ │ │ │ │ + 827 } │ │ │ │ │ + 828 │ │ │ │ │ + 829 template │ │ │ │ │ + 830 void DenseMatrix::ElimPivot::swap(std::size_t i, simd_index_type j) │ │ │ │ │ + 831 { │ │ │ │ │ + 832 pivot_[i] = │ │ │ │ │ + 833 Simd::cond(Simd::Scalar(i) == j, pivot_[i], j); │ │ │ │ │ + 834 } │ │ │ │ │ + 835 │ │ │ │ │ + 836 template │ │ │ │ │ + 837 template │ │ │ │ │ + 838 DenseMatrix::Elim::Elim(V& rhs) │ │ │ │ │ + 839 : rhs_(&rhs) │ │ │ │ │ + 840 {} │ │ │ │ │ + 841 │ │ │ │ │ + 842 template │ │ │ │ │ + 843 template │ │ │ │ │ + 844 void DenseMatrix::Elim::swap(std::size_t i, simd_index_type j) │ │ │ │ │ + 845 { │ │ │ │ │ + 846 using std::swap; │ │ │ │ │ + 847 │ │ │ │ │ + 848 // see the comment in luDecomposition() │ │ │ │ │ + 849 for(std::size_t l = 0; l < Simd::lanes(j); ++l) │ │ │ │ │ + 850 swap(Simd::lane(l, (*rhs_)[ i ]), │ │ │ │ │ + 851 Simd::lane(l, (*rhs_)[Simd::lane(l, j)])); │ │ │ │ │ + 852 } │ │ │ │ │ + 853 │ │ │ │ │ + 854 template │ │ │ │ │ + 855 template │ │ │ │ │ + 856 void DenseMatrix:: │ │ │ │ │ + 857 Elim::operator()(const typename V::field_type& factor, int k, int i) │ │ │ │ │ + 858 { │ │ │ │ │ + 859 (*rhs_)[k] -= factor*(*rhs_)[i]; │ │ │ │ │ + 860 } │ │ │ │ │ + 861 │ │ │ │ │ + 862 template │ │ │ │ │ + 863 template │ │ │ │ │ + 864 inline void DenseMatrix:: │ │ │ │ │ + 865luDecomposition(DenseMatrix& A, Func func, Mask &nonsingularLanes, │ │ │ │ │ + 866 bool throwEarly, bool doPivoting) │ │ │ │ │ + 867 { │ │ │ │ │ + 868 using std::max; │ │ │ │ │ + 869 using std::swap; │ │ │ │ │ + 870 │ │ │ │ │ + 871 typedef typename FieldTraits::real_type real_type; │ │ │ │ │ + 872 │ │ │ │ │ + 873 // LU decomposition of A in A │ │ │ │ │ + 874 for (size_type i=0; i pivmax; │ │ │ │ │ + 886 pivmax = Simd::cond(mask, abs, pivmax); │ │ │ │ │ + 887 imax = Simd::cond(mask, simd_index_type(k), imax); │ │ │ │ │ + 888 } │ │ │ │ │ + 889 // swap rows │ │ │ │ │ + 890 for (size_type j=0; j │ │ │ │ │ + 933 template │ │ │ │ │ + 934 inline void DenseMatrix::solve(V1& x, const V2& b, bool doPivoting) │ │ │ │ │ +const │ │ │ │ │ + 935 { │ │ │ │ │ + 936 using real_type = typename FieldTraits::real_type; │ │ │ │ │ + 937 // never mind those ifs, because they get optimized away │ │ │ │ │ + 938 if (rows()!=cols()) │ │ │ │ │ + 939 DUNE_THROW(FMatrixError, "Can't solve for a " << rows() << "x" << cols() │ │ │ │ │ +<< " matrix!"); │ │ │ │ │ + 940 │ │ │ │ │ + 941 if (rows()==1) { │ │ │ │ │ + 942 │ │ │ │ │ + 943#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ + 944 if (Simd::anyTrue(fvmeta::absreal((*this)[0][0]) │ │ │ │ │ + 945 < FMatrixPrecision<>::absolute_limit())) │ │ │ │ │ + 946 DUNE_THROW(FMatrixError,"matrix is singular"); │ │ │ │ │ + 947#endif │ │ │ │ │ + 948 x[0] = b[0]/(*this)[0][0]; │ │ │ │ │ + 949 │ │ │ │ │ + 950 } │ │ │ │ │ + 951 else if (rows()==2) { │ │ │ │ │ + 952 │ │ │ │ │ + 953 field_type detinv = (*this)[0][0]*(*this)[1][1]-(*this)[0][1]*(*this)[1] │ │ │ │ │ +[0]; │ │ │ │ │ + 954#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ + 955 if (Simd::anyTrue(fvmeta::absreal(detinv) │ │ │ │ │ + 956 < FMatrixPrecision<>::absolute_limit())) │ │ │ │ │ + 957 DUNE_THROW(FMatrixError,"matrix is singular"); │ │ │ │ │ + 958#endif │ │ │ │ │ + 959 detinv = real_type(1.0)/detinv; │ │ │ │ │ + 960 │ │ │ │ │ + 961 x[0] = detinv*((*this)[1][1]*b[0]-(*this)[0][1]*b[1]); │ │ │ │ │ + 962 x[1] = detinv*((*this)[0][0]*b[1]-(*this)[1][0]*b[0]); │ │ │ │ │ + 963 │ │ │ │ │ + 964 } │ │ │ │ │ + 965 else if (rows()==3) { │ │ │ │ │ + 966 │ │ │ │ │ + 967 field_type d = determinant(doPivoting); │ │ │ │ │ + 968#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ + 969 if (Simd::anyTrue(fvmeta::absreal(d) │ │ │ │ │ + 970 < FMatrixPrecision<>::absolute_limit())) │ │ │ │ │ + 971 DUNE_THROW(FMatrixError,"matrix is singular"); │ │ │ │ │ + 972#endif │ │ │ │ │ + 973 │ │ │ │ │ + 974 x[0] = (b[0]*(*this)[1][1]*(*this)[2][2] - b[0]*(*this)[2][1]*(*this)[1] │ │ │ │ │ +[2] │ │ │ │ │ + 975 - b[1] *(*this)[0][1]*(*this)[2][2] + b[1]*(*this)[2][1]*(*this)[0][2] │ │ │ │ │ + 976 + b[2] *(*this)[0][1]*(*this)[1][2] - b[2]*(*this)[1][1]*(*this)[0][2]) / │ │ │ │ │ +d; │ │ │ │ │ + 977 │ │ │ │ │ + 978 x[1] = ((*this)[0][0]*b[1]*(*this)[2][2] - (*this)[0][0]*b[2]*(*this)[1] │ │ │ │ │ +[2] │ │ │ │ │ + 979 - (*this)[1][0] *b[0]*(*this)[2][2] + (*this)[1][0]*b[2]*(*this)[0][2] │ │ │ │ │ + 980 + (*this)[2][0] *b[0]*(*this)[1][2] - (*this)[2][0]*b[1]*(*this)[0][2]) / │ │ │ │ │ +d; │ │ │ │ │ + 981 │ │ │ │ │ + 982 x[2] = ((*this)[0][0]*(*this)[1][1]*b[2] - (*this)[0][0]*(*this)[2][1]*b │ │ │ │ │ +[1] │ │ │ │ │ + 983 - (*this)[1][0] *(*this)[0][1]*b[2] + (*this)[1][0]*(*this)[2][1]*b[0] │ │ │ │ │ + 984 + (*this)[2][0] *(*this)[0][1]*b[1] - (*this)[2][0]*(*this)[1][1]*b[0]) / │ │ │ │ │ +d; │ │ │ │ │ + 985 │ │ │ │ │ + 986 } │ │ │ │ │ + 987 else { │ │ │ │ │ + 988 │ │ │ │ │ + 989 V1& rhs = x; // use x to store rhs │ │ │ │ │ + 990 rhs = b; // copy data │ │ │ │ │ + 991 Elim elim(rhs); │ │ │ │ │ + 992 AutonomousValue A(asImp()); │ │ │ │ │ + 993 Simd::Mask::real_type> │ │ │ │ │ + 994 nonsingularLanes(true); │ │ │ │ │ + 995 │ │ │ │ │ + 996 AutonomousValue::luDecomposition(A, elim, nonsingularLanes, true, │ │ │ │ │ +doPivoting); │ │ │ │ │ + 997 │ │ │ │ │ + 998 // backsolve │ │ │ │ │ + 999 for(int i=rows()-1; i>=0; i--) { │ │ │ │ │ + 1000 for (size_type j=i+1; j │ │ │ │ │ + 1008 inline void DenseMatrix::invert(bool doPivoting) │ │ │ │ │ + 1009 { │ │ │ │ │ + 1010 using real_type = typename FieldTraits::real_type; │ │ │ │ │ + 1011 using std::swap; │ │ │ │ │ + 1012 │ │ │ │ │ + 1013 // never mind those ifs, because they get optimized away │ │ │ │ │ + 1014 if (rows()!=cols()) │ │ │ │ │ + 1015 DUNE_THROW(FMatrixError, "Can't invert a " << rows() << "x" << cols() << │ │ │ │ │ +" matrix!"); │ │ │ │ │ + 1016 │ │ │ │ │ + 1017 if (rows()==1) { │ │ │ │ │ + 1018 │ │ │ │ │ + 1019#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ + 1020 if (Simd::anyTrue(fvmeta::absreal((*this)[0][0]) │ │ │ │ │ + 1021 < FMatrixPrecision<>::absolute_limit())) │ │ │ │ │ + 1022 DUNE_THROW(FMatrixError,"matrix is singular"); │ │ │ │ │ + 1023#endif │ │ │ │ │ + 1024 (*this)[0][0] = real_type( 1 ) / (*this)[0][0]; │ │ │ │ │ + 1025 │ │ │ │ │ + 1026 } │ │ │ │ │ + 1027 else if (rows()==2) { │ │ │ │ │ + 1028 │ │ │ │ │ + 1029 field_type detinv = (*this)[0][0]*(*this)[1][1]-(*this)[0][1]*(*this)[1] │ │ │ │ │ +[0]; │ │ │ │ │ + 1030#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ + 1031 if (Simd::anyTrue(fvmeta::absreal(detinv) │ │ │ │ │ + 1032 < FMatrixPrecision<>::absolute_limit())) │ │ │ │ │ + 1033 DUNE_THROW(FMatrixError,"matrix is singular"); │ │ │ │ │ + 1034#endif │ │ │ │ │ + 1035 detinv = real_type( 1 ) / detinv; │ │ │ │ │ + 1036 │ │ │ │ │ + 1037 field_type temp=(*this)[0][0]; │ │ │ │ │ + 1038 (*this)[0][0] = (*this)[1][1]*detinv; │ │ │ │ │ + 1039 (*this)[0][1] = -(*this)[0][1]*detinv; │ │ │ │ │ + 1040 (*this)[1][0] = -(*this)[1][0]*detinv; │ │ │ │ │ + 1041 (*this)[1][1] = temp*detinv; │ │ │ │ │ + 1042 │ │ │ │ │ + 1043 } │ │ │ │ │ + 1044 else if (rows()==3) │ │ │ │ │ + 1045 { │ │ │ │ │ + 1046 using K = field_type; │ │ │ │ │ + 1047 // code generated by maple │ │ │ │ │ + 1048 K t4 = (*this)[0][0] * (*this)[1][1]; │ │ │ │ │ + 1049 K t6 = (*this)[0][0] * (*this)[1][2]; │ │ │ │ │ + 1050 K t8 = (*this)[0][1] * (*this)[1][0]; │ │ │ │ │ + 1051 K t10 = (*this)[0][2] * (*this)[1][0]; │ │ │ │ │ + 1052 K t12 = (*this)[0][1] * (*this)[2][0]; │ │ │ │ │ + 1053 K t14 = (*this)[0][2] * (*this)[2][0]; │ │ │ │ │ + 1054 │ │ │ │ │ + 1055 K det = (t4*(*this)[2][2]-t6*(*this)[2][1]-t8*(*this)[2][2]+ │ │ │ │ │ + 1056 t10*(*this)[2][1]+t12*(*this)[1][2]-t14*(*this)[1][1]); │ │ │ │ │ + 1057 K t17 = K(1.0)/det; │ │ │ │ │ + 1058 │ │ │ │ │ + 1059 K matrix01 = (*this)[0][1]; │ │ │ │ │ + 1060 K matrix00 = (*this)[0][0]; │ │ │ │ │ + 1061 K matrix10 = (*this)[1][0]; │ │ │ │ │ + 1062 K matrix11 = (*this)[1][1]; │ │ │ │ │ + 1063 │ │ │ │ │ + 1064 (*this)[0][0] = ((*this)[1][1] * (*this)[2][2] - (*this)[1][2] * (*this) │ │ │ │ │ +[2][1])*t17; │ │ │ │ │ + 1065 (*this)[0][1] = -((*this)[0][1] * (*this)[2][2] - (*this)[0][2] * (*this) │ │ │ │ │ +[2][1])*t17; │ │ │ │ │ + 1066 (*this)[0][2] = (matrix01 * (*this)[1][2] - (*this)[0][2] * (*this)[1] │ │ │ │ │ +[1])*t17; │ │ │ │ │ + 1067 (*this)[1][0] = -((*this)[1][0] * (*this)[2][2] - (*this)[1][2] * (*this) │ │ │ │ │ +[2][0])*t17; │ │ │ │ │ + 1068 (*this)[1][1] = (matrix00 * (*this)[2][2] - t14) * t17; │ │ │ │ │ + 1069 (*this)[1][2] = -(t6-t10) * t17; │ │ │ │ │ + 1070 (*this)[2][0] = (matrix10 * (*this)[2][1] - matrix11 * (*this)[2][0]) * │ │ │ │ │ +t17; │ │ │ │ │ + 1071 (*this)[2][1] = -(matrix00 * (*this)[2][1] - t12) * t17; │ │ │ │ │ + 1072 (*this)[2][2] = (t4-t8) * t17; │ │ │ │ │ + 1073 } │ │ │ │ │ + 1074 else { │ │ │ │ │ + 1075 using std::swap; │ │ │ │ │ + 1076 │ │ │ │ │ + 1077 AutonomousValue A(asImp()); │ │ │ │ │ + 1078 std::vector pivot(rows()); │ │ │ │ │ + 1079 Simd::Mask::real_type> │ │ │ │ │ + 1080 nonsingularLanes(true); │ │ │ │ │ + 1081 AutonomousValue::luDecomposition(A, ElimPivot(pivot), │ │ │ │ │ +nonsingularLanes, true, doPivoting); │ │ │ │ │ + 1082 auto& L=A; │ │ │ │ │ + 1083 auto& U=A; │ │ │ │ │ + 1084 │ │ │ │ │ + 1085 // initialize inverse │ │ │ │ │ + 1086 *this=field_type(); │ │ │ │ │ + 1087 │ │ │ │ │ + 1088 for(size_type i=0; i0;) { │ │ │ │ │ + 1099 --i; │ │ │ │ │ + 1100 for (size_type k=0; k0; ) { │ │ │ │ │ + 1108 --i; │ │ │ │ │ + 1109 for(std::size_t l = 0; l < Simd::lanes((*this)[0][0]); ++l) │ │ │ │ │ + 1110 { │ │ │ │ │ + 1111 std::size_t pi = Simd::lane(l, pivot[i]); │ │ │ │ │ + 1112 if(i!=pi) │ │ │ │ │ + 1113 for(size_type j=0; j │ │ │ │ │ + 1123 inline typename DenseMatrix::field_type │ │ │ │ │ + 1124 DenseMatrix::determinant(bool doPivoting) const │ │ │ │ │ + 1125 { │ │ │ │ │ + 1126 // never mind those ifs, because they get optimized away │ │ │ │ │ + 1127 if (rows()!=cols()) │ │ │ │ │ + 1128 DUNE_THROW(FMatrixError, "There is no determinant for a " << rows() << │ │ │ │ │ +"x" << cols() << " matrix!"); │ │ │ │ │ + 1129 │ │ │ │ │ + 1130 if (rows()==1) │ │ │ │ │ + 1131 return (*this)[0][0]; │ │ │ │ │ + 1132 │ │ │ │ │ + 1133 if (rows()==2) │ │ │ │ │ + 1134 return (*this)[0][0]*(*this)[1][1] - (*this)[0][1]*(*this)[1][0]; │ │ │ │ │ + 1135 │ │ │ │ │ + 1136 if (rows()==3) { │ │ │ │ │ + 1137 // code generated by maple │ │ │ │ │ + 1138 field_type t4 = (*this)[0][0] * (*this)[1][1]; │ │ │ │ │ + 1139 field_type t6 = (*this)[0][0] * (*this)[1][2]; │ │ │ │ │ + 1140 field_type t8 = (*this)[0][1] * (*this)[1][0]; │ │ │ │ │ + 1141 field_type t10 = (*this)[0][2] * (*this)[1][0]; │ │ │ │ │ + 1142 field_type t12 = (*this)[0][1] * (*this)[2][0]; │ │ │ │ │ + 1143 field_type t14 = (*this)[0][2] * (*this)[2][0]; │ │ │ │ │ + 1144 │ │ │ │ │ + 1145 return (t4*(*this)[2][2]-t6*(*this)[2][1]-t8*(*this)[2][2]+ │ │ │ │ │ + 1146 t10*(*this)[2][1]+t12*(*this)[1][2]-t14*(*this)[1][1]); │ │ │ │ │ + 1147 │ │ │ │ │ + 1148 } │ │ │ │ │ + 1149 │ │ │ │ │ + 1150 AutonomousValue A(asImp()); │ │ │ │ │ + 1151 field_type det; │ │ │ │ │ + 1152 Simd::Mask::real_type> │ │ │ │ │ + 1153 nonsingularLanes(true); │ │ │ │ │ + 1154 │ │ │ │ │ + 1155 AutonomousValue::luDecomposition(A, ElimDet(det), nonsingularLanes, │ │ │ │ │ +false, doPivoting); │ │ │ │ │ + 1156 det = Simd::cond(nonsingularLanes, det, field_type(0)); │ │ │ │ │ + 1157 │ │ │ │ │ + 1158 for (size_type i = 0; i < rows(); ++i) │ │ │ │ │ + 1159 det *= A[i][i]; │ │ │ │ │ + 1160 return det; │ │ │ │ │ + 1161 } │ │ │ │ │ + 1162 │ │ │ │ │ + 1163#endif // DOXYGEN │ │ │ │ │ + 1164 │ │ │ │ │ +1165 namespace DenseMatrixHelp { │ │ │ │ │ + 1166 │ │ │ │ │ + 1168 template │ │ │ │ │ +1169 static inline void multAssign(const DenseMatrix &matrix, const │ │ │ │ │ +DenseVector & x, DenseVector & ret) │ │ │ │ │ + 1170 { │ │ │ │ │ + 1171 DUNE_ASSERT_BOUNDS(x.size() == matrix.cols()); │ │ │ │ │ + 1172 DUNE_ASSERT_BOUNDS(ret.size() == matrix.rows()); │ │ │ │ │ + 1173 typedef typename DenseMatrix::size_type size_type; │ │ │ │ │ + 1174 │ │ │ │ │ + 1175 for(size_type i=0; i │ │ │ │ │ + 1188 static inline void multAssignTransposed( const FieldMatrix │ │ │ │ │ +&matrix, const FieldVector & x, FieldVector & ret) │ │ │ │ │ + 1189 { │ │ │ │ │ + 1190 typedef typename FieldMatrix::size_type size_type; │ │ │ │ │ + 1191 │ │ │ │ │ + 1192 for(size_type i=0; i │ │ │ │ │ + 1202 static inline FieldVector mult(const FieldMatrix │ │ │ │ │ +&matrix, const FieldVector & x) │ │ │ │ │ + 1203 { │ │ │ │ │ + 1204 FieldVector ret; │ │ │ │ │ + 1205 multAssign(matrix,x,ret); │ │ │ │ │ + 1206 return ret; │ │ │ │ │ + 1207 } │ │ │ │ │ + 1208 │ │ │ │ │ + 1210 template │ │ │ │ │ + 1211 static inline FieldVector multTransposed(const │ │ │ │ │ +FieldMatrix &matrix, const FieldVector & x) │ │ │ │ │ + 1212 { │ │ │ │ │ + 1213 FieldVector ret; │ │ │ │ │ + 1214 multAssignTransposed( matrix, x, ret ); │ │ │ │ │ + 1215 return ret; │ │ │ │ │ + 1216 } │ │ │ │ │ + 1217#endif │ │ │ │ │ + 1218 │ │ │ │ │ + 1219 } // end namespace DenseMatrixHelp │ │ │ │ │ + 1220 │ │ │ │ │ + 1222 template │ │ │ │ │ +1223 std::ostream& operator<<(std::ostream& s, const DenseMatrix& a) │ │ │ │ │ + 1224 { │ │ │ │ │ + 1225 for (typename DenseMatrix::size_type i=0; i::type AutonomousValue │ │ │ │ │ +Type free of internal references that T can be converted to. │ │ │ │ │ +Definition typetraits.hh:558 │ │ │ │ │ +Dune::operator<< │ │ │ │ │ +std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x) │ │ │ │ │ +Definition bigunsignedint.hh:278 │ │ │ │ │ +DUNE_THROW │ │ │ │ │ +#define DUNE_THROW(E, m) │ │ │ │ │ +Definition exceptions.hh:218 │ │ │ │ │ +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::Rebind │ │ │ │ │ +typename Overloads::RebindType< std::decay_t< S >, std::decay_t< V > >::type │ │ │ │ │ +Rebind │ │ │ │ │ +Construct SIMD type with different scalar type. │ │ │ │ │ +Definition simd/interface.hh:253 │ │ │ │ │ +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::Overloads::mask │ │ │ │ │ +Mask< V > mask(ADLTag< 0, std::is_same< V, Mask< V > >::value >, const V &v) │ │ │ │ │ +implements Simd::mask() │ │ │ │ │ +Definition defaults.hh:153 │ │ │ │ │ +std │ │ │ │ │ +STL namespace. │ │ │ │ │ +Dune │ │ │ │ │ +Dune namespace. │ │ │ │ │ +Definition alignedallocator.hh:13 │ │ │ │ │ +Dune::swap │ │ │ │ │ +void swap(T &v1, T &v2, bool mask) │ │ │ │ │ +Definition simd.hh:472 │ │ │ │ │ +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::DenseMatrixHelp::multAssign │ │ │ │ │ +static void multAssign(const DenseMatrix< MAT > &matrix, const DenseVector< V1 │ │ │ │ │ +> &x, DenseVector< V2 > &ret) │ │ │ │ │ +calculates ret = matrix * x │ │ │ │ │ +Definition densematrix.hh:1169 │ │ │ │ │ +Dune::DenseMatrix │ │ │ │ │ +A dense n x m matrix. │ │ │ │ │ +Definition densematrix.hh:140 │ │ │ │ │ +Dune::DenseMatrix::const_iterator │ │ │ │ │ +ConstIterator const_iterator │ │ │ │ │ +typedef for stl compliant access │ │ │ │ │ +Definition densematrix.hh:244 │ │ │ │ │ +Dune::DenseMatrix::operator- │ │ │ │ │ +derived_type operator-() const │ │ │ │ │ +Matrix negation. │ │ │ │ │ +Definition densematrix.hh:298 │ │ │ │ │ +Dune::DenseMatrix::solve │ │ │ │ │ +void solve(V1 &x, const V2 &b, bool doPivoting=true) const │ │ │ │ │ +Solve system A x = b. │ │ │ │ │ +Dune::DenseMatrix::mv │ │ │ │ │ +void mv(const X &x, Y &y) const │ │ │ │ │ +y = A x │ │ │ │ │ +Definition densematrix.hh:368 │ │ │ │ │ +Dune::DenseMatrix::field_type │ │ │ │ │ +Traits::value_type field_type │ │ │ │ │ +export the type representing the field │ │ │ │ │ +Definition densematrix.hh:160 │ │ │ │ │ +Dune::DenseMatrix::axpy │ │ │ │ │ +derived_type & axpy(const field_type &a, const DenseMatrix< Other > &x) │ │ │ │ │ +vector space axpy operation (*this += a x) │ │ │ │ │ +Definition densematrix.hh:338 │ │ │ │ │ +Dune::DenseMatrix::beforeEnd │ │ │ │ │ +ConstIterator beforeEnd() const │ │ │ │ │ +Definition densematrix.hh:264 │ │ │ │ │ +Dune::DenseMatrix::operator= │ │ │ │ │ +derived_type & operator=(const RHS &rhs) │ │ │ │ │ +Definition densematrix.hh:279 │ │ │ │ │ +Dune::DenseMatrix::mmtv │ │ │ │ │ +void mmtv(const X &x, Y &y) const │ │ │ │ │ +y -= A^T x │ │ │ │ │ +Definition densematrix.hh:458 │ │ │ │ │ +Dune::DenseMatrix::infinity_norm_real │ │ │ │ │ +FieldTraits< vt >::real_type infinity_norm_real() const │ │ │ │ │ +simplified infinity norm (uses Manhattan norm for complex values) │ │ │ │ │ +Definition densematrix.hh:561 │ │ │ │ │ +Dune::DenseMatrix::ConstColIterator │ │ │ │ │ +std::remove_reference< const_row_reference >::type::ConstIterator │ │ │ │ │ +ConstColIterator │ │ │ │ │ +rename the iterators for easier access │ │ │ │ │ +Definition densematrix.hh:248 │ │ │ │ │ +Dune::DenseMatrix::beforeBegin │ │ │ │ │ +ConstIterator beforeBegin() const │ │ │ │ │ +Definition densematrix.hh:271 │ │ │ │ │ +Dune::DenseMatrix::invert │ │ │ │ │ +void invert(bool doPivoting=true) │ │ │ │ │ +Compute inverse. │ │ │ │ │ +Dune::DenseMatrix::luDecomposition │ │ │ │ │ +static void luDecomposition(DenseMatrix< MAT > &A, Func func, Mask │ │ │ │ │ +&nonsingularLanes, bool throwEarly, bool doPivoting) │ │ │ │ │ +do an LU-Decomposition on matrix A │ │ │ │ │ +Dune::DenseMatrix::block_type │ │ │ │ │ +Traits::value_type block_type │ │ │ │ │ +export the type representing the components │ │ │ │ │ +Definition densematrix.hh:163 │ │ │ │ │ +Dune::DenseMatrix::mtv │ │ │ │ │ +void mtv(const X &x, Y &y) const │ │ │ │ │ +y = A^T x │ │ │ │ │ +Definition densematrix.hh:387 │ │ │ │ │ +Dune::DenseMatrix::cols │ │ │ │ │ +constexpr size_type cols() const │ │ │ │ │ +number of columns │ │ │ │ │ +Definition densematrix.hh:715 │ │ │ │ │ +Dune::DenseMatrix::size │ │ │ │ │ +size_type size() const │ │ │ │ │ +size method (number of rows) │ │ │ │ │ +Definition densematrix.hh:200 │ │ │ │ │ +Dune::DenseMatrix::M │ │ │ │ │ +constexpr size_type M() const │ │ │ │ │ +number of columns │ │ │ │ │ +Definition densematrix.hh:703 │ │ │ │ │ +Dune::DenseMatrix::rightmultiply │ │ │ │ │ +MAT & rightmultiply(const DenseMatrix< M2 > &M) │ │ │ │ │ +Multiplies M from the right to this matrix. │ │ │ │ │ +Definition densematrix.hh:645 │ │ │ │ │ +Dune::DenseMatrix::end │ │ │ │ │ +Iterator end() │ │ │ │ │ +end iterator │ │ │ │ │ +Definition densematrix.hh:222 │ │ │ │ │ +Dune::DenseMatrix::beforeBegin │ │ │ │ │ +Iterator beforeBegin() │ │ │ │ │ +Definition densematrix.hh:236 │ │ │ │ │ +Dune::DenseMatrix::operator/= │ │ │ │ │ +derived_type & operator/=(const field_type &k) │ │ │ │ │ +vector space division by scalar │ │ │ │ │ +Definition densematrix.hh:329 │ │ │ │ │ +Dune::DenseMatrix::operator*= │ │ │ │ │ +derived_type & operator*=(const field_type &k) │ │ │ │ │ +vector space multiplication with scalar │ │ │ │ │ +Definition densematrix.hh:321 │ │ │ │ │ +Dune::DenseMatrix::beforeEnd │ │ │ │ │ +Iterator beforeEnd() │ │ │ │ │ +Definition densematrix.hh:229 │ │ │ │ │ +Dune::DenseMatrix::value_type │ │ │ │ │ +Traits::value_type value_type │ │ │ │ │ +export the type representing the field │ │ │ │ │ +Definition densematrix.hh:157 │ │ │ │ │ +Dune::DenseMatrix::usmv │ │ │ │ │ +void usmv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) │ │ │ │ │ +const │ │ │ │ │ +y += alpha A x │ │ │ │ │ +Definition densematrix.hh:484 │ │ │ │ │ +Dune::DenseMatrix::usmhv │ │ │ │ │ +void usmhv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y │ │ │ │ │ +&y) const │ │ │ │ │ +y += alpha A^H x │ │ │ │ │ +Definition densematrix.hh:512 │ │ │ │ │ +Dune::DenseMatrix::mmv │ │ │ │ │ +void mmv(const X &x, Y &y) const │ │ │ │ │ +y -= A x │ │ │ │ │ +Definition densematrix.hh:445 │ │ │ │ │ +Dune::DenseMatrix::rows │ │ │ │ │ +constexpr size_type rows() const │ │ │ │ │ +number of rows │ │ │ │ │ +Definition densematrix.hh:709 │ │ │ │ │ +Dune::DenseMatrix::leftmultiply │ │ │ │ │ +MAT & leftmultiply(const DenseMatrix< M2 > &M) │ │ │ │ │ +Multiplies M from the left to this matrix. │ │ │ │ │ +Definition densematrix.hh:627 │ │ │ │ │ +Dune::DenseMatrix::usmtv │ │ │ │ │ +void usmtv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y │ │ │ │ │ +&y) const │ │ │ │ │ +y += alpha A^T x │ │ │ │ │ +Definition densematrix.hh:498 │ │ │ │ │ +Dune::DenseMatrix::operator-= │ │ │ │ │ +derived_type & operator-=(const DenseMatrix< Other > &x) │ │ │ │ │ +vector space subtraction │ │ │ │ │ +Definition densematrix.hh:312 │ │ │ │ │ +Dune::DenseMatrix::operator!= │ │ │ │ │ +bool operator!=(const DenseMatrix< Other > &x) const │ │ │ │ │ +Binary matrix incomparison. │ │ │ │ │ +Definition densematrix.hh:358 │ │ │ │ │ +Dune::DenseMatrix::mmhv │ │ │ │ │ +void mmhv(const X &x, Y &y) const │ │ │ │ │ +y -= A^H x │ │ │ │ │ +Definition densematrix.hh:471 │ │ │ │ │ +Dune::DenseMatrix::derived_type │ │ │ │ │ +Traits::derived_type derived_type │ │ │ │ │ +type of derived matrix class │ │ │ │ │ +Definition densematrix.hh:154 │ │ │ │ │ +Dune::DenseMatrix::operator[] │ │ │ │ │ +row_reference operator[](size_type i) │ │ │ │ │ +random access │ │ │ │ │ +Definition densematrix.hh:189 │ │ │ │ │ +Dune::DenseMatrix::exists │ │ │ │ │ +bool exists(size_type i, size_type j) const │ │ │ │ │ +return true when (i,j) is in pattern │ │ │ │ │ +Definition densematrix.hh:723 │ │ │ │ │ +Dune::DenseMatrix::RowIterator │ │ │ │ │ +Iterator RowIterator │ │ │ │ │ +rename the iterators for easier access │ │ │ │ │ +Definition densematrix.hh:211 │ │ │ │ │ +Dune::DenseMatrix::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::frobenius_norm │ │ │ │ │ +FieldTraits< value_type >::real_type frobenius_norm() const │ │ │ │ │ +frobenius norm: sqrt(sum over squared values of entries) │ │ │ │ │ +Definition densematrix.hh:528 │ │ │ │ │ +Dune::DenseMatrix::umv │ │ │ │ │ +void umv(const X &x, Y &y) const │ │ │ │ │ +y += A x │ │ │ │ │ +Definition densematrix.hh:406 │ │ │ │ │ +Dune::DenseMatrix::ConstIterator │ │ │ │ │ +DenseIterator< const DenseMatrix, const row_type, const_row_reference > │ │ │ │ │ +ConstIterator │ │ │ │ │ +Iterator class for sequential access. │ │ │ │ │ +Definition densematrix.hh:242 │ │ │ │ │ +Dune::DenseMatrix::infinity_norm │ │ │ │ │ +FieldTraits< vt >::real_type infinity_norm() const │ │ │ │ │ +infinity norm (row sum norm, how to generalize for blocks?) │ │ │ │ │ +Definition densematrix.hh:546 │ │ │ │ │ +Dune::DenseMatrix::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::N │ │ │ │ │ +constexpr size_type N() const │ │ │ │ │ +number of rows │ │ │ │ │ +Definition densematrix.hh:697 │ │ │ │ │ +Dune::DenseMatrix::size_type │ │ │ │ │ +Traits::size_type size_type │ │ │ │ │ +The type used for the index access and size operation. │ │ │ │ │ +Definition densematrix.hh:166 │ │ │ │ │ +Dune::DenseMatrix::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::frobenius_norm2 │ │ │ │ │ +FieldTraits< value_type >::real_type frobenius_norm2() const │ │ │ │ │ +square of frobenius norm, need for block recursion │ │ │ │ │ +Definition densematrix.hh:536 │ │ │ │ │ +Dune::DenseMatrix::ColIterator │ │ │ │ │ +std::remove_reference< row_reference >::type::Iterator ColIterator │ │ │ │ │ +rename the iterators for easier access │ │ │ │ │ +Definition densematrix.hh:213 │ │ │ │ │ +Dune::DenseMatrix::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::DenseMatrix::operator== │ │ │ │ │ +bool operator==(const DenseMatrix< Other > &x) const │ │ │ │ │ +Binary matrix comparison. │ │ │ │ │ +Definition densematrix.hh:348 │ │ │ │ │ +Dune::DenseMatrix::iterator │ │ │ │ │ +Iterator iterator │ │ │ │ │ +typedef for stl compliant access │ │ │ │ │ +Definition densematrix.hh:209 │ │ │ │ │ +Dune::DenseMatrix::ConstRowIterator │ │ │ │ │ +ConstIterator ConstRowIterator │ │ │ │ │ +rename the iterators for easier access │ │ │ │ │ +Definition densematrix.hh:246 │ │ │ │ │ +Dune::DenseMatrix::Iterator │ │ │ │ │ +DenseIterator< DenseMatrix, row_type, row_reference > Iterator │ │ │ │ │ +Iterator class for sequential access. │ │ │ │ │ +Definition densematrix.hh:207 │ │ │ │ │ +Dune::DenseMatrix::umtv │ │ │ │ │ +void umtv(const X &x, Y &y) const │ │ │ │ │ +y += A^T x │ │ │ │ │ +Definition densematrix.hh:419 │ │ │ │ │ +Dune::DenseMatrix::begin │ │ │ │ │ +ConstIterator begin() const │ │ │ │ │ +begin iterator │ │ │ │ │ +Definition densematrix.hh:251 │ │ │ │ │ +Dune::DenseMatrix::determinant │ │ │ │ │ +field_type determinant(bool doPivoting=true) const │ │ │ │ │ +calculates the determinant of this matrix │ │ │ │ │ +Dune::DenseMatrix::begin │ │ │ │ │ +Iterator begin() │ │ │ │ │ +begin iterator │ │ │ │ │ +Definition densematrix.hh:216 │ │ │ │ │ +Dune::DenseMatrix::umhv │ │ │ │ │ +void umhv(const X &x, Y &y) const │ │ │ │ │ +y += A^H x │ │ │ │ │ +Definition densematrix.hh:432 │ │ │ │ │ +Dune::DenseMatrix::operator+= │ │ │ │ │ +derived_type & operator+=(const DenseMatrix< Other > &x) │ │ │ │ │ +vector space addition │ │ │ │ │ +Definition densematrix.hh:289 │ │ │ │ │ +Dune::DenseMatrix::end │ │ │ │ │ +ConstIterator end() const │ │ │ │ │ +end iterator │ │ │ │ │ +Definition densematrix.hh:257 │ │ │ │ │ +Dune::FieldTraits<_DenseMatrix<_M_>_>::real_type │ │ │ │ │ +const FieldTraits< typenameDenseMatVecTraits< M >::value_type >::real_type │ │ │ │ │ +real_type │ │ │ │ │ +Definition densematrix.hh:34 │ │ │ │ │ +Dune::FieldTraits<_DenseMatrix<_M_>_>::field_type │ │ │ │ │ +const FieldTraits< typenameDenseMatVecTraits< M >::value_type >::field_type │ │ │ │ │ +field_type │ │ │ │ │ +Definition densematrix.hh:33 │ │ │ │ │ +Dune::FieldMatrix │ │ │ │ │ +A dense n x m matrix. │ │ │ │ │ +Definition fmatrix.hh:117 │ │ │ │ │ +Dune::FieldMatrix::size_type │ │ │ │ │ +Base::size_type size_type │ │ │ │ │ +Definition fmatrix.hh:127 │ │ │ │ │ +Dune::FieldVector │ │ │ │ │ +vector space out of a tensor product of fields. │ │ │ │ │ +Definition fvector.hh:95 │ │ │ │ │ +Dune::DenseMatrixAssigner │ │ │ │ │ +you have to specialize this structure for any type that should be assignable to │ │ │ │ │ +a DenseMatrix │ │ │ │ │ +Definition densematrix.hh:59 │ │ │ │ │ +Dune::FMatrixError │ │ │ │ │ +Error thrown if operations of a FieldMatrix fail. │ │ │ │ │ +Definition densematrix.hh:126 │ │ │ │ │ +Dune::DenseVector │ │ │ │ │ +Interface for a class of dense vectors over a given field. │ │ │ │ │ +Definition densevector.hh:229 │ │ │ │ │ +Dune::DenseVector::size │ │ │ │ │ +size_type size() const │ │ │ │ │ +size method │ │ │ │ │ +Definition densevector.hh:336 │ │ │ │ │ +Dune::DenseIterator │ │ │ │ │ +Generic iterator class for dense vector and matrix implementations. │ │ │ │ │ +Definition densevector.hh:131 │ │ │ │ │ +Dune::MathError │ │ │ │ │ +Default exception class for mathematical errors. │ │ │ │ │ +Definition exceptions.hh:241 │ │ │ │ │ +Dune::FieldTraits │ │ │ │ │ +Definition ftraits.hh:26 │ │ │ │ │ +Dune::FieldTraits::field_type │ │ │ │ │ +T field_type │ │ │ │ │ +export the type representing the field │ │ │ │ │ +Definition ftraits.hh:28 │ │ │ │ │ +Dune::FieldTraits::real_type │ │ │ │ │ +T real_type │ │ │ │ │ +export the type representing the real type of the field │ │ │ │ │ +Definition ftraits.hh:30 │ │ │ │ │ +Dune::DenseMatVecTraits │ │ │ │ │ +Definition matvectraits.hh:31 │ │ │ │ │ +Dune::FMatrixPrecision::absolute_limit │ │ │ │ │ +static ctype absolute_limit() │ │ │ │ │ +return threshold to declare matrix singular │ │ │ │ │ +Definition precision.hh:28 │ │ │ │ │ +simd.hh │ │ │ │ │ +Include file for users of the SIMD abstraction layer. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00146.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: test.hh File Reference │ │ │ │ +dune-common: unused.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,496 +65,36 @@ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ -Classes | │ │ │ │ -Namespaces | │ │ │ │ -Macros | │ │ │ │ -Typedefs
    │ │ │ │ -
    test.hh File Reference
    │ │ │ │ +Macros
    │ │ │ │ +
    unused.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ -

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

    Definition of the DUNE_UNUSED_PARAMETER macro. │ │ │ │ More...

    │ │ │ │ -
    #include <algorithm>
    │ │ │ │ -#include <cstddef>
    │ │ │ │ -#include <iostream>
    │ │ │ │ -#include <sstream>
    │ │ │ │ -#include <string>
    │ │ │ │ -#include <type_traits>
    │ │ │ │ -#include <typeindex>
    │ │ │ │ -#include <typeinfo>
    │ │ │ │ -#include <unordered_set>
    │ │ │ │ -#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>
    │ │ │ │ -
    │ │ │ │ + │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ -Classes

    struct  Dune::Simd::EndMark
     final element marker for RebindList More...
     
    class  Dune::Simd::UnitTest
     
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

    │ │ │ │ -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
     
    #define DUNE_UNUSED_PARAMETER(param)   static_cast<void>(param)
     
    │ │ │ │

    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)); \
    │ │ │ │ -
    }
    │ │ │ │ -
    │ │ │ │ -
    │ │ │ │ -
    │ │ │ │ -
    │ │ │ │ +

    Definition of the DUNE_UNUSED_PARAMETER macro.

    │ │ │ │ +
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,205 +6,19 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ 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 │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Macros │ │ │ │ │ +unused.hh File Reference │ │ │ │ │ +Definition of the DUNE_UNUSED_PARAMETER macro. More... │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ - Classes │ │ │ │ │ -struct  Dune::Simd::EndMark │ │ │ │ │ -  final element marker for RebindList More... │ │ │ │ │ -  │ │ │ │ │ - class  Dune::Simd::UnitTest │ │ │ │ │ -  │ │ │ │ │ - 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 │ │ │ │ │ +#define DUNE_UNUSED_PARAMETER(param)   static_cast(param) │ │ │ │ │   │ │ │ │ │ ***** 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 (  expr )     ((expr) ? void() : complain(__FILE__, __LINE__, __func__, │ │ │ │ │ -DUNE_SIMD_CHECK #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)); \ │ │ │ │ │ -} │ │ │ │ │ +Definition of the DUNE_UNUSED_PARAMETER macro. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00146_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: test.hh Source File │ │ │ │ +dune-common: unused.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,2026 +70,30 @@ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    test.hh
    │ │ │ │ +
    unused.hh
    │ │ │ │
    │ │ │ │
    │ │ │ │ -Go to the documentation of this file.
    1// SPDX-FileCopyrightInfo: Copyright (C) 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 };
    │ │ │ │ -
    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;
    │ │ │ │ -
    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
    │ │ │ │ -
    Traits for type conversions and type information.
    │ │ │ │ -
    A free function to provide the demangled class name of a given object or type as a string.
    │ │ │ │ -
    #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)
    │ │ │ │ - │ │ │ │ -
    IO interface of the SIMD abstraction.
    │ │ │ │ - │ │ │ │ -
    Utilities for reduction like operations on ranges.
    │ │ │ │ - │ │ │ │ - │ │ │ │ -
    static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from >, std::integral_constant< T, to >) noexcept
    Definition rangeutilities.hh:300
    │ │ │ │ -
    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:268
    │ │ │ │ -
    constexpr AutonomousValue< T > autoCopy(T &&v)
    Autonomous copy of an expression's value for use in auto type deduction.
    Definition typetraits.hh:642
    │ │ │ │ -
    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.
    │ │ │ │ -
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ -
    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.
    │ │ │ │ +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 (C) 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_UNUSED_HH
    │ │ │ │ +
    6#define DUNE_COMMON_UNUSED_HH
    │ │ │ │ +
    7
    │ │ │ │ +
    21#define DUNE_UNUSED_PARAMETER(param) static_cast<void>(param)
    │ │ │ │ +
    22#endif
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,2098 +7,22 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * simd │ │ │ │ │ -test.hh │ │ │ │ │ +unused.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ - 1// SPDX-FileCopyrightInfo: Copyright (C) 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 (C) 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 │ │ │ │ │ - 75 { │ │ │ │ │ - 76 using type = std::add_lvalue_reference_t; │ │ │ │ │ - 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; │ │ │ │ │ - 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 │ │ │ │ │ -typetraits.hh │ │ │ │ │ -Traits for type conversions and type information. │ │ │ │ │ -classname.hh │ │ │ │ │ -A free function to provide the demangled class name of a given object or type │ │ │ │ │ -as a string. │ │ │ │ │ -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) │ │ │ │ │ -loop.hh │ │ │ │ │ -io.hh │ │ │ │ │ -IO interface of the SIMD abstraction. │ │ │ │ │ -type_traits.hh │ │ │ │ │ -rangeutilities.hh │ │ │ │ │ -Utilities for reduction like operations on ranges. │ │ │ │ │ -typelist.hh │ │ │ │ │ -hybridutilities.hh │ │ │ │ │ -Dune::range │ │ │ │ │ -static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from │ │ │ │ │ ->, std::integral_constant< T, to >) noexcept │ │ │ │ │ -Definition rangeutilities.hh:300 │ │ │ │ │ -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:268 │ │ │ │ │ -Dune::autoCopy │ │ │ │ │ -constexpr AutonomousValue< T > autoCopy(T &&v) │ │ │ │ │ -Autonomous copy of an expression's value for use in auto type deduction. │ │ │ │ │ -Definition typetraits.hh:642 │ │ │ │ │ -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. │ │ │ │ │ -Dune │ │ │ │ │ -Dune namespace. │ │ │ │ │ -Definition alignedallocator.hh:13 │ │ │ │ │ -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. │ │ │ │ │ + 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ + 5#ifndef DUNE_COMMON_UNUSED_HH │ │ │ │ │ + 6#define DUNE_COMMON_UNUSED_HH │ │ │ │ │ + 7 │ │ │ │ │ +21#define DUNE_UNUSED_PARAMETER(param) static_cast(param) │ │ │ │ │ + 22#endif │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00152.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: standard.hh File Reference │ │ │ │ +dune-common: bitsetvector.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,86 +65,65 @@ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ Classes | │ │ │ │ Namespaces
    │ │ │ │ - │ │ │ │ +
    bitsetvector.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ -

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

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

    │ │ │ │ -
    #include <cstddef>
    │ │ │ │ -#include <type_traits>
    │ │ │ │ -#include <utility>
    │ │ │ │ -#include <dune/common/indices.hh>
    │ │ │ │ -#include <dune/common/simd/base.hh>
    │ │ │ │ -#include <dune/common/simd/defaults.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::Simd::Overloads::ScalarType< V, class >
     should have a member type type More...
    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::Simd::Overloads::RebindType< S, class, class >
     should have a member type type More...
    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::Simd::Overloads::LaneCount< class, class >
     should be derived from a Dune::index_constant More...
    struct  Dune::const_reference< BitSetVectorReference< block_size, Alloc > >
     
    struct  Dune::const_reference< BitSetVectorConstReference< block_size, Alloc > >
     
    struct  Dune::mutable_reference< BitSetVectorReference< block_size, Alloc > >
     
    struct  Dune::mutable_reference< BitSetVectorConstReference< block_size, Alloc > >
     
    class  Dune::BitSetVector< block_size, Allocator >
     A dynamic array of blocks of booleans. 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.
     
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │

    │ │ │ │ -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()
     
    │ │ │ │

    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.

    │ │ │ │ +

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

    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,75 +6,50 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ 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... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +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::Simd::Overloads::ScalarType<_V,_class_> │ │ │ │ │ -  should have a member type type More... │ │ │ │ │ + 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::Simd::Overloads::RebindType<_S,_class,_class_> │ │ │ │ │ -  should have a member type type More... │ │ │ │ │ + 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::Simd::Overloads::LaneCount<_class,_class_> │ │ │ │ │ -  should be derived from a Dune::index_constant More... │ │ │ │ │ +struct  Dune::const_reference<_BitSetVectorReference<_block_size,_Alloc_>_> │ │ │ │ │   │ │ │ │ │ - Namespaces │ │ │ │ │ -namespace  Dune │ │ │ │ │ -  Dune namespace. │ │ │ │ │ +struct  Dune::const_reference<_BitSetVectorConstReference<_block_size,_Alloc_> │ │ │ │ │ + > │ │ │ │ │   │ │ │ │ │ -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 │ │ │ │ │ -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() │ │ │ │ │ +struct  Dune::mutable_reference<_BitSetVectorReference<_block_size,_Alloc_>_> │ │ │ │ │   │ │ │ │ │ -bool Dune::Simd::Overloads::allTrue (ADLTag< 2 >, bool mask) │ │ │ │ │ -  implements Simd::allTrue() │ │ │ │ │ +struct  Dune::mutable_reference<_BitSetVectorConstReference<_block_size,_Alloc │ │ │ │ │ + >_> │ │ │ │ │   │ │ │ │ │ -bool Dune::Simd::Overloads::anyFalse (ADLTag< 2 >, bool mask) │ │ │ │ │ -  implements Simd::anyFalse() │ │ │ │ │ + class  Dune::BitSetVector<_block_size,_Allocator_> │ │ │ │ │ +  A dynamic array of blocks of booleans. More... │ │ │ │ │   │ │ │ │ │ -bool Dune::Simd::Overloads::allFalse (ADLTag< 2 >, bool mask) │ │ │ │ │ -  implements Simd::allFalse() │ │ │ │ │ + Namespaces │ │ │ │ │ +namespace  Dune │ │ │ │ │ +  Dune namespace. │ │ │ │ │   │ │ │ │ │ ***** 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. │ │ │ │ │ +Efficient implementation of a dynamic array of static arrays of booleans. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00152_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: standard.hh Source File │ │ │ │ +dune-common: bitsetvector.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,102 +70,791 @@ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    standard.hh
    │ │ │ │ +
    bitsetvector.hh
    │ │ │ │
    │ │ │ │
    │ │ │ │ -Go to the documentation of this file.
    1// SPDX-FileCopyrightInfo: Copyright (C) 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
    │ │ │ │ -
    5
    │ │ │ │ -
    20#include <cstddef>
    │ │ │ │ -
    21#include <type_traits>
    │ │ │ │ -
    22#include <utility>
    │ │ │ │ -
    23
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
    27
    │ │ │ │ -
    45namespace Dune {
    │ │ │ │ -
    46 namespace Simd {
    │ │ │ │ -
    47
    │ │ │ │ -
    48 namespace Overloads {
    │ │ │ │ -
    49
    │ │ │ │ -
    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; };
    │ │ │ │ -
    68
    │ │ │ │ +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 (C) 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_BLOCK_BITFIELD_HH
    │ │ │ │ +
    6#define DUNE_BLOCK_BITFIELD_HH
    │ │ │ │ +
    7
    │ │ │ │ +
    12#include <vector>
    │ │ │ │ +
    13#include <bitset>
    │ │ │ │ +
    14#include <iostream>
    │ │ │ │ +
    15#include <algorithm>
    │ │ │ │ +
    16
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    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
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    65 {
    │ │ │ │ +
    66 bitset b = *this;
    │ │ │ │ +
    67 b <<= n;
    │ │ │ │ +
    68 return b;
    │ │ │ │ +
    69 }
    │ │ │ │ +
    │ │ │ │
    70
    │ │ │ │ -
    73 template<class, class>
    │ │ │ │ -
    74 struct LaneCount : public index_constant<1> { };
    │ │ │ │ -
    75
    │ │ │ │ -
    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; }
    │ │ │ │ -
    112
    │ │ │ │ -
    114
    │ │ │ │ -
    115 } // namespace Overloads
    │ │ │ │ -
    116 } // namespace Simd
    │ │ │ │ -
    117} // namespace Dune
    │ │ │ │ -
    118
    │ │ │ │ -
    119#endif // DUNE_COMMON_SIMD_STANDARD_HH
    │ │ │ │ - │ │ │ │ -
    Basic definitions for SIMD Implementations.
    │ │ │ │ -
    Default implementations for SIMD Implementations.
    │ │ │ │ -
    std::integral_constant< std::size_t, i > index_constant
    An index constant with value i.
    Definition indices.hh:30
    │ │ │ │ -
    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
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    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 }
    │ │ │ │ +
    │ │ │ │ +
    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
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    315 {
    │ │ │ │ +
    316 for (size_type i=0; i<block_size; i++)
    │ │ │ │ +
    317 getBit(i) = (test(i) ^ x.test(i));
    │ │ │ │ +
    318 return *this;
    │ │ │ │ +
    319 }
    │ │ │ │ +
    │ │ │ │ +
    320
    │ │ │ │ +
    321 private:
    │ │ │ │ +
    322
    │ │ │ │ +
    323 // For some reason, the following variant of operator^= triggers an ICE or a hanging
    │ │ │ │ +
    324 // compiler on Debian 9 with GCC 6.3 and full optimizations enabled (-O3).
    │ │ │ │ +
    325 // The only way to reliably avoid the issue is by making sure that the compiler does not
    │ │ │ │ +
    326 // see the XOR in the context of the function, so here is a little helper that will normally
    │ │ │ │ +
    327 // be inlined, but not on the broken compiler. This incurs a substantial overhead (a function
    │ │ │ │ +
    328 // call), but until someone else has a better idea, it's the only way to make it work reliably.
    │ │ │ │ +
    329
    │ │ │ │ +
    330 static bool xor_helper(bool a, bool b)
    │ │ │ │ +
    331#if defined(__GNUC__) && ! defined(__clang__) && __GNUC__ == 6 && __GNUC_MINOR__ == 3 && __cplusplus \
    │ │ │ │ +
    332 == 201402L
    │ │ │ │ +
    333 __attribute__((noinline))
    │ │ │ │ +
    334#endif
    │ │ │ │ +
    335 ;
    │ │ │ │ +
    336
    │ │ │ │ +
    337 public:
    │ │ │ │ +
    338
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    341 {
    │ │ │ │ +
    342 // This uses the helper from above to hoist the actual XOR computation out of the function for
    │ │ │ │ +
    343 // the buggy version of GCC.
    │ │ │ │ +
    344 for (size_type i=0; i<block_size; i++)
    │ │ │ │ +
    345 getBit(i) = xor_helper(test(i),x.test(i));
    │ │ │ │ +
    346 return *this;
    │ │ │ │ +
    347 }
    │ │ │ │ +
    │ │ │ │ +
    348
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    351 {
    │ │ │ │ +
    352 for (size_type i=0; i<block_size-n; i++)
    │ │ │ │ +
    353 getBit(i) = test(i+n);
    │ │ │ │ +
    354 return *this;
    │ │ │ │ +
    355 }
    │ │ │ │ +
    │ │ │ │ +
    356
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    359 {
    │ │ │ │ +
    360 for (size_type i=0; i<block_size-n; i++)
    │ │ │ │ +
    361 getBit(i+n) = test(i);
    │ │ │ │ +
    362 return *this;
    │ │ │ │ +
    363 }
    │ │ │ │ +
    │ │ │ │ +
    364
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    367 {
    │ │ │ │ +
    368 for (size_type i=0; i<block_size; i++)
    │ │ │ │ +
    369 set(i);
    │ │ │ │ +
    370 return *this;
    │ │ │ │ +
    371 }
    │ │ │ │ +
    │ │ │ │ +
    372
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    375 {
    │ │ │ │ +
    376 for (size_type i=0; i<block_size; i++)
    │ │ │ │ +
    377 flip(i);
    │ │ │ │ +
    378 return *this;
    │ │ │ │ +
    379 }
    │ │ │ │ +
    │ │ │ │ +
    380
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    383 {
    │ │ │ │ +
    384 *this = false;
    │ │ │ │ +
    385 return *this;
    │ │ │ │ +
    386 }
    │ │ │ │ +
    │ │ │ │ +
    387
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    390 {
    │ │ │ │ +
    391 getBit(n) = val;
    │ │ │ │ +
    392 return *this;
    │ │ │ │ +
    393 }
    │ │ │ │ +
    │ │ │ │ +
    394
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    397 {
    │ │ │ │ +
    398 set(n, false);
    │ │ │ │ +
    399 return *this;
    │ │ │ │ +
    400 }
    │ │ │ │ +
    │ │ │ │ +
    401
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    404 {
    │ │ │ │ +
    405 getBit(n).flip();
    │ │ │ │ +
    406 return *this;
    │ │ │ │ +
    407 }
    │ │ │ │ +
    │ │ │ │ +
    408
    │ │ │ │ + │ │ │ │ +
    410 using BitSetVectorConstReference::operator[];
    │ │ │ │ +
    411
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    414 {
    │ │ │ │ +
    415 return getBit(i);
    │ │ │ │ +
    416 }
    │ │ │ │ +
    │ │ │ │ +
    417
    │ │ │ │ +
    418 protected:
    │ │ │ │ + │ │ │ │ +
    420
    │ │ │ │ + │ │ │ │ +
    422
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    424 {
    │ │ │ │ +
    425 return blockBitField.getBit(this->block_number,i);
    │ │ │ │ +
    426 }
    │ │ │ │ +
    │ │ │ │ +
    427 };
    │ │ │ │ +
    │ │ │ │ +
    428
    │ │ │ │ +
    429 // implementation of helper - I put it into the template to avoid having
    │ │ │ │ +
    430 // to compile it in a dedicated compilation unit
    │ │ │ │ +
    431 template<int block_size, class Alloc>
    │ │ │ │ +
    432 bool BitSetVectorReference<block_size,Alloc>::xor_helper(bool a, bool b)
    │ │ │ │ +
    433 {
    │ │ │ │ +
    434 return a ^ b;
    │ │ │ │ +
    435 }
    │ │ │ │ +
    436
    │ │ │ │ +
    440 template<int block_size, class Alloc>
    │ │ │ │ +
    │ │ │ │ +
    441 struct const_reference< BitSetVectorReference<block_size,Alloc> >
    │ │ │ │ +
    442 {
    │ │ │ │ + │ │ │ │ +
    444 };
    │ │ │ │ +
    │ │ │ │ +
    445
    │ │ │ │ +
    446 template<int block_size, class Alloc>
    │ │ │ │ +
    │ │ │ │ +
    447 struct const_reference< BitSetVectorConstReference<block_size,Alloc> >
    │ │ │ │ +
    448 {
    │ │ │ │ + │ │ │ │ +
    450 };
    │ │ │ │ +
    │ │ │ │ +
    451
    │ │ │ │ +
    452 template<int block_size, class Alloc>
    │ │ │ │ +
    │ │ │ │ +
    453 struct mutable_reference< BitSetVectorReference<block_size,Alloc> >
    │ │ │ │ +
    454 {
    │ │ │ │ + │ │ │ │ +
    456 };
    │ │ │ │ +
    │ │ │ │ +
    457
    │ │ │ │ +
    458 template<int block_size, class Alloc>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    460 {
    │ │ │ │ + │ │ │ │ +
    462 };
    │ │ │ │ +
    │ │ │ │ +
    463
    │ │ │ │ +
    467 template <int block_size, class Allocator=std::allocator<bool> >
    │ │ │ │ +
    │ │ │ │ +
    468 class BitSetVector : private std::vector<bool, Allocator>
    │ │ │ │ +
    469 {
    │ │ │ │ +
    471 typedef std::vector<bool, Allocator> BlocklessBaseClass;
    │ │ │ │ +
    472
    │ │ │ │ +
    473 public:
    │ │ │ │ +
    476
    │ │ │ │ +
    478 typedef std::bitset<block_size> value_type;
    │ │ │ │ +
    479
    │ │ │ │ + │ │ │ │ +
    482
    │ │ │ │ + │ │ │ │ +
    485
    │ │ │ │ + │ │ │ │ +
    488
    │ │ │ │ + │ │ │ │ +
    491
    │ │ │ │ +
    493 typedef typename std::vector<bool, Allocator>::size_type size_type;
    │ │ │ │ +
    494
    │ │ │ │ +
    496 typedef Allocator allocator_type;
    │ │ │ │ +
    498
    │ │ │ │ + │ │ │ │ + │ │ │ │ +
    504
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    507 return iterator(*this, 0);
    │ │ │ │ +
    508 }
    │ │ │ │ +
    │ │ │ │ +
    509
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    512 return const_iterator(*this, 0);
    │ │ │ │ +
    513 }
    │ │ │ │ +
    │ │ │ │ +
    514
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    517 return iterator(*this, size());
    │ │ │ │ +
    518 }
    │ │ │ │ +
    │ │ │ │ +
    519
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    522 return const_iterator(*this, size());
    │ │ │ │ +
    523 }
    │ │ │ │ +
    │ │ │ │ +
    524
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    527 BlocklessBaseClass()
    │ │ │ │ +
    528 {}
    │ │ │ │ +
    │ │ │ │ +
    529
    │ │ │ │ +
    │ │ │ │ +
    531 BitSetVector(const BlocklessBaseClass& blocklessBitField) :
    │ │ │ │ +
    532 BlocklessBaseClass(blocklessBitField)
    │ │ │ │ +
    533 {
    │ │ │ │ +
    534 if (blocklessBitField.size()%block_size != 0)
    │ │ │ │ +
    535 DUNE_THROW(RangeError, "Vector size is not a multiple of the block size!");
    │ │ │ │ +
    536 }
    │ │ │ │ +
    │ │ │ │ +
    537
    │ │ │ │ +
    │ │ │ │ +
    541 explicit BitSetVector(int n) :
    │ │ │ │ +
    542 BlocklessBaseClass(n*block_size)
    │ │ │ │ +
    543 {}
    │ │ │ │ +
    │ │ │ │ +
    544
    │ │ │ │ +
    │ │ │ │ +
    546 BitSetVector(int n, bool v) :
    │ │ │ │ +
    547 BlocklessBaseClass(n*block_size,v)
    │ │ │ │ +
    548 {}
    │ │ │ │ +
    │ │ │ │ +
    549
    │ │ │ │ +
    │ │ │ │ +
    551 void clear()
    │ │ │ │ +
    552 {
    │ │ │ │ +
    553 BlocklessBaseClass::clear();
    │ │ │ │ +
    554 }
    │ │ │ │ +
    │ │ │ │ +
    555
    │ │ │ │ +
    │ │ │ │ +
    557 void resize(int n, bool v = bool())
    │ │ │ │ +
    558 {
    │ │ │ │ +
    559 BlocklessBaseClass::resize(n*block_size, v);
    │ │ │ │ +
    560 }
    │ │ │ │ +
    │ │ │ │ +
    561
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    564 {
    │ │ │ │ +
    565 return BlocklessBaseClass::size()/block_size;
    │ │ │ │ +
    566 }
    │ │ │ │ +
    │ │ │ │ +
    567
    │ │ │ │ +
    │ │ │ │ +
    569 void setAll() {
    │ │ │ │ +
    570 this->assign(BlocklessBaseClass::size(), true);
    │ │ │ │ +
    571 }
    │ │ │ │ +
    │ │ │ │ +
    572
    │ │ │ │ +
    │ │ │ │ +
    574 void unsetAll() {
    │ │ │ │ +
    575 this->assign(BlocklessBaseClass::size(), false);
    │ │ │ │ +
    576 }
    │ │ │ │ +
    │ │ │ │ +
    577
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    580 {
    │ │ │ │ +
    581 return reference(*this, i);
    │ │ │ │ +
    582 }
    │ │ │ │ +
    │ │ │ │ +
    583
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    586 {
    │ │ │ │ +
    587 return const_reference(*this, i);
    │ │ │ │ +
    588 }
    │ │ │ │ +
    │ │ │ │ +
    589
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    592 {
    │ │ │ │ +
    593 return reference(*this, size()-1);
    │ │ │ │ +
    594 }
    │ │ │ │ +
    │ │ │ │ +
    595
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    598 {
    │ │ │ │ +
    599 return const_reference(*this, size()-1);
    │ │ │ │ +
    600 }
    │ │ │ │ +
    │ │ │ │ +
    601
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    604 {
    │ │ │ │ +
    605 return std::count(BlocklessBaseClass::begin(), BlocklessBaseClass::end(), true);
    │ │ │ │ +
    606 }
    │ │ │ │ +
    │ │ │ │ +
    607
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    610 {
    │ │ │ │ +
    611 size_type n = 0;
    │ │ │ │ +
    612 size_type blocks = size();
    │ │ │ │ +
    613 for(size_type i=0; i<blocks; ++i)
    │ │ │ │ +
    614 n += getBit(i,j);
    │ │ │ │ +
    615 return n;
    │ │ │ │ +
    616 }
    │ │ │ │ +
    │ │ │ │ +
    617
    │ │ │ │ +
    │ │ │ │ +
    619 friend std::ostream& operator<< (std::ostream& s, const BitSetVector& v)
    │ │ │ │ +
    620 {
    │ │ │ │ +
    621 for (size_t i=0; i<v.size(); i++)
    │ │ │ │ +
    622 s << v[i] << " ";
    │ │ │ │ +
    623 return s;
    │ │ │ │ +
    624 }
    │ │ │ │ +
    │ │ │ │ +
    625
    │ │ │ │ +
    626 private:
    │ │ │ │ +
    627
    │ │ │ │ +
    629 value_type getRepr(int i) const
    │ │ │ │ +
    630 {
    │ │ │ │ +
    631 value_type bits;
    │ │ │ │ +
    632 for(int j=0; j<block_size; ++j)
    │ │ │ │ +
    633 bits.set(j, getBit(i,j));
    │ │ │ │ +
    634 return bits;
    │ │ │ │ +
    635 }
    │ │ │ │ +
    636
    │ │ │ │ +
    637 typename std::vector<bool>::reference getBit(size_type i, size_type j) {
    │ │ │ │ +
    638 DUNE_ASSERT_BOUNDS(j < block_size);
    │ │ │ │ + │ │ │ │ +
    640 return BlocklessBaseClass::operator[](i*block_size+j);
    │ │ │ │ +
    641 }
    │ │ │ │ +
    642
    │ │ │ │ +
    643 typename std::vector<bool>::const_reference getBit(size_type i, size_type j) const {
    │ │ │ │ +
    644 DUNE_ASSERT_BOUNDS(j < block_size);
    │ │ │ │ + │ │ │ │ +
    646 return BlocklessBaseClass::operator[](i*block_size+j);
    │ │ │ │ +
    647 }
    │ │ │ │ +
    648
    │ │ │ │ +
    649 friend class BitSetVectorReference<block_size,Allocator>;
    │ │ │ │ +
    650 friend class BitSetVectorConstReference<block_size,Allocator>;
    │ │ │ │ +
    651 };
    │ │ │ │ +
    │ │ │ │ +
    652
    │ │ │ │ +
    653} // namespace Dune
    │ │ │ │ +
    654
    │ │ │ │ +
    655#endif
    │ │ │ │ +
    A few common exception classes.
    │ │ │ │ +
    Macro for wrapping boundary checks.
    │ │ │ │ +
    Implements a generic iterator class for writing stl conformant iterators.
    │ │ │ │ +
    #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
    │ │ │ │ -
    bool anyTrue(ADLTag< 5 >, const AlignedNumber< bool, align > &mask)
    Definition debugalign.hh:543
    │ │ │ │ -
    T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v)
    Definition debugalign.hh:520
    │ │ │ │ -
    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
    │ │ │ │ +
    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:469
    │ │ │ │ +
    const_reference operator[](int i) const
    Return const reference to i-th block.
    Definition bitsetvector.hh:585
    │ │ │ │ +
    iterator begin()
    Returns a iterator pointing to the beginning of the vector.
    Definition bitsetvector.hh:506
    │ │ │ │ +
    BitSetVectorConstReference< block_size, Allocator > * const_pointer
    Const pointer to a small block of bits.
    Definition bitsetvector.hh:490
    │ │ │ │ +
    const_iterator end() const
    Returns a const_iterator pointing to the end of the vector.
    Definition bitsetvector.hh:521
    │ │ │ │ +
    BitSetVectorReference< block_size, Allocator > reference
    Reference to a small block of bits.
    Definition bitsetvector.hh:481
    │ │ │ │ +
    size_type countmasked(int j) const
    Returns the number of set bits, while each block is masked with 1<<i.
    Definition bitsetvector.hh:609
    │ │ │ │ +
    BitSetVectorConstReference< block_size, Allocator > const_reference
    Const reference to a small block of bits.
    Definition bitsetvector.hh:484
    │ │ │ │ +
    iterator end()
    Returns an iterator pointing to the end of the vector.
    Definition bitsetvector.hh:516
    │ │ │ │ +
    size_type count() const
    Returns the number of bits that are set.
    Definition bitsetvector.hh:603
    │ │ │ │ +
    BitSetVector()
    Default constructor.
    Definition bitsetvector.hh:526
    │ │ │ │ +
    void setAll()
    Sets all entries to true
    Definition bitsetvector.hh:569
    │ │ │ │ +
    Dune::GenericIterator< const BitSetVector< block_size, Allocator >, const value_type, const_reference, std::ptrdiff_t, ForwardIteratorFacade > const_iterator
    Definition bitsetvector.hh:502
    │ │ │ │ +
    std::bitset< block_size > value_type
    Type of the values stored by the container.
    Definition bitsetvector.hh:478
    │ │ │ │ +
    reference back()
    Return reference to last block.
    Definition bitsetvector.hh:591
    │ │ │ │ +
    BitSetVector(const BlocklessBaseClass &blocklessBitField)
    Construction from an unblocked bitfield.
    Definition bitsetvector.hh:531
    │ │ │ │ +
    friend std::ostream & operator<<(std::ostream &s, const BitSetVector &v)
    Send bitfield to an output stream.
    Definition bitsetvector.hh:619
    │ │ │ │ +
    const_reference back() const
    Return const reference to last block.
    Definition bitsetvector.hh:597
    │ │ │ │ +
    void clear()
    Erases all of the elements.
    Definition bitsetvector.hh:551
    │ │ │ │ +
    BitSetVectorReference< block_size, Allocator > * pointer
    Pointer to a small block of bits.
    Definition bitsetvector.hh:487
    │ │ │ │ +
    reference operator[](int i)
    Return reference to i-th block.
    Definition bitsetvector.hh:579
    │ │ │ │ +
    size_type size() const
    Return the number of blocks.
    Definition bitsetvector.hh:563
    │ │ │ │ +
    std::vector< bool, Allocator >::size_type size_type
    size type
    Definition bitsetvector.hh:493
    │ │ │ │ +
    BitSetVector(int n, bool v)
    Constructor which initializes the field with true or false.
    Definition bitsetvector.hh:546
    │ │ │ │ +
    const_iterator begin() const
    Returns a const_iterator pointing to the beginning of the vector.
    Definition bitsetvector.hh:511
    │ │ │ │ +
    Dune::GenericIterator< BitSetVector< block_size, Allocator >, value_type, reference, std::ptrdiff_t, ForwardIteratorFacade > iterator
    Definition bitsetvector.hh:501
    │ │ │ │ +
    void resize(int n, bool v=bool())
    Resize field.
    Definition bitsetvector.hh:557
    │ │ │ │ +
    Allocator allocator_type
    The type of the allocator.
    Definition bitsetvector.hh:496
    │ │ │ │ +
    BitSetVector(int n)
    Definition bitsetvector.hh:541
    │ │ │ │ +
    void unsetAll()
    Sets all entries to false
    Definition bitsetvector.hh:574
    │ │ │ │ +
    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:413
    │ │ │ │ +
    BitSetVectorReference & reset(size_type n)
    Clears bit n.
    Definition bitsetvector.hh:396
    │ │ │ │ +
    BitSetVectorReference & operator<<=(size_type n)
    Left shift.
    Definition bitsetvector.hh:350
    │ │ │ │ +
    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:423
    │ │ │ │ +
    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:382
    │ │ │ │ +
    BitSetVector & blockBitField
    Definition bitsetvector.hh:419
    │ │ │ │ +
    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:389
    │ │ │ │ +
    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:358
    │ │ │ │ +
    BitSetVectorReference & operator^=(const BitSetVectorConstReference &x)
    Bitwise exclusive or (for BitSetVectorConstReference and BitSetVectorReference)
    Definition bitsetvector.hh:340
    │ │ │ │ +
    BitSetVectorReference & flip(size_type n)
    Flips bit n.
    Definition bitsetvector.hh:403
    │ │ │ │ +
    BitSetVectorReference & flip()
    Flips the value of every bit.
    Definition bitsetvector.hh:374
    │ │ │ │ +
    BitSetVectorReference & set()
    Sets every bit.
    Definition bitsetvector.hh:366
    │ │ │ │ +
    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 & operator=(const BitSetVectorConstReference &b)
    hide assignment operator
    │ │ │ │ +
    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
    │ │ │ │ +
    friend std::ostream & operator<<(std::ostream &s, const BitSetVectorConstReference &v)
    Definition bitsetvector.hh:171
    │ │ │ │ +
    BitSetVectorConstReference< block_size, Alloc > type
    Definition bitsetvector.hh:443
    │ │ │ │ +
    BitSetVectorConstReference< block_size, Alloc > type
    Definition bitsetvector.hh:449
    │ │ │ │ +
    BitSetVectorReference< block_size, Alloc > type
    Definition bitsetvector.hh:455
    │ │ │ │ +
    BitSetVectorReference< block_size, Alloc > type
    Definition bitsetvector.hh:461
    │ │ │ │ +
    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:141
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,126 +7,939 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * simd │ │ │ │ │ -standard.hh │ │ │ │ │ +bitsetvector.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ - 1// SPDX-FileCopyrightInfo: Copyright (C) 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 (C) 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 │ │ │ │ │ - 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 │ │ │ │ │ - 56 │ │ │ │ │ - 59 template │ │ │ │ │ -60 struct ScalarType { using type = V; }; │ │ │ │ │ - 61 │ │ │ │ │ - 63 │ │ │ │ │ - 66 template │ │ │ │ │ -67 struct RebindType { using type = S; }; │ │ │ │ │ - 68 │ │ │ │ │ + 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ + 5#ifndef DUNE_BLOCK_BITFIELD_HH │ │ │ │ │ + 6#define DUNE_BLOCK_BITFIELD_HH │ │ │ │ │ + 7 │ │ │ │ │ + 12#include │ │ │ │ │ + 13#include │ │ │ │ │ + 14#include │ │ │ │ │ + 15#include │ │ │ │ │ + 16 │ │ │ │ │ + 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); │ │ │ │ │ + 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 │ │ │ │ │ +64 bitset operator<<(size_type n) const │ │ │ │ │ + 65 { │ │ │ │ │ + 66 bitset b = *this; │ │ │ │ │ + 67 b <<= n; │ │ │ │ │ + 68 return b; │ │ │ │ │ + 69 } │ │ │ │ │ 70 │ │ │ │ │ - 73 template │ │ │ │ │ -74 struct LaneCount : public index_constant<1> { }; │ │ │ │ │ - 75 │ │ │ │ │ - 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; } │ │ │ │ │ - 112 │ │ │ │ │ - 114 │ │ │ │ │ - 115 } // namespace Overloads │ │ │ │ │ - 116 } // namespace Simd │ │ │ │ │ - 117} // namespace Dune │ │ │ │ │ - 118 │ │ │ │ │ - 119#endif // DUNE_COMMON_SIMD_STANDARD_HH │ │ │ │ │ -indices.hh │ │ │ │ │ -base.hh │ │ │ │ │ -Basic definitions for SIMD Implementations. │ │ │ │ │ -defaults.hh │ │ │ │ │ -Default implementations for SIMD Implementations. │ │ │ │ │ -Dune::index_constant │ │ │ │ │ -std::integral_constant< std::size_t, i > index_constant │ │ │ │ │ -An index constant with value i. │ │ │ │ │ -Definition indices.hh:30 │ │ │ │ │ -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 │ │ │ │ │ +72 bitset operator>>(size_type n) const │ │ │ │ │ + 73 { │ │ │ │ │ + 74 bitset b = *this; │ │ │ │ │ + 75 b >>= n; │ │ │ │ │ + 76 return b; │ │ │ │ │ + 77 } │ │ │ │ │ + 78 │ │ │ │ │ +80 bitset operator~() const │ │ │ │ │ + 81 { │ │ │ │ │ + 82 bitset b = *this; │ │ │ │ │ + 83 b.flip(); │ │ │ │ │ + 84 return b; │ │ │ │ │ + 85 } │ │ │ │ │ + 86 │ │ │ │ │ +88 size_type size() const │ │ │ │ │ + 89 { │ │ │ │ │ + 90 return block_size; │ │ │ │ │ + 91 } │ │ │ │ │ + 92 │ │ │ │ │ +94 size_type count() const │ │ │ │ │ + 95 { │ │ │ │ │ + 96 size_type n = 0; │ │ │ │ │ + 97 for(size_type i=0; i │ │ │ │ │ +190 bool equals(const BS & bs) const │ │ │ │ │ + 191 { │ │ │ │ │ + 192 bool eq = true; │ │ │ │ │ + 193 for(int i=0; i; │ │ │ │ │ + 206 }; │ │ │ │ │ + 207 │ │ │ │ │ + 220 template │ │ │ │ │ +221 class BitSetVectorReference : public │ │ │ │ │ +BitSetVectorConstReference │ │ │ │ │ + 222 { │ │ │ │ │ + 223 protected: │ │ │ │ │ + 224 │ │ │ │ │ +225 typedef Dune::BitSetVector BitSetVector; │ │ │ │ │ + 226 friend class Dune::BitSetVector; │ │ │ │ │ + 227 │ │ │ │ │ +228 typedef Dune::BitSetVectorConstReference │ │ │ │ │ +BitSetVectorConstReference; │ │ │ │ │ + 229 │ │ │ │ │ +230 BitSetVectorReference(BitSetVector& blockBitField_, int block_number_) : │ │ │ │ │ + 231 BitSetVectorConstReference(blockBitField_, block_number_), │ │ │ │ │ + 232 blockBitField(blockBitField_) │ │ │ │ │ + 233 {} │ │ │ │ │ + 234 │ │ │ │ │ + 235 public: │ │ │ │ │ +236 typedef std::bitset bitset; │ │ │ │ │ + 237 │ │ │ │ │ +241 typedef typename std::vector::reference reference; │ │ │ │ │ +243 typedef typename std::vector::const_reference const_reference; │ │ │ │ │ + 245 │ │ │ │ │ +247 typedef size_t size_type; │ │ │ │ │ + 248 │ │ │ │ │ +250 BitSetVectorReference& operator=(bool b) │ │ │ │ │ + 251 { │ │ │ │ │ + 252 for(int i=0; i>=(size_type n) │ │ │ │ │ + 359 { │ │ │ │ │ + 360 for (size_type i=0; iblock_number,i); │ │ │ │ │ + 426 } │ │ │ │ │ + 427 }; │ │ │ │ │ + 428 │ │ │ │ │ + 429 // implementation of helper - I put it into the template to avoid having │ │ │ │ │ + 430 // to compile it in a dedicated compilation unit │ │ │ │ │ + 431 template │ │ │ │ │ + 432 bool BitSetVectorReference::xor_helper(bool a, bool b) │ │ │ │ │ + 433 { │ │ │ │ │ + 434 return a ^ b; │ │ │ │ │ + 435 } │ │ │ │ │ + 436 │ │ │ │ │ + 440 template │ │ │ │ │ +441 struct const_reference< BitSetVectorReference > │ │ │ │ │ + 442 { │ │ │ │ │ +443 typedef BitSetVectorConstReference type; │ │ │ │ │ + 444 }; │ │ │ │ │ + 445 │ │ │ │ │ + 446 template │ │ │ │ │ +447 struct const_reference< BitSetVectorConstReference > │ │ │ │ │ + 448 { │ │ │ │ │ +449 typedef BitSetVectorConstReference type; │ │ │ │ │ + 450 }; │ │ │ │ │ + 451 │ │ │ │ │ + 452 template │ │ │ │ │ +453 struct mutable_reference< BitSetVectorReference > │ │ │ │ │ + 454 { │ │ │ │ │ +455 typedef BitSetVectorReference type; │ │ │ │ │ + 456 }; │ │ │ │ │ + 457 │ │ │ │ │ + 458 template │ │ │ │ │ +459 struct mutable_reference< BitSetVectorConstReference > │ │ │ │ │ + 460 { │ │ │ │ │ +461 typedef BitSetVectorReference type; │ │ │ │ │ + 462 }; │ │ │ │ │ + 463 │ │ │ │ │ + 467 template > │ │ │ │ │ +468 class BitSetVector : private std::vector │ │ │ │ │ + 469 { │ │ │ │ │ + 471 typedef std::vector BlocklessBaseClass; │ │ │ │ │ + 472 │ │ │ │ │ + 473 public: │ │ │ │ │ + 476 │ │ │ │ │ +478 typedef std::bitset value_type; │ │ │ │ │ + 479 │ │ │ │ │ +481 typedef BitSetVectorReference reference; │ │ │ │ │ + 482 │ │ │ │ │ +484 typedef BitSetVectorConstReference const_reference; │ │ │ │ │ + 485 │ │ │ │ │ +487 typedef BitSetVectorReference* pointer; │ │ │ │ │ + 488 │ │ │ │ │ +490 typedef BitSetVectorConstReference* const_pointer; │ │ │ │ │ + 491 │ │ │ │ │ +493 typedef typename std::vector::size_type size_type; │ │ │ │ │ + 494 │ │ │ │ │ +496 typedef Allocator allocator_type; │ │ │ │ │ + 498 │ │ │ │ │ +501 typedef Dune::GenericIterator, │ │ │ │ │ +value_type, reference, std::ptrdiff_t, ForwardIteratorFacade> iterator; │ │ │ │ │ +502 typedef Dune::GenericIterator, │ │ │ │ │ +const value_type, const_reference, std::ptrdiff_t, ForwardIteratorFacade> │ │ │ │ │ +const_iterator; │ │ │ │ │ + 504 │ │ │ │ │ +506 iterator begin(){ │ │ │ │ │ + 507 return iterator(*this, 0); │ │ │ │ │ + 508 } │ │ │ │ │ + 509 │ │ │ │ │ +511 const_iterator begin() const { │ │ │ │ │ + 512 return const_iterator(*this, 0); │ │ │ │ │ + 513 } │ │ │ │ │ + 514 │ │ │ │ │ +516 iterator end(){ │ │ │ │ │ + 517 return iterator(*this, size()); │ │ │ │ │ + 518 } │ │ │ │ │ + 519 │ │ │ │ │ +521 const_iterator end() const { │ │ │ │ │ + 522 return const_iterator(*this, size()); │ │ │ │ │ + 523 } │ │ │ │ │ + 524 │ │ │ │ │ +526 BitSetVector() : │ │ │ │ │ + 527 BlocklessBaseClass() │ │ │ │ │ + 528 {} │ │ │ │ │ + 529 │ │ │ │ │ +531 BitSetVector(const BlocklessBaseClass& blocklessBitField) : │ │ │ │ │ + 532 BlocklessBaseClass(blocklessBitField) │ │ │ │ │ + 533 { │ │ │ │ │ + 534 if (blocklessBitField.size()%block_size != 0) │ │ │ │ │ + 535 DUNE_THROW(RangeError, "Vector size is not a multiple of the block │ │ │ │ │ +size!"); │ │ │ │ │ + 536 } │ │ │ │ │ + 537 │ │ │ │ │ +541 explicit BitSetVector(int n) : │ │ │ │ │ + 542 BlocklessBaseClass(n*block_size) │ │ │ │ │ + 543 {} │ │ │ │ │ + 544 │ │ │ │ │ +546 BitSetVector(int n, bool v) : │ │ │ │ │ + 547 BlocklessBaseClass(n*block_size,v) │ │ │ │ │ + 548 {} │ │ │ │ │ + 549 │ │ │ │ │ +551 void clear() │ │ │ │ │ + 552 { │ │ │ │ │ + 553 BlocklessBaseClass::clear(); │ │ │ │ │ + 554 } │ │ │ │ │ + 555 │ │ │ │ │ +557 void resize(int n, bool v = bool()) │ │ │ │ │ + 558 { │ │ │ │ │ + 559 BlocklessBaseClass::resize(n*block_size, v); │ │ │ │ │ + 560 } │ │ │ │ │ + 561 │ │ │ │ │ +563 size_type size() const │ │ │ │ │ + 564 { │ │ │ │ │ + 565 return BlocklessBaseClass::size()/block_size; │ │ │ │ │ + 566 } │ │ │ │ │ + 567 │ │ │ │ │ +569 void setAll() { │ │ │ │ │ + 570 this->assign(BlocklessBaseClass::size(), true); │ │ │ │ │ + 571 } │ │ │ │ │ + 572 │ │ │ │ │ +574 void unsetAll() { │ │ │ │ │ + 575 this->assign(BlocklessBaseClass::size(), false); │ │ │ │ │ + 576 } │ │ │ │ │ + 577 │ │ │ │ │ +579 reference operator[](int i) │ │ │ │ │ + 580 { │ │ │ │ │ + 581 return reference(*this, i); │ │ │ │ │ + 582 } │ │ │ │ │ + 583 │ │ │ │ │ +585 const_reference operator[](int i) const │ │ │ │ │ + 586 { │ │ │ │ │ + 587 return const_reference(*this, i); │ │ │ │ │ + 588 } │ │ │ │ │ + 589 │ │ │ │ │ +591 reference back() │ │ │ │ │ + 592 { │ │ │ │ │ + 593 return reference(*this, size()-1); │ │ │ │ │ + 594 } │ │ │ │ │ + 595 │ │ │ │ │ +597 const_reference back() const │ │ │ │ │ + 598 { │ │ │ │ │ + 599 return const_reference(*this, size()-1); │ │ │ │ │ + 600 } │ │ │ │ │ + 601 │ │ │ │ │ +603 size_type count() const │ │ │ │ │ + 604 { │ │ │ │ │ + 605 return std::count(BlocklessBaseClass::begin(), BlocklessBaseClass::end(), │ │ │ │ │ +true); │ │ │ │ │ + 606 } │ │ │ │ │ + 607 │ │ │ │ │ +609 size_type countmasked(int j) const │ │ │ │ │ + 610 { │ │ │ │ │ + 611 size_type n = 0; │ │ │ │ │ + 612 size_type blocks = size(); │ │ │ │ │ + 613 for(size_type i=0; i::reference getBit(size_type i, size_type j) { │ │ │ │ │ + 638 DUNE_ASSERT_BOUNDS(j < block_size); │ │ │ │ │ + 639 DUNE_ASSERT_BOUNDS(i < size()); │ │ │ │ │ + 640 return BlocklessBaseClass::operator[](i*block_size+j); │ │ │ │ │ + 641 } │ │ │ │ │ + 642 │ │ │ │ │ +643 typename std::vector::const_reference getBit(size_type i, size_type │ │ │ │ │ +j) const { │ │ │ │ │ + 644 DUNE_ASSERT_BOUNDS(j < block_size); │ │ │ │ │ + 645 DUNE_ASSERT_BOUNDS(i < size()); │ │ │ │ │ + 646 return BlocklessBaseClass::operator[](i*block_size+j); │ │ │ │ │ + 647 } │ │ │ │ │ + 648 │ │ │ │ │ + 649 friend class BitSetVectorReference; │ │ │ │ │ + 650 friend class BitSetVectorConstReference; │ │ │ │ │ + 651 }; │ │ │ │ │ + 652 │ │ │ │ │ + 653} // namespace Dune │ │ │ │ │ + 654 │ │ │ │ │ + 655#endif │ │ │ │ │ +exceptions.hh │ │ │ │ │ +A few common exception classes. │ │ │ │ │ +boundschecking.hh │ │ │ │ │ +Macro for wrapping boundary checks. │ │ │ │ │ +genericiterator.hh │ │ │ │ │ +Implements a generic iterator class for writing stl conformant iterators. │ │ │ │ │ +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 │ │ │ │ │ +DUNE_THROW │ │ │ │ │ +#define DUNE_THROW(E, m) │ │ │ │ │ +Definition exceptions.hh:218 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::Simd::Overloads::anyTrue │ │ │ │ │ -bool anyTrue(ADLTag< 5 >, const AlignedNumber< bool, align > &mask) │ │ │ │ │ -Definition debugalign.hh:543 │ │ │ │ │ -Dune::Simd::Overloads::lane │ │ │ │ │ -T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v) │ │ │ │ │ -Definition debugalign.hh:520 │ │ │ │ │ -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::assign │ │ │ │ │ +void assign(T &dst, const T &src, bool mask) │ │ │ │ │ +masked Simd assignment (scalar version) │ │ │ │ │ +Definition simd.hh:447 │ │ │ │ │ +Dune::BitSetVector │ │ │ │ │ +A dynamic array of blocks of booleans. │ │ │ │ │ +Definition bitsetvector.hh:469 │ │ │ │ │ +Dune::BitSetVector::operator[] │ │ │ │ │ +const_reference operator[](int i) const │ │ │ │ │ +Return const reference to i-th block. │ │ │ │ │ +Definition bitsetvector.hh:585 │ │ │ │ │ +Dune::BitSetVector::begin │ │ │ │ │ +iterator begin() │ │ │ │ │ +Returns a iterator pointing to the beginning of the vector. │ │ │ │ │ +Definition bitsetvector.hh:506 │ │ │ │ │ +Dune::BitSetVector::const_pointer │ │ │ │ │ +BitSetVectorConstReference< block_size, Allocator > * const_pointer │ │ │ │ │ +Const pointer to a small block of bits. │ │ │ │ │ +Definition bitsetvector.hh:490 │ │ │ │ │ +Dune::BitSetVector::end │ │ │ │ │ +const_iterator end() const │ │ │ │ │ +Returns a const_iterator pointing to the end of the vector. │ │ │ │ │ +Definition bitsetvector.hh:521 │ │ │ │ │ +Dune::BitSetVector::reference │ │ │ │ │ +BitSetVectorReference< block_size, Allocator > reference │ │ │ │ │ +Reference to a small block of bits. │ │ │ │ │ +Definition bitsetvector.hh:481 │ │ │ │ │ +Dune::BitSetVector::countmasked │ │ │ │ │ +size_type countmasked(int j) const │ │ │ │ │ +Returns the number of set bits, while each block is masked with 1< const_reference │ │ │ │ │ +Const reference to a small block of bits. │ │ │ │ │ +Definition bitsetvector.hh:484 │ │ │ │ │ +Dune::BitSetVector::end │ │ │ │ │ +iterator end() │ │ │ │ │ +Returns an iterator pointing to the end of the vector. │ │ │ │ │ +Definition bitsetvector.hh:516 │ │ │ │ │ +Dune::BitSetVector::count │ │ │ │ │ +size_type count() const │ │ │ │ │ +Returns the number of bits that are set. │ │ │ │ │ +Definition bitsetvector.hh:603 │ │ │ │ │ +Dune::BitSetVector::BitSetVector │ │ │ │ │ +BitSetVector() │ │ │ │ │ +Default constructor. │ │ │ │ │ +Definition bitsetvector.hh:526 │ │ │ │ │ +Dune::BitSetVector::setAll │ │ │ │ │ +void setAll() │ │ │ │ │ +Sets all entries to true │ │ │ │ │ +Definition bitsetvector.hh:569 │ │ │ │ │ +Dune::BitSetVector::const_iterator │ │ │ │ │ +Dune::GenericIterator< const BitSetVector< block_size, Allocator >, const │ │ │ │ │ +value_type, const_reference, std::ptrdiff_t, ForwardIteratorFacade > │ │ │ │ │ +const_iterator │ │ │ │ │ +Definition bitsetvector.hh:502 │ │ │ │ │ +Dune::BitSetVector::value_type │ │ │ │ │ +std::bitset< block_size > value_type │ │ │ │ │ +Type of the values stored by the container. │ │ │ │ │ +Definition bitsetvector.hh:478 │ │ │ │ │ +Dune::BitSetVector::back │ │ │ │ │ +reference back() │ │ │ │ │ +Return reference to last block. │ │ │ │ │ +Definition bitsetvector.hh:591 │ │ │ │ │ +Dune::BitSetVector::BitSetVector │ │ │ │ │ +BitSetVector(const BlocklessBaseClass &blocklessBitField) │ │ │ │ │ +Construction from an unblocked bitfield. │ │ │ │ │ +Definition bitsetvector.hh:531 │ │ │ │ │ +Dune::BitSetVector::operator<< │ │ │ │ │ +friend std::ostream & operator<<(std::ostream &s, const BitSetVector &v) │ │ │ │ │ +Send bitfield to an output stream. │ │ │ │ │ +Definition bitsetvector.hh:619 │ │ │ │ │ +Dune::BitSetVector::back │ │ │ │ │ +const_reference back() const │ │ │ │ │ +Return const reference to last block. │ │ │ │ │ +Definition bitsetvector.hh:597 │ │ │ │ │ +Dune::BitSetVector::clear │ │ │ │ │ +void clear() │ │ │ │ │ +Erases all of the elements. │ │ │ │ │ +Definition bitsetvector.hh:551 │ │ │ │ │ +Dune::BitSetVector::pointer │ │ │ │ │ +BitSetVectorReference< block_size, Allocator > * pointer │ │ │ │ │ +Pointer to a small block of bits. │ │ │ │ │ +Definition bitsetvector.hh:487 │ │ │ │ │ +Dune::BitSetVector::operator[] │ │ │ │ │ +reference operator[](int i) │ │ │ │ │ +Return reference to i-th block. │ │ │ │ │ +Definition bitsetvector.hh:579 │ │ │ │ │ +Dune::BitSetVector::size │ │ │ │ │ +size_type size() const │ │ │ │ │ +Return the number of blocks. │ │ │ │ │ +Definition bitsetvector.hh:563 │ │ │ │ │ +Dune::BitSetVector::size_type │ │ │ │ │ +std::vector< bool, Allocator >::size_type size_type │ │ │ │ │ +size type │ │ │ │ │ +Definition bitsetvector.hh:493 │ │ │ │ │ +Dune::BitSetVector::BitSetVector │ │ │ │ │ +BitSetVector(int n, bool v) │ │ │ │ │ +Constructor which initializes the field with true or false. │ │ │ │ │ +Definition bitsetvector.hh:546 │ │ │ │ │ +Dune::BitSetVector::begin │ │ │ │ │ +const_iterator begin() const │ │ │ │ │ +Returns a const_iterator pointing to the beginning of the vector. │ │ │ │ │ +Definition bitsetvector.hh:511 │ │ │ │ │ +Dune::BitSetVector::iterator │ │ │ │ │ +Dune::GenericIterator< BitSetVector< block_size, Allocator >, value_type, │ │ │ │ │ +reference, std::ptrdiff_t, ForwardIteratorFacade > iterator │ │ │ │ │ +Definition bitsetvector.hh:501 │ │ │ │ │ +Dune::BitSetVector::resize │ │ │ │ │ +void resize(int n, bool v=bool()) │ │ │ │ │ +Resize field. │ │ │ │ │ +Definition bitsetvector.hh:557 │ │ │ │ │ +Dune::BitSetVector::allocator_type │ │ │ │ │ +Allocator allocator_type │ │ │ │ │ +The type of the allocator. │ │ │ │ │ +Definition bitsetvector.hh:496 │ │ │ │ │ +Dune::BitSetVector::BitSetVector │ │ │ │ │ +BitSetVector(int n) │ │ │ │ │ +Definition bitsetvector.hh:541 │ │ │ │ │ +Dune::BitSetVector::unsetAll │ │ │ │ │ +void unsetAll() │ │ │ │ │ +Sets all entries to false │ │ │ │ │ +Definition bitsetvector.hh:574 │ │ │ │ │ +Dune::BitSetVectorReference │ │ │ │ │ +A proxy class that acts as a mutable reference to a single bitset in a │ │ │ │ │ +BitSetVector. │ │ │ │ │ +Definition bitsetvector.hh:222 │ │ │ │ │ +Dune::BitSetVectorReference::test │ │ │ │ │ +bool test(size_type n) const │ │ │ │ │ +Returns true if bit n is set. │ │ │ │ │ +Definition bitsetvector.hh:124 │ │ │ │ │ +Dune::BitSetVectorReference::operator= │ │ │ │ │ +BitSetVectorReference & operator=(const BitSetVectorConstReference &b) │ │ │ │ │ +Assignment from BitSetVectorConstReference. │ │ │ │ │ +Definition bitsetvector.hh:266 │ │ │ │ │ +Dune::BitSetVectorReference::operator[] │ │ │ │ │ +reference operator[](size_type i) │ │ │ │ │ +Return reference to the i-th bit. │ │ │ │ │ +Definition bitsetvector.hh:413 │ │ │ │ │ +Dune::BitSetVectorReference::reset │ │ │ │ │ +BitSetVectorReference & reset(size_type n) │ │ │ │ │ +Clears bit n. │ │ │ │ │ +Definition bitsetvector.hh:396 │ │ │ │ │ +Dune::BitSetVectorReference::operator<<= │ │ │ │ │ +BitSetVectorReference & operator<<=(size_type n) │ │ │ │ │ +Left shift. │ │ │ │ │ +Definition bitsetvector.hh:350 │ │ │ │ │ +Dune::BitSetVectorReference::BitSetVector │ │ │ │ │ +Dune::BitSetVector< block_size, Alloc > BitSetVector │ │ │ │ │ +Definition bitsetvector.hh:225 │ │ │ │ │ +Dune::BitSetVectorReference::const_reference │ │ │ │ │ +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 │ │ │ │ │ +Dune::BitSetVectorReference::operator= │ │ │ │ │ +BitSetVectorReference & operator=(const BitSetVectorReference &b) │ │ │ │ │ +Assignment from BitSetVectorReference. │ │ │ │ │ +Definition bitsetvector.hh:274 │ │ │ │ │ +Dune::BitSetVectorReference::getBit │ │ │ │ │ +reference getBit(size_type i) │ │ │ │ │ +Definition bitsetvector.hh:423 │ │ │ │ │ +Dune::BitSetVectorReference::operator&= │ │ │ │ │ +BitSetVectorReference & operator&=(const BitSetVectorConstReference &x) │ │ │ │ │ +Bitwise and (for BitSetVectorConstReference and BitSetVectorReference) │ │ │ │ │ +Definition bitsetvector.hh:290 │ │ │ │ │ +Dune::BitSetVectorReference::BitSetVectorReference │ │ │ │ │ +BitSetVectorReference(BitSetVector &blockBitField_, int block_number_) │ │ │ │ │ +Definition bitsetvector.hh:230 │ │ │ │ │ +Dune::BitSetVectorReference::size_type │ │ │ │ │ +size_t size_type │ │ │ │ │ +size_type typedef (an unsigned integral type) │ │ │ │ │ +Definition bitsetvector.hh:247 │ │ │ │ │ +Dune::BitSetVectorReference::operator= │ │ │ │ │ +BitSetVectorReference & operator=(const bitset &b) │ │ │ │ │ +Assignment from bitset. │ │ │ │ │ +Definition bitsetvector.hh:258 │ │ │ │ │ +Dune::BitSetVectorReference::BitSetVectorConstReference │ │ │ │ │ +Dune::BitSetVectorConstReference< block_size, Alloc > │ │ │ │ │ +BitSetVectorConstReference │ │ │ │ │ +Definition bitsetvector.hh:228 │ │ │ │ │ +Dune::BitSetVectorReference::reset │ │ │ │ │ +BitSetVectorReference & reset() │ │ │ │ │ +Clears every bit. │ │ │ │ │ +Definition bitsetvector.hh:382 │ │ │ │ │ +Dune::BitSetVectorReference::blockBitField │ │ │ │ │ +BitSetVector & blockBitField │ │ │ │ │ +Definition bitsetvector.hh:419 │ │ │ │ │ +Dune::BitSetVectorReference::operator|= │ │ │ │ │ +BitSetVectorReference & operator|=(const BitSetVectorConstReference &x) │ │ │ │ │ +Bitwise inclusive or (for BitSetVectorConstReference and BitSetVectorReference) │ │ │ │ │ +Definition bitsetvector.hh:306 │ │ │ │ │ +Dune::BitSetVectorReference::set │ │ │ │ │ +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:389 │ │ │ │ │ +Dune::BitSetVectorReference::bitset │ │ │ │ │ +std::bitset< block_size > bitset │ │ │ │ │ +Definition bitsetvector.hh:236 │ │ │ │ │ +Dune::BitSetVectorReference::operator^= │ │ │ │ │ +BitSetVectorReference & operator^=(const bitset &x) │ │ │ │ │ +Bitwise exclusive or (for bitset). │ │ │ │ │ +Definition bitsetvector.hh:314 │ │ │ │ │ +Dune::BitSetVectorReference::reference │ │ │ │ │ +std::vector< bool, Alloc >::reference reference │ │ │ │ │ +Definition bitsetvector.hh:241 │ │ │ │ │ +Dune::BitSetVectorReference::operator|= │ │ │ │ │ +BitSetVectorReference & operator|=(const bitset &x) │ │ │ │ │ +Bitwise inclusive or (for bitset) │ │ │ │ │ +Definition bitsetvector.hh:298 │ │ │ │ │ +Dune::BitSetVectorReference::operator>>= │ │ │ │ │ +BitSetVectorReference & operator>>=(size_type n) │ │ │ │ │ +Right shift. │ │ │ │ │ +Definition bitsetvector.hh:358 │ │ │ │ │ +Dune::BitSetVectorReference::operator^= │ │ │ │ │ +BitSetVectorReference & operator^=(const BitSetVectorConstReference &x) │ │ │ │ │ +Bitwise exclusive or (for BitSetVectorConstReference and BitSetVectorReference) │ │ │ │ │ +Definition bitsetvector.hh:340 │ │ │ │ │ +Dune::BitSetVectorReference::flip │ │ │ │ │ +BitSetVectorReference & flip(size_type n) │ │ │ │ │ +Flips bit n. │ │ │ │ │ +Definition bitsetvector.hh:403 │ │ │ │ │ +Dune::BitSetVectorReference::flip │ │ │ │ │ +BitSetVectorReference & flip() │ │ │ │ │ +Flips the value of every bit. │ │ │ │ │ +Definition bitsetvector.hh:374 │ │ │ │ │ +Dune::BitSetVectorReference::set │ │ │ │ │ +BitSetVectorReference & set() │ │ │ │ │ +Sets every bit. │ │ │ │ │ +Definition bitsetvector.hh:366 │ │ │ │ │ +Dune::BitSetVectorReference::operator&= │ │ │ │ │ +BitSetVectorReference & operator&=(const bitset &x) │ │ │ │ │ +Bitwise and (for bitset). │ │ │ │ │ +Definition bitsetvector.hh:282 │ │ │ │ │ +Dune::BitSetVectorReference::operator= │ │ │ │ │ +BitSetVectorReference & operator=(bool b) │ │ │ │ │ +Assignment from bool, sets each bit in the bitset to b. │ │ │ │ │ +Definition bitsetvector.hh:250 │ │ │ │ │ +Dune::BitSetVectorConstReference │ │ │ │ │ +A proxy class that acts as a const reference to a single bitset in a │ │ │ │ │ +BitSetVector. │ │ │ │ │ +Definition bitsetvector.hh:38 │ │ │ │ │ +Dune::BitSetVectorConstReference::operator== │ │ │ │ │ +bool operator==(const bitset &bs) const │ │ │ │ │ +Equality of reference and std::bitset. │ │ │ │ │ +Definition bitsetvector.hh:142 │ │ │ │ │ +Dune::BitSetVectorConstReference::test │ │ │ │ │ +bool test(size_type n) const │ │ │ │ │ +Returns true if bit n is set. │ │ │ │ │ +Definition bitsetvector.hh:124 │ │ │ │ │ +Dune::BitSetVectorConstReference::operator[] │ │ │ │ │ +const_reference operator[](size_type i) const │ │ │ │ │ +Return reference to the i-th bit. │ │ │ │ │ +Definition bitsetvector.hh:130 │ │ │ │ │ +Dune::BitSetVectorConstReference::operator<< │ │ │ │ │ +bitset operator<<(size_type n) const │ │ │ │ │ +Returns a copy of *this shifted left by n bits. │ │ │ │ │ +Definition bitsetvector.hh:64 │ │ │ │ │ +Dune::BitSetVectorConstReference::operator= │ │ │ │ │ +BitSetVectorConstReference & operator=(const BitSetVectorConstReference &b) │ │ │ │ │ +hide assignment operator │ │ │ │ │ +Dune::BitSetVectorConstReference::BitSetVectorConstReference │ │ │ │ │ +BitSetVectorConstReference(const BitSetVector &blockBitField_, int │ │ │ │ │ +block_number_) │ │ │ │ │ +Definition bitsetvector.hh:44 │ │ │ │ │ +Dune::BitSetVectorConstReference::blockBitField │ │ │ │ │ +const BitSetVector & blockBitField │ │ │ │ │ +Definition bitsetvector.hh:181 │ │ │ │ │ +Dune::BitSetVectorConstReference::operator>> │ │ │ │ │ +bitset operator>>(size_type n) const │ │ │ │ │ +Returns a copy of *this shifted right by n bits. │ │ │ │ │ +Definition bitsetvector.hh:72 │ │ │ │ │ +Dune::BitSetVectorConstReference::getBit │ │ │ │ │ +const_reference getBit(size_type i) const │ │ │ │ │ +Definition bitsetvector.hh:184 │ │ │ │ │ +Dune::BitSetVectorConstReference::operator!= │ │ │ │ │ +bool operator!=(const bitset &bs) const │ │ │ │ │ +Inequality of reference and std::bitset. │ │ │ │ │ +Definition bitsetvector.hh:154 │ │ │ │ │ +Dune::BitSetVectorConstReference::equals │ │ │ │ │ +bool equals(const BS &bs) const │ │ │ │ │ +Definition bitsetvector.hh:190 │ │ │ │ │ +Dune::BitSetVectorConstReference::BitSetVector │ │ │ │ │ +Dune::BitSetVector< block_size, Alloc > BitSetVector │ │ │ │ │ +Definition bitsetvector.hh:41 │ │ │ │ │ +Dune::BitSetVectorConstReference::bitset │ │ │ │ │ +std::bitset< block_size > bitset │ │ │ │ │ +Definition bitsetvector.hh:56 │ │ │ │ │ +Dune::BitSetVectorConstReference::all │ │ │ │ │ +bool all() const │ │ │ │ │ +Returns true if all bits are set. │ │ │ │ │ +Definition bitsetvector.hh:115 │ │ │ │ │ +Dune::BitSetVectorConstReference::size_type │ │ │ │ │ +size_t size_type │ │ │ │ │ +Definition bitsetvector.hh:61 │ │ │ │ │ +Dune::BitSetVectorConstReference::operator~ │ │ │ │ │ +bitset operator~() const │ │ │ │ │ +Returns a copy of *this with all of its bits flipped. │ │ │ │ │ +Definition bitsetvector.hh:80 │ │ │ │ │ +Dune::BitSetVectorConstReference::reference │ │ │ │ │ +std::vector< bool, Alloc >::const_reference reference │ │ │ │ │ +Definition bitsetvector.hh:59 │ │ │ │ │ +Dune::BitSetVectorConstReference::size │ │ │ │ │ +size_type size() const │ │ │ │ │ +Returns block_size. │ │ │ │ │ +Definition bitsetvector.hh:88 │ │ │ │ │ +Dune::BitSetVectorConstReference::count │ │ │ │ │ +size_type count() const │ │ │ │ │ +Returns the number of bits that are set. │ │ │ │ │ +Definition bitsetvector.hh:94 │ │ │ │ │ +Dune::BitSetVectorConstReference::none │ │ │ │ │ +bool none() const │ │ │ │ │ +Returns true if no bits are set. │ │ │ │ │ +Definition bitsetvector.hh:109 │ │ │ │ │ +Dune::BitSetVectorConstReference::any │ │ │ │ │ +bool any() const │ │ │ │ │ +Returns true if any bits are set. │ │ │ │ │ +Definition bitsetvector.hh:103 │ │ │ │ │ +Dune::BitSetVectorConstReference::block_number │ │ │ │ │ +int block_number │ │ │ │ │ +Definition bitsetvector.hh:182 │ │ │ │ │ +Dune::BitSetVectorConstReference::const_reference │ │ │ │ │ +std::vector< bool, Alloc >::const_reference const_reference │ │ │ │ │ +Definition bitsetvector.hh:60 │ │ │ │ │ +Dune::BitSetVectorConstReference::operator<< │ │ │ │ │ +friend std::ostream & operator<<(std::ostream &s, const │ │ │ │ │ +BitSetVectorConstReference &v) │ │ │ │ │ +Definition bitsetvector.hh:171 │ │ │ │ │ +Dune::const_reference<_BitSetVectorReference<_block_size,_Alloc_>_>::type │ │ │ │ │ +BitSetVectorConstReference< block_size, Alloc > type │ │ │ │ │ +Definition bitsetvector.hh:443 │ │ │ │ │ +Dune::const_reference<_BitSetVectorConstReference<_block_size,_Alloc_>_>::type │ │ │ │ │ +BitSetVectorConstReference< block_size, Alloc > type │ │ │ │ │ +Definition bitsetvector.hh:449 │ │ │ │ │ +Dune::mutable_reference<_BitSetVectorReference<_block_size,_Alloc_>_>::type │ │ │ │ │ +BitSetVectorReference< block_size, Alloc > type │ │ │ │ │ +Definition bitsetvector.hh:455 │ │ │ │ │ +Dune::mutable_reference<_BitSetVectorConstReference<_block_size,_Alloc_>_>:: │ │ │ │ │ +type │ │ │ │ │ +BitSetVectorReference< block_size, Alloc > type │ │ │ │ │ +Definition bitsetvector.hh:461 │ │ │ │ │ +Dune::RangeError │ │ │ │ │ +Default exception class for range errors. │ │ │ │ │ +Definition exceptions.hh:254 │ │ │ │ │ +Dune::const_reference │ │ │ │ │ +Get the 'const' version of a reference to a mutable object. │ │ │ │ │ +Definition genericiterator.hh:87 │ │ │ │ │ +Dune::mutable_reference │ │ │ │ │ +get the 'mutable' version of a reference to a const object │ │ │ │ │ +Definition genericiterator.hh:116 │ │ │ │ │ +Dune::GenericIterator │ │ │ │ │ +Generic class for stl-conforming iterators for container classes with operator │ │ │ │ │ +[]. │ │ │ │ │ +Definition genericiterator.hh:153 │ │ │ │ │ +Dune::ForwardIteratorFacade │ │ │ │ │ +Base class for stl conformant forward iterators. │ │ │ │ │ +Definition iteratorfacades.hh:141 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00155.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: base.hh File Reference │ │ │ │ +dune-common: indent.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,53 +65,54 @@ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ Classes | │ │ │ │ -Namespaces
    │ │ │ │ - │ │ │ │ +Namespaces | │ │ │ │ +Functions
    │ │ │ │ +
    indent.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ -

    Basic definitions for SIMD Implementations. │ │ │ │ +

    Utility class for handling nested indentation in output. │ │ │ │ More...

    │ │ │ │ - │ │ │ │ +
    #include <ostream>
    │ │ │ │ +#include <string>
    │ │ │ │ +
    │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ Classes

    struct  Dune::Simd::Overloads::ADLTag< i >
     
    struct  Dune::Simd::Overloads::ADLTag< 0 >
    class  Dune::Indent
     Utility class for handling nested indentation in output. 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.
     
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

    │ │ │ │ +Functions

    std::ostream & Dune::operator<< (std::ostream &s, const Indent &indent)
     write indentation to a stream
     
    │ │ │ │

    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.

    │ │ │ │ +

    Utility class for handling nested indentation in output.

    │ │ │ │ +
    Author
    Jö Fahlke
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── encoding │ │ │ │ │ @@ -1 +1 @@ │ │ │ │ │ -us-ascii │ │ │ │ │ +utf-8 │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,39 +6,33 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ 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 │ │ │ │ │ +indent.hh File Reference │ │ │ │ │ +Common │ │ │ │ │ +Utility class for handling nested indentation in output. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -struct  Dune::Simd::Overloads::ADLTag<_i_> │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::Simd::Overloads::ADLTag<_0_> │ │ │ │ │ +class  Dune::Indent │ │ │ │ │ +  Utility class for handling nested indentation in output. 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. │ │ │ │ │ + Functions │ │ │ │ │ +std::ostream & Dune::operator<< (std::ostream &s, const Indent &indent) │ │ │ │ │ +  write indentation to a stream │ │ │ │ │   │ │ │ │ │ ***** 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. │ │ │ │ │ +Utility class for handling nested indentation in output. │ │ │ │ │ + Author │ │ │ │ │ + Jö Fahlke │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00155_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: base.hh Source File │ │ │ │ +dune-common: indent.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,66 +70,111 @@ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    base.hh
    │ │ │ │ +
    indent.hh
    │ │ │ │
    │ │ │ │
    │ │ │ │ -Go to the documentation of this file.
    1// SPDX-FileCopyrightInfo: Copyright (C) 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
    │ │ │ │ +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 (C) 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_INDENT_HH
    │ │ │ │ +
    6#define DUNE_COMMON_INDENT_HH
    │ │ │ │ +
    7
    │ │ │ │ +
    8#include <ostream>
    │ │ │ │ +
    9#include <string>
    │ │ │ │ +
    10
    │ │ │ │ +
    11namespace Dune {
    │ │ │ │ +
    22
    │ │ │ │ +
    │ │ │ │ +
    52 class Indent
    │ │ │ │ +
    53 {
    │ │ │ │ +
    54 const Indent* parent;
    │ │ │ │ +
    55 std::string basic_indent;
    │ │ │ │ +
    56 unsigned level;
    │ │ │ │ +
    57
    │ │ │ │ +
    58 public:
    │ │ │ │ +
    60
    │ │ │ │ +
    │ │ │ │ +
    63 inline Indent(const std::string& basic_indent_ = " ", unsigned level_ = 0)
    │ │ │ │ +
    64 : parent(0), basic_indent(basic_indent_), level(level_)
    │ │ │ │ +
    65 { }
    │ │ │ │ +
    │ │ │ │ +
    66
    │ │ │ │ +
    │ │ │ │ +
    68 inline Indent(unsigned level_)
    │ │ │ │ +
    69 : parent(0), basic_indent(" "), level(level_)
    │ │ │ │ +
    70 { }
    │ │ │ │ +
    │ │ │ │ +
    71
    │ │ │ │ +
    73
    │ │ │ │ +
    │ │ │ │ +
    76 inline Indent(const Indent* parent_,
    │ │ │ │ +
    77 const std::string& basic_indent_ = " ", unsigned level_ = 1)
    │ │ │ │ +
    78 : parent(parent_), basic_indent(basic_indent_), level(level_)
    │ │ │ │ +
    79 { }
    │ │ │ │ +
    │ │ │ │ +
    80
    │ │ │ │ +
    │ │ │ │ +
    82 inline Indent(const Indent* parent_, unsigned level_)
    │ │ │ │ +
    83 : parent(parent_), basic_indent(" "), level(level_)
    │ │ │ │ +
    84 { }
    │ │ │ │ +
    │ │ │ │ +
    85
    │ │ │ │ +
    │ │ │ │ +
    87 inline Indent operator+(const std::string& newindent) const {
    │ │ │ │ +
    88 return Indent(this, newindent);
    │ │ │ │ +
    89 }
    │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ +
    91 inline Indent operator+(unsigned morelevel) const {
    │ │ │ │ +
    92 return Indent(parent, basic_indent, level+morelevel);
    │ │ │ │ +
    93 }
    │ │ │ │ +
    │ │ │ │ +
    95 inline Indent& operator++() { ++level; return *this; }
    │ │ │ │ +
    97 inline Indent& operator--() { if ( level > 0 ) --level; return *this; }
    │ │ │ │ +
    98
    │ │ │ │ +
    100 friend inline std::ostream& operator<<(std::ostream& s,
    │ │ │ │ +
    101 const Indent& indent);
    │ │ │ │ +
    102 };
    │ │ │ │ +
    │ │ │ │ +
    103
    │ │ │ │ +
    │ │ │ │ +
    105 inline std::ostream& operator<<(std::ostream& s, const Indent& indent) {
    │ │ │ │ +
    106 if(indent.parent)
    │ │ │ │ +
    107 s << *indent.parent;
    │ │ │ │ +
    108 for(unsigned i = 0; i < indent.level; ++i)
    │ │ │ │ +
    109 s << indent.basic_indent;
    │ │ │ │ +
    110 return s;
    │ │ │ │ +
    111 }
    │ │ │ │ +
    │ │ │ │ +
    112
    │ │ │ │ +
    115} // namespace Dune
    │ │ │ │
    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
    │ │ │ │ +
    117#endif // DUNE_COMMON_INDENT_HH
    │ │ │ │ +
    Indent operator+(const std::string &newindent) const
    create new indentation object with this one as parent
    Definition indent.hh:87
    │ │ │ │ +
    Indent(unsigned level_)
    setup without parent and basic_indentation of two spaces
    Definition indent.hh:68
    │ │ │ │ +
    Indent operator+(unsigned morelevel) const
    create a copy of this indentation object with raised level
    Definition indent.hh:91
    │ │ │ │ +
    Indent(const Indent *parent_, unsigned level_)
    setup with parent
    Definition indent.hh:82
    │ │ │ │ +
    Indent & operator++()
    raise indentation level
    Definition indent.hh:95
    │ │ │ │ +
    Indent(const std::string &basic_indent_=" ", unsigned level_=0)
    setup without parent
    Definition indent.hh:63
    │ │ │ │ +
    Indent & operator--()
    lower indentation level
    Definition indent.hh:97
    │ │ │ │ +
    friend std::ostream & operator<<(std::ostream &s, const Indent &indent)
    write indentation to a stream
    Definition indent.hh:105
    │ │ │ │ +
    Indent(const Indent *parent_, const std::string &basic_indent_=" ", unsigned level_=1)
    setup with parent
    Definition indent.hh:76
    │ │ │ │ +
    std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x)
    Definition bigunsignedint.hh:278
    │ │ │ │
    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
    │ │ │ │ +
    Utility class for handling nested indentation in output.
    Definition indent.hh:53
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,69 +7,121 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * simd │ │ │ │ │ -base.hh │ │ │ │ │ +indent.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ - 1// SPDX-FileCopyrightInfo: Copyright (C) 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 (C) 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 │ │ │ │ │ + 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ + 5#ifndef DUNE_COMMON_INDENT_HH │ │ │ │ │ + 6#define DUNE_COMMON_INDENT_HH │ │ │ │ │ + 7 │ │ │ │ │ + 8#include │ │ │ │ │ + 9#include │ │ │ │ │ + 10 │ │ │ │ │ + 11namespace Dune { │ │ │ │ │ + 22 │ │ │ │ │ +52 class Indent │ │ │ │ │ + 53 { │ │ │ │ │ + 54 const Indent* parent; │ │ │ │ │ + 55 std::string basic_indent; │ │ │ │ │ + 56 unsigned level; │ │ │ │ │ + 57 │ │ │ │ │ + 58 public: │ │ │ │ │ + 60 │ │ │ │ │ +63 inline Indent(const std::string& basic_indent_ = " ", unsigned level_ = 0) │ │ │ │ │ + 64 : parent(0), basic_indent(basic_indent_), level(level_) │ │ │ │ │ + 65 { } │ │ │ │ │ + 66 │ │ │ │ │ +68 inline Indent(unsigned level_) │ │ │ │ │ + 69 : parent(0), basic_indent(" "), level(level_) │ │ │ │ │ + 70 { } │ │ │ │ │ + 71 │ │ │ │ │ + 73 │ │ │ │ │ +76 inline Indent(const Indent* parent_, │ │ │ │ │ + 77 const std::string& basic_indent_ = " ", unsigned level_ = 1) │ │ │ │ │ + 78 : parent(parent_), basic_indent(basic_indent_), level(level_) │ │ │ │ │ + 79 { } │ │ │ │ │ + 80 │ │ │ │ │ +82 inline Indent(const Indent* parent_, unsigned level_) │ │ │ │ │ + 83 : parent(parent_), basic_indent(" "), level(level_) │ │ │ │ │ + 84 { } │ │ │ │ │ + 85 │ │ │ │ │ +87 inline Indent operator+(const std::string& newindent) const { │ │ │ │ │ + 88 return Indent(this, newindent); │ │ │ │ │ + 89 } │ │ │ │ │ +91 inline Indent operator+(unsigned morelevel) const { │ │ │ │ │ + 92 return Indent(parent, basic_indent, level+morelevel); │ │ │ │ │ + 93 } │ │ │ │ │ +95 inline Indent& operator++() { ++level; return *this; } │ │ │ │ │ +97 inline Indent& operator--() { if ( level > 0 ) --level; return *this; } │ │ │ │ │ + 98 │ │ │ │ │ + 100 friend inline std::ostream& operator<<(std::ostream& s, │ │ │ │ │ + 101 const Indent& indent); │ │ │ │ │ + 102 }; │ │ │ │ │ + 103 │ │ │ │ │ +105 inline std::ostream& operator<<(std::ostream& s, const Indent& indent) { │ │ │ │ │ + 106 if(indent.parent) │ │ │ │ │ + 107 s << *indent.parent; │ │ │ │ │ + 108 for(unsigned i = 0; i < indent.level; ++i) │ │ │ │ │ + 109 s << indent.basic_indent; │ │ │ │ │ + 110 return s; │ │ │ │ │ + 111 } │ │ │ │ │ + 112 │ │ │ │ │ + 115} // namespace Dune │ │ │ │ │ 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 │ │ │ │ │ + 117#endif // DUNE_COMMON_INDENT_HH │ │ │ │ │ +Dune::Indent::operator+ │ │ │ │ │ +Indent operator+(const std::string &newindent) const │ │ │ │ │ +create new indentation object with this one as parent │ │ │ │ │ +Definition indent.hh:87 │ │ │ │ │ +Dune::Indent::Indent │ │ │ │ │ +Indent(unsigned level_) │ │ │ │ │ +setup without parent and basic_indentation of two spaces │ │ │ │ │ +Definition indent.hh:68 │ │ │ │ │ +Dune::Indent::operator+ │ │ │ │ │ +Indent operator+(unsigned morelevel) const │ │ │ │ │ +create a copy of this indentation object with raised level │ │ │ │ │ +Definition indent.hh:91 │ │ │ │ │ +Dune::Indent::Indent │ │ │ │ │ +Indent(const Indent *parent_, unsigned level_) │ │ │ │ │ +setup with parent │ │ │ │ │ +Definition indent.hh:82 │ │ │ │ │ +Dune::Indent::operator++ │ │ │ │ │ +Indent & operator++() │ │ │ │ │ +raise indentation level │ │ │ │ │ +Definition indent.hh:95 │ │ │ │ │ +Dune::Indent::Indent │ │ │ │ │ +Indent(const std::string &basic_indent_=" ", unsigned level_=0) │ │ │ │ │ +setup without parent │ │ │ │ │ +Definition indent.hh:63 │ │ │ │ │ +Dune::Indent::operator-- │ │ │ │ │ +Indent & operator--() │ │ │ │ │ +lower indentation level │ │ │ │ │ +Definition indent.hh:97 │ │ │ │ │ +Dune::Indent::operator<< │ │ │ │ │ +friend std::ostream & operator<<(std::ostream &s, const Indent &indent) │ │ │ │ │ +write indentation to a stream │ │ │ │ │ +Definition indent.hh:105 │ │ │ │ │ +Dune::Indent::Indent │ │ │ │ │ +Indent(const Indent *parent_, const std::string &basic_indent_=" ", unsigned │ │ │ │ │ +level_=1) │ │ │ │ │ +setup with parent │ │ │ │ │ +Definition indent.hh:76 │ │ │ │ │ +Dune::operator<< │ │ │ │ │ +std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x) │ │ │ │ │ +Definition bigunsignedint.hh:278 │ │ │ │ │ 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::Indent │ │ │ │ │ +Utility class for handling nested indentation in output. │ │ │ │ │ +Definition indent.hh:53 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00158.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: test.cc File Reference │ │ │ │ +dune-common: fmatrixev.cc File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,25 +65,48 @@ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │ -
    test.cc File Reference
    │ │ │ │ +
    │ │ │ │ +Macros
    │ │ │ │ +
    fmatrixev.cc File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ -
    #include <config.h>
    │ │ │ │ -#include <ostream>
    │ │ │ │ -#include <string>
    │ │ │ │ -#include <dune/common/simd/test.hh>
    │ │ │ │ -
    │ │ │ │ +
    #include <iostream>
    │ │ │ │ +#include <cmath>
    │ │ │ │ +#include <cassert>
    │ │ │ │ +#include <dune/common/exceptions.hh>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

    │ │ │ │ +Macros

    #define DUNE_FMATRIXEIGENVALUES_CC
     
    │ │ │ │ +

    Macro Definition Documentation

    │ │ │ │ + │ │ │ │ +

    ◆ DUNE_FMATRIXEIGENVALUES_CC

    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    #define DUNE_FMATRIXEIGENVALUES_CC
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,16 +6,22 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * simd │ │ │ │ │ -test.cc File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Macros │ │ │ │ │ +fmatrixev.cc File Reference │ │ │ │ │ +#include │ │ │ │ │ +#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/a00161.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: defaults.hh File Reference │ │ │ │ +dune-common: dotproduct.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,127 +65,60 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -Namespaces
    │ │ │ │ - │ │ │ │ +Classes | │ │ │ │ +Namespaces | │ │ │ │ +Functions
    │ │ │ │ +
    dotproduct.hh File Reference
    │ │ │ │ │ │ │ │
    │ │ │ │ │ │ │ │ -

    Default implementations for SIMD Implementations. │ │ │ │ +

    Provides the functions dot(a,b) := $a^H \cdot b $ and dotT(a,b) := $a^T \cdot b $. │ │ │ │ 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 "ftraits.hh"
    │ │ │ │ +#include "typetraits.hh"
    │ │ │ │
    │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ +Classes

    struct  Dune::IsVector< T, class >
     
    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

    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<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

    │ │ │ │ -

    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.

    │ │ │ │ +

    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 {} │ │ │ │ │ @@ -6,128 +6,50 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * simd │ │ │ │ │ -Namespaces │ │ │ │ │ -defaults.hh File Reference │ │ │ │ │ -Common » Vectorization » Abstraction_Developer's_Interface │ │ │ │ │ -Default implementations for SIMD Implementations. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +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::IsVector<_T,_class_> │ │ │ │ │ +  │ │ │ │ │ +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 │ │ │ │ │ -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 │ │ │ │ │ +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 │ │ │ │ │ +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 ***** │ │ │ │ │ -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. │ │ │ │ │ +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/a00161_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: defaults.hh Source File │ │ │ │ +dune-common: dotproduct.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,215 +70,85 @@ │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │ -
    defaults.hh
    │ │ │ │ +
    dotproduct.hh
    │ │ │ │
    │ │ │ │
    │ │ │ │ -Go to the documentation of this file.
    1// SPDX-FileCopyrightInfo: Copyright (C) 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;
    │ │ │ │ -
    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 }
    │ │ │ │ +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 (C) 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 }
    │ │ │ │ +
    88 template<class A, class B>
    │ │ │ │ +
    89 auto
    │ │ │ │ +
    │ │ │ │ +
    90 dotT(const A & a, const B & b) -> decltype(a*b)
    │ │ │ │ +
    91 {
    │ │ │ │ +
    92 return a*b;
    │ │ │ │ +
    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 }
    │ │ │ │ -
    │ │ │ │ -
    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
    │ │ │ │ -
    Traits for type conversions and type information.
    │ │ │ │ -
    Basic definitions for SIMD Implementations.
    │ │ │ │ -
    Utilities for reduction like operations on ranges.
    │ │ │ │ - │ │ │ │ -
    static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from >, std::integral_constant< T, to >) noexcept
    Definition rangeutilities.hh:300
    │ │ │ │ -
    typename AutonomousValueType< T >::type AutonomousValue
    Type free of internal references that T can be converted to.
    Definition typetraits.hh:558
    │ │ │ │ -
    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
    │ │ │ │ +
    96} // end namespace DUNE
    │ │ │ │ +
    97
    │ │ │ │ +
    98#endif // DUNE_DOTPRODUCT_HH
    │ │ │ │ +
    Type traits to determine the type of reals (when working with complex numbers)
    │ │ │ │ +
    Traits for type conversions and type information.
    │ │ │ │ +
    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
    │ │ │ │ -
    bool anyTrue(ADLTag< 5 >, const AlignedNumber< bool, align > &mask)
    Definition debugalign.hh:543
    │ │ │ │ -
    const AlignedNumber< T, align > & cond(ADLTag< 5 >, AlignedNumber< bool, align > mask, const AlignedNumber< T, align > &ifTrue, const AlignedNumber< T, align > &ifFalse)
    Definition debugalign.hh:535
    │ │ │ │ -
    T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v)
    Definition debugalign.hh:520
    │ │ │ │ -
    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.
    │ │ │ │ +
    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:90
    │ │ │ │ +
    Definition dotproduct.hh:27
    │ │ │ │ +
    T real_type
    export the type representing the real type of the field
    Definition ftraits.hh:30
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,252 +7,100 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * simd │ │ │ │ │ -defaults.hh │ │ │ │ │ +dotproduct.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ - 1// SPDX-FileCopyrightInfo: Copyright (C) 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 (C) 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; │ │ │ │ │ - 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) │ │ │ │ │ + 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 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) │ │ │ │ │ - 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); │ │ │ │ │ + 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 } │ │ │ │ │ + 88 template │ │ │ │ │ + 89 auto │ │ │ │ │ +90 dotT(const A & a, const B & b) -> decltype(a*b) │ │ │ │ │ + 91 { │ │ │ │ │ + 92 return a*b; │ │ │ │ │ 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 } │ │ │ │ │ - 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); │ │ │ │ │ - 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 │ │ │ │ │ + 96} // end namespace DUNE │ │ │ │ │ + 97 │ │ │ │ │ + 98#endif // DUNE_DOTPRODUCT_HH │ │ │ │ │ +ftraits.hh │ │ │ │ │ +Type traits to determine the type of reals (when working with complex numbers) │ │ │ │ │ typetraits.hh │ │ │ │ │ Traits for type conversions and type information. │ │ │ │ │ -base.hh │ │ │ │ │ -Basic definitions for SIMD Implementations. │ │ │ │ │ -rangeutilities.hh │ │ │ │ │ -Utilities for reduction like operations on ranges. │ │ │ │ │ -typelist.hh │ │ │ │ │ -Dune::range │ │ │ │ │ -static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from │ │ │ │ │ ->, std::integral_constant< T, to >) noexcept │ │ │ │ │ -Definition rangeutilities.hh:300 │ │ │ │ │ -Dune::AutonomousValue │ │ │ │ │ -typename AutonomousValueType< T >::type AutonomousValue │ │ │ │ │ -Type free of internal references that T can be converted to. │ │ │ │ │ -Definition typetraits.hh:558 │ │ │ │ │ -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 │ │ │ │ │ +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::anyTrue │ │ │ │ │ -bool anyTrue(ADLTag< 5 >, const AlignedNumber< bool, align > &mask) │ │ │ │ │ -Definition debugalign.hh:543 │ │ │ │ │ -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:535 │ │ │ │ │ -Dune::Simd::Overloads::lane │ │ │ │ │ -T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v) │ │ │ │ │ -Definition debugalign.hh:520 │ │ │ │ │ -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::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:90 │ │ │ │ │ +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/a00164.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: simd.hh File Reference │ │ │ │ +dune-common: reservedvector.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -72,94 +72,70 @@ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ Classes | │ │ │ │ Namespaces | │ │ │ │ -Typedefs | │ │ │ │ -Functions
    │ │ │ │ -
    simd.hh File Reference
    │ │ │ │ +Macros
    │ │ │ │ +
    reservedvector.hh File Reference
    │ │ │ │ │ │ │ │
    │ │ │ │ │ │ │ │ -

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

    An stl-compliant random-access container which stores everything on the stack. │ │ │ │ More...

    │ │ │ │ -
    #include <cassert>
    │ │ │ │ +
    #include <algorithm>
    │ │ │ │ +#include <array>
    │ │ │ │ +#include <cassert>
    │ │ │ │ +#include <iostream>
    │ │ │ │ +#include <iterator>
    │ │ │ │ #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>
    │ │ │ │ +#include <initializer_list>
    │ │ │ │ +#include <dune/common/hash.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 >
    class  Dune::ReservedVector< T, n >
     A Vector class with statically reserved memory. More...
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

    │ │ │ │ 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)
     

    │ │ │ │ +Macros

    #define CHECKSIZE(X)   {}
     
    │ │ │ │

    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.
    │ │ │ │ -
    │ │ │ │ +

    An stl-compliant random-access container which stores everything on the stack.

    │ │ │ │ +

    Macro Definition Documentation

    │ │ │ │ + │ │ │ │ +

    ◆ CHECKSIZE

    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    #define CHECKSIZE( X)   {}
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,81 +6,39 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Typedefs | Functions │ │ │ │ │ -simd.hh File Reference │ │ │ │ │ -Abstractions for support of dedicated SIMD data types. More... │ │ │ │ │ +Classes | Namespaces | Macros │ │ │ │ │ +reservedvector.hh File Reference │ │ │ │ │ +An stl-compliant random-access container which stores everything on the stack. │ │ │ │ │ +More... │ │ │ │ │ +#include │ │ │ │ │ +#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::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_> │ │ │ │ │ +class  Dune::ReservedVector<_T,_n_> │ │ │ │ │ +  A Vector class with statically reserved memory. More... │ │ │ │ │   │ │ │ │ │ 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) │ │ │ │ │ + Macros │ │ │ │ │ +#define CHECKSIZE(X)   {} │ │ │ │ │   │ │ │ │ │ ***** 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. │ │ │ │ │ +An stl-compliant random-access container which stores everything on the stack. │ │ │ │ │ +***** Macro Definition Documentation ***** │ │ │ │ │ +***** ◆ CHECKSIZE ***** │ │ │ │ │ +#define CHECKSIZE (  X )    {} │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00164_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: simd.hh Source File │ │ │ │ +dune-common: reservedvector.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,518 +74,528 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │ -
    simd.hh
    │ │ │ │ +
    reservedvector.hh
    │ │ │ │
    │ │ │ │
    │ │ │ │ -Go to the documentation of this file.
    1// SPDX-FileCopyrightInfo: Copyright (C) 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
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
    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#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
    │ │ │ │ -
    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
    │ │ │ │ -
    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>
    │ │ │ │ - │ │ │ │ +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 (C) 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_RESERVEDVECTOR_HH
    │ │ │ │ +
    6#define DUNE_COMMON_RESERVEDVECTOR_HH
    │ │ │ │ +
    7
    │ │ │ │ +
    12#include <algorithm>
    │ │ │ │ +
    13#include <array>
    │ │ │ │ +
    14#include <cassert>
    │ │ │ │ +
    15#include <iostream>
    │ │ │ │ +
    16#include <iterator>
    │ │ │ │ +
    17#include <cstddef>
    │ │ │ │ +
    18#include <initializer_list>
    │ │ │ │ +
    19
    │ │ │ │ +
    20#include <dune/common/hash.hh>
    │ │ │ │ +
    21
    │ │ │ │ +
    22#ifdef CHECK_RESERVEDVECTOR
    │ │ │ │ +
    23#define CHECKSIZE(X) assert(X)
    │ │ │ │ +
    24#else
    │ │ │ │ +
    25#define CHECKSIZE(X) {}
    │ │ │ │ +
    26#endif
    │ │ │ │ +
    27
    │ │ │ │ +
    28namespace Dune
    │ │ │ │ +
    29{
    │ │ │ │ +
    45 template<class T, int n>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    47 {
    │ │ │ │ +
    48 using storage_type = std::array<T,n>;
    │ │ │ │ +
    49
    │ │ │ │ +
    50 public:
    │ │ │ │ +
    51
    │ │ │ │ +
    55 typedef typename storage_type::value_type value_type;
    │ │ │ │ +
    57 typedef typename storage_type::pointer pointer;
    │ │ │ │ +
    59 typedef typename storage_type::const_pointer const_pointer;
    │ │ │ │ +
    61 typedef typename storage_type::reference reference;
    │ │ │ │ +
    63 typedef typename storage_type::const_reference const_reference;
    │ │ │ │ +
    65 typedef typename storage_type::size_type size_type;
    │ │ │ │ +
    67 typedef typename storage_type::difference_type difference_type;
    │ │ │ │ +
    69 typedef typename storage_type::iterator iterator;
    │ │ │ │ +
    71 typedef typename storage_type::const_iterator const_iterator;
    │ │ │ │ +
    73 typedef std::reverse_iterator<iterator> reverse_iterator;
    │ │ │ │ +
    75 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
    │ │ │ │ +
    76
    │ │ │ │ +
    │ │ │ │ +
    82 constexpr ReservedVector()
    │ │ │ │ +
    83 noexcept(std::is_nothrow_default_constructible_v<value_type>)
    │ │ │ │ +
    84 : storage_()
    │ │ │ │ +
    85 , size_(0)
    │ │ │ │ +
    86 {}
    │ │ │ │ +
    │ │ │ │ +
    87
    │ │ │ │ +
    │ │ │ │ +
    89 explicit constexpr ReservedVector(size_type count)
    │ │ │ │ +
    90 noexcept(std::is_nothrow_default_constructible_v<value_type>)
    │ │ │ │ +
    91 : storage_()
    │ │ │ │ +
    92 , size_(count)
    │ │ │ │ +
    93 {
    │ │ │ │ +
    94 assert(count <= n);
    │ │ │ │ +
    95 }
    │ │ │ │ +
    │ │ │ │ +
    96
    │ │ │ │ +
    │ │ │ │ +
    98 constexpr ReservedVector(size_type count, const value_type& value)
    │ │ │ │ +
    99 noexcept(std::is_nothrow_copy_assignable_v<value_type> &&
    │ │ │ │ +
    100 noexcept(ReservedVector(count)))
    │ │ │ │ +
    101 : ReservedVector(count)
    │ │ │ │ +
    102 {
    │ │ │ │ +
    103 for (size_type i=0; i<count; ++i)
    │ │ │ │ +
    104 storage_[i] = value;
    │ │ │ │ +
    105 }
    │ │ │ │ +
    │ │ │ │ +
    106
    │ │ │ │ +
    108 template<class InputIt,
    │ │ │ │ +
    109 std::enable_if_t<std::is_convertible_v<typename std::iterator_traits<InputIt>::value_type, value_type>, int> = 0>
    │ │ │ │ +
    │ │ │ │ +
    110 constexpr ReservedVector(InputIt first, InputIt last)
    │ │ │ │ +
    111 noexcept(std::is_nothrow_copy_assignable_v<value_type> &&
    │ │ │ │ +
    112 noexcept(ReservedVector()))
    │ │ │ │ + │ │ │ │ +
    114 {
    │ │ │ │ +
    115 for (size_type i=0; i<n && first!=last; ++i,++size_)
    │ │ │ │ +
    116 storage_[i] = *first++;
    │ │ │ │ +
    117 assert(first == last);
    │ │ │ │ +
    118 }
    │ │ │ │ +
    │ │ │ │ +
    119
    │ │ │ │ +
    │ │ │ │ +
    121 constexpr ReservedVector(std::initializer_list<value_type> const& l)
    │ │ │ │ +
    122 noexcept(std::is_nothrow_copy_assignable_v<value_type> &&
    │ │ │ │ +
    123 noexcept(ReservedVector(l.begin(),l.end())))
    │ │ │ │ +
    124 : ReservedVector(l.begin(),l.end())
    │ │ │ │ +
    125 {}
    │ │ │ │ +
    │ │ │ │ +
    126
    │ │ │ │ +
    │ │ │ │ +
    132 constexpr bool operator== (const ReservedVector& that) const noexcept
    │ │ │ │ +
    133 {
    │ │ │ │ +
    134 if (size() != that.size())
    │ │ │ │ +
    135 return false;
    │ │ │ │ +
    136 for (size_type i=0; i<size(); ++i)
    │ │ │ │ +
    137 if (!(storage_[i]==that.storage_[i]))
    │ │ │ │ +
    138 return false;
    │ │ │ │ +
    139 return true;
    │ │ │ │ +
    140 }
    │ │ │ │ +
    │ │ │ │ +
    141
    │ │ │ │ +
    │ │ │ │ +
    143 constexpr bool operator!= (const ReservedVector& that) const noexcept
    │ │ │ │ +
    144 {
    │ │ │ │ +
    145 return !(*this == that);
    │ │ │ │ +
    146 }
    │ │ │ │ +
    │ │ │ │ +
    147
    │ │ │ │ +
    │ │ │ │ +
    149 constexpr bool operator< (const ReservedVector& that) const noexcept
    │ │ │ │ +
    150 {
    │ │ │ │ +
    151 for (size_type i=0; i<std::min(size(),that.size()); ++i) {
    │ │ │ │ +
    152 if (storage_[i] < that.storage_[i]) return true;
    │ │ │ │ +
    153 if (that.storage_[i] < storage_[i]) return false;
    │ │ │ │ +
    154 }
    │ │ │ │ +
    155 return size() < that.size();
    │ │ │ │ +
    156 }
    │ │ │ │ +
    │ │ │ │ +
    157
    │ │ │ │ +
    │ │ │ │ +
    159 constexpr bool operator> (const ReservedVector& that) const noexcept
    │ │ │ │ +
    160 {
    │ │ │ │ +
    161 return that < *this;
    │ │ │ │ +
    162 }
    │ │ │ │ +
    │ │ │ │ +
    163
    │ │ │ │ +
    │ │ │ │ +
    165 constexpr bool operator<= (const ReservedVector& that) const noexcept
    │ │ │ │ +
    166 {
    │ │ │ │ +
    167 return !(*this > that);
    │ │ │ │ +
    168 }
    │ │ │ │ +
    │ │ │ │ +
    169
    │ │ │ │ +
    │ │ │ │ +
    171 constexpr bool operator>= (const ReservedVector& that) const noexcept
    │ │ │ │ +
    172 {
    │ │ │ │ +
    173 return !(*this < that);
    │ │ │ │ +
    174 }
    │ │ │ │ +
    │ │ │ │ +
    175
    │ │ │ │ +
    │ │ │ │ +
    181 constexpr void clear() noexcept
    │ │ │ │ +
    182 {
    │ │ │ │ +
    183 size_ = 0;
    │ │ │ │ +
    184 }
    │ │ │ │ +
    │ │ │ │ +
    185
    │ │ │ │ +
    │ │ │ │ +
    187 constexpr void resize(size_type s) noexcept
    │ │ │ │ +
    188 {
    │ │ │ │ +
    189 CHECKSIZE(s<=n);
    │ │ │ │ +
    190 size_ = s;
    │ │ │ │ +
    191 }
    │ │ │ │ +
    │ │ │ │ +
    192
    │ │ │ │ +
    │ │ │ │ +
    194 constexpr void push_back(const value_type& t)
    │ │ │ │ +
    195 noexcept(std::is_nothrow_copy_assignable_v<value_type>)
    │ │ │ │ +
    196 {
    │ │ │ │ +
    197 CHECKSIZE(size_<n);
    │ │ │ │ +
    198 storage_[size_++] = t;
    │ │ │ │ +
    199 }
    │ │ │ │ +
    │ │ │ │ +
    200
    │ │ │ │ +
    │ │ │ │ +
    202 constexpr void push_back(value_type&& t)
    │ │ │ │ +
    203 noexcept(std::is_nothrow_move_assignable_v<value_type>)
    │ │ │ │ +
    204 {
    │ │ │ │ +
    205 CHECKSIZE(size_<n);
    │ │ │ │ +
    206 storage_[size_++] = std::move(t);
    │ │ │ │ +
    207 }
    │ │ │ │ +
    │ │ │ │
    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
    │ │ │ │ +
    210 template<class... Args>
    │ │ │ │ +
    │ │ │ │ +
    211 reference emplace_back(Args&&... args)
    │ │ │ │ +
    212 noexcept(std::is_nothrow_constructible_v<value_type,decltype(args)...>)
    │ │ │ │ +
    213 {
    │ │ │ │ +
    214 CHECKSIZE(size_<n);
    │ │ │ │ +
    215 value_type* p = &storage_[size_++];
    │ │ │ │ +
    216 // first destroy any previously (default) constructed element at that location
    │ │ │ │ +
    217 p->~value_type();
    │ │ │ │ +
    218 // construct the value_type in place
    │ │ │ │ +
    219 // NOTE: This is not an integral constant expression.
    │ │ │ │ +
    220 // With c++20 we could use std::construct_at
    │ │ │ │ +
    221 ::new (const_cast<void*>(static_cast<const volatile void*>(p)))
    │ │ │ │ +
    222 value_type(std::forward<Args>(args)...);
    │ │ │ │ +
    223 return *p;
    │ │ │ │ +
    224 }
    │ │ │ │ +
    │ │ │ │
    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>
    │ │ │ │ - │ │ │ │ +
    │ │ │ │ +
    227 constexpr void pop_back() noexcept
    │ │ │ │ +
    228 {
    │ │ │ │ +
    229 if (! empty()) size_--;
    │ │ │ │ +
    230 }
    │ │ │ │ +
    │ │ │ │ +
    231
    │ │ │ │ +
    │ │ │ │ +
    237 constexpr iterator begin() noexcept
    │ │ │ │ +
    238 {
    │ │ │ │ +
    239 return storage_.begin();
    │ │ │ │ +
    240 }
    │ │ │ │ +
    │ │ │ │ +
    241
    │ │ │ │ +
    │ │ │ │ +
    243 constexpr const_iterator begin() const noexcept
    │ │ │ │ +
    244 {
    │ │ │ │ +
    245 return storage_.begin();
    │ │ │ │ +
    246 }
    │ │ │ │ +
    │ │ │ │
    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 };
    │ │ │ │ +
    │ │ │ │ +
    249 constexpr const_iterator cbegin() const noexcept
    │ │ │ │ +
    250 {
    │ │ │ │ +
    251 return storage_.cbegin();
    │ │ │ │ +
    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
    │ │ │ │ +
    │ │ │ │ +
    255 constexpr reverse_iterator rbegin() noexcept
    │ │ │ │ +
    256 {
    │ │ │ │ +
    257 return reverse_iterator{begin()+size()};
    │ │ │ │ +
    258 }
    │ │ │ │ +
    │ │ │ │
    259
    │ │ │ │ -
    260 template<typename V, typename = void>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    262 using type = bool;
    │ │ │ │ -
    263 };
    │ │ │ │ -
    │ │ │ │ -
    264
    │ │ │ │ -
    266
    │ │ │ │ -
    269 template<typename V>
    │ │ │ │ - │ │ │ │ +
    │ │ │ │ +
    261 constexpr const_reverse_iterator rbegin() const noexcept
    │ │ │ │ +
    262 {
    │ │ │ │ + │ │ │ │ +
    264 }
    │ │ │ │ +
    │ │ │ │ +
    265
    │ │ │ │ +
    │ │ │ │ +
    267 constexpr const_reverse_iterator crbegin() const noexcept
    │ │ │ │ +
    268 {
    │ │ │ │ + │ │ │ │ +
    270 }
    │ │ │ │ +
    │ │ │ │
    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 };
    │ │ │ │ +
    │ │ │ │ +
    273 constexpr iterator end() noexcept
    │ │ │ │ +
    274 {
    │ │ │ │ +
    275 return storage_.begin()+size();
    │ │ │ │ +
    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
    │ │ │ │ +
    │ │ │ │ +
    279 constexpr const_iterator end() const noexcept
    │ │ │ │ +
    280 {
    │ │ │ │ +
    281 return storage_.begin()+size();
    │ │ │ │ +
    282 }
    │ │ │ │ +
    │ │ │ │
    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 }
    │ │ │ │ +
    │ │ │ │ +
    285 constexpr const_iterator cend() const noexcept
    │ │ │ │ +
    286 {
    │ │ │ │ +
    287 return storage_.cbegin()+size();
    │ │ │ │ +
    288 }
    │ │ │ │ +
    │ │ │ │ +
    289
    │ │ │ │ +
    │ │ │ │ +
    291 constexpr reverse_iterator rend() noexcept
    │ │ │ │ +
    292 {
    │ │ │ │ +
    293 return reverse_iterator{begin()};
    │ │ │ │ +
    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
    │ │ │ │ -
    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 }
    │ │ │ │ +
    │ │ │ │ +
    297 constexpr const_reverse_iterator rend() const noexcept
    │ │ │ │ +
    298 {
    │ │ │ │ + │ │ │ │ +
    300 }
    │ │ │ │ +
    │ │ │ │ +
    301
    │ │ │ │ +
    │ │ │ │ +
    303 constexpr const_reverse_iterator crend() const noexcept
    │ │ │ │ +
    304 {
    │ │ │ │ + │ │ │ │ +
    306 }
    │ │ │ │ +
    │ │ │ │ +
    307
    │ │ │ │ +
    │ │ │ │ +
    313 constexpr reference at(size_type i)
    │ │ │ │ +
    314 {
    │ │ │ │ +
    315 if (!(i < size()))
    │ │ │ │ +
    316 throw std::out_of_range("Index out of range");
    │ │ │ │ +
    317 return storage_[i];
    │ │ │ │ +
    318 }
    │ │ │ │ +
    │ │ │ │ +
    319
    │ │ │ │ +
    │ │ │ │ +
    321 constexpr const_reference at(size_type i) const
    │ │ │ │ +
    322 {
    │ │ │ │ +
    323 if (!(i < size()))
    │ │ │ │ +
    324 throw std::out_of_range("Index out of range");
    │ │ │ │ +
    325 return storage_[i];
    │ │ │ │ +
    326 }
    │ │ │ │ +
    │ │ │ │ +
    327
    │ │ │ │ +
    │ │ │ │ +
    329 constexpr reference operator[] (size_type i) noexcept
    │ │ │ │ +
    330 {
    │ │ │ │ +
    331 CHECKSIZE(size_>i);
    │ │ │ │ +
    332 return storage_[i];
    │ │ │ │ +
    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
    │ │ │ │ -
    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
    │ │ │ │ -
    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 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
    │ │ │ │ -
    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.
    │ │ │ │ - │ │ │ │ +
    │ │ │ │ +
    336 constexpr const_reference operator[] (size_type i) const noexcept
    │ │ │ │ +
    337 {
    │ │ │ │ +
    338 CHECKSIZE(size_>i);
    │ │ │ │ +
    339 return storage_[i];
    │ │ │ │ +
    340 }
    │ │ │ │ +
    │ │ │ │ +
    341
    │ │ │ │ +
    │ │ │ │ +
    343 constexpr reference front() noexcept
    │ │ │ │ +
    344 {
    │ │ │ │ +
    345 CHECKSIZE(size_>0);
    │ │ │ │ +
    346 return storage_[0];
    │ │ │ │ +
    347 }
    │ │ │ │ +
    │ │ │ │ +
    348
    │ │ │ │ +
    │ │ │ │ +
    350 constexpr const_reference front() const noexcept
    │ │ │ │ +
    351 {
    │ │ │ │ +
    352 CHECKSIZE(size_>0);
    │ │ │ │ +
    353 return storage_[0];
    │ │ │ │ +
    354 }
    │ │ │ │ +
    │ │ │ │ +
    355
    │ │ │ │ +
    │ │ │ │ +
    357 constexpr reference back() noexcept
    │ │ │ │ +
    358 {
    │ │ │ │ +
    359 CHECKSIZE(size_>0);
    │ │ │ │ +
    360 return storage_[size_-1];
    │ │ │ │ +
    361 }
    │ │ │ │ +
    │ │ │ │ +
    362
    │ │ │ │ +
    │ │ │ │ +
    364 constexpr const_reference back() const noexcept
    │ │ │ │ +
    365 {
    │ │ │ │ +
    366 CHECKSIZE(size_>0);
    │ │ │ │ +
    367 return storage_[size_-1];
    │ │ │ │ +
    368 }
    │ │ │ │ +
    │ │ │ │ +
    369
    │ │ │ │ +
    │ │ │ │ +
    371 constexpr pointer data() noexcept
    │ │ │ │ +
    372 {
    │ │ │ │ +
    373 return storage_.data();
    │ │ │ │ +
    374 }
    │ │ │ │ +
    │ │ │ │ +
    375
    │ │ │ │ +
    │ │ │ │ +
    377 constexpr const_pointer data() const noexcept
    │ │ │ │ +
    378 {
    │ │ │ │ +
    379 return storage_.data();
    │ │ │ │ +
    380 }
    │ │ │ │ +
    │ │ │ │ +
    381
    │ │ │ │ +
    │ │ │ │ +
    387 constexpr size_type size() const noexcept
    │ │ │ │ +
    388 {
    │ │ │ │ +
    389 return size_;
    │ │ │ │ +
    390 }
    │ │ │ │ +
    │ │ │ │ +
    391
    │ │ │ │ +
    │ │ │ │ +
    393 constexpr bool empty() const noexcept
    │ │ │ │ +
    394 {
    │ │ │ │ +
    395 return size_==0;
    │ │ │ │ +
    396 }
    │ │ │ │ +
    │ │ │ │ +
    397
    │ │ │ │ +
    │ │ │ │ +
    399 static constexpr size_type capacity() noexcept
    │ │ │ │ +
    400 {
    │ │ │ │ +
    401 return n;
    │ │ │ │ +
    402 }
    │ │ │ │ +
    │ │ │ │ +
    403
    │ │ │ │ +
    │ │ │ │ +
    405 static constexpr size_type max_size() noexcept
    │ │ │ │ +
    406 {
    │ │ │ │ +
    407 return n;
    │ │ │ │ +
    408 }
    │ │ │ │ +
    │ │ │ │ +
    409
    │ │ │ │ +
    │ │ │ │ +
    415 constexpr void fill(const value_type& value)
    │ │ │ │ +
    416 noexcept(std::is_nothrow_copy_assignable_v<value_type>)
    │ │ │ │ +
    417 {
    │ │ │ │ +
    418 for (size_type i=0; i<size(); ++i)
    │ │ │ │ +
    419 storage_[i] = value;
    │ │ │ │ +
    420 }
    │ │ │ │ +
    │ │ │ │ +
    421
    │ │ │ │ +
    │ │ │ │ +
    423 void swap(ReservedVector& other)
    │ │ │ │ +
    424 noexcept(std::is_nothrow_swappable_v<value_type>)
    │ │ │ │ +
    425 {
    │ │ │ │ +
    426 using std::swap;
    │ │ │ │ +
    427 swap(storage_, other.storage_);
    │ │ │ │ +
    428 swap(size_, other.size_);
    │ │ │ │ +
    429 }
    │ │ │ │ +
    │ │ │ │ +
    430
    │ │ │ │ +
    │ │ │ │ +
    434 friend std::ostream& operator<< (std::ostream& s, const ReservedVector& v)
    │ │ │ │ +
    435 {
    │ │ │ │ +
    436 for (size_type i=0; i<v.size(); i++)
    │ │ │ │ +
    437 s << v[i] << " ";
    │ │ │ │ +
    438 return s;
    │ │ │ │ +
    439 }
    │ │ │ │ +
    │ │ │ │ +
    440
    │ │ │ │ +
    │ │ │ │ +
    441 inline friend std::size_t hash_value(const ReservedVector& v) noexcept
    │ │ │ │ +
    442 {
    │ │ │ │ +
    443 return hash_range(v.storage_.data(),v.storage_.data()+v.size_);
    │ │ │ │ +
    444 }
    │ │ │ │ +
    │ │ │ │ +
    445
    │ │ │ │ +
    446 private:
    │ │ │ │ +
    447 storage_type storage_;
    │ │ │ │ +
    448 size_type size_;
    │ │ │ │ +
    449 };
    │ │ │ │ +
    │ │ │ │ +
    450
    │ │ │ │ +
    451}
    │ │ │ │ +
    452
    │ │ │ │ + │ │ │ │ +
    454
    │ │ │ │ +
    455#undef CHECKSIZE
    │ │ │ │ +
    456
    │ │ │ │ +
    457#endif // DUNE_COMMON_RESERVEDVECTOR_HH
    │ │ │ │ +
    #define CHECKSIZE(X)
    Definition reservedvector.hh:25
    │ │ │ │ +
    Support for calculating hash values of objects.
    │ │ │ │ +
    #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
    │ │ │ │ +
    STL namespace.
    │ │ │ │
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ -
    bool any_true(const AlignedNumber< bool, align > &val)
    Definition debugalign.hh:493
    │ │ │ │ -
    bool all_true(const AlignedNumber< bool, align > &val)
    Definition debugalign.hh:499
    │ │ │ │ -
    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:481
    │ │ │ │ -
    T min_value(const AlignedNumber< T, align > &val)
    Definition debugalign.hh:487
    │ │ │ │ -
    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:115
    │ │ │ │ -
    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
    │ │ │ │ +
    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
    │ │ │ │ +
    A Vector class with statically reserved memory.
    Definition reservedvector.hh:47
    │ │ │ │ +
    constexpr const_reference front() const noexcept
    Returns const reference to first element of vector.
    Definition reservedvector.hh:350
    │ │ │ │ +
    constexpr const_reverse_iterator crend() const noexcept
    Returns a const reverse-iterator pointing to the begin of the vector.
    Definition reservedvector.hh:303
    │ │ │ │ +
    constexpr ReservedVector(size_type count) noexcept(std::is_nothrow_default_constructible_v< value_type >)
    Constructs the vector with count elements that will be default-initialized.
    Definition reservedvector.hh:89
    │ │ │ │ +
    constexpr void fill(const value_type &value) noexcept(std::is_nothrow_copy_assignable_v< value_type >)
    Fill the container with the value.
    Definition reservedvector.hh:415
    │ │ │ │ +
    storage_type::pointer pointer
    Pointer to T.
    Definition reservedvector.hh:57
    │ │ │ │ +
    constexpr reverse_iterator rbegin() noexcept
    Returns a const reverse-iterator pointing to the end of the vector.
    Definition reservedvector.hh:255
    │ │ │ │ +
    constexpr bool operator<=(const ReservedVector &that) const noexcept
    Lexicographically compares the values in the vector this with that
    Definition reservedvector.hh:165
    │ │ │ │ +
    constexpr bool operator>(const ReservedVector &that) const noexcept
    Lexicographically compares the values in the vector this with that
    Definition reservedvector.hh:159
    │ │ │ │ +
    constexpr const_reverse_iterator rend() const noexcept
    Returns a const reverse-iterator pointing to the begin of the vector.
    Definition reservedvector.hh:297
    │ │ │ │ +
    static constexpr size_type max_size() noexcept
    Returns the maximum length of the vector.
    Definition reservedvector.hh:405
    │ │ │ │ +
    constexpr const_reference at(size_type i) const
    Returns a const reference to the i'th element.
    Definition reservedvector.hh:321
    │ │ │ │ +
    std::reverse_iterator< iterator > reverse_iterator
    Reverse iterator.
    Definition reservedvector.hh:73
    │ │ │ │ +
    constexpr iterator end() noexcept
    Returns an iterator pointing to the end of the vector.
    Definition reservedvector.hh:273
    │ │ │ │ +
    constexpr bool operator<(const ReservedVector &that) const noexcept
    Lexicographically compares the values in the vector this with that
    Definition reservedvector.hh:149
    │ │ │ │ +
    constexpr size_type size() const noexcept
    Returns number of elements in the vector.
    Definition reservedvector.hh:387
    │ │ │ │ +
    constexpr bool empty() const noexcept
    Returns true if vector has no elements.
    Definition reservedvector.hh:393
    │ │ │ │ +
    constexpr iterator begin() noexcept
    Returns a iterator pointing to the beginning of the vector.
    Definition reservedvector.hh:237
    │ │ │ │ +
    constexpr void push_back(const value_type &t) noexcept(std::is_nothrow_copy_assignable_v< value_type >)
    Appends an element to the end of a vector, up to the maximum size n, O(1) time.
    Definition reservedvector.hh:194
    │ │ │ │ +
    constexpr reverse_iterator rend() noexcept
    Returns a const reverse-iterator pointing to the begin of the vector.
    Definition reservedvector.hh:291
    │ │ │ │ +
    storage_type::iterator iterator
    Iterator used to iterate through a vector.
    Definition reservedvector.hh:69
    │ │ │ │ +
    constexpr const_iterator cbegin() const noexcept
    Returns a const_iterator pointing to the beginning of the vector.
    Definition reservedvector.hh:249
    │ │ │ │ +
    std::reverse_iterator< const_iterator > const_reverse_iterator
    Const reverse iterator.
    Definition reservedvector.hh:75
    │ │ │ │ +
    constexpr pointer data() noexcept
    Returns pointer to the underlying memory.
    Definition reservedvector.hh:371
    │ │ │ │ +
    constexpr const_reference back() const noexcept
    Returns const reference to last element of vector.
    Definition reservedvector.hh:364
    │ │ │ │ +
    friend std::ostream & operator<<(std::ostream &s, const ReservedVector &v)
    Send ReservedVector to an output stream.
    Definition reservedvector.hh:434
    │ │ │ │ +
    constexpr bool operator==(const ReservedVector &that) const noexcept
    Compares the values in the vector this with that for equality.
    Definition reservedvector.hh:132
    │ │ │ │ +
    constexpr void pop_back() noexcept
    Erases the last element of the vector, O(1) time.
    Definition reservedvector.hh:227
    │ │ │ │ +
    friend std::size_t hash_value(const ReservedVector &v) noexcept
    Definition reservedvector.hh:441
    │ │ │ │ +
    storage_type::difference_type difference_type
    A signed integral type.
    Definition reservedvector.hh:67
    │ │ │ │ +
    constexpr const_iterator end() const noexcept
    Returns a const_iterator pointing to the end of the vector.
    Definition reservedvector.hh:279
    │ │ │ │ +
    constexpr void clear() noexcept
    Erases all elements.
    Definition reservedvector.hh:181
    │ │ │ │ +
    constexpr ReservedVector() noexcept(std::is_nothrow_default_constructible_v< value_type >)
    Constructs an empty vector.
    Definition reservedvector.hh:82
    │ │ │ │ +
    storage_type::const_iterator const_iterator
    Const iterator used to iterate through a vector.
    Definition reservedvector.hh:71
    │ │ │ │ +
    reference emplace_back(Args &&... args) noexcept(std::is_nothrow_constructible_v< value_type, decltype(args)... >)
    Appends an element to the end of a vector by constructing it in place.
    Definition reservedvector.hh:211
    │ │ │ │ +
    storage_type::size_type size_type
    An unsigned integral type.
    Definition reservedvector.hh:65
    │ │ │ │ +
    constexpr bool operator>=(const ReservedVector &that) const noexcept
    Lexicographically compares the values in the vector this with that
    Definition reservedvector.hh:171
    │ │ │ │ +
    storage_type::const_reference const_reference
    Const reference to T.
    Definition reservedvector.hh:63
    │ │ │ │ +
    void swap(ReservedVector &other) noexcept(std::is_nothrow_swappable_v< value_type >)
    Swap the content with another vector.
    Definition reservedvector.hh:423
    │ │ │ │ +
    constexpr ReservedVector(InputIt first, InputIt last) noexcept(std::is_nothrow_copy_assignable_v< value_type > &&noexcept(ReservedVector()))
    Constructs the vector from an iterator range [first,last)
    Definition reservedvector.hh:110
    │ │ │ │ +
    constexpr const_pointer data() const noexcept
    Returns const pointer to the underlying memory.
    Definition reservedvector.hh:377
    │ │ │ │ +
    constexpr reference at(size_type i)
    Returns reference to the i'th element.
    Definition reservedvector.hh:313
    │ │ │ │ +
    constexpr const_iterator cend() const noexcept
    Returns a const_iterator pointing to the end of the vector.
    Definition reservedvector.hh:285
    │ │ │ │ +
    constexpr reference back() noexcept
    Returns reference to last element of vector.
    Definition reservedvector.hh:357
    │ │ │ │ +
    constexpr const_reverse_iterator rbegin() const noexcept
    Returns a const reverse-iterator pointing to the end of the vector.
    Definition reservedvector.hh:261
    │ │ │ │ +
    storage_type::value_type value_type
    The type of object, T, stored in the vector.
    Definition reservedvector.hh:55
    │ │ │ │ +
    constexpr const_iterator begin() const noexcept
    Returns a const_iterator pointing to the beginning of the vector.
    Definition reservedvector.hh:243
    │ │ │ │ +
    constexpr ReservedVector(size_type count, const value_type &value) noexcept(std::is_nothrow_copy_assignable_v< value_type > &&noexcept(ReservedVector(count)))
    Constructs the vector with count copies of elements with value value.
    Definition reservedvector.hh:98
    │ │ │ │ +
    constexpr reference operator[](size_type i) noexcept
    Returns reference to the i'th element.
    Definition reservedvector.hh:329
    │ │ │ │ +
    constexpr reference front() noexcept
    Returns reference to first element of vector.
    Definition reservedvector.hh:343
    │ │ │ │ +
    storage_type::const_pointer const_pointer
    Const pointer to T.
    Definition reservedvector.hh:59
    │ │ │ │ +
    constexpr ReservedVector(std::initializer_list< value_type > const &l) noexcept(std::is_nothrow_copy_assignable_v< value_type > &&noexcept(ReservedVector(l.begin(), l.end())))
    Constructs the vector from an initializer list.
    Definition reservedvector.hh:121
    │ │ │ │ +
    constexpr bool operator!=(const ReservedVector &that) const noexcept
    Compares the values in the vector this with that for not equality.
    Definition reservedvector.hh:143
    │ │ │ │ +
    constexpr void resize(size_type s) noexcept
    Specifies a new size for the vector.
    Definition reservedvector.hh:187
    │ │ │ │ +
    static constexpr size_type capacity() noexcept
    Returns current capacity (allocated memory) of the vector.
    Definition reservedvector.hh:399
    │ │ │ │ +
    storage_type::reference reference
    Reference to T.
    Definition reservedvector.hh:61
    │ │ │ │ +
    constexpr const_reverse_iterator crbegin() const noexcept
    Returns a const reverse-iterator pointing to the end of the vector.
    Definition reservedvector.hh:267
    │ │ │ │ +
    constexpr void push_back(value_type &&t) noexcept(std::is_nothrow_move_assignable_v< value_type >)
    Appends an element to the end of a vector by moving the value, up to the maximum size n,...
    Definition reservedvector.hh:202
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,552 +7,635 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -simd.hh │ │ │ │ │ +reservedvector.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ - 1// SPDX-FileCopyrightInfo: Copyright (C) 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 (C) 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 │ │ │ │ │ - 31#include │ │ │ │ │ - 32#include │ │ │ │ │ - 33#include │ │ │ │ │ - 34 │ │ │ │ │ - 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#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 │ │ │ │ │ - 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 │ │ │ │ │ - 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; │ │ │ │ │ + 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ + 5#ifndef DUNE_COMMON_RESERVEDVECTOR_HH │ │ │ │ │ + 6#define DUNE_COMMON_RESERVEDVECTOR_HH │ │ │ │ │ + 7 │ │ │ │ │ + 12#include │ │ │ │ │ + 13#include │ │ │ │ │ + 14#include │ │ │ │ │ + 15#include │ │ │ │ │ + 16#include │ │ │ │ │ + 17#include │ │ │ │ │ + 18#include │ │ │ │ │ + 19 │ │ │ │ │ + 20#include │ │ │ │ │ + 21 │ │ │ │ │ + 22#ifdef CHECK_RESERVEDVECTOR │ │ │ │ │ + 23#define CHECKSIZE(X) assert(X) │ │ │ │ │ + 24#else │ │ │ │ │ +25#define CHECKSIZE(X) {} │ │ │ │ │ + 26#endif │ │ │ │ │ + 27 │ │ │ │ │ + 28namespace Dune │ │ │ │ │ + 29{ │ │ │ │ │ + 45 template │ │ │ │ │ +46 class ReservedVector │ │ │ │ │ + 47 { │ │ │ │ │ + 48 using storage_type = std::array; │ │ │ │ │ + 49 │ │ │ │ │ + 50 public: │ │ │ │ │ + 51 │ │ │ │ │ +55 typedef typename storage_type::value_type value_type; │ │ │ │ │ +57 typedef typename storage_type::pointer pointer; │ │ │ │ │ +59 typedef typename storage_type::const_pointer const_pointer; │ │ │ │ │ +61 typedef typename storage_type::reference reference; │ │ │ │ │ +63 typedef typename storage_type::const_reference const_reference; │ │ │ │ │ +65 typedef typename storage_type::size_type size_type; │ │ │ │ │ +67 typedef typename storage_type::difference_type difference_type; │ │ │ │ │ +69 typedef typename storage_type::iterator iterator; │ │ │ │ │ +71 typedef typename storage_type::const_iterator const_iterator; │ │ │ │ │ +73 typedef std::reverse_iterator reverse_iterator; │ │ │ │ │ +75 typedef std::reverse_iterator const_reverse_iterator; │ │ │ │ │ + 76 │ │ │ │ │ +82 constexpr ReservedVector() │ │ │ │ │ + 83 noexcept(std::is_nothrow_default_constructible_v) │ │ │ │ │ + 84 : storage_() │ │ │ │ │ + 85 , size_(0) │ │ │ │ │ + 86 {} │ │ │ │ │ + 87 │ │ │ │ │ +89 explicit constexpr ReservedVector(size_type count) │ │ │ │ │ + 90 noexcept(std::is_nothrow_default_constructible_v) │ │ │ │ │ + 91 : storage_() │ │ │ │ │ + 92 , size_(count) │ │ │ │ │ + 93 { │ │ │ │ │ + 94 assert(count <= n); │ │ │ │ │ + 95 } │ │ │ │ │ + 96 │ │ │ │ │ +98 constexpr ReservedVector(size_type count, const value_type& value) │ │ │ │ │ + 99 noexcept(std::is_nothrow_copy_assignable_v && │ │ │ │ │ + 100 noexcept(ReservedVector(count))) │ │ │ │ │ + 101 : ReservedVector(count) │ │ │ │ │ + 102 { │ │ │ │ │ + 103 for (size_type i=0; i::value_type, value_type>, int> = 0> │ │ │ │ │ +110 constexpr ReservedVector(InputIt first, InputIt last) │ │ │ │ │ + 111 noexcept(std::is_nothrow_copy_assignable_v && │ │ │ │ │ + 112 noexcept(ReservedVector())) │ │ │ │ │ + 113 : ReservedVector() │ │ │ │ │ + 114 { │ │ │ │ │ + 115 for (size_type i=0; i const& l) │ │ │ │ │ + 122 noexcept(std::is_nothrow_copy_assignable_v && │ │ │ │ │ + 123 noexcept(ReservedVector(l.begin(),l.end()))) │ │ │ │ │ + 124 : ReservedVector(l.begin(),l.end()) │ │ │ │ │ + 125 {} │ │ │ │ │ + 126 │ │ │ │ │ +132 constexpr bool operator==(const ReservedVector& that) const noexcept │ │ │ │ │ + 133 { │ │ │ │ │ + 134 if (size() != that.size()) │ │ │ │ │ + 135 return false; │ │ │ │ │ + 136 for (size_type i=0; i(const ReservedVector& that) const noexcept │ │ │ │ │ + 160 { │ │ │ │ │ + 161 return that < *this; │ │ │ │ │ + 162 } │ │ │ │ │ + 163 │ │ │ │ │ +165 constexpr bool operator<=(const ReservedVector& that) const noexcept │ │ │ │ │ + 166 { │ │ │ │ │ + 167 return !(*this > that); │ │ │ │ │ + 168 } │ │ │ │ │ + 169 │ │ │ │ │ +171 constexpr bool operator>=(const ReservedVector& that) const noexcept │ │ │ │ │ + 172 { │ │ │ │ │ + 173 return !(*this < that); │ │ │ │ │ + 174 } │ │ │ │ │ + 175 │ │ │ │ │ +181 constexpr void clear() noexcept │ │ │ │ │ + 182 { │ │ │ │ │ + 183 size_ = 0; │ │ │ │ │ + 184 } │ │ │ │ │ + 185 │ │ │ │ │ +187 constexpr void resize(size_type s) noexcept │ │ │ │ │ + 188 { │ │ │ │ │ + 189 CHECKSIZE(s<=n); │ │ │ │ │ + 190 size_ = s; │ │ │ │ │ + 191 } │ │ │ │ │ + 192 │ │ │ │ │ +194 constexpr void push_back(const value_type& t) │ │ │ │ │ + 195 noexcept(std::is_nothrow_copy_assignable_v) │ │ │ │ │ + 196 { │ │ │ │ │ + 197 CHECKSIZE(size_) │ │ │ │ │ + 204 { │ │ │ │ │ + 205 CHECKSIZE(size_ │ │ │ │ │ - 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 │ │ │ │ │ + 210 template │ │ │ │ │ +211 reference emplace_back(Args&&... args) │ │ │ │ │ + 212 noexcept(std::is_nothrow_constructible_v) │ │ │ │ │ + 213 { │ │ │ │ │ + 214 CHECKSIZE(size_~value_type(); │ │ │ │ │ + 218 // construct the value_type in place │ │ │ │ │ + 219 // NOTE: This is not an integral constant expression. │ │ │ │ │ + 220 // With c++20 we could use std::construct_at │ │ │ │ │ + 221 ::new (const_cast(static_cast(p))) │ │ │ │ │ + 222 value_type(std::forward(args)...); │ │ │ │ │ + 223 return *p; │ │ │ │ │ + 224 } │ │ │ │ │ 225 │ │ │ │ │ - 227 template │ │ │ │ │ -228 struct SimdScalarTypeTraits< AlignedNumber > │ │ │ │ │ - 229 { │ │ │ │ │ -230 using type = T; │ │ │ │ │ - 231 }; │ │ │ │ │ - 232 │ │ │ │ │ - 233 template │ │ │ │ │ -234 struct SimdIndexTypeTraits { │ │ │ │ │ -235 using type = std::size_t; │ │ │ │ │ - 236 }; │ │ │ │ │ - 237 │ │ │ │ │ - 239 │ │ │ │ │ - 245 template │ │ │ │ │ -246 using SimdIndex = typename SimdIndexTypeTraits::type; │ │ │ │ │ +227 constexpr void pop_back() noexcept │ │ │ │ │ + 228 { │ │ │ │ │ + 229 if (! empty()) size_--; │ │ │ │ │ + 230 } │ │ │ │ │ + 231 │ │ │ │ │ +237 constexpr iterator begin() noexcept │ │ │ │ │ + 238 { │ │ │ │ │ + 239 return storage_.begin(); │ │ │ │ │ + 240 } │ │ │ │ │ + 241 │ │ │ │ │ +243 constexpr const_iterator begin() const noexcept │ │ │ │ │ + 244 { │ │ │ │ │ + 245 return storage_.begin(); │ │ │ │ │ + 246 } │ │ │ │ │ 247 │ │ │ │ │ - 248#if HAVE_VC │ │ │ │ │ - 249 template │ │ │ │ │ - 250 struct SimdIndexTypeTraits > { │ │ │ │ │ - 251 using type = typename Vc::Vector::index_type; │ │ │ │ │ - 252 }; │ │ │ │ │ +249 constexpr const_iterator cbegin() const noexcept │ │ │ │ │ + 250 { │ │ │ │ │ + 251 return storage_.cbegin(); │ │ │ │ │ + 252 } │ │ │ │ │ 253 │ │ │ │ │ - 254 template │ │ │ │ │ - 255 struct SimdIndexTypeTraits > { │ │ │ │ │ - 256 using type = typename Vc::SimdArray::index_type; │ │ │ │ │ - 257 }; │ │ │ │ │ - 258#endif // HAVE_VC │ │ │ │ │ +255 constexpr reverse_iterator rbegin() noexcept │ │ │ │ │ + 256 { │ │ │ │ │ + 257 return reverse_iterator{begin()+size()}; │ │ │ │ │ + 258 } │ │ │ │ │ 259 │ │ │ │ │ - 260 template │ │ │ │ │ -261 struct SimdMaskTypeTraits { │ │ │ │ │ -262 using type = bool; │ │ │ │ │ - 263 }; │ │ │ │ │ - 264 │ │ │ │ │ - 266 │ │ │ │ │ - 269 template │ │ │ │ │ -270 using SimdMask = typename SimdMaskTypeTraits::type; │ │ │ │ │ +261 constexpr const_reverse_iterator rbegin() const noexcept │ │ │ │ │ + 262 { │ │ │ │ │ + 263 return const_reverse_iterator{begin()+size()}; │ │ │ │ │ + 264 } │ │ │ │ │ + 265 │ │ │ │ │ +267 constexpr const_reverse_iterator crbegin() const noexcept │ │ │ │ │ + 268 { │ │ │ │ │ + 269 return const_reverse_iterator{begin()+size()}; │ │ │ │ │ + 270 } │ │ │ │ │ 271 │ │ │ │ │ - 272#if HAVE_VC │ │ │ │ │ - 273 template │ │ │ │ │ - 274 struct SimdMaskTypeTraits > { │ │ │ │ │ - 275 using type = typename Vc::Vector::mask_type; │ │ │ │ │ - 276 }; │ │ │ │ │ +273 constexpr iterator end() noexcept │ │ │ │ │ + 274 { │ │ │ │ │ + 275 return storage_.begin()+size(); │ │ │ │ │ + 276 } │ │ │ │ │ 277 │ │ │ │ │ - 278 template │ │ │ │ │ - 279 struct SimdMaskTypeTraits > { │ │ │ │ │ - 280 using type = typename Vc::SimdArray::mask_type; │ │ │ │ │ - 281 }; │ │ │ │ │ - 282#endif // HAVE_VC │ │ │ │ │ +279 constexpr const_iterator end() const noexcept │ │ │ │ │ + 280 { │ │ │ │ │ + 281 return storage_.begin()+size(); │ │ │ │ │ + 282 } │ │ │ │ │ 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) │ │ │ │ │ +285 constexpr const_iterator cend() const noexcept │ │ │ │ │ + 286 { │ │ │ │ │ + 287 return storage_.cbegin()+size(); │ │ │ │ │ + 288 } │ │ │ │ │ + 289 │ │ │ │ │ +291 constexpr reverse_iterator rend() noexcept │ │ │ │ │ 292 { │ │ │ │ │ - 293 return std::move(Vc::iif(b, v1, v2)); │ │ │ │ │ + 293 return reverse_iterator{begin()}; │ │ │ │ │ 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 │ │ │ │ │ - 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 v.min(); │ │ │ │ │ - 327 } │ │ │ │ │ - 328 │ │ │ │ │ - 329 template │ │ │ │ │ - 330 double min_value(const Vc::SimdArray & v) │ │ │ │ │ - 331 { │ │ │ │ │ - 332 return v.min(); │ │ │ │ │ +297 constexpr const_reverse_iterator rend() const noexcept │ │ │ │ │ + 298 { │ │ │ │ │ + 299 return const_reverse_iterator{begin()}; │ │ │ │ │ + 300 } │ │ │ │ │ + 301 │ │ │ │ │ +303 constexpr const_reverse_iterator crend() const noexcept │ │ │ │ │ + 304 { │ │ │ │ │ + 305 return const_reverse_iterator{begin()}; │ │ │ │ │ + 306 } │ │ │ │ │ + 307 │ │ │ │ │ +313 constexpr reference at(size_type i) │ │ │ │ │ + 314 { │ │ │ │ │ + 315 if (!(i < size())) │ │ │ │ │ + 316 throw std::out_of_range("Index out of range"); │ │ │ │ │ + 317 return storage_[i]; │ │ │ │ │ + 318 } │ │ │ │ │ + 319 │ │ │ │ │ +321 constexpr const_reference at(size_type i) const │ │ │ │ │ + 322 { │ │ │ │ │ + 323 if (!(i < size())) │ │ │ │ │ + 324 throw std::out_of_range("Index out of range"); │ │ │ │ │ + 325 return storage_[i]; │ │ │ │ │ + 326 } │ │ │ │ │ + 327 │ │ │ │ │ +329 constexpr reference operator[](size_type i) noexcept │ │ │ │ │ + 330 { │ │ │ │ │ + 331 CHECKSIZE(size_>i); │ │ │ │ │ + 332 return storage_[i]; │ │ │ │ │ 333 } │ │ │ │ │ 334 │ │ │ │ │ - 335 template │ │ │ │ │ - 336 bool any_true(const Vc::Mask & v) │ │ │ │ │ +336 constexpr const_reference operator[](size_type i) const noexcept │ │ │ │ │ 337 { │ │ │ │ │ - 338 return Vc::any_of(v); │ │ │ │ │ - 339 } │ │ │ │ │ - 340 │ │ │ │ │ - 341 template │ │ │ │ │ - 342 bool any_true(const Vc::SimdMaskArray & v) │ │ │ │ │ - 343 { │ │ │ │ │ - 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#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#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 │ │ │ │ │ - 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 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}; │ │ │ │ │ + 338 CHECKSIZE(size_>i); │ │ │ │ │ + 339 return storage_[i]; │ │ │ │ │ + 340 } │ │ │ │ │ + 341 │ │ │ │ │ +343 constexpr reference front() noexcept │ │ │ │ │ + 344 { │ │ │ │ │ + 345 CHECKSIZE(size_>0); │ │ │ │ │ + 346 return storage_[0]; │ │ │ │ │ + 347 } │ │ │ │ │ + 348 │ │ │ │ │ +350 constexpr const_reference front() const noexcept │ │ │ │ │ + 351 { │ │ │ │ │ + 352 CHECKSIZE(size_>0); │ │ │ │ │ + 353 return storage_[0]; │ │ │ │ │ + 354 } │ │ │ │ │ + 355 │ │ │ │ │ +357 constexpr reference back() noexcept │ │ │ │ │ + 358 { │ │ │ │ │ + 359 CHECKSIZE(size_>0); │ │ │ │ │ + 360 return storage_[size_-1]; │ │ │ │ │ + 361 } │ │ │ │ │ + 362 │ │ │ │ │ +364 constexpr const_reference back() const noexcept │ │ │ │ │ + 365 { │ │ │ │ │ + 366 CHECKSIZE(size_>0); │ │ │ │ │ + 367 return storage_[size_-1]; │ │ │ │ │ + 368 } │ │ │ │ │ + 369 │ │ │ │ │ +371 constexpr pointer data() noexcept │ │ │ │ │ + 372 { │ │ │ │ │ + 373 return storage_.data(); │ │ │ │ │ + 374 } │ │ │ │ │ + 375 │ │ │ │ │ +377 constexpr const_pointer data() const noexcept │ │ │ │ │ + 378 { │ │ │ │ │ + 379 return storage_.data(); │ │ │ │ │ + 380 } │ │ │ │ │ + 381 │ │ │ │ │ +387 constexpr size_type size() const noexcept │ │ │ │ │ + 388 { │ │ │ │ │ + 389 return size_; │ │ │ │ │ + 390 } │ │ │ │ │ + 391 │ │ │ │ │ +393 constexpr bool empty() const noexcept │ │ │ │ │ + 394 { │ │ │ │ │ + 395 return size_==0; │ │ │ │ │ + 396 } │ │ │ │ │ + 397 │ │ │ │ │ +399 static constexpr size_type capacity() noexcept │ │ │ │ │ + 400 { │ │ │ │ │ + 401 return n; │ │ │ │ │ + 402 } │ │ │ │ │ + 403 │ │ │ │ │ +405 static constexpr size_type max_size() noexcept │ │ │ │ │ + 406 { │ │ │ │ │ + 407 return n; │ │ │ │ │ + 408 } │ │ │ │ │ + 409 │ │ │ │ │ +415 constexpr void fill(const value_type& value) │ │ │ │ │ + 416 noexcept(std::is_nothrow_copy_assignable_v) │ │ │ │ │ + 417 { │ │ │ │ │ + 418 for (size_type i=0; i) │ │ │ │ │ + 425 { │ │ │ │ │ + 426 using std::swap; │ │ │ │ │ + 427 swap(storage_, other.storage_); │ │ │ │ │ + 428 swap(size_, other.size_); │ │ │ │ │ + 429 } │ │ │ │ │ + 430 │ │ │ │ │ +434 friend std::ostream& operator<<(std::ostream& s, const ReservedVector& v) │ │ │ │ │ + 435 { │ │ │ │ │ + 436 for (size_type i=0; i │ │ │ │ │ -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. │ │ │ │ │ -vc.hh │ │ │ │ │ -Compatibility header for including │ │ │ │ │ -conditional.hh │ │ │ │ │ -rangeutilities.hh │ │ │ │ │ -Utilities for reduction like operations on ranges. │ │ │ │ │ -debugalign.hh │ │ │ │ │ + 440 │ │ │ │ │ +441 inline friend std::size_t hash_value(const ReservedVector& v) noexcept │ │ │ │ │ + 442 { │ │ │ │ │ + 443 return hash_range(v.storage_.data(),v.storage_.data()+v.size_); │ │ │ │ │ + 444 } │ │ │ │ │ + 445 │ │ │ │ │ + 446 private: │ │ │ │ │ + 447 storage_type storage_; │ │ │ │ │ + 448 size_type size_; │ │ │ │ │ + 449 }; │ │ │ │ │ + 450 │ │ │ │ │ + 451} │ │ │ │ │ + 452 │ │ │ │ │ + 453DUNE_DEFINE_HASH(DUNE_HASH_TEMPLATE_ARGS(typename T, int n),DUNE_HASH_TYPE │ │ │ │ │ +(Dune::ReservedVector)) │ │ │ │ │ + 454 │ │ │ │ │ + 455#undef CHECKSIZE │ │ │ │ │ + 456 │ │ │ │ │ + 457#endif // DUNE_COMMON_RESERVEDVECTOR_HH │ │ │ │ │ +CHECKSIZE │ │ │ │ │ +#define CHECKSIZE(X) │ │ │ │ │ +Definition reservedvector.hh:25 │ │ │ │ │ +hash.hh │ │ │ │ │ +Support for calculating hash values of objects. │ │ │ │ │ +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 │ │ │ │ │ +std │ │ │ │ │ +STL namespace. │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::any_true │ │ │ │ │ -bool any_true(const AlignedNumber< bool, align > &val) │ │ │ │ │ -Definition debugalign.hh:493 │ │ │ │ │ -Dune::all_true │ │ │ │ │ -bool all_true(const AlignedNumber< bool, align > &val) │ │ │ │ │ -Definition debugalign.hh:499 │ │ │ │ │ -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:481 │ │ │ │ │ -Dune::min_value │ │ │ │ │ -T min_value(const AlignedNumber< T, align > &val) │ │ │ │ │ -Definition debugalign.hh:487 │ │ │ │ │ -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:115 │ │ │ │ │ -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 │ │ │ │ │ +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::ReservedVector │ │ │ │ │ +A Vector class with statically reserved memory. │ │ │ │ │ +Definition reservedvector.hh:47 │ │ │ │ │ +Dune::ReservedVector::front │ │ │ │ │ +constexpr const_reference front() const noexcept │ │ │ │ │ +Returns const reference to first element of vector. │ │ │ │ │ +Definition reservedvector.hh:350 │ │ │ │ │ +Dune::ReservedVector::crend │ │ │ │ │ +constexpr const_reverse_iterator crend() const noexcept │ │ │ │ │ +Returns a const reverse-iterator pointing to the begin of the vector. │ │ │ │ │ +Definition reservedvector.hh:303 │ │ │ │ │ +Dune::ReservedVector::ReservedVector │ │ │ │ │ +constexpr ReservedVector(size_type count) noexcept(std:: │ │ │ │ │ +is_nothrow_default_constructible_v< value_type >) │ │ │ │ │ +Constructs the vector with count elements that will be default-initialized. │ │ │ │ │ +Definition reservedvector.hh:89 │ │ │ │ │ +Dune::ReservedVector::fill │ │ │ │ │ +constexpr void fill(const value_type &value) noexcept(std:: │ │ │ │ │ +is_nothrow_copy_assignable_v< value_type >) │ │ │ │ │ +Fill the container with the value. │ │ │ │ │ +Definition reservedvector.hh:415 │ │ │ │ │ +Dune::ReservedVector::pointer │ │ │ │ │ +storage_type::pointer pointer │ │ │ │ │ +Pointer to T. │ │ │ │ │ +Definition reservedvector.hh:57 │ │ │ │ │ +Dune::ReservedVector::rbegin │ │ │ │ │ +constexpr reverse_iterator rbegin() noexcept │ │ │ │ │ +Returns a const reverse-iterator pointing to the end of the vector. │ │ │ │ │ +Definition reservedvector.hh:255 │ │ │ │ │ +Dune::ReservedVector::operator<= │ │ │ │ │ +constexpr bool operator<=(const ReservedVector &that) const noexcept │ │ │ │ │ +Lexicographically compares the values in the vector this with that │ │ │ │ │ +Definition reservedvector.hh:165 │ │ │ │ │ +Dune::ReservedVector::operator> │ │ │ │ │ +constexpr bool operator>(const ReservedVector &that) const noexcept │ │ │ │ │ +Lexicographically compares the values in the vector this with that │ │ │ │ │ +Definition reservedvector.hh:159 │ │ │ │ │ +Dune::ReservedVector::rend │ │ │ │ │ +constexpr const_reverse_iterator rend() const noexcept │ │ │ │ │ +Returns a const reverse-iterator pointing to the begin of the vector. │ │ │ │ │ +Definition reservedvector.hh:297 │ │ │ │ │ +Dune::ReservedVector::max_size │ │ │ │ │ +static constexpr size_type max_size() noexcept │ │ │ │ │ +Returns the maximum length of the vector. │ │ │ │ │ +Definition reservedvector.hh:405 │ │ │ │ │ +Dune::ReservedVector::at │ │ │ │ │ +constexpr const_reference at(size_type i) const │ │ │ │ │ +Returns a const reference to the i'th element. │ │ │ │ │ +Definition reservedvector.hh:321 │ │ │ │ │ +Dune::ReservedVector::reverse_iterator │ │ │ │ │ +std::reverse_iterator< iterator > reverse_iterator │ │ │ │ │ +Reverse iterator. │ │ │ │ │ +Definition reservedvector.hh:73 │ │ │ │ │ +Dune::ReservedVector::end │ │ │ │ │ +constexpr iterator end() noexcept │ │ │ │ │ +Returns an iterator pointing to the end of the vector. │ │ │ │ │ +Definition reservedvector.hh:273 │ │ │ │ │ +Dune::ReservedVector::operator< │ │ │ │ │ +constexpr bool operator<(const ReservedVector &that) const noexcept │ │ │ │ │ +Lexicographically compares the values in the vector this with that │ │ │ │ │ +Definition reservedvector.hh:149 │ │ │ │ │ +Dune::ReservedVector::size │ │ │ │ │ +constexpr size_type size() const noexcept │ │ │ │ │ +Returns number of elements in the vector. │ │ │ │ │ +Definition reservedvector.hh:387 │ │ │ │ │ +Dune::ReservedVector::empty │ │ │ │ │ +constexpr bool empty() const noexcept │ │ │ │ │ +Returns true if vector has no elements. │ │ │ │ │ +Definition reservedvector.hh:393 │ │ │ │ │ +Dune::ReservedVector::begin │ │ │ │ │ +constexpr iterator begin() noexcept │ │ │ │ │ +Returns a iterator pointing to the beginning of the vector. │ │ │ │ │ +Definition reservedvector.hh:237 │ │ │ │ │ +Dune::ReservedVector::push_back │ │ │ │ │ +constexpr void push_back(const value_type &t) noexcept(std:: │ │ │ │ │ +is_nothrow_copy_assignable_v< value_type >) │ │ │ │ │ +Appends an element to the end of a vector, up to the maximum size n, O(1) time. │ │ │ │ │ +Definition reservedvector.hh:194 │ │ │ │ │ +Dune::ReservedVector::rend │ │ │ │ │ +constexpr reverse_iterator rend() noexcept │ │ │ │ │ +Returns a const reverse-iterator pointing to the begin of the vector. │ │ │ │ │ +Definition reservedvector.hh:291 │ │ │ │ │ +Dune::ReservedVector::iterator │ │ │ │ │ +storage_type::iterator iterator │ │ │ │ │ +Iterator used to iterate through a vector. │ │ │ │ │ +Definition reservedvector.hh:69 │ │ │ │ │ +Dune::ReservedVector::cbegin │ │ │ │ │ +constexpr const_iterator cbegin() const noexcept │ │ │ │ │ +Returns a const_iterator pointing to the beginning of the vector. │ │ │ │ │ +Definition reservedvector.hh:249 │ │ │ │ │ +Dune::ReservedVector::const_reverse_iterator │ │ │ │ │ +std::reverse_iterator< const_iterator > const_reverse_iterator │ │ │ │ │ +Const reverse iterator. │ │ │ │ │ +Definition reservedvector.hh:75 │ │ │ │ │ +Dune::ReservedVector::data │ │ │ │ │ +constexpr pointer data() noexcept │ │ │ │ │ +Returns pointer to the underlying memory. │ │ │ │ │ +Definition reservedvector.hh:371 │ │ │ │ │ +Dune::ReservedVector::back │ │ │ │ │ +constexpr const_reference back() const noexcept │ │ │ │ │ +Returns const reference to last element of vector. │ │ │ │ │ +Definition reservedvector.hh:364 │ │ │ │ │ +Dune::ReservedVector::operator<< │ │ │ │ │ +friend std::ostream & operator<<(std::ostream &s, const ReservedVector &v) │ │ │ │ │ +Send ReservedVector to an output stream. │ │ │ │ │ +Definition reservedvector.hh:434 │ │ │ │ │ +Dune::ReservedVector::operator== │ │ │ │ │ +constexpr bool operator==(const ReservedVector &that) const noexcept │ │ │ │ │ +Compares the values in the vector this with that for equality. │ │ │ │ │ +Definition reservedvector.hh:132 │ │ │ │ │ +Dune::ReservedVector::pop_back │ │ │ │ │ +constexpr void pop_back() noexcept │ │ │ │ │ +Erases the last element of the vector, O(1) time. │ │ │ │ │ +Definition reservedvector.hh:227 │ │ │ │ │ +Dune::ReservedVector::hash_value │ │ │ │ │ +friend std::size_t hash_value(const ReservedVector &v) noexcept │ │ │ │ │ +Definition reservedvector.hh:441 │ │ │ │ │ +Dune::ReservedVector::difference_type │ │ │ │ │ +storage_type::difference_type difference_type │ │ │ │ │ +A signed integral type. │ │ │ │ │ +Definition reservedvector.hh:67 │ │ │ │ │ +Dune::ReservedVector::end │ │ │ │ │ +constexpr const_iterator end() const noexcept │ │ │ │ │ +Returns a const_iterator pointing to the end of the vector. │ │ │ │ │ +Definition reservedvector.hh:279 │ │ │ │ │ +Dune::ReservedVector::clear │ │ │ │ │ +constexpr void clear() noexcept │ │ │ │ │ +Erases all elements. │ │ │ │ │ +Definition reservedvector.hh:181 │ │ │ │ │ +Dune::ReservedVector::ReservedVector │ │ │ │ │ +constexpr ReservedVector() noexcept(std::is_nothrow_default_constructible_v< │ │ │ │ │ +value_type >) │ │ │ │ │ +Constructs an empty vector. │ │ │ │ │ +Definition reservedvector.hh:82 │ │ │ │ │ +Dune::ReservedVector::const_iterator │ │ │ │ │ +storage_type::const_iterator const_iterator │ │ │ │ │ +Const iterator used to iterate through a vector. │ │ │ │ │ +Definition reservedvector.hh:71 │ │ │ │ │ +Dune::ReservedVector::emplace_back │ │ │ │ │ +reference emplace_back(Args &&... args) noexcept(std:: │ │ │ │ │ +is_nothrow_constructible_v< value_type, decltype(args)... >) │ │ │ │ │ +Appends an element to the end of a vector by constructing it in place. │ │ │ │ │ +Definition reservedvector.hh:211 │ │ │ │ │ +Dune::ReservedVector::size_type │ │ │ │ │ +storage_type::size_type size_type │ │ │ │ │ +An unsigned integral type. │ │ │ │ │ +Definition reservedvector.hh:65 │ │ │ │ │ +Dune::ReservedVector::operator>= │ │ │ │ │ +constexpr bool operator>=(const ReservedVector &that) const noexcept │ │ │ │ │ +Lexicographically compares the values in the vector this with that │ │ │ │ │ +Definition reservedvector.hh:171 │ │ │ │ │ +Dune::ReservedVector::const_reference │ │ │ │ │ +storage_type::const_reference const_reference │ │ │ │ │ +Const reference to T. │ │ │ │ │ +Definition reservedvector.hh:63 │ │ │ │ │ +Dune::ReservedVector::swap │ │ │ │ │ +void swap(ReservedVector &other) noexcept(std::is_nothrow_swappable_v< │ │ │ │ │ +value_type >) │ │ │ │ │ +Swap the content with another vector. │ │ │ │ │ +Definition reservedvector.hh:423 │ │ │ │ │ +Dune::ReservedVector::ReservedVector │ │ │ │ │ +constexpr ReservedVector(InputIt first, InputIt last) noexcept(std:: │ │ │ │ │ +is_nothrow_copy_assignable_v< value_type > &&noexcept(ReservedVector())) │ │ │ │ │ +Constructs the vector from an iterator range [first,last) │ │ │ │ │ +Definition reservedvector.hh:110 │ │ │ │ │ +Dune::ReservedVector::data │ │ │ │ │ +constexpr const_pointer data() const noexcept │ │ │ │ │ +Returns const pointer to the underlying memory. │ │ │ │ │ +Definition reservedvector.hh:377 │ │ │ │ │ +Dune::ReservedVector::at │ │ │ │ │ +constexpr reference at(size_type i) │ │ │ │ │ +Returns reference to the i'th element. │ │ │ │ │ +Definition reservedvector.hh:313 │ │ │ │ │ +Dune::ReservedVector::cend │ │ │ │ │ +constexpr const_iterator cend() const noexcept │ │ │ │ │ +Returns a const_iterator pointing to the end of the vector. │ │ │ │ │ +Definition reservedvector.hh:285 │ │ │ │ │ +Dune::ReservedVector::back │ │ │ │ │ +constexpr reference back() noexcept │ │ │ │ │ +Returns reference to last element of vector. │ │ │ │ │ +Definition reservedvector.hh:357 │ │ │ │ │ +Dune::ReservedVector::rbegin │ │ │ │ │ +constexpr const_reverse_iterator rbegin() const noexcept │ │ │ │ │ +Returns a const reverse-iterator pointing to the end of the vector. │ │ │ │ │ +Definition reservedvector.hh:261 │ │ │ │ │ +Dune::ReservedVector::value_type │ │ │ │ │ +storage_type::value_type value_type │ │ │ │ │ +The type of object, T, stored in the vector. │ │ │ │ │ +Definition reservedvector.hh:55 │ │ │ │ │ +Dune::ReservedVector::begin │ │ │ │ │ +constexpr const_iterator begin() const noexcept │ │ │ │ │ +Returns a const_iterator pointing to the beginning of the vector. │ │ │ │ │ +Definition reservedvector.hh:243 │ │ │ │ │ +Dune::ReservedVector::ReservedVector │ │ │ │ │ +constexpr ReservedVector(size_type count, const value_type &value) noexcept │ │ │ │ │ +(std::is_nothrow_copy_assignable_v< value_type > &&noexcept(ReservedVector │ │ │ │ │ +(count))) │ │ │ │ │ +Constructs the vector with count copies of elements with value value. │ │ │ │ │ +Definition reservedvector.hh:98 │ │ │ │ │ +Dune::ReservedVector::operator[] │ │ │ │ │ +constexpr reference operator[](size_type i) noexcept │ │ │ │ │ +Returns reference to the i'th element. │ │ │ │ │ +Definition reservedvector.hh:329 │ │ │ │ │ +Dune::ReservedVector::front │ │ │ │ │ +constexpr reference front() noexcept │ │ │ │ │ +Returns reference to first element of vector. │ │ │ │ │ +Definition reservedvector.hh:343 │ │ │ │ │ +Dune::ReservedVector::const_pointer │ │ │ │ │ +storage_type::const_pointer const_pointer │ │ │ │ │ +Const pointer to T. │ │ │ │ │ +Definition reservedvector.hh:59 │ │ │ │ │ +Dune::ReservedVector::ReservedVector │ │ │ │ │ +constexpr ReservedVector(std::initializer_list< value_type > const &l) noexcept │ │ │ │ │ +(std::is_nothrow_copy_assignable_v< value_type > &&noexcept(ReservedVector │ │ │ │ │ +(l.begin(), l.end()))) │ │ │ │ │ +Constructs the vector from an initializer list. │ │ │ │ │ +Definition reservedvector.hh:121 │ │ │ │ │ +Dune::ReservedVector::operator!= │ │ │ │ │ +constexpr bool operator!=(const ReservedVector &that) const noexcept │ │ │ │ │ +Compares the values in the vector this with that for not equality. │ │ │ │ │ +Definition reservedvector.hh:143 │ │ │ │ │ +Dune::ReservedVector::resize │ │ │ │ │ +constexpr void resize(size_type s) noexcept │ │ │ │ │ +Specifies a new size for the vector. │ │ │ │ │ +Definition reservedvector.hh:187 │ │ │ │ │ +Dune::ReservedVector::capacity │ │ │ │ │ +static constexpr size_type capacity() noexcept │ │ │ │ │ +Returns current capacity (allocated memory) of the vector. │ │ │ │ │ +Definition reservedvector.hh:399 │ │ │ │ │ +Dune::ReservedVector::reference │ │ │ │ │ +storage_type::reference reference │ │ │ │ │ +Reference to T. │ │ │ │ │ +Definition reservedvector.hh:61 │ │ │ │ │ +Dune::ReservedVector::crbegin │ │ │ │ │ +constexpr const_reverse_iterator crbegin() const noexcept │ │ │ │ │ +Returns a const reverse-iterator pointing to the end of the vector. │ │ │ │ │ +Definition reservedvector.hh:267 │ │ │ │ │ +Dune::ReservedVector::push_back │ │ │ │ │ +constexpr void push_back(value_type &&t) noexcept(std:: │ │ │ │ │ +is_nothrow_move_assignable_v< value_type >) │ │ │ │ │ +Appends an element to the end of a vector by moving the value, up to the │ │ │ │ │ +maximum size n,... │ │ │ │ │ +Definition reservedvector.hh:202 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00167.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: vc.hh File Reference │ │ │ │ +dune-common: poolallocator.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -69,25 +69,87 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    vc.hh File Reference
    │ │ │ │ +
    │ │ │ │ +Classes | │ │ │ │ +Namespaces | │ │ │ │ +Functions
    │ │ │ │ +
    poolallocator.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ -

    Compatibility header for including <Vc/Vc> │ │ │ │ +

    An stl-compliant pool allocator. │ │ │ │ More...

    │ │ │ │ - │ │ │ │ +
    #include <numeric>
    │ │ │ │ +#include <typeinfo>
    │ │ │ │ +#include <iostream>
    │ │ │ │ +#include <cassert>
    │ │ │ │ +#include <new>
    │ │ │ │ +
    │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ +Classes

    class  Dune::Pool< T, s >
     A memory pool of objects. More...
     
    class  Dune::PoolAllocator< T, s >
     An allocator managing a pool of objects for reuse. More...
     
    struct  Dune::PoolAllocator< T, s >::rebind< U >
     Rebind the allocator to another type. More...
     
    class  Dune::PoolAllocator< void, s >
     
    struct  Dune::PoolAllocator< void, s >::rebind< U >
     
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

    │ │ │ │ +Namespaces

    namespace  Dune
     Dune namespace.
     
    namespace  std
     STL namespace.
     
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

    │ │ │ │ +Functions

    template<typename T1 , std::size_t t1, typename T2 , std::size_t t2>
    bool Dune::operator== (const PoolAllocator< T1, t1 > &, const PoolAllocator< T2, t2 > &)
     
    template<typename T1 , std::size_t t1, typename T2 , std::size_t t2>
    bool Dune::operator!= (const PoolAllocator< T1, t1 > &, const PoolAllocator< T2, t2 > &)
     
    template<typename T , std::size_t t1, std::size_t t2>
    bool Dune::operator== (const PoolAllocator< T, t1 > &p1, const PoolAllocator< T, t2 > &p2)
     
    template<typename T , std::size_t t1, std::size_t t2>
    bool Dune::operator!= (const PoolAllocator< T, t1 > &p1, const PoolAllocator< T, t2 > &p2)
     
    template<typename T , std::size_t t1, std::size_t t2>
    bool Dune::operator== (const PoolAllocator< void, t1 > &, const PoolAllocator< T, t2 > &)
     
    template<typename T , std::size_t t1, std::size_t t2>
    bool Dune::operator!= (const PoolAllocator< void, t1 > &, const PoolAllocator< T, t2 > &)
     
    template<std::size_t t1, std::size_t t2>
    bool Dune::operator== (const PoolAllocator< void, t1 > &p1, const PoolAllocator< void, t2 > &p2)
     
    template<std::size_t t1, std::size_t t2>
    bool Dune::operator!= (const PoolAllocator< void, t1 > &p1, const PoolAllocator< void, t2 > &p2)
     
    │ │ │ │

    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.

    │ │ │ │ +

    An stl-compliant pool allocator.

    │ │ │ │ +

    This file implements the classes Pool and PoolAllocator providing memory allocation for objects in chunks.

    Author
    Markus Blatt
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,17 +6,79 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -vc.hh File Reference │ │ │ │ │ -Compatibility header for including More... │ │ │ │ │ +Classes | Namespaces | Functions │ │ │ │ │ +poolallocator.hh File Reference │ │ │ │ │ +An stl-compliant pool allocator. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ + Classes │ │ │ │ │ + class  Dune::Pool<_T,_s_> │ │ │ │ │ +  A memory pool of objects. More... │ │ │ │ │ +  │ │ │ │ │ + class  Dune::PoolAllocator<_T,_s_> │ │ │ │ │ +  An allocator managing a pool of objects for reuse. More... │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::PoolAllocator<_T,_s_>::rebind<_U_> │ │ │ │ │ +  Rebind the allocator to another type. More... │ │ │ │ │ +  │ │ │ │ │ + class  Dune::PoolAllocator<_void,_s_> │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::PoolAllocator<_void,_s_>::rebind<_U_> │ │ │ │ │ +  │ │ │ │ │ + Namespaces │ │ │ │ │ +namespace  Dune │ │ │ │ │ +  Dune namespace. │ │ │ │ │ +  │ │ │ │ │ +namespace  std │ │ │ │ │ +  STL namespace. │ │ │ │ │ +  │ │ │ │ │ + Functions │ │ │ │ │ +template │ │ │ │ │ +bool Dune::operator== (const PoolAllocator< T1, t1 > &, const PoolAllocator< │ │ │ │ │ + T2, t2 > &) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +bool Dune::operator!= (const PoolAllocator< T1, t1 > &, const PoolAllocator< │ │ │ │ │ + T2, t2 > &) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +bool Dune::operator== (const PoolAllocator< T, t1 > &p1, const PoolAllocator< │ │ │ │ │ + T, t2 > &p2) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +bool Dune::operator!= (const PoolAllocator< T, t1 > &p1, const PoolAllocator< │ │ │ │ │ + T, t2 > &p2) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +bool Dune::operator== (const PoolAllocator< void, t1 > &, const PoolAllocator< │ │ │ │ │ + T, t2 > &) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +bool Dune::operator!= (const PoolAllocator< void, t1 > &, const PoolAllocator< │ │ │ │ │ + T, t2 > &) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +bool Dune::operator== (const PoolAllocator< void, t1 > &p1, const │ │ │ │ │ + PoolAllocator< void, t2 > &p2) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +bool Dune::operator!= (const PoolAllocator< void, t1 > &p1, const │ │ │ │ │ + PoolAllocator< void, t2 > &p2) │ │ │ │ │ +  │ │ │ │ │ ***** 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. │ │ │ │ │ +An stl-compliant pool allocator. │ │ │ │ │ +This file implements the classes Pool and PoolAllocator providing memory │ │ │ │ │ +allocation for objects in chunks. │ │ │ │ │ + Author │ │ │ │ │ + Markus Blatt │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00167_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: vc.hh Source File │ │ │ │ +dune-common: poolallocator.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,38 +74,519 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    vc.hh
    │ │ │ │ +
    poolallocator.hh
    │ │ │ │
    │ │ │ │
    │ │ │ │ -Go to the documentation of this file.
    1// SPDX-FileCopyrightInfo: Copyright (C) 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
    │ │ │ │ +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 (C) 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_POOLALLOCATOR_HH
    │ │ │ │ +
    6#define DUNE_COMMON_POOLALLOCATOR_HH
    │ │ │ │ +
    7
    │ │ │ │ +
    12#include <numeric>
    │ │ │ │ +
    13#include <typeinfo>
    │ │ │ │ +
    14#include <iostream>
    │ │ │ │ +
    15#include <cassert>
    │ │ │ │ +
    16#include <new>
    │ │ │ │ +
    17
    │ │ │ │ +
    18#ifndef DOXYGEN
    │ │ │ │ +
    19// forward declarations.
    │ │ │ │ +
    20// we need to know the test function to declare it friend
    │ │ │ │ +
    21template<std::size_t size, typename T>
    │ │ │ │ +
    22struct testPoolMain;
    │ │ │ │
    23#endif
    │ │ │ │
    24
    │ │ │ │ -
    25// include the rest of Vc
    │ │ │ │ -
    26#include <Vc/Vc>
    │ │ │ │ +
    25namespace Dune
    │ │ │ │ +
    26{
    │ │ │ │
    27
    │ │ │ │ -
    28#endif // HAVE_VC
    │ │ │ │ -
    29
    │ │ │ │ -
    30#endif // DUNE_COMMON_VC_HH
    │ │ │ │ +
    28 template<typename T, std::size_t s>
    │ │ │ │ +
    29 class Pool;
    │ │ │ │ +
    30
    │ │ │ │ +
    31 template<typename T, std::size_t s>
    │ │ │ │ +
    32 class PoolAllocator;
    │ │ │ │ +
    33
    │ │ │ │ +
    34}
    │ │ │ │ +
    35
    │ │ │ │ +
    36namespace std
    │ │ │ │ +
    37{
    │ │ │ │ +
    38 /*
    │ │ │ │ +
    39 template<class T, std::size_t S>
    │ │ │ │ +
    40 inline ostream& operator<<(ostream& os, Dune::Pool<T,S>& pool)
    │ │ │ │ +
    41 {
    │ │ │ │ +
    42 os<<"pool="<<&pool<<" allocated_="<<pool.allocated_;
    │ │ │ │ +
    43 return os;
    │ │ │ │ +
    44 }
    │ │ │ │ +
    45
    │ │ │ │ +
    46 template<class T, std::size_t S>
    │ │ │ │ +
    47 inline ostream& operator<<(ostream& os, Dune::PoolAllocator<T,S>& pool)
    │ │ │ │ +
    48 {
    │ │ │ │ +
    49 os<<pool.memoryPool_<<std::endl;
    │ │ │ │ +
    50 return os;
    │ │ │ │ +
    51 }
    │ │ │ │ +
    52 */
    │ │ │ │ +
    53}
    │ │ │ │ +
    54
    │ │ │ │ +
    55
    │ │ │ │ +
    56namespace Dune
    │ │ │ │ +
    57{
    │ │ │ │ +
    88 template<class T, std::size_t s>
    │ │ │ │ +
    │ │ │ │ +
    89 class Pool
    │ │ │ │ +
    90 {
    │ │ │ │ +
    91 // make the test function friend
    │ │ │ │ +
    92 friend struct ::testPoolMain<s,T>;
    │ │ │ │ +
    93
    │ │ │ │ +
    94 //friend std::ostream& std::operator<<<>(std::ostream&,Pool<T,s>&);
    │ │ │ │ +
    95 template< class, std::size_t > friend class PoolAllocator;
    │ │ │ │ +
    96
    │ │ │ │ +
    97 private:
    │ │ │ │ +
    98
    │ │ │ │ +
    100 struct Reference
    │ │ │ │ +
    101 {
    │ │ │ │ +
    102 Reference *next_;
    │ │ │ │ +
    103 };
    │ │ │ │ +
    104
    │ │ │ │ +
    105 public:
    │ │ │ │ +
    106
    │ │ │ │ +
    108 typedef T MemberType;
    │ │ │ │ +
    109
    │ │ │ │ +
    113 constexpr static int unionSize = (sizeof(MemberType) < sizeof(Reference)) ?
    │ │ │ │ +
    114 sizeof(Reference) : sizeof(MemberType);
    │ │ │ │ +
    115
    │ │ │ │ +
    120 constexpr static int size = (sizeof(MemberType) <= s && sizeof(Reference) <= s) ?
    │ │ │ │ +
    121 s : unionSize;
    │ │ │ │ +
    122
    │ │ │ │ +
    127 constexpr static int alignment = std::lcm(alignof(MemberType), alignof(Reference));
    │ │ │ │ +
    128
    │ │ │ │ +
    135 constexpr static int alignedSize = (unionSize % alignment == 0) ?
    │ │ │ │ +
    136 unionSize :
    │ │ │ │ +
    137 ((unionSize / alignment + 1) * alignment);
    │ │ │ │ +
    138
    │ │ │ │ +
    144 constexpr static int chunkSize = (size % alignment == 0) ?
    │ │ │ │ +
    145 size : ((size / alignment + 1)* alignment);
    │ │ │ │ +
    146
    │ │ │ │ +
    150 constexpr static int elements = (chunkSize / alignedSize);
    │ │ │ │ +
    151
    │ │ │ │ +
    152 private:
    │ │ │ │ +
    154 struct Chunk
    │ │ │ │ +
    155 {
    │ │ │ │ +
    156
    │ │ │ │ +
    157 //friend int testPool<s,T>();
    │ │ │ │ +
    158
    │ │ │ │ +
    160 alignas(alignment) char chunk_[chunkSize];
    │ │ │ │ +
    161
    │ │ │ │ +
    163 Chunk *next_;
    │ │ │ │ +
    164 };
    │ │ │ │ +
    165
    │ │ │ │ +
    166 public:
    │ │ │ │ +
    │ │ │ │ +
    168 inline Pool();
    │ │ │ │ +
    │ │ │ │ +
    170 inline ~Pool();
    │ │ │ │ +
    │ │ │ │ +
    175 inline void* allocate();
    │ │ │ │ +
    │ │ │ │ +
    180 inline void free(void* o);
    │ │ │ │ +
    181
    │ │ │ │ +
    │ │ │ │ +
    185 inline void print(std::ostream& os);
    │ │ │ │ +
    186
    │ │ │ │ +
    187 private:
    │ │ │ │ +
    188
    │ │ │ │ +
    189 // Prevent Copying!
    │ │ │ │ +
    190 Pool(const Pool<MemberType,s>&);
    │ │ │ │ +
    191
    │ │ │ │ +
    192 void operator=(const Pool<MemberType,s>& pool) const;
    │ │ │ │ +
    194 inline void grow();
    │ │ │ │ +
    196 Reference *head_;
    │ │ │ │ +
    198 Chunk *chunks_;
    │ │ │ │ +
    199 /* @brief The number of currently allocated elements. */
    │ │ │ │ +
    200 //size_t allocated_;
    │ │ │ │ +
    201
    │ │ │ │ +
    202 };
    │ │ │ │ +
    203
    │ │ │ │ +
    221 template<class T, std::size_t s>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    223 {
    │ │ │ │ +
    224 //friend std::ostream& std::operator<<<>(std::ostream&,PoolAllocator<T,s>&);
    │ │ │ │ +
    225
    │ │ │ │ +
    226 public:
    │ │ │ │ +
    230 typedef T value_type;
    │ │ │ │ +
    231
    │ │ │ │ +
    236 constexpr static int size = s * sizeof(value_type);
    │ │ │ │ +
    237
    │ │ │ │ +
    241 typedef T* pointer;
    │ │ │ │ +
    242
    │ │ │ │ +
    246 typedef const T* const_pointer;
    │ │ │ │ +
    247
    │ │ │ │ +
    251 typedef T& reference;
    │ │ │ │ +
    252
    │ │ │ │ +
    256 typedef const T& const_reference;
    │ │ │ │ +
    257
    │ │ │ │ +
    261 typedef std::size_t size_type;
    │ │ │ │ +
    262
    │ │ │ │ +
    266 typedef std::ptrdiff_t difference_type;
    │ │ │ │ +
    267
    │ │ │ │ +
    271 inline PoolAllocator();
    │ │ │ │ +
    272
    │ │ │ │ +
    276 template<typename U, std::size_t u>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    278 {
    │ │ │ │ +
    279 // we allow copying but never copy the pool
    │ │ │ │ +
    280 // to have a clear ownership of allocated pointers.
    │ │ │ │ +
    281 }
    │ │ │ │ +
    │ │ │ │ +
    282
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    285 {
    │ │ │ │ +
    286 // we allow copying but never copy the pool
    │ │ │ │ +
    287 // to have a clear ownership of allocated pointers.
    │ │ │ │ +
    288 // For this behaviour we have to implement
    │ │ │ │ +
    289 // the copy constructor, because the default
    │ │ │ │ +
    290 // one would copy the pool and deallocation
    │ │ │ │ +
    291 // of it would break.
    │ │ │ │ +
    292 }
    │ │ │ │ +
    │ │ │ │ +
    299 inline pointer allocate(std::size_t n, const_pointer hint=0);
    │ │ │ │ +
    300
    │ │ │ │ +
    308 inline void deallocate(pointer p, std::size_t n);
    │ │ │ │ +
    309
    │ │ │ │ +
    315 inline void construct(pointer p, const_reference value);
    │ │ │ │ +
    316
    │ │ │ │ +
    321 inline void destroy(pointer p);
    │ │ │ │ +
    322
    │ │ │ │ +
    326 inline pointer address(reference x) const { return &x; }
    │ │ │ │ +
    327
    │ │ │ │ +
    328
    │ │ │ │ +
    332 inline const_pointer address(const_reference x) const { return &x; }
    │ │ │ │ +
    333
    │ │ │ │ +
    337 inline int max_size() const noexcept { return 1; }
    │ │ │ │ +
    338
    │ │ │ │ +
    342 template<class U>
    │ │ │ │ +
    │ │ │ │ +
    343 struct rebind
    │ │ │ │ +
    344 {
    │ │ │ │ + │ │ │ │ +
    346 };
    │ │ │ │ +
    │ │ │ │ +
    347
    │ │ │ │ + │ │ │ │ +
    350
    │ │ │ │ +
    351 private:
    │ │ │ │ +
    355 PoolType memoryPool_;
    │ │ │ │ +
    356 };
    │ │ │ │ +
    │ │ │ │ +
    357
    │ │ │ │ +
    358 // specialization for void
    │ │ │ │ +
    359 template <std::size_t s>
    │ │ │ │ +
    │ │ │ │ +
    360 class PoolAllocator<void,s>
    │ │ │ │ +
    361 {
    │ │ │ │ +
    362 public:
    │ │ │ │ +
    363 typedef void* pointer;
    │ │ │ │ +
    364 typedef const void* const_pointer;
    │ │ │ │ +
    365 // reference to void members are impossible.
    │ │ │ │ +
    366 typedef void value_type;
    │ │ │ │ +
    │ │ │ │ +
    367 template <class U> struct rebind
    │ │ │ │ +
    368 {
    │ │ │ │ + │ │ │ │ +
    370 };
    │ │ │ │ +
    │ │ │ │ +
    371 };
    │ │ │ │ +
    │ │ │ │ +
    372
    │ │ │ │ +
    373
    │ │ │ │ +
    374 template<typename T1, std::size_t t1, typename T2, std::size_t t2>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    376 {
    │ │ │ │ +
    377 return false;
    │ │ │ │ +
    378 }
    │ │ │ │ +
    │ │ │ │ +
    379
    │ │ │ │ +
    380
    │ │ │ │ +
    381 template<typename T1, std::size_t t1, typename T2, std::size_t t2>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    383 {
    │ │ │ │ +
    384 return true;
    │ │ │ │ +
    385 }
    │ │ │ │ +
    │ │ │ │ +
    386
    │ │ │ │ +
    387 template<typename T, std::size_t t1, std::size_t t2>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    389 {
    │ │ │ │ +
    390 return &p1==&p2;
    │ │ │ │ +
    391 }
    │ │ │ │ +
    │ │ │ │ +
    392
    │ │ │ │ +
    393
    │ │ │ │ +
    394 template<typename T, std::size_t t1, std::size_t t2>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    396 {
    │ │ │ │ +
    397 return &p1 != &p2;
    │ │ │ │ +
    398 }
    │ │ │ │ +
    │ │ │ │ +
    399
    │ │ │ │ +
    400 template<typename T, std::size_t t1, std::size_t t2>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    402 {
    │ │ │ │ +
    403 return false;
    │ │ │ │ +
    404 }
    │ │ │ │ +
    │ │ │ │ +
    405
    │ │ │ │ +
    406
    │ │ │ │ +
    407 template<typename T, std::size_t t1, std::size_t t2>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    409 {
    │ │ │ │ +
    410 return true;
    │ │ │ │ +
    411 }
    │ │ │ │ +
    │ │ │ │ +
    412
    │ │ │ │ +
    413 template<std::size_t t1, std::size_t t2>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    415 {
    │ │ │ │ +
    416 return &p1==&p2;
    │ │ │ │ +
    417 }
    │ │ │ │ +
    │ │ │ │ +
    418
    │ │ │ │ +
    419 template<std::size_t t1, std::size_t t2>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    421 {
    │ │ │ │ +
    422 return &p1!=&p2;
    │ │ │ │ +
    423 }
    │ │ │ │ +
    │ │ │ │ +
    424
    │ │ │ │ +
    425 template<class T, std::size_t S>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    427 : head_(0), chunks_(0) //, allocated_(0)
    │ │ │ │ +
    428 {
    │ │ │ │ +
    429 static_assert(sizeof(T)<=unionSize, "Library Error: type T is too big");
    │ │ │ │ +
    430 static_assert(sizeof(Reference)<=unionSize, "Library Error: type of reference is too big");
    │ │ │ │ +
    431 static_assert(unionSize<=alignedSize, "Library Error: alignedSize too small");
    │ │ │ │ +
    432 static_assert(sizeof(T)<=chunkSize, "Library Error: chunkSize must be able to hold at least one value");
    │ │ │ │ +
    433 static_assert(sizeof(Reference)<=chunkSize, "Library Error: chunkSize must be able to hold at least one reference");
    │ │ │ │ +
    434 static_assert(chunkSize % alignment == 0, "Library Error: compiler cannot calculate!");
    │ │ │ │ +
    435 static_assert(elements>=1, "Library Error: we need to hold at least one element!");
    │ │ │ │ +
    436 static_assert(elements*alignedSize<=chunkSize, "Library Error: aligned elements must fit into chuck!");
    │ │ │ │ +
    437 }
    │ │ │ │ +
    │ │ │ │ +
    438
    │ │ │ │ +
    439 template<class T, std::size_t S>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    441 {
    │ │ │ │ +
    442 /*
    │ │ │ │ +
    443 if(allocated_!=0)
    │ │ │ │ +
    444 std::cerr<<"There are still "<<allocated_<<" allocated elements by the Pool<"<<typeid(T).name()<<","<<S<<"> "
    │ │ │ │ +
    445 <<static_cast<void*>(this)<<"! This is a memory leak and might result in segfaults"
    │ │ │ │ +
    446 <<std::endl;
    │ │ │ │ +
    447 */
    │ │ │ │ +
    448 // delete the allocated chunks.
    │ │ │ │ +
    449 Chunk *current=chunks_;
    │ │ │ │ +
    450
    │ │ │ │ +
    451 while(current!=0)
    │ │ │ │ +
    452 {
    │ │ │ │ +
    453 Chunk *tmp = current;
    │ │ │ │ +
    454 current = current->next_;
    │ │ │ │ +
    455 delete tmp;
    │ │ │ │ +
    456 }
    │ │ │ │ +
    457 }
    │ │ │ │ +
    │ │ │ │ +
    458
    │ │ │ │ +
    459 template<class T, std::size_t S>
    │ │ │ │ +
    │ │ │ │ +
    460 inline void Pool<T,S>::print(std::ostream& os)
    │ │ │ │ +
    461 {
    │ │ │ │ +
    462 Chunk* current=chunks_;
    │ │ │ │ +
    463 while(current) {
    │ │ │ │ +
    464 os<<current<<" ";
    │ │ │ │ +
    465 current=current->next_;
    │ │ │ │ +
    466 }
    │ │ │ │ +
    467 os<<current<<" ";
    │ │ │ │ +
    468 }
    │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ +
    469
    │ │ │ │ +
    470 template<class T, std::size_t S>
    │ │ │ │ +
    471 inline void Pool<T,S>::grow()
    │ │ │ │ +
    472 {
    │ │ │ │ +
    473 Chunk *newChunk = new Chunk;
    │ │ │ │ +
    474 newChunk->next_ = chunks_;
    │ │ │ │ +
    475 chunks_ = newChunk;
    │ │ │ │ +
    476
    │ │ │ │ +
    477 char* start = chunks_->chunk_;
    │ │ │ │ +
    478 char* last = &start[elements*alignedSize];
    │ │ │ │ +
    479 Reference* ref = new (start) (Reference);
    │ │ │ │ +
    480
    │ │ │ │ +
    481 // grow is only called if head==0,
    │ │ │ │ +
    482 assert(!head_);
    │ │ │ │ +
    483
    │ │ │ │ +
    484 head_ = ref;
    │ │ │ │ +
    485
    │ │ │ │ +
    486 for(char* element=start+alignedSize; element<last; element=element+alignedSize) {
    │ │ │ │ +
    487 Reference* next = new (element) (Reference);
    │ │ │ │ +
    488 ref->next_ = next;
    │ │ │ │ +
    489 ref = next;
    │ │ │ │ +
    490 }
    │ │ │ │ +
    491 ref->next_=0;
    │ │ │ │ +
    492 }
    │ │ │ │ +
    493
    │ │ │ │ +
    494 template<class T, std::size_t S>
    │ │ │ │ +
    │ │ │ │ +
    495 inline void Pool<T,S>::free(void* b)
    │ │ │ │ +
    496 {
    │ │ │ │ +
    497 if(b) {
    │ │ │ │ +
    498#ifndef NDEBUG
    │ │ │ │ +
    499 Chunk* current=chunks_;
    │ │ │ │ +
    500 while(current) {
    │ │ │ │ +
    501 if(static_cast<void*>(current->chunk_)<=b &&
    │ │ │ │ +
    502 static_cast<void*>(current->chunk_+chunkSize)>b)
    │ │ │ │ +
    503 break;
    │ │ │ │ +
    504 current=current->next_;
    │ │ │ │ +
    505 }
    │ │ │ │ +
    506 if(!current)
    │ │ │ │ +
    507 throw std::bad_alloc();
    │ │ │ │ +
    508#endif
    │ │ │ │ +
    509 Reference* freed = static_cast<Reference*>(b);
    │ │ │ │ +
    510 freed->next_ = head_;
    │ │ │ │ +
    511 head_ = freed;
    │ │ │ │ +
    512 //--allocated_;
    │ │ │ │ +
    513 }
    │ │ │ │ +
    514 else
    │ │ │ │ +
    515 {
    │ │ │ │ +
    516 std::cerr<< "Tried to free null pointer! "<<b<<std::endl;
    │ │ │ │ +
    517 throw std::bad_alloc();
    │ │ │ │ +
    518 }
    │ │ │ │ +
    519 }
    │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ +
    520
    │ │ │ │ +
    521 template<class T, std::size_t S>
    │ │ │ │ +
    │ │ │ │ +
    522 inline void* Pool<T,S>::allocate()
    │ │ │ │ +
    523 {
    │ │ │ │ +
    524 if(!head_)
    │ │ │ │ +
    525 grow();
    │ │ │ │ +
    526
    │ │ │ │ +
    527 Reference* p = head_;
    │ │ │ │ +
    528 head_ = p->next_;
    │ │ │ │ +
    529 //++allocated_;
    │ │ │ │ +
    530 return p;
    │ │ │ │ +
    531 }
    │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ +
    532
    │ │ │ │ +
    533 template<class T, std::size_t s>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    535 { }
    │ │ │ │ +
    │ │ │ │ +
    536
    │ │ │ │ +
    537 template<class T, std::size_t s>
    │ │ │ │ +
    538 inline typename PoolAllocator<T,s>::pointer
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    540 {
    │ │ │ │ +
    541 if(n==1)
    │ │ │ │ +
    542 return static_cast<T*>(memoryPool_.allocate());
    │ │ │ │ +
    543 else
    │ │ │ │ +
    544 throw std::bad_alloc();
    │ │ │ │ +
    545 }
    │ │ │ │ +
    │ │ │ │ +
    546
    │ │ │ │ +
    547 template<class T, std::size_t s>
    │ │ │ │ +
    │ │ │ │ +
    548 inline void PoolAllocator<T,s>::deallocate(pointer p, std::size_t n)
    │ │ │ │ +
    549 {
    │ │ │ │ +
    550 for(size_t i=0; i<n; i++)
    │ │ │ │ +
    551 memoryPool_.free(p++);
    │ │ │ │ +
    552 }
    │ │ │ │ +
    │ │ │ │ +
    553
    │ │ │ │ +
    554 template<class T, std::size_t s>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    556 {
    │ │ │ │ +
    557 ::new (static_cast<void*>(p))T(value);
    │ │ │ │ +
    558 }
    │ │ │ │ +
    │ │ │ │ +
    559
    │ │ │ │ +
    560 template<class T, std::size_t s>
    │ │ │ │ +
    561 inline void PoolAllocator<T,s>::destroy(pointer p)
    │ │ │ │ +
    562 {
    │ │ │ │ +
    563 p->~T();
    │ │ │ │ +
    564 }
    │ │ │ │ +
    565
    │ │ │ │ +
    567}
    │ │ │ │ +
    568#endif
    │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ +
    void construct(pointer p, const_reference value)
    Construct an object.
    Definition poolallocator.hh:555
    │ │ │ │ +
    void free(void *o)
    Free an object.
    Definition poolallocator.hh:495
    │ │ │ │ +
    ~Pool()
    Destructor.
    Definition poolallocator.hh:440
    │ │ │ │ +
    void * allocate()
    Get a new or recycled object.
    Definition poolallocator.hh:522
    │ │ │ │ +
    void print(std::ostream &os)
    Print elements in pool for debugging.
    Definition poolallocator.hh:460
    │ │ │ │ +
    pointer allocate(std::size_t n, const_pointer hint=0)
    Allocates objects.
    Definition poolallocator.hh:539
    │ │ │ │ +
    Pool()
    Constructor.
    Definition poolallocator.hh:426
    │ │ │ │ +
    void deallocate(pointer p, std::size_t n)
    Free objects.
    Definition poolallocator.hh:548
    │ │ │ │ +
    void destroy(pointer p)
    Destroy an object without freeing memory.
    Definition poolallocator.hh:561
    │ │ │ │ +
    PoolAllocator()
    Constructor.
    Definition poolallocator.hh:534
    │ │ │ │ +
    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:237
    │ │ │ │ +
    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:259
    │ │ │ │ +
    STL namespace.
    │ │ │ │ +
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ +
    Get the 'const' version of a reference to a mutable object.
    Definition genericiterator.hh:87
    │ │ │ │ +
    A memory pool of objects.
    Definition poolallocator.hh:90
    │ │ │ │ +
    static constexpr int alignment
    The alignment that suits both the MemberType and the Reference (i.e. their least common multiple).
    Definition poolallocator.hh:127
    │ │ │ │ +
    static constexpr int alignedSize
    The aligned size of the type.
    Definition poolallocator.hh:135
    │ │ │ │ +
    static constexpr int chunkSize
    The size of each chunk memory chunk.
    Definition poolallocator.hh:144
    │ │ │ │ +
    static constexpr int size
    Size requirement. At least one object has to stored.
    Definition poolallocator.hh:120
    │ │ │ │ +
    static constexpr int unionSize
    The size of a union of Reference and MemberType.
    Definition poolallocator.hh:113
    │ │ │ │ +
    T MemberType
    The type of object we allocate memory for.
    Definition poolallocator.hh:108
    │ │ │ │ +
    static constexpr int elements
    The number of element each chunk can hold.
    Definition poolallocator.hh:150
    │ │ │ │ +
    An allocator managing a pool of objects for reuse.
    Definition poolallocator.hh:223
    │ │ │ │ +
    Pool< T, size > PoolType
    The type of the memory pool we use.
    Definition poolallocator.hh:349
    │ │ │ │ +
    const_pointer address(const_reference x) const
    Convert a reference to a pointer.
    Definition poolallocator.hh:332
    │ │ │ │ +
    const T & const_reference
    The constant reference type.
    Definition poolallocator.hh:256
    │ │ │ │ +
    std::size_t size_type
    The size type.
    Definition poolallocator.hh:261
    │ │ │ │ +
    T value_type
    Type of the values we construct and allocate.
    Definition poolallocator.hh:230
    │ │ │ │ +
    T & reference
    The reference type.
    Definition poolallocator.hh:251
    │ │ │ │ +
    PoolAllocator(const PoolAllocator &)
    Copy constructor that does not copy the memory pool.
    Definition poolallocator.hh:284
    │ │ │ │ +
    const T * const_pointer
    The constant pointer type.
    Definition poolallocator.hh:246
    │ │ │ │ +
    pointer address(reference x) const
    Convert a reference to a pointer.
    Definition poolallocator.hh:326
    │ │ │ │ +
    T * pointer
    The pointer type.
    Definition poolallocator.hh:241
    │ │ │ │ +
    PoolAllocator(const PoolAllocator< U, u > &)
    Copy Constructor that does not copy the memory pool.
    Definition poolallocator.hh:277
    │ │ │ │ +
    std::ptrdiff_t difference_type
    The difference_type.
    Definition poolallocator.hh:266
    │ │ │ │ +
    int max_size() const noexcept
    Not correctly implemented, yet!
    Definition poolallocator.hh:337
    │ │ │ │ +
    static constexpr int size
    The number of objects to fit into one memory chunk allocated.
    Definition poolallocator.hh:236
    │ │ │ │ +
    Rebind the allocator to another type.
    Definition poolallocator.hh:344
    │ │ │ │ +
    PoolAllocator< U, s > other
    Definition poolallocator.hh:345
    │ │ │ │ +
    void value_type
    Definition poolallocator.hh:366
    │ │ │ │ +
    void * pointer
    Definition poolallocator.hh:363
    │ │ │ │ +
    const void * const_pointer
    Definition poolallocator.hh:364
    │ │ │ │ +
    PoolAllocator< U, s > other
    Definition poolallocator.hh:369
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,34 +7,599 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -vc.hh │ │ │ │ │ +poolallocator.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ - 1// SPDX-FileCopyrightInfo: Copyright (C) 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 (C) 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 │ │ │ │ │ + 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ + 5#ifndef DUNE_COMMON_POOLALLOCATOR_HH │ │ │ │ │ + 6#define DUNE_COMMON_POOLALLOCATOR_HH │ │ │ │ │ + 7 │ │ │ │ │ + 12#include │ │ │ │ │ + 13#include │ │ │ │ │ + 14#include │ │ │ │ │ + 15#include │ │ │ │ │ + 16#include │ │ │ │ │ + 17 │ │ │ │ │ + 18#ifndef DOXYGEN │ │ │ │ │ + 19// forward declarations. │ │ │ │ │ + 20// we need to know the test function to declare it friend │ │ │ │ │ + 21template │ │ │ │ │ + 22struct testPoolMain; │ │ │ │ │ 23#endif │ │ │ │ │ 24 │ │ │ │ │ - 25// include the rest of Vc │ │ │ │ │ - 26#include │ │ │ │ │ + 25namespace Dune │ │ │ │ │ + 26{ │ │ │ │ │ 27 │ │ │ │ │ - 28#endif // HAVE_VC │ │ │ │ │ - 29 │ │ │ │ │ - 30#endif // DUNE_COMMON_VC_HH │ │ │ │ │ + 28 template │ │ │ │ │ + 29 class Pool; │ │ │ │ │ + 30 │ │ │ │ │ + 31 template │ │ │ │ │ + 32 class PoolAllocator; │ │ │ │ │ + 33 │ │ │ │ │ + 34} │ │ │ │ │ + 35 │ │ │ │ │ + 36namespace std │ │ │ │ │ + 37{ │ │ │ │ │ + 38 /* │ │ │ │ │ + 39 template │ │ │ │ │ + 40 inline ostream& operator<<(ostream& os, Dune::Pool& pool) │ │ │ │ │ + 41 { │ │ │ │ │ + 42 os<<"pool="<<&pool<<" allocated_="< │ │ │ │ │ + 47 inline ostream& operator<<(ostream& os, Dune::PoolAllocator& pool) │ │ │ │ │ + 48 { │ │ │ │ │ + 49 os< │ │ │ │ │ +89 class Pool │ │ │ │ │ + 90 { │ │ │ │ │ + 91 // make the test function friend │ │ │ │ │ + 92 friend struct ::testPoolMain; │ │ │ │ │ + 93 │ │ │ │ │ + 94 //friend std::ostream& std::operator<<<>(std::ostream&,Pool&); │ │ │ │ │ +95 template< class, std::size_t > friend class PoolAllocator; │ │ │ │ │ + 96 │ │ │ │ │ + 97 private: │ │ │ │ │ + 98 │ │ │ │ │ + 100 struct Reference │ │ │ │ │ + 101 { │ │ │ │ │ + 102 Reference *next_; │ │ │ │ │ + 103 }; │ │ │ │ │ + 104 │ │ │ │ │ + 105 public: │ │ │ │ │ + 106 │ │ │ │ │ +108 typedef T MemberType; │ │ │ │ │ + 109 │ │ │ │ │ +113 constexpr static int unionSize = (sizeof(MemberType) < sizeof(Reference)) ? │ │ │ │ │ + 114 sizeof(Reference) : sizeof(MemberType); │ │ │ │ │ + 115 │ │ │ │ │ +120 constexpr static int size = (sizeof(MemberType) <= s && sizeof(Reference) │ │ │ │ │ +<= s) ? │ │ │ │ │ + 121 s : unionSize; │ │ │ │ │ + 122 │ │ │ │ │ +127 constexpr static int alignment = std::lcm(alignof(MemberType), alignof │ │ │ │ │ +(Reference)); │ │ │ │ │ + 128 │ │ │ │ │ +135 constexpr static int alignedSize = (unionSize % alignment == 0) ? │ │ │ │ │ + 136 unionSize : │ │ │ │ │ + 137 ((unionSize / alignment + 1) * alignment); │ │ │ │ │ + 138 │ │ │ │ │ +144 constexpr static int chunkSize = (size % alignment == 0) ? │ │ │ │ │ + 145 size : ((size / alignment + 1)* alignment); │ │ │ │ │ + 146 │ │ │ │ │ +150 constexpr static int elements = (chunkSize / alignedSize); │ │ │ │ │ + 151 │ │ │ │ │ + 152 private: │ │ │ │ │ + 154 struct Chunk │ │ │ │ │ + 155 { │ │ │ │ │ + 156 │ │ │ │ │ + 157 //friend int testPool(); │ │ │ │ │ + 158 │ │ │ │ │ + 160 alignas(alignment) char chunk_[chunkSize]; │ │ │ │ │ + 161 │ │ │ │ │ + 163 Chunk *next_; │ │ │ │ │ + 164 }; │ │ │ │ │ + 165 │ │ │ │ │ + 166 public: │ │ │ │ │ +168 inline Pool(); │ │ │ │ │ +170 inline ~Pool(); │ │ │ │ │ +175 inline void* allocate(); │ │ │ │ │ +180 inline void free(void* o); │ │ │ │ │ + 181 │ │ │ │ │ +185 inline void print(std::ostream& os); │ │ │ │ │ + 186 │ │ │ │ │ + 187 private: │ │ │ │ │ + 188 │ │ │ │ │ + 189 // Prevent Copying! │ │ │ │ │ + 190 Pool(const Pool&); │ │ │ │ │ + 191 │ │ │ │ │ + 192 void operator=(const Pool& pool) const; │ │ │ │ │ + 194 inline void grow(); │ │ │ │ │ + 196 Reference *head_; │ │ │ │ │ + 198 Chunk *chunks_; │ │ │ │ │ + 199 /* @brief The number of currently allocated elements. */ │ │ │ │ │ + 200 //size_t allocated_; │ │ │ │ │ + 201 │ │ │ │ │ + 202 }; │ │ │ │ │ + 203 │ │ │ │ │ + 221 template │ │ │ │ │ +222 class PoolAllocator │ │ │ │ │ + 223 { │ │ │ │ │ + 224 //friend std::ostream& std::operator<<<>(std:: │ │ │ │ │ +ostream&,PoolAllocator&); │ │ │ │ │ + 225 │ │ │ │ │ + 226 public: │ │ │ │ │ +230 typedef T value_type; │ │ │ │ │ + 231 │ │ │ │ │ +236 constexpr static int size = s * sizeof(value_type); │ │ │ │ │ + 237 │ │ │ │ │ +241 typedef T* pointer; │ │ │ │ │ + 242 │ │ │ │ │ +246 typedef const T* const_pointer; │ │ │ │ │ + 247 │ │ │ │ │ +251 typedef T& reference; │ │ │ │ │ + 252 │ │ │ │ │ +256 typedef const T& const_reference; │ │ │ │ │ + 257 │ │ │ │ │ +261 typedef std::size_t size_type; │ │ │ │ │ + 262 │ │ │ │ │ +266 typedef std::ptrdiff_t difference_type; │ │ │ │ │ + 267 │ │ │ │ │ + 271 inline PoolAllocator(); │ │ │ │ │ + 272 │ │ │ │ │ + 276 template │ │ │ │ │ +277 inline PoolAllocator(const PoolAllocator&) │ │ │ │ │ + 278 { │ │ │ │ │ + 279 // we allow copying but never copy the pool │ │ │ │ │ + 280 // to have a clear ownership of allocated pointers. │ │ │ │ │ + 281 } │ │ │ │ │ + 282 │ │ │ │ │ +284 PoolAllocator(const PoolAllocator&) │ │ │ │ │ + 285 { │ │ │ │ │ + 286 // we allow copying but never copy the pool │ │ │ │ │ + 287 // to have a clear ownership of allocated pointers. │ │ │ │ │ + 288 // For this behaviour we have to implement │ │ │ │ │ + 289 // the copy constructor, because the default │ │ │ │ │ + 290 // one would copy the pool and deallocation │ │ │ │ │ + 291 // of it would break. │ │ │ │ │ + 292 } │ │ │ │ │ + 299 inline pointer allocate(std::size_t n, const_pointer hint=0); │ │ │ │ │ + 300 │ │ │ │ │ + 308 inline void deallocate(pointer p, std::size_t n); │ │ │ │ │ + 309 │ │ │ │ │ + 315 inline void construct(pointer p, const_reference value); │ │ │ │ │ + 316 │ │ │ │ │ + 321 inline void destroy(pointer p); │ │ │ │ │ + 322 │ │ │ │ │ +326 inline pointer address(reference x) const { return &x; } │ │ │ │ │ + 327 │ │ │ │ │ + 328 │ │ │ │ │ +332 inline const_pointer address(const_reference x) const { return &x; } │ │ │ │ │ + 333 │ │ │ │ │ +337 inline int max_size() const noexcept { return 1; } │ │ │ │ │ + 338 │ │ │ │ │ + 342 template │ │ │ │ │ +343 struct rebind │ │ │ │ │ + 344 { │ │ │ │ │ +345 typedef PoolAllocator other; │ │ │ │ │ + 346 }; │ │ │ │ │ + 347 │ │ │ │ │ +349 typedef Pool PoolType; │ │ │ │ │ + 350 │ │ │ │ │ + 351 private: │ │ │ │ │ + 355 PoolType memoryPool_; │ │ │ │ │ + 356 }; │ │ │ │ │ + 357 │ │ │ │ │ + 358 // specialization for void │ │ │ │ │ + 359 template │ │ │ │ │ +360 class PoolAllocator │ │ │ │ │ + 361 { │ │ │ │ │ + 362 public: │ │ │ │ │ +363 typedef void* pointer; │ │ │ │ │ +364 typedef const void* const_pointer; │ │ │ │ │ + 365 // reference to void members are impossible. │ │ │ │ │ +366 typedef void value_type; │ │ │ │ │ +367 template struct rebind │ │ │ │ │ + 368 { │ │ │ │ │ +369 typedef PoolAllocator other; │ │ │ │ │ + 370 }; │ │ │ │ │ + 371 }; │ │ │ │ │ + 372 │ │ │ │ │ + 373 │ │ │ │ │ + 374 template │ │ │ │ │ +375 bool operator==(const PoolAllocator&, const PoolAllocator&) │ │ │ │ │ + 376 { │ │ │ │ │ + 377 return false; │ │ │ │ │ + 378 } │ │ │ │ │ + 379 │ │ │ │ │ + 380 │ │ │ │ │ + 381 template │ │ │ │ │ +382 bool operator!=(const PoolAllocator&, const PoolAllocator&) │ │ │ │ │ + 383 { │ │ │ │ │ + 384 return true; │ │ │ │ │ + 385 } │ │ │ │ │ + 386 │ │ │ │ │ + 387 template │ │ │ │ │ +388 bool operator==(const PoolAllocator& p1, const PoolAllocator& │ │ │ │ │ +p2) │ │ │ │ │ + 389 { │ │ │ │ │ + 390 return &p1==&p2; │ │ │ │ │ + 391 } │ │ │ │ │ + 392 │ │ │ │ │ + 393 │ │ │ │ │ + 394 template │ │ │ │ │ +395 bool operator!=(const PoolAllocator& p1, const PoolAllocator& │ │ │ │ │ +p2) │ │ │ │ │ + 396 { │ │ │ │ │ + 397 return &p1 != &p2; │ │ │ │ │ + 398 } │ │ │ │ │ + 399 │ │ │ │ │ + 400 template │ │ │ │ │ +401 bool operator==(const PoolAllocator&, const PoolAllocator&) │ │ │ │ │ + 402 { │ │ │ │ │ + 403 return false; │ │ │ │ │ + 404 } │ │ │ │ │ + 405 │ │ │ │ │ + 406 │ │ │ │ │ + 407 template │ │ │ │ │ +408 bool operator!=(const PoolAllocator&, const PoolAllocator&) │ │ │ │ │ + 409 { │ │ │ │ │ + 410 return true; │ │ │ │ │ + 411 } │ │ │ │ │ + 412 │ │ │ │ │ + 413 template │ │ │ │ │ +414 bool operator==(const PoolAllocator& p1, const │ │ │ │ │ +PoolAllocator& p2) │ │ │ │ │ + 415 { │ │ │ │ │ + 416 return &p1==&p2; │ │ │ │ │ + 417 } │ │ │ │ │ + 418 │ │ │ │ │ + 419 template │ │ │ │ │ +420 bool operator!=(const PoolAllocator& p1, const │ │ │ │ │ +PoolAllocator& p2) │ │ │ │ │ + 421 { │ │ │ │ │ + 422 return &p1!=&p2; │ │ │ │ │ + 423 } │ │ │ │ │ + 424 │ │ │ │ │ + 425 template │ │ │ │ │ +426 inline Pool::Pool() │ │ │ │ │ + 427 : head_(0), chunks_(0) //, allocated_(0) │ │ │ │ │ + 428 { │ │ │ │ │ + 429 static_assert(sizeof(T)<=unionSize, "Library Error: type T is too big"); │ │ │ │ │ + 430 static_assert(sizeof(Reference)<=unionSize, "Library Error: type of │ │ │ │ │ +reference is too big"); │ │ │ │ │ + 431 static_assert(unionSize<=alignedSize, "Library Error: alignedSize too │ │ │ │ │ +small"); │ │ │ │ │ + 432 static_assert(sizeof(T)<=chunkSize, "Library Error: chunkSize must be able │ │ │ │ │ +to hold at least one value"); │ │ │ │ │ + 433 static_assert(sizeof(Reference)<=chunkSize, "Library Error: chunkSize must │ │ │ │ │ +be able to hold at least one reference"); │ │ │ │ │ + 434 static_assert(chunkSize % alignment == 0, "Library Error: compiler cannot │ │ │ │ │ +calculate!"); │ │ │ │ │ + 435 static_assert(elements>=1, "Library Error: we need to hold at least one │ │ │ │ │ +element!"); │ │ │ │ │ + 436 static_assert(elements*alignedSize<=chunkSize, "Library Error: aligned │ │ │ │ │ +elements must fit into chuck!"); │ │ │ │ │ + 437 } │ │ │ │ │ + 438 │ │ │ │ │ + 439 template │ │ │ │ │ +440 inline Pool::~Pool() │ │ │ │ │ + 441 { │ │ │ │ │ + 442 /* │ │ │ │ │ + 443 if(allocated_!=0) │ │ │ │ │ + 444 std::cerr<<"There are still "< " │ │ │ │ │ + 445 <(this)<<"! This is a memory leak and might result in │ │ │ │ │ +segfaults" │ │ │ │ │ + 446 <next_; │ │ │ │ │ + 455 delete tmp; │ │ │ │ │ + 456 } │ │ │ │ │ + 457 } │ │ │ │ │ + 458 │ │ │ │ │ + 459 template │ │ │ │ │ +460 inline void Pool::print(std::ostream& os) │ │ │ │ │ + 461 { │ │ │ │ │ + 462 Chunk* current=chunks_; │ │ │ │ │ + 463 while(current) { │ │ │ │ │ + 464 os<next_; │ │ │ │ │ + 466 } │ │ │ │ │ + 467 os< │ │ │ │ │ + 471 inline void Pool::grow() │ │ │ │ │ + 472 { │ │ │ │ │ + 473 Chunk *newChunk = new Chunk; │ │ │ │ │ + 474 newChunk->next_ = chunks_; │ │ │ │ │ + 475 chunks_ = newChunk; │ │ │ │ │ + 476 │ │ │ │ │ + 477 char* start = chunks_->chunk_; │ │ │ │ │ + 478 char* last = &start[elements*alignedSize]; │ │ │ │ │ + 479 Reference* ref = new (start) (Reference); │ │ │ │ │ + 480 │ │ │ │ │ + 481 // grow is only called if head==0, │ │ │ │ │ + 482 assert(!head_); │ │ │ │ │ + 483 │ │ │ │ │ + 484 head_ = ref; │ │ │ │ │ + 485 │ │ │ │ │ + 486 for(char* element=start+alignedSize; elementnext_ = next; │ │ │ │ │ + 489 ref = next; │ │ │ │ │ + 490 } │ │ │ │ │ + 491 ref->next_=0; │ │ │ │ │ + 492 } │ │ │ │ │ + 493 │ │ │ │ │ + 494 template │ │ │ │ │ +495 inline void Pool::free(void* b) │ │ │ │ │ + 496 { │ │ │ │ │ + 497 if(b) { │ │ │ │ │ + 498#ifndef NDEBUG │ │ │ │ │ + 499 Chunk* current=chunks_; │ │ │ │ │ + 500 while(current) { │ │ │ │ │ + 501 if(static_cast(current->chunk_)<=b && │ │ │ │ │ + 502 static_cast(current->chunk_+chunkSize)>b) │ │ │ │ │ + 503 break; │ │ │ │ │ + 504 current=current->next_; │ │ │ │ │ + 505 } │ │ │ │ │ + 506 if(!current) │ │ │ │ │ + 507 throw std::bad_alloc(); │ │ │ │ │ + 508#endif │ │ │ │ │ + 509 Reference* freed = static_cast(b); │ │ │ │ │ + 510 freed->next_ = head_; │ │ │ │ │ + 511 head_ = freed; │ │ │ │ │ + 512 //--allocated_; │ │ │ │ │ + 513 } │ │ │ │ │ + 514 else │ │ │ │ │ + 515 { │ │ │ │ │ + 516 std::cerr<< "Tried to free null pointer! "< │ │ │ │ │ +522 inline void* Pool::allocate() │ │ │ │ │ + 523 { │ │ │ │ │ + 524 if(!head_) │ │ │ │ │ + 525 grow(); │ │ │ │ │ + 526 │ │ │ │ │ + 527 Reference* p = head_; │ │ │ │ │ + 528 head_ = p->next_; │ │ │ │ │ + 529 //++allocated_; │ │ │ │ │ + 530 return p; │ │ │ │ │ + 531 } │ │ │ │ │ + 532 │ │ │ │ │ + 533 template │ │ │ │ │ +534 inline PoolAllocator::PoolAllocator() │ │ │ │ │ + 535 { } │ │ │ │ │ + 536 │ │ │ │ │ + 537 template │ │ │ │ │ + 538 inline typename PoolAllocator::pointer │ │ │ │ │ +539 PoolAllocator::allocate(std::size_t n, const_pointer) │ │ │ │ │ + 540 { │ │ │ │ │ + 541 if(n==1) │ │ │ │ │ + 542 return static_cast(memoryPool_.allocate()); │ │ │ │ │ + 543 else │ │ │ │ │ + 544 throw std::bad_alloc(); │ │ │ │ │ + 545 } │ │ │ │ │ + 546 │ │ │ │ │ + 547 template │ │ │ │ │ +548 inline void PoolAllocator::deallocate(pointer p, std::size_t n) │ │ │ │ │ + 549 { │ │ │ │ │ + 550 for(size_t i=0; i │ │ │ │ │ +555 inline void PoolAllocator::construct(pointer p, const_reference value) │ │ │ │ │ + 556 { │ │ │ │ │ + 557 ::new (static_cast(p))T(value); │ │ │ │ │ + 558 } │ │ │ │ │ + 559 │ │ │ │ │ + 560 template │ │ │ │ │ +561 inline void PoolAllocator::destroy(pointer p) │ │ │ │ │ + 562 { │ │ │ │ │ + 563 p->~T(); │ │ │ │ │ + 564 } │ │ │ │ │ + 565 │ │ │ │ │ + 567} │ │ │ │ │ + 568#endif │ │ │ │ │ +Dune::PoolAllocator::construct │ │ │ │ │ +void construct(pointer p, const_reference value) │ │ │ │ │ +Construct an object. │ │ │ │ │ +Definition poolallocator.hh:555 │ │ │ │ │ +Dune::Pool::free │ │ │ │ │ +void free(void *o) │ │ │ │ │ +Free an object. │ │ │ │ │ +Definition poolallocator.hh:495 │ │ │ │ │ +Dune::Pool::~Pool │ │ │ │ │ +~Pool() │ │ │ │ │ +Destructor. │ │ │ │ │ +Definition poolallocator.hh:440 │ │ │ │ │ +Dune::Pool::allocate │ │ │ │ │ +void * allocate() │ │ │ │ │ +Get a new or recycled object. │ │ │ │ │ +Definition poolallocator.hh:522 │ │ │ │ │ +Dune::Pool::print │ │ │ │ │ +void print(std::ostream &os) │ │ │ │ │ +Print elements in pool for debugging. │ │ │ │ │ +Definition poolallocator.hh:460 │ │ │ │ │ +Dune::PoolAllocator::allocate │ │ │ │ │ +pointer allocate(std::size_t n, const_pointer hint=0) │ │ │ │ │ +Allocates objects. │ │ │ │ │ +Definition poolallocator.hh:539 │ │ │ │ │ +Dune::Pool::Pool │ │ │ │ │ +Pool() │ │ │ │ │ +Constructor. │ │ │ │ │ +Definition poolallocator.hh:426 │ │ │ │ │ +Dune::PoolAllocator::deallocate │ │ │ │ │ +void deallocate(pointer p, std::size_t n) │ │ │ │ │ +Free objects. │ │ │ │ │ +Definition poolallocator.hh:548 │ │ │ │ │ +Dune::PoolAllocator::destroy │ │ │ │ │ +void destroy(pointer p) │ │ │ │ │ +Destroy an object without freeing memory. │ │ │ │ │ +Definition poolallocator.hh:561 │ │ │ │ │ +Dune::PoolAllocator::PoolAllocator │ │ │ │ │ +PoolAllocator() │ │ │ │ │ +Constructor. │ │ │ │ │ +Definition poolallocator.hh:534 │ │ │ │ │ +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:237 │ │ │ │ │ +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:259 │ │ │ │ │ +std │ │ │ │ │ +STL namespace. │ │ │ │ │ +Dune │ │ │ │ │ +Dune namespace. │ │ │ │ │ +Definition alignedallocator.hh:13 │ │ │ │ │ +Dune::const_reference │ │ │ │ │ +Get the 'const' version of a reference to a mutable object. │ │ │ │ │ +Definition genericiterator.hh:87 │ │ │ │ │ +Dune::Pool │ │ │ │ │ +A memory pool of objects. │ │ │ │ │ +Definition poolallocator.hh:90 │ │ │ │ │ +Dune::Pool::alignment │ │ │ │ │ +static constexpr int alignment │ │ │ │ │ +The alignment that suits both the MemberType and the Reference (i.e. their │ │ │ │ │ +least common multiple). │ │ │ │ │ +Definition poolallocator.hh:127 │ │ │ │ │ +Dune::Pool::alignedSize │ │ │ │ │ +static constexpr int alignedSize │ │ │ │ │ +The aligned size of the type. │ │ │ │ │ +Definition poolallocator.hh:135 │ │ │ │ │ +Dune::Pool::chunkSize │ │ │ │ │ +static constexpr int chunkSize │ │ │ │ │ +The size of each chunk memory chunk. │ │ │ │ │ +Definition poolallocator.hh:144 │ │ │ │ │ +Dune::Pool::size │ │ │ │ │ +static constexpr int size │ │ │ │ │ +Size requirement. At least one object has to stored. │ │ │ │ │ +Definition poolallocator.hh:120 │ │ │ │ │ +Dune::Pool::unionSize │ │ │ │ │ +static constexpr int unionSize │ │ │ │ │ +The size of a union of Reference and MemberType. │ │ │ │ │ +Definition poolallocator.hh:113 │ │ │ │ │ +Dune::Pool::MemberType │ │ │ │ │ +T MemberType │ │ │ │ │ +The type of object we allocate memory for. │ │ │ │ │ +Definition poolallocator.hh:108 │ │ │ │ │ +Dune::Pool::elements │ │ │ │ │ +static constexpr int elements │ │ │ │ │ +The number of element each chunk can hold. │ │ │ │ │ +Definition poolallocator.hh:150 │ │ │ │ │ +Dune::PoolAllocator │ │ │ │ │ +An allocator managing a pool of objects for reuse. │ │ │ │ │ +Definition poolallocator.hh:223 │ │ │ │ │ +Dune::PoolAllocator::PoolType │ │ │ │ │ +Pool< T, size > PoolType │ │ │ │ │ +The type of the memory pool we use. │ │ │ │ │ +Definition poolallocator.hh:349 │ │ │ │ │ +Dune::PoolAllocator::address │ │ │ │ │ +const_pointer address(const_reference x) const │ │ │ │ │ +Convert a reference to a pointer. │ │ │ │ │ +Definition poolallocator.hh:332 │ │ │ │ │ +Dune::PoolAllocator::const_reference │ │ │ │ │ +const T & const_reference │ │ │ │ │ +The constant reference type. │ │ │ │ │ +Definition poolallocator.hh:256 │ │ │ │ │ +Dune::PoolAllocator::size_type │ │ │ │ │ +std::size_t size_type │ │ │ │ │ +The size type. │ │ │ │ │ +Definition poolallocator.hh:261 │ │ │ │ │ +Dune::PoolAllocator::value_type │ │ │ │ │ +T value_type │ │ │ │ │ +Type of the values we construct and allocate. │ │ │ │ │ +Definition poolallocator.hh:230 │ │ │ │ │ +Dune::PoolAllocator::reference │ │ │ │ │ +T & reference │ │ │ │ │ +The reference type. │ │ │ │ │ +Definition poolallocator.hh:251 │ │ │ │ │ +Dune::PoolAllocator::PoolAllocator │ │ │ │ │ +PoolAllocator(const PoolAllocator &) │ │ │ │ │ +Copy constructor that does not copy the memory pool. │ │ │ │ │ +Definition poolallocator.hh:284 │ │ │ │ │ +Dune::PoolAllocator::const_pointer │ │ │ │ │ +const T * const_pointer │ │ │ │ │ +The constant pointer type. │ │ │ │ │ +Definition poolallocator.hh:246 │ │ │ │ │ +Dune::PoolAllocator::address │ │ │ │ │ +pointer address(reference x) const │ │ │ │ │ +Convert a reference to a pointer. │ │ │ │ │ +Definition poolallocator.hh:326 │ │ │ │ │ +Dune::PoolAllocator::pointer │ │ │ │ │ +T * pointer │ │ │ │ │ +The pointer type. │ │ │ │ │ +Definition poolallocator.hh:241 │ │ │ │ │ +Dune::PoolAllocator::PoolAllocator │ │ │ │ │ +PoolAllocator(const PoolAllocator< U, u > &) │ │ │ │ │ +Copy Constructor that does not copy the memory pool. │ │ │ │ │ +Definition poolallocator.hh:277 │ │ │ │ │ +Dune::PoolAllocator::difference_type │ │ │ │ │ +std::ptrdiff_t difference_type │ │ │ │ │ +The difference_type. │ │ │ │ │ +Definition poolallocator.hh:266 │ │ │ │ │ +Dune::PoolAllocator::max_size │ │ │ │ │ +int max_size() const noexcept │ │ │ │ │ +Not correctly implemented, yet! │ │ │ │ │ +Definition poolallocator.hh:337 │ │ │ │ │ +Dune::PoolAllocator::size │ │ │ │ │ +static constexpr int size │ │ │ │ │ +The number of objects to fit into one memory chunk allocated. │ │ │ │ │ +Definition poolallocator.hh:236 │ │ │ │ │ +Dune::PoolAllocator::rebind │ │ │ │ │ +Rebind the allocator to another type. │ │ │ │ │ +Definition poolallocator.hh:344 │ │ │ │ │ +Dune::PoolAllocator::rebind::other │ │ │ │ │ +PoolAllocator< U, s > other │ │ │ │ │ +Definition poolallocator.hh:345 │ │ │ │ │ +Dune::PoolAllocator<_void,_s_>::value_type │ │ │ │ │ +void value_type │ │ │ │ │ +Definition poolallocator.hh:366 │ │ │ │ │ +Dune::PoolAllocator<_void,_s_>::pointer │ │ │ │ │ +void * pointer │ │ │ │ │ +Definition poolallocator.hh:363 │ │ │ │ │ +Dune::PoolAllocator<_void,_s_>::const_pointer │ │ │ │ │ +const void * const_pointer │ │ │ │ │ +Definition poolallocator.hh:364 │ │ │ │ │ +Dune::PoolAllocator<_void,_s_>::rebind::other │ │ │ │ │ +PoolAllocator< U, s > other │ │ │ │ │ +Definition poolallocator.hh:369 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00170.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: loop.hh File Reference │ │ │ │ +dune-common: indices.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,681 +65,119 @@ │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -Classes | │ │ │ │ Namespaces | │ │ │ │ -Macros | │ │ │ │ -Functions
    │ │ │ │ -
    loop.hh File Reference
    │ │ │ │ +Typedefs | │ │ │ │ +Functions | │ │ │ │ +Variables
    │ │ │ │ +
    indices.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>
    │ │ │ │ +
    #include <cstddef>
    │ │ │ │ +#include <type_traits>
    │ │ │ │ +#include <utility>
    │ │ │ │ +#include <dune/common/keywords.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 > >
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

    │ │ │ │ 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
    namespace  Dune::Indices
     Namespace with predefined compile time indices for the range [0,19].
     
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

    │ │ │ │ -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)
     

    │ │ │ │ +Typedefs

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

    │ │ │ │ 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<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>...
     
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

    │ │ │ │ +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.
     
    │ │ │ │ -

    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

    │ │ │ │ - │ │ │ │ -
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
    #define DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN( expr,
     returnType 
    )
    │ │ │ │ -
    │ │ │ │ -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

    │ │ │ │ - │ │ │ │ -
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
    #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

    │ │ │ │ - │ │ │ │ -
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
    #define DUNE_SIMD_LOOP_PREFIX_OP( 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

    │ │ │ │ - │ │ │ │ -
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
    #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

    │ │ │ │ - │ │ │ │ -
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
    #define DUNE_SIMD_LOOP_UNARY_OP( 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 ;")
    │ │ │ │ -
    │ │ │ │ -
    │ │ │ │ -
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,491 +6,98 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * simd │ │ │ │ │ -Classes | Namespaces | Macros | Functions │ │ │ │ │ -loop.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Namespaces | Typedefs | Functions | Variables │ │ │ │ │ +indices.hh File Reference │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#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_>_> │ │ │ │ │ -  │ │ │ │ │ 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]. │ │ │ │ │ +  │ │ │ │ │ + Typedefs │ │ │ │ │ +template │ │ │ │ │ +using Dune::index_constant = std::integral_constant< std::size_t, i > │ │ │ │ │ +  An index constant with value i. │ │ │ │ │   │ │ │ │ │ -namespace  Dune::Simd::Overloads │ │ │ │ │ -  Namespace for the overloads and specializations that make up a SIMD │ │ │ │ │ - implementation. │ │ │ │ │ + Functions │ │ │ │ │ +template │ │ │ │ │ +decltype(auto) constexpr Dune::unpackIntegerSequence (F &&f, std:: │ │ │ │ │ + integer_sequence< I, i... > sequence) │ │ │ │ │ +  Unpack an std::integer_sequence to std:: │ │ │ │ │ + integral_constant... │ │ │ │ │   │ │ │ │ │ -namespace  Dune::MathOverloads │ │ │ │ │ -  namespace for customization of math functions with Dune-Semantics │ │ │ │ │ + Variables │ │ │ │ │ + constexpr index_constant< 0 > Dune::Indices::_0 = {} │ │ │ │ │ +  Compile time index with value 0. │ │ │ │ │   │ │ │ │ │ - Macros │ │ │ │ │ -#define DUNE_PRAGMA_OMP_SIMD │ │ │ │ │ + constexpr index_constant< 1 > Dune::Indices::_1 = {} │ │ │ │ │ +  Compile time index with value 1. │ │ │ │ │   │ │ │ │ │ -#define DUNE_SIMD_LOOP_PREFIX_OP(SYMBOL) │ │ │ │ │ + constexpr index_constant< 2 > Dune::Indices::_2 = {} │ │ │ │ │ +  Compile time index with value 2. │ │ │ │ │   │ │ │ │ │ -#define DUNE_SIMD_LOOP_UNARY_OP(SYMBOL) │ │ │ │ │ + constexpr index_constant< 3 > Dune::Indices::_3 = {} │ │ │ │ │ +  Compile time index with value 3. │ │ │ │ │   │ │ │ │ │ -#define DUNE_SIMD_LOOP_POSTFIX_OP(SYMBOL) │ │ │ │ │ + constexpr index_constant< 4 > Dune::Indices::_4 = {} │ │ │ │ │ +  Compile time index with value 4. │ │ │ │ │   │ │ │ │ │ -#define DUNE_SIMD_LOOP_ASSIGNMENT_OP(SYMBOL) │ │ │ │ │ + constexpr index_constant< 5 > Dune::Indices::_5 = {} │ │ │ │ │ +  Compile time index with value 5. │ │ │ │ │   │ │ │ │ │ -#define DUNE_SIMD_LOOP_BINARY_OP(SYMBOL) │ │ │ │ │ + constexpr index_constant< 6 > Dune::Indices::_6 = {} │ │ │ │ │ +  Compile time index with value 6. │ │ │ │ │   │ │ │ │ │ -#define DUNE_SIMD_LOOP_BITSHIFT_OP(SYMBOL) │ │ │ │ │ + constexpr index_constant< 7 > Dune::Indices::_7 = {} │ │ │ │ │ +  Compile time index with value 7. │ │ │ │ │   │ │ │ │ │ -#define DUNE_SIMD_LOOP_COMPARISON_OP(SYMBOL) │ │ │ │ │ + constexpr index_constant< 8 > Dune::Indices::_8 = {} │ │ │ │ │ +  Compile time index with value 8. │ │ │ │ │   │ │ │ │ │ -#define DUNE_SIMD_LOOP_BOOLEAN_OP(SYMBOL) │ │ │ │ │ + constexpr index_constant< 9 > Dune::Indices::_9 = {} │ │ │ │ │ +  Compile time index with value 9. │ │ │ │ │   │ │ │ │ │ -#define DUNE_SIMD_LOOP_CMATH_UNARY_OP(expr) │ │ │ │ │ +constexpr index_constant< 10 > Dune::Indices::_10 = {} │ │ │ │ │ +  Compile time index with value 10. │ │ │ │ │   │ │ │ │ │ -#define DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN(expr, returnType) │ │ │ │ │ +constexpr index_constant< 11 > Dune::Indices::_11 = {} │ │ │ │ │ +  Compile time index with value 11. │ │ │ │ │   │ │ │ │ │ -#define DUNE_SIMD_LOOP_STD_UNARY_OP(expr) │ │ │ │ │ +constexpr index_constant< 12 > Dune::Indices::_12 = {} │ │ │ │ │ +  Compile time index with value 12. │ │ │ │ │   │ │ │ │ │ -#define DUNE_SIMD_LOOP_STD_BINARY_OP(expr) │ │ │ │ │ +constexpr index_constant< 13 > Dune::Indices::_13 = {} │ │ │ │ │ +  Compile time index with value 13. │ │ │ │ │   │ │ │ │ │ - Functions │ │ │ │ │ -  Dune::DUNE_SIMD_LOOP_BINARY_OP (+) │ │ │ │ │ +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. │ │ │ │ │   │ │ │ │ │ -  Dune::DUNE_SIMD_LOOP_BINARY_OP (-) │ │ │ │ │ +constexpr index_constant< 18 > Dune::Indices::_18 = {} │ │ │ │ │ +  Compile time index with value 18. │ │ │ │ │   │ │ │ │ │ - DUNE_SIMD_LOOP_BINARY_OP * Dune::DUNE_SIMD_LOOP_BINARY_OP (/ │ │ │ │ │ - );DUNE_SIMD_LOOP_BINARY_OP(% │ │ │ │ │ +constexpr index_constant< 19 > Dune::Indices::_19 = {} │ │ │ │ │ +  Compile time index with value 19. │ │ │ │ │   │ │ │ │ │ - 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) │ │ │ │ │ -  │ │ │ │ │ -***** 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 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: loop.hh Source File │ │ │ │ +dune-common: indices.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,766 +70,124 @@ │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │ -
    loop.hh
    │ │ │ │ +
    indices.hh
    │ │ │ │
    │ │ │ │
    │ │ │ │ -Go to the documentation of this file.
    1// SPDX-FileCopyrightInfo: Copyright (C) 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
    │ │ │ │ +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 (C) DUNE Project contributors, see file LICENSE.md in module root
    │ │ │ │ +
    4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
    │ │ │ │
    5
    │ │ │ │ -
    6#include <array>
    │ │ │ │ -
    7#include <cmath>
    │ │ │ │ -
    8#include <cstddef>
    │ │ │ │ -
    9#include <cstdlib>
    │ │ │ │ -
    10#include <cstdint>
    │ │ │ │ -
    11#include <ostream>
    │ │ │ │ +
    6#ifndef DUNE_COMMON_INDICES_HH
    │ │ │ │ +
    7#define DUNE_COMMON_INDICES_HH
    │ │ │ │ +
    8
    │ │ │ │ +
    9#include <cstddef>
    │ │ │ │ +
    10#include <type_traits>
    │ │ │ │ +
    11#include <utility>
    │ │ │ │
    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
    │ │ │ │ -
    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> {
    │ │ │ │ + │ │ │ │ +
    14
    │ │ │ │ +
    15namespace Dune
    │ │ │ │ +
    16{
    │ │ │ │ +
    29 template<std::size_t i>
    │ │ │ │ +
    30 using index_constant = std::integral_constant<std::size_t, i>;
    │ │ │ │ +
    31
    │ │ │ │ +
    32
    │ │ │ │ +
    33
    │ │ │ │ +
    │ │ │ │ +
    50 namespace Indices
    │ │ │ │ +
    51 {
    │ │ │ │ + │ │ │ │ +
    54
    │ │ │ │ + │ │ │ │ +
    57
    │ │ │ │ + │ │ │ │ +
    60
    │ │ │ │ + │ │ │ │ +
    63
    │ │ │ │ + │ │ │ │
    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 }
    │ │ │ │ -
    │ │ │ │ + │ │ │ │ +
    69
    │ │ │ │ + │ │ │ │ +
    72
    │ │ │ │ + │ │ │ │ +
    75
    │ │ │ │ + │ │ │ │
    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
    │ │ │ │ -
    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
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
    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
    │ │ │ │ -
    Traits for type conversions and type information.
    │ │ │ │ -
    #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.
    │ │ │ │ + │ │ │ │ +
    81
    │ │ │ │ + │ │ │ │ +
    84
    │ │ │ │ + │ │ │ │ +
    87
    │ │ │ │ + │ │ │ │ +
    90
    │ │ │ │ + │ │ │ │ +
    93
    │ │ │ │ + │ │ │ │ +
    96
    │ │ │ │ + │ │ │ │ +
    99
    │ │ │ │ + │ │ │ │ +
    102
    │ │ │ │ + │ │ │ │ +
    105
    │ │ │ │ + │ │ │ │ +
    108
    │ │ │ │ + │ │ │ │ +
    111
    │ │ │ │ +
    112 } // namespace Indices
    │ │ │ │ +
    │ │ │ │ +
    113
    │ │ │ │ +
    124 template<class F, class I, I... i>
    │ │ │ │ +
    │ │ │ │ +
    125 decltype(auto) constexpr unpackIntegerSequence(F&& f, std::integer_sequence<I, i...> sequence)
    │ │ │ │ +
    126 {
    │ │ │ │ +
    127 return f(std::integral_constant<I, i>()...);
    │ │ │ │ +
    128 }
    │ │ │ │ +
    │ │ │ │ +
    129
    │ │ │ │ +
    130} //namespace Dune
    │ │ │ │ +
    131
    │ │ │ │ +
    132#endif // DUNE_COMMON_INDICES_HH
    │ │ │ │ +
    Definitions of several macros that conditionally make C++ syntax available.
    │ │ │ │ +
    #define DUNE_INLINE_VARIABLE
    Definition keywords.hh:19
    │ │ │ │ +
    constexpr index_constant< 16 > _16
    Compile time index with value 16.
    Definition indices.hh:101
    │ │ │ │ +
    constexpr index_constant< 15 > _15
    Compile time index with value 15.
    Definition indices.hh:98
    │ │ │ │ +
    constexpr index_constant< 8 > _8
    Compile time index with value 8.
    Definition indices.hh:77
    │ │ │ │ +
    constexpr index_constant< 7 > _7
    Compile time index with value 7.
    Definition indices.hh:74
    │ │ │ │ +
    constexpr index_constant< 0 > _0
    Compile time index with value 0.
    Definition indices.hh:53
    │ │ │ │ +
    constexpr index_constant< 9 > _9
    Compile time index with value 9.
    Definition indices.hh:80
    │ │ │ │ +
    constexpr index_constant< 14 > _14
    Compile time index with value 14.
    Definition indices.hh:95
    │ │ │ │ +
    constexpr index_constant< 1 > _1
    Compile time index with value 1.
    Definition indices.hh:56
    │ │ │ │ +
    constexpr index_constant< 3 > _3
    Compile time index with value 3.
    Definition indices.hh:62
    │ │ │ │ +
    constexpr index_constant< 12 > _12
    Compile time index with value 12.
    Definition indices.hh:89
    │ │ │ │ +
    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:125
    │ │ │ │ +
    constexpr index_constant< 11 > _11
    Compile time index with value 11.
    Definition indices.hh:86
    │ │ │ │ +
    constexpr index_constant< 18 > _18
    Compile time index with value 18.
    Definition indices.hh:107
    │ │ │ │ +
    constexpr index_constant< 13 > _13
    Compile time index with value 13.
    Definition indices.hh:92
    │ │ │ │ +
    constexpr index_constant< 5 > _5
    Compile time index with value 5.
    Definition indices.hh:68
    │ │ │ │ +
    constexpr index_constant< 17 > _17
    Compile time index with value 17.
    Definition indices.hh:104
    │ │ │ │ +
    constexpr index_constant< 10 > _10
    Compile time index with value 10.
    Definition indices.hh:83
    │ │ │ │ +
    constexpr index_constant< 2 > _2
    Compile time index with value 2.
    Definition indices.hh:59
    │ │ │ │
    std::integral_constant< std::size_t, i > index_constant
    An index constant with value i.
    Definition indices.hh:30
    │ │ │ │ -
    static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from >, std::integral_constant< T, to >) noexcept
    Definition rangeutilities.hh:300
    │ │ │ │ -
    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.
    │ │ │ │ +
    constexpr index_constant< 19 > _19
    Compile time index with value 19.
    Definition indices.hh:110
    │ │ │ │ +
    constexpr index_constant< 6 > _6
    Compile time index with value 6.
    Definition indices.hh:71
    │ │ │ │ +
    constexpr index_constant< 4 > _4
    Compile time index with value 4.
    Definition indices.hh:65
    │ │ │ │
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ -
    DUNE_SIMD_LOOP_COMPARISON_OP(<)
    │ │ │ │ -
    bool anyTrue(ADLTag< 5 >, const AlignedNumber< bool, align > &mask)
    Definition debugalign.hh:543
    │ │ │ │ -
    const AlignedNumber< T, align > & cond(ADLTag< 5 >, AlignedNumber< bool, align > mask, const AlignedNumber< T, align > &ifTrue, const AlignedNumber< T, align > &ifFalse)
    Definition debugalign.hh:535
    │ │ │ │ -
    T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v)
    Definition debugalign.hh:520
    │ │ │ │ -
    bool isNaN(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag)
    Definition fvector.hh:604
    │ │ │ │ -
    bool isInf(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag)
    Definition fvector.hh:594
    │ │ │ │ -
    auto isFinite(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag)
    Definition fvector.hh:584
    │ │ │ │ -
    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.
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,827 +7,185 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * simd │ │ │ │ │ -loop.hh │ │ │ │ │ +indices.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ - 1// SPDX-FileCopyrightInfo: Copyright (C) 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 (C) 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 │ │ │ │ │ + 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ 5 │ │ │ │ │ - 6#include │ │ │ │ │ - 7#include │ │ │ │ │ - 8#include │ │ │ │ │ - 9#include │ │ │ │ │ - 10#include │ │ │ │ │ - 11#include │ │ │ │ │ + 6#ifndef DUNE_COMMON_INDICES_HH │ │ │ │ │ + 7#define DUNE_COMMON_INDICES_HH │ │ │ │ │ + 8 │ │ │ │ │ + 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 │ │ │ │ │ - 51 │ │ │ │ │ - 52 │ │ │ │ │ - 64 template │ │ │ │ │ -65 class alignas(A==0?alignof(T):A) LoopSIMD : public std::array { │ │ │ │ │ + 13#include │ │ │ │ │ + 14 │ │ │ │ │ + 15namespace Dune │ │ │ │ │ + 16{ │ │ │ │ │ + 29 template │ │ │ │ │ +30 using index_constant = std::integral_constant; │ │ │ │ │ + 31 │ │ │ │ │ + 32 │ │ │ │ │ + 33 │ │ │ │ │ +50 namespace Indices │ │ │ │ │ + 51 { │ │ │ │ │ +53 DUNE_INLINE_VARIABLE constexpr index_constant<_0> _0 = {}; │ │ │ │ │ + 54 │ │ │ │ │ +56 DUNE_INLINE_VARIABLE constexpr index_constant<_1> _1 = {}; │ │ │ │ │ + 57 │ │ │ │ │ +59 DUNE_INLINE_VARIABLE constexpr index_constant<_2> _2 = {}; │ │ │ │ │ + 60 │ │ │ │ │ +62 DUNE_INLINE_VARIABLE constexpr index_constant<_3> _3 = {}; │ │ │ │ │ + 63 │ │ │ │ │ +65 DUNE_INLINE_VARIABLE constexpr index_constant<_4> _4 = {}; │ │ │ │ │ 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 } │ │ │ │ │ +68 DUNE_INLINE_VARIABLE constexpr index_constant<_5> _5 = {}; │ │ │ │ │ + 69 │ │ │ │ │ +71 DUNE_INLINE_VARIABLE constexpr index_constant<_6> _6 = {}; │ │ │ │ │ + 72 │ │ │ │ │ +74 DUNE_INLINE_VARIABLE constexpr index_constant<_7> _7 = {}; │ │ │ │ │ + 75 │ │ │ │ │ +77 DUNE_INLINE_VARIABLE constexpr index_constant<_8> _8 = {}; │ │ │ │ │ 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 _9 = {}; │ │ │ │ │ + 81 │ │ │ │ │ +83 DUNE_INLINE_VARIABLE constexpr index_constant<10> _10 = {}; │ │ │ │ │ + 84 │ │ │ │ │ +86 DUNE_INLINE_VARIABLE constexpr index_constant<11> _11 = {}; │ │ │ │ │ + 87 │ │ │ │ │ +89 DUNE_INLINE_VARIABLE constexpr index_constant<12> _12 = {}; │ │ │ │ │ + 90 │ │ │ │ │ +92 DUNE_INLINE_VARIABLE constexpr index_constant<13> _13 = {}; │ │ │ │ │ + 93 │ │ │ │ │ +95 DUNE_INLINE_VARIABLE constexpr index_constant<14> _14 = {}; │ │ │ │ │ + 96 │ │ │ │ │ +98 DUNE_INLINE_VARIABLE constexpr index_constant<15> _15 = {}; │ │ │ │ │ + 99 │ │ │ │ │ +101 DUNE_INLINE_VARIABLE constexpr index_constant<16> _16 = {}; │ │ │ │ │ + 102 │ │ │ │ │ +104 DUNE_INLINE_VARIABLE constexpr index_constant<17> _17 = {}; │ │ │ │ │ + 105 │ │ │ │ │ +107 DUNE_INLINE_VARIABLE constexpr index_constant<18> _18 = {}; │ │ │ │ │ + 108 │ │ │ │ │ +110 DUNE_INLINE_VARIABLE constexpr index_constant<19> _19 = {}; │ │ │ │ │ + 111 │ │ │ │ │ + 112 } // namespace Indices │ │ │ │ │ + 113 │ │ │ │ │ + 124 template │ │ │ │ │ +125 decltype(auto) constexpr unpackIntegerSequence(F&& f, std:: │ │ │ │ │ +integer_sequence sequence) │ │ │ │ │ + 126 { │ │ │ │ │ + 127 return f(std::integral_constant()...); │ │ │ │ │ 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 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 &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 │ │ │ │ │ -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 │ │ │ │ │ -typetraits.hh │ │ │ │ │ -Traits for type conversions and type information. │ │ │ │ │ -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. │ │ │ │ │ + 129 │ │ │ │ │ + 130} //namespace Dune │ │ │ │ │ + 131 │ │ │ │ │ + 132#endif // DUNE_COMMON_INDICES_HH │ │ │ │ │ +keywords.hh │ │ │ │ │ +Definitions of several macros that conditionally make C++ syntax available. │ │ │ │ │ +DUNE_INLINE_VARIABLE │ │ │ │ │ +#define DUNE_INLINE_VARIABLE │ │ │ │ │ +Definition keywords.hh:19 │ │ │ │ │ +Dune::Indices::_16 │ │ │ │ │ +constexpr index_constant< 16 > _16 │ │ │ │ │ +Compile time index with value 16. │ │ │ │ │ +Definition indices.hh:101 │ │ │ │ │ +Dune::Indices::_15 │ │ │ │ │ +constexpr index_constant< 15 > _15 │ │ │ │ │ +Compile time index with value 15. │ │ │ │ │ +Definition indices.hh:98 │ │ │ │ │ +Dune::Indices::_8 │ │ │ │ │ +constexpr index_constant< 8 > _8 │ │ │ │ │ +Compile time index with value 8. │ │ │ │ │ +Definition indices.hh:77 │ │ │ │ │ +Dune::Indices::_7 │ │ │ │ │ +constexpr index_constant< 7 > _7 │ │ │ │ │ +Compile time index with value 7. │ │ │ │ │ +Definition indices.hh:74 │ │ │ │ │ +Dune::Indices::_0 │ │ │ │ │ +constexpr index_constant< 0 > _0 │ │ │ │ │ +Compile time index with value 0. │ │ │ │ │ +Definition indices.hh:53 │ │ │ │ │ +Dune::Indices::_9 │ │ │ │ │ +constexpr index_constant< 9 > _9 │ │ │ │ │ +Compile time index with value 9. │ │ │ │ │ +Definition indices.hh:80 │ │ │ │ │ +Dune::Indices::_14 │ │ │ │ │ +constexpr index_constant< 14 > _14 │ │ │ │ │ +Compile time index with value 14. │ │ │ │ │ +Definition indices.hh:95 │ │ │ │ │ +Dune::Indices::_1 │ │ │ │ │ +constexpr index_constant< 1 > _1 │ │ │ │ │ +Compile time index with value 1. │ │ │ │ │ +Definition indices.hh:56 │ │ │ │ │ +Dune::Indices::_3 │ │ │ │ │ +constexpr index_constant< 3 > _3 │ │ │ │ │ +Compile time index with value 3. │ │ │ │ │ +Definition indices.hh:62 │ │ │ │ │ +Dune::Indices::_12 │ │ │ │ │ +constexpr index_constant< 12 > _12 │ │ │ │ │ +Compile time index with value 12. │ │ │ │ │ +Definition indices.hh:89 │ │ │ │ │ +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:125 │ │ │ │ │ +Dune::Indices::_11 │ │ │ │ │ +constexpr index_constant< 11 > _11 │ │ │ │ │ +Compile time index with value 11. │ │ │ │ │ +Definition indices.hh:86 │ │ │ │ │ +Dune::Indices::_18 │ │ │ │ │ +constexpr index_constant< 18 > _18 │ │ │ │ │ +Compile time index with value 18. │ │ │ │ │ +Definition indices.hh:107 │ │ │ │ │ +Dune::Indices::_13 │ │ │ │ │ +constexpr index_constant< 13 > _13 │ │ │ │ │ +Compile time index with value 13. │ │ │ │ │ +Definition indices.hh:92 │ │ │ │ │ +Dune::Indices::_5 │ │ │ │ │ +constexpr index_constant< 5 > _5 │ │ │ │ │ +Compile time index with value 5. │ │ │ │ │ +Definition indices.hh:68 │ │ │ │ │ +Dune::Indices::_17 │ │ │ │ │ +constexpr index_constant< 17 > _17 │ │ │ │ │ +Compile time index with value 17. │ │ │ │ │ +Definition indices.hh:104 │ │ │ │ │ +Dune::Indices::_10 │ │ │ │ │ +constexpr index_constant< 10 > _10 │ │ │ │ │ +Compile time index with value 10. │ │ │ │ │ +Definition indices.hh:83 │ │ │ │ │ +Dune::Indices::_2 │ │ │ │ │ +constexpr index_constant< 2 > _2 │ │ │ │ │ +Compile time index with value 2. │ │ │ │ │ +Definition indices.hh:59 │ │ │ │ │ Dune::index_constant │ │ │ │ │ std::integral_constant< std::size_t, i > index_constant │ │ │ │ │ An index constant with value i. │ │ │ │ │ Definition indices.hh:30 │ │ │ │ │ -Dune::range │ │ │ │ │ -static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from │ │ │ │ │ ->, std::integral_constant< T, to >) noexcept │ │ │ │ │ -Definition rangeutilities.hh:300 │ │ │ │ │ -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::Indices::_19 │ │ │ │ │ +constexpr index_constant< 19 > _19 │ │ │ │ │ +Compile time index with value 19. │ │ │ │ │ +Definition indices.hh:110 │ │ │ │ │ +Dune::Indices::_6 │ │ │ │ │ +constexpr index_constant< 6 > _6 │ │ │ │ │ +Compile time index with value 6. │ │ │ │ │ +Definition indices.hh:71 │ │ │ │ │ +Dune::Indices::_4 │ │ │ │ │ +constexpr index_constant< 4 > _4 │ │ │ │ │ +Compile time index with value 4. │ │ │ │ │ +Definition indices.hh:65 │ │ │ │ │ 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:543 │ │ │ │ │ -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:535 │ │ │ │ │ -Dune::Simd::Overloads::lane │ │ │ │ │ -T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v) │ │ │ │ │ -Definition debugalign.hh:520 │ │ │ │ │ -Dune::MathOverloads::isNaN │ │ │ │ │ -bool isNaN(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag) │ │ │ │ │ -Definition fvector.hh:604 │ │ │ │ │ -Dune::MathOverloads::isInf │ │ │ │ │ -bool isInf(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag) │ │ │ │ │ -Definition fvector.hh:594 │ │ │ │ │ -Dune::MathOverloads::isFinite │ │ │ │ │ -auto isFinite(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag) │ │ │ │ │ -Definition fvector.hh:584 │ │ │ │ │ -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. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00173.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: io.hh File Reference │ │ │ │ +dune-common: stringutility.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,76 +65,62 @@ │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -Classes | │ │ │ │ Namespaces | │ │ │ │ Functions
    │ │ │ │ - │ │ │ │ +
    stringutility.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ -

    IO interface of the SIMD abstraction. │ │ │ │ +

    Miscellaneous helper stuff. │ │ │ │ More...

    │ │ │ │ -
    #include <ios>
    │ │ │ │ -#include <type_traits>
    │ │ │ │ -#include <dune/common/rangeutilities.hh>
    │ │ │ │ -#include <dune/common/simd/simd.hh>
    │ │ │ │ -#include <dune/common/typetraits.hh>
    │ │ │ │ +
    #include <cstddef>
    │ │ │ │ +#include <cstring>
    │ │ │ │ +#include <algorithm>
    │ │ │ │ +#include <cassert>
    │ │ │ │ +#include <cstdio>
    │ │ │ │ +#include <memory>
    │ │ │ │ +#include <string>
    │ │ │ │ +#include <new>
    │ │ │ │ +#include <dune/common/exceptions.hh>
    │ │ │ │
    │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ -Classes

    class  Dune::SimdImpl::Inserter< T >
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │

    │ │ │ │ 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
     
    template<typename C >
    bool Dune::hasPrefix (const C &c, const char *prefix)
     Check whether a character container has a given prefix.
     
    template<typename C >
    bool Dune::hasSuffix (const C &c, const char *suffix)
     Check whether a character container has a given suffix.
     
    template<class... T>
    static std::string Dune::formatString (const std::string &s, const T &... args)
     Format values according to printf format string.
     
    │ │ │ │

    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.

    │ │ │ │ +

    Miscellaneous helper stuff.

    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,58 +6,43 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ 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 │ │ │ │ │ +Namespaces | Functions │ │ │ │ │ +stringutility.hh File Reference │ │ │ │ │ +Miscellaneous helper stuff. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ - Classes │ │ │ │ │ -class  Dune::SimdImpl::Inserter<_T_> │ │ │ │ │ -  │ │ │ │ │ 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 │ │ │ │ │ +template │ │ │ │ │ + bool Dune::hasPrefix (const C &c, const char *prefix) │ │ │ │ │ +  Check whether a character container has a given prefix. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool Dune::hasSuffix (const C &c, const char *suffix) │ │ │ │ │ +  Check whether a character container has a given suffix. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +static std::string Dune::formatString (const std::string &s, const T &... │ │ │ │ │ + args) │ │ │ │ │ +  Format values according to printf format string. │ │ │ │ │   │ │ │ │ │ ***** 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. │ │ │ │ │ +Miscellaneous helper stuff. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00173_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: io.hh Source File │ │ │ │ +dune-common: stringutility.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,125 +70,113 @@ │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │ -
    io.hh
    │ │ │ │ +
    stringutility.hh
    │ │ │ │
    │ │ │ │
    │ │ │ │ -Go to the documentation of this file.
    1// SPDX-FileCopyrightInfo: Copyright (C) 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
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ +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 (C) 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_STRINGUTILITY_HH
    │ │ │ │ +
    6#define DUNE_COMMON_STRINGUTILITY_HH
    │ │ │ │ +
    7
    │ │ │ │ +
    12#include <cstddef>
    │ │ │ │ +
    13#include <cstring>
    │ │ │ │ +
    14#include <algorithm>
    │ │ │ │ +
    15#include <cassert>
    │ │ │ │ +
    16#include <cstdio>
    │ │ │ │ +
    17#include <memory>
    │ │ │ │ +
    18#include <string>
    │ │ │ │ +
    19#include <new>
    │ │ │ │ +
    20
    │ │ │ │ + │ │ │ │
    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 }
    │ │ │ │ -
    │ │ │ │ -
    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 }
    │ │ │ │ +
    23
    │ │ │ │ +
    24namespace Dune {
    │ │ │ │ +
    25
    │ │ │ │ +
    36 template<typename C>
    │ │ │ │ +
    │ │ │ │ +
    37 bool hasPrefix(const C& c, const char* prefix) {
    │ │ │ │ +
    38 std::size_t len = std::strlen(prefix);
    │ │ │ │ +
    39 return c.size() >= len &&
    │ │ │ │ +
    40 std::equal(prefix, prefix+len, c.begin());
    │ │ │ │ +
    41 }
    │ │ │ │ +
    │ │ │ │ +
    42
    │ │ │ │ +
    52 template<typename C>
    │ │ │ │ +
    │ │ │ │ +
    53 bool hasSuffix(const C& c, const char* suffix) {
    │ │ │ │ +
    54 std::size_t len = std::strlen(suffix);
    │ │ │ │ +
    55 if(c.size() < len) return false;
    │ │ │ │ +
    56 typename C::const_iterator it = c.begin();
    │ │ │ │ +
    57 std::advance(it, c.size() - len);
    │ │ │ │ +
    58 return std::equal(suffix, suffix+len, it);
    │ │ │ │ +
    59 }
    │ │ │ │ +
    │ │ │ │ +
    60
    │ │ │ │ +
    72 template<class... T>
    │ │ │ │ +
    │ │ │ │ +
    73 static std::string formatString(const std::string& s, const T&... args)
    │ │ │ │ +
    74 {
    │ │ │ │ +
    75 static const int bufferSize=1000;
    │ │ │ │ +
    76 char buffer[bufferSize];
    │ │ │ │ +
    77
    │ │ │ │ +
    78 // try to format with static buffer
    │ │ │ │ +
    79 int r = std::snprintf(buffer, bufferSize, s.c_str(), args...);
    │ │ │ │ +
    80
    │ │ │ │ +
    81 // negative return values correspond to errors
    │ │ │ │ +
    82 if (r<0)
    │ │ │ │ +
    83 DUNE_THROW(Dune::Exception,"Could not convert format string using given arguments.");
    │ │ │ │ +
    84
    │ │ │ │ +
    85 // if buffer was large enough return result as string
    │ │ │ │ +
    86 if (r<bufferSize)
    │ │ │ │ +
    87 return std::string(buffer);
    │ │ │ │ +
    88
    │ │ │ │ +
    89 // if buffer was to small allocate a larger buffer using
    │ │ │ │ +
    90 // the predicted size hint (+1 for the terminating 0-byte).
    │ │ │ │ +
    91 int dynamicBufferSize = r+1;
    │ │ │ │ +
    92
    │ │ │ │ +
    93 std::unique_ptr<char[]> dynamicBuffer;
    │ │ │ │ +
    94 try {
    │ │ │ │ +
    95 dynamicBuffer = std::make_unique<char[]>(dynamicBufferSize);
    │ │ │ │ +
    96 }
    │ │ │ │ +
    97 catch (const std::bad_alloc&) {
    │ │ │ │ +
    98 DUNE_THROW(Dune::Exception,"Could allocate large enough dynamic buffer in formatString.");
    │ │ │ │ +
    99 }
    │ │ │ │ +
    100
    │ │ │ │ +
    101 // convert and check for errors again
    │ │ │ │ +
    102 r = std::snprintf(dynamicBuffer.get(), dynamicBufferSize, s.c_str(), args...);
    │ │ │ │ +
    103 if (r<0)
    │ │ │ │ +
    104 DUNE_THROW(Dune::Exception,"Could not convert format string using given arguments.");
    │ │ │ │ +
    105
    │ │ │ │ +
    106 // the new buffer should always be large enough
    │ │ │ │ +
    107 assert(r<dynamicBufferSize);
    │ │ │ │ +
    108
    │ │ │ │ +
    109 return std::string(dynamicBuffer.get());
    │ │ │ │ +
    110 }
    │ │ │ │
    │ │ │ │ -
    110
    │ │ │ │ -
    112
    │ │ │ │ +
    113}
    │ │ │ │
    114
    │ │ │ │ -
    115 } // namespace Simd
    │ │ │ │ -
    116} // namespace Dune
    │ │ │ │ -
    117
    │ │ │ │ -
    118#endif // DUNE_COMMON_SIMD_IO_HH
    │ │ │ │ -
    Traits for type conversions and type information.
    │ │ │ │ -
    Utilities for reduction like operations on ranges.
    │ │ │ │ -
    static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from >, std::integral_constant< T, to >) noexcept
    Definition rangeutilities.hh:300
    │ │ │ │ -
    constexpr AutonomousValue< T > autoCopy(T &&v)
    Autonomous copy of an expression's value for use in auto type deduction.
    Definition typetraits.hh:642
    │ │ │ │ -
    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
    │ │ │ │ +
    115#endif // DUNE_COMMON_STRINGUTILITY_HH
    │ │ │ │ +
    A few common exception classes.
    │ │ │ │ +
    bool hasSuffix(const C &c, const char *suffix)
    Check whether a character container has a given suffix.
    Definition stringutility.hh:53
    │ │ │ │ +
    static std::string formatString(const std::string &s, const T &... args)
    Format values according to printf format string.
    Definition stringutility.hh:73
    │ │ │ │ +
    bool hasPrefix(const C &c, const char *prefix)
    Check whether a character container has a given prefix.
    Definition stringutility.hh:37
    │ │ │ │ +
    #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.
    │ │ │ │ +
    Base class for Dune-Exceptions.
    Definition exceptions.hh:96
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,137 +7,119 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * simd │ │ │ │ │ -io.hh │ │ │ │ │ +stringutility.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ - 1// SPDX-FileCopyrightInfo: Copyright (C) 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 (C) 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 │ │ │ │ │ + 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ + 5#ifndef DUNE_COMMON_STRINGUTILITY_HH │ │ │ │ │ + 6#define DUNE_COMMON_STRINGUTILITY_HH │ │ │ │ │ + 7 │ │ │ │ │ + 12#include │ │ │ │ │ + 13#include │ │ │ │ │ + 14#include │ │ │ │ │ + 15#include │ │ │ │ │ + 16#include │ │ │ │ │ + 17#include │ │ │ │ │ + 18#include │ │ │ │ │ + 19#include │ │ │ │ │ + 20 │ │ │ │ │ + 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) │ │ │ │ │ - 58 { │ │ │ │ │ - 59 return Simd::lane(0, v); │ │ │ │ │ - 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 │ │ │ │ │ + 23 │ │ │ │ │ + 24namespace Dune { │ │ │ │ │ + 25 │ │ │ │ │ + 36 template │ │ │ │ │ +37 bool hasPrefix(const C& c, const char* prefix) { │ │ │ │ │ + 38 std::size_t len = std::strlen(prefix); │ │ │ │ │ + 39 return c.size() >= len && │ │ │ │ │ + 40 std::equal(prefix, prefix+len, c.begin()); │ │ │ │ │ + 41 } │ │ │ │ │ + 42 │ │ │ │ │ + 52 template │ │ │ │ │ +53 bool hasSuffix(const C& c, const char* suffix) { │ │ │ │ │ + 54 std::size_t len = std::strlen(suffix); │ │ │ │ │ + 55 if(c.size() < len) return false; │ │ │ │ │ + 56 typename C::const_iterator it = c.begin(); │ │ │ │ │ + 57 std::advance(it, c.size() - len); │ │ │ │ │ + 58 return std::equal(suffix, suffix+len, it); │ │ │ │ │ + 59 } │ │ │ │ │ + 60 │ │ │ │ │ + 72 template │ │ │ │ │ +73 static std::string formatString(const std::string& s, const T&... args) │ │ │ │ │ + 74 { │ │ │ │ │ + 75 static const int bufferSize=1000; │ │ │ │ │ + 76 char buffer[bufferSize]; │ │ │ │ │ + 77 │ │ │ │ │ + 78 // try to format with static buffer │ │ │ │ │ + 79 int r = std::snprintf(buffer, bufferSize, s.c_str(), args...); │ │ │ │ │ + 80 │ │ │ │ │ + 81 // negative return values correspond to errors │ │ │ │ │ + 82 if (r<0) │ │ │ │ │ + 83 DUNE_THROW(Dune::Exception,"Could not convert format string using given │ │ │ │ │ +arguments."); │ │ │ │ │ + 84 │ │ │ │ │ + 85 // if buffer was large enough return result as string │ │ │ │ │ + 86 if (r dynamicBuffer; │ │ │ │ │ + 94 try { │ │ │ │ │ + 95 dynamicBuffer = std::make_unique(dynamicBufferSize); │ │ │ │ │ + 96 } │ │ │ │ │ + 97 catch (const std::bad_alloc&) { │ │ │ │ │ + 98 DUNE_THROW(Dune::Exception,"Could allocate large enough dynamic buffer in │ │ │ │ │ +formatString."); │ │ │ │ │ + 99 } │ │ │ │ │ + 100 │ │ │ │ │ + 101 // convert and check for errors again │ │ │ │ │ + 102 r = std::snprintf(dynamicBuffer.get(), dynamicBufferSize, s.c_str(), │ │ │ │ │ +args...); │ │ │ │ │ + 103 if (r<0) │ │ │ │ │ + 104 DUNE_THROW(Dune::Exception,"Could not convert format string using given │ │ │ │ │ +arguments."); │ │ │ │ │ + 105 │ │ │ │ │ + 106 // the new buffer should always be large enough │ │ │ │ │ + 107 assert(r range(std::integral_constant< T, from │ │ │ │ │ ->, std::integral_constant< T, to >) noexcept │ │ │ │ │ -Definition rangeutilities.hh:300 │ │ │ │ │ -Dune::autoCopy │ │ │ │ │ -constexpr AutonomousValue< T > autoCopy(T &&v) │ │ │ │ │ -Autonomous copy of an expression's value for use in auto type deduction. │ │ │ │ │ -Definition typetraits.hh:642 │ │ │ │ │ -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 │ │ │ │ │ + 115#endif // DUNE_COMMON_STRINGUTILITY_HH │ │ │ │ │ +exceptions.hh │ │ │ │ │ +A few common exception classes. │ │ │ │ │ +Dune::hasSuffix │ │ │ │ │ +bool hasSuffix(const C &c, const char *suffix) │ │ │ │ │ +Check whether a character container has a given suffix. │ │ │ │ │ +Definition stringutility.hh:53 │ │ │ │ │ +Dune::formatString │ │ │ │ │ +static std::string formatString(const std::string &s, const T &... args) │ │ │ │ │ +Format values according to printf format string. │ │ │ │ │ +Definition stringutility.hh:73 │ │ │ │ │ +Dune::hasPrefix │ │ │ │ │ +bool hasPrefix(const C &c, const char *prefix) │ │ │ │ │ +Check whether a character container has a given prefix. │ │ │ │ │ +Definition stringutility.hh:37 │ │ │ │ │ +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::Exception │ │ │ │ │ +Base class for Dune-Exceptions. │ │ │ │ │ +Definition exceptions.hh:96 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00176.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: lru.hh File Reference │ │ │ │ +dune-common: diagonalmatrix.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -72,43 +72,73 @@ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ Classes | │ │ │ │ Namespaces
    │ │ │ │ -
    lru.hh File Reference
    │ │ │ │ +
    diagonalmatrix.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ -

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

    This file implements a quadratic diagonal matrix of fixed size. │ │ │ │ More...

    │ │ │ │ -
    #include <list>
    │ │ │ │ -#include <utility>
    │ │ │ │ -#include <map>
    │ │ │ │ +
    #include <algorithm>
    │ │ │ │ +#include <cassert>
    │ │ │ │ +#include <cmath>
    │ │ │ │ +#include <complex>
    │ │ │ │ +#include <cstddef>
    │ │ │ │ +#include <initializer_list>
    │ │ │ │ +#include <iostream>
    │ │ │ │ #include <memory>
    │ │ │ │ -#include <dune/common/exceptions.hh>
    │ │ │ │ +#include <dune/common/boundschecking.hh>
    │ │ │ │ +#include <dune/common/densematrix.hh>
    │ │ │ │ +#include <dune/common/exceptions.hh>
    │ │ │ │ +#include <dune/common/fmatrix.hh>
    │ │ │ │ +#include <dune/common/fvector.hh>
    │ │ │ │ +#include <dune/common/genericiterator.hh>
    │ │ │ │ +#include <dune/common/typetraits.hh>
    │ │ │ │
    │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ Classes

    class  Dune::lru< Key, Tp, Traits >
     LRU Cache Container. More...
    class  Dune::DiagonalMatrix< K, n >
     A diagonal matrix of static size. More...
     
    struct  Dune::FieldTraits< DiagonalMatrix< K, n > >
     
    class  Dune::DiagonalMatrixWrapper< DiagonalMatrixType >
     
    class  Dune::DiagonalRowVectorConst< K, n >
     
    class  Dune::DiagonalRowVector< K, n >
     
    struct  Dune::const_reference< DiagonalRowVector< K, n > >
     
    struct  Dune::const_reference< DiagonalRowVectorConst< K, n > >
     
    struct  Dune::mutable_reference< DiagonalRowVector< K, n > >
     
    struct  Dune::mutable_reference< DiagonalRowVectorConst< K, n > >
     
    class  Dune::ContainerWrapperIterator< CW, T, R >
     Iterator class for sparse vector-like containers. More...
     
    struct  Dune::DenseMatrixAssigner< DenseMatrix, DiagonalMatrix< field, N > >
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

    │ │ │ │ Namespaces

    namespace  Dune
     Dune namespace.
     
    │ │ │ │

    Detailed Description

    │ │ │ │ -

    LRU Cache Container, using an STL like interface.

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

    This file implements a quadratic diagonal matrix of fixed size.

    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,30 +7,59 @@ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ Classes | Namespaces │ │ │ │ │ -lru.hh File Reference │ │ │ │ │ -LRU Cache Container, using an STL like interface. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +diagonalmatrix.hh File Reference │ │ │ │ │ +This file implements a quadratic diagonal matrix of fixed size. More... │ │ │ │ │ +#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::lru<_Key,_Tp,_Traits_> │ │ │ │ │ -  LRU Cache Container. More... │ │ │ │ │ + class  Dune::DiagonalMatrix<_K,_n_> │ │ │ │ │ +  A diagonal matrix of static size. More... │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::FieldTraits<_DiagonalMatrix<_K,_n_>_> │ │ │ │ │ +  │ │ │ │ │ + class  Dune::DiagonalMatrixWrapper<_DiagonalMatrixType_> │ │ │ │ │ +  │ │ │ │ │ + class  Dune::DiagonalRowVectorConst<_K,_n_> │ │ │ │ │ +  │ │ │ │ │ + class  Dune::DiagonalRowVector<_K,_n_> │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::const_reference<_DiagonalRowVector<_K,_n_>_> │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::const_reference<_DiagonalRowVectorConst<_K,_n_>_> │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::mutable_reference<_DiagonalRowVector<_K,_n_>_> │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::mutable_reference<_DiagonalRowVectorConst<_K,_n_>_> │ │ │ │ │ +  │ │ │ │ │ + class  Dune::ContainerWrapperIterator<_CW,_T,_R_> │ │ │ │ │ +  Iterator class for sparse vector-like containers. More... │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::DenseMatrixAssigner<_DenseMatrix,_DiagonalMatrix<_field,_N_>_> │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -LRU Cache Container, using an STL like interface. │ │ │ │ │ - Author │ │ │ │ │ - Christian Engwer │ │ │ │ │ +This file implements a quadratic diagonal matrix of fixed size. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00176_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: lru.hh Source File │ │ │ │ +dune-common: diagonalmatrix.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,238 +74,1353 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    lru.hh
    │ │ │ │ +
    diagonalmatrix.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 (C) 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
    │ │ │ │ +
    5#ifndef DUNE_DIAGONAL_MATRIX_HH
    │ │ │ │ +
    6#define DUNE_DIAGONAL_MATRIX_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;
    │ │ │ │ +
    12#include <algorithm>
    │ │ │ │ +
    13#include <cassert>
    │ │ │ │ +
    14#include <cmath>
    │ │ │ │ +
    15#include <complex>
    │ │ │ │ +
    16#include <cstddef>
    │ │ │ │ +
    17#include <initializer_list>
    │ │ │ │ +
    18#include <iostream>
    │ │ │ │ +
    19#include <memory>
    │ │ │ │ +
    20
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    28
    │ │ │ │ +
    29
    │ │ │ │ +
    30namespace Dune {
    │ │ │ │ +
    31
    │ │ │ │ +
    32 template< class K, int n > class DiagonalRowVectorConst;
    │ │ │ │ +
    33 template< class K, int n > class DiagonalRowVector;
    │ │ │ │ +
    34 template< class DiagonalMatrixType > class DiagonalMatrixWrapper;
    │ │ │ │ +
    35 template< class C, class T, class R> class ContainerWrapperIterator;
    │ │ │ │ +
    36
    │ │ │ │ +
    51 template<class K, int n>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    53 {
    │ │ │ │ + │ │ │ │ +
    55
    │ │ │ │ +
    56 public:
    │ │ │ │ +
    57 //===== type definitions and constants
    │ │ │ │
    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
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    84 {
    │ │ │ │ -
    85 return _data.front().second;
    │ │ │ │ -
    86 }
    │ │ │ │ -
    │ │ │ │ -
    87
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    93 {
    │ │ │ │ -
    94 return _data.back().second;
    │ │ │ │ -
    95 }
    │ │ │ │ -
    │ │ │ │ +
    60 typedef K value_type;
    │ │ │ │ + │ │ │ │ +
    62
    │ │ │ │ +
    64 typedef K block_type;
    │ │ │ │ +
    65
    │ │ │ │ +
    67 typedef std::size_t size_type;
    │ │ │ │ +
    68
    │ │ │ │ +
    70 constexpr static int blocklevel = 1;
    │ │ │ │ +
    71
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    79
    │ │ │ │ +
    81 constexpr static int rows = n;
    │ │ │ │ +
    83 constexpr static int cols = n;
    │ │ │ │ +
    84
    │ │ │ │ +
    85 //==== size
    │ │ │ │ +
    86
    │ │ │ │ +
    │ │ │ │ +
    87 static constexpr size_type size ()
    │ │ │ │ +
    88 {
    │ │ │ │ +
    89 return rows;
    │ │ │ │ +
    90 }
    │ │ │ │ +
    │ │ │ │ +
    91
    │ │ │ │ +
    92 //===== constructors
    │ │ │ │ +
    93
    │ │ │ │ +
    95 constexpr DiagonalMatrix() = default;
    │ │ │ │
    96
    │ │ │ │ -
    │ │ │ │ -
    101 const_reference back ([[maybe_unused]] int i) const
    │ │ │ │ -
    102 {
    │ │ │ │ -
    103 return _data.back().second;
    │ │ │ │ -
    104 }
    │ │ │ │ +
    │ │ │ │ +
    98 DiagonalMatrix (const K& k)
    │ │ │ │ +
    99 : diag_(k)
    │ │ │ │ +
    100 {}
    │ │ │ │ +
    │ │ │ │ +
    101
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    104 : diag_(diag)
    │ │ │ │ +
    105 {}
    │ │ │ │
    │ │ │ │ -
    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;
    │ │ │ │ +
    │ │ │ │ +
    115 DiagonalMatrix (std::initializer_list<K> const &l)
    │ │ │ │ +
    116 {
    │ │ │ │ +
    117 std::copy_n(l.begin(), std::min(static_cast<std::size_t>(rows),
    │ │ │ │ +
    118 l.size()),
    │ │ │ │ +
    119 diag_.begin());
    │ │ │ │ +
    120 }
    │ │ │ │ +
    │ │ │ │ +
    121
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    124 {
    │ │ │ │ +
    125 diag_ = k;
    │ │ │ │ +
    126 return *this;
    │ │ │ │ +
    127 }
    │ │ │ │ +
    │ │ │ │ +
    128
    │ │ │ │ +
    │ │ │ │ +
    130 bool identical(const DiagonalMatrix<K,n>& other) const
    │ │ │ │ +
    131 {
    │ │ │ │ +
    132 return (this==&other);
    │ │ │ │ +
    133 }
    │ │ │ │ +
    │ │ │ │ +
    134
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    137 {
    │ │ │ │ +
    138 return *this;
    │ │ │ │ +
    139 }
    │ │ │ │ +
    │ │ │ │ +
    140
    │ │ │ │ +
    141 //===== iterator interface to rows of the matrix
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    150
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    153 {
    │ │ │ │ +
    154 return Iterator(WrapperType(this),0);
    │ │ │ │ +
    155 }
    │ │ │ │ +
    │ │ │ │ +
    156
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    159 {
    │ │ │ │ +
    160 return Iterator(WrapperType(this),n);
    │ │ │ │ +
    161 }
    │ │ │ │ +
    │ │ │ │ +
    162
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    166 {
    │ │ │ │ +
    167 return Iterator(WrapperType(this),n-1);
    │ │ │ │ +
    168 }
    │ │ │ │ +
    │ │ │ │ +
    169
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    173 {
    │ │ │ │ +
    174 return Iterator(WrapperType(this),-1);
    │ │ │ │ +
    175 }
    │ │ │ │ +
    │ │ │ │ +
    176
    │ │ │ │ +
    177
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    186
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    189 {
    │ │ │ │ +
    190 return ConstIterator(WrapperType(this),0);
    │ │ │ │ +
    191 }
    │ │ │ │ +
    │ │ │ │ +
    192
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    195 {
    │ │ │ │ +
    196 return ConstIterator(WrapperType(this),n);
    │ │ │ │
    197 }
    │ │ │ │
    │ │ │ │
    198
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    203 {
    │ │ │ │ -
    204 return _data.size();
    │ │ │ │ -
    205 }
    │ │ │ │ -
    │ │ │ │ -
    206
    │ │ │ │ -
    │ │ │ │ -
    213 void resize(size_type new_size)
    │ │ │ │ -
    214 {
    │ │ │ │ -
    215 assert(new_size <= size());
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    202 {
    │ │ │ │ +
    203 return ConstIterator(WrapperType(this),n-1);
    │ │ │ │ +
    204 }
    │ │ │ │ +
    │ │ │ │ +
    205
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    209 {
    │ │ │ │ +
    210 return ConstIterator(WrapperType(this),-1);
    │ │ │ │ +
    211 }
    │ │ │ │ +
    │ │ │ │ +
    212
    │ │ │ │ +
    213
    │ │ │ │ +
    214
    │ │ │ │ +
    215 //===== vector space arithmetic
    │ │ │ │
    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 };
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    219 {
    │ │ │ │ +
    220 diag_ += y.diag_;
    │ │ │ │ +
    221 return *this;
    │ │ │ │ +
    222 }
    │ │ │ │ +
    │ │ │ │ +
    223
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    226 {
    │ │ │ │ +
    227 diag_ -= y.diag_;
    │ │ │ │ +
    228 return *this;
    │ │ │ │ +
    229 }
    │ │ │ │ +
    │ │ │ │ +
    230
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    233 {
    │ │ │ │ +
    234 diag_ += k;
    │ │ │ │ +
    235 return *this;
    │ │ │ │ +
    236 }
    │ │ │ │
    │ │ │ │ -
    235
    │ │ │ │ -
    236} // namespace Dune
    │ │ │ │
    237
    │ │ │ │ -
    238#endif // DUNE_COMMON_LRU_HH
    │ │ │ │ -
    A few common exception classes.
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    240 {
    │ │ │ │ +
    241 diag_ -= k;
    │ │ │ │ +
    242 return *this;
    │ │ │ │ +
    243 }
    │ │ │ │ +
    │ │ │ │ +
    244
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    247 {
    │ │ │ │ +
    248 diag_ *= k;
    │ │ │ │ +
    249 return *this;
    │ │ │ │ +
    250 }
    │ │ │ │ +
    │ │ │ │ +
    251
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    254 {
    │ │ │ │ +
    255 diag_ /= k;
    │ │ │ │ +
    256 return *this;
    │ │ │ │ +
    257 }
    │ │ │ │ +
    │ │ │ │ +
    258
    │ │ │ │ +
    259 //===== comparison ops
    │ │ │ │ +
    260
    │ │ │ │ +
    │ │ │ │ +
    262 bool operator==(const DiagonalMatrix& other) const
    │ │ │ │ +
    263 {
    │ │ │ │ +
    264 return diag_==other.diagonal();
    │ │ │ │ +
    265 }
    │ │ │ │ +
    │ │ │ │ +
    266
    │ │ │ │ +
    │ │ │ │ +
    268 bool operator!=(const DiagonalMatrix& other) const
    │ │ │ │ +
    269 {
    │ │ │ │ +
    270 return diag_!=other.diagonal();
    │ │ │ │ +
    271 }
    │ │ │ │ +
    │ │ │ │ +
    272
    │ │ │ │ +
    273
    │ │ │ │ +
    274 //===== linear maps
    │ │ │ │ +
    275
    │ │ │ │ +
    277 template<class X, class Y>
    │ │ │ │ +
    │ │ │ │ +
    278 void mv (const X& x, Y& y) const
    │ │ │ │ +
    279 {
    │ │ │ │ +
    280#ifdef DUNE_FMatrix_WITH_CHECKING
    │ │ │ │ +
    281 if (x.N()!=M()) DUNE_THROW(FMatrixError,"index out of range");
    │ │ │ │ +
    282 if (y.N()!=N()) DUNE_THROW(FMatrixError,"index out of range");
    │ │ │ │ +
    283#endif
    │ │ │ │ +
    284 for (size_type i=0; i<n; ++i)
    │ │ │ │ +
    285 y[i] = diag_[i] * x[i];
    │ │ │ │ +
    286 }
    │ │ │ │ +
    │ │ │ │ +
    287
    │ │ │ │ +
    289 template<class X, class Y>
    │ │ │ │ +
    │ │ │ │ +
    290 void mtv (const X& x, Y& y) const
    │ │ │ │ +
    291 {
    │ │ │ │ +
    292 mv(x, y);
    │ │ │ │ +
    293 }
    │ │ │ │ +
    │ │ │ │ +
    294
    │ │ │ │ +
    296 template<class X, class Y>
    │ │ │ │ +
    │ │ │ │ +
    297 void umv (const X& x, Y& y) const
    │ │ │ │ +
    298 {
    │ │ │ │ +
    299#ifdef DUNE_FMatrix_WITH_CHECKING
    │ │ │ │ +
    300 if (x.N()!=M()) DUNE_THROW(FMatrixError,"index out of range");
    │ │ │ │ +
    301 if (y.N()!=N()) DUNE_THROW(FMatrixError,"index out of range");
    │ │ │ │ +
    302#endif
    │ │ │ │ +
    303 for (size_type i=0; i<n; ++i)
    │ │ │ │ +
    304 y[i] += diag_[i] * x[i];
    │ │ │ │ +
    305 }
    │ │ │ │ +
    │ │ │ │ +
    306
    │ │ │ │ +
    308 template<class X, class Y>
    │ │ │ │ +
    │ │ │ │ +
    309 void umtv (const X& x, Y& y) const
    │ │ │ │ +
    310 {
    │ │ │ │ +
    311#ifdef DUNE_FMatrix_WITH_CHECKING
    │ │ │ │ +
    312 if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range");
    │ │ │ │ +
    313 if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range");
    │ │ │ │ +
    314#endif
    │ │ │ │ +
    315 for (size_type i=0; i<n; ++i)
    │ │ │ │ +
    316 y[i] += diag_[i] * x[i];
    │ │ │ │ +
    317 }
    │ │ │ │ +
    │ │ │ │ +
    318
    │ │ │ │ +
    320 template<class X, class Y>
    │ │ │ │ +
    │ │ │ │ +
    321 void umhv (const X& x, Y& y) const
    │ │ │ │ +
    322 {
    │ │ │ │ +
    323#ifdef DUNE_FMatrix_WITH_CHECKING
    │ │ │ │ +
    324 if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range");
    │ │ │ │ +
    325 if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range");
    │ │ │ │ +
    326#endif
    │ │ │ │ +
    327 for (size_type i=0; i<n; i++)
    │ │ │ │ +
    328 y[i] += conjugateComplex(diag_[i])*x[i];
    │ │ │ │ +
    329 }
    │ │ │ │ +
    │ │ │ │ +
    330
    │ │ │ │ +
    332 template<class X, class Y>
    │ │ │ │ +
    │ │ │ │ +
    333 void mmv (const X& x, Y& y) const
    │ │ │ │ +
    334 {
    │ │ │ │ +
    335#ifdef DUNE_FMatrix_WITH_CHECKING
    │ │ │ │ +
    336 if (x.N()!=M()) DUNE_THROW(FMatrixError,"index out of range");
    │ │ │ │ +
    337 if (y.N()!=N()) DUNE_THROW(FMatrixError,"index out of range");
    │ │ │ │ +
    338#endif
    │ │ │ │ +
    339 for (size_type i=0; i<n; ++i)
    │ │ │ │ +
    340 y[i] -= diag_[i] * x[i];
    │ │ │ │ +
    341 }
    │ │ │ │ +
    │ │ │ │ +
    342
    │ │ │ │ +
    344 template<class X, class Y>
    │ │ │ │ +
    │ │ │ │ +
    345 void mmtv (const X& x, Y& y) const
    │ │ │ │ +
    346 {
    │ │ │ │ +
    347#ifdef DUNE_FMatrix_WITH_CHECKING
    │ │ │ │ +
    348 if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range");
    │ │ │ │ +
    349 if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range");
    │ │ │ │ +
    350#endif
    │ │ │ │ +
    351 for (size_type i=0; i<n; ++i)
    │ │ │ │ +
    352 y[i] -= diag_[i] * x[i];
    │ │ │ │ +
    353 }
    │ │ │ │ +
    │ │ │ │ +
    354
    │ │ │ │ +
    356 template<class X, class Y>
    │ │ │ │ +
    │ │ │ │ +
    357 void mmhv (const X& x, Y& y) const
    │ │ │ │ +
    358 {
    │ │ │ │ +
    359#ifdef DUNE_FMatrix_WITH_CHECKING
    │ │ │ │ +
    360 if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range");
    │ │ │ │ +
    361 if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range");
    │ │ │ │ +
    362#endif
    │ │ │ │ +
    363 for (size_type i=0; i<n; i++)
    │ │ │ │ +
    364 y[i] -= conjugateComplex(diag_[i])*x[i];
    │ │ │ │ +
    365 }
    │ │ │ │ +
    │ │ │ │ +
    366
    │ │ │ │ +
    368 template<class X, class Y>
    │ │ │ │ +
    │ │ │ │ +
    369 void usmv (const typename FieldTraits<Y>::field_type & alpha,
    │ │ │ │ +
    370 const X& x, Y& y) const
    │ │ │ │ +
    371 {
    │ │ │ │ +
    372#ifdef DUNE_FMatrix_WITH_CHECKING
    │ │ │ │ +
    373 if (x.N()!=M()) DUNE_THROW(FMatrixError,"index out of range");
    │ │ │ │ +
    374 if (y.N()!=N()) DUNE_THROW(FMatrixError,"index out of range");
    │ │ │ │ +
    375#endif
    │ │ │ │ +
    376 for (size_type i=0; i<n; i++)
    │ │ │ │ +
    377 y[i] += alpha * diag_[i] * x[i];
    │ │ │ │ +
    378 }
    │ │ │ │ +
    │ │ │ │ +
    379
    │ │ │ │ +
    381 template<class X, class Y>
    │ │ │ │ +
    │ │ │ │ +
    382 void usmtv (const typename FieldTraits<Y>::field_type & alpha,
    │ │ │ │ +
    383 const X& x, Y& y) const
    │ │ │ │ +
    384 {
    │ │ │ │ +
    385#ifdef DUNE_FMatrix_WITH_CHECKING
    │ │ │ │ +
    386 if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range");
    │ │ │ │ +
    387 if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range");
    │ │ │ │ +
    388#endif
    │ │ │ │ +
    389 for (size_type i=0; i<n; i++)
    │ │ │ │ +
    390 y[i] += alpha * diag_[i] * x[i];
    │ │ │ │ +
    391 }
    │ │ │ │ +
    │ │ │ │ +
    392
    │ │ │ │ +
    394 template<class X, class Y>
    │ │ │ │ +
    │ │ │ │ +
    395 void usmhv (const typename FieldTraits<Y>::field_type & alpha,
    │ │ │ │ +
    396 const X& x, Y& y) const
    │ │ │ │ +
    397 {
    │ │ │ │ +
    398#ifdef DUNE_FMatrix_WITH_CHECKING
    │ │ │ │ +
    399 if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range");
    │ │ │ │ +
    400 if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range");
    │ │ │ │ +
    401#endif
    │ │ │ │ +
    402 for (size_type i=0; i<n; i++)
    │ │ │ │ +
    403 y[i] += alpha * conjugateComplex(diag_[i]) * x[i];
    │ │ │ │ +
    404 }
    │ │ │ │ +
    │ │ │ │ +
    405
    │ │ │ │ +
    406 //===== norms
    │ │ │ │ +
    407
    │ │ │ │ +
    │ │ │ │ +
    409 double frobenius_norm () const
    │ │ │ │ +
    410 {
    │ │ │ │ +
    411 return diag_.two_norm();
    │ │ │ │ +
    412 }
    │ │ │ │ +
    │ │ │ │ +
    413
    │ │ │ │ +
    │ │ │ │ +
    415 double frobenius_norm2 () const
    │ │ │ │ +
    416 {
    │ │ │ │ +
    417 return diag_.two_norm2();
    │ │ │ │ +
    418 }
    │ │ │ │ +
    │ │ │ │ +
    419
    │ │ │ │ +
    │ │ │ │ +
    421 double infinity_norm () const
    │ │ │ │ +
    422 {
    │ │ │ │ +
    423 return diag_.infinity_norm();
    │ │ │ │ +
    424 }
    │ │ │ │ +
    │ │ │ │ +
    425
    │ │ │ │ +
    │ │ │ │ +
    427 double infinity_norm_real () const
    │ │ │ │ +
    428 {
    │ │ │ │ +
    429 return diag_.infinity_norm_real();
    │ │ │ │ +
    430 }
    │ │ │ │ +
    │ │ │ │ +
    431
    │ │ │ │ +
    432
    │ │ │ │ +
    433
    │ │ │ │ +
    434 //===== solve
    │ │ │ │ +
    435
    │ │ │ │ +
    437 template<class V>
    │ │ │ │ +
    │ │ │ │ +
    438 void solve (V& x, const V& b) const
    │ │ │ │ +
    439 {
    │ │ │ │ +
    440 for (int i=0; i<n; i++)
    │ │ │ │ +
    441 x[i] = b[i]/diag_[i];
    │ │ │ │ +
    442 }
    │ │ │ │ +
    │ │ │ │ +
    443
    │ │ │ │ +
    │ │ │ │ +
    445 void invert()
    │ │ │ │ +
    446 {
    │ │ │ │ +
    447 using real_type = typename FieldTraits<K>::real_type;
    │ │ │ │ +
    448 for (int i=0; i<n; i++)
    │ │ │ │ +
    449 diag_[i] = real_type(1.0)/diag_[i];
    │ │ │ │ +
    450 }
    │ │ │ │ +
    │ │ │ │ +
    451
    │ │ │ │ +
    │ │ │ │ +
    453 K determinant () const
    │ │ │ │ +
    454 {
    │ │ │ │ +
    455 K det = diag_[0];
    │ │ │ │ +
    456 for (int i=1; i<n; i++)
    │ │ │ │ +
    457 det *= diag_[i];
    │ │ │ │ +
    458 return det;
    │ │ │ │ +
    459 }
    │ │ │ │ +
    │ │ │ │ +
    460
    │ │ │ │ +
    461
    │ │ │ │ +
    462
    │ │ │ │ +
    463 //===== matrix-matrix multiplication
    │ │ │ │ +
    464
    │ │ │ │ +
    467 template <class OtherScalar>
    │ │ │ │ +
    │ │ │ │ +
    468 friend auto operator* ( const DiagonalMatrix& matrixA,
    │ │ │ │ +
    469 const DiagonalMatrix<OtherScalar, n>& matrixB)
    │ │ │ │ +
    470 {
    │ │ │ │ + │ │ │ │ +
    472 for(int i=0; i<n; ++i)
    │ │ │ │ +
    473 result.diagonal(i) = matrixA.diagonal(i)*matrixB.diagonal(i);
    │ │ │ │ +
    474 return result;
    │ │ │ │ +
    475 }
    │ │ │ │ +
    │ │ │ │ +
    476
    │ │ │ │ +
    477
    │ │ │ │ +
    478
    │ │ │ │ +
    479 //===== sizes
    │ │ │ │ +
    480
    │ │ │ │ +
    │ │ │ │ +
    482 static constexpr size_type N ()
    │ │ │ │ +
    483 {
    │ │ │ │ +
    484 return n;
    │ │ │ │ +
    485 }
    │ │ │ │ +
    │ │ │ │ +
    486
    │ │ │ │ +
    │ │ │ │ +
    488 static constexpr size_type M ()
    │ │ │ │ +
    489 {
    │ │ │ │ +
    490 return n;
    │ │ │ │ +
    491 }
    │ │ │ │ +
    │ │ │ │ +
    492
    │ │ │ │ +
    493
    │ │ │ │ +
    494
    │ │ │ │ +
    495 //===== query
    │ │ │ │ +
    496
    │ │ │ │ +
    │ │ │ │ +
    498 bool exists (size_type i, size_type j) const
    │ │ │ │ +
    499 {
    │ │ │ │ +
    500 DUNE_ASSERT_BOUNDS(i >= 0 && i < n);
    │ │ │ │ +
    501 DUNE_ASSERT_BOUNDS(j >= 0 && j < n);
    │ │ │ │ +
    502 return i==j;
    │ │ │ │ +
    503 }
    │ │ │ │ +
    │ │ │ │ +
    504
    │ │ │ │ +
    505
    │ │ │ │ +
    506
    │ │ │ │ +
    │ │ │ │ +
    508 friend std::ostream& operator<< (std::ostream& s, const DiagonalMatrix<K,n>& a)
    │ │ │ │ +
    509 {
    │ │ │ │ +
    510 for (size_type i=0; i<n; i++) {
    │ │ │ │ +
    511 for (size_type j=0; j<n; j++)
    │ │ │ │ +
    512 s << ((i==j) ? a.diag_[i] : 0) << " ";
    │ │ │ │ +
    513 s << std::endl;
    │ │ │ │ +
    514 }
    │ │ │ │ +
    515 return s;
    │ │ │ │ +
    516 }
    │ │ │ │ +
    │ │ │ │ +
    517
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    520 {
    │ │ │ │ +
    521 return reference(const_cast<K*>(&diag_[i]), i);
    │ │ │ │ +
    522 }
    │ │ │ │ +
    │ │ │ │ +
    523
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    526 {
    │ │ │ │ +
    527 return const_reference(const_cast<K*>(&diag_[i]), i);
    │ │ │ │ +
    528 }
    │ │ │ │ +
    │ │ │ │ +
    529
    │ │ │ │ +
    │ │ │ │ +
    531 const K& diagonal(size_type i) const
    │ │ │ │ +
    532 {
    │ │ │ │ +
    533 return diag_[i];
    │ │ │ │ +
    534 }
    │ │ │ │ +
    │ │ │ │ +
    535
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    538 {
    │ │ │ │ +
    539 return diag_[i];
    │ │ │ │ +
    540 }
    │ │ │ │ +
    │ │ │ │ +
    541
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    544 {
    │ │ │ │ +
    545 return diag_;
    │ │ │ │ +
    546 }
    │ │ │ │ +
    │ │ │ │ +
    547
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    550 {
    │ │ │ │ +
    551 return diag_;
    │ │ │ │ +
    552 }
    │ │ │ │ +
    │ │ │ │ +
    553
    │ │ │ │ +
    554 private:
    │ │ │ │ +
    555
    │ │ │ │ +
    556 // the data, a FieldVector storing the diagonal
    │ │ │ │ +
    557 FieldVector<K,n> diag_;
    │ │ │ │ +
    558 };
    │ │ │ │ +
    │ │ │ │ +
    559
    │ │ │ │ +
    560 template< class K, int n >
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    562 {
    │ │ │ │ + │ │ │ │ + │ │ │ │ +
    565 };
    │ │ │ │ +
    │ │ │ │ +
    566
    │ │ │ │ +
    567
    │ │ │ │ +
    568#ifndef DOXYGEN // hide specialization
    │ │ │ │ +
    571 template< class K >
    │ │ │ │ +
    572 class DiagonalMatrix<K, 1> : public FieldMatrix<K, 1, 1>
    │ │ │ │ +
    573 {
    │ │ │ │ +
    574 typedef FieldMatrix<K,1,1> Base;
    │ │ │ │ +
    575 public:
    │ │ │ │ +
    577 typedef typename Base::size_type size_type;
    │ │ │ │ +
    578
    │ │ │ │ +
    581 constexpr static int blocklevel = 1;
    │ │ │ │ +
    582
    │ │ │ │ +
    583 typedef typename Base::row_type row_type;
    │ │ │ │ +
    584
    │ │ │ │ +
    585 typedef typename Base::row_reference row_reference;
    │ │ │ │ +
    586 typedef typename Base::const_row_reference const_row_reference;
    │ │ │ │ +
    587
    │ │ │ │ +
    590 constexpr static int rows = 1;
    │ │ │ │ +
    593 constexpr static int cols = 1;
    │ │ │ │ +
    594
    │ │ │ │ +
    595
    │ │ │ │ +
    597 constexpr DiagonalMatrix() = default;
    │ │ │ │ +
    598
    │ │ │ │ +
    600 DiagonalMatrix(const K& scalar)
    │ │ │ │ +
    601 {
    │ │ │ │ +
    602 (*this)[0][0] = scalar;
    │ │ │ │ +
    603 }
    │ │ │ │ +
    604
    │ │ │ │ +
    606 const K& diagonal(size_type) const
    │ │ │ │ +
    607 {
    │ │ │ │ +
    608 return (*this)[0][0];
    │ │ │ │ +
    609 }
    │ │ │ │ +
    610
    │ │ │ │ + │ │ │ │ +
    613 {
    │ │ │ │ +
    614 return (*this)[0][0];
    │ │ │ │ +
    615 }
    │ │ │ │ +
    616
    │ │ │ │ +
    618 const FieldVector<K,1>& diagonal() const
    │ │ │ │ +
    619 {
    │ │ │ │ +
    620 return (*this)[0];
    │ │ │ │ +
    621 }
    │ │ │ │ +
    622
    │ │ │ │ +
    624 FieldVector<K,1>& diagonal()
    │ │ │ │ +
    625 {
    │ │ │ │ +
    626 return (*this)[0];
    │ │ │ │ +
    627 }
    │ │ │ │ +
    628
    │ │ │ │ +
    630 DiagonalMatrix<K, 1> transposed() const
    │ │ │ │ +
    631 {
    │ │ │ │ +
    632 return *this;
    │ │ │ │ +
    633 }
    │ │ │ │ +
    634
    │ │ │ │ +
    637 template <class OtherScalar>
    │ │ │ │ +
    638 friend auto operator* ( const DiagonalMatrix& matrixA,
    │ │ │ │ +
    639 const DiagonalMatrix<OtherScalar, 1>& matrixB)
    │ │ │ │ +
    640 {
    │ │ │ │ +
    641 return DiagonalMatrix<typename PromotionTraits<K,OtherScalar>::PromotedType, 1>{matrixA.diagonal(0)*matrixB.diagonal(0)};
    │ │ │ │ +
    642 }
    │ │ │ │ +
    643
    │ │ │ │ +
    644 };
    │ │ │ │ +
    645#endif
    │ │ │ │ +
    646
    │ │ │ │ +
    647
    │ │ │ │ +
    648 template<class DiagonalMatrixType>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    650 {
    │ │ │ │ +
    651 typedef typename DiagonalMatrixType::reference reference;
    │ │ │ │ +
    652 typedef typename DiagonalMatrixType::const_reference const_reference;
    │ │ │ │ +
    653 typedef typename DiagonalMatrixType::field_type K;
    │ │ │ │ + │ │ │ │ +
    655 typedef std::size_t size_type;
    │ │ │ │ + │ │ │ │ +
    657
    │ │ │ │ +
    658 friend class ContainerWrapperIterator<const MyType, reference, reference>;
    │ │ │ │ +
    659 friend class ContainerWrapperIterator<const MyType, const_reference, const_reference>;
    │ │ │ │ +
    660
    │ │ │ │ +
    661 public:
    │ │ │ │ +
    662
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    664 mat_(0)
    │ │ │ │ +
    665 {}
    │ │ │ │ +
    │ │ │ │ +
    666
    │ │ │ │ +
    │ │ │ │ +
    667 DiagonalMatrixWrapper(const DiagonalMatrixType* mat) :
    │ │ │ │ +
    668 mat_(const_cast<DiagonalMatrixType*>(mat))
    │ │ │ │ +
    669 {}
    │ │ │ │ +
    │ │ │ │ +
    670
    │ │ │ │ +
    │ │ │ │ +
    671 size_type realIndex(int i) const
    │ │ │ │ +
    672 {
    │ │ │ │ +
    673 return i;
    │ │ │ │ +
    674 }
    │ │ │ │ +
    │ │ │ │ +
    675
    │ │ │ │ +
    │ │ │ │ +
    676 row_type* pointer(int i) const
    │ │ │ │ +
    677 {
    │ │ │ │ +
    678 row_ = row_type(&(mat_->diagonal(i)), i);
    │ │ │ │ +
    679 return &row_;
    │ │ │ │ +
    680 }
    │ │ │ │ +
    │ │ │ │ +
    681
    │ │ │ │ +
    │ │ │ │ +
    682 bool identical(const DiagonalMatrixWrapper& other) const
    │ │ │ │ +
    683 {
    │ │ │ │ +
    684 return mat_==other.mat_;
    │ │ │ │ +
    685 }
    │ │ │ │ +
    │ │ │ │ +
    686
    │ │ │ │ +
    687 private:
    │ │ │ │ +
    688
    │ │ │ │ +
    689 mutable DiagonalMatrixType* mat_;
    │ │ │ │ +
    690 mutable row_type row_;
    │ │ │ │ +
    691 };
    │ │ │ │ +
    │ │ │ │ +
    692
    │ │ │ │ +
    696 template< class K, int n >
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    698 {
    │ │ │ │ +
    699 template<class DiagonalMatrixType>
    │ │ │ │ + │ │ │ │ +
    701 friend class ContainerWrapperIterator<DiagonalRowVectorConst<K,n>, const K, const K&>;
    │ │ │ │ +
    702
    │ │ │ │ +
    703 public:
    │ │ │ │ +
    704 // remember size of vector
    │ │ │ │ +
    705 constexpr static int dimension = n;
    │ │ │ │ +
    706
    │ │ │ │ +
    707 // standard constructor and everything is sufficient ...
    │ │ │ │ +
    708
    │ │ │ │ +
    709 //===== type definitions and constants
    │ │ │ │ +
    710
    │ │ │ │ +
    712 typedef K field_type;
    │ │ │ │ +
    713
    │ │ │ │ +
    715 typedef K block_type;
    │ │ │ │ +
    716
    │ │ │ │ +
    718 typedef std::size_t size_type;
    │ │ │ │ +
    719
    │ │ │ │ +
    721 constexpr static int blocklevel = 1;
    │ │ │ │ +
    722
    │ │ │ │ +
    724 constexpr static int size = n;
    │ │ │ │ +
    725
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    728 p_(0),
    │ │ │ │ +
    729 row_(0)
    │ │ │ │ +
    730 {}
    │ │ │ │ +
    │ │ │ │ +
    731
    │ │ │ │ +
    │ │ │ │ +
    733 explicit DiagonalRowVectorConst (K* p, int col) :
    │ │ │ │ +
    734 p_(p),
    │ │ │ │ +
    735 row_(col)
    │ │ │ │ +
    736 {}
    │ │ │ │ +
    │ │ │ │ +
    737
    │ │ │ │ +
    738 //===== access to components
    │ │ │ │ +
    739
    │ │ │ │ +
    │ │ │ │ +
    741 const K& operator[] ([[maybe_unused]] size_type i) const
    │ │ │ │ +
    742 {
    │ │ │ │ + │ │ │ │ +
    744 return *p_;
    │ │ │ │ +
    745 }
    │ │ │ │ +
    │ │ │ │ +
    746
    │ │ │ │ +
    747 // check if row is identical to other row (not only identical values)
    │ │ │ │ +
    748 // since this is a proxy class we need to check equality of the stored pointer
    │ │ │ │ +
    │ │ │ │ +
    749 bool identical(const DiagonalRowVectorConst<K,n>& other) const
    │ │ │ │ +
    750 {
    │ │ │ │ +
    751 return ((p_ == other.p_)and (row_ == other.row_));
    │ │ │ │ +
    752 }
    │ │ │ │ +
    │ │ │ │ +
    753
    │ │ │ │ + │ │ │ │ + │ │ │ │ +
    758
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    761 {
    │ │ │ │ +
    762 return ConstIterator(*this,0);
    │ │ │ │ +
    763 }
    │ │ │ │ +
    │ │ │ │ +
    764
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    767 {
    │ │ │ │ +
    768 return ConstIterator(*this,1);
    │ │ │ │ +
    769 }
    │ │ │ │ +
    │ │ │ │ +
    770
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    774 {
    │ │ │ │ +
    775 return ConstIterator(*this,0);
    │ │ │ │ +
    776 }
    │ │ │ │ +
    │ │ │ │ +
    777
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    781 {
    │ │ │ │ +
    782 return ConstIterator(*this,-1);
    │ │ │ │ +
    783 }
    │ │ │ │ +
    │ │ │ │ +
    784
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    787 {
    │ │ │ │ +
    788 return ((p_==y.p_)and (row_==y.row_));
    │ │ │ │ +
    789 }
    │ │ │ │ +
    │ │ │ │ +
    790
    │ │ │ │ +
    791 //===== sizes
    │ │ │ │ +
    792
    │ │ │ │ +
    │ │ │ │ +
    794 size_type N () const
    │ │ │ │ +
    795 {
    │ │ │ │ +
    796 return n;
    │ │ │ │ +
    797 }
    │ │ │ │ +
    │ │ │ │ +
    798
    │ │ │ │ +
    │ │ │ │ +
    800 size_type dim () const
    │ │ │ │ +
    801 {
    │ │ │ │ +
    802 return n;
    │ │ │ │ +
    803 }
    │ │ │ │ +
    │ │ │ │ +
    804
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    807 {
    │ │ │ │ +
    808 return row_;
    │ │ │ │ +
    809 }
    │ │ │ │ +
    │ │ │ │ +
    810
    │ │ │ │ +
    │ │ │ │ +
    812 const K& diagonal() const
    │ │ │ │ +
    813 {
    │ │ │ │ +
    814 return *p_;
    │ │ │ │ +
    815 }
    │ │ │ │ +
    │ │ │ │ +
    816
    │ │ │ │ +
    817 protected:
    │ │ │ │ +
    818
    │ │ │ │ +
    │ │ │ │ +
    819 size_type realIndex([[maybe_unused]] int i) const
    │ │ │ │ +
    820 {
    │ │ │ │ +
    821 return rowIndex();
    │ │ │ │ +
    822 }
    │ │ │ │ +
    │ │ │ │ +
    823
    │ │ │ │ +
    │ │ │ │ +
    824 K* pointer([[maybe_unused]] size_type i) const
    │ │ │ │ +
    825 {
    │ │ │ │ +
    826 return const_cast<K*>(p_);
    │ │ │ │ +
    827 }
    │ │ │ │ +
    │ │ │ │ +
    828
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    830 {
    │ │ │ │ +
    831 return this;
    │ │ │ │ +
    832 }
    │ │ │ │ +
    │ │ │ │ +
    833
    │ │ │ │ +
    834 // the data, very simply a pointer to the diagonal value and the row number
    │ │ │ │ +
    835 K* p_;
    │ │ │ │ + │ │ │ │ +
    837 };
    │ │ │ │ +
    │ │ │ │ +
    838
    │ │ │ │ +
    839 template< class K, int n >
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    841 {
    │ │ │ │ +
    842 template<class DiagonalMatrixType>
    │ │ │ │ + │ │ │ │ +
    844 friend class ContainerWrapperIterator<DiagonalRowVector<K,n>, K, K&>;
    │ │ │ │ +
    845
    │ │ │ │ +
    846 public:
    │ │ │ │ +
    847 // standard constructor and everything is sufficient ...
    │ │ │ │ +
    848
    │ │ │ │ +
    849 //===== type definitions and constants
    │ │ │ │ +
    850
    │ │ │ │ +
    852 typedef K field_type;
    │ │ │ │ +
    853
    │ │ │ │ +
    855 typedef K block_type;
    │ │ │ │ +
    856
    │ │ │ │ +
    858 typedef std::size_t size_type;
    │ │ │ │ +
    859
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    862 {}
    │ │ │ │ +
    │ │ │ │ +
    863
    │ │ │ │ +
    │ │ │ │ +
    865 explicit DiagonalRowVector (K* p, int col) : DiagonalRowVectorConst<K,n>(p, col)
    │ │ │ │ +
    866 {}
    │ │ │ │ +
    │ │ │ │ +
    867
    │ │ │ │ +
    868 //===== assignment from scalar
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    871 {
    │ │ │ │ +
    872 *p_ = k;
    │ │ │ │ +
    873 return *this;
    │ │ │ │ +
    874 }
    │ │ │ │ +
    │ │ │ │ +
    875
    │ │ │ │ +
    876 //===== access to components
    │ │ │ │ +
    877
    │ │ │ │ +
    │ │ │ │ +
    879 K& operator[] ([[maybe_unused]] size_type i)
    │ │ │ │ +
    880 {
    │ │ │ │ + │ │ │ │ +
    882 return *p_;
    │ │ │ │ +
    883 }
    │ │ │ │ +
    │ │ │ │ +
    884
    │ │ │ │ + │ │ │ │ + │ │ │ │ +
    889
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    892 {
    │ │ │ │ +
    893 return Iterator(*this, 0);
    │ │ │ │ +
    894 }
    │ │ │ │ +
    │ │ │ │ +
    895
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    898 {
    │ │ │ │ +
    899 return Iterator(*this, 1);
    │ │ │ │ +
    900 }
    │ │ │ │ +
    │ │ │ │ +
    901
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    905 {
    │ │ │ │ +
    906 return Iterator(*this, 0);
    │ │ │ │ +
    907 }
    │ │ │ │ +
    │ │ │ │ +
    908
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    912 {
    │ │ │ │ +
    913 return Iterator(*this, -1);
    │ │ │ │ +
    914 }
    │ │ │ │ +
    │ │ │ │ +
    915
    │ │ │ │ + │ │ │ │ + │ │ │ │ +
    920
    │ │ │ │ + │ │ │ │ +
    922 using DiagonalRowVectorConst<K,n>::operator[];
    │ │ │ │ +
    923 using DiagonalRowVectorConst<K,n>::operator==;
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    928 using DiagonalRowVectorConst<K,n>::N;
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    932
    │ │ │ │ +
    933 protected:
    │ │ │ │ +
    934
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    936 {
    │ │ │ │ +
    937 return this;
    │ │ │ │ +
    938 }
    │ │ │ │ +
    │ │ │ │ +
    939
    │ │ │ │ +
    940 private:
    │ │ │ │ +
    941
    │ │ │ │ + │ │ │ │ + │ │ │ │ +
    944 };
    │ │ │ │ +
    │ │ │ │ +
    945
    │ │ │ │ +
    946
    │ │ │ │ +
    947 // implement type traits
    │ │ │ │ +
    948 template<class K, int n>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    950 {
    │ │ │ │ + │ │ │ │ +
    952 };
    │ │ │ │ +
    │ │ │ │ +
    953
    │ │ │ │ +
    954 template<class K, int n>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    956 {
    │ │ │ │ + │ │ │ │ +
    958 };
    │ │ │ │ +
    │ │ │ │ +
    959
    │ │ │ │ +
    960 template<class K, int n>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    962 {
    │ │ │ │ + │ │ │ │ +
    964 };
    │ │ │ │ +
    │ │ │ │ +
    965
    │ │ │ │ +
    966 template<class K, int n>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    968 {
    │ │ │ │ + │ │ │ │ +
    970 };
    │ │ │ │ +
    │ │ │ │ +
    971
    │ │ │ │ +
    972
    │ │ │ │ +
    973
    │ │ │ │ +
    996 template<class CW, class T, class R>
    │ │ │ │ +
    │ │ │ │ +
    997 class ContainerWrapperIterator : public BidirectionalIteratorFacade<ContainerWrapperIterator<CW,T,R>,T, R, int>
    │ │ │ │ +
    998 {
    │ │ │ │ +
    999 typedef typename std::remove_const<CW>::type NonConstCW;
    │ │ │ │ +
    1000
    │ │ │ │ +
    1001 friend class ContainerWrapperIterator<CW, typename mutable_reference<T>::type, typename mutable_reference<R>::type>;
    │ │ │ │ +
    1002 friend class ContainerWrapperIterator<CW, typename const_reference<T>::type, typename const_reference<R>::type>;
    │ │ │ │ +
    1003
    │ │ │ │ +
    1004 typedef ContainerWrapperIterator<CW, typename mutable_reference<T>::type, typename mutable_reference<R>::type> MyType;
    │ │ │ │ +
    1005 typedef ContainerWrapperIterator<CW, typename const_reference<T>::type, typename const_reference<R>::type> MyConstType;
    │ │ │ │ +
    1006
    │ │ │ │ +
    1007 public:
    │ │ │ │ +
    1008
    │ │ │ │ +
    1009 // Constructors needed by the facade iterators.
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    1011 containerWrapper_(),
    │ │ │ │ +
    1012 position_(0)
    │ │ │ │ +
    1013 {}
    │ │ │ │ +
    │ │ │ │ +
    1014
    │ │ │ │ +
    │ │ │ │ +
    1015 ContainerWrapperIterator(CW containerWrapper, int position) :
    │ │ │ │ +
    1016 containerWrapper_(containerWrapper),
    │ │ │ │ +
    1017 position_(position)
    │ │ │ │ +
    1018 {}
    │ │ │ │ +
    │ │ │ │ +
    1019
    │ │ │ │ +
    1020 template<class OtherContainerWrapperIteratorType>
    │ │ │ │ +
    │ │ │ │ +
    1021 ContainerWrapperIterator(OtherContainerWrapperIteratorType& other) :
    │ │ │ │ +
    1022 containerWrapper_(other.containerWrapper_),
    │ │ │ │ +
    1023 position_(other.position_)
    │ │ │ │ +
    1024 {}
    │ │ │ │ +
    │ │ │ │ +
    1025
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    1027 containerWrapper_(other.containerWrapper_),
    │ │ │ │ +
    1028 position_(other.position_)
    │ │ │ │ +
    1029 {}
    │ │ │ │ +
    │ │ │ │ +
    1030
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    1032 containerWrapper_(other.containerWrapper_),
    │ │ │ │ +
    1033 position_(other.position_)
    │ │ │ │ +
    1034 {}
    │ │ │ │ +
    │ │ │ │ +
    1035
    │ │ │ │ +
    1036 template<class OtherContainerWrapperIteratorType>
    │ │ │ │ +
    │ │ │ │ +
    1037 ContainerWrapperIterator& operator=(OtherContainerWrapperIteratorType& other)
    │ │ │ │ +
    1038 {
    │ │ │ │ +
    1039 containerWrapper_ = other.containerWrapper_;
    │ │ │ │ +
    1040 position_ = other.position_;
    │ │ │ │ +
    1041 return *this;
    │ │ │ │ +
    1042 }
    │ │ │ │ +
    │ │ │ │ +
    1043
    │ │ │ │ +
    1044 // This operator is needed since we can not get the address of the
    │ │ │ │ +
    1045 // temporary object returned by dereference
    │ │ │ │ +
    │ │ │ │ +
    1046 T* operator->() const
    │ │ │ │ +
    1047 {
    │ │ │ │ +
    1048 return containerWrapper_.pointer(position_);
    │ │ │ │ +
    1049 }
    │ │ │ │ +
    │ │ │ │ +
    1050
    │ │ │ │ +
    1051 // Methods needed by the forward iterator
    │ │ │ │ +
    │ │ │ │ +
    1052 bool equals(const MyType& other) const
    │ │ │ │ +
    1053 {
    │ │ │ │ +
    1054 return position_ == other.position_ && containerWrapper_.identical(other.containerWrapper_);
    │ │ │ │ +
    1055 }
    │ │ │ │ +
    │ │ │ │ +
    1056
    │ │ │ │ +
    │ │ │ │ +
    1057 bool equals(const MyConstType& other) const
    │ │ │ │ +
    1058 {
    │ │ │ │ +
    1059 return position_ == other.position_ && containerWrapper_.identical(other.containerWrapper_);
    │ │ │ │ +
    1060 }
    │ │ │ │ +
    │ │ │ │ +
    1061
    │ │ │ │ +
    │ │ │ │ +
    1062 R dereference() const
    │ │ │ │ +
    1063 {
    │ │ │ │ +
    1064 return *containerWrapper_.pointer(position_);
    │ │ │ │ +
    1065 }
    │ │ │ │ +
    │ │ │ │ +
    1066
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    1068 {
    │ │ │ │ +
    1069 ++position_;
    │ │ │ │ +
    1070 }
    │ │ │ │ +
    │ │ │ │ +
    1071
    │ │ │ │ +
    1072 // Additional function needed by BidirectionalIterator
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    1074 {
    │ │ │ │ +
    1075 --position_;
    │ │ │ │ +
    1076 }
    │ │ │ │ +
    │ │ │ │ +
    1077
    │ │ │ │ +
    1078 // Additional function needed by RandomAccessIterator
    │ │ │ │ +
    │ │ │ │ +
    1079 R elementAt(int i) const
    │ │ │ │ +
    1080 {
    │ │ │ │ +
    1081 return *containerWrapper_.pointer(position_+i);
    │ │ │ │ +
    1082 }
    │ │ │ │ +
    │ │ │ │ +
    1083
    │ │ │ │ +
    │ │ │ │ +
    1084 void advance(int n)
    │ │ │ │ +
    1085 {
    │ │ │ │ +
    1086 position_=position_+n;
    │ │ │ │ +
    1087 }
    │ │ │ │ +
    │ │ │ │ +
    1088
    │ │ │ │ +
    1089 template<class OtherContainerWrapperIteratorType>
    │ │ │ │ +
    │ │ │ │ +
    1090 std::ptrdiff_t distanceTo(OtherContainerWrapperIteratorType& other) const
    │ │ │ │ +
    1091 {
    │ │ │ │ +
    1092 assert(containerWrapper_.identical(other));
    │ │ │ │ +
    1093 return other.position_ - position_;
    │ │ │ │ +
    1094 }
    │ │ │ │ +
    │ │ │ │ +
    1095
    │ │ │ │ +
    │ │ │ │ +
    1096 std::ptrdiff_t index() const
    │ │ │ │ +
    1097 {
    │ │ │ │ +
    1098 return containerWrapper_.realIndex(position_);
    │ │ │ │ +
    1099 }
    │ │ │ │ +
    │ │ │ │ +
    1100
    │ │ │ │ +
    1101 private:
    │ │ │ │ +
    1102 NonConstCW containerWrapper_;
    │ │ │ │ +
    1103 size_t position_;
    │ │ │ │ +
    1104 };
    │ │ │ │ +
    │ │ │ │ +
    1105
    │ │ │ │ +
    1106 template <class DenseMatrix, class field, int N>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    1108 static void apply(DenseMatrix& denseMatrix,
    │ │ │ │ +
    1109 DiagonalMatrix<field, N> const& rhs) {
    │ │ │ │ +
    1110 DUNE_ASSERT_BOUNDS(denseMatrix.M() == N);
    │ │ │ │ +
    1111 DUNE_ASSERT_BOUNDS(denseMatrix.N() == N);
    │ │ │ │ +
    1112 denseMatrix = field(0);
    │ │ │ │ +
    1113 for (int i = 0; i < N; ++i)
    │ │ │ │ +
    1114 denseMatrix[i][i] = rhs.diagonal()[i];
    │ │ │ │ +
    1115 }
    │ │ │ │ +
    │ │ │ │ +
    1116 };
    │ │ │ │ +
    │ │ │ │ +
    1117 /* @} */
    │ │ │ │ +
    1118} // end namespace
    │ │ │ │ +
    1119#endif
    │ │ │ │ +
    A few common exception classes.
    │ │ │ │ +
    Implements a matrix constructed from a given type representing a field and a compile-time given numbe...
    │ │ │ │ +
    Implements a vector constructed from a given type representing a field and a compile-time given size.
    │ │ │ │ +
    Macro for wrapping boundary checks.
    │ │ │ │ +
    Implements a matrix constructed from a given type representing a field and compile-time given number ...
    │ │ │ │ +
    Implements a generic iterator class for writing stl conformant iterators.
    │ │ │ │ +
    Traits for type conversions and type information.
    │ │ │ │ +
    #define DUNE_ASSERT_BOUNDS(cond)
    If DUNE_CHECK_BOUNDS is defined: check if condition cond holds; otherwise, do nothing.
    Definition boundschecking.hh:30
    │ │ │ │ +
    ConstIterator beforeBegin() const
    Definition diagonalmatrix.hh:208
    │ │ │ │ +
    DiagonalMatrix< K, n > transposed() const
    Return transposed of the matrix as DiagonalMatrix.
    Definition diagonalmatrix.hh:136
    │ │ │ │ +
    void mmhv(const X &x, Y &y) const
    y -= A^H x
    Definition diagonalmatrix.hh:357
    │ │ │ │ +
    DiagonalMatrix & operator*=(const K &k)
    vector space multiplication with scalar
    Definition diagonalmatrix.hh:246
    │ │ │ │ +
    FieldTraits< K >::field_type field_type
    Definition diagonalmatrix.hh:563
    │ │ │ │ +
    std::size_t size_type
    The type used for the index access and size operations.
    Definition diagonalmatrix.hh:67
    │ │ │ │ +
    size_type dim() const
    dimension of the vector space
    Definition diagonalmatrix.hh:800
    │ │ │ │ +
    ConstIterator ConstRowIterator
    rename the iterators for easier access
    Definition diagonalmatrix.hh:183
    │ │ │ │ +
    row_type row_reference
    Definition diagonalmatrix.hh:75
    │ │ │ │ +
    K & operator[](size_type i)
    random access
    Definition diagonalmatrix.hh:879
    │ │ │ │ +
    ContainerWrapperIterator & operator=(OtherContainerWrapperIteratorType &other)
    Definition diagonalmatrix.hh:1037
    │ │ │ │ +
    static constexpr int rows
    The number of rows.
    Definition diagonalmatrix.hh:81
    │ │ │ │ +
    static constexpr size_type M()
    number of blocks in column direction
    Definition diagonalmatrix.hh:488
    │ │ │ │ +
    FieldVector< K, n > & diagonal()
    Get reference to diagonal vector.
    Definition diagonalmatrix.hh:549
    │ │ │ │ +
    void usmhv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) const
    y += alpha A^H x
    Definition diagonalmatrix.hh:395
    │ │ │ │ +
    Iterator iterator
    typedef for stl compliant access
    Definition diagonalmatrix.hh:888
    │ │ │ │ +
    void increment()
    Definition diagonalmatrix.hh:1067
    │ │ │ │ +
    static constexpr int blocklevel
    The number of block levels we contain. This is the leaf, that is, 1.
    Definition diagonalmatrix.hh:70
    │ │ │ │ +
    DiagonalRowVectorConst< K, n > type
    Definition diagonalmatrix.hh:957
    │ │ │ │ +
    T * operator->() const
    Definition diagonalmatrix.hh:1046
    │ │ │ │ +
    static constexpr int size
    The size of this vector.
    Definition diagonalmatrix.hh:724
    │ │ │ │ +
    K * pointer(size_type i) const
    Definition diagonalmatrix.hh:824
    │ │ │ │ +
    K field_type
    export the type representing the field
    Definition diagonalmatrix.hh:712
    │ │ │ │ +
    DiagonalRowVector< K, n > type
    Definition diagonalmatrix.hh:963
    │ │ │ │ +
    ConstIterator beforeEnd() const
    Definition diagonalmatrix.hh:773
    │ │ │ │ +
    const_row_type::ConstIterator ConstColIterator
    rename the iterators for easier access
    Definition diagonalmatrix.hh:185
    │ │ │ │ +
    bool exists(size_type i, size_type j) const
    return true when (i,j) is in pattern
    Definition diagonalmatrix.hh:498
    │ │ │ │ +
    ContainerWrapperIterator< const WrapperType, const_reference, const_reference > ConstIterator
    Iterator class for sequential access.
    Definition diagonalmatrix.hh:179
    │ │ │ │ +
    const_row_type const_row_reference
    Definition diagonalmatrix.hh:78
    │ │ │ │ +
    static constexpr size_type size()
    Definition diagonalmatrix.hh:87
    │ │ │ │ +
    size_type row_
    Definition diagonalmatrix.hh:836
    │ │ │ │ +
    ContainerWrapperIterator(CW containerWrapper, int position)
    Definition diagonalmatrix.hh:1015
    │ │ │ │ +
    DiagonalRowVector(K *p, int col)
    Constructor making vector with identical coordinates.
    Definition diagonalmatrix.hh:865
    │ │ │ │ +
    K & diagonal(size_type i)
    Get reference to diagonal entry.
    Definition diagonalmatrix.hh:537
    │ │ │ │ +
    void solve(V &x, const V &b) const
    Solve system A x = b.
    Definition diagonalmatrix.hh:438
    │ │ │ │ +
    static constexpr size_type N()
    number of blocks in row direction
    Definition diagonalmatrix.hh:482
    │ │ │ │ +
    Iterator beforeBegin()
    Definition diagonalmatrix.hh:911
    │ │ │ │ +
    ContainerWrapperIterator(OtherContainerWrapperIteratorType &other)
    Definition diagonalmatrix.hh:1021
    │ │ │ │ +
    const_reference operator[](size_type i) const
    Return const_reference object as row replacement.
    Definition diagonalmatrix.hh:525
    │ │ │ │ +
    Iterator iterator
    typedef for stl compliant access
    Definition diagonalmatrix.hh:145
    │ │ │ │ +
    ConstIterator begin() const
    begin ConstIterator
    Definition diagonalmatrix.hh:760
    │ │ │ │ +
    ConstIterator const_iterator
    typedef for stl compliant access
    Definition diagonalmatrix.hh:919
    │ │ │ │ +
    bool identical(const DiagonalRowVectorConst< K, n > &other) const
    Definition diagonalmatrix.hh:749
    │ │ │ │ +
    DiagonalMatrix & operator-=(const DiagonalMatrix &y)
    vector space subtraction
    Definition diagonalmatrix.hh:225
    │ │ │ │ +
    DiagonalRowVectorConst(K *p, int col)
    Constructor making vector with identical coordinates.
    Definition diagonalmatrix.hh:733
    │ │ │ │ +
    void mmtv(const X &x, Y &y) const
    y -= A^T x
    Definition diagonalmatrix.hh:345
    │ │ │ │ +
    static constexpr int blocklevel
    The number of block levels we contain.
    Definition diagonalmatrix.hh:721
    │ │ │ │ +
    row_type * pointer(int i) const
    Definition diagonalmatrix.hh:676
    │ │ │ │ +
    DiagonalMatrix(const K &k)
    Constructor initializing the whole matrix with a scalar.
    Definition diagonalmatrix.hh:98
    │ │ │ │ +
    ContainerWrapperIterator< DiagonalRowVector< K, n >, K, K & > Iterator
    Iterator class for sequential access.
    Definition diagonalmatrix.hh:886
    │ │ │ │ +
    R elementAt(int i) const
    Definition diagonalmatrix.hh:1079
    │ │ │ │ +
    std::ptrdiff_t distanceTo(OtherContainerWrapperIteratorType &other) const
    Definition diagonalmatrix.hh:1090
    │ │ │ │ +
    Iterator beforeEnd()
    Definition diagonalmatrix.hh:904
    │ │ │ │ +
    void umtv(const X &x, Y &y) const
    y += A^T x
    Definition diagonalmatrix.hh:309
    │ │ │ │ +
    ConstIterator const_iterator
    typedef for stl compliant access
    Definition diagonalmatrix.hh:757
    │ │ │ │ +
    double infinity_norm_real() const
    simplified infinity norm (uses Manhattan norm for complex values)
    Definition diagonalmatrix.hh:427
    │ │ │ │ +
    DiagonalMatrixWrapper(const DiagonalMatrixType *mat)
    Definition diagonalmatrix.hh:667
    │ │ │ │ +
    void umv(const X &x, Y &y) const
    y += A x
    Definition diagonalmatrix.hh:297
    │ │ │ │ +
    ContainerWrapperIterator< const WrapperType, reference, reference > Iterator
    Iterator class for sequential access.
    Definition diagonalmatrix.hh:143
    │ │ │ │ +
    DiagonalRowVector< K, n > type
    Definition diagonalmatrix.hh:969
    │ │ │ │ +
    void mv(const X &x, Y &y) const
    y = A x
    Definition diagonalmatrix.hh:278
    │ │ │ │ +
    double frobenius_norm() const
    frobenius norm: sqrt(sum over squared values of entries)
    Definition diagonalmatrix.hh:409
    │ │ │ │ +
    ConstIterator end() const
    end iterator
    Definition diagonalmatrix.hh:194
    │ │ │ │ +
    static constexpr int cols
    The number of columns.
    Definition diagonalmatrix.hh:83
    │ │ │ │ +
    static constexpr int dimension
    Definition diagonalmatrix.hh:705
    │ │ │ │ +
    K * p_
    Definition diagonalmatrix.hh:835
    │ │ │ │ +
    size_type rowIndex() const
    index of this row in surrounding matrix
    Definition diagonalmatrix.hh:806
    │ │ │ │ +
    R dereference() const
    Definition diagonalmatrix.hh:1062
    │ │ │ │ +
    DiagonalRowVector & operator=(const K &k)
    Assignment operator for scalar.
    Definition diagonalmatrix.hh:870
    │ │ │ │ +
    bool operator!=(const DiagonalMatrix &other) const
    incomparison operator
    Definition diagonalmatrix.hh:268
    │ │ │ │ +
    value_type field_type
    Definition diagonalmatrix.hh:61
    │ │ │ │ +
    void advance(int n)
    Definition diagonalmatrix.hh:1084
    │ │ │ │ +
    ConstIterator begin() const
    begin iterator
    Definition diagonalmatrix.hh:188
    │ │ │ │ +
    Iterator begin()
    begin iterator
    Definition diagonalmatrix.hh:891
    │ │ │ │ +
    void mmv(const X &x, Y &y) const
    y -= A x
    Definition diagonalmatrix.hh:333
    │ │ │ │ +
    DiagonalMatrix & operator/=(const K &k)
    vector space division by scalar
    Definition diagonalmatrix.hh:253
    │ │ │ │ +
    ConstIterator const_iterator
    typedef for stl compliant access
    Definition diagonalmatrix.hh:181
    │ │ │ │ +
    const_row_type const_reference
    Definition diagonalmatrix.hh:77
    │ │ │ │ +
    bool identical(const DiagonalMatrix< K, n > &other) const
    Check if matrix is the same object as the other matrix.
    Definition diagonalmatrix.hh:130
    │ │ │ │ +
    friend auto operator*(const DiagonalMatrix &matrixA, const DiagonalMatrix< OtherScalar, n > &matrixB)
    Matrix-matrix multiplication.
    Definition diagonalmatrix.hh:468
    │ │ │ │ +
    size_type realIndex(int i) const
    Definition diagonalmatrix.hh:671
    │ │ │ │ +
    Iterator end()
    end iterator
    Definition diagonalmatrix.hh:158
    │ │ │ │ +
    const K & operator[](size_type i) const
    same for read only access
    Definition diagonalmatrix.hh:741
    │ │ │ │ +
    DiagonalRowVector()
    Constructor making uninitialized vector.
    Definition diagonalmatrix.hh:861
    │ │ │ │ +
    row_type reference
    Definition diagonalmatrix.hh:74
    │ │ │ │ +
    DiagonalRowVectorConst * operator&()
    Definition diagonalmatrix.hh:829
    │ │ │ │ +
    bool operator==(const DiagonalRowVectorConst &y) const
    Binary vector comparison.
    Definition diagonalmatrix.hh:786
    │ │ │ │ +
    double frobenius_norm2() const
    square of frobenius norm, need for block recursion
    Definition diagonalmatrix.hh:415
    │ │ │ │ +
    constexpr DiagonalMatrix()=default
    Default constructor.
    │ │ │ │ +
    void mtv(const X &x, Y &y) const
    y = A^T x
    Definition diagonalmatrix.hh:290
    │ │ │ │ +
    ContainerWrapperIterator< DiagonalRowVectorConst< K, n >, const K, const K & > ConstIterator
    ConstIterator class for sequential access.
    Definition diagonalmatrix.hh:917
    │ │ │ │ +
    bool identical(const DiagonalMatrixWrapper &other) const
    Definition diagonalmatrix.hh:682
    │ │ │ │ +
    void usmtv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) const
    y += alpha A^T x
    Definition diagonalmatrix.hh:382
    │ │ │ │ +
    void decrement()
    Definition diagonalmatrix.hh:1073
    │ │ │ │ +
    std::ptrdiff_t index() const
    Definition diagonalmatrix.hh:1096
    │ │ │ │ +
    const FieldVector< K, n > & diagonal() const
    Get const reference to diagonal vector.
    Definition diagonalmatrix.hh:543
    │ │ │ │ +
    void invert()
    Compute inverse.
    Definition diagonalmatrix.hh:445
    │ │ │ │ +
    DiagonalRowVector * operator&()
    Definition diagonalmatrix.hh:935
    │ │ │ │ +
    const K & diagonal(size_type i) const
    Get const reference to diagonal entry.
    Definition diagonalmatrix.hh:531
    │ │ │ │ +
    size_type N() const
    number of blocks in the vector (are of size 1 here)
    Definition diagonalmatrix.hh:794
    │ │ │ │ +
    DiagonalMatrix(std::initializer_list< K > const &l)
    Construct diagonal matrix from an initializer list.
    Definition diagonalmatrix.hh:115
    │ │ │ │ +
    row_type::Iterator ColIterator
    rename the iterators for easier access
    Definition diagonalmatrix.hh:149
    │ │ │ │ +
    K field_type
    export the type representing the field
    Definition diagonalmatrix.hh:852
    │ │ │ │ +
    reference operator[](size_type i)
    Return reference object as row replacement.
    Definition diagonalmatrix.hh:519
    │ │ │ │ +
    DiagonalRowVectorConst< K, n > type
    Definition diagonalmatrix.hh:951
    │ │ │ │ +
    Iterator end()
    end iterator
    Definition diagonalmatrix.hh:897
    │ │ │ │ +
    DiagonalMatrix(const FieldVector< K, n > &diag)
    Constructor initializing the diagonal with a vector.
    Definition diagonalmatrix.hh:103
    │ │ │ │ +
    std::size_t size_type
    The type used for the index access and size operation.
    Definition diagonalmatrix.hh:858
    │ │ │ │ +
    void usmv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) const
    y += alpha A x
    Definition diagonalmatrix.hh:369
    │ │ │ │ +
    double infinity_norm() const
    infinity norm (row sum norm, how to generalize for blocks?)
    Definition diagonalmatrix.hh:421
    │ │ │ │ +
    DiagonalMatrix & operator+=(const DiagonalMatrix &y)
    vector space addition
    Definition diagonalmatrix.hh:218
    │ │ │ │ +
    K block_type
    export the type representing the components
    Definition diagonalmatrix.hh:64
    │ │ │ │ +
    void umhv(const X &x, Y &y) const
    y += A^H x
    Definition diagonalmatrix.hh:321
    │ │ │ │ +
    Iterator beforeBegin()
    Definition diagonalmatrix.hh:172
    │ │ │ │ +
    static void apply(DenseMatrix &denseMatrix, DiagonalMatrix< field, N > const &rhs)
    Definition diagonalmatrix.hh:1108
    │ │ │ │ +
    ContainerWrapperIterator(const MyType &other)
    Definition diagonalmatrix.hh:1026
    │ │ │ │ +
    ConstIterator end() const
    end ConstIterator
    Definition diagonalmatrix.hh:766
    │ │ │ │ +
    std::size_t size_type
    The type used for the index access and size operation.
    Definition diagonalmatrix.hh:718
    │ │ │ │ +
    DiagonalMatrix & operator=(const K &k)
    Assignment from a scalar.
    Definition diagonalmatrix.hh:123
    │ │ │ │ +
    DiagonalRowVectorConst()
    Constructor making uninitialized vector.
    Definition diagonalmatrix.hh:727
    │ │ │ │ +
    Iterator beforeEnd()
    Definition diagonalmatrix.hh:165
    │ │ │ │ +
    size_type realIndex(int i) const
    Definition diagonalmatrix.hh:819
    │ │ │ │ +
    friend std::ostream & operator<<(std::ostream &s, const DiagonalMatrix< K, n > &a)
    Sends the matrix to an output stream.
    Definition diagonalmatrix.hh:508
    │ │ │ │ +
    K value_type
    export the type representing the field
    Definition diagonalmatrix.hh:60
    │ │ │ │ +
    K block_type
    export the type representing the components
    Definition diagonalmatrix.hh:715
    │ │ │ │ +
    K determinant() const
    calculates the determinant of this matrix
    Definition diagonalmatrix.hh:453
    │ │ │ │ +
    FieldTraits< K >::real_type real_type
    Definition diagonalmatrix.hh:564
    │ │ │ │ +
    ConstIterator beforeBegin() const
    Definition diagonalmatrix.hh:780
    │ │ │ │ +
    DiagonalMatrixWrapper()
    Definition diagonalmatrix.hh:663
    │ │ │ │ +
    ContainerWrapperIterator< DiagonalRowVectorConst< K, n >, const K, const K & > ConstIterator
    ConstIterator class for sequential access.
    Definition diagonalmatrix.hh:755
    │ │ │ │ +
    Iterator begin()
    begin iterator
    Definition diagonalmatrix.hh:152
    │ │ │ │ +
    bool operator==(const DiagonalMatrix &other) const
    comparison operator
    Definition diagonalmatrix.hh:262
    │ │ │ │ +
    DiagonalRowVectorConst< K, n > const_row_type
    Definition diagonalmatrix.hh:76
    │ │ │ │ +
    DiagonalRowVector< K, n > row_type
    Each row is implemented by a field vector.
    Definition diagonalmatrix.hh:73
    │ │ │ │ +
    bool equals(const MyType &other) const
    Definition diagonalmatrix.hh:1052
    │ │ │ │ +
    Iterator RowIterator
    rename the iterators for easier access
    Definition diagonalmatrix.hh:147
    │ │ │ │ +
    K block_type
    export the type representing the components
    Definition diagonalmatrix.hh:855
    │ │ │ │ +
    ConstIterator beforeEnd() const
    Definition diagonalmatrix.hh:201
    │ │ │ │ +
    const K & diagonal() const
    the diagonal value
    Definition diagonalmatrix.hh:812
    │ │ │ │
    #define DUNE_THROW(E, m)
    Definition exceptions.hh:218
    │ │ │ │
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ -
    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
    │ │ │ │ +
    K conjugateComplex(const K &x)
    compute conjugate complex of x
    Definition math.hh:164
    │ │ │ │ +
    A dense n x m matrix.
    Definition densematrix.hh:140
    │ │ │ │ +
    constexpr size_type M() const
    number of columns
    Definition densematrix.hh:703
    │ │ │ │ +
    constexpr size_type N() const
    number of rows
    Definition densematrix.hh:697
    │ │ │ │ +
    A dense n x m matrix.
    Definition fmatrix.hh:117
    │ │ │ │ +
    vector space out of a tensor product of fields.
    Definition fvector.hh:95
    │ │ │ │ +
    you have to specialize this structure for any type that should be assignable to a DenseMatrix
    Definition densematrix.hh:59
    │ │ │ │ +
    Error thrown if operations of a FieldMatrix fail.
    Definition densematrix.hh:126
    │ │ │ │ +
    FieldTraits< value_type >::real_type two_norm2() const
    square of two norm (sum over squared values of entries), need for block recursion
    Definition densevector.hh:650
    │ │ │ │ +
    FieldTraits< value_type >::real_type two_norm() const
    two norm sqrt(sum over squared values of entries)
    Definition densevector.hh:641
    │ │ │ │ +
    Iterator begin()
    begin iterator
    Definition densevector.hh:347
    │ │ │ │ +
    FieldTraits< vt >::real_type infinity_norm() const
    infinity norm (maximum of absolute values of entries)
    Definition densevector.hh:661
    │ │ │ │ +
    FieldTraits< vt >::real_type infinity_norm_real() const
    simplified infinity norm (uses Manhattan norm for complex values)
    Definition densevector.hh:677
    │ │ │ │ +
    Definition diagonalmatrix.hh:698
    │ │ │ │ +
    Definition diagonalmatrix.hh:841
    │ │ │ │ +
    Definition diagonalmatrix.hh:650
    │ │ │ │ +
    Iterator class for sparse vector-like containers.
    Definition diagonalmatrix.hh:998
    │ │ │ │ +
    ContainerWrapperIterator(const MyConstType &other)
    Definition diagonalmatrix.hh:1031
    │ │ │ │ +
    bool equals(const MyConstType &other) const
    Definition diagonalmatrix.hh:1057
    │ │ │ │ +
    A diagonal matrix of static size.
    Definition diagonalmatrix.hh:53
    │ │ │ │ +
    Definition ftraits.hh:26
    │ │ │ │ +
    T field_type
    export the type representing the field
    Definition ftraits.hh:28
    │ │ │ │ +
    T real_type
    export the type representing the real type of the field
    Definition ftraits.hh:30
    │ │ │ │ +
    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
    │ │ │ │ +
    Facade class for stl conformant bidirectional iterators.
    Definition iteratorfacades.hh:274
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,269 +7,1604 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -lru.hh │ │ │ │ │ +diagonalmatrix.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 (C) 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 │ │ │ │ │ + 5#ifndef DUNE_DIAGONAL_MATRIX_HH │ │ │ │ │ + 6#define DUNE_DIAGONAL_MATRIX_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; │ │ │ │ │ + 12#include │ │ │ │ │ + 13#include │ │ │ │ │ + 14#include │ │ │ │ │ + 15#include │ │ │ │ │ + 16#include │ │ │ │ │ + 17#include │ │ │ │ │ + 18#include │ │ │ │ │ + 19#include │ │ │ │ │ + 20 │ │ │ │ │ + 21#include │ │ │ │ │ + 22#include │ │ │ │ │ + 23#include │ │ │ │ │ + 24#include │ │ │ │ │ + 25#include │ │ │ │ │ + 26#include │ │ │ │ │ + 27#include │ │ │ │ │ + 28 │ │ │ │ │ + 29 │ │ │ │ │ + 30namespace Dune { │ │ │ │ │ + 31 │ │ │ │ │ + 32 template< class K, int n > class DiagonalRowVectorConst; │ │ │ │ │ + 33 template< class K, int n > class DiagonalRowVector; │ │ │ │ │ + 34 template< class DiagonalMatrixType > class DiagonalMatrixWrapper; │ │ │ │ │ + 35 template< class C, class T, class R> class ContainerWrapperIterator; │ │ │ │ │ + 36 │ │ │ │ │ + 51 template │ │ │ │ │ +52 class DiagonalMatrix │ │ │ │ │ + 53 { │ │ │ │ │ + 54 typedef DiagonalMatrixWrapper<_DiagonalMatrix > WrapperType; │ │ │ │ │ + 55 │ │ │ │ │ + 56 public: │ │ │ │ │ + 57 //===== type definitions and constants │ │ │ │ │ 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 return _data.front().second; │ │ │ │ │ - 77 } │ │ │ │ │ - 78 │ │ │ │ │ -83 const_reference front() const │ │ │ │ │ - 84 { │ │ │ │ │ - 85 return _data.front().second; │ │ │ │ │ - 86 } │ │ │ │ │ - 87 │ │ │ │ │ -92 reference back() │ │ │ │ │ - 93 { │ │ │ │ │ - 94 return _data.back().second; │ │ │ │ │ - 95 } │ │ │ │ │ +60 typedef K value_type; │ │ │ │ │ +61 typedef value_type field_type; │ │ │ │ │ + 62 │ │ │ │ │ +64 typedef K block_type; │ │ │ │ │ + 65 │ │ │ │ │ +67 typedef std::size_t size_type; │ │ │ │ │ + 68 │ │ │ │ │ +70 constexpr static int blocklevel = 1; │ │ │ │ │ + 71 │ │ │ │ │ +73 typedef DiagonalRowVector row_type; │ │ │ │ │ +74 typedef row_type reference; │ │ │ │ │ +75 typedef row_type row_reference; │ │ │ │ │ +76 typedef DiagonalRowVectorConst const_row_type; │ │ │ │ │ +77 typedef const_row_type const_reference; │ │ │ │ │ +78 typedef const_row_type const_row_reference; │ │ │ │ │ + 79 │ │ │ │ │ +81 constexpr static int rows = n; │ │ │ │ │ +83 constexpr static int cols = n; │ │ │ │ │ + 84 │ │ │ │ │ + 85 //==== size │ │ │ │ │ + 86 │ │ │ │ │ +87 static constexpr size_type size () │ │ │ │ │ + 88 { │ │ │ │ │ + 89 return rows; │ │ │ │ │ + 90 } │ │ │ │ │ + 91 │ │ │ │ │ + 92 //===== constructors │ │ │ │ │ + 93 │ │ │ │ │ +95 constexpr DiagonalMatrix() = default; │ │ │ │ │ 96 │ │ │ │ │ -101 const_reference back ([[maybe_unused]] int i) const │ │ │ │ │ - 102 { │ │ │ │ │ - 103 return _data.back().second; │ │ │ │ │ - 104 } │ │ │ │ │ - 105 │ │ │ │ │ +98 DiagonalMatrix (const K& k) │ │ │ │ │ + 99 : diag_(k) │ │ │ │ │ + 100 {} │ │ │ │ │ + 101 │ │ │ │ │ +103 DiagonalMatrix (const FieldVector& diag) │ │ │ │ │ + 104 : diag_(diag) │ │ │ │ │ + 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; │ │ │ │ │ +115 DiagonalMatrix (std::initializer_list const &l) │ │ │ │ │ + 116 { │ │ │ │ │ + 117 std::copy_n(l.begin(), std::min(static_cast(rows), │ │ │ │ │ + 118 l.size()), │ │ │ │ │ + 119 diag_.begin()); │ │ │ │ │ + 120 } │ │ │ │ │ + 121 │ │ │ │ │ +123 DiagonalMatrix& operator=(const K& k) │ │ │ │ │ + 124 { │ │ │ │ │ + 125 diag_ = k; │ │ │ │ │ + 126 return *this; │ │ │ │ │ + 127 } │ │ │ │ │ + 128 │ │ │ │ │ +130 bool identical(const DiagonalMatrix& other) const │ │ │ │ │ + 131 { │ │ │ │ │ + 132 return (this==&other); │ │ │ │ │ + 133 } │ │ │ │ │ + 134 │ │ │ │ │ +136 DiagonalMatrix transposed() const │ │ │ │ │ + 137 { │ │ │ │ │ + 138 return *this; │ │ │ │ │ + 139 } │ │ │ │ │ + 140 │ │ │ │ │ + 141 //===== iterator interface to rows of the matrix │ │ │ │ │ +143 typedef ContainerWrapperIterator │ │ │ │ │ +Iterator; │ │ │ │ │ +145 typedef Iterator iterator; │ │ │ │ │ +147 typedef Iterator RowIterator; │ │ │ │ │ +149 typedef typename row_type::Iterator ColIterator; │ │ │ │ │ + 150 │ │ │ │ │ +152 Iterator begin () │ │ │ │ │ + 153 { │ │ │ │ │ + 154 return Iterator(WrapperType(this),0); │ │ │ │ │ + 155 } │ │ │ │ │ + 156 │ │ │ │ │ +158 Iterator end () │ │ │ │ │ + 159 { │ │ │ │ │ + 160 return Iterator(WrapperType(this),n); │ │ │ │ │ + 161 } │ │ │ │ │ + 162 │ │ │ │ │ +165 Iterator beforeEnd () │ │ │ │ │ + 166 { │ │ │ │ │ + 167 return Iterator(WrapperType(this),n-1); │ │ │ │ │ + 168 } │ │ │ │ │ + 169 │ │ │ │ │ +172 Iterator beforeBegin () │ │ │ │ │ + 173 { │ │ │ │ │ + 174 return Iterator(WrapperType(this),-1); │ │ │ │ │ + 175 } │ │ │ │ │ + 176 │ │ │ │ │ + 177 │ │ │ │ │ +179 typedef ContainerWrapperIterator ConstIterator; │ │ │ │ │ +181 typedef ConstIterator const_iterator; │ │ │ │ │ +183 typedef ConstIterator ConstRowIterator; │ │ │ │ │ +185 typedef typename const_row_type::ConstIterator ConstColIterator; │ │ │ │ │ + 186 │ │ │ │ │ +188 ConstIterator begin () const │ │ │ │ │ + 189 { │ │ │ │ │ + 190 return ConstIterator(WrapperType(this),0); │ │ │ │ │ + 191 } │ │ │ │ │ + 192 │ │ │ │ │ +194 ConstIterator end () const │ │ │ │ │ + 195 { │ │ │ │ │ + 196 return ConstIterator(WrapperType(this),n); │ │ │ │ │ 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()); │ │ │ │ │ +201 ConstIterator beforeEnd() const │ │ │ │ │ + 202 { │ │ │ │ │ + 203 return ConstIterator(WrapperType(this),n-1); │ │ │ │ │ + 204 } │ │ │ │ │ + 205 │ │ │ │ │ +208 ConstIterator beforeBegin () const │ │ │ │ │ + 209 { │ │ │ │ │ + 210 return ConstIterator(WrapperType(this),-1); │ │ │ │ │ + 211 } │ │ │ │ │ + 212 │ │ │ │ │ + 213 │ │ │ │ │ + 214 │ │ │ │ │ + 215 //===== vector space arithmetic │ │ │ │ │ 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 │ │ │ │ │ +218 DiagonalMatrix& operator+=(const DiagonalMatrix& y) │ │ │ │ │ + 219 { │ │ │ │ │ + 220 diag_ += y.diag_; │ │ │ │ │ + 221 return *this; │ │ │ │ │ + 222 } │ │ │ │ │ + 223 │ │ │ │ │ +225 DiagonalMatrix& operator-=(const DiagonalMatrix& y) │ │ │ │ │ + 226 { │ │ │ │ │ + 227 diag_ -= y.diag_; │ │ │ │ │ + 228 return *this; │ │ │ │ │ + 229 } │ │ │ │ │ + 230 │ │ │ │ │ +232 DiagonalMatrix& operator+=(const K& k) │ │ │ │ │ + 233 { │ │ │ │ │ + 234 diag_ += k; │ │ │ │ │ + 235 return *this; │ │ │ │ │ + 236 } │ │ │ │ │ 237 │ │ │ │ │ - 238#endif // DUNE_COMMON_LRU_HH │ │ │ │ │ +239 DiagonalMatrix& operator-=(const K& k) │ │ │ │ │ + 240 { │ │ │ │ │ + 241 diag_ -= k; │ │ │ │ │ + 242 return *this; │ │ │ │ │ + 243 } │ │ │ │ │ + 244 │ │ │ │ │ +246 DiagonalMatrix& operator*=(const K& k) │ │ │ │ │ + 247 { │ │ │ │ │ + 248 diag_ *= k; │ │ │ │ │ + 249 return *this; │ │ │ │ │ + 250 } │ │ │ │ │ + 251 │ │ │ │ │ +253 DiagonalMatrix& operator/=(const K& k) │ │ │ │ │ + 254 { │ │ │ │ │ + 255 diag_ /= k; │ │ │ │ │ + 256 return *this; │ │ │ │ │ + 257 } │ │ │ │ │ + 258 │ │ │ │ │ + 259 //===== comparison ops │ │ │ │ │ + 260 │ │ │ │ │ +262 bool operator==(const DiagonalMatrix& other) const │ │ │ │ │ + 263 { │ │ │ │ │ + 264 return diag_==other.diagonal(); │ │ │ │ │ + 265 } │ │ │ │ │ + 266 │ │ │ │ │ +268 bool operator!=(const DiagonalMatrix& other) const │ │ │ │ │ + 269 { │ │ │ │ │ + 270 return diag_!=other.diagonal(); │ │ │ │ │ + 271 } │ │ │ │ │ + 272 │ │ │ │ │ + 273 │ │ │ │ │ + 274 //===== linear maps │ │ │ │ │ + 275 │ │ │ │ │ + 277 template │ │ │ │ │ +278 void mv (const X& x, Y& y) const │ │ │ │ │ + 279 { │ │ │ │ │ + 280#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ + 281 if (x.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ + 282 if (y.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ + 283#endif │ │ │ │ │ + 284 for (size_type i=0; i │ │ │ │ │ +290 void mtv (const X& x, Y& y) const │ │ │ │ │ + 291 { │ │ │ │ │ + 292 mv(x, y); │ │ │ │ │ + 293 } │ │ │ │ │ + 294 │ │ │ │ │ + 296 template │ │ │ │ │ +297 void umv (const X& x, Y& y) const │ │ │ │ │ + 298 { │ │ │ │ │ + 299#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ + 300 if (x.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ + 301 if (y.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ + 302#endif │ │ │ │ │ + 303 for (size_type i=0; i │ │ │ │ │ +309 void umtv (const X& x, Y& y) const │ │ │ │ │ + 310 { │ │ │ │ │ + 311#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ + 312 if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ + 313 if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ + 314#endif │ │ │ │ │ + 315 for (size_type i=0; i │ │ │ │ │ +321 void umhv (const X& x, Y& y) const │ │ │ │ │ + 322 { │ │ │ │ │ + 323#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ + 324 if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ + 325 if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ + 326#endif │ │ │ │ │ + 327 for (size_type i=0; i │ │ │ │ │ +333 void mmv (const X& x, Y& y) const │ │ │ │ │ + 334 { │ │ │ │ │ + 335#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ + 336 if (x.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ + 337 if (y.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ + 338#endif │ │ │ │ │ + 339 for (size_type i=0; i │ │ │ │ │ +345 void mmtv (const X& x, Y& y) const │ │ │ │ │ + 346 { │ │ │ │ │ + 347#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ + 348 if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ + 349 if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ + 350#endif │ │ │ │ │ + 351 for (size_type i=0; i │ │ │ │ │ +357 void mmhv (const X& x, Y& y) const │ │ │ │ │ + 358 { │ │ │ │ │ + 359#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ + 360 if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ + 361 if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ + 362#endif │ │ │ │ │ + 363 for (size_type i=0; i │ │ │ │ │ +369 void usmv (const typename FieldTraits::field_type & alpha, │ │ │ │ │ + 370 const X& x, Y& y) const │ │ │ │ │ + 371 { │ │ │ │ │ + 372#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ + 373 if (x.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ + 374 if (y.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ + 375#endif │ │ │ │ │ + 376 for (size_type i=0; i │ │ │ │ │ +382 void usmtv (const typename FieldTraits::field_type & alpha, │ │ │ │ │ + 383 const X& x, Y& y) const │ │ │ │ │ + 384 { │ │ │ │ │ + 385#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ + 386 if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ + 387 if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ + 388#endif │ │ │ │ │ + 389 for (size_type i=0; i │ │ │ │ │ +395 void usmhv (const typename FieldTraits::field_type & alpha, │ │ │ │ │ + 396 const X& x, Y& y) const │ │ │ │ │ + 397 { │ │ │ │ │ + 398#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ + 399 if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ + 400 if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); │ │ │ │ │ + 401#endif │ │ │ │ │ + 402 for (size_type i=0; i │ │ │ │ │ +438 void solve (V& x, const V& b) const │ │ │ │ │ + 439 { │ │ │ │ │ + 440 for (int i=0; i::real_type; │ │ │ │ │ + 448 for (int i=0; i │ │ │ │ │ +468 friend auto operator*( const DiagonalMatrix& matrixA, │ │ │ │ │ + 469 const DiagonalMatrix& matrixB) │ │ │ │ │ + 470 { │ │ │ │ │ + 471 auto result = DiagonalMatrix:: │ │ │ │ │ +PromotedType, n>{}; │ │ │ │ │ + 472 for(int i=0; i= 0 && i < n); │ │ │ │ │ + 501 DUNE_ASSERT_BOUNDS(j >= 0 && j < n); │ │ │ │ │ + 502 return i==j; │ │ │ │ │ + 503 } │ │ │ │ │ + 504 │ │ │ │ │ + 505 │ │ │ │ │ + 506 │ │ │ │ │ +508 friend std::ostream& operator<<(std::ostream& s, const DiagonalMatrix& │ │ │ │ │ +a) │ │ │ │ │ + 509 { │ │ │ │ │ + 510 for (size_type i=0; i(&diag_[i]), i); │ │ │ │ │ + 522 } │ │ │ │ │ + 523 │ │ │ │ │ +525 const_reference operator[](size_type i) const │ │ │ │ │ + 526 { │ │ │ │ │ + 527 return const_reference(const_cast(&diag_[i]), i); │ │ │ │ │ + 528 } │ │ │ │ │ + 529 │ │ │ │ │ +531 const K& diagonal(size_type i) const │ │ │ │ │ + 532 { │ │ │ │ │ + 533 return diag_[i]; │ │ │ │ │ + 534 } │ │ │ │ │ + 535 │ │ │ │ │ +537 K& diagonal(size_type i) │ │ │ │ │ + 538 { │ │ │ │ │ + 539 return diag_[i]; │ │ │ │ │ + 540 } │ │ │ │ │ + 541 │ │ │ │ │ +543 const FieldVector& diagonal() const │ │ │ │ │ + 544 { │ │ │ │ │ + 545 return diag_; │ │ │ │ │ + 546 } │ │ │ │ │ + 547 │ │ │ │ │ +549 FieldVector& diagonal() │ │ │ │ │ + 550 { │ │ │ │ │ + 551 return diag_; │ │ │ │ │ + 552 } │ │ │ │ │ + 553 │ │ │ │ │ + 554 private: │ │ │ │ │ + 555 │ │ │ │ │ + 556 // the data, a FieldVector storing the diagonal │ │ │ │ │ + 557 FieldVector diag_; │ │ │ │ │ + 558 }; │ │ │ │ │ + 559 │ │ │ │ │ + 560 template< class K, int n > │ │ │ │ │ +561 struct FieldTraits< DiagonalMatrix > │ │ │ │ │ + 562 { │ │ │ │ │ +563 typedef typename FieldTraits::field_type field_type; │ │ │ │ │ +564 typedef typename FieldTraits::real_type real_type; │ │ │ │ │ + 565 }; │ │ │ │ │ + 566 │ │ │ │ │ + 567 │ │ │ │ │ + 568#ifndef DOXYGEN // hide specialization │ │ │ │ │ + 571 template< class K > │ │ │ │ │ + 572 class DiagonalMatrix : public FieldMatrix │ │ │ │ │ + 573 { │ │ │ │ │ + 574 typedef FieldMatrix Base; │ │ │ │ │ + 575 public: │ │ │ │ │ + 577 typedef typename Base::size_type size_type; │ │ │ │ │ + 578 │ │ │ │ │ + 581 constexpr static int blocklevel = 1; │ │ │ │ │ + 582 │ │ │ │ │ + 583 typedef typename Base::row_type row_type; │ │ │ │ │ + 584 │ │ │ │ │ + 585 typedef typename Base::row_reference row_reference; │ │ │ │ │ + 586 typedef typename Base::const_row_reference const_row_reference; │ │ │ │ │ + 587 │ │ │ │ │ + 590 constexpr static int rows = 1; │ │ │ │ │ + 593 constexpr static int cols = 1; │ │ │ │ │ + 594 │ │ │ │ │ + 595 │ │ │ │ │ + 597 constexpr DiagonalMatrix() = default; │ │ │ │ │ + 598 │ │ │ │ │ + 600 DiagonalMatrix(const K& scalar) │ │ │ │ │ + 601 { │ │ │ │ │ + 602 (*this)[0][0] = scalar; │ │ │ │ │ + 603 } │ │ │ │ │ + 604 │ │ │ │ │ + 606 const K& diagonal(size_type) const │ │ │ │ │ + 607 { │ │ │ │ │ + 608 return (*this)[0][0]; │ │ │ │ │ + 609 } │ │ │ │ │ + 610 │ │ │ │ │ + 612 K& diagonal(size_type) │ │ │ │ │ + 613 { │ │ │ │ │ + 614 return (*this)[0][0]; │ │ │ │ │ + 615 } │ │ │ │ │ + 616 │ │ │ │ │ + 618 const FieldVector& diagonal() const │ │ │ │ │ + 619 { │ │ │ │ │ + 620 return (*this)[0]; │ │ │ │ │ + 621 } │ │ │ │ │ + 622 │ │ │ │ │ + 624 FieldVector& diagonal() │ │ │ │ │ + 625 { │ │ │ │ │ + 626 return (*this)[0]; │ │ │ │ │ + 627 } │ │ │ │ │ + 628 │ │ │ │ │ + 630 DiagonalMatrix transposed() const │ │ │ │ │ + 631 { │ │ │ │ │ + 632 return *this; │ │ │ │ │ + 633 } │ │ │ │ │ + 634 │ │ │ │ │ + 637 template │ │ │ │ │ + 638 friend auto operator*( const DiagonalMatrix& matrixA, │ │ │ │ │ + 639 const DiagonalMatrix& matrixB) │ │ │ │ │ + 640 { │ │ │ │ │ + 641 return DiagonalMatrix:: │ │ │ │ │ +PromotedType, 1>{matrixA.diagonal(0)*matrixB.diagonal(0)}; │ │ │ │ │ + 642 } │ │ │ │ │ + 643 │ │ │ │ │ + 644 }; │ │ │ │ │ + 645#endif │ │ │ │ │ + 646 │ │ │ │ │ + 647 │ │ │ │ │ + 648 template │ │ │ │ │ +649 class DiagonalMatrixWrapper │ │ │ │ │ + 650 { │ │ │ │ │ + 651 typedef typename DiagonalMatrixType::reference reference; │ │ │ │ │ + 652 typedef typename DiagonalMatrixType::const_reference const_reference; │ │ │ │ │ + 653 typedef typename DiagonalMatrixType::field_type K; │ │ │ │ │ + 654 typedef DiagonalRowVector row_type; │ │ │ │ │ + 655 typedef std::size_t size_type; │ │ │ │ │ +656 typedef DiagonalMatrixWrapper<_DiagonalMatrixType> MyType; │ │ │ │ │ + 657 │ │ │ │ │ + 658 friend class ContainerWrapperIterator; │ │ │ │ │ + 659 friend class ContainerWrapperIterator; │ │ │ │ │ + 660 │ │ │ │ │ + 661 public: │ │ │ │ │ + 662 │ │ │ │ │ +663 DiagonalMatrixWrapper() : │ │ │ │ │ + 664 mat_(0) │ │ │ │ │ + 665 {} │ │ │ │ │ + 666 │ │ │ │ │ +667 DiagonalMatrixWrapper(const DiagonalMatrixType* mat) : │ │ │ │ │ + 668 mat_(const_cast(mat)) │ │ │ │ │ + 669 {} │ │ │ │ │ + 670 │ │ │ │ │ +671 size_type realIndex(int i) const │ │ │ │ │ + 672 { │ │ │ │ │ + 673 return i; │ │ │ │ │ + 674 } │ │ │ │ │ + 675 │ │ │ │ │ +676 row_type* pointer(int i) const │ │ │ │ │ + 677 { │ │ │ │ │ + 678 row_ = row_type(&(mat_->diagonal(i)), i); │ │ │ │ │ + 679 return &row_; │ │ │ │ │ + 680 } │ │ │ │ │ + 681 │ │ │ │ │ +682 bool identical(const DiagonalMatrixWrapper& other) const │ │ │ │ │ + 683 { │ │ │ │ │ + 684 return mat_==other.mat_; │ │ │ │ │ + 685 } │ │ │ │ │ + 686 │ │ │ │ │ + 687 private: │ │ │ │ │ + 688 │ │ │ │ │ + 689 mutable DiagonalMatrixType* mat_; │ │ │ │ │ + 690 mutable row_type row_; │ │ │ │ │ + 691 }; │ │ │ │ │ + 692 │ │ │ │ │ + 696 template< class K, int n > │ │ │ │ │ +697 class DiagonalRowVectorConst │ │ │ │ │ + 698 { │ │ │ │ │ + 699 template │ │ │ │ │ +700 friend class DiagonalMatrixWrapper; │ │ │ │ │ + 701 friend class ContainerWrapperIterator, const │ │ │ │ │ +K, const K&>; │ │ │ │ │ + 702 │ │ │ │ │ + 703 public: │ │ │ │ │ + 704 // remember size of vector │ │ │ │ │ +705 constexpr static int dimension = n; │ │ │ │ │ + 706 │ │ │ │ │ + 707 // standard constructor and everything is sufficient ... │ │ │ │ │ + 708 │ │ │ │ │ + 709 //===== type definitions and constants │ │ │ │ │ + 710 │ │ │ │ │ +712 typedef K field_type; │ │ │ │ │ + 713 │ │ │ │ │ +715 typedef K block_type; │ │ │ │ │ + 716 │ │ │ │ │ +718 typedef std::size_t size_type; │ │ │ │ │ + 719 │ │ │ │ │ +721 constexpr static int blocklevel = 1; │ │ │ │ │ + 722 │ │ │ │ │ +724 constexpr static int size = n; │ │ │ │ │ + 725 │ │ │ │ │ +727 DiagonalRowVectorConst() : │ │ │ │ │ + 728 p_(0), │ │ │ │ │ + 729 row_(0) │ │ │ │ │ + 730 {} │ │ │ │ │ + 731 │ │ │ │ │ +733 explicit DiagonalRowVectorConst (K* p, int col) : │ │ │ │ │ + 734 p_(p), │ │ │ │ │ + 735 row_(col) │ │ │ │ │ + 736 {} │ │ │ │ │ + 737 │ │ │ │ │ + 738 //===== access to components │ │ │ │ │ + 739 │ │ │ │ │ +741 const K& operator[]([[maybe_unused]] size_type i) const │ │ │ │ │ + 742 { │ │ │ │ │ + 743 DUNE_ASSERT_BOUNDS(i == row_); │ │ │ │ │ + 744 return *p_; │ │ │ │ │ + 745 } │ │ │ │ │ + 746 │ │ │ │ │ + 747 // check if row is identical to other row (not only identical values) │ │ │ │ │ + 748 // since this is a proxy class we need to check equality of the stored │ │ │ │ │ +pointer │ │ │ │ │ +749 bool identical(const DiagonalRowVectorConst& other) const │ │ │ │ │ + 750 { │ │ │ │ │ + 751 return ((p_ == other.p_)and (row_ == other.row_)); │ │ │ │ │ + 752 } │ │ │ │ │ + 753 │ │ │ │ │ +755 typedef ContainerWrapperIterator, const K, │ │ │ │ │ +const K&> ConstIterator; │ │ │ │ │ +757 typedef ConstIterator const_iterator; │ │ │ │ │ + 758 │ │ │ │ │ +760 ConstIterator begin () const │ │ │ │ │ + 761 { │ │ │ │ │ + 762 return ConstIterator(*this,0); │ │ │ │ │ + 763 } │ │ │ │ │ + 764 │ │ │ │ │ +766 ConstIterator end () const │ │ │ │ │ + 767 { │ │ │ │ │ + 768 return ConstIterator(*this,1); │ │ │ │ │ + 769 } │ │ │ │ │ + 770 │ │ │ │ │ +773 ConstIterator beforeEnd() const │ │ │ │ │ + 774 { │ │ │ │ │ + 775 return ConstIterator(*this,0); │ │ │ │ │ + 776 } │ │ │ │ │ + 777 │ │ │ │ │ +780 ConstIterator beforeBegin () const │ │ │ │ │ + 781 { │ │ │ │ │ + 782 return ConstIterator(*this,-1); │ │ │ │ │ + 783 } │ │ │ │ │ + 784 │ │ │ │ │ +786 bool operator==(const DiagonalRowVectorConst& y) const │ │ │ │ │ + 787 { │ │ │ │ │ + 788 return ((p_==y.p_)and (row_==y.row_)); │ │ │ │ │ + 789 } │ │ │ │ │ + 790 │ │ │ │ │ + 791 //===== sizes │ │ │ │ │ + 792 │ │ │ │ │ +794 size_type N () const │ │ │ │ │ + 795 { │ │ │ │ │ + 796 return n; │ │ │ │ │ + 797 } │ │ │ │ │ + 798 │ │ │ │ │ +800 size_type dim () const │ │ │ │ │ + 801 { │ │ │ │ │ + 802 return n; │ │ │ │ │ + 803 } │ │ │ │ │ + 804 │ │ │ │ │ +806 size_type rowIndex() const │ │ │ │ │ + 807 { │ │ │ │ │ + 808 return row_; │ │ │ │ │ + 809 } │ │ │ │ │ + 810 │ │ │ │ │ +812 const K& diagonal() const │ │ │ │ │ + 813 { │ │ │ │ │ + 814 return *p_; │ │ │ │ │ + 815 } │ │ │ │ │ + 816 │ │ │ │ │ + 817 protected: │ │ │ │ │ + 818 │ │ │ │ │ +819 size_type realIndex([[maybe_unused]] int i) const │ │ │ │ │ + 820 { │ │ │ │ │ + 821 return rowIndex(); │ │ │ │ │ + 822 } │ │ │ │ │ + 823 │ │ │ │ │ +824 K* pointer([[maybe_unused]] size_type i) const │ │ │ │ │ + 825 { │ │ │ │ │ + 826 return const_cast(p_); │ │ │ │ │ + 827 } │ │ │ │ │ + 828 │ │ │ │ │ +829 DiagonalRowVectorConst* operator&() │ │ │ │ │ + 830 { │ │ │ │ │ + 831 return this; │ │ │ │ │ + 832 } │ │ │ │ │ + 833 │ │ │ │ │ + 834 // the data, very simply a pointer to the diagonal value and the row │ │ │ │ │ +number │ │ │ │ │ +835 K* p_; │ │ │ │ │ +836 size_type row_; │ │ │ │ │ + 837 }; │ │ │ │ │ + 838 │ │ │ │ │ + 839 template< class K, int n > │ │ │ │ │ +840 class DiagonalRowVector : public DiagonalRowVectorConst │ │ │ │ │ + 841 { │ │ │ │ │ + 842 template │ │ │ │ │ +843 friend class DiagonalMatrixWrapper; │ │ │ │ │ + 844 friend class ContainerWrapperIterator, K, K&>; │ │ │ │ │ + 845 │ │ │ │ │ + 846 public: │ │ │ │ │ + 847 // standard constructor and everything is sufficient ... │ │ │ │ │ + 848 │ │ │ │ │ + 849 //===== type definitions and constants │ │ │ │ │ + 850 │ │ │ │ │ +852 typedef K field_type; │ │ │ │ │ + 853 │ │ │ │ │ +855 typedef K block_type; │ │ │ │ │ + 856 │ │ │ │ │ +858 typedef std::size_t size_type; │ │ │ │ │ + 859 │ │ │ │ │ +861 DiagonalRowVector() : DiagonalRowVectorConst() │ │ │ │ │ + 862 {} │ │ │ │ │ + 863 │ │ │ │ │ +865 explicit DiagonalRowVector (K* p, int col) : DiagonalRowVectorConst(p, │ │ │ │ │ +col) │ │ │ │ │ + 866 {} │ │ │ │ │ + 867 │ │ │ │ │ + 868 //===== assignment from scalar │ │ │ │ │ +870 DiagonalRowVector& operator=(const K& k) │ │ │ │ │ + 871 { │ │ │ │ │ + 872 *p_ = k; │ │ │ │ │ + 873 return *this; │ │ │ │ │ + 874 } │ │ │ │ │ + 875 │ │ │ │ │ + 876 //===== access to components │ │ │ │ │ + 877 │ │ │ │ │ +879 K& operator[]([[maybe_unused]] size_type i) │ │ │ │ │ + 880 { │ │ │ │ │ + 881 DUNE_ASSERT_BOUNDS(i == row_); │ │ │ │ │ + 882 return *p_; │ │ │ │ │ + 883 } │ │ │ │ │ + 884 │ │ │ │ │ +886 typedef ContainerWrapperIterator, K, K&> Iterator; │ │ │ │ │ +888 typedef Iterator iterator; │ │ │ │ │ + 889 │ │ │ │ │ +891 Iterator begin () │ │ │ │ │ + 892 { │ │ │ │ │ + 893 return Iterator(*this, 0); │ │ │ │ │ + 894 } │ │ │ │ │ + 895 │ │ │ │ │ +897 Iterator end () │ │ │ │ │ + 898 { │ │ │ │ │ + 899 return Iterator(*this, 1); │ │ │ │ │ + 900 } │ │ │ │ │ + 901 │ │ │ │ │ +904 Iterator beforeEnd () │ │ │ │ │ + 905 { │ │ │ │ │ + 906 return Iterator(*this, 0); │ │ │ │ │ + 907 } │ │ │ │ │ + 908 │ │ │ │ │ +911 Iterator beforeBegin () │ │ │ │ │ + 912 { │ │ │ │ │ + 913 return Iterator(*this, -1); │ │ │ │ │ + 914 } │ │ │ │ │ + 915 │ │ │ │ │ +917 typedef ContainerWrapperIterator, const K, │ │ │ │ │ +const K&> ConstIterator; │ │ │ │ │ +919 typedef ConstIterator const_iterator; │ │ │ │ │ + 920 │ │ │ │ │ + 921 using DiagonalRowVectorConst::identical; │ │ │ │ │ + 922 using DiagonalRowVectorConst::operator[]; │ │ │ │ │ + 923 using DiagonalRowVectorConst::operator==; │ │ │ │ │ + 924 using DiagonalRowVectorConst::begin; │ │ │ │ │ + 925 using DiagonalRowVectorConst::end; │ │ │ │ │ + 926 using DiagonalRowVectorConst::beforeEnd; │ │ │ │ │ + 927 using DiagonalRowVectorConst::beforeBegin; │ │ │ │ │ + 928 using DiagonalRowVectorConst::N; │ │ │ │ │ + 929 using DiagonalRowVectorConst::dim; │ │ │ │ │ + 930 using DiagonalRowVectorConst::rowIndex; │ │ │ │ │ + 931 using DiagonalRowVectorConst::diagonal; │ │ │ │ │ + 932 │ │ │ │ │ + 933 protected: │ │ │ │ │ + 934 │ │ │ │ │ +935 DiagonalRowVector* operator&() │ │ │ │ │ + 936 { │ │ │ │ │ + 937 return this; │ │ │ │ │ + 938 } │ │ │ │ │ + 939 │ │ │ │ │ + 940 private: │ │ │ │ │ + 941 │ │ │ │ │ + 942 using DiagonalRowVectorConst::p_; │ │ │ │ │ + 943 using DiagonalRowVectorConst::row_; │ │ │ │ │ + 944 }; │ │ │ │ │ + 945 │ │ │ │ │ + 946 │ │ │ │ │ + 947 // implement type traits │ │ │ │ │ + 948 template │ │ │ │ │ +949 struct const_reference< DiagonalRowVector > │ │ │ │ │ + 950 { │ │ │ │ │ +951 typedef DiagonalRowVectorConst type; │ │ │ │ │ + 952 }; │ │ │ │ │ + 953 │ │ │ │ │ + 954 template │ │ │ │ │ +955 struct const_reference< DiagonalRowVectorConst > │ │ │ │ │ + 956 { │ │ │ │ │ +957 typedef DiagonalRowVectorConst type; │ │ │ │ │ + 958 }; │ │ │ │ │ + 959 │ │ │ │ │ + 960 template │ │ │ │ │ +961 struct mutable_reference< DiagonalRowVector > │ │ │ │ │ + 962 { │ │ │ │ │ +963 typedef DiagonalRowVector type; │ │ │ │ │ + 964 }; │ │ │ │ │ + 965 │ │ │ │ │ + 966 template │ │ │ │ │ +967 struct mutable_reference< DiagonalRowVectorConst > │ │ │ │ │ + 968 { │ │ │ │ │ +969 typedef DiagonalRowVector type; │ │ │ │ │ + 970 }; │ │ │ │ │ + 971 │ │ │ │ │ + 972 │ │ │ │ │ + 973 │ │ │ │ │ + 996 template │ │ │ │ │ +997 class ContainerWrapperIterator : public │ │ │ │ │ +BidirectionalIteratorFacade,T, R, int> │ │ │ │ │ + 998 { │ │ │ │ │ +999 typedef typename std::remove_const::type NonConstCW; │ │ │ │ │ + 1000 │ │ │ │ │ + 1001 friend class ContainerWrapperIterator:: │ │ │ │ │ +type, typename mutable_reference::type>; │ │ │ │ │ + 1002 friend class ContainerWrapperIterator:: │ │ │ │ │ +type, typename const_reference::type>; │ │ │ │ │ + 1003 │ │ │ │ │ + 1004 typedef ContainerWrapperIterator::type, │ │ │ │ │ +typename mutable_reference::type> MyType; │ │ │ │ │ + 1005 typedef ContainerWrapperIterator::type, │ │ │ │ │ +typename const_reference::type> MyConstType; │ │ │ │ │ + 1006 │ │ │ │ │ + 1007 public: │ │ │ │ │ + 1008 │ │ │ │ │ + 1009 // Constructors needed by the facade iterators. │ │ │ │ │ +1010 ContainerWrapperIterator() : │ │ │ │ │ + 1011 containerWrapper_(), │ │ │ │ │ + 1012 position_(0) │ │ │ │ │ + 1013 {} │ │ │ │ │ + 1014 │ │ │ │ │ +1015 ContainerWrapperIterator(CW containerWrapper, int position) : │ │ │ │ │ + 1016 containerWrapper_(containerWrapper), │ │ │ │ │ + 1017 position_(position) │ │ │ │ │ + 1018 {} │ │ │ │ │ + 1019 │ │ │ │ │ + 1020 template │ │ │ │ │ +1021 ContainerWrapperIterator(OtherContainerWrapperIteratorType& other) : │ │ │ │ │ + 1022 containerWrapper_(other.containerWrapper_), │ │ │ │ │ + 1023 position_(other.position_) │ │ │ │ │ + 1024 {} │ │ │ │ │ + 1025 │ │ │ │ │ +1026 ContainerWrapperIterator(const MyType& other) : │ │ │ │ │ + 1027 containerWrapper_(other.containerWrapper_), │ │ │ │ │ + 1028 position_(other.position_) │ │ │ │ │ + 1029 {} │ │ │ │ │ + 1030 │ │ │ │ │ +1031 ContainerWrapperIterator(const MyConstType& other) : │ │ │ │ │ + 1032 containerWrapper_(other.containerWrapper_), │ │ │ │ │ + 1033 position_(other.position_) │ │ │ │ │ + 1034 {} │ │ │ │ │ + 1035 │ │ │ │ │ + 1036 template │ │ │ │ │ +1037 ContainerWrapperIterator& operator=(OtherContainerWrapperIteratorType& │ │ │ │ │ +other) │ │ │ │ │ + 1038 { │ │ │ │ │ + 1039 containerWrapper_ = other.containerWrapper_; │ │ │ │ │ + 1040 position_ = other.position_; │ │ │ │ │ + 1041 return *this; │ │ │ │ │ + 1042 } │ │ │ │ │ + 1043 │ │ │ │ │ + 1044 // This operator is needed since we can not get the address of the │ │ │ │ │ + 1045 // temporary object returned by dereference │ │ │ │ │ +1046 T* operator->() const │ │ │ │ │ + 1047 { │ │ │ │ │ + 1048 return containerWrapper_.pointer(position_); │ │ │ │ │ + 1049 } │ │ │ │ │ + 1050 │ │ │ │ │ + 1051 // Methods needed by the forward iterator │ │ │ │ │ +1052 bool equals(const MyType& other) const │ │ │ │ │ + 1053 { │ │ │ │ │ + 1054 return position_ == other.position_ && containerWrapper_.identical │ │ │ │ │ +(other.containerWrapper_); │ │ │ │ │ + 1055 } │ │ │ │ │ + 1056 │ │ │ │ │ +1057 bool equals(const MyConstType& other) const │ │ │ │ │ + 1058 { │ │ │ │ │ + 1059 return position_ == other.position_ && containerWrapper_.identical │ │ │ │ │ +(other.containerWrapper_); │ │ │ │ │ + 1060 } │ │ │ │ │ + 1061 │ │ │ │ │ +1062 R dereference() const │ │ │ │ │ + 1063 { │ │ │ │ │ + 1064 return *containerWrapper_.pointer(position_); │ │ │ │ │ + 1065 } │ │ │ │ │ + 1066 │ │ │ │ │ +1067 void increment() │ │ │ │ │ + 1068 { │ │ │ │ │ + 1069 ++position_; │ │ │ │ │ + 1070 } │ │ │ │ │ + 1071 │ │ │ │ │ + 1072 // Additional function needed by BidirectionalIterator │ │ │ │ │ +1073 void decrement() │ │ │ │ │ + 1074 { │ │ │ │ │ + 1075 --position_; │ │ │ │ │ + 1076 } │ │ │ │ │ + 1077 │ │ │ │ │ + 1078 // Additional function needed by RandomAccessIterator │ │ │ │ │ +1079 R elementAt(int i) const │ │ │ │ │ + 1080 { │ │ │ │ │ + 1081 return *containerWrapper_.pointer(position_+i); │ │ │ │ │ + 1082 } │ │ │ │ │ + 1083 │ │ │ │ │ +1084 void advance(int n) │ │ │ │ │ + 1085 { │ │ │ │ │ + 1086 position_=position_+n; │ │ │ │ │ + 1087 } │ │ │ │ │ + 1088 │ │ │ │ │ + 1089 template │ │ │ │ │ +1090 std::ptrdiff_t distanceTo(OtherContainerWrapperIteratorType& other) const │ │ │ │ │ + 1091 { │ │ │ │ │ + 1092 assert(containerWrapper_.identical(other)); │ │ │ │ │ + 1093 return other.position_ - position_; │ │ │ │ │ + 1094 } │ │ │ │ │ + 1095 │ │ │ │ │ +1096 std::ptrdiff_t index() const │ │ │ │ │ + 1097 { │ │ │ │ │ + 1098 return containerWrapper_.realIndex(position_); │ │ │ │ │ + 1099 } │ │ │ │ │ + 1100 │ │ │ │ │ + 1101 private: │ │ │ │ │ + 1102 NonConstCW containerWrapper_; │ │ │ │ │ + 1103 size_t position_; │ │ │ │ │ + 1104 }; │ │ │ │ │ + 1105 │ │ │ │ │ + 1106 template │ │ │ │ │ +1107 struct DenseMatrixAssigner> { │ │ │ │ │ +1108 static void apply(DenseMatrix& denseMatrix, │ │ │ │ │ + 1109 DiagonalMatrix const& rhs) { │ │ │ │ │ + 1110 DUNE_ASSERT_BOUNDS(denseMatrix.M() == N); │ │ │ │ │ + 1111 DUNE_ASSERT_BOUNDS(denseMatrix.N() == N); │ │ │ │ │ + 1112 denseMatrix = field(0); │ │ │ │ │ + 1113 for (int i = 0; i < N; ++i) │ │ │ │ │ + 1114 denseMatrix[i][i] = rhs.diagonal()[i]; │ │ │ │ │ + 1115 } │ │ │ │ │ + 1116 }; │ │ │ │ │ + 1117 /* @} */ │ │ │ │ │ + 1118} // end namespace │ │ │ │ │ + 1119#endif │ │ │ │ │ exceptions.hh │ │ │ │ │ A few common exception classes. │ │ │ │ │ +densematrix.hh │ │ │ │ │ +Implements a matrix constructed from a given type representing a field and a │ │ │ │ │ +compile-time given numbe... │ │ │ │ │ +fvector.hh │ │ │ │ │ +Implements a vector constructed from a given type representing a field and a │ │ │ │ │ +compile-time given size. │ │ │ │ │ +boundschecking.hh │ │ │ │ │ +Macro for wrapping boundary checks. │ │ │ │ │ +fmatrix.hh │ │ │ │ │ +Implements a matrix constructed from a given type representing a field and │ │ │ │ │ +compile-time given number ... │ │ │ │ │ +genericiterator.hh │ │ │ │ │ +Implements a generic iterator class for writing stl conformant iterators. │ │ │ │ │ +typetraits.hh │ │ │ │ │ +Traits for type conversions and type information. │ │ │ │ │ +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 │ │ │ │ │ +Dune::DiagonalMatrix::beforeBegin │ │ │ │ │ +ConstIterator beforeBegin() const │ │ │ │ │ +Definition diagonalmatrix.hh:208 │ │ │ │ │ +Dune::DiagonalMatrix::transposed │ │ │ │ │ +DiagonalMatrix< K, n > transposed() const │ │ │ │ │ +Return transposed of the matrix as DiagonalMatrix. │ │ │ │ │ +Definition diagonalmatrix.hh:136 │ │ │ │ │ +Dune::DiagonalMatrix::mmhv │ │ │ │ │ +void mmhv(const X &x, Y &y) const │ │ │ │ │ +y -= A^H x │ │ │ │ │ +Definition diagonalmatrix.hh:357 │ │ │ │ │ +Dune::DiagonalMatrix::operator*= │ │ │ │ │ +DiagonalMatrix & operator*=(const K &k) │ │ │ │ │ +vector space multiplication with scalar │ │ │ │ │ +Definition diagonalmatrix.hh:246 │ │ │ │ │ +Dune::FieldTraits<_DiagonalMatrix<_K,_n_>_>::field_type │ │ │ │ │ +FieldTraits< K >::field_type field_type │ │ │ │ │ +Definition diagonalmatrix.hh:563 │ │ │ │ │ +Dune::DiagonalMatrix::size_type │ │ │ │ │ +std::size_t size_type │ │ │ │ │ +The type used for the index access and size operations. │ │ │ │ │ +Definition diagonalmatrix.hh:67 │ │ │ │ │ +Dune::DiagonalRowVectorConst::dim │ │ │ │ │ +size_type dim() const │ │ │ │ │ +dimension of the vector space │ │ │ │ │ +Definition diagonalmatrix.hh:800 │ │ │ │ │ +Dune::DiagonalMatrix::ConstRowIterator │ │ │ │ │ +ConstIterator ConstRowIterator │ │ │ │ │ +rename the iterators for easier access │ │ │ │ │ +Definition diagonalmatrix.hh:183 │ │ │ │ │ +Dune::DiagonalMatrix::row_reference │ │ │ │ │ +row_type row_reference │ │ │ │ │ +Definition diagonalmatrix.hh:75 │ │ │ │ │ +Dune::DiagonalRowVector::operator[] │ │ │ │ │ +K & operator[](size_type i) │ │ │ │ │ +random access │ │ │ │ │ +Definition diagonalmatrix.hh:879 │ │ │ │ │ +Dune::ContainerWrapperIterator::operator= │ │ │ │ │ +ContainerWrapperIterator & operator=(OtherContainerWrapperIteratorType &other) │ │ │ │ │ +Definition diagonalmatrix.hh:1037 │ │ │ │ │ +Dune::DiagonalMatrix::rows │ │ │ │ │ +static constexpr int rows │ │ │ │ │ +The number of rows. │ │ │ │ │ +Definition diagonalmatrix.hh:81 │ │ │ │ │ +Dune::DiagonalMatrix::M │ │ │ │ │ +static constexpr size_type M() │ │ │ │ │ +number of blocks in column direction │ │ │ │ │ +Definition diagonalmatrix.hh:488 │ │ │ │ │ +Dune::DiagonalMatrix::diagonal │ │ │ │ │ +FieldVector< K, n > & diagonal() │ │ │ │ │ +Get reference to diagonal vector. │ │ │ │ │ +Definition diagonalmatrix.hh:549 │ │ │ │ │ +Dune::DiagonalMatrix::usmhv │ │ │ │ │ +void usmhv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y │ │ │ │ │ +&y) const │ │ │ │ │ +y += alpha A^H x │ │ │ │ │ +Definition diagonalmatrix.hh:395 │ │ │ │ │ +Dune::DiagonalRowVector::iterator │ │ │ │ │ +Iterator iterator │ │ │ │ │ +typedef for stl compliant access │ │ │ │ │ +Definition diagonalmatrix.hh:888 │ │ │ │ │ +Dune::ContainerWrapperIterator::increment │ │ │ │ │ +void increment() │ │ │ │ │ +Definition diagonalmatrix.hh:1067 │ │ │ │ │ +Dune::DiagonalMatrix::blocklevel │ │ │ │ │ +static constexpr int blocklevel │ │ │ │ │ +The number of block levels we contain. This is the leaf, that is, 1. │ │ │ │ │ +Definition diagonalmatrix.hh:70 │ │ │ │ │ +Dune::const_reference<_DiagonalRowVectorConst<_K,_n_>_>::type │ │ │ │ │ +DiagonalRowVectorConst< K, n > type │ │ │ │ │ +Definition diagonalmatrix.hh:957 │ │ │ │ │ +Dune::ContainerWrapperIterator::operator-> │ │ │ │ │ +T * operator->() const │ │ │ │ │ +Definition diagonalmatrix.hh:1046 │ │ │ │ │ +Dune::DiagonalRowVectorConst::size │ │ │ │ │ +static constexpr int size │ │ │ │ │ +The size of this vector. │ │ │ │ │ +Definition diagonalmatrix.hh:724 │ │ │ │ │ +Dune::DiagonalRowVectorConst::pointer │ │ │ │ │ +K * pointer(size_type i) const │ │ │ │ │ +Definition diagonalmatrix.hh:824 │ │ │ │ │ +Dune::DiagonalRowVectorConst::field_type │ │ │ │ │ +K field_type │ │ │ │ │ +export the type representing the field │ │ │ │ │ +Definition diagonalmatrix.hh:712 │ │ │ │ │ +Dune::mutable_reference<_DiagonalRowVector<_K,_n_>_>::type │ │ │ │ │ +DiagonalRowVector< K, n > type │ │ │ │ │ +Definition diagonalmatrix.hh:963 │ │ │ │ │ +Dune::DiagonalRowVectorConst::beforeEnd │ │ │ │ │ +ConstIterator beforeEnd() const │ │ │ │ │ +Definition diagonalmatrix.hh:773 │ │ │ │ │ +Dune::DiagonalMatrix::ConstColIterator │ │ │ │ │ +const_row_type::ConstIterator ConstColIterator │ │ │ │ │ +rename the iterators for easier access │ │ │ │ │ +Definition diagonalmatrix.hh:185 │ │ │ │ │ +Dune::DiagonalMatrix::exists │ │ │ │ │ +bool exists(size_type i, size_type j) const │ │ │ │ │ +return true when (i,j) is in pattern │ │ │ │ │ +Definition diagonalmatrix.hh:498 │ │ │ │ │ +Dune::DiagonalMatrix::ConstIterator │ │ │ │ │ +ContainerWrapperIterator< const WrapperType, const_reference, const_reference > │ │ │ │ │ +ConstIterator │ │ │ │ │ +Iterator class for sequential access. │ │ │ │ │ +Definition diagonalmatrix.hh:179 │ │ │ │ │ +Dune::DiagonalMatrix::const_row_reference │ │ │ │ │ +const_row_type const_row_reference │ │ │ │ │ +Definition diagonalmatrix.hh:78 │ │ │ │ │ +Dune::DiagonalMatrix::size │ │ │ │ │ +static constexpr size_type size() │ │ │ │ │ +Definition diagonalmatrix.hh:87 │ │ │ │ │ +Dune::DiagonalRowVectorConst::row_ │ │ │ │ │ +size_type row_ │ │ │ │ │ +Definition diagonalmatrix.hh:836 │ │ │ │ │ +Dune::ContainerWrapperIterator::ContainerWrapperIterator │ │ │ │ │ +ContainerWrapperIterator(CW containerWrapper, int position) │ │ │ │ │ +Definition diagonalmatrix.hh:1015 │ │ │ │ │ +Dune::DiagonalRowVector::DiagonalRowVector │ │ │ │ │ +DiagonalRowVector(K *p, int col) │ │ │ │ │ +Constructor making vector with identical coordinates. │ │ │ │ │ +Definition diagonalmatrix.hh:865 │ │ │ │ │ +Dune::DiagonalMatrix::diagonal │ │ │ │ │ +K & diagonal(size_type i) │ │ │ │ │ +Get reference to diagonal entry. │ │ │ │ │ +Definition diagonalmatrix.hh:537 │ │ │ │ │ +Dune::DiagonalMatrix::solve │ │ │ │ │ +void solve(V &x, const V &b) const │ │ │ │ │ +Solve system A x = b. │ │ │ │ │ +Definition diagonalmatrix.hh:438 │ │ │ │ │ +Dune::DiagonalMatrix::N │ │ │ │ │ +static constexpr size_type N() │ │ │ │ │ +number of blocks in row direction │ │ │ │ │ +Definition diagonalmatrix.hh:482 │ │ │ │ │ +Dune::DiagonalRowVector::beforeBegin │ │ │ │ │ +Iterator beforeBegin() │ │ │ │ │ +Definition diagonalmatrix.hh:911 │ │ │ │ │ +Dune::ContainerWrapperIterator::ContainerWrapperIterator │ │ │ │ │ +ContainerWrapperIterator(OtherContainerWrapperIteratorType &other) │ │ │ │ │ +Definition diagonalmatrix.hh:1021 │ │ │ │ │ +Dune::DiagonalMatrix::operator[] │ │ │ │ │ +const_reference operator[](size_type i) const │ │ │ │ │ +Return const_reference object as row replacement. │ │ │ │ │ +Definition diagonalmatrix.hh:525 │ │ │ │ │ +Dune::DiagonalMatrix::iterator │ │ │ │ │ +Iterator iterator │ │ │ │ │ +typedef for stl compliant access │ │ │ │ │ +Definition diagonalmatrix.hh:145 │ │ │ │ │ +Dune::DiagonalRowVectorConst::begin │ │ │ │ │ +ConstIterator begin() const │ │ │ │ │ +begin ConstIterator │ │ │ │ │ +Definition diagonalmatrix.hh:760 │ │ │ │ │ +Dune::DiagonalRowVector::const_iterator │ │ │ │ │ +ConstIterator const_iterator │ │ │ │ │ +typedef for stl compliant access │ │ │ │ │ +Definition diagonalmatrix.hh:919 │ │ │ │ │ +Dune::DiagonalRowVectorConst::identical │ │ │ │ │ +bool identical(const DiagonalRowVectorConst< K, n > &other) const │ │ │ │ │ +Definition diagonalmatrix.hh:749 │ │ │ │ │ +Dune::DiagonalMatrix::operator-= │ │ │ │ │ +DiagonalMatrix & operator-=(const DiagonalMatrix &y) │ │ │ │ │ +vector space subtraction │ │ │ │ │ +Definition diagonalmatrix.hh:225 │ │ │ │ │ +Dune::DiagonalRowVectorConst::DiagonalRowVectorConst │ │ │ │ │ +DiagonalRowVectorConst(K *p, int col) │ │ │ │ │ +Constructor making vector with identical coordinates. │ │ │ │ │ +Definition diagonalmatrix.hh:733 │ │ │ │ │ +Dune::DiagonalMatrix::mmtv │ │ │ │ │ +void mmtv(const X &x, Y &y) const │ │ │ │ │ +y -= A^T x │ │ │ │ │ +Definition diagonalmatrix.hh:345 │ │ │ │ │ +Dune::DiagonalRowVectorConst::blocklevel │ │ │ │ │ +static constexpr int blocklevel │ │ │ │ │ +The number of block levels we contain. │ │ │ │ │ +Definition diagonalmatrix.hh:721 │ │ │ │ │ +Dune::DiagonalMatrixWrapper::pointer │ │ │ │ │ +row_type * pointer(int i) const │ │ │ │ │ +Definition diagonalmatrix.hh:676 │ │ │ │ │ +Dune::DiagonalMatrix::DiagonalMatrix │ │ │ │ │ +DiagonalMatrix(const K &k) │ │ │ │ │ +Constructor initializing the whole matrix with a scalar. │ │ │ │ │ +Definition diagonalmatrix.hh:98 │ │ │ │ │ +Dune::DiagonalRowVector::Iterator │ │ │ │ │ +ContainerWrapperIterator< DiagonalRowVector< K, n >, K, K & > Iterator │ │ │ │ │ +Iterator class for sequential access. │ │ │ │ │ +Definition diagonalmatrix.hh:886 │ │ │ │ │ +Dune::ContainerWrapperIterator::elementAt │ │ │ │ │ +R elementAt(int i) const │ │ │ │ │ +Definition diagonalmatrix.hh:1079 │ │ │ │ │ +Dune::ContainerWrapperIterator::distanceTo │ │ │ │ │ +std::ptrdiff_t distanceTo(OtherContainerWrapperIteratorType &other) const │ │ │ │ │ +Definition diagonalmatrix.hh:1090 │ │ │ │ │ +Dune::DiagonalRowVector::beforeEnd │ │ │ │ │ +Iterator beforeEnd() │ │ │ │ │ +Definition diagonalmatrix.hh:904 │ │ │ │ │ +Dune::DiagonalMatrix::umtv │ │ │ │ │ +void umtv(const X &x, Y &y) const │ │ │ │ │ +y += A^T x │ │ │ │ │ +Definition diagonalmatrix.hh:309 │ │ │ │ │ +Dune::DiagonalRowVectorConst::const_iterator │ │ │ │ │ +ConstIterator const_iterator │ │ │ │ │ +typedef for stl compliant access │ │ │ │ │ +Definition diagonalmatrix.hh:757 │ │ │ │ │ +Dune::DiagonalMatrix::infinity_norm_real │ │ │ │ │ +double infinity_norm_real() const │ │ │ │ │ +simplified infinity norm (uses Manhattan norm for complex values) │ │ │ │ │ +Definition diagonalmatrix.hh:427 │ │ │ │ │ +Dune::DiagonalMatrixWrapper::DiagonalMatrixWrapper │ │ │ │ │ +DiagonalMatrixWrapper(const DiagonalMatrixType *mat) │ │ │ │ │ +Definition diagonalmatrix.hh:667 │ │ │ │ │ +Dune::DiagonalMatrix::umv │ │ │ │ │ +void umv(const X &x, Y &y) const │ │ │ │ │ +y += A x │ │ │ │ │ +Definition diagonalmatrix.hh:297 │ │ │ │ │ +Dune::DiagonalMatrix::Iterator │ │ │ │ │ +ContainerWrapperIterator< const WrapperType, reference, reference > Iterator │ │ │ │ │ +Iterator class for sequential access. │ │ │ │ │ +Definition diagonalmatrix.hh:143 │ │ │ │ │ +Dune::mutable_reference<_DiagonalRowVectorConst<_K,_n_>_>::type │ │ │ │ │ +DiagonalRowVector< K, n > type │ │ │ │ │ +Definition diagonalmatrix.hh:969 │ │ │ │ │ +Dune::DiagonalMatrix::mv │ │ │ │ │ +void mv(const X &x, Y &y) const │ │ │ │ │ +y = A x │ │ │ │ │ +Definition diagonalmatrix.hh:278 │ │ │ │ │ +Dune::DiagonalMatrix::frobenius_norm │ │ │ │ │ +double frobenius_norm() const │ │ │ │ │ +frobenius norm: sqrt(sum over squared values of entries) │ │ │ │ │ +Definition diagonalmatrix.hh:409 │ │ │ │ │ +Dune::DiagonalMatrix::end │ │ │ │ │ +ConstIterator end() const │ │ │ │ │ +end iterator │ │ │ │ │ +Definition diagonalmatrix.hh:194 │ │ │ │ │ +Dune::DiagonalMatrix::cols │ │ │ │ │ +static constexpr int cols │ │ │ │ │ +The number of columns. │ │ │ │ │ +Definition diagonalmatrix.hh:83 │ │ │ │ │ +Dune::DiagonalRowVectorConst::dimension │ │ │ │ │ +static constexpr int dimension │ │ │ │ │ +Definition diagonalmatrix.hh:705 │ │ │ │ │ +Dune::DiagonalRowVectorConst::p_ │ │ │ │ │ +K * p_ │ │ │ │ │ +Definition diagonalmatrix.hh:835 │ │ │ │ │ +Dune::DiagonalRowVectorConst::rowIndex │ │ │ │ │ +size_type rowIndex() const │ │ │ │ │ +index of this row in surrounding matrix │ │ │ │ │ +Definition diagonalmatrix.hh:806 │ │ │ │ │ +Dune::ContainerWrapperIterator::dereference │ │ │ │ │ +R dereference() const │ │ │ │ │ +Definition diagonalmatrix.hh:1062 │ │ │ │ │ +Dune::DiagonalRowVector::operator= │ │ │ │ │ +DiagonalRowVector & operator=(const K &k) │ │ │ │ │ +Assignment operator for scalar. │ │ │ │ │ +Definition diagonalmatrix.hh:870 │ │ │ │ │ +Dune::DiagonalMatrix::operator!= │ │ │ │ │ +bool operator!=(const DiagonalMatrix &other) const │ │ │ │ │ +incomparison operator │ │ │ │ │ +Definition diagonalmatrix.hh:268 │ │ │ │ │ +Dune::DiagonalMatrix::field_type │ │ │ │ │ +value_type field_type │ │ │ │ │ +Definition diagonalmatrix.hh:61 │ │ │ │ │ +Dune::ContainerWrapperIterator::advance │ │ │ │ │ +void advance(int n) │ │ │ │ │ +Definition diagonalmatrix.hh:1084 │ │ │ │ │ +Dune::DiagonalMatrix::begin │ │ │ │ │ +ConstIterator begin() const │ │ │ │ │ +begin iterator │ │ │ │ │ +Definition diagonalmatrix.hh:188 │ │ │ │ │ +Dune::DiagonalRowVector::begin │ │ │ │ │ +Iterator begin() │ │ │ │ │ +begin iterator │ │ │ │ │ +Definition diagonalmatrix.hh:891 │ │ │ │ │ +Dune::DiagonalMatrix::mmv │ │ │ │ │ +void mmv(const X &x, Y &y) const │ │ │ │ │ +y -= A x │ │ │ │ │ +Definition diagonalmatrix.hh:333 │ │ │ │ │ +Dune::DiagonalMatrix::operator/= │ │ │ │ │ +DiagonalMatrix & operator/=(const K &k) │ │ │ │ │ +vector space division by scalar │ │ │ │ │ +Definition diagonalmatrix.hh:253 │ │ │ │ │ +Dune::DiagonalMatrix::const_iterator │ │ │ │ │ +ConstIterator const_iterator │ │ │ │ │ +typedef for stl compliant access │ │ │ │ │ +Definition diagonalmatrix.hh:181 │ │ │ │ │ +Dune::DiagonalMatrix::const_reference │ │ │ │ │ +const_row_type const_reference │ │ │ │ │ +Definition diagonalmatrix.hh:77 │ │ │ │ │ +Dune::DiagonalMatrix::identical │ │ │ │ │ +bool identical(const DiagonalMatrix< K, n > &other) const │ │ │ │ │ +Check if matrix is the same object as the other matrix. │ │ │ │ │ +Definition diagonalmatrix.hh:130 │ │ │ │ │ +Dune::DiagonalMatrix::operator* │ │ │ │ │ +friend auto operator*(const DiagonalMatrix &matrixA, const DiagonalMatrix< │ │ │ │ │ +OtherScalar, n > &matrixB) │ │ │ │ │ +Matrix-matrix multiplication. │ │ │ │ │ +Definition diagonalmatrix.hh:468 │ │ │ │ │ +Dune::DiagonalMatrixWrapper::realIndex │ │ │ │ │ +size_type realIndex(int i) const │ │ │ │ │ +Definition diagonalmatrix.hh:671 │ │ │ │ │ +Dune::DiagonalMatrix::end │ │ │ │ │ +Iterator end() │ │ │ │ │ +end iterator │ │ │ │ │ +Definition diagonalmatrix.hh:158 │ │ │ │ │ +Dune::DiagonalRowVectorConst::operator[] │ │ │ │ │ +const K & operator[](size_type i) const │ │ │ │ │ +same for read only access │ │ │ │ │ +Definition diagonalmatrix.hh:741 │ │ │ │ │ +Dune::DiagonalRowVector::DiagonalRowVector │ │ │ │ │ +DiagonalRowVector() │ │ │ │ │ +Constructor making uninitialized vector. │ │ │ │ │ +Definition diagonalmatrix.hh:861 │ │ │ │ │ +Dune::DiagonalMatrix::reference │ │ │ │ │ +row_type reference │ │ │ │ │ +Definition diagonalmatrix.hh:74 │ │ │ │ │ +Dune::DiagonalRowVectorConst::operator& │ │ │ │ │ +DiagonalRowVectorConst * operator&() │ │ │ │ │ +Definition diagonalmatrix.hh:829 │ │ │ │ │ +Dune::DiagonalRowVectorConst::operator== │ │ │ │ │ +bool operator==(const DiagonalRowVectorConst &y) const │ │ │ │ │ +Binary vector comparison. │ │ │ │ │ +Definition diagonalmatrix.hh:786 │ │ │ │ │ +Dune::DiagonalMatrix::frobenius_norm2 │ │ │ │ │ +double frobenius_norm2() const │ │ │ │ │ +square of frobenius norm, need for block recursion │ │ │ │ │ +Definition diagonalmatrix.hh:415 │ │ │ │ │ +Dune::DiagonalMatrix::DiagonalMatrix │ │ │ │ │ +constexpr DiagonalMatrix()=default │ │ │ │ │ +Default constructor. │ │ │ │ │ +Dune::DiagonalMatrix::mtv │ │ │ │ │ +void mtv(const X &x, Y &y) const │ │ │ │ │ +y = A^T x │ │ │ │ │ +Definition diagonalmatrix.hh:290 │ │ │ │ │ +Dune::DiagonalRowVector::ConstIterator │ │ │ │ │ +ContainerWrapperIterator< DiagonalRowVectorConst< K, n >, const K, const K & > │ │ │ │ │ +ConstIterator │ │ │ │ │ +ConstIterator class for sequential access. │ │ │ │ │ +Definition diagonalmatrix.hh:917 │ │ │ │ │ +Dune::DiagonalMatrixWrapper::identical │ │ │ │ │ +bool identical(const DiagonalMatrixWrapper &other) const │ │ │ │ │ +Definition diagonalmatrix.hh:682 │ │ │ │ │ +Dune::DiagonalMatrix::usmtv │ │ │ │ │ +void usmtv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y │ │ │ │ │ +&y) const │ │ │ │ │ +y += alpha A^T x │ │ │ │ │ +Definition diagonalmatrix.hh:382 │ │ │ │ │ +Dune::ContainerWrapperIterator::decrement │ │ │ │ │ +void decrement() │ │ │ │ │ +Definition diagonalmatrix.hh:1073 │ │ │ │ │ +Dune::ContainerWrapperIterator::index │ │ │ │ │ +std::ptrdiff_t index() const │ │ │ │ │ +Definition diagonalmatrix.hh:1096 │ │ │ │ │ +Dune::DiagonalMatrix::diagonal │ │ │ │ │ +const FieldVector< K, n > & diagonal() const │ │ │ │ │ +Get const reference to diagonal vector. │ │ │ │ │ +Definition diagonalmatrix.hh:543 │ │ │ │ │ +Dune::DiagonalMatrix::invert │ │ │ │ │ +void invert() │ │ │ │ │ +Compute inverse. │ │ │ │ │ +Definition diagonalmatrix.hh:445 │ │ │ │ │ +Dune::DiagonalRowVector::operator& │ │ │ │ │ +DiagonalRowVector * operator&() │ │ │ │ │ +Definition diagonalmatrix.hh:935 │ │ │ │ │ +Dune::DiagonalMatrix::diagonal │ │ │ │ │ +const K & diagonal(size_type i) const │ │ │ │ │ +Get const reference to diagonal entry. │ │ │ │ │ +Definition diagonalmatrix.hh:531 │ │ │ │ │ +Dune::DiagonalRowVectorConst::N │ │ │ │ │ +size_type N() const │ │ │ │ │ +number of blocks in the vector (are of size 1 here) │ │ │ │ │ +Definition diagonalmatrix.hh:794 │ │ │ │ │ +Dune::DiagonalMatrix::DiagonalMatrix │ │ │ │ │ +DiagonalMatrix(std::initializer_list< K > const &l) │ │ │ │ │ +Construct diagonal matrix from an initializer list. │ │ │ │ │ +Definition diagonalmatrix.hh:115 │ │ │ │ │ +Dune::DiagonalMatrix::ColIterator │ │ │ │ │ +row_type::Iterator ColIterator │ │ │ │ │ +rename the iterators for easier access │ │ │ │ │ +Definition diagonalmatrix.hh:149 │ │ │ │ │ +Dune::DiagonalRowVector::field_type │ │ │ │ │ +K field_type │ │ │ │ │ +export the type representing the field │ │ │ │ │ +Definition diagonalmatrix.hh:852 │ │ │ │ │ +Dune::DiagonalMatrix::operator[] │ │ │ │ │ +reference operator[](size_type i) │ │ │ │ │ +Return reference object as row replacement. │ │ │ │ │ +Definition diagonalmatrix.hh:519 │ │ │ │ │ +Dune::const_reference<_DiagonalRowVector<_K,_n_>_>::type │ │ │ │ │ +DiagonalRowVectorConst< K, n > type │ │ │ │ │ +Definition diagonalmatrix.hh:951 │ │ │ │ │ +Dune::DiagonalRowVector::end │ │ │ │ │ +Iterator end() │ │ │ │ │ +end iterator │ │ │ │ │ +Definition diagonalmatrix.hh:897 │ │ │ │ │ +Dune::DiagonalMatrix::DiagonalMatrix │ │ │ │ │ +DiagonalMatrix(const FieldVector< K, n > &diag) │ │ │ │ │ +Constructor initializing the diagonal with a vector. │ │ │ │ │ +Definition diagonalmatrix.hh:103 │ │ │ │ │ +Dune::DiagonalRowVector::size_type │ │ │ │ │ +std::size_t size_type │ │ │ │ │ +The type used for the index access and size operation. │ │ │ │ │ +Definition diagonalmatrix.hh:858 │ │ │ │ │ +Dune::DiagonalMatrix::usmv │ │ │ │ │ +void usmv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) │ │ │ │ │ +const │ │ │ │ │ +y += alpha A x │ │ │ │ │ +Definition diagonalmatrix.hh:369 │ │ │ │ │ +Dune::DiagonalMatrix::infinity_norm │ │ │ │ │ +double infinity_norm() const │ │ │ │ │ +infinity norm (row sum norm, how to generalize for blocks?) │ │ │ │ │ +Definition diagonalmatrix.hh:421 │ │ │ │ │ +Dune::DiagonalMatrix::operator+= │ │ │ │ │ +DiagonalMatrix & operator+=(const DiagonalMatrix &y) │ │ │ │ │ +vector space addition │ │ │ │ │ +Definition diagonalmatrix.hh:218 │ │ │ │ │ +Dune::DiagonalMatrix::block_type │ │ │ │ │ +K block_type │ │ │ │ │ +export the type representing the components │ │ │ │ │ +Definition diagonalmatrix.hh:64 │ │ │ │ │ +Dune::DiagonalMatrix::umhv │ │ │ │ │ +void umhv(const X &x, Y &y) const │ │ │ │ │ +y += A^H x │ │ │ │ │ +Definition diagonalmatrix.hh:321 │ │ │ │ │ +Dune::DiagonalMatrix::beforeBegin │ │ │ │ │ +Iterator beforeBegin() │ │ │ │ │ +Definition diagonalmatrix.hh:172 │ │ │ │ │ +Dune::DenseMatrixAssigner<_DenseMatrix,_DiagonalMatrix<_field,_N_>_>::apply │ │ │ │ │ +static void apply(DenseMatrix &denseMatrix, DiagonalMatrix< field, N > const │ │ │ │ │ +&rhs) │ │ │ │ │ +Definition diagonalmatrix.hh:1108 │ │ │ │ │ +Dune::ContainerWrapperIterator::ContainerWrapperIterator │ │ │ │ │ +ContainerWrapperIterator(const MyType &other) │ │ │ │ │ +Definition diagonalmatrix.hh:1026 │ │ │ │ │ +Dune::DiagonalRowVectorConst::end │ │ │ │ │ +ConstIterator end() const │ │ │ │ │ +end ConstIterator │ │ │ │ │ +Definition diagonalmatrix.hh:766 │ │ │ │ │ +Dune::DiagonalRowVectorConst::size_type │ │ │ │ │ +std::size_t size_type │ │ │ │ │ +The type used for the index access and size operation. │ │ │ │ │ +Definition diagonalmatrix.hh:718 │ │ │ │ │ +Dune::DiagonalMatrix::operator= │ │ │ │ │ +DiagonalMatrix & operator=(const K &k) │ │ │ │ │ +Assignment from a scalar. │ │ │ │ │ +Definition diagonalmatrix.hh:123 │ │ │ │ │ +Dune::DiagonalRowVectorConst::DiagonalRowVectorConst │ │ │ │ │ +DiagonalRowVectorConst() │ │ │ │ │ +Constructor making uninitialized vector. │ │ │ │ │ +Definition diagonalmatrix.hh:727 │ │ │ │ │ +Dune::DiagonalMatrix::beforeEnd │ │ │ │ │ +Iterator beforeEnd() │ │ │ │ │ +Definition diagonalmatrix.hh:165 │ │ │ │ │ +Dune::DiagonalRowVectorConst::realIndex │ │ │ │ │ +size_type realIndex(int i) const │ │ │ │ │ +Definition diagonalmatrix.hh:819 │ │ │ │ │ +Dune::DiagonalMatrix::operator<< │ │ │ │ │ +friend std::ostream & operator<<(std::ostream &s, const DiagonalMatrix< K, n > │ │ │ │ │ +&a) │ │ │ │ │ +Sends the matrix to an output stream. │ │ │ │ │ +Definition diagonalmatrix.hh:508 │ │ │ │ │ +Dune::DiagonalMatrix::value_type │ │ │ │ │ +K value_type │ │ │ │ │ +export the type representing the field │ │ │ │ │ +Definition diagonalmatrix.hh:60 │ │ │ │ │ +Dune::DiagonalRowVectorConst::block_type │ │ │ │ │ +K block_type │ │ │ │ │ +export the type representing the components │ │ │ │ │ +Definition diagonalmatrix.hh:715 │ │ │ │ │ +Dune::DiagonalMatrix::determinant │ │ │ │ │ +K determinant() const │ │ │ │ │ +calculates the determinant of this matrix │ │ │ │ │ +Definition diagonalmatrix.hh:453 │ │ │ │ │ +Dune::FieldTraits<_DiagonalMatrix<_K,_n_>_>::real_type │ │ │ │ │ +FieldTraits< K >::real_type real_type │ │ │ │ │ +Definition diagonalmatrix.hh:564 │ │ │ │ │ +Dune::DiagonalRowVectorConst::beforeBegin │ │ │ │ │ +ConstIterator beforeBegin() const │ │ │ │ │ +Definition diagonalmatrix.hh:780 │ │ │ │ │ +Dune::DiagonalMatrixWrapper::DiagonalMatrixWrapper │ │ │ │ │ +DiagonalMatrixWrapper() │ │ │ │ │ +Definition diagonalmatrix.hh:663 │ │ │ │ │ +Dune::DiagonalRowVectorConst::ConstIterator │ │ │ │ │ +ContainerWrapperIterator< DiagonalRowVectorConst< K, n >, const K, const K & > │ │ │ │ │ +ConstIterator │ │ │ │ │ +ConstIterator class for sequential access. │ │ │ │ │ +Definition diagonalmatrix.hh:755 │ │ │ │ │ +Dune::DiagonalMatrix::begin │ │ │ │ │ +Iterator begin() │ │ │ │ │ +begin iterator │ │ │ │ │ +Definition diagonalmatrix.hh:152 │ │ │ │ │ +Dune::DiagonalMatrix::operator== │ │ │ │ │ +bool operator==(const DiagonalMatrix &other) const │ │ │ │ │ +comparison operator │ │ │ │ │ +Definition diagonalmatrix.hh:262 │ │ │ │ │ +Dune::DiagonalMatrix::const_row_type │ │ │ │ │ +DiagonalRowVectorConst< K, n > const_row_type │ │ │ │ │ +Definition diagonalmatrix.hh:76 │ │ │ │ │ +Dune::DiagonalMatrix::row_type │ │ │ │ │ +DiagonalRowVector< K, n > row_type │ │ │ │ │ +Each row is implemented by a field vector. │ │ │ │ │ +Definition diagonalmatrix.hh:73 │ │ │ │ │ +Dune::ContainerWrapperIterator::equals │ │ │ │ │ +bool equals(const MyType &other) const │ │ │ │ │ +Definition diagonalmatrix.hh:1052 │ │ │ │ │ +Dune::DiagonalMatrix::RowIterator │ │ │ │ │ +Iterator RowIterator │ │ │ │ │ +rename the iterators for easier access │ │ │ │ │ +Definition diagonalmatrix.hh:147 │ │ │ │ │ +Dune::DiagonalRowVector::block_type │ │ │ │ │ +K block_type │ │ │ │ │ +export the type representing the components │ │ │ │ │ +Definition diagonalmatrix.hh:855 │ │ │ │ │ +Dune::DiagonalMatrix::beforeEnd │ │ │ │ │ +ConstIterator beforeEnd() const │ │ │ │ │ +Definition diagonalmatrix.hh:201 │ │ │ │ │ +Dune::DiagonalRowVectorConst::diagonal │ │ │ │ │ +const K & diagonal() const │ │ │ │ │ +the diagonal value │ │ │ │ │ +Definition diagonalmatrix.hh:812 │ │ │ │ │ DUNE_THROW │ │ │ │ │ #define DUNE_THROW(E, m) │ │ │ │ │ Definition exceptions.hh:218 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -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 │ │ │ │ │ +Dune::conjugateComplex │ │ │ │ │ +K conjugateComplex(const K &x) │ │ │ │ │ +compute conjugate complex of x │ │ │ │ │ +Definition math.hh:164 │ │ │ │ │ +Dune::DenseMatrix │ │ │ │ │ +A dense n x m matrix. │ │ │ │ │ +Definition densematrix.hh:140 │ │ │ │ │ +Dune::DenseMatrix::M │ │ │ │ │ +constexpr size_type M() const │ │ │ │ │ +number of columns │ │ │ │ │ +Definition densematrix.hh:703 │ │ │ │ │ +Dune::DenseMatrix::N │ │ │ │ │ +constexpr size_type N() const │ │ │ │ │ +number of rows │ │ │ │ │ +Definition densematrix.hh:697 │ │ │ │ │ +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:95 │ │ │ │ │ +Dune::DenseMatrixAssigner │ │ │ │ │ +you have to specialize this structure for any type that should be assignable to │ │ │ │ │ +a DenseMatrix │ │ │ │ │ +Definition densematrix.hh:59 │ │ │ │ │ +Dune::FMatrixError │ │ │ │ │ +Error thrown if operations of a FieldMatrix fail. │ │ │ │ │ +Definition densematrix.hh:126 │ │ │ │ │ +Dune::DenseVector::two_norm2 │ │ │ │ │ +FieldTraits< value_type >::real_type two_norm2() const │ │ │ │ │ +square of two norm (sum over squared values of entries), need for block │ │ │ │ │ +recursion │ │ │ │ │ +Definition densevector.hh:650 │ │ │ │ │ +Dune::DenseVector::two_norm │ │ │ │ │ +FieldTraits< value_type >::real_type two_norm() const │ │ │ │ │ +two norm sqrt(sum over squared values of entries) │ │ │ │ │ +Definition densevector.hh:641 │ │ │ │ │ +Dune::DenseVector::begin │ │ │ │ │ +Iterator begin() │ │ │ │ │ +begin iterator │ │ │ │ │ +Definition densevector.hh:347 │ │ │ │ │ +Dune::DenseVector::infinity_norm │ │ │ │ │ +FieldTraits< vt >::real_type infinity_norm() const │ │ │ │ │ +infinity norm (maximum of absolute values of entries) │ │ │ │ │ +Definition densevector.hh:661 │ │ │ │ │ +Dune::DenseVector::infinity_norm_real │ │ │ │ │ +FieldTraits< vt >::real_type infinity_norm_real() const │ │ │ │ │ +simplified infinity norm (uses Manhattan norm for complex values) │ │ │ │ │ +Definition densevector.hh:677 │ │ │ │ │ +Dune::DiagonalRowVectorConst │ │ │ │ │ +Definition diagonalmatrix.hh:698 │ │ │ │ │ +Dune::DiagonalRowVector │ │ │ │ │ +Definition diagonalmatrix.hh:841 │ │ │ │ │ +Dune::DiagonalMatrixWrapper │ │ │ │ │ +Definition diagonalmatrix.hh:650 │ │ │ │ │ +Dune::ContainerWrapperIterator │ │ │ │ │ +Iterator class for sparse vector-like containers. │ │ │ │ │ +Definition diagonalmatrix.hh:998 │ │ │ │ │ +Dune::ContainerWrapperIterator::ContainerWrapperIterator │ │ │ │ │ +ContainerWrapperIterator(const MyConstType &other) │ │ │ │ │ +Definition diagonalmatrix.hh:1031 │ │ │ │ │ +Dune::ContainerWrapperIterator::equals │ │ │ │ │ +bool equals(const MyConstType &other) const │ │ │ │ │ +Definition diagonalmatrix.hh:1057 │ │ │ │ │ +Dune::DiagonalMatrix │ │ │ │ │ +A diagonal matrix of static size. │ │ │ │ │ +Definition diagonalmatrix.hh:53 │ │ │ │ │ +Dune::FieldTraits │ │ │ │ │ +Definition ftraits.hh:26 │ │ │ │ │ +Dune::FieldTraits::field_type │ │ │ │ │ +T field_type │ │ │ │ │ +export the type representing the field │ │ │ │ │ +Definition ftraits.hh:28 │ │ │ │ │ +Dune::FieldTraits::real_type │ │ │ │ │ +T real_type │ │ │ │ │ +export the type representing the real type of the field │ │ │ │ │ +Definition ftraits.hh:30 │ │ │ │ │ +Dune::const_reference │ │ │ │ │ +Get the 'const' version of a reference to a mutable object. │ │ │ │ │ +Definition genericiterator.hh:87 │ │ │ │ │ +Dune::mutable_reference │ │ │ │ │ +get the 'mutable' version of a reference to a const object │ │ │ │ │ +Definition genericiterator.hh:116 │ │ │ │ │ +Dune::BidirectionalIteratorFacade │ │ │ │ │ +Facade class for stl conformant bidirectional iterators. │ │ │ │ │ +Definition iteratorfacades.hh:274 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00179.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: float_cmp.hh File Reference │ │ │ │ +dune-common: parametertree.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -71,100 +71,69 @@ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ Classes | │ │ │ │ -Namespaces | │ │ │ │ -Enumerations | │ │ │ │ -Functions
    │ │ │ │ -
    float_cmp.hh File Reference
    │ │ │ │ +Namespaces
    │ │ │ │ +
    parametertree.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ -

    Various ways to compare floating-point numbers. │ │ │ │ +

    A hierarchical structure of string parameters. │ │ │ │ More...

    │ │ │ │ -
    #include "float_cmp.cc"
    │ │ │ │ +
    #include <array>
    │ │ │ │ +#include <cstddef>
    │ │ │ │ +#include <iostream>
    │ │ │ │ +#include <istream>
    │ │ │ │ +#include <iterator>
    │ │ │ │ +#include <locale>
    │ │ │ │ +#include <map>
    │ │ │ │ +#include <ostream>
    │ │ │ │ +#include <sstream>
    │ │ │ │ +#include <string>
    │ │ │ │ +#include <typeinfo>
    │ │ │ │ +#include <vector>
    │ │ │ │ +#include <algorithm>
    │ │ │ │ +#include <bitset>
    │ │ │ │ +#include <dune/common/exceptions.hh>
    │ │ │ │ +#include <dune/common/fvector.hh>
    │ │ │ │ +#include <dune/common/classname.hh>
    │ │ │ │
    │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ Classes

    struct  Dune::FloatCmp::DefaultEpsilon< T, style >
     mapping from a value type and a compare style to a default epsilon More...
    class  Dune::ParameterTree
     Hierarchical structure of string parameters. More...
     
    class  Dune::FloatCmpOps< T, cstyle_, rstyle_ >
     Class encapsulating a default epsilon. More...
    struct  Dune::ParameterTree::Parser< std::basic_string< char, traits, Allocator > >
     
    struct  Dune::ParameterTree::Parser< bool >
     
    struct  Dune::ParameterTree::Parser< bool >::ToLower
     
    struct  Dune::ParameterTree::Parser< FieldVector< T, n > >
     
    struct  Dune::ParameterTree::Parser< std::array< T, n > >
     
    struct  Dune::ParameterTree::Parser< std::bitset< n > >
     
    struct  Dune::ParameterTree::Parser< std::vector< T, A > >
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ -

    │ │ │ │ Namespaces

    namespace  Dune
     Dune namespace.
     
    namespace  Dune::FloatCmp
     
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

    │ │ │ │ -Enumerations

    enum  Dune::FloatCmp::CmpStyle { Dune::FloatCmp::relativeWeak │ │ │ │ -, Dune::FloatCmp::relativeStrong │ │ │ │ -, Dune::FloatCmp::absolute │ │ │ │ -, Dune::FloatCmp::defaultCmpStyle = relativeWeak │ │ │ │ - }
     
    enum  Dune::FloatCmp::RoundingStyle {
    │ │ │ │ -  Dune::FloatCmp::towardZero │ │ │ │ -, Dune::FloatCmp::towardInf │ │ │ │ -, Dune::FloatCmp::downward │ │ │ │ -, Dune::FloatCmp::upward │ │ │ │ -,
    │ │ │ │ -  Dune::FloatCmp::defaultRoundingStyle = towardZero │ │ │ │ -
    │ │ │ │ - }
     
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │

    │ │ │ │ -Functions

    template<class T , CmpStyle style>
    bool Dune::FloatCmp::eq (const T &first, const T &second, typename EpsilonType< T >::Type epsilon=DefaultEpsilon< T, style >::value())
     test for equality using epsilon
     
    template<class T , CmpStyle style>
    bool Dune::FloatCmp::ne (const T &first, const T &second, typename EpsilonType< T >::Type epsilon=DefaultEpsilon< T, style >::value())
     test for inequality using epsilon
     
    template<class T , CmpStyle style>
    bool Dune::FloatCmp::gt (const T &first, const T &second, typename EpsilonType< T >::Type epsilon=DefaultEpsilon< T, style >::value())
     test if first greater than second
     
    template<class T , CmpStyle style>
    bool Dune::FloatCmp::lt (const T &first, const T &second, typename EpsilonType< T >::Type epsilon=DefaultEpsilon< T, style >::value())
     test if first lesser than second
     
    template<class T , CmpStyle style>
    bool Dune::FloatCmp::ge (const T &first, const T &second, typename EpsilonType< T >::Type epsilon=DefaultEpsilon< T, style >::value())
     test if first greater or equal second
     
    template<class T , CmpStyle style>
    bool Dune::FloatCmp::le (const T &first, const T &second, typename EpsilonType< T >::Type epsilon=DefaultEpsilon< T, style >::value())
     test if first lesser or equal second
     
    template<class I , class T , CmpStyle cstyle, RoundingStyle rstyle>
    Dune::FloatCmp::round (const T &val, typename EpsilonType< T >::Type epsilon=DefaultEpsilon< T, cstyle >::value())
     round using epsilon
     
    template<class I , class T , CmpStyle cstyle, RoundingStyle rstyle>
    Dune::FloatCmp::trunc (const T &val, typename EpsilonType< T >::Type epsilon=DefaultEpsilon< T, cstyle >::value())
     truncate using epsilon
     
    │ │ │ │

    Detailed Description

    │ │ │ │ -

    Various ways to compare floating-point numbers.

    │ │ │ │ +

    A hierarchical structure of string parameters.

    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,83 +6,56 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Enumerations | Functions │ │ │ │ │ -float_cmp.hh File Reference │ │ │ │ │ -Various ways to compare floating-point numbers. More... │ │ │ │ │ -#include "float_cmp.cc" │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +parametertree.hh File Reference │ │ │ │ │ +A hierarchical structure of string parameters. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#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::FloatCmp::DefaultEpsilon<_T,_style_> │ │ │ │ │ -  mapping from a value type and a compare style to a default epsilon │ │ │ │ │ - More... │ │ │ │ │ + class  Dune::ParameterTree │ │ │ │ │ +  Hierarchical structure of string parameters. More... │ │ │ │ │   │ │ │ │ │ - class  Dune::FloatCmpOps<_T,_cstyle_,_rstyle__> │ │ │ │ │ -  Class encapsulating a default epsilon. More... │ │ │ │ │ +struct  Dune::ParameterTree::Parser<_std::basic_string<_char,_traits, │ │ │ │ │ + Allocator_>_> │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::ParameterTree::Parser<_bool_> │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::ParameterTree::Parser<_bool_>::ToLower │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::ParameterTree::Parser<_FieldVector<_T,_n_>_> │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::ParameterTree::Parser<_std::array<_T,_n_>_> │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::ParameterTree::Parser<_std::bitset<_n_>_> │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::ParameterTree::Parser<_std::vector<_T,_A_>_> │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -namespace  Dune::FloatCmp │ │ │ │ │ -  │ │ │ │ │ - Enumerations │ │ │ │ │ -enum Dune::FloatCmp::CmpStyle { Dune::FloatCmp::relativeWeak , Dune::FloatCmp:: │ │ │ │ │ -  relativeStrong , Dune::FloatCmp::absolute , Dune::FloatCmp::defaultCmpStyle = │ │ │ │ │ - relativeWeak } │ │ │ │ │ -  │ │ │ │ │ -enum Dune::FloatCmp::RoundingStyle { │ │ │ │ │ -    Dune::FloatCmp::towardZero , Dune::FloatCmp::towardInf , Dune::FloatCmp:: │ │ │ │ │ - downward , Dune::FloatCmp::upward , │ │ │ │ │ -   Dune::FloatCmp::defaultRoundingStyle = towardZero │ │ │ │ │ - } │ │ │ │ │ -  │ │ │ │ │ - Functions │ │ │ │ │ -template │ │ │ │ │ -bool Dune::FloatCmp::eq (const T &first, const T &second, typename │ │ │ │ │ - EpsilonType< T >::Type epsilon=DefaultEpsilon< T, style >::value()) │ │ │ │ │ -  test for equality using epsilon │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool Dune::FloatCmp::ne (const T &first, const T &second, typename │ │ │ │ │ - EpsilonType< T >::Type epsilon=DefaultEpsilon< T, style >::value()) │ │ │ │ │ -  test for inequality using epsilon │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool Dune::FloatCmp::gt (const T &first, const T &second, typename │ │ │ │ │ - EpsilonType< T >::Type epsilon=DefaultEpsilon< T, style >::value()) │ │ │ │ │ -  test if first greater than second │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool Dune::FloatCmp::lt (const T &first, const T &second, typename │ │ │ │ │ - EpsilonType< T >::Type epsilon=DefaultEpsilon< T, style >::value()) │ │ │ │ │ -  test if first lesser than second │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool Dune::FloatCmp::ge (const T &first, const T &second, typename │ │ │ │ │ - EpsilonType< T >::Type epsilon=DefaultEpsilon< T, style >::value()) │ │ │ │ │ -  test if first greater or equal second │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool Dune::FloatCmp::le (const T &first, const T &second, typename │ │ │ │ │ - EpsilonType< T >::Type epsilon=DefaultEpsilon< T, style >::value()) │ │ │ │ │ -  test if first lesser or equal second │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - I Dune::FloatCmp::round (const T &val, typename EpsilonType< T >::Type │ │ │ │ │ - epsilon=DefaultEpsilon< T, cstyle >::value()) │ │ │ │ │ -  round using epsilon │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - I Dune::FloatCmp::trunc (const T &val, typename EpsilonType< T >::Type │ │ │ │ │ - epsilon=DefaultEpsilon< T, cstyle >::value()) │ │ │ │ │ -  truncate using epsilon │ │ │ │ │ -  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Various ways to compare floating-point numbers. │ │ │ │ │ +A hierarchical structure of string parameters. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00179_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: float_cmp.hh Source File │ │ │ │ +dune-common: parametertree.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,197 +74,345 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    float_cmp.hh
    │ │ │ │ +
    parametertree.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 (C) 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_FLOAT_CMP_HH
    │ │ │ │ -
    6#define DUNE_COMMON_FLOAT_CMP_HH
    │ │ │ │ +
    5#ifndef DUNE_PARAMETERTREE_HH
    │ │ │ │ +
    6#define DUNE_PARAMETERTREE_HH
    │ │ │ │
    7
    │ │ │ │ -
    97namespace Dune {
    │ │ │ │ -
    100 namespace FloatCmp {
    │ │ │ │ -
    101 // basic constants
    │ │ │ │ -
    │ │ │ │ -
    104 enum CmpStyle {
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
    113 };
    │ │ │ │ -
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
    127 };
    │ │ │ │ -
    │ │ │ │ -
    128
    │ │ │ │ -
    129 template<class T> struct EpsilonType;
    │ │ │ │ -
    130
    │ │ │ │ -
    132
    │ │ │ │ -
    137 template<class T, CmpStyle style = defaultCmpStyle>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    140 static typename EpsilonType<T>::Type value();
    │ │ │ │ -
    141 };
    │ │ │ │ -
    │ │ │ │ -
    142
    │ │ │ │ -
    143 // operations in functional style
    │ │ │ │ -
    144
    │ │ │ │ +
    12#include <array>
    │ │ │ │ +
    13#include <cstddef>
    │ │ │ │ +
    14#include <iostream>
    │ │ │ │ +
    15#include <istream>
    │ │ │ │ +
    16#include <iterator>
    │ │ │ │ +
    17#include <locale>
    │ │ │ │ +
    18#include <map>
    │ │ │ │ +
    19#include <ostream>
    │ │ │ │ +
    20#include <sstream>
    │ │ │ │ +
    21#include <string>
    │ │ │ │ +
    22#include <typeinfo>
    │ │ │ │ +
    23#include <vector>
    │ │ │ │ +
    24#include <algorithm>
    │ │ │ │ +
    25#include <bitset>
    │ │ │ │ +
    26
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    30
    │ │ │ │ +
    31namespace Dune {
    │ │ │ │ +
    32
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    37 {
    │ │ │ │ +
    38 // class providing a single static parse() function, used by the
    │ │ │ │ +
    39 // generic get() method
    │ │ │ │ +
    40 template<typename T>
    │ │ │ │ +
    41 struct Parser;
    │ │ │ │ +
    42
    │ │ │ │ +
    43 public:
    │ │ │ │ +
    44
    │ │ │ │ +
    47 typedef std::vector<std::string> KeyVector;
    │ │ │ │ +
    48
    │ │ │ │ + │ │ │ │ +
    52
    │ │ │ │ +
    53
    │ │ │ │ +
    61 bool hasKey(const std::string& key) const;
    │ │ │ │ +
    62
    │ │ │ │ +
    63
    │ │ │ │ +
    71 bool hasSub(const std::string& sub) const;
    │ │ │ │ +
    72
    │ │ │ │ +
    73
    │ │ │ │ +
    82 std::string& operator[] (const std::string& key);
    │ │ │ │ +
    83
    │ │ │ │ +
    84
    │ │ │ │ +
    94 const std::string& operator[] (const std::string& key) const;
    │ │ │ │ +
    95
    │ │ │ │ +
    96
    │ │ │ │ +
    104 void report(std::ostream& stream = std::cout,
    │ │ │ │ +
    105 const std::string& prefix = "") const;
    │ │ │ │ +
    106
    │ │ │ │ +
    107
    │ │ │ │ +
    113 ParameterTree& sub(const std::string& sub);
    │ │ │ │ +
    114
    │ │ │ │ +
    115
    │ │ │ │ +
    122 const ParameterTree& sub(const std::string& sub, bool fail_if_missing = false) const;
    │ │ │ │ +
    123
    │ │ │ │ +
    124
    │ │ │ │ +
    133 std::string get(const std::string& key, const std::string& defaultValue) const;
    │ │ │ │ +
    134
    │ │ │ │ +
    145 std::string get(const std::string& key, const char* defaultValue) const;
    │ │ │ │ +
    146
    │ │ │ │
    147
    │ │ │ │ -
    149
    │ │ │ │ -
    156 template <class T, CmpStyle style /*= defaultCmpStyle*/>
    │ │ │ │ -
    157 bool eq(const T &first,
    │ │ │ │ -
    158 const T &second,
    │ │ │ │ - │ │ │ │ -
    161
    │ │ │ │ -
    169 template <class T, CmpStyle style /*= defaultCmpStyle*/>
    │ │ │ │ -
    170 bool ne(const T &first,
    │ │ │ │ -
    171 const T &second,
    │ │ │ │ - │ │ │ │ -
    174
    │ │ │ │ -
    185 template <class T, CmpStyle style /*= defaultCmpStyle*/>
    │ │ │ │ -
    186 bool gt(const T &first,
    │ │ │ │ -
    187 const T &second,
    │ │ │ │ - │ │ │ │ -
    190
    │ │ │ │ -
    201 template <class T, CmpStyle style /*= defaultCmpStyle*/>
    │ │ │ │ -
    202 bool lt(const T &first,
    │ │ │ │ -
    203 const T &second,
    │ │ │ │ - │ │ │ │ -
    206
    │ │ │ │ -
    217 template <class T, CmpStyle style /*= defaultCmpStyle*/>
    │ │ │ │ -
    218 bool ge(const T &first,
    │ │ │ │ -
    219 const T &second,
    │ │ │ │ - │ │ │ │ -
    222
    │ │ │ │ -
    233 template <class T, CmpStyle style /*= defaultCmpStyle*/>
    │ │ │ │ -
    234 bool le(const T &first,
    │ │ │ │ -
    235 const T &second,
    │ │ │ │ - │ │ │ │ -
    237
    │ │ │ │ -
    238 // rounding operations
    │ │ │ │ -
    240
    │ │ │ │ -
    253 template<class I, class T, CmpStyle cstyle /*= defaultCmpStyle*/, RoundingStyle rstyle /*= defaultRoundingStyle*/>
    │ │ │ │ -
    254 I round(const T &val, typename EpsilonType<T>::Type epsilon = DefaultEpsilon<T, cstyle>::value());
    │ │ │ │ -
    255 // truncation
    │ │ │ │ -
    257
    │ │ │ │ -
    270 template<class I, class T, CmpStyle cstyle /*= defaultCmpStyle*/, RoundingStyle rstyle /*= defaultRoundingStyle*/>
    │ │ │ │ -
    271 I trunc(const T &val, typename EpsilonType<T>::Type epsilon = DefaultEpsilon<T, cstyle>::value());
    │ │ │ │ -
    272
    │ │ │ │ -
    274 // group FloatCmp
    │ │ │ │ -
    275 } //namespace FloatCmp
    │ │ │ │ -
    276
    │ │ │ │ -
    277
    │ │ │ │ -
    278 // oo interface
    │ │ │ │ -
    280
    │ │ │ │ -
    286 template<class T, FloatCmp::CmpStyle cstyle_ = FloatCmp::defaultCmpStyle,
    │ │ │ │ - │ │ │ │ -
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ +
    157 template<typename T>
    │ │ │ │ +
    │ │ │ │ +
    158 T get(const std::string& key, const T& defaultValue) const {
    │ │ │ │ +
    159 if(hasKey(key))
    │ │ │ │ +
    160 return get<T>(key);
    │ │ │ │ +
    161 else
    │ │ │ │ +
    162 return defaultValue;
    │ │ │ │ +
    163 }
    │ │ │ │ +
    │ │ │ │ +
    164
    │ │ │ │ +
    173 template <class T>
    │ │ │ │ +
    │ │ │ │ +
    174 T get(const std::string& key) const {
    │ │ │ │ +
    175 if(not hasKey(key))
    │ │ │ │ +
    176 DUNE_THROW(Dune::RangeError, "Key '" << key
    │ │ │ │ +
    177 << "' not found in ParameterTree (prefix " + prefix_ + ")");
    │ │ │ │ +
    178 try {
    │ │ │ │ +
    179 return Parser<T>::parse((*this)[key]);
    │ │ │ │ +
    180 }
    │ │ │ │ +
    181 catch(const RangeError& e) {
    │ │ │ │ +
    182 // rethrow the error and add more information
    │ │ │ │ +
    183 DUNE_THROW(RangeError, "Cannot parse value \"" << (*this)[key]
    │ │ │ │ +
    184 << "\" for key \"" << prefix_ << "." << key << "\""
    │ │ │ │ +
    185 << e.what());
    │ │ │ │ +
    186 }
    │ │ │ │ +
    187 }
    │ │ │ │ +
    │ │ │ │ +
    188
    │ │ │ │ +
    196 const KeyVector& getValueKeys() const;
    │ │ │ │ +
    197
    │ │ │ │ +
    198
    │ │ │ │ +
    206 const KeyVector& getSubKeys() const;
    │ │ │ │ +
    207
    │ │ │ │ +
    208 protected:
    │ │ │ │ +
    209
    │ │ │ │ +
    210 static const ParameterTree empty_;
    │ │ │ │ +
    211
    │ │ │ │ +
    212 std::string prefix_;
    │ │ │ │ +
    213
    │ │ │ │ + │ │ │ │ + │ │ │ │ +
    216
    │ │ │ │ +
    217 std::map<std::string, std::string> values_;
    │ │ │ │ +
    218 std::map<std::string, ParameterTree> subs_;
    │ │ │ │ +
    219
    │ │ │ │ +
    220 static std::string ltrim(const std::string& s);
    │ │ │ │ +
    221 static std::string rtrim(const std::string& s);
    │ │ │ │ +
    222 static std::vector<std::string> split(const std::string & s);
    │ │ │ │ +
    223
    │ │ │ │ +
    224 // parse into a fixed-size range of iterators
    │ │ │ │ +
    225 template<class Iterator>
    │ │ │ │ +
    │ │ │ │ +
    226 static void parseRange(const std::string &str,
    │ │ │ │ +
    227 Iterator it, const Iterator &end)
    │ │ │ │ +
    228 {
    │ │ │ │ +
    229 typedef typename std::iterator_traits<Iterator>::value_type Value;
    │ │ │ │ +
    230 std::istringstream s(str);
    │ │ │ │ +
    231 // make sure we are in locale "C"
    │ │ │ │ +
    232 s.imbue(std::locale::classic());
    │ │ │ │ +
    233 std::size_t n = 0;
    │ │ │ │ +
    234 for(; it != end; ++it, ++n) {
    │ │ │ │ +
    235 s >> *it;
    │ │ │ │ +
    236 if(!s)
    │ │ │ │ +
    237 DUNE_THROW(RangeError, "as a range of items of type "
    │ │ │ │ +
    238 << className<Value>()
    │ │ │ │ +
    239 << " (" << n << " items were extracted successfully)");
    │ │ │ │ +
    240 }
    │ │ │ │ +
    241 Value dummy;
    │ │ │ │ +
    242 s >> dummy;
    │ │ │ │ +
    243 // now extraction should have failed, and eof should be set
    │ │ │ │ +
    244 if(not s.fail() or not s.eof())
    │ │ │ │ +
    245 DUNE_THROW(RangeError, "as a range of "
    │ │ │ │ +
    246 << n << " items of type "
    │ │ │ │ +
    247 << className<Value>() << " (more items than the range can hold)");
    │ │ │ │ +
    248 }
    │ │ │ │ +
    │ │ │ │ +
    249 };
    │ │ │ │ +
    │ │ │ │ +
    250
    │ │ │ │ +
    251 template<typename T>
    │ │ │ │ +
    252 struct ParameterTree::Parser {
    │ │ │ │ +
    253 static T parse(const std::string& str) {
    │ │ │ │ +
    254 T val;
    │ │ │ │ +
    255 std::istringstream s(str);
    │ │ │ │ +
    256 // make sure we are in locale "C"
    │ │ │ │ +
    257 s.imbue(std::locale::classic());
    │ │ │ │ +
    258 s >> val;
    │ │ │ │ +
    259 if(!s)
    │ │ │ │ +
    260 DUNE_THROW(RangeError, " as a " << className<T>());
    │ │ │ │ +
    261 char dummy;
    │ │ │ │ +
    262 s >> dummy;
    │ │ │ │ +
    263 // now extraction should have failed, and eof should be set
    │ │ │ │ +
    264 if ((! s.fail()) || (! s.eof()))
    │ │ │ │ +
    265 DUNE_THROW(RangeError, " as a " << className<T>());
    │ │ │ │ +
    266 return val;
    │ │ │ │ +
    267 }
    │ │ │ │ +
    268 };
    │ │ │ │ +
    269
    │ │ │ │ +
    270 // "How do I convert a string into a wstring in C++?" "Why, that very simple
    │ │ │ │ +
    271 // son. You just need a these hundred lines of code."
    │ │ │ │ +
    272 // Instead im going to restrict myself to string with charT=char here.
    │ │ │ │ +
    273 template<typename traits, typename Allocator>
    │ │ │ │ +
    │ │ │ │ +
    274 struct ParameterTree::Parser<std::basic_string<char, traits, Allocator> > {
    │ │ │ │ +
    275 static std::basic_string<char, traits, Allocator>
    │ │ │ │ +
    │ │ │ │ +
    276 parse(const std::string& str) {
    │ │ │ │ +
    277 std::string trimmed = ltrim(rtrim(str));
    │ │ │ │ +
    278 return std::basic_string<char, traits, Allocator>(trimmed.begin(),
    │ │ │ │ +
    279 trimmed.end());
    │ │ │ │ +
    280 }
    │ │ │ │ +
    │ │ │ │ +
    281 };
    │ │ │ │ +
    │ │ │ │ +
    282
    │ │ │ │ +
    283 template<>
    │ │ │ │ +
    │ │ │ │ +
    284 struct ParameterTree::Parser< bool > {
    │ │ │ │ +
    │ │ │ │ +
    285 struct ToLower {
    │ │ │ │ +
    │ │ │ │ +
    286 char operator()(char c)
    │ │ │ │ +
    287 {
    │ │ │ │ +
    288 return std::tolower(c, std::locale::classic());
    │ │ │ │ +
    289 }
    │ │ │ │ +
    │ │ │ │ +
    290 };
    │ │ │ │ +
    │ │ │ │
    291
    │ │ │ │ -
    292 public:
    │ │ │ │ -
    293 // record template parameters
    │ │ │ │ -
    295 static const CmpStyle cstyle = cstyle_;
    │ │ │ │ -
    297 static const RoundingStyle rstyle = rstyle_;
    │ │ │ │ -
    299 typedef T ValueType;
    │ │ │ │ -
    301
    │ │ │ │ - │ │ │ │ -
    305
    │ │ │ │ -
    306 private:
    │ │ │ │ -
    307 EpsilonType epsilon_;
    │ │ │ │ -
    308
    │ │ │ │ - │ │ │ │ -
    310
    │ │ │ │ -
    311 public:
    │ │ │ │ -
    313
    │ │ │ │ - │ │ │ │ +
    292 static bool
    │ │ │ │ +
    │ │ │ │ +
    293 parse(const std::string& str) {
    │ │ │ │ +
    294 std::string ret = str;
    │ │ │ │ +
    295
    │ │ │ │ +
    296 std::transform(ret.begin(), ret.end(), ret.begin(), ToLower());
    │ │ │ │ +
    297
    │ │ │ │ +
    298 if (ret == "yes" || ret == "true")
    │ │ │ │ +
    299 return true;
    │ │ │ │ +
    300
    │ │ │ │ +
    301 if (ret == "no" || ret == "false")
    │ │ │ │ +
    302 return false;
    │ │ │ │ +
    303
    │ │ │ │ +
    304 return (Parser<int>::parse(ret) != 0);
    │ │ │ │ +
    305 }
    │ │ │ │ +
    │ │ │ │ +
    306 };
    │ │ │ │ +
    │ │ │ │ +
    307
    │ │ │ │ +
    308 template<typename T, int n>
    │ │ │ │ +
    │ │ │ │ +
    309 struct ParameterTree::Parser<FieldVector<T, n> > {
    │ │ │ │ +
    310 static FieldVector<T, n>
    │ │ │ │ +
    │ │ │ │ +
    311 parse(const std::string& str) {
    │ │ │ │ + │ │ │ │ +
    313 parseRange(str, val.begin(), val.end());
    │ │ │ │ +
    314 return val;
    │ │ │ │ +
    315 }
    │ │ │ │ +
    │ │ │ │ +
    316 };
    │ │ │ │ +
    │ │ │ │
    317
    │ │ │ │ -
    319 EpsilonType epsilon() const;
    │ │ │ │ -
    321 void epsilon(EpsilonType epsilon__);
    │ │ │ │ -
    322
    │ │ │ │ -
    324 bool eq(const ValueType &first, const ValueType &second) const;
    │ │ │ │ -
    326
    │ │ │ │ -
    329 bool ne(const ValueType &first, const ValueType &second) const;
    │ │ │ │ -
    331
    │ │ │ │ -
    335 bool gt(const ValueType &first, const ValueType &second) const;
    │ │ │ │ -
    337
    │ │ │ │ -
    341 bool lt(const ValueType &first, const ValueType &second) const;
    │ │ │ │ +
    318 template<typename T, std::size_t n>
    │ │ │ │ +
    │ │ │ │ +
    319 struct ParameterTree::Parser<std::array<T, n> > {
    │ │ │ │ +
    320 static std::array<T, n>
    │ │ │ │ +
    │ │ │ │ +
    321 parse(const std::string& str) {
    │ │ │ │ +
    322 std::array<T, n> val;
    │ │ │ │ +
    323 parseRange(str, val.begin(), val.end());
    │ │ │ │ +
    324 return val;
    │ │ │ │ +
    325 }
    │ │ │ │ +
    │ │ │ │ +
    326 };
    │ │ │ │ +
    │ │ │ │ +
    327
    │ │ │ │ +
    328 template<std::size_t n>
    │ │ │ │ +
    │ │ │ │ +
    329 struct ParameterTree::Parser<std::bitset<n> > {
    │ │ │ │ +
    330 static std::bitset<n>
    │ │ │ │ +
    │ │ │ │ +
    331 parse(const std::string& str) {
    │ │ │ │ +
    332 std::bitset<n> val;
    │ │ │ │ +
    333 std::vector<std::string> sub = split(str);
    │ │ │ │ +
    334 if (sub.size() != n)
    │ │ │ │ +
    335 DUNE_THROW(RangeError, "as a bitset<" << n << "> "
    │ │ │ │ +
    336 << "because of unmatching size " << sub.size());
    │ │ │ │ +
    337 for (std::size_t i=0; i<n; ++i) {
    │ │ │ │ +
    338 val[i] = ParameterTree::Parser<bool>::parse(sub[i]);
    │ │ │ │ +
    339 }
    │ │ │ │ +
    340 return val;
    │ │ │ │ +
    341 }
    │ │ │ │ +
    │ │ │ │ +
    342 };
    │ │ │ │ +
    │ │ │ │
    343
    │ │ │ │ -
    347 bool ge(const ValueType &first, const ValueType &second) const;
    │ │ │ │ -
    349
    │ │ │ │ -
    353 bool le(const ValueType &first, const ValueType &second) const;
    │ │ │ │ -
    354
    │ │ │ │ -
    356
    │ │ │ │ -
    365 template<class I>
    │ │ │ │ -
    366 I round(const ValueType &val) const;
    │ │ │ │ -
    367
    │ │ │ │ -
    369
    │ │ │ │ -
    378 template<class I>
    │ │ │ │ -
    379 I trunc(const ValueType &val) const;
    │ │ │ │ -
    380
    │ │ │ │ -
    381 };
    │ │ │ │ -
    │ │ │ │ -
    382
    │ │ │ │ -
    383} //namespace Dune
    │ │ │ │ -
    384
    │ │ │ │ -
    385#include "float_cmp.cc"
    │ │ │ │ -
    386
    │ │ │ │ -
    387#endif //DUNE_COMMON_FLOAT_CMP_HH
    │ │ │ │ - │ │ │ │ -
    bool ne(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
    test for inequality using epsilon
    Definition float_cmp.cc:151
    │ │ │ │ -
    CmpStyle
    Definition float_cmp.hh:104
    │ │ │ │ -
    bool eq(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
    test for equality using epsilon
    Definition float_cmp.cc:144
    │ │ │ │ -
    I round(const T &val, typename EpsilonType< T >::Type epsilon)
    round using epsilon
    Definition float_cmp.cc:311
    │ │ │ │ -
    I trunc(const T &val, typename EpsilonType< T >::Type epsilon)
    truncate using epsilon
    Definition float_cmp.cc:407
    │ │ │ │ -
    RoundingStyle
    Definition float_cmp.hh:116
    │ │ │ │ -
    bool lt(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
    test if first lesser than second
    Definition float_cmp.cc:165
    │ │ │ │ -
    bool gt(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
    test if first greater than second
    Definition float_cmp.cc:158
    │ │ │ │ -
    bool ge(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
    test if first greater or equal second
    Definition float_cmp.cc:172
    │ │ │ │ -
    bool le(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
    test if first lesser or equal second
    Definition float_cmp.cc:179
    │ │ │ │ -
    @ defaultCmpStyle
    the global default compare style (relative_weak)
    Definition float_cmp.hh:112
    │ │ │ │ -
    @ relativeStrong
    |a-b|/|a| <= epsilon && |a-b|/|b| <= epsilon
    Definition float_cmp.hh:108
    │ │ │ │ -
    @ relativeWeak
    |a-b|/|a| <= epsilon || |a-b|/|b| <= epsilon
    Definition float_cmp.hh:106
    │ │ │ │ -
    @ absolute
    |a-b| <= epsilon
    Definition float_cmp.hh:110
    │ │ │ │ -
    @ towardZero
    always round toward 0
    Definition float_cmp.hh:118
    │ │ │ │ -
    @ towardInf
    always round away from 0
    Definition float_cmp.hh:120
    │ │ │ │ -
    @ upward
    round toward
    Definition float_cmp.hh:124
    │ │ │ │ -
    @ downward
    round toward
    Definition float_cmp.hh:122
    │ │ │ │ -
    @ defaultRoundingStyle
    the global default rounding style (toward_zero)
    Definition float_cmp.hh:126
    │ │ │ │ +
    344 template<typename T, typename A>
    │ │ │ │ +
    │ │ │ │ +
    345 struct ParameterTree::Parser<std::vector<T, A> > {
    │ │ │ │ +
    346 static std::vector<T, A>
    │ │ │ │ +
    │ │ │ │ +
    347 parse(const std::string& str) {
    │ │ │ │ +
    348 std::vector<std::string> sub = split(str);
    │ │ │ │ +
    349 std::vector<T, A> vec;
    │ │ │ │ +
    350 for (unsigned int i=0; i<sub.size(); ++i) {
    │ │ │ │ +
    351 T val = ParameterTree::Parser<T>::parse(sub[i]);
    │ │ │ │ +
    352 vec.push_back(val);
    │ │ │ │ +
    353 }
    │ │ │ │ +
    354 return vec;
    │ │ │ │ +
    355 }
    │ │ │ │ +
    │ │ │ │ +
    356 };
    │ │ │ │ +
    │ │ │ │ +
    357
    │ │ │ │ +
    358} // end namespace Dune
    │ │ │ │ +
    359
    │ │ │ │ +
    360#endif // DUNE_PARAMETERTREE_HH
    │ │ │ │ +
    A few common exception classes.
    │ │ │ │ +
    A free function to provide the demangled class name of a given object or type as a string.
    │ │ │ │ +
    Implements a vector constructed from a given type representing a field and a compile-time given size.
    │ │ │ │ +
    const char * what() const noexcept override
    output internal message buffer
    Definition exceptions.cc:37
    │ │ │ │ +
    #define DUNE_THROW(E, m)
    Definition exceptions.hh:218
    │ │ │ │ +
    STL namespace.
    │ │ │ │
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ -
    T Type
    The epsilon type corresponding to value type T.
    Definition float_cmp.cc:25
    │ │ │ │ -
    mapping from a value type and a compare style to a default epsilon
    Definition float_cmp.hh:138
    │ │ │ │ -
    static EpsilonType< T >::Type value()
    Returns the default epsilon for the given value type and compare style.
    │ │ │ │ -
    Class encapsulating a default epsilon.
    Definition float_cmp.hh:288
    │ │ │ │ -
    bool le(const ValueType &first, const ValueType &second) const
    test if first lesser or equal second
    Definition float_cmp.cc:486
    │ │ │ │ -
    bool eq(const ValueType &first, const ValueType &second) const
    test for equality using epsilon
    Definition float_cmp.cc:451
    │ │ │ │ -
    static const CmpStyle cstyle
    How comparisons are done.
    Definition float_cmp.hh:295
    │ │ │ │ -
    bool lt(const ValueType &first, const ValueType &second) const
    test if first lesser than second
    Definition float_cmp.cc:472
    │ │ │ │ -
    bool ge(const ValueType &first, const ValueType &second) const
    test if first greater or equal second
    Definition float_cmp.cc:479
    │ │ │ │ -
    static const RoundingStyle rstyle
    How rounding is done.
    Definition float_cmp.hh:297
    │ │ │ │ -
    FloatCmp::EpsilonType< T >::Type EpsilonType
    Type of the epsilon.
    Definition float_cmp.hh:304
    │ │ │ │ -
    bool ne(const ValueType &first, const ValueType &second) const
    test for inequality using epsilon
    Definition float_cmp.cc:458
    │ │ │ │ -
    T ValueType
    Type of the values to compare.
    Definition float_cmp.hh:299
    │ │ │ │ -
    EpsilonType epsilon() const
    return the current epsilon
    Definition float_cmp.cc:436
    │ │ │ │ -
    I round(const ValueType &val) const
    round using epsilon
    Definition float_cmp.cc:495
    │ │ │ │ -
    I trunc(const ValueType &val) const
    truncate using epsilon
    Definition float_cmp.cc:503
    │ │ │ │ -
    bool gt(const ValueType &first, const ValueType &second) const
    test if first greater than second
    Definition float_cmp.cc:465
    │ │ │ │ +
    vector space out of a tensor product of fields.
    Definition fvector.hh:95
    │ │ │ │ +
    Iterator begin()
    begin iterator
    Definition densevector.hh:347
    │ │ │ │ +
    Iterator end()
    end iterator
    Definition densevector.hh:353
    │ │ │ │ +
    Default exception class for range errors.
    Definition exceptions.hh:254
    │ │ │ │ +
    Hierarchical structure of string parameters.
    Definition parametertree.hh:37
    │ │ │ │ +
    KeyVector valueKeys_
    Definition parametertree.hh:214
    │ │ │ │ +
    std::map< std::string, ParameterTree > subs_
    Definition parametertree.hh:218
    │ │ │ │ +
    static const ParameterTree empty_
    Definition parametertree.hh:210
    │ │ │ │ +
    static std::string rtrim(const std::string &s)
    Definition parametertree.cc:210
    │ │ │ │ +
    std::string get(const std::string &key, const std::string &defaultValue) const
    get value as string
    Definition parametertree.cc:185
    │ │ │ │ +
    static std::string ltrim(const std::string &s)
    Definition parametertree.cc:201
    │ │ │ │ +
    void report(std::ostream &stream=std::cout, const std::string &prefix="") const
    print distinct substructure to stream
    Definition parametertree.cc:29
    │ │ │ │ +
    std::vector< std::string > KeyVector
    storage for key lists
    Definition parametertree.hh:47
    │ │ │ │ +
    static void parseRange(const std::string &str, Iterator it, const Iterator &end)
    Definition parametertree.hh:226
    │ │ │ │ +
    ParameterTree()
    Create new empty ParameterTree.
    Definition parametertree.cc:24
    │ │ │ │ +
    std::string & operator[](const std::string &key)
    get value reference for key
    Definition parametertree.cc:150
    │ │ │ │ +
    KeyVector subKeys_
    Definition parametertree.hh:215
    │ │ │ │ +
    ParameterTree & sub(const std::string &sub)
    get substructure by name
    Definition parametertree.cc:103
    │ │ │ │ +
    bool hasKey(const std::string &key) const
    test for key
    Definition parametertree.cc:48
    │ │ │ │ +
    const KeyVector & getSubKeys() const
    get substructure keys
    Definition parametertree.cc:240
    │ │ │ │ +
    T get(const std::string &key) const
    Get value.
    Definition parametertree.hh:174
    │ │ │ │ +
    bool hasSub(const std::string &sub) const
    test for substructure
    Definition parametertree.cc:76
    │ │ │ │ +
    std::map< std::string, std::string > values_
    Definition parametertree.hh:217
    │ │ │ │ +
    T get(const std::string &key, const T &defaultValue) const
    get value converted to a certain type
    Definition parametertree.hh:158
    │ │ │ │ +
    std::string prefix_
    Definition parametertree.hh:212
    │ │ │ │ +
    static std::vector< std::string > split(const std::string &s)
    Definition parametertree.cc:219
    │ │ │ │ +
    const KeyVector & getValueKeys() const
    get value keys
    Definition parametertree.cc:235
    │ │ │ │ +
    static std::basic_string< char, traits, Allocator > parse(const std::string &str)
    Definition parametertree.hh:276
    │ │ │ │ +
    static bool parse(const std::string &str)
    Definition parametertree.hh:293
    │ │ │ │ +
    char operator()(char c)
    Definition parametertree.hh:286
    │ │ │ │ +
    static FieldVector< T, n > parse(const std::string &str)
    Definition parametertree.hh:311
    │ │ │ │ +
    static std::array< T, n > parse(const std::string &str)
    Definition parametertree.hh:321
    │ │ │ │ +
    static std::bitset< n > parse(const std::string &str)
    Definition parametertree.hh:331
    │ │ │ │ +
    static std::vector< T, A > parse(const std::string &str)
    Definition parametertree.hh:347
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,306 +7,406 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -float_cmp.hh │ │ │ │ │ +parametertree.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 (C) 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_FLOAT_CMP_HH │ │ │ │ │ - 6#define DUNE_COMMON_FLOAT_CMP_HH │ │ │ │ │ + 5#ifndef DUNE_PARAMETERTREE_HH │ │ │ │ │ + 6#define DUNE_PARAMETERTREE_HH │ │ │ │ │ 7 │ │ │ │ │ - 97namespace Dune { │ │ │ │ │ - 100 namespace FloatCmp { │ │ │ │ │ - 101 // basic constants │ │ │ │ │ -104 enum CmpStyle { │ │ │ │ │ -106 relativeWeak, │ │ │ │ │ -108 relativeStrong, │ │ │ │ │ -110 absolute, │ │ │ │ │ - 112 defaultCmpStyle = relativeWeak │ │ │ │ │ -113 }; │ │ │ │ │ -116 enum RoundingStyle { │ │ │ │ │ -118 towardZero, │ │ │ │ │ -120 towardInf, │ │ │ │ │ -122 downward, │ │ │ │ │ -124 upward, │ │ │ │ │ - 126 defaultRoundingStyle = towardZero │ │ │ │ │ -127 }; │ │ │ │ │ - 128 │ │ │ │ │ - 129 template struct EpsilonType; │ │ │ │ │ - 130 │ │ │ │ │ - 132 │ │ │ │ │ - 137 template │ │ │ │ │ -138 struct DefaultEpsilon { │ │ │ │ │ -140 static typename EpsilonType::Type value(); │ │ │ │ │ - 141 }; │ │ │ │ │ - 142 │ │ │ │ │ - 143 // operations in functional style │ │ │ │ │ - 144 │ │ │ │ │ + 12#include │ │ │ │ │ + 13#include │ │ │ │ │ + 14#include │ │ │ │ │ + 15#include │ │ │ │ │ + 16#include │ │ │ │ │ + 17#include │ │ │ │ │ + 18#include │ │ │ │ │ + 19#include │ │ │ │ │ + 20#include │ │ │ │ │ + 21#include │ │ │ │ │ + 22#include │ │ │ │ │ + 23#include │ │ │ │ │ + 24#include │ │ │ │ │ + 25#include │ │ │ │ │ + 26 │ │ │ │ │ + 27#include │ │ │ │ │ + 28#include │ │ │ │ │ + 29#include │ │ │ │ │ + 30 │ │ │ │ │ + 31namespace Dune { │ │ │ │ │ + 32 │ │ │ │ │ +36 class ParameterTree │ │ │ │ │ + 37 { │ │ │ │ │ + 38 // class providing a single static parse() function, used by the │ │ │ │ │ + 39 // generic get() method │ │ │ │ │ + 40 template │ │ │ │ │ + 41 struct Parser; │ │ │ │ │ + 42 │ │ │ │ │ + 43 public: │ │ │ │ │ + 44 │ │ │ │ │ +47 typedef std::vector KeyVector; │ │ │ │ │ + 48 │ │ │ │ │ + 51 ParameterTree(); │ │ │ │ │ + 52 │ │ │ │ │ + 53 │ │ │ │ │ + 61 bool hasKey(const std::string& key) const; │ │ │ │ │ + 62 │ │ │ │ │ + 63 │ │ │ │ │ + 71 bool hasSub(const std::string& sub) const; │ │ │ │ │ + 72 │ │ │ │ │ + 73 │ │ │ │ │ + 82 std::string& operator[](const std::string& key); │ │ │ │ │ + 83 │ │ │ │ │ + 84 │ │ │ │ │ + 94 const std::string& operator[](const std::string& key) const; │ │ │ │ │ + 95 │ │ │ │ │ + 96 │ │ │ │ │ + 104 void report(std::ostream& stream = std::cout, │ │ │ │ │ + 105 const std::string& prefix = "") const; │ │ │ │ │ + 106 │ │ │ │ │ + 107 │ │ │ │ │ + 113 ParameterTree& sub(const std::string& sub); │ │ │ │ │ + 114 │ │ │ │ │ + 115 │ │ │ │ │ + 122 const ParameterTree& sub(const std::string& sub, bool fail_if_missing = │ │ │ │ │ +false) const; │ │ │ │ │ + 123 │ │ │ │ │ + 124 │ │ │ │ │ + 133 std::string get(const std::string& key, const std::string& defaultValue) │ │ │ │ │ +const; │ │ │ │ │ + 134 │ │ │ │ │ + 145 std::string get(const std::string& key, const char* defaultValue) const; │ │ │ │ │ + 146 │ │ │ │ │ 147 │ │ │ │ │ - 149 │ │ │ │ │ - 156 template │ │ │ │ │ - 157 bool eq(const T &first, │ │ │ │ │ - 158 const T &second, │ │ │ │ │ - 159 typename EpsilonType::Type epsilon = DefaultEpsilon::value │ │ │ │ │ -()); │ │ │ │ │ - 161 │ │ │ │ │ - 169 template │ │ │ │ │ - 170 bool ne(const T &first, │ │ │ │ │ - 171 const T &second, │ │ │ │ │ - 172 typename EpsilonType::Type epsilon = DefaultEpsilon::value │ │ │ │ │ -()); │ │ │ │ │ - 174 │ │ │ │ │ - 185 template │ │ │ │ │ - 186 bool gt(const T &first, │ │ │ │ │ - 187 const T &second, │ │ │ │ │ - 188 typename EpsilonType::Type epsilon = DefaultEpsilon::value │ │ │ │ │ -()); │ │ │ │ │ - 190 │ │ │ │ │ - 201 template │ │ │ │ │ - 202 bool lt(const T &first, │ │ │ │ │ - 203 const T &second, │ │ │ │ │ - 204 typename EpsilonType::Type epsilon = DefaultEpsilon::value │ │ │ │ │ -()); │ │ │ │ │ - 206 │ │ │ │ │ - 217 template │ │ │ │ │ - 218 bool ge(const T &first, │ │ │ │ │ - 219 const T &second, │ │ │ │ │ - 220 typename EpsilonType::Type epsilon = DefaultEpsilon::value │ │ │ │ │ -()); │ │ │ │ │ - 222 │ │ │ │ │ - 233 template │ │ │ │ │ - 234 bool le(const T &first, │ │ │ │ │ - 235 const T &second, │ │ │ │ │ - 236 typename EpsilonType::Type epsilon = DefaultEpsilon::value │ │ │ │ │ -()); │ │ │ │ │ - 237 │ │ │ │ │ - 238 // rounding operations │ │ │ │ │ - 240 │ │ │ │ │ - 253 template │ │ │ │ │ - 254 I round(const T &val, typename EpsilonType::Type epsilon = │ │ │ │ │ -DefaultEpsilon::value()); │ │ │ │ │ - 255 // truncation │ │ │ │ │ - 257 │ │ │ │ │ - 270 template │ │ │ │ │ - 271 I trunc(const T &val, typename EpsilonType::Type epsilon = │ │ │ │ │ -DefaultEpsilon::value()); │ │ │ │ │ - 272 │ │ │ │ │ - 274 // group FloatCmp │ │ │ │ │ - 275 } //namespace FloatCmp │ │ │ │ │ - 276 │ │ │ │ │ - 277 │ │ │ │ │ - 278 // oo interface │ │ │ │ │ - 280 │ │ │ │ │ - 286 template │ │ │ │ │ -288 class FloatCmpOps { │ │ │ │ │ - 289 typedef FloatCmp::CmpStyle CmpStyle; │ │ │ │ │ - 290 typedef FloatCmp::RoundingStyle RoundingStyle; │ │ │ │ │ + 157 template │ │ │ │ │ +158 T get(const std::string& key, const T& defaultValue) const { │ │ │ │ │ + 159 if(hasKey(key)) │ │ │ │ │ + 160 return get(key); │ │ │ │ │ + 161 else │ │ │ │ │ + 162 return defaultValue; │ │ │ │ │ + 163 } │ │ │ │ │ + 164 │ │ │ │ │ + 173 template │ │ │ │ │ +174 T get(const std::string& key) const { │ │ │ │ │ + 175 if(not hasKey(key)) │ │ │ │ │ + 176 DUNE_THROW(Dune::RangeError, "Key '" << key │ │ │ │ │ + 177 << "' not found in ParameterTree (prefix " + prefix_ + ")"); │ │ │ │ │ + 178 try { │ │ │ │ │ + 179 return Parser::parse((*this)[key]); │ │ │ │ │ + 180 } │ │ │ │ │ + 181 catch(const RangeError& e) { │ │ │ │ │ + 182 // rethrow the error and add more information │ │ │ │ │ + 183 DUNE_THROW(RangeError, "Cannot parse value \"" << (*this)[key] │ │ │ │ │ + 184 << "\" for key \"" << prefix_ << "." << key << "\"" │ │ │ │ │ + 185 << e.what()); │ │ │ │ │ + 186 } │ │ │ │ │ + 187 } │ │ │ │ │ + 188 │ │ │ │ │ + 196 const KeyVector& getValueKeys() const; │ │ │ │ │ + 197 │ │ │ │ │ + 198 │ │ │ │ │ + 206 const KeyVector& getSubKeys() const; │ │ │ │ │ + 207 │ │ │ │ │ + 208 protected: │ │ │ │ │ + 209 │ │ │ │ │ +210 static const ParameterTree empty_; │ │ │ │ │ + 211 │ │ │ │ │ +212 std::string prefix_; │ │ │ │ │ + 213 │ │ │ │ │ +214 KeyVector valueKeys_; │ │ │ │ │ +215 KeyVector subKeys_; │ │ │ │ │ + 216 │ │ │ │ │ +217 std::map values_; │ │ │ │ │ +218 std::map subs_; │ │ │ │ │ + 219 │ │ │ │ │ + 220 static std::string ltrim(const std::string& s); │ │ │ │ │ + 221 static std::string rtrim(const std::string& s); │ │ │ │ │ + 222 static std::vector split(const std::string & s); │ │ │ │ │ + 223 │ │ │ │ │ + 224 // parse into a fixed-size range of iterators │ │ │ │ │ + 225 template │ │ │ │ │ +226 static void parseRange(const std::string &str, │ │ │ │ │ + 227 Iterator it, const Iterator &end) │ │ │ │ │ + 228 { │ │ │ │ │ + 229 typedef typename std::iterator_traits::value_type Value; │ │ │ │ │ + 230 std::istringstream s(str); │ │ │ │ │ + 231 // make sure we are in locale "C" │ │ │ │ │ + 232 s.imbue(std::locale::classic()); │ │ │ │ │ + 233 std::size_t n = 0; │ │ │ │ │ + 234 for(; it != end; ++it, ++n) { │ │ │ │ │ + 235 s >> *it; │ │ │ │ │ + 236 if(!s) │ │ │ │ │ + 237 DUNE_THROW(RangeError, "as a range of items of type " │ │ │ │ │ + 238 << className() │ │ │ │ │ + 239 << " (" << n << " items were extracted successfully)"); │ │ │ │ │ + 240 } │ │ │ │ │ + 241 Value dummy; │ │ │ │ │ + 242 s >> dummy; │ │ │ │ │ + 243 // now extraction should have failed, and eof should be set │ │ │ │ │ + 244 if(not s.fail() or not s.eof()) │ │ │ │ │ + 245 DUNE_THROW(RangeError, "as a range of " │ │ │ │ │ + 246 << n << " items of type " │ │ │ │ │ + 247 << className() << " (more items than the range can hold)"); │ │ │ │ │ + 248 } │ │ │ │ │ + 249 }; │ │ │ │ │ + 250 │ │ │ │ │ + 251 template │ │ │ │ │ + 252 struct ParameterTree::Parser { │ │ │ │ │ + 253 static T parse(const std::string& str) { │ │ │ │ │ + 254 T val; │ │ │ │ │ + 255 std::istringstream s(str); │ │ │ │ │ + 256 // make sure we are in locale "C" │ │ │ │ │ + 257 s.imbue(std::locale::classic()); │ │ │ │ │ + 258 s >> val; │ │ │ │ │ + 259 if(!s) │ │ │ │ │ + 260 DUNE_THROW(RangeError, " as a " << className()); │ │ │ │ │ + 261 char dummy; │ │ │ │ │ + 262 s >> dummy; │ │ │ │ │ + 263 // now extraction should have failed, and eof should be set │ │ │ │ │ + 264 if ((! s.fail()) || (! s.eof())) │ │ │ │ │ + 265 DUNE_THROW(RangeError, " as a " << className()); │ │ │ │ │ + 266 return val; │ │ │ │ │ + 267 } │ │ │ │ │ + 268 }; │ │ │ │ │ + 269 │ │ │ │ │ + 270 // "How do I convert a string into a wstring in C++?" "Why, that very │ │ │ │ │ +simple │ │ │ │ │ + 271 // son. You just need a these hundred lines of code." │ │ │ │ │ + 272 // Instead im going to restrict myself to string with charT=char here. │ │ │ │ │ + 273 template │ │ │ │ │ +274 struct ParameterTree::Parser > { │ │ │ │ │ + 275 static std::basic_string │ │ │ │ │ +276 parse(const std::string& str) { │ │ │ │ │ + 277 std::string trimmed = ltrim(rtrim(str)); │ │ │ │ │ + 278 return std::basic_string(trimmed.begin(), │ │ │ │ │ + 279 trimmed.end()); │ │ │ │ │ + 280 } │ │ │ │ │ + 281 }; │ │ │ │ │ + 282 │ │ │ │ │ + 283 template<> │ │ │ │ │ +284 struct ParameterTree::Parser< bool > { │ │ │ │ │ +285 struct ToLower { │ │ │ │ │ +286 char operator()(char c) │ │ │ │ │ + 287 { │ │ │ │ │ + 288 return std::tolower(c, std::locale::classic()); │ │ │ │ │ + 289 } │ │ │ │ │ + 290 }; │ │ │ │ │ 291 │ │ │ │ │ - 292 public: │ │ │ │ │ - 293 // record template parameters │ │ │ │ │ -295 static const CmpStyle cstyle = cstyle_; │ │ │ │ │ -297 static const RoundingStyle rstyle = rstyle_; │ │ │ │ │ -299 typedef T ValueType; │ │ │ │ │ - 301 │ │ │ │ │ -304 typedef typename FloatCmp::EpsilonType::Type EpsilonType; │ │ │ │ │ - 305 │ │ │ │ │ - 306 private: │ │ │ │ │ - 307 EpsilonType epsilon_; │ │ │ │ │ - 308 │ │ │ │ │ - 309 typedef FloatCmp::DefaultEpsilon DefaultEpsilon; │ │ │ │ │ - 310 │ │ │ │ │ - 311 public: │ │ │ │ │ - 313 │ │ │ │ │ - 316 FloatCmpOps(EpsilonType epsilon = DefaultEpsilon::value()); │ │ │ │ │ + 292 static bool │ │ │ │ │ +293 parse(const std::string& str) { │ │ │ │ │ + 294 std::string ret = str; │ │ │ │ │ + 295 │ │ │ │ │ + 296 std::transform(ret.begin(), ret.end(), ret.begin(), ToLower()); │ │ │ │ │ + 297 │ │ │ │ │ + 298 if (ret == "yes" || ret == "true") │ │ │ │ │ + 299 return true; │ │ │ │ │ + 300 │ │ │ │ │ + 301 if (ret == "no" || ret == "false") │ │ │ │ │ + 302 return false; │ │ │ │ │ + 303 │ │ │ │ │ + 304 return (Parser::parse(ret) != 0); │ │ │ │ │ + 305 } │ │ │ │ │ + 306 }; │ │ │ │ │ + 307 │ │ │ │ │ + 308 template │ │ │ │ │ +309 struct ParameterTree::Parser > { │ │ │ │ │ + 310 static FieldVector │ │ │ │ │ +311 parse(const std::string& str) { │ │ │ │ │ + 312 FieldVector val; │ │ │ │ │ + 313 parseRange(str, val.begin(), val.end()); │ │ │ │ │ + 314 return val; │ │ │ │ │ + 315 } │ │ │ │ │ + 316 }; │ │ │ │ │ 317 │ │ │ │ │ - 319 EpsilonType epsilon() const; │ │ │ │ │ - 321 void epsilon(EpsilonType epsilon__); │ │ │ │ │ - 322 │ │ │ │ │ - 324 bool eq(const ValueType &first, const ValueType &second) const; │ │ │ │ │ - 326 │ │ │ │ │ - 329 bool ne(const ValueType &first, const ValueType &second) const; │ │ │ │ │ - 331 │ │ │ │ │ - 335 bool gt(const ValueType &first, const ValueType &second) const; │ │ │ │ │ - 337 │ │ │ │ │ - 341 bool lt(const ValueType &first, const ValueType &second) const; │ │ │ │ │ + 318 template │ │ │ │ │ +319 struct ParameterTree::Parser > { │ │ │ │ │ + 320 static std::array │ │ │ │ │ +321 parse(const std::string& str) { │ │ │ │ │ + 322 std::array val; │ │ │ │ │ + 323 parseRange(str, val.begin(), val.end()); │ │ │ │ │ + 324 return val; │ │ │ │ │ + 325 } │ │ │ │ │ + 326 }; │ │ │ │ │ + 327 │ │ │ │ │ + 328 template │ │ │ │ │ +329 struct ParameterTree::Parser > { │ │ │ │ │ + 330 static std::bitset │ │ │ │ │ +331 parse(const std::string& str) { │ │ │ │ │ + 332 std::bitset val; │ │ │ │ │ + 333 std::vector sub = split(str); │ │ │ │ │ + 334 if (sub.size() != n) │ │ │ │ │ + 335 DUNE_THROW(RangeError, "as a bitset<" << n << "> " │ │ │ │ │ + 336 << "because of unmatching size " << sub.size()); │ │ │ │ │ + 337 for (std::size_t i=0; i::parse(sub[i]); │ │ │ │ │ + 339 } │ │ │ │ │ + 340 return val; │ │ │ │ │ + 341 } │ │ │ │ │ + 342 }; │ │ │ │ │ 343 │ │ │ │ │ - 347 bool ge(const ValueType &first, const ValueType &second) const; │ │ │ │ │ - 349 │ │ │ │ │ - 353 bool le(const ValueType &first, const ValueType &second) const; │ │ │ │ │ - 354 │ │ │ │ │ - 356 │ │ │ │ │ - 365 template │ │ │ │ │ - 366 I round(const ValueType &val) const; │ │ │ │ │ - 367 │ │ │ │ │ - 369 │ │ │ │ │ - 378 template │ │ │ │ │ - 379 I trunc(const ValueType &val) const; │ │ │ │ │ - 380 │ │ │ │ │ - 381 }; │ │ │ │ │ - 382 │ │ │ │ │ - 383} //namespace Dune │ │ │ │ │ - 384 │ │ │ │ │ - 385#include "float_cmp.cc" │ │ │ │ │ - 386 │ │ │ │ │ - 387#endif //DUNE_COMMON_FLOAT_CMP_HH │ │ │ │ │ -float_cmp.cc │ │ │ │ │ -Dune::FloatCmp::ne │ │ │ │ │ -bool ne(const T &first, const T &second, typename EpsilonType< T >::Type │ │ │ │ │ -epsilon) │ │ │ │ │ -test for inequality using epsilon │ │ │ │ │ -Definition float_cmp.cc:151 │ │ │ │ │ -Dune::FloatCmp::CmpStyle │ │ │ │ │ -CmpStyle │ │ │ │ │ -Definition float_cmp.hh:104 │ │ │ │ │ -Dune::FloatCmp::eq │ │ │ │ │ -bool eq(const T &first, const T &second, typename EpsilonType< T >::Type │ │ │ │ │ -epsilon) │ │ │ │ │ -test for equality using epsilon │ │ │ │ │ -Definition float_cmp.cc:144 │ │ │ │ │ -Dune::FloatCmp::round │ │ │ │ │ -I round(const T &val, typename EpsilonType< T >::Type epsilon) │ │ │ │ │ -round using epsilon │ │ │ │ │ -Definition float_cmp.cc:311 │ │ │ │ │ -Dune::FloatCmp::trunc │ │ │ │ │ -I trunc(const T &val, typename EpsilonType< T >::Type epsilon) │ │ │ │ │ -truncate using epsilon │ │ │ │ │ -Definition float_cmp.cc:407 │ │ │ │ │ -Dune::FloatCmp::RoundingStyle │ │ │ │ │ -RoundingStyle │ │ │ │ │ -Definition float_cmp.hh:116 │ │ │ │ │ -Dune::FloatCmp::lt │ │ │ │ │ -bool lt(const T &first, const T &second, typename EpsilonType< T >::Type │ │ │ │ │ -epsilon) │ │ │ │ │ -test if first lesser than second │ │ │ │ │ -Definition float_cmp.cc:165 │ │ │ │ │ -Dune::FloatCmp::gt │ │ │ │ │ -bool gt(const T &first, const T &second, typename EpsilonType< T >::Type │ │ │ │ │ -epsilon) │ │ │ │ │ -test if first greater than second │ │ │ │ │ -Definition float_cmp.cc:158 │ │ │ │ │ -Dune::FloatCmp::ge │ │ │ │ │ -bool ge(const T &first, const T &second, typename EpsilonType< T >::Type │ │ │ │ │ -epsilon) │ │ │ │ │ -test if first greater or equal second │ │ │ │ │ -Definition float_cmp.cc:172 │ │ │ │ │ -Dune::FloatCmp::le │ │ │ │ │ -bool le(const T &first, const T &second, typename EpsilonType< T >::Type │ │ │ │ │ -epsilon) │ │ │ │ │ -test if first lesser or equal second │ │ │ │ │ -Definition float_cmp.cc:179 │ │ │ │ │ -Dune::FloatCmp::defaultCmpStyle │ │ │ │ │ -@ defaultCmpStyle │ │ │ │ │ -the global default compare style (relative_weak) │ │ │ │ │ -Definition float_cmp.hh:112 │ │ │ │ │ -Dune::FloatCmp::relativeStrong │ │ │ │ │ -@ relativeStrong │ │ │ │ │ -|a-b|/|a| <= epsilon && |a-b|/|b| <= epsilon │ │ │ │ │ -Definition float_cmp.hh:108 │ │ │ │ │ -Dune::FloatCmp::relativeWeak │ │ │ │ │ -@ relativeWeak │ │ │ │ │ -|a-b|/|a| <= epsilon || |a-b|/|b| <= epsilon │ │ │ │ │ -Definition float_cmp.hh:106 │ │ │ │ │ -Dune::FloatCmp::absolute │ │ │ │ │ -@ absolute │ │ │ │ │ -|a-b| <= epsilon │ │ │ │ │ -Definition float_cmp.hh:110 │ │ │ │ │ -Dune::FloatCmp::towardZero │ │ │ │ │ -@ towardZero │ │ │ │ │ -always round toward 0 │ │ │ │ │ -Definition float_cmp.hh:118 │ │ │ │ │ -Dune::FloatCmp::towardInf │ │ │ │ │ -@ towardInf │ │ │ │ │ -always round away from 0 │ │ │ │ │ -Definition float_cmp.hh:120 │ │ │ │ │ -Dune::FloatCmp::upward │ │ │ │ │ -@ upward │ │ │ │ │ -round toward │ │ │ │ │ -Definition float_cmp.hh:124 │ │ │ │ │ -Dune::FloatCmp::downward │ │ │ │ │ -@ downward │ │ │ │ │ -round toward │ │ │ │ │ -Definition float_cmp.hh:122 │ │ │ │ │ -Dune::FloatCmp::defaultRoundingStyle │ │ │ │ │ -@ defaultRoundingStyle │ │ │ │ │ -the global default rounding style (toward_zero) │ │ │ │ │ -Definition float_cmp.hh:126 │ │ │ │ │ + 344 template │ │ │ │ │ +345 struct ParameterTree::Parser > { │ │ │ │ │ + 346 static std::vector │ │ │ │ │ +347 parse(const std::string& str) { │ │ │ │ │ + 348 std::vector sub = split(str); │ │ │ │ │ + 349 std::vector vec; │ │ │ │ │ + 350 for (unsigned int i=0; i::parse(sub[i]); │ │ │ │ │ + 352 vec.push_back(val); │ │ │ │ │ + 353 } │ │ │ │ │ + 354 return vec; │ │ │ │ │ + 355 } │ │ │ │ │ + 356 }; │ │ │ │ │ + 357 │ │ │ │ │ + 358} // end namespace Dune │ │ │ │ │ + 359 │ │ │ │ │ + 360#endif // DUNE_PARAMETERTREE_HH │ │ │ │ │ +exceptions.hh │ │ │ │ │ +A few common exception classes. │ │ │ │ │ +classname.hh │ │ │ │ │ +A free function to provide the demangled class name of a given object or type │ │ │ │ │ +as a string. │ │ │ │ │ +fvector.hh │ │ │ │ │ +Implements a vector constructed from a given type representing a field and a │ │ │ │ │ +compile-time given size. │ │ │ │ │ +Dune::Exception::what │ │ │ │ │ +const char * what() const noexcept override │ │ │ │ │ +output internal message buffer │ │ │ │ │ +Definition exceptions.cc:37 │ │ │ │ │ +DUNE_THROW │ │ │ │ │ +#define DUNE_THROW(E, m) │ │ │ │ │ +Definition exceptions.hh:218 │ │ │ │ │ +std │ │ │ │ │ +STL namespace. │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::FloatCmp::EpsilonType::Type │ │ │ │ │ -T Type │ │ │ │ │ -The epsilon type corresponding to value type T. │ │ │ │ │ -Definition float_cmp.cc:25 │ │ │ │ │ -Dune::FloatCmp::DefaultEpsilon │ │ │ │ │ -mapping from a value type and a compare style to a default epsilon │ │ │ │ │ -Definition float_cmp.hh:138 │ │ │ │ │ -Dune::FloatCmp::DefaultEpsilon::value │ │ │ │ │ -static EpsilonType< T >::Type value() │ │ │ │ │ -Returns the default epsilon for the given value type and compare style. │ │ │ │ │ -Dune::FloatCmpOps │ │ │ │ │ -Class encapsulating a default epsilon. │ │ │ │ │ -Definition float_cmp.hh:288 │ │ │ │ │ -Dune::FloatCmpOps::le │ │ │ │ │ -bool le(const ValueType &first, const ValueType &second) const │ │ │ │ │ -test if first lesser or equal second │ │ │ │ │ -Definition float_cmp.cc:486 │ │ │ │ │ -Dune::FloatCmpOps::eq │ │ │ │ │ -bool eq(const ValueType &first, const ValueType &second) const │ │ │ │ │ -test for equality using epsilon │ │ │ │ │ -Definition float_cmp.cc:451 │ │ │ │ │ -Dune::FloatCmpOps::cstyle │ │ │ │ │ -static const CmpStyle cstyle │ │ │ │ │ -How comparisons are done. │ │ │ │ │ -Definition float_cmp.hh:295 │ │ │ │ │ -Dune::FloatCmpOps::lt │ │ │ │ │ -bool lt(const ValueType &first, const ValueType &second) const │ │ │ │ │ -test if first lesser than second │ │ │ │ │ -Definition float_cmp.cc:472 │ │ │ │ │ -Dune::FloatCmpOps::ge │ │ │ │ │ -bool ge(const ValueType &first, const ValueType &second) const │ │ │ │ │ -test if first greater or equal second │ │ │ │ │ -Definition float_cmp.cc:479 │ │ │ │ │ -Dune::FloatCmpOps::rstyle │ │ │ │ │ -static const RoundingStyle rstyle │ │ │ │ │ -How rounding is done. │ │ │ │ │ -Definition float_cmp.hh:297 │ │ │ │ │ -Dune::FloatCmpOps::EpsilonType │ │ │ │ │ -FloatCmp::EpsilonType< T >::Type EpsilonType │ │ │ │ │ -Type of the epsilon. │ │ │ │ │ -Definition float_cmp.hh:304 │ │ │ │ │ -Dune::FloatCmpOps::ne │ │ │ │ │ -bool ne(const ValueType &first, const ValueType &second) const │ │ │ │ │ -test for inequality using epsilon │ │ │ │ │ -Definition float_cmp.cc:458 │ │ │ │ │ -Dune::FloatCmpOps::ValueType │ │ │ │ │ -T ValueType │ │ │ │ │ -Type of the values to compare. │ │ │ │ │ -Definition float_cmp.hh:299 │ │ │ │ │ -Dune::FloatCmpOps::epsilon │ │ │ │ │ -EpsilonType epsilon() const │ │ │ │ │ -return the current epsilon │ │ │ │ │ -Definition float_cmp.cc:436 │ │ │ │ │ -Dune::FloatCmpOps::round │ │ │ │ │ -I round(const ValueType &val) const │ │ │ │ │ -round using epsilon │ │ │ │ │ -Definition float_cmp.cc:495 │ │ │ │ │ -Dune::FloatCmpOps::trunc │ │ │ │ │ -I trunc(const ValueType &val) const │ │ │ │ │ -truncate using epsilon │ │ │ │ │ -Definition float_cmp.cc:503 │ │ │ │ │ -Dune::FloatCmpOps::gt │ │ │ │ │ -bool gt(const ValueType &first, const ValueType &second) const │ │ │ │ │ -test if first greater than second │ │ │ │ │ -Definition float_cmp.cc:465 │ │ │ │ │ +Dune::FieldVector │ │ │ │ │ +vector space out of a tensor product of fields. │ │ │ │ │ +Definition fvector.hh:95 │ │ │ │ │ +Dune::DenseVector::begin │ │ │ │ │ +Iterator begin() │ │ │ │ │ +begin iterator │ │ │ │ │ +Definition densevector.hh:347 │ │ │ │ │ +Dune::DenseVector::end │ │ │ │ │ +Iterator end() │ │ │ │ │ +end iterator │ │ │ │ │ +Definition densevector.hh:353 │ │ │ │ │ +Dune::RangeError │ │ │ │ │ +Default exception class for range errors. │ │ │ │ │ +Definition exceptions.hh:254 │ │ │ │ │ +Dune::ParameterTree │ │ │ │ │ +Hierarchical structure of string parameters. │ │ │ │ │ +Definition parametertree.hh:37 │ │ │ │ │ +Dune::ParameterTree::valueKeys_ │ │ │ │ │ +KeyVector valueKeys_ │ │ │ │ │ +Definition parametertree.hh:214 │ │ │ │ │ +Dune::ParameterTree::subs_ │ │ │ │ │ +std::map< std::string, ParameterTree > subs_ │ │ │ │ │ +Definition parametertree.hh:218 │ │ │ │ │ +Dune::ParameterTree::empty_ │ │ │ │ │ +static const ParameterTree empty_ │ │ │ │ │ +Definition parametertree.hh:210 │ │ │ │ │ +Dune::ParameterTree::rtrim │ │ │ │ │ +static std::string rtrim(const std::string &s) │ │ │ │ │ +Definition parametertree.cc:210 │ │ │ │ │ +Dune::ParameterTree::get │ │ │ │ │ +std::string get(const std::string &key, const std::string &defaultValue) const │ │ │ │ │ +get value as string │ │ │ │ │ +Definition parametertree.cc:185 │ │ │ │ │ +Dune::ParameterTree::ltrim │ │ │ │ │ +static std::string ltrim(const std::string &s) │ │ │ │ │ +Definition parametertree.cc:201 │ │ │ │ │ +Dune::ParameterTree::report │ │ │ │ │ +void report(std::ostream &stream=std::cout, const std::string &prefix="") const │ │ │ │ │ +print distinct substructure to stream │ │ │ │ │ +Definition parametertree.cc:29 │ │ │ │ │ +Dune::ParameterTree::KeyVector │ │ │ │ │ +std::vector< std::string > KeyVector │ │ │ │ │ +storage for key lists │ │ │ │ │ +Definition parametertree.hh:47 │ │ │ │ │ +Dune::ParameterTree::parseRange │ │ │ │ │ +static void parseRange(const std::string &str, Iterator it, const Iterator │ │ │ │ │ +&end) │ │ │ │ │ +Definition parametertree.hh:226 │ │ │ │ │ +Dune::ParameterTree::ParameterTree │ │ │ │ │ +ParameterTree() │ │ │ │ │ +Create new empty ParameterTree. │ │ │ │ │ +Definition parametertree.cc:24 │ │ │ │ │ +Dune::ParameterTree::operator[] │ │ │ │ │ +std::string & operator[](const std::string &key) │ │ │ │ │ +get value reference for key │ │ │ │ │ +Definition parametertree.cc:150 │ │ │ │ │ +Dune::ParameterTree::subKeys_ │ │ │ │ │ +KeyVector subKeys_ │ │ │ │ │ +Definition parametertree.hh:215 │ │ │ │ │ +Dune::ParameterTree::sub │ │ │ │ │ +ParameterTree & sub(const std::string &sub) │ │ │ │ │ +get substructure by name │ │ │ │ │ +Definition parametertree.cc:103 │ │ │ │ │ +Dune::ParameterTree::hasKey │ │ │ │ │ +bool hasKey(const std::string &key) const │ │ │ │ │ +test for key │ │ │ │ │ +Definition parametertree.cc:48 │ │ │ │ │ +Dune::ParameterTree::getSubKeys │ │ │ │ │ +const KeyVector & getSubKeys() const │ │ │ │ │ +get substructure keys │ │ │ │ │ +Definition parametertree.cc:240 │ │ │ │ │ +Dune::ParameterTree::get │ │ │ │ │ +T get(const std::string &key) const │ │ │ │ │ +Get value. │ │ │ │ │ +Definition parametertree.hh:174 │ │ │ │ │ +Dune::ParameterTree::hasSub │ │ │ │ │ +bool hasSub(const std::string &sub) const │ │ │ │ │ +test for substructure │ │ │ │ │ +Definition parametertree.cc:76 │ │ │ │ │ +Dune::ParameterTree::values_ │ │ │ │ │ +std::map< std::string, std::string > values_ │ │ │ │ │ +Definition parametertree.hh:217 │ │ │ │ │ +Dune::ParameterTree::get │ │ │ │ │ +T get(const std::string &key, const T &defaultValue) const │ │ │ │ │ +get value converted to a certain type │ │ │ │ │ +Definition parametertree.hh:158 │ │ │ │ │ +Dune::ParameterTree::prefix_ │ │ │ │ │ +std::string prefix_ │ │ │ │ │ +Definition parametertree.hh:212 │ │ │ │ │ +Dune::ParameterTree::split │ │ │ │ │ +static std::vector< std::string > split(const std::string &s) │ │ │ │ │ +Definition parametertree.cc:219 │ │ │ │ │ +Dune::ParameterTree::getValueKeys │ │ │ │ │ +const KeyVector & getValueKeys() const │ │ │ │ │ +get value keys │ │ │ │ │ +Definition parametertree.cc:235 │ │ │ │ │ +Dune::ParameterTree::Parser<_std::basic_string<_char,_traits,_Allocator_>_>:: │ │ │ │ │ +parse │ │ │ │ │ +static std::basic_string< char, traits, Allocator > parse(const std::string │ │ │ │ │ +&str) │ │ │ │ │ +Definition parametertree.hh:276 │ │ │ │ │ +Dune::ParameterTree::Parser<_bool_>::parse │ │ │ │ │ +static bool parse(const std::string &str) │ │ │ │ │ +Definition parametertree.hh:293 │ │ │ │ │ +Dune::ParameterTree::Parser<_bool_>::ToLower::operator() │ │ │ │ │ +char operator()(char c) │ │ │ │ │ +Definition parametertree.hh:286 │ │ │ │ │ +Dune::ParameterTree::Parser<_FieldVector<_T,_n_>_>::parse │ │ │ │ │ +static FieldVector< T, n > parse(const std::string &str) │ │ │ │ │ +Definition parametertree.hh:311 │ │ │ │ │ +Dune::ParameterTree::Parser<_std::array<_T,_n_>_>::parse │ │ │ │ │ +static std::array< T, n > parse(const std::string &str) │ │ │ │ │ +Definition parametertree.hh:321 │ │ │ │ │ +Dune::ParameterTree::Parser<_std::bitset<_n_>_>::parse │ │ │ │ │ +static std::bitset< n > parse(const std::string &str) │ │ │ │ │ +Definition parametertree.hh:331 │ │ │ │ │ +Dune::ParameterTree::Parser<_std::vector<_T,_A_>_>::parse │ │ │ │ │ +static std::vector< T, A > parse(const std::string &str) │ │ │ │ │ +Definition parametertree.hh:347 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00182.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: precision.hh File Reference │ │ │ │ +dune-common: vc.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -69,41 +69,25 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    │ │ │ │ -Classes | │ │ │ │ -Namespaces
    │ │ │ │ -
    precision.hh File Reference
    │ │ │ │ +
    vc.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ -

    Various precision settings for calculations with FieldMatrix and FieldVector. │ │ │ │ +

    Compatibility header for including <Vc/Vc> │ │ │ │ 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...
     
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

    │ │ │ │ -Namespaces

    namespace  Dune
     Dune namespace.
     
    │ │ │ │

    Detailed Description

    │ │ │ │ -

    Various precision settings for calculations with FieldMatrix and FieldVector.

    │ │ │ │ +

    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.

    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,26 +6,17 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -precision.hh File Reference │ │ │ │ │ -Various precision settings for calculations with FieldMatrix and FieldVector. │ │ │ │ │ -More... │ │ │ │ │ -#include │ │ │ │ │ +vc.hh File Reference │ │ │ │ │ +Compatibility header for including More... │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ - Classes │ │ │ │ │ -class  Dune::FMatrixPrecision<_ctype_> │ │ │ │ │ -  Precisions for calculations with FieldMatrix and FieldVector. More... │ │ │ │ │ -  │ │ │ │ │ - Namespaces │ │ │ │ │ -namespace  Dune │ │ │ │ │ -  Dune namespace. │ │ │ │ │ -  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Various precision settings for calculations with FieldMatrix and FieldVector. │ │ │ │ │ +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. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00182_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: precision.hh Source File │ │ │ │ +dune-common: vc.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,62 +74,38 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    precision.hh
    │ │ │ │ +
    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 (C) 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
    │ │ │ │ -
    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;
    │ │ │ │ -
    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
    │ │ │ │ +Go to the documentation of this file.
    1// SPDX-FileCopyrightInfo: Copyright (C) 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
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,62 +7,34 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -precision.hh │ │ │ │ │ +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 (C) DUNE Project contributors, see file │ │ │ │ │ + 1// SPDX-FileCopyrightInfo: Copyright (C) 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 │ │ │ │ │ - 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; │ │ │ │ │ - 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 │ │ │ │ │ + 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 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00185.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: stdthread.hh File Reference │ │ │ │ +dune-common: proxymemberaccess.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -71,63 +71,41 @@ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ Namespaces | │ │ │ │ -Macros | │ │ │ │ Functions
    │ │ │ │ -
    stdthread.hh File Reference
    │ │ │ │ +
    proxymemberaccess.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ +

    infrastructure for supporting operator->() on both references and proxies │ │ │ │ +More...

    │ │ │ │ +
    #include <type_traits>
    │ │ │ │ +#include <utility>
    │ │ │ │ +
    │ │ │ │

    Go to the source code of this file.

    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

    │ │ │ │ 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.
     
    template<typename T >
    pointer_or_proxy_holder Dune::handle_proxy_member_access (T &&t)
     Transparent support for providing member access to both lvalues and rvalues (temporary proxies).
     
    │ │ │ │ -

    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.

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

    Detailed Description

    │ │ │ │ +

    infrastructure for supporting operator->() on both references and proxies

    │ │ │ │ +
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,38 +6,30 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Namespaces | Macros | Functions │ │ │ │ │ -stdthread.hh File Reference │ │ │ │ │ +Namespaces | Functions │ │ │ │ │ +proxymemberaccess.hh File Reference │ │ │ │ │ +Common » Utilities » C++_utilities_and_backports │ │ │ │ │ +infrastructure for supporting operator->() on both references and proxies │ │ │ │ │ +More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ 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. │ │ │ │ │ +template │ │ │ │ │ +pointer_or_proxy_holder Dune::handle_proxy_member_access (T &&t) │ │ │ │ │ +  Transparent support for providing member access to │ │ │ │ │ + both lvalues and rvalues (temporary proxies). │ │ │ │ │   │ │ │ │ │ -***** Macro Definition Documentation ***** │ │ │ │ │ -***** ◆ DUNE_ASSERT_CALL_ONCE ***** │ │ │ │ │ -#define ( )     ::Dune::assertCallOnce(__FILE__, __LINE__, │ │ │ │ │ -DUNE_ASSERT_CALL_ONCE __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. │ │ │ │ │ +***** Detailed Description ***** │ │ │ │ │ +infrastructure for supporting operator->() on both references and proxies │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00185_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: stdthread.hh Source File │ │ │ │ +dune-common: proxymemberaccess.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,54 +74,107 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │ -
    stdthread.hh
    │ │ │ │ +
    proxymemberaccess.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 (C) 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{
    │ │ │ │ -
    11
    │ │ │ │ -
    12 // used internally by assertCallOnce for the actual check
    │ │ │ │ -
    13 void doAssertCallOnce(const char *file, int line, const char *function);
    │ │ │ │ -
    14
    │ │ │ │ -
    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 }
    │ │ │ │ -
    │ │ │ │ +
    5#ifndef DUNE_COMMON_PROXYMEMBERACCESS_HH
    │ │ │ │ +
    6#define DUNE_COMMON_PROXYMEMBERACCESS_HH
    │ │ │ │ +
    7
    │ │ │ │ +
    14#include <type_traits>
    │ │ │ │ +
    15#include <utility>
    │ │ │ │ +
    16
    │ │ │ │ +
    17namespace Dune {
    │ │ │ │ +
    18
    │ │ │ │ +
    19 namespace Impl {
    │ │ │ │ +
    20
    │ │ │ │ +
    21 // helper struct to store a temporary / proxy
    │ │ │ │ +
    22 // for the duration of the member access
    │ │ │ │ +
    23 template<typename T>
    │ │ │ │ +
    24 struct member_access_proxy_holder
    │ │ │ │ +
    25 {
    │ │ │ │ +
    26
    │ │ │ │ +
    27 // only support moving the temporary into the holder object
    │ │ │ │ +
    28 member_access_proxy_holder(T&& t)
    │ │ │ │ +
    29 : _t(std::move(t))
    │ │ │ │ +
    30 {}
    │ │ │ │ +
    31
    │ │ │ │ +
    32 // The object is fundamentally a temporary, i.e. an rvalue,
    │ │ │ │ +
    33 //
    │ │ │ │ +
    34 const T* operator->() const
    │ │ │ │ +
    35 {
    │ │ │ │ +
    36 return &_t;
    │ │ │ │ +
    37 }
    │ │ │ │ +
    38
    │ │ │ │ +
    39 T _t;
    │ │ │ │ +
    40
    │ │ │ │ +
    41 };
    │ │ │ │
    42
    │ │ │ │ +
    43 } // end Impl namespace
    │ │ │ │ +
    44
    │ │ │ │
    45
    │ │ │ │ -
    │ │ │ │ -
    49#define DUNE_ASSERT_CALL_ONCE() \
    │ │ │ │ -
    50 ::Dune::assertCallOnce(__FILE__, __LINE__, __func__)
    │ │ │ │ -
    │ │ │ │ -
    51
    │ │ │ │ -
    52} // namespace Dune
    │ │ │ │ -
    53
    │ │ │ │ -
    54#endif // DUNE_COMMON_STDTHREAD_HH
    │ │ │ │ +
    46#ifdef DOXYGEN
    │ │ │ │ +
    47
    │ │ │ │ +
    49
    │ │ │ │ +
    79 template<typename T>
    │ │ │ │ +
    80 pointer_or_proxy_holder
    │ │ │ │ + │ │ │ │ +
    82
    │ │ │ │ +
    83#else // DOXYGEN
    │ │ │ │ +
    84
    │ │ │ │ +
    85
    │ │ │ │ +
    86 // This version matches lvalues (the C++ type deduction rules state that
    │ │ │ │ +
    87 // the T&& signature deduces to a reference iff the argument is an lvalue).
    │ │ │ │ +
    88 // As the argument is an lvalue, we do not have to worry about its lifetime
    │ │ │ │ +
    89 // and can just return its address.
    │ │ │ │ +
    90 template<typename T>
    │ │ │ │ +
    91 inline typename std::enable_if<
    │ │ │ │ +
    92 std::is_lvalue_reference<T>::value,
    │ │ │ │ +
    93 typename std::add_pointer<
    │ │ │ │ +
    94 typename std::remove_reference<
    │ │ │ │ +
    95 T
    │ │ │ │ +
    96 >::type
    │ │ │ │ +
    97 >::type
    │ │ │ │ +
    98 >::type
    │ │ │ │ + │ │ │ │ +
    100 {
    │ │ │ │ +
    101 return &target;
    │ │ │ │ +
    102 }
    │ │ │ │ +
    103
    │ │ │ │ +
    104 // This version matches rvalues (the C++ type deduction rules state that
    │ │ │ │ +
    105 // the T&& signature deduces to a non-reference iff the argument is an rvalue).
    │ │ │ │ +
    106 // In this case, we have to capture the rvalue in a new object to make sure it
    │ │ │ │ +
    107 // is kept alive for the duration of the member access. For this purpose, we move
    │ │ │ │ +
    108 // it into a member_access_proxy_holder instance.
    │ │ │ │ +
    109 template<typename T>
    │ │ │ │ +
    110 inline typename std::enable_if<
    │ │ │ │ +
    111 !std::is_lvalue_reference<T>::value,
    │ │ │ │ +
    112 Impl::member_access_proxy_holder<T>
    │ │ │ │ +
    113 >::type
    │ │ │ │ + │ │ │ │ +
    115 {
    │ │ │ │ +
    116 return {std::forward<T>(target)};
    │ │ │ │ +
    117 }
    │ │ │ │ +
    118
    │ │ │ │ +
    119#endif // DOXYGEN
    │ │ │ │ +
    120
    │ │ │ │ +
    121} // namespace Dune
    │ │ │ │ +
    122
    │ │ │ │ +
    123#endif // DUNE_COMMON_PROXYMEMBERACCESS_HH
    │ │ │ │ +
    pointer_or_proxy_holder handle_proxy_member_access(T &&t)
    Transparent support for providing member access to both lvalues and rvalues (temporary proxies).
    │ │ │ │ +
    STL namespace.
    │ │ │ │
    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:42
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,54 +7,112 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -stdthread.hh │ │ │ │ │ +proxymemberaccess.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 (C) 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{ │ │ │ │ │ - 11 │ │ │ │ │ - 12 // used internally by assertCallOnce for the actual check │ │ │ │ │ - 13 void doAssertCallOnce(const char *file, int line, const char *function); │ │ │ │ │ - 14 │ │ │ │ │ - 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 } │ │ │ │ │ + 5#ifndef DUNE_COMMON_PROXYMEMBERACCESS_HH │ │ │ │ │ + 6#define DUNE_COMMON_PROXYMEMBERACCESS_HH │ │ │ │ │ + 7 │ │ │ │ │ + 14#include │ │ │ │ │ + 15#include │ │ │ │ │ + 16 │ │ │ │ │ + 17namespace Dune { │ │ │ │ │ + 18 │ │ │ │ │ + 19 namespace Impl { │ │ │ │ │ + 20 │ │ │ │ │ + 21 // helper struct to store a temporary / proxy │ │ │ │ │ + 22 // for the duration of the member access │ │ │ │ │ + 23 template │ │ │ │ │ + 24 struct member_access_proxy_holder │ │ │ │ │ + 25 { │ │ │ │ │ + 26 │ │ │ │ │ + 27 // only support moving the temporary into the holder object │ │ │ │ │ + 28 member_access_proxy_holder(T&& t) │ │ │ │ │ + 29 : _t(std::move(t)) │ │ │ │ │ + 30 {} │ │ │ │ │ + 31 │ │ │ │ │ + 32 // The object is fundamentally a temporary, i.e. an rvalue, │ │ │ │ │ + 33 // │ │ │ │ │ + 34 const T* operator->() const │ │ │ │ │ + 35 { │ │ │ │ │ + 36 return &_t; │ │ │ │ │ + 37 } │ │ │ │ │ + 38 │ │ │ │ │ + 39 T _t; │ │ │ │ │ + 40 │ │ │ │ │ + 41 }; │ │ │ │ │ 42 │ │ │ │ │ + 43 } // end Impl namespace │ │ │ │ │ + 44 │ │ │ │ │ 45 │ │ │ │ │ -49#define DUNE_ASSERT_CALL_ONCE() \ │ │ │ │ │ - 50 ::Dune::assertCallOnce(__FILE__, __LINE__, __func__) │ │ │ │ │ - 51 │ │ │ │ │ - 52} // namespace Dune │ │ │ │ │ - 53 │ │ │ │ │ - 54#endif // DUNE_COMMON_STDTHREAD_HH │ │ │ │ │ + 46#ifdef DOXYGEN │ │ │ │ │ + 47 │ │ │ │ │ + 49 │ │ │ │ │ + 79 template │ │ │ │ │ + 80 pointer_or_proxy_holder │ │ │ │ │ +81 handle_proxy_member_access(T&& t); │ │ │ │ │ + 82 │ │ │ │ │ + 83#else // DOXYGEN │ │ │ │ │ + 84 │ │ │ │ │ + 85 │ │ │ │ │ + 86 // This version matches lvalues (the C++ type deduction rules state that │ │ │ │ │ + 87 // the T&& signature deduces to a reference iff the argument is an lvalue). │ │ │ │ │ + 88 // As the argument is an lvalue, we do not have to worry about its lifetime │ │ │ │ │ + 89 // and can just return its address. │ │ │ │ │ + 90 template │ │ │ │ │ + 91 inline typename std::enable_if< │ │ │ │ │ + 92 std::is_lvalue_reference::value, │ │ │ │ │ + 93 typename std::add_pointer< │ │ │ │ │ + 94 typename std::remove_reference< │ │ │ │ │ + 95 T │ │ │ │ │ + 96 >::type │ │ │ │ │ + 97 >::type │ │ │ │ │ + 98 >::type │ │ │ │ │ + 99 handle_proxy_member_access(T&& target) │ │ │ │ │ + 100 { │ │ │ │ │ + 101 return ⌖ │ │ │ │ │ + 102 } │ │ │ │ │ + 103 │ │ │ │ │ + 104 // This version matches rvalues (the C++ type deduction rules state that │ │ │ │ │ + 105 // the T&& signature deduces to a non-reference iff the argument is an │ │ │ │ │ +rvalue). │ │ │ │ │ + 106 // In this case, we have to capture the rvalue in a new object to make │ │ │ │ │ +sure it │ │ │ │ │ + 107 // is kept alive for the duration of the member access. For this purpose, │ │ │ │ │ +we move │ │ │ │ │ + 108 // it into a member_access_proxy_holder instance. │ │ │ │ │ + 109 template │ │ │ │ │ + 110 inline typename std::enable_if< │ │ │ │ │ + 111 !std::is_lvalue_reference::value, │ │ │ │ │ + 112 Impl::member_access_proxy_holder │ │ │ │ │ + 113 >::type │ │ │ │ │ + 114 handle_proxy_member_access(T&& target) │ │ │ │ │ + 115 { │ │ │ │ │ + 116 return {std::forward(target)}; │ │ │ │ │ + 117 } │ │ │ │ │ + 118 │ │ │ │ │ + 119#endif // DOXYGEN │ │ │ │ │ + 120 │ │ │ │ │ + 121} // namespace Dune │ │ │ │ │ + 122 │ │ │ │ │ + 123#endif // DUNE_COMMON_PROXYMEMBERACCESS_HH │ │ │ │ │ +Dune::handle_proxy_member_access │ │ │ │ │ +pointer_or_proxy_holder handle_proxy_member_access(T &&t) │ │ │ │ │ +Transparent support for providing member access to both lvalues and rvalues │ │ │ │ │ +(temporary proxies). │ │ │ │ │ +std │ │ │ │ │ +STL namespace. │ │ │ │ │ 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:42 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00188.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: densematrix.hh File Reference │ │ │ │ +dune-common: referencehelper.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,73 +70,60 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -Classes | │ │ │ │ Namespaces | │ │ │ │ -Functions
    │ │ │ │ -
    densematrix.hh File Reference
    │ │ │ │ +Typedefs | │ │ │ │ +Functions | │ │ │ │ +Variables
    │ │ │ │ +
    referencehelper.hh File Reference
    │ │ │ │ │ │ │ │
    │ │ │ │ - │ │ │ │ -

    Implements a matrix constructed from a given type representing a field and a compile-time given number of rows and columns. │ │ │ │ -More...

    │ │ │ │ -
    #include <cmath>
    │ │ │ │ -#include <cstddef>
    │ │ │ │ -#include <iostream>
    │ │ │ │ -#include <type_traits>
    │ │ │ │ -#include <utility>
    │ │ │ │ -#include <vector>
    │ │ │ │ -#include <dune/common/boundschecking.hh>
    │ │ │ │ -#include <dune/common/classname.hh>
    │ │ │ │ -#include <dune/common/exceptions.hh>
    │ │ │ │ -#include <dune/common/fvector.hh>
    │ │ │ │ -#include <dune/common/math.hh>
    │ │ │ │ -#include <dune/common/precision.hh>
    │ │ │ │ -#include <dune/common/simd/simd.hh>
    │ │ │ │ -#include <dune/common/typetraits.hh>
    │ │ │ │ -#include <dune/common/scalarvectorview.hh>
    │ │ │ │ +
    #include <type_traits>
    │ │ │ │ +#include <functional>
    │ │ │ │
    │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ -Classes

    struct  Dune::FieldTraits< DenseMatrix< M > >
     
    class  Dune::FMatrixError
     Error thrown if operations of a FieldMatrix fail. More...
     
    class  Dune::DenseMatrix< MAT >
     A dense n x m matrix. More...
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ +

    │ │ │ │ Namespaces

    namespace  Dune
     Dune namespace.
     
    namespace  Dune::DenseMatrixHelp
     
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

    │ │ │ │ +Typedefs

    template<class T >
    using Dune::ResolveRef_t = std::remove_reference_t< decltype(Dune::resolveRef(std::declval< T & >()))>
     Type trait to resolve std::reference_wrapper.
     
    │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

    │ │ │ │ Functions

    template<typename MAT , typename V1 , typename V2 >
    static void Dune::DenseMatrixHelp::multAssign (const DenseMatrix< MAT > &matrix, const DenseVector< V1 > &x, DenseVector< V2 > &ret)
     calculates ret = matrix * x
     
    template<typename MAT >
    std::ostream & Dune::operator<< (std::ostream &s, const DenseMatrix< MAT > &a)
     Sends the matrix to an output stream.
     
    template<class T >
    constexpr T & Dune::resolveRef (T &gf) noexcept
     Helper function to resolve std::reference_wrapper.
     
    template<class T >
    const auto & Dune::resolveRef (T &&gf)=delete
     
    template<class T >
    constexpr T & Dune::resolveRef (std::reference_wrapper< T > gf) noexcept
     Helper function to resolve std::reference_wrapper.
     
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

    │ │ │ │ +Variables

    template<class T >
    constexpr bool Dune::IsReferenceWrapper_v = Impl::IsReferenceWrapper<T>::value
     Helper to detect if given type is a std::reference_wrapper.
     
    │ │ │ │ -

    Detailed Description

    │ │ │ │ -

    Implements a matrix constructed from a given type representing a field and a compile-time given number of rows and columns.

    │ │ │ │ -
    │ │ │ │ +
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,59 +6,42 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Functions │ │ │ │ │ -densematrix.hh File Reference │ │ │ │ │ -Common » Dense_Matrix_and_Vector_Template_Library │ │ │ │ │ -Implements a matrix constructed from a given type representing a field and a │ │ │ │ │ -compile-time given number of rows and columns. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Namespaces | Typedefs | Functions | Variables │ │ │ │ │ +referencehelper.hh File Reference │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ - Classes │ │ │ │ │ -struct  Dune::FieldTraits<_DenseMatrix<_M_>_> │ │ │ │ │ -  │ │ │ │ │ - class  Dune::FMatrixError │ │ │ │ │ -  Error thrown if operations of a FieldMatrix fail. More... │ │ │ │ │ -  │ │ │ │ │ - class  Dune::DenseMatrix<_MAT_> │ │ │ │ │ -  A dense n x m matrix. More... │ │ │ │ │ -  │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -namespace  Dune::DenseMatrixHelp │ │ │ │ │ + Typedefs │ │ │ │ │ +template │ │ │ │ │ +using Dune::ResolveRef_t = std::remove_reference_t< decltype(Dune::resolveRef │ │ │ │ │ + (std::declval< T & >()))> │ │ │ │ │ +  Type trait to resolve std::reference_wrapper. │ │ │ │ │   │ │ │ │ │ Functions │ │ │ │ │ -template │ │ │ │ │ - static void Dune::DenseMatrixHelp::multAssign (const DenseMatrix< MAT > │ │ │ │ │ - &matrix, const DenseVector< V1 > &x, DenseVector< V2 > &ret) │ │ │ │ │ -  calculates ret = matrix * x │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -std::ostream & Dune::operator<< (std::ostream &s, const DenseMatrix< MAT > &a) │ │ │ │ │ -  Sends the matrix to an output stream. │ │ │ │ │ -  │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -Implements a matrix constructed from a given type representing a field and a │ │ │ │ │ -compile-time given number of rows and columns. │ │ │ │ │ +template │ │ │ │ │ +constexpr T & Dune::resolveRef (T &gf) noexcept │ │ │ │ │ +  Helper function to resolve std::reference_wrapper. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + const auto & Dune::resolveRef (T &&gf)=delete │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +constexpr T & Dune::resolveRef (std::reference_wrapper< T > gf) noexcept │ │ │ │ │ +  Helper function to resolve std::reference_wrapper. │ │ │ │ │ +  │ │ │ │ │ + Variables │ │ │ │ │ +template │ │ │ │ │ +constexpr bool Dune::IsReferenceWrapper_v = Impl::IsReferenceWrapper::value │ │ │ │ │ +  Helper to detect if given type is a std::reference_wrapper. │ │ │ │ │ +  │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00188_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: densematrix.hh Source File │ │ │ │ +dune-common: referencehelper.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,1304 +74,92 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │ -
    densematrix.hh
    │ │ │ │ +
    referencehelper.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 (C) 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_DENSEMATRIX_HH
    │ │ │ │ -
    6#define DUNE_DENSEMATRIX_HH
    │ │ │ │ +
    5#ifndef DUNE_COMMON_REFERENCE_HELPER_HH
    │ │ │ │ +
    6#define DUNE_COMMON_REFERENCE_HELPER_HH
    │ │ │ │
    7
    │ │ │ │ -
    8#include <cmath>
    │ │ │ │ -
    9#include <cstddef>
    │ │ │ │ -
    10#include <iostream>
    │ │ │ │ -
    11#include <type_traits>
    │ │ │ │ -
    12#include <utility>
    │ │ │ │ -
    13#include <vector>
    │ │ │ │ +
    8#include <type_traits>
    │ │ │ │ +
    9#include <functional>
    │ │ │ │ +
    10
    │ │ │ │ +
    11
    │ │ │ │ +
    12
    │ │ │ │ +
    13namespace Dune {
    │ │ │ │
    14
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
    19#include <dune/common/math.hh>
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
    24
    │ │ │ │ -
    25namespace Dune
    │ │ │ │ -
    26{
    │ │ │ │ +
    15namespace Impl {
    │ │ │ │ +
    16
    │ │ │ │ +
    17 template<class T>
    │ │ │ │ +
    18 class IsReferenceWrapper : public std::false_type {};
    │ │ │ │ +
    19
    │ │ │ │ +
    20 template<class T>
    │ │ │ │ +
    21 class IsReferenceWrapper<std::reference_wrapper<T>> : public std::true_type {};
    │ │ │ │ +
    22
    │ │ │ │ +
    23 template<class T>
    │ │ │ │ +
    24 class IsReferenceWrapper<const std::reference_wrapper<T>> : public std::true_type {};
    │ │ │ │ +
    25
    │ │ │ │ +
    26} // namespace Dune::Impl
    │ │ │ │
    27
    │ │ │ │ -
    28 template<typename M> class DenseMatrix;
    │ │ │ │ -
    29
    │ │ │ │ -
    30 template<typename M>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    32 {
    │ │ │ │ - │ │ │ │ - │ │ │ │ -
    35 };
    │ │ │ │ -
    │ │ │ │ +
    28
    │ │ │ │ +
    34template<class T>
    │ │ │ │ +
    35constexpr bool IsReferenceWrapper_v = Impl::IsReferenceWrapper<T>::value;
    │ │ │ │
    36
    │ │ │ │ -
    37 template<class K, int N, int M> class FieldMatrix;
    │ │ │ │ -
    38 template<class K, int N> class FieldVector;
    │ │ │ │ -
    39
    │ │ │ │ -
    58 template< class DenseMatrix, class RHS >
    │ │ │ │ - │ │ │ │ -
    60
    │ │ │ │ -
    61#ifndef DOXYGEN
    │ │ │ │ -
    62 namespace Impl
    │ │ │ │ -
    63 {
    │ │ │ │ -
    64
    │ │ │ │ -
    65 template< class DenseMatrix, class RHS, class = void >
    │ │ │ │ - │ │ │ │ -
    67 {};
    │ │ │ │ -
    68
    │ │ │ │ -
    69 template< class DenseMatrix, class RHS >
    │ │ │ │ -
    70 class DenseMatrixAssigner< DenseMatrix, RHS, std::enable_if_t< Dune::IsNumber< RHS >::value > >
    │ │ │ │ -
    71 {
    │ │ │ │ -
    72 public:
    │ │ │ │ -
    73 static void apply ( DenseMatrix &denseMatrix, const RHS &rhs )
    │ │ │ │ -
    74 {
    │ │ │ │ -
    75 typedef typename DenseMatrix::field_type field_type;
    │ │ │ │ -
    76 std::fill( denseMatrix.begin(), denseMatrix.end(), static_cast< field_type >( rhs ) );
    │ │ │ │ -
    77 }
    │ │ │ │ -
    78 };
    │ │ │ │ -
    79
    │ │ │ │ -
    80 template< class DenseMatrix, class RHS >
    │ │ │ │ -
    81 class DenseMatrixAssigner< DenseMatrix, RHS, std::enable_if_t< !std::is_same< typename RHS::const_iterator, void >::value
    │ │ │ │ -
    82 && std::is_convertible< typename RHS::const_iterator::value_type, typename DenseMatrix::iterator::value_type >::value > >
    │ │ │ │ -
    83 {
    │ │ │ │ -
    84 public:
    │ │ │ │ -
    85 static void apply ( DenseMatrix &denseMatrix, const RHS &rhs )
    │ │ │ │ -
    86 {
    │ │ │ │ -
    87 DUNE_ASSERT_BOUNDS(rhs.N() == denseMatrix.N());
    │ │ │ │ -
    88 DUNE_ASSERT_BOUNDS(rhs.M() == denseMatrix.M());
    │ │ │ │ -
    89 typename DenseMatrix::iterator tIt = std::begin(denseMatrix);
    │ │ │ │ -
    90 typename RHS::const_iterator sIt = std::begin(rhs);
    │ │ │ │ -
    91 for(; sIt != std::end(rhs); ++tIt, ++sIt)
    │ │ │ │ -
    92 std::copy(std::begin(*sIt), std::end(*sIt), std::begin(*tIt));
    │ │ │ │ -
    93 }
    │ │ │ │ -
    94 };
    │ │ │ │ -
    95
    │ │ │ │ -
    96 } // namespace Impl
    │ │ │ │ -
    97
    │ │ │ │ -
    98
    │ │ │ │ -
    99
    │ │ │ │ -
    100 template< class DenseMatrix, class RHS >
    │ │ │ │ -
    101 struct DenseMatrixAssigner
    │ │ │ │ -
    102 : public Impl::DenseMatrixAssigner< DenseMatrix, RHS >
    │ │ │ │ -
    103 {};
    │ │ │ │ +
    37
    │ │ │ │ +
    46template<class T>
    │ │ │ │ +
    │ │ │ │ +
    47constexpr T& resolveRef(T& gf) noexcept
    │ │ │ │ +
    48{
    │ │ │ │ +
    49 return gf;
    │ │ │ │ +
    50}
    │ │ │ │ +
    │ │ │ │ +
    51
    │ │ │ │ +
    52
    │ │ │ │ +
    53// There's no overload for non std::reference_wrapper r-values,
    │ │ │ │ +
    54// because this may lead to undefined behavior whenever the
    │ │ │ │ +
    55// return value is stored.
    │ │ │ │ +
    56// Notice that deleting the overload is not necessary, but
    │ │ │ │ +
    57// helps to document that it is missing on purpose. It also
    │ │ │ │ +
    58// leads to nicer error messages.
    │ │ │ │ +
    59template<class T>
    │ │ │ │ +
    60const auto& resolveRef(T&& gf) = delete;
    │ │ │ │ +
    61
    │ │ │ │ +
    62
    │ │ │ │ +
    81template<class T>
    │ │ │ │ +
    │ │ │ │ +
    82constexpr T& resolveRef(std::reference_wrapper<T> gf) noexcept
    │ │ │ │ +
    83{
    │ │ │ │ +
    84 return gf.get();
    │ │ │ │ +
    85}
    │ │ │ │ +
    │ │ │ │ +
    86
    │ │ │ │ +
    87
    │ │ │ │ +
    88
    │ │ │ │ +
    99template<class T>
    │ │ │ │ +
    100using ResolveRef_t = std::remove_reference_t<decltype(Dune::resolveRef(std::declval<T&>()))>;
    │ │ │ │ +
    101
    │ │ │ │ +
    102
    │ │ │ │ +
    103} // namespace Dune
    │ │ │ │
    104
    │ │ │ │
    105
    │ │ │ │ -
    106 namespace Impl
    │ │ │ │ -
    107 {
    │ │ │ │ -
    108
    │ │ │ │ -
    109 template< class DenseMatrix, class RHS >
    │ │ │ │ -
    110 std::true_type hasDenseMatrixAssigner ( DenseMatrix &, const RHS &, decltype( Dune::DenseMatrixAssigner< DenseMatrix, RHS >::apply( std::declval< DenseMatrix & >(), std::declval< const RHS & >() ) ) * = nullptr );
    │ │ │ │ -
    111
    │ │ │ │ -
    112 std::false_type hasDenseMatrixAssigner ( ... );
    │ │ │ │ -
    113
    │ │ │ │ -
    114 } // namespace Impl
    │ │ │ │ -
    115
    │ │ │ │ -
    116 template< class DenseMatrix, class RHS >
    │ │ │ │ -
    117 struct HasDenseMatrixAssigner
    │ │ │ │ -
    118 : public decltype( Impl::hasDenseMatrixAssigner( std::declval< DenseMatrix & >(), std::declval< const RHS & >() ) )
    │ │ │ │ -
    119 {};
    │ │ │ │ -
    120
    │ │ │ │ -
    121#endif // #ifndef DOXYGEN
    │ │ │ │ -
    122
    │ │ │ │ -
    123
    │ │ │ │ -
    124
    │ │ │ │ -
    126 class FMatrixError : public MathError {};
    │ │ │ │ -
    127
    │ │ │ │ -
    138 template<typename MAT>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    140 {
    │ │ │ │ - │ │ │ │ -
    142
    │ │ │ │ -
    143 // Curiously recurring template pattern
    │ │ │ │ -
    144 constexpr MAT & asImp() { return static_cast<MAT&>(*this); }
    │ │ │ │ -
    145 constexpr const MAT & asImp() const { return static_cast<const MAT&>(*this); }
    │ │ │ │ -
    146
    │ │ │ │ -
    147 template <class>
    │ │ │ │ -
    148 friend class DenseMatrix;
    │ │ │ │ -
    149
    │ │ │ │ -
    150 public:
    │ │ │ │ -
    151 //===== type definitions and constants
    │ │ │ │ -
    152
    │ │ │ │ -
    154 typedef typename Traits::derived_type derived_type;
    │ │ │ │ -
    155
    │ │ │ │ -
    157 typedef typename Traits::value_type value_type;
    │ │ │ │ -
    158
    │ │ │ │ -
    160 typedef typename Traits::value_type field_type;
    │ │ │ │ -
    161
    │ │ │ │ -
    163 typedef typename Traits::value_type block_type;
    │ │ │ │ -
    164
    │ │ │ │ -
    166 typedef typename Traits::size_type size_type;
    │ │ │ │ -
    167
    │ │ │ │ -
    169 typedef typename Traits::row_type row_type;
    │ │ │ │ -
    170
    │ │ │ │ -
    172 typedef typename Traits::row_reference row_reference;
    │ │ │ │ -
    173
    │ │ │ │ -
    175 typedef typename Traits::const_row_reference const_row_reference;
    │ │ │ │ -
    176
    │ │ │ │ -
    178 constexpr static int blocklevel = 1;
    │ │ │ │ -
    179
    │ │ │ │ -
    180 private:
    │ │ │ │ -
    183 using simd_index_type = Simd::Rebind<std::size_t, value_type>;
    │ │ │ │ -
    184
    │ │ │ │ -
    185 public:
    │ │ │ │ -
    186 //===== access to components
    │ │ │ │ -
    187
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    190 {
    │ │ │ │ -
    191 return asImp().mat_access(i);
    │ │ │ │ -
    192 }
    │ │ │ │ -
    │ │ │ │ -
    193
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    195 {
    │ │ │ │ -
    196 return asImp().mat_access(i);
    │ │ │ │ -
    197 }
    │ │ │ │ -
    │ │ │ │ -
    198
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    201 {
    │ │ │ │ -
    202 return rows();
    │ │ │ │ -
    203 }
    │ │ │ │ -
    │ │ │ │ -
    204
    │ │ │ │ -
    205 //===== iterator interface to rows of the matrix
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
    213 typedef typename std::remove_reference<row_reference>::type::Iterator ColIterator;
    │ │ │ │ -
    214
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    217 {
    │ │ │ │ -
    218 return Iterator(*this,0);
    │ │ │ │ -
    219 }
    │ │ │ │ -
    │ │ │ │ -
    220
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    223 {
    │ │ │ │ -
    224 return Iterator(*this,rows());
    │ │ │ │ -
    225 }
    │ │ │ │ -
    │ │ │ │ -
    226
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    230 {
    │ │ │ │ -
    231 return Iterator(*this,rows()-1);
    │ │ │ │ -
    232 }
    │ │ │ │ -
    │ │ │ │ -
    233
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    237 {
    │ │ │ │ -
    238 return Iterator(*this,-1);
    │ │ │ │ -
    239 }
    │ │ │ │ -
    │ │ │ │ -
    240
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
    248 typedef typename std::remove_reference<const_row_reference>::type::ConstIterator ConstColIterator;
    │ │ │ │ -
    249
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    252 {
    │ │ │ │ -
    253 return ConstIterator(*this,0);
    │ │ │ │ -
    254 }
    │ │ │ │ -
    │ │ │ │ -
    255
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    258 {
    │ │ │ │ -
    259 return ConstIterator(*this,rows());
    │ │ │ │ -
    260 }
    │ │ │ │ -
    │ │ │ │ -
    261
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    265 {
    │ │ │ │ -
    266 return ConstIterator(*this,rows()-1);
    │ │ │ │ -
    267 }
    │ │ │ │ -
    │ │ │ │ -
    268
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    272 {
    │ │ │ │ -
    273 return ConstIterator(*this,-1);
    │ │ │ │ -
    274 }
    │ │ │ │ -
    │ │ │ │ -
    275
    │ │ │ │ -
    276 //===== assignment
    │ │ │ │ -
    277
    │ │ │ │ -
    278 template< class RHS, class = std::enable_if_t< HasDenseMatrixAssigner< MAT, RHS >::value > >
    │ │ │ │ -
    │ │ │ │ -
    279 derived_type &operator= ( const RHS &rhs )
    │ │ │ │ -
    280 {
    │ │ │ │ - │ │ │ │ -
    282 return asImp();
    │ │ │ │ -
    283 }
    │ │ │ │ -
    │ │ │ │ -
    284
    │ │ │ │ -
    285 //===== vector space arithmetic
    │ │ │ │ -
    286
    │ │ │ │ -
    288 template <class Other>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    290 {
    │ │ │ │ -
    291 DUNE_ASSERT_BOUNDS(rows() == x.rows());
    │ │ │ │ -
    292 for (size_type i=0; i<rows(); i++)
    │ │ │ │ -
    293 (*this)[i] += x[i];
    │ │ │ │ -
    294 return asImp();
    │ │ │ │ -
    295 }
    │ │ │ │ -
    │ │ │ │ -
    296
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    299 {
    │ │ │ │ -
    300 MAT result;
    │ │ │ │ -
    301 using idx_type = typename decltype(result)::size_type;
    │ │ │ │ -
    302
    │ │ │ │ -
    303 for (idx_type i = 0; i < rows(); ++i)
    │ │ │ │ -
    304 for (idx_type j = 0; j < cols(); ++j)
    │ │ │ │ -
    305 result[i][j] = - asImp()[i][j];
    │ │ │ │ -
    306
    │ │ │ │ -
    307 return result;
    │ │ │ │ -
    308 }
    │ │ │ │ -
    │ │ │ │ -
    309
    │ │ │ │ -
    311 template <class Other>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    313 {
    │ │ │ │ -
    314 DUNE_ASSERT_BOUNDS(rows() == x.rows());
    │ │ │ │ -
    315 for (size_type i=0; i<rows(); i++)
    │ │ │ │ -
    316 (*this)[i] -= x[i];
    │ │ │ │ -
    317 return asImp();
    │ │ │ │ -
    318 }
    │ │ │ │ -
    │ │ │ │ -
    319
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    322 {
    │ │ │ │ -
    323 for (size_type i=0; i<rows(); i++)
    │ │ │ │ -
    324 (*this)[i] *= k;
    │ │ │ │ -
    325 return asImp();
    │ │ │ │ -
    326 }
    │ │ │ │ -
    │ │ │ │ -
    327
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    330 {
    │ │ │ │ -
    331 for (size_type i=0; i<rows(); i++)
    │ │ │ │ -
    332 (*this)[i] /= k;
    │ │ │ │ -
    333 return asImp();
    │ │ │ │ -
    334 }
    │ │ │ │ -
    │ │ │ │ -
    335
    │ │ │ │ -
    337 template <class Other>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    339 {
    │ │ │ │ -
    340 DUNE_ASSERT_BOUNDS(rows() == x.rows());
    │ │ │ │ -
    341 for( size_type i = 0; i < rows(); ++i )
    │ │ │ │ -
    342 (*this)[ i ].axpy( a, x[ i ] );
    │ │ │ │ -
    343 return asImp();
    │ │ │ │ -
    344 }
    │ │ │ │ -
    │ │ │ │ -
    345
    │ │ │ │ -
    347 template <class Other>
    │ │ │ │ -
    │ │ │ │ -
    348 bool operator== (const DenseMatrix<Other>& x) const
    │ │ │ │ -
    349 {
    │ │ │ │ -
    350 DUNE_ASSERT_BOUNDS(rows() == x.rows());
    │ │ │ │ -
    351 for (size_type i=0; i<rows(); i++)
    │ │ │ │ -
    352 if ((*this)[i]!=x[i])
    │ │ │ │ -
    353 return false;
    │ │ │ │ -
    354 return true;
    │ │ │ │ -
    355 }
    │ │ │ │ -
    │ │ │ │ -
    357 template <class Other>
    │ │ │ │ -
    │ │ │ │ -
    358 bool operator!= (const DenseMatrix<Other>& x) const
    │ │ │ │ -
    359 {
    │ │ │ │ -
    360 return !operator==(x);
    │ │ │ │ -
    361 }
    │ │ │ │ -
    │ │ │ │ -
    362
    │ │ │ │ -
    363
    │ │ │ │ -
    364 //===== linear maps
    │ │ │ │ -
    365
    │ │ │ │ -
    367 template<class X, class Y>
    │ │ │ │ -
    │ │ │ │ -
    368 void mv (const X& x, Y& y) const
    │ │ │ │ -
    369 {
    │ │ │ │ -
    370 auto&& xx = Impl::asVector(x);
    │ │ │ │ -
    371 auto&& yy = Impl::asVector(y);
    │ │ │ │ -
    372 DUNE_ASSERT_BOUNDS((void*)(&x) != (void*)(&y));
    │ │ │ │ -
    373 DUNE_ASSERT_BOUNDS(xx.N() == M());
    │ │ │ │ -
    374 DUNE_ASSERT_BOUNDS(yy.N() == N());
    │ │ │ │ -
    375
    │ │ │ │ -
    376 using y_field_type = typename FieldTraits<Y>::field_type;
    │ │ │ │ -
    377 for (size_type i=0; i<rows(); ++i)
    │ │ │ │ -
    378 {
    │ │ │ │ -
    379 yy[i] = y_field_type(0);
    │ │ │ │ -
    380 for (size_type j=0; j<cols(); j++)
    │ │ │ │ -
    381 yy[i] += (*this)[i][j] * xx[j];
    │ │ │ │ -
    382 }
    │ │ │ │ -
    383 }
    │ │ │ │ -
    │ │ │ │ -
    384
    │ │ │ │ -
    386 template< class X, class Y >
    │ │ │ │ -
    │ │ │ │ -
    387 void mtv ( const X &x, Y &y ) const
    │ │ │ │ -
    388 {
    │ │ │ │ -
    389 auto&& xx = Impl::asVector(x);
    │ │ │ │ -
    390 auto&& yy = Impl::asVector(y);
    │ │ │ │ -
    391 DUNE_ASSERT_BOUNDS((void*)(&x) != (void*)(&y));
    │ │ │ │ -
    392 DUNE_ASSERT_BOUNDS(xx.N() == N());
    │ │ │ │ -
    393 DUNE_ASSERT_BOUNDS(yy.N() == M());
    │ │ │ │ -
    394
    │ │ │ │ -
    395 using y_field_type = typename FieldTraits<Y>::field_type;
    │ │ │ │ -
    396 for(size_type i = 0; i < cols(); ++i)
    │ │ │ │ -
    397 {
    │ │ │ │ -
    398 yy[i] = y_field_type(0);
    │ │ │ │ -
    399 for(size_type j = 0; j < rows(); ++j)
    │ │ │ │ -
    400 yy[i] += (*this)[j][i] * xx[j];
    │ │ │ │ -
    401 }
    │ │ │ │ -
    402 }
    │ │ │ │ -
    │ │ │ │ -
    403
    │ │ │ │ -
    405 template<class X, class Y>
    │ │ │ │ -
    │ │ │ │ -
    406 void umv (const X& x, Y& y) const
    │ │ │ │ -
    407 {
    │ │ │ │ -
    408 auto&& xx = Impl::asVector(x);
    │ │ │ │ -
    409 auto&& yy = Impl::asVector(y);
    │ │ │ │ -
    410 DUNE_ASSERT_BOUNDS(xx.N() == M());
    │ │ │ │ -
    411 DUNE_ASSERT_BOUNDS(yy.N() == N());
    │ │ │ │ -
    412 for (size_type i=0; i<rows(); ++i)
    │ │ │ │ -
    413 for (size_type j=0; j<cols(); j++)
    │ │ │ │ -
    414 yy[i] += (*this)[i][j] * xx[j];
    │ │ │ │ -
    415 }
    │ │ │ │ -
    │ │ │ │ -
    416
    │ │ │ │ -
    418 template<class X, class Y>
    │ │ │ │ -
    │ │ │ │ -
    419 void umtv (const X& x, Y& y) const
    │ │ │ │ -
    420 {
    │ │ │ │ -
    421 auto&& xx = Impl::asVector(x);
    │ │ │ │ -
    422 auto&& yy = Impl::asVector(y);
    │ │ │ │ -
    423 DUNE_ASSERT_BOUNDS(xx.N() == N());
    │ │ │ │ -
    424 DUNE_ASSERT_BOUNDS(yy.N() == M());
    │ │ │ │ -
    425 for(size_type i = 0; i<rows(); ++i)
    │ │ │ │ -
    426 for (size_type j=0; j<cols(); j++)
    │ │ │ │ -
    427 yy[j] += (*this)[i][j]*xx[i];
    │ │ │ │ -
    428 }
    │ │ │ │ -
    │ │ │ │ -
    429
    │ │ │ │ -
    431 template<class X, class Y>
    │ │ │ │ -
    │ │ │ │ -
    432 void umhv (const X& x, Y& y) const
    │ │ │ │ -
    433 {
    │ │ │ │ -
    434 auto&& xx = Impl::asVector(x);
    │ │ │ │ -
    435 auto&& yy = Impl::asVector(y);
    │ │ │ │ -
    436 DUNE_ASSERT_BOUNDS(xx.N() == N());
    │ │ │ │ -
    437 DUNE_ASSERT_BOUNDS(yy.N() == M());
    │ │ │ │ -
    438 for (size_type i=0; i<rows(); i++)
    │ │ │ │ -
    439 for (size_type j=0; j<cols(); j++)
    │ │ │ │ -
    440 yy[j] += conjugateComplex((*this)[i][j])*xx[i];
    │ │ │ │ -
    441 }
    │ │ │ │ -
    │ │ │ │ -
    442
    │ │ │ │ -
    444 template<class X, class Y>
    │ │ │ │ -
    │ │ │ │ -
    445 void mmv (const X& x, Y& y) const
    │ │ │ │ -
    446 {
    │ │ │ │ -
    447 auto&& xx = Impl::asVector(x);
    │ │ │ │ -
    448 auto&& yy = Impl::asVector(y);
    │ │ │ │ -
    449 DUNE_ASSERT_BOUNDS(xx.N() == M());
    │ │ │ │ -
    450 DUNE_ASSERT_BOUNDS(yy.N() == N());
    │ │ │ │ -
    451 for (size_type i=0; i<rows(); i++)
    │ │ │ │ -
    452 for (size_type j=0; j<cols(); j++)
    │ │ │ │ -
    453 yy[i] -= (*this)[i][j] * xx[j];
    │ │ │ │ -
    454 }
    │ │ │ │ -
    │ │ │ │ -
    455
    │ │ │ │ -
    457 template<class X, class Y>
    │ │ │ │ -
    │ │ │ │ -
    458 void mmtv (const X& x, Y& y) const
    │ │ │ │ -
    459 {
    │ │ │ │ -
    460 auto&& xx = Impl::asVector(x);
    │ │ │ │ -
    461 auto&& yy = Impl::asVector(y);
    │ │ │ │ -
    462 DUNE_ASSERT_BOUNDS(xx.N() == N());
    │ │ │ │ -
    463 DUNE_ASSERT_BOUNDS(yy.N() == M());
    │ │ │ │ -
    464 for (size_type i=0; i<rows(); i++)
    │ │ │ │ -
    465 for (size_type j=0; j<cols(); j++)
    │ │ │ │ -
    466 yy[j] -= (*this)[i][j]*xx[i];
    │ │ │ │ -
    467 }
    │ │ │ │ -
    │ │ │ │ -
    468
    │ │ │ │ -
    470 template<class X, class Y>
    │ │ │ │ -
    │ │ │ │ -
    471 void mmhv (const X& x, Y& y) const
    │ │ │ │ -
    472 {
    │ │ │ │ -
    473 auto&& xx = Impl::asVector(x);
    │ │ │ │ -
    474 auto&& yy = Impl::asVector(y);
    │ │ │ │ -
    475 DUNE_ASSERT_BOUNDS(xx.N() == N());
    │ │ │ │ -
    476 DUNE_ASSERT_BOUNDS(yy.N() == M());
    │ │ │ │ -
    477 for (size_type i=0; i<rows(); i++)
    │ │ │ │ -
    478 for (size_type j=0; j<cols(); j++)
    │ │ │ │ -
    479 yy[j] -= conjugateComplex((*this)[i][j])*xx[i];
    │ │ │ │ -
    480 }
    │ │ │ │ -
    │ │ │ │ -
    481
    │ │ │ │ -
    483 template<class X, class Y>
    │ │ │ │ -
    │ │ │ │ -
    484 void usmv (const typename FieldTraits<Y>::field_type & alpha,
    │ │ │ │ -
    485 const X& x, Y& y) const
    │ │ │ │ -
    486 {
    │ │ │ │ -
    487 auto&& xx = Impl::asVector(x);
    │ │ │ │ -
    488 auto&& yy = Impl::asVector(y);
    │ │ │ │ -
    489 DUNE_ASSERT_BOUNDS(xx.N() == M());
    │ │ │ │ -
    490 DUNE_ASSERT_BOUNDS(yy.N() == N());
    │ │ │ │ -
    491 for (size_type i=0; i<rows(); i++)
    │ │ │ │ -
    492 for (size_type j=0; j<cols(); j++)
    │ │ │ │ -
    493 yy[i] += alpha * (*this)[i][j] * xx[j];
    │ │ │ │ -
    494 }
    │ │ │ │ -
    │ │ │ │ -
    495
    │ │ │ │ -
    497 template<class X, class Y>
    │ │ │ │ -
    │ │ │ │ -
    498 void usmtv (const typename FieldTraits<Y>::field_type & alpha,
    │ │ │ │ -
    499 const X& x, Y& y) const
    │ │ │ │ -
    500 {
    │ │ │ │ -
    501 auto&& xx = Impl::asVector(x);
    │ │ │ │ -
    502 auto&& yy = Impl::asVector(y);
    │ │ │ │ -
    503 DUNE_ASSERT_BOUNDS(xx.N() == N());
    │ │ │ │ -
    504 DUNE_ASSERT_BOUNDS(yy.N() == M());
    │ │ │ │ -
    505 for (size_type i=0; i<rows(); i++)
    │ │ │ │ -
    506 for (size_type j=0; j<cols(); j++)
    │ │ │ │ -
    507 yy[j] += alpha*(*this)[i][j]*xx[i];
    │ │ │ │ -
    508 }
    │ │ │ │ -
    │ │ │ │ -
    509
    │ │ │ │ -
    511 template<class X, class Y>
    │ │ │ │ -
    │ │ │ │ -
    512 void usmhv (const typename FieldTraits<Y>::field_type & alpha,
    │ │ │ │ -
    513 const X& x, Y& y) const
    │ │ │ │ -
    514 {
    │ │ │ │ -
    515 auto&& xx = Impl::asVector(x);
    │ │ │ │ -
    516 auto&& yy = Impl::asVector(y);
    │ │ │ │ -
    517 DUNE_ASSERT_BOUNDS(xx.N() == N());
    │ │ │ │ -
    518 DUNE_ASSERT_BOUNDS(yy.N() == M());
    │ │ │ │ -
    519 for (size_type i=0; i<rows(); i++)
    │ │ │ │ -
    520 for (size_type j=0; j<cols(); j++)
    │ │ │ │ -
    521 yy[j] +=
    │ │ │ │ -
    522 alpha*conjugateComplex((*this)[i][j])*xx[i];
    │ │ │ │ -
    523 }
    │ │ │ │ -
    │ │ │ │ -
    524
    │ │ │ │ -
    525 //===== norms
    │ │ │ │ -
    526
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    529 {
    │ │ │ │ -
    530 typename FieldTraits<value_type>::real_type sum=(0.0);
    │ │ │ │ -
    531 for (size_type i=0; i<rows(); ++i) sum += (*this)[i].two_norm2();
    │ │ │ │ -
    532 return fvmeta::sqrt(sum);
    │ │ │ │ -
    533 }
    │ │ │ │ -
    │ │ │ │ -
    534
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    537 {
    │ │ │ │ -
    538 typename FieldTraits<value_type>::real_type sum=(0.0);
    │ │ │ │ -
    539 for (size_type i=0; i<rows(); ++i) sum += (*this)[i].two_norm2();
    │ │ │ │ -
    540 return sum;
    │ │ │ │ -
    541 }
    │ │ │ │ -
    │ │ │ │ -
    542
    │ │ │ │ -
    544 template <typename vt = value_type,
    │ │ │ │ -
    545 typename std::enable_if<!HasNaN<vt>::value, int>::type = 0>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    547 using real_type = typename FieldTraits<vt>::real_type;
    │ │ │ │ -
    548 using std::max;
    │ │ │ │ -
    549
    │ │ │ │ -
    550 real_type norm = 0;
    │ │ │ │ -
    551 for (auto const &x : *this) {
    │ │ │ │ -
    552 real_type const a = x.one_norm();
    │ │ │ │ -
    553 norm = max(a, norm);
    │ │ │ │ -
    554 }
    │ │ │ │ -
    555 return norm;
    │ │ │ │ -
    556 }
    │ │ │ │ -
    │ │ │ │ -
    557
    │ │ │ │ -
    559 template <typename vt = value_type,
    │ │ │ │ -
    560 typename std::enable_if<!HasNaN<vt>::value, int>::type = 0>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    562 using real_type = typename FieldTraits<vt>::real_type;
    │ │ │ │ -
    563 using std::max;
    │ │ │ │ -
    564
    │ │ │ │ -
    565 real_type norm = 0;
    │ │ │ │ -
    566 for (auto const &x : *this) {
    │ │ │ │ -
    567 real_type const a = x.one_norm_real();
    │ │ │ │ -
    568 norm = max(a, norm);
    │ │ │ │ -
    569 }
    │ │ │ │ -
    570 return norm;
    │ │ │ │ -
    571 }
    │ │ │ │ -
    │ │ │ │ -
    572
    │ │ │ │ -
    574 template <typename vt = value_type,
    │ │ │ │ -
    575 typename std::enable_if<HasNaN<vt>::value, int>::type = 0>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    577 using real_type = typename FieldTraits<vt>::real_type;
    │ │ │ │ -
    578 using std::max;
    │ │ │ │ -
    579
    │ │ │ │ -
    580 real_type norm = 0;
    │ │ │ │ -
    581 real_type isNaN = 1;
    │ │ │ │ -
    582 for (auto const &x : *this) {
    │ │ │ │ -
    583 real_type const a = x.one_norm();
    │ │ │ │ -
    584 norm = max(a, norm);
    │ │ │ │ -
    585 isNaN += a;
    │ │ │ │ -
    586 }
    │ │ │ │ -
    587 return norm * (isNaN / isNaN);
    │ │ │ │ -
    588 }
    │ │ │ │ -
    │ │ │ │ -
    589
    │ │ │ │ -
    591 template <typename vt = value_type,
    │ │ │ │ -
    592 typename std::enable_if<HasNaN<vt>::value, int>::type = 0>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    594 using real_type = typename FieldTraits<vt>::real_type;
    │ │ │ │ -
    595 using std::max;
    │ │ │ │ -
    596
    │ │ │ │ -
    597 real_type norm = 0;
    │ │ │ │ -
    598 real_type isNaN = 1;
    │ │ │ │ -
    599 for (auto const &x : *this) {
    │ │ │ │ -
    600 real_type const a = x.one_norm_real();
    │ │ │ │ -
    601 norm = max(a, norm);
    │ │ │ │ -
    602 isNaN += a;
    │ │ │ │ -
    603 }
    │ │ │ │ -
    604 return norm * (isNaN / isNaN);
    │ │ │ │ -
    605 }
    │ │ │ │ -
    │ │ │ │ -
    606
    │ │ │ │ -
    607 //===== solve
    │ │ │ │ -
    608
    │ │ │ │ -
    613 template <class V1, class V2>
    │ │ │ │ -
    614 void solve (V1& x, const V2& b, bool doPivoting = true) const;
    │ │ │ │ -
    615
    │ │ │ │ -
    620 void invert(bool doPivoting = true);
    │ │ │ │ -
    621
    │ │ │ │ -
    623 field_type determinant (bool doPivoting = true) const;
    │ │ │ │ -
    624
    │ │ │ │ -
    626 template<typename M2>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    628 {
    │ │ │ │ -
    629 DUNE_ASSERT_BOUNDS(M.rows() == M.cols());
    │ │ │ │ -
    630 DUNE_ASSERT_BOUNDS(M.rows() == rows());
    │ │ │ │ -
    631 AutonomousValue<MAT> C(asImp());
    │ │ │ │ -
    632
    │ │ │ │ -
    633 for (size_type i=0; i<rows(); i++)
    │ │ │ │ -
    634 for (size_type j=0; j<cols(); j++) {
    │ │ │ │ -
    635 (*this)[i][j] = 0;
    │ │ │ │ -
    636 for (size_type k=0; k<rows(); k++)
    │ │ │ │ -
    637 (*this)[i][j] += M[i][k]*C[k][j];
    │ │ │ │ -
    638 }
    │ │ │ │ -
    639
    │ │ │ │ -
    640 return asImp();
    │ │ │ │ -
    641 }
    │ │ │ │ -
    │ │ │ │ -
    642
    │ │ │ │ -
    644 template<typename M2>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    646 {
    │ │ │ │ -
    647 DUNE_ASSERT_BOUNDS(M.rows() == M.cols());
    │ │ │ │ -
    648 DUNE_ASSERT_BOUNDS(M.cols() == cols());
    │ │ │ │ -
    649 AutonomousValue<MAT> C(asImp());
    │ │ │ │ -
    650
    │ │ │ │ -
    651 for (size_type i=0; i<rows(); i++)
    │ │ │ │ -
    652 for (size_type j=0; j<cols(); j++) {
    │ │ │ │ -
    653 (*this)[i][j] = 0;
    │ │ │ │ -
    654 for (size_type k=0; k<cols(); k++)
    │ │ │ │ -
    655 (*this)[i][j] += C[i][k]*M[k][j];
    │ │ │ │ -
    656 }
    │ │ │ │ -
    657 return asImp();
    │ │ │ │ -
    658 }
    │ │ │ │ -
    │ │ │ │ -
    659
    │ │ │ │ -
    660#if 0
    │ │ │ │ -
    662 template<int l>
    │ │ │ │ -
    663 DenseMatrix<K,l,cols> leftmultiplyany (const FieldMatrix<K,l,rows>& M) const
    │ │ │ │ -
    664 {
    │ │ │ │ - │ │ │ │ -
    666
    │ │ │ │ -
    667 for (size_type i=0; i<l; i++) {
    │ │ │ │ -
    668 for (size_type j=0; j<cols(); j++) {
    │ │ │ │ -
    669 C[i][j] = 0;
    │ │ │ │ -
    670 for (size_type k=0; k<rows(); k++)
    │ │ │ │ -
    671 C[i][j] += M[i][k]*(*this)[k][j];
    │ │ │ │ -
    672 }
    │ │ │ │ -
    673 }
    │ │ │ │ -
    674 return C;
    │ │ │ │ -
    675 }
    │ │ │ │ -
    676
    │ │ │ │ -
    678 template<int l>
    │ │ │ │ -
    679 FieldMatrix<K,rows,l> rightmultiplyany (const FieldMatrix<K,cols,l>& M) const
    │ │ │ │ -
    680 {
    │ │ │ │ -
    681 FieldMatrix<K,rows,l> C;
    │ │ │ │ -
    682
    │ │ │ │ -
    683 for (size_type i=0; i<rows(); i++) {
    │ │ │ │ -
    684 for (size_type j=0; j<l; j++) {
    │ │ │ │ -
    685 C[i][j] = 0;
    │ │ │ │ -
    686 for (size_type k=0; k<cols(); k++)
    │ │ │ │ -
    687 C[i][j] += (*this)[i][k]*M[k][j];
    │ │ │ │ -
    688 }
    │ │ │ │ -
    689 }
    │ │ │ │ -
    690 return C;
    │ │ │ │ -
    691 }
    │ │ │ │ -
    692#endif
    │ │ │ │ -
    693
    │ │ │ │ -
    694 //===== sizes
    │ │ │ │ -
    695
    │ │ │ │ -
    │ │ │ │ -
    697 constexpr size_type N () const
    │ │ │ │ -
    698 {
    │ │ │ │ -
    699 return rows();
    │ │ │ │ -
    700 }
    │ │ │ │ -
    │ │ │ │ -
    701
    │ │ │ │ -
    │ │ │ │ -
    703 constexpr size_type M () const
    │ │ │ │ -
    704 {
    │ │ │ │ -
    705 return cols();
    │ │ │ │ -
    706 }
    │ │ │ │ -
    │ │ │ │ -
    707
    │ │ │ │ -
    │ │ │ │ -
    709 constexpr size_type rows() const
    │ │ │ │ -
    710 {
    │ │ │ │ -
    711 return asImp().mat_rows();
    │ │ │ │ -
    712 }
    │ │ │ │ -
    │ │ │ │ -
    713
    │ │ │ │ -
    │ │ │ │ -
    715 constexpr size_type cols() const
    │ │ │ │ -
    716 {
    │ │ │ │ -
    717 return asImp().mat_cols();
    │ │ │ │ -
    718 }
    │ │ │ │ -
    │ │ │ │ -
    719
    │ │ │ │ -
    720 //===== query
    │ │ │ │ -
    721
    │ │ │ │ -
    │ │ │ │ -
    723 bool exists ([[maybe_unused]] size_type i, [[maybe_unused]] size_type j) const
    │ │ │ │ -
    724 {
    │ │ │ │ -
    725 DUNE_ASSERT_BOUNDS(i >= 0 && i < rows());
    │ │ │ │ -
    726 DUNE_ASSERT_BOUNDS(j >= 0 && j < cols());
    │ │ │ │ -
    727 return true;
    │ │ │ │ -
    728 }
    │ │ │ │ -
    │ │ │ │ -
    729
    │ │ │ │ -
    730 protected:
    │ │ │ │ -
    731
    │ │ │ │ -
    732#ifndef DOXYGEN
    │ │ │ │ -
    733 struct ElimPivot
    │ │ │ │ -
    734 {
    │ │ │ │ -
    735 ElimPivot(std::vector<simd_index_type> & pivot);
    │ │ │ │ -
    736
    │ │ │ │ -
    737 void swap(std::size_t i, simd_index_type j);
    │ │ │ │ -
    738
    │ │ │ │ -
    739 template<typename T>
    │ │ │ │ -
    740 void operator()(const T&, int, int)
    │ │ │ │ -
    741 {}
    │ │ │ │ -
    742
    │ │ │ │ -
    743 std::vector<simd_index_type> & pivot_;
    │ │ │ │ -
    744 };
    │ │ │ │ -
    745
    │ │ │ │ -
    746 template<typename V>
    │ │ │ │ -
    747 struct Elim
    │ │ │ │ -
    748 {
    │ │ │ │ -
    749 Elim(V& rhs);
    │ │ │ │ -
    750
    │ │ │ │ -
    751 void swap(std::size_t i, simd_index_type j);
    │ │ │ │ -
    752
    │ │ │ │ -
    753 void operator()(const typename V::field_type& factor, int k, int i);
    │ │ │ │ -
    754
    │ │ │ │ -
    755 V* rhs_;
    │ │ │ │ -
    756 };
    │ │ │ │ -
    757
    │ │ │ │ -
    758 struct ElimDet
    │ │ │ │ -
    759 {
    │ │ │ │ -
    760 ElimDet(field_type& sign) : sign_(sign)
    │ │ │ │ -
    761 { sign_ = 1; }
    │ │ │ │ -
    762
    │ │ │ │ -
    763 void swap(std::size_t i, simd_index_type j)
    │ │ │ │ -
    764 {
    │ │ │ │ -
    765 sign_ *=
    │ │ │ │ -
    766 Simd::cond(simd_index_type(i) == j, field_type(1), field_type(-1));
    │ │ │ │ -
    767 }
    │ │ │ │ -
    768
    │ │ │ │ -
    769 void operator()(const field_type&, int, int)
    │ │ │ │ -
    770 {}
    │ │ │ │ -
    771
    │ │ │ │ -
    772 field_type& sign_;
    │ │ │ │ -
    773 };
    │ │ │ │ -
    774#endif // DOXYGEN
    │ │ │ │ -
    775
    │ │ │ │ -
    777
    │ │ │ │ -
    815 template<class Func, class Mask>
    │ │ │ │ -
    816 static void luDecomposition(DenseMatrix<MAT>& A, Func func,
    │ │ │ │ -
    817 Mask &nonsingularLanes, bool throwEarly, bool doPivoting);
    │ │ │ │ -
    818 };
    │ │ │ │ -
    │ │ │ │ -
    819
    │ │ │ │ -
    820#ifndef DOXYGEN
    │ │ │ │ -
    821 template<typename MAT>
    │ │ │ │ -
    822 DenseMatrix<MAT>::ElimPivot::ElimPivot(std::vector<simd_index_type> & pivot)
    │ │ │ │ -
    823 : pivot_(pivot)
    │ │ │ │ -
    824 {
    │ │ │ │ -
    825 typedef typename std::vector<size_type>::size_type size_type;
    │ │ │ │ -
    826 for(size_type i=0; i < pivot_.size(); ++i) pivot_[i]=i;
    │ │ │ │ -
    827 }
    │ │ │ │ -
    828
    │ │ │ │ -
    829 template<typename MAT>
    │ │ │ │ -
    830 void DenseMatrix<MAT>::ElimPivot::swap(std::size_t i, simd_index_type j)
    │ │ │ │ -
    831 {
    │ │ │ │ -
    832 pivot_[i] =
    │ │ │ │ -
    833 Simd::cond(Simd::Scalar<simd_index_type>(i) == j, pivot_[i], j);
    │ │ │ │ -
    834 }
    │ │ │ │ -
    835
    │ │ │ │ -
    836 template<typename MAT>
    │ │ │ │ -
    837 template<typename V>
    │ │ │ │ -
    838 DenseMatrix<MAT>::Elim<V>::Elim(V& rhs)
    │ │ │ │ -
    839 : rhs_(&rhs)
    │ │ │ │ -
    840 {}
    │ │ │ │ -
    841
    │ │ │ │ -
    842 template<typename MAT>
    │ │ │ │ -
    843 template<typename V>
    │ │ │ │ -
    844 void DenseMatrix<MAT>::Elim<V>::swap(std::size_t i, simd_index_type j)
    │ │ │ │ -
    845 {
    │ │ │ │ -
    846 using std::swap;
    │ │ │ │ -
    847
    │ │ │ │ -
    848 // see the comment in luDecomposition()
    │ │ │ │ -
    849 for(std::size_t l = 0; l < Simd::lanes(j); ++l)
    │ │ │ │ -
    850 swap(Simd::lane(l, (*rhs_)[ i ]),
    │ │ │ │ -
    851 Simd::lane(l, (*rhs_)[Simd::lane(l, j)]));
    │ │ │ │ -
    852 }
    │ │ │ │ -
    853
    │ │ │ │ -
    854 template<typename MAT>
    │ │ │ │ -
    855 template<typename V>
    │ │ │ │ -
    856 void DenseMatrix<MAT>::
    │ │ │ │ -
    857 Elim<V>::operator()(const typename V::field_type& factor, int k, int i)
    │ │ │ │ -
    858 {
    │ │ │ │ -
    859 (*rhs_)[k] -= factor*(*rhs_)[i];
    │ │ │ │ -
    860 }
    │ │ │ │ -
    861
    │ │ │ │ -
    862 template<typename MAT>
    │ │ │ │ -
    863 template<typename Func, class Mask>
    │ │ │ │ -
    864 inline void DenseMatrix<MAT>::
    │ │ │ │ -
    865 luDecomposition(DenseMatrix<MAT>& A, Func func, Mask &nonsingularLanes,
    │ │ │ │ -
    866 bool throwEarly, bool doPivoting)
    │ │ │ │ -
    867 {
    │ │ │ │ -
    868 using std::max;
    │ │ │ │ -
    869 using std::swap;
    │ │ │ │ -
    870
    │ │ │ │ -
    871 typedef typename FieldTraits<value_type>::real_type real_type;
    │ │ │ │ -
    872
    │ │ │ │ -
    873 // LU decomposition of A in A
    │ │ │ │ -
    874 for (size_type i=0; i<A.rows(); i++) // loop over all rows
    │ │ │ │ -
    875 {
    │ │ │ │ -
    876 real_type pivmax = fvmeta::absreal(A[i][i]);
    │ │ │ │ -
    877
    │ │ │ │ -
    878 if (doPivoting)
    │ │ │ │ -
    879 {
    │ │ │ │ -
    880 // compute maximum of column
    │ │ │ │ -
    881 simd_index_type imax=i;
    │ │ │ │ -
    882 for (size_type k=i+1; k<A.rows(); k++)
    │ │ │ │ -
    883 {
    │ │ │ │ -
    884 auto abs = fvmeta::absreal(A[k][i]);
    │ │ │ │ -
    885 auto mask = abs > pivmax;
    │ │ │ │ -
    886 pivmax = Simd::cond(mask, abs, pivmax);
    │ │ │ │ -
    887 imax = Simd::cond(mask, simd_index_type(k), imax);
    │ │ │ │ -
    888 }
    │ │ │ │ -
    889 // swap rows
    │ │ │ │ -
    890 for (size_type j=0; j<A.rows(); j++)
    │ │ │ │ -
    891 {
    │ │ │ │ -
    892 // This is a swap operation where the second operand is scattered,
    │ │ │ │ -
    893 // and on top of that is also extracted from deep within a
    │ │ │ │ -
    894 // moderately complicated data structure (a DenseMatrix), where we
    │ │ │ │ -
    895 // can't assume much on the memory layout. On intel processors,
    │ │ │ │ -
    896 // the only instruction that might help us here is vgather, but it
    │ │ │ │ -
    897 // is unclear whether that is even faster than a software
    │ │ │ │ -
    898 // implementation, and we would also need vscatter which does not
    │ │ │ │ -
    899 // exist. So break vectorization here and do it manually.
    │ │ │ │ -
    900 for(std::size_t l = 0; l < Simd::lanes(A[i][j]); ++l)
    │ │ │ │ -
    901 swap(Simd::lane(l, A[i][j]),
    │ │ │ │ -
    902 Simd::lane(l, A[Simd::lane(l, imax)][j]));
    │ │ │ │ -
    903 }
    │ │ │ │ -
    904 func.swap(i, imax); // swap the pivot or rhs
    │ │ │ │ -
    905 }
    │ │ │ │ -
    906
    │ │ │ │ -
    907 // singular ?
    │ │ │ │ -
    908 nonsingularLanes = nonsingularLanes && (pivmax != real_type(0));
    │ │ │ │ -
    909 if (throwEarly) {
    │ │ │ │ -
    910 if(!Simd::allTrue(nonsingularLanes))
    │ │ │ │ -
    911 DUNE_THROW(FMatrixError, "matrix is singular");
    │ │ │ │ -
    912 }
    │ │ │ │ -
    913 else { // !throwEarly
    │ │ │ │ -
    914 if(!Simd::anyTrue(nonsingularLanes))
    │ │ │ │ -
    915 return;
    │ │ │ │ -
    916 }
    │ │ │ │ -
    917
    │ │ │ │ -
    918 // eliminate
    │ │ │ │ -
    919 for (size_type k=i+1; k<A.rows(); k++)
    │ │ │ │ -
    920 {
    │ │ │ │ -
    921 // in the simd case, A[i][i] may be close to zero in some lanes. Pray
    │ │ │ │ -
    922 // that the result is no worse than a quiet NaN.
    │ │ │ │ -
    923 field_type factor = A[k][i]/A[i][i];
    │ │ │ │ -
    924 A[k][i] = factor;
    │ │ │ │ -
    925 for (size_type j=i+1; j<A.rows(); j++)
    │ │ │ │ -
    926 A[k][j] -= factor*A[i][j];
    │ │ │ │ -
    927 func(factor, k, i);
    │ │ │ │ -
    928 }
    │ │ │ │ -
    929 }
    │ │ │ │ -
    930 }
    │ │ │ │ -
    931
    │ │ │ │ -
    932 template<typename MAT>
    │ │ │ │ -
    933 template <class V1, class V2>
    │ │ │ │ -
    934 inline void DenseMatrix<MAT>::solve(V1& x, const V2& b, bool doPivoting) const
    │ │ │ │ -
    935 {
    │ │ │ │ -
    936 using real_type = typename FieldTraits<value_type>::real_type;
    │ │ │ │ -
    937 // never mind those ifs, because they get optimized away
    │ │ │ │ -
    938 if (rows()!=cols())
    │ │ │ │ -
    939 DUNE_THROW(FMatrixError, "Can't solve for a " << rows() << "x" << cols() << " matrix!");
    │ │ │ │ -
    940
    │ │ │ │ -
    941 if (rows()==1) {
    │ │ │ │ -
    942
    │ │ │ │ -
    943#ifdef DUNE_FMatrix_WITH_CHECKING
    │ │ │ │ -
    944 if (Simd::anyTrue(fvmeta::absreal((*this)[0][0])
    │ │ │ │ - │ │ │ │ -
    946 DUNE_THROW(FMatrixError,"matrix is singular");
    │ │ │ │ -
    947#endif
    │ │ │ │ -
    948 x[0] = b[0]/(*this)[0][0];
    │ │ │ │ -
    949
    │ │ │ │ -
    950 }
    │ │ │ │ -
    951 else if (rows()==2) {
    │ │ │ │ -
    952
    │ │ │ │ -
    953 field_type detinv = (*this)[0][0]*(*this)[1][1]-(*this)[0][1]*(*this)[1][0];
    │ │ │ │ -
    954#ifdef DUNE_FMatrix_WITH_CHECKING
    │ │ │ │ -
    955 if (Simd::anyTrue(fvmeta::absreal(detinv)
    │ │ │ │ - │ │ │ │ -
    957 DUNE_THROW(FMatrixError,"matrix is singular");
    │ │ │ │ -
    958#endif
    │ │ │ │ -
    959 detinv = real_type(1.0)/detinv;
    │ │ │ │ -
    960
    │ │ │ │ -
    961 x[0] = detinv*((*this)[1][1]*b[0]-(*this)[0][1]*b[1]);
    │ │ │ │ -
    962 x[1] = detinv*((*this)[0][0]*b[1]-(*this)[1][0]*b[0]);
    │ │ │ │ -
    963
    │ │ │ │ -
    964 }
    │ │ │ │ -
    965 else if (rows()==3) {
    │ │ │ │ -
    966
    │ │ │ │ -
    967 field_type d = determinant(doPivoting);
    │ │ │ │ -
    968#ifdef DUNE_FMatrix_WITH_CHECKING
    │ │ │ │ -
    969 if (Simd::anyTrue(fvmeta::absreal(d)
    │ │ │ │ - │ │ │ │ -
    971 DUNE_THROW(FMatrixError,"matrix is singular");
    │ │ │ │ -
    972#endif
    │ │ │ │ -
    973
    │ │ │ │ -
    974 x[0] = (b[0]*(*this)[1][1]*(*this)[2][2] - b[0]*(*this)[2][1]*(*this)[1][2]
    │ │ │ │ -
    975 - b[1] *(*this)[0][1]*(*this)[2][2] + b[1]*(*this)[2][1]*(*this)[0][2]
    │ │ │ │ -
    976 + b[2] *(*this)[0][1]*(*this)[1][2] - b[2]*(*this)[1][1]*(*this)[0][2]) / d;
    │ │ │ │ -
    977
    │ │ │ │ -
    978 x[1] = ((*this)[0][0]*b[1]*(*this)[2][2] - (*this)[0][0]*b[2]*(*this)[1][2]
    │ │ │ │ -
    979 - (*this)[1][0] *b[0]*(*this)[2][2] + (*this)[1][0]*b[2]*(*this)[0][2]
    │ │ │ │ -
    980 + (*this)[2][0] *b[0]*(*this)[1][2] - (*this)[2][0]*b[1]*(*this)[0][2]) / d;
    │ │ │ │ -
    981
    │ │ │ │ -
    982 x[2] = ((*this)[0][0]*(*this)[1][1]*b[2] - (*this)[0][0]*(*this)[2][1]*b[1]
    │ │ │ │ -
    983 - (*this)[1][0] *(*this)[0][1]*b[2] + (*this)[1][0]*(*this)[2][1]*b[0]
    │ │ │ │ -
    984 + (*this)[2][0] *(*this)[0][1]*b[1] - (*this)[2][0]*(*this)[1][1]*b[0]) / d;
    │ │ │ │ -
    985
    │ │ │ │ -
    986 }
    │ │ │ │ -
    987 else {
    │ │ │ │ -
    988
    │ │ │ │ -
    989 V1& rhs = x; // use x to store rhs
    │ │ │ │ -
    990 rhs = b; // copy data
    │ │ │ │ -
    991 Elim<V1> elim(rhs);
    │ │ │ │ -
    992 AutonomousValue<MAT> A(asImp());
    │ │ │ │ -
    993 Simd::Mask<typename FieldTraits<value_type>::real_type>
    │ │ │ │ -
    994 nonsingularLanes(true);
    │ │ │ │ -
    995
    │ │ │ │ -
    996 AutonomousValue<MAT>::luDecomposition(A, elim, nonsingularLanes, true, doPivoting);
    │ │ │ │ -
    997
    │ │ │ │ -
    998 // backsolve
    │ │ │ │ -
    999 for(int i=rows()-1; i>=0; i--) {
    │ │ │ │ -
    1000 for (size_type j=i+1; j<rows(); j++)
    │ │ │ │ -
    1001 rhs[i] -= A[i][j]*x[j];
    │ │ │ │ -
    1002 x[i] = rhs[i]/A[i][i];
    │ │ │ │ -
    1003 }
    │ │ │ │ -
    1004 }
    │ │ │ │ -
    1005 }
    │ │ │ │ -
    1006
    │ │ │ │ -
    1007 template<typename MAT>
    │ │ │ │ -
    1008 inline void DenseMatrix<MAT>::invert(bool doPivoting)
    │ │ │ │ -
    1009 {
    │ │ │ │ -
    1010 using real_type = typename FieldTraits<MAT>::real_type;
    │ │ │ │ -
    1011 using std::swap;
    │ │ │ │ -
    1012
    │ │ │ │ -
    1013 // never mind those ifs, because they get optimized away
    │ │ │ │ -
    1014 if (rows()!=cols())
    │ │ │ │ -
    1015 DUNE_THROW(FMatrixError, "Can't invert a " << rows() << "x" << cols() << " matrix!");
    │ │ │ │ -
    1016
    │ │ │ │ -
    1017 if (rows()==1) {
    │ │ │ │ -
    1018
    │ │ │ │ -
    1019#ifdef DUNE_FMatrix_WITH_CHECKING
    │ │ │ │ -
    1020 if (Simd::anyTrue(fvmeta::absreal((*this)[0][0])
    │ │ │ │ - │ │ │ │ -
    1022 DUNE_THROW(FMatrixError,"matrix is singular");
    │ │ │ │ -
    1023#endif
    │ │ │ │ -
    1024 (*this)[0][0] = real_type( 1 ) / (*this)[0][0];
    │ │ │ │ -
    1025
    │ │ │ │ -
    1026 }
    │ │ │ │ -
    1027 else if (rows()==2) {
    │ │ │ │ -
    1028
    │ │ │ │ -
    1029 field_type detinv = (*this)[0][0]*(*this)[1][1]-(*this)[0][1]*(*this)[1][0];
    │ │ │ │ -
    1030#ifdef DUNE_FMatrix_WITH_CHECKING
    │ │ │ │ -
    1031 if (Simd::anyTrue(fvmeta::absreal(detinv)
    │ │ │ │ - │ │ │ │ -
    1033 DUNE_THROW(FMatrixError,"matrix is singular");
    │ │ │ │ -
    1034#endif
    │ │ │ │ -
    1035 detinv = real_type( 1 ) / detinv;
    │ │ │ │ -
    1036
    │ │ │ │ -
    1037 field_type temp=(*this)[0][0];
    │ │ │ │ -
    1038 (*this)[0][0] = (*this)[1][1]*detinv;
    │ │ │ │ -
    1039 (*this)[0][1] = -(*this)[0][1]*detinv;
    │ │ │ │ -
    1040 (*this)[1][0] = -(*this)[1][0]*detinv;
    │ │ │ │ -
    1041 (*this)[1][1] = temp*detinv;
    │ │ │ │ -
    1042
    │ │ │ │ -
    1043 }
    │ │ │ │ -
    1044 else if (rows()==3)
    │ │ │ │ -
    1045 {
    │ │ │ │ -
    1046 using K = field_type;
    │ │ │ │ -
    1047 // code generated by maple
    │ │ │ │ -
    1048 K t4 = (*this)[0][0] * (*this)[1][1];
    │ │ │ │ -
    1049 K t6 = (*this)[0][0] * (*this)[1][2];
    │ │ │ │ -
    1050 K t8 = (*this)[0][1] * (*this)[1][0];
    │ │ │ │ -
    1051 K t10 = (*this)[0][2] * (*this)[1][0];
    │ │ │ │ -
    1052 K t12 = (*this)[0][1] * (*this)[2][0];
    │ │ │ │ -
    1053 K t14 = (*this)[0][2] * (*this)[2][0];
    │ │ │ │ -
    1054
    │ │ │ │ -
    1055 K det = (t4*(*this)[2][2]-t6*(*this)[2][1]-t8*(*this)[2][2]+
    │ │ │ │ -
    1056 t10*(*this)[2][1]+t12*(*this)[1][2]-t14*(*this)[1][1]);
    │ │ │ │ -
    1057 K t17 = K(1.0)/det;
    │ │ │ │ -
    1058
    │ │ │ │ -
    1059 K matrix01 = (*this)[0][1];
    │ │ │ │ -
    1060 K matrix00 = (*this)[0][0];
    │ │ │ │ -
    1061 K matrix10 = (*this)[1][0];
    │ │ │ │ -
    1062 K matrix11 = (*this)[1][1];
    │ │ │ │ -
    1063
    │ │ │ │ -
    1064 (*this)[0][0] = ((*this)[1][1] * (*this)[2][2] - (*this)[1][2] * (*this)[2][1])*t17;
    │ │ │ │ -
    1065 (*this)[0][1] = -((*this)[0][1] * (*this)[2][2] - (*this)[0][2] * (*this)[2][1])*t17;
    │ │ │ │ -
    1066 (*this)[0][2] = (matrix01 * (*this)[1][2] - (*this)[0][2] * (*this)[1][1])*t17;
    │ │ │ │ -
    1067 (*this)[1][0] = -((*this)[1][0] * (*this)[2][2] - (*this)[1][2] * (*this)[2][0])*t17;
    │ │ │ │ -
    1068 (*this)[1][1] = (matrix00 * (*this)[2][2] - t14) * t17;
    │ │ │ │ -
    1069 (*this)[1][2] = -(t6-t10) * t17;
    │ │ │ │ -
    1070 (*this)[2][0] = (matrix10 * (*this)[2][1] - matrix11 * (*this)[2][0]) * t17;
    │ │ │ │ -
    1071 (*this)[2][1] = -(matrix00 * (*this)[2][1] - t12) * t17;
    │ │ │ │ -
    1072 (*this)[2][2] = (t4-t8) * t17;
    │ │ │ │ -
    1073 }
    │ │ │ │ -
    1074 else {
    │ │ │ │ -
    1075 using std::swap;
    │ │ │ │ -
    1076
    │ │ │ │ -
    1077 AutonomousValue<MAT> A(asImp());
    │ │ │ │ -
    1078 std::vector<simd_index_type> pivot(rows());
    │ │ │ │ -
    1079 Simd::Mask<typename FieldTraits<value_type>::real_type>
    │ │ │ │ -
    1080 nonsingularLanes(true);
    │ │ │ │ -
    1081 AutonomousValue<MAT>::luDecomposition(A, ElimPivot(pivot), nonsingularLanes, true, doPivoting);
    │ │ │ │ -
    1082 auto& L=A;
    │ │ │ │ -
    1083 auto& U=A;
    │ │ │ │ -
    1084
    │ │ │ │ -
    1085 // initialize inverse
    │ │ │ │ -
    1086 *this=field_type();
    │ │ │ │ -
    1087
    │ │ │ │ -
    1088 for(size_type i=0; i<rows(); ++i)
    │ │ │ │ -
    1089 (*this)[i][i]=1;
    │ │ │ │ -
    1090
    │ │ │ │ -
    1091 // L Y = I; multiple right hand sides
    │ │ │ │ -
    1092 for (size_type i=0; i<rows(); i++)
    │ │ │ │ -
    1093 for (size_type j=0; j<i; j++)
    │ │ │ │ -
    1094 for (size_type k=0; k<rows(); k++)
    │ │ │ │ -
    1095 (*this)[i][k] -= L[i][j]*(*this)[j][k];
    │ │ │ │ -
    1096
    │ │ │ │ -
    1097 // U A^{-1} = Y
    │ │ │ │ -
    1098 for (size_type i=rows(); i>0;) {
    │ │ │ │ -
    1099 --i;
    │ │ │ │ -
    1100 for (size_type k=0; k<rows(); k++) {
    │ │ │ │ -
    1101 for (size_type j=i+1; j<rows(); j++)
    │ │ │ │ -
    1102 (*this)[i][k] -= U[i][j]*(*this)[j][k];
    │ │ │ │ -
    1103 (*this)[i][k] /= U[i][i];
    │ │ │ │ -
    1104 }
    │ │ │ │ -
    1105 }
    │ │ │ │ -
    1106
    │ │ │ │ -
    1107 for(size_type i=rows(); i>0; ) {
    │ │ │ │ -
    1108 --i;
    │ │ │ │ -
    1109 for(std::size_t l = 0; l < Simd::lanes((*this)[0][0]); ++l)
    │ │ │ │ -
    1110 {
    │ │ │ │ -
    1111 std::size_t pi = Simd::lane(l, pivot[i]);
    │ │ │ │ -
    1112 if(i!=pi)
    │ │ │ │ -
    1113 for(size_type j=0; j<rows(); ++j)
    │ │ │ │ -
    1114 swap(Simd::lane(l, (*this)[j][pi]),
    │ │ │ │ -
    1115 Simd::lane(l, (*this)[j][ i]));
    │ │ │ │ -
    1116 }
    │ │ │ │ -
    1117 }
    │ │ │ │ -
    1118 }
    │ │ │ │ -
    1119 }
    │ │ │ │ -
    1120
    │ │ │ │ -
    1121 // implementation of the determinant
    │ │ │ │ -
    1122 template<typename MAT>
    │ │ │ │ -
    1123 inline typename DenseMatrix<MAT>::field_type
    │ │ │ │ -
    1124 DenseMatrix<MAT>::determinant(bool doPivoting) const
    │ │ │ │ -
    1125 {
    │ │ │ │ -
    1126 // never mind those ifs, because they get optimized away
    │ │ │ │ -
    1127 if (rows()!=cols())
    │ │ │ │ -
    1128 DUNE_THROW(FMatrixError, "There is no determinant for a " << rows() << "x" << cols() << " matrix!");
    │ │ │ │ -
    1129
    │ │ │ │ -
    1130 if (rows()==1)
    │ │ │ │ -
    1131 return (*this)[0][0];
    │ │ │ │ -
    1132
    │ │ │ │ -
    1133 if (rows()==2)
    │ │ │ │ -
    1134 return (*this)[0][0]*(*this)[1][1] - (*this)[0][1]*(*this)[1][0];
    │ │ │ │ -
    1135
    │ │ │ │ -
    1136 if (rows()==3) {
    │ │ │ │ -
    1137 // code generated by maple
    │ │ │ │ -
    1138 field_type t4 = (*this)[0][0] * (*this)[1][1];
    │ │ │ │ -
    1139 field_type t6 = (*this)[0][0] * (*this)[1][2];
    │ │ │ │ -
    1140 field_type t8 = (*this)[0][1] * (*this)[1][0];
    │ │ │ │ -
    1141 field_type t10 = (*this)[0][2] * (*this)[1][0];
    │ │ │ │ -
    1142 field_type t12 = (*this)[0][1] * (*this)[2][0];
    │ │ │ │ -
    1143 field_type t14 = (*this)[0][2] * (*this)[2][0];
    │ │ │ │ -
    1144
    │ │ │ │ -
    1145 return (t4*(*this)[2][2]-t6*(*this)[2][1]-t8*(*this)[2][2]+
    │ │ │ │ -
    1146 t10*(*this)[2][1]+t12*(*this)[1][2]-t14*(*this)[1][1]);
    │ │ │ │ -
    1147
    │ │ │ │ -
    1148 }
    │ │ │ │ -
    1149
    │ │ │ │ -
    1150 AutonomousValue<MAT> A(asImp());
    │ │ │ │ -
    1151 field_type det;
    │ │ │ │ -
    1152 Simd::Mask<typename FieldTraits<value_type>::real_type>
    │ │ │ │ -
    1153 nonsingularLanes(true);
    │ │ │ │ -
    1154
    │ │ │ │ -
    1155 AutonomousValue<MAT>::luDecomposition(A, ElimDet(det), nonsingularLanes, false, doPivoting);
    │ │ │ │ -
    1156 det = Simd::cond(nonsingularLanes, det, field_type(0));
    │ │ │ │ -
    1157
    │ │ │ │ -
    1158 for (size_type i = 0; i < rows(); ++i)
    │ │ │ │ -
    1159 det *= A[i][i];
    │ │ │ │ -
    1160 return det;
    │ │ │ │ -
    1161 }
    │ │ │ │ -
    1162
    │ │ │ │ -
    1163#endif // DOXYGEN
    │ │ │ │ -
    1164
    │ │ │ │ -
    │ │ │ │ -
    1165 namespace DenseMatrixHelp {
    │ │ │ │ -
    1166
    │ │ │ │ -
    1168 template <typename MAT, typename V1, typename V2>
    │ │ │ │ -
    │ │ │ │ -
    1169 static inline void multAssign(const DenseMatrix<MAT> &matrix, const DenseVector<V1> & x, DenseVector<V2> & ret)
    │ │ │ │ -
    1170 {
    │ │ │ │ -
    1171 DUNE_ASSERT_BOUNDS(x.size() == matrix.cols());
    │ │ │ │ -
    1172 DUNE_ASSERT_BOUNDS(ret.size() == matrix.rows());
    │ │ │ │ -
    1173 typedef typename DenseMatrix<MAT>::size_type size_type;
    │ │ │ │ -
    1174
    │ │ │ │ -
    1175 for(size_type i=0; i<matrix.rows(); ++i)
    │ │ │ │ -
    1176 {
    │ │ │ │ -
    1177 ret[i] = 0.0;
    │ │ │ │ -
    1178 for(size_type j=0; j<matrix.cols(); ++j)
    │ │ │ │ -
    1179 {
    │ │ │ │ -
    1180 ret[i] += matrix[i][j]*x[j];
    │ │ │ │ -
    1181 }
    │ │ │ │ -
    1182 }
    │ │ │ │ -
    1183 }
    │ │ │ │ -
    │ │ │ │ -
    1184
    │ │ │ │ -
    1185#if 0
    │ │ │ │ -
    1187 template <typename K, int rows, int cols>
    │ │ │ │ -
    1188 static inline void multAssignTransposed( const FieldMatrix<K,rows,cols> &matrix, const FieldVector<K,rows> & x, FieldVector<K,cols> & ret)
    │ │ │ │ -
    1189 {
    │ │ │ │ -
    1190 typedef typename FieldMatrix<K,rows,cols>::size_type size_type;
    │ │ │ │ -
    1191
    │ │ │ │ -
    1192 for(size_type i=0; i<cols(); ++i)
    │ │ │ │ -
    1193 {
    │ │ │ │ -
    1194 ret[i] = 0.0;
    │ │ │ │ -
    1195 for(size_type j=0; j<rows(); ++j)
    │ │ │ │ -
    1196 ret[i] += matrix[j][i]*x[j];
    │ │ │ │ -
    1197 }
    │ │ │ │ -
    1198 }
    │ │ │ │ -
    1199
    │ │ │ │ -
    1201 template <typename K, int rows, int cols>
    │ │ │ │ -
    1202 static inline FieldVector<K,rows> mult(const FieldMatrix<K,rows,cols> &matrix, const FieldVector<K,cols> & x)
    │ │ │ │ -
    1203 {
    │ │ │ │ -
    1204 FieldVector<K,rows> ret;
    │ │ │ │ -
    1205 multAssign(matrix,x,ret);
    │ │ │ │ -
    1206 return ret;
    │ │ │ │ -
    1207 }
    │ │ │ │ -
    1208
    │ │ │ │ -
    1210 template <typename K, int rows, int cols>
    │ │ │ │ -
    1211 static inline FieldVector<K,cols> multTransposed(const FieldMatrix<K,rows,cols> &matrix, const FieldVector<K,rows> & x)
    │ │ │ │ -
    1212 {
    │ │ │ │ -
    1213 FieldVector<K,cols> ret;
    │ │ │ │ -
    1214 multAssignTransposed( matrix, x, ret );
    │ │ │ │ -
    1215 return ret;
    │ │ │ │ -
    1216 }
    │ │ │ │ -
    1217#endif
    │ │ │ │ -
    1218
    │ │ │ │ -
    1219 } // end namespace DenseMatrixHelp
    │ │ │ │ -
    │ │ │ │ -
    1220
    │ │ │ │ -
    1222 template<typename MAT>
    │ │ │ │ -
    │ │ │ │ -
    1223 std::ostream& operator<< (std::ostream& s, const DenseMatrix<MAT>& a)
    │ │ │ │ -
    1224 {
    │ │ │ │ -
    1225 for (typename DenseMatrix<MAT>::size_type i=0; i<a.rows(); i++)
    │ │ │ │ -
    1226 s << a[i] << std::endl;
    │ │ │ │ -
    1227 return s;
    │ │ │ │ -
    1228 }
    │ │ │ │ -
    │ │ │ │ -
    1229
    │ │ │ │ -
    1232} // end namespace Dune
    │ │ │ │ -
    1233
    │ │ │ │ -
    1234#endif
    │ │ │ │ -
    Traits for type conversions and type information.
    │ │ │ │ -
    Implements a scalar vector view wrapper around an existing scalar.
    │ │ │ │ -
    A free function to provide the demangled class name of a given object or type as a string.
    │ │ │ │ -
    A few common exception classes.
    │ │ │ │ -
    Various precision settings for calculations with FieldMatrix and FieldVector.
    │ │ │ │ -
    Implements a vector constructed from a given type representing a field and a compile-time given size.
    │ │ │ │ -
    Some useful basic math stuff.
    │ │ │ │ -
    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
    │ │ │ │ -
    typename AutonomousValueType< T >::type AutonomousValue
    Type free of internal references that T can be converted to.
    Definition typetraits.hh:558
    │ │ │ │ -
    std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x)
    Definition bigunsignedint.hh:278
    │ │ │ │ -
    #define DUNE_THROW(E, m)
    Definition exceptions.hh:218
    │ │ │ │ -
    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
    │ │ │ │ -
    typename Overloads::RebindType< std::decay_t< S >, std::decay_t< V > >::type Rebind
    Construct SIMD type with different scalar type.
    Definition simd/interface.hh:253
    │ │ │ │ -
    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
    │ │ │ │ -
    Mask< V > mask(ADLTag< 0, std::is_same< V, Mask< V > >::value >, const V &v)
    implements Simd::mask()
    Definition defaults.hh:153
    │ │ │ │ +
    106
    │ │ │ │ +
    107#endif // DUNE_COMMON_REFERENCE_HELPER_HH
    │ │ │ │ +
    constexpr bool IsReferenceWrapper_v
    Helper to detect if given type is a std::reference_wrapper.
    Definition referencehelper.hh:35
    │ │ │ │ +
    constexpr T & resolveRef(T &gf) noexcept
    Helper function to resolve std::reference_wrapper.
    Definition referencehelper.hh:47
    │ │ │ │
    STL namespace.
    │ │ │ │
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ -
    void swap(T &v1, T &v2, bool mask)
    Definition simd.hh:472
    │ │ │ │ -
    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
    │ │ │ │ -
    static void multAssign(const DenseMatrix< MAT > &matrix, const DenseVector< V1 > &x, DenseVector< V2 > &ret)
    calculates ret = matrix * x
    Definition densematrix.hh:1169
    │ │ │ │ -
    A dense n x m matrix.
    Definition densematrix.hh:140
    │ │ │ │ -
    ConstIterator const_iterator
    typedef for stl compliant access
    Definition densematrix.hh:244
    │ │ │ │ -
    derived_type operator-() const
    Matrix negation.
    Definition densematrix.hh:298
    │ │ │ │ -
    void solve(V1 &x, const V2 &b, bool doPivoting=true) const
    Solve system A x = b.
    │ │ │ │ -
    void mv(const X &x, Y &y) const
    y = A x
    Definition densematrix.hh:368
    │ │ │ │ -
    Traits::value_type field_type
    export the type representing the field
    Definition densematrix.hh:160
    │ │ │ │ -
    derived_type & axpy(const field_type &a, const DenseMatrix< Other > &x)
    vector space axpy operation (*this += a x)
    Definition densematrix.hh:338
    │ │ │ │ -
    ConstIterator beforeEnd() const
    Definition densematrix.hh:264
    │ │ │ │ -
    derived_type & operator=(const RHS &rhs)
    Definition densematrix.hh:279
    │ │ │ │ -
    void mmtv(const X &x, Y &y) const
    y -= A^T x
    Definition densematrix.hh:458
    │ │ │ │ -
    FieldTraits< vt >::real_type infinity_norm_real() const
    simplified infinity norm (uses Manhattan norm for complex values)
    Definition densematrix.hh:561
    │ │ │ │ -
    std::remove_reference< const_row_reference >::type::ConstIterator ConstColIterator
    rename the iterators for easier access
    Definition densematrix.hh:248
    │ │ │ │ -
    ConstIterator beforeBegin() const
    Definition densematrix.hh:271
    │ │ │ │ -
    void invert(bool doPivoting=true)
    Compute inverse.
    │ │ │ │ -
    static void luDecomposition(DenseMatrix< MAT > &A, Func func, Mask &nonsingularLanes, bool throwEarly, bool doPivoting)
    do an LU-Decomposition on matrix A
    │ │ │ │ -
    Traits::value_type block_type
    export the type representing the components
    Definition densematrix.hh:163
    │ │ │ │ -
    void mtv(const X &x, Y &y) const
    y = A^T x
    Definition densematrix.hh:387
    │ │ │ │ -
    constexpr size_type cols() const
    number of columns
    Definition densematrix.hh:715
    │ │ │ │ -
    size_type size() const
    size method (number of rows)
    Definition densematrix.hh:200
    │ │ │ │ -
    constexpr size_type M() const
    number of columns
    Definition densematrix.hh:703
    │ │ │ │ -
    MAT & rightmultiply(const DenseMatrix< M2 > &M)
    Multiplies M from the right to this matrix.
    Definition densematrix.hh:645
    │ │ │ │ -
    Iterator end()
    end iterator
    Definition densematrix.hh:222
    │ │ │ │ -
    Iterator beforeBegin()
    Definition densematrix.hh:236
    │ │ │ │ -
    derived_type & operator/=(const field_type &k)
    vector space division by scalar
    Definition densematrix.hh:329
    │ │ │ │ -
    derived_type & operator*=(const field_type &k)
    vector space multiplication with scalar
    Definition densematrix.hh:321
    │ │ │ │ -
    Iterator beforeEnd()
    Definition densematrix.hh:229
    │ │ │ │ -
    Traits::value_type value_type
    export the type representing the field
    Definition densematrix.hh:157
    │ │ │ │ -
    void usmv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) const
    y += alpha A x
    Definition densematrix.hh:484
    │ │ │ │ -
    void usmhv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) const
    y += alpha A^H x
    Definition densematrix.hh:512
    │ │ │ │ -
    void mmv(const X &x, Y &y) const
    y -= A x
    Definition densematrix.hh:445
    │ │ │ │ -
    constexpr size_type rows() const
    number of rows
    Definition densematrix.hh:709
    │ │ │ │ -
    MAT & leftmultiply(const DenseMatrix< M2 > &M)
    Multiplies M from the left to this matrix.
    Definition densematrix.hh:627
    │ │ │ │ -
    void usmtv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) const
    y += alpha A^T x
    Definition densematrix.hh:498
    │ │ │ │ -
    derived_type & operator-=(const DenseMatrix< Other > &x)
    vector space subtraction
    Definition densematrix.hh:312
    │ │ │ │ -
    bool operator!=(const DenseMatrix< Other > &x) const
    Binary matrix incomparison.
    Definition densematrix.hh:358
    │ │ │ │ -
    void mmhv(const X &x, Y &y) const
    y -= A^H x
    Definition densematrix.hh:471
    │ │ │ │ -
    Traits::derived_type derived_type
    type of derived matrix class
    Definition densematrix.hh:154
    │ │ │ │ -
    row_reference operator[](size_type i)
    random access
    Definition densematrix.hh:189
    │ │ │ │ -
    bool exists(size_type i, size_type j) const
    return true when (i,j) is in pattern
    Definition densematrix.hh:723
    │ │ │ │ -
    Iterator RowIterator
    rename the iterators for easier access
    Definition densematrix.hh:211
    │ │ │ │ -
    static constexpr int blocklevel
    The number of block levels we contain. This is the leaf, that is, 1.
    Definition densematrix.hh:178
    │ │ │ │ -
    FieldTraits< value_type >::real_type frobenius_norm() const
    frobenius norm: sqrt(sum over squared values of entries)
    Definition densematrix.hh:528
    │ │ │ │ -
    void umv(const X &x, Y &y) const
    y += A x
    Definition densematrix.hh:406
    │ │ │ │ -
    DenseIterator< const DenseMatrix, const row_type, const_row_reference > ConstIterator
    Iterator class for sequential access.
    Definition densematrix.hh:242
    │ │ │ │ -
    FieldTraits< vt >::real_type infinity_norm() const
    infinity norm (row sum norm, how to generalize for blocks?)
    Definition densematrix.hh:546
    │ │ │ │ -
    Traits::row_type row_type
    The type used to represent a row (must fulfill the Dune::DenseVector interface)
    Definition densematrix.hh:169
    │ │ │ │ -
    constexpr size_type N() const
    number of rows
    Definition densematrix.hh:697
    │ │ │ │ -
    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
    │ │ │ │ -
    FieldTraits< value_type >::real_type frobenius_norm2() const
    square of frobenius norm, need for block recursion
    Definition densematrix.hh:536
    │ │ │ │ -
    std::remove_reference< row_reference >::type::Iterator ColIterator
    rename the iterators for easier access
    Definition densematrix.hh:213
    │ │ │ │ -
    Traits::row_reference row_reference
    The type used to represent a reference to a row (usually row_type &)
    Definition densematrix.hh:172
    │ │ │ │ -
    bool operator==(const DenseMatrix< Other > &x) const
    Binary matrix comparison.
    Definition densematrix.hh:348
    │ │ │ │ -
    Iterator iterator
    typedef for stl compliant access
    Definition densematrix.hh:209
    │ │ │ │ -
    ConstIterator ConstRowIterator
    rename the iterators for easier access
    Definition densematrix.hh:246
    │ │ │ │ -
    DenseIterator< DenseMatrix, row_type, row_reference > Iterator
    Iterator class for sequential access.
    Definition densematrix.hh:207
    │ │ │ │ -
    void umtv(const X &x, Y &y) const
    y += A^T x
    Definition densematrix.hh:419
    │ │ │ │ -
    ConstIterator begin() const
    begin iterator
    Definition densematrix.hh:251
    │ │ │ │ -
    field_type determinant(bool doPivoting=true) const
    calculates the determinant of this matrix
    │ │ │ │ -
    Iterator begin()
    begin iterator
    Definition densematrix.hh:216
    │ │ │ │ -
    void umhv(const X &x, Y &y) const
    y += A^H x
    Definition densematrix.hh:432
    │ │ │ │ -
    derived_type & operator+=(const DenseMatrix< Other > &x)
    vector space addition
    Definition densematrix.hh:289
    │ │ │ │ -
    ConstIterator end() const
    end iterator
    Definition densematrix.hh:257
    │ │ │ │ -
    const FieldTraits< typenameDenseMatVecTraits< M >::value_type >::real_type real_type
    Definition densematrix.hh:34
    │ │ │ │ -
    const FieldTraits< typenameDenseMatVecTraits< M >::value_type >::field_type field_type
    Definition densematrix.hh:33
    │ │ │ │ -
    A dense n x m matrix.
    Definition fmatrix.hh:117
    │ │ │ │ -
    Base::size_type size_type
    Definition fmatrix.hh:127
    │ │ │ │ -
    vector space out of a tensor product of fields.
    Definition fvector.hh:95
    │ │ │ │ -
    you have to specialize this structure for any type that should be assignable to a DenseMatrix
    Definition densematrix.hh:59
    │ │ │ │ -
    Error thrown if operations of a FieldMatrix fail.
    Definition densematrix.hh:126
    │ │ │ │ -
    Interface for a class of dense vectors over a given field.
    Definition densevector.hh:229
    │ │ │ │ -
    size_type size() const
    size method
    Definition densevector.hh:336
    │ │ │ │ -
    Generic iterator class for dense vector and matrix implementations.
    Definition densevector.hh:131
    │ │ │ │ -
    Default exception class for mathematical errors.
    Definition exceptions.hh:241
    │ │ │ │ -
    Definition ftraits.hh:26
    │ │ │ │ -
    T field_type
    export the type representing the field
    Definition ftraits.hh:28
    │ │ │ │ -
    T real_type
    export the type representing the real type of the field
    Definition ftraits.hh:30
    │ │ │ │ -
    Definition matvectraits.hh:31
    │ │ │ │ -
    static ctype absolute_limit()
    return threshold to declare matrix singular
    Definition precision.hh:28
    │ │ │ │ -
    Include file for users of the SIMD abstraction layer.
    │ │ │ │ +
    std::remove_reference_t< decltype(Dune::resolveRef(std::declval< T & >()))> ResolveRef_t
    Type trait to resolve std::reference_wrapper.
    Definition referencehelper.hh:100
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,1526 +7,100 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -densematrix.hh │ │ │ │ │ +referencehelper.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 (C) 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_DENSEMATRIX_HH │ │ │ │ │ - 6#define DUNE_DENSEMATRIX_HH │ │ │ │ │ + 5#ifndef DUNE_COMMON_REFERENCE_HELPER_HH │ │ │ │ │ + 6#define DUNE_COMMON_REFERENCE_HELPER_HH │ │ │ │ │ 7 │ │ │ │ │ - 8#include │ │ │ │ │ - 9#include │ │ │ │ │ - 10#include │ │ │ │ │ - 11#include │ │ │ │ │ - 12#include │ │ │ │ │ - 13#include │ │ │ │ │ + 8#include │ │ │ │ │ + 9#include │ │ │ │ │ + 10 │ │ │ │ │ + 11 │ │ │ │ │ + 12 │ │ │ │ │ + 13namespace Dune { │ │ │ │ │ 14 │ │ │ │ │ - 15#include │ │ │ │ │ - 16#include │ │ │ │ │ - 17#include │ │ │ │ │ - 18#include │ │ │ │ │ - 19#include │ │ │ │ │ - 20#include │ │ │ │ │ - 21#include │ │ │ │ │ - 22#include │ │ │ │ │ - 23#include │ │ │ │ │ - 24 │ │ │ │ │ - 25namespace Dune │ │ │ │ │ - 26{ │ │ │ │ │ + 15namespace Impl { │ │ │ │ │ + 16 │ │ │ │ │ + 17 template │ │ │ │ │ + 18 class IsReferenceWrapper : public std::false_type {}; │ │ │ │ │ + 19 │ │ │ │ │ + 20 template │ │ │ │ │ + 21 class IsReferenceWrapper> : public std::true_type │ │ │ │ │ +{}; │ │ │ │ │ + 22 │ │ │ │ │ + 23 template │ │ │ │ │ + 24 class IsReferenceWrapper> : public std:: │ │ │ │ │ +true_type {}; │ │ │ │ │ + 25 │ │ │ │ │ + 26} // namespace Dune::Impl │ │ │ │ │ 27 │ │ │ │ │ - 28 template class DenseMatrix; │ │ │ │ │ - 29 │ │ │ │ │ - 30 template │ │ │ │ │ -31 struct FieldTraits< DenseMatrix > │ │ │ │ │ - 32 { │ │ │ │ │ -33 typedef const typename FieldTraits<_typename_DenseMatVecTraits:: │ │ │ │ │ -value_type >::field_type field_type; │ │ │ │ │ -34 typedef const typename FieldTraits<_typename_DenseMatVecTraits:: │ │ │ │ │ -value_type >::real_type real_type; │ │ │ │ │ - 35 }; │ │ │ │ │ + 28 │ │ │ │ │ + 34template │ │ │ │ │ +35constexpr bool IsReferenceWrapper_v = Impl::IsReferenceWrapper::value; │ │ │ │ │ 36 │ │ │ │ │ - 37 template class FieldMatrix; │ │ │ │ │ - 38 template class FieldVector; │ │ │ │ │ - 39 │ │ │ │ │ - 58 template< class DenseMatrix, class RHS > │ │ │ │ │ -59 struct DenseMatrixAssigner; │ │ │ │ │ - 60 │ │ │ │ │ - 61#ifndef DOXYGEN │ │ │ │ │ - 62 namespace Impl │ │ │ │ │ - 63 { │ │ │ │ │ - 64 │ │ │ │ │ - 65 template< class DenseMatrix, class RHS, class = void > │ │ │ │ │ - 66 class DenseMatrixAssigner │ │ │ │ │ - 67 {}; │ │ │ │ │ - 68 │ │ │ │ │ - 69 template< class DenseMatrix, class RHS > │ │ │ │ │ - 70 class DenseMatrixAssigner< DenseMatrix, RHS, std::enable_if_t< Dune:: │ │ │ │ │ -IsNumber< RHS >::value > > │ │ │ │ │ - 71 { │ │ │ │ │ - 72 public: │ │ │ │ │ - 73 static void apply ( DenseMatrix &denseMatrix, const RHS &rhs ) │ │ │ │ │ - 74 { │ │ │ │ │ - 75 typedef typename DenseMatrix::field_type field_type; │ │ │ │ │ - 76 std::fill( denseMatrix.begin(), denseMatrix.end(), static_cast< field_type │ │ │ │ │ ->( rhs ) ); │ │ │ │ │ - 77 } │ │ │ │ │ - 78 }; │ │ │ │ │ - 79 │ │ │ │ │ - 80 template< class DenseMatrix, class RHS > │ │ │ │ │ - 81 class DenseMatrixAssigner< DenseMatrix, RHS, std::enable_if_t< !std:: │ │ │ │ │ -is_same< typename RHS::const_iterator, void >::value │ │ │ │ │ - 82 && std::is_convertible< typename RHS::const_iterator::value_type, typename │ │ │ │ │ -DenseMatrix::iterator::value_type >::value > > │ │ │ │ │ - 83 { │ │ │ │ │ - 84 public: │ │ │ │ │ - 85 static void apply ( DenseMatrix &denseMatrix, const RHS &rhs ) │ │ │ │ │ - 86 { │ │ │ │ │ - 87 DUNE_ASSERT_BOUNDS(rhs.N() == denseMatrix.N()); │ │ │ │ │ - 88 DUNE_ASSERT_BOUNDS(rhs.M() == denseMatrix.M()); │ │ │ │ │ - 89 typename DenseMatrix::iterator tIt = std::begin(denseMatrix); │ │ │ │ │ - 90 typename RHS::const_iterator sIt = std::begin(rhs); │ │ │ │ │ - 91 for(; sIt != std::end(rhs); ++tIt, ++sIt) │ │ │ │ │ - 92 std::copy(std::begin(*sIt), std::end(*sIt), std::begin(*tIt)); │ │ │ │ │ - 93 } │ │ │ │ │ - 94 }; │ │ │ │ │ - 95 │ │ │ │ │ - 96 } // namespace Impl │ │ │ │ │ - 97 │ │ │ │ │ - 98 │ │ │ │ │ - 99 │ │ │ │ │ - 100 template< class DenseMatrix, class RHS > │ │ │ │ │ - 101 struct DenseMatrixAssigner │ │ │ │ │ - 102 : public Impl::DenseMatrixAssigner< DenseMatrix, RHS > │ │ │ │ │ - 103 {}; │ │ │ │ │ + 37 │ │ │ │ │ + 46template │ │ │ │ │ +47constexpr T& resolveRef(T& gf) noexcept │ │ │ │ │ + 48{ │ │ │ │ │ + 49 return gf; │ │ │ │ │ + 50} │ │ │ │ │ + 51 │ │ │ │ │ + 52 │ │ │ │ │ + 53// There's no overload for non std::reference_wrapper r-values, │ │ │ │ │ + 54// because this may lead to undefined behavior whenever the │ │ │ │ │ + 55// return value is stored. │ │ │ │ │ + 56// Notice that deleting the overload is not necessary, but │ │ │ │ │ + 57// helps to document that it is missing on purpose. It also │ │ │ │ │ + 58// leads to nicer error messages. │ │ │ │ │ + 59template │ │ │ │ │ +60const auto& resolveRef(T&& gf) = delete; │ │ │ │ │ + 61 │ │ │ │ │ + 62 │ │ │ │ │ + 81template │ │ │ │ │ +82constexpr T& resolveRef(std::reference_wrapper gf) noexcept │ │ │ │ │ + 83{ │ │ │ │ │ + 84 return gf.get(); │ │ │ │ │ + 85} │ │ │ │ │ + 86 │ │ │ │ │ + 87 │ │ │ │ │ + 88 │ │ │ │ │ + 99template │ │ │ │ │ +100using ResolveRef_t = std::remove_reference_t()))>; │ │ │ │ │ + 101 │ │ │ │ │ + 102 │ │ │ │ │ + 103} // namespace Dune │ │ │ │ │ 104 │ │ │ │ │ 105 │ │ │ │ │ - 106 namespace Impl │ │ │ │ │ - 107 { │ │ │ │ │ - 108 │ │ │ │ │ - 109 template< class DenseMatrix, class RHS > │ │ │ │ │ - 110 std::true_type hasDenseMatrixAssigner ( DenseMatrix &, const RHS &, │ │ │ │ │ -decltype( Dune::DenseMatrixAssigner<_DenseMatrix,_RHS_>::apply( std::declval< │ │ │ │ │ -DenseMatrix & >(), std::declval< const RHS & >() ) ) * = nullptr ); │ │ │ │ │ - 111 │ │ │ │ │ - 112 std::false_type hasDenseMatrixAssigner ( ... ); │ │ │ │ │ - 113 │ │ │ │ │ - 114 } // namespace Impl │ │ │ │ │ - 115 │ │ │ │ │ - 116 template< class DenseMatrix, class RHS > │ │ │ │ │ - 117 struct HasDenseMatrixAssigner │ │ │ │ │ - 118 : public decltype( Impl::hasDenseMatrixAssigner( std::declval< DenseMatrix │ │ │ │ │ -& >(), std::declval< const RHS & >() ) ) │ │ │ │ │ - 119 {}; │ │ │ │ │ - 120 │ │ │ │ │ - 121#endif // #ifndef DOXYGEN │ │ │ │ │ - 122 │ │ │ │ │ - 123 │ │ │ │ │ - 124 │ │ │ │ │ -126 class FMatrixError : public MathError {}; │ │ │ │ │ - 127 │ │ │ │ │ - 138 template │ │ │ │ │ -139 class DenseMatrix │ │ │ │ │ - 140 { │ │ │ │ │ - 141 typedef DenseMatVecTraits Traits; │ │ │ │ │ - 142 │ │ │ │ │ - 143 // Curiously recurring template pattern │ │ │ │ │ - 144 constexpr MAT & asImp() { return static_cast(*this); } │ │ │ │ │ - 145 constexpr const MAT & asImp() const { return static_cast │ │ │ │ │ -(*this); } │ │ │ │ │ - 146 │ │ │ │ │ - 147 template │ │ │ │ │ -148 friend class DenseMatrix; │ │ │ │ │ - 149 │ │ │ │ │ - 150 public: │ │ │ │ │ - 151 //===== type definitions and constants │ │ │ │ │ - 152 │ │ │ │ │ -154 typedef typename Traits::derived_type derived_type; │ │ │ │ │ - 155 │ │ │ │ │ -157 typedef typename Traits::value_type value_type; │ │ │ │ │ - 158 │ │ │ │ │ -160 typedef typename Traits::value_type field_type; │ │ │ │ │ - 161 │ │ │ │ │ -163 typedef typename Traits::value_type block_type; │ │ │ │ │ - 164 │ │ │ │ │ -166 typedef typename Traits::size_type size_type; │ │ │ │ │ - 167 │ │ │ │ │ -169 typedef typename Traits::row_type row_type; │ │ │ │ │ - 170 │ │ │ │ │ -172 typedef typename Traits::row_reference row_reference; │ │ │ │ │ - 173 │ │ │ │ │ -175 typedef typename Traits::const_row_reference const_row_reference; │ │ │ │ │ - 176 │ │ │ │ │ -178 constexpr static int blocklevel = 1; │ │ │ │ │ - 179 │ │ │ │ │ - 180 private: │ │ │ │ │ - 183 using simd_index_type = Simd::Rebind; │ │ │ │ │ - 184 │ │ │ │ │ - 185 public: │ │ │ │ │ - 186 //===== access to components │ │ │ │ │ - 187 │ │ │ │ │ -189 row_reference operator[]( size_type i ) │ │ │ │ │ - 190 { │ │ │ │ │ - 191 return asImp().mat_access(i); │ │ │ │ │ - 192 } │ │ │ │ │ - 193 │ │ │ │ │ -194 const_row_reference operator[]( size_type i ) const │ │ │ │ │ - 195 { │ │ │ │ │ - 196 return asImp().mat_access(i); │ │ │ │ │ - 197 } │ │ │ │ │ - 198 │ │ │ │ │ -200 size_type size() const │ │ │ │ │ - 201 { │ │ │ │ │ - 202 return rows(); │ │ │ │ │ - 203 } │ │ │ │ │ - 204 │ │ │ │ │ - 205 //===== iterator interface to rows of the matrix │ │ │ │ │ -207 typedef DenseIterator Iterator; │ │ │ │ │ -209 typedef Iterator iterator; │ │ │ │ │ -211 typedef Iterator RowIterator; │ │ │ │ │ -213 typedef typename std::remove_reference::type::Iterator │ │ │ │ │ -ColIterator; │ │ │ │ │ - 214 │ │ │ │ │ -216 Iterator begin () │ │ │ │ │ - 217 { │ │ │ │ │ - 218 return Iterator(*this,0); │ │ │ │ │ - 219 } │ │ │ │ │ - 220 │ │ │ │ │ -222 Iterator end () │ │ │ │ │ - 223 { │ │ │ │ │ - 224 return Iterator(*this,rows()); │ │ │ │ │ - 225 } │ │ │ │ │ - 226 │ │ │ │ │ -229 Iterator beforeEnd () │ │ │ │ │ - 230 { │ │ │ │ │ - 231 return Iterator(*this,rows()-1); │ │ │ │ │ - 232 } │ │ │ │ │ - 233 │ │ │ │ │ -236 Iterator beforeBegin () │ │ │ │ │ - 237 { │ │ │ │ │ - 238 return Iterator(*this,-1); │ │ │ │ │ - 239 } │ │ │ │ │ - 240 │ │ │ │ │ -242 typedef DenseIterator │ │ │ │ │ -ConstIterator; │ │ │ │ │ -244 typedef ConstIterator const_iterator; │ │ │ │ │ -246 typedef ConstIterator ConstRowIterator; │ │ │ │ │ -248 typedef typename std::remove_reference::type:: │ │ │ │ │ -ConstIterator ConstColIterator; │ │ │ │ │ - 249 │ │ │ │ │ -251 ConstIterator begin () const │ │ │ │ │ - 252 { │ │ │ │ │ - 253 return ConstIterator(*this,0); │ │ │ │ │ - 254 } │ │ │ │ │ - 255 │ │ │ │ │ -257 ConstIterator end () const │ │ │ │ │ - 258 { │ │ │ │ │ - 259 return ConstIterator(*this,rows()); │ │ │ │ │ - 260 } │ │ │ │ │ - 261 │ │ │ │ │ -264 ConstIterator beforeEnd () const │ │ │ │ │ - 265 { │ │ │ │ │ - 266 return ConstIterator(*this,rows()-1); │ │ │ │ │ - 267 } │ │ │ │ │ - 268 │ │ │ │ │ -271 ConstIterator beforeBegin () const │ │ │ │ │ - 272 { │ │ │ │ │ - 273 return ConstIterator(*this,-1); │ │ │ │ │ - 274 } │ │ │ │ │ - 275 │ │ │ │ │ - 276 //===== assignment │ │ │ │ │ - 277 │ │ │ │ │ - 278 template< class RHS, class = std::enable_if_t< HasDenseMatrixAssigner< │ │ │ │ │ -MAT, RHS >::value > > │ │ │ │ │ -279 derived_type &operator=( const RHS &rhs ) │ │ │ │ │ - 280 { │ │ │ │ │ - 281 DenseMatrixAssigner<_MAT,_RHS_>::apply( asImp(), rhs ); │ │ │ │ │ - 282 return asImp(); │ │ │ │ │ - 283 } │ │ │ │ │ - 284 │ │ │ │ │ - 285 //===== vector space arithmetic │ │ │ │ │ - 286 │ │ │ │ │ - 288 template │ │ │ │ │ -289 derived_type &operator+=(const DenseMatrix& x) │ │ │ │ │ - 290 { │ │ │ │ │ - 291 DUNE_ASSERT_BOUNDS(rows() == x.rows()); │ │ │ │ │ - 292 for (size_type i=0; i │ │ │ │ │ -312 derived_type &operator-=(const DenseMatrix& x) │ │ │ │ │ - 313 { │ │ │ │ │ - 314 DUNE_ASSERT_BOUNDS(rows() == x.rows()); │ │ │ │ │ - 315 for (size_type i=0; i │ │ │ │ │ -338 derived_type &axpy (const field_type &a, const DenseMatrix &x ) │ │ │ │ │ - 339 { │ │ │ │ │ - 340 DUNE_ASSERT_BOUNDS(rows() == x.rows()); │ │ │ │ │ - 341 for( size_type i = 0; i < rows(); ++i ) │ │ │ │ │ - 342 (*this)[ i ].axpy( a, x[ i ] ); │ │ │ │ │ - 343 return asImp(); │ │ │ │ │ - 344 } │ │ │ │ │ - 345 │ │ │ │ │ - 347 template │ │ │ │ │ -348 bool operator==(const DenseMatrix& x) const │ │ │ │ │ - 349 { │ │ │ │ │ - 350 DUNE_ASSERT_BOUNDS(rows() == x.rows()); │ │ │ │ │ - 351 for (size_type i=0; i │ │ │ │ │ -358 bool operator!=(const DenseMatrix& x) const │ │ │ │ │ - 359 { │ │ │ │ │ - 360 return !operator==(x); │ │ │ │ │ - 361 } │ │ │ │ │ - 362 │ │ │ │ │ - 363 │ │ │ │ │ - 364 //===== linear maps │ │ │ │ │ - 365 │ │ │ │ │ - 367 template │ │ │ │ │ -368 void mv (const X& x, Y& y) const │ │ │ │ │ - 369 { │ │ │ │ │ - 370 auto&& xx = Impl::asVector(x); │ │ │ │ │ - 371 auto&& yy = Impl::asVector(y); │ │ │ │ │ - 372 DUNE_ASSERT_BOUNDS((void*)(&x) != (void*)(&y)); │ │ │ │ │ - 373 DUNE_ASSERT_BOUNDS(xx.N() == M()); │ │ │ │ │ - 374 DUNE_ASSERT_BOUNDS(yy.N() == N()); │ │ │ │ │ - 375 │ │ │ │ │ - 376 using y_field_type = typename FieldTraits::field_type; │ │ │ │ │ - 377 for (size_type i=0; i │ │ │ │ │ -387 void mtv ( const X &x, Y &y ) const │ │ │ │ │ - 388 { │ │ │ │ │ - 389 auto&& xx = Impl::asVector(x); │ │ │ │ │ - 390 auto&& yy = Impl::asVector(y); │ │ │ │ │ - 391 DUNE_ASSERT_BOUNDS((void*)(&x) != (void*)(&y)); │ │ │ │ │ - 392 DUNE_ASSERT_BOUNDS(xx.N() == N()); │ │ │ │ │ - 393 DUNE_ASSERT_BOUNDS(yy.N() == M()); │ │ │ │ │ - 394 │ │ │ │ │ - 395 using y_field_type = typename FieldTraits::field_type; │ │ │ │ │ - 396 for(size_type i = 0; i < cols(); ++i) │ │ │ │ │ - 397 { │ │ │ │ │ - 398 yy[i] = y_field_type(0); │ │ │ │ │ - 399 for(size_type j = 0; j < rows(); ++j) │ │ │ │ │ - 400 yy[i] += (*this)[j][i] * xx[j]; │ │ │ │ │ - 401 } │ │ │ │ │ - 402 } │ │ │ │ │ - 403 │ │ │ │ │ - 405 template │ │ │ │ │ -406 void umv (const X& x, Y& y) const │ │ │ │ │ - 407 { │ │ │ │ │ - 408 auto&& xx = Impl::asVector(x); │ │ │ │ │ - 409 auto&& yy = Impl::asVector(y); │ │ │ │ │ - 410 DUNE_ASSERT_BOUNDS(xx.N() == M()); │ │ │ │ │ - 411 DUNE_ASSERT_BOUNDS(yy.N() == N()); │ │ │ │ │ - 412 for (size_type i=0; i │ │ │ │ │ -419 void umtv (const X& x, Y& y) const │ │ │ │ │ - 420 { │ │ │ │ │ - 421 auto&& xx = Impl::asVector(x); │ │ │ │ │ - 422 auto&& yy = Impl::asVector(y); │ │ │ │ │ - 423 DUNE_ASSERT_BOUNDS(xx.N() == N()); │ │ │ │ │ - 424 DUNE_ASSERT_BOUNDS(yy.N() == M()); │ │ │ │ │ - 425 for(size_type i = 0; i │ │ │ │ │ -432 void umhv (const X& x, Y& y) const │ │ │ │ │ - 433 { │ │ │ │ │ - 434 auto&& xx = Impl::asVector(x); │ │ │ │ │ - 435 auto&& yy = Impl::asVector(y); │ │ │ │ │ - 436 DUNE_ASSERT_BOUNDS(xx.N() == N()); │ │ │ │ │ - 437 DUNE_ASSERT_BOUNDS(yy.N() == M()); │ │ │ │ │ - 438 for (size_type i=0; i │ │ │ │ │ -445 void mmv (const X& x, Y& y) const │ │ │ │ │ - 446 { │ │ │ │ │ - 447 auto&& xx = Impl::asVector(x); │ │ │ │ │ - 448 auto&& yy = Impl::asVector(y); │ │ │ │ │ - 449 DUNE_ASSERT_BOUNDS(xx.N() == M()); │ │ │ │ │ - 450 DUNE_ASSERT_BOUNDS(yy.N() == N()); │ │ │ │ │ - 451 for (size_type i=0; i │ │ │ │ │ -458 void mmtv (const X& x, Y& y) const │ │ │ │ │ - 459 { │ │ │ │ │ - 460 auto&& xx = Impl::asVector(x); │ │ │ │ │ - 461 auto&& yy = Impl::asVector(y); │ │ │ │ │ - 462 DUNE_ASSERT_BOUNDS(xx.N() == N()); │ │ │ │ │ - 463 DUNE_ASSERT_BOUNDS(yy.N() == M()); │ │ │ │ │ - 464 for (size_type i=0; i │ │ │ │ │ -471 void mmhv (const X& x, Y& y) const │ │ │ │ │ - 472 { │ │ │ │ │ - 473 auto&& xx = Impl::asVector(x); │ │ │ │ │ - 474 auto&& yy = Impl::asVector(y); │ │ │ │ │ - 475 DUNE_ASSERT_BOUNDS(xx.N() == N()); │ │ │ │ │ - 476 DUNE_ASSERT_BOUNDS(yy.N() == M()); │ │ │ │ │ - 477 for (size_type i=0; i │ │ │ │ │ -484 void usmv (const typename FieldTraits::field_type & alpha, │ │ │ │ │ - 485 const X& x, Y& y) const │ │ │ │ │ - 486 { │ │ │ │ │ - 487 auto&& xx = Impl::asVector(x); │ │ │ │ │ - 488 auto&& yy = Impl::asVector(y); │ │ │ │ │ - 489 DUNE_ASSERT_BOUNDS(xx.N() == M()); │ │ │ │ │ - 490 DUNE_ASSERT_BOUNDS(yy.N() == N()); │ │ │ │ │ - 491 for (size_type i=0; i │ │ │ │ │ -498 void usmtv (const typename FieldTraits::field_type & alpha, │ │ │ │ │ - 499 const X& x, Y& y) const │ │ │ │ │ - 500 { │ │ │ │ │ - 501 auto&& xx = Impl::asVector(x); │ │ │ │ │ - 502 auto&& yy = Impl::asVector(y); │ │ │ │ │ - 503 DUNE_ASSERT_BOUNDS(xx.N() == N()); │ │ │ │ │ - 504 DUNE_ASSERT_BOUNDS(yy.N() == M()); │ │ │ │ │ - 505 for (size_type i=0; i │ │ │ │ │ -512 void usmhv (const typename FieldTraits::field_type & alpha, │ │ │ │ │ - 513 const X& x, Y& y) const │ │ │ │ │ - 514 { │ │ │ │ │ - 515 auto&& xx = Impl::asVector(x); │ │ │ │ │ - 516 auto&& yy = Impl::asVector(y); │ │ │ │ │ - 517 DUNE_ASSERT_BOUNDS(xx.N() == N()); │ │ │ │ │ - 518 DUNE_ASSERT_BOUNDS(yy.N() == M()); │ │ │ │ │ - 519 for (size_type i=0; i::real_type frobenius_norm () const │ │ │ │ │ - 529 { │ │ │ │ │ - 530 typename FieldTraits::real_type sum=(0.0); │ │ │ │ │ - 531 for (size_type i=0; i::real_type frobenius_norm2 () const │ │ │ │ │ - 537 { │ │ │ │ │ - 538 typename FieldTraits::real_type sum=(0.0); │ │ │ │ │ - 539 for (size_type i=0; i::value, int>::type = 0> │ │ │ │ │ -546 typename FieldTraits::real_type infinity_norm() const { │ │ │ │ │ - 547 using real_type = typename FieldTraits::real_type; │ │ │ │ │ - 548 using std::max; │ │ │ │ │ - 549 │ │ │ │ │ - 550 real_type norm = 0; │ │ │ │ │ - 551 for (auto const &x : *this) { │ │ │ │ │ - 552 real_type const a = x.one_norm(); │ │ │ │ │ - 553 norm = max(a, norm); │ │ │ │ │ - 554 } │ │ │ │ │ - 555 return norm; │ │ │ │ │ - 556 } │ │ │ │ │ - 557 │ │ │ │ │ - 559 template ::value, int>::type = 0> │ │ │ │ │ -561 typename FieldTraits::real_type infinity_norm_real() const { │ │ │ │ │ - 562 using real_type = typename FieldTraits::real_type; │ │ │ │ │ - 563 using std::max; │ │ │ │ │ - 564 │ │ │ │ │ - 565 real_type norm = 0; │ │ │ │ │ - 566 for (auto const &x : *this) { │ │ │ │ │ - 567 real_type const a = x.one_norm_real(); │ │ │ │ │ - 568 norm = max(a, norm); │ │ │ │ │ - 569 } │ │ │ │ │ - 570 return norm; │ │ │ │ │ - 571 } │ │ │ │ │ - 572 │ │ │ │ │ - 574 template ::value, int>::type = 0> │ │ │ │ │ -576 typename FieldTraits::real_type infinity_norm() const { │ │ │ │ │ - 577 using real_type = typename FieldTraits::real_type; │ │ │ │ │ - 578 using std::max; │ │ │ │ │ - 579 │ │ │ │ │ - 580 real_type norm = 0; │ │ │ │ │ - 581 real_type isNaN = 1; │ │ │ │ │ - 582 for (auto const &x : *this) { │ │ │ │ │ - 583 real_type const a = x.one_norm(); │ │ │ │ │ - 584 norm = max(a, norm); │ │ │ │ │ - 585 isNaN += a; │ │ │ │ │ - 586 } │ │ │ │ │ - 587 return norm * (isNaN / isNaN); │ │ │ │ │ - 588 } │ │ │ │ │ - 589 │ │ │ │ │ - 591 template ::value, int>::type = 0> │ │ │ │ │ -593 typename FieldTraits::real_type infinity_norm_real() const { │ │ │ │ │ - 594 using real_type = typename FieldTraits::real_type; │ │ │ │ │ - 595 using std::max; │ │ │ │ │ - 596 │ │ │ │ │ - 597 real_type norm = 0; │ │ │ │ │ - 598 real_type isNaN = 1; │ │ │ │ │ - 599 for (auto const &x : *this) { │ │ │ │ │ - 600 real_type const a = x.one_norm_real(); │ │ │ │ │ - 601 norm = max(a, norm); │ │ │ │ │ - 602 isNaN += a; │ │ │ │ │ - 603 } │ │ │ │ │ - 604 return norm * (isNaN / isNaN); │ │ │ │ │ - 605 } │ │ │ │ │ - 606 │ │ │ │ │ - 607 //===== solve │ │ │ │ │ - 608 │ │ │ │ │ - 613 template │ │ │ │ │ -614 void solve (V1& x, const V2& b, bool doPivoting = true) const; │ │ │ │ │ - 615 │ │ │ │ │ -620 void invert(bool doPivoting = true); │ │ │ │ │ - 621 │ │ │ │ │ -623 field_type determinant (bool doPivoting = true) const; │ │ │ │ │ - 624 │ │ │ │ │ - 626 template │ │ │ │ │ -627 MAT& leftmultiply (const DenseMatrix& M) │ │ │ │ │ - 628 { │ │ │ │ │ - 629 DUNE_ASSERT_BOUNDS(M.rows() == M.cols()); │ │ │ │ │ - 630 DUNE_ASSERT_BOUNDS(M.rows() == rows()); │ │ │ │ │ - 631 AutonomousValue C(asImp()); │ │ │ │ │ - 632 │ │ │ │ │ - 633 for (size_type i=0; i │ │ │ │ │ -645 MAT& rightmultiply (const DenseMatrix& M) │ │ │ │ │ - 646 { │ │ │ │ │ - 647 DUNE_ASSERT_BOUNDS(M.rows() == M.cols()); │ │ │ │ │ - 648 DUNE_ASSERT_BOUNDS(M.cols() == cols()); │ │ │ │ │ - 649 AutonomousValue C(asImp()); │ │ │ │ │ - 650 │ │ │ │ │ - 651 for (size_type i=0; i │ │ │ │ │ - 663 DenseMatrix leftmultiplyany (const FieldMatrix& M) │ │ │ │ │ -const │ │ │ │ │ - 664 { │ │ │ │ │ - 665 FieldMatrix C; │ │ │ │ │ - 666 │ │ │ │ │ - 667 for (size_type i=0; i │ │ │ │ │ - 679 FieldMatrix rightmultiplyany (const FieldMatrix& M) │ │ │ │ │ -const │ │ │ │ │ - 680 { │ │ │ │ │ - 681 FieldMatrix C; │ │ │ │ │ - 682 │ │ │ │ │ - 683 for (size_type i=0; i= 0 && i < rows()); │ │ │ │ │ - 726 DUNE_ASSERT_BOUNDS(j >= 0 && j < cols()); │ │ │ │ │ - 727 return true; │ │ │ │ │ - 728 } │ │ │ │ │ - 729 │ │ │ │ │ - 730 protected: │ │ │ │ │ - 731 │ │ │ │ │ - 732#ifndef DOXYGEN │ │ │ │ │ - 733 struct ElimPivot │ │ │ │ │ - 734 { │ │ │ │ │ - 735 ElimPivot(std::vector & pivot); │ │ │ │ │ - 736 │ │ │ │ │ - 737 void swap(std::size_t i, simd_index_type j); │ │ │ │ │ - 738 │ │ │ │ │ - 739 template │ │ │ │ │ - 740 void operator()(const T&, int, int) │ │ │ │ │ - 741 {} │ │ │ │ │ - 742 │ │ │ │ │ - 743 std::vector & pivot_; │ │ │ │ │ - 744 }; │ │ │ │ │ - 745 │ │ │ │ │ - 746 template │ │ │ │ │ - 747 struct Elim │ │ │ │ │ - 748 { │ │ │ │ │ - 749 Elim(V& rhs); │ │ │ │ │ - 750 │ │ │ │ │ - 751 void swap(std::size_t i, simd_index_type j); │ │ │ │ │ - 752 │ │ │ │ │ - 753 void operator()(const typename V::field_type& factor, int k, int i); │ │ │ │ │ - 754 │ │ │ │ │ - 755 V* rhs_; │ │ │ │ │ - 756 }; │ │ │ │ │ - 757 │ │ │ │ │ - 758 struct ElimDet │ │ │ │ │ - 759 { │ │ │ │ │ - 760 ElimDet(field_type& sign) : sign_(sign) │ │ │ │ │ - 761 { sign_ = 1; } │ │ │ │ │ - 762 │ │ │ │ │ - 763 void swap(std::size_t i, simd_index_type j) │ │ │ │ │ - 764 { │ │ │ │ │ - 765 sign_ *= │ │ │ │ │ - 766 Simd::cond(simd_index_type(i) == j, field_type(1), field_type(-1)); │ │ │ │ │ - 767 } │ │ │ │ │ - 768 │ │ │ │ │ - 769 void operator()(const field_type&, int, int) │ │ │ │ │ - 770 {} │ │ │ │ │ - 771 │ │ │ │ │ - 772 field_type& sign_; │ │ │ │ │ - 773 }; │ │ │ │ │ - 774#endif // DOXYGEN │ │ │ │ │ - 775 │ │ │ │ │ - 777 │ │ │ │ │ - 815 template │ │ │ │ │ -816 static void luDecomposition(DenseMatrix& A, Func func, │ │ │ │ │ - 817 Mask &nonsingularLanes, bool throwEarly, bool doPivoting); │ │ │ │ │ - 818 }; │ │ │ │ │ - 819 │ │ │ │ │ - 820#ifndef DOXYGEN │ │ │ │ │ - 821 template │ │ │ │ │ - 822 DenseMatrix::ElimPivot::ElimPivot(std::vector & │ │ │ │ │ -pivot) │ │ │ │ │ - 823 : pivot_(pivot) │ │ │ │ │ - 824 { │ │ │ │ │ - 825 typedef typename std::vector::size_type size_type; │ │ │ │ │ - 826 for(size_type i=0; i < pivot_.size(); ++i) pivot_[i]=i; │ │ │ │ │ - 827 } │ │ │ │ │ - 828 │ │ │ │ │ - 829 template │ │ │ │ │ - 830 void DenseMatrix::ElimPivot::swap(std::size_t i, simd_index_type j) │ │ │ │ │ - 831 { │ │ │ │ │ - 832 pivot_[i] = │ │ │ │ │ - 833 Simd::cond(Simd::Scalar(i) == j, pivot_[i], j); │ │ │ │ │ - 834 } │ │ │ │ │ - 835 │ │ │ │ │ - 836 template │ │ │ │ │ - 837 template │ │ │ │ │ - 838 DenseMatrix::Elim::Elim(V& rhs) │ │ │ │ │ - 839 : rhs_(&rhs) │ │ │ │ │ - 840 {} │ │ │ │ │ - 841 │ │ │ │ │ - 842 template │ │ │ │ │ - 843 template │ │ │ │ │ - 844 void DenseMatrix::Elim::swap(std::size_t i, simd_index_type j) │ │ │ │ │ - 845 { │ │ │ │ │ - 846 using std::swap; │ │ │ │ │ - 847 │ │ │ │ │ - 848 // see the comment in luDecomposition() │ │ │ │ │ - 849 for(std::size_t l = 0; l < Simd::lanes(j); ++l) │ │ │ │ │ - 850 swap(Simd::lane(l, (*rhs_)[ i ]), │ │ │ │ │ - 851 Simd::lane(l, (*rhs_)[Simd::lane(l, j)])); │ │ │ │ │ - 852 } │ │ │ │ │ - 853 │ │ │ │ │ - 854 template │ │ │ │ │ - 855 template │ │ │ │ │ - 856 void DenseMatrix:: │ │ │ │ │ - 857 Elim::operator()(const typename V::field_type& factor, int k, int i) │ │ │ │ │ - 858 { │ │ │ │ │ - 859 (*rhs_)[k] -= factor*(*rhs_)[i]; │ │ │ │ │ - 860 } │ │ │ │ │ - 861 │ │ │ │ │ - 862 template │ │ │ │ │ - 863 template │ │ │ │ │ - 864 inline void DenseMatrix:: │ │ │ │ │ - 865luDecomposition(DenseMatrix& A, Func func, Mask &nonsingularLanes, │ │ │ │ │ - 866 bool throwEarly, bool doPivoting) │ │ │ │ │ - 867 { │ │ │ │ │ - 868 using std::max; │ │ │ │ │ - 869 using std::swap; │ │ │ │ │ - 870 │ │ │ │ │ - 871 typedef typename FieldTraits::real_type real_type; │ │ │ │ │ - 872 │ │ │ │ │ - 873 // LU decomposition of A in A │ │ │ │ │ - 874 for (size_type i=0; i pivmax; │ │ │ │ │ - 886 pivmax = Simd::cond(mask, abs, pivmax); │ │ │ │ │ - 887 imax = Simd::cond(mask, simd_index_type(k), imax); │ │ │ │ │ - 888 } │ │ │ │ │ - 889 // swap rows │ │ │ │ │ - 890 for (size_type j=0; j │ │ │ │ │ - 933 template │ │ │ │ │ - 934 inline void DenseMatrix::solve(V1& x, const V2& b, bool doPivoting) │ │ │ │ │ -const │ │ │ │ │ - 935 { │ │ │ │ │ - 936 using real_type = typename FieldTraits::real_type; │ │ │ │ │ - 937 // never mind those ifs, because they get optimized away │ │ │ │ │ - 938 if (rows()!=cols()) │ │ │ │ │ - 939 DUNE_THROW(FMatrixError, "Can't solve for a " << rows() << "x" << cols() │ │ │ │ │ -<< " matrix!"); │ │ │ │ │ - 940 │ │ │ │ │ - 941 if (rows()==1) { │ │ │ │ │ - 942 │ │ │ │ │ - 943#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ - 944 if (Simd::anyTrue(fvmeta::absreal((*this)[0][0]) │ │ │ │ │ - 945 < FMatrixPrecision<>::absolute_limit())) │ │ │ │ │ - 946 DUNE_THROW(FMatrixError,"matrix is singular"); │ │ │ │ │ - 947#endif │ │ │ │ │ - 948 x[0] = b[0]/(*this)[0][0]; │ │ │ │ │ - 949 │ │ │ │ │ - 950 } │ │ │ │ │ - 951 else if (rows()==2) { │ │ │ │ │ - 952 │ │ │ │ │ - 953 field_type detinv = (*this)[0][0]*(*this)[1][1]-(*this)[0][1]*(*this)[1] │ │ │ │ │ -[0]; │ │ │ │ │ - 954#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ - 955 if (Simd::anyTrue(fvmeta::absreal(detinv) │ │ │ │ │ - 956 < FMatrixPrecision<>::absolute_limit())) │ │ │ │ │ - 957 DUNE_THROW(FMatrixError,"matrix is singular"); │ │ │ │ │ - 958#endif │ │ │ │ │ - 959 detinv = real_type(1.0)/detinv; │ │ │ │ │ - 960 │ │ │ │ │ - 961 x[0] = detinv*((*this)[1][1]*b[0]-(*this)[0][1]*b[1]); │ │ │ │ │ - 962 x[1] = detinv*((*this)[0][0]*b[1]-(*this)[1][0]*b[0]); │ │ │ │ │ - 963 │ │ │ │ │ - 964 } │ │ │ │ │ - 965 else if (rows()==3) { │ │ │ │ │ - 966 │ │ │ │ │ - 967 field_type d = determinant(doPivoting); │ │ │ │ │ - 968#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ - 969 if (Simd::anyTrue(fvmeta::absreal(d) │ │ │ │ │ - 970 < FMatrixPrecision<>::absolute_limit())) │ │ │ │ │ - 971 DUNE_THROW(FMatrixError,"matrix is singular"); │ │ │ │ │ - 972#endif │ │ │ │ │ - 973 │ │ │ │ │ - 974 x[0] = (b[0]*(*this)[1][1]*(*this)[2][2] - b[0]*(*this)[2][1]*(*this)[1] │ │ │ │ │ -[2] │ │ │ │ │ - 975 - b[1] *(*this)[0][1]*(*this)[2][2] + b[1]*(*this)[2][1]*(*this)[0][2] │ │ │ │ │ - 976 + b[2] *(*this)[0][1]*(*this)[1][2] - b[2]*(*this)[1][1]*(*this)[0][2]) / │ │ │ │ │ -d; │ │ │ │ │ - 977 │ │ │ │ │ - 978 x[1] = ((*this)[0][0]*b[1]*(*this)[2][2] - (*this)[0][0]*b[2]*(*this)[1] │ │ │ │ │ -[2] │ │ │ │ │ - 979 - (*this)[1][0] *b[0]*(*this)[2][2] + (*this)[1][0]*b[2]*(*this)[0][2] │ │ │ │ │ - 980 + (*this)[2][0] *b[0]*(*this)[1][2] - (*this)[2][0]*b[1]*(*this)[0][2]) / │ │ │ │ │ -d; │ │ │ │ │ - 981 │ │ │ │ │ - 982 x[2] = ((*this)[0][0]*(*this)[1][1]*b[2] - (*this)[0][0]*(*this)[2][1]*b │ │ │ │ │ -[1] │ │ │ │ │ - 983 - (*this)[1][0] *(*this)[0][1]*b[2] + (*this)[1][0]*(*this)[2][1]*b[0] │ │ │ │ │ - 984 + (*this)[2][0] *(*this)[0][1]*b[1] - (*this)[2][0]*(*this)[1][1]*b[0]) / │ │ │ │ │ -d; │ │ │ │ │ - 985 │ │ │ │ │ - 986 } │ │ │ │ │ - 987 else { │ │ │ │ │ - 988 │ │ │ │ │ - 989 V1& rhs = x; // use x to store rhs │ │ │ │ │ - 990 rhs = b; // copy data │ │ │ │ │ - 991 Elim elim(rhs); │ │ │ │ │ - 992 AutonomousValue A(asImp()); │ │ │ │ │ - 993 Simd::Mask::real_type> │ │ │ │ │ - 994 nonsingularLanes(true); │ │ │ │ │ - 995 │ │ │ │ │ - 996 AutonomousValue::luDecomposition(A, elim, nonsingularLanes, true, │ │ │ │ │ -doPivoting); │ │ │ │ │ - 997 │ │ │ │ │ - 998 // backsolve │ │ │ │ │ - 999 for(int i=rows()-1; i>=0; i--) { │ │ │ │ │ - 1000 for (size_type j=i+1; j │ │ │ │ │ - 1008 inline void DenseMatrix::invert(bool doPivoting) │ │ │ │ │ - 1009 { │ │ │ │ │ - 1010 using real_type = typename FieldTraits::real_type; │ │ │ │ │ - 1011 using std::swap; │ │ │ │ │ - 1012 │ │ │ │ │ - 1013 // never mind those ifs, because they get optimized away │ │ │ │ │ - 1014 if (rows()!=cols()) │ │ │ │ │ - 1015 DUNE_THROW(FMatrixError, "Can't invert a " << rows() << "x" << cols() << │ │ │ │ │ -" matrix!"); │ │ │ │ │ - 1016 │ │ │ │ │ - 1017 if (rows()==1) { │ │ │ │ │ - 1018 │ │ │ │ │ - 1019#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ - 1020 if (Simd::anyTrue(fvmeta::absreal((*this)[0][0]) │ │ │ │ │ - 1021 < FMatrixPrecision<>::absolute_limit())) │ │ │ │ │ - 1022 DUNE_THROW(FMatrixError,"matrix is singular"); │ │ │ │ │ - 1023#endif │ │ │ │ │ - 1024 (*this)[0][0] = real_type( 1 ) / (*this)[0][0]; │ │ │ │ │ - 1025 │ │ │ │ │ - 1026 } │ │ │ │ │ - 1027 else if (rows()==2) { │ │ │ │ │ - 1028 │ │ │ │ │ - 1029 field_type detinv = (*this)[0][0]*(*this)[1][1]-(*this)[0][1]*(*this)[1] │ │ │ │ │ -[0]; │ │ │ │ │ - 1030#ifdef DUNE_FMatrix_WITH_CHECKING │ │ │ │ │ - 1031 if (Simd::anyTrue(fvmeta::absreal(detinv) │ │ │ │ │ - 1032 < FMatrixPrecision<>::absolute_limit())) │ │ │ │ │ - 1033 DUNE_THROW(FMatrixError,"matrix is singular"); │ │ │ │ │ - 1034#endif │ │ │ │ │ - 1035 detinv = real_type( 1 ) / detinv; │ │ │ │ │ - 1036 │ │ │ │ │ - 1037 field_type temp=(*this)[0][0]; │ │ │ │ │ - 1038 (*this)[0][0] = (*this)[1][1]*detinv; │ │ │ │ │ - 1039 (*this)[0][1] = -(*this)[0][1]*detinv; │ │ │ │ │ - 1040 (*this)[1][0] = -(*this)[1][0]*detinv; │ │ │ │ │ - 1041 (*this)[1][1] = temp*detinv; │ │ │ │ │ - 1042 │ │ │ │ │ - 1043 } │ │ │ │ │ - 1044 else if (rows()==3) │ │ │ │ │ - 1045 { │ │ │ │ │ - 1046 using K = field_type; │ │ │ │ │ - 1047 // code generated by maple │ │ │ │ │ - 1048 K t4 = (*this)[0][0] * (*this)[1][1]; │ │ │ │ │ - 1049 K t6 = (*this)[0][0] * (*this)[1][2]; │ │ │ │ │ - 1050 K t8 = (*this)[0][1] * (*this)[1][0]; │ │ │ │ │ - 1051 K t10 = (*this)[0][2] * (*this)[1][0]; │ │ │ │ │ - 1052 K t12 = (*this)[0][1] * (*this)[2][0]; │ │ │ │ │ - 1053 K t14 = (*this)[0][2] * (*this)[2][0]; │ │ │ │ │ - 1054 │ │ │ │ │ - 1055 K det = (t4*(*this)[2][2]-t6*(*this)[2][1]-t8*(*this)[2][2]+ │ │ │ │ │ - 1056 t10*(*this)[2][1]+t12*(*this)[1][2]-t14*(*this)[1][1]); │ │ │ │ │ - 1057 K t17 = K(1.0)/det; │ │ │ │ │ - 1058 │ │ │ │ │ - 1059 K matrix01 = (*this)[0][1]; │ │ │ │ │ - 1060 K matrix00 = (*this)[0][0]; │ │ │ │ │ - 1061 K matrix10 = (*this)[1][0]; │ │ │ │ │ - 1062 K matrix11 = (*this)[1][1]; │ │ │ │ │ - 1063 │ │ │ │ │ - 1064 (*this)[0][0] = ((*this)[1][1] * (*this)[2][2] - (*this)[1][2] * (*this) │ │ │ │ │ -[2][1])*t17; │ │ │ │ │ - 1065 (*this)[0][1] = -((*this)[0][1] * (*this)[2][2] - (*this)[0][2] * (*this) │ │ │ │ │ -[2][1])*t17; │ │ │ │ │ - 1066 (*this)[0][2] = (matrix01 * (*this)[1][2] - (*this)[0][2] * (*this)[1] │ │ │ │ │ -[1])*t17; │ │ │ │ │ - 1067 (*this)[1][0] = -((*this)[1][0] * (*this)[2][2] - (*this)[1][2] * (*this) │ │ │ │ │ -[2][0])*t17; │ │ │ │ │ - 1068 (*this)[1][1] = (matrix00 * (*this)[2][2] - t14) * t17; │ │ │ │ │ - 1069 (*this)[1][2] = -(t6-t10) * t17; │ │ │ │ │ - 1070 (*this)[2][0] = (matrix10 * (*this)[2][1] - matrix11 * (*this)[2][0]) * │ │ │ │ │ -t17; │ │ │ │ │ - 1071 (*this)[2][1] = -(matrix00 * (*this)[2][1] - t12) * t17; │ │ │ │ │ - 1072 (*this)[2][2] = (t4-t8) * t17; │ │ │ │ │ - 1073 } │ │ │ │ │ - 1074 else { │ │ │ │ │ - 1075 using std::swap; │ │ │ │ │ - 1076 │ │ │ │ │ - 1077 AutonomousValue A(asImp()); │ │ │ │ │ - 1078 std::vector pivot(rows()); │ │ │ │ │ - 1079 Simd::Mask::real_type> │ │ │ │ │ - 1080 nonsingularLanes(true); │ │ │ │ │ - 1081 AutonomousValue::luDecomposition(A, ElimPivot(pivot), │ │ │ │ │ -nonsingularLanes, true, doPivoting); │ │ │ │ │ - 1082 auto& L=A; │ │ │ │ │ - 1083 auto& U=A; │ │ │ │ │ - 1084 │ │ │ │ │ - 1085 // initialize inverse │ │ │ │ │ - 1086 *this=field_type(); │ │ │ │ │ - 1087 │ │ │ │ │ - 1088 for(size_type i=0; i0;) { │ │ │ │ │ - 1099 --i; │ │ │ │ │ - 1100 for (size_type k=0; k0; ) { │ │ │ │ │ - 1108 --i; │ │ │ │ │ - 1109 for(std::size_t l = 0; l < Simd::lanes((*this)[0][0]); ++l) │ │ │ │ │ - 1110 { │ │ │ │ │ - 1111 std::size_t pi = Simd::lane(l, pivot[i]); │ │ │ │ │ - 1112 if(i!=pi) │ │ │ │ │ - 1113 for(size_type j=0; j │ │ │ │ │ - 1123 inline typename DenseMatrix::field_type │ │ │ │ │ - 1124 DenseMatrix::determinant(bool doPivoting) const │ │ │ │ │ - 1125 { │ │ │ │ │ - 1126 // never mind those ifs, because they get optimized away │ │ │ │ │ - 1127 if (rows()!=cols()) │ │ │ │ │ - 1128 DUNE_THROW(FMatrixError, "There is no determinant for a " << rows() << │ │ │ │ │ -"x" << cols() << " matrix!"); │ │ │ │ │ - 1129 │ │ │ │ │ - 1130 if (rows()==1) │ │ │ │ │ - 1131 return (*this)[0][0]; │ │ │ │ │ - 1132 │ │ │ │ │ - 1133 if (rows()==2) │ │ │ │ │ - 1134 return (*this)[0][0]*(*this)[1][1] - (*this)[0][1]*(*this)[1][0]; │ │ │ │ │ - 1135 │ │ │ │ │ - 1136 if (rows()==3) { │ │ │ │ │ - 1137 // code generated by maple │ │ │ │ │ - 1138 field_type t4 = (*this)[0][0] * (*this)[1][1]; │ │ │ │ │ - 1139 field_type t6 = (*this)[0][0] * (*this)[1][2]; │ │ │ │ │ - 1140 field_type t8 = (*this)[0][1] * (*this)[1][0]; │ │ │ │ │ - 1141 field_type t10 = (*this)[0][2] * (*this)[1][0]; │ │ │ │ │ - 1142 field_type t12 = (*this)[0][1] * (*this)[2][0]; │ │ │ │ │ - 1143 field_type t14 = (*this)[0][2] * (*this)[2][0]; │ │ │ │ │ - 1144 │ │ │ │ │ - 1145 return (t4*(*this)[2][2]-t6*(*this)[2][1]-t8*(*this)[2][2]+ │ │ │ │ │ - 1146 t10*(*this)[2][1]+t12*(*this)[1][2]-t14*(*this)[1][1]); │ │ │ │ │ - 1147 │ │ │ │ │ - 1148 } │ │ │ │ │ - 1149 │ │ │ │ │ - 1150 AutonomousValue A(asImp()); │ │ │ │ │ - 1151 field_type det; │ │ │ │ │ - 1152 Simd::Mask::real_type> │ │ │ │ │ - 1153 nonsingularLanes(true); │ │ │ │ │ - 1154 │ │ │ │ │ - 1155 AutonomousValue::luDecomposition(A, ElimDet(det), nonsingularLanes, │ │ │ │ │ -false, doPivoting); │ │ │ │ │ - 1156 det = Simd::cond(nonsingularLanes, det, field_type(0)); │ │ │ │ │ - 1157 │ │ │ │ │ - 1158 for (size_type i = 0; i < rows(); ++i) │ │ │ │ │ - 1159 det *= A[i][i]; │ │ │ │ │ - 1160 return det; │ │ │ │ │ - 1161 } │ │ │ │ │ - 1162 │ │ │ │ │ - 1163#endif // DOXYGEN │ │ │ │ │ - 1164 │ │ │ │ │ -1165 namespace DenseMatrixHelp { │ │ │ │ │ - 1166 │ │ │ │ │ - 1168 template │ │ │ │ │ -1169 static inline void multAssign(const DenseMatrix &matrix, const │ │ │ │ │ -DenseVector & x, DenseVector & ret) │ │ │ │ │ - 1170 { │ │ │ │ │ - 1171 DUNE_ASSERT_BOUNDS(x.size() == matrix.cols()); │ │ │ │ │ - 1172 DUNE_ASSERT_BOUNDS(ret.size() == matrix.rows()); │ │ │ │ │ - 1173 typedef typename DenseMatrix::size_type size_type; │ │ │ │ │ - 1174 │ │ │ │ │ - 1175 for(size_type i=0; i │ │ │ │ │ - 1188 static inline void multAssignTransposed( const FieldMatrix │ │ │ │ │ -&matrix, const FieldVector & x, FieldVector & ret) │ │ │ │ │ - 1189 { │ │ │ │ │ - 1190 typedef typename FieldMatrix::size_type size_type; │ │ │ │ │ - 1191 │ │ │ │ │ - 1192 for(size_type i=0; i │ │ │ │ │ - 1202 static inline FieldVector mult(const FieldMatrix │ │ │ │ │ -&matrix, const FieldVector & x) │ │ │ │ │ - 1203 { │ │ │ │ │ - 1204 FieldVector ret; │ │ │ │ │ - 1205 multAssign(matrix,x,ret); │ │ │ │ │ - 1206 return ret; │ │ │ │ │ - 1207 } │ │ │ │ │ - 1208 │ │ │ │ │ - 1210 template │ │ │ │ │ - 1211 static inline FieldVector multTransposed(const │ │ │ │ │ -FieldMatrix &matrix, const FieldVector & x) │ │ │ │ │ - 1212 { │ │ │ │ │ - 1213 FieldVector ret; │ │ │ │ │ - 1214 multAssignTransposed( matrix, x, ret ); │ │ │ │ │ - 1215 return ret; │ │ │ │ │ - 1216 } │ │ │ │ │ - 1217#endif │ │ │ │ │ - 1218 │ │ │ │ │ - 1219 } // end namespace DenseMatrixHelp │ │ │ │ │ - 1220 │ │ │ │ │ - 1222 template │ │ │ │ │ -1223 std::ostream& operator<<(std::ostream& s, const DenseMatrix& a) │ │ │ │ │ - 1224 { │ │ │ │ │ - 1225 for (typename DenseMatrix::size_type i=0; i::type AutonomousValue │ │ │ │ │ -Type free of internal references that T can be converted to. │ │ │ │ │ -Definition typetraits.hh:558 │ │ │ │ │ -Dune::operator<< │ │ │ │ │ -std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x) │ │ │ │ │ -Definition bigunsignedint.hh:278 │ │ │ │ │ -DUNE_THROW │ │ │ │ │ -#define DUNE_THROW(E, m) │ │ │ │ │ -Definition exceptions.hh:218 │ │ │ │ │ -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::Rebind │ │ │ │ │ -typename Overloads::RebindType< std::decay_t< S >, std::decay_t< V > >::type │ │ │ │ │ -Rebind │ │ │ │ │ -Construct SIMD type with different scalar type. │ │ │ │ │ -Definition simd/interface.hh:253 │ │ │ │ │ -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::Overloads::mask │ │ │ │ │ -Mask< V > mask(ADLTag< 0, std::is_same< V, Mask< V > >::value >, const V &v) │ │ │ │ │ -implements Simd::mask() │ │ │ │ │ -Definition defaults.hh:153 │ │ │ │ │ + 106 │ │ │ │ │ + 107#endif // DUNE_COMMON_REFERENCE_HELPER_HH │ │ │ │ │ +Dune::IsReferenceWrapper_v │ │ │ │ │ +constexpr bool IsReferenceWrapper_v │ │ │ │ │ +Helper to detect if given type is a std::reference_wrapper. │ │ │ │ │ +Definition referencehelper.hh:35 │ │ │ │ │ +Dune::resolveRef │ │ │ │ │ +constexpr T & resolveRef(T &gf) noexcept │ │ │ │ │ +Helper function to resolve std::reference_wrapper. │ │ │ │ │ +Definition referencehelper.hh:47 │ │ │ │ │ std │ │ │ │ │ STL namespace. │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::swap │ │ │ │ │ -void swap(T &v1, T &v2, bool mask) │ │ │ │ │ -Definition simd.hh:472 │ │ │ │ │ -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::DenseMatrixHelp::multAssign │ │ │ │ │ -static void multAssign(const DenseMatrix< MAT > &matrix, const DenseVector< V1 │ │ │ │ │ -> &x, DenseVector< V2 > &ret) │ │ │ │ │ -calculates ret = matrix * x │ │ │ │ │ -Definition densematrix.hh:1169 │ │ │ │ │ -Dune::DenseMatrix │ │ │ │ │ -A dense n x m matrix. │ │ │ │ │ -Definition densematrix.hh:140 │ │ │ │ │ -Dune::DenseMatrix::const_iterator │ │ │ │ │ -ConstIterator const_iterator │ │ │ │ │ -typedef for stl compliant access │ │ │ │ │ -Definition densematrix.hh:244 │ │ │ │ │ -Dune::DenseMatrix::operator- │ │ │ │ │ -derived_type operator-() const │ │ │ │ │ -Matrix negation. │ │ │ │ │ -Definition densematrix.hh:298 │ │ │ │ │ -Dune::DenseMatrix::solve │ │ │ │ │ -void solve(V1 &x, const V2 &b, bool doPivoting=true) const │ │ │ │ │ -Solve system A x = b. │ │ │ │ │ -Dune::DenseMatrix::mv │ │ │ │ │ -void mv(const X &x, Y &y) const │ │ │ │ │ -y = A x │ │ │ │ │ -Definition densematrix.hh:368 │ │ │ │ │ -Dune::DenseMatrix::field_type │ │ │ │ │ -Traits::value_type field_type │ │ │ │ │ -export the type representing the field │ │ │ │ │ -Definition densematrix.hh:160 │ │ │ │ │ -Dune::DenseMatrix::axpy │ │ │ │ │ -derived_type & axpy(const field_type &a, const DenseMatrix< Other > &x) │ │ │ │ │ -vector space axpy operation (*this += a x) │ │ │ │ │ -Definition densematrix.hh:338 │ │ │ │ │ -Dune::DenseMatrix::beforeEnd │ │ │ │ │ -ConstIterator beforeEnd() const │ │ │ │ │ -Definition densematrix.hh:264 │ │ │ │ │ -Dune::DenseMatrix::operator= │ │ │ │ │ -derived_type & operator=(const RHS &rhs) │ │ │ │ │ -Definition densematrix.hh:279 │ │ │ │ │ -Dune::DenseMatrix::mmtv │ │ │ │ │ -void mmtv(const X &x, Y &y) const │ │ │ │ │ -y -= A^T x │ │ │ │ │ -Definition densematrix.hh:458 │ │ │ │ │ -Dune::DenseMatrix::infinity_norm_real │ │ │ │ │ -FieldTraits< vt >::real_type infinity_norm_real() const │ │ │ │ │ -simplified infinity norm (uses Manhattan norm for complex values) │ │ │ │ │ -Definition densematrix.hh:561 │ │ │ │ │ -Dune::DenseMatrix::ConstColIterator │ │ │ │ │ -std::remove_reference< const_row_reference >::type::ConstIterator │ │ │ │ │ -ConstColIterator │ │ │ │ │ -rename the iterators for easier access │ │ │ │ │ -Definition densematrix.hh:248 │ │ │ │ │ -Dune::DenseMatrix::beforeBegin │ │ │ │ │ -ConstIterator beforeBegin() const │ │ │ │ │ -Definition densematrix.hh:271 │ │ │ │ │ -Dune::DenseMatrix::invert │ │ │ │ │ -void invert(bool doPivoting=true) │ │ │ │ │ -Compute inverse. │ │ │ │ │ -Dune::DenseMatrix::luDecomposition │ │ │ │ │ -static void luDecomposition(DenseMatrix< MAT > &A, Func func, Mask │ │ │ │ │ -&nonsingularLanes, bool throwEarly, bool doPivoting) │ │ │ │ │ -do an LU-Decomposition on matrix A │ │ │ │ │ -Dune::DenseMatrix::block_type │ │ │ │ │ -Traits::value_type block_type │ │ │ │ │ -export the type representing the components │ │ │ │ │ -Definition densematrix.hh:163 │ │ │ │ │ -Dune::DenseMatrix::mtv │ │ │ │ │ -void mtv(const X &x, Y &y) const │ │ │ │ │ -y = A^T x │ │ │ │ │ -Definition densematrix.hh:387 │ │ │ │ │ -Dune::DenseMatrix::cols │ │ │ │ │ -constexpr size_type cols() const │ │ │ │ │ -number of columns │ │ │ │ │ -Definition densematrix.hh:715 │ │ │ │ │ -Dune::DenseMatrix::size │ │ │ │ │ -size_type size() const │ │ │ │ │ -size method (number of rows) │ │ │ │ │ -Definition densematrix.hh:200 │ │ │ │ │ -Dune::DenseMatrix::M │ │ │ │ │ -constexpr size_type M() const │ │ │ │ │ -number of columns │ │ │ │ │ -Definition densematrix.hh:703 │ │ │ │ │ -Dune::DenseMatrix::rightmultiply │ │ │ │ │ -MAT & rightmultiply(const DenseMatrix< M2 > &M) │ │ │ │ │ -Multiplies M from the right to this matrix. │ │ │ │ │ -Definition densematrix.hh:645 │ │ │ │ │ -Dune::DenseMatrix::end │ │ │ │ │ -Iterator end() │ │ │ │ │ -end iterator │ │ │ │ │ -Definition densematrix.hh:222 │ │ │ │ │ -Dune::DenseMatrix::beforeBegin │ │ │ │ │ -Iterator beforeBegin() │ │ │ │ │ -Definition densematrix.hh:236 │ │ │ │ │ -Dune::DenseMatrix::operator/= │ │ │ │ │ -derived_type & operator/=(const field_type &k) │ │ │ │ │ -vector space division by scalar │ │ │ │ │ -Definition densematrix.hh:329 │ │ │ │ │ -Dune::DenseMatrix::operator*= │ │ │ │ │ -derived_type & operator*=(const field_type &k) │ │ │ │ │ -vector space multiplication with scalar │ │ │ │ │ -Definition densematrix.hh:321 │ │ │ │ │ -Dune::DenseMatrix::beforeEnd │ │ │ │ │ -Iterator beforeEnd() │ │ │ │ │ -Definition densematrix.hh:229 │ │ │ │ │ -Dune::DenseMatrix::value_type │ │ │ │ │ -Traits::value_type value_type │ │ │ │ │ -export the type representing the field │ │ │ │ │ -Definition densematrix.hh:157 │ │ │ │ │ -Dune::DenseMatrix::usmv │ │ │ │ │ -void usmv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) │ │ │ │ │ -const │ │ │ │ │ -y += alpha A x │ │ │ │ │ -Definition densematrix.hh:484 │ │ │ │ │ -Dune::DenseMatrix::usmhv │ │ │ │ │ -void usmhv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y │ │ │ │ │ -&y) const │ │ │ │ │ -y += alpha A^H x │ │ │ │ │ -Definition densematrix.hh:512 │ │ │ │ │ -Dune::DenseMatrix::mmv │ │ │ │ │ -void mmv(const X &x, Y &y) const │ │ │ │ │ -y -= A x │ │ │ │ │ -Definition densematrix.hh:445 │ │ │ │ │ -Dune::DenseMatrix::rows │ │ │ │ │ -constexpr size_type rows() const │ │ │ │ │ -number of rows │ │ │ │ │ -Definition densematrix.hh:709 │ │ │ │ │ -Dune::DenseMatrix::leftmultiply │ │ │ │ │ -MAT & leftmultiply(const DenseMatrix< M2 > &M) │ │ │ │ │ -Multiplies M from the left to this matrix. │ │ │ │ │ -Definition densematrix.hh:627 │ │ │ │ │ -Dune::DenseMatrix::usmtv │ │ │ │ │ -void usmtv(const typename FieldTraits< Y >::field_type &alpha, const X &x, Y │ │ │ │ │ -&y) const │ │ │ │ │ -y += alpha A^T x │ │ │ │ │ -Definition densematrix.hh:498 │ │ │ │ │ -Dune::DenseMatrix::operator-= │ │ │ │ │ -derived_type & operator-=(const DenseMatrix< Other > &x) │ │ │ │ │ -vector space subtraction │ │ │ │ │ -Definition densematrix.hh:312 │ │ │ │ │ -Dune::DenseMatrix::operator!= │ │ │ │ │ -bool operator!=(const DenseMatrix< Other > &x) const │ │ │ │ │ -Binary matrix incomparison. │ │ │ │ │ -Definition densematrix.hh:358 │ │ │ │ │ -Dune::DenseMatrix::mmhv │ │ │ │ │ -void mmhv(const X &x, Y &y) const │ │ │ │ │ -y -= A^H x │ │ │ │ │ -Definition densematrix.hh:471 │ │ │ │ │ -Dune::DenseMatrix::derived_type │ │ │ │ │ -Traits::derived_type derived_type │ │ │ │ │ -type of derived matrix class │ │ │ │ │ -Definition densematrix.hh:154 │ │ │ │ │ -Dune::DenseMatrix::operator[] │ │ │ │ │ -row_reference operator[](size_type i) │ │ │ │ │ -random access │ │ │ │ │ -Definition densematrix.hh:189 │ │ │ │ │ -Dune::DenseMatrix::exists │ │ │ │ │ -bool exists(size_type i, size_type j) const │ │ │ │ │ -return true when (i,j) is in pattern │ │ │ │ │ -Definition densematrix.hh:723 │ │ │ │ │ -Dune::DenseMatrix::RowIterator │ │ │ │ │ -Iterator RowIterator │ │ │ │ │ -rename the iterators for easier access │ │ │ │ │ -Definition densematrix.hh:211 │ │ │ │ │ -Dune::DenseMatrix::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::frobenius_norm │ │ │ │ │ -FieldTraits< value_type >::real_type frobenius_norm() const │ │ │ │ │ -frobenius norm: sqrt(sum over squared values of entries) │ │ │ │ │ -Definition densematrix.hh:528 │ │ │ │ │ -Dune::DenseMatrix::umv │ │ │ │ │ -void umv(const X &x, Y &y) const │ │ │ │ │ -y += A x │ │ │ │ │ -Definition densematrix.hh:406 │ │ │ │ │ -Dune::DenseMatrix::ConstIterator │ │ │ │ │ -DenseIterator< const DenseMatrix, const row_type, const_row_reference > │ │ │ │ │ -ConstIterator │ │ │ │ │ -Iterator class for sequential access. │ │ │ │ │ -Definition densematrix.hh:242 │ │ │ │ │ -Dune::DenseMatrix::infinity_norm │ │ │ │ │ -FieldTraits< vt >::real_type infinity_norm() const │ │ │ │ │ -infinity norm (row sum norm, how to generalize for blocks?) │ │ │ │ │ -Definition densematrix.hh:546 │ │ │ │ │ -Dune::DenseMatrix::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::N │ │ │ │ │ -constexpr size_type N() const │ │ │ │ │ -number of rows │ │ │ │ │ -Definition densematrix.hh:697 │ │ │ │ │ -Dune::DenseMatrix::size_type │ │ │ │ │ -Traits::size_type size_type │ │ │ │ │ -The type used for the index access and size operation. │ │ │ │ │ -Definition densematrix.hh:166 │ │ │ │ │ -Dune::DenseMatrix::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::frobenius_norm2 │ │ │ │ │ -FieldTraits< value_type >::real_type frobenius_norm2() const │ │ │ │ │ -square of frobenius norm, need for block recursion │ │ │ │ │ -Definition densematrix.hh:536 │ │ │ │ │ -Dune::DenseMatrix::ColIterator │ │ │ │ │ -std::remove_reference< row_reference >::type::Iterator ColIterator │ │ │ │ │ -rename the iterators for easier access │ │ │ │ │ -Definition densematrix.hh:213 │ │ │ │ │ -Dune::DenseMatrix::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::DenseMatrix::operator== │ │ │ │ │ -bool operator==(const DenseMatrix< Other > &x) const │ │ │ │ │ -Binary matrix comparison. │ │ │ │ │ -Definition densematrix.hh:348 │ │ │ │ │ -Dune::DenseMatrix::iterator │ │ │ │ │ -Iterator iterator │ │ │ │ │ -typedef for stl compliant access │ │ │ │ │ -Definition densematrix.hh:209 │ │ │ │ │ -Dune::DenseMatrix::ConstRowIterator │ │ │ │ │ -ConstIterator ConstRowIterator │ │ │ │ │ -rename the iterators for easier access │ │ │ │ │ -Definition densematrix.hh:246 │ │ │ │ │ -Dune::DenseMatrix::Iterator │ │ │ │ │ -DenseIterator< DenseMatrix, row_type, row_reference > Iterator │ │ │ │ │ -Iterator class for sequential access. │ │ │ │ │ -Definition densematrix.hh:207 │ │ │ │ │ -Dune::DenseMatrix::umtv │ │ │ │ │ -void umtv(const X &x, Y &y) const │ │ │ │ │ -y += A^T x │ │ │ │ │ -Definition densematrix.hh:419 │ │ │ │ │ -Dune::DenseMatrix::begin │ │ │ │ │ -ConstIterator begin() const │ │ │ │ │ -begin iterator │ │ │ │ │ -Definition densematrix.hh:251 │ │ │ │ │ -Dune::DenseMatrix::determinant │ │ │ │ │ -field_type determinant(bool doPivoting=true) const │ │ │ │ │ -calculates the determinant of this matrix │ │ │ │ │ -Dune::DenseMatrix::begin │ │ │ │ │ -Iterator begin() │ │ │ │ │ -begin iterator │ │ │ │ │ -Definition densematrix.hh:216 │ │ │ │ │ -Dune::DenseMatrix::umhv │ │ │ │ │ -void umhv(const X &x, Y &y) const │ │ │ │ │ -y += A^H x │ │ │ │ │ -Definition densematrix.hh:432 │ │ │ │ │ -Dune::DenseMatrix::operator+= │ │ │ │ │ -derived_type & operator+=(const DenseMatrix< Other > &x) │ │ │ │ │ -vector space addition │ │ │ │ │ -Definition densematrix.hh:289 │ │ │ │ │ -Dune::DenseMatrix::end │ │ │ │ │ -ConstIterator end() const │ │ │ │ │ -end iterator │ │ │ │ │ -Definition densematrix.hh:257 │ │ │ │ │ -Dune::FieldTraits<_DenseMatrix<_M_>_>::real_type │ │ │ │ │ -const FieldTraits< typenameDenseMatVecTraits< M >::value_type >::real_type │ │ │ │ │ -real_type │ │ │ │ │ -Definition densematrix.hh:34 │ │ │ │ │ -Dune::FieldTraits<_DenseMatrix<_M_>_>::field_type │ │ │ │ │ -const FieldTraits< typenameDenseMatVecTraits< M >::value_type >::field_type │ │ │ │ │ -field_type │ │ │ │ │ -Definition densematrix.hh:33 │ │ │ │ │ -Dune::FieldMatrix │ │ │ │ │ -A dense n x m matrix. │ │ │ │ │ -Definition fmatrix.hh:117 │ │ │ │ │ -Dune::FieldMatrix::size_type │ │ │ │ │ -Base::size_type size_type │ │ │ │ │ -Definition fmatrix.hh:127 │ │ │ │ │ -Dune::FieldVector │ │ │ │ │ -vector space out of a tensor product of fields. │ │ │ │ │ -Definition fvector.hh:95 │ │ │ │ │ -Dune::DenseMatrixAssigner │ │ │ │ │ -you have to specialize this structure for any type that should be assignable to │ │ │ │ │ -a DenseMatrix │ │ │ │ │ -Definition densematrix.hh:59 │ │ │ │ │ -Dune::FMatrixError │ │ │ │ │ -Error thrown if operations of a FieldMatrix fail. │ │ │ │ │ -Definition densematrix.hh:126 │ │ │ │ │ -Dune::DenseVector │ │ │ │ │ -Interface for a class of dense vectors over a given field. │ │ │ │ │ -Definition densevector.hh:229 │ │ │ │ │ -Dune::DenseVector::size │ │ │ │ │ -size_type size() const │ │ │ │ │ -size method │ │ │ │ │ -Definition densevector.hh:336 │ │ │ │ │ -Dune::DenseIterator │ │ │ │ │ -Generic iterator class for dense vector and matrix implementations. │ │ │ │ │ -Definition densevector.hh:131 │ │ │ │ │ -Dune::MathError │ │ │ │ │ -Default exception class for mathematical errors. │ │ │ │ │ -Definition exceptions.hh:241 │ │ │ │ │ -Dune::FieldTraits │ │ │ │ │ -Definition ftraits.hh:26 │ │ │ │ │ -Dune::FieldTraits::field_type │ │ │ │ │ -T field_type │ │ │ │ │ -export the type representing the field │ │ │ │ │ -Definition ftraits.hh:28 │ │ │ │ │ -Dune::FieldTraits::real_type │ │ │ │ │ -T real_type │ │ │ │ │ -export the type representing the real type of the field │ │ │ │ │ -Definition ftraits.hh:30 │ │ │ │ │ -Dune::DenseMatVecTraits │ │ │ │ │ -Definition matvectraits.hh:31 │ │ │ │ │ -Dune::FMatrixPrecision::absolute_limit │ │ │ │ │ -static ctype absolute_limit() │ │ │ │ │ -return threshold to declare matrix singular │ │ │ │ │ -Definition precision.hh:28 │ │ │ │ │ -simd.hh │ │ │ │ │ -Include file for users of the SIMD abstraction layer. │ │ │ │ │ +Dune::ResolveRef_t │ │ │ │ │ +std::remove_reference_t< decltype(Dune::resolveRef(std::declval< T & >()))> │ │ │ │ │ +ResolveRef_t │ │ │ │ │ +Type trait to resolve std::reference_wrapper. │ │ │ │ │ +Definition referencehelper.hh:100 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00191.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: overloadset.hh File Reference │ │ │ │ +dune-common: alignedallocator.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,41 +70,37 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -Namespaces | │ │ │ │ -Functions
    │ │ │ │ -
    overloadset.hh File Reference
    │ │ │ │ +Classes | │ │ │ │ +Namespaces
    │ │ │ │ +
    alignedallocator.hh File Reference
    │ │ │ │ │ │ │ │
    │ │ │ │ -
    #include <utility>
    │ │ │ │ -#include <type_traits>
    │ │ │ │ -#include <dune/common/typetraits.hh>
    │ │ │ │ +
    #include "mallocallocator.hh"
    │ │ │ │ +#include <cstdlib>
    │ │ │ │
    │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ +Classes

    class  Dune::AlignedAllocator< T, Alignment >
     Allocators which guarantee alignment of the memory. More...
     
    struct  Dune::AlignedAllocator< T, Alignment >::rebind< U >
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

    │ │ │ │ Namespaces

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

    │ │ │ │ -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.
     
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,29 +6,25 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Namespaces | Functions │ │ │ │ │ -overloadset.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +alignedallocator.hh File Reference │ │ │ │ │ +#include "mallocallocator.hh" │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ + Classes │ │ │ │ │ + class  Dune::AlignedAllocator<_T,_Alignment_> │ │ │ │ │ +  Allocators which guarantee alignment of the memory. More... │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::AlignedAllocator<_T,_Alignment_>::rebind<_U_> │ │ │ │ │ +  │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ - Functions │ │ │ │ │ -template │ │ │ │ │ -auto Dune::overload (F &&... f) │ │ │ │ │ -  Create an overload set. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -auto Dune::orderedOverload (F &&... f) │ │ │ │ │ -  Create an ordered overload set. │ │ │ │ │ -  │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00191_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: overloadset.hh Source File │ │ │ │ +dune-common: alignedallocator.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,139 +74,122 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    overloadset.hh
    │ │ │ │ +
    alignedallocator.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 (C) 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_ALIGNED_ALLOCATOR_HH
    │ │ │ │ +
    6#define DUNE_ALIGNED_ALLOCATOR_HH
    │ │ │ │
    7
    │ │ │ │ -
    8#include <utility>
    │ │ │ │ -
    9#include <type_traits>
    │ │ │ │ - │ │ │ │ +
    8#include "mallocallocator.hh"
    │ │ │ │ +
    9#include <cstdlib>
    │ │ │ │ +
    10
    │ │ │ │
    11
    │ │ │ │ -
    12namespace Dune {
    │ │ │ │ -
    13
    │ │ │ │ -
    14namespace Impl {
    │ │ │ │ -
    15
    │ │ │ │ -
    16 template<typename... F>
    │ │ │ │ -
    17 class OverloadSet
    │ │ │ │ -
    18 : public F...
    │ │ │ │ -
    19 {
    │ │ │ │ -
    20
    │ │ │ │ -
    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
    │ │ │ │ -
    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 }
    │ │ │ │ +
    │ │ │ │ +
    12namespace Dune
    │ │ │ │ +
    13{
    │ │ │ │ +
    14
    │ │ │ │ +
    22 template<class T, int Alignment = -1>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    24
    │ │ │ │ +
    25#if __APPLE__
    │ │ │ │ +
    26
    │ │ │ │ +
    27 /*
    │ │ │ │ +
    28 * macOS has pretty draconian restrictions on the
    │ │ │ │ +
    29 * alignments that you may ask for: It has to be
    │ │ │ │ +
    30 *
    │ │ │ │ +
    31 * 1) a power of 2
    │ │ │ │ +
    32 * 2) at least as large as sizeof(void*)
    │ │ │ │ +
    33 *
    │ │ │ │ +
    34 * So here is a little constexpr function that calculates just that
    │ │ │ │ +
    35 * (together with the correct starting value for align fed in further down).
    │ │ │ │ +
    36 */
    │ │ │ │ +
    37 static constexpr int fixAlignment(int align)
    │ │ │ │ +
    38 {
    │ │ │ │ +
    39 return ((Alignment==-1) ? std::alignment_of<T>::value : Alignment) > align
    │ │ │ │ +
    40 ? fixAlignment(align << 1) : align;
    │ │ │ │ +
    41 }
    │ │ │ │ +
    42
    │ │ │ │ +
    43#else
    │ │ │ │ +
    44
    │ │ │ │ +
    45 /*
    │ │ │ │ +
    46 * Non-Apple platforms we just have to check whether an explicit alignment was
    │ │ │ │ +
    47 * restricted or fall back to the default alignment of T.
    │ │ │ │ +
    48 */
    │ │ │ │ +
    49 static constexpr int fixAlignment(int align)
    │ │ │ │ +
    50 {
    │ │ │ │ +
    51 return (Alignment==-1) ? std::alignment_of<T>::value : Alignment;
    │ │ │ │ +
    52 }
    │ │ │ │ +
    53
    │ │ │ │ +
    54#endif
    │ │ │ │ +
    55
    │ │ │ │ +
    56 public:
    │ │ │ │ + │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    59 template <class U> struct rebind {
    │ │ │ │ + │ │ │ │ +
    61 };
    │ │ │ │ +
    │ │ │ │ +
    62
    │ │ │ │ +
    63 static constexpr int alignment = fixAlignment(sizeof(void*));
    │ │ │ │ +
    64
    │ │ │ │ +
    │ │ │ │ +
    66 pointer allocate(size_type n, [[maybe_unused]] const void* hint = 0)
    │ │ │ │ +
    67 {
    │ │ │ │ +
    68 if (n > this->max_size())
    │ │ │ │ +
    69 throw std::bad_alloc();
    │ │ │ │ +
    70
    │ │ │ │ +
    71#if __APPLE__
    │ │ │ │ +
    72 // Apple is also restrictive regarding the allocation size.
    │ │ │ │ +
    73 // size must be at least the alignment size.
    │ │ │ │ +
    74 size_type size = n * sizeof(T) >= alignment ? n * sizeof(T) : alignment;
    │ │ │ │ +
    75#else
    │ │ │ │ +
    76 size_type size = n * sizeof(T);
    │ │ │ │ +
    77#endif
    │ │ │ │ +
    78
    │ │ │ │ +
    79 /*
    │ │ │ │ +
    80 * Everybody else gets the standard treatment.
    │ │ │ │ +
    81 */
    │ │ │ │ +
    82 pointer ret = static_cast<pointer>(std::aligned_alloc(alignment, size));
    │ │ │ │ +
    83 if (!ret)
    │ │ │ │ +
    84 throw std::bad_alloc();
    │ │ │ │ +
    85
    │ │ │ │ +
    86 return ret;
    │ │ │ │ +
    87 }
    │ │ │ │ +
    │ │ │ │ +
    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}
    │ │ │ │ -
    │ │ │ │ -
    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
    │ │ │ │ -
    STL namespace.
    │ │ │ │ +
    90}
    │ │ │ │ +
    │ │ │ │ +
    91
    │ │ │ │ +
    92#endif // DUNE_ALIGNED_ALLOCATOR_HH
    │ │ │ │ +
    Allocators that use malloc/free.
    │ │ │ │
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ +
    Allocators which guarantee alignment of the memory.
    Definition alignedallocator.hh:23
    │ │ │ │ +
    typename MallocAllocator< T >::size_type size_type
    Definition alignedallocator.hh:58
    │ │ │ │ +
    pointer allocate(size_type n, const void *hint=0)
    allocate n objects of type T
    Definition alignedallocator.hh:66
    │ │ │ │ +
    typename MallocAllocator< T >::pointer pointer
    Definition alignedallocator.hh:57
    │ │ │ │ +
    static constexpr int alignment
    Definition alignedallocator.hh:63
    │ │ │ │ +
    Definition alignedallocator.hh:59
    │ │ │ │ +
    AlignedAllocator< U, Alignment > other
    Definition alignedallocator.hh:60
    │ │ │ │ +
    Allocators implementation which simply calls malloc/free.
    Definition mallocallocator.hh:24
    │ │ │ │ +
    T * pointer
    Definition mallocallocator.hh:28
    │ │ │ │ +
    std::size_t size_type
    Definition mallocallocator.hh:26
    │ │ │ │ +
    size_type max_size() const noexcept
    max size for allocate
    Definition mallocallocator.hh:74
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,144 +7,137 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -overloadset.hh │ │ │ │ │ +alignedallocator.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 (C) 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_ALIGNED_ALLOCATOR_HH │ │ │ │ │ + 6#define DUNE_ALIGNED_ALLOCATOR_HH │ │ │ │ │ 7 │ │ │ │ │ - 8#include │ │ │ │ │ - 9#include │ │ │ │ │ - 10#include │ │ │ │ │ + 8#include "mallocallocator.hh" │ │ │ │ │ + 9#include │ │ │ │ │ + 10 │ │ │ │ │ 11 │ │ │ │ │ - 12namespace Dune { │ │ │ │ │ - 13 │ │ │ │ │ - 14namespace Impl { │ │ │ │ │ - 15 │ │ │ │ │ - 16 template │ │ │ │ │ - 17 class OverloadSet │ │ │ │ │ - 18 : public F... │ │ │ │ │ - 19 { │ │ │ │ │ - 20 │ │ │ │ │ - 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 │ │ │ │ │ - 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 } │ │ │ │ │ +12namespace Dune │ │ │ │ │ + 13{ │ │ │ │ │ + 14 │ │ │ │ │ + 22 template │ │ │ │ │ +23 class AlignedAllocator : public MallocAllocator { │ │ │ │ │ + 24 │ │ │ │ │ + 25#if __APPLE__ │ │ │ │ │ + 26 │ │ │ │ │ + 27 /* │ │ │ │ │ + 28 * macOS has pretty draconian restrictions on the │ │ │ │ │ + 29 * alignments that you may ask for: It has to be │ │ │ │ │ + 30 * │ │ │ │ │ + 31 * 1) a power of 2 │ │ │ │ │ + 32 * 2) at least as large as sizeof(void*) │ │ │ │ │ + 33 * │ │ │ │ │ + 34 * So here is a little constexpr function that calculates just that │ │ │ │ │ + 35 * (together with the correct starting value for align fed in further down). │ │ │ │ │ + 36 */ │ │ │ │ │ + 37 static constexpr int fixAlignment(int align) │ │ │ │ │ + 38 { │ │ │ │ │ + 39 return ((Alignment==-1) ? std::alignment_of::value : Alignment) > align │ │ │ │ │ + 40 ? fixAlignment(align << 1) : align; │ │ │ │ │ + 41 } │ │ │ │ │ + 42 │ │ │ │ │ + 43#else │ │ │ │ │ + 44 │ │ │ │ │ + 45 /* │ │ │ │ │ + 46 * Non-Apple platforms we just have to check whether an explicit alignment │ │ │ │ │ +was │ │ │ │ │ + 47 * restricted or fall back to the default alignment of T. │ │ │ │ │ + 48 */ │ │ │ │ │ + 49 static constexpr int fixAlignment(int align) │ │ │ │ │ + 50 { │ │ │ │ │ + 51 return (Alignment==-1) ? std::alignment_of::value : Alignment; │ │ │ │ │ + 52 } │ │ │ │ │ + 53 │ │ │ │ │ + 54#endif │ │ │ │ │ + 55 │ │ │ │ │ + 56 public: │ │ │ │ │ +57 using pointer = typename MallocAllocator::pointer; │ │ │ │ │ +58 using size_type = typename MallocAllocator::size_type; │ │ │ │ │ +59 template struct rebind { │ │ │ │ │ +60 typedef AlignedAllocator other; │ │ │ │ │ + 61 }; │ │ │ │ │ + 62 │ │ │ │ │ +63 static constexpr int alignment = fixAlignment(sizeof(void*)); │ │ │ │ │ + 64 │ │ │ │ │ +66 pointer allocate(size_type n, [[maybe_unused]] const void* hint = 0) │ │ │ │ │ + 67 { │ │ │ │ │ + 68 if (n > this->max_size()) │ │ │ │ │ + 69 throw std::bad_alloc(); │ │ │ │ │ + 70 │ │ │ │ │ + 71#if __APPLE__ │ │ │ │ │ + 72 // Apple is also restrictive regarding the allocation size. │ │ │ │ │ + 73 // size must be at least the alignment size. │ │ │ │ │ + 74 size_type size = n * sizeof(T) >= alignment ? n * sizeof(T) : alignment; │ │ │ │ │ + 75#else │ │ │ │ │ + 76 size_type size = n * sizeof(T); │ │ │ │ │ + 77#endif │ │ │ │ │ + 78 │ │ │ │ │ + 79 /* │ │ │ │ │ + 80 * Everybody else gets the standard treatment. │ │ │ │ │ + 81 */ │ │ │ │ │ + 82 pointer ret = static_cast(std::aligned_alloc(alignment, size)); │ │ │ │ │ + 83 if (!ret) │ │ │ │ │ + 84 throw std::bad_alloc(); │ │ │ │ │ + 85 │ │ │ │ │ + 86 return ret; │ │ │ │ │ + 87 } │ │ │ │ │ + 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 │ │ │ │ │ - 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 │ │ │ │ │ -std │ │ │ │ │ -STL namespace. │ │ │ │ │ + 90} │ │ │ │ │ + 91 │ │ │ │ │ + 92#endif // DUNE_ALIGNED_ALLOCATOR_HH │ │ │ │ │ +mallocallocator.hh │ │ │ │ │ +Allocators that use malloc/free. │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ +Dune::AlignedAllocator │ │ │ │ │ +Allocators which guarantee alignment of the memory. │ │ │ │ │ +Definition alignedallocator.hh:23 │ │ │ │ │ +Dune::AlignedAllocator::size_type │ │ │ │ │ +typename MallocAllocator< T >::size_type size_type │ │ │ │ │ +Definition alignedallocator.hh:58 │ │ │ │ │ +Dune::AlignedAllocator::allocate │ │ │ │ │ +pointer allocate(size_type n, const void *hint=0) │ │ │ │ │ +allocate n objects of type T │ │ │ │ │ +Definition alignedallocator.hh:66 │ │ │ │ │ +Dune::AlignedAllocator::pointer │ │ │ │ │ +typename MallocAllocator< T >::pointer pointer │ │ │ │ │ +Definition alignedallocator.hh:57 │ │ │ │ │ +Dune::AlignedAllocator::alignment │ │ │ │ │ +static constexpr int alignment │ │ │ │ │ +Definition alignedallocator.hh:63 │ │ │ │ │ +Dune::AlignedAllocator::rebind │ │ │ │ │ +Definition alignedallocator.hh:59 │ │ │ │ │ +Dune::AlignedAllocator::rebind::other │ │ │ │ │ +AlignedAllocator< U, Alignment > other │ │ │ │ │ +Definition alignedallocator.hh:60 │ │ │ │ │ +Dune::MallocAllocator │ │ │ │ │ +Allocators implementation which simply calls malloc/free. │ │ │ │ │ +Definition mallocallocator.hh:24 │ │ │ │ │ +Dune::MallocAllocator::pointer │ │ │ │ │ +T * pointer │ │ │ │ │ +Definition mallocallocator.hh:28 │ │ │ │ │ +Dune::MallocAllocator::size_type │ │ │ │ │ +std::size_t size_type │ │ │ │ │ +Definition mallocallocator.hh:26 │ │ │ │ │ +Dune::MallocAllocator::max_size │ │ │ │ │ +size_type max_size() const noexcept │ │ │ │ │ +max size for allocate │ │ │ │ │ +Definition mallocallocator.hh:74 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00194.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: functional.hh File Reference │ │ │ │ +dune-common: deprecated.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,43 +65,40 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -Classes | │ │ │ │ -Namespaces
    │ │ │ │ -
    functional.hh File Reference
    │ │ │ │ +Macros
    │ │ │ │ +
    deprecated.hh File Reference
    │ │ │ │ │ │ │ │
    │ │ │ │ -
    #include <functional>
    │ │ │ │ -
    │ │ │ │ + │ │ │ │ +

    Definition of the DUNE_NO_DEPRECATED_* macros. │ │ │ │ +More...

    │ │ │ │ + │ │ │ │

    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.
     
    namespace  Dune::Std
     Namespace for features backported from new C++ standards.
     

    │ │ │ │ +Macros

    #define DUNE_NO_DEPRECATED_BEGIN   ...
     Ignore deprecation warnings (start)
     
    #define DUNE_NO_DEPRECATED_END   ...
     Ignore deprecation warnings (end)
     
    │ │ │ │ -
    │ │ │ │ +

    Detailed Description

    │ │ │ │ +

    Definition of the DUNE_NO_DEPRECATED_* macros.

    │ │ │ │ +
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,27 +6,23 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * std │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -functional.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ +Macros │ │ │ │ │ +deprecated.hh File Reference │ │ │ │ │ +Definition of the DUNE_NO_DEPRECATED_* macros. More... │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ - Classes │ │ │ │ │ -struct  Dune::Std::identity │ │ │ │ │ -  A function object type whose operator() returns its argument │ │ │ │ │ - unchanged. More... │ │ │ │ │ + Macros │ │ │ │ │ +#define DUNE_NO_DEPRECATED_BEGIN   ... │ │ │ │ │ +  Ignore deprecation warnings (start) │ │ │ │ │   │ │ │ │ │ - Namespaces │ │ │ │ │ -namespace  Dune │ │ │ │ │ -  Dune namespace. │ │ │ │ │ -  │ │ │ │ │ -namespace  Dune::Std │ │ │ │ │ -  Namespace for features backported from new C++ standards. │ │ │ │ │ +#define DUNE_NO_DEPRECATED_END   ... │ │ │ │ │ +  Ignore deprecation warnings (end) │ │ │ │ │   │ │ │ │ │ +***** Detailed Description ***** │ │ │ │ │ +Definition of the DUNE_NO_DEPRECATED_* macros. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00194_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: functional.hh Source File │ │ │ │ +dune-common: deprecated.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,54 +70,56 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │ -
    functional.hh
    │ │ │ │ +
    deprecated.hh
    │ │ │ │
    │ │ │ │
    │ │ │ │ -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:
    │ │ │ │ +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 (C) 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_STD_FUNCTIONAL_HH
    │ │ │ │ -
    6#define DUNE_COMMON_STD_FUNCTIONAL_HH
    │ │ │ │ +
    5#ifndef DUNE_DEPRECATED_HH
    │ │ │ │ +
    6#define DUNE_DEPRECATED_HH
    │ │ │ │
    7
    │ │ │ │ -
    8#include <functional>
    │ │ │ │ -
    9
    │ │ │ │ -
    10namespace Dune
    │ │ │ │ -
    11{
    │ │ │ │ -
    12
    │ │ │ │ -
    13 namespace Std
    │ │ │ │ -
    14 {
    │ │ │ │ -
    15
    │ │ │ │ -
    22#if DUNE_HAVE_CXX_STD_IDENTITY
    │ │ │ │ -
    23 using std::identity;
    │ │ │ │ -
    24#else //DUNE_HAVE_CXX_STD_IDENTITY
    │ │ │ │ -
    │ │ │ │ -
    25 struct identity {
    │ │ │ │ -
    26 template<class T>
    │ │ │ │ -
    27 constexpr T&& operator()(T&& t ) const noexcept {return std::forward<T>(t);}
    │ │ │ │ -
    28 };
    │ │ │ │ -
    │ │ │ │ -
    29#endif
    │ │ │ │ -
    30 } // namespace Std
    │ │ │ │ -
    31
    │ │ │ │ -
    32} // namespace Dune
    │ │ │ │ -
    33
    │ │ │ │ -
    34#endif // #ifndef DUNE_COMMON_STD_FUNCTIONAL_HH
    │ │ │ │ -
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ -
    A function object type whose operator() returns its argument unchanged.
    Definition functional.hh:25
    │ │ │ │ -
    constexpr T && operator()(T &&t) const noexcept
    Definition functional.hh:27
    │ │ │ │ +
    14#ifdef DOXYGEN
    │ │ │ │ +
    32#define DUNE_NO_DEPRECATED_BEGIN ...
    │ │ │ │ +
    38#define DUNE_NO_DEPRECATED_END ...
    │ │ │ │ +
    39#else
    │ │ │ │ +
    40# if defined __clang__
    │ │ │ │ +
    41# define DUNE_NO_DEPRECATED_BEGIN \
    │ │ │ │ +
    42 _Pragma("clang diagnostic push") \
    │ │ │ │ +
    43 _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
    │ │ │ │ +
    44# define DUNE_NO_DEPRECATED_END _Pragma("clang diagnostic pop")
    │ │ │ │ +
    45# elif defined __INTEL_COMPILER
    │ │ │ │ +
    46# define DUNE_NO_DEPRECATED_BEGIN \
    │ │ │ │ +
    47 _Pragma("warning push") \
    │ │ │ │ +
    48 _Pragma("warning(disable:1478)") \
    │ │ │ │ +
    49 _Pragma("warning(disable:1786)")
    │ │ │ │ +
    50# define DUNE_NO_DEPRECATED_END _Pragma("warning pop")
    │ │ │ │ +
    51# elif defined __GNUC__
    │ │ │ │ +
    52# define DUNE_NO_DEPRECATED_BEGIN \
    │ │ │ │ +
    53 _Pragma("GCC diagnostic push") \
    │ │ │ │ +
    54 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
    │ │ │ │ +
    55# define DUNE_NO_DEPRECATED_END _Pragma("GCC diagnostic pop")
    │ │ │ │ +
    56# else
    │ │ │ │ +
    57# define DUNE_NO_DEPRECATED_BEGIN /* Noop. */
    │ │ │ │ +
    58# define DUNE_NO_DEPRECATED_END /* Noop. */
    │ │ │ │ +
    59# endif
    │ │ │ │ +
    60#endif
    │ │ │ │ +
    61
    │ │ │ │ +
    63
    │ │ │ │ +
    64#endif
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,51 +7,48 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * std │ │ │ │ │ -functional.hh │ │ │ │ │ +deprecated.hh │ │ │ │ │ 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: │ │ │ │ │ + 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 (C) 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_STD_FUNCTIONAL_HH │ │ │ │ │ - 6#define DUNE_COMMON_STD_FUNCTIONAL_HH │ │ │ │ │ + 5#ifndef DUNE_DEPRECATED_HH │ │ │ │ │ + 6#define DUNE_DEPRECATED_HH │ │ │ │ │ 7 │ │ │ │ │ - 8#include │ │ │ │ │ - 9 │ │ │ │ │ - 10namespace Dune │ │ │ │ │ - 11{ │ │ │ │ │ - 12 │ │ │ │ │ - 13 namespace Std │ │ │ │ │ - 14 { │ │ │ │ │ - 15 │ │ │ │ │ - 22#if DUNE_HAVE_CXX_STD_IDENTITY │ │ │ │ │ - 23 using std::identity; │ │ │ │ │ - 24#else //DUNE_HAVE_CXX_STD_IDENTITY │ │ │ │ │ -25 struct identity { │ │ │ │ │ - 26 template │ │ │ │ │ -27 constexpr T&& operator()(T&& t ) const noexcept {return std::forward(t);} │ │ │ │ │ - 28 }; │ │ │ │ │ - 29#endif │ │ │ │ │ - 30 } // namespace Std │ │ │ │ │ - 31 │ │ │ │ │ - 32} // namespace Dune │ │ │ │ │ - 33 │ │ │ │ │ - 34#endif // #ifndef DUNE_COMMON_STD_FUNCTIONAL_HH │ │ │ │ │ -Dune │ │ │ │ │ -Dune namespace. │ │ │ │ │ -Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::Std::identity │ │ │ │ │ -A function object type whose operator() returns its argument unchanged. │ │ │ │ │ -Definition functional.hh:25 │ │ │ │ │ -Dune::Std::identity::operator() │ │ │ │ │ -constexpr T && operator()(T &&t) const noexcept │ │ │ │ │ -Definition functional.hh:27 │ │ │ │ │ + 14#ifdef DOXYGEN │ │ │ │ │ +32#define DUNE_NO_DEPRECATED_BEGIN ... │ │ │ │ │ +38#define DUNE_NO_DEPRECATED_END ... │ │ │ │ │ + 39#else │ │ │ │ │ + 40# if defined __clang__ │ │ │ │ │ + 41# define DUNE_NO_DEPRECATED_BEGIN \ │ │ │ │ │ + 42 _Pragma("clang diagnostic push") \ │ │ │ │ │ + 43 _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") │ │ │ │ │ + 44# define DUNE_NO_DEPRECATED_END _Pragma("clang diagnostic pop") │ │ │ │ │ + 45# elif defined __INTEL_COMPILER │ │ │ │ │ + 46# define DUNE_NO_DEPRECATED_BEGIN \ │ │ │ │ │ + 47 _Pragma("warning push") \ │ │ │ │ │ + 48 _Pragma("warning(disable:1478)") \ │ │ │ │ │ + 49 _Pragma("warning(disable:1786)") │ │ │ │ │ + 50# define DUNE_NO_DEPRECATED_END _Pragma("warning pop") │ │ │ │ │ + 51# elif defined __GNUC__ │ │ │ │ │ + 52# define DUNE_NO_DEPRECATED_BEGIN \ │ │ │ │ │ + 53 _Pragma("GCC diagnostic push") \ │ │ │ │ │ + 54 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") │ │ │ │ │ + 55# define DUNE_NO_DEPRECATED_END _Pragma("GCC diagnostic pop") │ │ │ │ │ + 56# else │ │ │ │ │ + 57# define DUNE_NO_DEPRECATED_BEGIN /* Noop. */ │ │ │ │ │ + 58# define DUNE_NO_DEPRECATED_END /* Noop. */ │ │ │ │ │ + 59# endif │ │ │ │ │ + 60#endif │ │ │ │ │ + 61 │ │ │ │ │ + 63 │ │ │ │ │ + 64#endif │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00197.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: utility.hh File Reference │ │ │ │ +dune-common: binaryfunctions.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,36 +65,46 @@ │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ +Classes | │ │ │ │ Namespaces
    │ │ │ │ -
    utility.hh File Reference
    │ │ │ │ +
    binaryfunctions.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ -
    #include <utility>
    │ │ │ │ + │ │ │ │ +

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

    │ │ │ │ +
    #include <algorithm>
    │ │ │ │
    │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ +Classes

    struct  Dune::Min< Type >
     
    struct  Dune::Max< Type >
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │

    │ │ │ │ Namespaces

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

    Detailed Description

    │ │ │ │ +

    helper classes to provide unique types for standard functions

    │ │ │ │ +
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,22 +6,26 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * std │ │ │ │ │ -Namespaces │ │ │ │ │ -utility.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +binaryfunctions.hh File Reference │ │ │ │ │ +helper classes to provide unique types for standard functions More... │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ + Classes │ │ │ │ │ +struct  Dune::Min<_Type_> │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::Max<_Type_> │ │ │ │ │ +  │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -namespace  Dune::Std │ │ │ │ │ -  Namespace for features backported from new C++ standards. │ │ │ │ │ -  │ │ │ │ │ +***** Detailed Description ***** │ │ │ │ │ +helper classes to provide unique types for standard functions │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00197_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: utility.hh Source File │ │ │ │ +dune-common: binaryfunctions.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,49 +70,85 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │ -
    utility.hh
    │ │ │ │ +
    binaryfunctions.hh
    │ │ │ │
    │ │ │ │
    │ │ │ │ -Go to the documentation of this file.
    1// SPDX-FileCopyrightInfo: Copyright (C) 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_STD_UTILITY_HH
    │ │ │ │ -
    4#define DUNE_COMMON_STD_UTILITY_HH
    │ │ │ │ -
    5
    │ │ │ │ -
    6#include <utility>
    │ │ │ │ +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 (C) 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
    │ │ │ │
    7
    │ │ │ │ -
    8#warning dune/common/std/utility.hh is deprecated and will be removed after Dune 2.8.\
    │ │ │ │ -
    9 Include <utility> instead
    │ │ │ │ -
    10
    │ │ │ │ -
    11namespace Dune
    │ │ │ │ -
    12{
    │ │ │ │ +
    12#include <algorithm>
    │ │ │ │
    13
    │ │ │ │ -
    14 namespace Std
    │ │ │ │ -
    15 {
    │ │ │ │ -
    16
    │ │ │ │ -
    17 using std::integer_sequence;
    │ │ │ │ -
    18 using std::index_sequence;
    │ │ │ │ -
    19 using std::make_integer_sequence;
    │ │ │ │ -
    20 using std::make_index_sequence;
    │ │ │ │ -
    21 using std::index_sequence_for;
    │ │ │ │ +
    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 } // namespace Std
    │ │ │ │ +
    23 using result_type [[deprecated("This type alias is deprecated following similar deprecations in C++17")]] = Type;
    │ │ │ │
    24
    │ │ │ │ -
    25} // namespace Dune
    │ │ │ │ -
    26
    │ │ │ │ -
    27#endif // #ifndef DUNE_COMMON_STD_UTILITY_HH
    │ │ │ │ +
    │ │ │ │ +
    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>
    │ │ │ │ +
    │ │ │ │ +
    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
    │ │ │ │
    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
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,45 +7,95 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * std │ │ │ │ │ -utility.hh │ │ │ │ │ +binaryfunctions.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ - 1// SPDX-FileCopyrightInfo: Copyright (C) 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 (C) 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_STD_UTILITY_HH │ │ │ │ │ - 4#define DUNE_COMMON_STD_UTILITY_HH │ │ │ │ │ - 5 │ │ │ │ │ - 6#include │ │ │ │ │ + 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ + 5#ifndef DUNE_BINARYFUNCTIONS_HH │ │ │ │ │ + 6#define DUNE_BINARYFUNCTIONS_HH │ │ │ │ │ 7 │ │ │ │ │ - 8#warning dune/common/std/utility.hh is deprecated and will be removed after │ │ │ │ │ -Dune 2.8.\ │ │ │ │ │ - 9 Include instead │ │ │ │ │ - 10 │ │ │ │ │ - 11namespace Dune │ │ │ │ │ - 12{ │ │ │ │ │ + 12#include │ │ │ │ │ 13 │ │ │ │ │ - 14 namespace Std │ │ │ │ │ - 15 { │ │ │ │ │ - 16 │ │ │ │ │ - 17 using std::integer_sequence; │ │ │ │ │ - 18 using std::index_sequence; │ │ │ │ │ - 19 using std::make_integer_sequence; │ │ │ │ │ - 20 using std::make_index_sequence; │ │ │ │ │ - 21 using std::index_sequence_for; │ │ │ │ │ + 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 } // namespace Std │ │ │ │ │ +23 using result_type [[deprecated("This type alias is deprecated following │ │ │ │ │ +similar deprecations in C++17")]] = Type; │ │ │ │ │ 24 │ │ │ │ │ - 25} // namespace Dune │ │ │ │ │ - 26 │ │ │ │ │ - 27#endif // #ifndef DUNE_COMMON_STD_UTILITY_HH │ │ │ │ │ +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 │ │ │ │ │ + 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 │ │ │ │ │ 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 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00200.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: variant.hh File Reference │ │ │ │ +dune-common: test.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,36 +65,496 @@ │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -Namespaces
    │ │ │ │ -
    variant.hh File Reference
    │ │ │ │ +Classes | │ │ │ │ +Namespaces | │ │ │ │ +Macros | │ │ │ │ +Typedefs
    │ │ │ │ +
    test.hh File Reference
    │ │ │ │ │ │ │ │
    │ │ │ │ -
    #include <variant>
    │ │ │ │ + │ │ │ │ +

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

    │ │ │ │ +
    #include <algorithm>
    │ │ │ │ +#include <cstddef>
    │ │ │ │ +#include <iostream>
    │ │ │ │ +#include <sstream>
    │ │ │ │ +#include <string>
    │ │ │ │ +#include <type_traits>
    │ │ │ │ +#include <typeindex>
    │ │ │ │ +#include <typeinfo>
    │ │ │ │ +#include <unordered_set>
    │ │ │ │ +#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>
    │ │ │ │
    │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ +Classes

    struct  Dune::Simd::EndMark
     final element marker for RebindList More...
     
    class  Dune::Simd::UnitTest
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ +

    │ │ │ │ Namespaces

    namespace  Dune
     Dune namespace.
     
    namespace  Dune::Std
     Namespace for features backported from new C++ standards.
    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)); \
    │ │ │ │ +
    }
    │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ +
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,22 +6,205 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * std │ │ │ │ │ -Namespaces │ │ │ │ │ -variant.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ + * 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 │ │ │ │ │ +#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 │ │ │ │ │ +  │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -namespace  Dune::Std │ │ │ │ │ -  Namespace for features backported from new C++ standards. │ │ │ │ │ +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 (  expr )     ((expr) ? void() : complain(__FILE__, __LINE__, __func__, │ │ │ │ │ +DUNE_SIMD_CHECK #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)); \ │ │ │ │ │ +} │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00200_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: variant.hh Source File │ │ │ │ +dune-common: test.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,48 +70,2026 @@ │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │ -
    variant.hh
    │ │ │ │ +
    test.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 (C) 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_STD_VARIANT_HH
    │ │ │ │ -
    6#define DUNE_COMMON_STD_VARIANT_HH
    │ │ │ │ -
    7
    │ │ │ │ -
    8#warning dune/common/std/variant.hh is deprecated and will be removed after Dune 2.8.\
    │ │ │ │ -
    9 Include <variant> instead
    │ │ │ │ -
    10
    │ │ │ │ -
    11#include <variant>
    │ │ │ │ -
    12
    │ │ │ │ -
    13namespace Dune {
    │ │ │ │ -
    14namespace Std {
    │ │ │ │ -
    15 using std::variant;
    │ │ │ │ -
    16 using std::visit;
    │ │ │ │ -
    17 using std::variant_size;
    │ │ │ │ -
    18 using std::variant_size_v;
    │ │ │ │ -
    19 using std::get;
    │ │ │ │ -
    20 using std::get_if;
    │ │ │ │ -
    21 using std::holds_alternative;
    │ │ │ │ -
    22 using std::monostate;
    │ │ │ │ -
    23}
    │ │ │ │ -
    24}
    │ │ │ │ -
    25
    │ │ │ │ -
    26#endif
    │ │ │ │ +Go to the documentation of this file.
    1// SPDX-FileCopyrightInfo: Copyright (C) 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 };
    │ │ │ │ +
    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;
    │ │ │ │ +
    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
    │ │ │ │ +
    A free function to provide the demangled class name of a given object or type as a string.
    │ │ │ │ +
    #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)
    │ │ │ │ + │ │ │ │ +
    IO interface of the SIMD abstraction.
    │ │ │ │ + │ │ │ │ +
    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:300
    │ │ │ │ +
    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:268
    │ │ │ │ +
    constexpr AutonomousValue< T > autoCopy(T &&v)
    Autonomous copy of an expression's value for use in auto type deduction.
    Definition typetraits.hh:642
    │ │ │ │ +
    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.
    │ │ │ │
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ +
    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.
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,44 +7,2098 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * std │ │ │ │ │ -variant.hh │ │ │ │ │ + * simd │ │ │ │ │ +test.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 (C) DUNE Project contributors, see file │ │ │ │ │ + 1// SPDX-FileCopyrightInfo: Copyright (C) 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_STD_VARIANT_HH │ │ │ │ │ - 6#define DUNE_COMMON_STD_VARIANT_HH │ │ │ │ │ - 7 │ │ │ │ │ - 8#warning dune/common/std/variant.hh is deprecated and will be removed after │ │ │ │ │ -Dune 2.8.\ │ │ │ │ │ - 9 Include instead │ │ │ │ │ - 10 │ │ │ │ │ - 11#include │ │ │ │ │ - 12 │ │ │ │ │ - 13namespace Dune { │ │ │ │ │ - 14namespace Std { │ │ │ │ │ - 15 using std::variant; │ │ │ │ │ - 16 using std::visit; │ │ │ │ │ - 17 using std::variant_size; │ │ │ │ │ - 18 using std::variant_size_v; │ │ │ │ │ - 19 using std::get; │ │ │ │ │ - 20 using std::get_if; │ │ │ │ │ - 21 using std::holds_alternative; │ │ │ │ │ - 22 using std::monostate; │ │ │ │ │ - 23} │ │ │ │ │ - 24} │ │ │ │ │ - 25 │ │ │ │ │ - 26#endif │ │ │ │ │ + 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 │ │ │ │ │ + 75 { │ │ │ │ │ + 76 using type = std::add_lvalue_reference_t; │ │ │ │ │ + 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; │ │ │ │ │ + 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 │ │ │ │ │ +classname.hh │ │ │ │ │ +A free function to provide the demangled class name of a given object or type │ │ │ │ │ +as a string. │ │ │ │ │ +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) │ │ │ │ │ +loop.hh │ │ │ │ │ +io.hh │ │ │ │ │ +IO interface of the SIMD abstraction. │ │ │ │ │ +typelist.hh │ │ │ │ │ +rangeutilities.hh │ │ │ │ │ +Utilities for reduction like operations on ranges. │ │ │ │ │ +type_traits.hh │ │ │ │ │ +typetraits.hh │ │ │ │ │ +Traits for type conversions and type information. │ │ │ │ │ +hybridutilities.hh │ │ │ │ │ +Dune::range │ │ │ │ │ +static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from │ │ │ │ │ +>, std::integral_constant< T, to >) noexcept │ │ │ │ │ +Definition rangeutilities.hh:300 │ │ │ │ │ +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:268 │ │ │ │ │ +Dune::autoCopy │ │ │ │ │ +constexpr AutonomousValue< T > autoCopy(T &&v) │ │ │ │ │ +Autonomous copy of an expression's value for use in auto type deduction. │ │ │ │ │ +Definition typetraits.hh:642 │ │ │ │ │ +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. │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ +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. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00203.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: type_traits.hh File Reference │ │ │ │ +dune-common: test.cc File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,102 +65,25 @@ │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │ -
    │ │ │ │ -Classes | │ │ │ │ -Namespaces | │ │ │ │ -Typedefs | │ │ │ │ -Variables
    │ │ │ │ -
    type_traits.hh File Reference
    │ │ │ │ +
    test.cc File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ -
    #include <type_traits>
    │ │ │ │ -#include <dune/common/typetraits.hh>
    │ │ │ │ -#include <dune/common/typeutilities.hh>
    │ │ │ │ -
    │ │ │ │ -

    Go to the source code of this file.

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

    │ │ │ │ -Classes

    struct  Dune::Std::nonesuch
     Type representing a lookup failure by std::detected_or and friends. More...
     
    struct  Dune::Std::conjunction< B >
     forms the logical conjunction of the type traits B... More...
     
    struct  Dune::Std::disjunction< B >
     forms the logical disjunction of the type traits B... More...
     
    struct  Dune::Std::negation< B >
     forms the logical negation of the type traits B... 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.
     
    │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

    │ │ │ │ -Variables

    template<template< typename... > class Op, typename... Args>
    constexpr bool Dune::Std::is_detected_v = is_detected<Op,Args...>::value
     Detects whether Op<Args...> is valid and makes the result available as a value.
     
    template<typename Expected , template< typename... > class Op, typename... Args>
    constexpr bool Dune::Std::is_detected_exact_v = is_detected_exact<Expected,Op,Args...>::value
     Convenient access to the result value of is_detected_exact.
     
    template<typename Target , template< typename... > class Op, typename... Args>
    constexpr bool Dune::Std::is_detected_convertible_v = is_detected_convertible<Target,Op,Args...>::value
     Convenient access to the result value of is_detected_convertible.
     
    │ │ │ │ -
    │ │ │ │ +
    #include <config.h>
    │ │ │ │ +#include <ostream>
    │ │ │ │ +#include <string>
    │ │ │ │ +#include <dune/common/simd/test.hh>
    │ │ │ │ +
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,99 +6,16 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * std │ │ │ │ │ -Classes | Namespaces | Typedefs | Variables │ │ │ │ │ -type_traits.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -Go_to_the_source_code_of_this_file. │ │ │ │ │ - Classes │ │ │ │ │ -struct  Dune::Std::nonesuch │ │ │ │ │ -  Type representing a lookup failure by std::detected_or and friends. │ │ │ │ │ - More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::Std::conjunction<_B_> │ │ │ │ │ -  forms the logical conjunction of the type traits B... More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::Std::disjunction<_B_> │ │ │ │ │ -  forms the logical disjunction of the type traits B... More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::Std::negation<_B_> │ │ │ │ │ -  forms the logical negation of the type traits B... 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. │ │ │ │ │ -  │ │ │ │ │ - Variables │ │ │ │ │ -template class Op, typename... Args> │ │ │ │ │ -constexpr bool Dune::Std::is_detected_v = is_detected::value │ │ │ │ │ -  Detects whether Op is valid and makes the result │ │ │ │ │ - available as a value. │ │ │ │ │ -  │ │ │ │ │ -template class Op, typename... │ │ │ │ │ -Args> │ │ │ │ │ -constexpr bool Dune::Std::is_detected_exact_v = │ │ │ │ │ - is_detected_exact::value │ │ │ │ │ -  Convenient access to the result value of is_detected_exact. │ │ │ │ │ -  │ │ │ │ │ -template class Op, typename... Args> │ │ │ │ │ -constexpr bool Dune::Std::is_detected_convertible_v = │ │ │ │ │ - is_detected_convertible::value │ │ │ │ │ -  Convenient access to the result value of │ │ │ │ │ - is_detected_convertible. │ │ │ │ │ -  │ │ │ │ │ + * simd │ │ │ │ │ +test.cc File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00206.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: apply.hh File Reference │ │ │ │ +dune-common: loop.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,36 +65,681 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -Namespaces
    │ │ │ │ -
    apply.hh File Reference
    │ │ │ │ +Classes | │ │ │ │ +Namespaces | │ │ │ │ +Macros | │ │ │ │ +Functions
    │ │ │ │ +
    loop.hh File Reference
    │ │ │ │ │ │ │ │
    │ │ │ │ -
    #include <tuple>
    │ │ │ │ +
    #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>
    │ │ │ │
    │ │ │ │

    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 > >
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

    │ │ │ │ Namespaces

    namespace  Dune
     Dune namespace.
     
    namespace  Dune::Std
     Namespace for features backported from new C++ standards.
    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)
     
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

    │ │ │ │ +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)
     
    │ │ │ │ +

    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

    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    #define DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN( expr,
     returnType 
    )
    │ │ │ │ +
    │ │ │ │ +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

    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    #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

    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    #define DUNE_SIMD_LOOP_PREFIX_OP( 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

    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    #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

    │ │ │ │ + │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    #define DUNE_SIMD_LOOP_UNARY_OP( 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 ;")
    │ │ │ │ +
    │ │ │ │ +
    │ │ │ │ +
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,22 +6,491 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * std │ │ │ │ │ -Namespaces │ │ │ │ │ -apply.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ + * simd │ │ │ │ │ +Classes | Namespaces | Macros | Functions │ │ │ │ │ +loop.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#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_>_> │ │ │ │ │ +  │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -namespace  Dune::Std │ │ │ │ │ -  Namespace for features backported from new C++ standards. │ │ │ │ │ +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) │ │ │ │ │ +  │ │ │ │ │ + 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) │ │ │ │ │   │ │ │ │ │ +***** 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 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: apply.hh Source File │ │ │ │ +dune-common: loop.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,44 +70,766 @@ │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │ -
    apply.hh
    │ │ │ │ +
    loop.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 (C) 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_STD_APPLY_HH
    │ │ │ │ -
    6#define DUNE_COMMON_STD_APPLY_HH
    │ │ │ │ -
    7
    │ │ │ │ -
    8#include <tuple>
    │ │ │ │ -
    9
    │ │ │ │ -
    10namespace Dune
    │ │ │ │ -
    11{
    │ │ │ │ -
    │ │ │ │ -
    12 namespace Std
    │ │ │ │ -
    13 {
    │ │ │ │ -
    14
    │ │ │ │ -
    17 using std::apply;
    │ │ │ │ +Go to the documentation of this file.
    1// SPDX-FileCopyrightInfo: Copyright (C) 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 } // namespace Std
    │ │ │ │ +
    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
    │ │ │ │ +
    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 }
    │ │ │ │
    │ │ │ │ -
    20} // namespace Dune
    │ │ │ │ -
    21
    │ │ │ │ -
    22#endif // #ifndef DUNE_COMMON_STD_APPLY_HH
    │ │ │ │ +
    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
    │ │ │ │ +
    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
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    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
    │ │ │ │ +
    Some useful basic math stuff.
    │ │ │ │ +
    #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
    │ │ │ │ +
    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:30
    │ │ │ │ +
    static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from >, std::integral_constant< T, to >) noexcept
    Definition rangeutilities.hh:300
    │ │ │ │ +
    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.
    │ │ │ │
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ +
    DUNE_SIMD_LOOP_COMPARISON_OP(<)
    │ │ │ │ +
    bool anyTrue(ADLTag< 5 >, const AlignedNumber< bool, align > &mask)
    Definition debugalign.hh:543
    │ │ │ │ +
    const AlignedNumber< T, align > & cond(ADLTag< 5 >, AlignedNumber< bool, align > mask, const AlignedNumber< T, align > &ifTrue, const AlignedNumber< T, align > &ifFalse)
    Definition debugalign.hh:535
    │ │ │ │ +
    T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v)
    Definition debugalign.hh:520
    │ │ │ │ +
    bool isNaN(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag)
    Definition fvector.hh:604
    │ │ │ │ +
    bool isInf(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag)
    Definition fvector.hh:594
    │ │ │ │ +
    auto isFinite(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag)
    Definition fvector.hh:584
    │ │ │ │ +
    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.
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,37 +7,827 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * std │ │ │ │ │ -apply.hh │ │ │ │ │ + * simd │ │ │ │ │ +loop.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 (C) DUNE Project contributors, see file │ │ │ │ │ + 1// SPDX-FileCopyrightInfo: Copyright (C) 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_STD_APPLY_HH │ │ │ │ │ - 6#define DUNE_COMMON_STD_APPLY_HH │ │ │ │ │ - 7 │ │ │ │ │ - 8#include │ │ │ │ │ - 9 │ │ │ │ │ - 10namespace Dune │ │ │ │ │ - 11{ │ │ │ │ │ -12 namespace Std │ │ │ │ │ - 13 { │ │ │ │ │ - 14 │ │ │ │ │ - 17 using std::apply; │ │ │ │ │ + 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 } // namespace Std │ │ │ │ │ - 20} // namespace Dune │ │ │ │ │ - 21 │ │ │ │ │ - 22#endif // #ifndef DUNE_COMMON_STD_APPLY_HH │ │ │ │ │ + 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 │ │ │ │ │ + 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 &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 │ │ │ │ │ +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 │ │ │ │ │ +math.hh │ │ │ │ │ +Some useful basic math stuff. │ │ │ │ │ +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 │ │ │ │ │ +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:30 │ │ │ │ │ +Dune::range │ │ │ │ │ +static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from │ │ │ │ │ +>, std::integral_constant< T, to >) noexcept │ │ │ │ │ +Definition rangeutilities.hh:300 │ │ │ │ │ +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:543 │ │ │ │ │ +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:535 │ │ │ │ │ +Dune::Simd::Overloads::lane │ │ │ │ │ +T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v) │ │ │ │ │ +Definition debugalign.hh:520 │ │ │ │ │ +Dune::MathOverloads::isNaN │ │ │ │ │ +bool isNaN(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag) │ │ │ │ │ +Definition fvector.hh:604 │ │ │ │ │ +Dune::MathOverloads::isInf │ │ │ │ │ +bool isInf(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag) │ │ │ │ │ +Definition fvector.hh:594 │ │ │ │ │ +Dune::MathOverloads::isFinite │ │ │ │ │ +auto isFinite(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag) │ │ │ │ │ +Definition fvector.hh:584 │ │ │ │ │ +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. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00209.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: make_array.hh File Reference │ │ │ │ +dune-common: io.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,45 +65,76 @@ │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ +Classes | │ │ │ │ Namespaces | │ │ │ │ Functions
    │ │ │ │ -
    make_array.hh File Reference
    │ │ │ │ + │ │ │ │
    │ │ │ │
    │ │ │ │ -
    #include <array>
    │ │ │ │ + │ │ │ │ +

    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>
    │ │ │ │
    │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ +Classes

    class  Dune::SimdImpl::Inserter< T >
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

    │ │ │ │ Namespaces

    namespace  Dune
     Dune namespace.
     
    namespace  Dune::Std
     Namespace for features backported from new C++ standards.
    namespace  Dune::SimdImpl
     
    namespace  Dune::Simd
     Namespace for vectorization interface functions used by library developers.
     
    │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

    │ │ │ │ Functions

    template<typename... Args>
    std::array< typename std::common_type< Args... >::type, sizeof...(Args)> Dune::Std::make_array (const Args &... args)
     Create and initialize an array.
     
    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 {} │ │ │ │ │ @@ -6,29 +6,58 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * std │ │ │ │ │ -Namespaces | Functions │ │ │ │ │ -make_array.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ + * 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 │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ + Classes │ │ │ │ │ +class  Dune::SimdImpl::Inserter<_T_> │ │ │ │ │ +  │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -namespace  Dune::Std │ │ │ │ │ -  Namespace for features backported from new C++ standards. │ │ │ │ │ +namespace  Dune::SimdImpl │ │ │ │ │ +  │ │ │ │ │ +namespace  Dune::Simd │ │ │ │ │ +  Namespace for vectorization interface functions used by library │ │ │ │ │ + developers. │ │ │ │ │   │ │ │ │ │ Functions │ │ │ │ │ -template │ │ │ │ │ -std::array< typename std::common_type< Dune::Std::make_array (const Args &... │ │ │ │ │ - Args... >::type, sizeof...(Args)> args) │ │ │ │ │ -  Create and initialize an array. │ │ │ │ │ +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/a00209_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: make_array.hh Source File │ │ │ │ +dune-common: io.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,64 +70,125 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │ -
    make_array.hh
    │ │ │ │ +
    io.hh
    │ │ │ │
    │ │ │ │
    │ │ │ │ Go to the documentation of this file.
    1// SPDX-FileCopyrightInfo: Copyright (C) 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_STD_MAKE_ARRAY_HH
    │ │ │ │ -
    4#define DUNE_COMMON_STD_MAKE_ARRAY_HH
    │ │ │ │ +
    3#ifndef DUNE_COMMON_SIMD_IO_HH
    │ │ │ │ +
    4#define DUNE_COMMON_SIMD_IO_HH
    │ │ │ │
    5
    │ │ │ │ -
    6#include <array>
    │ │ │ │ -
    7#include <type_traits>
    │ │ │ │ -
    8
    │ │ │ │ -
    9#if DUNE_HAVE_CXX_EXPERIMENTAL_MAKE_ARRAY
    │ │ │ │ -
    10#include <experimental/array>
    │ │ │ │ -
    11#endif
    │ │ │ │ -
    12
    │ │ │ │ -
    13#warning make_array.hh is deprecated and will be removed after Dune 2.9. \
    │ │ │ │ -
    14 Use deduction guide of `std::array` or `std::to_array`.
    │ │ │ │ -
    15
    │ │ │ │ -
    16namespace Dune {
    │ │ │ │ -
    17namespace Std {
    │ │ │ │ +
    16#include <ios>
    │ │ │ │ +
    17#include <type_traits>
    │ │ │ │
    18
    │ │ │ │ -
    19#if DUNE_HAVE_CXX_EXPERIMENTAL_MAKE_ARRAY
    │ │ │ │ -
    20
    │ │ │ │ -
    22 using std::experimental::make_array;
    │ │ │ │ -
    23
    │ │ │ │ -
    24#else // DUNE_HAVE_CXX_EXPERIMENTAL_MAKE_ARRAY
    │ │ │ │ -
    25
    │ │ │ │ -
    27
    │ │ │ │ -
    41 template <typename... Args>
    │ │ │ │ -
    42 std::array<typename std::common_type<Args...>::type, sizeof...(Args)>
    │ │ │ │ -
    │ │ │ │ -
    43 make_array(const Args&... args) {
    │ │ │ │ -
    44 std::array<typename std::common_type<Args...>::type, sizeof...(Args)>
    │ │ │ │ -
    45 result = {{args...}};
    │ │ │ │ -
    46 return result;
    │ │ │ │ -
    47 }
    │ │ │ │ -
    │ │ │ │ -
    48
    │ │ │ │ -
    49#endif // DUNE_HAVE_CXX_EXPERIMENTAL_MAKE_ARRAY
    │ │ │ │ -
    50
    │ │ │ │ -
    51}
    │ │ │ │ -
    52}
    │ │ │ │ -
    53
    │ │ │ │ -
    54#endif
    │ │ │ │ -
    std::array< typename std::common_type< Args... >::type, sizeof...(Args)> make_array(const Args &... args)
    Create and initialize an array.
    Definition make_array.hh:43
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    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 }
    │ │ │ │ +
    │ │ │ │ +
    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:300
    │ │ │ │ +
    constexpr AutonomousValue< T > autoCopy(T &&v)
    Autonomous copy of an expression's value for use in auto type deduction.
    Definition typetraits.hh:642
    │ │ │ │ +
    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
    │ │ │ │
    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.
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,61 +7,137 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * std │ │ │ │ │ -make_array.hh │ │ │ │ │ + * simd │ │ │ │ │ +io.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// SPDX-FileCopyrightInfo: Copyright (C) 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_STD_MAKE_ARRAY_HH │ │ │ │ │ - 4#define DUNE_COMMON_STD_MAKE_ARRAY_HH │ │ │ │ │ + 3#ifndef DUNE_COMMON_SIMD_IO_HH │ │ │ │ │ + 4#define DUNE_COMMON_SIMD_IO_HH │ │ │ │ │ 5 │ │ │ │ │ - 6#include │ │ │ │ │ - 7#include │ │ │ │ │ - 8 │ │ │ │ │ - 9#if DUNE_HAVE_CXX_EXPERIMENTAL_MAKE_ARRAY │ │ │ │ │ - 10#include │ │ │ │ │ - 11#endif │ │ │ │ │ - 12 │ │ │ │ │ - 13#warning make_array.hh is deprecated and will be removed after Dune 2.9. \ │ │ │ │ │ - 14 Use deduction guide of `std::array` or `std::to_array`. │ │ │ │ │ - 15 │ │ │ │ │ - 16namespace Dune { │ │ │ │ │ - 17namespace Std { │ │ │ │ │ + 16#include │ │ │ │ │ + 17#include │ │ │ │ │ 18 │ │ │ │ │ - 19#if DUNE_HAVE_CXX_EXPERIMENTAL_MAKE_ARRAY │ │ │ │ │ - 20 │ │ │ │ │ - 22 using std::experimental::make_array; │ │ │ │ │ - 23 │ │ │ │ │ - 24#else // DUNE_HAVE_CXX_EXPERIMENTAL_MAKE_ARRAY │ │ │ │ │ - 25 │ │ │ │ │ - 27 │ │ │ │ │ - 41 template │ │ │ │ │ - 42 std::array::type, sizeof...(Args)> │ │ │ │ │ -43 make_array(const Args&... args) { │ │ │ │ │ - 44 std::array::type, sizeof...(Args)> │ │ │ │ │ - 45 result = {{args...}}; │ │ │ │ │ - 46 return result; │ │ │ │ │ + 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#endif // DUNE_HAVE_CXX_EXPERIMENTAL_MAKE_ARRAY │ │ │ │ │ - 50 │ │ │ │ │ - 51} │ │ │ │ │ - 52} │ │ │ │ │ - 53 │ │ │ │ │ - 54#endif │ │ │ │ │ -Dune::Std::make_array │ │ │ │ │ -std::array< typename std::common_type< Args... >::type, sizeof...(Args)> │ │ │ │ │ -make_array(const Args &... args) │ │ │ │ │ -Create and initialize an array. │ │ │ │ │ -Definition make_array.hh:43 │ │ │ │ │ + 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) │ │ │ │ │ + 58 { │ │ │ │ │ + 59 return Simd::lane(0, v); │ │ │ │ │ + 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:300 │ │ │ │ │ +Dune::autoCopy │ │ │ │ │ +constexpr AutonomousValue< T > autoCopy(T &&v) │ │ │ │ │ +Autonomous copy of an expression's value for use in auto type deduction. │ │ │ │ │ +Definition typetraits.hh:642 │ │ │ │ │ +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 │ │ │ │ │ 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. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00212.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: quadmath.hh File Reference │ │ │ │ +dune-common: standard.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,23 +65,86 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │ -
    quadmath.hh File Reference
    │ │ │ │ +
    │ │ │ │ +Classes | │ │ │ │ +Namespaces
    │ │ │ │ + │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ +

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

    │ │ │ │ +
    #include <cstddef>
    │ │ │ │ +#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::Simd::Overloads
     Namespace for the overloads and specializations that make up a SIMD implementation.
     
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

    │ │ │ │ +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()
     
    │ │ │ │ +

    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 {} │ │ │ │ │ @@ -6,12 +6,75 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -quadmath.hh File Reference │ │ │ │ │ + * 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... │ │ │ │ │ +#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. │ │ │ │ │ +  │ │ │ │ │ + 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. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00212_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: quadmath.hh Source File │ │ │ │ +dune-common: standard.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,494 +70,102 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │ -
    quadmath.hh
    │ │ │ │ +
    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 (C) 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
    │ │ │ │ -
    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;
    │ │ │ │ -
    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_; }
    │ │ │ │ +Go to the documentation of this file.
    1// SPDX-FileCopyrightInfo: Copyright (C) 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
    │ │ │ │ +
    5
    │ │ │ │ +
    20#include <cstddef>
    │ │ │ │ +
    21#include <type_traits>
    │ │ │ │ +
    22#include <utility>
    │ │ │ │ +
    23
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    27
    │ │ │ │ +
    45namespace Dune {
    │ │ │ │ +
    46 namespace Simd {
    │ │ │ │ +
    47
    │ │ │ │ +
    48 namespace Overloads {
    │ │ │ │ +
    49
    │ │ │ │ +
    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; };
    │ │ │ │
    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;
    │ │ │ │ +
    70
    │ │ │ │ +
    73 template<class, class>
    │ │ │ │ +
    74 struct LaneCount : public index_constant<1> { };
    │ │ │ │ +
    75
    │ │ │ │ +
    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 // 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
    │ │ │ │ -
    Traits for type conversions and type information.
    │ │ │ │ -
    A few common exception classes.
    │ │ │ │ -
    #define DUNE_BINARY_OP(OP)
    Definition debugalign.hh:248
    │ │ │ │ -
    #define DUNE_UNARY_FUNC(name)
    │ │ │ │ -
    #define DUNE_ASSIGN_OP(OP)
    Definition debugalign.hh:207
    │ │ │ │ -
    Stream & operator>>(Stream &stream, std::tuple< Ts... > &t)
    Read a std::tuple.
    Definition streamoperators.hh:43
    │ │ │ │ -
    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.
    │ │ │ │ +
    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; }
    │ │ │ │ +
    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.
    │ │ │ │ +
    std::integral_constant< std::size_t, i > index_constant
    An index constant with value i.
    Definition indices.hh:30
    │ │ │ │ +
    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
    │ │ │ │
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ -
    T max_value(const AlignedNumber< T, align > &val)
    Definition debugalign.hh:481
    │ │ │ │ -
    T min_value(const AlignedNumber< T, align > &val)
    Definition debugalign.hh:487
    │ │ │ │ -
    auto min(const AlignedNumber< T, align > &a, const AlignedNumber< T, align > &b)
    Definition debugalign.hh:447
    │ │ │ │ -
    auto max(const AlignedNumber< T, align > &a, const AlignedNumber< T, align > &b)
    Definition debugalign.hh:425
    │ │ │ │ -
    Default exception class for range errors.
    Definition exceptions.hh:254
    │ │ │ │ +
    bool anyTrue(ADLTag< 5 >, const AlignedNumber< bool, align > &mask)
    Definition debugalign.hh:543
    │ │ │ │ +
    T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v)
    Definition debugalign.hh:520
    │ │ │ │ +
    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
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,534 +7,126 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -quadmath.hh │ │ │ │ │ + * 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 (C) DUNE Project contributors, see file │ │ │ │ │ + 1// SPDX-FileCopyrightInfo: Copyright (C) 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 │ │ │ │ │ - 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; │ │ │ │ │ - 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_; } │ │ │ │ │ + 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 │ │ │ │ │ + 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 │ │ │ │ │ + 56 │ │ │ │ │ + 59 template │ │ │ │ │ +60 struct ScalarType { using type = V; }; │ │ │ │ │ + 61 │ │ │ │ │ + 63 │ │ │ │ │ + 66 template │ │ │ │ │ +67 struct RebindType { using type = S; }; │ │ │ │ │ 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; │ │ │ │ │ + 70 │ │ │ │ │ + 73 template │ │ │ │ │ +74 struct LaneCount : public index_constant<1> { }; │ │ │ │ │ + 75 │ │ │ │ │ + 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 // 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 │ │ │ │ │ -typetraits.hh │ │ │ │ │ -Traits for type conversions and type information. │ │ │ │ │ -exceptions.hh │ │ │ │ │ -A few common exception classes. │ │ │ │ │ -DUNE_BINARY_OP │ │ │ │ │ -#define DUNE_BINARY_OP(OP) │ │ │ │ │ -Definition debugalign.hh:248 │ │ │ │ │ -DUNE_UNARY_FUNC │ │ │ │ │ -#define DUNE_UNARY_FUNC(name) │ │ │ │ │ -DUNE_ASSIGN_OP │ │ │ │ │ -#define DUNE_ASSIGN_OP(OP) │ │ │ │ │ -Definition debugalign.hh:207 │ │ │ │ │ -Dune::operator>> │ │ │ │ │ -Stream & operator>>(Stream &stream, std::tuple< Ts... > &t) │ │ │ │ │ -Read a std::tuple. │ │ │ │ │ -Definition streamoperators.hh:43 │ │ │ │ │ -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. │ │ │ │ │ + 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; } │ │ │ │ │ + 112 │ │ │ │ │ + 114 │ │ │ │ │ + 115 } // namespace Overloads │ │ │ │ │ + 116 } // namespace Simd │ │ │ │ │ + 117} // namespace Dune │ │ │ │ │ + 118 │ │ │ │ │ + 119#endif // DUNE_COMMON_SIMD_STANDARD_HH │ │ │ │ │ +indices.hh │ │ │ │ │ +defaults.hh │ │ │ │ │ +Default implementations for SIMD Implementations. │ │ │ │ │ +base.hh │ │ │ │ │ +Basic definitions for SIMD Implementations. │ │ │ │ │ +Dune::index_constant │ │ │ │ │ +std::integral_constant< std::size_t, i > index_constant │ │ │ │ │ +An index constant with value i. │ │ │ │ │ +Definition indices.hh:30 │ │ │ │ │ +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 │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::max_value │ │ │ │ │ -T max_value(const AlignedNumber< T, align > &val) │ │ │ │ │ -Definition debugalign.hh:481 │ │ │ │ │ -Dune::min_value │ │ │ │ │ -T min_value(const AlignedNumber< T, align > &val) │ │ │ │ │ -Definition debugalign.hh:487 │ │ │ │ │ -Dune::AlignedNumberImpl::min │ │ │ │ │ -auto min(const AlignedNumber< T, align > &a, const AlignedNumber< T, align > │ │ │ │ │ -&b) │ │ │ │ │ -Definition debugalign.hh:447 │ │ │ │ │ -Dune::AlignedNumberImpl::max │ │ │ │ │ -auto max(const AlignedNumber< T, align > &a, const AlignedNumber< T, align > │ │ │ │ │ -&b) │ │ │ │ │ -Definition debugalign.hh:425 │ │ │ │ │ -Dune::RangeError │ │ │ │ │ -Default exception class for range errors. │ │ │ │ │ -Definition exceptions.hh:254 │ │ │ │ │ +Dune::Simd::Overloads::anyTrue │ │ │ │ │ +bool anyTrue(ADLTag< 5 >, const AlignedNumber< bool, align > &mask) │ │ │ │ │ +Definition debugalign.hh:543 │ │ │ │ │ +Dune::Simd::Overloads::lane │ │ │ │ │ +T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v) │ │ │ │ │ +Definition debugalign.hh:520 │ │ │ │ │ +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 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00215.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: fvector.hh File Reference │ │ │ │ +dune-common: simd.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -72,83 +72,94 @@ │ │ │ │ │ │ │ │
    │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ Classes | │ │ │ │ Namespaces | │ │ │ │ +Typedefs | │ │ │ │ Functions
    │ │ │ │ - │ │ │ │ +
    simd.hh File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ -

    Implements a vector constructed from a given type representing a field and a compile-time given size. │ │ │ │ +

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

    │ │ │ │ -
    #include <array>
    │ │ │ │ -#include <cmath>
    │ │ │ │ +
    #include <cassert>
    │ │ │ │ #include <cstddef>
    │ │ │ │ -#include <cstdlib>
    │ │ │ │ -#include <complex>
    │ │ │ │ -#include <cstring>
    │ │ │ │ +#include <type_traits>
    │ │ │ │ #include <utility>
    │ │ │ │ -#include <initializer_list>
    │ │ │ │ -#include <algorithm>
    │ │ │ │ -#include "typetraits.hh"
    │ │ │ │ -#include "exceptions.hh"
    │ │ │ │ -#include "ftraits.hh"
    │ │ │ │ -#include "densevector.hh"
    │ │ │ │ -#include "boundschecking.hh"
    │ │ │ │ -#include <dune/common/math.hh>
    │ │ │ │ -#include <dune/common/promotiontraits.hh>
    │ │ │ │ +#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::DenseMatVecTraits< FieldVector< K, SIZE > >
    struct  Dune::SimdScalarTypeTraits< T >
     
    struct  Dune::FieldTraits< FieldVector< K, SIZE > >
    struct  Dune::SimdScalarTypeTraits< AlignedNumber< T, align > >
     deduce the underlying scalar data type of an AlignedNumber More...
     
    struct  Dune::IsFieldVectorSizeCorrect< C, SIZE >
     TMP to check the size of a DenseVectors statically, if possible. More...
    struct  Dune::SimdIndexTypeTraits< V, typename >
     
    struct  Dune::IsFieldVectorSizeCorrect< FieldVector< T, SIZE >, SIZE >
     
    struct  Dune::IsFieldVectorSizeCorrect< FieldVector< T, SIZE1 >, SIZE >
     
    class  Dune::FieldVector< K, SIZE >
     vector space out of a tensor product of fields. More...
    struct  Dune::SimdMaskTypeTraits< V, typename >
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ +

    │ │ │ │ Namespaces

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

    │ │ │ │ +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 K , int SIZE>
    auto Dune::MathOverloads::isFinite (const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag)
     
    template<class K , int SIZE>
    bool Dune::MathOverloads::isInf (const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag)
     
    template<class K , int SIZE, typename = std::enable_if_t<HasNaN<K>::value>>
    bool Dune::MathOverloads::isNaN (const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag)
     
    template<class K , typename = std::enable_if_t<HasNaN<K>::value>>
    bool Dune::MathOverloads::isUnordered (const FieldVector< K, 1 > &b, const FieldVector< K, 1 > &c, PriorityTag< 2 >, ADLTag)
     
    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 vector constructed from a given type representing a field and a compile-time given size.

    │ │ │ │ +

    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 {} │ │ │ │ │ @@ -6,75 +6,81 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Functions │ │ │ │ │ -fvector.hh File Reference │ │ │ │ │ -Common » Dense_Matrix_and_Vector_Template_Library │ │ │ │ │ -Implements a vector constructed from a given type representing a field and a │ │ │ │ │ -compile-time given size. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces | Typedefs | Functions │ │ │ │ │ +simd.hh File Reference │ │ │ │ │ +Abstractions for support of dedicated SIMD data types. More... │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include "typetraits.hh" │ │ │ │ │ -#include "exceptions.hh" │ │ │ │ │ -#include "ftraits.hh" │ │ │ │ │ -#include "densevector.hh" │ │ │ │ │ -#include "boundschecking.hh" │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -struct  Dune::DenseMatVecTraits<_FieldVector<_K,_SIZE_>_> │ │ │ │ │ +struct  Dune::SimdScalarTypeTraits<_T_> │ │ │ │ │   │ │ │ │ │ -struct  Dune::FieldTraits<_FieldVector<_K,_SIZE_>_> │ │ │ │ │ +struct  Dune::SimdScalarTypeTraits<_AlignedNumber<_T,_align_>_> │ │ │ │ │ +  deduce the underlying scalar data type of an AlignedNumber More... │ │ │ │ │   │ │ │ │ │ -struct  Dune::IsFieldVectorSizeCorrect<_C,_SIZE_> │ │ │ │ │ -  TMP to check the size of a DenseVectors statically, if possible. │ │ │ │ │ - More... │ │ │ │ │ +struct  Dune::SimdIndexTypeTraits<_V,_typename_> │ │ │ │ │   │ │ │ │ │ -struct  Dune::IsFieldVectorSizeCorrect<_FieldVector<_T,_SIZE_>,_SIZE_> │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::IsFieldVectorSizeCorrect<_FieldVector<_T,_SIZE1_>,_SIZE_> │ │ │ │ │ -  │ │ │ │ │ - class  Dune::FieldVector<_K,_SIZE_> │ │ │ │ │ -  vector space out of a tensor product of fields. More... │ │ │ │ │ +struct  Dune::SimdMaskTypeTraits<_V,_typename_> │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -namespace  Dune::MathOverloads │ │ │ │ │ -  namespace for customization of math functions with Dune-Semantics │ │ │ │ │ + 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 │ │ │ │ │ -auto Dune::MathOverloads::isFinite (const FieldVector< K, SIZE > &b, │ │ │ │ │ - PriorityTag< 2 >, ADLTag) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool Dune::MathOverloads::isInf (const FieldVector< K, SIZE > &b, PriorityTag< │ │ │ │ │ - 2 >, ADLTag) │ │ │ │ │ -  │ │ │ │ │ -template::value>> │ │ │ │ │ -bool Dune::MathOverloads::isNaN (const FieldVector< K, SIZE > &b, PriorityTag< │ │ │ │ │ - 2 >, ADLTag) │ │ │ │ │ -  │ │ │ │ │ -template::value>> │ │ │ │ │ -bool Dune::MathOverloads::isUnordered (const FieldVector< K, 1 > &b, const │ │ │ │ │ - FieldVector< K, 1 > &c, PriorityTag< 2 >, ADLTag) │ │ │ │ │ +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 vector constructed from a given type representing a field and a │ │ │ │ │ -compile-time given size. │ │ │ │ │ +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/a00215_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: fvector.hh Source File │ │ │ │ +dune-common: simd.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,639 +74,518 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    fvector.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 (C) 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_FVECTOR_HH
    │ │ │ │ -
    6#define DUNE_FVECTOR_HH
    │ │ │ │ -
    7
    │ │ │ │ -
    8#include <array>
    │ │ │ │ -
    9#include <cmath>
    │ │ │ │ -
    10#include <cstddef>
    │ │ │ │ -
    11#include <cstdlib>
    │ │ │ │ -
    12#include <complex>
    │ │ │ │ -
    13#include <cstring>
    │ │ │ │ -
    14#include <utility>
    │ │ │ │ -
    15#include <initializer_list>
    │ │ │ │ -
    16#include <algorithm>
    │ │ │ │ -
    17
    │ │ │ │ -
    18#include "typetraits.hh"
    │ │ │ │ -
    19#include "exceptions.hh"
    │ │ │ │ -
    20
    │ │ │ │ -
    21#include "ftraits.hh"
    │ │ │ │ -
    22#include "densevector.hh"
    │ │ │ │ -
    23#include "boundschecking.hh"
    │ │ │ │ -
    24
    │ │ │ │ -
    25#include <dune/common/math.hh>
    │ │ │ │ - │ │ │ │ -
    27
    │ │ │ │ -
    28namespace Dune {
    │ │ │ │ -
    29
    │ │ │ │ -
    39 template< class K, int SIZE > class FieldVector;
    │ │ │ │ -
    40 template< class K, int SIZE >
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    42 {
    │ │ │ │ - │ │ │ │ -
    44 typedef std::array<K,SIZE> container_type;
    │ │ │ │ -
    45 typedef K value_type;
    │ │ │ │ -
    46 typedef typename container_type::size_type size_type;
    │ │ │ │ -
    47 };
    │ │ │ │ -
    │ │ │ │ +Go to the documentation of this file.
    1// SPDX-FileCopyrightInfo: Copyright (C) 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
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    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 template< class K, int SIZE >
    │ │ │ │ -
    │ │ │ │ -
    50 struct FieldTraits< FieldVector<K,SIZE> >
    │ │ │ │ -
    51 {
    │ │ │ │ - │ │ │ │ - │ │ │ │ -
    54 };
    │ │ │ │ -
    │ │ │ │ -
    55
    │ │ │ │ -
    64 template<typename C, int SIZE>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    66 {
    │ │ │ │ -
    71 constexpr static bool value = true;
    │ │ │ │ -
    72 };
    │ │ │ │ -
    │ │ │ │ -
    73
    │ │ │ │ -
    74 template<typename T, int SIZE>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    76 {
    │ │ │ │ -
    77 constexpr static bool value = true;
    │ │ │ │ -
    78 };
    │ │ │ │ -
    │ │ │ │ +
    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 template<typename T, int SIZE, int SIZE1>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    82 {
    │ │ │ │ -
    83 constexpr static bool value = false;
    │ │ │ │ -
    84 };
    │ │ │ │ -
    │ │ │ │ -
    85
    │ │ │ │ -
    86
    │ │ │ │ -
    92 template< class K, int SIZE >
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    94 public DenseVector< FieldVector<K,SIZE> >
    │ │ │ │ -
    95 {
    │ │ │ │ -
    96 std::array<K,SIZE> _data;
    │ │ │ │ - │ │ │ │ -
    98 public:
    │ │ │ │ -
    100 constexpr static int dimension = SIZE;
    │ │ │ │ -
    101
    │ │ │ │ -
    102 typedef typename Base::size_type size_type;
    │ │ │ │ -
    103 typedef typename Base::value_type value_type;
    │ │ │ │ +
    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
    │ │ │ │ - │ │ │ │ -
    107
    │ │ │ │ - │ │ │ │ -
    110
    │ │ │ │ -
    │ │ │ │ -
    112 constexpr FieldVector()
    │ │ │ │ -
    113 : _data{{}}
    │ │ │ │ -
    114 {}
    │ │ │ │ -
    │ │ │ │ -
    115
    │ │ │ │ -
    │ │ │ │ -
    117 explicit FieldVector (const K& t)
    │ │ │ │ -
    118 {
    │ │ │ │ -
    119 std::fill(_data.begin(),_data.end(),t);
    │ │ │ │ -
    120 }
    │ │ │ │ -
    │ │ │ │ +
    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#if __GNUC__ == 5 && !defined(__clang__)
    │ │ │ │ -
    123 // `... = default;` causes an internal compiler error on GCC 5.4 (Ubuntu 16.04)
    │ │ │ │ -
    125 FieldVector(const FieldVector& x) : _data(x._data) {}
    │ │ │ │ -
    126#else
    │ │ │ │ -
    128 FieldVector (const FieldVector&) = default;
    │ │ │ │ -
    129#endif
    │ │ │ │ -
    130
    │ │ │ │ -
    │ │ │ │ -
    132 FieldVector (std::initializer_list<K> const &l)
    │ │ │ │ -
    133 {
    │ │ │ │ -
    134 assert(l.size() == dimension);// Actually, this is not needed any more!
    │ │ │ │ -
    135 std::copy_n(l.begin(), std::min(static_cast<std::size_t>(dimension),
    │ │ │ │ -
    136 l.size()),
    │ │ │ │ -
    137 _data.begin());
    │ │ │ │ -
    138 }
    │ │ │ │ -
    │ │ │ │ -
    139
    │ │ │ │ -
    141 FieldVector& operator= (const FieldVector&) = default;
    │ │ │ │ -
    142
    │ │ │ │ -
    143 template <typename T>
    │ │ │ │ -
    │ │ │ │ -
    144 FieldVector& operator= (const FieldVector<T, SIZE>& x)
    │ │ │ │ -
    145 {
    │ │ │ │ -
    146 std::copy_n(x.begin(), SIZE, _data.begin());
    │ │ │ │ -
    147 return *this;
    │ │ │ │ -
    148 }
    │ │ │ │ -
    │ │ │ │ -
    149
    │ │ │ │ -
    150 template<typename T, int N>
    │ │ │ │ - │ │ │ │ +
    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 template<class C>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    166 [[maybe_unused]] typename std::enable_if<IsFieldVectorSizeCorrect<C,SIZE>::value>::type* dummy=0)
    │ │ │ │ -
    167 {
    │ │ │ │ -
    168 // do a run-time size check, for the case that x is not a FieldVector
    │ │ │ │ -
    169 assert(x.size() == SIZE); // Actually this is not needed any more!
    │ │ │ │ -
    170 std::copy_n(x.begin(), std::min(static_cast<std::size_t>(SIZE),x.size()), _data.begin());
    │ │ │ │ -
    171 }
    │ │ │ │ -
    │ │ │ │ -
    172
    │ │ │ │ -
    174 template<class K1>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    176 {
    │ │ │ │ -
    177 std::copy_n(x.begin(), SIZE, _data.begin());
    │ │ │ │ -
    178 }
    │ │ │ │ -
    │ │ │ │ -
    179
    │ │ │ │ -
    180 template<typename T, int N>
    │ │ │ │ -
    181 explicit FieldVector(const FieldVector<T, N>&) = delete;
    │ │ │ │ -
    182
    │ │ │ │ -
    183 using Base::operator=;
    │ │ │ │ -
    184
    │ │ │ │ -
    185 // make this thing a vector
    │ │ │ │ -
    186 static constexpr size_type size () { return SIZE; }
    │ │ │ │ -
    187
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    189 DUNE_ASSERT_BOUNDS(i < SIZE);
    │ │ │ │ -
    190 return _data[i];
    │ │ │ │ -
    191 }
    │ │ │ │ -
    │ │ │ │ -
    │ │ │ │ -
    192 const K & operator[](size_type i) const {
    │ │ │ │ -
    193 DUNE_ASSERT_BOUNDS(i < SIZE);
    │ │ │ │ -
    194 return _data[i];
    │ │ │ │ -
    195 }
    │ │ │ │ -
    │ │ │ │ -
    196
    │ │ │ │ -
    │ │ │ │ -
    198 K* data() noexcept
    │ │ │ │ -
    199 {
    │ │ │ │ -
    200 return _data.data();
    │ │ │ │ -
    201 }
    │ │ │ │ -
    │ │ │ │ -
    202
    │ │ │ │ -
    │ │ │ │ -
    204 const K* data() const noexcept
    │ │ │ │ -
    205 {
    │ │ │ │ -
    206 return _data.data();
    │ │ │ │ -
    207 }
    │ │ │ │ -
    │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
    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
    │ │ │ │ +
    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
    │ │ │ │ -
    210 template <class Scalar,
    │ │ │ │ -
    211 std::enable_if_t<IsNumber<Scalar>::value, int> = 0>
    │ │ │ │ -
    │ │ │ │ -
    212 friend auto operator* ( const FieldVector& vector, Scalar scalar)
    │ │ │ │ -
    213 {
    │ │ │ │ - │ │ │ │ -
    215
    │ │ │ │ -
    216 for (size_type i = 0; i < vector.size(); ++i)
    │ │ │ │ -
    217 result[i] = vector[i] * scalar;
    │ │ │ │ +
    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 return result;
    │ │ │ │ -
    220 }
    │ │ │ │ -
    │ │ │ │ -
    221
    │ │ │ │ -
    223 template <class Scalar,
    │ │ │ │ -
    224 std::enable_if_t<IsNumber<Scalar>::value, int> = 0>
    │ │ │ │ -
    │ │ │ │ -
    225 friend auto operator* ( Scalar scalar, const FieldVector& vector)
    │ │ │ │ -
    226 {
    │ │ │ │ - │ │ │ │ -
    228
    │ │ │ │ -
    229 for (size_type i = 0; i < vector.size(); ++i)
    │ │ │ │ -
    230 result[i] = scalar * vector[i];
    │ │ │ │ -
    231
    │ │ │ │ -
    232 return result;
    │ │ │ │ -
    233 }
    │ │ │ │ -
    │ │ │ │ -
    234
    │ │ │ │ -
    236 template <class Scalar,
    │ │ │ │ -
    237 std::enable_if_t<IsNumber<Scalar>::value, int> = 0>
    │ │ │ │ -
    │ │ │ │ -
    238 friend auto operator/ ( const FieldVector& vector, Scalar scalar)
    │ │ │ │ -
    239 {
    │ │ │ │ - │ │ │ │ -
    241
    │ │ │ │ -
    242 for (size_type i = 0; i < vector.size(); ++i)
    │ │ │ │ -
    243 result[i] = vector[i] / scalar;
    │ │ │ │ -
    244
    │ │ │ │ -
    245 return result;
    │ │ │ │ -
    246 }
    │ │ │ │ -
    │ │ │ │ +
    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 };
    │ │ │ │ -
    │ │ │ │ -
    249
    │ │ │ │ -
    261 template<class K, int SIZE>
    │ │ │ │ -
    │ │ │ │ -
    262 inline std::istream &operator>> ( std::istream &in,
    │ │ │ │ - │ │ │ │ -
    264 {
    │ │ │ │ - │ │ │ │ -
    266 for( typename FieldVector<K, SIZE>::size_type i = 0; i < SIZE; ++i )
    │ │ │ │ -
    267 in >> w[ i ];
    │ │ │ │ -
    268 if(in)
    │ │ │ │ -
    269 v = w;
    │ │ │ │ -
    270 return in;
    │ │ │ │ -
    271 }
    │ │ │ │ -
    │ │ │ │ -
    272
    │ │ │ │ -
    273#ifndef DOXYGEN
    │ │ │ │ -
    274 template< class K >
    │ │ │ │ -
    275 struct DenseMatVecTraits< FieldVector<K,1> >
    │ │ │ │ -
    276 {
    │ │ │ │ -
    277 typedef FieldVector<K,1> derived_type;
    │ │ │ │ -
    278 typedef K container_type;
    │ │ │ │ -
    279 typedef K value_type;
    │ │ │ │ -
    280 typedef size_t size_type;
    │ │ │ │ +
    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
    │ │ │ │ -
    285 template<class K>
    │ │ │ │ -
    286 class FieldVector<K, 1> :
    │ │ │ │ -
    287 public DenseVector< FieldVector<K,1> >
    │ │ │ │ -
    288 {
    │ │ │ │ -
    289 K _data;
    │ │ │ │ -
    290 typedef DenseVector< FieldVector<K,1> > Base;
    │ │ │ │ -
    291 public:
    │ │ │ │ -
    293 constexpr static int dimension = 1;
    │ │ │ │ -
    294
    │ │ │ │ -
    295 typedef typename Base::size_type size_type;
    │ │ │ │ -
    296
    │ │ │ │ -
    298 typedef K& reference;
    │ │ │ │ -
    299
    │ │ │ │ -
    301 typedef const K& const_reference;
    │ │ │ │ -
    302
    │ │ │ │ -
    303 //===== construction
    │ │ │ │ +
    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
    │ │ │ │ -
    306 constexpr FieldVector ()
    │ │ │ │ -
    307 : _data()
    │ │ │ │ -
    308 {}
    │ │ │ │ -
    309
    │ │ │ │ -
    311 template<typename T,
    │ │ │ │ -
    312 typename EnableIf = typename std::enable_if<
    │ │ │ │ -
    313 std::is_convertible<T, K>::value &&
    │ │ │ │ -
    314 ! std::is_base_of<DenseVector<typename FieldTraits<T>::field_type>, K
    │ │ │ │ -
    315 >::value
    │ │ │ │ -
    316 >::type
    │ │ │ │ -
    317 >
    │ │ │ │ -
    318 FieldVector (const T& k) : _data(k) {}
    │ │ │ │ -
    319
    │ │ │ │ -
    321 template<class C,
    │ │ │ │ -
    322 std::enable_if_t<
    │ │ │ │ -
    323 std::is_assignable<K&, typename DenseVector<C>::value_type>::value, int> = 0>
    │ │ │ │ -
    324 FieldVector (const DenseVector<C> & x)
    │ │ │ │ -
    325 {
    │ │ │ │ -
    326 static_assert(((bool)IsFieldVectorSizeCorrect<C,1>::value), "FieldVectors do not match in dimension!");
    │ │ │ │ -
    327 assert(x.size() == 1);
    │ │ │ │ -
    328 _data = x[0];
    │ │ │ │ -
    329 }
    │ │ │ │ -
    330
    │ │ │ │ -
    332 FieldVector(const FieldVector&) = default;
    │ │ │ │ -
    333
    │ │ │ │ -
    335 FieldVector& operator=(const FieldVector&) = default;
    │ │ │ │ -
    336
    │ │ │ │ -
    337 template <typename T>
    │ │ │ │ -
    338 FieldVector& operator= (const FieldVector<T, 1>& other)
    │ │ │ │ -
    339 {
    │ │ │ │ -
    340 _data = other[0];
    │ │ │ │ -
    341 return *this;
    │ │ │ │ -
    342 }
    │ │ │ │ -
    343
    │ │ │ │ -
    344 template<typename T, int N>
    │ │ │ │ -
    345 FieldVector& operator=(const FieldVector<T, N>&) = delete;
    │ │ │ │ +
    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
    │ │ │ │ +
    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
    │ │ │ │ -
    348 FieldVector (std::initializer_list<K> const &l)
    │ │ │ │ -
    349 {
    │ │ │ │ -
    350 assert(l.size() == 1);
    │ │ │ │ -
    351 _data = *l.begin();
    │ │ │ │ -
    352 }
    │ │ │ │ -
    353
    │ │ │ │ -
    355 template<typename T,
    │ │ │ │ -
    356 typename EnableIf = typename std::enable_if<
    │ │ │ │ -
    357 std::is_assignable<K&, T>::value &&
    │ │ │ │ -
    358 ! std::is_base_of<DenseVector<typename FieldTraits<T>::field_type>, K
    │ │ │ │ -
    359 >::value
    │ │ │ │ -
    360 >::type
    │ │ │ │ -
    361 >
    │ │ │ │ -
    362 inline FieldVector& operator= (const T& k)
    │ │ │ │ -
    363 {
    │ │ │ │ -
    364 _data = k;
    │ │ │ │ -
    365 return *this;
    │ │ │ │ -
    366 }
    │ │ │ │ -
    367
    │ │ │ │ -
    368 //===== forward methods to container
    │ │ │ │ -
    369 static constexpr size_type size () { return 1; }
    │ │ │ │ -
    370
    │ │ │ │ -
    371 K & operator[]([[maybe_unused]] size_type i)
    │ │ │ │ -
    372 {
    │ │ │ │ -
    373 DUNE_ASSERT_BOUNDS(i == 0);
    │ │ │ │ -
    374 return _data;
    │ │ │ │ -
    375 }
    │ │ │ │ -
    376 const K & operator[]([[maybe_unused]] size_type i) const
    │ │ │ │ -
    377 {
    │ │ │ │ -
    378 DUNE_ASSERT_BOUNDS(i == 0);
    │ │ │ │ -
    379 return _data;
    │ │ │ │ -
    380 }
    │ │ │ │ -
    381
    │ │ │ │ -
    383 K* data() noexcept
    │ │ │ │ -
    384 {
    │ │ │ │ -
    385 return &_data;
    │ │ │ │ -
    386 }
    │ │ │ │ -
    387
    │ │ │ │ -
    389 const K* data() const noexcept
    │ │ │ │ -
    390 {
    │ │ │ │ -
    391 return &_data;
    │ │ │ │ -
    392 }
    │ │ │ │ +
    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
    │ │ │ │ +
    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 //===== conversion operator
    │ │ │ │ -
    395
    │ │ │ │ -
    397 operator K& () { return _data; }
    │ │ │ │ -
    398
    │ │ │ │ -
    400 operator const K& () const { return _data; }
    │ │ │ │ -
    401 };
    │ │ │ │ -
    402
    │ │ │ │ -
    403 /* ----- FV / FV ----- */
    │ │ │ │ -
    404 /* mostly not necessary as these operations are already covered via the cast operator */
    │ │ │ │ -
    405
    │ │ │ │ -
    407 template<class K>
    │ │ │ │ -
    408 inline bool operator> (const FieldVector<K,1>& a, const FieldVector<K,1>& b)
    │ │ │ │ +
    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
    │ │ │ │ +
    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 return a[0]>b[0];
    │ │ │ │ -
    411 }
    │ │ │ │ -
    412
    │ │ │ │ -
    414 template<class K>
    │ │ │ │ -
    415 inline bool operator>= (const FieldVector<K,1>& a, const FieldVector<K,1>& b)
    │ │ │ │ +
    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 return a[0]>=b[0];
    │ │ │ │ -
    418 }
    │ │ │ │ -
    419
    │ │ │ │ -
    421 template<class K>
    │ │ │ │ -
    422 inline bool operator< (const FieldVector<K,1>& a, const FieldVector<K,1>& b)
    │ │ │ │ +
    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 a[0]<b[0];
    │ │ │ │ +
    424 return n;
    │ │ │ │
    425 }
    │ │ │ │
    426
    │ │ │ │ -
    428 template<class K>
    │ │ │ │ -
    429 inline bool operator<= (const FieldVector<K,1>& a, const FieldVector<K,1>& b)
    │ │ │ │ -
    430 {
    │ │ │ │ -
    431 return a[0]<=b[0];
    │ │ │ │ +
    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 assert(l < n);
    │ │ │ │ +
    431 return v[l];
    │ │ │ │
    432 }
    │ │ │ │
    433
    │ │ │ │ -
    434 /* ----- FV / scalar ----- */
    │ │ │ │ -
    435
    │ │ │ │ -
    437 template<class K>
    │ │ │ │ -
    438 inline FieldVector<K,1> operator+ (const FieldVector<K,1>& a, const K b)
    │ │ │ │ -
    439 {
    │ │ │ │ -
    440 return a[0]+b;
    │ │ │ │ -
    441 }
    │ │ │ │ -
    442
    │ │ │ │ -
    444 template<class K>
    │ │ │ │ -
    445 inline FieldVector<K,1> operator- (const FieldVector<K,1>& a, const K b)
    │ │ │ │ -
    446 {
    │ │ │ │ -
    447 return a[0]-b;
    │ │ │ │ -
    448 }
    │ │ │ │ -
    449
    │ │ │ │ -
    451 template<class K>
    │ │ │ │ -
    452 inline FieldVector<K,1> operator* (const FieldVector<K,1>& a, const K b)
    │ │ │ │ -
    453 {
    │ │ │ │ -
    454 return a[0]*b;
    │ │ │ │ -
    455 }
    │ │ │ │ -
    456
    │ │ │ │ -
    458 template<class K>
    │ │ │ │ -
    459 inline FieldVector<K,1> operator/ (const FieldVector<K,1>& a, const K b)
    │ │ │ │ -
    460 {
    │ │ │ │ -
    461 return a[0]/b;
    │ │ │ │ -
    462 }
    │ │ │ │ -
    463
    │ │ │ │ -
    465 template<class K>
    │ │ │ │ -
    466 inline bool operator> (const FieldVector<K,1>& a, const K b)
    │ │ │ │ -
    467 {
    │ │ │ │ -
    468 return a[0]>b;
    │ │ │ │ -
    469 }
    │ │ │ │ +
    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
    │ │ │ │ +
    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
    │ │ │ │ -
    472 template<class K>
    │ │ │ │ -
    473 inline bool operator>= (const FieldVector<K,1>& a, const K b)
    │ │ │ │ -
    474 {
    │ │ │ │ -
    475 return a[0]>=b;
    │ │ │ │ +
    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
    │ │ │ │ -
    479 template<class K>
    │ │ │ │ -
    480 inline bool operator< (const FieldVector<K,1>& a, const K b)
    │ │ │ │ -
    481 {
    │ │ │ │ -
    482 return a[0]<b;
    │ │ │ │ -
    483 }
    │ │ │ │ -
    484
    │ │ │ │ -
    486 template<class K>
    │ │ │ │ -
    487 inline bool operator<= (const FieldVector<K,1>& a, const K b)
    │ │ │ │ -
    488 {
    │ │ │ │ -
    489 return a[0]<=b;
    │ │ │ │ -
    490 }
    │ │ │ │ -
    491
    │ │ │ │ -
    493 template<class K>
    │ │ │ │ -
    494 inline bool operator== (const FieldVector<K,1>& a, const K b)
    │ │ │ │ -
    495 {
    │ │ │ │ -
    496 return a[0]==b;
    │ │ │ │ -
    497 }
    │ │ │ │ -
    498
    │ │ │ │ -
    500 template<class K>
    │ │ │ │ -
    501 inline bool operator!= (const FieldVector<K,1>& a, const K b)
    │ │ │ │ -
    502 {
    │ │ │ │ -
    503 return a[0]!=b;
    │ │ │ │ -
    504 }
    │ │ │ │ -
    505
    │ │ │ │ -
    506 /* ----- scalar / FV ------ */
    │ │ │ │ -
    507
    │ │ │ │ -
    509 template<class K>
    │ │ │ │ -
    510 inline FieldVector<K,1> operator+ (const K a, const FieldVector<K,1>& b)
    │ │ │ │ -
    511 {
    │ │ │ │ -
    512 return a+b[0];
    │ │ │ │ -
    513 }
    │ │ │ │ -
    514
    │ │ │ │ -
    516 template<class K>
    │ │ │ │ -
    517 inline FieldVector<K,1> operator- (const K a, const FieldVector<K,1>& b)
    │ │ │ │ -
    518 {
    │ │ │ │ -
    519 return a-b[0];
    │ │ │ │ -
    520 }
    │ │ │ │ -
    521
    │ │ │ │ -
    523 template<class K>
    │ │ │ │ -
    524 inline FieldVector<K,1> operator* (const K a, const FieldVector<K,1>& b)
    │ │ │ │ -
    525 {
    │ │ │ │ -
    526 return a*b[0];
    │ │ │ │ -
    527 }
    │ │ │ │ -
    528
    │ │ │ │ -
    530 template<class K>
    │ │ │ │ -
    531 inline FieldVector<K,1> operator/ (const K a, const FieldVector<K,1>& b)
    │ │ │ │ -
    532 {
    │ │ │ │ -
    533 return a/b[0];
    │ │ │ │ -
    534 }
    │ │ │ │ -
    535
    │ │ │ │ -
    537 template<class K>
    │ │ │ │ -
    538 inline bool operator> (const K a, const FieldVector<K,1>& b)
    │ │ │ │ -
    539 {
    │ │ │ │ -
    540 return a>b[0];
    │ │ │ │ -
    541 }
    │ │ │ │ -
    542
    │ │ │ │ -
    544 template<class K>
    │ │ │ │ -
    545 inline bool operator>= (const K a, const FieldVector<K,1>& b)
    │ │ │ │ -
    546 {
    │ │ │ │ -
    547 return a>=b[0];
    │ │ │ │ -
    548 }
    │ │ │ │ -
    549
    │ │ │ │ -
    551 template<class K>
    │ │ │ │ -
    552 inline bool operator< (const K a, const FieldVector<K,1>& b)
    │ │ │ │ -
    553 {
    │ │ │ │ -
    554 return a<b[0];
    │ │ │ │ -
    555 }
    │ │ │ │ -
    556
    │ │ │ │ -
    558 template<class K>
    │ │ │ │ -
    559 inline bool operator<= (const K a, const FieldVector<K,1>& b)
    │ │ │ │ -
    560 {
    │ │ │ │ -
    561 return a<=b[0];
    │ │ │ │ -
    562 }
    │ │ │ │ -
    563
    │ │ │ │ -
    565 template<class K>
    │ │ │ │ -
    566 inline bool operator== (const K a, const FieldVector<K,1>& b)
    │ │ │ │ -
    567 {
    │ │ │ │ -
    568 return a==b[0];
    │ │ │ │ -
    569 }
    │ │ │ │ -
    570
    │ │ │ │ -
    572 template<class K>
    │ │ │ │ -
    573 inline bool operator!= (const K a, const FieldVector<K,1>& b)
    │ │ │ │ -
    574 {
    │ │ │ │ -
    575 return a!=b[0];
    │ │ │ │ -
    576 }
    │ │ │ │ -
    577#endif
    │ │ │ │ -
    578
    │ │ │ │ -
    579 /* Overloads for common classification functions */
    │ │ │ │ -
    │ │ │ │ -
    580 namespace MathOverloads {
    │ │ │ │ -
    581
    │ │ │ │ -
    582 // ! Returns whether all entries are finite
    │ │ │ │ -
    583 template<class K, int SIZE>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    585 bool out = true;
    │ │ │ │ -
    586 for(int i=0; i<SIZE; i++) {
    │ │ │ │ -
    587 out &= Dune::isFinite(b[i]);
    │ │ │ │ -
    588 }
    │ │ │ │ -
    589 return out;
    │ │ │ │ -
    590 }
    │ │ │ │ -
    │ │ │ │ -
    591
    │ │ │ │ -
    592 // ! Returns whether any entry is infinite
    │ │ │ │ -
    593 template<class K, int SIZE>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    595 bool out = false;
    │ │ │ │ -
    596 for(int i=0; i<SIZE; i++) {
    │ │ │ │ -
    597 out |= Dune::isInf(b[i]);
    │ │ │ │ -
    598 }
    │ │ │ │ -
    599 return out;
    │ │ │ │ -
    600 }
    │ │ │ │ -
    │ │ │ │ -
    601
    │ │ │ │ -
    602 // ! Returns whether any entry is NaN
    │ │ │ │ -
    603 template<class K, int SIZE, typename = std::enable_if_t<HasNaN<K>::value>>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    605 bool out = false;
    │ │ │ │ -
    606 for(int i=0; i<SIZE; i++) {
    │ │ │ │ -
    607 out |= Dune::isNaN(b[i]);
    │ │ │ │ -
    608 }
    │ │ │ │ -
    609 return out;
    │ │ │ │ -
    610 }
    │ │ │ │ -
    │ │ │ │ -
    611
    │ │ │ │ -
    612 // ! Returns true if either b or c is NaN
    │ │ │ │ -
    613 template<class K, typename = std::enable_if_t<HasNaN<K>::value>>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ - │ │ │ │ -
    616 return Dune::isUnordered(b[0],c[0]);
    │ │ │ │ -
    617 }
    │ │ │ │ -
    │ │ │ │ -
    618 } //MathOverloads
    │ │ │ │ -
    │ │ │ │ -
    619
    │ │ │ │ -
    622} // end namespace
    │ │ │ │ -
    623
    │ │ │ │ -
    624#endif
    │ │ │ │ -
    Compute type of the result of an arithmetic operation involving two different number types.
    │ │ │ │ -
    Traits for type conversions and type information.
    │ │ │ │ -
    A few common exception classes.
    │ │ │ │ -
    Type traits to determine the type of reals (when working with complex numbers)
    │ │ │ │ -
    Some useful basic math stuff.
    │ │ │ │ -
    Macro for wrapping boundary checks.
    │ │ │ │ -
    Implements the dense vector interface, with an exchangeable storage class.
    │ │ │ │ -
    #define DUNE_ASSERT_BOUNDS(cond)
    If DUNE_CHECK_BOUNDS is defined: check if condition cond holds; otherwise, do nothing.
    Definition boundschecking.hh:30
    │ │ │ │ -
    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:556
    │ │ │ │ +
    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
    │ │ │ │ + │ │ │ │ +
    Compatibility header for including <Vc/Vc>
    │ │ │ │ +
    Utilities for reduction like operations on ranges.
    │ │ │ │ + │ │ │ │ +
    Traits for type conversions and type information.
    │ │ │ │
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ -
    bool isNaN(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag)
    Definition fvector.hh:604
    │ │ │ │ -
    bool isInf(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag)
    Definition fvector.hh:594
    │ │ │ │ -
    auto isFinite(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag)
    Definition fvector.hh:584
    │ │ │ │ -
    bool isUnordered(const FieldVector< K, 1 > &b, const FieldVector< K, 1 > &c, PriorityTag< 2 >, ADLTag)
    Definition fvector.hh:614
    │ │ │ │ -
    vector space out of a tensor product of fields.
    Definition fvector.hh:95
    │ │ │ │ -
    K * data() noexcept
    return pointer to underlying array
    Definition fvector.hh:198
    │ │ │ │ -
    constexpr FieldVector()
    Constructor making default-initialized vector.
    Definition fvector.hh:112
    │ │ │ │ -
    const value_type & const_reference
    The type used for const references to the vector entry.
    Definition fvector.hh:109
    │ │ │ │ -
    Base::size_type size_type
    Definition fvector.hh:102
    │ │ │ │ -
    FieldVector(const DenseVector< C > &x, typename std::enable_if< IsFieldVectorSizeCorrect< C, SIZE >::value >::type *dummy=0)
    Copy constructor from a second vector of possibly different type.
    Definition fvector.hh:165
    │ │ │ │ -
    FieldVector(const FieldVector< T, N > &)=delete
    │ │ │ │ -
    FieldVector(const K &t)
    Constructor making vector with identical coordinates.
    Definition fvector.hh:117
    │ │ │ │ -
    FieldVector(std::initializer_list< K > const &l)
    Construct from a std::initializer_list.
    Definition fvector.hh:132
    │ │ │ │ -
    const K * data() const noexcept
    return pointer to underlying array
    Definition fvector.hh:204
    │ │ │ │ -
    static constexpr int dimension
    The size of this vector.
    Definition fvector.hh:100
    │ │ │ │ -
    FieldVector(const FieldVector< K1, SIZE > &x)
    Constructor making vector with identical coordinates.
    Definition fvector.hh:175
    │ │ │ │ -
    static constexpr size_type size()
    Definition fvector.hh:186
    │ │ │ │ -
    K & operator[](size_type i)
    Definition fvector.hh:188
    │ │ │ │ -
    value_type & reference
    The type used for references to the vector entry.
    Definition fvector.hh:106
    │ │ │ │ -
    Base::value_type value_type
    Definition fvector.hh:103
    │ │ │ │ -
    const K & operator[](size_type i) const
    Definition fvector.hh:192
    │ │ │ │ -
    FieldVector & operator=(const FieldVector< T, N > &)=delete
    │ │ │ │ -
    FieldVector(const FieldVector &)=default
    Copy constructor.
    │ │ │ │ -
    Interface for a class of dense vectors over a given field.
    Definition densevector.hh:229
    │ │ │ │ -
    Traits::value_type value_type
    export the type representing the field
    Definition densevector.hh:250
    │ │ │ │ -
    Iterator begin()
    begin iterator
    Definition densevector.hh:347
    │ │ │ │ -
    size_type size() const
    size method
    Definition densevector.hh:336
    │ │ │ │ -
    Traits::size_type size_type
    The type used for the index access and size operation.
    Definition densevector.hh:259
    │ │ │ │ -
    Definition ftraits.hh:26
    │ │ │ │ -
    T field_type
    export the type representing the field
    Definition ftraits.hh:28
    │ │ │ │ -
    T real_type
    export the type representing the real type of the field
    Definition ftraits.hh:30
    │ │ │ │ - │ │ │ │ -
    std::array< K, SIZE > container_type
    Definition fvector.hh:44
    │ │ │ │ -
    container_type::size_type size_type
    Definition fvector.hh:46
    │ │ │ │ -
    FieldVector< K, SIZE > derived_type
    Definition fvector.hh:43
    │ │ │ │ -
    FieldTraits< K >::real_type real_type
    Definition fvector.hh:53
    │ │ │ │ -
    FieldTraits< K >::field_type field_type
    Definition fvector.hh:52
    │ │ │ │ -
    TMP to check the size of a DenseVectors statically, if possible.
    Definition fvector.hh:66
    │ │ │ │ -
    static constexpr bool value
    True if C is not of type FieldVector or its dimension is not equal SIZE.
    Definition fvector.hh:71
    │ │ │ │ -
    Tag to make sure the functions in this namespace can be found by ADL.
    Definition math.hh:230
    │ │ │ │ -
    Definition matvectraits.hh:31
    │ │ │ │ -
    Helper class for tagging priorities.
    Definition typeutilities.hh:73
    │ │ │ │ +
    bool any_true(const AlignedNumber< bool, align > &val)
    Definition debugalign.hh:493
    │ │ │ │ +
    bool all_true(const AlignedNumber< bool, align > &val)
    Definition debugalign.hh:499
    │ │ │ │ +
    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:481
    │ │ │ │ +
    T min_value(const AlignedNumber< T, align > &val)
    Definition debugalign.hh:487
    │ │ │ │ +
    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:115
    │ │ │ │ +
    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 {} │ │ │ │ │ @@ -7,715 +7,552 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -fvector.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 (C) DUNE Project contributors, see file │ │ │ │ │ + 1// SPDX-FileCopyrightInfo: Copyright (C) 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_FVECTOR_HH │ │ │ │ │ - 6#define DUNE_FVECTOR_HH │ │ │ │ │ - 7 │ │ │ │ │ - 8#include │ │ │ │ │ - 9#include │ │ │ │ │ - 10#include │ │ │ │ │ - 11#include │ │ │ │ │ - 12#include │ │ │ │ │ - 13#include │ │ │ │ │ - 14#include │ │ │ │ │ - 15#include │ │ │ │ │ - 16#include │ │ │ │ │ - 17 │ │ │ │ │ - 18#include "typetraits.hh" │ │ │ │ │ - 19#include "exceptions.hh" │ │ │ │ │ - 20 │ │ │ │ │ - 21#include "ftraits.hh" │ │ │ │ │ - 22#include "densevector.hh" │ │ │ │ │ - 23#include "boundschecking.hh" │ │ │ │ │ - 24 │ │ │ │ │ - 25#include │ │ │ │ │ - 26#include │ │ │ │ │ - 27 │ │ │ │ │ - 28namespace Dune { │ │ │ │ │ - 29 │ │ │ │ │ - 39 template< class K, int SIZE > class FieldVector; │ │ │ │ │ - 40 template< class K, int SIZE > │ │ │ │ │ -41 struct DenseMatVecTraits< FieldVector > │ │ │ │ │ - 42 { │ │ │ │ │ -43 typedef FieldVector derived_type; │ │ │ │ │ -44 typedef std::array container_type; │ │ │ │ │ -45 typedef K value_type; │ │ │ │ │ -46 typedef typename container_type::size_type size_type; │ │ │ │ │ - 47 }; │ │ │ │ │ + 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 │ │ │ │ │ + 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 template< class K, int SIZE > │ │ │ │ │ -50 struct FieldTraits< FieldVector > │ │ │ │ │ - 51 { │ │ │ │ │ -52 typedef typename FieldTraits::field_type field_type; │ │ │ │ │ -53 typedef typename FieldTraits::real_type real_type; │ │ │ │ │ - 54 }; │ │ │ │ │ - 55 │ │ │ │ │ - 64 template │ │ │ │ │ -65 struct IsFieldVectorSizeCorrect │ │ │ │ │ - 66 { │ │ │ │ │ -71 constexpr static bool value = true; │ │ │ │ │ - 72 }; │ │ │ │ │ - 73 │ │ │ │ │ - 74 template │ │ │ │ │ -75 struct IsFieldVectorSizeCorrect,SIZE> │ │ │ │ │ - 76 { │ │ │ │ │ -77 constexpr static bool value = true; │ │ │ │ │ - 78 }; │ │ │ │ │ + 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 template │ │ │ │ │ -81 struct IsFieldVectorSizeCorrect,SIZE> │ │ │ │ │ - 82 { │ │ │ │ │ -83 constexpr static bool value = false; │ │ │ │ │ - 84 }; │ │ │ │ │ - 85 │ │ │ │ │ - 86 │ │ │ │ │ - 92 template< class K, int SIZE > │ │ │ │ │ -93 class FieldVector : │ │ │ │ │ - 94 public DenseVector< FieldVector > │ │ │ │ │ - 95 { │ │ │ │ │ - 96 std::array _data; │ │ │ │ │ - 97 typedef DenseVector<_FieldVector > Base; │ │ │ │ │ - 98 public: │ │ │ │ │ -100 constexpr static int dimension = SIZE; │ │ │ │ │ - 101 │ │ │ │ │ -102 typedef typename Base::size_type size_type; │ │ │ │ │ -103 typedef typename Base::value_type value_type; │ │ │ │ │ + 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 │ │ │ │ │ -106 typedef value_type& reference; │ │ │ │ │ - 107 │ │ │ │ │ -109 typedef const value_type& const_reference; │ │ │ │ │ - 110 │ │ │ │ │ -112 constexpr FieldVector() │ │ │ │ │ - 113 : _data{{}} │ │ │ │ │ - 114 {} │ │ │ │ │ - 115 │ │ │ │ │ -117 explicit FieldVector (const K& t) │ │ │ │ │ - 118 { │ │ │ │ │ - 119 std::fill(_data.begin(),_data.end(),t); │ │ │ │ │ - 120 } │ │ │ │ │ + 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#if __GNUC__ == 5 && !defined(__clang__) │ │ │ │ │ - 123 // `... = default;` causes an internal compiler error on GCC 5.4 (Ubuntu │ │ │ │ │ -16.04) │ │ │ │ │ - 125 FieldVector(const FieldVector& x) : _data(x._data) {} │ │ │ │ │ - 126#else │ │ │ │ │ -128 FieldVector (const FieldVector&) = default; │ │ │ │ │ - 129#endif │ │ │ │ │ - 130 │ │ │ │ │ -132 FieldVector (std::initializer_list const &l) │ │ │ │ │ - 133 { │ │ │ │ │ - 134 assert(l.size() == dimension);// Actually, this is not needed any more! │ │ │ │ │ - 135 std::copy_n(l.begin(), std::min(static_cast(dimension), │ │ │ │ │ - 136 l.size()), │ │ │ │ │ - 137 _data.begin()); │ │ │ │ │ - 138 } │ │ │ │ │ - 139 │ │ │ │ │ -141 FieldVector& operator= (const FieldVector&) = default; │ │ │ │ │ - 142 │ │ │ │ │ - 143 template │ │ │ │ │ -144 FieldVector& operator= (const FieldVector& x) │ │ │ │ │ - 145 { │ │ │ │ │ - 146 std::copy_n(x.begin(), SIZE, _data.begin()); │ │ │ │ │ - 147 return *this; │ │ │ │ │ - 148 } │ │ │ │ │ - 149 │ │ │ │ │ - 150 template │ │ │ │ │ -151 FieldVector& operator=(const FieldVector&) = delete; │ │ │ │ │ + 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 │ │ │ │ │ - 164 template │ │ │ │ │ -165 FieldVector (const DenseVector & x, │ │ │ │ │ - 166 [[maybe_unused]] typename std:: │ │ │ │ │ -enable_if::value>::type* dummy=0) │ │ │ │ │ - 167 { │ │ │ │ │ - 168 // do a run-time size check, for the case that x is not a FieldVector │ │ │ │ │ - 169 assert(x.size() == SIZE); // Actually this is not needed any more! │ │ │ │ │ - 170 std::copy_n(x.begin(), std::min(static_cast(SIZE),x.size()), │ │ │ │ │ -_data.begin()); │ │ │ │ │ - 171 } │ │ │ │ │ - 172 │ │ │ │ │ - 174 template │ │ │ │ │ -175 explicit FieldVector (const FieldVector & x) │ │ │ │ │ - 176 { │ │ │ │ │ - 177 std::copy_n(x.begin(), SIZE, _data.begin()); │ │ │ │ │ - 178 } │ │ │ │ │ - 179 │ │ │ │ │ - 180 template │ │ │ │ │ -181 explicit FieldVector(const FieldVector&) = delete; │ │ │ │ │ - 182 │ │ │ │ │ - 183 using Base::operator=; │ │ │ │ │ - 184 │ │ │ │ │ - 185 // make this thing a vector │ │ │ │ │ -186 static constexpr size_type size () { return SIZE; } │ │ │ │ │ - 187 │ │ │ │ │ -188 K & operator[](size_type i) { │ │ │ │ │ - 189 DUNE_ASSERT_BOUNDS(i < SIZE); │ │ │ │ │ - 190 return _data[i]; │ │ │ │ │ - 191 } │ │ │ │ │ -192 const K & operator[](size_type i) const { │ │ │ │ │ - 193 DUNE_ASSERT_BOUNDS(i < SIZE); │ │ │ │ │ - 194 return _data[i]; │ │ │ │ │ - 195 } │ │ │ │ │ - 196 │ │ │ │ │ -198 K* data() noexcept │ │ │ │ │ - 199 { │ │ │ │ │ - 200 return _data.data(); │ │ │ │ │ - 201 } │ │ │ │ │ - 202 │ │ │ │ │ -204 const K* data() const noexcept │ │ │ │ │ - 205 { │ │ │ │ │ - 206 return _data.data(); │ │ │ │ │ - 207 } │ │ │ │ │ + 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 │ │ │ │ │ + 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 │ │ │ │ │ - 210 template ::value, int> = 0> │ │ │ │ │ -212 friend auto operator*( const FieldVector& vector, Scalar scalar) │ │ │ │ │ - 213 { │ │ │ │ │ - 214 FieldVector:: │ │ │ │ │ -PromotedType,SIZE> result; │ │ │ │ │ - 215 │ │ │ │ │ - 216 for (size_type i = 0; i < vector.size(); ++i) │ │ │ │ │ - 217 result[i] = vector[i] * scalar; │ │ │ │ │ + 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 return result; │ │ │ │ │ - 220 } │ │ │ │ │ - 221 │ │ │ │ │ - 223 template ::value, int> = 0> │ │ │ │ │ -225 friend auto operator*( Scalar scalar, const FieldVector& vector) │ │ │ │ │ - 226 { │ │ │ │ │ - 227 FieldVector:: │ │ │ │ │ -PromotedType,SIZE> result; │ │ │ │ │ - 228 │ │ │ │ │ - 229 for (size_type i = 0; i < vector.size(); ++i) │ │ │ │ │ - 230 result[i] = scalar * vector[i]; │ │ │ │ │ - 231 │ │ │ │ │ - 232 return result; │ │ │ │ │ - 233 } │ │ │ │ │ - 234 │ │ │ │ │ - 236 template ::value, int> = 0> │ │ │ │ │ -238 friend auto operator/( const FieldVector& vector, Scalar scalar) │ │ │ │ │ - 239 { │ │ │ │ │ - 240 FieldVector:: │ │ │ │ │ -PromotedType,SIZE> result; │ │ │ │ │ - 241 │ │ │ │ │ - 242 for (size_type i = 0; i < vector.size(); ++i) │ │ │ │ │ - 243 result[i] = vector[i] / scalar; │ │ │ │ │ - 244 │ │ │ │ │ - 245 return result; │ │ │ │ │ - 246 } │ │ │ │ │ + 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 │ │ │ │ │ + 233 template │ │ │ │ │ +234 struct SimdIndexTypeTraits { │ │ │ │ │ +235 using type = std::size_t; │ │ │ │ │ + 236 }; │ │ │ │ │ + 237 │ │ │ │ │ + 239 │ │ │ │ │ + 245 template │ │ │ │ │ +246 using SimdIndex = typename SimdIndexTypeTraits::type; │ │ │ │ │ 247 │ │ │ │ │ - 248 }; │ │ │ │ │ - 249 │ │ │ │ │ - 261 template │ │ │ │ │ -262 inline std::istream &operator>> ( std::istream &in, │ │ │ │ │ - 263 FieldVector &v ) │ │ │ │ │ - 264 { │ │ │ │ │ - 265 FieldVector w; │ │ │ │ │ - 266 for( typename FieldVector::size_type i = 0; i < SIZE; ++i ) │ │ │ │ │ - 267 in >> w[ i ]; │ │ │ │ │ - 268 if(in) │ │ │ │ │ - 269 v = w; │ │ │ │ │ - 270 return in; │ │ │ │ │ - 271 } │ │ │ │ │ - 272 │ │ │ │ │ - 273#ifndef DOXYGEN │ │ │ │ │ - 274 template< class K > │ │ │ │ │ - 275 struct DenseMatVecTraits< FieldVector > │ │ │ │ │ - 276 { │ │ │ │ │ - 277 typedef FieldVector derived_type; │ │ │ │ │ - 278 typedef K container_type; │ │ │ │ │ - 279 typedef K value_type; │ │ │ │ │ - 280 typedef size_t size_type; │ │ │ │ │ + 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 │ │ │ │ │ - 285 template │ │ │ │ │ - 286 class FieldVector : │ │ │ │ │ - 287 public DenseVector< FieldVector > │ │ │ │ │ - 288 { │ │ │ │ │ - 289 K _data; │ │ │ │ │ - 290 typedef DenseVector< FieldVector > Base; │ │ │ │ │ - 291 public: │ │ │ │ │ - 293 constexpr static int dimension = 1; │ │ │ │ │ - 294 │ │ │ │ │ - 295 typedef typename Base::size_type size_type; │ │ │ │ │ - 296 │ │ │ │ │ - 298 typedef K& reference; │ │ │ │ │ - 299 │ │ │ │ │ - 301 typedef const K& const_reference; │ │ │ │ │ - 302 │ │ │ │ │ - 303 //===== construction │ │ │ │ │ + 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 │ │ │ │ │ - 306 constexpr FieldVector () │ │ │ │ │ - 307 : _data() │ │ │ │ │ - 308 {} │ │ │ │ │ - 309 │ │ │ │ │ - 311 template::value && │ │ │ │ │ - 314 ! std::is_base_of::field_type>, K │ │ │ │ │ - 315 >::value │ │ │ │ │ - 316 >::type │ │ │ │ │ - 317 > │ │ │ │ │ - 318 FieldVector (const T& k) : _data(k) {} │ │ │ │ │ - 319 │ │ │ │ │ - 321 template::value_type>::value, int> = │ │ │ │ │ -0> │ │ │ │ │ - 324 FieldVector (const DenseVector & x) │ │ │ │ │ + 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 │ │ │ │ │ + 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 static_assert(((bool)IsFieldVectorSizeCorrect::value), "FieldVectors │ │ │ │ │ -do not match in dimension!"); │ │ │ │ │ - 327 assert(x.size() == 1); │ │ │ │ │ - 328 _data = x[0]; │ │ │ │ │ - 329 } │ │ │ │ │ - 330 │ │ │ │ │ - 332 FieldVector(const FieldVector&) = default; │ │ │ │ │ - 333 │ │ │ │ │ - 335 FieldVector& operator=(const FieldVector&) = default; │ │ │ │ │ - 336 │ │ │ │ │ - 337 template │ │ │ │ │ - 338 FieldVector& operator= (const FieldVector& other) │ │ │ │ │ - 339 { │ │ │ │ │ - 340 _data = other[0]; │ │ │ │ │ - 341 return *this; │ │ │ │ │ - 342 } │ │ │ │ │ - 343 │ │ │ │ │ - 344 template │ │ │ │ │ - 345 FieldVector& operator=(const FieldVector&) = delete; │ │ │ │ │ + 326 return v.min(); │ │ │ │ │ + 327 } │ │ │ │ │ + 328 │ │ │ │ │ + 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 return Vc::any_of(v); │ │ │ │ │ + 345 } │ │ │ │ │ 346 │ │ │ │ │ - 348 FieldVector (std::initializer_list const &l) │ │ │ │ │ + 347 template │ │ │ │ │ + 348 bool all_true(const Vc::Mask & v) │ │ │ │ │ 349 { │ │ │ │ │ - 350 assert(l.size() == 1); │ │ │ │ │ - 351 _data = *l.begin(); │ │ │ │ │ - 352 } │ │ │ │ │ - 353 │ │ │ │ │ - 355 template::value && │ │ │ │ │ - 358 ! std::is_base_of::field_type>, K │ │ │ │ │ - 359 >::value │ │ │ │ │ - 360 >::type │ │ │ │ │ - 361 > │ │ │ │ │ - 362 inline FieldVector& operator= (const T& k) │ │ │ │ │ - 363 { │ │ │ │ │ - 364 _data = k; │ │ │ │ │ - 365 return *this; │ │ │ │ │ - 366 } │ │ │ │ │ - 367 │ │ │ │ │ - 368 //===== forward methods to container │ │ │ │ │ - 369 static constexpr size_type size () { return 1; } │ │ │ │ │ - 370 │ │ │ │ │ - 371 K & operator[]([[maybe_unused]] size_type i) │ │ │ │ │ - 372 { │ │ │ │ │ - 373 DUNE_ASSERT_BOUNDS(i == 0); │ │ │ │ │ - 374 return _data; │ │ │ │ │ - 375 } │ │ │ │ │ - 376 const K & operator[]([[maybe_unused]] size_type i) const │ │ │ │ │ - 377 { │ │ │ │ │ - 378 DUNE_ASSERT_BOUNDS(i == 0); │ │ │ │ │ - 379 return _data; │ │ │ │ │ - 380 } │ │ │ │ │ - 381 │ │ │ │ │ - 383 K* data() noexcept │ │ │ │ │ - 384 { │ │ │ │ │ - 385 return &_data; │ │ │ │ │ - 386 } │ │ │ │ │ - 387 │ │ │ │ │ - 389 const K* data() const noexcept │ │ │ │ │ - 390 { │ │ │ │ │ - 391 return &_data; │ │ │ │ │ + 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#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#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 //===== conversion operator │ │ │ │ │ - 395 │ │ │ │ │ - 397 operator K& () { return _data; } │ │ │ │ │ - 398 │ │ │ │ │ - 400 operator const K& () const { return _data; } │ │ │ │ │ - 401 }; │ │ │ │ │ - 402 │ │ │ │ │ - 403 /* ----- FV / FV ----- */ │ │ │ │ │ - 404 /* mostly not necessary as these operations are already covered via the │ │ │ │ │ -cast operator */ │ │ │ │ │ - 405 │ │ │ │ │ - 407 template │ │ │ │ │ - 408 inline bool operator> (const FieldVector& a, const FieldVector& │ │ │ │ │ -b) │ │ │ │ │ + 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 │ │ │ │ │ + 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 return a[0]>b[0]; │ │ │ │ │ - 411 } │ │ │ │ │ - 412 │ │ │ │ │ - 414 template │ │ │ │ │ - 415 inline bool operator>= (const FieldVector& a, const FieldVector& │ │ │ │ │ -b) │ │ │ │ │ + 410 assert(l < n); │ │ │ │ │ + 411 return v[l]; │ │ │ │ │ + 412 } │ │ │ │ │ + 413 │ │ │ │ │ + 414 template │ │ │ │ │ + 415 auto lane(std::size_t l, Vc::SimdArray &v) │ │ │ │ │ 416 { │ │ │ │ │ - 417 return a[0]>=b[0]; │ │ │ │ │ - 418 } │ │ │ │ │ - 419 │ │ │ │ │ - 421 template │ │ │ │ │ - 422 inline bool operator< (const FieldVector& a, const FieldVector& │ │ │ │ │ -b) │ │ │ │ │ + 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 a[0] │ │ │ │ │ - 429 inline bool operator<= (const FieldVector& a, const FieldVector& │ │ │ │ │ -b) │ │ │ │ │ - 430 { │ │ │ │ │ - 431 return a[0]<=b[0]; │ │ │ │ │ + 427 template │ │ │ │ │ + 428 bool lane(std::size_t l, const Vc::SimdMaskArray &v) │ │ │ │ │ + 429 { │ │ │ │ │ + 430 assert(l < n); │ │ │ │ │ + 431 return v[l]; │ │ │ │ │ 432 } │ │ │ │ │ 433 │ │ │ │ │ - 434 /* ----- FV / scalar ----- */ │ │ │ │ │ - 435 │ │ │ │ │ - 437 template │ │ │ │ │ - 438 inline FieldVector operator+ (const FieldVector& a, const K b) │ │ │ │ │ - 439 { │ │ │ │ │ - 440 return a[0]+b; │ │ │ │ │ - 441 } │ │ │ │ │ - 442 │ │ │ │ │ - 444 template │ │ │ │ │ - 445 inline FieldVector operator- (const FieldVector& a, const K b) │ │ │ │ │ - 446 { │ │ │ │ │ - 447 return a[0]-b; │ │ │ │ │ - 448 } │ │ │ │ │ - 449 │ │ │ │ │ - 451 template │ │ │ │ │ - 452 inline FieldVector operator* (const FieldVector& a, const K b) │ │ │ │ │ - 453 { │ │ │ │ │ - 454 return a[0]*b; │ │ │ │ │ - 455 } │ │ │ │ │ - 456 │ │ │ │ │ - 458 template │ │ │ │ │ - 459 inline FieldVector operator/ (const FieldVector& a, const K b) │ │ │ │ │ - 460 { │ │ │ │ │ - 461 return a[0]/b; │ │ │ │ │ - 462 } │ │ │ │ │ - 463 │ │ │ │ │ - 465 template │ │ │ │ │ - 466 inline bool operator> (const FieldVector& a, const K b) │ │ │ │ │ - 467 { │ │ │ │ │ - 468 return a[0]>b; │ │ │ │ │ - 469 } │ │ │ │ │ + 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 │ │ │ │ │ + 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 │ │ │ │ │ - 472 template │ │ │ │ │ - 473 inline bool operator>= (const FieldVector& a, const K b) │ │ │ │ │ - 474 { │ │ │ │ │ - 475 return a[0]>=b; │ │ │ │ │ + 471 template │ │ │ │ │ +472 void swap(T &v1, T &v2, bool mask) │ │ │ │ │ + 473 { │ │ │ │ │ + 474 using std::swap; │ │ │ │ │ + 475 if(mask) swap(v1, v2); │ │ │ │ │ 476 } │ │ │ │ │ 477 │ │ │ │ │ - 479 template │ │ │ │ │ - 480 inline bool operator< (const FieldVector& a, const K b) │ │ │ │ │ - 481 { │ │ │ │ │ - 482 return a[0] │ │ │ │ │ - 487 inline bool operator<= (const FieldVector& a, const K b) │ │ │ │ │ - 488 { │ │ │ │ │ - 489 return a[0]<=b; │ │ │ │ │ - 490 } │ │ │ │ │ - 491 │ │ │ │ │ - 493 template │ │ │ │ │ - 494 inline bool operator== (const FieldVector& a, const K b) │ │ │ │ │ - 495 { │ │ │ │ │ - 496 return a[0]==b; │ │ │ │ │ - 497 } │ │ │ │ │ - 498 │ │ │ │ │ - 500 template │ │ │ │ │ - 501 inline bool operator!= (const FieldVector& a, const K b) │ │ │ │ │ - 502 { │ │ │ │ │ - 503 return a[0]!=b; │ │ │ │ │ - 504 } │ │ │ │ │ - 505 │ │ │ │ │ - 506 /* ----- scalar / FV ------ */ │ │ │ │ │ - 507 │ │ │ │ │ - 509 template │ │ │ │ │ - 510 inline FieldVector operator+ (const K a, const FieldVector& b) │ │ │ │ │ - 511 { │ │ │ │ │ - 512 return a+b[0]; │ │ │ │ │ - 513 } │ │ │ │ │ - 514 │ │ │ │ │ - 516 template │ │ │ │ │ - 517 inline FieldVector operator- (const K a, const FieldVector& b) │ │ │ │ │ - 518 { │ │ │ │ │ - 519 return a-b[0]; │ │ │ │ │ - 520 } │ │ │ │ │ - 521 │ │ │ │ │ - 523 template │ │ │ │ │ - 524 inline FieldVector operator* (const K a, const FieldVector& b) │ │ │ │ │ - 525 { │ │ │ │ │ - 526 return a*b[0]; │ │ │ │ │ - 527 } │ │ │ │ │ - 528 │ │ │ │ │ - 530 template │ │ │ │ │ - 531 inline FieldVector operator/ (const K a, const FieldVector& b) │ │ │ │ │ - 532 { │ │ │ │ │ - 533 return a/b[0]; │ │ │ │ │ - 534 } │ │ │ │ │ - 535 │ │ │ │ │ - 537 template │ │ │ │ │ - 538 inline bool operator> (const K a, const FieldVector& b) │ │ │ │ │ - 539 { │ │ │ │ │ - 540 return a>b[0]; │ │ │ │ │ - 541 } │ │ │ │ │ - 542 │ │ │ │ │ - 544 template │ │ │ │ │ - 545 inline bool operator>= (const K a, const FieldVector& b) │ │ │ │ │ - 546 { │ │ │ │ │ - 547 return a>=b[0]; │ │ │ │ │ - 548 } │ │ │ │ │ - 549 │ │ │ │ │ - 551 template │ │ │ │ │ - 552 inline bool operator< (const K a, const FieldVector& b) │ │ │ │ │ - 553 { │ │ │ │ │ - 554 return a │ │ │ │ │ - 559 inline bool operator<= (const K a, const FieldVector& b) │ │ │ │ │ - 560 { │ │ │ │ │ - 561 return a<=b[0]; │ │ │ │ │ - 562 } │ │ │ │ │ - 563 │ │ │ │ │ - 565 template │ │ │ │ │ - 566 inline bool operator== (const K a, const FieldVector& b) │ │ │ │ │ - 567 { │ │ │ │ │ - 568 return a==b[0]; │ │ │ │ │ - 569 } │ │ │ │ │ - 570 │ │ │ │ │ - 572 template │ │ │ │ │ - 573 inline bool operator!= (const K a, const FieldVector& b) │ │ │ │ │ - 574 { │ │ │ │ │ - 575 return a!=b[0]; │ │ │ │ │ - 576 } │ │ │ │ │ - 577#endif │ │ │ │ │ - 578 │ │ │ │ │ - 579 /* Overloads for common classification functions */ │ │ │ │ │ -580 namespace MathOverloads { │ │ │ │ │ - 581 │ │ │ │ │ - 582 // ! Returns whether all entries are finite │ │ │ │ │ - 583 template │ │ │ │ │ -584 auto isFinite(const FieldVector &b, PriorityTag<2>, ADLTag) { │ │ │ │ │ - 585 bool out = true; │ │ │ │ │ - 586 for(int i=0; i │ │ │ │ │ -594 bool isInf(const FieldVector &b, PriorityTag<2>, ADLTag) { │ │ │ │ │ - 595 bool out = false; │ │ │ │ │ - 596 for(int i=0; i::value>> │ │ │ │ │ -604 bool isNaN(const FieldVector &b, PriorityTag<2>, ADLTag) { │ │ │ │ │ - 605 bool out = false; │ │ │ │ │ - 606 for(int i=0; i::value>> │ │ │ │ │ -614 bool isUnordered(const FieldVector &b, const FieldVector &c, │ │ │ │ │ - 615 PriorityTag<2>, ADLTag) { │ │ │ │ │ - 616 return Dune::isUnordered(b[0],c[0]); │ │ │ │ │ - 617 } │ │ │ │ │ - 618 } //MathOverloads │ │ │ │ │ - 619 │ │ │ │ │ - 622} // end namespace │ │ │ │ │ - 623 │ │ │ │ │ - 624#endif │ │ │ │ │ -promotiontraits.hh │ │ │ │ │ -Compute type of the result of an arithmetic operation involving two different │ │ │ │ │ -number types. │ │ │ │ │ + 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 │ │ │ │ │ +debugalign.hh │ │ │ │ │ +vc.hh │ │ │ │ │ +Compatibility header for including │ │ │ │ │ +rangeutilities.hh │ │ │ │ │ +Utilities for reduction like operations on ranges. │ │ │ │ │ +conditional.hh │ │ │ │ │ typetraits.hh │ │ │ │ │ Traits for type conversions and type information. │ │ │ │ │ -exceptions.hh │ │ │ │ │ -A few common exception classes. │ │ │ │ │ -ftraits.hh │ │ │ │ │ -Type traits to determine the type of reals (when working with complex numbers) │ │ │ │ │ -math.hh │ │ │ │ │ -Some useful basic math stuff. │ │ │ │ │ -boundschecking.hh │ │ │ │ │ -Macro for wrapping boundary checks. │ │ │ │ │ -densevector.hh │ │ │ │ │ -Implements the dense vector interface, with an exchangeable storage class. │ │ │ │ │ -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 │ │ │ │ │ -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:556 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::MathOverloads::isNaN │ │ │ │ │ -bool isNaN(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag) │ │ │ │ │ -Definition fvector.hh:604 │ │ │ │ │ -Dune::MathOverloads::isInf │ │ │ │ │ -bool isInf(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag) │ │ │ │ │ -Definition fvector.hh:594 │ │ │ │ │ -Dune::MathOverloads::isFinite │ │ │ │ │ -auto isFinite(const FieldVector< K, SIZE > &b, PriorityTag< 2 >, ADLTag) │ │ │ │ │ -Definition fvector.hh:584 │ │ │ │ │ -Dune::MathOverloads::isUnordered │ │ │ │ │ -bool isUnordered(const FieldVector< K, 1 > &b, const FieldVector< K, 1 > &c, │ │ │ │ │ -PriorityTag< 2 >, ADLTag) │ │ │ │ │ -Definition fvector.hh:614 │ │ │ │ │ -Dune::FieldVector │ │ │ │ │ -vector space out of a tensor product of fields. │ │ │ │ │ -Definition fvector.hh:95 │ │ │ │ │ -Dune::FieldVector::data │ │ │ │ │ -K * data() noexcept │ │ │ │ │ -return pointer to underlying array │ │ │ │ │ -Definition fvector.hh:198 │ │ │ │ │ -Dune::FieldVector::FieldVector │ │ │ │ │ -constexpr FieldVector() │ │ │ │ │ -Constructor making default-initialized vector. │ │ │ │ │ -Definition fvector.hh:112 │ │ │ │ │ -Dune::FieldVector::const_reference │ │ │ │ │ -const value_type & const_reference │ │ │ │ │ -The type used for const references to the vector entry. │ │ │ │ │ -Definition fvector.hh:109 │ │ │ │ │ -Dune::FieldVector::size_type │ │ │ │ │ -Base::size_type size_type │ │ │ │ │ -Definition fvector.hh:102 │ │ │ │ │ -Dune::FieldVector::FieldVector │ │ │ │ │ -FieldVector(const DenseVector< C > &x, typename std::enable_if< │ │ │ │ │ -IsFieldVectorSizeCorrect< C, SIZE >::value >::type *dummy=0) │ │ │ │ │ -Copy constructor from a second vector of possibly different type. │ │ │ │ │ -Definition fvector.hh:165 │ │ │ │ │ -Dune::FieldVector::FieldVector │ │ │ │ │ -FieldVector(const FieldVector< T, N > &)=delete │ │ │ │ │ -Dune::FieldVector::FieldVector │ │ │ │ │ -FieldVector(const K &t) │ │ │ │ │ -Constructor making vector with identical coordinates. │ │ │ │ │ -Definition fvector.hh:117 │ │ │ │ │ -Dune::FieldVector::FieldVector │ │ │ │ │ -FieldVector(std::initializer_list< K > const &l) │ │ │ │ │ -Construct from a std::initializer_list. │ │ │ │ │ -Definition fvector.hh:132 │ │ │ │ │ -Dune::FieldVector::data │ │ │ │ │ -const K * data() const noexcept │ │ │ │ │ -return pointer to underlying array │ │ │ │ │ -Definition fvector.hh:204 │ │ │ │ │ -Dune::FieldVector::dimension │ │ │ │ │ -static constexpr int dimension │ │ │ │ │ -The size of this vector. │ │ │ │ │ -Definition fvector.hh:100 │ │ │ │ │ -Dune::FieldVector::FieldVector │ │ │ │ │ -FieldVector(const FieldVector< K1, SIZE > &x) │ │ │ │ │ -Constructor making vector with identical coordinates. │ │ │ │ │ -Definition fvector.hh:175 │ │ │ │ │ -Dune::FieldVector::size │ │ │ │ │ -static constexpr size_type size() │ │ │ │ │ -Definition fvector.hh:186 │ │ │ │ │ -Dune::FieldVector::operator[] │ │ │ │ │ -K & operator[](size_type i) │ │ │ │ │ -Definition fvector.hh:188 │ │ │ │ │ -Dune::FieldVector::reference │ │ │ │ │ -value_type & reference │ │ │ │ │ -The type used for references to the vector entry. │ │ │ │ │ -Definition fvector.hh:106 │ │ │ │ │ -Dune::FieldVector::value_type │ │ │ │ │ -Base::value_type value_type │ │ │ │ │ -Definition fvector.hh:103 │ │ │ │ │ -Dune::FieldVector::operator[] │ │ │ │ │ -const K & operator[](size_type i) const │ │ │ │ │ -Definition fvector.hh:192 │ │ │ │ │ -Dune::FieldVector::operator= │ │ │ │ │ -FieldVector & operator=(const FieldVector< T, N > &)=delete │ │ │ │ │ -Dune::FieldVector::FieldVector │ │ │ │ │ -FieldVector(const FieldVector &)=default │ │ │ │ │ -Copy constructor. │ │ │ │ │ -Dune::DenseVector │ │ │ │ │ -Interface for a class of dense vectors over a given field. │ │ │ │ │ -Definition densevector.hh:229 │ │ │ │ │ -Dune::DenseVector<_FieldVector<_K,_SIZE_>_>::value_type │ │ │ │ │ -Traits::value_type value_type │ │ │ │ │ -export the type representing the field │ │ │ │ │ -Definition densevector.hh:250 │ │ │ │ │ -Dune::DenseVector::begin │ │ │ │ │ -Iterator begin() │ │ │ │ │ -begin iterator │ │ │ │ │ -Definition densevector.hh:347 │ │ │ │ │ -Dune::DenseVector::size │ │ │ │ │ -size_type size() const │ │ │ │ │ -size method │ │ │ │ │ -Definition densevector.hh:336 │ │ │ │ │ -Dune::DenseVector<_FieldVector<_K,_SIZE_>_>::size_type │ │ │ │ │ -Traits::size_type size_type │ │ │ │ │ -The type used for the index access and size operation. │ │ │ │ │ -Definition densevector.hh:259 │ │ │ │ │ -Dune::FieldTraits │ │ │ │ │ -Definition ftraits.hh:26 │ │ │ │ │ -Dune::FieldTraits::field_type │ │ │ │ │ -T field_type │ │ │ │ │ -export the type representing the field │ │ │ │ │ -Definition ftraits.hh:28 │ │ │ │ │ -Dune::FieldTraits::real_type │ │ │ │ │ -T real_type │ │ │ │ │ -export the type representing the real type of the field │ │ │ │ │ -Definition ftraits.hh:30 │ │ │ │ │ -Dune::DenseMatVecTraits<_FieldVector<_K,_SIZE_>_>::value_type │ │ │ │ │ -K value_type │ │ │ │ │ -Definition fvector.hh:45 │ │ │ │ │ -Dune::DenseMatVecTraits<_FieldVector<_K,_SIZE_>_>::container_type │ │ │ │ │ -std::array< K, SIZE > container_type │ │ │ │ │ -Definition fvector.hh:44 │ │ │ │ │ -Dune::DenseMatVecTraits<_FieldVector<_K,_SIZE_>_>::size_type │ │ │ │ │ -container_type::size_type size_type │ │ │ │ │ -Definition fvector.hh:46 │ │ │ │ │ -Dune::DenseMatVecTraits<_FieldVector<_K,_SIZE_>_>::derived_type │ │ │ │ │ -FieldVector< K, SIZE > derived_type │ │ │ │ │ -Definition fvector.hh:43 │ │ │ │ │ -Dune::FieldTraits<_FieldVector<_K,_SIZE_>_>::real_type │ │ │ │ │ -FieldTraits< K >::real_type real_type │ │ │ │ │ -Definition fvector.hh:53 │ │ │ │ │ -Dune::FieldTraits<_FieldVector<_K,_SIZE_>_>::field_type │ │ │ │ │ -FieldTraits< K >::field_type field_type │ │ │ │ │ -Definition fvector.hh:52 │ │ │ │ │ -Dune::IsFieldVectorSizeCorrect │ │ │ │ │ -TMP to check the size of a DenseVectors statically, if possible. │ │ │ │ │ -Definition fvector.hh:66 │ │ │ │ │ -Dune::IsFieldVectorSizeCorrect::value │ │ │ │ │ -static constexpr bool value │ │ │ │ │ -True if C is not of type FieldVector or its dimension is not equal SIZE. │ │ │ │ │ -Definition fvector.hh:71 │ │ │ │ │ -Dune::MathOverloads::ADLTag │ │ │ │ │ -Tag to make sure the functions in this namespace can be found by ADL. │ │ │ │ │ -Definition math.hh:230 │ │ │ │ │ -Dune::DenseMatVecTraits │ │ │ │ │ -Definition matvectraits.hh:31 │ │ │ │ │ -Dune::PriorityTag │ │ │ │ │ -Helper class for tagging priorities. │ │ │ │ │ -Definition typeutilities.hh:73 │ │ │ │ │ +Dune::any_true │ │ │ │ │ +bool any_true(const AlignedNumber< bool, align > &val) │ │ │ │ │ +Definition debugalign.hh:493 │ │ │ │ │ +Dune::all_true │ │ │ │ │ +bool all_true(const AlignedNumber< bool, align > &val) │ │ │ │ │ +Definition debugalign.hh:499 │ │ │ │ │ +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:481 │ │ │ │ │ +Dune::min_value │ │ │ │ │ +T min_value(const AlignedNumber< T, align > &val) │ │ │ │ │ +Definition debugalign.hh:487 │ │ │ │ │ +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:115 │ │ │ │ │ +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/a00218.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: conditional.hh File Reference │ │ │ │ +dune-common: defaults.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,40 +65,127 @@ │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -Namespaces | │ │ │ │ -Functions
    │ │ │ │ -
    conditional.hh File Reference
    │ │ │ │ +Namespaces
    │ │ │ │ + │ │ │ │ │ │ │ │
    │ │ │ │ │ │ │ │ +

    Default implementations for SIMD Implementations. │ │ │ │ +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>
    │ │ │ │ +
    │ │ │ │

    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.
     
    │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

    │ │ │ │ Functions

    template<typename T1 , typename T2 >
    const T1 Dune::cond (bool b, const T1 &v1, const T2 &v2)
     conditional evaluate
     
    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()
     
    │ │ │ │ -
    │ │ │ │ +

    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.

    │ │ │ │ +
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,22 +6,128 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Namespaces | Functions │ │ │ │ │ -conditional.hh File Reference │ │ │ │ │ + * simd │ │ │ │ │ +Namespaces │ │ │ │ │ +defaults.hh File Reference │ │ │ │ │ +Common » Vectorization » Abstraction_Developer's_Interface │ │ │ │ │ +Default implementations for SIMD Implementations. More... │ │ │ │ │ +#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. │ │ │ │ │ +  │ │ │ │ │ Functions │ │ │ │ │ -template │ │ │ │ │ -const T1 Dune::cond (bool b, const T1 &v1, const T2 &v2) │ │ │ │ │ -  conditional evaluate │ │ │ │ │ +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() │ │ │ │ │   │ │ │ │ │ +***** 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. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00218_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: conditional.hh Source File │ │ │ │ +dune-common: defaults.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,42 +70,215 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │ -
    conditional.hh
    │ │ │ │ +
    defaults.hh
    │ │ │ │
    │ │ │ │
    │ │ │ │ Go to the documentation of this file.
    1// SPDX-FileCopyrightInfo: Copyright (C) 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_CONDITIONAL_HH
    │ │ │ │ -
    4#define DUNE_COMMON_CONDITIONAL_HH
    │ │ │ │ +
    3#ifndef DUNE_COMMON_SIMD_DEFAULTS_HH
    │ │ │ │ +
    4#define DUNE_COMMON_SIMD_DEFAULTS_HH
    │ │ │ │
    5
    │ │ │ │ -
    6namespace Dune
    │ │ │ │ -
    7{
    │ │ │ │ -
    8
    │ │ │ │ -
    27 template<typename T1, typename T2>
    │ │ │ │ -
    │ │ │ │ -
    28 const T1 cond(bool b, const T1 & v1, const T2 & v2)
    │ │ │ │ -
    29 {
    │ │ │ │ -
    30 return (b ? v1 : v2);
    │ │ │ │ -
    31 }
    │ │ │ │ -
    │ │ │ │ -
    32
    │ │ │ │ -
    33} // end namespace Dune
    │ │ │ │ -
    34
    │ │ │ │ -
    35#endif // DUNE_COMMON_CONDITIONAL_HH
    │ │ │ │ +
    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;
    │ │ │ │ +
    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 }
    │ │ │ │ +
    │ │ │ │ +
    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:300
    │ │ │ │ +
    typename AutonomousValueType< T >::type AutonomousValue
    Type free of internal references that T can be converted to.
    Definition typetraits.hh:558
    │ │ │ │ +
    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
    │ │ │ │
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ -
    const T1 cond(bool b, const T1 &v1, const T2 &v2)
    conditional evaluate
    Definition conditional.hh:28
    │ │ │ │ +
    bool anyTrue(ADLTag< 5 >, const AlignedNumber< bool, align > &mask)
    Definition debugalign.hh:543
    │ │ │ │ +
    const AlignedNumber< T, align > & cond(ADLTag< 5 >, AlignedNumber< bool, align > mask, const AlignedNumber< T, align > &ifTrue, const AlignedNumber< T, align > &ifFalse)
    Definition debugalign.hh:535
    │ │ │ │ +
    T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v)
    Definition debugalign.hh:520
    │ │ │ │ +
    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.
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,37 +7,252 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -conditional.hh │ │ │ │ │ + * simd │ │ │ │ │ +defaults.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// SPDX-FileCopyrightInfo: Copyright (C) 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_CONDITIONAL_HH │ │ │ │ │ - 4#define DUNE_COMMON_CONDITIONAL_HH │ │ │ │ │ + 3#ifndef DUNE_COMMON_SIMD_DEFAULTS_HH │ │ │ │ │ + 4#define DUNE_COMMON_SIMD_DEFAULTS_HH │ │ │ │ │ 5 │ │ │ │ │ - 6namespace Dune │ │ │ │ │ - 7{ │ │ │ │ │ - 8 │ │ │ │ │ - 27 template │ │ │ │ │ -28 const T1 cond(bool b, const T1 & v1, const T2 & v2) │ │ │ │ │ - 29 { │ │ │ │ │ - 30 return (b ? v1 : v2); │ │ │ │ │ - 31 } │ │ │ │ │ - 32 │ │ │ │ │ - 33} // end namespace Dune │ │ │ │ │ - 34 │ │ │ │ │ - 35#endif // DUNE_COMMON_CONDITIONAL_HH │ │ │ │ │ + 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; │ │ │ │ │ + 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) │ │ │ │ │ + 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 } │ │ │ │ │ + 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); │ │ │ │ │ + 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:300 │ │ │ │ │ +Dune::AutonomousValue │ │ │ │ │ +typename AutonomousValueType< T >::type AutonomousValue │ │ │ │ │ +Type free of internal references that T can be converted to. │ │ │ │ │ +Definition typetraits.hh:558 │ │ │ │ │ +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 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::cond │ │ │ │ │ -const T1 cond(bool b, const T1 &v1, const T2 &v2) │ │ │ │ │ -conditional evaluate │ │ │ │ │ -Definition conditional.hh:28 │ │ │ │ │ +Dune::Simd::Overloads::anyTrue │ │ │ │ │ +bool anyTrue(ADLTag< 5 >, const AlignedNumber< bool, align > &mask) │ │ │ │ │ +Definition debugalign.hh:543 │ │ │ │ │ +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:535 │ │ │ │ │ +Dune::Simd::Overloads::lane │ │ │ │ │ +T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v) │ │ │ │ │ +Definition debugalign.hh:520 │ │ │ │ │ +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. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00221.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: gmpfield.hh File Reference │ │ │ │ +dune-common: base.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,60 +65,53 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ Classes | │ │ │ │ Namespaces
    │ │ │ │ -
    gmpfield.hh File Reference
    │ │ │ │ + │ │ │ │
    │ │ │ │
    │ │ │ │ │ │ │ │ -

    Wrapper for the GNU multiprecision (GMP) library. │ │ │ │ +

    Basic definitions for SIMD Implementations. │ │ │ │ More...

    │ │ │ │ -
    #include <iostream>
    │ │ │ │ -#include <string>
    │ │ │ │ -#include <type_traits>
    │ │ │ │ -#include <gmpxx.h>
    │ │ │ │ -#include <dune/common/promotiontraits.hh>
    │ │ │ │ -#include <dune/common/typetraits.hh>
    │ │ │ │ -
    │ │ │ │ + │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ Classes

    class  Dune::GMPField< precision >
     Number class for high precision floating point number using the GMP library mpf_class implementation. More...
     
    struct  Dune::IsNumber< GMPField< precision > >
     
    struct  Dune::PromotionTraits< GMPField< precision1 >, GMPField< precision2 > >
    struct  Dune::Simd::Overloads::ADLTag< i >
     
    struct  Dune::PromotionTraits< GMPField< precision >, GMPField< precision > >
     
    struct  Dune::PromotionTraits< GMPField< precision >, T >
     
    struct  Dune::PromotionTraits< T, GMPField< precision > >
    struct  Dune::Simd::Overloads::ADLTag< 0 >
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

    │ │ │ │ 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.
     
    │ │ │ │

    Detailed Description

    │ │ │ │ -

    Wrapper for the GNU multiprecision (GMP) library.

    │ │ │ │ +

    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.

    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,42 +6,39 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ + * simd │ │ │ │ │ Classes | Namespaces │ │ │ │ │ -gmpfield.hh File Reference │ │ │ │ │ -Wrapper for the GNU multiprecision (GMP) library. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +base.hh File Reference │ │ │ │ │ +Common » Vectorization » Abstraction_Developer's_Interface │ │ │ │ │ +Basic definitions for SIMD Implementations. More... │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ - class  Dune::GMPField<_precision_> │ │ │ │ │ -  Number class for high precision floating point number using the GMP │ │ │ │ │ - library mpf_class implementation. More... │ │ │ │ │ +struct  Dune::Simd::Overloads::ADLTag<_i_> │ │ │ │ │   │ │ │ │ │ -struct  Dune::IsNumber<_GMPField<_precision_>_> │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::PromotionTraits<_GMPField<_precision1_>,_GMPField<_precision2_> │ │ │ │ │ - > │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::PromotionTraits<_GMPField<_precision_>,_GMPField<_precision_>_> │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::PromotionTraits<_GMPField<_precision_>,_T_> │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::PromotionTraits<_T,_GMPField<_precision_>_> │ │ │ │ │ +struct  Dune::Simd::Overloads::ADLTag<_0_> │ │ │ │ │   │ │ │ │ │ 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. │ │ │ │ │ +  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Wrapper for the GNU multiprecision (GMP) library. │ │ │ │ │ +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. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00221_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: gmpfield.hh Source File │ │ │ │ +dune-common: base.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,145 +70,66 @@ │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │ -
    gmpfield.hh
    │ │ │ │ +
    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 (C) 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_GMPFIELD_HH
    │ │ │ │ -
    6#define DUNE_GMPFIELD_HH
    │ │ │ │ -
    7
    │ │ │ │ -
    12#include <iostream>
    │ │ │ │ -
    13#include <string>
    │ │ │ │ -
    14#include <type_traits>
    │ │ │ │ -
    15
    │ │ │ │ -
    16#if HAVE_GMP || DOXYGEN
    │ │ │ │ -
    17
    │ │ │ │ -
    18#include <gmpxx.h>
    │ │ │ │ -
    19
    │ │ │ │ - │ │ │ │ - │ │ │ │ -
    22
    │ │ │ │ -
    23namespace Dune
    │ │ │ │ -
    24{
    │ │ │ │ -
    25
    │ │ │ │ -
    30 template< unsigned int precision >
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    32 : public mpf_class
    │ │ │ │ -
    33 {
    │ │ │ │ -
    34 typedef mpf_class Base;
    │ │ │ │ -
    35
    │ │ │ │ -
    36 public:
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    39 : Base(0,precision)
    │ │ │ │ -
    40 {}
    │ │ │ │ -
    │ │ │ │ -
    41
    │ │ │ │ -
    │ │ │ │ -
    45 GMPField ( const char* str )
    │ │ │ │ -
    46 : Base(str,precision)
    │ │ │ │ -
    47 {}
    │ │ │ │ -
    │ │ │ │ -
    48
    │ │ │ │ -
    │ │ │ │ -
    52 GMPField ( const std::string& str )
    │ │ │ │ -
    53 : Base(str,precision)
    │ │ │ │ -
    54 {}
    │ │ │ │ -
    │ │ │ │ -
    55
    │ │ │ │ -
    58 template< class T,
    │ │ │ │ -
    59 typename EnableIf = typename std::enable_if<
    │ │ │ │ -
    60 std::is_convertible<T, mpf_class>::value>::type
    │ │ │ │ -
    61 >
    │ │ │ │ -
    │ │ │ │ -
    62 GMPField ( const T &v )
    │ │ │ │ -
    63 : Base( v,precision )
    │ │ │ │ -
    64 {}
    │ │ │ │ -
    │ │ │ │ -
    65
    │ │ │ │ -
    66 // type conversion operators
    │ │ │ │ -
    │ │ │ │ -
    67 operator double () const
    │ │ │ │ -
    68 {
    │ │ │ │ -
    69 return this->get_d();
    │ │ │ │ -
    70 }
    │ │ │ │ -
    │ │ │ │ -
    71
    │ │ │ │ -
    72 };
    │ │ │ │ -
    │ │ │ │ -
    73
    │ │ │ │ -
    74 template <unsigned int precision>
    │ │ │ │ -
    │ │ │ │ -
    75 struct IsNumber<GMPField<precision>>
    │ │ │ │ -
    76 : public std::integral_constant<bool, true> {
    │ │ │ │ -
    77 };
    │ │ │ │ -
    │ │ │ │ -
    78
    │ │ │ │ -
    79 template< unsigned int precision1, unsigned int precision2 >
    │ │ │ │ -
    │ │ │ │ -
    80 struct PromotionTraits<GMPField<precision1>, GMPField<precision2>>
    │ │ │ │ -
    81 {
    │ │ │ │ -
    82 typedef GMPField<(precision1 > precision2 ? precision1 : precision2)> PromotedType;
    │ │ │ │ -
    83 };
    │ │ │ │ -
    │ │ │ │ -
    84
    │ │ │ │ -
    85 template< unsigned int precision >
    │ │ │ │ -
    │ │ │ │ -
    86 struct PromotionTraits<GMPField<precision>,GMPField<precision>>
    │ │ │ │ -
    87 {
    │ │ │ │ - │ │ │ │ -
    89 };
    │ │ │ │ -
    │ │ │ │ -
    90
    │ │ │ │ -
    91 template< unsigned int precision, class T >
    │ │ │ │ -
    │ │ │ │ -
    92 struct PromotionTraits<GMPField<precision>, T>
    │ │ │ │ -
    93 {
    │ │ │ │ - │ │ │ │ -
    95 };
    │ │ │ │ -
    │ │ │ │ -
    96
    │ │ │ │ -
    97 template< class T, unsigned int precision >
    │ │ │ │ -
    │ │ │ │ -
    98 struct PromotionTraits<T, GMPField<precision>>
    │ │ │ │ -
    99 {
    │ │ │ │ - │ │ │ │ -
    101 };
    │ │ │ │ -
    │ │ │ │ -
    102}
    │ │ │ │ -
    103
    │ │ │ │ -
    104#endif // HAVE_GMP
    │ │ │ │ -
    105
    │ │ │ │ -
    106#endif // #ifndef DUNE_GMPFIELD_HH
    │ │ │ │ -
    Compute type of the result of an arithmetic operation involving two different number types.
    │ │ │ │ -
    Traits for type conversions and type information.
    │ │ │ │ +Go to the documentation of this file.
    1// SPDX-FileCopyrightInfo: Copyright (C) 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
    │ │ │ │
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ -
    Whether this type acts as a scalar in the context of (hierarchically blocked) containers.
    Definition typetraits.hh:194
    │ │ │ │ -
    Number class for high precision floating point number using the GMP library mpf_class implementation.
    Definition gmpfield.hh:33
    │ │ │ │ -
    GMPField(const T &v)
    initialize from a compatible scalar type
    Definition gmpfield.hh:62
    │ │ │ │ -
    GMPField()
    Definition gmpfield.hh:38
    │ │ │ │ -
    GMPField(const std::string &str)
    initialize from a string
    Definition gmpfield.hh:52
    │ │ │ │ -
    GMPField(const char *str)
    initialize from a string
    Definition gmpfield.hh:45
    │ │ │ │ -
    GMPField< precision > PromotedType
    Definition gmpfield.hh:88
    │ │ │ │ -
    GMPField< precision > PromotedType
    Definition gmpfield.hh:94
    │ │ │ │ -
    GMPField< precision > PromotedType
    Definition gmpfield.hh:100
    │ │ │ │ -
    Compute type of the result of an arithmetic operation involving two different number types.
    Definition promotiontraits.hh:27
    │ │ │ │ +
    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 {} │ │ │ │ │ @@ -7,148 +7,69 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -gmpfield.hh │ │ │ │ │ + * 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 (C) DUNE Project contributors, see file │ │ │ │ │ + 1// SPDX-FileCopyrightInfo: Copyright (C) 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_GMPFIELD_HH │ │ │ │ │ - 6#define DUNE_GMPFIELD_HH │ │ │ │ │ - 7 │ │ │ │ │ - 12#include │ │ │ │ │ - 13#include │ │ │ │ │ - 14#include │ │ │ │ │ - 15 │ │ │ │ │ - 16#if HAVE_GMP || DOXYGEN │ │ │ │ │ - 17 │ │ │ │ │ - 18#include │ │ │ │ │ - 19 │ │ │ │ │ - 20#include │ │ │ │ │ - 21#include │ │ │ │ │ - 22 │ │ │ │ │ - 23namespace Dune │ │ │ │ │ - 24{ │ │ │ │ │ - 25 │ │ │ │ │ - 30 template< unsigned int precision > │ │ │ │ │ -31 class GMPField │ │ │ │ │ - 32 : public mpf_class │ │ │ │ │ - 33 { │ │ │ │ │ - 34 typedef mpf_class Base; │ │ │ │ │ - 35 │ │ │ │ │ - 36 public: │ │ │ │ │ -38 GMPField () │ │ │ │ │ - 39 : Base(0,precision) │ │ │ │ │ - 40 {} │ │ │ │ │ - 41 │ │ │ │ │ -45 GMPField ( const char* str ) │ │ │ │ │ - 46 : Base(str,precision) │ │ │ │ │ - 47 {} │ │ │ │ │ - 48 │ │ │ │ │ -52 GMPField ( const std::string& str ) │ │ │ │ │ - 53 : Base(str,precision) │ │ │ │ │ - 54 {} │ │ │ │ │ - 55 │ │ │ │ │ - 58 template< class T, │ │ │ │ │ - 59 typename EnableIf = typename std::enable_if< │ │ │ │ │ - 60 std::is_convertible::value>::type │ │ │ │ │ - 61 > │ │ │ │ │ -62 GMPField ( const T &v ) │ │ │ │ │ - 63 : Base( v,precision ) │ │ │ │ │ - 64 {} │ │ │ │ │ - 65 │ │ │ │ │ - 66 // type conversion operators │ │ │ │ │ -67 operator double () const │ │ │ │ │ - 68 { │ │ │ │ │ - 69 return this->get_d(); │ │ │ │ │ - 70 } │ │ │ │ │ - 71 │ │ │ │ │ - 72 }; │ │ │ │ │ - 73 │ │ │ │ │ - 74 template │ │ │ │ │ -75 struct IsNumber> │ │ │ │ │ - 76 : public std::integral_constant { │ │ │ │ │ - 77 }; │ │ │ │ │ - 78 │ │ │ │ │ - 79 template< unsigned int precision1, unsigned int precision2 > │ │ │ │ │ -80 struct PromotionTraits, GMPField> │ │ │ │ │ - 81 { │ │ │ │ │ -82 typedef GMPField<(precision1 > precision2 ? precision1 : precision2)> │ │ │ │ │ -PromotedType; │ │ │ │ │ - 83 }; │ │ │ │ │ - 84 │ │ │ │ │ - 85 template< unsigned int precision > │ │ │ │ │ -86 struct PromotionTraits,GMPField> │ │ │ │ │ - 87 { │ │ │ │ │ -88 typedef GMPField PromotedType; │ │ │ │ │ - 89 }; │ │ │ │ │ - 90 │ │ │ │ │ - 91 template< unsigned int precision, class T > │ │ │ │ │ -92 struct PromotionTraits, T> │ │ │ │ │ - 93 { │ │ │ │ │ -94 typedef GMPField PromotedType; │ │ │ │ │ - 95 }; │ │ │ │ │ - 96 │ │ │ │ │ - 97 template< class T, unsigned int precision > │ │ │ │ │ -98 struct PromotionTraits> │ │ │ │ │ - 99 { │ │ │ │ │ -100 typedef GMPField PromotedType; │ │ │ │ │ - 101 }; │ │ │ │ │ - 102} │ │ │ │ │ - 103 │ │ │ │ │ - 104#endif // HAVE_GMP │ │ │ │ │ - 105 │ │ │ │ │ - 106#endif // #ifndef DUNE_GMPFIELD_HH │ │ │ │ │ -promotiontraits.hh │ │ │ │ │ -Compute type of the result of an arithmetic operation involving two different │ │ │ │ │ -number types. │ │ │ │ │ -typetraits.hh │ │ │ │ │ -Traits for type conversions and type information. │ │ │ │ │ + 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 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::IsNumber │ │ │ │ │ -Whether this type acts as a scalar in the context of (hierarchically blocked) │ │ │ │ │ -containers. │ │ │ │ │ -Definition typetraits.hh:194 │ │ │ │ │ -Dune::GMPField │ │ │ │ │ -Number class for high precision floating point number using the GMP library │ │ │ │ │ -mpf_class implementation. │ │ │ │ │ -Definition gmpfield.hh:33 │ │ │ │ │ -Dune::GMPField::GMPField │ │ │ │ │ -GMPField(const T &v) │ │ │ │ │ -initialize from a compatible scalar type │ │ │ │ │ -Definition gmpfield.hh:62 │ │ │ │ │ -Dune::GMPField::GMPField │ │ │ │ │ -GMPField() │ │ │ │ │ -Definition gmpfield.hh:38 │ │ │ │ │ -Dune::GMPField::GMPField │ │ │ │ │ -GMPField(const std::string &str) │ │ │ │ │ -initialize from a string │ │ │ │ │ -Definition gmpfield.hh:52 │ │ │ │ │ -Dune::GMPField::GMPField │ │ │ │ │ -GMPField(const char *str) │ │ │ │ │ -initialize from a string │ │ │ │ │ -Definition gmpfield.hh:45 │ │ │ │ │ -Dune::PromotionTraits<_GMPField<_precision_>,_GMPField<_precision_>_>:: │ │ │ │ │ -PromotedType │ │ │ │ │ -GMPField< precision > PromotedType │ │ │ │ │ -Definition gmpfield.hh:88 │ │ │ │ │ -Dune::PromotionTraits<_GMPField<_precision_>,_T_>::PromotedType │ │ │ │ │ -GMPField< precision > PromotedType │ │ │ │ │ -Definition gmpfield.hh:94 │ │ │ │ │ -Dune::PromotionTraits<_T,_GMPField<_precision_>_>::PromotedType │ │ │ │ │ -GMPField< precision > PromotedType │ │ │ │ │ -Definition gmpfield.hh:100 │ │ │ │ │ -Dune::PromotionTraits │ │ │ │ │ -Compute type of the result of an arithmetic operation involving two different │ │ │ │ │ -number types. │ │ │ │ │ -Definition promotiontraits.hh:27 │ │ │ │ │ +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/a00224.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: math.hh File Reference │ │ │ │ +dune-common: debugalign.cc File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,197 +70,46 @@ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │
    │ │ │ │ -Classes | │ │ │ │ Namespaces | │ │ │ │ -Macros | │ │ │ │ Functions
    │ │ │ │ -
    math.hh File Reference
    │ │ │ │ +
    debugalign.cc File Reference
    │ │ │ │
    │ │ │ │
    │ │ │ │ - │ │ │ │ -

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

    │ │ │ │ -
    #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::StandardMathematicalConstants< T >
     Standard implementation of MathematicalConstants. More...
     
    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
     
    │ │ │ │ +
    #include <config.h>
    │ │ │ │ +#include <cstddef>
    │ │ │ │ +#include <cstdlib>
    │ │ │ │ +#include <functional>
    │ │ │ │ +#include <ios>
    │ │ │ │ +#include <iostream>
    │ │ │ │ +#include <utility>
    │ │ │ │ +#include <dune/common/debugalign.hh>
    │ │ │ │ +
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

    │ │ │ │ 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)
     
    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

    │ │ │ │ -

    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 {} │ │ │ │ │ @@ -6,156 +6,37 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -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::StandardMathematicalConstants<_T_> │ │ │ │ │ -  Standard implementation of MathematicalConstants. More... │ │ │ │ │ -  │ │ │ │ │ -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 | Functions │ │ │ │ │ +debugalign.cc File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ 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) │ │ │ │ │ + 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 ***** │ │ │ │ │ -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/a00227.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: ios_state.hh File Reference │ │ │ │ +dune-common: mallocallocator.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -71,40 +71,56 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ Classes | │ │ │ │ -Namespaces
    │ │ │ │ -
    ios_state.hh File Reference
    │ │ │ │ +Namespaces | │ │ │ │ +Functions
    │ │ │ │ +
    mallocallocator.hh File Reference
    │ │ │ │ │ │ │ │
    │ │ │ │ │ │ │ │ -

    Utility class for storing and resetting stream attributes. │ │ │ │ +

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

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

    Go to the source code of this file.

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

    │ │ │ │ Classes

    class  Dune::ios_base_all_saver
     Utility class for storing and resetting stream attributes. More...
    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

    │ │ │ │ -

    Utility class for storing and resetting stream attributes.

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

    Allocators that use malloc/free.

    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,28 +6,41 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -ios_state.hh File Reference │ │ │ │ │ -Common │ │ │ │ │ -Utility class for storing and resetting stream attributes. More... │ │ │ │ │ -#include │ │ │ │ │ +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::ios_base_all_saver │ │ │ │ │ -  Utility class for storing and resetting stream attributes. More... │ │ │ │ │ + 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 ***** │ │ │ │ │ -Utility class for storing and resetting stream attributes. │ │ │ │ │ - Author │ │ │ │ │ - Markus Blatt │ │ │ │ │ +Allocators that use malloc/free. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00227_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: ios_state.hh Source File │ │ │ │ +dune-common: mallocallocator.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,55 +74,162 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    ios_state.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 (C) 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_IOS_STATE_HH
    │ │ │ │ -
    6#define DUNE_COMMON_IOS_STATE_HH
    │ │ │ │ +
    5#ifndef DUNE_MALLOC_ALLOCATOR_HH
    │ │ │ │ +
    6#define DUNE_MALLOC_ALLOCATOR_HH
    │ │ │ │
    7
    │ │ │ │ -
    8#include <ios>
    │ │ │ │ -
    9
    │ │ │ │ -
    10namespace Dune {
    │ │ │ │ +
    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;
    │ │ │ │
    │ │ │ │ - │ │ │ │ -
    34 {
    │ │ │ │ -
    35 public:
    │ │ │ │ -
    37 typedef std::ios_base state_type;
    │ │ │ │ -
    38
    │ │ │ │ - │ │ │ │ -
    49
    │ │ │ │ - │ │ │ │ -
    54
    │ │ │ │ -
    61 void restore();
    │ │ │ │ -
    62
    │ │ │ │ -
    63 private:
    │ │ │ │ -
    65 state_type& ios;
    │ │ │ │ -
    67 state_type::fmtflags oldflags;
    │ │ │ │ -
    69 std::streamsize oldprec;
    │ │ │ │ -
    71 std::streamsize oldwidth;
    │ │ │ │ -
    72 };
    │ │ │ │ -
    │ │ │ │ -
    73
    │ │ │ │ -
    75}
    │ │ │ │ -
    76
    │ │ │ │ -
    77#endif // DUNE_COMMON_IOS_STATE_HH
    │ │ │ │ -
    ~ios_base_all_saver()
    Destructor that restores the flags stored by the constructor.
    Definition ios_state.cc:24
    │ │ │ │ -
    void restore()
    Restore flags now.
    Definition ios_state.cc:29
    │ │ │ │ -
    std::ios_base state_type
    Export type of object we save the state for.
    Definition ios_state.hh:37
    │ │ │ │ +
    33 template <class U> struct rebind {
    │ │ │ │ + │ │ │ │ +
    35 };
    │ │ │ │ +
    │ │ │ │ +
    36
    │ │ │ │ +
    38 MallocAllocator() noexcept {}
    │ │ │ │ +
    40 template <class U>
    │ │ │ │ + │ │ │ │ +
    43 ~MallocAllocator() noexcept {}
    │ │ │ │ +
    44
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    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:237
    │ │ │ │ +
    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:259
    │ │ │ │
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ -
    Utility class for storing and resetting stream attributes.
    Definition ios_state.hh:34
    │ │ │ │ +
    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 {} │ │ │ │ │ @@ -7,62 +7,197 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -ios_state.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 (C) 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_IOS_STATE_HH │ │ │ │ │ - 6#define DUNE_COMMON_IOS_STATE_HH │ │ │ │ │ + 5#ifndef DUNE_MALLOC_ALLOCATOR_HH │ │ │ │ │ + 6#define DUNE_MALLOC_ALLOCATOR_HH │ │ │ │ │ 7 │ │ │ │ │ - 8#include │ │ │ │ │ - 9 │ │ │ │ │ - 10namespace Dune { │ │ │ │ │ -33 class ios_base_all_saver │ │ │ │ │ - 34 { │ │ │ │ │ - 35 public: │ │ │ │ │ -37 typedef std::ios_base state_type; │ │ │ │ │ - 38 │ │ │ │ │ - 48 ios_base_all_saver(state_type& ios_); │ │ │ │ │ - 49 │ │ │ │ │ - 53 ~ios_base_all_saver(); │ │ │ │ │ - 54 │ │ │ │ │ - 61 void restore(); │ │ │ │ │ - 62 │ │ │ │ │ - 63 private: │ │ │ │ │ - 65 state_type& ios; │ │ │ │ │ - 67 state_type::fmtflags oldflags; │ │ │ │ │ - 69 std::streamsize oldprec; │ │ │ │ │ - 71 std::streamsize oldwidth; │ │ │ │ │ - 72 }; │ │ │ │ │ - 73 │ │ │ │ │ - 75} │ │ │ │ │ - 76 │ │ │ │ │ - 77#endif // DUNE_COMMON_IOS_STATE_HH │ │ │ │ │ -Dune::ios_base_all_saver::~ios_base_all_saver │ │ │ │ │ -~ios_base_all_saver() │ │ │ │ │ -Destructor that restores the flags stored by the constructor. │ │ │ │ │ -Definition ios_state.cc:24 │ │ │ │ │ -Dune::ios_base_all_saver::restore │ │ │ │ │ -void restore() │ │ │ │ │ -Restore flags now. │ │ │ │ │ -Definition ios_state.cc:29 │ │ │ │ │ -Dune::ios_base_all_saver::state_type │ │ │ │ │ -std::ios_base state_type │ │ │ │ │ -Export type of object we save the state for. │ │ │ │ │ -Definition ios_state.hh:37 │ │ │ │ │ + 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 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 │ │ │ │ │ + 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:237 │ │ │ │ │ +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:259 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::ios_base_all_saver │ │ │ │ │ -Utility class for storing and resetting stream attributes. │ │ │ │ │ -Definition ios_state.hh:34 │ │ │ │ │ +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/a00230.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: indent.hh File Reference │ │ │ │ +dune-common: scalarmatrixview.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,49 +70,41 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -Classes | │ │ │ │ -Namespaces | │ │ │ │ -Functions
    │ │ │ │ -
    indent.hh File Reference
    │ │ │ │ +Namespaces
    │ │ │ │ +
    scalarmatrixview.hh File Reference
    │ │ │ │ │ │ │ │
    │ │ │ │ │ │ │ │ -

    Utility class for handling nested indentation in output. │ │ │ │ +

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

    │ │ │ │ -
    #include <ostream>
    │ │ │ │ -#include <string>
    │ │ │ │ +
    #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>
    │ │ │ │
    │ │ │ │

    Go to the source code of this file.

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

    │ │ │ │ -Classes

    class  Dune::Indent
     Utility class for handling nested indentation in output. More...
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

    │ │ │ │ Namespaces

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

    │ │ │ │ -Functions

    std::ostream & Dune::operator<< (std::ostream &s, const Indent &indent)
     write indentation to a stream
     
    │ │ │ │

    Detailed Description

    │ │ │ │ -

    Utility class for handling nested indentation in output.

    │ │ │ │ -
    Author
    Jö Fahlke
    │ │ │ │ +

    Implements a scalar matrix view wrapper around an existing scalar.

    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── encoding │ │ │ │ │ @@ -1 +1 @@ │ │ │ │ │ -utf-8 │ │ │ │ │ +us-ascii │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,33 +6,30 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Functions │ │ │ │ │ -indent.hh File Reference │ │ │ │ │ -Common │ │ │ │ │ -Utility class for handling nested indentation in output. More... │ │ │ │ │ +Namespaces │ │ │ │ │ +scalarmatrixview.hh File Reference │ │ │ │ │ +Common » Dense_Matrix_and_Vector_Template_Library │ │ │ │ │ +Implements a scalar matrix view wrapper around an existing scalar. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ - Classes │ │ │ │ │ -class  Dune::Indent │ │ │ │ │ -  Utility class for handling nested indentation in output. More... │ │ │ │ │ -  │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ - Functions │ │ │ │ │ -std::ostream & Dune::operator<< (std::ostream &s, const Indent &indent) │ │ │ │ │ -  write indentation to a stream │ │ │ │ │ -  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Utility class for handling nested indentation in output. │ │ │ │ │ - Author │ │ │ │ │ - Jö Fahlke │ │ │ │ │ +Implements a scalar matrix view wrapper around an existing scalar. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00230_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: indent.hh Source File │ │ │ │ +dune-common: scalarmatrixview.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,107 +74,198 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    indent.hh
    │ │ │ │ +
    scalarmatrixview.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 (C) 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_INDENT_HH
    │ │ │ │ -
    6#define DUNE_COMMON_INDENT_HH
    │ │ │ │ +
    5#ifndef DUNE_COMMON_SCALARMATRIXVIEW_HH
    │ │ │ │ +
    6#define DUNE_COMMON_SCALARMATRIXVIEW_HH
    │ │ │ │
    7
    │ │ │ │ -
    8#include <ostream>
    │ │ │ │ -
    9#include <string>
    │ │ │ │ -
    10
    │ │ │ │ -
    11namespace Dune {
    │ │ │ │ -
    22
    │ │ │ │ -
    │ │ │ │ -
    52 class Indent
    │ │ │ │ -
    53 {
    │ │ │ │ -
    54 const Indent* parent;
    │ │ │ │ -
    55 std::string basic_indent;
    │ │ │ │ -
    56 unsigned level;
    │ │ │ │ -
    57
    │ │ │ │ -
    58 public:
    │ │ │ │ +
    8#include <cstddef>
    │ │ │ │ +
    9#include <type_traits>
    │ │ │ │ +
    10#include <ostream>
    │ │ │ │ +
    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;
    │ │ │ │ + │ │ │ │
    60
    │ │ │ │ -
    │ │ │ │ -
    63 inline Indent(const std::string& basic_indent_ = " ", unsigned level_ = 0)
    │ │ │ │ -
    64 : parent(0), basic_indent(basic_indent_), level(level_)
    │ │ │ │ -
    65 { }
    │ │ │ │ -
    │ │ │ │ -
    66
    │ │ │ │ -
    │ │ │ │ -
    68 inline Indent(unsigned level_)
    │ │ │ │ -
    69 : parent(0), basic_indent(" "), level(level_)
    │ │ │ │ -
    70 { }
    │ │ │ │ -
    │ │ │ │ -
    71
    │ │ │ │ -
    73
    │ │ │ │ -
    │ │ │ │ -
    76 inline Indent(const Indent* parent_,
    │ │ │ │ -
    77 const std::string& basic_indent_ = " ", unsigned level_ = 1)
    │ │ │ │ -
    78 : parent(parent_), basic_indent(basic_indent_), level(level_)
    │ │ │ │ -
    79 { }
    │ │ │ │ -
    │ │ │ │ -
    80
    │ │ │ │ -
    │ │ │ │ -
    82 inline Indent(const Indent* parent_, unsigned level_)
    │ │ │ │ -
    83 : parent(parent_), basic_indent(" "), level(level_)
    │ │ │ │ -
    84 { }
    │ │ │ │ -
    │ │ │ │ +
    63 constexpr static int rows = 1;
    │ │ │ │ +
    66 constexpr static int cols = 1;
    │ │ │ │ +
    67
    │ │ │ │ +
    68 //===== constructors
    │ │ │ │ +
    71 constexpr ScalarMatrixView ()
    │ │ │ │ +
    72 : data_()
    │ │ │ │ +
    73 {}
    │ │ │ │ +
    74
    │ │ │ │ +
    76 ScalarMatrixView (K* p) :
    │ │ │ │ +
    77 data_(p)
    │ │ │ │ +
    78 {}
    │ │ │ │ +
    79
    │ │ │ │ +
    81 ScalarMatrixView (const ScalarMatrixView &other) :
    │ │ │ │ +
    82 Base(),
    │ │ │ │ +
    83 data_(other.data_)
    │ │ │ │ +
    84 {}
    │ │ │ │
    85
    │ │ │ │ -
    │ │ │ │ -
    87 inline Indent operator+(const std::string& newindent) const {
    │ │ │ │ -
    88 return Indent(this, newindent);
    │ │ │ │ -
    89 }
    │ │ │ │ -
    │ │ │ │ -
    │ │ │ │ -
    91 inline Indent operator+(unsigned morelevel) const {
    │ │ │ │ -
    92 return Indent(parent, basic_indent, level+morelevel);
    │ │ │ │ -
    93 }
    │ │ │ │ -
    │ │ │ │ -
    95 inline Indent& operator++() { ++level; return *this; }
    │ │ │ │ -
    97 inline Indent& operator--() { if ( level > 0 ) --level; return *this; }
    │ │ │ │ +
    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 }
    │ │ │ │
    98
    │ │ │ │ -
    100 friend inline std::ostream& operator<<(std::ostream& s,
    │ │ │ │ -
    101 const Indent& indent);
    │ │ │ │ -
    102 };
    │ │ │ │ -
    │ │ │ │ -
    103
    │ │ │ │ -
    │ │ │ │ -
    105 inline std::ostream& operator<<(std::ostream& s, const Indent& indent) {
    │ │ │ │ -
    106 if(indent.parent)
    │ │ │ │ -
    107 s << *indent.parent;
    │ │ │ │ -
    108 for(unsigned i = 0; i < indent.level; ++i)
    │ │ │ │ -
    109 s << indent.basic_indent;
    │ │ │ │ -
    110 return s;
    │ │ │ │ -
    111 }
    │ │ │ │ -
    │ │ │ │ -
    112
    │ │ │ │ -
    115} // namespace Dune
    │ │ │ │ -
    116
    │ │ │ │ -
    117#endif // DUNE_COMMON_INDENT_HH
    │ │ │ │ -
    Indent operator+(const std::string &newindent) const
    create new indentation object with this one as parent
    Definition indent.hh:87
    │ │ │ │ -
    Indent(unsigned level_)
    setup without parent and basic_indentation of two spaces
    Definition indent.hh:68
    │ │ │ │ -
    Indent operator+(unsigned morelevel) const
    create a copy of this indentation object with raised level
    Definition indent.hh:91
    │ │ │ │ -
    Indent(const Indent *parent_, unsigned level_)
    setup with parent
    Definition indent.hh:82
    │ │ │ │ -
    Indent & operator++()
    raise indentation level
    Definition indent.hh:95
    │ │ │ │ -
    Indent(const std::string &basic_indent_=" ", unsigned level_=0)
    setup without parent
    Definition indent.hh:63
    │ │ │ │ -
    Indent & operator--()
    lower indentation level
    Definition indent.hh:97
    │ │ │ │ -
    friend std::ostream & operator<<(std::ostream &s, const Indent &indent)
    write indentation to a stream
    Definition indent.hh:105
    │ │ │ │ -
    Indent(const Indent *parent_, const std::string &basic_indent_=" ", unsigned level_=1)
    setup with parent
    Definition indent.hh:76
    │ │ │ │ -
    std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x)
    Definition bigunsignedint.hh:278
    │ │ │ │ +
    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 }
    │ │ │ │ +
    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 };
    │ │ │ │ +
    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
    │ │ │ │ +
    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 scalar vector view wrapper around an existing scalar.
    │ │ │ │ +
    Implements a matrix constructed from a given type representing a field and a compile-time given numbe...
    │ │ │ │ +
    Macro for wrapping boundary checks.
    │ │ │ │ +
    Implements a matrix constructed from a given type representing a field and compile-time given number ...
    │ │ │ │ +
    Traits for type conversions and type information.
    │ │ │ │ +
    #define DUNE_ASSERT_BOUNDS(cond)
    If DUNE_CHECK_BOUNDS is defined: check if condition cond holds; otherwise, do nothing.
    Definition boundschecking.hh:30
    │ │ │ │
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ -
    Utility class for handling nested indentation in output.
    Definition indent.hh:53
    │ │ │ │ +
    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:501
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,121 +7,234 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -indent.hh │ │ │ │ │ +scalarmatrixview.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 (C) 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_INDENT_HH │ │ │ │ │ - 6#define DUNE_COMMON_INDENT_HH │ │ │ │ │ + 5#ifndef DUNE_COMMON_SCALARMATRIXVIEW_HH │ │ │ │ │ + 6#define DUNE_COMMON_SCALARMATRIXVIEW_HH │ │ │ │ │ 7 │ │ │ │ │ - 8#include │ │ │ │ │ - 9#include │ │ │ │ │ - 10 │ │ │ │ │ - 11namespace Dune { │ │ │ │ │ - 22 │ │ │ │ │ -52 class Indent │ │ │ │ │ - 53 { │ │ │ │ │ - 54 const Indent* parent; │ │ │ │ │ - 55 std::string basic_indent; │ │ │ │ │ - 56 unsigned level; │ │ │ │ │ - 57 │ │ │ │ │ - 58 public: │ │ │ │ │ + 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; │ │ │ │ │ 60 │ │ │ │ │ -63 inline Indent(const std::string& basic_indent_ = " ", unsigned level_ = 0) │ │ │ │ │ - 64 : parent(0), basic_indent(basic_indent_), level(level_) │ │ │ │ │ - 65 { } │ │ │ │ │ - 66 │ │ │ │ │ -68 inline Indent(unsigned level_) │ │ │ │ │ - 69 : parent(0), basic_indent(" "), level(level_) │ │ │ │ │ - 70 { } │ │ │ │ │ - 71 │ │ │ │ │ - 73 │ │ │ │ │ -76 inline Indent(const Indent* parent_, │ │ │ │ │ - 77 const std::string& basic_indent_ = " ", unsigned level_ = 1) │ │ │ │ │ - 78 : parent(parent_), basic_indent(basic_indent_), level(level_) │ │ │ │ │ - 79 { } │ │ │ │ │ - 80 │ │ │ │ │ -82 inline Indent(const Indent* parent_, unsigned level_) │ │ │ │ │ - 83 : parent(parent_), basic_indent(" "), level(level_) │ │ │ │ │ - 84 { } │ │ │ │ │ + 63 constexpr static int rows = 1; │ │ │ │ │ + 66 constexpr static int cols = 1; │ │ │ │ │ + 67 │ │ │ │ │ + 68 //===== constructors │ │ │ │ │ + 71 constexpr ScalarMatrixView () │ │ │ │ │ + 72 : data_() │ │ │ │ │ + 73 {} │ │ │ │ │ + 74 │ │ │ │ │ + 76 ScalarMatrixView (K* p) : │ │ │ │ │ + 77 data_(p) │ │ │ │ │ + 78 {} │ │ │ │ │ + 79 │ │ │ │ │ + 81 ScalarMatrixView (const ScalarMatrixView &other) : │ │ │ │ │ + 82 Base(), │ │ │ │ │ + 83 data_(other.data_) │ │ │ │ │ + 84 {} │ │ │ │ │ 85 │ │ │ │ │ -87 inline Indent operator+(const std::string& newindent) const { │ │ │ │ │ - 88 return Indent(this, newindent); │ │ │ │ │ - 89 } │ │ │ │ │ -91 inline Indent operator+(unsigned morelevel) const { │ │ │ │ │ - 92 return Indent(parent, basic_indent, level+morelevel); │ │ │ │ │ - 93 } │ │ │ │ │ -95 inline Indent& operator++() { ++level; return *this; } │ │ │ │ │ -97 inline Indent& operator--() { if ( level > 0 ) --level; return *this; } │ │ │ │ │ + 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 } │ │ │ │ │ 98 │ │ │ │ │ - 100 friend inline std::ostream& operator<<(std::ostream& s, │ │ │ │ │ - 101 const Indent& indent); │ │ │ │ │ - 102 }; │ │ │ │ │ - 103 │ │ │ │ │ -105 inline std::ostream& operator<<(std::ostream& s, const Indent& indent) { │ │ │ │ │ - 106 if(indent.parent) │ │ │ │ │ - 107 s << *indent.parent; │ │ │ │ │ - 108 for(unsigned i = 0; i < indent.level; ++i) │ │ │ │ │ - 109 s << indent.basic_indent; │ │ │ │ │ - 110 return s; │ │ │ │ │ - 111 } │ │ │ │ │ - 112 │ │ │ │ │ - 115} // namespace Dune │ │ │ │ │ - 116 │ │ │ │ │ - 117#endif // DUNE_COMMON_INDENT_HH │ │ │ │ │ -Dune::Indent::operator+ │ │ │ │ │ -Indent operator+(const std::string &newindent) const │ │ │ │ │ -create new indentation object with this one as parent │ │ │ │ │ -Definition indent.hh:87 │ │ │ │ │ -Dune::Indent::Indent │ │ │ │ │ -Indent(unsigned level_) │ │ │ │ │ -setup without parent and basic_indentation of two spaces │ │ │ │ │ -Definition indent.hh:68 │ │ │ │ │ -Dune::Indent::operator+ │ │ │ │ │ -Indent operator+(unsigned morelevel) const │ │ │ │ │ -create a copy of this indentation object with raised level │ │ │ │ │ -Definition indent.hh:91 │ │ │ │ │ -Dune::Indent::Indent │ │ │ │ │ -Indent(const Indent *parent_, unsigned level_) │ │ │ │ │ -setup with parent │ │ │ │ │ -Definition indent.hh:82 │ │ │ │ │ -Dune::Indent::operator++ │ │ │ │ │ -Indent & operator++() │ │ │ │ │ -raise indentation level │ │ │ │ │ -Definition indent.hh:95 │ │ │ │ │ -Dune::Indent::Indent │ │ │ │ │ -Indent(const std::string &basic_indent_=" ", unsigned level_=0) │ │ │ │ │ -setup without parent │ │ │ │ │ -Definition indent.hh:63 │ │ │ │ │ -Dune::Indent::operator-- │ │ │ │ │ -Indent & operator--() │ │ │ │ │ -lower indentation level │ │ │ │ │ -Definition indent.hh:97 │ │ │ │ │ -Dune::Indent::operator<< │ │ │ │ │ -friend std::ostream & operator<<(std::ostream &s, const Indent &indent) │ │ │ │ │ -write indentation to a stream │ │ │ │ │ -Definition indent.hh:105 │ │ │ │ │ -Dune::Indent::Indent │ │ │ │ │ -Indent(const Indent *parent_, const std::string &basic_indent_=" ", unsigned │ │ │ │ │ -level_=1) │ │ │ │ │ -setup with parent │ │ │ │ │ -Definition indent.hh:76 │ │ │ │ │ -Dune::operator<< │ │ │ │ │ -std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x) │ │ │ │ │ -Definition bigunsignedint.hh:278 │ │ │ │ │ + 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 } │ │ │ │ │ + 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 }; │ │ │ │ │ + 189 │ │ │ │ │ + 190 │ │ │ │ │ + 191 template │ │ │ │ │ + 192 struct AutonomousValueType> │ │ │ │ │ + 193 { │ │ │ │ │ + 194 using type = FieldMatrix,1,1>; │ │ │ │ │ + 195 }; │ │ │ │ │ + 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... │ │ │ │ │ +scalarvectorview.hh │ │ │ │ │ +Implements a scalar vector view wrapper around an existing scalar. │ │ │ │ │ +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. │ │ │ │ │ +fmatrix.hh │ │ │ │ │ +Implements a matrix constructed from a given type representing a field and │ │ │ │ │ +compile-time given number ... │ │ │ │ │ +typetraits.hh │ │ │ │ │ +Traits for type conversions and type information. │ │ │ │ │ +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 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::Indent │ │ │ │ │ -Utility class for handling nested indentation in output. │ │ │ │ │ -Definition indent.hh:53 │ │ │ │ │ +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:501 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00233.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: rangeutilities.hh File Reference │ │ │ │ +dune-common: tupleutility.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -72,119 +72,116 @@ │ │ │ │ │ │ │ │
    │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ Classes | │ │ │ │ Namespaces | │ │ │ │ -Functions | │ │ │ │ -Variables
    │ │ │ │ -
    rangeutilities.hh File Reference
    │ │ │ │ +Functions
    │ │ │ │ +
    tupleutility.hh File Reference
    │ │ │ │ │ │ │ │
    │ │ │ │ │ │ │ │ -

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

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

    │ │ │ │ -
    #include <dune/common/typetraits.hh>
    │ │ │ │ -#include <algorithm>
    │ │ │ │ -#include <utility>
    │ │ │ │ +
    #include <cstddef>
    │ │ │ │ +#include <tuple>
    │ │ │ │ #include <type_traits>
    │ │ │ │ -#include <bitset>
    │ │ │ │ +#include <utility>
    │ │ │ │ +#include <dune/common/hybridutilities.hh>
    │ │ │ │ +#include <dune/common/typetraits.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...
    struct  Dune::TupleAccessTraits< T >
     
    struct  Dune::TupleAccessTraits< T * >
     
    struct  Dune::TupleAccessTraits< T & >
     
    struct  Dune::NullPointerInitialiser< std::tuple< Args... > >
     
    struct  Dune::ForEachType< TE, std::tuple< Args... > >
     
    class  Dune::TransformTupleFunctor< TE, Args >
     
    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 & >
     
    class  Dune::StaticIntegralRange< T, to, from >
     static integer range for use in range-based for loops More...
    struct  Dune::AtType< N, Tuple >
     Type for reverse element access. More...
     
    struct  Dune::ValueTransformationTag
     Tag to enable value based transformations in TransformedRangeView. More...
    struct  Dune::At< N >
     Reverse element access. More...
     
    struct  Dune::IteratorTransformationTag
     Tag to enable iterator based transformations in TransformedRangeView. More...
    struct  Dune::PointerPairDeletor< Tuple >
     Deletes all objects pointed to in a std::tuple of pointers. More...
     
    class  Dune::TransformedRangeView< R, F, T >
     A range transforming the values of another range on-the-fly. 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...
     
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

    │ │ │ │ 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, const F &f)
     Create a TransformedRangeView.
     
    template<class R , class F >
    auto Dune::iteratorTransformedRangeView (R &&range, const 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
     
    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

    │ │ │ │ -

    Utilities for reduction like operations on ranges.

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

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

    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,134 +6,110 @@ │ │ │ │ │ dune-common 2.9.0 │ │ │ │ │ │ │ │ │ │ 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 │ │ │ │ │ +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 │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ - class  Dune::IntegralRange<_T_> │ │ │ │ │ -  dynamic integer range for use in range-based for loops More... │ │ │ │ │ +struct  Dune::TupleAccessTraits<_T_> │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::TupleAccessTraits<_T_*_> │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::TupleAccessTraits<_T_&_> │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::NullPointerInitialiser<_std::tuple<_Args..._>_> │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::ForEachType<_TE,_std::tuple<_Args..._>_> │ │ │ │ │ +  │ │ │ │ │ + class  Dune::TransformTupleFunctor<_TE,_Args_> │ │ │ │ │ +  │ │ │ │ │ +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... │ │ │ │ │   │ │ │ │ │ - class  Dune::StaticIntegralRange<_T,_to,_from_> │ │ │ │ │ -  static integer range for use in range-based for loops More... │ │ │ │ │ +struct  Dune::ReduceTuple<_F,_Tuple,_Seed,_0_> │ │ │ │ │ +  Apply reduce with meta binary function to template. 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... │ │ │ │ │ +struct  Dune::JoinTuples<_Head,_Tail_> │ │ │ │ │ +  Join two std::tuple's. More... │ │ │ │ │   │ │ │ │ │ - class  Dune::TransformedRangeView<_R,_F,_T_> │ │ │ │ │ -  A range transforming the values of another range on-the-fly. More... │ │ │ │ │ +struct  Dune::FlattenTuple<_Tuple_> │ │ │ │ │ +  Flatten a std::tuple of std::tuple's. 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, const F &f) │ │ │ │ │ -  Create a TransformedRangeView. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - auto Dune::iteratorTransformedRangeView │ │ │ │ │ - (R &&range, const 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 │ │ │ │ │ +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 ***** │ │ │ │ │ -Utilities for reduction like operations on ranges. │ │ │ │ │ - Author │ │ │ │ │ - Christian Engwer │ │ │ │ │ +Contains utility classes which can be used with std::tuple. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00233_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: rangeutilities.hh Source File │ │ │ │ +dune-common: tupleutility.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,707 +74,447 @@ │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ │
    │ │ │ │ -
    rangeutilities.hh
    │ │ │ │ +
    tupleutility.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 (C) 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
    │ │ │ │ - │ │ │ │ -
    9#include <algorithm>
    │ │ │ │ -
    10#include <utility>
    │ │ │ │ +
    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 <bitset>
    │ │ │ │ +
    12#include <utility>
    │ │ │ │
    13
    │ │ │ │ -
    21namespace Dune
    │ │ │ │ -
    22{
    │ │ │ │ -
    23
    │ │ │ │ -
    34 template <typename T,
    │ │ │ │ -
    35 typename std::enable_if<IsIterable<T>::value, int>::type = 0>
    │ │ │ │ -
    36 typename T::value_type
    │ │ │ │ -
    │ │ │ │ -
    37 max_value(const T & v) {
    │ │ │ │ -
    38 using std::max_element;
    │ │ │ │ -
    39 return *max_element(v.begin(), v.end());
    │ │ │ │ -
    40 }
    │ │ │ │ -
    │ │ │ │ -
    41
    │ │ │ │ -
    42 template <typename T,
    │ │ │ │ -
    43 typename std::enable_if<!IsIterable<T>::value, int>::type = 0>
    │ │ │ │ -
    44 const T & max_value(const T & v) { return v; }
    │ │ │ │ -
    45
    │ │ │ │ -
    51 template <typename T,
    │ │ │ │ -
    52 typename std::enable_if<IsIterable<T>::value, int>::type = 0>
    │ │ │ │ -
    53 typename T::value_type
    │ │ │ │ -
    │ │ │ │ -
    54 min_value(const T & v) {
    │ │ │ │ -
    55 using std::min_element;
    │ │ │ │ -
    56 return *min_element(v.begin(), v.end());
    │ │ │ │ -
    57 }
    │ │ │ │ -
    │ │ │ │ -
    58
    │ │ │ │ -
    59 template <typename T,
    │ │ │ │ -
    60 typename std::enable_if<!IsIterable<T>::value, int>::type = 0>
    │ │ │ │ -
    61 const T & min_value(const T & v) { return v; }
    │ │ │ │ + │ │ │ │ + │ │ │ │ +
    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 };
    │ │ │ │ +
    │ │ │ │
    62
    │ │ │ │ -
    68 template <typename T,
    │ │ │ │ -
    69 typename std::enable_if<IsIterable<T>::value, int>::type = 0>
    │ │ │ │ -
    │ │ │ │ -
    70 bool any_true(const T & v) {
    │ │ │ │ -
    71 bool b = false;
    │ │ │ │ -
    72 for (const auto & e : v)
    │ │ │ │ -
    73 b = b or bool(e);
    │ │ │ │ -
    74 return b;
    │ │ │ │ -
    75 }
    │ │ │ │ -
    │ │ │ │ -
    76
    │ │ │ │ -
    77 template <typename T,
    │ │ │ │ -
    78 typename std::enable_if<!IsIterable<T>::value, int>::type = 0>
    │ │ │ │ -
    79 bool any_true(const T & v) { return v; }
    │ │ │ │ +
    63 template<class T>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    65 {
    │ │ │ │ +
    66 typedef T& ConstType;
    │ │ │ │ +
    67 typedef T& NonConstType;
    │ │ │ │ +
    68 typedef T& ParameterType;
    │ │ │ │ +
    69 };
    │ │ │ │ +
    │ │ │ │ +
    70
    │ │ │ │ +
    78 template<class T>
    │ │ │ │ + │ │ │ │
    80
    │ │ │ │ -
    81 template<std::size_t N>
    │ │ │ │ -
    │ │ │ │ -
    82 bool any_true(const std::bitset<N> & b)
    │ │ │ │ +
    81 template<class... Args>
    │ │ │ │ +
    │ │ │ │ +
    82 struct NullPointerInitialiser<std::tuple<Args...> >
    │ │ │ │
    83 {
    │ │ │ │ -
    84 return b.any();
    │ │ │ │ -
    85 }
    │ │ │ │ -
    │ │ │ │ -
    86
    │ │ │ │ -
    92 template <typename T,
    │ │ │ │ -
    93 typename std::enable_if<IsIterable<T>::value, int>::type = 0>
    │ │ │ │ -
    │ │ │ │ -
    94 bool all_true(const T & v) {
    │ │ │ │ -
    95 bool b = true;
    │ │ │ │ -
    96 for (const auto & e : v)
    │ │ │ │ -
    97 b = b and bool(e);
    │ │ │ │ -
    98 return b;
    │ │ │ │ -
    99 }
    │ │ │ │ -
    │ │ │ │ -
    100
    │ │ │ │ -
    101 template <typename T,
    │ │ │ │ -
    102 typename std::enable_if<!IsIterable<T>::value, int>::type = 0>
    │ │ │ │ -
    103 bool all_true(const T & v) { return v; }
    │ │ │ │ -
    104
    │ │ │ │ -
    105 template<std::size_t N>
    │ │ │ │ -
    │ │ │ │ -
    106 bool all_true(const std::bitset<N> & b)
    │ │ │ │ -
    107 {
    │ │ │ │ -
    108 return b.all();
    │ │ │ │ -
    109 }
    │ │ │ │ -
    │ │ │ │ -
    110
    │ │ │ │ -
    111
    │ │ │ │ -
    112
    │ │ │ │ -
    113 namespace Impl
    │ │ │ │ -
    114 {
    │ │ │ │ -
    115
    │ │ │ │ -
    116 template <class T>
    │ │ │ │ -
    117 class IntegralRangeIterator
    │ │ │ │ -
    118 {
    │ │ │ │ -
    119 public:
    │ │ │ │ -
    120 typedef std::random_access_iterator_tag iterator_category;
    │ │ │ │ -
    121 typedef T value_type;
    │ │ │ │ -
    122 typedef std::make_signed_t<T> difference_type;
    │ │ │ │ -
    123 typedef const T *pointer;
    │ │ │ │ -
    124 typedef T reference;
    │ │ │ │ -
    125
    │ │ │ │ -
    126 constexpr IntegralRangeIterator() noexcept : value_(0) {}
    │ │ │ │ -
    127 constexpr explicit IntegralRangeIterator(value_type value) noexcept : value_(value) {}
    │ │ │ │ -
    128
    │ │ │ │ -
    129 pointer operator->() const noexcept { return &value_; }
    │ │ │ │ -
    130 constexpr reference operator*() const noexcept { return value_; }
    │ │ │ │ +
    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 constexpr reference operator[]( difference_type n ) const noexcept { return (value_ + n); }
    │ │ │ │ -
    133
    │ │ │ │ -
    134 constexpr bool operator==(const IntegralRangeIterator & other) const noexcept { return (value_ == other.value_); }
    │ │ │ │ -
    135 constexpr bool operator!=(const IntegralRangeIterator & other) const noexcept { return (value_ != other.value_); }
    │ │ │ │ -
    136
    │ │ │ │ -
    137 constexpr bool operator<(const IntegralRangeIterator & other) const noexcept { return (value_ <= other.value_); }
    │ │ │ │ -
    138 constexpr bool operator<=(const IntegralRangeIterator & other) const noexcept { return (value_ <= other.value_); }
    │ │ │ │ -
    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
    │ │ │ │ -
    142 IntegralRangeIterator& operator++() noexcept { ++value_; return *this; }
    │ │ │ │ -
    143 IntegralRangeIterator operator++(int) noexcept { IntegralRangeIterator copy( *this ); ++(*this); return copy; }
    │ │ │ │ -
    144
    │ │ │ │ -
    145 IntegralRangeIterator& operator--() noexcept { --value_; return *this; }
    │ │ │ │ -
    146 IntegralRangeIterator operator--(int) noexcept { IntegralRangeIterator copy( *this ); --(*this); return copy; }
    │ │ │ │ -
    147
    │ │ │ │ -
    148 IntegralRangeIterator& operator+=(difference_type n) noexcept { value_ += n; return *this; }
    │ │ │ │ -
    149 IntegralRangeIterator& operator-=(difference_type n) noexcept { value_ -= n; return *this; }
    │ │ │ │ -
    150
    │ │ │ │ -
    151 friend constexpr IntegralRangeIterator operator+(const IntegralRangeIterator &a, difference_type n) noexcept { return IntegralRangeIterator(a.value_ + n); }
    │ │ │ │ -
    152 friend constexpr IntegralRangeIterator operator+(difference_type n, const IntegralRangeIterator &a) noexcept { return IntegralRangeIterator(a.value_ + n); }
    │ │ │ │ -
    153 friend constexpr IntegralRangeIterator operator-(const IntegralRangeIterator &a, difference_type n) noexcept { return IntegralRangeIterator(a.value_ - n); }
    │ │ │ │ -
    154
    │ │ │ │ -
    155 constexpr difference_type operator-(const IntegralRangeIterator &other) const noexcept { return (static_cast<difference_type>(value_) - static_cast<difference_type>(other.value_)); }
    │ │ │ │ -
    156
    │ │ │ │ -
    157 private:
    │ │ │ │ -
    158 value_type value_;
    │ │ │ │ -
    159 };
    │ │ │ │ -
    160
    │ │ │ │ -
    161 } // namespace Impl
    │ │ │ │ -
    162
    │ │ │ │ -
    163
    │ │ │ │ -
    164
    │ │ │ │ -
    173 template <class T>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    175 {
    │ │ │ │ -
    176 public:
    │ │ │ │ -
    178 typedef T value_type;
    │ │ │ │ -
    180 typedef Impl::IntegralRangeIterator<T> iterator;
    │ │ │ │ -
    182 typedef std::make_unsigned_t<T> size_type;
    │ │ │ │ -
    183
    │ │ │ │ -
    185 constexpr IntegralRange(value_type from, value_type to) noexcept : from_(from), to_(to) {}
    │ │ │ │ -
    187 constexpr explicit IntegralRange(value_type to) noexcept : from_(0), to_(to) {}
    │ │ │ │ -
    189 constexpr IntegralRange(std::pair<value_type, value_type> range) noexcept : from_(range.first), to_(range.second) {}
    │ │ │ │ -
    190
    │ │ │ │ -
    192 constexpr iterator begin() const noexcept { return iterator(from_); }
    │ │ │ │ -
    194 constexpr iterator end() const noexcept { return iterator(to_); }
    │ │ │ │ -
    195
    │ │ │ │ -
    197 constexpr value_type operator[](const value_type &i) const noexcept { return (from_ + i); }
    │ │ │ │ -
    198
    │ │ │ │ -
    200 constexpr bool empty() const noexcept { return (from_ == to_); }
    │ │ │ │ -
    202 constexpr size_type size() const noexcept { return (static_cast<size_type>(to_) - static_cast<size_type>(from_)); }
    │ │ │ │ -
    203
    │ │ │ │ -
    204 private:
    │ │ │ │ -
    205 value_type from_, to_;
    │ │ │ │ -
    206 };
    │ │ │ │ -
    │ │ │ │ -
    207
    │ │ │ │ -
    208
    │ │ │ │ -
    223 template <class T, T to, T from = 0>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    225 {
    │ │ │ │ -
    226 template <T ofs, T... i>
    │ │ │ │ -
    227 static std::integer_sequence<T, (i+ofs)...> shift_integer_sequence(std::integer_sequence<T, i...>);
    │ │ │ │ +
    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 public:
    │ │ │ │ -
    231 typedef T value_type;
    │ │ │ │ -
    233 typedef Impl::IntegralRangeIterator<T> iterator;
    │ │ │ │ -
    235 typedef std::make_unsigned_t<T> size_type;
    │ │ │ │ -
    236
    │ │ │ │ -
    238 typedef decltype(shift_integer_sequence<from>(std::make_integer_sequence<T, to-from>())) integer_sequence;
    │ │ │ │ -
    239
    │ │ │ │ -
    241 constexpr StaticIntegralRange() noexcept = default;
    │ │ │ │ -
    242
    │ │ │ │ -
    244 constexpr operator IntegralRange<T>() const noexcept { return {from, to}; }
    │ │ │ │ -
    246 constexpr operator integer_sequence() const noexcept { return {}; }
    │ │ │ │ -
    247
    │ │ │ │ -
    249 static constexpr iterator begin() noexcept { return iterator(from); }
    │ │ │ │ -
    251 static constexpr iterator end() noexcept { return iterator(to); }
    │ │ │ │ +
    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
    │ │ │ │ -
    254 template <class U, U i>
    │ │ │ │ -
    │ │ │ │ -
    255 constexpr auto operator[](const std::integral_constant<U, i> &) const noexcept
    │ │ │ │ -
    256 -> std::integral_constant<value_type, from + static_cast<value_type>(i)>
    │ │ │ │ -
    257 {
    │ │ │ │ -
    258 return {};
    │ │ │ │ -
    259 }
    │ │ │ │ -
    │ │ │ │ -
    260
    │ │ │ │ -
    262 constexpr value_type operator[](const size_type &i) const noexcept { return (from + static_cast<value_type>(i)); }
    │ │ │ │ -
    263
    │ │ │ │ -
    265 static constexpr std::integral_constant<bool, from == to> empty() noexcept { return {}; }
    │ │ │ │ -
    267 static constexpr std::integral_constant<size_type, static_cast<size_type>(to) - static_cast<size_type>(from) > size() noexcept { return {}; }
    │ │ │ │ -
    268 };
    │ │ │ │ -
    │ │ │ │ -
    269
    │ │ │ │ -
    279 template<class T, class U,
    │ │ │ │ -
    280 std::enable_if_t<std::is_same<std::decay_t<T>, std::decay_t<U>>::value, int> = 0,
    │ │ │ │ -
    281 std::enable_if_t<std::is_integral<std::decay_t<T>>::value, int> = 0>
    │ │ │ │ -
    │ │ │ │ -
    282 inline static IntegralRange<std::decay_t<T>> range(T &&from, U &&to) noexcept
    │ │ │ │ -
    283 {
    │ │ │ │ -
    284 return IntegralRange<std::decay_t<T>>(std::forward<T>(from), std::forward<U>(to));
    │ │ │ │ -
    285 }
    │ │ │ │ -
    │ │ │ │ -
    286
    │ │ │ │ -
    287 template<class T, std::enable_if_t<std::is_integral<std::decay_t<T>>::value, int> = 0>
    │ │ │ │ -
    │ │ │ │ -
    288 inline static IntegralRange<std::decay_t<T>> range(T &&to) noexcept
    │ │ │ │ -
    289 {
    │ │ │ │ -
    290 return IntegralRange<std::decay_t<T>>(std::forward<T>(to));
    │ │ │ │ -
    291 }
    │ │ │ │ -
    │ │ │ │ -
    292
    │ │ │ │ -
    293 template<class T, std::enable_if_t<std::is_enum<std::decay_t<T>>::value, int> = 0>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    295 {
    │ │ │ │ -
    296 return IntegralRange<std::underlying_type_t<std::decay_t<T>>>(std::forward<T>(to));
    │ │ │ │ -
    297 }
    │ │ │ │ -
    │ │ │ │ -
    298
    │ │ │ │ -
    299 template<class T, T from, T to>
    │ │ │ │ -
    │ │ │ │ -
    300 inline static StaticIntegralRange<T, to, from> range(std::integral_constant<T, from>, std::integral_constant<T, to>) noexcept
    │ │ │ │ -
    301 {
    │ │ │ │ -
    302 return {};
    │ │ │ │ -
    303 }
    │ │ │ │ -
    │ │ │ │ -
    304
    │ │ │ │ -
    305 template<class T, T to>
    │ │ │ │ -
    │ │ │ │ -
    306 inline static StaticIntegralRange<T, to> range(std::integral_constant<T, to>) noexcept
    │ │ │ │ -
    307 {
    │ │ │ │ -
    308 return {};
    │ │ │ │ -
    309 }
    │ │ │ │ +
    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 }
    │ │ │ │ +
    │ │ │ │ +
    311 };
    │ │ │ │
    │ │ │ │ -
    310
    │ │ │ │ -
    311
    │ │ │ │
    312
    │ │ │ │ - │ │ │ │ -
    317
    │ │ │ │ - │ │ │ │ -
    322
    │ │ │ │ -
    323 namespace Impl
    │ │ │ │ -
    324 {
    │ │ │ │ -
    325
    │ │ │ │ -
    326 // Helper class to mimic a pointer for proxy objects.
    │ │ │ │ -
    327 // This is needed to implement operator-> on an iterator
    │ │ │ │ -
    328 // using proxy-values. It stores the proxy value but
    │ │ │ │ -
    329 // provides operator-> like a pointer.
    │ │ │ │ -
    330 template<class ProxyType>
    │ │ │ │ -
    331 class PointerProxy
    │ │ │ │ -
    332 {
    │ │ │ │ -
    333 public:
    │ │ │ │ -
    334 PointerProxy(ProxyType&& p) : p_(p)
    │ │ │ │ -
    335 {}
    │ │ │ │ -
    336
    │ │ │ │ -
    337 ProxyType* operator->()
    │ │ │ │ -
    338 {
    │ │ │ │ -
    339 return &p_;
    │ │ │ │ -
    340 }
    │ │ │ │ -
    341
    │ │ │ │ -
    342 ProxyType p_;
    │ │ │ │ -
    343 };
    │ │ │ │ -
    344
    │ │ │ │ -
    345 // An iterator transforming a wrapped iterator using
    │ │ │ │ -
    346 // an unary function. It inherits the iterator-category
    │ │ │ │ -
    347 // of the underlying iterator.
    │ │ │ │ -
    348 template <class I, class F, class TransformationType, class C = typename std::iterator_traits<I>::iterator_category>
    │ │ │ │ -
    349 class TransformedRangeIterator;
    │ │ │ │ -
    350
    │ │ │ │ -
    351 template <class I, class F, class TransformationType>
    │ │ │ │ -
    352 class TransformedRangeIterator<I,F,TransformationType,std::forward_iterator_tag>
    │ │ │ │ -
    353 {
    │ │ │ │ -
    354 protected:
    │ │ │ │ -
    355
    │ │ │ │ -
    356 static decltype(auto) transform(const F& f, const I& it) {
    │ │ │ │ -
    357 if constexpr (std::is_same_v<TransformationType,IteratorTransformationTag>)
    │ │ │ │ -
    358 return f(it);
    │ │ │ │ -
    359 else
    │ │ │ │ -
    360 return f(*it);
    │ │ │ │ -
    361 }
    │ │ │ │ -
    362
    │ │ │ │ -
    363 public:
    │ │ │ │ -
    364 using iterator_category = std::forward_iterator_tag;
    │ │ │ │ -
    365 using reference = decltype(transform(std::declval<F>(), std::declval<I>()));
    │ │ │ │ -
    366 using value_type = std::decay_t<reference>;
    │ │ │ │ -
    367 using pointer = PointerProxy<value_type>;
    │ │ │ │ -
    368
    │ │ │ │ -
    369 // If we later want to allow standalone TransformedRangeIterators,
    │ │ │ │ -
    370 // we could customize the FunctionPointer to be a default-constructible,
    │ │ │ │ -
    371 // copy-assignable type storing a function but acting like a pointer
    │ │ │ │ -
    372 // to function.
    │ │ │ │ -
    373 using FunctionPointer = const F*;
    │ │ │ │ +
    314
    │ │ │ │ +
    318 template<class T>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    320 {
    │ │ │ │ +
    321 typedef typename std::remove_reference<T>::type* Type;
    │ │ │ │ +
    │ │ │ │ +
    322 static Type apply(T& t)
    │ │ │ │ +
    323 {
    │ │ │ │ +
    324 return &t;
    │ │ │ │ +
    325 }
    │ │ │ │ +
    │ │ │ │ +
    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
    │ │ │ │ +
    │ │ │ │ +
    362 get(Tuple& t)
    │ │ │ │ +
    363 {
    │ │ │ │ +
    364 return std::get<std::tuple_size<Tuple>::value - N - 1>(t);
    │ │ │ │ +
    365 }
    │ │ │ │ +
    │ │ │ │ +
    366
    │ │ │ │ +
    367 template<typename Tuple>
    │ │ │ │ +
    368 static typename TupleAccessTraits<typename AtType<N, Tuple>::Type>::ConstType
    │ │ │ │ +
    │ │ │ │ +
    369 get(const Tuple& t)
    │ │ │ │ +
    370 {
    │ │ │ │ +
    371 return std::get<std::tuple_size<Tuple>::value - N - 1>(t);
    │ │ │ │ +
    372 }
    │ │ │ │ +
    │ │ │ │ +
    373 };
    │ │ │ │ +
    │ │ │ │
    374
    │ │ │ │ -
    375 constexpr TransformedRangeIterator(const I& it, FunctionPointer f) noexcept :
    │ │ │ │ -
    376 it_(it),
    │ │ │ │ -
    377 f_(f)
    │ │ │ │ -
    378 {}
    │ │ │ │ -
    379
    │ │ │ │ -
    380 // Explicitly initialize members. Using a plain
    │ │ │ │ -
    381 //
    │ │ │ │ -
    382 // constexpr TransformedRangeIterator() noexcept {}
    │ │ │ │ -
    383 //
    │ │ │ │ -
    384 // would default-initialize the members while
    │ │ │ │ -
    385 //
    │ │ │ │ -
    386 // constexpr TransformedRangeIterator() noexcept : it_(), f_() {}
    │ │ │ │ -
    387 //
    │ │ │ │ -
    388 // leads to value-initialization. This is a case where
    │ │ │ │ -
    389 // both are really different. If it_ is a raw pointer (i.e. POD)
    │ │ │ │ -
    390 // then default-initialization leaves it uninitialized while
    │ │ │ │ -
    391 // value-initialization zero-initializes it.
    │ │ │ │ -
    392 constexpr TransformedRangeIterator() noexcept :
    │ │ │ │ -
    393 it_(),
    │ │ │ │ -
    394 f_()
    │ │ │ │ -
    395 {}
    │ │ │ │ -
    396
    │ │ │ │ -
    397 // Dereferencing returns a value created by the function
    │ │ │ │ -
    398 constexpr reference operator*() const noexcept {
    │ │ │ │ -
    399 return transform(*f_, it_);
    │ │ │ │ -
    400 }
    │ │ │ │ -
    401
    │ │ │ │ -
    402 // Dereferencing returns a value created by the function
    │ │ │ │ -
    403 pointer operator->() const noexcept {
    │ │ │ │ -
    404 return transform(*f_, it_);
    │ │ │ │ -
    405 }
    │ │ │ │ -
    406
    │ │ │ │ -
    407 constexpr TransformedRangeIterator& operator=(const TransformedRangeIterator& other) = default;
    │ │ │ │ -
    408
    │ │ │ │ -
    409 constexpr bool operator==(const TransformedRangeIterator& other) const noexcept {
    │ │ │ │ -
    410 return (it_ == other.it_);
    │ │ │ │ -
    411 }
    │ │ │ │ -
    412
    │ │ │ │ -
    413 constexpr bool operator!=(const TransformedRangeIterator& other) const noexcept {
    │ │ │ │ -
    414 return (it_ != other.it_);
    │ │ │ │ -
    415 }
    │ │ │ │ -
    416
    │ │ │ │ -
    417 TransformedRangeIterator& operator++() noexcept {
    │ │ │ │ -
    418 ++it_;
    │ │ │ │ -
    419 return *this;
    │ │ │ │ -
    420 }
    │ │ │ │ -
    421
    │ │ │ │ -
    422 TransformedRangeIterator operator++(int) noexcept {
    │ │ │ │ -
    423 TransformedRangeIterator copy(*this);
    │ │ │ │ -
    424 ++(*this);
    │ │ │ │ -
    425 return copy;
    │ │ │ │ -
    426 }
    │ │ │ │ -
    427
    │ │ │ │ -
    428 protected:
    │ │ │ │ -
    429 I it_;
    │ │ │ │ -
    430 FunctionPointer f_;
    │ │ │ │ -
    431 };
    │ │ │ │ -
    432
    │ │ │ │ +
    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>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    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
    │ │ │ │ -
    434
    │ │ │ │ -
    435 template <class I, class F, class T>
    │ │ │ │ -
    436 class TransformedRangeIterator<I,F,T,std::bidirectional_iterator_tag> :
    │ │ │ │ -
    437 public TransformedRangeIterator<I,F,T,std::forward_iterator_tag>
    │ │ │ │ -
    438 {
    │ │ │ │ -
    439 protected:
    │ │ │ │ -
    440 using Base = TransformedRangeIterator<I,F,T,std::forward_iterator_tag>;
    │ │ │ │ -
    441 using Base::it_;
    │ │ │ │ -
    442 using Base::f_;
    │ │ │ │ -
    443 public:
    │ │ │ │ -
    444 using iterator_category = std::bidirectional_iterator_tag;
    │ │ │ │ -
    445 using reference = typename Base::reference;
    │ │ │ │ -
    446 using value_type = typename Base::value_type;
    │ │ │ │ -
    447 using pointer = typename Base::pointer;
    │ │ │ │ -
    448
    │ │ │ │ -
    449 using FunctionPointer = typename Base::FunctionPointer;
    │ │ │ │ +
    443 template<class T>
    │ │ │ │ +
    │ │ │ │ +
    444 struct IsType
    │ │ │ │ +
    445 {
    │ │ │ │ +
    447 template<class U>
    │ │ │ │ +
    448 struct Predicate : public std::is_same<T, U> {};
    │ │ │ │ +
    449 };
    │ │ │ │ +
    │ │ │ │
    450
    │ │ │ │ -
    451 using Base::Base;
    │ │ │ │ -
    452
    │ │ │ │ -
    453 // Member functions of the forward_iterator that need
    │ │ │ │ -
    454 // to be redefined because the base class methods return a
    │ │ │ │ -
    455 // forward_iterator.
    │ │ │ │ -
    456 constexpr TransformedRangeIterator& operator=(const TransformedRangeIterator& other) = default;
    │ │ │ │ -
    457
    │ │ │ │ -
    458 TransformedRangeIterator& operator++() noexcept {
    │ │ │ │ -
    459 ++it_;
    │ │ │ │ -
    460 return *this;
    │ │ │ │ -
    461 }
    │ │ │ │ -
    462
    │ │ │ │ -
    463 TransformedRangeIterator operator++(int) noexcept {
    │ │ │ │ -
    464 TransformedRangeIterator copy(*this);
    │ │ │ │ -
    465 ++(*this);
    │ │ │ │ -
    466 return copy;
    │ │ │ │ -
    467 }
    │ │ │ │ +
    464 template<class Tuple, class T, std::size_t start = 0>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    466 public FirstPredicateIndex<Tuple, IsType<T>::template Predicate, start>
    │ │ │ │ +
    467 { };
    │ │ │ │ +
    │ │ │ │
    468
    │ │ │ │ -
    469 // Additional member functions of bidirectional_iterator
    │ │ │ │ -
    470 TransformedRangeIterator& operator--() noexcept {
    │ │ │ │ -
    471 --(this->it_);
    │ │ │ │ -
    472 return *this;
    │ │ │ │ -
    473 }
    │ │ │ │ -
    474
    │ │ │ │ -
    475 TransformedRangeIterator operator--(int) noexcept {
    │ │ │ │ -
    476 TransformedRangeIterator copy(*this);
    │ │ │ │ -
    477 --(*this);
    │ │ │ │ -
    478 return copy;
    │ │ │ │ -
    479 }
    │ │ │ │ -
    480 };
    │ │ │ │ -
    481
    │ │ │ │ -
    482
    │ │ │ │ +
    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
    │ │ │ │ -
    484 template <class I, class F, class T>
    │ │ │ │ -
    485 class TransformedRangeIterator<I,F,T,std::random_access_iterator_tag> :
    │ │ │ │ -
    486 public TransformedRangeIterator<I,F,T,std::bidirectional_iterator_tag>
    │ │ │ │ -
    487 {
    │ │ │ │ -
    488 protected:
    │ │ │ │ -
    489 using Base = TransformedRangeIterator<I,F,T,std::bidirectional_iterator_tag>;
    │ │ │ │ -
    490 using Base::it_;
    │ │ │ │ -
    491 using Base::f_;
    │ │ │ │ -
    492 public:
    │ │ │ │ -
    493 using iterator_category = std::random_access_iterator_tag;
    │ │ │ │ -
    494 using reference = typename Base::reference;
    │ │ │ │ -
    495 using value_type = typename Base::value_type;
    │ │ │ │ -
    496 using pointer = typename Base::pointer;
    │ │ │ │ -
    497 using difference_type = typename std::iterator_traits<I>::difference_type;
    │ │ │ │ +
    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
    │ │ │ │ -
    499 using FunctionPointer = typename Base::FunctionPointer;
    │ │ │ │ -
    500
    │ │ │ │ -
    501 using Base::Base;
    │ │ │ │ -
    502
    │ │ │ │ -
    503 // Member functions of the forward_iterator that need
    │ │ │ │ -
    504 // to be redefined because the base class methods return a
    │ │ │ │ -
    505 // forward_iterator.
    │ │ │ │ -
    506 constexpr TransformedRangeIterator& operator=(const TransformedRangeIterator& other) = default;
    │ │ │ │ -
    507
    │ │ │ │ -
    508 TransformedRangeIterator& operator++() noexcept {
    │ │ │ │ -
    509 ++it_;
    │ │ │ │ -
    510 return *this;
    │ │ │ │ -
    511 }
    │ │ │ │ -
    512
    │ │ │ │ -
    513 TransformedRangeIterator operator++(int) noexcept {
    │ │ │ │ -
    514 TransformedRangeIterator copy(*this);
    │ │ │ │ -
    515 ++(*this);
    │ │ │ │ -
    516 return copy;
    │ │ │ │ -
    517 }
    │ │ │ │ -
    518
    │ │ │ │ -
    519 // Member functions of the bidirectional_iterator that need
    │ │ │ │ -
    520 // to be redefined because the base class methods return a
    │ │ │ │ -
    521 // bidirectional_iterator.
    │ │ │ │ -
    522 TransformedRangeIterator& operator--() noexcept {
    │ │ │ │ -
    523 --(this->it_);
    │ │ │ │ -
    524 return *this;
    │ │ │ │ -
    525 }
    │ │ │ │ -
    526
    │ │ │ │ -
    527 TransformedRangeIterator operator--(int) noexcept {
    │ │ │ │ -
    528 TransformedRangeIterator copy(*this);
    │ │ │ │ -
    529 --(*this);
    │ │ │ │ -
    530 return copy;
    │ │ │ │ -
    531 }
    │ │ │ │ -
    532
    │ │ │ │ -
    533 // Additional member functions of random_access_iterator
    │ │ │ │ -
    534 TransformedRangeIterator& operator+=(difference_type n) noexcept {
    │ │ │ │ -
    535 it_ += n;
    │ │ │ │ -
    536 return *this;
    │ │ │ │ -
    537 }
    │ │ │ │ -
    538
    │ │ │ │ -
    539 TransformedRangeIterator& operator-=(difference_type n) noexcept {
    │ │ │ │ -
    540 it_ -= n;
    │ │ │ │ -
    541 return *this;
    │ │ │ │ -
    542 }
    │ │ │ │ -
    543
    │ │ │ │ -
    544 bool operator<(const TransformedRangeIterator& other) noexcept {
    │ │ │ │ -
    545 return it_<other.it_;
    │ │ │ │ -
    546 }
    │ │ │ │ -
    547
    │ │ │ │ -
    548 bool operator<=(const TransformedRangeIterator& other) noexcept {
    │ │ │ │ -
    549 return it_<=other.it_;
    │ │ │ │ -
    550 }
    │ │ │ │ -
    551
    │ │ │ │ -
    552 bool operator>(const TransformedRangeIterator& other) noexcept {
    │ │ │ │ -
    553 return it_>other.it_;
    │ │ │ │ -
    554 }
    │ │ │ │ -
    555
    │ │ │ │ -
    556 bool operator>=(const TransformedRangeIterator& other) noexcept {
    │ │ │ │ -
    557 return it_>=other.it_;
    │ │ │ │ -
    558 }
    │ │ │ │ -
    559
    │ │ │ │ -
    560 reference operator[](difference_type n) noexcept {
    │ │ │ │ -
    561 return Base::transform(*f_, it_+n);
    │ │ │ │ -
    562 }
    │ │ │ │ -
    563
    │ │ │ │ -
    564 friend
    │ │ │ │ -
    565 TransformedRangeIterator operator+(const TransformedRangeIterator& it, difference_type n) noexcept {
    │ │ │ │ -
    566 return TransformedRangeIterator(it.it_+n, it.f_);
    │ │ │ │ -
    567 }
    │ │ │ │ -
    568
    │ │ │ │ -
    569 friend
    │ │ │ │ -
    570 TransformedRangeIterator operator+(difference_type n, const TransformedRangeIterator& it) noexcept {
    │ │ │ │ -
    571 return TransformedRangeIterator(n+it.it_, it.f_);
    │ │ │ │ -
    572 }
    │ │ │ │ -
    573
    │ │ │ │ -
    574 friend
    │ │ │ │ -
    575 TransformedRangeIterator operator-(const TransformedRangeIterator& it, difference_type n) noexcept {
    │ │ │ │ -
    576 return TransformedRangeIterator(it.it_-n, it.f_);
    │ │ │ │ -
    577 }
    │ │ │ │ +
    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 };
    │ │ │ │ +
    │ │ │ │ +
    544
    │ │ │ │ +
    554 template<class Head, class Tail>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    556 {
    │ │ │ │ + │ │ │ │ +
    559 };
    │ │ │ │ +
    │ │ │ │ +
    560
    │ │ │ │ +
    569 template<class Tuple>
    │ │ │ │ +
    │ │ │ │ + │ │ │ │ +
    571 {
    │ │ │ │ + │ │ │ │ +
    574 };
    │ │ │ │ +
    │ │ │ │ +
    575
    │ │ │ │ +
    577}
    │ │ │ │
    578
    │ │ │ │ -
    579 friend
    │ │ │ │ -
    580 difference_type operator-(const TransformedRangeIterator& first, const TransformedRangeIterator& second) noexcept {
    │ │ │ │ -
    581 return first.it_-second.it_;
    │ │ │ │ -
    582 }
    │ │ │ │ -
    583 };
    │ │ │ │ -
    584
    │ │ │ │ -
    585
    │ │ │ │ -
    586 } // namespace Impl
    │ │ │ │ -
    587
    │ │ │ │ -
    588
    │ │ │ │ -
    589
    │ │ │ │ -
    626 template <class R, class F, class T=ValueTransformationTag>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    628 {
    │ │ │ │ -
    629 using RawConstIterator = std::decay_t<decltype(std::declval<const R>().begin())>;
    │ │ │ │ -
    630 using RawIterator = std::decay_t<decltype(std::declval<R>().begin())>;
    │ │ │ │ -
    631
    │ │ │ │ -
    632 public:
    │ │ │ │ -
    633
    │ │ │ │ -
    640 using const_iterator = Impl::TransformedRangeIterator<RawConstIterator, F, T>;
    │ │ │ │ -
    641
    │ │ │ │ -
    648 using iterator = Impl::TransformedRangeIterator<RawIterator, F, T>;
    │ │ │ │ -
    649
    │ │ │ │ -
    656 using RawRange = std::remove_reference_t<R>;
    │ │ │ │ -
    657
    │ │ │ │ -
    661 template<class RR>
    │ │ │ │ -
    │ │ │ │ -
    662 constexpr TransformedRangeView(RR&& rawRange, const F& f) noexcept :
    │ │ │ │ -
    663 rawRange_(std::forward<RR>(rawRange)),
    │ │ │ │ -
    664 f_(f)
    │ │ │ │ -
    665 {
    │ │ │ │ -
    666 static_assert(std::is_same_v<T, ValueTransformationTag> or std::is_same_v<T, IteratorTransformationTag>,
    │ │ │ │ -
    667 "The TransformationType passed to TransformedRangeView has to be either ValueTransformationTag or IteratorTransformationTag.");
    │ │ │ │ -
    668 }
    │ │ │ │ -
    │ │ │ │ -
    669
    │ │ │ │ -
    │ │ │ │ -
    678 constexpr const_iterator begin() const noexcept {
    │ │ │ │ -
    679 return const_iterator(rawRange_.begin(), &f_);
    │ │ │ │ -
    680 }
    │ │ │ │ -
    │ │ │ │ -
    681
    │ │ │ │ -
    │ │ │ │ -
    682 constexpr iterator begin() noexcept {
    │ │ │ │ -
    683 return iterator(rawRange_.begin(), &f_);
    │ │ │ │ -
    684 }
    │ │ │ │ -
    │ │ │ │ -
    685
    │ │ │ │ -
    │ │ │ │ -
    694 constexpr const_iterator end() const noexcept {
    │ │ │ │ -
    695 return const_iterator(rawRange_.end(), &f_);
    │ │ │ │ -
    696 }
    │ │ │ │ -
    │ │ │ │ -
    697
    │ │ │ │ -
    │ │ │ │ -
    698 constexpr iterator end() noexcept {
    │ │ │ │ -
    699 return iterator(rawRange_.end(), &f_);
    │ │ │ │ -
    700 }
    │ │ │ │ -
    │ │ │ │ -
    701
    │ │ │ │ -
    712 template<class Dummy=R,
    │ │ │ │ -
    713 class = std::void_t<decltype(std::declval<Dummy>().size())>>
    │ │ │ │ -
    │ │ │ │ -
    714 auto size() const
    │ │ │ │ -
    715 {
    │ │ │ │ -
    716 return rawRange_.size();
    │ │ │ │ -
    717 }
    │ │ │ │ -
    │ │ │ │ -
    718
    │ │ │ │ -
    │ │ │ │ -
    722 const RawRange& rawRange() const
    │ │ │ │ -
    723 {
    │ │ │ │ -
    724 return rawRange_;
    │ │ │ │ -
    725 }
    │ │ │ │ -
    │ │ │ │ -
    726
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    731 {
    │ │ │ │ -
    732 return rawRange_;
    │ │ │ │ -
    733 }
    │ │ │ │ -
    │ │ │ │ -
    734
    │ │ │ │ -
    735 private:
    │ │ │ │ -
    736 R rawRange_;
    │ │ │ │ -
    737 F f_;
    │ │ │ │ -
    738 };
    │ │ │ │ -
    │ │ │ │ -
    739
    │ │ │ │ -
    768 template <class R, class F>
    │ │ │ │ -
    │ │ │ │ -
    769 auto transformedRangeView(R&& range, const F& f)
    │ │ │ │ -
    770 {
    │ │ │ │ - │ │ │ │ -
    772 }
    │ │ │ │ -
    │ │ │ │ -
    773
    │ │ │ │ -
    801 template <class R, class F>
    │ │ │ │ -
    │ │ │ │ - │ │ │ │ -
    803 {
    │ │ │ │ - │ │ │ │ -
    805 }
    │ │ │ │ -
    │ │ │ │ -
    806
    │ │ │ │ -
    807
    │ │ │ │ -
    820 template<class Range>
    │ │ │ │ -
    │ │ │ │ -
    821 auto sparseRange(Range&& range) {
    │ │ │ │ -
    822 return Dune::iteratorTransformedRangeView(std::forward<Range>(range), [](auto&& it) {
    │ │ │ │ -
    823 return std::tuple<decltype(*it), decltype(it.index())>(*it, it.index());
    │ │ │ │ -
    824 });
    │ │ │ │ -
    825 }
    │ │ │ │ -
    │ │ │ │ -
    826
    │ │ │ │ -
    831}
    │ │ │ │ -
    832
    │ │ │ │ -
    833#endif // DUNE_COMMON_RANGE_UTILITIES_HH
    │ │ │ │ -
    Traits for type conversions and type information.
    │ │ │ │ -
    auto sparseRange(Range &&range)
    Allow structured-binding for-loops for sparse iterators.
    Definition rangeutilities.hh:821
    │ │ │ │ -
    auto iteratorTransformedRangeView(R &&range, const F &f)
    Create a TransformedRangeView using an iterator transformation.
    Definition rangeutilities.hh:802
    │ │ │ │ -
    auto transformedRangeView(R &&range, const F &f)
    Create a TransformedRangeView.
    Definition rangeutilities.hh:769
    │ │ │ │ -
    static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from >, std::integral_constant< T, to >) noexcept
    Definition rangeutilities.hh:300
    │ │ │ │ -
    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:637
    │ │ │ │ -
    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:683
    │ │ │ │ -
    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:660
    │ │ │ │ -
    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:237
    │ │ │ │ -
    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:705
    │ │ │ │ -
    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:259
    │ │ │ │ +
    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:268
    │ │ │ │
    STL namespace.
    │ │ │ │
    Dune namespace.
    Definition alignedallocator.hh:13
    │ │ │ │ -
    bool any_true(const AlignedNumber< bool, align > &val)
    Definition debugalign.hh:493
    │ │ │ │ -
    bool all_true(const AlignedNumber< bool, align > &val)
    Definition debugalign.hh:499
    │ │ │ │ -
    T max_value(const AlignedNumber< T, align > &val)
    Definition debugalign.hh:481
    │ │ │ │ -
    T min_value(const AlignedNumber< T, align > &val)
    Definition debugalign.hh:487
    │ │ │ │ -
    dynamic integer range for use in range-based for loops
    Definition rangeutilities.hh:175
    │ │ │ │ -
    constexpr iterator begin() const noexcept
    obtain a random-access iterator to the first element
    Definition rangeutilities.hh:192
    │ │ │ │ -
    constexpr iterator end() const noexcept
    obtain a random-access iterator past the last element
    Definition rangeutilities.hh:194
    │ │ │ │ -
    std::make_unsigned_t< T > size_type
    unsigned integer type corresponding to value_type
    Definition rangeutilities.hh:182
    │ │ │ │ -
    Impl::IntegralRangeIterator< T > iterator
    type of iterator
    Definition rangeutilities.hh:180
    │ │ │ │ -
    constexpr value_type operator[](const value_type &i) const noexcept
    access specified element
    Definition rangeutilities.hh:197
    │ │ │ │ -
    constexpr bool empty() const noexcept
    check whether the range is empty
    Definition rangeutilities.hh:200
    │ │ │ │ -
    constexpr IntegralRange(std::pair< value_type, value_type > range) noexcept
    construct integer range std::pair
    Definition rangeutilities.hh:189
    │ │ │ │ -
    constexpr IntegralRange(value_type from, value_type to) noexcept
    construct integer range [from, to)
    Definition rangeutilities.hh:185
    │ │ │ │ -
    constexpr size_type size() const noexcept
    obtain number of elements in the range
    Definition rangeutilities.hh:202
    │ │ │ │ -
    constexpr IntegralRange(value_type to) noexcept
    construct integer range [0, to)
    Definition rangeutilities.hh:187
    │ │ │ │ -
    T value_type
    type of integers contained in the range
    Definition rangeutilities.hh:178
    │ │ │ │ -
    static integer range for use in range-based for loops
    Definition rangeutilities.hh:225
    │ │ │ │ -
    static constexpr iterator end() noexcept
    obtain a random-access iterator past the last element
    Definition rangeutilities.hh:251
    │ │ │ │ -
    decltype(shift_integer_sequence< from >(std::make_integer_sequence< T, to-from >())) integer_sequence
    type of corresponding std::integer_sequence
    Definition rangeutilities.hh:238
    │ │ │ │ -
    constexpr StaticIntegralRange() noexcept=default
    default constructor
    │ │ │ │ -
    std::make_unsigned_t< T > size_type
    unsigned integer type corresponding to value_type
    Definition rangeutilities.hh:235
    │ │ │ │ -
    T value_type
    type of integers contained in the range
    Definition rangeutilities.hh:231
    │ │ │ │ -
    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:255
    │ │ │ │ -
    static constexpr std::integral_constant< bool, from==to > empty() noexcept
    check whether the range is empty
    Definition rangeutilities.hh:265
    │ │ │ │ -
    static constexpr iterator begin() noexcept
    obtain a random-access iterator to the first element
    Definition rangeutilities.hh:249
    │ │ │ │ -
    constexpr value_type operator[](const size_type &i) const noexcept
    access specified element (dynamic version)
    Definition rangeutilities.hh:262
    │ │ │ │ -
    Impl::IntegralRangeIterator< T > iterator
    type of iterator
    Definition rangeutilities.hh:233
    │ │ │ │ -
    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:267
    │ │ │ │ -
    Tag to enable value based transformations in TransformedRangeView.
    Definition rangeutilities.hh:316
    │ │ │ │ -
    Tag to enable iterator based transformations in TransformedRangeView.
    Definition rangeutilities.hh:321
    │ │ │ │ -
    A range transforming the values of another range on-the-fly.
    Definition rangeutilities.hh:628
    │ │ │ │ -
    auto size() const
    Obtain the size of the range.
    Definition rangeutilities.hh:714
    │ │ │ │ -
    constexpr iterator end() noexcept
    Definition rangeutilities.hh:698
    │ │ │ │ -
    std::remove_reference_t< R > RawRange
    Export type of the wrapped untransformed range.
    Definition rangeutilities.hh:656
    │ │ │ │ -
    Impl::TransformedRangeIterator< RawConstIterator, F, T > const_iterator
    Const iterator type.
    Definition rangeutilities.hh:640
    │ │ │ │ -
    constexpr iterator begin() noexcept
    Definition rangeutilities.hh:682
    │ │ │ │ -
    constexpr TransformedRangeView(RR &&rawRange, const F &f) noexcept
    Construct from range and function.
    Definition rangeutilities.hh:662
    │ │ │ │ -
    const RawRange & rawRange() const
    Export the wrapped untransformed range.
    Definition rangeutilities.hh:722
    │ │ │ │ -
    Impl::TransformedRangeIterator< RawIterator, F, T > iterator
    Iterator type.
    Definition rangeutilities.hh:648
    │ │ │ │ -
    constexpr const_iterator begin() const noexcept
    Obtain a iterator to the first element.
    Definition rangeutilities.hh:678
    │ │ │ │ -
    constexpr const_iterator end() const noexcept
    Obtain a iterator past the last element.
    Definition rangeutilities.hh:694
    │ │ │ │ -
    RawRange & rawRange()
    Export the wrapped untransformed range.
    Definition rangeutilities.hh:730
    │ │ │ │ +
    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
    │ │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -7,883 +7,517 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -rangeutilities.hh │ │ │ │ │ +tupleutility.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 (C) 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 │ │ │ │ │ + 5 │ │ │ │ │ + 6#ifndef DUNE_TUPLE_UTILITY_HH │ │ │ │ │ + 7#define DUNE_TUPLE_UTILITY_HH │ │ │ │ │ + 8 │ │ │ │ │ + 9#include │ │ │ │ │ + 10#include │ │ │ │ │ 11#include │ │ │ │ │ - 12#include │ │ │ │ │ + 12#include │ │ │ │ │ 13 │ │ │ │ │ - 21namespace Dune │ │ │ │ │ - 22{ │ │ │ │ │ - 23 │ │ │ │ │ - 34 template ::value, int>::type = 0> │ │ │ │ │ - 36 typename T::value_type │ │ │ │ │ -37 max_value(const T & v) { │ │ │ │ │ - 38 using std::max_element; │ │ │ │ │ - 39 return *max_element(v.begin(), v.end()); │ │ │ │ │ - 40 } │ │ │ │ │ - 41 │ │ │ │ │ - 42 template ::value, int>::type = 0> │ │ │ │ │ -44 const T & max_value(const T & v) { return v; } │ │ │ │ │ - 45 │ │ │ │ │ - 51 template ::value, int>::type = 0> │ │ │ │ │ - 53 typename T::value_type │ │ │ │ │ -54 min_value(const T & v) { │ │ │ │ │ - 55 using std::min_element; │ │ │ │ │ - 56 return *min_element(v.begin(), v.end()); │ │ │ │ │ - 57 } │ │ │ │ │ - 58 │ │ │ │ │ - 59 template ::value, int>::type = 0> │ │ │ │ │ -61 const T & min_value(const T & v) { return v; } │ │ │ │ │ + 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 }; │ │ │ │ │ 62 │ │ │ │ │ - 68 template ::value, int>::type = 0> │ │ │ │ │ -70 bool any_true(const T & v) { │ │ │ │ │ - 71 bool b = false; │ │ │ │ │ - 72 for (const auto & e : v) │ │ │ │ │ - 73 b = b or bool(e); │ │ │ │ │ - 74 return b; │ │ │ │ │ - 75 } │ │ │ │ │ - 76 │ │ │ │ │ - 77 template ::value, int>::type = 0> │ │ │ │ │ - 79 bool any_true(const T & v) { return v; } │ │ │ │ │ + 63 template │ │ │ │ │ +64 struct TupleAccessTraits │ │ │ │ │ + 65 { │ │ │ │ │ +66 typedef T& ConstType; │ │ │ │ │ +67 typedef T& NonConstType; │ │ │ │ │ +68 typedef T& ParameterType; │ │ │ │ │ + 69 }; │ │ │ │ │ + 70 │ │ │ │ │ + 78 template │ │ │ │ │ +79 struct NullPointerInitialiser; │ │ │ │ │ 80 │ │ │ │ │ - 81 template │ │ │ │ │ -82 bool any_true(const std::bitset & b) │ │ │ │ │ + 81 template │ │ │ │ │ +82 struct NullPointerInitialiser > │ │ │ │ │ 83 { │ │ │ │ │ - 84 return b.any(); │ │ │ │ │ - 85 } │ │ │ │ │ - 86 │ │ │ │ │ - 92 template ::value, int>::type = 0> │ │ │ │ │ -94 bool all_true(const T & v) { │ │ │ │ │ - 95 bool b = true; │ │ │ │ │ - 96 for (const auto & e : v) │ │ │ │ │ - 97 b = b and bool(e); │ │ │ │ │ - 98 return b; │ │ │ │ │ - 99 } │ │ │ │ │ - 100 │ │ │ │ │ - 101 template ::value, int>::type = 0> │ │ │ │ │ - 103 bool all_true(const T & v) { return v; } │ │ │ │ │ - 104 │ │ │ │ │ - 105 template │ │ │ │ │ -106 bool all_true(const std::bitset & b) │ │ │ │ │ - 107 { │ │ │ │ │ - 108 return b.all(); │ │ │ │ │ - 109 } │ │ │ │ │ - 110 │ │ │ │ │ - 111 │ │ │ │ │ - 112 │ │ │ │ │ - 113 namespace Impl │ │ │ │ │ - 114 { │ │ │ │ │ - 115 │ │ │ │ │ - 116 template │ │ │ │ │ - 117 class IntegralRangeIterator │ │ │ │ │ - 118 { │ │ │ │ │ - 119 public: │ │ │ │ │ - 120 typedef std::random_access_iterator_tag iterator_category; │ │ │ │ │ - 121 typedef T value_type; │ │ │ │ │ - 122 typedef std::make_signed_t difference_type; │ │ │ │ │ - 123 typedef const T *pointer; │ │ │ │ │ - 124 typedef T reference; │ │ │ │ │ - 125 │ │ │ │ │ - 126 constexpr IntegralRangeIterator() noexcept : value_(0) {} │ │ │ │ │ - 127 constexpr explicit IntegralRangeIterator(value_type value) noexcept : │ │ │ │ │ -value_(value) {} │ │ │ │ │ - 128 │ │ │ │ │ - 129 pointer operator->() const noexcept { return &value_; } │ │ │ │ │ - 130 constexpr reference operator*() const noexcept { return value_; } │ │ │ │ │ +84 typedef std::tuple ResultType; │ │ │ │ │ +85 static ResultType apply() │ │ │ │ │ + 86 { │ │ │ │ │ + 87 return ResultType(static_cast(nullptr)...); │ │ │ │ │ + 88 } │ │ │ │ │ + 89 }; │ │ │ │ │ + 90 │ │ │ │ │ + 115 template