ckormanyos / wide-decimal Goto Github PK
View Code? Open in Web Editor NEWWide-Decimal implements a generic C++ template for large decimal float types from about 10 up to 10 million digits.
License: Boost Software License 1.0
Wide-Decimal implements a generic C++ template for large decimal float types from about 10 up to 10 million digits.
License: Boost Software License 1.0
Try to implement as much C++20 constexpr
-ness as possible.
Let's add some more CI runners performing a variety of extended compiler jobs.
Include jobs for:
avr-gcc
and arm-none-eabi-gcc
-std=c++11
and -std=c++14
Extend the limb type from (already implemented and tested) template instantiations of uint32_t
and uint16_t
down to also include limb type uint8_t
.
Preliminary checks show some small bugs regarding precision of square roots, etc. These need to be found and corrected.
Move example header to the examples folder
Even though elementary transcendental <cmath>
-like functions are not the primary focus of this work, there are some implementations of a few functions including, among others, log()
and exp()
.
The implementation of exp()
is very basic, relying solely on argument scaling in combination with Taylor series expansion. for high precision, consider Newton iteration. If this is done, variable precision would still be helpful and needed on the intermediate logarithmic steps.
Preliminary testing on ARM(R) CM4 core looks good. Test on further embedded targets.
The wide_integer project among other experience shows us that construction from aggregate types such as std::initializer_list
can lead to ambiguities with initialization with C++11 uniform initialization syntax.
In fact, the code below does not compile with decwide_t
at the time of writing this issue.
Remove constructor(s) from initializer list and replace these with static private convenience functions (or even find a better solution, if possible).
auto input{math::wide_decimal::decwide_t<wide_decimal_digits10>{1.23F}};
Does it make sense to make hard-coded primitives for small n-by-n-to-2n multiplications and use these as basecase for Karatsuba multiplication?
Support optional provision of the void
tape as the template allocator typ parameter. The default can remain set to std::allocator
, but optionall support for void
should default back to using a statically allocated container for the internal data representation.
Reduce amount of Git cloning in CI, which should be possible with the reduced dependencies of Math and (to a lesser extent) Multiprecision in develop branch.
Slight threading defects have been revealed in CI with -fsanitize=thread.
These seem to be associated with the need to synchronize Boost's eval_log()
that lies within Multiprecision. This might have been fixed in more modern versions of Boost. Or it might be a misunderstanding regarding the proper multithreaded usage of cpp_bin_float
.
Consider caching the values of the constants pi and ln2.
The template parameter InternalFloatType
defines the floating-point type used internally for elementary initializations and the like. Ensure that this parameter can use a user-defined type for systems not having, for instance, 64-bit double
.
The implementation of the custom-written container dynamic_array
seems like it probably has slight memory defects revealed by using GCC with -fsanitize=address
. These are only detected with many parallel threads in, for example, the algebra tests of this project.
The topic of this issue is to try to identify if there are, in fact, such weaknesses and subsequently correct them if there are.
Sometimes the first Add Repo fails. Try using retry add repo (similar to Boost Multiprecision example) in this CI.
Consider adding (yet another) template parameter for the FFT floating-point type.
The built-in type double
is not necessarily the only type that will be used for the FFT multiplication. Adding a suitable template parameter allows clients to specify the floating-point type used internally for FFT multiplication.
Reinstate -Werror
on most gcc/clang runners in CI, as this is expected to be stable (post-clang-tidy) and improve overall quality. It may also provide early-detection of some changes such as in Boost.
Add GCC MinGW builds and runs to CI.
There is an existing exp()
function. Based on this, it should be simple to add hyperbolic trigonometric functions sinh(x)
, cosh(x)
and tanh(x)
.
Boost bindings need proper implementatoin of certain boost::math::constants
such as pi, etc.
The CI jobs are programmed in a linear, redundant fashion. It should be possible to simplify the CI code via the use of job matrices.
The decwide_t
class-internal parameters representing the base-10 exponent type and the floating point type can be reworked.
The functionalities of isinf()
, isnan()
were never fully implemented. Remove these entirely and (also from numeric limits) and always assume isfinite()
.
We can eliminate cloning of Core. it's not much, but it's something.
Try for LGTM syntax check integration
Stack consumption is large for some test cases. We will use allocator(s) for Boost control types.
Implement rounding and improved comparison using individual base-10 digit(s) slightly beyond the digit of least significance instead of entire limbs and even if these least significant digits are within the middle of a given limb or separated between two limbs.
Incubate this technology here in wide-decimal. When this technology is stable, port it over to cpp_dec_float
in Boost.
The inner loop of limb multiplicatoin can be optimized in 2 ways.
Investigate/implement rounding to be used in this project and serve as a prototype for Boost's cpp_dec_float
.
Re-activate and handle the clang-tidy magic numbers rulse including:
-cppcoreguidelines-avoid-magic-numbers, \
-readability-magic-numbers
Heavy string-streaming is used in the rd_string()
method over std::stringstream
object(s). Experiments show that, when activated, these heavyweight string-streaming functions bring in several hundred kilobytes of compiler code.
These can be replaced with very simple C-Library functions such as strtoll()
and similar.
The million digit pi calculation with 8-bit limbs and InternalFloatType=float
fails.
The template parameter FftFloatType
was introduced a bit later and it was not yet incorporated as a template parameter in the Boost.Math bindings.
This issue includes the template parameter FftFloatType
in the Boost.Math bindings.
The FFT implementation is very rudimentary. Use more refined FFT or DHT to improve performance.
Using the few constants defined in decwide_t
such as one
, half
, pi
, etc. is tedious because numerous template parameters need to be listed. It would be convenient to make a very small selection of easy-to-use constants including this limited set of values.
The implementations of addition and subtraction can be improved in two areas.
__AVR__
patch(es) in a separate file (optionally or if possible one day see why exactly -lstdc++
isn't working).Use the clang-tidy environment that successfully tidies up the wide-integer project as shown here.
While going for this enhancement, also reduce (or try to reduce) the number of clang-tidy rule exceptions.
When the internal storage container type is merely allocator and non-initialized (which would ordinarily happen when an empty non-initialized decwide_t
is created), faulty calculation values arise.
There seems to be a constructor or some other king of memory (or perhaps something directly wrong with one or more examples) that leads to this behavior. Having now a stack allocator should make it a lot easier to track down this problem (which also arised for low digit counts).
Hi!
Do I can use wide-decimal type how a integer type? How?
Thanks in Advance!
Best wishes, Daniel.
Set up continuous integration. This is an excellent project for easy CI because the tests run entirely on the PC with VC/GCC/CLANG.
Just as in the wide-integer project, add an optional outer namespace to shield use of the global ::math
namespace.
Consider to implement Toom-Cook 3-way and Toom-Cook 4-way for speed-up of multiplication when the bit count is many thousands of bits.
The quintic million digit test breaks optimization setting -Ofast3 on clang. This might be a compiler issue, as all other compilers including clang itself at lower optimization levels pass the test.
We will, nonetheless, create this issue for artempting to work around the potential bug. The reason is because the code to test success of the million digit run is somewhat complex and could potentially be made more clear or be implemented with reduced complexity, which requires some thought
Add apple clang builds and runs in CI, where details (like brew install boost) can be found in wide-integer.
Implement Karatsuba multiplication for intermediate digit counts
Set up a syntax-checking process with clang-tidy
and handle messages/warnings therefrom.
See example of this in wide-integer's similar issue.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.