瀏覽代碼

* added sumInt

git-svn-id: trunk@2380 -
peter 19 年之前
父節點
當前提交
e58e92c4fa
共有 1 個文件被更改,包括 19 次插入0 次删除
  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 sum(const data : array of float) : float;
 function mean(const data : PFloat; Const N : longint) : float;
 function mean(const data : PFloat; Const N : longint) : float;
 function sum(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 : array of float) : float;
 function sumofsquares(const data : PFloat; Const N : Integer) : float;
 function sumofsquares(const data : PFloat; Const N : Integer) : float;
 { calculates the sum and the sum of squares of data }
 { 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];
        sum:=sum+data[i];
   end;
   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;
  function sumofsquares(const data : array of float) : float;
 
 
  begin
  begin