git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1538772 13f79535-47bb-0310-9956-ffa450edef68tags/REL_3_10_FINAL
super(1); | super(1); | ||||
_value = value; | _value = value; | ||||
} | } | ||||
@Override | |||||
protected ValueEval getItemInternal(int index) { | protected ValueEval getItemInternal(int index) { | ||||
return _value; | return _value; | ||||
} | } | ||||
super(1); | super(1); | ||||
_ref = ref; | _ref = ref; | ||||
} | } | ||||
@Override | |||||
protected ValueEval getItemInternal(int index) { | protected ValueEval getItemInternal(int index) { | ||||
return _ref.getInnerValueEval(); | return _ref.getInnerValueEval(); | ||||
} | } | ||||
_ae = ae; | _ae = ae; | ||||
_width = ae.getWidth(); | _width = ae.getWidth(); | ||||
} | } | ||||
@Override | |||||
protected ValueEval getItemInternal(int index) { | protected ValueEval getItemInternal(int index) { | ||||
int rowIx = index / _width; | int rowIx = index / _width; | ||||
int colIx = index % _width; | int colIx = index % _width; | ||||
ValueEval arg0, ValueEval arg1) { | ValueEval arg0, ValueEval arg1) { | ||||
double result; | double result; | ||||
try { | try { | ||||
ValueVector vvX = createValueVector(arg0); | |||||
ValueVector vvY = createValueVector(arg1); | |||||
ValueVector vvY = createValueVector(arg0); | |||||
ValueVector vvX = createValueVector(arg1); | |||||
int size = vvX.getSize(); | int size = vvX.getSize(); | ||||
if (size == 0 || vvY.getSize() != size) { | if (size == 0 || vvY.getSize() != size) { | ||||
return ErrorEval.NA; | return ErrorEval.NA; | ||||
ErrorEval firstXerr = null; | ErrorEval firstXerr = null; | ||||
ErrorEval firstYerr = null; | ErrorEval firstYerr = null; | ||||
boolean accumlatedSome = false; | boolean accumlatedSome = false; | ||||
double result = 0.0; | |||||
// first pass: read in data, compute xbar and ybar | // first pass: read in data, compute xbar and ybar | ||||
double sumx = 0.0, sumy = 0.0; | double sumx = 0.0, sumy = 0.0; | ||||
public void testBasic() { | public void testBasic() { | ||||
Double exp = Math.pow(10, 7.5); | Double exp = Math.pow(10, 7.5); | ||||
ValueEval[] xValues = { | |||||
ValueEval[] yValues = { | |||||
new NumberEval(3+exp), | new NumberEval(3+exp), | ||||
new NumberEval(4+exp), | new NumberEval(4+exp), | ||||
new NumberEval(2+exp), | new NumberEval(2+exp), | ||||
new NumberEval(4+exp), | new NumberEval(4+exp), | ||||
new NumberEval(7+exp), | new NumberEval(7+exp), | ||||
}; | }; | ||||
ValueEval areaEvalX = createAreaEval(xValues); | |||||
ValueEval areaEvalY = createAreaEval(yValues); | |||||
ValueEval[] yValues = { | |||||
ValueEval[] xValues = { | |||||
new NumberEval(1), | new NumberEval(1), | ||||
new NumberEval(2), | new NumberEval(2), | ||||
new NumberEval(3), | new NumberEval(3), | ||||
new NumberEval(5), | new NumberEval(5), | ||||
new NumberEval(6), | new NumberEval(6), | ||||
}; | }; | ||||
ValueEval areaEvalY = createAreaEval(yValues); | |||||
ValueEval areaEvalX = createAreaEval(xValues); | |||||
confirm(INTERCEPT, areaEvalX, areaEvalY, -24516534.39905822); | confirm(INTERCEPT, areaEvalX, areaEvalY, -24516534.39905822); | ||||
// Excel 2010 gives -24516534.3990583 | // Excel 2010 gives -24516534.3990583 | ||||
} | } | ||||
* number of items in array is not limited to 30 | * number of items in array is not limited to 30 | ||||
*/ | */ | ||||
public void testLargeArrays() { | public void testLargeArrays() { | ||||
ValueEval[] xValues = createMockNumberArray(100, 3); // [1,2,0,1,2,0,...,0,1] | |||||
xValues[0] = new NumberEval(2.0); // Changes first element to 2 | |||||
ValueEval[] yValues = createMockNumberArray(100, 101); // [1,2,3,4,...,99,100] | |||||
ValueEval[] yValues = createMockNumberArray(100, 3); // [1,2,0,1,2,0,...,0,1] | |||||
yValues[0] = new NumberEval(2.0); // Changes first element to 2 | |||||
ValueEval[] xValues = createMockNumberArray(100, 101); // [1,2,3,4,...,99,100] | |||||
confirm(INTERCEPT, createAreaEval(xValues), createAreaEval(yValues), 51.74384236453202); | confirm(INTERCEPT, createAreaEval(xValues), createAreaEval(yValues), 51.74384236453202); | ||||
// Excel 2010 gives 51.74384236453200 | // Excel 2010 gives 51.74384236453200 | ||||
confirmError(areaEvalX, areaEvalX, ErrorEval.REF_INVALID); | confirmError(areaEvalX, areaEvalX, ErrorEval.REF_INVALID); | ||||
// search for errors array by array, not pair by pair | // search for errors array by array, not pair by pair | ||||
confirmError(areaEvalX, areaEvalY, ErrorEval.REF_INVALID); | |||||
confirmError(areaEvalY, areaEvalX, ErrorEval.NULL_INTERSECTION); | |||||
confirmError(areaEvalX, areaEvalY, ErrorEval.NULL_INTERSECTION); | |||||
confirmError(areaEvalY, areaEvalX, ErrorEval.REF_INVALID); | |||||
} | } | ||||
/** | /** |
public void testBasic() { | public void testBasic() { | ||||
Double exp = Math.pow(10, 7.5); | Double exp = Math.pow(10, 7.5); | ||||
ValueEval[] xValues = { | |||||
ValueEval[] yValues = { | |||||
new NumberEval(3+exp), | new NumberEval(3+exp), | ||||
new NumberEval(4+exp), | new NumberEval(4+exp), | ||||
new NumberEval(2+exp), | new NumberEval(2+exp), | ||||
new NumberEval(4+exp), | new NumberEval(4+exp), | ||||
new NumberEval(7+exp), | new NumberEval(7+exp), | ||||
}; | }; | ||||
ValueEval areaEvalX = createAreaEval(xValues); | |||||
ValueEval areaEvalY = createAreaEval(yValues); | |||||
ValueEval[] yValues = { | |||||
ValueEval[] xValues = { | |||||
new NumberEval(1), | new NumberEval(1), | ||||
new NumberEval(2), | new NumberEval(2), | ||||
new NumberEval(3), | new NumberEval(3), | ||||
new NumberEval(5), | new NumberEval(5), | ||||
new NumberEval(6), | new NumberEval(6), | ||||
}; | }; | ||||
ValueEval areaEvalY = createAreaEval(yValues); | |||||
ValueEval areaEvalX = createAreaEval(xValues); | |||||
confirm(SLOPE, areaEvalX, areaEvalY, 0.7752808988764045); | confirm(SLOPE, areaEvalX, areaEvalY, 0.7752808988764045); | ||||
// Excel 2010 gives 0.775280898876405 | // Excel 2010 gives 0.775280898876405 | ||||
} | } | ||||
* number of items in array is not limited to 30 | * number of items in array is not limited to 30 | ||||
*/ | */ | ||||
public void testLargeArrays() { | public void testLargeArrays() { | ||||
ValueEval[] xValues = createMockNumberArray(100, 3); // [1,2,0,1,2,0,...,0,1] | |||||
xValues[0] = new NumberEval(2.0); // Changes first element to 2 | |||||
ValueEval[] yValues = createMockNumberArray(100, 101); // [1,2,3,4,...,99,100] | |||||
ValueEval[] yValues = createMockNumberArray(100, 3); // [1,2,0,1,2,0,...,0,1] | |||||
yValues[0] = new NumberEval(2.0); // Changes first element to 2 | |||||
ValueEval[] xValues = createMockNumberArray(100, 101); // [1,2,3,4,...,99,100] | |||||
confirm(SLOPE, createAreaEval(xValues), createAreaEval(yValues), -1.231527093596059); | confirm(SLOPE, createAreaEval(xValues), createAreaEval(yValues), -1.231527093596059); | ||||
// Excel 2010 gives -1.23152709359606 | // Excel 2010 gives -1.23152709359606 | ||||
confirmError(areaEvalX, areaEvalX, ErrorEval.REF_INVALID); | confirmError(areaEvalX, areaEvalX, ErrorEval.REF_INVALID); | ||||
// search for errors array by array, not pair by pair | // search for errors array by array, not pair by pair | ||||
confirmError(areaEvalX, areaEvalY, ErrorEval.REF_INVALID); | |||||
confirmError(areaEvalY, areaEvalX, ErrorEval.NULL_INTERSECTION); | |||||
confirmError(areaEvalX, areaEvalY, ErrorEval.NULL_INTERSECTION); | |||||
confirmError(areaEvalY, areaEvalX, ErrorEval.REF_INVALID); | |||||
} | } | ||||
} | } |