Commit 8dc561bc authored by GoshaZotov's avatar GoshaZotov

change PERMUT formula

parent cbcf00eb
...@@ -6079,75 +6079,29 @@ ...@@ -6079,75 +6079,29 @@
cPERMUT.prototype.argumentsMin = 2; cPERMUT.prototype.argumentsMin = 2;
cPERMUT.prototype.argumentsMax = 2; cPERMUT.prototype.argumentsMax = 2;
cPERMUT.prototype.Calculate = function (arg) { cPERMUT.prototype.Calculate = function (arg) {
var arg0 = arg[0], arg1 = arg[1];
if (arg0 instanceof cArea || arg0 instanceof cArea3D) {
arg0 = arg0.cross(arguments[1]);
}
arg0 = arg0.tocNumber();
if (arg1 instanceof cArea || arg1 instanceof cArea3D) {
arg1 = arg1.cross(arguments[1]);
}
arg1 = arg1.tocNumber();
if (arg0 instanceof cError) {
return this.value = arg0;
}
if (arg1 instanceof cError) {
return this.value = arg1;
}
if (arg0 instanceof cArray && arg1 instanceof cArray) {
if (arg0.getCountElement() != arg1.getCountElement() || arg0.getRowCount() != arg1.getRowCount()) {
return this.value = new cError(cErrorType.not_available);
} else {
arg0.foreach(function (elem, r, c) {
var a = elem, b = arg1.getElementRowCol(r, c);
if (a instanceof cNumber && b instanceof cNumber) {
this.array[r][c] = new cNumber(Math.permut(a.getValue(), b.getValue()));
} else {
this.array[r][c] = new cError(cErrorType.wrong_value_type);
}
});
return this.value = arg0;
}
} else if (arg0 instanceof cArray) {
arg0.foreach(function (elem, r, c) {
var a = elem, b = arg1;
if (a instanceof cNumber && b instanceof cNumber) {
if (a.getValue() <= 0 || b.getValue() <= 0 || a.getValue() < b.getValue()) { var oArguments = this._prepareArguments(arg, arguments[1], true);
this.array[r][c] = new cError(cErrorType.not_numeric); var argClone = oArguments.args;
}
this.array[r][c] = new cNumber(Math.permut(a.getValue(), b.getValue())); argClone[0] = argClone[0].tocNumber();
} else { argClone[1] = argClone[1].tocNumber();
this.array[r][c] = new cError(cErrorType.wrong_value_type);
}
});
return this.value = arg0;
} else if (arg1 instanceof cArray) {
arg1.foreach(function (elem, r, c) {
var a = arg0, b = elem;
if (a instanceof cNumber && b instanceof cNumber) {
if (a.getValue() <= 0 || b.getValue() <= 0 || a.getValue() < b.getValue()) { var argError;
this.array[r][c] = new cError(cErrorType.not_numeric); if (argError = this._checkErrorArg(argClone)) {
return this.value = argError;
} }
this.array[r][c] = new cNumber(Math.permut(a.getValue(), b.getValue())); function permut(argArray) {
} else { var n = Math.floor(argArray[0]);
this.array[r][c] = new cError(cErrorType.wrong_value_type); var k = Math.floor(argArray[1]);
} if (n <= 0 || k <= 0 || n < k) {
}); return new cError(cErrorType.not_numeric);
return this.value = arg1;
} }
if (arg0.getValue() <= 0 || arg1.getValue() <= 0 || arg0.getValue() < arg1.getValue()) { return new cNumber(Math.permut(n, k));
return this.value = new cError(cErrorType.not_numeric);
} }
return this.value = new cNumber(Math.permut(arg0.getValue(), arg1.getValue())); return this.value = this._findArrayInNumberArguments(oArguments, permut);
}; };
/** /**
......
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