![]() ![]() | ![]() |
File: [local] / OpenXM_contrib / PHC / Ada / Math_Lib / Numbers / multprec_random_numbers.adb (download)
Revision 1.1.1.1 (vendor branch), Sun Oct 29 17:45:26 2000 UTC (23 years, 10 months ago) by maekawa
Import the second public release of PHCpack. OKed by Jan Verschelde. |
with Standard_Floating_Numbers; use Standard_Floating_Numbers; with Standard_Random_Numbers; package body Multprec_Random_Numbers is function Random ( size : natural ) return Natural_Number is res : Natural_Number; arn : Array_of_Naturals(0..size); begin for i in arn'range loop arn(i) := Standard_Random_Numbers.Random(0,Base-1); end loop; res := Create(arn); return res; end Random; function Random ( size : natural ) return Integer_Number is res : Integer_Number; sig : double_float := Standard_Random_Numbers.Random; rnd : Natural_Number := Random(size); begin res := Create(rnd); if sig < 0.0 then Min(res); end if; Clear(rnd); return res; end Random; function Random ( size : natural ) return Floating_Number is res : Floating_Number; naturfrac : Natural_Number := Random(size); frac,expo : Integer_Number; begin frac := Create(naturfrac); Clear(naturfrac); expo := Create(-Decimal_Places(frac)); res := Create(frac,expo); Clear(frac); Clear(expo); return res; end Random; function Random ( size : natural ) return Complex_Number is res : Complex_Number; re : Floating_Number := Random(size); im : Floating_Number := Random(size); begin res := Create(re,im); Clear(re); Clear(im); return res; end Random; end Multprec_Random_Numbers;