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

File: [local] / OpenXM_contrib / PHC / Ada / Math_Lib / Matrices / generic_norms_equals.adb (download)

Revision 1.1.1.1 (vendor branch), Sun Oct 29 17:45:23 2000 UTC (23 years, 8 months ago) by maekawa
Branch: PHC, MAIN
CVS Tags: v2, maekawa-ipv6, RELEASE_1_2_3, RELEASE_1_2_2_KNOPPIX_b, RELEASE_1_2_2_KNOPPIX, RELEASE_1_2_2, RELEASE_1_2_1, HEAD
Changes since 1.1: +0 -0 lines

Import the second public release of PHCpack.

OKed by Jan Verschelde.

package body Generic_Norms_Equals is

  function Max_Norm ( v : Vector ) return number is

    res : number := AbsVal(v(v'first));

  begin
    for i in v'first+1..v'last loop
      declare
        abstmp : number := AbsVal(v(i));
      begin
        if abstmp > res
         then Copy(abstmp,res);
        end if;
        Clear(abstmp);
      end;
    end loop;
    return res;
  end Max_Norm;

  function Sum_Norm ( v : Vector ) return number is

    res : number := AbsVal(v(v'first));

  begin
    for i in v'first+1..v'last loop
      declare
        abstmp : number := AbsVal(v(i));
      begin
        Add(res,abstmp);
        Clear(abstmp);
      end;
    end loop;
    return res;
  end Sum_Norm;

  function Max_Norm ( m : Matrix ) return number is

    res : number;
 
  begin
    Copy(zero,res);
    for i in m'range(1) loop
      for j in m'range(2) loop
        declare
          abstmp : number := AbsVal(m(i,j));
        begin
          if abstmp > res
           then Copy(abstmp,res);
          end if;
          Clear(abstmp);
        end;
      end loop;
    end loop;
    return res;
  end Max_Norm;

  function Equal ( x,y,tol : number ) return boolean is

    dif : number := x-y;
    absdif : number := AbsVal(dif);
    res : boolean := (absdif < tol);

  begin
    Clear(dif);
    Clear(absdif);
    return res;
  end Equal;

  function Equal ( x,y : Vector; tol : number ) return boolean is
  begin
    for i in x'range loop
      if not Equal(x(i),y(i),tol)
       then return false;
      end if;
    end loop;
    return true;
  end Equal;

end Generic_Norms_Equals;