[BACK]Return to standard_integer_norms.adb CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / PHC / Ada / Math_Lib / Matrices

Annotation of OpenXM_contrib/PHC/Ada/Math_Lib/Matrices/standard_integer_norms.adb, Revision 1.1

1.1     ! maekawa     1: with Standard_Common_Divisors;           use Standard_Common_Divisors;
        !             2:
        !             3: package body Standard_Integer_Norms is
        !             4:
        !             5:   function gcd ( v : Vector ) return integer is
        !             6:
        !             7:     tmp : Vector(v'range);
        !             8:     res : integer;
        !             9:
        !            10:   begin
        !            11:     for i in v'range loop
        !            12:       if v(i) < 0
        !            13:        then tmp(i) := -v(i);
        !            14:        else tmp(i) :=  v(i);
        !            15:       end if;
        !            16:     end loop;
        !            17:     res := tmp(tmp'first);
        !            18:     for i in (tmp'first+1)..tmp'last loop
        !            19:       res := gcd(res,tmp(i));
        !            20:       exit when (res = 1);
        !            21:     end loop;
        !            22:     return res;
        !            23:   end gcd;
        !            24:
        !            25:   procedure Normalize ( v : in out Vector ) is
        !            26:
        !            27:     g : constant integer := gcd(v);
        !            28:
        !            29:   begin
        !            30:     if (g /= 0) and then (g /= 1)
        !            31:      then for i in v'range loop
        !            32:             v(i) := v(i)/g;
        !            33:           end loop;
        !            34:     end if;
        !            35:   end Normalize;
        !            36:
        !            37: end Standard_Integer_Norms;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>