Explorar o código

* added sumInt

git-svn-id: trunk@2380 -
peter %!s(int64=19) %!d(string=hai) anos
pai
achega
e58e92c4fa
Modificáronse 1 ficheiros con 19 adicións e 0 borrados
  1. 19 0
      rtl/objpas/math.pp

+ 19 - 0
rtl/objpas/math.pp

@@ -304,6 +304,8 @@ function mean(const data : array of float) : float;
 function sum(const data : array of float) : float;
 function mean(const data : PFloat; Const N : longint) : float;
 function sum(const data : PFloat; Const N : Longint) : float;
+function sumInt(const data : PInt64;Const N : longint) : Int64;
+function sumInt(const data : array of Int64) : Int64;
 function sumofsquares(const data : array of float) : float;
 function sumofsquares(const data : PFloat; Const N : Integer) : float;
 { calculates the sum and the sum of squares of data }
@@ -752,6 +754,23 @@ function sum(const data : PFloat;Const N : longint) : float;
        sum:=sum+data[i];
   end;
 
+function sumInt(const data : PInt64;Const N : longint) : Int64;
+
+  var
+     i : longint;
+
+  begin
+     sumInt:=0;
+     for i:=0 to N-1 do
+       sumInt:=sumInt+data[i];
+  end;
+
+function sumInt(const data : array of Int64) : Int64;
+
+  begin
+     Result:=SumInt(@Data[0],High(Data)+1);
+  end;
+
  function sumofsquares(const data : array of float) : float;
 
  begin