Skip to content

Commit

Permalink
Merge pull request #187 from BoostGSoC21/cpp_double_fp_backend
Browse files Browse the repository at this point in the history
Cpp double fp backend
  • Loading branch information
ckormanyos authored Jan 15, 2025
2 parents 7eef2c4 + 7742123 commit ae5167b
Show file tree
Hide file tree
Showing 20 changed files with 1,065 additions and 302 deletions.
44 changes: 24 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ Boost Multiprecision Library

| | Master | Develop |
|------------------|----------|-------------|
| Drone | [![Build Status](https://drone.cpp.al/api/badges/boostorg/multiprecision/status.svg?ref=refs/heads/master)](https://drone.cpp.al/boostorg/multiprecision) | [![Build Status](https://drone.cpp.al/api/badges/boostorg/multiprecision/status.svg)](https://drone.cpp.al/boostorg/multiprecision) |
| Github Actions | [![Build Status](https://github.com/boostorg/multiprecision/workflows/multiprecision/badge.svg?branch=master)](https://github.com/boostorg/multiprecision/actions) | [![Build Status](https://github.com/boostorg/multiprecision/workflows/multiprecision/badge.svg?branch=develop)](https://github.com/boostorg/multiprecision/actions) |
| Codecov | [![codecov](https://codecov.io/gh/boostorg/multiprecision/branch/master/graph/badge.svg)](https://codecov.io/gh/boostorg/multiprecision/branch/master) | [![codecov](https://codecov.io/gh/boostorg/multiprecision/branch/develop/graph/badge.svg)](https://codecov.io/gh/boostorg/multiprecision/branch/develop) |
| Drone | [![Build Status](https://drone.cpp.al/api/badges/boostorg/multiprecision/status.svg?ref=refs/heads/master)](https://drone.cpp.al/boostorg/multiprecision) | [![Build Status](https://drone.cpp.al/api/badges/boostorg/multiprecision/status.svg)](https://drone.cpp.al/boostorg/multiprecision) |
| Github Actions | [![Build Status](https://github.com/boostorg/multiprecision/actions/workflows/multiprecision.yml/badge.svg?branch=master)](https://github.com/boostorg/multiprecision/actions) | [![Build Status](https://github.com/boostorg/multiprecision/actions/workflows/multiprecision.yml/badge.svg?branch=develop)](https://github.com/boostorg/multiprecision/actions) |
| Codecov | [![codecov](https://codecov.io/gh/boostorg/multiprecision/branch/master/graph/badge.svg)](https://codecov.io/gh/boostorg/multiprecision/branch/master) | [![codecov](https://codecov.io/gh/boostorg/multiprecision/branch/develop/graph/badge.svg)](https://codecov.io/gh/boostorg/multiprecision/branch/develop) |


`Boost.Multiprecision` is a C++ library that provides integer, rational, floating-point, complex and interval number types
having more range and precision than the language's ordinary built-in types.
`Boost.Multiprecision` is a C++ library that provides integer, rational, floating-point,
complex and interval number types having more range and precision than the language's
ordinary built-in types.

Language adherence:
- `Boost.Multiprecision` requires a compliant C++14 compiler.
Expand All @@ -21,48 +22,50 @@ also interoperate with the built-in types in C++ using clearly defined conversio
used for all kinds of mathematical calculations involving integer, rational and floating-point types requiring extended range and precision.

Multiprecision consists of a generic interface to the mathematics of large numbers as well as a selection of big number back ends, with
support for integer, rational and floating-point types. `Boost.Multiprecision` provides a selection of back ends provided off-the-rack in
support for integer, rational and floating-point types. `Boost.Multiprecision` provides a selection of back ends provided off-the-rack
including interfaces to GMP, MPFR, MPIR, TomMath as well as its own collection of Boost-licensed, header-only back ends for integers,
rationals, floats and complex. In addition, user-defined back ends can be created and used with the interface of Multiprecision,
provided the class implementation adheres to the necessary concepts.

Depending upon the number type, precision may be arbitrarily large (limited only by available memory), fixed at compile time
(for example $50$ or $100$ decimal digits), or a variable controlled at run-time by member functions.
The types are expression-template-enabled by default. This usually provides better performance than naive user-defined types.
If not needed, expression templates can be disabled when configuring the `number` type with its backend.
If not needed, expression templates can be disabled when configuring the `number`-type with its backend.

The full documentation is available on [boost.org](http://www.boost.org/doc/libs/release/libs/multiprecision/index.html).

## Using Multiprecision ##
## Using Multiprecision

<p align="center">
<a href="https://godbolt.org/z/hj75jEqcz" alt="godbolt">
<a href="https://godbolt.org/z/aqGhaqdfK" alt="godbolt">
<img src="https://img.shields.io/badge/try%20it%20on-godbolt-green" /></a>
</p>

In the following example, we use Multiprecision's Boost-licensed binary
floating-point backend type `cpp_bin_float` to compute ${\sim}100$ decimal digits of

$$\sqrt{\pi} = \Gamma \left( \frac{1}{2} \right)~{\approx}~1.772453850905516027298{\ldots}\text{,}$$
$$
\sqrt{\pi} = \Gamma \left( \frac{1}{2} \right)~{\approx}~1.772453850905516027298{\ldots}\text{,}
$$

where we also observe that Multiprecision can seemlesly interoperate with
[Boost.Math](https://github.com/boostorg/math).

```cpp
#include <boost/multiprecision/cpp_bin_float.hpp>
#include <boost/math/special_functions/gamma.hpp>

#include <iomanip>
#include <iostream>
#include <sstream>

#include <boost/multiprecision/cpp_bin_float.hpp>
#include <boost/math/special_functions/gamma.hpp>

auto main() -> int
{
using big_float_type = boost::multiprecision::cpp_bin_float_100;

const big_float_type sqrt_pi { sqrt(boost::math::constants::pi<big_float_type>()) };

const big_float_type half { big_float_type(1) / 2 };
const big_float_type half { big_float_type { 1 } / 2 };

const big_float_type gamma_half { boost::math::tgamma(half) };

Expand All @@ -75,19 +78,19 @@ auto main() -> int
}
```

## Standalone ##
## Standalone

Defining `BOOST_MP_STANDALONE` allows `Boost.Multiprecision`
to be used with the only dependency being [Boost.Config](https://github.com/boostorg/config).

Our [package on this page](https://github.com/boostorg/multiprecision/releases)
already includes a copy of Boost.Config so no other downloads are required.
Some functionality is reduced in this mode.
A static_assert message will alert you if a particular feature has been disabled by standalone mode.
A `static_assert` message will alert you if a particular feature has been disabled by standalone mode.
[Boost.Math](https://github.com/boostorg/math) standalone mode is compatiable,
and recommended if special functions are required for the floating point types.
and recommended if special functions are required for the floating-point types.

## Support, bugs and feature requests ##
## Support, bugs and feature requests

Bugs and feature requests can be reported through the [Gitub issue tracker](https://github.com/boostorg/multiprecision/issues)
(see [open issues](https://github.com/boostorg/multiprecision/issues) and
Expand All @@ -100,7 +103,7 @@ although you can use the general-purpose Boost [mailing-list](http://lists.boost
using the tag [multiprecision].


## Development ##
## Development

Clone the whole boost project, which includes the individual Boost projects as submodules
([see boost+git doc](https://github.com/boostorg/boost/wiki/Getting-Started)):
Expand All @@ -113,7 +116,8 @@ Clone the whole boost project, which includes the individual Boost projects as s

The Boost Multiprecision Library is located in `libs/multiprecision/`.

### Running tests ###
### Running tests

First, build the `b2` engine by running `bootstrap.sh` in the root of the boost directory. This will generate `b2` configuration in `project-config.jam`.

```sh
Expand Down
8 changes: 4 additions & 4 deletions doc/multiprecision.qbk
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[/
Copyright 2011 - 2024 John Maddock.
Copyright 2011 - 2025 John Maddock.
Copyright 2013 - 2019 Paul A. Bristow.
Copyright 2013 - 2024 Christopher Kormanyos.
Copyright 2021 - 2024 Fahad Syed.
Copyright 2013 - 2025 Christopher Kormanyos.
Copyright 2021 - 2025 Fahad Syed.

Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
Expand All @@ -11,7 +11,7 @@

[library Boost.Multiprecision
[quickbook 1.7]
[copyright 2002-2020 John Maddock and Christopher Kormanyos]
[copyright 2002-2025 John Maddock and Christopher Kormanyos]
[purpose Multiprecision Number library]
[license
Distributed under the Boost Software License, Version 1.0.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright 2021 Fahad Syed.
// Copyright 2021 - 2024 Christopher Kormanyos.
// Copyright 2021 - 2025 Christopher Kormanyos.
// Copyright 2021 Janek Kozicki.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2023.
// Copyright Christopher Kormanyos 2023 - 2025.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2023 - 2024.
// Copyright Christopher Kormanyos 2023 - 2025.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2024.
// Copyright Christopher Kormanyos 2024 - 2025.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2024.
// Copyright Christopher Kormanyos 2024 - 2025.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2024.
// Copyright Christopher Kormanyos 2024 - 2025.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2023 - 2024.
// Copyright Christopher Kormanyos 2023 - 2025.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2023 - 2024.
// Copyright Christopher Kormanyos 2023 - 2025.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2023 - 2024.
// Copyright Christopher Kormanyos 2023 - 2025.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2023 - 2024.
// Copyright Christopher Kormanyos 2023 - 2025.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2023 - 2024.
// Copyright Christopher Kormanyos 2023 - 2025.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2024.
// Copyright Christopher Kormanyos 2024 - 2025.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2023 - 2024.
// Copyright Christopher Kormanyos 2023 - 2025.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
Expand Down
Loading

0 comments on commit ae5167b

Please sign in to comment.