File : fz_sqr.ads


   1 ------------------------------------------------------------------------------
   2 ------------------------------------------------------------------------------
   3 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'.               --
   4 --                                                                          --
   5 -- (C) 2019 Stanislav Datskovskiy ( www.loper-os.org )                      --
   6 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html     --
   7 --                                                                          --
   8 -- You do not have, nor can you ever acquire the right to use, copy or      --
   9 -- distribute this software ; Should you use this software for any purpose, --
  10 -- or copy and distribute it to anyone or in any manner, you are breaking   --
  11 -- the laws of whatever soi-disant jurisdiction, and you promise to         --
  12 -- continue doing so for the indefinite future. In any case, please         --
  13 -- always : read and understand any software ; verify any PGP signatures    --
  14 -- that you use - for any purpose.                                          --
  15 --                                                                          --
  16 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm .     --
  17 ------------------------------------------------------------------------------
  18 ------------------------------------------------------------------------------
  19 
  20 with FZ_Type; use FZ_Type;
  21 
  22 
  23 package FZ_Sqr is
  24    
  25    pragma Pure;
  26    
  27    -- Karatsuba Threshhold - at or below this many Words, we use Comba mult.
  28    Sqr_Karatsuba_Thresh : constant Indices := 8;
  29    
  30    -- Square. (CAUTION: UNBUFFERED)
  31    procedure FZ_Square_Unbuffered(X     : in  FZ;
  32                                   XX    : out FZ);
  33    pragma Inline_Always(FZ_Square_Unbuffered);
  34    
  35    -- Comba's squaring. (CAUTION: UNBUFFERED)
  36    procedure FZ_Sqr_Comba(X     : in  FZ;
  37                           XX    : out FZ);
  38    pragma Inline_Always(FZ_Sqr_Comba);
  39    
  40    -- Karatsuba's Squaring. (CAUTION: UNBUFFERED)
  41    procedure Sqr_Karatsuba(X  : in  FZ;
  42                            XX : out FZ)
  43      with Pre => XX'Length = 2 * X'Length and
  44      X'Length mod 2 = 0;
  45    -- CAUTION: Inlining prohibited for Sqr_Karatsuba !
  46    
  47    -- Squaring. Preserves the inputs.
  48    procedure FZ_Square_Buffered(X     : in  FZ;
  49                                 XX_Lo : out FZ;
  50                                 XX_Hi : out FZ);
  51    pragma Inline_Always(FZ_Square_Buffered);
  52    
  53 end FZ_Sqr;