File : fz_mul.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_Mul is
24
25 pragma Pure;
26
27 -- Karatsuba Threshhold - at or below this many Words, we use Comba mult.
28 Karatsuba_Thresh : constant Indices := 8;
29
30 -- Multiply. (CAUTION: UNBUFFERED)
31 procedure FZ_Multiply_Unbuffered(X : in FZ;
32 Y : in FZ;
33 XY : out FZ);
34 pragma Inline_Always(FZ_Multiply_Unbuffered);
35
36 -- Comba's multiplier. (CAUTION: UNBUFFERED)
37 procedure FZ_Mul_Comba(X : in FZ;
38 Y : in FZ;
39 XY : out FZ);
40 pragma Inline_Always(FZ_Mul_Comba);
41
42 -- Karatsuba's Multiplier. (CAUTION: UNBUFFERED)
43 procedure Mul_Karatsuba(X : in FZ;
44 Y : in FZ;
45 XY : out FZ)
46 with Pre => X'Length = Y'Length and
47 XY'Length = (X'Length + Y'Length) and
48 X'Length mod 2 = 0;
49 -- CAUTION: Inlining prohibited for Mul_Karatsuba !
50
51 -- Multiplier. Preserves the inputs.
52 procedure FZ_Multiply_Buffered(X : in FZ;
53 Y : in FZ;
54 XY_Lo : out FZ;
55 XY_Hi : out FZ);
56 pragma Inline_Always(FZ_Multiply_Buffered);
57
58 end FZ_Mul;