public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0,ValueEval arg1) {double dn;try {ValueEval ve1 = OperandResolver.getSingleValue(arg1, srcRowIndex, srcColumnIndex);dn = OperandResolver.coerceValueToDouble(ve1);} catch (EvaluationException e1) {return ErrorEval.VALUE_INVALID;}if (dn < 1.0) {return ErrorEval.NUM_ERROR;}int k = (int) Math.ceil(dn);double result;try {double[] ds = ValueCollector.collectValues(arg0);if (k > ds.length) {return ErrorEval.NUM_ERROR;}result = _isLarge ? StatsLib.kthLargest(ds, k) : StatsLib.kthSmallest(ds, k);NumericFunction.checkValue(result);} catch (EvaluationException e) {return e.getErrorEval();}return new NumberEval(result);}

public override ValueEval Evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0,ValueEval arg1){double dn;try{ValueEval ve1 = OperandResolver.GetSingleValue(arg1, srcRowIndex, srcColumnIndex);dn = OperandResolver.CoerceValueToDouble(ve1);}catch (EvaluationException){return ErrorEval.VALUE_INVALID;}if (dn < 1.0){return ErrorEval.NUM_ERROR;}int k = (int)Math.Ceiling(dn);double result;try{double[] ds = NPOI.SS.Formula.Functions.AggregateFunction.ValueCollector.CollectValues(arg0);if (k > ds.Length){return ErrorEval.NUM_ERROR;}result = _isLarge ? StatsLib.kthLargest(ds, k) : StatsLib.kthSmallest(ds, k);NumericFunction.CheckValue(result);}catch (EvaluationException e){return e.GetErrorEval();}return new NumberEval(result);}
