Is there a huge arithmetic tool kit for Ada to support matrix/vector operations

Is there a huge arithmetic tool kit for Ada with these characteristics for numeric variables and arrays of type HUGE where for example Pi and e are constants of 126 decimal places, and all trig functions and matrix/vector operations are supported.

“How it is done
The huge numbers are stored as strings. The first three bytes of the string contain the algebraic sign of the number and the number of decimal places. Each subsequent group of three bytes contains six digits of the number, with the least significant part coming first. The advantage is that a single huge number can be stored and manipulated as a single string rather than as a large numeric vector.”

From: Kurtz, T. 2001. Huge arithmetic toolkit. True BASIC Inc.

[Thomas E. Kurtz was co-inventor with John G. Kemeny of BASIC at Dartmouth in 1964.]

Just wondering, how is that an advantage? Decimal arithmetic must be extremely slow.

With encoding on top:

It must be slower than extremely slow.

1 Like

No, please check it out.

Ada has the standard library package Ada.Numerics.Big_Numbers.Big_Reals. You can compare performance yourself.

From Ada 2020 at AdaCore: Ada.Text_IO.Put_Line (Big_Integer’Image(2 ** 256));

115792089237316195423570985008687907853269984665640564039457584007913129639936

That’s 79-digits, not 126-decimal digits as described.

So what do I have to do, put image of 2 ** 419 to test it for 126 decimal places?

That begs the question to me of how it does that and how quickly in 80386 code as a baseline.

What follows for me is the result for Pi to 126 decimal places from the AdaCore 2020 pay-to-play compiler. Checking that result against some published tome seems a good starting place because C-renditions of floating point are known to vary in the past. I think AdaCore’s implementation of Ada 2020 is embellishing the gnat/gcc compiler with ornaments, if I am not mistaken.

This is the mathematically correct result.

Described where?

Put_Line (Big_Integer’Image (2**419));

I guess.

You can inspect the implementation in the package body. Long arithmetic algorithms can be found by Internet search.

Thank you for the link to the Ada 2022 standard annotated document bearing seven separate copyright notices at
http://www.ada-auth.org/standards/22aarm/AA-Final.pdf

The standard is non informative as to how compiler vendors implement big numbers but is informative to the extent handled exclusively as numeric vectors.
This means it’s only as good the C-compiler used which now engenders this question:

Are there other Ada 2022 compiler vendors, in the spirit of the question, other than AdaCore?

I couldn’t find any, implying AdaCore has a virtual monopoly, so is that in fact the case? (Yes / No)

There are no Ada 2022 compilers. Period.

No, there are several other compilers:

  1. Green Hills [Ada 95]
  2. DDC-I [Ada 95]
  3. RR Software [Ada 95 + all 2005/2012 recognized, some 2005 and 2012 implemented]
  4. PTC [Ada 2012]

There are, also, efforts to produce other open-source implementations such as:

  1. Byron — Self-hosted Ada2012. [Incomplete]
  2. HAC — Compiler and maybe(?) interpreter. [Incomplete]
  3. BAATS — Implementation of Ada2012 (possibly 2022) in Java, meant as for bootstrapping. [Incomplete]
2 Likes

According to AdaCore, the implementation of Ada 2022 is finalized in their GNAT Pro 22 release with GCC 10.

Given that they said in the ARG meeting in the beginning of the year that they weren’t going to develop/support the PARALLEL block/for, I don’t believe that means what you think it means.

I wonder if the Karatsuba multiplication algorithm could be used in a parallel construct. The algorithm does three independent multiplications recursively. So it is 3, 9, 18.and so on tasks.

C compiler?

“GNAT does not and never did translate Ada code to C code. It translates Ada in the same way that the C front end translates C.”

https://gcc.gnu.org/wiki/GNAT

This really makes following the thread much more difficult.

It means that when the thread goes off-topic with comments about disparate topics, such as at another topic with a reply link to a dated and unrelated topic, a volunteer succeeds to terminate the original thread within the rules of considerate discourse.