------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. -- -- -- -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) -- -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html -- -- -- -- You do not have, nor can you ever acquire the right to use, copy or -- -- distribute this software ; Should you use this software for any purpose, -- -- or copy and distribute it to anyone or in any manner, you are breaking -- -- the laws of whatever soi-disant jurisdiction, and you promise to -- -- continue doing so for the indefinite future. In any case, please -- -- always : read and understand any software ; verify any PGP signatures -- -- that you use - for any purpose. -- -- -- -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ with W_Pred; use W_Pred; package body FZ_Pred is --------------------------------------------------------------------------- -- Fundamental Predicate Operations on FZ (finite integers) --------------------------------------------------------------------------- -- 1 iff N == 0 (branch-free); else 0 function FZ_ZeroP(N : in FZ) return WBool is A : WBool := 1; begin for i in N'Range loop A := A and W_ZeroP(N(i)); end loop; return A; end FZ_ZeroP; pragma Inline_Always(FZ_ZeroP); -- 1 iff N != 0 (branch-free); else 0 function FZ_NZeroP(N : in FZ) return WBool is begin return 1 xor FZ_ZeroP(N); end FZ_NZeroP; pragma Inline_Always(FZ_NZeroP); -- 1 iff N is odd function FZ_OddP(N : in FZ) return WBool is begin return W_OddP(N(N'First)); end FZ_OddP; pragma Inline_Always(FZ_OddP); end FZ_Pred;