GithubHelp home page GithubHelp logo

ckormanyos / wide-decimal Goto Github PK

View Code? Open in Web Editor NEW
50.0 7.0 8.0 1.78 MB

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

C++ 98.61% C 0.63% CMake 0.27% Python 0.49%
high-performance embedded-systems multiprecision multiple-precision bigfloat bigdecimal arbitrary-precision

wide-decimal's People

Contributors

ckormanyos avatar saxbophone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

wide-decimal's Issues

Extend limb type down to uint8

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.

Implement rounding and improved comparison

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.

dynamic_array slight memory defects revealed with -fsanitize=address

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.

Polish up new examples 13 and 13a

  • Put the __AVR__ patch(es) in a separate file (optionally or if possible one day see why exactly -lstdc++ isn't working).
  • Document examples 13 and 13a in the markdown.

Add more CI runners embedded, old GCC, newer GCC/clang

Let's add some more CI runners performing a variety of extended compiler jobs.

Include jobs for:

  • Some embedded builds like avr-gcc and arm-none-eabi-gcc
  • Old GCC-5 compiler(s) with -std=c++11 and -std=c++14
  • New GCC/clang compilers such as GCC-11/clang-12.

Default (non-initialized) container values faulty

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

Use Retry Add Repo in CI

Sometimes the first Add Repo fails. Try using retry add repo (similar to Boost Multiprecision example) in this CI.

Remove constructor(s) from aggregate type(s)

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

Set up CI

Set up continuous integration. This is an excellent project for easy CI because the tests run entirely on the PC with VC/GCC/CLANG.

Make a small collection of constants

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.

Ensure the floating-point template parameter can use UDTs

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.

Optimize inner loop of limb multiplication

The inner loop of limb multiplicatoin can be optimized in 2 ways.

  • First be sure to write the div/mod operations in an optimal way.
  • Second the multiplication loop n-by-n-to-2n (for limb types) 16-bit and 32-bit can carry at end of column mul/add sub-loops. This is expected to be a significant improvement.

Slight threading defects revealed with -fsanitize=thread

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.

Toom-Cook multiplication

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.

Optional void type as allocator type

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.

Reinstate -Werror on most gcc/clang runners in CI

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.

Simplify CI via job matrices

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.

Optional faster exp function

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.

quintic pi million digit test breaks clang -Ofast3

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

Consider template param for FFT float type

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.

Rework internal exponent type and float type

The decwide_t class-internal parameters representing the base-10 exponent type and the floating point type can be reworked.

  • The base-10 decimal type can either be a template parameter or possibly simply reduced to 32-bit signed integer.
  • There are actually two floating-point types used internally. One is mainly for the type of float used in the FFTs while the other is used for various other internal calcultions. These should be separated into two differently-named parameters and used consistently yet separately from each other.

Reduce amount of Git cloning in CI

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.

Improve addition and subtraction implementations

The implementations of addition and subtraction can be improved in two areas.

  • An internal memory array is used for temporary results. This can probably be eliminated.
  • The entire array length of the wide decimal is used for add/sub regardless of the actual precision. Lmit this to the precision of the opertion.

Replace heavy string-streaming in rd_string() with C-Lib methods

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.

Improve FFT performance

The FFT implementation is very rudimentary. Use more refined FFT or DHT to improve performance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.