ANN: Simple Components v4.70

The current version provides implementations of smart pointers, directed graphs, sets, maps, B-trees, stacks, tables, string editing, unbounded arrays, expression analyzers, lock-free data structures, synchronization primitives (events, race condition free pulse events, arrays of events, reentrant mutexes, deadlock-free arrays of mutexes), arbitrary precision arithmetic, pseudo-random non-repeating numbers, symmetric encoding and decoding, IEEE 754 representations support, streams, persistent storage, multiple connections server/client designing tools and protocols implementations.

Changes to the previous version:

  • The package Unbounded_Unsigneds implementing arbitrary precision unsigned arithmetic was added;
  • The package Unbounded_Integers implementing arbitrary precision integer arithmetic was added;
  • The package Unbounded_Unsigneds Primes implementing operations with prime numbers was added;
  • The package Unbounded_Unsigneds.Montgomery implementing Montgomery domain operations was added;
  • The package Unbounded_Unsigneds.Barrett implementing Barrett reduction was added;
  • The package Strings_Edit.Unbounded_Unsigned_Edit string editing for arbitrary precision unsigned numbers was added;
  • The package Strings_Edit.Unbounded_Integer_Edit string editing for arbitrary precision integer numbers was added;
  • The package Unbounded_Unsigneds.Parallel implementing parallel arbitrary precision algorithms was added;
  • The package Job_Servers was added implementing servers of jobs backed by a task pool;
  • The number protocol added to Python bindings;
  • Reply_Text and Reply_HTML in GNAT.Sockets.Connection_State_Machine.HTTP_Server modified to call Send_Body passing the Get parameter rather than skipping it when Get = False;
  • UUID v6 and v7 generation was added to Universally_Unique_Identifiers.

The key points of the arbitrary precision arithmetic packages design and functionality:

  • Advanced memory management preventing excessive copying;
  • The number internal representation vector is shared between objects if possible;
  • No limit on the number size, except for the storage pool size;
  • In-place versions of operations (e.g. for addition, subtraction) further reduce need of copying;
  • Lazy memory deallocation strategy, the memory is kept between variable updates;
  • Swapping variables;
  • Long to short operations;
  • Squaring;
  • Square root, square root with remainder;
  • Multiplicative inverse;
  • 2’s complement;
  • Bit representation access, slicing, truncation;
  • Full division with remainder, remainder only division;
  • Karatsuba multiplication and squaring;
  • Specialized operations involving powers of two and words;
  • Exponentiation under modulo;
  • Fibonacci number under modulo;
  • Montgomery domain multiplication, squaring, exponentiation under modulo and primality tests of the domain modulus;
  • Barrett reduction, multiplication, exponentiation;
  • Primality tests: Miller-Rabin, Fibonacci, Lucas-Lehmer, strong Lucas;
  • Parallel algorithms for very large numbers;
  • String editing and formatting packages for the numbers.

Performance notes. In order to get optimal performance -O2 switch need to be used. It does 3x performance boost. 64-bit (with 128-bit integer) outperform 32-bit by many multiplies. See GPR variables: Simple components for Ada E.g.

gprbuild -P components-tests.gpr -XTarget_OS=Linux -Xarch=aarch64 -XDevelopment=Release

9 Likes