Return to standard_integer_norms.adb CVS log | Up to [local] / OpenXM_contrib / PHC / Ada / Math_Lib / Matrices |
File: [local] / OpenXM_contrib / PHC / Ada / Math_Lib / Matrices / standard_integer_norms.adb (download)
Revision 1.1.1.1 (vendor branch), Sun Oct 29 17:45:24 2000 UTC (23 years, 8 months ago) by maekawa
Import the second public release of PHCpack. OKed by Jan Verschelde. |
with Standard_Common_Divisors; use Standard_Common_Divisors; package body Standard_Integer_Norms is function gcd ( v : Vector ) return integer is tmp : Vector(v'range); res : integer; begin for i in v'range loop if v(i) < 0 then tmp(i) := -v(i); else tmp(i) := v(i); end if; end loop; res := tmp(tmp'first); for i in (tmp'first+1)..tmp'last loop res := gcd(res,tmp(i)); exit when (res = 1); end loop; return res; end gcd; procedure Normalize ( v : in out Vector ) is g : constant integer := gcd(v); begin if (g /= 0) and then (g /= 1) then for i in v'range loop v(i) := v(i)/g; end loop; end if; end Normalize; end Standard_Integer_Norms;