Search in sources :

Example 91 with NumberEval

use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.

the class TestRoundFuncs method assertRoundFuncEquals.

private static void assertRoundFuncEquals(Function func, double expected, double number, double places, double tolerance) {
    ValueEval[] args = { new NumberEval(number), new NumberEval(places) };
    NumberEval result = (NumberEval) func.evaluate(args, -1, (short) -1);
    assertEquals(expected, result.getNumberValue(), tolerance);
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval) NumberEval(org.apache.poi.ss.formula.eval.NumberEval)

Example 92 with NumberEval

use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.

the class TestSlope method testBasic.

public void testBasic() {
    Double exp = Math.pow(10, 7.5);
    ValueEval[] yValues = { new NumberEval(3 + exp), new NumberEval(4 + exp), new NumberEval(2 + exp), new NumberEval(5 + exp), new NumberEval(4 + exp), new NumberEval(7 + exp) };
    ValueEval areaEvalY = createAreaEval(yValues);
    ValueEval[] xValues = { new NumberEval(1), new NumberEval(2), new NumberEval(3), new NumberEval(4), new NumberEval(5), new NumberEval(6) };
    ValueEval areaEvalX = createAreaEval(xValues);
    confirm(SLOPE, areaEvalX, areaEvalY, 0.7752808988764045);
// Excel 2010 gives 0.775280898876405
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval) NumberEval(org.apache.poi.ss.formula.eval.NumberEval)

Example 93 with NumberEval

use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.

the class TestPoisson method testXZeroMeanZero.

public void testXZeroMeanZero() {
    double x = 0;
    double mean = 0;
    // known result in excel
    double result = 1;
    NumberEval myResult = (NumberEval) invokePoisson(x, mean, true);
    assertEquals(myResult.getNumberValue(), result, DELTA);
}
Also used : NumberEval(org.apache.poi.ss.formula.eval.NumberEval)

Example 94 with NumberEval

use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.

the class TestPoisson method testCumulativeProbability.

public void testCumulativeProbability() {
    double x = 1;
    double mean = 0.2;
    // known result
    double result = 0.9824769036935787;
    NumberEval myResult = (NumberEval) invokePoisson(x, mean, true);
    assertEquals(myResult.getNumberValue(), result, DELTA);
}
Also used : NumberEval(org.apache.poi.ss.formula.eval.NumberEval)

Example 95 with NumberEval

use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.

the class TestNper method testSimpleEvaluate.

@Test
public void testSimpleEvaluate() {
    ValueEval[] args = { new NumberEval(0.05), new NumberEval(250), new NumberEval(-1000) };
    ValueEval result = FinanceFunction.NPER.evaluate(args, 0, (short) 0);
    assertEquals(NumberEval.class, result.getClass());
    assertEquals(4.57353557, ((NumberEval) result).getNumberValue(), 0.00000001);
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval) NumberEval(org.apache.poi.ss.formula.eval.NumberEval) Test(org.junit.Test)

Aggregations

NumberEval (org.apache.poi.ss.formula.eval.NumberEval)123 ValueEval (org.apache.poi.ss.formula.eval.ValueEval)101 Test (org.junit.Test)34 StringEval (org.apache.poi.ss.formula.eval.StringEval)29 AreaEval (org.apache.poi.ss.formula.eval.AreaEval)21 EvaluationException (org.apache.poi.ss.formula.eval.EvaluationException)19 Calendar (java.util.Calendar)17 Date (java.util.Date)13 NumericValueEval (org.apache.poi.ss.formula.eval.NumericValueEval)12 ErrorEval (org.apache.poi.ss.formula.eval.ErrorEval)8 I_MatchPredicate (org.apache.poi.ss.formula.functions.CountUtils.I_MatchPredicate)5 RefEval (org.apache.poi.ss.formula.eval.RefEval)4 AssertionFailedError (junit.framework.AssertionFailedError)3 ValueVector (org.apache.poi.ss.formula.functions.LookupUtils.ValueVector)3 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)2 BoolEval (org.apache.poi.ss.formula.eval.BoolEval)2 Workbook (org.apache.poi.ss.usermodel.Workbook)2 DateFormatSymbols (java.text.DateFormatSymbols)1 DecimalFormatSymbols (java.text.DecimalFormatSymbols)1 SimpleDateFormat (java.text.SimpleDateFormat)1