{"id":21275355,"url":"https://github.com/tuwien-cms/libxprec","last_synced_at":"2025-07-11T07:30:54.054Z","repository":{"id":209435366,"uuid":"713969577","full_name":"tuwien-cms/libxprec","owner":"tuwien-cms","description":"C++11 library for double-double (emulated quad precision) arithmetic","archived":false,"fork":false,"pushed_at":"2024-09-12T09:40:53.000Z","size":197,"stargazers_count":7,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"mainline","last_synced_at":"2024-09-12T20:51:48.269Z","etag":null,"topics":["extended-precision","numerics","quad-precision"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tuwien-cms.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-03T16:13:31.000Z","updated_at":"2024-09-12T09:40:56.000Z","dependencies_parsed_at":"2023-11-27T11:25:39.980Z","dependency_job_id":"9b60f722-713a-4427-800b-1e69620ef482","html_url":"https://github.com/tuwien-cms/libxprec","commit_stats":null,"previous_names":["tuwien-cms/libxprec"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuwien-cms%2Flibxprec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuwien-cms%2Flibxprec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuwien-cms%2Flibxprec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuwien-cms%2Flibxprec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tuwien-cms","download_url":"https://codeload.github.com/tuwien-cms/libxprec/tar.gz/refs/heads/mainline","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225704674,"owners_count":17511140,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["extended-precision","numerics","quad-precision"],"created_at":"2024-11-21T09:30:00.986Z","updated_at":"2025-07-11T07:30:54.048Z","avatar_url":"https://github.com/tuwien-cms.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"Small double-double library\n===========================\n\nEmulates quadruple precision with a pair of doubles.  This roughly doubles\nthe mantissa bits (and thus squares the precision of double).  The range\nis almost the same as double, with a larger area of denormalized numbers.\n\nThe rough cost in floating point operations (flops) and relative error as\nmultiples of u² = 1.32e-32 (round-off error or half the machine epsilon) is\nas follows:\n\n    double d;\n    xprec::ExDouble xd;        // double \"cast\" to quad precsion\n    xprec::DDouble dd;         // emulated quad precision number\n\n  | (op)       | xd (op) d | error | dd (op) d | error | dd (op) dd | error |\n  |------------|----------:|------:|----------:|------:|-----------:|------:|\n  | add_small  |   3 flops |   0u² |   7 flops |   2u² |   17 flops |   3u² |\n  | + -        |   6 flops |   0u² |  10 flops |   2u² |   20 flops |   3u² |\n  | *          |   2 flops |   0u² |   6 flops |   2u² |    9 flops |   4u² |\n  | /          |  3* flops |   1u² |  7* flops |   3u² |  28* flops |   6u² |\n  | reciprocal |  3* flops |   1u² |           |       |  19* flops | 2.3u² |\n\nThe error bounds are mostly tight analytical bounds (except for divisions).[^1]\nAn asterisk indicates the need for one or two double divisions, which are about\nan order of magnitude more expensive than regular flops on a modern CPU.\n\nThe table can be distilled into two rules of thumb: double-double arithmetic\nroughly doubles the number of significant digits at the cost of a roughly\n15x slowdown compared to double arithmetic.\n\n[^1]: M. Joldes, et al., ACM Trans. Math. Softw. 44, 1-27 (2018) and\n      J.-M. Muller and L. Rideau, ACM Trans. Math. Softw. 48, 1, 9 (2022).\n      The flop count has been reduced by 3 for divisons/reciprocals.\n      In the case of double-double division, the bound is 10u² but largest\n      observed error is 6u². In double by double division, we expect u². We\n      report the largest observed error.\n\nUsage\n-----\nSimple example:\n\n    #include \u003ciostream\u003e\n    #include \u003cxprec/ddouble.hpp\u003e\n\n    int main()\n    {\n      xprec::DDouble x = 1.0;                // emulated quad precision\n      x = (4 - x) / (x + 6);                 // arithmetic operators work\n      std::cout \u003c\u003c x \u003c\u003c std::endl;           // output to full precision\n      std::cout \u003c\u003c x.hi() \u003c\u003c std::endl;      // output truncated to double\n      std::cout \u003c\u003c exp(x) \u003c\u003c std::endl;      // higher-precision exp\n    }\n\nInstallation\n------------\nlibxprec has no mandatory dependencies other than a C++11-compliant compiler.\n\n    mkdir build\n    cd build\n    cmake .. [EXTRA_CMAKE_FLAGS_GO_HERE]\n    make\n    ./test/tests      # requires -DBUILD_TESTING=ON\n    make install      # set -DCMAKE_INSTALL_PREFIX to customize install dir\n\nUseful CMake flags:\n\n - `-DBUILD_TESTING=ON`: builds unit tests. You need to have the [GNU MPFR]\n   library installed for this to work.\n\n - `-DCMAKE_CXX_FLAGS=-mfma`: the double-double arithmetic in libxprec is much\n   faster when using the fused-multiply add (FMA) instruction, which should\n   be available on most modern CPUs. We recommend adding this flag unless you\n   require portable binaries.\n\n - `-DCMAKE_INSTALL_PREFIX=/path/to/usr`: sets the base directory below which\n   to install include files and the shared object.\n\n#### Header-only mode ####\nlibxprec can also be used in header-only mode, which does not require\ninstallation. For this, simply drop the full libxprec directory into your project\nand use the following header:\n\n    #include \"libxprec/include/xprec/ddouble-header-only.hpp\"\n\nPlease note that this will likely lead to considerably longer compile times.\n\n[GNU MPFR]: https://www.mpfr.org/\n\n#### Import in other CMake project ####\nIn order to use the library in CMake projects, we recommend using [FetchContent]:\n\n    include(FetchContent)\n    FetchContent_Declare(XPrec\n        GIT_REPOSITORY https://github.com/tuwien-cms/libxprec\n        GIT_TAG v0.7.0\n        FIND_PACKAGE_ARGS 0.7.0\n        )\n    FetchContent_MakeAvailable(XPrec)\n\nYou then should be able to simply link against the `XPrec::xprec` target.\n\n[FetchContent]: https://cmake.org/cmake/help/latest/module/FetchContent.html\n\nLicense and Copying\n-------------------\nCopyright (C) 2023 Markus Wallerberger and others.\n\nReleased under the MIT license (see LICENSE for details).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuwien-cms%2Flibxprec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftuwien-cms%2Flibxprec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuwien-cms%2Flibxprec/lists"}