Top Description Inners Constructors Methods
org.apache.poi.ss.formula.functions

public final Class Trend

extends Object
implements Function
Class Inheritance
All Implemented Interfaces
org.apache.poi.ss.formula.functions.Function
Imports
java.util.Arrays, org.apache.commons.math3.linear.SingularMatrixException, org.apache.commons.math3.stat.regression.OLSMultipleLinearRegression, org.apache.poi.ss.formula.CacheAreaEval, org.apache.poi.ss.formula.eval.AreaEval, .BoolEval, .ErrorEval, .EvaluationException, .MissingArgEval, .NotImplementedException, .NumberEval, .NumericValueEval, .RefEval, .ValueEval

Implementation for the Excel function TREND

Syntax:
TREND(known_y's, known_x's, new_x's, constant)

Parameter descriptions
known_y's, known_x's, new_x'stypically area references, possibly cell references or scalar values
constantTRUE or FALSE: determines whether the regression line should include an intercept term

If known_x's is not given, it is assumed to be the default array {1, 2, 3, ...} of the same size as known_y's.
If new_x's is not given, it is assumed to be the same as known_x's
If constant is omitted, it is assumed to be TRUE

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static double[][]
public ValueEval
evaluate(ValueEval[]
the evaluated function arguments. Empty values are represented with BlankEval or MissingArgEval, never null.
args
,
int
row index of the cell containing the formula under evaluation
srcRowIndex
,
int
column index of the cell containing the formula under evaluation
srcColumnIndex
)

Implements org.apache.poi.ss.formula.functions.Function.evaluate.

private static double[]
flattenArray(double[][] twoD)

private static double[][]
flattenArrayToRow(double[][] twoD)

private static double[][]
private static Trend.TrendResults
private static boolean

Returns:

true if all columns contain the same value
isAllColumnsSame
(double[][]
column-oriented matrix. A Row matrix should be transposed to column .
matrix
)

Check if all columns in a matrix contain the same values.

private static double[][]
switchRowsColumns(double[][] array)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Trendback to summary
public Trend()

Method Detail

evalToArrayback to summary
private static double[][] evalToArray(ValueEval arg) throws EvaluationException
evaluateback to summary
public ValueEval evaluate(ValueEval[] args, int srcRowIndex, int srcColumnIndex)

Implements org.apache.poi.ss.formula.functions.Function.evaluate.

Parameters
args:ValueEval[]

Doc from org.apache.poi.ss.formula.functions.Function.evaluate.

the evaluated function arguments. Empty values are represented with BlankEval or MissingArgEval, never null.

srcRowIndex:int

Doc from org.apache.poi.ss.formula.functions.Function.evaluate.

row index of the cell containing the formula under evaluation

srcColumnIndex:int

Doc from org.apache.poi.ss.formula.functions.Function.evaluate.

column index of the cell containing the formula under evaluation

Returns:ValueEval

Doc from org.apache.poi.ss.formula.functions.Function.evaluate.

The evaluated result, possibly an ErrorEval, never null

Note

- Excel uses the error code #NUM! instead of IEEE NaN, so when numeric functions evaluate to Double#NaN be sure to translate the result to ErrorEval#NUM_ERROR.

Annotations
@Override
flattenArrayback to summary
private static double[] flattenArray(double[][] twoD)
flattenArrayToRowback to summary
private static double[][] flattenArrayToRow(double[][] twoD)
getDefaultArrayOneDback to summary
private static double[][] getDefaultArrayOneD(int w)
getNewYback to summary
private static Trend.TrendResults getNewY(ValueEval[] args) throws EvaluationException
isAllColumnsSameback to summary
private static boolean isAllColumnsSame(double[][] matrix)

Check if all columns in a matrix contain the same values. Return true if the number of distinct values in each column is 1.

Parameters
matrix:double[][]

column-oriented matrix. A Row matrix should be transposed to column .

Returns:boolean

true if all columns contain the same value

switchRowsColumnsback to summary
private static double[][] switchRowsColumns(double[][] array)
org.apache.poi.ss.formula.functions back to summary

private final Class Trend.TrendResults

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final int
private final int
private final double[]

Constructor Summary

AccessConstructor and Description
public
TrendResults(double[] vals, int resultWidth, int resultHeight)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

resultHeightback to summary
private final int resultHeight
resultWidthback to summary
private final int resultWidth
valsback to summary
private final double[] vals

Constructor Detail

TrendResultsback to summary
public TrendResults(double[] vals, int resultWidth, int resultHeight)