]> source.dussan.org Git - poi.git/commitdiff
add VARPA and STDEVPA functions
authorPJ Fanning <fanningpj@apache.org>
Thu, 26 May 2022 22:47:07 +0000 (22:47 +0000)
committerPJ Fanning <fanningpj@apache.org>
Thu, 26 May 2022 22:47:07 +0000 (22:47 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1901300 13f79535-47bb-0310-9956-ffa450edef68

poi/src/main/java/org/apache/poi/ss/formula/eval/FunctionEval.java
poi/src/main/java/org/apache/poi/ss/formula/functions/AggregateFunction.java

index 741a7921d0ff2e8e5cca52587fc9c9c3ee212c22..eb322007fd00ffdb07f4b6b834ba1578896136e9 100644 (file)
@@ -336,8 +336,8 @@ public final class FunctionEval {
         retval[361] = AggregateFunction.AVERAGEA;
         retval[362] = MinaMaxa.MAXA;
         retval[363] = MinaMaxa.MINA;
-        // 364: STDEVPA
-        // 365: VARPA
+        retval[364] = AggregateFunction.STDEVPA;
+        retval[365] = AggregateFunction.VARPA;
         retval[366] = AggregateFunction.STDEVA;
         retval[367] = AggregateFunction.VARA;
 
index 02dd83c93ef67fd4153e200fb9795e203975c49a..b8379bc5eafca2e56e17acef2b066b24822e6079 100644 (file)
@@ -265,6 +265,20 @@ public abstract class AggregateFunction extends MultiOperandNumericFunction {
             return StatsLib.stdev(values);
         }
     };
+    public static final Function STDEVPA = new AggregateFunction() {
+        @Override
+        protected boolean handleLogicalValues() {
+            return true;
+        }
+
+        @Override
+        protected double evaluate(double[] values) throws EvaluationException {
+            if (values.length < 1) {
+                throw new EvaluationException(ErrorEval.DIV_ZERO);
+            }
+            return StatsLib.stdevp(values);
+        }
+    };
     public static final Function SUM = new AggregateFunction() {
         protected double evaluate(double[] values) {
             return MathX.sum(values);
@@ -296,7 +310,7 @@ public abstract class AggregateFunction extends MultiOperandNumericFunction {
         protected boolean handleLogicalValues() {
             return true;
         }
-        
+
         @Override
         protected double evaluate(double[] values) throws EvaluationException {
             if (values.length < 1) {
@@ -305,6 +319,20 @@ public abstract class AggregateFunction extends MultiOperandNumericFunction {
             return StatsLib.var(values);
         }
     };
+    public static final Function VARPA = new AggregateFunction() {
+        @Override
+        protected boolean handleLogicalValues() {
+            return true;
+        }
+
+        @Override
+        protected double evaluate(double[] values) throws EvaluationException {
+            if (values.length < 1) {
+                throw new EvaluationException(ErrorEval.DIV_ZERO);
+            }
+            return StatsLib.varp(values);
+        }
+    };
     public static final Function GEOMEAN = new Geomean();
 
     private static class Product extends AggregateFunction {