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