Commit 89a8a67e authored by GoshaZotov's avatar GoshaZotov

add functions for LINEST formula

parent 19f340bc
......@@ -1763,24 +1763,40 @@
function prepeareGrowthTrendCalculation(t, arg){
//если первое значение число
var tempNumber;
if(cElementType.number === arg[0].type){
if (cElementType.number === arg[0].type) {
tempNumber = arg[0];
arg[0] = new cArray();
arg[0].addElement(tempNumber);
} else if (cElementType.cell === arg[0].type || cElementType.cell3D === arg[0].type) {
tempNumber = arg[0].getValue();
arg[0] = new cArray();
arg[0].addElement(tempNumber);
}
//если первое значение число
if(arg[1] && cElementType.number === arg[1].type){
tempNumber = arg[1];
arg[1] = new cArray();
arg[1].addElement(tempNumber);
if (arg[1]) {
if (cElementType.number === arg[1].type) {
tempNumber = arg[1];
arg[1] = new cArray();
arg[1].addElement(tempNumber);
} else if (cElementType.cell === arg[1].type || cElementType.cell3D === arg[1].type) {
tempNumber = arg[1].getValue();
arg[1] = new cArray();
arg[1].addElement(tempNumber);
}
}
//если первое значение число
if(arg[2] && cElementType.number === arg[2].type){
tempNumber = arg[2];
arg[2] = new cArray();
arg[2].addElement(tempNumber);
if (arg[2] && cElementType.number === arg[2].type) {
if (cElementType.number === arg[2].type) {
tempNumber = arg[2];
arg[2] = new cArray();
arg[2].addElement(tempNumber);
} else if (cElementType.cell === arg[2].type || cElementType.cell3D === arg[2].type) {
tempNumber = arg[2].getValue();
arg[2] = new cArray();
arg[2].addElement(tempNumber);
}
}
var oArguments = t._prepareArguments(arg, arguments[1], true, [cElementType.array, cElementType.array, cElementType.array]);
......@@ -2072,7 +2088,7 @@
}
function CalculateRGPRKP(pMatY, pMatX, bConstant, bStats, _bRKP) {
var getMatrixParams = CheckMatrix(_bGrowth, pMatX, pMatY);
var getMatrixParams = CheckMatrix(_bRKP, pMatX, pMatY);
if (!getMatrixParams) {
return;
}
......@@ -2119,7 +2135,7 @@
if (bConstant) {
var pNewX = matrixClone(pMatX);
var pNewY = matrixClone(pMatY);
if (!pCopyX || !pCopyY) {
if (!pNewX || !pNewY) {
//PushError(FormulaError::MatrixSize);
return;
}
......@@ -2545,6 +2561,21 @@
return pResMat;
}
function getBoolValue(val, defaultValue){
var res = undefined !== defaultValue ? defaultValue : null;
if(!val){
return res;
}
if(cElementType.number === val.type){
res = val.tocBool().value;
}else if(cElementType.bool === val.type){
res = val.value;
}
return res;
}
function GAMMADISTFUNCTION(fp, fAlpha, fBeta){
this.fp = fp;
this.fAlpha = fAlpha;
......@@ -7292,11 +7323,63 @@
* @extends {AscCommonExcel.cBaseFunction}
*/
function cLINEST() {
cBaseFunction.call(this, "LINEST");
this.name = "LINEST";
this.value = null;
this.argumentsCurrent = 0;
}
cLINEST.prototype = Object.create(cBaseFunction.prototype);
cLINEST.prototype.constructor = cLINEST;
cLINEST.prototype.argumentsMin = 1;
cLINEST.prototype.argumentsMax = 4;
/*cLINEST.prototype.Calculate = function (arg) {
//если первое значение число
var tempNumber;
if (cElementType.number === arg[0].type) {
tempNumber = arg[0];
arg[0] = new cArray();
arg[0].addElement(tempNumber);
} else if (cElementType.cell === arg[0].type || cElementType.cell3D === arg[0].type) {
tempNumber = arg[0].getValue();
arg[0] = new cArray();
arg[0].addElement(tempNumber);
}
//если первое значение число
if (arg[1]) {
if (cElementType.number === arg[1].type) {
tempNumber = arg[1];
arg[1] = new cArray();
arg[1].addElement(tempNumber);
} else if (cElementType.cell === arg[1].type || cElementType.cell3D === arg[1].type) {
tempNumber = arg[1].getValue();
arg[1] = new cArray();
arg[1].addElement(tempNumber);
}
}
var oArguments = this._prepareArguments(arg, arguments[1], true, [cElementType.array, cElementType.array]);
var argClone = oArguments.args;
var argError;
if (argError = this._checkErrorArg(argClone)) {
return argError;
}
var pMatY = argClone[0];
var pMatX = argClone[1];
var bConstant = getBoolValue(argClone[2], true);
var bStats = getBoolValue(argClone[3], true);
var res = CalculateRGPRKP( pMatY, pMatX, bConstant, bStats);
if(res && res[0] && res[0][0]){
return this.value = new cNumber(res[0][0]);
}else{
return this.value = new cError(cErrorType.wrong_value_type);
}
};*/
/**
* @constructor
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment