Commit ad79ceeb authored by GoshaZotov's avatar GoshaZotov

add IMSEC / IMSECH formulas

parent 6699ab83
......@@ -2062,6 +2062,18 @@ $( function () {
strictEqual( oParser.calculate().getValue(), "-0.03627588962862601-0.0051744731840193976i", 'IMCSCH("4+3i")' );
} );
test( "Test: \"IMSEC\"", function () {
oParser = new parserFormula( 'IMSEC("4+3i")', "A2", ws );
ok( oParser.parse(), 'IMSEC("4+3i")' );
strictEqual( oParser.calculate().getValue(), "-0.06529402785794705-0.07522496030277323i", 'IMSEC("4+3i")' );
} );
test( "Test: \"IMSECH\"", function () {
oParser = new parserFormula( 'IMSECH("4+3i")', "A2", ws );
ok( oParser.parse(), 'IMSECH("4+3i")' );
strictEqual( oParser.calculate().getValue(), "-0.03625349691586888+0.00516434460775318i", 'IMSECH("4+3i")' );
} );
test( "Test: \"IMTAN\"", function () {
oParser = new parserFormula( 'IMTAN("4+3i")', "A2", ws );
ok( oParser.parse(), 'IMTAN("4+3i")' );
......
......@@ -52,7 +52,7 @@
cFormulaFunctionGroup['DateAndTime'].push(cDAYS, cISOWEEKNUM);
cFormulaFunctionGroup['Engineering'] = cFormulaFunctionGroup['Engineering'] || [];
cFormulaFunctionGroup['Engineering'].push(cBITAND, cBITLSHIFT, cBITOR, cBITRSHIFT, cBITXOR, cERF_PRECISE,
cERFC_PRECISE, cIMSEC, cIMSECH, cIMSINH);
cERFC_PRECISE, cIMSINH);
cFormulaFunctionGroup['TextAndData'] = cFormulaFunctionGroup['TextAndData'] || [];
cFormulaFunctionGroup['TextAndData'].push(cDBCS, cNUMBERVALUE, cUNICHAR, cUNICODE);
cFormulaFunctionGroup['Statistical'] = cFormulaFunctionGroup['Statistical'] || [];
......@@ -616,30 +616,6 @@
cIFNA.prototype = Object.create(cBaseFunction.prototype);
cIFNA.prototype.constructor = cIFNA;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cIMSEC() {
cBaseFunction.call(this, "IMSEC");
this.isXLFN = true;
}
cIMSEC.prototype = Object.create(cBaseFunction.prototype);
cIMSEC.prototype.constructor = cIMSEC;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cIMSECH() {
cBaseFunction.call(this, "IMSECH");
this.isXLFN = true;
}
cIMSECH.prototype = Object.create(cBaseFunction.prototype);
cIMSECH.prototype.constructor = cIMSECH;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
......
......@@ -516,6 +516,22 @@
} else {
this.real = 1 / Math.sinh(this.real);
}
}, Sec: function () {
if (this.img) {
var a = (2 * Math.cos(this.real) * Math.cosh(this.img)) / (Math.cosh(2 * this.img) + Math.cos(2 *this.real));
this.img = (2 * Math.sin(this.real) * Math.sinh(this.img)) / (Math.cosh(2 * this.img) + Math.cos(2 *this.real));
this.real = a;
} else {
this.real = 1 / Math.cos(this.real);
}
}, Sech: function () {
if (this.img) {
var a = (2 * Math.cosh(this.real) * Math.cos(this.img)) / (Math.cosh(2 * this.real) + Math.cos(2 *this.img));
this.img = (2 * Math.sinh(this.real) * Math.sin(this.img)) / (Math.cosh(2 * this.real) + Math.cos(2 *this.img));
this.real = a;
} else {
this.real = 1 / Math.cosh(this.real);
}
}, Sin: function () {
if (this.img) {
var a = Math.sin(this.real) * Math.cosh(this.img);
......@@ -914,7 +930,7 @@
cFormulaFunctionGroup['Engineering'].push(cBESSELI, cBESSELJ, cBESSELK, cBESSELY, cBIN2DEC, cBIN2HEX, cBIN2OCT,
cCOMPLEX, cCONVERT, cDEC2BIN, cDEC2HEX, cDEC2OCT, cDELTA, cERF, cERFC, cGESTEP, cHEX2BIN, cHEX2DEC, cHEX2OCT,
cIMABS, cIMAGINARY, cIMARGUMENT, cIMCONJUGATE, cIMCOS, cIMCOSH, cIMCOT, cIMCSC, cIMCSCH, cIMDIV, cIMEXP, cIMLN, cIMLOG10, cIMLOG2, cIMPOWER,
cIMPRODUCT, cIMREAL, cIMSIN, cIMSQRT, cIMSUB, cIMSUM, cIMTAN, cOCT2BIN, cOCT2DEC, cOCT2HEX);
cIMPRODUCT, cIMREAL, cIMSEC, cIMSECH, cIMSIN, cIMSQRT, cIMSUB, cIMSUM, cIMTAN, cOCT2BIN, cOCT2DEC, cOCT2HEX);
/**
* @constructor
......@@ -2782,6 +2798,110 @@
};
};
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cIMSEC() {
cBaseFunction.call(this, "IMSEC");
}
cIMSEC.prototype = Object.create(cBaseFunction.prototype);
cIMSEC.prototype.constructor = cIMSEC;
cIMSEC.prototype.argumentsMin = 1;
cIMSEC.prototype.argumentsMax = 1;
cIMSEC.prototype.isXLFN = true;
cIMSEC.prototype.Calculate = function (arg) {
var arg0 = arg[0];
if (arg0 instanceof cArea || arg0 instanceof cArea3D) {
arg0 = arg0.cross(arguments[1]);
} else if (arg0 instanceof cArray) {
arg0 = arg0.getElementRowCol(0, 0);
}
if(arg0.value === true || arg0.value === false){
return this.value = new cError(cErrorType.wrong_value_type);
}
arg0 = arg0.tocString();
if (arg0 instanceof cError) {
return this.value = arg0;
}
var c = new Complex(arg0.toString());
if (c instanceof cError) {
return this.value = c;
}
c.Sec();
this.value = new cString(c.toString());
this.value.numFormat = 0;
return this.value;
};
cIMSEC.prototype.getInfo = function () {
return {
name: this.name, args: "( complex-number )"
};
};
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cIMSECH() {
cBaseFunction.call(this, "IMSECH");
}
cIMSECH.prototype = Object.create(cBaseFunction.prototype);
cIMSECH.prototype.constructor = cIMSECH;
cIMSECH.prototype.argumentsMin = 1;
cIMSECH.prototype.argumentsMax = 1;
cIMSECH.prototype.isXLFN = true;
cIMSECH.prototype.Calculate = function (arg) {
var arg0 = arg[0];
if (arg0 instanceof cArea || arg0 instanceof cArea3D) {
arg0 = arg0.cross(arguments[1]);
} else if (arg0 instanceof cArray) {
arg0 = arg0.getElementRowCol(0, 0);
}
if(arg0.value === true || arg0.value === false){
return this.value = new cError(cErrorType.wrong_value_type);
}
arg0 = arg0.tocString();
if (arg0 instanceof cError) {
return this.value = arg0;
}
var c = new Complex(arg0.toString());
if (c instanceof cError) {
return this.value = c;
}
c.Sech();
this.value = new cString(c.toString());
this.value.numFormat = 0;
return this.value;
};
cIMSECH.prototype.getInfo = function () {
return {
name: this.name, args: "( complex-number )"
};
};
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
......
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