@univerjs/engine-formula 0.2.14 → 0.3.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +2 -2
- package/lib/es/index.js +2744 -886
- package/lib/types/basics/engineering.d.ts +2 -0
- package/lib/types/basics/statistical.d.ts +32 -0
- package/lib/types/engine/reference-object/base-reference-object.d.ts +1 -1
- package/lib/types/engine/utils/compare.d.ts +11 -3
- package/lib/types/engine/value-object/array-value-object.d.ts +12 -1
- package/lib/types/engine/value-object/lambda-value-object.d.ts +2 -2
- package/lib/types/functions/base-function.d.ts +6 -6
- package/lib/types/functions/compatibility/betadist/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/compatibility/betadist/index.d.ts +8 -0
- package/lib/types/functions/compatibility/normsdist/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/compatibility/normsdist/index.d.ts +8 -0
- package/lib/types/functions/logical/bycol/index.d.ts +3 -1
- package/lib/types/functions/logical/byrow/index.d.ts +3 -1
- package/lib/types/functions/logical/map/index.d.ts +3 -1
- package/lib/types/functions/logical/reduce/index.d.ts +3 -1
- package/lib/types/functions/logical/scan/index.d.ts +3 -1
- package/lib/types/functions/lookup/offset/index.d.ts +1 -1
- package/lib/types/functions/lookup/xlookup/index.d.ts +8 -2
- package/lib/types/functions/lookup/xmatch/index.d.ts +1 -2
- package/lib/types/functions/math/function-map.d.ts +1 -1
- package/lib/types/functions/statistical/beta-dist/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/beta-dist/index.d.ts +8 -0
- package/lib/types/functions/statistical/beta-inv/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/beta-inv/index.d.ts +8 -0
- package/lib/types/functions/statistical/binom-dist/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/binom-dist/index.d.ts +8 -0
- package/lib/types/functions/statistical/binom-dist-range/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/binom-dist-range/index.d.ts +8 -0
- package/lib/types/functions/statistical/binom-inv/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/binom-inv/index.d.ts +8 -0
- package/lib/types/functions/statistical/chisq-dist/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/chisq-dist/index.d.ts +8 -0
- package/lib/types/functions/statistical/chisq-dist-rt/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/chisq-dist-rt/index.d.ts +8 -0
- package/lib/types/functions/statistical/chisq-inv/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/chisq-inv/index.d.ts +8 -0
- package/lib/types/functions/statistical/chisq-inv-rt/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/chisq-inv-rt/index.d.ts +8 -0
- package/lib/types/functions/statistical/chisq-test/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/chisq-test/index.d.ts +8 -0
- package/lib/types/functions/statistical/confidence-norm/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/confidence-norm/index.d.ts +7 -0
- package/lib/types/functions/statistical/confidence-t/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/confidence-t/index.d.ts +7 -0
- package/lib/types/functions/statistical/correl/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/correl/index.d.ts +8 -0
- package/lib/types/functions/statistical/covariance-p/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/covariance-p/index.d.ts +8 -0
- package/lib/types/functions/statistical/covariance-s/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/covariance-s/index.d.ts +8 -0
- package/lib/types/functions/statistical/devsq/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/devsq/index.d.ts +8 -0
- package/lib/types/functions/statistical/expon-dist/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/expon-dist/index.d.ts +8 -0
- package/lib/types/functions/statistical/f-dist/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/f-dist/index.d.ts +8 -0
- package/lib/types/functions/statistical/f-dist-rt/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/f-dist-rt/index.d.ts +8 -0
- package/lib/types/functions/statistical/f-inv/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/f-inv/index.d.ts +8 -0
- package/lib/types/functions/statistical/f-inv-rt/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/f-inv-rt/index.d.ts +8 -0
- package/lib/types/functions/statistical/f-test/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/f-test/index.d.ts +8 -0
- package/lib/types/functions/statistical/fisher/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/fisher/index.d.ts +8 -0
- package/lib/types/functions/statistical/fisherinv/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/fisherinv/index.d.ts +8 -0
- package/lib/types/functions/statistical/forecast/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/forecast/index.d.ts +8 -0
- package/lib/types/functions/statistical/function-map.d.ts +1 -1
- package/lib/types/functions/statistical/intercept/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/intercept/index.d.ts +8 -0
- package/lib/types/functions/statistical/norm-dist/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/norm-dist/index.d.ts +8 -0
- package/lib/types/functions/statistical/norm-inv/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/norm-inv/index.d.ts +8 -0
- package/lib/types/functions/statistical/norm-s-dist/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/norm-s-dist/index.d.ts +8 -0
- package/lib/types/functions/statistical/norm-s-inv/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/statistical/norm-s-inv/index.d.ts +8 -0
- package/lib/types/functions/text/function-map.d.ts +1 -1
- package/lib/types/functions/text/leftb/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/leftb/index.d.ts +9 -0
- package/lib/types/functions/text/mid/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/mid/index.d.ts +8 -0
- package/lib/types/functions/text/textafter/index.d.ts +2 -1
- package/lib/types/functions/text/textbefore/index.d.ts +2 -1
- package/lib/types/index.d.ts +13 -13
- package/lib/umd/index.js +2 -2
- package/package.json +8 -8
package/lib/es/index.js
CHANGED
|
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
-
import { ObjectMatrix, LRUMap, hashAlgorithm, Tools, AbsoluteRefType, RANGE_TYPE, Disposable, moveRangeByOffset, isValidRange,
|
|
5
|
+
import { ObjectMatrix, LRUMap, hashAlgorithm, Tools, AbsoluteRefType, RANGE_TYPE, Disposable, moveRangeByOffset, isValidRange, BuildTextUtils, numfmt, isRealNum, isNullCell, CellValueType, BooleanNumber, isFormulaString, isFormulaId, Inject, UniverInstanceType, IUniverInstanceService, CommandType, createIdentifier, toDisposable, Injector, sortRules, OnLifecycle, LifecycleStages, requestImmediateMacroTask, IConfigService, ICommandService, Optional, Plugin } from "@univerjs/core";
|
|
6
6
|
import { Subject } from "rxjs";
|
|
7
7
|
import { DataSyncPrimaryController } from "@univerjs/rpc";
|
|
8
8
|
function isInDirtyRange(dirtyRanges, unitId, sheetId, row, column) {
|
|
@@ -1207,7 +1207,7 @@ function getCellValue(cell) {
|
|
|
1207
1207
|
if (body == null)
|
|
1208
1208
|
return 0;
|
|
1209
1209
|
const data = body.dataStream;
|
|
1210
|
-
return
|
|
1210
|
+
return BuildTextUtils.transform.getPlainText(data);
|
|
1211
1211
|
}
|
|
1212
1212
|
return (cell == null ? void 0 : cell.v) || 0;
|
|
1213
1213
|
}
|
|
@@ -1351,6 +1351,23 @@ function escapeRegExp(str) {
|
|
|
1351
1351
|
return str.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
1352
1352
|
}
|
|
1353
1353
|
__name(escapeRegExp, "escapeRegExp");
|
|
1354
|
+
function getMatchModeValue(matchModeValue) {
|
|
1355
|
+
switch (matchModeValue) {
|
|
1356
|
+
case 1:
|
|
1357
|
+
return 2;
|
|
1358
|
+
case 0:
|
|
1359
|
+
return 0;
|
|
1360
|
+
case -1:
|
|
1361
|
+
return 1;
|
|
1362
|
+
default:
|
|
1363
|
+
return 0;
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
__name(getMatchModeValue, "getMatchModeValue");
|
|
1367
|
+
function getSearchModeValue(searchModeValue) {
|
|
1368
|
+
return searchModeValue === -2 ? 1 : 0;
|
|
1369
|
+
}
|
|
1370
|
+
__name(getSearchModeValue, "getSearchModeValue");
|
|
1354
1371
|
const _BaseValueObject = class _BaseValueObject extends ObjectClassType {
|
|
1355
1372
|
constructor(_rawValue) {
|
|
1356
1373
|
super(), this._rawValue = _rawValue;
|
|
@@ -4097,49 +4114,56 @@ const _ArrayValueObject = class _ArrayValueObject extends BaseValueObject {
|
|
|
4097
4114
|
return result = itemValue, resultPosition = { row, column }, !1;
|
|
4098
4115
|
searchType === ArrayOrderSearchType.MAX ? itemValue.isGreaterThan(valueObject).getValue() === !0 && (maxOrMin2 == null || itemValue.minus(valueObject).abs().isLessThanOrEqual(maxOrMin2.minus(valueObject).abs()).getValue() === !0) && (maxOrMin2 = itemValue, maxOrMinPosition = { row, column }) : searchType === ArrayOrderSearchType.MIN && itemValue.isLessThan(valueObject).getValue() === !0 && (maxOrMin2 == null || itemValue.minus(valueObject).abs().isLessThanOrEqual(maxOrMin2.minus(valueObject).abs()).getValue() === !0) && (maxOrMin2 = itemValue, maxOrMinPosition = { row, column });
|
|
4099
4116
|
}, "_handleMatch");
|
|
4100
|
-
if (isDesc)
|
|
4101
|
-
const rowCount = this._values.length;
|
|
4102
|
-
if (this._values[0] == null)
|
|
4103
|
-
return;
|
|
4104
|
-
const columnCount = this._values[0].length;
|
|
4105
|
-
for (let r = rowCount - 1; r >= 0; r--)
|
|
4106
|
-
for (let c = columnCount - 1; c >= 0; c--) {
|
|
4107
|
-
const itemValue = this._values[r][c];
|
|
4108
|
-
_handleMatch(itemValue, r, c);
|
|
4109
|
-
}
|
|
4110
|
-
} else
|
|
4111
|
-
this.iterator((itemValue, r, c) => {
|
|
4112
|
-
_handleMatch(itemValue, r, c);
|
|
4113
|
-
});
|
|
4114
|
-
if (result != null)
|
|
4117
|
+
if (isDesc ? this.iteratorReverse((itemValue, r, c) => _handleMatch(itemValue, r, c)) : this.iterator((itemValue, r, c) => _handleMatch(itemValue, r, c)), result != null)
|
|
4115
4118
|
return resultPosition;
|
|
4116
4119
|
if (maxOrMin2 != null)
|
|
4117
4120
|
return maxOrMinPosition;
|
|
4118
4121
|
}
|
|
4119
|
-
binarySearch(valueObject, searchType = ArrayBinarySearchType.MIN) {
|
|
4122
|
+
binarySearch(valueObject, searchType = ArrayBinarySearchType.MIN, matchType = ArrayOrderSearchType.MIN) {
|
|
4120
4123
|
if (valueObject.isError())
|
|
4121
4124
|
return;
|
|
4122
4125
|
const { stringArray, stringPosition, numberArray, numberPosition } = this.flattenPosition();
|
|
4123
|
-
return valueObject.isString() ? this._binarySearch(valueObject, stringArray, stringPosition, searchType) : this._binarySearch(valueObject, numberArray, numberPosition, searchType);
|
|
4126
|
+
return valueObject.isString() ? this._binarySearch(valueObject, stringArray, stringPosition, searchType, matchType) : this._binarySearch(valueObject, numberArray, numberPosition, searchType, matchType);
|
|
4124
4127
|
}
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
+
/**
|
|
4129
|
+
* searchType defaults to ascending order
|
|
4130
|
+
*
|
|
4131
|
+
* matchType defaults to the maximum value less than the search value, which is used for the default matching mode of VLOOKUP/LOOKUP/HLOOKUP.
|
|
4132
|
+
* @param valueObject
|
|
4133
|
+
* @param searchArray
|
|
4134
|
+
* @param positionArray
|
|
4135
|
+
* @param searchType
|
|
4136
|
+
* @param matchType
|
|
4137
|
+
* @returns
|
|
4138
|
+
*/
|
|
4139
|
+
_binarySearch(valueObject, searchArray, positionArray, searchType = ArrayBinarySearchType.MIN, matchType = ArrayOrderSearchType.MIN) {
|
|
4140
|
+
const compareFunc = getCompare(), value = Number(valueObject.getValue()), isValueNumber = !Number.isNaN(value);
|
|
4141
|
+
let start = 0, end = searchArray.length - 1, exactMatchIndex = -1, nearestSmallerIndex = -1, nearestLargerIndex = -1;
|
|
4128
4142
|
for (; start <= end; ) {
|
|
4129
4143
|
const middle = Math.floor((start + end) / 2), compareTo = searchArray[middle];
|
|
4130
|
-
let
|
|
4144
|
+
let compareResult;
|
|
4131
4145
|
if (compareTo.isNull())
|
|
4132
|
-
|
|
4146
|
+
compareResult = searchType === ArrayBinarySearchType.MIN ? 1 : -1;
|
|
4133
4147
|
else {
|
|
4134
4148
|
const compareToValue = compareTo.getValue();
|
|
4135
|
-
|
|
4149
|
+
if (isValueNumber) {
|
|
4150
|
+
const compareToNumber = Number(compareToValue);
|
|
4151
|
+
compareResult = Number.isNaN(compareToNumber) ? 1 : Math.sign(compareToNumber - value);
|
|
4152
|
+
} else
|
|
4153
|
+
compareResult = compareFunc(compareToValue.toString().toLocaleLowerCase(), valueObject.getValue().toString().toLocaleLowerCase());
|
|
4154
|
+
}
|
|
4155
|
+
if (searchType === ArrayBinarySearchType.MAX && (compareResult = -compareResult), compareResult === 0) {
|
|
4156
|
+
exactMatchIndex = middle;
|
|
4157
|
+
break;
|
|
4136
4158
|
}
|
|
4137
|
-
|
|
4138
|
-
return positionArray[middle];
|
|
4139
|
-
compare === -1 ? (start = middle + 1, searchType === ArrayBinarySearchType.MIN && (lastValue = middle)) : (end = middle - 1, searchType === ArrayBinarySearchType.MAX && (lastValue = middle));
|
|
4159
|
+
compareResult < 0 ? (nearestSmallerIndex = middle, start = middle + 1) : (nearestLargerIndex = middle, end = middle - 1);
|
|
4140
4160
|
}
|
|
4141
|
-
if (
|
|
4142
|
-
return positionArray[
|
|
4161
|
+
if (matchType === ArrayOrderSearchType.NORMAL)
|
|
4162
|
+
return exactMatchIndex !== -1 ? positionArray[exactMatchIndex] : void 0;
|
|
4163
|
+
if (matchType === ArrayOrderSearchType.MIN)
|
|
4164
|
+
return exactMatchIndex !== -1 ? positionArray[exactMatchIndex] : searchType === ArrayBinarySearchType.MIN ? positionArray[nearestSmallerIndex] : positionArray[nearestLargerIndex];
|
|
4165
|
+
if (matchType === ArrayOrderSearchType.MAX)
|
|
4166
|
+
return exactMatchIndex !== -1 ? positionArray[exactMatchIndex] : searchType === ArrayBinarySearchType.MIN ? positionArray[nearestLargerIndex] : positionArray[nearestSmallerIndex];
|
|
4143
4167
|
}
|
|
4144
4168
|
sum() {
|
|
4145
4169
|
let accumulatorAll = NumberValueObject.create(0);
|
|
@@ -5209,6 +5233,103 @@ function getR1C1Ref(index, absoluteRefType = AbsoluteRefType.ALL, isRow) {
|
|
|
5209
5233
|
__name(getR1C1Ref, "getR1C1Ref");
|
|
5210
5234
|
const functionArray = [];
|
|
5211
5235
|
var FUNCTION_NAMES_ARRAY = /* @__PURE__ */ ((FUNCTION_NAMES_ARRAY2) => FUNCTION_NAMES_ARRAY2)(FUNCTION_NAMES_ARRAY || {});
|
|
5236
|
+
const _CellReferenceObject = class _CellReferenceObject extends BaseReferenceObject {
|
|
5237
|
+
constructor(token) {
|
|
5238
|
+
super(token);
|
|
5239
|
+
const grid = deserializeRangeWithSheet(token);
|
|
5240
|
+
this.setForcedUnitIdDirect(grid.unitId), this.setForcedSheetName(grid.sheetName), this.setRangeData(grid.range);
|
|
5241
|
+
}
|
|
5242
|
+
isCell() {
|
|
5243
|
+
return !0;
|
|
5244
|
+
}
|
|
5245
|
+
unionBy(referenceObject) {
|
|
5246
|
+
if (!referenceObject.isCell())
|
|
5247
|
+
return ErrorValueObject.create(ErrorType$1.REF);
|
|
5248
|
+
const cellReferenceObject = referenceObject, newRangeData = this.unionRange(this.getRangeData(), cellReferenceObject.getRangeData());
|
|
5249
|
+
return this._createRange(newRangeData);
|
|
5250
|
+
}
|
|
5251
|
+
unionRange(rangeData1, rangeData2) {
|
|
5252
|
+
const startRow1 = rangeData1.startRow, startColumn1 = rangeData1.startColumn, startRow2 = rangeData2.startRow, startColumn2 = rangeData2.startColumn, range = {
|
|
5253
|
+
startRow: -1,
|
|
5254
|
+
startColumn: -1,
|
|
5255
|
+
endRow: -1,
|
|
5256
|
+
endColumn: -1
|
|
5257
|
+
};
|
|
5258
|
+
return startRow1 > startRow2 ? (range.startRow = startRow2, range.endRow = startRow1) : (range.startRow = startRow1, range.endRow = startRow2), startColumn1 > startColumn2 ? (range.startColumn = startColumn2, range.endColumn = startColumn1) : (range.startColumn = startColumn1, range.endColumn = startColumn2), rangeData1.startAbsoluteRefType && (range.startAbsoluteRefType = rangeData1.startAbsoluteRefType), rangeData2.startAbsoluteRefType && (range.endAbsoluteRefType = rangeData2.startAbsoluteRefType), range;
|
|
5259
|
+
}
|
|
5260
|
+
_createRange(newRangeData) {
|
|
5261
|
+
const rangeReferenceObject = new RangeReferenceObject(
|
|
5262
|
+
newRangeData,
|
|
5263
|
+
this.getForcedSheetId(),
|
|
5264
|
+
this.getForcedUnitId()
|
|
5265
|
+
);
|
|
5266
|
+
rangeReferenceObject.setUnitData(this.getUnitData()), rangeReferenceObject.setDefaultSheetId(this.getDefaultSheetId()), rangeReferenceObject.setDefaultUnitId(this.getDefaultUnitId()), rangeReferenceObject.setRuntimeData(this.getRuntimeData()), rangeReferenceObject.setUnitStylesData(this.getUnitStylesData()), rangeReferenceObject.setArrayFormulaCellData(this.getArrayFormulaCellData()), rangeReferenceObject.setRuntimeArrayFormulaCellData(this.getRuntimeArrayFormulaCellData()), rangeReferenceObject.setRuntimeFeatureCellData(this.getRuntimeFeatureCellData());
|
|
5267
|
+
const { x, y } = this.getRefOffset();
|
|
5268
|
+
rangeReferenceObject.setRefOffset(x, y);
|
|
5269
|
+
const forceSheetId = this.getForcedSheetId();
|
|
5270
|
+
rangeReferenceObject.setForcedSheetName(this.getForcedSheetName()), forceSheetId != null && rangeReferenceObject.setForcedSheetIdDirect(forceSheetId);
|
|
5271
|
+
const forcedUnitId = this.getForcedUnitId();
|
|
5272
|
+
return forcedUnitId && rangeReferenceObject.setForcedUnitIdDirect(forcedUnitId), rangeReferenceObject;
|
|
5273
|
+
}
|
|
5274
|
+
};
|
|
5275
|
+
__name(_CellReferenceObject, "CellReferenceObject");
|
|
5276
|
+
let CellReferenceObject = _CellReferenceObject;
|
|
5277
|
+
const _ColumnReferenceObject = class _ColumnReferenceObject extends BaseReferenceObject {
|
|
5278
|
+
constructor(token) {
|
|
5279
|
+
super(token);
|
|
5280
|
+
const grid = deserializeRangeWithSheet(token);
|
|
5281
|
+
this.setForcedUnitIdDirect(grid.unitId), this.setForcedSheetName(grid.sheetName);
|
|
5282
|
+
const range = {
|
|
5283
|
+
startColumn: grid.range.startColumn,
|
|
5284
|
+
startRow: Number.NaN,
|
|
5285
|
+
endColumn: -1,
|
|
5286
|
+
endRow: Number.NaN
|
|
5287
|
+
};
|
|
5288
|
+
this.setRangeData(range);
|
|
5289
|
+
}
|
|
5290
|
+
isColumn() {
|
|
5291
|
+
return !0;
|
|
5292
|
+
}
|
|
5293
|
+
unionBy(referenceObject) {
|
|
5294
|
+
if (!referenceObject.isColumn())
|
|
5295
|
+
return ErrorValueObject.create(ErrorType$1.REF);
|
|
5296
|
+
const columnReferenceObject = referenceObject;
|
|
5297
|
+
if (columnReferenceObject.getForcedSheetName() !== void 0 && columnReferenceObject.getForcedSheetName() !== "")
|
|
5298
|
+
return ErrorValueObject.create(ErrorType$1.REF);
|
|
5299
|
+
const currentRangeData = this.getRangeData(), newColumnRange = columnReferenceObject.getRangeData(), newColumn = newColumnRange.startColumn, column = currentRangeData.startColumn;
|
|
5300
|
+
return newColumn > column ? currentRangeData.endColumn = newColumn : (currentRangeData.startColumn = newColumn, currentRangeData.endColumn = column), newColumnRange.startAbsoluteRefType && (currentRangeData.endAbsoluteRefType = newColumnRange.startAbsoluteRefType), currentRangeData.rangeType = RANGE_TYPE.COLUMN, this.setToken(`${this.getToken()}${matchToken.COLON}${columnReferenceObject.getToken()}`), this;
|
|
5301
|
+
}
|
|
5302
|
+
};
|
|
5303
|
+
__name(_ColumnReferenceObject, "ColumnReferenceObject");
|
|
5304
|
+
let ColumnReferenceObject = _ColumnReferenceObject;
|
|
5305
|
+
const _RowReferenceObject = class _RowReferenceObject extends BaseReferenceObject {
|
|
5306
|
+
constructor(token) {
|
|
5307
|
+
super(token);
|
|
5308
|
+
const grid = deserializeRangeWithSheet(token);
|
|
5309
|
+
this.setForcedUnitIdDirect(grid.unitId), this.setForcedSheetName(grid.sheetName);
|
|
5310
|
+
const range = {
|
|
5311
|
+
startColumn: Number.NaN,
|
|
5312
|
+
startRow: grid.range.startRow,
|
|
5313
|
+
endColumn: Number.NaN,
|
|
5314
|
+
endRow: -1
|
|
5315
|
+
};
|
|
5316
|
+
this.setRangeData(range);
|
|
5317
|
+
}
|
|
5318
|
+
isRow() {
|
|
5319
|
+
return !0;
|
|
5320
|
+
}
|
|
5321
|
+
unionBy(referenceObject) {
|
|
5322
|
+
if (!referenceObject.isRow())
|
|
5323
|
+
return ErrorValueObject.create(ErrorType$1.REF);
|
|
5324
|
+
const rowReferenceObject = referenceObject;
|
|
5325
|
+
if (rowReferenceObject.getForcedSheetName() !== void 0 && rowReferenceObject.getForcedSheetName() !== "")
|
|
5326
|
+
return ErrorValueObject.create(ErrorType$1.REF);
|
|
5327
|
+
const currentRangeData = this.getRangeData(), newRowRange = rowReferenceObject.getRangeData(), newRow = newRowRange.startRow, row = currentRangeData.startRow;
|
|
5328
|
+
return newRow > row ? currentRangeData.endRow = newRow : (currentRangeData.startRow = newRow, currentRangeData.endRow = row), newRowRange.startAbsoluteRefType && (currentRangeData.endAbsoluteRefType = newRowRange.startAbsoluteRefType), currentRangeData.rangeType = RANGE_TYPE.ROW, this.setToken(`${this.getToken()}${matchToken.COLON}${rowReferenceObject.getToken()}`), this;
|
|
5329
|
+
}
|
|
5330
|
+
};
|
|
5331
|
+
__name(_RowReferenceObject, "RowReferenceObject");
|
|
5332
|
+
let RowReferenceObject = _RowReferenceObject;
|
|
5212
5333
|
function expandArrayValueObject(rowCount, columnCount, valueObject, defaultValue) {
|
|
5213
5334
|
const result = [];
|
|
5214
5335
|
if (valueObject.isArray()) {
|
|
@@ -5418,103 +5539,6 @@ function isSameValueObjectType(left, right) {
|
|
|
5418
5539
|
return !!((isLeftBlank || left.isNull()) && (isRightBlank || right.isNull()) || left.isString() && !isLeftBlank && right.isString() && !isRightBlank);
|
|
5419
5540
|
}
|
|
5420
5541
|
__name(isSameValueObjectType, "isSameValueObjectType");
|
|
5421
|
-
const _CellReferenceObject = class _CellReferenceObject extends BaseReferenceObject {
|
|
5422
|
-
constructor(token) {
|
|
5423
|
-
super(token);
|
|
5424
|
-
const grid = deserializeRangeWithSheet(token);
|
|
5425
|
-
this.setForcedUnitIdDirect(grid.unitId), this.setForcedSheetName(grid.sheetName), this.setRangeData(grid.range);
|
|
5426
|
-
}
|
|
5427
|
-
isCell() {
|
|
5428
|
-
return !0;
|
|
5429
|
-
}
|
|
5430
|
-
unionBy(referenceObject) {
|
|
5431
|
-
if (!referenceObject.isCell())
|
|
5432
|
-
return ErrorValueObject.create(ErrorType$1.REF);
|
|
5433
|
-
const cellReferenceObject = referenceObject, newRangeData = this.unionRange(this.getRangeData(), cellReferenceObject.getRangeData());
|
|
5434
|
-
return this._createRange(newRangeData);
|
|
5435
|
-
}
|
|
5436
|
-
unionRange(rangeData1, rangeData2) {
|
|
5437
|
-
const startRow1 = rangeData1.startRow, startColumn1 = rangeData1.startColumn, startRow2 = rangeData2.startRow, startColumn2 = rangeData2.startColumn, range = {
|
|
5438
|
-
startRow: -1,
|
|
5439
|
-
startColumn: -1,
|
|
5440
|
-
endRow: -1,
|
|
5441
|
-
endColumn: -1
|
|
5442
|
-
};
|
|
5443
|
-
return startRow1 > startRow2 ? (range.startRow = startRow2, range.endRow = startRow1) : (range.startRow = startRow1, range.endRow = startRow2), startColumn1 > startColumn2 ? (range.startColumn = startColumn2, range.endColumn = startColumn1) : (range.startColumn = startColumn1, range.endColumn = startColumn2), rangeData1.startAbsoluteRefType && (range.startAbsoluteRefType = rangeData1.startAbsoluteRefType), rangeData2.startAbsoluteRefType && (range.endAbsoluteRefType = rangeData2.startAbsoluteRefType), range;
|
|
5444
|
-
}
|
|
5445
|
-
_createRange(newRangeData) {
|
|
5446
|
-
const rangeReferenceObject = new RangeReferenceObject(
|
|
5447
|
-
newRangeData,
|
|
5448
|
-
this.getForcedSheetId(),
|
|
5449
|
-
this.getForcedUnitId()
|
|
5450
|
-
);
|
|
5451
|
-
rangeReferenceObject.setUnitData(this.getUnitData()), rangeReferenceObject.setDefaultSheetId(this.getDefaultSheetId()), rangeReferenceObject.setDefaultUnitId(this.getDefaultUnitId()), rangeReferenceObject.setRuntimeData(this.getRuntimeData()), rangeReferenceObject.setUnitStylesData(this.getUnitStylesData()), rangeReferenceObject.setArrayFormulaCellData(this.getArrayFormulaCellData()), rangeReferenceObject.setRuntimeArrayFormulaCellData(this.getRuntimeArrayFormulaCellData()), rangeReferenceObject.setRuntimeFeatureCellData(this.getRuntimeFeatureCellData());
|
|
5452
|
-
const { x, y } = this.getRefOffset();
|
|
5453
|
-
rangeReferenceObject.setRefOffset(x, y);
|
|
5454
|
-
const forceSheetId = this.getForcedSheetId();
|
|
5455
|
-
rangeReferenceObject.setForcedSheetName(this.getForcedSheetName()), forceSheetId != null && rangeReferenceObject.setForcedSheetIdDirect(forceSheetId);
|
|
5456
|
-
const forcedUnitId = this.getForcedUnitId();
|
|
5457
|
-
return forcedUnitId && rangeReferenceObject.setForcedUnitIdDirect(forcedUnitId), rangeReferenceObject;
|
|
5458
|
-
}
|
|
5459
|
-
};
|
|
5460
|
-
__name(_CellReferenceObject, "CellReferenceObject");
|
|
5461
|
-
let CellReferenceObject = _CellReferenceObject;
|
|
5462
|
-
const _RowReferenceObject = class _RowReferenceObject extends BaseReferenceObject {
|
|
5463
|
-
constructor(token) {
|
|
5464
|
-
super(token);
|
|
5465
|
-
const grid = deserializeRangeWithSheet(token);
|
|
5466
|
-
this.setForcedUnitIdDirect(grid.unitId), this.setForcedSheetName(grid.sheetName);
|
|
5467
|
-
const range = {
|
|
5468
|
-
startColumn: Number.NaN,
|
|
5469
|
-
startRow: grid.range.startRow,
|
|
5470
|
-
endColumn: Number.NaN,
|
|
5471
|
-
endRow: -1
|
|
5472
|
-
};
|
|
5473
|
-
this.setRangeData(range);
|
|
5474
|
-
}
|
|
5475
|
-
isRow() {
|
|
5476
|
-
return !0;
|
|
5477
|
-
}
|
|
5478
|
-
unionBy(referenceObject) {
|
|
5479
|
-
if (!referenceObject.isRow())
|
|
5480
|
-
return ErrorValueObject.create(ErrorType$1.REF);
|
|
5481
|
-
const rowReferenceObject = referenceObject;
|
|
5482
|
-
if (rowReferenceObject.getForcedSheetName() !== void 0 && rowReferenceObject.getForcedSheetName() !== "")
|
|
5483
|
-
return ErrorValueObject.create(ErrorType$1.REF);
|
|
5484
|
-
const currentRangeData = this.getRangeData(), newRowRange = rowReferenceObject.getRangeData(), newRow = newRowRange.startRow, row = currentRangeData.startRow;
|
|
5485
|
-
return newRow > row ? currentRangeData.endRow = newRow : (currentRangeData.startRow = newRow, currentRangeData.endRow = row), newRowRange.startAbsoluteRefType && (currentRangeData.endAbsoluteRefType = newRowRange.startAbsoluteRefType), currentRangeData.rangeType = RANGE_TYPE.ROW, this.setToken(`${this.getToken()}${matchToken.COLON}${rowReferenceObject.getToken()}`), this;
|
|
5486
|
-
}
|
|
5487
|
-
};
|
|
5488
|
-
__name(_RowReferenceObject, "RowReferenceObject");
|
|
5489
|
-
let RowReferenceObject = _RowReferenceObject;
|
|
5490
|
-
const _ColumnReferenceObject = class _ColumnReferenceObject extends BaseReferenceObject {
|
|
5491
|
-
constructor(token) {
|
|
5492
|
-
super(token);
|
|
5493
|
-
const grid = deserializeRangeWithSheet(token);
|
|
5494
|
-
this.setForcedUnitIdDirect(grid.unitId), this.setForcedSheetName(grid.sheetName);
|
|
5495
|
-
const range = {
|
|
5496
|
-
startColumn: grid.range.startColumn,
|
|
5497
|
-
startRow: Number.NaN,
|
|
5498
|
-
endColumn: -1,
|
|
5499
|
-
endRow: Number.NaN
|
|
5500
|
-
};
|
|
5501
|
-
this.setRangeData(range);
|
|
5502
|
-
}
|
|
5503
|
-
isColumn() {
|
|
5504
|
-
return !0;
|
|
5505
|
-
}
|
|
5506
|
-
unionBy(referenceObject) {
|
|
5507
|
-
if (!referenceObject.isColumn())
|
|
5508
|
-
return ErrorValueObject.create(ErrorType$1.REF);
|
|
5509
|
-
const columnReferenceObject = referenceObject;
|
|
5510
|
-
if (columnReferenceObject.getForcedSheetName() !== void 0 && columnReferenceObject.getForcedSheetName() !== "")
|
|
5511
|
-
return ErrorValueObject.create(ErrorType$1.REF);
|
|
5512
|
-
const currentRangeData = this.getRangeData(), newColumnRange = columnReferenceObject.getRangeData(), newColumn = newColumnRange.startColumn, column = currentRangeData.startColumn;
|
|
5513
|
-
return newColumn > column ? currentRangeData.endColumn = newColumn : (currentRangeData.startColumn = newColumn, currentRangeData.endColumn = column), newColumnRange.startAbsoluteRefType && (currentRangeData.endAbsoluteRefType = newColumnRange.startAbsoluteRefType), currentRangeData.rangeType = RANGE_TYPE.COLUMN, this.setToken(`${this.getToken()}${matchToken.COLON}${columnReferenceObject.getToken()}`), this;
|
|
5514
|
-
}
|
|
5515
|
-
};
|
|
5516
|
-
__name(_ColumnReferenceObject, "ColumnReferenceObject");
|
|
5517
|
-
let ColumnReferenceObject = _ColumnReferenceObject;
|
|
5518
5542
|
const _BaseFunction = class _BaseFunction extends Disposable {
|
|
5519
5543
|
constructor(_name) {
|
|
5520
5544
|
super();
|
|
@@ -5654,8 +5678,8 @@ const _BaseFunction = class _BaseFunction extends Disposable {
|
|
|
5654
5678
|
}
|
|
5655
5679
|
return logicValue;
|
|
5656
5680
|
}
|
|
5657
|
-
binarySearch(value, searchArray, resultArray, searchType) {
|
|
5658
|
-
const rowOrColumn = searchArray.binarySearch(value, searchType);
|
|
5681
|
+
binarySearch(value, searchArray, resultArray, searchType, matchType) {
|
|
5682
|
+
const rowOrColumn = searchArray.binarySearch(value, searchType, matchType);
|
|
5659
5683
|
if (rowOrColumn == null)
|
|
5660
5684
|
return ErrorValueObject.create(ErrorType$1.NA);
|
|
5661
5685
|
let resultValue;
|
|
@@ -5682,8 +5706,8 @@ const _BaseFunction = class _BaseFunction extends Disposable {
|
|
|
5682
5706
|
const resultValue = resultArray.get(position.row, position.column) || NullValueObject.create();
|
|
5683
5707
|
return resultValue.isNull() ? ErrorValueObject.create(ErrorType$1.NA) : resultValue;
|
|
5684
5708
|
}
|
|
5685
|
-
binarySearchExpand(value, searchArray, resultArray, axis = 0, searchType) {
|
|
5686
|
-
const rowOrColumn = searchArray.binarySearch(value, searchType);
|
|
5709
|
+
binarySearchExpand(value, searchArray, resultArray, axis = 0, searchType, matchType) {
|
|
5710
|
+
const rowOrColumn = searchArray.binarySearch(value, searchType, matchType);
|
|
5687
5711
|
return rowOrColumn == null ? ErrorValueObject.create(ErrorType$1.NA) : axis === 0 ? resultArray.slice([rowOrColumn, rowOrColumn + 1]) : resultArray.slice(void 0, [rowOrColumn, rowOrColumn + 1]);
|
|
5688
5712
|
}
|
|
5689
5713
|
equalSearchExpand(value, searchArray, resultArray, isFirst = !0, axis = 0) {
|
|
@@ -5751,32 +5775,1281 @@ const _CustomFunction = class _CustomFunction extends BaseFunction {
|
|
|
5751
5775
|
};
|
|
5752
5776
|
__name(_CustomFunction, "CustomFunction");
|
|
5753
5777
|
let CustomFunction = _CustomFunction;
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
return flattenArray.isError() ? flattenArray : flattenArray.std();
|
|
5763
|
-
}
|
|
5764
|
-
};
|
|
5765
|
-
__name(_StdevP, "StdevP");
|
|
5766
|
-
let StdevP = _StdevP;
|
|
5767
|
-
const _StdevS = class _StdevS extends BaseFunction {
|
|
5768
|
-
constructor() {
|
|
5769
|
-
super(...arguments);
|
|
5770
|
-
__publicField(this, "minParams", 1);
|
|
5771
|
-
__publicField(this, "maxParams", 255);
|
|
5778
|
+
var BESSEL;
|
|
5779
|
+
((BESSEL2) => {
|
|
5780
|
+
const W = 0.636619772;
|
|
5781
|
+
function _horner(arr, v) {
|
|
5782
|
+
let z = 0;
|
|
5783
|
+
for (let i = 0; i < arr.length; ++i)
|
|
5784
|
+
z = v * z + arr[i];
|
|
5785
|
+
return z;
|
|
5772
5786
|
}
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5787
|
+
__name(_horner, "_horner");
|
|
5788
|
+
function _bessel_iter(x, n, f0, f1, sign2) {
|
|
5789
|
+
if (n === 0)
|
|
5790
|
+
return f0;
|
|
5791
|
+
if (n === 1)
|
|
5792
|
+
return f1;
|
|
5793
|
+
const tdx = 2 / x;
|
|
5794
|
+
let _f0 = f0, _f1 = f1, f2 = f1;
|
|
5795
|
+
for (let o = 1; o < n; ++o)
|
|
5796
|
+
f2 = _f1 * o * tdx + sign2 * _f0, _f0 = _f1, _f1 = f2;
|
|
5797
|
+
return f2;
|
|
5776
5798
|
}
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5799
|
+
__name(_bessel_iter, "_bessel_iter");
|
|
5800
|
+
function _bessel_wrap(bessel0, bessel1, nonzero, sign2) {
|
|
5801
|
+
return /* @__PURE__ */ __name(function(x, n) {
|
|
5802
|
+
if (nonzero) {
|
|
5803
|
+
if (x === 0)
|
|
5804
|
+
return nonzero === 1 ? -1 / 0 : 1 / 0;
|
|
5805
|
+
if (x < 0)
|
|
5806
|
+
return Number.NaN;
|
|
5807
|
+
}
|
|
5808
|
+
if (n === 0)
|
|
5809
|
+
return bessel0(x);
|
|
5810
|
+
if (n === 1)
|
|
5811
|
+
return bessel1(x);
|
|
5812
|
+
if (n < 0)
|
|
5813
|
+
return Number.NaN;
|
|
5814
|
+
const _n = n | 0, b0 = bessel0(x), b1 = bessel1(x);
|
|
5815
|
+
return _bessel_iter(x, _n, b0, b1, sign2);
|
|
5816
|
+
}, "bessel");
|
|
5817
|
+
}
|
|
5818
|
+
__name(_bessel_wrap, "_bessel_wrap"), BESSEL2.besselj = /* @__PURE__ */ (() => {
|
|
5819
|
+
const b0_a1a = [-184.9052456, 77392.33017, -1121442418e-2, 6516196407e-1, -13362590354, 57568490574], b0_a2a = [1, 267.8532712, 59272.64853, 9494680718e-3, 1029532985, 57568490411], b0_a1b = [2093887211e-16, -2073370639e-15, 2734510407e-14, -0.001098628627, 1], b0_a2b = [-934935152e-16, 7621095161e-16, -6911147651e-15, 1430488765e-13, -0.01562499995];
|
|
5820
|
+
function bessel0(x) {
|
|
5821
|
+
let a = 0, a1 = 0, a2 = 0, y = x * x;
|
|
5822
|
+
if (x < 8)
|
|
5823
|
+
a1 = _horner(b0_a1a, y), a2 = _horner(b0_a2a, y), a = a1 / a2;
|
|
5824
|
+
else {
|
|
5825
|
+
const xx = x - 0.785398164;
|
|
5826
|
+
y = 64 / y, a1 = _horner(b0_a1b, y), a2 = _horner(b0_a2b, y), a = Math.sqrt(W / x) * (Math.cos(xx) * a1 - Math.sin(xx) * a2 * 8 / x);
|
|
5827
|
+
}
|
|
5828
|
+
return a;
|
|
5829
|
+
}
|
|
5830
|
+
__name(bessel0, "bessel0");
|
|
5831
|
+
const b1_a1a = [-30.16036606, 15704.4826, -2972611439e-3, 2423968531e-1, -7895059235, 72362614232], b1_a2a = [1, 376.9991397, 99447.43394, 1858330474e-2, 2300535178, 144725228442], b1_a1b = [-240337019e-15, 2457520174e-15, -3516396496e-14, 183105e-8, 1], b1_a2b = [105787412e-15, -88228987e-14, 8449199096e-15, -2002690873e-13, 0.04687499995];
|
|
5832
|
+
function bessel1(x) {
|
|
5833
|
+
let a = 0, a1 = 0, a2 = 0, y = x * x;
|
|
5834
|
+
const xx = Math.abs(x) - 2.356194491;
|
|
5835
|
+
return Math.abs(x) < 8 ? (a1 = x * _horner(b1_a1a, y), a2 = _horner(b1_a2a, y), a = a1 / a2) : (y = 64 / y, a1 = _horner(b1_a1b, y), a2 = _horner(b1_a2b, y), a = Math.sqrt(W / Math.abs(x)) * (Math.cos(xx) * a1 - Math.sin(xx) * a2 * 8 / Math.abs(x)), x < 0 && (a = -a)), a;
|
|
5836
|
+
}
|
|
5837
|
+
return __name(bessel1, "bessel1"), /* @__PURE__ */ __name(function besselj2(x, n) {
|
|
5838
|
+
const _n = Math.round(n);
|
|
5839
|
+
if (!Number.isFinite(x))
|
|
5840
|
+
return Number.isNaN(x) ? x : 0;
|
|
5841
|
+
if (_n < 0)
|
|
5842
|
+
return (_n % 2 ? -1 : 1) * besselj2(x, -_n);
|
|
5843
|
+
if (x < 0)
|
|
5844
|
+
return (_n % 2 ? -1 : 1) * besselj2(-x, _n);
|
|
5845
|
+
if (_n === 0)
|
|
5846
|
+
return bessel0(x);
|
|
5847
|
+
if (_n === 1)
|
|
5848
|
+
return bessel1(x);
|
|
5849
|
+
if (x === 0)
|
|
5850
|
+
return 0;
|
|
5851
|
+
let ret = 0;
|
|
5852
|
+
if (x > _n)
|
|
5853
|
+
ret = _bessel_iter(x, _n, bessel0(x), bessel1(x), -1);
|
|
5854
|
+
else {
|
|
5855
|
+
const m = 2 * Math.floor((_n + Math.floor(Math.sqrt(40 * _n))) / 2);
|
|
5856
|
+
let jsum = !1, bjp = 0, sum2 = 0, bj = 1, bjm = 0;
|
|
5857
|
+
const tox = 2 / x;
|
|
5858
|
+
for (let j = m; j > 0; j--)
|
|
5859
|
+
if (bjm = j * tox * bj - bjp, bjp = bj, bj = bjm, Math.abs(bj) > 1e10 && (bj *= 1e-10, bjp *= 1e-10, ret *= 1e-10, sum2 *= 1e-10), jsum && (sum2 += bj), jsum = !jsum, j === _n && (ret = bjp), m - j > 100 && ret === 0)
|
|
5860
|
+
return Number.NaN;
|
|
5861
|
+
sum2 = 2 * sum2 - bj, ret /= sum2;
|
|
5862
|
+
}
|
|
5863
|
+
return ret;
|
|
5864
|
+
}, "besselj2");
|
|
5865
|
+
})(), BESSEL2.bessely = (() => {
|
|
5866
|
+
const b0_a1a = [228.4622733, -86327.92757, 1087988129e-2, -5123598036e-1, 7062834065, -2957821389], b0_a2a = [1, 226.1030244, 47447.2647, 7189466438e-3, 7452499648e-1, 40076544269], b0_a1b = [2093887211e-16, -2073370639e-15, 2734510407e-14, -0.001098628627, 1], b0_a2b = [-934945152e-16, 7621095161e-16, -6911147651e-15, 1430488765e-13, -0.01562499995];
|
|
5867
|
+
function bessel0(x) {
|
|
5868
|
+
let a = 0, a1 = 0, a2 = 0, y = x * x;
|
|
5869
|
+
const xx = x - 0.785398164;
|
|
5870
|
+
return x < 8 ? (a1 = _horner(b0_a1a, y), a2 = _horner(b0_a2a, y), a = a1 / a2 + W * (0, BESSEL2.besselj)(x, 0) * Math.log(x)) : (y = 64 / y, a1 = _horner(b0_a1b, y), a2 = _horner(b0_a2b, y), a = Math.sqrt(W / x) * (Math.sin(xx) * a1 + Math.cos(xx) * a2 * 8 / x)), a;
|
|
5871
|
+
}
|
|
5872
|
+
__name(bessel0, "bessel0");
|
|
5873
|
+
const b1_a1a = [8511.937935, -4237922726e-3, 7349264551e-1, -51534381390, 127527439e4, -4900604943e3], b1_a2a = [1, 354.9632885, 102042.605, 2245904002e-2, 3733650367, 424441966400, 249958057e5], b1_a1b = [-240337019e-15, 2457520174e-15, -3516396496e-14, 183105e-8, 1], b1_a2b = [105787412e-15, -88228987e-14, 8449199096e-15, -2002690873e-13, 0.04687499995];
|
|
5874
|
+
function bessel1(x) {
|
|
5875
|
+
let a = 0, a1 = 0, a2 = 0, y = x * x;
|
|
5876
|
+
const xx = x - 2.356194491;
|
|
5877
|
+
return x < 8 ? (a1 = x * _horner(b1_a1a, y), a2 = _horner(b1_a2a, y), a = a1 / a2 + W * ((0, BESSEL2.besselj)(x, 1) * Math.log(x) - 1 / x)) : (y = 64 / y, a1 = _horner(b1_a1b, y), a2 = _horner(b1_a2b, y), a = Math.sqrt(W / x) * (Math.sin(xx) * a1 + Math.cos(xx) * a2 * 8 / x)), a;
|
|
5878
|
+
}
|
|
5879
|
+
return __name(bessel1, "bessel1"), _bessel_wrap(bessel0, bessel1, 1, -1);
|
|
5880
|
+
})(), BESSEL2.besseli = /* @__PURE__ */ (() => {
|
|
5881
|
+
const b0_a = [45813e-7, 0.0360768, 0.2659732, 1.2067492, 3.0899424, 3.5156229, 1], b0_b = [392377e-8, -0.01647633, 0.02635537, -0.02057706, 916281e-8, -157565e-8, 225319e-8, 0.01328592, 0.39894228];
|
|
5882
|
+
function bessel0(x) {
|
|
5883
|
+
return x <= 3.75 ? _horner(b0_a, x * x / (3.75 * 3.75)) : Math.exp(Math.abs(x)) / Math.sqrt(Math.abs(x)) * _horner(b0_b, 3.75 / Math.abs(x));
|
|
5884
|
+
}
|
|
5885
|
+
__name(bessel0, "bessel0");
|
|
5886
|
+
const b1_a = [32411e-8, 301532e-8, 0.02658733, 0.15084934, 0.51498869, 0.87890594, 0.5], b1_b = [-420059e-8, 0.01787654, -0.02895312, 0.02282967, -0.01031555, 163801e-8, -362018e-8, -0.03988024, 0.39894228];
|
|
5887
|
+
function bessel1(x) {
|
|
5888
|
+
return x < 3.75 ? x * _horner(b1_a, x * x / (3.75 * 3.75)) : (x < 0 ? -1 : 1) * Math.exp(Math.abs(x)) / Math.sqrt(Math.abs(x)) * _horner(b1_b, 3.75 / Math.abs(x));
|
|
5889
|
+
}
|
|
5890
|
+
return __name(bessel1, "bessel1"), /* @__PURE__ */ __name(function besseli2(x, n) {
|
|
5891
|
+
const _n = Math.round(n);
|
|
5892
|
+
if (_n === 0)
|
|
5893
|
+
return bessel0(x);
|
|
5894
|
+
if (_n === 1)
|
|
5895
|
+
return bessel1(x);
|
|
5896
|
+
if (_n < 0)
|
|
5897
|
+
return Number.NaN;
|
|
5898
|
+
if (Math.abs(x) === 0)
|
|
5899
|
+
return 0;
|
|
5900
|
+
if (x === 1 / 0)
|
|
5901
|
+
return 1 / 0;
|
|
5902
|
+
let ret = 0, j;
|
|
5903
|
+
const tox = 2 / Math.abs(x);
|
|
5904
|
+
let bip = 0, bi = 1, bim = 0;
|
|
5905
|
+
const m = 2 * Math.round((_n + Math.round(Math.sqrt(40 * _n))) / 2);
|
|
5906
|
+
for (j = m; j > 0; j--)
|
|
5907
|
+
if (bim = j * tox * bi + bip, bip = bi, bi = bim, Math.abs(bi) > 1e10 && (bi *= 1e-10, bip *= 1e-10, ret *= 1e-10), j === _n && (ret = bip), m - j > 100 && ret === 0)
|
|
5908
|
+
return Number.NaN;
|
|
5909
|
+
return ret *= besseli2(x, 0) / bi, x < 0 && _n % 2 ? -ret : ret;
|
|
5910
|
+
}, "besseli2");
|
|
5911
|
+
})(), BESSEL2.besselk = (() => {
|
|
5912
|
+
const b0_a = [74e-7, 1075e-7, 262698e-8, 0.0348859, 0.23069756, 0.4227842, -0.57721566], b0_b = [53208e-8, -25154e-7, 587872e-8, -0.01062446, 0.02189568, -0.07832358, 1.25331414];
|
|
5913
|
+
function bessel0(x) {
|
|
5914
|
+
return x <= 2 ? -Math.log(x / 2) * (0, BESSEL2.besseli)(x, 0) + _horner(b0_a, x * x / 4) : Math.exp(-x) / Math.sqrt(x) * _horner(b0_b, 2 / x);
|
|
5915
|
+
}
|
|
5916
|
+
__name(bessel0, "bessel0");
|
|
5917
|
+
const b1_a = [-4686e-8, -110404e-8, -0.01919402, -0.18156897, -0.67278579, 0.15443144, 1], b1_b = [-68245e-8, 325614e-8, -780353e-8, 0.01504268, -0.0365562, 0.23498619, 1.25331414];
|
|
5918
|
+
function bessel1(x) {
|
|
5919
|
+
return x <= 2 ? Math.log(x / 2) * (0, BESSEL2.besseli)(x, 1) + 1 / x * _horner(b1_a, x * x / 4) : Math.exp(-x) / Math.sqrt(x) * _horner(b1_b, 2 / x);
|
|
5920
|
+
}
|
|
5921
|
+
return __name(bessel1, "bessel1"), _bessel_wrap(bessel0, bessel1, 2, 1);
|
|
5922
|
+
})();
|
|
5923
|
+
})(BESSEL || (BESSEL = {}));
|
|
5924
|
+
function isValidBinaryNumber(number) {
|
|
5925
|
+
return /^[01]{1,10}$/.test(number);
|
|
5926
|
+
}
|
|
5927
|
+
__name(isValidBinaryNumber, "isValidBinaryNumber");
|
|
5928
|
+
function isValidOctalNumber(number) {
|
|
5929
|
+
return /^[0-7]{1,10}$/.test(number);
|
|
5930
|
+
}
|
|
5931
|
+
__name(isValidOctalNumber, "isValidOctalNumber");
|
|
5932
|
+
function isValidHexadecimalNumber(number) {
|
|
5933
|
+
return /^[0-9A-Fa-f]{1,10}$/.test(number);
|
|
5934
|
+
}
|
|
5935
|
+
__name(isValidHexadecimalNumber, "isValidHexadecimalNumber");
|
|
5936
|
+
function erf(x) {
|
|
5937
|
+
if (x === 0)
|
|
5938
|
+
return 0;
|
|
5939
|
+
const cof = [
|
|
5940
|
+
-1.3026537197817094,
|
|
5941
|
+
0.6419697923564902,
|
|
5942
|
+
0.019476473204185836,
|
|
5943
|
+
-0.00956151478680863,
|
|
5944
|
+
-946595344482036e-18,
|
|
5945
|
+
366839497852761e-18,
|
|
5946
|
+
42523324806907e-18,
|
|
5947
|
+
-20278578112534e-18,
|
|
5948
|
+
-1624290004647e-18,
|
|
5949
|
+
130365583558e-17,
|
|
5950
|
+
15626441722e-18,
|
|
5951
|
+
-85238095915e-18,
|
|
5952
|
+
6529054439e-18,
|
|
5953
|
+
5059343495e-18,
|
|
5954
|
+
-991364156e-18,
|
|
5955
|
+
-227365122e-18,
|
|
5956
|
+
96467911e-18,
|
|
5957
|
+
2394038e-18,
|
|
5958
|
+
-6886027e-18,
|
|
5959
|
+
894487e-18,
|
|
5960
|
+
313092e-18,
|
|
5961
|
+
-112708e-18,
|
|
5962
|
+
381e-18,
|
|
5963
|
+
7106e-18,
|
|
5964
|
+
-1523e-18,
|
|
5965
|
+
-94e-18,
|
|
5966
|
+
121e-18,
|
|
5967
|
+
-28e-18
|
|
5968
|
+
];
|
|
5969
|
+
let _x = x, isNeg = !1;
|
|
5970
|
+
_x < 0 && (_x = -_x, isNeg = !0);
|
|
5971
|
+
const t = 2 / (2 + _x), ty = 4 * t - 2;
|
|
5972
|
+
let d = 0, dd = 0, tmp;
|
|
5973
|
+
for (let j = cof.length - 1; j > 0; j--)
|
|
5974
|
+
tmp = d, d = ty * d - dd + cof[j], dd = tmp;
|
|
5975
|
+
const res = t * Math.exp(-_x * _x + 0.5 * (cof[0] + ty * d) - dd);
|
|
5976
|
+
return isNeg ? res - 1 : 1 - res;
|
|
5977
|
+
}
|
|
5978
|
+
__name(erf, "erf");
|
|
5979
|
+
function erfc(x) {
|
|
5980
|
+
return 1 - erf(x);
|
|
5981
|
+
}
|
|
5982
|
+
__name(erfc, "erfc");
|
|
5983
|
+
function erfcINV(p) {
|
|
5984
|
+
if (p >= 2)
|
|
5985
|
+
return -100;
|
|
5986
|
+
if (p <= 0)
|
|
5987
|
+
return 100;
|
|
5988
|
+
const _p = p < 1 ? p : 2 - p, temp = Math.sqrt(-2 * Math.log(_p / 2));
|
|
5989
|
+
let x = -0.70711 * ((2.30753 + temp * 0.27061) / (1 + temp * (0.99229 + temp * 0.04481)) - temp);
|
|
5990
|
+
for (let j = 0; j < 2; j++) {
|
|
5991
|
+
const err = erfc(x) - _p;
|
|
5992
|
+
x += err / (1.1283791670955126 * Math.exp(-x * x) - x * err);
|
|
5993
|
+
}
|
|
5994
|
+
return p < 1 ? x : -x;
|
|
5995
|
+
}
|
|
5996
|
+
__name(erfcINV, "erfcINV");
|
|
5997
|
+
function calculateFactorial(n, step = 1) {
|
|
5998
|
+
let _n = Math.floor(n);
|
|
5999
|
+
if (n < 0)
|
|
6000
|
+
return Number.NaN;
|
|
6001
|
+
let result = 1;
|
|
6002
|
+
for (; _n > 1 && Number.isFinite(result); )
|
|
6003
|
+
result *= _n, _n -= step;
|
|
6004
|
+
return result;
|
|
6005
|
+
}
|
|
6006
|
+
__name(calculateFactorial, "calculateFactorial");
|
|
6007
|
+
function calculateCombin(n, k) {
|
|
6008
|
+
const t = Math.min(n - k, k);
|
|
6009
|
+
let result = 1;
|
|
6010
|
+
for (let i = 1; i <= t && Number.isFinite(result); i++)
|
|
6011
|
+
result *= n - i + 1, result /= i;
|
|
6012
|
+
return result;
|
|
6013
|
+
}
|
|
6014
|
+
__name(calculateCombin, "calculateCombin");
|
|
6015
|
+
function calculateGcd(a, b) {
|
|
6016
|
+
let _a26 = Math.floor(a), _b = Math.floor(b);
|
|
6017
|
+
for (; _b !== 0; ) {
|
|
6018
|
+
const t = _b;
|
|
6019
|
+
_b = _a26 % _b, _a26 = t;
|
|
6020
|
+
}
|
|
6021
|
+
return _a26;
|
|
6022
|
+
}
|
|
6023
|
+
__name(calculateGcd, "calculateGcd");
|
|
6024
|
+
function calculateLcm(a, b) {
|
|
6025
|
+
const den = calculateGcd(a, b);
|
|
6026
|
+
return den === 0 ? 0 : Math.abs(a * b) / den;
|
|
6027
|
+
}
|
|
6028
|
+
__name(calculateLcm, "calculateLcm");
|
|
6029
|
+
function calculateMdeterm(matrix) {
|
|
6030
|
+
const n = matrix.length;
|
|
6031
|
+
if (n === 1)
|
|
6032
|
+
return matrix[0][0];
|
|
6033
|
+
if (n === 2)
|
|
6034
|
+
return matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0];
|
|
6035
|
+
let det = 0;
|
|
6036
|
+
for (let col = 0; col < n; col++)
|
|
6037
|
+
det += (col % 2 === 0 ? 1 : -1) * matrix[0][col] * calculateMdeterm(minor(matrix, 0, col));
|
|
6038
|
+
return det;
|
|
6039
|
+
}
|
|
6040
|
+
__name(calculateMdeterm, "calculateMdeterm");
|
|
6041
|
+
function calculateMinverse(matrix) {
|
|
6042
|
+
const det = calculateMdeterm(matrix);
|
|
6043
|
+
return det === 0 ? null : matrix.length === 1 ? [[1 / det]] : adjoint(matrix).map((row) => row.map((value) => value / det));
|
|
6044
|
+
}
|
|
6045
|
+
__name(calculateMinverse, "calculateMinverse");
|
|
6046
|
+
function minor(matrix, row, col) {
|
|
6047
|
+
return matrix.filter((_, r) => r !== row).map((row2) => row2.filter((_, c) => c !== col));
|
|
6048
|
+
}
|
|
6049
|
+
__name(minor, "minor");
|
|
6050
|
+
function adjoint(matrix) {
|
|
6051
|
+
const n = matrix.length, adj = Array.from({ length: n }, () => new Array(n).fill(0));
|
|
6052
|
+
for (let i = 0; i < n; i++)
|
|
6053
|
+
for (let j = 0; j < n; j++) {
|
|
6054
|
+
const sign2 = (i + j) % 2 === 0 ? 1 : -1;
|
|
6055
|
+
adj[j][i] = sign2 * calculateMdeterm(minor(matrix, i, j));
|
|
6056
|
+
}
|
|
6057
|
+
return adj;
|
|
6058
|
+
}
|
|
6059
|
+
__name(adjoint, "adjoint");
|
|
6060
|
+
function betaCDF(x, alpha, beta) {
|
|
6061
|
+
return x <= 0 ? 0 : x >= 1 ? 1 : incompleteBetaFunction(x, alpha, beta);
|
|
6062
|
+
}
|
|
6063
|
+
__name(betaCDF, "betaCDF");
|
|
6064
|
+
function betaPDF(x, alpha, beta) {
|
|
6065
|
+
return x <= 0 || x >= 1 ? 0 : alpha === 1 && beta === 1 ? 1 : alpha < 512 && beta < 512 ? x ** (alpha - 1) * (1 - x) ** (beta - 1) / betaFunction(alpha, beta) : Math.exp((alpha - 1) * Math.log(x) + (beta - 1) * Math.log(1 - x) - betaFunctionNaturalLogarithm(alpha, beta));
|
|
6066
|
+
}
|
|
6067
|
+
__name(betaPDF, "betaPDF");
|
|
6068
|
+
function betaINV(probability, alpha, beta) {
|
|
6069
|
+
if (probability <= 0)
|
|
6070
|
+
return 0;
|
|
6071
|
+
if (probability >= 1)
|
|
6072
|
+
return 1;
|
|
6073
|
+
const EPSILON = 1e-8;
|
|
6074
|
+
let x;
|
|
6075
|
+
if (alpha >= 1 && beta >= 1) {
|
|
6076
|
+
const p = probability < 0.5 ? probability : 1 - probability, temp = Math.sqrt(-2 * Math.log(p));
|
|
6077
|
+
x = (2.30753 + temp * 0.27061) / (1 + temp * (0.99229 + temp * 0.04481)) - temp, probability < 0.5 && (x = -x);
|
|
6078
|
+
const temp1 = (x * x - 3) / 6, temp2 = 2 / (1 / (2 * alpha - 1) + 1 / (2 * beta - 1)), temp3 = x * Math.sqrt(temp1 + temp2) / temp2 - (1 / (2 * beta - 1) - 1 / (2 * alpha - 1)) * (temp1 + 5 / 6 - 2 / (3 * temp2));
|
|
6079
|
+
x = alpha / (alpha + beta * Math.exp(2 * temp3));
|
|
6080
|
+
} else {
|
|
6081
|
+
const temp1 = Math.exp(alpha * Math.log(alpha / (alpha + beta))) / alpha, temp2 = Math.exp(beta * Math.log(beta / (alpha + beta))) / beta, temp3 = temp1 + temp2;
|
|
6082
|
+
probability < temp1 / temp3 ? x = (alpha * temp3 * probability) ** (1 / alpha) : x = 1 - (beta * temp3 * (1 - probability)) ** (1 / beta);
|
|
6083
|
+
}
|
|
6084
|
+
const betalnNeg = -betaFunctionNaturalLogarithm(alpha, beta);
|
|
6085
|
+
let ibeta, t, u;
|
|
6086
|
+
for (let j = 0; j < 10; j++) {
|
|
6087
|
+
if (x === 0 || x === 1)
|
|
6088
|
+
return x;
|
|
6089
|
+
if (ibeta = incompleteBetaFunction(x, alpha, beta) - probability, t = Math.exp((alpha - 1) * Math.log(x) + (beta - 1) * Math.log(1 - x) + betalnNeg), u = ibeta / t, x -= t = u / (1 - 0.5 * Math.min(1, u * ((alpha - 1) / x - (beta - 1) / (1 - x)))), x <= 0 && (x = 0.5 * (x + t)), x >= 1 && (x = 0.5 * (x + t + 1)), Math.abs(t) < EPSILON * x && j > 0)
|
|
6090
|
+
break;
|
|
6091
|
+
}
|
|
6092
|
+
return x;
|
|
6093
|
+
}
|
|
6094
|
+
__name(betaINV, "betaINV");
|
|
6095
|
+
function incompleteBetaFunction(x, alpha, beta) {
|
|
6096
|
+
const bt = x === 0 || x === 1 ? 0 : Math.exp(logGamma(alpha + beta) - logGamma(alpha) - logGamma(beta) + alpha * Math.log(x) + beta * Math.log(1 - x));
|
|
6097
|
+
return x < (alpha + 1) / (alpha + beta + 2) ? bt * betaContinuedFraction(x, alpha, beta) / alpha : 1 - bt * betaContinuedFraction(1 - x, beta, alpha) / beta;
|
|
6098
|
+
}
|
|
6099
|
+
__name(incompleteBetaFunction, "incompleteBetaFunction");
|
|
6100
|
+
function betaContinuedFraction(x, alpha, beta) {
|
|
6101
|
+
let d = 1 - (alpha + beta) * x / (alpha + 1);
|
|
6102
|
+
Math.abs(d) < 1e-8 && (d = 1e-8), d = 1 / d;
|
|
6103
|
+
let c = 1, h = d;
|
|
6104
|
+
for (let m = 1; m <= 100; m++) {
|
|
6105
|
+
let temp = m * (beta - m) * x / ((alpha - 1 + m * 2) * (alpha + m * 2));
|
|
6106
|
+
if (d = 1 + temp * d, Math.abs(d) < 1e-8 && (d = 1e-8), c = 1 + temp / c, Math.abs(c) < 1e-8 && (c = 1e-8), d = 1 / d, h *= d * c, temp = -(alpha + m) * (alpha + beta + m) * x / ((alpha + m * 2) * (alpha + 1 + m * 2)), d = 1 + temp * d, Math.abs(d) < 1e-8 && (d = 1e-8), c = 1 + temp / c, Math.abs(c) < 1e-8 && (c = 1e-8), d = 1 / d, h *= d * c, Math.abs(d * c - 1) < 1e-8)
|
|
6107
|
+
break;
|
|
6108
|
+
}
|
|
6109
|
+
return h;
|
|
6110
|
+
}
|
|
6111
|
+
__name(betaContinuedFraction, "betaContinuedFraction");
|
|
6112
|
+
function betaFunction(alpha, beta) {
|
|
6113
|
+
return alpha + beta > 170 ? Math.exp(betaFunctionNaturalLogarithm(alpha, beta)) : gammaFunction(alpha) * gammaFunction(beta) / gammaFunction(alpha + beta);
|
|
6114
|
+
}
|
|
6115
|
+
__name(betaFunction, "betaFunction");
|
|
6116
|
+
function betaFunctionNaturalLogarithm(alpha, beta) {
|
|
6117
|
+
return logGamma(alpha) + logGamma(beta) - logGamma(alpha + beta);
|
|
6118
|
+
}
|
|
6119
|
+
__name(betaFunctionNaturalLogarithm, "betaFunctionNaturalLogarithm");
|
|
6120
|
+
function logGamma(x) {
|
|
6121
|
+
const coefficients = [
|
|
6122
|
+
76.18009172947146,
|
|
6123
|
+
-86.50532032941678,
|
|
6124
|
+
24.01409824083091,
|
|
6125
|
+
// eslint-disable-line
|
|
6126
|
+
-1.231739572450155,
|
|
6127
|
+
0.001208650973866179,
|
|
6128
|
+
-5395239384953e-18
|
|
6129
|
+
];
|
|
6130
|
+
let y = x, tmp = x + 5.5;
|
|
6131
|
+
tmp -= (x + 0.5) * Math.log(tmp);
|
|
6132
|
+
let ser = 1.000000000190015;
|
|
6133
|
+
for (let j = 0; j < 6; j++)
|
|
6134
|
+
y += 1, ser += coefficients[j] / y;
|
|
6135
|
+
return -tmp + Math.log(2.5066282746310007 * ser / x);
|
|
6136
|
+
}
|
|
6137
|
+
__name(logGamma, "logGamma");
|
|
6138
|
+
function gammaFunction(x) {
|
|
6139
|
+
const p = [
|
|
6140
|
+
-1.716185138865495,
|
|
6141
|
+
24.76565080557592,
|
|
6142
|
+
-379.80425647094563,
|
|
6143
|
+
629.3311553128184,
|
|
6144
|
+
866.9662027904133,
|
|
6145
|
+
-31451.272968848367,
|
|
6146
|
+
-36144.413418691176,
|
|
6147
|
+
66456.14382024054
|
|
6148
|
+
], q = [
|
|
6149
|
+
-30.8402300119739,
|
|
6150
|
+
315.35062697960416,
|
|
6151
|
+
-1015.1563674902192,
|
|
6152
|
+
-3107.771671572311,
|
|
6153
|
+
22538.11842098015,
|
|
6154
|
+
4755.846277527881,
|
|
6155
|
+
// eslint-disable-line
|
|
6156
|
+
-134659.9598649693,
|
|
6157
|
+
-115132.2596755535
|
|
6158
|
+
];
|
|
6159
|
+
let fact = 0, y = x;
|
|
6160
|
+
if (x > 171.6243769536076)
|
|
6161
|
+
return 1 / 0;
|
|
6162
|
+
if (y <= 0) {
|
|
6163
|
+
const resMod = y % 1 + 36e-17;
|
|
6164
|
+
if (resMod)
|
|
6165
|
+
fact = (y & 1 ? -1 : 1) * Math.PI / Math.sin(Math.PI * resMod), y = 1 - y;
|
|
6166
|
+
else
|
|
6167
|
+
return 1 / 0;
|
|
6168
|
+
}
|
|
6169
|
+
const yi = y;
|
|
6170
|
+
let n = 0, z;
|
|
6171
|
+
y < 1 ? z = y++ : z = (y -= n = (y | 0) - 1) - 1;
|
|
6172
|
+
let xnum = 0, xden = 0;
|
|
6173
|
+
for (let i = 0; i < 8; ++i)
|
|
6174
|
+
xnum = (xnum + p[i]) * z, xden = xden * z + q[i];
|
|
6175
|
+
let res = xnum / xden + 1;
|
|
6176
|
+
if (yi < y)
|
|
6177
|
+
res /= yi;
|
|
6178
|
+
else if (yi > y)
|
|
6179
|
+
for (let i = 0; i < n; ++i)
|
|
6180
|
+
res *= y, y++;
|
|
6181
|
+
return fact && (res = fact / res), res;
|
|
6182
|
+
}
|
|
6183
|
+
__name(gammaFunction, "gammaFunction");
|
|
6184
|
+
function binomialCDF(x, trials, probability) {
|
|
6185
|
+
if (x < 0)
|
|
6186
|
+
return 0;
|
|
6187
|
+
if (x >= trials)
|
|
6188
|
+
return 1;
|
|
6189
|
+
if (probability < 0 || probability > 1 || trials <= 0)
|
|
6190
|
+
return Number.NaN;
|
|
6191
|
+
let result = 0;
|
|
6192
|
+
for (let i = 0; i <= x; i++)
|
|
6193
|
+
result += binomialPDF(i, trials, probability);
|
|
6194
|
+
return result;
|
|
6195
|
+
}
|
|
6196
|
+
__name(binomialCDF, "binomialCDF");
|
|
6197
|
+
function binomialPDF(x, trials, probability) {
|
|
6198
|
+
return probability === 0 || probability === 1 ? trials * probability === x ? 1 : 0 : calculateCombin(trials, x) * probability ** x * (1 - probability) ** (trials - x);
|
|
6199
|
+
}
|
|
6200
|
+
__name(binomialPDF, "binomialPDF");
|
|
6201
|
+
function chisquareCDF(x, degFreedom) {
|
|
6202
|
+
return x <= 0 ? 0 : lowRegGamma(degFreedom / 2, x / 2);
|
|
6203
|
+
}
|
|
6204
|
+
__name(chisquareCDF, "chisquareCDF");
|
|
6205
|
+
function chisquarePDF(x, degFreedom) {
|
|
6206
|
+
return x < 0 ? 0 : x === 0 && degFreedom === 2 ? 0.5 : Math.exp((degFreedom / 2 - 1) * Math.log(x) - x / 2 - degFreedom / 2 * Math.log(2) - logGamma(degFreedom / 2));
|
|
6207
|
+
}
|
|
6208
|
+
__name(chisquarePDF, "chisquarePDF");
|
|
6209
|
+
function chisquareINV(probability, degFreedom) {
|
|
6210
|
+
return probability <= 0 ? 0 : probability >= 1 ? 1 / 0 : 2 * lowRegGammaInverse(probability, degFreedom / 2);
|
|
6211
|
+
}
|
|
6212
|
+
__name(chisquareINV, "chisquareINV");
|
|
6213
|
+
function lowRegGamma(a, x) {
|
|
6214
|
+
if (x < 0 || a <= 0)
|
|
6215
|
+
return Number.NaN;
|
|
6216
|
+
const MAX_ITER = Math.min(-~(Math.log(a >= 1 ? a : 1 / a) * 8.5 + a * 0.4 + 17), 1e4), aln = logGamma(a), exp2 = Math.exp(-x + a * Math.log(x) - aln);
|
|
6217
|
+
let _a26 = a, sum2 = 1 / a, del = sum2;
|
|
6218
|
+
if (x < a + 1) {
|
|
6219
|
+
if (exp2 === 0)
|
|
6220
|
+
return 0;
|
|
6221
|
+
for (let i = 1; i <= MAX_ITER; i++)
|
|
6222
|
+
sum2 += del *= x / ++_a26;
|
|
6223
|
+
return sum2 * exp2;
|
|
6224
|
+
}
|
|
6225
|
+
if (exp2 === 0)
|
|
6226
|
+
return 1;
|
|
6227
|
+
let b = x + 1 - a, c = 1 / 1e-30, d = 1 / b, h = d;
|
|
6228
|
+
for (let i = 1; i <= MAX_ITER; i++) {
|
|
6229
|
+
const temp = -i * (i - a);
|
|
6230
|
+
b += 2, d = temp * d + b, c = b + temp / c, d = 1 / d, h *= d * c;
|
|
6231
|
+
}
|
|
6232
|
+
return 1 - h * exp2;
|
|
6233
|
+
}
|
|
6234
|
+
__name(lowRegGamma, "lowRegGamma");
|
|
6235
|
+
function lowRegGammaInverse(p, a) {
|
|
6236
|
+
if (p <= 0)
|
|
6237
|
+
return 0;
|
|
6238
|
+
if (p >= 1)
|
|
6239
|
+
return Math.max(100, a + 100 * Math.sqrt(a));
|
|
6240
|
+
let x;
|
|
6241
|
+
if (a > 1) {
|
|
6242
|
+
const _p = p < 0.5 ? p : 1 - p, temp = Math.sqrt(-2 * Math.log(_p));
|
|
6243
|
+
x = (2.30753 + temp * 0.27061) / (1 + temp * (0.99229 + temp * 0.04481)) - temp, p < 0.5 && (x = -x), x = Math.max(1e-3, a * (1 - 1 / (9 * a) - x / (3 * Math.sqrt(a))) ** 3);
|
|
6244
|
+
} else {
|
|
6245
|
+
const temp = 1 - a * (0.253 + a * 0.12);
|
|
6246
|
+
p < temp ? x = (p / temp) ** (1 / a) : x = 1 - Math.log(1 - (p - temp) / (1 - temp));
|
|
6247
|
+
}
|
|
6248
|
+
const EPSILON = 1e-8, aln = logGamma(a);
|
|
6249
|
+
let err, t;
|
|
6250
|
+
for (let j = 0; j < 12; j++) {
|
|
6251
|
+
if (x <= 0)
|
|
6252
|
+
return 0;
|
|
6253
|
+
if (err = lowRegGamma(a, x) - p, a > 1 ? t = Math.exp((a - 1) * (Math.log(a - 1) - 1) - aln) * Math.exp(-(x - (a - 1)) + (a - 1) * (Math.log(x) - Math.log(a - 1))) : t = Math.exp(-x + (a - 1) * Math.log(x) - aln), t !== 0 && (t = err / t / (1 - 0.5 * Math.min(1, err / t * ((a - 1) / x - 1)))), x -= t, x <= 0 && (x = 0.5 * (x + t)), Math.abs(t) < EPSILON * x)
|
|
6254
|
+
break;
|
|
6255
|
+
}
|
|
6256
|
+
return x;
|
|
6257
|
+
}
|
|
6258
|
+
__name(lowRegGammaInverse, "lowRegGammaInverse");
|
|
6259
|
+
function studentTINV(probability, degFreedom) {
|
|
6260
|
+
let x = betaINV(2 * Math.min(probability, 1 - probability), 0.5 * degFreedom, 0.5);
|
|
6261
|
+
return x = Math.sqrt(degFreedom * (1 - x) / x), probability > 0.5 ? x : -x;
|
|
6262
|
+
}
|
|
6263
|
+
__name(studentTINV, "studentTINV");
|
|
6264
|
+
function exponentialCDF(x, lambda) {
|
|
6265
|
+
return x < 0 ? 0 : 1 - Math.exp(-lambda * x);
|
|
6266
|
+
}
|
|
6267
|
+
__name(exponentialCDF, "exponentialCDF");
|
|
6268
|
+
function exponentialPDF(x, lambda) {
|
|
6269
|
+
return x < 0 ? 0 : lambda * Math.exp(-lambda * x);
|
|
6270
|
+
}
|
|
6271
|
+
__name(exponentialPDF, "exponentialPDF");
|
|
6272
|
+
function centralFCDF(x, degFreedom1, degFreedom2) {
|
|
6273
|
+
return x < 0 ? 0 : incompleteBetaFunction(degFreedom1 * x / (degFreedom1 * x + degFreedom2), degFreedom1 / 2, degFreedom2 / 2);
|
|
6274
|
+
}
|
|
6275
|
+
__name(centralFCDF, "centralFCDF");
|
|
6276
|
+
function centralFPDF(x, degFreedom1, degFreedom2) {
|
|
6277
|
+
if (x < 0)
|
|
6278
|
+
return 0;
|
|
6279
|
+
if (x === 0 && degFreedom1 < 2)
|
|
6280
|
+
return 1 / 0;
|
|
6281
|
+
if (x === 0 && degFreedom1 === 2)
|
|
6282
|
+
return 1;
|
|
6283
|
+
let result = 1 / betaFunction(degFreedom1 / 2, degFreedom2 / 2);
|
|
6284
|
+
return result *= (degFreedom1 / degFreedom2) ** (degFreedom1 / 2), result *= x ** (degFreedom1 / 2 - 1), result *= (1 + degFreedom1 / degFreedom2 * x) ** (-(degFreedom1 + degFreedom2) / 2), result;
|
|
6285
|
+
}
|
|
6286
|
+
__name(centralFPDF, "centralFPDF");
|
|
6287
|
+
function centralFINV(probability, degFreedom1, degFreedom2) {
|
|
6288
|
+
return probability <= 0 ? 0 : probability >= 1 ? 1 / 0 : degFreedom2 / (degFreedom1 * (1 / betaINV(probability, degFreedom1 / 2, degFreedom2 / 2) - 1));
|
|
6289
|
+
}
|
|
6290
|
+
__name(centralFINV, "centralFINV");
|
|
6291
|
+
function forecastLinear(x, knownYs, knownXs) {
|
|
6292
|
+
const n = knownYs.length;
|
|
6293
|
+
let knownYsSum = 0, knownXsSum = 0;
|
|
6294
|
+
for (let i = 0; i < n; i++)
|
|
6295
|
+
knownYsSum += knownYs[i], knownXsSum += knownXs[i];
|
|
6296
|
+
const knownYsMean = knownYsSum / n, knownXsMean = knownXsSum / n;
|
|
6297
|
+
let num = 0, den = 0;
|
|
6298
|
+
for (let i = 0; i < n; i++)
|
|
6299
|
+
num += (knownYs[i] - knownYsMean) * (knownXs[i] - knownXsMean), den += (knownXs[i] - knownXsMean) ** 2;
|
|
6300
|
+
if (den === 0)
|
|
6301
|
+
return 1 / 0;
|
|
6302
|
+
const b = num / den;
|
|
6303
|
+
return knownYsMean - b * knownXsMean + b * x;
|
|
6304
|
+
}
|
|
6305
|
+
__name(forecastLinear, "forecastLinear");
|
|
6306
|
+
function normalCDF(x, mean, standardDev) {
|
|
6307
|
+
return 0.5 * (1 + erf((x - mean) / Math.sqrt(2 * standardDev * standardDev)));
|
|
6308
|
+
}
|
|
6309
|
+
__name(normalCDF, "normalCDF");
|
|
6310
|
+
function normalPDF(x, mean, standardDev) {
|
|
6311
|
+
return Math.exp(-0.5 * Math.log(2 * Math.PI) - Math.log(standardDev) - (x - mean) ** 2 / (2 * standardDev * standardDev));
|
|
6312
|
+
}
|
|
6313
|
+
__name(normalPDF, "normalPDF");
|
|
6314
|
+
function normalINV(probability, mean, standardDev) {
|
|
6315
|
+
return -1.4142135623730951 * standardDev * erfcINV(2 * probability) + mean;
|
|
6316
|
+
}
|
|
6317
|
+
__name(normalINV, "normalINV");
|
|
6318
|
+
function getTwoArrayNumberValues(array1, array2, count, array1ColumnCount, array2ColumnCount) {
|
|
6319
|
+
const array1Values = [], array2Values = [];
|
|
6320
|
+
let noCalculate = !0;
|
|
6321
|
+
for (let i = 0; i < count; i++) {
|
|
6322
|
+
const array1RowIndex = Math.floor(i / array1ColumnCount), array1ColumnIndex = i % array1ColumnCount, array2RowIndex = Math.floor(i / array2ColumnCount), array2ColumnIndex = i % array2ColumnCount, array1Object = array1.isArray() ? array1.get(array1RowIndex, array1ColumnIndex) : array1, array2Object = array2.isArray() ? array2.get(array2RowIndex, array2ColumnIndex) : array2;
|
|
6323
|
+
if (array1Object.isError())
|
|
6324
|
+
return {
|
|
6325
|
+
isError: !0,
|
|
6326
|
+
errorObject: array1Object,
|
|
6327
|
+
array1Values,
|
|
6328
|
+
array2Values,
|
|
6329
|
+
noCalculate
|
|
6330
|
+
};
|
|
6331
|
+
if (array2Object.isError())
|
|
6332
|
+
return {
|
|
6333
|
+
isError: !0,
|
|
6334
|
+
errorObject: array2Object,
|
|
6335
|
+
array1Values,
|
|
6336
|
+
array2Values,
|
|
6337
|
+
noCalculate
|
|
6338
|
+
};
|
|
6339
|
+
if (array1Object.isNull() || array2Object.isNull() || array1Object.isBoolean() || array2Object.isBoolean())
|
|
6340
|
+
continue;
|
|
6341
|
+
const array1Value = array1Object.getValue(), array2Value = array2Object.getValue();
|
|
6342
|
+
!isRealNum(array1Value) || !isRealNum(array2Value) || (array1Values.push(+array1Value), array2Values.push(+array2Value), noCalculate = !1);
|
|
6343
|
+
}
|
|
6344
|
+
return {
|
|
6345
|
+
isError: !1,
|
|
6346
|
+
errorObject: null,
|
|
6347
|
+
array1Values,
|
|
6348
|
+
array2Values,
|
|
6349
|
+
noCalculate
|
|
6350
|
+
};
|
|
6351
|
+
}
|
|
6352
|
+
__name(getTwoArrayNumberValues, "getTwoArrayNumberValues");
|
|
6353
|
+
function checkVariantErrorIsArray(variant) {
|
|
6354
|
+
let _variant = variant;
|
|
6355
|
+
if (variant.isArray()) {
|
|
6356
|
+
const rowCount = variant.getRowCount(), columnCount = variant.getColumnCount();
|
|
6357
|
+
if (rowCount > 1 || columnCount > 1)
|
|
6358
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
6359
|
+
_variant = variant.get(0, 0);
|
|
6360
|
+
}
|
|
6361
|
+
return _variant.isError(), _variant;
|
|
6362
|
+
}
|
|
6363
|
+
__name(checkVariantErrorIsArray, "checkVariantErrorIsArray");
|
|
6364
|
+
function checkVariantsErrorIsArrayOrBoolean(...variants) {
|
|
6365
|
+
for (let i = 0; i < variants.length; i++) {
|
|
6366
|
+
const variant = checkVariantErrorIsArray(variants[i]);
|
|
6367
|
+
if (variant.isError())
|
|
6368
|
+
return {
|
|
6369
|
+
isError: !0,
|
|
6370
|
+
errorObject: variant
|
|
6371
|
+
};
|
|
6372
|
+
if (variant.isBoolean())
|
|
6373
|
+
return {
|
|
6374
|
+
isError: !0,
|
|
6375
|
+
errorObject: ErrorValueObject.create(ErrorType$1.VALUE)
|
|
6376
|
+
};
|
|
6377
|
+
variants[i] = variant;
|
|
6378
|
+
}
|
|
6379
|
+
return {
|
|
6380
|
+
isError: !1,
|
|
6381
|
+
variants
|
|
6382
|
+
};
|
|
6383
|
+
}
|
|
6384
|
+
__name(checkVariantsErrorIsArrayOrBoolean, "checkVariantsErrorIsArrayOrBoolean");
|
|
6385
|
+
function checkVariantsErrorIsNullorArrayOrBoolean(...variants) {
|
|
6386
|
+
for (let i = 0; i < variants.length; i++) {
|
|
6387
|
+
let variant = variants[i];
|
|
6388
|
+
if (variant.isError())
|
|
6389
|
+
return {
|
|
6390
|
+
isError: !0,
|
|
6391
|
+
errorObject: variant
|
|
6392
|
+
};
|
|
6393
|
+
if (variant.isNull())
|
|
6394
|
+
return {
|
|
6395
|
+
isError: !0,
|
|
6396
|
+
errorObject: ErrorValueObject.create(ErrorType$1.NA)
|
|
6397
|
+
};
|
|
6398
|
+
if (variant = checkVariantErrorIsArray(variants[i]), variant.isError())
|
|
6399
|
+
return {
|
|
6400
|
+
isError: !0,
|
|
6401
|
+
errorObject: variant
|
|
6402
|
+
};
|
|
6403
|
+
if (variant.isBoolean())
|
|
6404
|
+
return {
|
|
6405
|
+
isError: !0,
|
|
6406
|
+
errorObject: ErrorValueObject.create(ErrorType$1.VALUE)
|
|
6407
|
+
};
|
|
6408
|
+
variants[i] = variant;
|
|
6409
|
+
}
|
|
6410
|
+
return {
|
|
6411
|
+
isError: !1,
|
|
6412
|
+
variants
|
|
6413
|
+
};
|
|
6414
|
+
}
|
|
6415
|
+
__name(checkVariantsErrorIsNullorArrayOrBoolean, "checkVariantsErrorIsNullorArrayOrBoolean");
|
|
6416
|
+
function checkVariantsErrorIsStringToNumber(...variants) {
|
|
6417
|
+
for (let i = 0; i < variants.length; i++) {
|
|
6418
|
+
let variant = variants[i];
|
|
6419
|
+
if (variant.isString() && (variant = variant.convertToNumberObjectValue()), variant.isError())
|
|
6420
|
+
return {
|
|
6421
|
+
isError: !0,
|
|
6422
|
+
errorObject: variant
|
|
6423
|
+
};
|
|
6424
|
+
variants[i] = variant;
|
|
6425
|
+
}
|
|
6426
|
+
return {
|
|
6427
|
+
isError: !1,
|
|
6428
|
+
variants
|
|
6429
|
+
};
|
|
6430
|
+
}
|
|
6431
|
+
__name(checkVariantsErrorIsStringToNumber, "checkVariantsErrorIsStringToNumber");
|
|
6432
|
+
const _BetaInv = class _BetaInv extends BaseFunction {
|
|
6433
|
+
constructor() {
|
|
6434
|
+
super(...arguments);
|
|
6435
|
+
__publicField(this, "minParams", 3);
|
|
6436
|
+
__publicField(this, "maxParams", 5);
|
|
6437
|
+
}
|
|
6438
|
+
calculate(probability, alpha, beta, A, B) {
|
|
6439
|
+
let _A = A != null ? A : NumberValueObject.create(0), _B = B != null ? B : NumberValueObject.create(1);
|
|
6440
|
+
_A.isNull() && (_A = NumberValueObject.create(0)), _B.isNull() && (_B = NumberValueObject.create(1));
|
|
6441
|
+
const maxRowLength = Math.max(
|
|
6442
|
+
probability.isArray() ? probability.getRowCount() : 1,
|
|
6443
|
+
alpha.isArray() ? alpha.getRowCount() : 1,
|
|
6444
|
+
beta.isArray() ? beta.getRowCount() : 1,
|
|
6445
|
+
_A.isArray() ? _A.getRowCount() : 1,
|
|
6446
|
+
_B.isArray() ? _B.getRowCount() : 1
|
|
6447
|
+
), maxColumnLength = Math.max(
|
|
6448
|
+
probability.isArray() ? probability.getColumnCount() : 1,
|
|
6449
|
+
alpha.isArray() ? alpha.getColumnCount() : 1,
|
|
6450
|
+
beta.isArray() ? beta.getColumnCount() : 1,
|
|
6451
|
+
_A.isArray() ? _A.getColumnCount() : 1,
|
|
6452
|
+
_B.isArray() ? _B.getColumnCount() : 1
|
|
6453
|
+
), probabilityArray = expandArrayValueObject(maxRowLength, maxColumnLength, probability, ErrorValueObject.create(ErrorType$1.NA)), alphaArray = expandArrayValueObject(maxRowLength, maxColumnLength, alpha, ErrorValueObject.create(ErrorType$1.NA)), betaArray = expandArrayValueObject(maxRowLength, maxColumnLength, beta, ErrorValueObject.create(ErrorType$1.NA)), AArray = expandArrayValueObject(maxRowLength, maxColumnLength, _A, ErrorValueObject.create(ErrorType$1.NA)), BArray = expandArrayValueObject(maxRowLength, maxColumnLength, _B, ErrorValueObject.create(ErrorType$1.NA)), resultArray = probabilityArray.mapValue((probabilityObject, rowIndex, columnIndex) => {
|
|
6454
|
+
const alphaObject = alphaArray.get(rowIndex, columnIndex), betaObject = betaArray.get(rowIndex, columnIndex), AObject = AArray.get(rowIndex, columnIndex), BObject = BArray.get(rowIndex, columnIndex);
|
|
6455
|
+
return this._handleSignleObject(probabilityObject, alphaObject, betaObject, AObject, BObject);
|
|
6456
|
+
});
|
|
6457
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
6458
|
+
}
|
|
6459
|
+
_handleSignleObject(probabilityObject, alphaObject, betaObject, AObject, BObject) {
|
|
6460
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(probabilityObject, alphaObject, betaObject, AObject, BObject);
|
|
6461
|
+
if (isError)
|
|
6462
|
+
return errorObject;
|
|
6463
|
+
const [_probabilityObject, _alphaObject, _betaObject, _AObject, _BObject] = variants, probabilityValue = +_probabilityObject.getValue(), alphaValue = +_alphaObject.getValue(), betaValue = +_betaObject.getValue(), AValue = +_AObject.getValue(), BValue = +_BObject.getValue();
|
|
6464
|
+
if (alphaValue <= 0 || betaValue <= 0 || probabilityValue <= 0 || probabilityValue >= 1 || AValue >= BValue)
|
|
6465
|
+
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
6466
|
+
const result = betaINV(probabilityValue, alphaValue, betaValue) * (BValue - AValue) + AValue;
|
|
6467
|
+
return NumberValueObject.create(result);
|
|
6468
|
+
}
|
|
6469
|
+
};
|
|
6470
|
+
__name(_BetaInv, "BetaInv");
|
|
6471
|
+
let BetaInv = _BetaInv;
|
|
6472
|
+
const _BinomDist = class _BinomDist extends BaseFunction {
|
|
6473
|
+
constructor() {
|
|
6474
|
+
super(...arguments);
|
|
6475
|
+
__publicField(this, "minParams", 4);
|
|
6476
|
+
__publicField(this, "maxParams", 4);
|
|
6477
|
+
}
|
|
6478
|
+
calculate(numberS, trials, probabilityS, cumulative) {
|
|
6479
|
+
const maxRowLength = Math.max(
|
|
6480
|
+
numberS.isArray() ? numberS.getRowCount() : 1,
|
|
6481
|
+
trials.isArray() ? trials.getRowCount() : 1,
|
|
6482
|
+
probabilityS.isArray() ? probabilityS.getRowCount() : 1,
|
|
6483
|
+
cumulative.isArray() ? cumulative.getRowCount() : 1
|
|
6484
|
+
), maxColumnLength = Math.max(
|
|
6485
|
+
numberS.isArray() ? numberS.getColumnCount() : 1,
|
|
6486
|
+
trials.isArray() ? trials.getColumnCount() : 1,
|
|
6487
|
+
probabilityS.isArray() ? probabilityS.getColumnCount() : 1,
|
|
6488
|
+
cumulative.isArray() ? cumulative.getColumnCount() : 1
|
|
6489
|
+
), numberSArray = expandArrayValueObject(maxRowLength, maxColumnLength, numberS, ErrorValueObject.create(ErrorType$1.NA)), trialsArray = expandArrayValueObject(maxRowLength, maxColumnLength, trials, ErrorValueObject.create(ErrorType$1.NA)), probabilitySArray = expandArrayValueObject(maxRowLength, maxColumnLength, probabilityS, ErrorValueObject.create(ErrorType$1.NA)), cumulativeArray = expandArrayValueObject(maxRowLength, maxColumnLength, cumulative, ErrorValueObject.create(ErrorType$1.NA)), resultArray = numberSArray.mapValue((numberSObject, rowIndex, columnIndex) => {
|
|
6490
|
+
const trialsObject = trialsArray.get(rowIndex, columnIndex), probabilitySObject = probabilitySArray.get(rowIndex, columnIndex), cumulativeObject = cumulativeArray.get(rowIndex, columnIndex);
|
|
6491
|
+
return this._handleSignleObject(numberSObject, trialsObject, probabilitySObject, cumulativeObject);
|
|
6492
|
+
});
|
|
6493
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
6494
|
+
}
|
|
6495
|
+
_handleSignleObject(numberSObject, trialsObject, probabilitySObject, cumulativeObject) {
|
|
6496
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(numberSObject, trialsObject, probabilitySObject, cumulativeObject);
|
|
6497
|
+
if (isError)
|
|
6498
|
+
return errorObject;
|
|
6499
|
+
const [_numberSObject, _trialsObject, _probabilitySObject, _cumulativeObject] = variants, numberSValue = Math.floor(+_numberSObject.getValue()), trialsValue = Math.floor(+_trialsObject.getValue()), probabilitySValue = +_probabilitySObject.getValue(), cumulativeValue = +_cumulativeObject.getValue();
|
|
6500
|
+
if (numberSValue < 0 || numberSValue > trialsValue || probabilitySValue < 0 || probabilitySValue > 1)
|
|
6501
|
+
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
6502
|
+
let result;
|
|
6503
|
+
return cumulativeValue ? result = binomialCDF(numberSValue, trialsValue, probabilitySValue) : result = binomialPDF(numberSValue, trialsValue, probabilitySValue), NumberValueObject.create(result);
|
|
6504
|
+
}
|
|
6505
|
+
};
|
|
6506
|
+
__name(_BinomDist, "BinomDist");
|
|
6507
|
+
let BinomDist = _BinomDist;
|
|
6508
|
+
const _BinomInv = class _BinomInv extends BaseFunction {
|
|
6509
|
+
constructor() {
|
|
6510
|
+
super(...arguments);
|
|
6511
|
+
__publicField(this, "minParams", 3);
|
|
6512
|
+
__publicField(this, "maxParams", 3);
|
|
6513
|
+
}
|
|
6514
|
+
calculate(trials, probabilityS, alpha) {
|
|
6515
|
+
const maxRowLength = Math.max(
|
|
6516
|
+
trials.isArray() ? trials.getRowCount() : 1,
|
|
6517
|
+
probabilityS.isArray() ? probabilityS.getRowCount() : 1,
|
|
6518
|
+
alpha.isArray() ? alpha.getRowCount() : 1
|
|
6519
|
+
), maxColumnLength = Math.max(
|
|
6520
|
+
trials.isArray() ? trials.getColumnCount() : 1,
|
|
6521
|
+
probabilityS.isArray() ? probabilityS.getColumnCount() : 1,
|
|
6522
|
+
alpha.isArray() ? alpha.getColumnCount() : 1
|
|
6523
|
+
), trialsArray = expandArrayValueObject(maxRowLength, maxColumnLength, trials, ErrorValueObject.create(ErrorType$1.NA)), probabilitySArray = expandArrayValueObject(maxRowLength, maxColumnLength, probabilityS, ErrorValueObject.create(ErrorType$1.NA)), alphaArray = expandArrayValueObject(maxRowLength, maxColumnLength, alpha, ErrorValueObject.create(ErrorType$1.NA)), resultArray = trialsArray.mapValue((trialsObject, rowIndex, columnIndex) => {
|
|
6524
|
+
const probabilitySObject = probabilitySArray.get(rowIndex, columnIndex), alphaObject = alphaArray.get(rowIndex, columnIndex);
|
|
6525
|
+
return this._handleSignleObject(trialsObject, probabilitySObject, alphaObject);
|
|
6526
|
+
});
|
|
6527
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
6528
|
+
}
|
|
6529
|
+
_handleSignleObject(trialsObject, probabilitySObject, alphaObject) {
|
|
6530
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(trialsObject, probabilitySObject, alphaObject);
|
|
6531
|
+
if (isError)
|
|
6532
|
+
return errorObject;
|
|
6533
|
+
const [_trialsObject, _probabilitySObject, _alphaObject] = variants, trialsValue = Math.floor(+_trialsObject.getValue()), probabilitySValue = +_probabilitySObject.getValue(), alphaValue = +_alphaObject.getValue();
|
|
6534
|
+
if (trialsValue < 0 || probabilitySValue <= 0 || probabilitySValue >= 1 || alphaValue <= 0 || alphaValue >= 1)
|
|
6535
|
+
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
6536
|
+
let result = 0;
|
|
6537
|
+
for (; result <= trialsValue && !(binomialCDF(result, trialsValue, probabilitySValue) >= alphaValue); )
|
|
6538
|
+
result++;
|
|
6539
|
+
return NumberValueObject.create(result);
|
|
6540
|
+
}
|
|
6541
|
+
};
|
|
6542
|
+
__name(_BinomInv, "BinomInv");
|
|
6543
|
+
let BinomInv = _BinomInv;
|
|
6544
|
+
const _ChisqDistRt = class _ChisqDistRt extends BaseFunction {
|
|
6545
|
+
constructor() {
|
|
6546
|
+
super(...arguments);
|
|
6547
|
+
__publicField(this, "minParams", 2);
|
|
6548
|
+
__publicField(this, "maxParams", 2);
|
|
6549
|
+
}
|
|
6550
|
+
calculate(x, degFreedom) {
|
|
6551
|
+
const maxRowLength = Math.max(
|
|
6552
|
+
x.isArray() ? x.getRowCount() : 1,
|
|
6553
|
+
degFreedom.isArray() ? degFreedom.getRowCount() : 1
|
|
6554
|
+
), maxColumnLength = Math.max(
|
|
6555
|
+
x.isArray() ? x.getColumnCount() : 1,
|
|
6556
|
+
degFreedom.isArray() ? degFreedom.getColumnCount() : 1
|
|
6557
|
+
), xArray = expandArrayValueObject(maxRowLength, maxColumnLength, x, ErrorValueObject.create(ErrorType$1.NA)), degFreedomArray = expandArrayValueObject(maxRowLength, maxColumnLength, degFreedom, ErrorValueObject.create(ErrorType$1.NA)), resultArray = xArray.mapValue((xObject, rowIndex, columnIndex) => {
|
|
6558
|
+
const degFreedomObject = degFreedomArray.get(rowIndex, columnIndex);
|
|
6559
|
+
return this._handleSignleObject(xObject, degFreedomObject);
|
|
6560
|
+
});
|
|
6561
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
6562
|
+
}
|
|
6563
|
+
_handleSignleObject(xObject, degFreedomObject) {
|
|
6564
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(xObject, degFreedomObject);
|
|
6565
|
+
if (isError)
|
|
6566
|
+
return errorObject;
|
|
6567
|
+
const [_xObject, _degFreedomObject] = variants, xValue = +_xObject.getValue(), degFreedomValue = Math.floor(+_degFreedomObject.getValue());
|
|
6568
|
+
if (xValue < 0 || degFreedomValue < 1 || degFreedomValue > 10 ** 10)
|
|
6569
|
+
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
6570
|
+
const result = 1 - chisquareCDF(xValue, degFreedomValue);
|
|
6571
|
+
return NumberValueObject.create(result);
|
|
6572
|
+
}
|
|
6573
|
+
};
|
|
6574
|
+
__name(_ChisqDistRt, "ChisqDistRt");
|
|
6575
|
+
let ChisqDistRt = _ChisqDistRt;
|
|
6576
|
+
const _ChisqInvRt = class _ChisqInvRt extends BaseFunction {
|
|
6577
|
+
constructor() {
|
|
6578
|
+
super(...arguments);
|
|
6579
|
+
__publicField(this, "minParams", 2);
|
|
6580
|
+
__publicField(this, "maxParams", 2);
|
|
6581
|
+
}
|
|
6582
|
+
calculate(probability, degFreedom) {
|
|
6583
|
+
const maxRowLength = Math.max(
|
|
6584
|
+
probability.isArray() ? probability.getRowCount() : 1,
|
|
6585
|
+
degFreedom.isArray() ? degFreedom.getRowCount() : 1
|
|
6586
|
+
), maxColumnLength = Math.max(
|
|
6587
|
+
probability.isArray() ? probability.getColumnCount() : 1,
|
|
6588
|
+
degFreedom.isArray() ? degFreedom.getColumnCount() : 1
|
|
6589
|
+
), probabilityArray = expandArrayValueObject(maxRowLength, maxColumnLength, probability, ErrorValueObject.create(ErrorType$1.NA)), degFreedomArray = expandArrayValueObject(maxRowLength, maxColumnLength, degFreedom, ErrorValueObject.create(ErrorType$1.NA)), resultArray = probabilityArray.mapValue((probabilityObject, rowIndex, columnIndex) => {
|
|
6590
|
+
const degFreedomObject = degFreedomArray.get(rowIndex, columnIndex);
|
|
6591
|
+
return this._handleSignleObject(probabilityObject, degFreedomObject);
|
|
6592
|
+
});
|
|
6593
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
6594
|
+
}
|
|
6595
|
+
_handleSignleObject(probabilityObject, degFreedomObject) {
|
|
6596
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(probabilityObject, degFreedomObject);
|
|
6597
|
+
if (isError)
|
|
6598
|
+
return errorObject;
|
|
6599
|
+
const [_probabilityObject, _degFreedomObject] = variants, probabilityValue = +_probabilityObject.getValue(), degFreedomValue = Math.floor(+_degFreedomObject.getValue());
|
|
6600
|
+
if (probabilityValue < 0 || probabilityValue > 1 || degFreedomValue < 1)
|
|
6601
|
+
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
6602
|
+
const result = chisquareINV(1 - probabilityValue, degFreedomValue);
|
|
6603
|
+
return Number.isNaN(result) || !Number.isFinite(result) ? ErrorValueObject.create(ErrorType$1.NUM) : NumberValueObject.create(result);
|
|
6604
|
+
}
|
|
6605
|
+
};
|
|
6606
|
+
__name(_ChisqInvRt, "ChisqInvRt");
|
|
6607
|
+
let ChisqInvRt = _ChisqInvRt;
|
|
6608
|
+
const _ChisqTest = class _ChisqTest extends BaseFunction {
|
|
6609
|
+
constructor() {
|
|
6610
|
+
super(...arguments);
|
|
6611
|
+
__publicField(this, "minParams", 2);
|
|
6612
|
+
__publicField(this, "maxParams", 2);
|
|
6613
|
+
}
|
|
6614
|
+
calculate(actualRange, expectedRange) {
|
|
6615
|
+
const actualRangeRowCount = actualRange.isArray() ? actualRange.getRowCount() : 1, actualRangeColumnCount = actualRange.isArray() ? actualRange.getColumnCount() : 1, expectedRangeRowCount = expectedRange.isArray() ? expectedRange.getRowCount() : 1, expectedRangeColumnCount = expectedRange.isArray() ? expectedRange.getColumnCount() : 1;
|
|
6616
|
+
let _actualRange = actualRange;
|
|
6617
|
+
if (actualRange.isArray() && actualRangeRowCount === 1 && actualRangeColumnCount === 1 && (_actualRange = actualRange.get(0, 0)), _actualRange.isError())
|
|
6618
|
+
return _actualRange;
|
|
6619
|
+
let _expectedRange = expectedRange;
|
|
6620
|
+
if (expectedRange.isArray() && expectedRangeRowCount === 1 && expectedRangeColumnCount === 1 && (_expectedRange = expectedRange.get(0, 0)), _expectedRange.isError())
|
|
6621
|
+
return _expectedRange;
|
|
6622
|
+
if (actualRangeRowCount * actualRangeColumnCount === 1 || expectedRangeRowCount * expectedRangeColumnCount === 1)
|
|
6623
|
+
return _actualRange.isNull() || _expectedRange.isNull() ? ErrorValueObject.create(ErrorType$1.VALUE) : ErrorValueObject.create(ErrorType$1.NA);
|
|
6624
|
+
if (actualRangeRowCount * actualRangeColumnCount !== expectedRangeRowCount * expectedRangeColumnCount)
|
|
6625
|
+
return ErrorValueObject.create(ErrorType$1.NA);
|
|
6626
|
+
const {
|
|
6627
|
+
isError,
|
|
6628
|
+
errorObject,
|
|
6629
|
+
array1Values,
|
|
6630
|
+
array2Values,
|
|
6631
|
+
noCalculate
|
|
6632
|
+
} = getTwoArrayNumberValues(
|
|
6633
|
+
actualRange,
|
|
6634
|
+
expectedRange,
|
|
6635
|
+
actualRangeRowCount * actualRangeColumnCount,
|
|
6636
|
+
actualRangeColumnCount,
|
|
6637
|
+
expectedRangeColumnCount
|
|
6638
|
+
);
|
|
6639
|
+
return isError ? errorObject : noCalculate ? ErrorValueObject.create(ErrorType$1.DIV_BY_ZERO) : this._getResult(array1Values, array2Values, actualRangeRowCount, actualRangeColumnCount);
|
|
6640
|
+
}
|
|
6641
|
+
_getResult(actualRangeValues, expectedRangeValues, actualRangeRowCount, actualRangeColumnCount) {
|
|
6642
|
+
let sumxmy2 = 0;
|
|
6643
|
+
for (let i = 0; i < actualRangeValues.length; i++) {
|
|
6644
|
+
if (expectedRangeValues[i] === 0)
|
|
6645
|
+
return ErrorValueObject.create(ErrorType$1.DIV_BY_ZERO);
|
|
6646
|
+
sumxmy2 += (actualRangeValues[i] - expectedRangeValues[i]) ** 2 / expectedRangeValues[i];
|
|
6647
|
+
}
|
|
6648
|
+
let df = (actualRangeRowCount - 1) * (actualRangeColumnCount - 1);
|
|
6649
|
+
actualRangeRowCount === 1 ? df = actualRangeColumnCount - 1 : actualRangeColumnCount === 1 && (df = actualRangeRowCount - 1);
|
|
6650
|
+
const result = 1 - chisquareCDF(sumxmy2, df);
|
|
6651
|
+
return NumberValueObject.create(result);
|
|
6652
|
+
}
|
|
6653
|
+
};
|
|
6654
|
+
__name(_ChisqTest, "ChisqTest");
|
|
6655
|
+
let ChisqTest = _ChisqTest;
|
|
6656
|
+
const _ConfidenceNorm = class _ConfidenceNorm extends BaseFunction {
|
|
6657
|
+
constructor() {
|
|
6658
|
+
super(...arguments);
|
|
6659
|
+
__publicField(this, "minParams", 3);
|
|
6660
|
+
__publicField(this, "maxParams", 3);
|
|
6661
|
+
}
|
|
6662
|
+
calculate(alpha, standardDev, size) {
|
|
6663
|
+
const maxRowLength = Math.max(
|
|
6664
|
+
alpha.isArray() ? alpha.getRowCount() : 1,
|
|
6665
|
+
standardDev.isArray() ? standardDev.getRowCount() : 1,
|
|
6666
|
+
size.isArray() ? size.getRowCount() : 1
|
|
6667
|
+
), maxColumnLength = Math.max(
|
|
6668
|
+
alpha.isArray() ? alpha.getColumnCount() : 1,
|
|
6669
|
+
standardDev.isArray() ? standardDev.getColumnCount() : 1,
|
|
6670
|
+
size.isArray() ? size.getColumnCount() : 1
|
|
6671
|
+
), alphaArray = expandArrayValueObject(maxRowLength, maxColumnLength, alpha, ErrorValueObject.create(ErrorType$1.NA)), standardDevArray = expandArrayValueObject(maxRowLength, maxColumnLength, standardDev, ErrorValueObject.create(ErrorType$1.NA)), sizeArray = expandArrayValueObject(maxRowLength, maxColumnLength, size, ErrorValueObject.create(ErrorType$1.NA)), resultArray = alphaArray.mapValue((alphaObject, rowIndex, columnIndex) => {
|
|
6672
|
+
const standardDevObject = standardDevArray.get(rowIndex, columnIndex), sizeObject = sizeArray.get(rowIndex, columnIndex), { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(alphaObject, standardDevObject, sizeObject);
|
|
6673
|
+
if (isError)
|
|
6674
|
+
return errorObject;
|
|
6675
|
+
const [_alphaObject, _standardDevObject, _sizeObject] = variants, alphaValue = +_alphaObject.getValue(), standardDevValue = +_standardDevObject.getValue(), sizeValue = Math.floor(+_sizeObject.getValue());
|
|
6676
|
+
if (alphaValue <= 0 || alphaValue >= 1 || standardDevValue <= 0 || sizeValue < 1)
|
|
6677
|
+
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
6678
|
+
const result = Math.abs(normalINV(alphaValue / 2, 0, 1) * standardDevValue / Math.sqrt(sizeValue));
|
|
6679
|
+
return NumberValueObject.create(result);
|
|
6680
|
+
});
|
|
6681
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
6682
|
+
}
|
|
6683
|
+
};
|
|
6684
|
+
__name(_ConfidenceNorm, "ConfidenceNorm");
|
|
6685
|
+
let ConfidenceNorm = _ConfidenceNorm;
|
|
6686
|
+
const _CovarianceP = class _CovarianceP extends BaseFunction {
|
|
6687
|
+
constructor() {
|
|
6688
|
+
super(...arguments);
|
|
6689
|
+
__publicField(this, "minParams", 2);
|
|
6690
|
+
__publicField(this, "maxParams", 2);
|
|
6691
|
+
}
|
|
6692
|
+
calculate(array1, array2) {
|
|
6693
|
+
const array1RowCount = array1.isArray() ? array1.getRowCount() : 1, array1ColumnCount = array1.isArray() ? array1.getColumnCount() : 1, array2RowCount = array2.isArray() ? array2.getRowCount() : 1, array2ColumnCount = array2.isArray() ? array2.getColumnCount() : 1;
|
|
6694
|
+
let _array1 = array1;
|
|
6695
|
+
if (array1.isArray() && array1RowCount === 1 && array1ColumnCount === 1 && (_array1 = array1.get(0, 0)), _array1.isError())
|
|
6696
|
+
return _array1;
|
|
6697
|
+
let _array2 = array2;
|
|
6698
|
+
if (array2.isArray() && array2RowCount === 1 && array2ColumnCount === 1 && (_array2 = array2.get(0, 0)), _array2.isError())
|
|
6699
|
+
return _array2;
|
|
6700
|
+
if ((array1RowCount * array1ColumnCount === 1 || array2RowCount * array2ColumnCount === 1) && (_array1.isNull() || _array2.isNull()))
|
|
6701
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
6702
|
+
if (array1RowCount * array1ColumnCount !== array2RowCount * array2ColumnCount)
|
|
6703
|
+
return ErrorValueObject.create(ErrorType$1.NA);
|
|
6704
|
+
const {
|
|
6705
|
+
isError,
|
|
6706
|
+
errorObject,
|
|
6707
|
+
array1Values,
|
|
6708
|
+
array2Values,
|
|
6709
|
+
noCalculate
|
|
6710
|
+
} = getTwoArrayNumberValues(
|
|
6711
|
+
array1,
|
|
6712
|
+
array2,
|
|
6713
|
+
array1RowCount * array1ColumnCount,
|
|
6714
|
+
array1ColumnCount,
|
|
6715
|
+
array2ColumnCount
|
|
6716
|
+
);
|
|
6717
|
+
return isError ? errorObject : noCalculate ? ErrorValueObject.create(ErrorType$1.DIV_BY_ZERO) : this._getResult(array1Values, array2Values);
|
|
6718
|
+
}
|
|
6719
|
+
_getResult(array1Values, array2Values) {
|
|
6720
|
+
if (array1Values.length === 0)
|
|
6721
|
+
return ErrorValueObject.create(ErrorType$1.DIV_BY_ZERO);
|
|
6722
|
+
const n = array1Values.length;
|
|
6723
|
+
let array1Sum = 0, array2Sum = 0;
|
|
6724
|
+
for (let i = 0; i < n; i++)
|
|
6725
|
+
array1Sum += array1Values[i], array2Sum += array2Values[i];
|
|
6726
|
+
const array1Mean = array1Sum / n, array2Mean = array2Sum / n;
|
|
6727
|
+
let numerator = 0;
|
|
6728
|
+
for (let i = 0; i < n; i++) {
|
|
6729
|
+
const array1Diff = array1Values[i] - array1Mean, array2Diff = array2Values[i] - array2Mean;
|
|
6730
|
+
numerator += array1Diff * array2Diff;
|
|
6731
|
+
}
|
|
6732
|
+
return NumberValueObject.create(numerator / n);
|
|
6733
|
+
}
|
|
6734
|
+
};
|
|
6735
|
+
__name(_CovarianceP, "CovarianceP");
|
|
6736
|
+
let CovarianceP = _CovarianceP;
|
|
6737
|
+
const _ExponDist = class _ExponDist extends BaseFunction {
|
|
6738
|
+
constructor() {
|
|
6739
|
+
super(...arguments);
|
|
6740
|
+
__publicField(this, "minParams", 3);
|
|
6741
|
+
__publicField(this, "maxParams", 3);
|
|
6742
|
+
}
|
|
6743
|
+
calculate(x, lambda, cumulative) {
|
|
6744
|
+
const maxRowLength = Math.max(
|
|
6745
|
+
x.isArray() ? x.getRowCount() : 1,
|
|
6746
|
+
lambda.isArray() ? lambda.getRowCount() : 1,
|
|
6747
|
+
cumulative.isArray() ? cumulative.getRowCount() : 1
|
|
6748
|
+
), maxColumnLength = Math.max(
|
|
6749
|
+
x.isArray() ? x.getColumnCount() : 1,
|
|
6750
|
+
lambda.isArray() ? lambda.getColumnCount() : 1,
|
|
6751
|
+
cumulative.isArray() ? cumulative.getColumnCount() : 1
|
|
6752
|
+
), xArray = expandArrayValueObject(maxRowLength, maxColumnLength, x, ErrorValueObject.create(ErrorType$1.NA)), lambdaArray = expandArrayValueObject(maxRowLength, maxColumnLength, lambda, ErrorValueObject.create(ErrorType$1.NA)), cumulativeArray = expandArrayValueObject(maxRowLength, maxColumnLength, cumulative, ErrorValueObject.create(ErrorType$1.NA)), resultArray = xArray.mapValue((xObject, rowIndex, columnIndex) => {
|
|
6753
|
+
const lambdaObject = lambdaArray.get(rowIndex, columnIndex), cumulativeObject = cumulativeArray.get(rowIndex, columnIndex);
|
|
6754
|
+
return this._handleSignleObject(xObject, lambdaObject, cumulativeObject);
|
|
6755
|
+
});
|
|
6756
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
6757
|
+
}
|
|
6758
|
+
_handleSignleObject(xObject, lambdaObject, cumulativeObject) {
|
|
6759
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(xObject, lambdaObject, cumulativeObject);
|
|
6760
|
+
if (isError)
|
|
6761
|
+
return errorObject;
|
|
6762
|
+
const [_xObject, _lambdaObject, _cumulativeObject] = variants, xValue = +_xObject.getValue(), lambdaValue = +_lambdaObject.getValue(), cumulativeValue = +_cumulativeObject.getValue();
|
|
6763
|
+
if (xValue < 0 || lambdaValue <= 0)
|
|
6764
|
+
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
6765
|
+
let result;
|
|
6766
|
+
return cumulativeValue ? result = exponentialCDF(xValue, lambdaValue) : result = exponentialPDF(xValue, lambdaValue), NumberValueObject.create(result);
|
|
6767
|
+
}
|
|
6768
|
+
};
|
|
6769
|
+
__name(_ExponDist, "ExponDist");
|
|
6770
|
+
let ExponDist = _ExponDist;
|
|
6771
|
+
const _FDistRt = class _FDistRt extends BaseFunction {
|
|
6772
|
+
constructor() {
|
|
6773
|
+
super(...arguments);
|
|
6774
|
+
__publicField(this, "minParams", 3);
|
|
6775
|
+
__publicField(this, "maxParams", 3);
|
|
6776
|
+
}
|
|
6777
|
+
calculate(x, degFreedom1, degFreedom2) {
|
|
6778
|
+
const maxRowLength = Math.max(
|
|
6779
|
+
x.isArray() ? x.getRowCount() : 1,
|
|
6780
|
+
degFreedom1.isArray() ? degFreedom1.getRowCount() : 1,
|
|
6781
|
+
degFreedom2.isArray() ? degFreedom2.getRowCount() : 1
|
|
6782
|
+
), maxColumnLength = Math.max(
|
|
6783
|
+
x.isArray() ? x.getColumnCount() : 1,
|
|
6784
|
+
degFreedom1.isArray() ? degFreedom1.getColumnCount() : 1,
|
|
6785
|
+
degFreedom2.isArray() ? degFreedom2.getColumnCount() : 1
|
|
6786
|
+
), xArray = expandArrayValueObject(maxRowLength, maxColumnLength, x, ErrorValueObject.create(ErrorType$1.NA)), degFreedom1Array = expandArrayValueObject(maxRowLength, maxColumnLength, degFreedom1, ErrorValueObject.create(ErrorType$1.NA)), degFreedom2Array = expandArrayValueObject(maxRowLength, maxColumnLength, degFreedom2, ErrorValueObject.create(ErrorType$1.NA)), resultArray = xArray.mapValue((xObject, rowIndex, columnIndex) => {
|
|
6787
|
+
const degFreedom1Object = degFreedom1Array.get(rowIndex, columnIndex), degFreedom2Object = degFreedom2Array.get(rowIndex, columnIndex);
|
|
6788
|
+
return this._handleSignleObject(xObject, degFreedom1Object, degFreedom2Object);
|
|
6789
|
+
});
|
|
6790
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
6791
|
+
}
|
|
6792
|
+
_handleSignleObject(xObject, degFreedom1Object, degFreedom2Object) {
|
|
6793
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(xObject, degFreedom1Object, degFreedom2Object);
|
|
6794
|
+
if (isError)
|
|
6795
|
+
return errorObject;
|
|
6796
|
+
const [_xObject, _degFreedom1Object, _degFreedom2Object] = variants, xValue = +_xObject.getValue(), degFreedom1Value = Math.floor(+_degFreedom1Object.getValue()), degFreedom2Value = Math.floor(+_degFreedom2Object.getValue());
|
|
6797
|
+
if (xValue < 0 || degFreedom1Value < 1 || degFreedom1Value > 10 ** 10 || degFreedom2Value < 1 || degFreedom2Value > 10 ** 10)
|
|
6798
|
+
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
6799
|
+
const result = 1 - centralFCDF(xValue, degFreedom1Value, degFreedom2Value);
|
|
6800
|
+
return NumberValueObject.create(result);
|
|
6801
|
+
}
|
|
6802
|
+
};
|
|
6803
|
+
__name(_FDistRt, "FDistRt");
|
|
6804
|
+
let FDistRt = _FDistRt;
|
|
6805
|
+
const _FInvRt = class _FInvRt extends BaseFunction {
|
|
6806
|
+
constructor() {
|
|
6807
|
+
super(...arguments);
|
|
6808
|
+
__publicField(this, "minParams", 3);
|
|
6809
|
+
__publicField(this, "maxParams", 3);
|
|
6810
|
+
}
|
|
6811
|
+
calculate(probability, degFreedom1, degFreedom2) {
|
|
6812
|
+
const maxRowLength = Math.max(
|
|
6813
|
+
probability.isArray() ? probability.getRowCount() : 1,
|
|
6814
|
+
degFreedom1.isArray() ? degFreedom1.getRowCount() : 1,
|
|
6815
|
+
degFreedom2.isArray() ? degFreedom2.getRowCount() : 1
|
|
6816
|
+
), maxColumnLength = Math.max(
|
|
6817
|
+
probability.isArray() ? probability.getColumnCount() : 1,
|
|
6818
|
+
degFreedom1.isArray() ? degFreedom1.getColumnCount() : 1,
|
|
6819
|
+
degFreedom2.isArray() ? degFreedom2.getColumnCount() : 1
|
|
6820
|
+
), probabilityArray = expandArrayValueObject(maxRowLength, maxColumnLength, probability, ErrorValueObject.create(ErrorType$1.NA)), degFreedom1Array = expandArrayValueObject(maxRowLength, maxColumnLength, degFreedom1, ErrorValueObject.create(ErrorType$1.NA)), degFreedom2Array = expandArrayValueObject(maxRowLength, maxColumnLength, degFreedom2, ErrorValueObject.create(ErrorType$1.NA)), resultArray = probabilityArray.mapValue((probabilityObject, rowIndex, columnIndex) => {
|
|
6821
|
+
const degFreedom1Object = degFreedom1Array.get(rowIndex, columnIndex), degFreedom2Object = degFreedom2Array.get(rowIndex, columnIndex);
|
|
6822
|
+
return this._handleSignleObject(probabilityObject, degFreedom1Object, degFreedom2Object);
|
|
6823
|
+
});
|
|
6824
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
6825
|
+
}
|
|
6826
|
+
_handleSignleObject(probabilityObject, degFreedom1Object, degFreedom2Object) {
|
|
6827
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(probabilityObject, degFreedom1Object, degFreedom2Object);
|
|
6828
|
+
if (isError)
|
|
6829
|
+
return errorObject;
|
|
6830
|
+
const [_probabilityObject, _degFreedom1Object, _degFreedom2Object] = variants, probabilityValue = +_probabilityObject.getValue(), degFreedom1Value = Math.floor(+_degFreedom1Object.getValue()), degFreedom2Value = Math.floor(+_degFreedom2Object.getValue());
|
|
6831
|
+
if (probabilityValue < 0 || probabilityValue > 1 || degFreedom1Value < 1 || degFreedom1Value > 10 ** 10 || degFreedom2Value < 1 || degFreedom2Value > 10 ** 10)
|
|
6832
|
+
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
6833
|
+
const result = centralFINV(1 - probabilityValue, degFreedom1Value, degFreedom2Value);
|
|
6834
|
+
return Number.isNaN(result) || !Number.isFinite(result) ? ErrorValueObject.create(ErrorType$1.NUM) : NumberValueObject.create(result);
|
|
6835
|
+
}
|
|
6836
|
+
};
|
|
6837
|
+
__name(_FInvRt, "FInvRt");
|
|
6838
|
+
let FInvRt = _FInvRt;
|
|
6839
|
+
const _FTest = class _FTest extends BaseFunction {
|
|
6840
|
+
constructor() {
|
|
6841
|
+
super(...arguments);
|
|
6842
|
+
__publicField(this, "minParams", 2);
|
|
6843
|
+
__publicField(this, "maxParams", 2);
|
|
6844
|
+
}
|
|
6845
|
+
calculate(array1, array2) {
|
|
6846
|
+
const {
|
|
6847
|
+
isError: isError_array1,
|
|
6848
|
+
errorObject: errorObject_array1,
|
|
6849
|
+
variance: variance_array1,
|
|
6850
|
+
ns1: ns1_array1
|
|
6851
|
+
} = this._getValues(array1);
|
|
6852
|
+
if (isError_array1)
|
|
6853
|
+
return errorObject_array1;
|
|
6854
|
+
const {
|
|
6855
|
+
isError: isError_array2,
|
|
6856
|
+
errorObject: errorObject_array2,
|
|
6857
|
+
variance: variance_array2,
|
|
6858
|
+
ns1: ns1_array2
|
|
6859
|
+
} = this._getValues(array2);
|
|
6860
|
+
if (isError_array2)
|
|
6861
|
+
return errorObject_array2;
|
|
6862
|
+
let result = 2 * (1 - centralFCDF(variance_array1 / variance_array2, ns1_array1, ns1_array2));
|
|
6863
|
+
return result > 1 && (result = 2 - result), NumberValueObject.create(result);
|
|
6864
|
+
}
|
|
6865
|
+
// eslint-disable-next-line
|
|
6866
|
+
_getValues(array) {
|
|
6867
|
+
let variance = 0, ns1 = 0;
|
|
6868
|
+
const arrayRowCount = array.isArray() ? array.getRowCount() : 1, arrayColumnCount = array.isArray() ? array.getColumnCount() : 1;
|
|
6869
|
+
if (arrayRowCount === 1 && arrayColumnCount === 1) {
|
|
6870
|
+
const _array = array.isArray() ? array.get(0, 0) : array;
|
|
6871
|
+
return _array.isError() ? {
|
|
6872
|
+
isError: !0,
|
|
6873
|
+
errorObject: _array,
|
|
6874
|
+
variance,
|
|
6875
|
+
ns1
|
|
6876
|
+
} : _array.isNull() ? {
|
|
6877
|
+
isError: !0,
|
|
6878
|
+
errorObject: ErrorValueObject.create(ErrorType$1.VALUE),
|
|
6879
|
+
variance,
|
|
6880
|
+
ns1
|
|
6881
|
+
} : {
|
|
6882
|
+
isError: !0,
|
|
6883
|
+
errorObject: ErrorValueObject.create(ErrorType$1.DIV_BY_ZERO),
|
|
6884
|
+
variance,
|
|
6885
|
+
ns1
|
|
6886
|
+
};
|
|
6887
|
+
}
|
|
6888
|
+
const values = [];
|
|
6889
|
+
let sum2 = 0;
|
|
6890
|
+
for (let r = 0; r < arrayRowCount; r++)
|
|
6891
|
+
for (let c = 0; c < arrayColumnCount; c++) {
|
|
6892
|
+
const valueObject = array.isArray() ? array.get(r, c) : array;
|
|
6893
|
+
if (valueObject.isError())
|
|
6894
|
+
return {
|
|
6895
|
+
isError: !0,
|
|
6896
|
+
errorObject: valueObject,
|
|
6897
|
+
variance,
|
|
6898
|
+
ns1
|
|
6899
|
+
};
|
|
6900
|
+
if (valueObject.isNull() || valueObject.isBoolean())
|
|
6901
|
+
continue;
|
|
6902
|
+
const value = valueObject.getValue();
|
|
6903
|
+
isRealNum(value) && (values.push(+value), sum2 += +value);
|
|
6904
|
+
}
|
|
6905
|
+
if (values.length <= 1)
|
|
6906
|
+
return {
|
|
6907
|
+
isError: !0,
|
|
6908
|
+
errorObject: ErrorValueObject.create(ErrorType$1.DIV_BY_ZERO),
|
|
6909
|
+
variance,
|
|
6910
|
+
ns1
|
|
6911
|
+
};
|
|
6912
|
+
const mean = sum2 / values.length;
|
|
6913
|
+
let sumSquares = 0;
|
|
6914
|
+
for (let i = 0; i < values.length; i++)
|
|
6915
|
+
sumSquares += (values[i] - mean) ** 2;
|
|
6916
|
+
return ns1 = values.length - 1, variance = sumSquares / ns1, variance === 0 ? {
|
|
6917
|
+
isError: !0,
|
|
6918
|
+
errorObject: ErrorValueObject.create(ErrorType$1.DIV_BY_ZERO),
|
|
6919
|
+
variance,
|
|
6920
|
+
ns1
|
|
6921
|
+
} : {
|
|
6922
|
+
isError: !1,
|
|
6923
|
+
errorObject: null,
|
|
6924
|
+
variance,
|
|
6925
|
+
ns1
|
|
6926
|
+
};
|
|
6927
|
+
}
|
|
6928
|
+
};
|
|
6929
|
+
__name(_FTest, "FTest");
|
|
6930
|
+
let FTest = _FTest;
|
|
6931
|
+
const _NormDist = class _NormDist extends BaseFunction {
|
|
6932
|
+
constructor() {
|
|
6933
|
+
super(...arguments);
|
|
6934
|
+
__publicField(this, "minParams", 4);
|
|
6935
|
+
__publicField(this, "maxParams", 4);
|
|
6936
|
+
}
|
|
6937
|
+
calculate(x, mean, standardDev, cumulative) {
|
|
6938
|
+
const maxRowLength = Math.max(
|
|
6939
|
+
x.isArray() ? x.getRowCount() : 1,
|
|
6940
|
+
mean.isArray() ? mean.getRowCount() : 1,
|
|
6941
|
+
standardDev.isArray() ? standardDev.getRowCount() : 1,
|
|
6942
|
+
cumulative.isArray() ? cumulative.getRowCount() : 1
|
|
6943
|
+
), maxColumnLength = Math.max(
|
|
6944
|
+
x.isArray() ? x.getColumnCount() : 1,
|
|
6945
|
+
mean.isArray() ? mean.getColumnCount() : 1,
|
|
6946
|
+
standardDev.isArray() ? standardDev.getColumnCount() : 1,
|
|
6947
|
+
cumulative.isArray() ? cumulative.getColumnCount() : 1
|
|
6948
|
+
), xArray = expandArrayValueObject(maxRowLength, maxColumnLength, x, ErrorValueObject.create(ErrorType$1.NA)), meanArray = expandArrayValueObject(maxRowLength, maxColumnLength, mean, ErrorValueObject.create(ErrorType$1.NA)), standardDevArray = expandArrayValueObject(maxRowLength, maxColumnLength, standardDev, ErrorValueObject.create(ErrorType$1.NA)), cumulativeArray = expandArrayValueObject(maxRowLength, maxColumnLength, cumulative, ErrorValueObject.create(ErrorType$1.NA)), resultArray = xArray.mapValue((xObject, rowIndex, columnIndex) => {
|
|
6949
|
+
const meanObject = meanArray.get(rowIndex, columnIndex), standardDevObject = standardDevArray.get(rowIndex, columnIndex), cumulativeObject = cumulativeArray.get(rowIndex, columnIndex);
|
|
6950
|
+
return this._handleSignleObject(xObject, meanObject, standardDevObject, cumulativeObject);
|
|
6951
|
+
});
|
|
6952
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
6953
|
+
}
|
|
6954
|
+
_handleSignleObject(xObject, meanObject, standardDevObject, cumulativeObject) {
|
|
6955
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(xObject, meanObject, standardDevObject, cumulativeObject);
|
|
6956
|
+
if (isError)
|
|
6957
|
+
return errorObject;
|
|
6958
|
+
const [_xObject, _meanObject, _standardDevObject, _cumulativeObject] = variants, xValue = +_xObject.getValue(), meanValue = +_meanObject.getValue(), standardDevValue = +_standardDevObject.getValue(), cumulativeValue = +_cumulativeObject.getValue();
|
|
6959
|
+
if (standardDevValue <= 0)
|
|
6960
|
+
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
6961
|
+
let result;
|
|
6962
|
+
return cumulativeValue ? result = normalCDF(xValue, meanValue, standardDevValue) : result = normalPDF(xValue, meanValue, standardDevValue), NumberValueObject.create(result);
|
|
6963
|
+
}
|
|
6964
|
+
};
|
|
6965
|
+
__name(_NormDist, "NormDist");
|
|
6966
|
+
let NormDist = _NormDist;
|
|
6967
|
+
const _NormInv = class _NormInv extends BaseFunction {
|
|
6968
|
+
constructor() {
|
|
6969
|
+
super(...arguments);
|
|
6970
|
+
__publicField(this, "minParams", 3);
|
|
6971
|
+
__publicField(this, "maxParams", 3);
|
|
6972
|
+
}
|
|
6973
|
+
calculate(probability, mean, standardDev) {
|
|
6974
|
+
const maxRowLength = Math.max(
|
|
6975
|
+
probability.isArray() ? probability.getRowCount() : 1,
|
|
6976
|
+
mean.isArray() ? mean.getRowCount() : 1,
|
|
6977
|
+
standardDev.isArray() ? standardDev.getRowCount() : 1
|
|
6978
|
+
), maxColumnLength = Math.max(
|
|
6979
|
+
probability.isArray() ? probability.getColumnCount() : 1,
|
|
6980
|
+
mean.isArray() ? mean.getColumnCount() : 1,
|
|
6981
|
+
standardDev.isArray() ? standardDev.getColumnCount() : 1
|
|
6982
|
+
), probabilityArray = expandArrayValueObject(maxRowLength, maxColumnLength, probability, ErrorValueObject.create(ErrorType$1.NA)), meanArray = expandArrayValueObject(maxRowLength, maxColumnLength, mean, ErrorValueObject.create(ErrorType$1.NA)), standardDevArray = expandArrayValueObject(maxRowLength, maxColumnLength, standardDev, ErrorValueObject.create(ErrorType$1.NA)), resultArray = probabilityArray.mapValue((probabilityObject, rowIndex, columnIndex) => {
|
|
6983
|
+
const meanObject = meanArray.get(rowIndex, columnIndex), standardDevObject = standardDevArray.get(rowIndex, columnIndex);
|
|
6984
|
+
return this._handleSignleObject(probabilityObject, meanObject, standardDevObject);
|
|
6985
|
+
});
|
|
6986
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
6987
|
+
}
|
|
6988
|
+
_handleSignleObject(probabilityObject, meanObject, standardDevObject) {
|
|
6989
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(probabilityObject, meanObject, standardDevObject);
|
|
6990
|
+
if (isError)
|
|
6991
|
+
return errorObject;
|
|
6992
|
+
const [_probabilityObject, _meanObject, _standardDevObject] = variants, probabilityValue = +_probabilityObject.getValue(), meanValue = +_meanObject.getValue(), standardDevValue = +_standardDevObject.getValue();
|
|
6993
|
+
if (probabilityValue <= 0 || probabilityValue >= 1 || standardDevValue <= 0)
|
|
6994
|
+
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
6995
|
+
const result = normalINV(probabilityValue, meanValue, standardDevValue);
|
|
6996
|
+
return NumberValueObject.create(result);
|
|
6997
|
+
}
|
|
6998
|
+
};
|
|
6999
|
+
__name(_NormInv, "NormInv");
|
|
7000
|
+
let NormInv = _NormInv;
|
|
7001
|
+
const _NormSInv = class _NormSInv extends BaseFunction {
|
|
7002
|
+
constructor() {
|
|
7003
|
+
super(...arguments);
|
|
7004
|
+
__publicField(this, "minParams", 1);
|
|
7005
|
+
__publicField(this, "maxParams", 1);
|
|
7006
|
+
}
|
|
7007
|
+
calculate(probability) {
|
|
7008
|
+
if (probability.isArray()) {
|
|
7009
|
+
const resultArray = probability.mapValue((probabilityObject) => this._handleSignleObject(probabilityObject));
|
|
7010
|
+
return probability.getRowCount() === 1 && probability.getColumnCount() === 1 ? resultArray.get(0, 0) : resultArray;
|
|
7011
|
+
}
|
|
7012
|
+
return this._handleSignleObject(probability);
|
|
7013
|
+
}
|
|
7014
|
+
_handleSignleObject(probabilityObject) {
|
|
7015
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(probabilityObject);
|
|
7016
|
+
if (isError)
|
|
7017
|
+
return errorObject;
|
|
7018
|
+
const [_probabilityObject] = variants, probabilityValue = +_probabilityObject.getValue();
|
|
7019
|
+
if (probabilityValue <= 0 || probabilityValue >= 1)
|
|
7020
|
+
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
7021
|
+
const result = normalINV(probabilityValue, 0, 1);
|
|
7022
|
+
return NumberValueObject.create(result);
|
|
7023
|
+
}
|
|
7024
|
+
};
|
|
7025
|
+
__name(_NormSInv, "NormSInv");
|
|
7026
|
+
let NormSInv = _NormSInv;
|
|
7027
|
+
const _StdevP = class _StdevP extends BaseFunction {
|
|
7028
|
+
constructor() {
|
|
7029
|
+
super(...arguments);
|
|
7030
|
+
__publicField(this, "minParams", 1);
|
|
7031
|
+
__publicField(this, "maxParams", 255);
|
|
7032
|
+
}
|
|
7033
|
+
calculate(...variants) {
|
|
7034
|
+
const flattenArray = this.flattenArray(variants);
|
|
7035
|
+
return flattenArray.isError() ? flattenArray : flattenArray.std();
|
|
7036
|
+
}
|
|
7037
|
+
};
|
|
7038
|
+
__name(_StdevP, "StdevP");
|
|
7039
|
+
let StdevP = _StdevP;
|
|
7040
|
+
const _StdevS = class _StdevS extends BaseFunction {
|
|
7041
|
+
constructor() {
|
|
7042
|
+
super(...arguments);
|
|
7043
|
+
__publicField(this, "minParams", 1);
|
|
7044
|
+
__publicField(this, "maxParams", 255);
|
|
7045
|
+
}
|
|
7046
|
+
calculate(...variants) {
|
|
7047
|
+
const flattenArray = this.flattenArray(variants);
|
|
7048
|
+
return flattenArray.isError() ? flattenArray : flattenArray.std(1);
|
|
7049
|
+
}
|
|
7050
|
+
};
|
|
7051
|
+
__name(_StdevS, "StdevS");
|
|
7052
|
+
let StdevS = _StdevS;
|
|
5780
7053
|
const _VarP = class _VarP extends BaseFunction {
|
|
5781
7054
|
constructor() {
|
|
5782
7055
|
super(...arguments);
|
|
@@ -5803,6 +7076,70 @@ const _VarS = class _VarS extends BaseFunction {
|
|
|
5803
7076
|
};
|
|
5804
7077
|
__name(_VarS, "VarS");
|
|
5805
7078
|
let VarS = _VarS;
|
|
7079
|
+
const _Betadist = class _Betadist extends BaseFunction {
|
|
7080
|
+
constructor() {
|
|
7081
|
+
super(...arguments);
|
|
7082
|
+
__publicField(this, "minParams", 3);
|
|
7083
|
+
__publicField(this, "maxParams", 5);
|
|
7084
|
+
}
|
|
7085
|
+
calculate(x, alpha, beta, A, B) {
|
|
7086
|
+
let _A = A != null ? A : NumberValueObject.create(0), _B = B != null ? B : NumberValueObject.create(1);
|
|
7087
|
+
_A.isNull() && (_A = NumberValueObject.create(0)), _B.isNull() && (_B = NumberValueObject.create(1));
|
|
7088
|
+
const maxRowLength = Math.max(
|
|
7089
|
+
x.isArray() ? x.getRowCount() : 1,
|
|
7090
|
+
alpha.isArray() ? alpha.getRowCount() : 1,
|
|
7091
|
+
beta.isArray() ? beta.getRowCount() : 1,
|
|
7092
|
+
_A.isArray() ? _A.getRowCount() : 1,
|
|
7093
|
+
_B.isArray() ? _B.getRowCount() : 1
|
|
7094
|
+
), maxColumnLength = Math.max(
|
|
7095
|
+
x.isArray() ? x.getColumnCount() : 1,
|
|
7096
|
+
alpha.isArray() ? alpha.getColumnCount() : 1,
|
|
7097
|
+
beta.isArray() ? beta.getColumnCount() : 1,
|
|
7098
|
+
_A.isArray() ? _A.getColumnCount() : 1,
|
|
7099
|
+
_B.isArray() ? _B.getColumnCount() : 1
|
|
7100
|
+
), xArray = expandArrayValueObject(maxRowLength, maxColumnLength, x, ErrorValueObject.create(ErrorType$1.NA)), alphaArray = expandArrayValueObject(maxRowLength, maxColumnLength, alpha, ErrorValueObject.create(ErrorType$1.NA)), betaArray = expandArrayValueObject(maxRowLength, maxColumnLength, beta, ErrorValueObject.create(ErrorType$1.NA)), AArray = expandArrayValueObject(maxRowLength, maxColumnLength, _A, ErrorValueObject.create(ErrorType$1.NA)), BArray = expandArrayValueObject(maxRowLength, maxColumnLength, _B, ErrorValueObject.create(ErrorType$1.NA)), resultArray = xArray.mapValue((xObject, rowIndex, columnIndex) => {
|
|
7101
|
+
const alphaObject = alphaArray.get(rowIndex, columnIndex), betaObject = betaArray.get(rowIndex, columnIndex), AObject = AArray.get(rowIndex, columnIndex), BObject = BArray.get(rowIndex, columnIndex);
|
|
7102
|
+
return this._handleSignleObject(xObject, alphaObject, betaObject, AObject, BObject);
|
|
7103
|
+
});
|
|
7104
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
7105
|
+
}
|
|
7106
|
+
_handleSignleObject(xObject, alphaObject, betaObject, AObject, BObject) {
|
|
7107
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(xObject, alphaObject, betaObject, AObject, BObject);
|
|
7108
|
+
if (isError)
|
|
7109
|
+
return errorObject;
|
|
7110
|
+
const [_xObject, _alphaObject, _betaObject, _AObject, _BObject] = variants, xValue = +_xObject.getValue(), alphaValue = +_alphaObject.getValue(), betaValue = +_betaObject.getValue(), AValue = +_AObject.getValue(), BValue = +_BObject.getValue();
|
|
7111
|
+
if (alphaValue <= 0 || betaValue <= 0 || xValue < AValue || xValue > BValue || AValue === BValue)
|
|
7112
|
+
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
7113
|
+
const result = betaCDF((xValue - AValue) / (BValue - AValue), alphaValue, betaValue);
|
|
7114
|
+
return NumberValueObject.create(result);
|
|
7115
|
+
}
|
|
7116
|
+
};
|
|
7117
|
+
__name(_Betadist, "Betadist");
|
|
7118
|
+
let Betadist = _Betadist;
|
|
7119
|
+
var FUNCTION_NAMES_COMPATIBILITY = /* @__PURE__ */ ((FUNCTION_NAMES_COMPATIBILITY2) => (FUNCTION_NAMES_COMPATIBILITY2.BETADIST = "BETADIST", FUNCTION_NAMES_COMPATIBILITY2.BETAINV = "BETAINV", FUNCTION_NAMES_COMPATIBILITY2.BINOMDIST = "BINOMDIST", FUNCTION_NAMES_COMPATIBILITY2.CHIDIST = "CHIDIST", FUNCTION_NAMES_COMPATIBILITY2.CHIINV = "CHIINV", FUNCTION_NAMES_COMPATIBILITY2.CHITEST = "CHITEST", FUNCTION_NAMES_COMPATIBILITY2.CONFIDENCE = "CONFIDENCE", FUNCTION_NAMES_COMPATIBILITY2.COVAR = "COVAR", FUNCTION_NAMES_COMPATIBILITY2.CRITBINOM = "CRITBINOM", FUNCTION_NAMES_COMPATIBILITY2.EXPONDIST = "EXPONDIST", FUNCTION_NAMES_COMPATIBILITY2.FDIST = "FDIST", FUNCTION_NAMES_COMPATIBILITY2.FINV = "FINV", FUNCTION_NAMES_COMPATIBILITY2.FTEST = "FTEST", FUNCTION_NAMES_COMPATIBILITY2.GAMMADIST = "GAMMADIST", FUNCTION_NAMES_COMPATIBILITY2.GAMMAINV = "GAMMAINV", FUNCTION_NAMES_COMPATIBILITY2.HYPGEOMDIST = "HYPGEOMDIST", FUNCTION_NAMES_COMPATIBILITY2.LOGINV = "LOGINV", FUNCTION_NAMES_COMPATIBILITY2.LOGNORMDIST = "LOGNORMDIST", FUNCTION_NAMES_COMPATIBILITY2.MODE = "MODE", FUNCTION_NAMES_COMPATIBILITY2.NEGBINOMDIST = "NEGBINOMDIST", FUNCTION_NAMES_COMPATIBILITY2.NORMDIST = "NORMDIST", FUNCTION_NAMES_COMPATIBILITY2.NORMINV = "NORMINV", FUNCTION_NAMES_COMPATIBILITY2.NORMSDIST = "NORMSDIST", FUNCTION_NAMES_COMPATIBILITY2.NORMSINV = "NORMSINV", FUNCTION_NAMES_COMPATIBILITY2.PERCENTILE = "PERCENTILE", FUNCTION_NAMES_COMPATIBILITY2.PERCENTRANK = "PERCENTRANK", FUNCTION_NAMES_COMPATIBILITY2.POISSON = "POISSON", FUNCTION_NAMES_COMPATIBILITY2.QUARTILE = "QUARTILE", FUNCTION_NAMES_COMPATIBILITY2.RANK = "RANK", FUNCTION_NAMES_COMPATIBILITY2.STDEV = "STDEV", FUNCTION_NAMES_COMPATIBILITY2.STDEVP = "STDEVP", FUNCTION_NAMES_COMPATIBILITY2.TDIST = "TDIST", FUNCTION_NAMES_COMPATIBILITY2.TINV = "TINV", FUNCTION_NAMES_COMPATIBILITY2.TTEST = "TTEST", FUNCTION_NAMES_COMPATIBILITY2.VAR = "VAR", FUNCTION_NAMES_COMPATIBILITY2.VARP = "VARP", FUNCTION_NAMES_COMPATIBILITY2.WEIBULL = "WEIBULL", FUNCTION_NAMES_COMPATIBILITY2.ZTEST = "ZTEST", FUNCTION_NAMES_COMPATIBILITY2))(FUNCTION_NAMES_COMPATIBILITY || {});
|
|
7120
|
+
const _Normsdist = class _Normsdist extends BaseFunction {
|
|
7121
|
+
constructor() {
|
|
7122
|
+
super(...arguments);
|
|
7123
|
+
__publicField(this, "minParams", 1);
|
|
7124
|
+
__publicField(this, "maxParams", 1);
|
|
7125
|
+
}
|
|
7126
|
+
calculate(z) {
|
|
7127
|
+
if (z.isArray()) {
|
|
7128
|
+
const resultArray = z.mapValue((zObject) => this._handleSignleObject(zObject));
|
|
7129
|
+
return z.getRowCount() === 1 && z.getColumnCount() === 1 ? resultArray.get(0, 0) : resultArray;
|
|
7130
|
+
}
|
|
7131
|
+
return this._handleSignleObject(z);
|
|
7132
|
+
}
|
|
7133
|
+
_handleSignleObject(zObject) {
|
|
7134
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(zObject);
|
|
7135
|
+
if (isError)
|
|
7136
|
+
return errorObject;
|
|
7137
|
+
const [_zObject] = variants, zValue = +_zObject.getValue(), result = normalCDF(zValue, 0, 1);
|
|
7138
|
+
return NumberValueObject.create(result);
|
|
7139
|
+
}
|
|
7140
|
+
};
|
|
7141
|
+
__name(_Normsdist, "Normsdist");
|
|
7142
|
+
let Normsdist = _Normsdist;
|
|
5806
7143
|
const _Rank = class _Rank extends BaseFunction {
|
|
5807
7144
|
constructor() {
|
|
5808
7145
|
super(...arguments);
|
|
@@ -5864,8 +7201,24 @@ const _Rank = class _Rank extends BaseFunction {
|
|
|
5864
7201
|
};
|
|
5865
7202
|
__name(_Rank, "Rank");
|
|
5866
7203
|
let Rank = _Rank;
|
|
5867
|
-
var FUNCTION_NAMES_COMPATIBILITY = /* @__PURE__ */ ((FUNCTION_NAMES_COMPATIBILITY2) => (FUNCTION_NAMES_COMPATIBILITY2.BETADIST = "BETADIST", FUNCTION_NAMES_COMPATIBILITY2.BETAINV = "BETAINV", FUNCTION_NAMES_COMPATIBILITY2.BINOMDIST = "BINOMDIST", FUNCTION_NAMES_COMPATIBILITY2.CHIDIST = "CHIDIST", FUNCTION_NAMES_COMPATIBILITY2.CHIINV = "CHIINV", FUNCTION_NAMES_COMPATIBILITY2.CHITEST = "CHITEST", FUNCTION_NAMES_COMPATIBILITY2.CONFIDENCE = "CONFIDENCE", FUNCTION_NAMES_COMPATIBILITY2.COVAR = "COVAR", FUNCTION_NAMES_COMPATIBILITY2.CRITBINOM = "CRITBINOM", FUNCTION_NAMES_COMPATIBILITY2.EXPONDIST = "EXPONDIST", FUNCTION_NAMES_COMPATIBILITY2.FDIST = "FDIST", FUNCTION_NAMES_COMPATIBILITY2.FINV = "FINV", FUNCTION_NAMES_COMPATIBILITY2.FTEST = "FTEST", FUNCTION_NAMES_COMPATIBILITY2.GAMMADIST = "GAMMADIST", FUNCTION_NAMES_COMPATIBILITY2.GAMMAINV = "GAMMAINV", FUNCTION_NAMES_COMPATIBILITY2.HYPGEOMDIST = "HYPGEOMDIST", FUNCTION_NAMES_COMPATIBILITY2.LOGINV = "LOGINV", FUNCTION_NAMES_COMPATIBILITY2.LOGNORMDIST = "LOGNORMDIST", FUNCTION_NAMES_COMPATIBILITY2.MODE = "MODE", FUNCTION_NAMES_COMPATIBILITY2.NEGBINOMDIST = "NEGBINOMDIST", FUNCTION_NAMES_COMPATIBILITY2.NORMDIST = "NORMDIST", FUNCTION_NAMES_COMPATIBILITY2.NORMINV = "NORMINV", FUNCTION_NAMES_COMPATIBILITY2.NORMSDIST = "NORMSDIST", FUNCTION_NAMES_COMPATIBILITY2.NORMSINV = "NORMSINV", FUNCTION_NAMES_COMPATIBILITY2.PERCENTILE = "PERCENTILE", FUNCTION_NAMES_COMPATIBILITY2.PERCENTRANK = "PERCENTRANK", FUNCTION_NAMES_COMPATIBILITY2.POISSON = "POISSON", FUNCTION_NAMES_COMPATIBILITY2.QUARTILE = "QUARTILE", FUNCTION_NAMES_COMPATIBILITY2.RANK = "RANK", FUNCTION_NAMES_COMPATIBILITY2.STDEV = "STDEV", FUNCTION_NAMES_COMPATIBILITY2.STDEVP = "STDEVP", FUNCTION_NAMES_COMPATIBILITY2.TDIST = "TDIST", FUNCTION_NAMES_COMPATIBILITY2.TINV = "TINV", FUNCTION_NAMES_COMPATIBILITY2.TTEST = "TTEST", FUNCTION_NAMES_COMPATIBILITY2.VAR = "VAR", FUNCTION_NAMES_COMPATIBILITY2.VARP = "VARP", FUNCTION_NAMES_COMPATIBILITY2.WEIBULL = "WEIBULL", FUNCTION_NAMES_COMPATIBILITY2.ZTEST = "ZTEST", FUNCTION_NAMES_COMPATIBILITY2))(FUNCTION_NAMES_COMPATIBILITY || {});
|
|
5868
7204
|
const functionCompatibility = [
|
|
7205
|
+
[Betadist, FUNCTION_NAMES_COMPATIBILITY.BETADIST],
|
|
7206
|
+
[BetaInv, FUNCTION_NAMES_COMPATIBILITY.BETAINV],
|
|
7207
|
+
[BinomDist, FUNCTION_NAMES_COMPATIBILITY.BINOMDIST],
|
|
7208
|
+
[ChisqDistRt, FUNCTION_NAMES_COMPATIBILITY.CHIDIST],
|
|
7209
|
+
[ChisqInvRt, FUNCTION_NAMES_COMPATIBILITY.CHIINV],
|
|
7210
|
+
[ChisqTest, FUNCTION_NAMES_COMPATIBILITY.CHITEST],
|
|
7211
|
+
[ConfidenceNorm, FUNCTION_NAMES_COMPATIBILITY.CONFIDENCE],
|
|
7212
|
+
[CovarianceP, FUNCTION_NAMES_COMPATIBILITY.COVAR],
|
|
7213
|
+
[BinomInv, FUNCTION_NAMES_COMPATIBILITY.CRITBINOM],
|
|
7214
|
+
[ExponDist, FUNCTION_NAMES_COMPATIBILITY.EXPONDIST],
|
|
7215
|
+
[FDistRt, FUNCTION_NAMES_COMPATIBILITY.FDIST],
|
|
7216
|
+
[FInvRt, FUNCTION_NAMES_COMPATIBILITY.FINV],
|
|
7217
|
+
[FTest, FUNCTION_NAMES_COMPATIBILITY.FTEST],
|
|
7218
|
+
[NormDist, FUNCTION_NAMES_COMPATIBILITY.NORMDIST],
|
|
7219
|
+
[NormInv, FUNCTION_NAMES_COMPATIBILITY.NORMINV],
|
|
7220
|
+
[Normsdist, FUNCTION_NAMES_COMPATIBILITY.NORMSDIST],
|
|
7221
|
+
[NormSInv, FUNCTION_NAMES_COMPATIBILITY.NORMSINV],
|
|
5869
7222
|
[Rank, FUNCTION_NAMES_COMPATIBILITY.RANK],
|
|
5870
7223
|
[StdevS, FUNCTION_NAMES_COMPATIBILITY.STDEV],
|
|
5871
7224
|
[StdevP, FUNCTION_NAMES_COMPATIBILITY.STDEVP],
|
|
@@ -6955,480 +8308,201 @@ const _Workday = class _Workday extends BaseFunction {
|
|
|
6955
8308
|
const result = getDateSerialNumberByWorkingDays(startDateSerialNumber, workingDays);
|
|
6956
8309
|
return typeof result != "number" ? result : NumberValueObject.create(result);
|
|
6957
8310
|
}
|
|
6958
|
-
_getResultByHolidays(startDateSerialNumber, workingDays, holidays) {
|
|
6959
|
-
const holidaysValueArray = [];
|
|
6960
|
-
if (holidays != null && holidays.isArray()) {
|
|
6961
|
-
const rowCount = holidays.getRowCount(), columnCount = holidays.getColumnCount();
|
|
6962
|
-
for (let r = 0; r < rowCount; r++)
|
|
6963
|
-
for (let c = 0; c < columnCount; c++) {
|
|
6964
|
-
const cell = holidays.get(r, c);
|
|
6965
|
-
if (cell.isBoolean())
|
|
6966
|
-
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
6967
|
-
const holidaySerialNumber = getDateSerialNumberByObject(cell);
|
|
6968
|
-
if (typeof holidaySerialNumber != "number")
|
|
6969
|
-
return holidaySerialNumber;
|
|
6970
|
-
holidaysValueArray.push(holidaySerialNumber);
|
|
6971
|
-
}
|
|
6972
|
-
} else {
|
|
6973
|
-
if (holidays.isBoolean())
|
|
6974
|
-
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
6975
|
-
const holidaySerialNumber = getDateSerialNumberByObject(holidays);
|
|
6976
|
-
if (typeof holidaySerialNumber != "number")
|
|
6977
|
-
return holidaySerialNumber;
|
|
6978
|
-
holidaysValueArray.push(holidaySerialNumber);
|
|
6979
|
-
}
|
|
6980
|
-
const result = getDateSerialNumberByWorkingDays(startDateSerialNumber, workingDays, 1, holidaysValueArray);
|
|
6981
|
-
return typeof result != "number" ? result : NumberValueObject.create(result);
|
|
6982
|
-
}
|
|
6983
|
-
};
|
|
6984
|
-
__name(_Workday, "Workday");
|
|
6985
|
-
let Workday = _Workday;
|
|
6986
|
-
const _WorkdayIntl = class _WorkdayIntl extends BaseFunction {
|
|
6987
|
-
constructor() {
|
|
6988
|
-
super(...arguments);
|
|
6989
|
-
__publicField(this, "minParams", 2);
|
|
6990
|
-
__publicField(this, "maxParams", 4);
|
|
6991
|
-
}
|
|
6992
|
-
calculate(startDate, days, weekend, holidays) {
|
|
6993
|
-
return startDate.isError() ? startDate : days.isError() ? days : weekend != null && weekend.isError() ? weekend : holidays != null && holidays.isError() ? holidays : weekend != null && weekend.isArray() ? weekend.map((weekendItem) => this._handleSingleObject(startDate, days, weekendItem, holidays)) : this._handleSingleObject(startDate, days, weekend, holidays);
|
|
6994
|
-
}
|
|
6995
|
-
_handleSingleObject(startDate, days, weekend, holidays) {
|
|
6996
|
-
const _weekend = weekend != null ? weekend : NumberValueObject.create(1), _startDate = this._checkArrayError(startDate);
|
|
6997
|
-
if (_startDate.isError())
|
|
6998
|
-
return _startDate;
|
|
6999
|
-
const _days = this._checkArrayError(days);
|
|
7000
|
-
if (_days.isError())
|
|
7001
|
-
return _days;
|
|
7002
|
-
if (_startDate.isBoolean() || _days.isBoolean())
|
|
7003
|
-
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
7004
|
-
const startDateSerialNumber = getDateSerialNumberByObject(startDate);
|
|
7005
|
-
if (typeof startDateSerialNumber != "number")
|
|
7006
|
-
return startDateSerialNumber;
|
|
7007
|
-
const workingDays = +days.getValue();
|
|
7008
|
-
if (Number.isNaN(workingDays))
|
|
7009
|
-
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
7010
|
-
let weekendValue = _weekend.getValue();
|
|
7011
|
-
if (_weekend.isBoolean() && (weekendValue = +weekendValue), _weekend.isString() && (!isValidWeekend(weekendValue) || weekendValue === "1111111"))
|
|
7012
|
-
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
7013
|
-
if (!isValidWeekend(weekendValue))
|
|
7014
|
-
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
7015
|
-
if (holidays)
|
|
7016
|
-
return this._getResultByHolidays(startDateSerialNumber, workingDays, weekendValue, holidays);
|
|
7017
|
-
const result = getDateSerialNumberByWorkingDays(startDateSerialNumber, workingDays, weekendValue);
|
|
7018
|
-
return typeof result != "number" ? result : NumberValueObject.create(result);
|
|
7019
|
-
}
|
|
7020
|
-
_checkArrayError(variant) {
|
|
7021
|
-
let _variant = variant;
|
|
7022
|
-
if (_variant.isArray()) {
|
|
7023
|
-
const rowCount = _variant.getRowCount(), columnCount = _variant.getColumnCount();
|
|
7024
|
-
if (rowCount > 1 || columnCount > 1)
|
|
7025
|
-
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
7026
|
-
_variant = _variant.get(0, 0);
|
|
7027
|
-
}
|
|
7028
|
-
return _variant.isError(), _variant;
|
|
7029
|
-
}
|
|
7030
|
-
_getResultByHolidays(startDateSerialNumber, workingDays, weekendValue, holidays) {
|
|
7031
|
-
const holidaysValueArray = [];
|
|
7032
|
-
if (holidays != null && holidays.isArray()) {
|
|
7033
|
-
const rowCount = holidays.getRowCount(), columnCount = holidays.getColumnCount();
|
|
7034
|
-
for (let r = 0; r < rowCount; r++)
|
|
7035
|
-
for (let c = 0; c < columnCount; c++) {
|
|
7036
|
-
const cell = holidays.get(r, c);
|
|
7037
|
-
if (cell.isBoolean())
|
|
7038
|
-
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
7039
|
-
const holidaySerialNumber = getDateSerialNumberByObject(cell);
|
|
7040
|
-
if (typeof holidaySerialNumber != "number")
|
|
7041
|
-
return holidaySerialNumber;
|
|
7042
|
-
holidaysValueArray.push(holidaySerialNumber);
|
|
7043
|
-
}
|
|
7044
|
-
} else {
|
|
7045
|
-
if (holidays.isBoolean())
|
|
7046
|
-
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
7047
|
-
const holidaySerialNumber = getDateSerialNumberByObject(holidays);
|
|
7048
|
-
if (typeof holidaySerialNumber != "number")
|
|
7049
|
-
return holidaySerialNumber;
|
|
7050
|
-
holidaysValueArray.push(holidaySerialNumber);
|
|
7051
|
-
}
|
|
7052
|
-
const result = getDateSerialNumberByWorkingDays(startDateSerialNumber, workingDays, weekendValue, holidaysValueArray);
|
|
7053
|
-
return typeof result != "number" ? result : NumberValueObject.create(result);
|
|
7054
|
-
}
|
|
7055
|
-
};
|
|
7056
|
-
__name(_WorkdayIntl, "WorkdayIntl");
|
|
7057
|
-
let WorkdayIntl = _WorkdayIntl;
|
|
7058
|
-
const _Year = class _Year extends BaseFunction {
|
|
7059
|
-
constructor() {
|
|
7060
|
-
super(...arguments);
|
|
7061
|
-
__publicField(this, "minParams", 1);
|
|
7062
|
-
__publicField(this, "maxParams", 1);
|
|
7063
|
-
}
|
|
7064
|
-
calculate(serialNumber) {
|
|
7065
|
-
return serialNumber.isArray() ? serialNumber.map((serialNumberObject) => this._handleSingleObject(serialNumberObject)) : this._handleSingleObject(serialNumber);
|
|
7066
|
-
}
|
|
7067
|
-
_handleSingleObject(serialNumberObject) {
|
|
7068
|
-
if (serialNumberObject.isError())
|
|
7069
|
-
return serialNumberObject;
|
|
7070
|
-
let date;
|
|
7071
|
-
const dateValue = serialNumberObject.getValue();
|
|
7072
|
-
if (serialNumberObject.isString()) {
|
|
7073
|
-
if (!isValidDateStr(`${dateValue}`))
|
|
7074
|
-
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
7075
|
-
date = /* @__PURE__ */ new Date(`${dateValue}`);
|
|
7076
|
-
} else {
|
|
7077
|
-
const dateSerial = +dateValue;
|
|
7078
|
-
if (dateSerial < 0)
|
|
7079
|
-
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
7080
|
-
if (dateSerial === 0)
|
|
7081
|
-
return NumberValueObject.create(1900);
|
|
7082
|
-
date = excelSerialToDate(dateSerial);
|
|
7083
|
-
}
|
|
7084
|
-
const year = date.getUTCFullYear();
|
|
7085
|
-
return NumberValueObject.create(year);
|
|
7086
|
-
}
|
|
7087
|
-
};
|
|
7088
|
-
__name(_Year, "Year");
|
|
7089
|
-
let Year = _Year;
|
|
7090
|
-
function checkVariantErrorIsArray(variant) {
|
|
7091
|
-
let _variant = variant;
|
|
7092
|
-
if (variant.isArray()) {
|
|
7093
|
-
const rowCount = variant.getRowCount(), columnCount = variant.getColumnCount();
|
|
7094
|
-
if (rowCount > 1 || columnCount > 1)
|
|
7095
|
-
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
7096
|
-
_variant = variant.get(0, 0);
|
|
7097
|
-
}
|
|
7098
|
-
return _variant.isError(), _variant;
|
|
7099
|
-
}
|
|
7100
|
-
__name(checkVariantErrorIsArray, "checkVariantErrorIsArray");
|
|
7101
|
-
function checkVariantsErrorIsArrayOrBoolean(...variants) {
|
|
7102
|
-
for (let i = 0; i < variants.length; i++) {
|
|
7103
|
-
const variant = checkVariantErrorIsArray(variants[i]);
|
|
7104
|
-
if (variant.isError())
|
|
7105
|
-
return {
|
|
7106
|
-
isError: !0,
|
|
7107
|
-
errorObject: variant
|
|
7108
|
-
};
|
|
7109
|
-
if (variant.isBoolean())
|
|
7110
|
-
return {
|
|
7111
|
-
isError: !0,
|
|
7112
|
-
errorObject: ErrorValueObject.create(ErrorType$1.VALUE)
|
|
7113
|
-
};
|
|
7114
|
-
variants[i] = variant;
|
|
7115
|
-
}
|
|
7116
|
-
return {
|
|
7117
|
-
isError: !1,
|
|
7118
|
-
variants
|
|
7119
|
-
};
|
|
7120
|
-
}
|
|
7121
|
-
__name(checkVariantsErrorIsArrayOrBoolean, "checkVariantsErrorIsArrayOrBoolean");
|
|
7122
|
-
function checkVariantsErrorIsNullorArrayOrBoolean(...variants) {
|
|
7123
|
-
for (let i = 0; i < variants.length; i++) {
|
|
7124
|
-
let variant = variants[i];
|
|
7125
|
-
if (variant.isError())
|
|
7126
|
-
return {
|
|
7127
|
-
isError: !0,
|
|
7128
|
-
errorObject: variant
|
|
7129
|
-
};
|
|
7130
|
-
if (variant.isNull())
|
|
7131
|
-
return {
|
|
7132
|
-
isError: !0,
|
|
7133
|
-
errorObject: ErrorValueObject.create(ErrorType$1.NA)
|
|
7134
|
-
};
|
|
7135
|
-
if (variant = checkVariantErrorIsArray(variants[i]), variant.isError())
|
|
7136
|
-
return {
|
|
7137
|
-
isError: !0,
|
|
7138
|
-
errorObject: variant
|
|
7139
|
-
};
|
|
7140
|
-
if (variant.isBoolean())
|
|
7141
|
-
return {
|
|
7142
|
-
isError: !0,
|
|
7143
|
-
errorObject: ErrorValueObject.create(ErrorType$1.VALUE)
|
|
7144
|
-
};
|
|
7145
|
-
variants[i] = variant;
|
|
7146
|
-
}
|
|
7147
|
-
return {
|
|
7148
|
-
isError: !1,
|
|
7149
|
-
variants
|
|
7150
|
-
};
|
|
7151
|
-
}
|
|
7152
|
-
__name(checkVariantsErrorIsNullorArrayOrBoolean, "checkVariantsErrorIsNullorArrayOrBoolean");
|
|
7153
|
-
function checkVariantsErrorIsStringToNumber(...variants) {
|
|
7154
|
-
for (let i = 0; i < variants.length; i++) {
|
|
7155
|
-
let variant = variants[i];
|
|
7156
|
-
if (variant.isString() && (variant = variant.convertToNumberObjectValue()), variant.isError())
|
|
7157
|
-
return {
|
|
7158
|
-
isError: !0,
|
|
7159
|
-
errorObject: variant
|
|
7160
|
-
};
|
|
7161
|
-
variants[i] = variant;
|
|
8311
|
+
_getResultByHolidays(startDateSerialNumber, workingDays, holidays) {
|
|
8312
|
+
const holidaysValueArray = [];
|
|
8313
|
+
if (holidays != null && holidays.isArray()) {
|
|
8314
|
+
const rowCount = holidays.getRowCount(), columnCount = holidays.getColumnCount();
|
|
8315
|
+
for (let r = 0; r < rowCount; r++)
|
|
8316
|
+
for (let c = 0; c < columnCount; c++) {
|
|
8317
|
+
const cell = holidays.get(r, c);
|
|
8318
|
+
if (cell.isBoolean())
|
|
8319
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
8320
|
+
const holidaySerialNumber = getDateSerialNumberByObject(cell);
|
|
8321
|
+
if (typeof holidaySerialNumber != "number")
|
|
8322
|
+
return holidaySerialNumber;
|
|
8323
|
+
holidaysValueArray.push(holidaySerialNumber);
|
|
8324
|
+
}
|
|
8325
|
+
} else {
|
|
8326
|
+
if (holidays.isBoolean())
|
|
8327
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
8328
|
+
const holidaySerialNumber = getDateSerialNumberByObject(holidays);
|
|
8329
|
+
if (typeof holidaySerialNumber != "number")
|
|
8330
|
+
return holidaySerialNumber;
|
|
8331
|
+
holidaysValueArray.push(holidaySerialNumber);
|
|
8332
|
+
}
|
|
8333
|
+
const result = getDateSerialNumberByWorkingDays(startDateSerialNumber, workingDays, 1, holidaysValueArray);
|
|
8334
|
+
return typeof result != "number" ? result : NumberValueObject.create(result);
|
|
7162
8335
|
}
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
|
|
7167
|
-
}
|
|
7168
|
-
__name(checkVariantsErrorIsStringToNumber, "checkVariantsErrorIsStringToNumber");
|
|
7169
|
-
const _Yearfrac = class _Yearfrac extends BaseFunction {
|
|
8336
|
+
};
|
|
8337
|
+
__name(_Workday, "Workday");
|
|
8338
|
+
let Workday = _Workday;
|
|
8339
|
+
const _WorkdayIntl = class _WorkdayIntl extends BaseFunction {
|
|
7170
8340
|
constructor() {
|
|
7171
8341
|
super(...arguments);
|
|
7172
8342
|
__publicField(this, "minParams", 2);
|
|
7173
|
-
__publicField(this, "maxParams",
|
|
8343
|
+
__publicField(this, "maxParams", 4);
|
|
7174
8344
|
}
|
|
7175
|
-
calculate(startDate,
|
|
7176
|
-
|
|
7177
|
-
|
|
8345
|
+
calculate(startDate, days, weekend, holidays) {
|
|
8346
|
+
return startDate.isError() ? startDate : days.isError() ? days : weekend != null && weekend.isError() ? weekend : holidays != null && holidays.isError() ? holidays : weekend != null && weekend.isArray() ? weekend.map((weekendItem) => this._handleSingleObject(startDate, days, weekendItem, holidays)) : this._handleSingleObject(startDate, days, weekend, holidays);
|
|
8347
|
+
}
|
|
8348
|
+
_handleSingleObject(startDate, days, weekend, holidays) {
|
|
8349
|
+
const _weekend = weekend != null ? weekend : NumberValueObject.create(1), _startDate = this._checkArrayError(startDate);
|
|
7178
8350
|
if (_startDate.isError())
|
|
7179
8351
|
return _startDate;
|
|
7180
|
-
const
|
|
7181
|
-
if (
|
|
7182
|
-
return
|
|
7183
|
-
if (
|
|
7184
|
-
return _basis;
|
|
7185
|
-
if (_startDate.isBoolean() || _endDate.isBoolean() || _basis.isBoolean())
|
|
8352
|
+
const _days = this._checkArrayError(days);
|
|
8353
|
+
if (_days.isError())
|
|
8354
|
+
return _days;
|
|
8355
|
+
if (_startDate.isBoolean() || _days.isBoolean())
|
|
7186
8356
|
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
7187
|
-
const startDateSerialNumber = getDateSerialNumberByObject(
|
|
8357
|
+
const startDateSerialNumber = getDateSerialNumberByObject(startDate);
|
|
7188
8358
|
if (typeof startDateSerialNumber != "number")
|
|
7189
8359
|
return startDateSerialNumber;
|
|
7190
|
-
const
|
|
7191
|
-
if (
|
|
7192
|
-
return endDateSerialNumber;
|
|
7193
|
-
const basisValue = Math.floor(+_basis.getValue());
|
|
7194
|
-
if (Number.isNaN(basisValue))
|
|
8360
|
+
const workingDays = +days.getValue();
|
|
8361
|
+
if (Number.isNaN(workingDays))
|
|
7195
8362
|
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
7196
|
-
|
|
8363
|
+
let weekendValue = _weekend.getValue();
|
|
8364
|
+
if (_weekend.isBoolean() && (weekendValue = +weekendValue), _weekend.isString() && (!isValidWeekend(weekendValue) || weekendValue === "1111111"))
|
|
8365
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
8366
|
+
if (!isValidWeekend(weekendValue))
|
|
7197
8367
|
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
7198
|
-
|
|
7199
|
-
|
|
7200
|
-
|
|
7201
|
-
|
|
7202
|
-
__name(_Yearfrac, "Yearfrac");
|
|
7203
|
-
let Yearfrac = _Yearfrac;
|
|
7204
|
-
const functionDate = [
|
|
7205
|
-
[DateFunction, FUNCTION_NAMES_DATE.DATE],
|
|
7206
|
-
[Datedif, FUNCTION_NAMES_DATE.DATEDIF],
|
|
7207
|
-
[Datevalue, FUNCTION_NAMES_DATE.DATEVALUE],
|
|
7208
|
-
[Day, FUNCTION_NAMES_DATE.DAY],
|
|
7209
|
-
[Days, FUNCTION_NAMES_DATE.DAYS],
|
|
7210
|
-
[Days360, FUNCTION_NAMES_DATE.DAYS360],
|
|
7211
|
-
[Edate, FUNCTION_NAMES_DATE.EDATE],
|
|
7212
|
-
[Eomonth, FUNCTION_NAMES_DATE.EOMONTH],
|
|
7213
|
-
[Hour, FUNCTION_NAMES_DATE.HOUR],
|
|
7214
|
-
[Isoweeknum, FUNCTION_NAMES_DATE.ISOWEEKNUM],
|
|
7215
|
-
[Minute, FUNCTION_NAMES_DATE.MINUTE],
|
|
7216
|
-
[Month, FUNCTION_NAMES_DATE.MONTH],
|
|
7217
|
-
[Networkdays, FUNCTION_NAMES_DATE.NETWORKDAYS],
|
|
7218
|
-
[NetworkdaysIntl, FUNCTION_NAMES_DATE.NETWORKDAYS_INTL],
|
|
7219
|
-
[Now, FUNCTION_NAMES_DATE.NOW],
|
|
7220
|
-
[Second, FUNCTION_NAMES_DATE.SECOND],
|
|
7221
|
-
[Time, FUNCTION_NAMES_DATE.TIME],
|
|
7222
|
-
[Timevalue, FUNCTION_NAMES_DATE.TIMEVALUE],
|
|
7223
|
-
[Today, FUNCTION_NAMES_DATE.TODAY],
|
|
7224
|
-
[Weekday, FUNCTION_NAMES_DATE.WEEKDAY],
|
|
7225
|
-
[Weeknum, FUNCTION_NAMES_DATE.WEEKNUM],
|
|
7226
|
-
[Workday, FUNCTION_NAMES_DATE.WORKDAY],
|
|
7227
|
-
[WorkdayIntl, FUNCTION_NAMES_DATE.WORKDAY_INTL],
|
|
7228
|
-
[Year, FUNCTION_NAMES_DATE.YEAR],
|
|
7229
|
-
[Yearfrac, FUNCTION_NAMES_DATE.YEARFRAC]
|
|
7230
|
-
];
|
|
7231
|
-
var FUNCTION_NAMES_ENGINEERING = /* @__PURE__ */ ((FUNCTION_NAMES_ENGINEERING2) => (FUNCTION_NAMES_ENGINEERING2.BESSELI = "BESSELI", FUNCTION_NAMES_ENGINEERING2.BESSELJ = "BESSELJ", FUNCTION_NAMES_ENGINEERING2.BESSELK = "BESSELK", FUNCTION_NAMES_ENGINEERING2.BESSELY = "BESSELY", FUNCTION_NAMES_ENGINEERING2.BIN2DEC = "BIN2DEC", FUNCTION_NAMES_ENGINEERING2.BIN2HEX = "BIN2HEX", FUNCTION_NAMES_ENGINEERING2.BIN2OCT = "BIN2OCT", FUNCTION_NAMES_ENGINEERING2.BITAND = "BITAND", FUNCTION_NAMES_ENGINEERING2.BITLSHIFT = "BITLSHIFT", FUNCTION_NAMES_ENGINEERING2.BITOR = "BITOR", FUNCTION_NAMES_ENGINEERING2.BITRSHIFT = "BITRSHIFT", FUNCTION_NAMES_ENGINEERING2.BITXOR = "BITXOR", FUNCTION_NAMES_ENGINEERING2.COMPLEX = "COMPLEX", FUNCTION_NAMES_ENGINEERING2.CONVERT = "CONVERT", FUNCTION_NAMES_ENGINEERING2.DEC2BIN = "DEC2BIN", FUNCTION_NAMES_ENGINEERING2.DEC2HEX = "DEC2HEX", FUNCTION_NAMES_ENGINEERING2.DEC2OCT = "DEC2OCT", FUNCTION_NAMES_ENGINEERING2.DELTA = "DELTA", FUNCTION_NAMES_ENGINEERING2.ERF = "ERF", FUNCTION_NAMES_ENGINEERING2.ERF_PRECISE = "ERF.PRECISE", FUNCTION_NAMES_ENGINEERING2.ERFC = "ERFC", FUNCTION_NAMES_ENGINEERING2.ERFC_PRECISE = "ERFC.PRECISE", FUNCTION_NAMES_ENGINEERING2.GESTEP = "GESTEP", FUNCTION_NAMES_ENGINEERING2.HEX2BIN = "HEX2BIN", FUNCTION_NAMES_ENGINEERING2.HEX2DEC = "HEX2DEC", FUNCTION_NAMES_ENGINEERING2.HEX2OCT = "HEX2OCT", FUNCTION_NAMES_ENGINEERING2.IMABS = "IMABS", FUNCTION_NAMES_ENGINEERING2.IMAGINARY = "IMAGINARY", FUNCTION_NAMES_ENGINEERING2.IMARGUMENT = "IMARGUMENT", FUNCTION_NAMES_ENGINEERING2.IMCONJUGATE = "IMCONJUGATE", FUNCTION_NAMES_ENGINEERING2.IMCOS = "IMCOS", FUNCTION_NAMES_ENGINEERING2.IMCOSH = "IMCOSH", FUNCTION_NAMES_ENGINEERING2.IMCOT = "IMCOT", FUNCTION_NAMES_ENGINEERING2.IMCSC = "IMCSC", FUNCTION_NAMES_ENGINEERING2.IMCSCH = "IMCSCH", FUNCTION_NAMES_ENGINEERING2.IMDIV = "IMDIV", FUNCTION_NAMES_ENGINEERING2.IMEXP = "IMEXP", FUNCTION_NAMES_ENGINEERING2.IMLN = "IMLN", FUNCTION_NAMES_ENGINEERING2.IMLOG10 = "IMLOG10", FUNCTION_NAMES_ENGINEERING2.IMLOG2 = "IMLOG2", FUNCTION_NAMES_ENGINEERING2.IMPOWER = "IMPOWER", FUNCTION_NAMES_ENGINEERING2.IMPRODUCT = "IMPRODUCT", FUNCTION_NAMES_ENGINEERING2.IMREAL = "IMREAL", FUNCTION_NAMES_ENGINEERING2.IMSEC = "IMSEC", FUNCTION_NAMES_ENGINEERING2.IMSECH = "IMSECH", FUNCTION_NAMES_ENGINEERING2.IMSIN = "IMSIN", FUNCTION_NAMES_ENGINEERING2.IMSINH = "IMSINH", FUNCTION_NAMES_ENGINEERING2.IMSQRT = "IMSQRT", FUNCTION_NAMES_ENGINEERING2.IMSUB = "IMSUB", FUNCTION_NAMES_ENGINEERING2.IMSUM = "IMSUM", FUNCTION_NAMES_ENGINEERING2.IMTAN = "IMTAN", FUNCTION_NAMES_ENGINEERING2.OCT2BIN = "OCT2BIN", FUNCTION_NAMES_ENGINEERING2.OCT2DEC = "OCT2DEC", FUNCTION_NAMES_ENGINEERING2.OCT2HEX = "OCT2HEX", FUNCTION_NAMES_ENGINEERING2))(FUNCTION_NAMES_ENGINEERING || {}), BESSEL;
|
|
7232
|
-
((BESSEL2) => {
|
|
7233
|
-
const W = 0.636619772;
|
|
7234
|
-
function _horner(arr, v) {
|
|
7235
|
-
let z = 0;
|
|
7236
|
-
for (let i = 0; i < arr.length; ++i)
|
|
7237
|
-
z = v * z + arr[i];
|
|
7238
|
-
return z;
|
|
7239
|
-
}
|
|
7240
|
-
__name(_horner, "_horner");
|
|
7241
|
-
function _bessel_iter(x, n, f0, f1, sign2) {
|
|
7242
|
-
if (n === 0)
|
|
7243
|
-
return f0;
|
|
7244
|
-
if (n === 1)
|
|
7245
|
-
return f1;
|
|
7246
|
-
const tdx = 2 / x;
|
|
7247
|
-
let _f0 = f0, _f1 = f1, f2 = f1;
|
|
7248
|
-
for (let o = 1; o < n; ++o)
|
|
7249
|
-
f2 = _f1 * o * tdx + sign2 * _f0, _f0 = _f1, _f1 = f2;
|
|
7250
|
-
return f2;
|
|
7251
|
-
}
|
|
7252
|
-
__name(_bessel_iter, "_bessel_iter");
|
|
7253
|
-
function _bessel_wrap(bessel0, bessel1, nonzero, sign2) {
|
|
7254
|
-
return /* @__PURE__ */ __name(function(x, n) {
|
|
7255
|
-
if (nonzero) {
|
|
7256
|
-
if (x === 0)
|
|
7257
|
-
return nonzero === 1 ? -1 / 0 : 1 / 0;
|
|
7258
|
-
if (x < 0)
|
|
7259
|
-
return Number.NaN;
|
|
7260
|
-
}
|
|
7261
|
-
if (n === 0)
|
|
7262
|
-
return bessel0(x);
|
|
7263
|
-
if (n === 1)
|
|
7264
|
-
return bessel1(x);
|
|
7265
|
-
if (n < 0)
|
|
7266
|
-
return Number.NaN;
|
|
7267
|
-
const _n = n | 0, b0 = bessel0(x), b1 = bessel1(x);
|
|
7268
|
-
return _bessel_iter(x, _n, b0, b1, sign2);
|
|
7269
|
-
}, "bessel");
|
|
8368
|
+
if (holidays)
|
|
8369
|
+
return this._getResultByHolidays(startDateSerialNumber, workingDays, weekendValue, holidays);
|
|
8370
|
+
const result = getDateSerialNumberByWorkingDays(startDateSerialNumber, workingDays, weekendValue);
|
|
8371
|
+
return typeof result != "number" ? result : NumberValueObject.create(result);
|
|
7270
8372
|
}
|
|
7271
|
-
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
if (
|
|
7276
|
-
|
|
7277
|
-
|
|
7278
|
-
const xx = x - 0.785398164;
|
|
7279
|
-
y = 64 / y, a1 = _horner(b0_a1b, y), a2 = _horner(b0_a2b, y), a = Math.sqrt(W / x) * (Math.cos(xx) * a1 - Math.sin(xx) * a2 * 8 / x);
|
|
7280
|
-
}
|
|
7281
|
-
return a;
|
|
7282
|
-
}
|
|
7283
|
-
__name(bessel0, "bessel0");
|
|
7284
|
-
const b1_a1a = [-30.16036606, 15704.4826, -2972611439e-3, 2423968531e-1, -7895059235, 72362614232], b1_a2a = [1, 376.9991397, 99447.43394, 1858330474e-2, 2300535178, 144725228442], b1_a1b = [-240337019e-15, 2457520174e-15, -3516396496e-14, 183105e-8, 1], b1_a2b = [105787412e-15, -88228987e-14, 8449199096e-15, -2002690873e-13, 0.04687499995];
|
|
7285
|
-
function bessel1(x) {
|
|
7286
|
-
let a = 0, a1 = 0, a2 = 0, y = x * x;
|
|
7287
|
-
const xx = Math.abs(x) - 2.356194491;
|
|
7288
|
-
return Math.abs(x) < 8 ? (a1 = x * _horner(b1_a1a, y), a2 = _horner(b1_a2a, y), a = a1 / a2) : (y = 64 / y, a1 = _horner(b1_a1b, y), a2 = _horner(b1_a2b, y), a = Math.sqrt(W / Math.abs(x)) * (Math.cos(xx) * a1 - Math.sin(xx) * a2 * 8 / Math.abs(x)), x < 0 && (a = -a)), a;
|
|
7289
|
-
}
|
|
7290
|
-
return __name(bessel1, "bessel1"), /* @__PURE__ */ __name(function besselj2(x, n) {
|
|
7291
|
-
const _n = Math.round(n);
|
|
7292
|
-
if (!Number.isFinite(x))
|
|
7293
|
-
return Number.isNaN(x) ? x : 0;
|
|
7294
|
-
if (_n < 0)
|
|
7295
|
-
return (_n % 2 ? -1 : 1) * besselj2(x, -_n);
|
|
7296
|
-
if (x < 0)
|
|
7297
|
-
return (_n % 2 ? -1 : 1) * besselj2(-x, _n);
|
|
7298
|
-
if (_n === 0)
|
|
7299
|
-
return bessel0(x);
|
|
7300
|
-
if (_n === 1)
|
|
7301
|
-
return bessel1(x);
|
|
7302
|
-
if (x === 0)
|
|
7303
|
-
return 0;
|
|
7304
|
-
let ret = 0;
|
|
7305
|
-
if (x > _n)
|
|
7306
|
-
ret = _bessel_iter(x, _n, bessel0(x), bessel1(x), -1);
|
|
7307
|
-
else {
|
|
7308
|
-
const m = 2 * Math.floor((_n + Math.floor(Math.sqrt(40 * _n))) / 2);
|
|
7309
|
-
let jsum = !1, bjp = 0, sum2 = 0, bj = 1, bjm = 0;
|
|
7310
|
-
const tox = 2 / x;
|
|
7311
|
-
for (let j = m; j > 0; j--)
|
|
7312
|
-
if (bjm = j * tox * bj - bjp, bjp = bj, bj = bjm, Math.abs(bj) > 1e10 && (bj *= 1e-10, bjp *= 1e-10, ret *= 1e-10, sum2 *= 1e-10), jsum && (sum2 += bj), jsum = !jsum, j === _n && (ret = bjp), m - j > 100 && ret === 0)
|
|
7313
|
-
return Number.NaN;
|
|
7314
|
-
sum2 = 2 * sum2 - bj, ret /= sum2;
|
|
7315
|
-
}
|
|
7316
|
-
return ret;
|
|
7317
|
-
}, "besselj2");
|
|
7318
|
-
})(), BESSEL2.bessely = (() => {
|
|
7319
|
-
const b0_a1a = [228.4622733, -86327.92757, 1087988129e-2, -5123598036e-1, 7062834065, -2957821389], b0_a2a = [1, 226.1030244, 47447.2647, 7189466438e-3, 7452499648e-1, 40076544269], b0_a1b = [2093887211e-16, -2073370639e-15, 2734510407e-14, -0.001098628627, 1], b0_a2b = [-934945152e-16, 7621095161e-16, -6911147651e-15, 1430488765e-13, -0.01562499995];
|
|
7320
|
-
function bessel0(x) {
|
|
7321
|
-
let a = 0, a1 = 0, a2 = 0, y = x * x;
|
|
7322
|
-
const xx = x - 0.785398164;
|
|
7323
|
-
return x < 8 ? (a1 = _horner(b0_a1a, y), a2 = _horner(b0_a2a, y), a = a1 / a2 + W * (0, BESSEL2.besselj)(x, 0) * Math.log(x)) : (y = 64 / y, a1 = _horner(b0_a1b, y), a2 = _horner(b0_a2b, y), a = Math.sqrt(W / x) * (Math.sin(xx) * a1 + Math.cos(xx) * a2 * 8 / x)), a;
|
|
7324
|
-
}
|
|
7325
|
-
__name(bessel0, "bessel0");
|
|
7326
|
-
const b1_a1a = [8511.937935, -4237922726e-3, 7349264551e-1, -51534381390, 127527439e4, -4900604943e3], b1_a2a = [1, 354.9632885, 102042.605, 2245904002e-2, 3733650367, 424441966400, 249958057e5], b1_a1b = [-240337019e-15, 2457520174e-15, -3516396496e-14, 183105e-8, 1], b1_a2b = [105787412e-15, -88228987e-14, 8449199096e-15, -2002690873e-13, 0.04687499995];
|
|
7327
|
-
function bessel1(x) {
|
|
7328
|
-
let a = 0, a1 = 0, a2 = 0, y = x * x;
|
|
7329
|
-
const xx = x - 2.356194491;
|
|
7330
|
-
return x < 8 ? (a1 = x * _horner(b1_a1a, y), a2 = _horner(b1_a2a, y), a = a1 / a2 + W * ((0, BESSEL2.besselj)(x, 1) * Math.log(x) - 1 / x)) : (y = 64 / y, a1 = _horner(b1_a1b, y), a2 = _horner(b1_a2b, y), a = Math.sqrt(W / x) * (Math.sin(xx) * a1 + Math.cos(xx) * a2 * 8 / x)), a;
|
|
7331
|
-
}
|
|
7332
|
-
return __name(bessel1, "bessel1"), _bessel_wrap(bessel0, bessel1, 1, -1);
|
|
7333
|
-
})(), BESSEL2.besseli = /* @__PURE__ */ (() => {
|
|
7334
|
-
const b0_a = [45813e-7, 0.0360768, 0.2659732, 1.2067492, 3.0899424, 3.5156229, 1], b0_b = [392377e-8, -0.01647633, 0.02635537, -0.02057706, 916281e-8, -157565e-8, 225319e-8, 0.01328592, 0.39894228];
|
|
7335
|
-
function bessel0(x) {
|
|
7336
|
-
return x <= 3.75 ? _horner(b0_a, x * x / (3.75 * 3.75)) : Math.exp(Math.abs(x)) / Math.sqrt(Math.abs(x)) * _horner(b0_b, 3.75 / Math.abs(x));
|
|
7337
|
-
}
|
|
7338
|
-
__name(bessel0, "bessel0");
|
|
7339
|
-
const b1_a = [32411e-8, 301532e-8, 0.02658733, 0.15084934, 0.51498869, 0.87890594, 0.5], b1_b = [-420059e-8, 0.01787654, -0.02895312, 0.02282967, -0.01031555, 163801e-8, -362018e-8, -0.03988024, 0.39894228];
|
|
7340
|
-
function bessel1(x) {
|
|
7341
|
-
return x < 3.75 ? x * _horner(b1_a, x * x / (3.75 * 3.75)) : (x < 0 ? -1 : 1) * Math.exp(Math.abs(x)) / Math.sqrt(Math.abs(x)) * _horner(b1_b, 3.75 / Math.abs(x));
|
|
8373
|
+
_checkArrayError(variant) {
|
|
8374
|
+
let _variant = variant;
|
|
8375
|
+
if (_variant.isArray()) {
|
|
8376
|
+
const rowCount = _variant.getRowCount(), columnCount = _variant.getColumnCount();
|
|
8377
|
+
if (rowCount > 1 || columnCount > 1)
|
|
8378
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
8379
|
+
_variant = _variant.get(0, 0);
|
|
7342
8380
|
}
|
|
7343
|
-
return
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
|
|
7358
|
-
|
|
7359
|
-
|
|
7360
|
-
|
|
7361
|
-
|
|
7362
|
-
|
|
7363
|
-
|
|
7364
|
-
|
|
7365
|
-
|
|
7366
|
-
function bessel0(x) {
|
|
7367
|
-
return x <= 2 ? -Math.log(x / 2) * (0, BESSEL2.besseli)(x, 0) + _horner(b0_a, x * x / 4) : Math.exp(-x) / Math.sqrt(x) * _horner(b0_b, 2 / x);
|
|
8381
|
+
return _variant.isError(), _variant;
|
|
8382
|
+
}
|
|
8383
|
+
_getResultByHolidays(startDateSerialNumber, workingDays, weekendValue, holidays) {
|
|
8384
|
+
const holidaysValueArray = [];
|
|
8385
|
+
if (holidays != null && holidays.isArray()) {
|
|
8386
|
+
const rowCount = holidays.getRowCount(), columnCount = holidays.getColumnCount();
|
|
8387
|
+
for (let r = 0; r < rowCount; r++)
|
|
8388
|
+
for (let c = 0; c < columnCount; c++) {
|
|
8389
|
+
const cell = holidays.get(r, c);
|
|
8390
|
+
if (cell.isBoolean())
|
|
8391
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
8392
|
+
const holidaySerialNumber = getDateSerialNumberByObject(cell);
|
|
8393
|
+
if (typeof holidaySerialNumber != "number")
|
|
8394
|
+
return holidaySerialNumber;
|
|
8395
|
+
holidaysValueArray.push(holidaySerialNumber);
|
|
8396
|
+
}
|
|
8397
|
+
} else {
|
|
8398
|
+
if (holidays.isBoolean())
|
|
8399
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
8400
|
+
const holidaySerialNumber = getDateSerialNumberByObject(holidays);
|
|
8401
|
+
if (typeof holidaySerialNumber != "number")
|
|
8402
|
+
return holidaySerialNumber;
|
|
8403
|
+
holidaysValueArray.push(holidaySerialNumber);
|
|
7368
8404
|
}
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
8405
|
+
const result = getDateSerialNumberByWorkingDays(startDateSerialNumber, workingDays, weekendValue, holidaysValueArray);
|
|
8406
|
+
return typeof result != "number" ? result : NumberValueObject.create(result);
|
|
8407
|
+
}
|
|
8408
|
+
};
|
|
8409
|
+
__name(_WorkdayIntl, "WorkdayIntl");
|
|
8410
|
+
let WorkdayIntl = _WorkdayIntl;
|
|
8411
|
+
const _Year = class _Year extends BaseFunction {
|
|
8412
|
+
constructor() {
|
|
8413
|
+
super(...arguments);
|
|
8414
|
+
__publicField(this, "minParams", 1);
|
|
8415
|
+
__publicField(this, "maxParams", 1);
|
|
8416
|
+
}
|
|
8417
|
+
calculate(serialNumber) {
|
|
8418
|
+
return serialNumber.isArray() ? serialNumber.map((serialNumberObject) => this._handleSingleObject(serialNumberObject)) : this._handleSingleObject(serialNumber);
|
|
8419
|
+
}
|
|
8420
|
+
_handleSingleObject(serialNumberObject) {
|
|
8421
|
+
if (serialNumberObject.isError())
|
|
8422
|
+
return serialNumberObject;
|
|
8423
|
+
let date;
|
|
8424
|
+
const dateValue = serialNumberObject.getValue();
|
|
8425
|
+
if (serialNumberObject.isString()) {
|
|
8426
|
+
if (!isValidDateStr(`${dateValue}`))
|
|
8427
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
8428
|
+
date = /* @__PURE__ */ new Date(`${dateValue}`);
|
|
8429
|
+
} else {
|
|
8430
|
+
const dateSerial = +dateValue;
|
|
8431
|
+
if (dateSerial < 0)
|
|
8432
|
+
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
8433
|
+
if (dateSerial === 0)
|
|
8434
|
+
return NumberValueObject.create(1900);
|
|
8435
|
+
date = excelSerialToDate(dateSerial);
|
|
7373
8436
|
}
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
}
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
|
|
7390
|
-
|
|
7391
|
-
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
]
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
8437
|
+
const year = date.getUTCFullYear();
|
|
8438
|
+
return NumberValueObject.create(year);
|
|
8439
|
+
}
|
|
8440
|
+
};
|
|
8441
|
+
__name(_Year, "Year");
|
|
8442
|
+
let Year = _Year;
|
|
8443
|
+
const _Yearfrac = class _Yearfrac extends BaseFunction {
|
|
8444
|
+
constructor() {
|
|
8445
|
+
super(...arguments);
|
|
8446
|
+
__publicField(this, "minParams", 2);
|
|
8447
|
+
__publicField(this, "maxParams", 3);
|
|
8448
|
+
}
|
|
8449
|
+
calculate(startDate, endDate, basis) {
|
|
8450
|
+
let _basis = basis != null ? basis : NumberValueObject.create(0);
|
|
8451
|
+
const _startDate = checkVariantErrorIsArray(startDate);
|
|
8452
|
+
if (_startDate.isError())
|
|
8453
|
+
return _startDate;
|
|
8454
|
+
const _endDate = checkVariantErrorIsArray(endDate);
|
|
8455
|
+
if (_endDate.isError())
|
|
8456
|
+
return _endDate;
|
|
8457
|
+
if (_basis = checkVariantErrorIsArray(_basis), _basis.isError())
|
|
8458
|
+
return _basis;
|
|
8459
|
+
if (_startDate.isBoolean() || _endDate.isBoolean() || _basis.isBoolean())
|
|
8460
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
8461
|
+
const startDateSerialNumber = getDateSerialNumberByObject(_startDate);
|
|
8462
|
+
if (typeof startDateSerialNumber != "number")
|
|
8463
|
+
return startDateSerialNumber;
|
|
8464
|
+
const endDateSerialNumber = getDateSerialNumberByObject(_endDate);
|
|
8465
|
+
if (typeof endDateSerialNumber != "number")
|
|
8466
|
+
return endDateSerialNumber;
|
|
8467
|
+
const basisValue = Math.floor(+_basis.getValue());
|
|
8468
|
+
if (Number.isNaN(basisValue))
|
|
8469
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
8470
|
+
if (basisValue < 0 || basisValue > 4)
|
|
8471
|
+
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
8472
|
+
const { days, yearDays } = getTwoDateDaysByBasis(startDateSerialNumber, endDateSerialNumber, basisValue), result = days / yearDays;
|
|
8473
|
+
return NumberValueObject.create(result);
|
|
8474
|
+
}
|
|
8475
|
+
};
|
|
8476
|
+
__name(_Yearfrac, "Yearfrac");
|
|
8477
|
+
let Yearfrac = _Yearfrac;
|
|
8478
|
+
const functionDate = [
|
|
8479
|
+
[DateFunction, FUNCTION_NAMES_DATE.DATE],
|
|
8480
|
+
[Datedif, FUNCTION_NAMES_DATE.DATEDIF],
|
|
8481
|
+
[Datevalue, FUNCTION_NAMES_DATE.DATEVALUE],
|
|
8482
|
+
[Day, FUNCTION_NAMES_DATE.DAY],
|
|
8483
|
+
[Days, FUNCTION_NAMES_DATE.DAYS],
|
|
8484
|
+
[Days360, FUNCTION_NAMES_DATE.DAYS360],
|
|
8485
|
+
[Edate, FUNCTION_NAMES_DATE.EDATE],
|
|
8486
|
+
[Eomonth, FUNCTION_NAMES_DATE.EOMONTH],
|
|
8487
|
+
[Hour, FUNCTION_NAMES_DATE.HOUR],
|
|
8488
|
+
[Isoweeknum, FUNCTION_NAMES_DATE.ISOWEEKNUM],
|
|
8489
|
+
[Minute, FUNCTION_NAMES_DATE.MINUTE],
|
|
8490
|
+
[Month, FUNCTION_NAMES_DATE.MONTH],
|
|
8491
|
+
[Networkdays, FUNCTION_NAMES_DATE.NETWORKDAYS],
|
|
8492
|
+
[NetworkdaysIntl, FUNCTION_NAMES_DATE.NETWORKDAYS_INTL],
|
|
8493
|
+
[Now, FUNCTION_NAMES_DATE.NOW],
|
|
8494
|
+
[Second, FUNCTION_NAMES_DATE.SECOND],
|
|
8495
|
+
[Time, FUNCTION_NAMES_DATE.TIME],
|
|
8496
|
+
[Timevalue, FUNCTION_NAMES_DATE.TIMEVALUE],
|
|
8497
|
+
[Today, FUNCTION_NAMES_DATE.TODAY],
|
|
8498
|
+
[Weekday, FUNCTION_NAMES_DATE.WEEKDAY],
|
|
8499
|
+
[Weeknum, FUNCTION_NAMES_DATE.WEEKNUM],
|
|
8500
|
+
[Workday, FUNCTION_NAMES_DATE.WORKDAY],
|
|
8501
|
+
[WorkdayIntl, FUNCTION_NAMES_DATE.WORKDAY_INTL],
|
|
8502
|
+
[Year, FUNCTION_NAMES_DATE.YEAR],
|
|
8503
|
+
[Yearfrac, FUNCTION_NAMES_DATE.YEARFRAC]
|
|
8504
|
+
];
|
|
8505
|
+
var FUNCTION_NAMES_ENGINEERING = /* @__PURE__ */ ((FUNCTION_NAMES_ENGINEERING2) => (FUNCTION_NAMES_ENGINEERING2.BESSELI = "BESSELI", FUNCTION_NAMES_ENGINEERING2.BESSELJ = "BESSELJ", FUNCTION_NAMES_ENGINEERING2.BESSELK = "BESSELK", FUNCTION_NAMES_ENGINEERING2.BESSELY = "BESSELY", FUNCTION_NAMES_ENGINEERING2.BIN2DEC = "BIN2DEC", FUNCTION_NAMES_ENGINEERING2.BIN2HEX = "BIN2HEX", FUNCTION_NAMES_ENGINEERING2.BIN2OCT = "BIN2OCT", FUNCTION_NAMES_ENGINEERING2.BITAND = "BITAND", FUNCTION_NAMES_ENGINEERING2.BITLSHIFT = "BITLSHIFT", FUNCTION_NAMES_ENGINEERING2.BITOR = "BITOR", FUNCTION_NAMES_ENGINEERING2.BITRSHIFT = "BITRSHIFT", FUNCTION_NAMES_ENGINEERING2.BITXOR = "BITXOR", FUNCTION_NAMES_ENGINEERING2.COMPLEX = "COMPLEX", FUNCTION_NAMES_ENGINEERING2.CONVERT = "CONVERT", FUNCTION_NAMES_ENGINEERING2.DEC2BIN = "DEC2BIN", FUNCTION_NAMES_ENGINEERING2.DEC2HEX = "DEC2HEX", FUNCTION_NAMES_ENGINEERING2.DEC2OCT = "DEC2OCT", FUNCTION_NAMES_ENGINEERING2.DELTA = "DELTA", FUNCTION_NAMES_ENGINEERING2.ERF = "ERF", FUNCTION_NAMES_ENGINEERING2.ERF_PRECISE = "ERF.PRECISE", FUNCTION_NAMES_ENGINEERING2.ERFC = "ERFC", FUNCTION_NAMES_ENGINEERING2.ERFC_PRECISE = "ERFC.PRECISE", FUNCTION_NAMES_ENGINEERING2.GESTEP = "GESTEP", FUNCTION_NAMES_ENGINEERING2.HEX2BIN = "HEX2BIN", FUNCTION_NAMES_ENGINEERING2.HEX2DEC = "HEX2DEC", FUNCTION_NAMES_ENGINEERING2.HEX2OCT = "HEX2OCT", FUNCTION_NAMES_ENGINEERING2.IMABS = "IMABS", FUNCTION_NAMES_ENGINEERING2.IMAGINARY = "IMAGINARY", FUNCTION_NAMES_ENGINEERING2.IMARGUMENT = "IMARGUMENT", FUNCTION_NAMES_ENGINEERING2.IMCONJUGATE = "IMCONJUGATE", FUNCTION_NAMES_ENGINEERING2.IMCOS = "IMCOS", FUNCTION_NAMES_ENGINEERING2.IMCOSH = "IMCOSH", FUNCTION_NAMES_ENGINEERING2.IMCOT = "IMCOT", FUNCTION_NAMES_ENGINEERING2.IMCSC = "IMCSC", FUNCTION_NAMES_ENGINEERING2.IMCSCH = "IMCSCH", FUNCTION_NAMES_ENGINEERING2.IMDIV = "IMDIV", FUNCTION_NAMES_ENGINEERING2.IMEXP = "IMEXP", FUNCTION_NAMES_ENGINEERING2.IMLN = "IMLN", FUNCTION_NAMES_ENGINEERING2.IMLOG10 = "IMLOG10", FUNCTION_NAMES_ENGINEERING2.IMLOG2 = "IMLOG2", FUNCTION_NAMES_ENGINEERING2.IMPOWER = "IMPOWER", FUNCTION_NAMES_ENGINEERING2.IMPRODUCT = "IMPRODUCT", FUNCTION_NAMES_ENGINEERING2.IMREAL = "IMREAL", FUNCTION_NAMES_ENGINEERING2.IMSEC = "IMSEC", FUNCTION_NAMES_ENGINEERING2.IMSECH = "IMSECH", FUNCTION_NAMES_ENGINEERING2.IMSIN = "IMSIN", FUNCTION_NAMES_ENGINEERING2.IMSINH = "IMSINH", FUNCTION_NAMES_ENGINEERING2.IMSQRT = "IMSQRT", FUNCTION_NAMES_ENGINEERING2.IMSUB = "IMSUB", FUNCTION_NAMES_ENGINEERING2.IMSUM = "IMSUM", FUNCTION_NAMES_ENGINEERING2.IMTAN = "IMTAN", FUNCTION_NAMES_ENGINEERING2.OCT2BIN = "OCT2BIN", FUNCTION_NAMES_ENGINEERING2.OCT2DEC = "OCT2DEC", FUNCTION_NAMES_ENGINEERING2.OCT2HEX = "OCT2HEX", FUNCTION_NAMES_ENGINEERING2))(FUNCTION_NAMES_ENGINEERING || {});
|
|
7432
8506
|
const _Besseli = class _Besseli extends BaseFunction {
|
|
7433
8507
|
constructor() {
|
|
7434
8508
|
super(...arguments);
|
|
@@ -8630,7 +9704,7 @@ const _Erfc = class _Erfc extends BaseFunction {
|
|
|
8630
9704
|
const [xObject] = variants, xValue = +xObject.getValue();
|
|
8631
9705
|
if (Number.isNaN(xValue))
|
|
8632
9706
|
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
8633
|
-
const result =
|
|
9707
|
+
const result = erfc(xValue);
|
|
8634
9708
|
return NumberValueObject.create(result);
|
|
8635
9709
|
}
|
|
8636
9710
|
};
|
|
@@ -8649,7 +9723,7 @@ const _ErfcPrecise = class _ErfcPrecise extends BaseFunction {
|
|
|
8649
9723
|
const [xObject] = variants, xValue = +xObject.getValue();
|
|
8650
9724
|
if (Number.isNaN(xValue))
|
|
8651
9725
|
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
8652
|
-
const result =
|
|
9726
|
+
const result = erfc(xValue);
|
|
8653
9727
|
return NumberValueObject.create(result);
|
|
8654
9728
|
}
|
|
8655
9729
|
};
|
|
@@ -12411,22 +13485,27 @@ const _Bycol = class _Bycol extends BaseFunction {
|
|
|
12411
13485
|
super(...arguments);
|
|
12412
13486
|
__publicField(this, "minParams", 2);
|
|
12413
13487
|
__publicField(this, "maxParams", 2);
|
|
13488
|
+
__publicField(this, "needsReferenceObject", !0);
|
|
12414
13489
|
}
|
|
13490
|
+
// eslint-disable-next-line
|
|
12415
13491
|
calculate(array, lambda) {
|
|
12416
|
-
|
|
12417
|
-
|
|
13492
|
+
let _array = array, _array_reference = null;
|
|
13493
|
+
if (array.isReferenceObject() && (_array = array.toArrayValueObject(), _array_reference = array), _array.isError())
|
|
13494
|
+
return _array;
|
|
12418
13495
|
if (lambda.isError())
|
|
12419
13496
|
return lambda;
|
|
12420
13497
|
if (!(lambda.isValueObject() && lambda.isLambda() && lambda.getLambdaPrivacyVarKeys().length === 1))
|
|
12421
13498
|
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
12422
|
-
const _lambda = lambda, rowCount =
|
|
13499
|
+
const _lambda = lambda, rowCount = _array.isArray() ? _array.getRowCount() : 1, columnCount = _array.isArray() ? _array.getColumnCount() : 1;
|
|
13500
|
+
_array = expandArrayValueObject(rowCount, columnCount, _array);
|
|
13501
|
+
const result = [[]];
|
|
12423
13502
|
for (let c = 0; c < columnCount; c++) {
|
|
12424
13503
|
const rows = [];
|
|
12425
13504
|
for (let r = 0; r < rowCount; r++) {
|
|
12426
13505
|
const col = _array.get(r, c);
|
|
12427
13506
|
rows.push([col]);
|
|
12428
13507
|
}
|
|
12429
|
-
|
|
13508
|
+
let lambdaVariant = ArrayValueObject.create({
|
|
12430
13509
|
calculateValueList: rows,
|
|
12431
13510
|
rowCount,
|
|
12432
13511
|
columnCount: 1,
|
|
@@ -12435,6 +13514,15 @@ const _Bycol = class _Bycol extends BaseFunction {
|
|
|
12435
13514
|
row: 0,
|
|
12436
13515
|
column: 0
|
|
12437
13516
|
});
|
|
13517
|
+
if (_array_reference) {
|
|
13518
|
+
const { startRow, startColumn } = _array_reference.getRangePosition(), range = {
|
|
13519
|
+
startRow,
|
|
13520
|
+
startColumn: startColumn + c,
|
|
13521
|
+
endRow: startRow + rowCount - 1,
|
|
13522
|
+
endColumn: startColumn + c
|
|
13523
|
+
};
|
|
13524
|
+
lambdaVariant = this.createReferenceObject(_array_reference, range);
|
|
13525
|
+
}
|
|
12438
13526
|
let value = _lambda.execute(lambdaVariant);
|
|
12439
13527
|
if (value.isArray()) {
|
|
12440
13528
|
const valueRowCount = value.getRowCount(), valueColumnCount = value.getColumnCount();
|
|
@@ -12462,22 +13550,27 @@ const _Byrow = class _Byrow extends BaseFunction {
|
|
|
12462
13550
|
super(...arguments);
|
|
12463
13551
|
__publicField(this, "minParams", 2);
|
|
12464
13552
|
__publicField(this, "maxParams", 2);
|
|
13553
|
+
__publicField(this, "needsReferenceObject", !0);
|
|
12465
13554
|
}
|
|
13555
|
+
// eslint-disable-next-line
|
|
12466
13556
|
calculate(array, lambda) {
|
|
12467
|
-
|
|
12468
|
-
|
|
13557
|
+
let _array = array, _array_reference = null;
|
|
13558
|
+
if (array.isReferenceObject() && (_array = array.toArrayValueObject(), _array_reference = array), _array.isError())
|
|
13559
|
+
return _array;
|
|
12469
13560
|
if (lambda.isError())
|
|
12470
13561
|
return lambda;
|
|
12471
13562
|
if (!(lambda.isValueObject() && lambda.isLambda() && lambda.getLambdaPrivacyVarKeys().length === 1))
|
|
12472
13563
|
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
12473
|
-
const _lambda = lambda, rowCount =
|
|
13564
|
+
const _lambda = lambda, rowCount = _array.isArray() ? _array.getRowCount() : 1, columnCount = _array.isArray() ? _array.getColumnCount() : 1;
|
|
13565
|
+
_array = expandArrayValueObject(rowCount, columnCount, _array);
|
|
13566
|
+
const result = [];
|
|
12474
13567
|
for (let r = 0; r < rowCount; r++) {
|
|
12475
13568
|
const rows = [[]];
|
|
12476
13569
|
for (let c = 0; c < columnCount; c++) {
|
|
12477
13570
|
const col = _array.get(r, c);
|
|
12478
13571
|
rows[0].push(col);
|
|
12479
13572
|
}
|
|
12480
|
-
|
|
13573
|
+
let lambdaVariant = ArrayValueObject.create({
|
|
12481
13574
|
calculateValueList: rows,
|
|
12482
13575
|
rowCount: 1,
|
|
12483
13576
|
columnCount,
|
|
@@ -12486,6 +13579,15 @@ const _Byrow = class _Byrow extends BaseFunction {
|
|
|
12486
13579
|
row: 0,
|
|
12487
13580
|
column: 0
|
|
12488
13581
|
});
|
|
13582
|
+
if (_array_reference) {
|
|
13583
|
+
const { startRow, startColumn } = _array_reference.getRangePosition(), range = {
|
|
13584
|
+
startRow: startRow + r,
|
|
13585
|
+
startColumn,
|
|
13586
|
+
endRow: startRow + r,
|
|
13587
|
+
endColumn: startColumn + columnCount - 1
|
|
13588
|
+
};
|
|
13589
|
+
lambdaVariant = this.createReferenceObject(_array_reference, range);
|
|
13590
|
+
}
|
|
12489
13591
|
let value = _lambda.execute(lambdaVariant);
|
|
12490
13592
|
if (value.isArray()) {
|
|
12491
13593
|
const valueRowCount = value.getRowCount(), valueColumnCount = value.getColumnCount();
|
|
@@ -12720,23 +13822,25 @@ let Map$1 = (_a2 = class extends BaseFunction {
|
|
|
12720
13822
|
super(...arguments);
|
|
12721
13823
|
__publicField(this, "minParams", 2);
|
|
12722
13824
|
__publicField(this, "maxParams", 255);
|
|
13825
|
+
__publicField(this, "needsReferenceObject", !0);
|
|
12723
13826
|
}
|
|
12724
13827
|
calculate(...variants) {
|
|
12725
13828
|
const _variants = [];
|
|
12726
13829
|
let lambda = null, maxRowLength = 0, maxColumnLength = 0;
|
|
12727
13830
|
for (let i = 0; i < variants.length; i++) {
|
|
12728
13831
|
const variant = variants[i];
|
|
12729
|
-
|
|
12730
|
-
|
|
13832
|
+
let _variant = variant;
|
|
13833
|
+
if (_variant.isReferenceObject() && (_variant = variant.toArrayValueObject()), _variant.isError())
|
|
13834
|
+
return _variant;
|
|
12731
13835
|
if (i === variants.length - 1) {
|
|
12732
13836
|
if (!(variant.isValueObject() && variant.isLambda()))
|
|
12733
13837
|
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
12734
13838
|
lambda = variant;
|
|
12735
13839
|
} else
|
|
12736
|
-
_variants.push(variant), maxRowLength = Math.max(maxRowLength,
|
|
13840
|
+
_variants.push(variant), maxRowLength = Math.max(maxRowLength, _variant.isArray() ? _variant.getRowCount() : 1), maxColumnLength = Math.max(maxColumnLength, _variant.isArray() ? _variant.getColumnCount() : 1);
|
|
12737
13841
|
}
|
|
12738
13842
|
const resultArray = this._getResultArray(_variants, lambda, maxRowLength, maxColumnLength);
|
|
12739
|
-
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray[0][0] : ArrayValueObject.create({
|
|
13843
|
+
return resultArray instanceof ErrorValueObject ? resultArray : maxRowLength === 1 && maxColumnLength === 1 ? resultArray[0][0] : ArrayValueObject.create({
|
|
12740
13844
|
calculateValueList: resultArray,
|
|
12741
13845
|
rowCount: maxRowLength,
|
|
12742
13846
|
columnCount: maxColumnLength,
|
|
@@ -12746,6 +13850,7 @@ let Map$1 = (_a2 = class extends BaseFunction {
|
|
|
12746
13850
|
column: this.column
|
|
12747
13851
|
});
|
|
12748
13852
|
}
|
|
13853
|
+
// eslint-disable-next-line
|
|
12749
13854
|
_getResultArray(variants, lambda, maxRowLength, maxColumnLength) {
|
|
12750
13855
|
const resultArray = [];
|
|
12751
13856
|
for (let r = 0; r < maxRowLength; r++) {
|
|
@@ -12754,26 +13859,41 @@ let Map$1 = (_a2 = class extends BaseFunction {
|
|
|
12754
13859
|
const lambdaVariant = [];
|
|
12755
13860
|
let isRowPushed = !1;
|
|
12756
13861
|
for (let i = 0; i < variants.length; i++) {
|
|
12757
|
-
|
|
12758
|
-
if (!variant.isArray())
|
|
13862
|
+
let variant = variants[i], _variant_reference = null;
|
|
13863
|
+
if (variant.isReferenceObject() && (_variant_reference = variant, variant = variant.toArrayValueObject()), !variant.isArray())
|
|
12759
13864
|
if (r === 0 && c === 0) {
|
|
12760
|
-
lambdaVariant.push(variant);
|
|
13865
|
+
lambdaVariant.push(_variant_reference || variant);
|
|
12761
13866
|
continue;
|
|
12762
13867
|
} else {
|
|
12763
13868
|
row.push(ErrorValueObject.create(ErrorType$1.NA)), isRowPushed = !0;
|
|
12764
13869
|
break;
|
|
12765
13870
|
}
|
|
12766
|
-
|
|
13871
|
+
let valueObject = variant.get(r, c);
|
|
12767
13872
|
if (!valueObject) {
|
|
12768
13873
|
row.push(ErrorValueObject.create(ErrorType$1.NA)), isRowPushed = !0;
|
|
12769
13874
|
break;
|
|
12770
13875
|
}
|
|
13876
|
+
if (_variant_reference) {
|
|
13877
|
+
const { startRow, startColumn } = _variant_reference.getRangePosition(), range = {
|
|
13878
|
+
startRow: startRow + r,
|
|
13879
|
+
startColumn: startColumn + c,
|
|
13880
|
+
endRow: startRow + r,
|
|
13881
|
+
endColumn: startColumn + c
|
|
13882
|
+
};
|
|
13883
|
+
valueObject = this.createReferenceObject(_variant_reference, range);
|
|
13884
|
+
}
|
|
12771
13885
|
lambdaVariant.push(valueObject);
|
|
12772
13886
|
}
|
|
12773
13887
|
if (isRowPushed || lambdaVariant.length === 0)
|
|
12774
13888
|
continue;
|
|
12775
13889
|
let value = lambda.execute(...lambdaVariant);
|
|
12776
|
-
|
|
13890
|
+
if (value.isArray()) {
|
|
13891
|
+
const rowCount = value.getRowCount(), columnCount = value.getColumnCount();
|
|
13892
|
+
if (rowCount > 1 || columnCount > 1)
|
|
13893
|
+
return ErrorValueObject.create(ErrorType$1.CALC);
|
|
13894
|
+
value = value.get(0, 0);
|
|
13895
|
+
}
|
|
13896
|
+
value.isNull() && (value = NumberValueObject.create(0)), row.push(value);
|
|
12777
13897
|
}
|
|
12778
13898
|
resultArray.push(row);
|
|
12779
13899
|
}
|
|
@@ -12828,11 +13948,15 @@ const _Reduce = class _Reduce extends BaseFunction {
|
|
|
12828
13948
|
super(...arguments);
|
|
12829
13949
|
__publicField(this, "minParams", 3);
|
|
12830
13950
|
__publicField(this, "maxParams", 3);
|
|
13951
|
+
__publicField(this, "needsReferenceObject", !0);
|
|
12831
13952
|
}
|
|
12832
13953
|
calculate(initialValue, array, lambda) {
|
|
12833
|
-
|
|
13954
|
+
let _initialValue, _initialValueReference;
|
|
13955
|
+
initialValue.isReferenceObject() ? (_initialValue = initialValue.toArrayValueObject(), _initialValueReference = initialValue) : (_initialValue = initialValue, _initialValueReference = null);
|
|
13956
|
+
let _array, _arrayReference;
|
|
13957
|
+
return array.isReferenceObject() ? (_array = array.toArrayValueObject(), _arrayReference = array) : (_array = array, _arrayReference = null), _initialValue.isArray() ? _initialValue.mapValue((initialValueObject) => this._handleSingleValueObject(initialValueObject, _array, lambda, _initialValueReference, _arrayReference)) : this._handleSingleValueObject(_initialValue, _array, lambda, _initialValueReference, _arrayReference);
|
|
12834
13958
|
}
|
|
12835
|
-
_handleSingleValueObject(initialValue, array, lambda) {
|
|
13959
|
+
_handleSingleValueObject(initialValue, array, lambda, _initialValue_reference, _array_reference) {
|
|
12836
13960
|
if (initialValue.isError())
|
|
12837
13961
|
return initialValue;
|
|
12838
13962
|
if (array.isError())
|
|
@@ -12843,18 +13967,27 @@ const _Reduce = class _Reduce extends BaseFunction {
|
|
|
12843
13967
|
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
12844
13968
|
const _lambda = lambda, rowCount = array.isArray() ? array.getRowCount() : 1, columnCount = array.isArray() ? array.getColumnCount() : 1;
|
|
12845
13969
|
let accumulator = initialValue;
|
|
13970
|
+
_initialValue_reference && (accumulator = _initialValue_reference);
|
|
12846
13971
|
for (let r = 0; r < rowCount; r++)
|
|
12847
13972
|
for (let c = 0; c < columnCount; c++) {
|
|
12848
|
-
|
|
13973
|
+
let valueObject = array.isArray() ? array.get(r, c) : array;
|
|
12849
13974
|
if (valueObject.isError())
|
|
12850
13975
|
return valueObject;
|
|
13976
|
+
if (_array_reference) {
|
|
13977
|
+
const { startRow, startColumn } = _array_reference.getRangePosition(), range = {
|
|
13978
|
+
startRow: startRow + r,
|
|
13979
|
+
startColumn: startColumn + c,
|
|
13980
|
+
endRow: startRow + r,
|
|
13981
|
+
endColumn: startColumn + c
|
|
13982
|
+
};
|
|
13983
|
+
valueObject = this.createReferenceObject(_array_reference, range);
|
|
13984
|
+
}
|
|
12851
13985
|
let value = _lambda.execute(accumulator, valueObject);
|
|
12852
|
-
if (value.
|
|
13986
|
+
if (value.isError())
|
|
12853
13987
|
return value;
|
|
12854
13988
|
value.isNull() && (value = NumberValueObject.create(0)), accumulator = value;
|
|
12855
13989
|
}
|
|
12856
|
-
|
|
12857
|
-
return Number.isNaN(result) || !Number.isFinite(result) ? ErrorValueObject.create(ErrorType$1.VALUE) : NumberValueObject.create(result);
|
|
13990
|
+
return accumulator.isReferenceObject() ? accumulator.toArrayValueObject() : accumulator;
|
|
12858
13991
|
}
|
|
12859
13992
|
};
|
|
12860
13993
|
__name(_Reduce, "Reduce");
|
|
@@ -12864,29 +13997,33 @@ const _Scan = class _Scan extends BaseFunction {
|
|
|
12864
13997
|
super(...arguments);
|
|
12865
13998
|
__publicField(this, "minParams", 3);
|
|
12866
13999
|
__publicField(this, "maxParams", 3);
|
|
14000
|
+
__publicField(this, "needsReferenceObject", !0);
|
|
12867
14001
|
}
|
|
12868
14002
|
calculate(initialValue, array, lambda) {
|
|
12869
|
-
|
|
12870
|
-
|
|
12871
|
-
|
|
12872
|
-
|
|
14003
|
+
let _initialValue = initialValue, _initialValue_reference = null;
|
|
14004
|
+
initialValue.isReferenceObject() && (_initialValue = initialValue.toArrayValueObject(), _initialValue_reference = initialValue), _initialValue = _initialValue;
|
|
14005
|
+
let _array = array, _array_reference = null;
|
|
14006
|
+
if (array.isReferenceObject() && (_array = array.toArrayValueObject(), _array_reference = array), _array = _array, _initialValue.isError())
|
|
14007
|
+
return _initialValue;
|
|
14008
|
+
if (_array.isError())
|
|
14009
|
+
return _array;
|
|
12873
14010
|
if (lambda.isError())
|
|
12874
14011
|
return lambda;
|
|
12875
14012
|
if (!(lambda.isValueObject() && lambda.isLambda() && lambda.getLambdaPrivacyVarKeys().length === 2))
|
|
12876
14013
|
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
12877
|
-
|
|
12878
|
-
|
|
12879
|
-
const rowCount = initialValue.getRowCount(), columnCount = initialValue.getColumnCount();
|
|
14014
|
+
if (_initialValue.isArray()) {
|
|
14015
|
+
const rowCount = _initialValue.getRowCount(), columnCount = _initialValue.getColumnCount();
|
|
12880
14016
|
if (rowCount > 1 || columnCount > 1)
|
|
12881
14017
|
return ErrorValueObject.create(ErrorType$1.CALC);
|
|
12882
|
-
_initialValue =
|
|
14018
|
+
_initialValue = _initialValue.get(0, 0);
|
|
12883
14019
|
}
|
|
12884
|
-
return this._getResult(_initialValue,
|
|
14020
|
+
return this._getResult(_initialValue, _array, lambda, _initialValue_reference, _array_reference);
|
|
12885
14021
|
}
|
|
12886
|
-
|
|
12887
|
-
|
|
14022
|
+
// eslint-disable-next-line
|
|
14023
|
+
_getResult(initialValue, array, lambda, _initialValue_reference, _array_reference) {
|
|
14024
|
+
const resultArray = [], rowCount = array.isArray() ? array.getRowCount() : 1, columnCount = array.isArray() ? array.getColumnCount() : 1;
|
|
12888
14025
|
let accumulator = initialValue;
|
|
12889
|
-
|
|
14026
|
+
_initialValue_reference && (accumulator = _initialValue_reference);
|
|
12890
14027
|
for (let r = 0; r < rowCount; r++) {
|
|
12891
14028
|
const row = [];
|
|
12892
14029
|
for (let c = 0; c < columnCount; c++) {
|
|
@@ -12894,13 +14031,28 @@ const _Scan = class _Scan extends BaseFunction {
|
|
|
12894
14031
|
row.push(accumulator);
|
|
12895
14032
|
continue;
|
|
12896
14033
|
}
|
|
12897
|
-
|
|
14034
|
+
let valueObject = array.isArray() ? array.get(r, c) : array;
|
|
12898
14035
|
if (valueObject.isError()) {
|
|
12899
14036
|
accumulator = valueObject, row.push(valueObject);
|
|
12900
14037
|
continue;
|
|
12901
14038
|
}
|
|
14039
|
+
if (_array_reference) {
|
|
14040
|
+
const { startRow, startColumn } = _array_reference.getRangePosition(), range = {
|
|
14041
|
+
startRow: startRow + r,
|
|
14042
|
+
startColumn: startColumn + c,
|
|
14043
|
+
endRow: startRow + r,
|
|
14044
|
+
endColumn: startColumn + c
|
|
14045
|
+
};
|
|
14046
|
+
valueObject = this.createReferenceObject(_array_reference, range);
|
|
14047
|
+
}
|
|
12902
14048
|
let value = lambda.execute(accumulator, valueObject);
|
|
12903
|
-
|
|
14049
|
+
if (value.isArray()) {
|
|
14050
|
+
const rowCount2 = value.getRowCount(), columnCount2 = value.getColumnCount();
|
|
14051
|
+
if (rowCount2 > 1 || columnCount2 > 1)
|
|
14052
|
+
return ErrorValueObject.create(ErrorType$1.CALC);
|
|
14053
|
+
value = value.get(0, 0);
|
|
14054
|
+
}
|
|
14055
|
+
value.isNull() && (value = NumberValueObject.create(0)), accumulator = value, row.push(value);
|
|
12904
14056
|
}
|
|
12905
14057
|
resultArray.push(row);
|
|
12906
14058
|
}
|
|
@@ -13850,10 +15002,10 @@ const _Offset = class _Offset extends BaseFunction {
|
|
|
13850
15002
|
_rows.isReferenceObject() && (_rows = _rows.toArrayValueObject());
|
|
13851
15003
|
let _columns = columns;
|
|
13852
15004
|
_columns.isReferenceObject() && (_columns = _columns.toArrayValueObject());
|
|
13853
|
-
let _height = height;
|
|
13854
|
-
_height
|
|
13855
|
-
let _width = width;
|
|
13856
|
-
_width
|
|
15005
|
+
let _height = height != null ? height : NumberValueObject.create(rowCount);
|
|
15006
|
+
_height.isReferenceObject() && (_height = _height.toArrayValueObject()), _height.isNull() && (_height = NumberValueObject.create(rowCount));
|
|
15007
|
+
let _width = width != null ? width : NumberValueObject.create(columnCount);
|
|
15008
|
+
_width.isReferenceObject() && (_width = _width.toArrayValueObject()), _width.isNull() && (_width = NumberValueObject.create(columnCount));
|
|
13857
15009
|
const maxRowLength = Math.max(
|
|
13858
15010
|
_rows.isArray() ? _rows.getRowCount() : 1,
|
|
13859
15011
|
_columns.isArray() ? _columns.getRowCount() : 1,
|
|
@@ -13866,15 +15018,23 @@ const _Offset = class _Offset extends BaseFunction {
|
|
|
13866
15018
|
_width.isArray() ? _width.getColumnCount() : 1
|
|
13867
15019
|
);
|
|
13868
15020
|
if (_rows = _rows, _columns = _columns, _height = _height, _width = _width, maxRowLength === 1 && maxColumnLength === 1)
|
|
13869
|
-
return this._handleSingleObject(reference, _rows, _columns, _height, _width);
|
|
15021
|
+
return _rows = _rows.isArray() ? _rows.get(0, 0) : _rows, _columns = _columns.isArray() ? _columns.get(0, 0) : _columns, _height = _height.isArray() ? _height.get(0, 0) : _height, _width = _width.isArray() ? _width.get(0, 0) : _width, this._handleSingleObject(reference, _rows, _columns, _height, _width);
|
|
13870
15022
|
const rowsArray = expandArrayValueObject(maxRowLength, maxColumnLength, _rows, ErrorValueObject.create(ErrorType$1.NA)), columnsArray = expandArrayValueObject(maxRowLength, maxColumnLength, _columns, ErrorValueObject.create(ErrorType$1.NA)), heightArray = expandArrayValueObject(maxRowLength, maxColumnLength, _height, ErrorValueObject.create(ErrorType$1.NA)), widthArray = expandArrayValueObject(maxRowLength, maxColumnLength, _width, ErrorValueObject.create(ErrorType$1.NA));
|
|
13871
15023
|
return rowsArray.mapValue((rowsValue, rowIndex, columnIndex) => {
|
|
13872
15024
|
const columnsValue = columnsArray.get(rowIndex, columnIndex), heightValue = heightArray.get(rowIndex, columnIndex), widthValue = widthArray.get(rowIndex, columnIndex);
|
|
13873
15025
|
return rowsValue.isError() ? rowsValue : columnsValue.isError() ? columnsValue : heightValue.isError() ? heightValue : widthValue.isError() ? widthValue : this._handleSingleObject(reference, rowsValue, columnsValue, heightValue, widthValue, !0);
|
|
13874
15026
|
});
|
|
13875
15027
|
}
|
|
15028
|
+
// eslint-disable-next-line
|
|
13876
15029
|
_handleSingleObject(reference, rowsValue, columnsValue, heightValue, widthValue, isReportError = !1) {
|
|
13877
|
-
const { startRow: referenceStartRow, startColumn: referenceStartColumn } = reference.getRangePosition()
|
|
15030
|
+
const { startRow: referenceStartRow, startColumn: referenceStartColumn } = reference.getRangePosition();
|
|
15031
|
+
let _rowsValue = rowsValue;
|
|
15032
|
+
if (_rowsValue.isString() && (_rowsValue = _rowsValue.convertToNumberObjectValue()), _rowsValue.isError())
|
|
15033
|
+
return _rowsValue;
|
|
15034
|
+
let _columnsValue = columnsValue;
|
|
15035
|
+
if (_columnsValue.isString() && (_columnsValue = _columnsValue.convertToNumberObjectValue()), _columnsValue.isError())
|
|
15036
|
+
return _columnsValue;
|
|
15037
|
+
const rowOffset = +_rowsValue.getValue(), columnOffset = +_columnsValue.getValue();
|
|
13878
15038
|
if (typeof rowOffset != "number" || typeof columnOffset != "number")
|
|
13879
15039
|
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
13880
15040
|
const targetRow = referenceStartRow + rowOffset, targetColumn = referenceStartColumn + columnOffset;
|
|
@@ -14843,11 +16003,17 @@ const _Xlookup = class _Xlookup extends BaseFunction {
|
|
|
14843
16003
|
if (lookupValue.isArray()) {
|
|
14844
16004
|
let resultArray2;
|
|
14845
16005
|
return rowCountLookup === 1 ? resultArray2 = returnArray.slice([0, 1]) : resultArray2 = returnArray.slice(void 0, [0, 1]), resultArray2 == null ? ErrorValueObject.create(ErrorType$1.NA) : lookupValue.map((value) => {
|
|
16006
|
+
const checkErrorCombination = this._checkErrorCombination(matchModeValue, searchModeValue);
|
|
16007
|
+
if (checkErrorCombination)
|
|
16008
|
+
return checkErrorCombination;
|
|
14846
16009
|
const result = this._handleSingleObject(value, lookupArray, resultArray2, matchModeValue, searchModeValue);
|
|
14847
16010
|
return result.isError() ? ifNotFound : result;
|
|
14848
16011
|
});
|
|
14849
16012
|
}
|
|
14850
16013
|
if (columnCountLookup === columnCountReturn && rowCountLookup === rowCountReturn) {
|
|
16014
|
+
const checkErrorCombination = this._checkErrorCombination(matchModeValue, searchModeValue);
|
|
16015
|
+
if (checkErrorCombination)
|
|
16016
|
+
return checkErrorCombination;
|
|
14851
16017
|
const result = this._handleSingleObject(lookupValue, lookupArray, returnArray, matchModeValue, searchModeValue);
|
|
14852
16018
|
return result.isError() ? ifNotFound : result;
|
|
14853
16019
|
}
|
|
@@ -14857,13 +16023,18 @@ const _Xlookup = class _Xlookup extends BaseFunction {
|
|
|
14857
16023
|
return resultArray == null ? ErrorValueObject.create(ErrorType$1.NA) : resultArray;
|
|
14858
16024
|
}
|
|
14859
16025
|
_handleExpandObject(value, searchArray, resultArray, matchModeValue, searchModeValue, axis = 0) {
|
|
14860
|
-
|
|
14861
|
-
|
|
14862
|
-
|
|
14863
|
-
|
|
14864
|
-
|
|
14865
|
-
|
|
14866
|
-
|
|
16026
|
+
if ((searchModeValue === 2 || searchModeValue === -2) && matchModeValue !== 2) {
|
|
16027
|
+
const searchType = getSearchModeValue(searchModeValue), matchType = getMatchModeValue(matchModeValue);
|
|
16028
|
+
return this.binarySearchExpand(
|
|
16029
|
+
value,
|
|
16030
|
+
searchArray,
|
|
16031
|
+
resultArray,
|
|
16032
|
+
axis,
|
|
16033
|
+
searchType,
|
|
16034
|
+
matchType
|
|
16035
|
+
);
|
|
16036
|
+
}
|
|
16037
|
+
return matchModeValue === 2 ? this.fuzzySearchExpand(value, searchArray, resultArray, searchModeValue !== -1, axis) : matchModeValue === -1 || matchModeValue === 1 ? this.orderSearchExpand(
|
|
14867
16038
|
value,
|
|
14868
16039
|
searchArray,
|
|
14869
16040
|
resultArray,
|
|
@@ -14873,7 +16044,11 @@ const _Xlookup = class _Xlookup extends BaseFunction {
|
|
|
14873
16044
|
) : this.equalSearchExpand(value, searchArray, resultArray, searchModeValue !== -1, axis);
|
|
14874
16045
|
}
|
|
14875
16046
|
_handleSingleObject(value, searchArray, resultArray, matchModeValue, searchModeValue) {
|
|
14876
|
-
|
|
16047
|
+
if ((searchModeValue === 2 || searchModeValue === -2) && matchModeValue !== 2) {
|
|
16048
|
+
const searchType = getSearchModeValue(searchModeValue), matchType = getMatchModeValue(matchModeValue);
|
|
16049
|
+
return this.binarySearch(value, searchArray, resultArray, searchType, matchType);
|
|
16050
|
+
}
|
|
16051
|
+
return matchModeValue === 2 ? this.fuzzySearch(value, searchArray, resultArray, searchModeValue !== -1) : matchModeValue === -1 || matchModeValue === 1 ? this.orderSearch(
|
|
14877
16052
|
value,
|
|
14878
16053
|
searchArray,
|
|
14879
16054
|
resultArray,
|
|
@@ -14881,8 +16056,14 @@ const _Xlookup = class _Xlookup extends BaseFunction {
|
|
|
14881
16056
|
searchModeValue === -1
|
|
14882
16057
|
) : this.equalSearch(value, searchArray, resultArray, searchModeValue !== -1);
|
|
14883
16058
|
}
|
|
14884
|
-
|
|
14885
|
-
|
|
16059
|
+
/**
|
|
16060
|
+
* Wildcard matching and binary search cannot appear at the same time
|
|
16061
|
+
* @param matchModeValue
|
|
16062
|
+
* @param searchModeValue
|
|
16063
|
+
* @returns
|
|
16064
|
+
*/
|
|
16065
|
+
_checkErrorCombination(matchModeValue, searchModeValue) {
|
|
16066
|
+
return matchModeValue === 2 && (searchModeValue === -2 || searchModeValue === 2) ? ErrorValueObject.create(ErrorType$1.VALUE) : null;
|
|
14886
16067
|
}
|
|
14887
16068
|
};
|
|
14888
16069
|
__name(_Xlookup, "Xlookup");
|
|
@@ -14924,8 +16105,8 @@ const _Xmatch = class _Xmatch extends BaseFunction {
|
|
|
14924
16105
|
_handleSingleObject(value, searchArray, matchModeValue, searchModeValue) {
|
|
14925
16106
|
let rowOrColumn;
|
|
14926
16107
|
if ((searchModeValue === 2 || searchModeValue === -2) && matchModeValue !== 2) {
|
|
14927
|
-
const searchType =
|
|
14928
|
-
rowOrColumn = searchArray.binarySearch(value, searchType);
|
|
16108
|
+
const searchType = getSearchModeValue(searchModeValue), matchType = getMatchModeValue(matchModeValue);
|
|
16109
|
+
rowOrColumn = searchArray.binarySearch(value, searchType, matchType);
|
|
14929
16110
|
} else if (matchModeValue === 2) {
|
|
14930
16111
|
const matchObject = searchArray.compare(value, compareToken.EQUALS);
|
|
14931
16112
|
let position;
|
|
@@ -14948,9 +16129,6 @@ const _Xmatch = class _Xmatch extends BaseFunction {
|
|
|
14948
16129
|
}
|
|
14949
16130
|
return rowOrColumn == null ? ErrorValueObject.create(ErrorType$1.NA) : NumberValueObject.create(rowOrColumn + 1);
|
|
14950
16131
|
}
|
|
14951
|
-
_getSearchModeValue(searchModeValue) {
|
|
14952
|
-
return searchModeValue === -2 ? ArrayBinarySearchType.MAX : ArrayBinarySearchType.MIN;
|
|
14953
|
-
}
|
|
14954
16132
|
};
|
|
14955
16133
|
__name(_Xmatch, "Xmatch");
|
|
14956
16134
|
let Xmatch = _Xmatch;
|
|
@@ -14987,9 +16165,7 @@ const functionLookup = [
|
|
|
14987
16165
|
[Wraprows, FUNCTION_NAMES_LOOKUP.WRAPROWS],
|
|
14988
16166
|
[Xlookup, FUNCTION_NAMES_LOOKUP.XLOOKUP],
|
|
14989
16167
|
[Xmatch, FUNCTION_NAMES_LOOKUP.XMATCH]
|
|
14990
|
-
]
|
|
14991
|
-
var FUNCTION_NAMES_MATH = /* @__PURE__ */ ((FUNCTION_NAMES_MATH2) => (FUNCTION_NAMES_MATH2.ABS = "ABS", FUNCTION_NAMES_MATH2.ACOS = "ACOS", FUNCTION_NAMES_MATH2.ACOSH = "ACOSH", FUNCTION_NAMES_MATH2.ACOT = "ACOT", FUNCTION_NAMES_MATH2.ACOTH = "ACOTH", FUNCTION_NAMES_MATH2.AGGREGATE = "AGGREGATE", FUNCTION_NAMES_MATH2.ARABIC = "ARABIC", FUNCTION_NAMES_MATH2.ASIN = "ASIN", FUNCTION_NAMES_MATH2.ASINH = "ASINH", FUNCTION_NAMES_MATH2.ATAN = "ATAN", FUNCTION_NAMES_MATH2.ATAN2 = "ATAN2", FUNCTION_NAMES_MATH2.ATANH = "ATANH", FUNCTION_NAMES_MATH2.BASE = "BASE", FUNCTION_NAMES_MATH2.CEILING = "CEILING", FUNCTION_NAMES_MATH2.CEILING_MATH = "CEILING.MATH", FUNCTION_NAMES_MATH2.CEILING_PRECISE = "CEILING.PRECISE", FUNCTION_NAMES_MATH2.COMBIN = "COMBIN", FUNCTION_NAMES_MATH2.COMBINA = "COMBINA", FUNCTION_NAMES_MATH2.COS = "COS", FUNCTION_NAMES_MATH2.COSH = "COSH", FUNCTION_NAMES_MATH2.COT = "COT", FUNCTION_NAMES_MATH2.COTH = "COTH", FUNCTION_NAMES_MATH2.CSC = "CSC", FUNCTION_NAMES_MATH2.CSCH = "CSCH", FUNCTION_NAMES_MATH2.DECIMAL = "DECIMAL", FUNCTION_NAMES_MATH2.DEGREES = "DEGREES", FUNCTION_NAMES_MATH2.EVEN = "EVEN", FUNCTION_NAMES_MATH2.EXP = "EXP", FUNCTION_NAMES_MATH2.FACT = "FACT", FUNCTION_NAMES_MATH2.FACTDOUBLE = "FACTDOUBLE", FUNCTION_NAMES_MATH2.FLOOR = "FLOOR", FUNCTION_NAMES_MATH2.FLOOR_MATH = "FLOOR.MATH", FUNCTION_NAMES_MATH2.FLOOR_PRECISE = "FLOOR.PRECISE", FUNCTION_NAMES_MATH2.GCD = "GCD", FUNCTION_NAMES_MATH2.INT = "INT", FUNCTION_NAMES_MATH2.ISO_CEILING = "ISO.CEILING", FUNCTION_NAMES_MATH2.LCM = "LCM", FUNCTION_NAMES_MATH2.LET = "LET", FUNCTION_NAMES_MATH2.LN = "LN", FUNCTION_NAMES_MATH2.LOG = "LOG", FUNCTION_NAMES_MATH2.LOG10 = "LOG10", FUNCTION_NAMES_MATH2.MDETERM = "MDETERM", FUNCTION_NAMES_MATH2.MINVERSE = "MINVERSE", FUNCTION_NAMES_MATH2.MMULT = "MMULT", FUNCTION_NAMES_MATH2.MOD = "MOD", FUNCTION_NAMES_MATH2.MROUND = "MROUND", FUNCTION_NAMES_MATH2.MULTINOMIAL = "MULTINOMIAL", FUNCTION_NAMES_MATH2.MUNIT = "MUNIT", FUNCTION_NAMES_MATH2.ODD = "ODD", FUNCTION_NAMES_MATH2.PI = "PI", FUNCTION_NAMES_MATH2.POWER = "POWER", FUNCTION_NAMES_MATH2.PRODUCT = "PRODUCT", FUNCTION_NAMES_MATH2.QUOTIENT = "QUOTIENT", FUNCTION_NAMES_MATH2.RADIANS = "RADIANS", FUNCTION_NAMES_MATH2.RAND = "RAND", FUNCTION_NAMES_MATH2.RANDARRAY = "RANDARRAY", FUNCTION_NAMES_MATH2.RANDBETWEEN = "RANDBETWEEN", FUNCTION_NAMES_MATH2.ROMAN = "ROMAN", FUNCTION_NAMES_MATH2.ROUND = "ROUND", FUNCTION_NAMES_MATH2.ROUNDDOWN = "ROUNDDOWN", FUNCTION_NAMES_MATH2.ROUNDUP = "ROUNDUP", FUNCTION_NAMES_MATH2.SEC = "SEC", FUNCTION_NAMES_MATH2.SECH = "SECH", FUNCTION_NAMES_MATH2.SERIESSUM = "SERIESSUM", FUNCTION_NAMES_MATH2.SEQUENCE = "SEQUENCE", FUNCTION_NAMES_MATH2.SIGN = "SIGN", FUNCTION_NAMES_MATH2.SIN = "SIN", FUNCTION_NAMES_MATH2.SINH = "SINH", FUNCTION_NAMES_MATH2.SQRT = "SQRT", FUNCTION_NAMES_MATH2.SQRTPI = "SQRTPI", FUNCTION_NAMES_MATH2.SUBTOTAL = "SUBTOTAL", FUNCTION_NAMES_MATH2.SUM = "SUM", FUNCTION_NAMES_MATH2.SUMIF = "SUMIF", FUNCTION_NAMES_MATH2.SUMIFS = "SUMIFS", FUNCTION_NAMES_MATH2.SUMPRODUCT = "SUMPRODUCT", FUNCTION_NAMES_MATH2.SUMSQ = "SUMSQ", FUNCTION_NAMES_MATH2.SUMX2MY2 = "SUMX2MY2", FUNCTION_NAMES_MATH2.SUMX2PY2 = "SUMX2PY2", FUNCTION_NAMES_MATH2.SUMXMY2 = "SUMXMY2", FUNCTION_NAMES_MATH2.TAN = "TAN", FUNCTION_NAMES_MATH2.TANH = "TANH", FUNCTION_NAMES_MATH2.TRUNC = "TRUNC", FUNCTION_NAMES_MATH2))(FUNCTION_NAMES_MATH || {});
|
|
14992
|
-
const _Abs = class _Abs extends BaseFunction {
|
|
16168
|
+
], _Abs = class _Abs extends BaseFunction {
|
|
14993
16169
|
constructor() {
|
|
14994
16170
|
super(...arguments);
|
|
14995
16171
|
__publicField(this, "minParams", 1);
|
|
@@ -15291,76 +16467,13 @@ const _CeilingPrecise = class _CeilingPrecise extends BaseFunction {
|
|
|
15291
16467
|
if (numberValue === 0 || significanceValue === 0)
|
|
15292
16468
|
return NumberValueObject.create(0);
|
|
15293
16469
|
const result = (significanceValue < 0 ? -ceil(numberValue / Math.abs(significanceValue), 0) : ceil(numberValue / significanceValue, 0)) * significanceValue;
|
|
15294
|
-
return NumberValueObject.create(result);
|
|
15295
|
-
});
|
|
15296
|
-
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
15297
|
-
}
|
|
15298
|
-
};
|
|
15299
|
-
__name(_CeilingPrecise, "CeilingPrecise");
|
|
15300
|
-
let CeilingPrecise = _CeilingPrecise;
|
|
15301
|
-
function calculateFactorial(n, step = 1) {
|
|
15302
|
-
let _n = Math.floor(n);
|
|
15303
|
-
if (n < 0)
|
|
15304
|
-
return Number.NaN;
|
|
15305
|
-
let result = 1;
|
|
15306
|
-
for (; _n > 1 && Number.isFinite(result); )
|
|
15307
|
-
result *= _n, _n -= step;
|
|
15308
|
-
return result;
|
|
15309
|
-
}
|
|
15310
|
-
__name(calculateFactorial, "calculateFactorial");
|
|
15311
|
-
function calculateCombin(n, k) {
|
|
15312
|
-
const t = Math.min(n - k, k);
|
|
15313
|
-
let result = 1;
|
|
15314
|
-
for (let i = 1; i <= t && Number.isFinite(result); i++)
|
|
15315
|
-
result *= n - i + 1, result /= i;
|
|
15316
|
-
return result;
|
|
15317
|
-
}
|
|
15318
|
-
__name(calculateCombin, "calculateCombin");
|
|
15319
|
-
function calculateGcd(a, b) {
|
|
15320
|
-
let _a26 = Math.floor(a), _b = Math.floor(b);
|
|
15321
|
-
for (; _b !== 0; ) {
|
|
15322
|
-
const t = _b;
|
|
15323
|
-
_b = _a26 % _b, _a26 = t;
|
|
16470
|
+
return NumberValueObject.create(result);
|
|
16471
|
+
});
|
|
16472
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
15324
16473
|
}
|
|
15325
|
-
|
|
15326
|
-
|
|
15327
|
-
|
|
15328
|
-
function calculateLcm(a, b) {
|
|
15329
|
-
const den = calculateGcd(a, b);
|
|
15330
|
-
return den === 0 ? 0 : Math.abs(a * b) / den;
|
|
15331
|
-
}
|
|
15332
|
-
__name(calculateLcm, "calculateLcm");
|
|
15333
|
-
function calculateMdeterm(matrix) {
|
|
15334
|
-
const n = matrix.length;
|
|
15335
|
-
if (n === 1)
|
|
15336
|
-
return matrix[0][0];
|
|
15337
|
-
if (n === 2)
|
|
15338
|
-
return matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0];
|
|
15339
|
-
let det = 0;
|
|
15340
|
-
for (let col = 0; col < n; col++)
|
|
15341
|
-
det += (col % 2 === 0 ? 1 : -1) * matrix[0][col] * calculateMdeterm(minor(matrix, 0, col));
|
|
15342
|
-
return det;
|
|
15343
|
-
}
|
|
15344
|
-
__name(calculateMdeterm, "calculateMdeterm");
|
|
15345
|
-
function calculateMinverse(matrix) {
|
|
15346
|
-
const det = calculateMdeterm(matrix);
|
|
15347
|
-
return det === 0 ? null : matrix.length === 1 ? [[1 / det]] : adjoint(matrix).map((row) => row.map((value) => value / det));
|
|
15348
|
-
}
|
|
15349
|
-
__name(calculateMinverse, "calculateMinverse");
|
|
15350
|
-
function minor(matrix, row, col) {
|
|
15351
|
-
return matrix.filter((_, r) => r !== row).map((row2) => row2.filter((_, c) => c !== col));
|
|
15352
|
-
}
|
|
15353
|
-
__name(minor, "minor");
|
|
15354
|
-
function adjoint(matrix) {
|
|
15355
|
-
const n = matrix.length, adj = Array.from({ length: n }, () => new Array(n).fill(0));
|
|
15356
|
-
for (let i = 0; i < n; i++)
|
|
15357
|
-
for (let j = 0; j < n; j++) {
|
|
15358
|
-
const sign2 = (i + j) % 2 === 0 ? 1 : -1;
|
|
15359
|
-
adj[j][i] = sign2 * calculateMdeterm(minor(matrix, i, j));
|
|
15360
|
-
}
|
|
15361
|
-
return adj;
|
|
15362
|
-
}
|
|
15363
|
-
__name(adjoint, "adjoint");
|
|
16474
|
+
};
|
|
16475
|
+
__name(_CeilingPrecise, "CeilingPrecise");
|
|
16476
|
+
let CeilingPrecise = _CeilingPrecise;
|
|
15364
16477
|
const _Combin = class _Combin extends BaseFunction {
|
|
15365
16478
|
constructor() {
|
|
15366
16479
|
super(...arguments);
|
|
@@ -15775,6 +16888,7 @@ const _FloorPrecise = class _FloorPrecise extends BaseFunction {
|
|
|
15775
16888
|
};
|
|
15776
16889
|
__name(_FloorPrecise, "FloorPrecise");
|
|
15777
16890
|
let FloorPrecise = _FloorPrecise;
|
|
16891
|
+
var FUNCTION_NAMES_MATH = /* @__PURE__ */ ((FUNCTION_NAMES_MATH2) => (FUNCTION_NAMES_MATH2.ABS = "ABS", FUNCTION_NAMES_MATH2.ACOS = "ACOS", FUNCTION_NAMES_MATH2.ACOSH = "ACOSH", FUNCTION_NAMES_MATH2.ACOT = "ACOT", FUNCTION_NAMES_MATH2.ACOTH = "ACOTH", FUNCTION_NAMES_MATH2.AGGREGATE = "AGGREGATE", FUNCTION_NAMES_MATH2.ARABIC = "ARABIC", FUNCTION_NAMES_MATH2.ASIN = "ASIN", FUNCTION_NAMES_MATH2.ASINH = "ASINH", FUNCTION_NAMES_MATH2.ATAN = "ATAN", FUNCTION_NAMES_MATH2.ATAN2 = "ATAN2", FUNCTION_NAMES_MATH2.ATANH = "ATANH", FUNCTION_NAMES_MATH2.BASE = "BASE", FUNCTION_NAMES_MATH2.CEILING = "CEILING", FUNCTION_NAMES_MATH2.CEILING_MATH = "CEILING.MATH", FUNCTION_NAMES_MATH2.CEILING_PRECISE = "CEILING.PRECISE", FUNCTION_NAMES_MATH2.COMBIN = "COMBIN", FUNCTION_NAMES_MATH2.COMBINA = "COMBINA", FUNCTION_NAMES_MATH2.COS = "COS", FUNCTION_NAMES_MATH2.COSH = "COSH", FUNCTION_NAMES_MATH2.COT = "COT", FUNCTION_NAMES_MATH2.COTH = "COTH", FUNCTION_NAMES_MATH2.CSC = "CSC", FUNCTION_NAMES_MATH2.CSCH = "CSCH", FUNCTION_NAMES_MATH2.DECIMAL = "DECIMAL", FUNCTION_NAMES_MATH2.DEGREES = "DEGREES", FUNCTION_NAMES_MATH2.EVEN = "EVEN", FUNCTION_NAMES_MATH2.EXP = "EXP", FUNCTION_NAMES_MATH2.FACT = "FACT", FUNCTION_NAMES_MATH2.FACTDOUBLE = "FACTDOUBLE", FUNCTION_NAMES_MATH2.FLOOR = "FLOOR", FUNCTION_NAMES_MATH2.FLOOR_MATH = "FLOOR.MATH", FUNCTION_NAMES_MATH2.FLOOR_PRECISE = "FLOOR.PRECISE", FUNCTION_NAMES_MATH2.GCD = "GCD", FUNCTION_NAMES_MATH2.INT = "INT", FUNCTION_NAMES_MATH2.ISO_CEILING = "ISO.CEILING", FUNCTION_NAMES_MATH2.LCM = "LCM", FUNCTION_NAMES_MATH2.LET = "LET", FUNCTION_NAMES_MATH2.LN = "LN", FUNCTION_NAMES_MATH2.LOG = "LOG", FUNCTION_NAMES_MATH2.LOG10 = "LOG10", FUNCTION_NAMES_MATH2.MDETERM = "MDETERM", FUNCTION_NAMES_MATH2.MINVERSE = "MINVERSE", FUNCTION_NAMES_MATH2.MMULT = "MMULT", FUNCTION_NAMES_MATH2.MOD = "MOD", FUNCTION_NAMES_MATH2.MROUND = "MROUND", FUNCTION_NAMES_MATH2.MULTINOMIAL = "MULTINOMIAL", FUNCTION_NAMES_MATH2.MUNIT = "MUNIT", FUNCTION_NAMES_MATH2.ODD = "ODD", FUNCTION_NAMES_MATH2.PI = "PI", FUNCTION_NAMES_MATH2.POWER = "POWER", FUNCTION_NAMES_MATH2.PRODUCT = "PRODUCT", FUNCTION_NAMES_MATH2.QUOTIENT = "QUOTIENT", FUNCTION_NAMES_MATH2.RADIANS = "RADIANS", FUNCTION_NAMES_MATH2.RAND = "RAND", FUNCTION_NAMES_MATH2.RANDARRAY = "RANDARRAY", FUNCTION_NAMES_MATH2.RANDBETWEEN = "RANDBETWEEN", FUNCTION_NAMES_MATH2.ROMAN = "ROMAN", FUNCTION_NAMES_MATH2.ROUND = "ROUND", FUNCTION_NAMES_MATH2.ROUNDDOWN = "ROUNDDOWN", FUNCTION_NAMES_MATH2.ROUNDUP = "ROUNDUP", FUNCTION_NAMES_MATH2.SEC = "SEC", FUNCTION_NAMES_MATH2.SECH = "SECH", FUNCTION_NAMES_MATH2.SERIESSUM = "SERIESSUM", FUNCTION_NAMES_MATH2.SEQUENCE = "SEQUENCE", FUNCTION_NAMES_MATH2.SIGN = "SIGN", FUNCTION_NAMES_MATH2.SIN = "SIN", FUNCTION_NAMES_MATH2.SINH = "SINH", FUNCTION_NAMES_MATH2.SQRT = "SQRT", FUNCTION_NAMES_MATH2.SQRTPI = "SQRTPI", FUNCTION_NAMES_MATH2.SUBTOTAL = "SUBTOTAL", FUNCTION_NAMES_MATH2.SUM = "SUM", FUNCTION_NAMES_MATH2.SUMIF = "SUMIF", FUNCTION_NAMES_MATH2.SUMIFS = "SUMIFS", FUNCTION_NAMES_MATH2.SUMPRODUCT = "SUMPRODUCT", FUNCTION_NAMES_MATH2.SUMSQ = "SUMSQ", FUNCTION_NAMES_MATH2.SUMX2MY2 = "SUMX2MY2", FUNCTION_NAMES_MATH2.SUMX2PY2 = "SUMX2PY2", FUNCTION_NAMES_MATH2.SUMXMY2 = "SUMXMY2", FUNCTION_NAMES_MATH2.TAN = "TAN", FUNCTION_NAMES_MATH2.TANH = "TANH", FUNCTION_NAMES_MATH2.TRUNC = "TRUNC", FUNCTION_NAMES_MATH2))(FUNCTION_NAMES_MATH || {});
|
|
15778
16892
|
const _Gcd = class _Gcd extends BaseFunction {
|
|
15779
16893
|
constructor() {
|
|
15780
16894
|
super(...arguments);
|
|
@@ -16630,6 +17744,51 @@ const _Sech = class _Sech extends BaseFunction {
|
|
|
16630
17744
|
};
|
|
16631
17745
|
__name(_Sech, "Sech");
|
|
16632
17746
|
let Sech = _Sech;
|
|
17747
|
+
const _Sequence = class _Sequence extends BaseFunction {
|
|
17748
|
+
constructor() {
|
|
17749
|
+
super(...arguments);
|
|
17750
|
+
__publicField(this, "minParams", 1);
|
|
17751
|
+
__publicField(this, "maxParams", 4);
|
|
17752
|
+
}
|
|
17753
|
+
calculate(rows, columns, start, step) {
|
|
17754
|
+
let _rows = rows, _columns = columns != null ? columns : NumberValueObject.create(1), _start = start != null ? start : NumberValueObject.create(1), _step = step != null ? step : NumberValueObject.create(1);
|
|
17755
|
+
_rows.isNull() && (_rows = NumberValueObject.create(1)), _columns.isNull() && (_columns = NumberValueObject.create(1)), _start.isNull() && (_start = NumberValueObject.create(1)), _step.isNull() && (_step = NumberValueObject.create(1));
|
|
17756
|
+
const maxRowLength = Math.max(
|
|
17757
|
+
_rows.isArray() ? _rows.getRowCount() : 1,
|
|
17758
|
+
_columns.isArray() ? _columns.getRowCount() : 1,
|
|
17759
|
+
_start.isArray() ? _start.getRowCount() : 1,
|
|
17760
|
+
_step.isArray() ? _step.getRowCount() : 1
|
|
17761
|
+
), maxColumnLength = Math.max(
|
|
17762
|
+
_rows.isArray() ? _rows.getColumnCount() : 1,
|
|
17763
|
+
_columns.isArray() ? _columns.getColumnCount() : 1,
|
|
17764
|
+
_start.isArray() ? _start.getColumnCount() : 1,
|
|
17765
|
+
_step.isArray() ? _step.getColumnCount() : 1
|
|
17766
|
+
), rowsArray = expandArrayValueObject(maxRowLength, maxColumnLength, _rows, ErrorValueObject.create(ErrorType$1.NA)), columnsArray = expandArrayValueObject(maxRowLength, maxColumnLength, _columns, ErrorValueObject.create(ErrorType$1.NA)), startArray = expandArrayValueObject(maxRowLength, maxColumnLength, _start, ErrorValueObject.create(ErrorType$1.NA)), stepArray = expandArrayValueObject(maxRowLength, maxColumnLength, _step, ErrorValueObject.create(ErrorType$1.NA)), resultArray = rowsArray.mapValue((rowsObject, rowIndex, columnIndex) => {
|
|
17767
|
+
const columnsObject = columnsArray.get(rowIndex, columnIndex), startObject = startArray.get(rowIndex, columnIndex), stepObject = stepArray.get(rowIndex, columnIndex);
|
|
17768
|
+
return rowsObject.isError() ? rowsObject : columnsObject.isError() ? columnsObject : startObject.isError() ? startObject : stepObject.isError() ? stepObject : this._getResult(rowsObject, columnsObject, startObject, stepObject, maxRowLength, maxColumnLength);
|
|
17769
|
+
});
|
|
17770
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
17771
|
+
}
|
|
17772
|
+
_getResult(rowsObject, columnsObject, startObject, stepObject, maxRowLength, maxColumnLength) {
|
|
17773
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(rowsObject, columnsObject, startObject, stepObject);
|
|
17774
|
+
if (isError)
|
|
17775
|
+
return errorObject;
|
|
17776
|
+
const [_rowsObject, _columnsObject, _startObject, _stepObject] = variants, rowsValue = Math.floor(+_rowsObject.getValue()), columnsValue = Math.floor(+_columnsObject.getValue()), startValue = +_startObject.getValue(), stepValue = +_stepObject.getValue();
|
|
17777
|
+
if (rowsValue < 0 || columnsValue < 0)
|
|
17778
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
17779
|
+
if (rowsValue === 0 || columnsValue === 0)
|
|
17780
|
+
return ErrorValueObject.create(ErrorType$1.CALC);
|
|
17781
|
+
const result = [];
|
|
17782
|
+
for (let r = 0; r < rowsValue; r++) {
|
|
17783
|
+
result[r] = [];
|
|
17784
|
+
for (let c = 0; c < columnsValue; c++)
|
|
17785
|
+
result[r][c] = startValue + (r * columnsValue + c) * stepValue;
|
|
17786
|
+
}
|
|
17787
|
+
return maxRowLength > 1 || maxColumnLength > 1 ? NumberValueObject.create(result[0][0]) : ArrayValueObject.createByArray(result);
|
|
17788
|
+
}
|
|
17789
|
+
};
|
|
17790
|
+
__name(_Sequence, "Sequence");
|
|
17791
|
+
let Sequence = _Sequence;
|
|
16633
17792
|
const _Seriessum = class _Seriessum extends BaseFunction {
|
|
16634
17793
|
constructor() {
|
|
16635
17794
|
super(...arguments);
|
|
@@ -16695,51 +17854,6 @@ const _Seriessum = class _Seriessum extends BaseFunction {
|
|
|
16695
17854
|
};
|
|
16696
17855
|
__name(_Seriessum, "Seriessum");
|
|
16697
17856
|
let Seriessum = _Seriessum;
|
|
16698
|
-
const _Sequence = class _Sequence extends BaseFunction {
|
|
16699
|
-
constructor() {
|
|
16700
|
-
super(...arguments);
|
|
16701
|
-
__publicField(this, "minParams", 1);
|
|
16702
|
-
__publicField(this, "maxParams", 4);
|
|
16703
|
-
}
|
|
16704
|
-
calculate(rows, columns, start, step) {
|
|
16705
|
-
let _rows = rows, _columns = columns != null ? columns : NumberValueObject.create(1), _start = start != null ? start : NumberValueObject.create(1), _step = step != null ? step : NumberValueObject.create(1);
|
|
16706
|
-
_rows.isNull() && (_rows = NumberValueObject.create(1)), _columns.isNull() && (_columns = NumberValueObject.create(1)), _start.isNull() && (_start = NumberValueObject.create(1)), _step.isNull() && (_step = NumberValueObject.create(1));
|
|
16707
|
-
const maxRowLength = Math.max(
|
|
16708
|
-
_rows.isArray() ? _rows.getRowCount() : 1,
|
|
16709
|
-
_columns.isArray() ? _columns.getRowCount() : 1,
|
|
16710
|
-
_start.isArray() ? _start.getRowCount() : 1,
|
|
16711
|
-
_step.isArray() ? _step.getRowCount() : 1
|
|
16712
|
-
), maxColumnLength = Math.max(
|
|
16713
|
-
_rows.isArray() ? _rows.getColumnCount() : 1,
|
|
16714
|
-
_columns.isArray() ? _columns.getColumnCount() : 1,
|
|
16715
|
-
_start.isArray() ? _start.getColumnCount() : 1,
|
|
16716
|
-
_step.isArray() ? _step.getColumnCount() : 1
|
|
16717
|
-
), rowsArray = expandArrayValueObject(maxRowLength, maxColumnLength, _rows, ErrorValueObject.create(ErrorType$1.NA)), columnsArray = expandArrayValueObject(maxRowLength, maxColumnLength, _columns, ErrorValueObject.create(ErrorType$1.NA)), startArray = expandArrayValueObject(maxRowLength, maxColumnLength, _start, ErrorValueObject.create(ErrorType$1.NA)), stepArray = expandArrayValueObject(maxRowLength, maxColumnLength, _step, ErrorValueObject.create(ErrorType$1.NA)), resultArray = rowsArray.mapValue((rowsObject, rowIndex, columnIndex) => {
|
|
16718
|
-
const columnsObject = columnsArray.get(rowIndex, columnIndex), startObject = startArray.get(rowIndex, columnIndex), stepObject = stepArray.get(rowIndex, columnIndex);
|
|
16719
|
-
return rowsObject.isError() ? rowsObject : columnsObject.isError() ? columnsObject : startObject.isError() ? startObject : stepObject.isError() ? stepObject : this._getResult(rowsObject, columnsObject, startObject, stepObject, maxRowLength, maxColumnLength);
|
|
16720
|
-
});
|
|
16721
|
-
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
16722
|
-
}
|
|
16723
|
-
_getResult(rowsObject, columnsObject, startObject, stepObject, maxRowLength, maxColumnLength) {
|
|
16724
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(rowsObject, columnsObject, startObject, stepObject);
|
|
16725
|
-
if (isError)
|
|
16726
|
-
return errorObject;
|
|
16727
|
-
const [_rowsObject, _columnsObject, _startObject, _stepObject] = variants, rowsValue = Math.floor(+_rowsObject.getValue()), columnsValue = Math.floor(+_columnsObject.getValue()), startValue = +_startObject.getValue(), stepValue = +_stepObject.getValue();
|
|
16728
|
-
if (rowsValue < 0 || columnsValue < 0)
|
|
16729
|
-
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
16730
|
-
if (rowsValue === 0 || columnsValue === 0)
|
|
16731
|
-
return ErrorValueObject.create(ErrorType$1.CALC);
|
|
16732
|
-
const result = [];
|
|
16733
|
-
for (let r = 0; r < rowsValue; r++) {
|
|
16734
|
-
result[r] = [];
|
|
16735
|
-
for (let c = 0; c < columnsValue; c++)
|
|
16736
|
-
result[r][c] = startValue + (r * columnsValue + c) * stepValue;
|
|
16737
|
-
}
|
|
16738
|
-
return maxRowLength > 1 || maxColumnLength > 1 ? NumberValueObject.create(result[0][0]) : ArrayValueObject.createByArray(result);
|
|
16739
|
-
}
|
|
16740
|
-
};
|
|
16741
|
-
__name(_Sequence, "Sequence");
|
|
16742
|
-
let Sequence = _Sequence;
|
|
16743
17857
|
const _Sign = class _Sign extends BaseFunction {
|
|
16744
17858
|
constructor() {
|
|
16745
17859
|
super(...arguments);
|
|
@@ -17653,9 +18767,7 @@ const functionMeta = [
|
|
|
17653
18767
|
[Multiply, FUNCTION_NAMES_META.MULTIPLY],
|
|
17654
18768
|
[Plus, FUNCTION_NAMES_META.PLUS],
|
|
17655
18769
|
[Cube, FUNCTION_NAMES_META.CUBE]
|
|
17656
|
-
]
|
|
17657
|
-
var FUNCTION_NAMES_STATISTICAL = /* @__PURE__ */ ((FUNCTION_NAMES_STATISTICAL2) => (FUNCTION_NAMES_STATISTICAL2.AVEDEV = "AVEDEV", FUNCTION_NAMES_STATISTICAL2.AVERAGE = "AVERAGE", FUNCTION_NAMES_STATISTICAL2.AVERAGEA = "AVERAGEA", FUNCTION_NAMES_STATISTICAL2.AVERAGEIF = "AVERAGEIF", FUNCTION_NAMES_STATISTICAL2.AVERAGEIFS = "AVERAGEIFS", FUNCTION_NAMES_STATISTICAL2.BETA_DIST = "BETA.DIST", FUNCTION_NAMES_STATISTICAL2.BETA_INV = "BETA.INV", FUNCTION_NAMES_STATISTICAL2.BINOM_DIST = "BINOM.DIST", FUNCTION_NAMES_STATISTICAL2.BINOM_DIST_RANGE = "BINOM.DIST.RANGE", FUNCTION_NAMES_STATISTICAL2.BINOM_INV = "BINOM.INV", FUNCTION_NAMES_STATISTICAL2.CHISQ_DIST = "CHISQ.DIST", FUNCTION_NAMES_STATISTICAL2.CHISQ_DIST_RT = "CHISQ.DIST.RT", FUNCTION_NAMES_STATISTICAL2.CHISQ_INV = "CHISQ.INV", FUNCTION_NAMES_STATISTICAL2.CHISQ_INV_RT = "CHISQ.INV.RT", FUNCTION_NAMES_STATISTICAL2.CHISQ_TEST = "CHISQ.TEST", FUNCTION_NAMES_STATISTICAL2.CONFIDENCE_NORM = "CONFIDENCE.NORM", FUNCTION_NAMES_STATISTICAL2.CONFIDENCE_T = "CONFIDENCE.T", FUNCTION_NAMES_STATISTICAL2.CORREL = "CORREL", FUNCTION_NAMES_STATISTICAL2.COUNT = "COUNT", FUNCTION_NAMES_STATISTICAL2.COUNTA = "COUNTA", FUNCTION_NAMES_STATISTICAL2.COUNTBLANK = "COUNTBLANK", FUNCTION_NAMES_STATISTICAL2.COUNTIF = "COUNTIF", FUNCTION_NAMES_STATISTICAL2.COUNTIFS = "COUNTIFS", FUNCTION_NAMES_STATISTICAL2.COVARIANCE_P = "COVARIANCE.P", FUNCTION_NAMES_STATISTICAL2.COVARIANCE_S = "COVARIANCE.S", FUNCTION_NAMES_STATISTICAL2.DEVSQ = "DEVSQ", FUNCTION_NAMES_STATISTICAL2.EXPON_DIST = "EXPON.DIST", FUNCTION_NAMES_STATISTICAL2.F_DIST = "F.DIST", FUNCTION_NAMES_STATISTICAL2.F_DIST_RT = "F.DIST.RT", FUNCTION_NAMES_STATISTICAL2.F_INV = "F.INV", FUNCTION_NAMES_STATISTICAL2.F_INV_RT = "F.INV.RT", FUNCTION_NAMES_STATISTICAL2.F_TEST = "F.TEST", FUNCTION_NAMES_STATISTICAL2.FISHER = "FISHER", FUNCTION_NAMES_STATISTICAL2.FISHERINV = "FISHERINV", FUNCTION_NAMES_STATISTICAL2.FORECAST = "FORECAST", FUNCTION_NAMES_STATISTICAL2.FORECAST_ETS = "FORECAST.ETS", FUNCTION_NAMES_STATISTICAL2.FORECAST_ETS_CONFINT = "FORECAST.ETS.CONFINT", FUNCTION_NAMES_STATISTICAL2.FORECAST_ETS_SEASONALITY = "FORECAST.ETS.SEASONALITY", FUNCTION_NAMES_STATISTICAL2.FORECAST_ETS_STAT = "FORECAST.ETS.STAT", FUNCTION_NAMES_STATISTICAL2.FORECAST_LINEAR = "FORECAST.LINEAR", FUNCTION_NAMES_STATISTICAL2.FREQUENCY = "FREQUENCY", FUNCTION_NAMES_STATISTICAL2.GAMMA = "GAMMA", FUNCTION_NAMES_STATISTICAL2.GAMMA_DIST = "GAMMA.DIST", FUNCTION_NAMES_STATISTICAL2.GAMMA_INV = "GAMMA.INV", FUNCTION_NAMES_STATISTICAL2.GAMMALN = "GAMMALN", FUNCTION_NAMES_STATISTICAL2.GAMMALN_PRECISE = "GAMMALN.PRECISE", FUNCTION_NAMES_STATISTICAL2.GAUSS = "GAUSS", FUNCTION_NAMES_STATISTICAL2.GEOMEAN = "GEOMEAN", FUNCTION_NAMES_STATISTICAL2.GROWTH = "GROWTH", FUNCTION_NAMES_STATISTICAL2.HARMEAN = "HARMEAN", FUNCTION_NAMES_STATISTICAL2.HYPGEOM_DIST = "HYPGEOM.DIST", FUNCTION_NAMES_STATISTICAL2.INTERCEPT = "INTERCEPT", FUNCTION_NAMES_STATISTICAL2.KURT = "KURT", FUNCTION_NAMES_STATISTICAL2.LARGE = "LARGE", FUNCTION_NAMES_STATISTICAL2.LINEST = "LINEST", FUNCTION_NAMES_STATISTICAL2.LOGEST = "LOGEST", FUNCTION_NAMES_STATISTICAL2.LOGNORM_DIST = "LOGNORM.DIST", FUNCTION_NAMES_STATISTICAL2.LOGNORM_INV = "LOGNORM.INV", FUNCTION_NAMES_STATISTICAL2.MAX = "MAX", FUNCTION_NAMES_STATISTICAL2.MAXA = "MAXA", FUNCTION_NAMES_STATISTICAL2.MAXIFS = "MAXIFS", FUNCTION_NAMES_STATISTICAL2.MEDIAN = "MEDIAN", FUNCTION_NAMES_STATISTICAL2.MIN = "MIN", FUNCTION_NAMES_STATISTICAL2.MINA = "MINA", FUNCTION_NAMES_STATISTICAL2.MINIFS = "MINIFS", FUNCTION_NAMES_STATISTICAL2.MODE_MULT = "MODE.MULT", FUNCTION_NAMES_STATISTICAL2.MODE_SNGL = "MODE.SNGL", FUNCTION_NAMES_STATISTICAL2.NEGBINOM_DIST = "NEGBINOM.DIST", FUNCTION_NAMES_STATISTICAL2.NORM_DIST = "NORM.DIST", FUNCTION_NAMES_STATISTICAL2.NORM_INV = "NORM.INV", FUNCTION_NAMES_STATISTICAL2.NORM_S_DIST = "NORM.S.DIST", FUNCTION_NAMES_STATISTICAL2.NORM_S_INV = "NORM.S.INV", FUNCTION_NAMES_STATISTICAL2.PEARSON = "PEARSON", FUNCTION_NAMES_STATISTICAL2.PERCENTILE_EXC = "PERCENTILE.EXC", FUNCTION_NAMES_STATISTICAL2.PERCENTILE_INC = "PERCENTILE.INC", FUNCTION_NAMES_STATISTICAL2.PERCENTRANK_EXC = "PERCENTRANK.EXC", FUNCTION_NAMES_STATISTICAL2.PERCENTRANK_INC = "PERCENTRANK.INC", FUNCTION_NAMES_STATISTICAL2.PERMUT = "PERMUT", FUNCTION_NAMES_STATISTICAL2.PERMUTATIONA = "PERMUTATIONA", FUNCTION_NAMES_STATISTICAL2.PHI = "PHI", FUNCTION_NAMES_STATISTICAL2.POISSON_DIST = "POISSON.DIST", FUNCTION_NAMES_STATISTICAL2.PROB = "PROB", FUNCTION_NAMES_STATISTICAL2.QUARTILE_EXC = "QUARTILE.EXC", FUNCTION_NAMES_STATISTICAL2.QUARTILE_INC = "QUARTILE.INC", FUNCTION_NAMES_STATISTICAL2.RANK_AVG = "RANK.AVG", FUNCTION_NAMES_STATISTICAL2.RANK_EQ = "RANK.EQ", FUNCTION_NAMES_STATISTICAL2.RSQ = "RSQ", FUNCTION_NAMES_STATISTICAL2.SKEW = "SKEW", FUNCTION_NAMES_STATISTICAL2.SKEW_P = "SKEW.P", FUNCTION_NAMES_STATISTICAL2.SLOPE = "SLOPE", FUNCTION_NAMES_STATISTICAL2.SMALL = "SMALL", FUNCTION_NAMES_STATISTICAL2.STANDARDIZE = "STANDARDIZE", FUNCTION_NAMES_STATISTICAL2.STDEV_P = "STDEV.P", FUNCTION_NAMES_STATISTICAL2.STDEV_S = "STDEV.S", FUNCTION_NAMES_STATISTICAL2.STDEVA = "STDEVA", FUNCTION_NAMES_STATISTICAL2.STDEVPA = "STDEVPA", FUNCTION_NAMES_STATISTICAL2.STEYX = "STEYX", FUNCTION_NAMES_STATISTICAL2.T_DIST = "T.DIST", FUNCTION_NAMES_STATISTICAL2.T_DIST_2T = "T.DIST.2T", FUNCTION_NAMES_STATISTICAL2.T_DIST_RT = "T.DIST.RT", FUNCTION_NAMES_STATISTICAL2.T_INV = "T.INV", FUNCTION_NAMES_STATISTICAL2.T_INV_2T = "T.INV.2T", FUNCTION_NAMES_STATISTICAL2.T_TEST = "T.TEST", FUNCTION_NAMES_STATISTICAL2.TREND = "TREND", FUNCTION_NAMES_STATISTICAL2.TRIMMEAN = "TRIMMEAN", FUNCTION_NAMES_STATISTICAL2.VAR_P = "VAR.P", FUNCTION_NAMES_STATISTICAL2.VAR_S = "VAR.S", FUNCTION_NAMES_STATISTICAL2.VARA = "VARA", FUNCTION_NAMES_STATISTICAL2.VARPA = "VARPA", FUNCTION_NAMES_STATISTICAL2.WEIBULL_DIST = "WEIBULL.DIST", FUNCTION_NAMES_STATISTICAL2.Z_TEST = "Z.TEST", FUNCTION_NAMES_STATISTICAL2))(FUNCTION_NAMES_STATISTICAL || {});
|
|
17658
|
-
const _Avedev = class _Avedev extends BaseFunction {
|
|
18770
|
+
], _Avedev = class _Avedev extends BaseFunction {
|
|
17659
18771
|
constructor() {
|
|
17660
18772
|
super(...arguments);
|
|
17661
18773
|
__publicField(this, "minParams", 1);
|
|
@@ -17810,43 +18922,273 @@ const _Averageif = class _Averageif extends BaseFunction {
|
|
|
17810
18922
|
return this.createReferenceObject(averageRange, rangeData);
|
|
17811
18923
|
}
|
|
17812
18924
|
};
|
|
17813
|
-
__name(_Averageif, "Averageif");
|
|
17814
|
-
let Averageif = _Averageif;
|
|
17815
|
-
const _Averageifs = class _Averageifs extends BaseFunction {
|
|
18925
|
+
__name(_Averageif, "Averageif");
|
|
18926
|
+
let Averageif = _Averageif;
|
|
18927
|
+
const _Averageifs = class _Averageifs extends BaseFunction {
|
|
18928
|
+
constructor() {
|
|
18929
|
+
super(...arguments);
|
|
18930
|
+
__publicField(this, "minParams", 3);
|
|
18931
|
+
__publicField(this, "maxParams", 255);
|
|
18932
|
+
}
|
|
18933
|
+
calculate(averageRange, ...variants) {
|
|
18934
|
+
if (averageRange.isError())
|
|
18935
|
+
return ErrorValueObject.create(ErrorType$1.NA);
|
|
18936
|
+
if (!averageRange.isArray() || variants.length % 2 !== 0 || variants.some((variant, i) => i % 2 === 0 && !variant.isArray()))
|
|
18937
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
18938
|
+
const { maxRowLength, maxColumnLength } = calculateMaxDimensions(variants), errorArray = getErrorArray(variants, averageRange, maxRowLength, maxColumnLength);
|
|
18939
|
+
if (errorArray)
|
|
18940
|
+
return errorArray;
|
|
18941
|
+
const booleanResults = getBooleanResults(variants, maxRowLength, maxColumnLength, !0);
|
|
18942
|
+
return this._aggregateResults(averageRange, booleanResults);
|
|
18943
|
+
}
|
|
18944
|
+
_aggregateResults(averageRange, booleanResults) {
|
|
18945
|
+
const maxResults = booleanResults.map((row) => row.map((booleanResult) => {
|
|
18946
|
+
const picked = averageRange.pick(booleanResult), sum2 = picked.sum(), count = picked.count();
|
|
18947
|
+
return sum2.divided(count);
|
|
18948
|
+
})), arrayValueObjectData = {
|
|
18949
|
+
calculateValueList: maxResults,
|
|
18950
|
+
rowCount: maxResults.length,
|
|
18951
|
+
columnCount: maxResults[0].length,
|
|
18952
|
+
unitId: this.unitId || "",
|
|
18953
|
+
sheetId: this.subUnitId || "",
|
|
18954
|
+
row: this.row,
|
|
18955
|
+
column: this.column
|
|
18956
|
+
};
|
|
18957
|
+
return ArrayValueObject.create(arrayValueObjectData);
|
|
18958
|
+
}
|
|
18959
|
+
};
|
|
18960
|
+
__name(_Averageifs, "Averageifs");
|
|
18961
|
+
let Averageifs = _Averageifs;
|
|
18962
|
+
const _BetaDist = class _BetaDist extends BaseFunction {
|
|
18963
|
+
constructor() {
|
|
18964
|
+
super(...arguments);
|
|
18965
|
+
__publicField(this, "minParams", 4);
|
|
18966
|
+
__publicField(this, "maxParams", 6);
|
|
18967
|
+
}
|
|
18968
|
+
calculate(x, alpha, beta, cumulative, A, B) {
|
|
18969
|
+
let _A = A != null ? A : NumberValueObject.create(0), _B = B != null ? B : NumberValueObject.create(1);
|
|
18970
|
+
_A.isNull() && (_A = NumberValueObject.create(0)), _B.isNull() && (_B = NumberValueObject.create(1));
|
|
18971
|
+
const maxRowLength = Math.max(
|
|
18972
|
+
x.isArray() ? x.getRowCount() : 1,
|
|
18973
|
+
alpha.isArray() ? alpha.getRowCount() : 1,
|
|
18974
|
+
beta.isArray() ? beta.getRowCount() : 1,
|
|
18975
|
+
cumulative.isArray() ? cumulative.getRowCount() : 1,
|
|
18976
|
+
_A.isArray() ? _A.getRowCount() : 1,
|
|
18977
|
+
_B.isArray() ? _B.getRowCount() : 1
|
|
18978
|
+
), maxColumnLength = Math.max(
|
|
18979
|
+
x.isArray() ? x.getColumnCount() : 1,
|
|
18980
|
+
alpha.isArray() ? alpha.getColumnCount() : 1,
|
|
18981
|
+
beta.isArray() ? beta.getColumnCount() : 1,
|
|
18982
|
+
cumulative.isArray() ? cumulative.getColumnCount() : 1,
|
|
18983
|
+
_A.isArray() ? _A.getColumnCount() : 1,
|
|
18984
|
+
_B.isArray() ? _B.getColumnCount() : 1
|
|
18985
|
+
), xArray = expandArrayValueObject(maxRowLength, maxColumnLength, x, ErrorValueObject.create(ErrorType$1.NA)), alphaArray = expandArrayValueObject(maxRowLength, maxColumnLength, alpha, ErrorValueObject.create(ErrorType$1.NA)), betaArray = expandArrayValueObject(maxRowLength, maxColumnLength, beta, ErrorValueObject.create(ErrorType$1.NA)), cumulativeArray = expandArrayValueObject(maxRowLength, maxColumnLength, cumulative, ErrorValueObject.create(ErrorType$1.NA)), AArray = expandArrayValueObject(maxRowLength, maxColumnLength, _A, ErrorValueObject.create(ErrorType$1.NA)), BArray = expandArrayValueObject(maxRowLength, maxColumnLength, _B, ErrorValueObject.create(ErrorType$1.NA)), resultArray = xArray.mapValue((xObject, rowIndex, columnIndex) => {
|
|
18986
|
+
const alphaObject = alphaArray.get(rowIndex, columnIndex), betaObject = betaArray.get(rowIndex, columnIndex), cumulativeObject = cumulativeArray.get(rowIndex, columnIndex), AObject = AArray.get(rowIndex, columnIndex), BObject = BArray.get(rowIndex, columnIndex);
|
|
18987
|
+
return this._handleSignleObject(xObject, alphaObject, betaObject, cumulativeObject, AObject, BObject);
|
|
18988
|
+
});
|
|
18989
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
18990
|
+
}
|
|
18991
|
+
_handleSignleObject(xObject, alphaObject, betaObject, cumulativeObject, AObject, BObject) {
|
|
18992
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(xObject, alphaObject, betaObject, cumulativeObject, AObject, BObject);
|
|
18993
|
+
if (isError)
|
|
18994
|
+
return errorObject;
|
|
18995
|
+
const [_xObject, _alphaObject, _betaObject, _cumulativeObject, _AObject, _BObject] = variants, xValue = +_xObject.getValue(), alphaValue = +_alphaObject.getValue(), betaValue = +_betaObject.getValue(), cumulativeValue = +_cumulativeObject.getValue(), AValue = +_AObject.getValue(), BValue = +_BObject.getValue();
|
|
18996
|
+
if (alphaValue <= 0 || betaValue <= 0 || xValue < AValue || xValue > BValue || AValue === BValue)
|
|
18997
|
+
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
18998
|
+
let result;
|
|
18999
|
+
return cumulativeValue ? result = betaCDF((xValue - AValue) / (BValue - AValue), alphaValue, betaValue) : result = betaPDF((xValue - AValue) / (BValue - AValue), alphaValue, betaValue) / (BValue - AValue), NumberValueObject.create(result);
|
|
19000
|
+
}
|
|
19001
|
+
};
|
|
19002
|
+
__name(_BetaDist, "BetaDist");
|
|
19003
|
+
let BetaDist = _BetaDist;
|
|
19004
|
+
const _BinomDistRange = class _BinomDistRange extends BaseFunction {
|
|
19005
|
+
constructor() {
|
|
19006
|
+
super(...arguments);
|
|
19007
|
+
__publicField(this, "minParams", 3);
|
|
19008
|
+
__publicField(this, "maxParams", 4);
|
|
19009
|
+
}
|
|
19010
|
+
calculate(trials, probabilityS, numberS, numberS2) {
|
|
19011
|
+
let _numberS2 = numberS2 != null ? numberS2 : numberS;
|
|
19012
|
+
_numberS2.isNull() && (_numberS2 = numberS);
|
|
19013
|
+
const maxRowLength = Math.max(
|
|
19014
|
+
trials.isArray() ? trials.getRowCount() : 1,
|
|
19015
|
+
probabilityS.isArray() ? probabilityS.getRowCount() : 1,
|
|
19016
|
+
numberS.isArray() ? numberS.getRowCount() : 1,
|
|
19017
|
+
_numberS2.isArray() ? _numberS2.getRowCount() : 1
|
|
19018
|
+
), maxColumnLength = Math.max(
|
|
19019
|
+
trials.isArray() ? trials.getColumnCount() : 1,
|
|
19020
|
+
probabilityS.isArray() ? probabilityS.getColumnCount() : 1,
|
|
19021
|
+
numberS.isArray() ? numberS.getColumnCount() : 1,
|
|
19022
|
+
_numberS2.isArray() ? _numberS2.getColumnCount() : 1
|
|
19023
|
+
), trialsArray = expandArrayValueObject(maxRowLength, maxColumnLength, trials, ErrorValueObject.create(ErrorType$1.NA)), probabilitySArray = expandArrayValueObject(maxRowLength, maxColumnLength, probabilityS, ErrorValueObject.create(ErrorType$1.NA)), numberSArray = expandArrayValueObject(maxRowLength, maxColumnLength, numberS, ErrorValueObject.create(ErrorType$1.NA)), numberS2Array = expandArrayValueObject(maxRowLength, maxColumnLength, _numberS2, ErrorValueObject.create(ErrorType$1.NA)), resultArray = trialsArray.mapValue((trialsObject, rowIndex, columnIndex) => {
|
|
19024
|
+
const probabilitySObject = probabilitySArray.get(rowIndex, columnIndex), numberSObject = numberSArray.get(rowIndex, columnIndex), numberS2Object = numberS2Array.get(rowIndex, columnIndex);
|
|
19025
|
+
return this._handleSignleObject(trialsObject, probabilitySObject, numberSObject, numberS2Object);
|
|
19026
|
+
});
|
|
19027
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
19028
|
+
}
|
|
19029
|
+
_handleSignleObject(trialsObject, probabilitySObject, numberSObject, numberS2Object) {
|
|
19030
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(trialsObject, probabilitySObject, numberSObject, numberS2Object);
|
|
19031
|
+
if (isError)
|
|
19032
|
+
return errorObject;
|
|
19033
|
+
const [_trialsObject, _probabilitySObject, _numberSObject, _numberS2Object] = variants, trialsValue = Math.floor(+_trialsObject.getValue()), probabilitySValue = +_probabilitySObject.getValue(), numberSValue = Math.floor(+_numberSObject.getValue()), numberS2Value = Math.floor(+_numberS2Object.getValue());
|
|
19034
|
+
if (trialsValue < 0 || probabilitySValue < 0 || probabilitySValue > 1 || numberSValue < 0 || numberSValue > trialsValue || numberS2Value < 0 || numberS2Value < numberSValue || numberS2Value > trialsValue)
|
|
19035
|
+
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
19036
|
+
let result = 0;
|
|
19037
|
+
for (let i = numberSValue; i <= numberS2Value; i++)
|
|
19038
|
+
result += binomialPDF(i, trialsValue, probabilitySValue);
|
|
19039
|
+
return NumberValueObject.create(result);
|
|
19040
|
+
}
|
|
19041
|
+
};
|
|
19042
|
+
__name(_BinomDistRange, "BinomDistRange");
|
|
19043
|
+
let BinomDistRange = _BinomDistRange;
|
|
19044
|
+
const _ChisqDist = class _ChisqDist extends BaseFunction {
|
|
19045
|
+
constructor() {
|
|
19046
|
+
super(...arguments);
|
|
19047
|
+
__publicField(this, "minParams", 3);
|
|
19048
|
+
__publicField(this, "maxParams", 3);
|
|
19049
|
+
}
|
|
19050
|
+
calculate(x, degFreedom, cumulative) {
|
|
19051
|
+
const maxRowLength = Math.max(
|
|
19052
|
+
x.isArray() ? x.getRowCount() : 1,
|
|
19053
|
+
degFreedom.isArray() ? degFreedom.getRowCount() : 1,
|
|
19054
|
+
cumulative.isArray() ? cumulative.getRowCount() : 1
|
|
19055
|
+
), maxColumnLength = Math.max(
|
|
19056
|
+
x.isArray() ? x.getColumnCount() : 1,
|
|
19057
|
+
degFreedom.isArray() ? degFreedom.getColumnCount() : 1,
|
|
19058
|
+
cumulative.isArray() ? cumulative.getColumnCount() : 1
|
|
19059
|
+
), xArray = expandArrayValueObject(maxRowLength, maxColumnLength, x, ErrorValueObject.create(ErrorType$1.NA)), degFreedomArray = expandArrayValueObject(maxRowLength, maxColumnLength, degFreedom, ErrorValueObject.create(ErrorType$1.NA)), cumulativeArray = expandArrayValueObject(maxRowLength, maxColumnLength, cumulative, ErrorValueObject.create(ErrorType$1.NA)), resultArray = xArray.mapValue((xObject, rowIndex, columnIndex) => {
|
|
19060
|
+
const degFreedomObject = degFreedomArray.get(rowIndex, columnIndex), cumulativeObject = cumulativeArray.get(rowIndex, columnIndex);
|
|
19061
|
+
return this._handleSignleObject(xObject, degFreedomObject, cumulativeObject);
|
|
19062
|
+
});
|
|
19063
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
19064
|
+
}
|
|
19065
|
+
_handleSignleObject(xObject, degFreedomObject, cumulativeObject) {
|
|
19066
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(xObject, degFreedomObject, cumulativeObject);
|
|
19067
|
+
if (isError)
|
|
19068
|
+
return errorObject;
|
|
19069
|
+
const [_xObject, _degFreedomObject, _cumulativeObject] = variants, xValue = +_xObject.getValue(), degFreedomValue = Math.floor(+_degFreedomObject.getValue()), cumulativeValue = +_cumulativeObject.getValue();
|
|
19070
|
+
if (xValue < 0 || degFreedomValue < 1 || degFreedomValue > 10 ** 10)
|
|
19071
|
+
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
19072
|
+
let result;
|
|
19073
|
+
return cumulativeValue ? result = chisquareCDF(xValue, degFreedomValue) : result = chisquarePDF(xValue, degFreedomValue), NumberValueObject.create(result);
|
|
19074
|
+
}
|
|
19075
|
+
};
|
|
19076
|
+
__name(_ChisqDist, "ChisqDist");
|
|
19077
|
+
let ChisqDist = _ChisqDist;
|
|
19078
|
+
const _ChisqInv = class _ChisqInv extends BaseFunction {
|
|
19079
|
+
constructor() {
|
|
19080
|
+
super(...arguments);
|
|
19081
|
+
__publicField(this, "minParams", 2);
|
|
19082
|
+
__publicField(this, "maxParams", 2);
|
|
19083
|
+
}
|
|
19084
|
+
calculate(probability, degFreedom) {
|
|
19085
|
+
const maxRowLength = Math.max(
|
|
19086
|
+
probability.isArray() ? probability.getRowCount() : 1,
|
|
19087
|
+
degFreedom.isArray() ? degFreedom.getRowCount() : 1
|
|
19088
|
+
), maxColumnLength = Math.max(
|
|
19089
|
+
probability.isArray() ? probability.getColumnCount() : 1,
|
|
19090
|
+
degFreedom.isArray() ? degFreedom.getColumnCount() : 1
|
|
19091
|
+
), probabilityArray = expandArrayValueObject(maxRowLength, maxColumnLength, probability, ErrorValueObject.create(ErrorType$1.NA)), degFreedomArray = expandArrayValueObject(maxRowLength, maxColumnLength, degFreedom, ErrorValueObject.create(ErrorType$1.NA)), resultArray = probabilityArray.mapValue((probabilityObject, rowIndex, columnIndex) => {
|
|
19092
|
+
const degFreedomObject = degFreedomArray.get(rowIndex, columnIndex);
|
|
19093
|
+
return this._handleSignleObject(probabilityObject, degFreedomObject);
|
|
19094
|
+
});
|
|
19095
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
19096
|
+
}
|
|
19097
|
+
_handleSignleObject(probabilityObject, degFreedomObject) {
|
|
19098
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(probabilityObject, degFreedomObject);
|
|
19099
|
+
if (isError)
|
|
19100
|
+
return errorObject;
|
|
19101
|
+
const [_probabilityObject, _degFreedomObject] = variants, probabilityValue = +_probabilityObject.getValue(), degFreedomValue = Math.floor(+_degFreedomObject.getValue());
|
|
19102
|
+
if (probabilityValue < 0 || probabilityValue > 1 || degFreedomValue < 1 || degFreedomValue > 10 ** 10)
|
|
19103
|
+
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
19104
|
+
const result = chisquareINV(probabilityValue, degFreedomValue);
|
|
19105
|
+
return Number.isNaN(result) || !Number.isFinite(result) ? ErrorValueObject.create(ErrorType$1.NUM) : NumberValueObject.create(result);
|
|
19106
|
+
}
|
|
19107
|
+
};
|
|
19108
|
+
__name(_ChisqInv, "ChisqInv");
|
|
19109
|
+
let ChisqInv = _ChisqInv;
|
|
19110
|
+
const _ConfidenceT = class _ConfidenceT extends BaseFunction {
|
|
19111
|
+
constructor() {
|
|
19112
|
+
super(...arguments);
|
|
19113
|
+
__publicField(this, "minParams", 3);
|
|
19114
|
+
__publicField(this, "maxParams", 3);
|
|
19115
|
+
}
|
|
19116
|
+
calculate(alpha, standardDev, size) {
|
|
19117
|
+
const maxRowLength = Math.max(
|
|
19118
|
+
alpha.isArray() ? alpha.getRowCount() : 1,
|
|
19119
|
+
standardDev.isArray() ? standardDev.getRowCount() : 1,
|
|
19120
|
+
size.isArray() ? size.getRowCount() : 1
|
|
19121
|
+
), maxColumnLength = Math.max(
|
|
19122
|
+
alpha.isArray() ? alpha.getColumnCount() : 1,
|
|
19123
|
+
standardDev.isArray() ? standardDev.getColumnCount() : 1,
|
|
19124
|
+
size.isArray() ? size.getColumnCount() : 1
|
|
19125
|
+
), alphaArray = expandArrayValueObject(maxRowLength, maxColumnLength, alpha, ErrorValueObject.create(ErrorType$1.NA)), standardDevArray = expandArrayValueObject(maxRowLength, maxColumnLength, standardDev, ErrorValueObject.create(ErrorType$1.NA)), sizeArray = expandArrayValueObject(maxRowLength, maxColumnLength, size, ErrorValueObject.create(ErrorType$1.NA)), resultArray = alphaArray.mapValue((alphaObject, rowIndex, columnIndex) => {
|
|
19126
|
+
const standardDevObject = standardDevArray.get(rowIndex, columnIndex), sizeObject = sizeArray.get(rowIndex, columnIndex), { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(alphaObject, standardDevObject, sizeObject);
|
|
19127
|
+
if (isError)
|
|
19128
|
+
return errorObject;
|
|
19129
|
+
const [_alphaObject, _standardDevObject, _sizeObject] = variants, alphaValue = +_alphaObject.getValue(), standardDevValue = +_standardDevObject.getValue(), sizeValue = Math.floor(+_sizeObject.getValue());
|
|
19130
|
+
if (alphaValue <= 0 || alphaValue >= 1 || standardDevValue <= 0 || sizeValue < 1)
|
|
19131
|
+
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
19132
|
+
if (sizeValue === 1)
|
|
19133
|
+
return ErrorValueObject.create(ErrorType$1.DIV_BY_ZERO);
|
|
19134
|
+
const result = Math.abs(studentTINV(alphaValue / 2, sizeValue - 1) * standardDevValue / Math.sqrt(sizeValue));
|
|
19135
|
+
return NumberValueObject.create(result);
|
|
19136
|
+
});
|
|
19137
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
19138
|
+
}
|
|
19139
|
+
};
|
|
19140
|
+
__name(_ConfidenceT, "ConfidenceT");
|
|
19141
|
+
let ConfidenceT = _ConfidenceT;
|
|
19142
|
+
const _Correl = class _Correl extends BaseFunction {
|
|
17816
19143
|
constructor() {
|
|
17817
19144
|
super(...arguments);
|
|
17818
|
-
__publicField(this, "minParams",
|
|
17819
|
-
__publicField(this, "maxParams",
|
|
19145
|
+
__publicField(this, "minParams", 2);
|
|
19146
|
+
__publicField(this, "maxParams", 2);
|
|
17820
19147
|
}
|
|
17821
|
-
calculate(
|
|
17822
|
-
|
|
19148
|
+
calculate(array1, array2) {
|
|
19149
|
+
const array1RowCount = array1.isArray() ? array1.getRowCount() : 1, array1ColumnCount = array1.isArray() ? array1.getColumnCount() : 1, array2RowCount = array2.isArray() ? array2.getRowCount() : 1, array2ColumnCount = array2.isArray() ? array2.getColumnCount() : 1;
|
|
19150
|
+
let _array1 = array1;
|
|
19151
|
+
if (array1.isArray() && array1RowCount === 1 && array1ColumnCount === 1 && (_array1 = array1.get(0, 0)), _array1.isError())
|
|
19152
|
+
return _array1;
|
|
19153
|
+
let _array2 = array2;
|
|
19154
|
+
if (array2.isArray() && array2RowCount === 1 && array2ColumnCount === 1 && (_array2 = array2.get(0, 0)), _array2.isError())
|
|
19155
|
+
return _array2;
|
|
19156
|
+
if (array1RowCount * array1ColumnCount === 1 || array2RowCount * array2ColumnCount === 1)
|
|
19157
|
+
return _array1.isNull() || _array2.isNull() ? ErrorValueObject.create(ErrorType$1.VALUE) : ErrorValueObject.create(ErrorType$1.DIV_BY_ZERO);
|
|
19158
|
+
if (array1RowCount * array1ColumnCount !== array2RowCount * array2ColumnCount)
|
|
17823
19159
|
return ErrorValueObject.create(ErrorType$1.NA);
|
|
17824
|
-
|
|
17825
|
-
|
|
17826
|
-
|
|
17827
|
-
|
|
17828
|
-
|
|
17829
|
-
|
|
17830
|
-
|
|
19160
|
+
const {
|
|
19161
|
+
isError,
|
|
19162
|
+
errorObject,
|
|
19163
|
+
array1Values,
|
|
19164
|
+
array2Values,
|
|
19165
|
+
noCalculate
|
|
19166
|
+
} = getTwoArrayNumberValues(
|
|
19167
|
+
array1,
|
|
19168
|
+
array2,
|
|
19169
|
+
array1RowCount * array1ColumnCount,
|
|
19170
|
+
array1ColumnCount,
|
|
19171
|
+
array2ColumnCount
|
|
19172
|
+
);
|
|
19173
|
+
return isError ? errorObject : noCalculate ? ErrorValueObject.create(ErrorType$1.DIV_BY_ZERO) : this._getResult(array1Values, array2Values);
|
|
17831
19174
|
}
|
|
17832
|
-
|
|
17833
|
-
const
|
|
17834
|
-
|
|
17835
|
-
|
|
17836
|
-
|
|
17837
|
-
|
|
17838
|
-
|
|
17839
|
-
|
|
17840
|
-
|
|
17841
|
-
|
|
17842
|
-
|
|
17843
|
-
|
|
17844
|
-
|
|
17845
|
-
return ArrayValueObject.create(arrayValueObjectData);
|
|
19175
|
+
_getResult(array1Values, array2Values) {
|
|
19176
|
+
const n = array1Values.length;
|
|
19177
|
+
let array1Sum = 0, array2Sum = 0;
|
|
19178
|
+
for (let i = 0; i < n; i++)
|
|
19179
|
+
array1Sum += array1Values[i], array2Sum += array2Values[i];
|
|
19180
|
+
const array1Mean = array1Sum / n, array2Mean = array2Sum / n;
|
|
19181
|
+
let numerator = 0, array1DiffSum = 0, array2DiffSum = 0;
|
|
19182
|
+
for (let i = 0; i < n; i++) {
|
|
19183
|
+
const array1Diff = array1Values[i] - array1Mean, array2Diff = array2Values[i] - array2Mean;
|
|
19184
|
+
numerator += array1Diff * array2Diff, array1DiffSum += array1Diff ** 2, array2DiffSum += array2Diff ** 2;
|
|
19185
|
+
}
|
|
19186
|
+
const denominator = Math.sqrt(array1DiffSum * array2DiffSum);
|
|
19187
|
+
return denominator === 0 ? ErrorValueObject.create(ErrorType$1.DIV_BY_ZERO) : NumberValueObject.create(numerator / denominator);
|
|
17846
19188
|
}
|
|
17847
19189
|
};
|
|
17848
|
-
__name(
|
|
17849
|
-
let
|
|
19190
|
+
__name(_Correl, "Correl");
|
|
19191
|
+
let Correl = _Correl;
|
|
17850
19192
|
const _Count = class _Count extends BaseFunction {
|
|
17851
19193
|
constructor() {
|
|
17852
19194
|
super(...arguments);
|
|
@@ -17961,6 +19303,314 @@ function countTrueValue(array) {
|
|
|
17961
19303
|
}), NumberValueObject.create(count);
|
|
17962
19304
|
}
|
|
17963
19305
|
__name(countTrueValue, "countTrueValue");
|
|
19306
|
+
const _CovarianceS = class _CovarianceS extends BaseFunction {
|
|
19307
|
+
constructor() {
|
|
19308
|
+
super(...arguments);
|
|
19309
|
+
__publicField(this, "minParams", 2);
|
|
19310
|
+
__publicField(this, "maxParams", 2);
|
|
19311
|
+
}
|
|
19312
|
+
calculate(array1, array2) {
|
|
19313
|
+
const array1RowCount = array1.isArray() ? array1.getRowCount() : 1, array1ColumnCount = array1.isArray() ? array1.getColumnCount() : 1, array2RowCount = array2.isArray() ? array2.getRowCount() : 1, array2ColumnCount = array2.isArray() ? array2.getColumnCount() : 1;
|
|
19314
|
+
let _array1 = array1;
|
|
19315
|
+
if (array1.isArray() && array1RowCount === 1 && array1ColumnCount === 1 && (_array1 = array1.get(0, 0)), _array1.isError())
|
|
19316
|
+
return _array1;
|
|
19317
|
+
let _array2 = array2;
|
|
19318
|
+
if (array2.isArray() && array2RowCount === 1 && array2ColumnCount === 1 && (_array2 = array2.get(0, 0)), _array2.isError())
|
|
19319
|
+
return _array2;
|
|
19320
|
+
if ((array1RowCount * array1ColumnCount === 1 || array2RowCount * array2ColumnCount === 1) && (_array1.isNull() || _array2.isNull()))
|
|
19321
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
19322
|
+
if (array1RowCount * array1ColumnCount !== array2RowCount * array2ColumnCount)
|
|
19323
|
+
return ErrorValueObject.create(ErrorType$1.NA);
|
|
19324
|
+
const {
|
|
19325
|
+
isError,
|
|
19326
|
+
errorObject,
|
|
19327
|
+
array1Values,
|
|
19328
|
+
array2Values,
|
|
19329
|
+
noCalculate
|
|
19330
|
+
} = getTwoArrayNumberValues(
|
|
19331
|
+
array1,
|
|
19332
|
+
array2,
|
|
19333
|
+
array1RowCount * array1ColumnCount,
|
|
19334
|
+
array1ColumnCount,
|
|
19335
|
+
array2ColumnCount
|
|
19336
|
+
);
|
|
19337
|
+
return isError ? errorObject : noCalculate ? ErrorValueObject.create(ErrorType$1.DIV_BY_ZERO) : this._getResult(array1Values, array2Values);
|
|
19338
|
+
}
|
|
19339
|
+
_getResult(array1Values, array2Values) {
|
|
19340
|
+
if (array1Values.length <= 1)
|
|
19341
|
+
return ErrorValueObject.create(ErrorType$1.DIV_BY_ZERO);
|
|
19342
|
+
const n = array1Values.length;
|
|
19343
|
+
let array1Sum = 0, array2Sum = 0;
|
|
19344
|
+
for (let i = 0; i < n; i++)
|
|
19345
|
+
array1Sum += array1Values[i], array2Sum += array2Values[i];
|
|
19346
|
+
const array1Mean = array1Sum / n, array2Mean = array2Sum / n;
|
|
19347
|
+
let numerator = 0;
|
|
19348
|
+
for (let i = 0; i < n; i++) {
|
|
19349
|
+
const array1Diff = array1Values[i] - array1Mean, array2Diff = array2Values[i] - array2Mean;
|
|
19350
|
+
numerator += array1Diff * array2Diff;
|
|
19351
|
+
}
|
|
19352
|
+
return NumberValueObject.create(numerator / (n - 1));
|
|
19353
|
+
}
|
|
19354
|
+
};
|
|
19355
|
+
__name(_CovarianceS, "CovarianceS");
|
|
19356
|
+
let CovarianceS = _CovarianceS;
|
|
19357
|
+
const _Devsq = class _Devsq extends BaseFunction {
|
|
19358
|
+
constructor() {
|
|
19359
|
+
super(...arguments);
|
|
19360
|
+
__publicField(this, "minParams", 1);
|
|
19361
|
+
__publicField(this, "maxParams", 255);
|
|
19362
|
+
}
|
|
19363
|
+
calculate(...variants) {
|
|
19364
|
+
const values = [];
|
|
19365
|
+
let sum2 = 0, noCalculate = !0;
|
|
19366
|
+
for (let i = 0; i < variants.length; i++) {
|
|
19367
|
+
const variant = variants[i];
|
|
19368
|
+
if (variant.isArray()) {
|
|
19369
|
+
let isError = !1, errorObject = ErrorValueObject.create(ErrorType$1.VALUE);
|
|
19370
|
+
if (variant.iterator((valueObject) => {
|
|
19371
|
+
const _valueObject = this._handleSingleObject(valueObject);
|
|
19372
|
+
if (_valueObject.isError())
|
|
19373
|
+
return isError = !0, errorObject = _valueObject, !1;
|
|
19374
|
+
if (_valueObject.isNull())
|
|
19375
|
+
return !0;
|
|
19376
|
+
const value = _valueObject.getValue();
|
|
19377
|
+
values.push(value), sum2 += value, noCalculate = !1;
|
|
19378
|
+
}), isError)
|
|
19379
|
+
return errorObject;
|
|
19380
|
+
} else {
|
|
19381
|
+
const _variant = this._handleSingleObject(variant);
|
|
19382
|
+
if (_variant.isError())
|
|
19383
|
+
return _variant;
|
|
19384
|
+
if (_variant.isNull())
|
|
19385
|
+
continue;
|
|
19386
|
+
const value = _variant.getValue();
|
|
19387
|
+
values.push(value), sum2 += value, noCalculate = !1;
|
|
19388
|
+
}
|
|
19389
|
+
}
|
|
19390
|
+
if (noCalculate)
|
|
19391
|
+
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
19392
|
+
const mean = sum2 / values.length;
|
|
19393
|
+
let result = 0;
|
|
19394
|
+
for (let i = 0; i < values.length; i++)
|
|
19395
|
+
result += (values[i] - mean) ** 2;
|
|
19396
|
+
return NumberValueObject.create(result);
|
|
19397
|
+
}
|
|
19398
|
+
_handleSingleObject(variant) {
|
|
19399
|
+
if (variant.isError())
|
|
19400
|
+
return variant;
|
|
19401
|
+
if (variant.isNull() || variant.isBoolean())
|
|
19402
|
+
return NullValueObject.create();
|
|
19403
|
+
const value = variant.getValue();
|
|
19404
|
+
return isRealNum(value) ? NumberValueObject.create(+value) : NullValueObject.create();
|
|
19405
|
+
}
|
|
19406
|
+
};
|
|
19407
|
+
__name(_Devsq, "Devsq");
|
|
19408
|
+
let Devsq = _Devsq;
|
|
19409
|
+
const _FDist = class _FDist extends BaseFunction {
|
|
19410
|
+
constructor() {
|
|
19411
|
+
super(...arguments);
|
|
19412
|
+
__publicField(this, "minParams", 4);
|
|
19413
|
+
__publicField(this, "maxParams", 4);
|
|
19414
|
+
}
|
|
19415
|
+
calculate(x, degFreedom1, degFreedom2, cumulative) {
|
|
19416
|
+
const maxRowLength = Math.max(
|
|
19417
|
+
x.isArray() ? x.getRowCount() : 1,
|
|
19418
|
+
degFreedom1.isArray() ? degFreedom1.getRowCount() : 1,
|
|
19419
|
+
degFreedom2.isArray() ? degFreedom2.getRowCount() : 1,
|
|
19420
|
+
cumulative.isArray() ? cumulative.getRowCount() : 1
|
|
19421
|
+
), maxColumnLength = Math.max(
|
|
19422
|
+
x.isArray() ? x.getColumnCount() : 1,
|
|
19423
|
+
degFreedom1.isArray() ? degFreedom1.getColumnCount() : 1,
|
|
19424
|
+
degFreedom2.isArray() ? degFreedom2.getColumnCount() : 1,
|
|
19425
|
+
cumulative.isArray() ? cumulative.getColumnCount() : 1
|
|
19426
|
+
), xArray = expandArrayValueObject(maxRowLength, maxColumnLength, x, ErrorValueObject.create(ErrorType$1.NA)), degFreedom1Array = expandArrayValueObject(maxRowLength, maxColumnLength, degFreedom1, ErrorValueObject.create(ErrorType$1.NA)), degFreedom2Array = expandArrayValueObject(maxRowLength, maxColumnLength, degFreedom2, ErrorValueObject.create(ErrorType$1.NA)), cumulativeArray = expandArrayValueObject(maxRowLength, maxColumnLength, cumulative, ErrorValueObject.create(ErrorType$1.NA)), resultArray = xArray.mapValue((xObject, rowIndex, columnIndex) => {
|
|
19427
|
+
const degFreedom1Object = degFreedom1Array.get(rowIndex, columnIndex), degFreedom2Object = degFreedom2Array.get(rowIndex, columnIndex), cumulativeObject = cumulativeArray.get(rowIndex, columnIndex);
|
|
19428
|
+
return this._handleSignleObject(xObject, degFreedom1Object, degFreedom2Object, cumulativeObject);
|
|
19429
|
+
});
|
|
19430
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
19431
|
+
}
|
|
19432
|
+
_handleSignleObject(xObject, degFreedom1Object, degFreedom2Object, cumulativeObject) {
|
|
19433
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(xObject, degFreedom1Object, degFreedom2Object, cumulativeObject);
|
|
19434
|
+
if (isError)
|
|
19435
|
+
return errorObject;
|
|
19436
|
+
const [_xObject, _degFreedom1Object, _degFreedom2Object, _cumulativeObject] = variants, xValue = +_xObject.getValue(), degFreedom1Value = Math.floor(+_degFreedom1Object.getValue()), degFreedom2Value = Math.floor(+_degFreedom2Object.getValue()), cumulativeValue = +_cumulativeObject.getValue();
|
|
19437
|
+
if (xValue < 0 || degFreedom1Value < 1 || degFreedom1Value > 10 ** 10 || degFreedom2Value < 1 || degFreedom2Value > 10 ** 10)
|
|
19438
|
+
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
19439
|
+
let result;
|
|
19440
|
+
return cumulativeValue ? result = centralFCDF(xValue, degFreedom1Value, degFreedom2Value) : result = centralFPDF(xValue, degFreedom1Value, degFreedom2Value), Number.isNaN(result) || !Number.isFinite(result) ? ErrorValueObject.create(ErrorType$1.NUM) : NumberValueObject.create(result);
|
|
19441
|
+
}
|
|
19442
|
+
};
|
|
19443
|
+
__name(_FDist, "FDist");
|
|
19444
|
+
let FDist = _FDist;
|
|
19445
|
+
const _FInv = class _FInv extends BaseFunction {
|
|
19446
|
+
constructor() {
|
|
19447
|
+
super(...arguments);
|
|
19448
|
+
__publicField(this, "minParams", 3);
|
|
19449
|
+
__publicField(this, "maxParams", 3);
|
|
19450
|
+
}
|
|
19451
|
+
calculate(probability, degFreedom1, degFreedom2) {
|
|
19452
|
+
const maxRowLength = Math.max(
|
|
19453
|
+
probability.isArray() ? probability.getRowCount() : 1,
|
|
19454
|
+
degFreedom1.isArray() ? degFreedom1.getRowCount() : 1,
|
|
19455
|
+
degFreedom2.isArray() ? degFreedom2.getRowCount() : 1
|
|
19456
|
+
), maxColumnLength = Math.max(
|
|
19457
|
+
probability.isArray() ? probability.getColumnCount() : 1,
|
|
19458
|
+
degFreedom1.isArray() ? degFreedom1.getColumnCount() : 1,
|
|
19459
|
+
degFreedom2.isArray() ? degFreedom2.getColumnCount() : 1
|
|
19460
|
+
), probabilityArray = expandArrayValueObject(maxRowLength, maxColumnLength, probability, ErrorValueObject.create(ErrorType$1.NA)), degFreedom1Array = expandArrayValueObject(maxRowLength, maxColumnLength, degFreedom1, ErrorValueObject.create(ErrorType$1.NA)), degFreedom2Array = expandArrayValueObject(maxRowLength, maxColumnLength, degFreedom2, ErrorValueObject.create(ErrorType$1.NA)), resultArray = probabilityArray.mapValue((probabilityObject, rowIndex, columnIndex) => {
|
|
19461
|
+
const degFreedom1Object = degFreedom1Array.get(rowIndex, columnIndex), degFreedom2Object = degFreedom2Array.get(rowIndex, columnIndex);
|
|
19462
|
+
return this._handleSignleObject(probabilityObject, degFreedom1Object, degFreedom2Object);
|
|
19463
|
+
});
|
|
19464
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
19465
|
+
}
|
|
19466
|
+
_handleSignleObject(probabilityObject, degFreedom1Object, degFreedom2Object) {
|
|
19467
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(probabilityObject, degFreedom1Object, degFreedom2Object);
|
|
19468
|
+
if (isError)
|
|
19469
|
+
return errorObject;
|
|
19470
|
+
const [_probabilityObject, _degFreedom1Object, _degFreedom2Object] = variants, probabilityValue = +_probabilityObject.getValue(), degFreedom1Value = Math.floor(+_degFreedom1Object.getValue()), degFreedom2Value = Math.floor(+_degFreedom2Object.getValue());
|
|
19471
|
+
if (probabilityValue < 0 || probabilityValue > 1 || degFreedom1Value < 1 || degFreedom1Value > 10 ** 10 || degFreedom2Value < 1 || degFreedom2Value > 10 ** 10)
|
|
19472
|
+
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
19473
|
+
const result = centralFINV(probabilityValue, degFreedom1Value, degFreedom2Value);
|
|
19474
|
+
return Number.isNaN(result) || !Number.isFinite(result) ? ErrorValueObject.create(ErrorType$1.NUM) : NumberValueObject.create(result);
|
|
19475
|
+
}
|
|
19476
|
+
};
|
|
19477
|
+
__name(_FInv, "FInv");
|
|
19478
|
+
let FInv = _FInv;
|
|
19479
|
+
const _Fisher = class _Fisher extends BaseFunction {
|
|
19480
|
+
constructor() {
|
|
19481
|
+
super(...arguments);
|
|
19482
|
+
__publicField(this, "minParams", 1);
|
|
19483
|
+
__publicField(this, "maxParams", 1);
|
|
19484
|
+
}
|
|
19485
|
+
calculate(x) {
|
|
19486
|
+
return x.isArray() ? x.mapValue((xObject) => this._handleSingleObject(xObject)) : this._handleSingleObject(x);
|
|
19487
|
+
}
|
|
19488
|
+
_handleSingleObject(x) {
|
|
19489
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(x);
|
|
19490
|
+
if (isError)
|
|
19491
|
+
return errorObject;
|
|
19492
|
+
const [xObject] = variants, xValue = xObject.getValue();
|
|
19493
|
+
if (xValue <= -1 || xValue >= 1)
|
|
19494
|
+
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
19495
|
+
const result = Math.log((1 + xValue) / (1 - xValue)) / 2;
|
|
19496
|
+
return NumberValueObject.create(result);
|
|
19497
|
+
}
|
|
19498
|
+
};
|
|
19499
|
+
__name(_Fisher, "Fisher");
|
|
19500
|
+
let Fisher = _Fisher;
|
|
19501
|
+
const _Fisherinv = class _Fisherinv extends BaseFunction {
|
|
19502
|
+
constructor() {
|
|
19503
|
+
super(...arguments);
|
|
19504
|
+
__publicField(this, "minParams", 1);
|
|
19505
|
+
__publicField(this, "maxParams", 1);
|
|
19506
|
+
}
|
|
19507
|
+
calculate(y) {
|
|
19508
|
+
return y.isArray() ? y.mapValue((yObject) => this._handleSingleObject(yObject)) : this._handleSingleObject(y);
|
|
19509
|
+
}
|
|
19510
|
+
_handleSingleObject(y) {
|
|
19511
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(y);
|
|
19512
|
+
if (isError)
|
|
19513
|
+
return errorObject;
|
|
19514
|
+
const [yObject] = variants, yValue = +yObject.getValue(), num = Math.exp(2 * yValue) - 1, den = Math.exp(2 * yValue) + 1;
|
|
19515
|
+
return !Number.isFinite(num) && num > 0 && !Number.isFinite(den) && den > 0 ? NumberValueObject.create(1) : NumberValueObject.create(num / den);
|
|
19516
|
+
}
|
|
19517
|
+
};
|
|
19518
|
+
__name(_Fisherinv, "Fisherinv");
|
|
19519
|
+
let Fisherinv = _Fisherinv;
|
|
19520
|
+
const _Forecast = class _Forecast extends BaseFunction {
|
|
19521
|
+
constructor() {
|
|
19522
|
+
super(...arguments);
|
|
19523
|
+
__publicField(this, "minParams", 3);
|
|
19524
|
+
__publicField(this, "maxParams", 3);
|
|
19525
|
+
}
|
|
19526
|
+
calculate(x, knownYs, knownXs) {
|
|
19527
|
+
const knownYsRowCount = knownYs.isArray() ? knownYs.getRowCount() : 1, knownYsColumnCount = knownYs.isArray() ? knownYs.getColumnCount() : 1, knownXsRowCount = knownXs.isArray() ? knownXs.getRowCount() : 1, knownXsColumnCount = knownXs.isArray() ? knownXs.getColumnCount() : 1;
|
|
19528
|
+
let _knownYs = knownYs;
|
|
19529
|
+
knownYs.isArray() && knownYsRowCount === 1 && knownYsColumnCount === 1 && (_knownYs = knownYs.get(0, 0));
|
|
19530
|
+
let _knownXs = knownXs;
|
|
19531
|
+
return knownXs.isArray() && knownXsRowCount === 1 && knownXsColumnCount === 1 && (_knownXs = knownXs.get(0, 0)), x.isArray() ? x.mapValue(
|
|
19532
|
+
(xObject) => this._handleSignleObject(xObject, _knownYs, _knownXs, knownYsRowCount, knownYsColumnCount, knownXsRowCount, knownXsColumnCount)
|
|
19533
|
+
) : this._handleSignleObject(x, _knownYs, _knownXs, knownYsRowCount, knownYsColumnCount, knownXsRowCount, knownXsColumnCount);
|
|
19534
|
+
}
|
|
19535
|
+
_handleSignleObject(x, knownYs, knownXs, knownYsRowCount, knownYsColumnCount, knownXsRowCount, knownXsColumnCount) {
|
|
19536
|
+
if (x.isError())
|
|
19537
|
+
return x;
|
|
19538
|
+
if (knownYs.isError())
|
|
19539
|
+
return knownYs;
|
|
19540
|
+
if (knownXs.isError())
|
|
19541
|
+
return knownXs;
|
|
19542
|
+
let _x = x;
|
|
19543
|
+
if (x.isString() && (_x = x.convertToNumberObjectValue()), _x.isError())
|
|
19544
|
+
return _x;
|
|
19545
|
+
const xValue = +_x.getValue();
|
|
19546
|
+
if ((knownYsRowCount * knownYsColumnCount === 1 || knownXsRowCount * knownXsColumnCount === 1) && (knownYs.isNull() || knownXs.isNull()))
|
|
19547
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
19548
|
+
if (knownYsRowCount * knownYsColumnCount !== knownXsRowCount * knownXsColumnCount)
|
|
19549
|
+
return ErrorValueObject.create(ErrorType$1.NA);
|
|
19550
|
+
const {
|
|
19551
|
+
isError,
|
|
19552
|
+
errorObject,
|
|
19553
|
+
array1Values,
|
|
19554
|
+
array2Values,
|
|
19555
|
+
noCalculate
|
|
19556
|
+
} = getTwoArrayNumberValues(
|
|
19557
|
+
knownYs,
|
|
19558
|
+
knownXs,
|
|
19559
|
+
knownYsRowCount * knownYsColumnCount,
|
|
19560
|
+
knownYsColumnCount,
|
|
19561
|
+
knownXsColumnCount
|
|
19562
|
+
);
|
|
19563
|
+
if (isError)
|
|
19564
|
+
return errorObject;
|
|
19565
|
+
if (noCalculate)
|
|
19566
|
+
return ErrorValueObject.create(ErrorType$1.DIV_BY_ZERO);
|
|
19567
|
+
const result = forecastLinear(xValue, array1Values, array2Values);
|
|
19568
|
+
return Number.isFinite(result) ? NumberValueObject.create(result) : ErrorValueObject.create(ErrorType$1.DIV_BY_ZERO);
|
|
19569
|
+
}
|
|
19570
|
+
};
|
|
19571
|
+
__name(_Forecast, "Forecast");
|
|
19572
|
+
let Forecast = _Forecast;
|
|
19573
|
+
var FUNCTION_NAMES_STATISTICAL = /* @__PURE__ */ ((FUNCTION_NAMES_STATISTICAL2) => (FUNCTION_NAMES_STATISTICAL2.AVEDEV = "AVEDEV", FUNCTION_NAMES_STATISTICAL2.AVERAGE = "AVERAGE", FUNCTION_NAMES_STATISTICAL2.AVERAGEA = "AVERAGEA", FUNCTION_NAMES_STATISTICAL2.AVERAGEIF = "AVERAGEIF", FUNCTION_NAMES_STATISTICAL2.AVERAGEIFS = "AVERAGEIFS", FUNCTION_NAMES_STATISTICAL2.BETA_DIST = "BETA.DIST", FUNCTION_NAMES_STATISTICAL2.BETA_INV = "BETA.INV", FUNCTION_NAMES_STATISTICAL2.BINOM_DIST = "BINOM.DIST", FUNCTION_NAMES_STATISTICAL2.BINOM_DIST_RANGE = "BINOM.DIST.RANGE", FUNCTION_NAMES_STATISTICAL2.BINOM_INV = "BINOM.INV", FUNCTION_NAMES_STATISTICAL2.CHISQ_DIST = "CHISQ.DIST", FUNCTION_NAMES_STATISTICAL2.CHISQ_DIST_RT = "CHISQ.DIST.RT", FUNCTION_NAMES_STATISTICAL2.CHISQ_INV = "CHISQ.INV", FUNCTION_NAMES_STATISTICAL2.CHISQ_INV_RT = "CHISQ.INV.RT", FUNCTION_NAMES_STATISTICAL2.CHISQ_TEST = "CHISQ.TEST", FUNCTION_NAMES_STATISTICAL2.CONFIDENCE_NORM = "CONFIDENCE.NORM", FUNCTION_NAMES_STATISTICAL2.CONFIDENCE_T = "CONFIDENCE.T", FUNCTION_NAMES_STATISTICAL2.CORREL = "CORREL", FUNCTION_NAMES_STATISTICAL2.COUNT = "COUNT", FUNCTION_NAMES_STATISTICAL2.COUNTA = "COUNTA", FUNCTION_NAMES_STATISTICAL2.COUNTBLANK = "COUNTBLANK", FUNCTION_NAMES_STATISTICAL2.COUNTIF = "COUNTIF", FUNCTION_NAMES_STATISTICAL2.COUNTIFS = "COUNTIFS", FUNCTION_NAMES_STATISTICAL2.COVARIANCE_P = "COVARIANCE.P", FUNCTION_NAMES_STATISTICAL2.COVARIANCE_S = "COVARIANCE.S", FUNCTION_NAMES_STATISTICAL2.DEVSQ = "DEVSQ", FUNCTION_NAMES_STATISTICAL2.EXPON_DIST = "EXPON.DIST", FUNCTION_NAMES_STATISTICAL2.F_DIST = "F.DIST", FUNCTION_NAMES_STATISTICAL2.F_DIST_RT = "F.DIST.RT", FUNCTION_NAMES_STATISTICAL2.F_INV = "F.INV", FUNCTION_NAMES_STATISTICAL2.F_INV_RT = "F.INV.RT", FUNCTION_NAMES_STATISTICAL2.F_TEST = "F.TEST", FUNCTION_NAMES_STATISTICAL2.FISHER = "FISHER", FUNCTION_NAMES_STATISTICAL2.FISHERINV = "FISHERINV", FUNCTION_NAMES_STATISTICAL2.FORECAST = "FORECAST", FUNCTION_NAMES_STATISTICAL2.FORECAST_ETS = "FORECAST.ETS", FUNCTION_NAMES_STATISTICAL2.FORECAST_ETS_CONFINT = "FORECAST.ETS.CONFINT", FUNCTION_NAMES_STATISTICAL2.FORECAST_ETS_SEASONALITY = "FORECAST.ETS.SEASONALITY", FUNCTION_NAMES_STATISTICAL2.FORECAST_ETS_STAT = "FORECAST.ETS.STAT", FUNCTION_NAMES_STATISTICAL2.FORECAST_LINEAR = "FORECAST.LINEAR", FUNCTION_NAMES_STATISTICAL2.FREQUENCY = "FREQUENCY", FUNCTION_NAMES_STATISTICAL2.GAMMA = "GAMMA", FUNCTION_NAMES_STATISTICAL2.GAMMA_DIST = "GAMMA.DIST", FUNCTION_NAMES_STATISTICAL2.GAMMA_INV = "GAMMA.INV", FUNCTION_NAMES_STATISTICAL2.GAMMALN = "GAMMALN", FUNCTION_NAMES_STATISTICAL2.GAMMALN_PRECISE = "GAMMALN.PRECISE", FUNCTION_NAMES_STATISTICAL2.GAUSS = "GAUSS", FUNCTION_NAMES_STATISTICAL2.GEOMEAN = "GEOMEAN", FUNCTION_NAMES_STATISTICAL2.GROWTH = "GROWTH", FUNCTION_NAMES_STATISTICAL2.HARMEAN = "HARMEAN", FUNCTION_NAMES_STATISTICAL2.HYPGEOM_DIST = "HYPGEOM.DIST", FUNCTION_NAMES_STATISTICAL2.INTERCEPT = "INTERCEPT", FUNCTION_NAMES_STATISTICAL2.KURT = "KURT", FUNCTION_NAMES_STATISTICAL2.LARGE = "LARGE", FUNCTION_NAMES_STATISTICAL2.LINEST = "LINEST", FUNCTION_NAMES_STATISTICAL2.LOGEST = "LOGEST", FUNCTION_NAMES_STATISTICAL2.LOGNORM_DIST = "LOGNORM.DIST", FUNCTION_NAMES_STATISTICAL2.LOGNORM_INV = "LOGNORM.INV", FUNCTION_NAMES_STATISTICAL2.MAX = "MAX", FUNCTION_NAMES_STATISTICAL2.MAXA = "MAXA", FUNCTION_NAMES_STATISTICAL2.MAXIFS = "MAXIFS", FUNCTION_NAMES_STATISTICAL2.MEDIAN = "MEDIAN", FUNCTION_NAMES_STATISTICAL2.MIN = "MIN", FUNCTION_NAMES_STATISTICAL2.MINA = "MINA", FUNCTION_NAMES_STATISTICAL2.MINIFS = "MINIFS", FUNCTION_NAMES_STATISTICAL2.MODE_MULT = "MODE.MULT", FUNCTION_NAMES_STATISTICAL2.MODE_SNGL = "MODE.SNGL", FUNCTION_NAMES_STATISTICAL2.NEGBINOM_DIST = "NEGBINOM.DIST", FUNCTION_NAMES_STATISTICAL2.NORM_DIST = "NORM.DIST", FUNCTION_NAMES_STATISTICAL2.NORM_INV = "NORM.INV", FUNCTION_NAMES_STATISTICAL2.NORM_S_DIST = "NORM.S.DIST", FUNCTION_NAMES_STATISTICAL2.NORM_S_INV = "NORM.S.INV", FUNCTION_NAMES_STATISTICAL2.PEARSON = "PEARSON", FUNCTION_NAMES_STATISTICAL2.PERCENTILE_EXC = "PERCENTILE.EXC", FUNCTION_NAMES_STATISTICAL2.PERCENTILE_INC = "PERCENTILE.INC", FUNCTION_NAMES_STATISTICAL2.PERCENTRANK_EXC = "PERCENTRANK.EXC", FUNCTION_NAMES_STATISTICAL2.PERCENTRANK_INC = "PERCENTRANK.INC", FUNCTION_NAMES_STATISTICAL2.PERMUT = "PERMUT", FUNCTION_NAMES_STATISTICAL2.PERMUTATIONA = "PERMUTATIONA", FUNCTION_NAMES_STATISTICAL2.PHI = "PHI", FUNCTION_NAMES_STATISTICAL2.POISSON_DIST = "POISSON.DIST", FUNCTION_NAMES_STATISTICAL2.PROB = "PROB", FUNCTION_NAMES_STATISTICAL2.QUARTILE_EXC = "QUARTILE.EXC", FUNCTION_NAMES_STATISTICAL2.QUARTILE_INC = "QUARTILE.INC", FUNCTION_NAMES_STATISTICAL2.RANK_AVG = "RANK.AVG", FUNCTION_NAMES_STATISTICAL2.RANK_EQ = "RANK.EQ", FUNCTION_NAMES_STATISTICAL2.RSQ = "RSQ", FUNCTION_NAMES_STATISTICAL2.SKEW = "SKEW", FUNCTION_NAMES_STATISTICAL2.SKEW_P = "SKEW.P", FUNCTION_NAMES_STATISTICAL2.SLOPE = "SLOPE", FUNCTION_NAMES_STATISTICAL2.SMALL = "SMALL", FUNCTION_NAMES_STATISTICAL2.STANDARDIZE = "STANDARDIZE", FUNCTION_NAMES_STATISTICAL2.STDEV_P = "STDEV.P", FUNCTION_NAMES_STATISTICAL2.STDEV_S = "STDEV.S", FUNCTION_NAMES_STATISTICAL2.STDEVA = "STDEVA", FUNCTION_NAMES_STATISTICAL2.STDEVPA = "STDEVPA", FUNCTION_NAMES_STATISTICAL2.STEYX = "STEYX", FUNCTION_NAMES_STATISTICAL2.T_DIST = "T.DIST", FUNCTION_NAMES_STATISTICAL2.T_DIST_2T = "T.DIST.2T", FUNCTION_NAMES_STATISTICAL2.T_DIST_RT = "T.DIST.RT", FUNCTION_NAMES_STATISTICAL2.T_INV = "T.INV", FUNCTION_NAMES_STATISTICAL2.T_INV_2T = "T.INV.2T", FUNCTION_NAMES_STATISTICAL2.T_TEST = "T.TEST", FUNCTION_NAMES_STATISTICAL2.TREND = "TREND", FUNCTION_NAMES_STATISTICAL2.TRIMMEAN = "TRIMMEAN", FUNCTION_NAMES_STATISTICAL2.VAR_P = "VAR.P", FUNCTION_NAMES_STATISTICAL2.VAR_S = "VAR.S", FUNCTION_NAMES_STATISTICAL2.VARA = "VARA", FUNCTION_NAMES_STATISTICAL2.VARPA = "VARPA", FUNCTION_NAMES_STATISTICAL2.WEIBULL_DIST = "WEIBULL.DIST", FUNCTION_NAMES_STATISTICAL2.Z_TEST = "Z.TEST", FUNCTION_NAMES_STATISTICAL2))(FUNCTION_NAMES_STATISTICAL || {});
|
|
19574
|
+
const _Intercept = class _Intercept extends BaseFunction {
|
|
19575
|
+
constructor() {
|
|
19576
|
+
super(...arguments);
|
|
19577
|
+
__publicField(this, "minParams", 2);
|
|
19578
|
+
__publicField(this, "maxParams", 2);
|
|
19579
|
+
}
|
|
19580
|
+
calculate(knownYs, knownXs) {
|
|
19581
|
+
const knownYsRowCount = knownYs.isArray() ? knownYs.getRowCount() : 1, knownYsColumnCount = knownYs.isArray() ? knownYs.getColumnCount() : 1, knownXsRowCount = knownXs.isArray() ? knownXs.getRowCount() : 1, knownXsColumnCount = knownXs.isArray() ? knownXs.getColumnCount() : 1;
|
|
19582
|
+
let _knownYs = knownYs;
|
|
19583
|
+
if (knownYs.isArray() && knownYsRowCount === 1 && knownYsColumnCount === 1 && (_knownYs = knownYs.get(0, 0)), _knownYs.isError())
|
|
19584
|
+
return _knownYs;
|
|
19585
|
+
let _knownXs = knownXs;
|
|
19586
|
+
if (knownXs.isArray() && knownXsRowCount === 1 && knownXsColumnCount === 1 && (_knownXs = knownXs.get(0, 0)), _knownXs.isError())
|
|
19587
|
+
return _knownXs;
|
|
19588
|
+
if (knownYsRowCount * knownYsColumnCount === 1 || knownXsRowCount * knownXsColumnCount === 1)
|
|
19589
|
+
return knownYs.isNull() || knownXs.isNull() ? ErrorValueObject.create(ErrorType$1.VALUE) : ErrorValueObject.create(ErrorType$1.DIV_BY_ZERO);
|
|
19590
|
+
if (knownYsRowCount * knownYsColumnCount !== knownXsRowCount * knownXsColumnCount)
|
|
19591
|
+
return ErrorValueObject.create(ErrorType$1.NA);
|
|
19592
|
+
const {
|
|
19593
|
+
isError,
|
|
19594
|
+
errorObject,
|
|
19595
|
+
array1Values,
|
|
19596
|
+
array2Values,
|
|
19597
|
+
noCalculate
|
|
19598
|
+
} = getTwoArrayNumberValues(
|
|
19599
|
+
knownYs,
|
|
19600
|
+
knownXs,
|
|
19601
|
+
knownYsRowCount * knownYsColumnCount,
|
|
19602
|
+
knownYsColumnCount,
|
|
19603
|
+
knownXsColumnCount
|
|
19604
|
+
);
|
|
19605
|
+
return isError ? errorObject : noCalculate ? ErrorValueObject.create(ErrorType$1.DIV_BY_ZERO) : this._getResult(array1Values, array2Values);
|
|
19606
|
+
}
|
|
19607
|
+
_getResult(knownYs, knownXs) {
|
|
19608
|
+
const result = forecastLinear(0, knownYs, knownXs);
|
|
19609
|
+
return Number.isFinite(result) ? NumberValueObject.create(result) : ErrorValueObject.create(ErrorType$1.DIV_BY_ZERO);
|
|
19610
|
+
}
|
|
19611
|
+
};
|
|
19612
|
+
__name(_Intercept, "Intercept");
|
|
19613
|
+
let Intercept = _Intercept;
|
|
17964
19614
|
const _Max = class _Max extends BaseFunction {
|
|
17965
19615
|
constructor() {
|
|
17966
19616
|
super(...arguments);
|
|
@@ -18149,6 +19799,36 @@ const _Minifs = class _Minifs extends BaseFunction {
|
|
|
18149
19799
|
};
|
|
18150
19800
|
__name(_Minifs, "Minifs");
|
|
18151
19801
|
let Minifs = _Minifs;
|
|
19802
|
+
const _NormSDist = class _NormSDist extends BaseFunction {
|
|
19803
|
+
constructor() {
|
|
19804
|
+
super(...arguments);
|
|
19805
|
+
__publicField(this, "minParams", 2);
|
|
19806
|
+
__publicField(this, "maxParams", 2);
|
|
19807
|
+
}
|
|
19808
|
+
calculate(z, cumulative) {
|
|
19809
|
+
const maxRowLength = Math.max(
|
|
19810
|
+
z.isArray() ? z.getRowCount() : 1,
|
|
19811
|
+
cumulative.isArray() ? cumulative.getRowCount() : 1
|
|
19812
|
+
), maxColumnLength = Math.max(
|
|
19813
|
+
z.isArray() ? z.getColumnCount() : 1,
|
|
19814
|
+
cumulative.isArray() ? cumulative.getColumnCount() : 1
|
|
19815
|
+
), zArray = expandArrayValueObject(maxRowLength, maxColumnLength, z, ErrorValueObject.create(ErrorType$1.NA)), cumulativeArray = expandArrayValueObject(maxRowLength, maxColumnLength, cumulative, ErrorValueObject.create(ErrorType$1.NA)), resultArray = zArray.mapValue((zObject, rowIndex, columnIndex) => {
|
|
19816
|
+
const cumulativeObject = cumulativeArray.get(rowIndex, columnIndex);
|
|
19817
|
+
return this._handleSignleObject(zObject, cumulativeObject);
|
|
19818
|
+
});
|
|
19819
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
19820
|
+
}
|
|
19821
|
+
_handleSignleObject(zObject, cumulativeObject) {
|
|
19822
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(zObject, cumulativeObject);
|
|
19823
|
+
if (isError)
|
|
19824
|
+
return errorObject;
|
|
19825
|
+
const [_zObject, _cumulativeObject] = variants, zValue = +_zObject.getValue(), cumulativeValue = +_cumulativeObject.getValue();
|
|
19826
|
+
let result;
|
|
19827
|
+
return cumulativeValue ? result = normalCDF(zValue, 0, 1) : result = normalPDF(zValue, 0, 1), NumberValueObject.create(result);
|
|
19828
|
+
}
|
|
19829
|
+
};
|
|
19830
|
+
__name(_NormSDist, "NormSDist");
|
|
19831
|
+
let NormSDist = _NormSDist;
|
|
18152
19832
|
const _RankAvg = class _RankAvg extends BaseFunction {
|
|
18153
19833
|
constructor() {
|
|
18154
19834
|
super(...arguments);
|
|
@@ -18339,17 +20019,48 @@ const functionStatistical = [
|
|
|
18339
20019
|
[Averagea, FUNCTION_NAMES_STATISTICAL.AVERAGEA],
|
|
18340
20020
|
[Averageif, FUNCTION_NAMES_STATISTICAL.AVERAGEIF],
|
|
18341
20021
|
[Averageifs, FUNCTION_NAMES_STATISTICAL.AVERAGEIFS],
|
|
20022
|
+
[BetaDist, FUNCTION_NAMES_STATISTICAL.BETA_DIST],
|
|
20023
|
+
[BetaInv, FUNCTION_NAMES_STATISTICAL.BETA_INV],
|
|
20024
|
+
[BinomDist, FUNCTION_NAMES_STATISTICAL.BINOM_DIST],
|
|
20025
|
+
[BinomDistRange, FUNCTION_NAMES_STATISTICAL.BINOM_DIST_RANGE],
|
|
20026
|
+
[BinomInv, FUNCTION_NAMES_STATISTICAL.BINOM_INV],
|
|
20027
|
+
[ChisqDist, FUNCTION_NAMES_STATISTICAL.CHISQ_DIST],
|
|
20028
|
+
[ChisqDistRt, FUNCTION_NAMES_STATISTICAL.CHISQ_DIST_RT],
|
|
20029
|
+
[ChisqInv, FUNCTION_NAMES_STATISTICAL.CHISQ_INV],
|
|
20030
|
+
[ChisqInvRt, FUNCTION_NAMES_STATISTICAL.CHISQ_INV_RT],
|
|
20031
|
+
[ChisqTest, FUNCTION_NAMES_STATISTICAL.CHISQ_TEST],
|
|
20032
|
+
[ConfidenceNorm, FUNCTION_NAMES_STATISTICAL.CONFIDENCE_NORM],
|
|
20033
|
+
[ConfidenceT, FUNCTION_NAMES_STATISTICAL.CONFIDENCE_T],
|
|
20034
|
+
[Correl, FUNCTION_NAMES_STATISTICAL.CORREL],
|
|
18342
20035
|
[Count, FUNCTION_NAMES_STATISTICAL.COUNT],
|
|
18343
20036
|
[Counta, FUNCTION_NAMES_STATISTICAL.COUNTA],
|
|
18344
20037
|
[Countblank, FUNCTION_NAMES_STATISTICAL.COUNTBLANK],
|
|
18345
20038
|
[Countif, FUNCTION_NAMES_STATISTICAL.COUNTIF],
|
|
18346
20039
|
[Countifs, FUNCTION_NAMES_STATISTICAL.COUNTIFS],
|
|
20040
|
+
[CovarianceP, FUNCTION_NAMES_STATISTICAL.COVARIANCE_P],
|
|
20041
|
+
[CovarianceS, FUNCTION_NAMES_STATISTICAL.COVARIANCE_S],
|
|
20042
|
+
[Devsq, FUNCTION_NAMES_STATISTICAL.DEVSQ],
|
|
20043
|
+
[ExponDist, FUNCTION_NAMES_STATISTICAL.EXPON_DIST],
|
|
20044
|
+
[FDist, FUNCTION_NAMES_STATISTICAL.F_DIST],
|
|
20045
|
+
[FDistRt, FUNCTION_NAMES_STATISTICAL.F_DIST_RT],
|
|
20046
|
+
[FInv, FUNCTION_NAMES_STATISTICAL.F_INV],
|
|
20047
|
+
[FInvRt, FUNCTION_NAMES_STATISTICAL.F_INV_RT],
|
|
20048
|
+
[FTest, FUNCTION_NAMES_STATISTICAL.F_TEST],
|
|
20049
|
+
[Fisher, FUNCTION_NAMES_STATISTICAL.FISHER],
|
|
20050
|
+
[Fisherinv, FUNCTION_NAMES_STATISTICAL.FISHERINV],
|
|
20051
|
+
[Forecast, FUNCTION_NAMES_STATISTICAL.FORECAST],
|
|
20052
|
+
[Forecast, FUNCTION_NAMES_STATISTICAL.FORECAST_LINEAR],
|
|
20053
|
+
[Intercept, FUNCTION_NAMES_STATISTICAL.INTERCEPT],
|
|
18347
20054
|
[Max, FUNCTION_NAMES_STATISTICAL.MAX],
|
|
18348
20055
|
[Maxa, FUNCTION_NAMES_STATISTICAL.MAXA],
|
|
18349
20056
|
[Maxifs, FUNCTION_NAMES_STATISTICAL.MAXIFS],
|
|
18350
20057
|
[Min, FUNCTION_NAMES_STATISTICAL.MIN],
|
|
18351
20058
|
[Mina, FUNCTION_NAMES_STATISTICAL.MINA],
|
|
18352
20059
|
[Minifs, FUNCTION_NAMES_STATISTICAL.MINIFS],
|
|
20060
|
+
[NormDist, FUNCTION_NAMES_STATISTICAL.NORM_DIST],
|
|
20061
|
+
[NormInv, FUNCTION_NAMES_STATISTICAL.NORM_INV],
|
|
20062
|
+
[NormSDist, FUNCTION_NAMES_STATISTICAL.NORM_S_DIST],
|
|
20063
|
+
[NormSInv, FUNCTION_NAMES_STATISTICAL.NORM_S_INV],
|
|
18353
20064
|
[RankAvg, FUNCTION_NAMES_STATISTICAL.RANK_AVG],
|
|
18354
20065
|
[RankEq, FUNCTION_NAMES_STATISTICAL.RANK_EQ],
|
|
18355
20066
|
[StdevP, FUNCTION_NAMES_STATISTICAL.STDEV_P],
|
|
@@ -18360,9 +20071,7 @@ const functionStatistical = [
|
|
|
18360
20071
|
[VarS, FUNCTION_NAMES_STATISTICAL.VAR_S],
|
|
18361
20072
|
[Vara, FUNCTION_NAMES_STATISTICAL.VARA],
|
|
18362
20073
|
[Varpa, FUNCTION_NAMES_STATISTICAL.VARPA]
|
|
18363
|
-
]
|
|
18364
|
-
var FUNCTION_NAMES_TEXT = /* @__PURE__ */ ((FUNCTION_NAMES_TEXT2) => (FUNCTION_NAMES_TEXT2.ASC = "ASC", FUNCTION_NAMES_TEXT2.ARRAYTOTEXT = "ARRAYTOTEXT", FUNCTION_NAMES_TEXT2.BAHTTEXT = "BAHTTEXT", FUNCTION_NAMES_TEXT2.CHAR = "CHAR", FUNCTION_NAMES_TEXT2.CLEAN = "CLEAN", FUNCTION_NAMES_TEXT2.CODE = "CODE", FUNCTION_NAMES_TEXT2.CONCAT = "CONCAT", FUNCTION_NAMES_TEXT2.CONCATENATE = "CONCATENATE", FUNCTION_NAMES_TEXT2.DBCS = "DBCS", FUNCTION_NAMES_TEXT2.DOLLAR = "DOLLAR", FUNCTION_NAMES_TEXT2.EXACT = "EXACT", FUNCTION_NAMES_TEXT2.FIND = "FIND", FUNCTION_NAMES_TEXT2.FINDB = "FINDB", FUNCTION_NAMES_TEXT2.FIXED = "FIXED", FUNCTION_NAMES_TEXT2.LEFT = "LEFT", FUNCTION_NAMES_TEXT2.LEFTB = "LEFTB", FUNCTION_NAMES_TEXT2.LEN = "LEN", FUNCTION_NAMES_TEXT2.LENB = "LENB", FUNCTION_NAMES_TEXT2.LOWER = "LOWER", FUNCTION_NAMES_TEXT2.MID = "MID", FUNCTION_NAMES_TEXT2.MIDB = "MIDB", FUNCTION_NAMES_TEXT2.NUMBERVALUE = "NUMBERVALUE", FUNCTION_NAMES_TEXT2.PHONETIC = "PHONETIC", FUNCTION_NAMES_TEXT2.PROPER = "PROPER", FUNCTION_NAMES_TEXT2.REPLACE = "REPLACE", FUNCTION_NAMES_TEXT2.REPLACEB = "REPLACEB", FUNCTION_NAMES_TEXT2.REPT = "REPT", FUNCTION_NAMES_TEXT2.RIGHT = "RIGHT", FUNCTION_NAMES_TEXT2.RIGHTB = "RIGHTB", FUNCTION_NAMES_TEXT2.SEARCH = "SEARCH", FUNCTION_NAMES_TEXT2.SEARCHB = "SEARCHB", FUNCTION_NAMES_TEXT2.SUBSTITUTE = "SUBSTITUTE", FUNCTION_NAMES_TEXT2.T = "T", FUNCTION_NAMES_TEXT2.TEXT = "TEXT", FUNCTION_NAMES_TEXT2.TEXTAFTER = "TEXTAFTER", FUNCTION_NAMES_TEXT2.TEXTBEFORE = "TEXTBEFORE", FUNCTION_NAMES_TEXT2.TEXTJOIN = "TEXTJOIN", FUNCTION_NAMES_TEXT2.TEXTSPLIT = "TEXTSPLIT", FUNCTION_NAMES_TEXT2.TRIM = "TRIM", FUNCTION_NAMES_TEXT2.UNICHAR = "UNICHAR", FUNCTION_NAMES_TEXT2.UNICODE = "UNICODE", FUNCTION_NAMES_TEXT2.UPPER = "UPPER", FUNCTION_NAMES_TEXT2.VALUE = "VALUE", FUNCTION_NAMES_TEXT2.VALUETOTEXT = "VALUETOTEXT", FUNCTION_NAMES_TEXT2.CALL = "CALL", FUNCTION_NAMES_TEXT2.EUROCONVERT = "EUROCONVERT", FUNCTION_NAMES_TEXT2.REGISTER_ID = "REGISTER.ID", FUNCTION_NAMES_TEXT2))(FUNCTION_NAMES_TEXT || {});
|
|
18365
|
-
const _Concat = class _Concat extends BaseFunction {
|
|
20074
|
+
], _Concat = class _Concat extends BaseFunction {
|
|
18366
20075
|
constructor() {
|
|
18367
20076
|
super(...arguments);
|
|
18368
20077
|
__publicField(this, "minParams", 1);
|
|
@@ -18419,6 +20128,61 @@ const _Concatenate = class _Concatenate extends BaseFunction {
|
|
|
18419
20128
|
};
|
|
18420
20129
|
__name(_Concatenate, "Concatenate");
|
|
18421
20130
|
let Concatenate = _Concatenate;
|
|
20131
|
+
var FUNCTION_NAMES_TEXT = /* @__PURE__ */ ((FUNCTION_NAMES_TEXT2) => (FUNCTION_NAMES_TEXT2.ASC = "ASC", FUNCTION_NAMES_TEXT2.ARRAYTOTEXT = "ARRAYTOTEXT", FUNCTION_NAMES_TEXT2.BAHTTEXT = "BAHTTEXT", FUNCTION_NAMES_TEXT2.CHAR = "CHAR", FUNCTION_NAMES_TEXT2.CLEAN = "CLEAN", FUNCTION_NAMES_TEXT2.CODE = "CODE", FUNCTION_NAMES_TEXT2.CONCAT = "CONCAT", FUNCTION_NAMES_TEXT2.CONCATENATE = "CONCATENATE", FUNCTION_NAMES_TEXT2.DBCS = "DBCS", FUNCTION_NAMES_TEXT2.DOLLAR = "DOLLAR", FUNCTION_NAMES_TEXT2.EXACT = "EXACT", FUNCTION_NAMES_TEXT2.FIND = "FIND", FUNCTION_NAMES_TEXT2.FINDB = "FINDB", FUNCTION_NAMES_TEXT2.FIXED = "FIXED", FUNCTION_NAMES_TEXT2.LEFT = "LEFT", FUNCTION_NAMES_TEXT2.LEFTB = "LEFTB", FUNCTION_NAMES_TEXT2.LEN = "LEN", FUNCTION_NAMES_TEXT2.LENB = "LENB", FUNCTION_NAMES_TEXT2.LOWER = "LOWER", FUNCTION_NAMES_TEXT2.MID = "MID", FUNCTION_NAMES_TEXT2.MIDB = "MIDB", FUNCTION_NAMES_TEXT2.NUMBERVALUE = "NUMBERVALUE", FUNCTION_NAMES_TEXT2.PHONETIC = "PHONETIC", FUNCTION_NAMES_TEXT2.PROPER = "PROPER", FUNCTION_NAMES_TEXT2.REPLACE = "REPLACE", FUNCTION_NAMES_TEXT2.REPLACEB = "REPLACEB", FUNCTION_NAMES_TEXT2.REPT = "REPT", FUNCTION_NAMES_TEXT2.RIGHT = "RIGHT", FUNCTION_NAMES_TEXT2.RIGHTB = "RIGHTB", FUNCTION_NAMES_TEXT2.SEARCH = "SEARCH", FUNCTION_NAMES_TEXT2.SEARCHB = "SEARCHB", FUNCTION_NAMES_TEXT2.SUBSTITUTE = "SUBSTITUTE", FUNCTION_NAMES_TEXT2.T = "T", FUNCTION_NAMES_TEXT2.TEXT = "TEXT", FUNCTION_NAMES_TEXT2.TEXTAFTER = "TEXTAFTER", FUNCTION_NAMES_TEXT2.TEXTBEFORE = "TEXTBEFORE", FUNCTION_NAMES_TEXT2.TEXTJOIN = "TEXTJOIN", FUNCTION_NAMES_TEXT2.TEXTSPLIT = "TEXTSPLIT", FUNCTION_NAMES_TEXT2.TRIM = "TRIM", FUNCTION_NAMES_TEXT2.UNICHAR = "UNICHAR", FUNCTION_NAMES_TEXT2.UNICODE = "UNICODE", FUNCTION_NAMES_TEXT2.UPPER = "UPPER", FUNCTION_NAMES_TEXT2.VALUE = "VALUE", FUNCTION_NAMES_TEXT2.VALUETOTEXT = "VALUETOTEXT", FUNCTION_NAMES_TEXT2.CALL = "CALL", FUNCTION_NAMES_TEXT2.EUROCONVERT = "EUROCONVERT", FUNCTION_NAMES_TEXT2.REGISTER_ID = "REGISTER.ID", FUNCTION_NAMES_TEXT2))(FUNCTION_NAMES_TEXT || {});
|
|
20132
|
+
function charLenByte(str) {
|
|
20133
|
+
let byteCount = 0;
|
|
20134
|
+
for (let i = 0; i < str.length; i++) {
|
|
20135
|
+
const charCode = str.charCodeAt(i);
|
|
20136
|
+
charCode >= 12352 && charCode <= 12543 || // Japanese hiragana and katakana
|
|
20137
|
+
charCode >= 19968 && charCode <= 40959 || // Chinese (simplified and traditional)
|
|
20138
|
+
charCode >= 44032 && charCode <= 55215 ? byteCount += 2 : byteCount += 1;
|
|
20139
|
+
}
|
|
20140
|
+
return byteCount;
|
|
20141
|
+
}
|
|
20142
|
+
__name(charLenByte, "charLenByte");
|
|
20143
|
+
const _Leftb = class _Leftb extends BaseFunction {
|
|
20144
|
+
constructor() {
|
|
20145
|
+
super(...arguments);
|
|
20146
|
+
__publicField(this, "minParams", 1);
|
|
20147
|
+
__publicField(this, "maxParams", 2);
|
|
20148
|
+
}
|
|
20149
|
+
calculate(text, numBytes) {
|
|
20150
|
+
if (text.isError())
|
|
20151
|
+
return text;
|
|
20152
|
+
if (numBytes != null && numBytes.isError())
|
|
20153
|
+
return numBytes;
|
|
20154
|
+
const _numBytes = numBytes || NumberValueObject.create(1), maxRowLength = Math.max(
|
|
20155
|
+
text.isArray() ? text.getRowCount() : 1,
|
|
20156
|
+
_numBytes && _numBytes.isArray() ? _numBytes.getRowCount() : 1
|
|
20157
|
+
), maxColumnLength = Math.max(
|
|
20158
|
+
text.isArray() ? text.getColumnCount() : 1,
|
|
20159
|
+
_numBytes && _numBytes.isArray() ? _numBytes.getColumnCount() : 1
|
|
20160
|
+
), textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text), numBytesArray = expandArrayValueObject(maxRowLength, maxColumnLength, _numBytes);
|
|
20161
|
+
return textArray.map((textValue, rowIndex, columnIndex) => this._handleSingleText(textValue, rowIndex, columnIndex, numBytesArray));
|
|
20162
|
+
}
|
|
20163
|
+
_handleSingleText(textValue, rowIndex, columnIndex, numBytesArray) {
|
|
20164
|
+
let numBytes = numBytesArray.get(rowIndex, columnIndex) || NumberValueObject.create(1);
|
|
20165
|
+
if (numBytes.isError())
|
|
20166
|
+
return numBytes;
|
|
20167
|
+
let textValueString = textValue.getValue();
|
|
20168
|
+
if (textValue.isNull() && (textValueString = ""), textValue.isBoolean() && (textValueString = textValueString ? "TRUE" : "FALSE"), textValueString = `${textValueString}`, (numBytes.isString() || numBytes.isBoolean() || numBytes.isNull()) && (numBytes = numBytes.convertToNumberObjectValue()), numBytes.isError())
|
|
20169
|
+
return numBytes;
|
|
20170
|
+
const numBytesValueNumber = Math.floor(+numBytes.getValue());
|
|
20171
|
+
return numBytesValueNumber < 0 ? ErrorValueObject.create(ErrorType$1.VALUE) : StringValueObject.create(this._sliceByBytes(textValueString, numBytesValueNumber));
|
|
20172
|
+
}
|
|
20173
|
+
_sliceByBytes(text, numBytes) {
|
|
20174
|
+
let byteCount = 0, sliceIndex = 0;
|
|
20175
|
+
for (let i = 0; i < text.length; i++) {
|
|
20176
|
+
const char = text[i], charByteLength = charLenByte(char);
|
|
20177
|
+
if (byteCount + charByteLength > numBytes)
|
|
20178
|
+
break;
|
|
20179
|
+
byteCount += charByteLength, sliceIndex++;
|
|
20180
|
+
}
|
|
20181
|
+
return [...text].slice(0, sliceIndex).join("");
|
|
20182
|
+
}
|
|
20183
|
+
};
|
|
20184
|
+
__name(_Leftb, "Leftb");
|
|
20185
|
+
let Leftb = _Leftb;
|
|
18422
20186
|
const _Len = class _Len extends BaseFunction {
|
|
18423
20187
|
constructor() {
|
|
18424
20188
|
super(...arguments);
|
|
@@ -18446,17 +20210,6 @@ const _Len = class _Len extends BaseFunction {
|
|
|
18446
20210
|
};
|
|
18447
20211
|
__name(_Len, "Len");
|
|
18448
20212
|
let Len = _Len;
|
|
18449
|
-
function charLenByte(str) {
|
|
18450
|
-
let byteCount = 0;
|
|
18451
|
-
for (let i = 0; i < str.length; i++) {
|
|
18452
|
-
const charCode = str.charCodeAt(i);
|
|
18453
|
-
charCode >= 12352 && charCode <= 12543 || // Japanese hiragana and katakana
|
|
18454
|
-
charCode >= 19968 && charCode <= 40959 || // Chinese (simplified and traditional)
|
|
18455
|
-
charCode >= 44032 && charCode <= 55215 ? byteCount += 2 : byteCount += 1;
|
|
18456
|
-
}
|
|
18457
|
-
return byteCount;
|
|
18458
|
-
}
|
|
18459
|
-
__name(charLenByte, "charLenByte");
|
|
18460
20213
|
const _Lenb = class _Lenb extends BaseFunction {
|
|
18461
20214
|
constructor() {
|
|
18462
20215
|
super(...arguments);
|
|
@@ -18503,6 +20256,47 @@ const _Lower = class _Lower extends BaseFunction {
|
|
|
18503
20256
|
};
|
|
18504
20257
|
__name(_Lower, "Lower");
|
|
18505
20258
|
let Lower = _Lower;
|
|
20259
|
+
const _Mid = class _Mid extends BaseFunction {
|
|
20260
|
+
constructor() {
|
|
20261
|
+
super(...arguments);
|
|
20262
|
+
__publicField(this, "minParams", 3);
|
|
20263
|
+
__publicField(this, "maxParams", 3);
|
|
20264
|
+
}
|
|
20265
|
+
calculate(withinText, startNum, numChars) {
|
|
20266
|
+
if (withinText.isError())
|
|
20267
|
+
return withinText;
|
|
20268
|
+
if (startNum.isError())
|
|
20269
|
+
return startNum;
|
|
20270
|
+
if (numChars.isError())
|
|
20271
|
+
return numChars;
|
|
20272
|
+
const maxRowLength = Math.max(
|
|
20273
|
+
withinText.isArray() ? withinText.getRowCount() : 1,
|
|
20274
|
+
startNum.isArray() ? startNum.getRowCount() : 1,
|
|
20275
|
+
numChars.isArray() ? numChars.getRowCount() : 1
|
|
20276
|
+
), maxColumnLength = Math.max(
|
|
20277
|
+
withinText.isArray() ? withinText.getColumnCount() : 1,
|
|
20278
|
+
startNum.isArray() ? startNum.getColumnCount() : 1,
|
|
20279
|
+
numChars.isArray() ? numChars.getColumnCount() : 1
|
|
20280
|
+
), withinTextArray = expandArrayValueObject(maxRowLength, maxColumnLength, withinText), startNumArray = expandArrayValueObject(maxRowLength, maxColumnLength, startNum), numCharsArray = expandArrayValueObject(maxRowLength, maxColumnLength, numChars);
|
|
20281
|
+
return withinTextArray.map((withinTextValue, rowIndex, columnIndex) => this._handleSingleText(withinTextValue, rowIndex, columnIndex, startNumArray, numCharsArray));
|
|
20282
|
+
}
|
|
20283
|
+
_handleSingleText(withinTextValue, rowIndex, columnIndex, startNumArray, numCharsArray) {
|
|
20284
|
+
let startNumValue = startNumArray.get(rowIndex, columnIndex) || NullValueObject.create(), numCharsValue = numCharsArray.get(rowIndex, columnIndex) || NullValueObject.create();
|
|
20285
|
+
if (startNumValue.isError())
|
|
20286
|
+
return startNumValue;
|
|
20287
|
+
if (numCharsValue.isError())
|
|
20288
|
+
return numCharsValue;
|
|
20289
|
+
let withinTextValueString = withinTextValue.getValue();
|
|
20290
|
+
if (withinTextValue.isNull() && (withinTextValueString = ""), withinTextValue.isBoolean() && (withinTextValueString = withinTextValueString ? "TRUE" : "FALSE"), withinTextValueString = `${withinTextValueString}`, (startNumValue.isString() || startNumValue.isBoolean() || startNumValue.isNull()) && (startNumValue = startNumValue.convertToNumberObjectValue()), startNumValue.isError())
|
|
20291
|
+
return startNumValue;
|
|
20292
|
+
if ((numCharsValue.isString() || numCharsValue.isBoolean() || numCharsValue.isNull()) && (numCharsValue = numCharsValue.convertToNumberObjectValue()), numCharsValue.isError())
|
|
20293
|
+
return numCharsValue;
|
|
20294
|
+
const startNumValueNumber = Math.floor(+startNumValue.getValue()) - 1, numCharsValueNumber = numCharsValue.getValue();
|
|
20295
|
+
return startNumValueNumber < 0 || numCharsValueNumber < 0 ? ErrorValueObject.create(ErrorType$1.VALUE) : StringValueObject.create(withinTextValueString.substring(startNumValueNumber, startNumValueNumber + numCharsValueNumber));
|
|
20296
|
+
}
|
|
20297
|
+
};
|
|
20298
|
+
__name(_Mid, "Mid");
|
|
20299
|
+
let Mid = _Mid;
|
|
18506
20300
|
const _Rept = class _Rept extends BaseFunction {
|
|
18507
20301
|
constructor() {
|
|
18508
20302
|
super(...arguments);
|
|
@@ -18538,7 +20332,7 @@ const _Rept = class _Rept extends BaseFunction {
|
|
|
18538
20332
|
};
|
|
18539
20333
|
__name(_Rept, "Rept");
|
|
18540
20334
|
let Rept = _Rept;
|
|
18541
|
-
const getFormatPreview = /* @__PURE__ */ __name((pattern, value) => numfmt.format(pattern, value), "getFormatPreview"), _Text = class _Text extends BaseFunction {
|
|
20335
|
+
const getFormatPreview = /* @__PURE__ */ __name((pattern, value) => numfmt.format(pattern, value, { throws: !1 }), "getFormatPreview"), _Text = class _Text extends BaseFunction {
|
|
18542
20336
|
constructor() {
|
|
18543
20337
|
super(...arguments);
|
|
18544
20338
|
__publicField(this, "minParams", 2);
|
|
@@ -18557,19 +20351,24 @@ const getFormatPreview = /* @__PURE__ */ __name((pattern, value) => numfmt.forma
|
|
|
18557
20351
|
formatText.isArray() ? formatText.getColumnCount() : 1
|
|
18558
20352
|
), textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text), formatTextArray = expandArrayValueObject(maxRowLength, maxColumnLength, formatText);
|
|
18559
20353
|
return textArray.map((textValue, rowIndex, columnIndex) => {
|
|
18560
|
-
if (textValue.isError()
|
|
20354
|
+
if (textValue.isError())
|
|
18561
20355
|
return textValue;
|
|
18562
20356
|
let formatTextValue = formatTextArray.get(rowIndex, columnIndex) || StringValueObject.create(" ");
|
|
18563
20357
|
if (formatTextValue.isError())
|
|
18564
20358
|
return formatTextValue;
|
|
18565
20359
|
if (formatTextValue.isBoolean())
|
|
18566
20360
|
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
18567
|
-
|
|
18568
|
-
|
|
20361
|
+
if (textValue.isBoolean())
|
|
20362
|
+
return textValue;
|
|
18569
20363
|
let textValueNumber = textValue.getValue();
|
|
18570
|
-
textValue.isNull() && (textValueNumber = 0)
|
|
18571
|
-
|
|
18572
|
-
|
|
20364
|
+
if (textValue.isNull() && (textValueNumber = 0), textValue.isString()) {
|
|
20365
|
+
if (!isRealNum(textValueNumber))
|
|
20366
|
+
return textValue;
|
|
20367
|
+
textValueNumber = Number(textValueNumber);
|
|
20368
|
+
}
|
|
20369
|
+
formatTextValue.isNull() && (formatTextValue = StringValueObject.create(" "));
|
|
20370
|
+
const formatTextValueString = `${formatTextValue.getValue()}`, previewText = getFormatPreview(formatTextValueString, textValueNumber);
|
|
20371
|
+
return StringValueObject.create(formatTextValueString === " " ? previewText.trimEnd() : previewText);
|
|
18573
20372
|
});
|
|
18574
20373
|
}
|
|
18575
20374
|
};
|
|
@@ -18582,8 +20381,6 @@ const _Textafter = class _Textafter extends BaseFunction {
|
|
|
18582
20381
|
__publicField(this, "maxParams", 6);
|
|
18583
20382
|
}
|
|
18584
20383
|
calculate(text, delimiter, instanceNum, matchMode, matchEnd, ifNotFound) {
|
|
18585
|
-
let _delimiter = delimiter;
|
|
18586
|
-
_delimiter.isArray() && (_delimiter = _delimiter.get(0, 0));
|
|
18587
20384
|
let instanceNumIsNull = !1, _instanceNum = instanceNum != null ? instanceNum : NumberValueObject.create(1);
|
|
18588
20385
|
_instanceNum.isNull() && (instanceNumIsNull = !0, _instanceNum = NumberValueObject.create(1));
|
|
18589
20386
|
const onlyThreeVariant = !matchMode, _matchMode = matchMode != null ? matchMode : NumberValueObject.create(0), _matchEnd = matchEnd != null ? matchEnd : NumberValueObject.create(0), _ifNotFound = ifNotFound != null ? ifNotFound : ErrorValueObject.create(ErrorType$1.NA), maxRowLength = Math.max(
|
|
@@ -18598,19 +20395,22 @@ const _Textafter = class _Textafter extends BaseFunction {
|
|
|
18598
20395
|
_matchMode.isArray() ? _matchMode.getColumnCount() : 1,
|
|
18599
20396
|
_matchEnd.isArray() ? _matchEnd.getColumnCount() : 1,
|
|
18600
20397
|
_ifNotFound.isArray() ? _ifNotFound.getColumnCount() : 1
|
|
18601
|
-
), textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, ErrorValueObject.create(ErrorType$1.NA)), instanceNumArray = expandArrayValueObject(maxRowLength, maxColumnLength, _instanceNum, ErrorValueObject.create(ErrorType$1.NA)), matchModeArray = expandArrayValueObject(maxRowLength, maxColumnLength, _matchMode, ErrorValueObject.create(ErrorType$1.NA)), matchEndArray = expandArrayValueObject(maxRowLength, maxColumnLength, _matchEnd, ErrorValueObject.create(ErrorType$1.NA)), ifNotFoundArray = expandArrayValueObject(maxRowLength, maxColumnLength, _ifNotFound, ErrorValueObject.create(ErrorType$1.NA)), resultArray = this._getResultArray(textArray,
|
|
20398
|
+
), textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, ErrorValueObject.create(ErrorType$1.NA)), instanceNumArray = expandArrayValueObject(maxRowLength, maxColumnLength, _instanceNum, ErrorValueObject.create(ErrorType$1.NA)), matchModeArray = expandArrayValueObject(maxRowLength, maxColumnLength, _matchMode, ErrorValueObject.create(ErrorType$1.NA)), matchEndArray = expandArrayValueObject(maxRowLength, maxColumnLength, _matchEnd, ErrorValueObject.create(ErrorType$1.NA)), ifNotFoundArray = expandArrayValueObject(maxRowLength, maxColumnLength, _ifNotFound, ErrorValueObject.create(ErrorType$1.NA)), resultArray = this._getResultArray(textArray, delimiter, instanceNumArray, matchModeArray, matchEndArray, ifNotFoundArray, instanceNumIsNull, onlyThreeVariant);
|
|
18602
20399
|
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
18603
20400
|
}
|
|
18604
|
-
_getResultArray(textArray,
|
|
20401
|
+
_getResultArray(textArray, delimiter, instanceNumArray, matchModeArray, matchEndArray, ifNotFoundArray, instanceNumIsNull, onlyThreeVariant) {
|
|
18605
20402
|
return textArray.map((textObject, rowIndex, columnIndex) => {
|
|
18606
|
-
const instanceNumObject = instanceNumArray.get(rowIndex, columnIndex), matchModeObject = matchModeArray.get(rowIndex, columnIndex), matchEndObject = matchEndArray.get(rowIndex, columnIndex), ifNotFoundObject = ifNotFoundArray.get(rowIndex, columnIndex), _variantsError = this._checkVariantsError(textObject, instanceNumObject, matchModeObject, matchEndObject
|
|
20403
|
+
const instanceNumObject = instanceNumArray.get(rowIndex, columnIndex), matchModeObject = matchModeArray.get(rowIndex, columnIndex), matchEndObject = matchEndArray.get(rowIndex, columnIndex), ifNotFoundObject = ifNotFoundArray.get(rowIndex, columnIndex), _variantsError = this._checkVariantsError(textObject, instanceNumObject, matchModeObject, matchEndObject);
|
|
18607
20404
|
if (_variantsError.isError())
|
|
18608
20405
|
return _variantsError;
|
|
18609
|
-
const textValue = this._getStringValue(textObject), delimiterValue = this.
|
|
20406
|
+
const textValue = this._getStringValue(textObject), delimiterValue = this._getDelimiterValue(delimiter);
|
|
20407
|
+
if (delimiterValue instanceof ErrorValueObject)
|
|
20408
|
+
return delimiterValue;
|
|
20409
|
+
const _variantsNumberFloorValue = this._getVariantsNumberFloorValue(instanceNumObject, matchModeObject, matchEndObject);
|
|
18610
20410
|
if (_variantsNumberFloorValue instanceof ErrorValueObject)
|
|
18611
20411
|
return _variantsNumberFloorValue;
|
|
18612
20412
|
const [instanceNumValue, matchModeValue, matchEndValue] = _variantsNumberFloorValue;
|
|
18613
|
-
return instanceNumValue === 0 || matchModeValue < 0 || matchModeValue > 1 || matchEndValue < 0 || matchEndValue > 1 ? ErrorValueObject.create(ErrorType$1.VALUE) : delimiterValue
|
|
20413
|
+
return instanceNumValue === 0 || matchModeValue < 0 || matchModeValue > 1 || matchEndValue < 0 || matchEndValue > 1 ? ErrorValueObject.create(ErrorType$1.VALUE) : delimiterValue.includes("") ? instanceNumValue > 0 ? StringValueObject.create(textValue) : StringValueObject.create("") : !instanceNumIsNull && Math.abs(instanceNumValue) > textValue.length ? ErrorValueObject.create(ErrorType$1.VALUE) : delimiterValue.every((item) => item.length > textValue.length) ? ErrorValueObject.create(ErrorType$1.NA) : this._getResult(textValue, delimiterValue, instanceNumValue, matchModeValue, matchEndValue, ifNotFoundObject, onlyThreeVariant);
|
|
18614
20414
|
});
|
|
18615
20415
|
}
|
|
18616
20416
|
_checkVariantsError(...variantas) {
|
|
@@ -18625,6 +20425,24 @@ const _Textafter = class _Textafter extends BaseFunction {
|
|
|
18625
20425
|
let value = `${variant.getValue()}`;
|
|
18626
20426
|
return variant.isNull() && (value = ""), variant.isBoolean() && (value = value.toLocaleUpperCase()), value;
|
|
18627
20427
|
}
|
|
20428
|
+
_getDelimiterValue(delimiter) {
|
|
20429
|
+
const delimiterValue = [];
|
|
20430
|
+
if (delimiter.isArray()) {
|
|
20431
|
+
let isError = !1, errorObject = ErrorValueObject.create(ErrorType$1.VALUE);
|
|
20432
|
+
if (delimiter.iterator((delimiterObject) => {
|
|
20433
|
+
const _delimiterObject = delimiterObject;
|
|
20434
|
+
if (_delimiterObject.isError())
|
|
20435
|
+
return isError = !0, errorObject = _delimiterObject, !1;
|
|
20436
|
+
delimiterValue.push(this._getStringValue(_delimiterObject));
|
|
20437
|
+
}), isError)
|
|
20438
|
+
return errorObject;
|
|
20439
|
+
} else {
|
|
20440
|
+
if (delimiter.isError())
|
|
20441
|
+
return delimiter;
|
|
20442
|
+
delimiterValue.push(this._getStringValue(delimiter));
|
|
20443
|
+
}
|
|
20444
|
+
return delimiterValue;
|
|
20445
|
+
}
|
|
18628
20446
|
_getVariantsNumberFloorValue(...variants) {
|
|
18629
20447
|
const values = [];
|
|
18630
20448
|
for (let i = 0; i < variants.length; i++) {
|
|
@@ -18637,23 +20455,32 @@ const _Textafter = class _Textafter extends BaseFunction {
|
|
|
18637
20455
|
return values;
|
|
18638
20456
|
}
|
|
18639
20457
|
_getResult(textValue, delimiterValue, instanceNumValue, matchModeValue, matchEndValue, ifNotFoundObject, onlyThreeVariant) {
|
|
18640
|
-
const matchNum = textValue.match(new RegExp(delimiterValue, `g${matchModeValue ? "i" : ""}`));
|
|
18641
|
-
if (matchNum && matchNum.length < Math.abs(instanceNumValue) && onlyThreeVariant)
|
|
18642
|
-
return ErrorValueObject.create(ErrorType$1.NA);
|
|
18643
|
-
if (!matchNum || matchNum.length < Math.abs(instanceNumValue))
|
|
18644
|
-
return matchEndValue ? instanceNumValue > 0 ? StringValueObject.create("") : StringValueObject.create(textValue) : ifNotFoundObject;
|
|
18645
20458
|
let substrText = matchModeValue ? textValue.toLocaleLowerCase() : textValue;
|
|
18646
|
-
const _delimiterValue = matchModeValue ? delimiterValue.toLocaleLowerCase() : delimiterValue;
|
|
18647
|
-
let resultIndex = 0;
|
|
20459
|
+
const _delimiterValue = matchModeValue ? delimiterValue.map((item) => item.toLocaleLowerCase()) : delimiterValue;
|
|
20460
|
+
let resultIndex = 0, matchNum = 0, preDelimiterLength = 0;
|
|
18648
20461
|
for (let i = 0; i < Math.abs(instanceNumValue); i++)
|
|
18649
20462
|
if (instanceNumValue < 0) {
|
|
18650
|
-
const
|
|
18651
|
-
|
|
20463
|
+
const delimiterItem = _delimiterValue.map((item) => ({
|
|
20464
|
+
index: substrText.lastIndexOf(item),
|
|
20465
|
+
length: item.length
|
|
20466
|
+
})).filter((item) => item.index !== -1).sort((a, b) => b.index - a.index)[0];
|
|
20467
|
+
if (!delimiterItem)
|
|
20468
|
+
break;
|
|
20469
|
+
resultIndex = delimiterItem.index, substrText = substrText.substr(0, delimiterItem.index), preDelimiterLength = delimiterItem.length, matchNum++;
|
|
18652
20470
|
} else {
|
|
18653
|
-
const
|
|
18654
|
-
|
|
20471
|
+
const delimiterItem = _delimiterValue.map((item) => ({
|
|
20472
|
+
index: substrText.indexOf(item),
|
|
20473
|
+
length: item.length
|
|
20474
|
+
})).filter((item) => item.index !== -1).sort((a, b) => a.index - b.index)[0];
|
|
20475
|
+
if (!delimiterItem)
|
|
20476
|
+
break;
|
|
20477
|
+
resultIndex += delimiterItem.index + preDelimiterLength, substrText = substrText.substr(delimiterItem.index + delimiterItem.length), preDelimiterLength = delimiterItem.length, matchNum++;
|
|
18655
20478
|
}
|
|
18656
|
-
|
|
20479
|
+
if (matchNum && matchNum < Math.abs(instanceNumValue) && onlyThreeVariant)
|
|
20480
|
+
return ErrorValueObject.create(ErrorType$1.NA);
|
|
20481
|
+
if (!matchNum || matchNum < Math.abs(instanceNumValue))
|
|
20482
|
+
return matchEndValue ? instanceNumValue > 0 ? StringValueObject.create("") : StringValueObject.create(textValue) : ifNotFoundObject;
|
|
20483
|
+
const result = textValue.substr(resultIndex + preDelimiterLength);
|
|
18657
20484
|
return StringValueObject.create(result);
|
|
18658
20485
|
}
|
|
18659
20486
|
};
|
|
@@ -18666,8 +20493,6 @@ const _Textbefore = class _Textbefore extends BaseFunction {
|
|
|
18666
20493
|
__publicField(this, "maxParams", 6);
|
|
18667
20494
|
}
|
|
18668
20495
|
calculate(text, delimiter, instanceNum, matchMode, matchEnd, ifNotFound) {
|
|
18669
|
-
let _delimiter = delimiter;
|
|
18670
|
-
_delimiter.isArray() && (_delimiter = _delimiter.get(0, 0));
|
|
18671
20496
|
let instanceNumIsNull = !1, _instanceNum = instanceNum != null ? instanceNum : NumberValueObject.create(1);
|
|
18672
20497
|
_instanceNum.isNull() && (instanceNumIsNull = !0, _instanceNum = NumberValueObject.create(1));
|
|
18673
20498
|
const onlyThreeVariant = !matchMode, _matchMode = matchMode != null ? matchMode : NumberValueObject.create(0), _matchEnd = matchEnd != null ? matchEnd : NumberValueObject.create(0), _ifNotFound = ifNotFound != null ? ifNotFound : ErrorValueObject.create(ErrorType$1.NA), maxRowLength = Math.max(
|
|
@@ -18682,19 +20507,22 @@ const _Textbefore = class _Textbefore extends BaseFunction {
|
|
|
18682
20507
|
_matchMode.isArray() ? _matchMode.getColumnCount() : 1,
|
|
18683
20508
|
_matchEnd.isArray() ? _matchEnd.getColumnCount() : 1,
|
|
18684
20509
|
_ifNotFound.isArray() ? _ifNotFound.getColumnCount() : 1
|
|
18685
|
-
), textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, ErrorValueObject.create(ErrorType$1.NA)), instanceNumArray = expandArrayValueObject(maxRowLength, maxColumnLength, _instanceNum, ErrorValueObject.create(ErrorType$1.NA)), matchModeArray = expandArrayValueObject(maxRowLength, maxColumnLength, _matchMode, ErrorValueObject.create(ErrorType$1.NA)), matchEndArray = expandArrayValueObject(maxRowLength, maxColumnLength, _matchEnd, ErrorValueObject.create(ErrorType$1.NA)), ifNotFoundArray = expandArrayValueObject(maxRowLength, maxColumnLength, _ifNotFound, ErrorValueObject.create(ErrorType$1.NA)), resultArray = this._getResultArray(textArray,
|
|
20510
|
+
), textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, ErrorValueObject.create(ErrorType$1.NA)), instanceNumArray = expandArrayValueObject(maxRowLength, maxColumnLength, _instanceNum, ErrorValueObject.create(ErrorType$1.NA)), matchModeArray = expandArrayValueObject(maxRowLength, maxColumnLength, _matchMode, ErrorValueObject.create(ErrorType$1.NA)), matchEndArray = expandArrayValueObject(maxRowLength, maxColumnLength, _matchEnd, ErrorValueObject.create(ErrorType$1.NA)), ifNotFoundArray = expandArrayValueObject(maxRowLength, maxColumnLength, _ifNotFound, ErrorValueObject.create(ErrorType$1.NA)), resultArray = this._getResultArray(textArray, delimiter, instanceNumArray, matchModeArray, matchEndArray, ifNotFoundArray, instanceNumIsNull, onlyThreeVariant);
|
|
18686
20511
|
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
18687
20512
|
}
|
|
18688
|
-
_getResultArray(textArray,
|
|
20513
|
+
_getResultArray(textArray, delimiter, instanceNumArray, matchModeArray, matchEndArray, ifNotFoundArray, instanceNumIsNull, onlyThreeVariant) {
|
|
18689
20514
|
return textArray.map((textObject, rowIndex, columnIndex) => {
|
|
18690
|
-
const instanceNumObject = instanceNumArray.get(rowIndex, columnIndex), matchModeObject = matchModeArray.get(rowIndex, columnIndex), matchEndObject = matchEndArray.get(rowIndex, columnIndex), ifNotFoundObject = ifNotFoundArray.get(rowIndex, columnIndex), _variantsError = this._checkVariantsError(textObject, instanceNumObject, matchModeObject, matchEndObject
|
|
20515
|
+
const instanceNumObject = instanceNumArray.get(rowIndex, columnIndex), matchModeObject = matchModeArray.get(rowIndex, columnIndex), matchEndObject = matchEndArray.get(rowIndex, columnIndex), ifNotFoundObject = ifNotFoundArray.get(rowIndex, columnIndex), _variantsError = this._checkVariantsError(textObject, instanceNumObject, matchModeObject, matchEndObject);
|
|
18691
20516
|
if (_variantsError.isError())
|
|
18692
20517
|
return _variantsError;
|
|
18693
|
-
const textValue = this._getStringValue(textObject), delimiterValue = this.
|
|
20518
|
+
const textValue = this._getStringValue(textObject), delimiterValue = this._getDelimiterValue(delimiter);
|
|
20519
|
+
if (delimiterValue instanceof ErrorValueObject)
|
|
20520
|
+
return delimiterValue;
|
|
20521
|
+
const _variantsNumberFloorValue = this._getVariantsNumberFloorValue(instanceNumObject, matchModeObject, matchEndObject);
|
|
18694
20522
|
if (_variantsNumberFloorValue instanceof ErrorValueObject)
|
|
18695
20523
|
return _variantsNumberFloorValue;
|
|
18696
20524
|
const [instanceNumValue, matchModeValue, matchEndValue] = _variantsNumberFloorValue;
|
|
18697
|
-
return instanceNumValue === 0 || matchModeValue < 0 || matchModeValue > 1 || matchEndValue < 0 || matchEndValue > 1 ? ErrorValueObject.create(ErrorType$1.VALUE) : delimiterValue
|
|
20525
|
+
return instanceNumValue === 0 || matchModeValue < 0 || matchModeValue > 1 || matchEndValue < 0 || matchEndValue > 1 ? ErrorValueObject.create(ErrorType$1.VALUE) : delimiterValue.includes("") ? instanceNumValue > 0 ? StringValueObject.create("") : StringValueObject.create(textValue) : !instanceNumIsNull && Math.abs(instanceNumValue) > textValue.length ? ErrorValueObject.create(ErrorType$1.VALUE) : delimiterValue.every((item) => item.length > textValue.length) ? ErrorValueObject.create(ErrorType$1.NA) : this._getResult(textValue, delimiterValue, instanceNumValue, matchModeValue, matchEndValue, ifNotFoundObject, onlyThreeVariant);
|
|
18698
20526
|
});
|
|
18699
20527
|
}
|
|
18700
20528
|
_checkVariantsError(...variantas) {
|
|
@@ -18709,6 +20537,24 @@ const _Textbefore = class _Textbefore extends BaseFunction {
|
|
|
18709
20537
|
let value = `${variant.getValue()}`;
|
|
18710
20538
|
return variant.isNull() && (value = ""), variant.isBoolean() && (value = value.toLocaleUpperCase()), value;
|
|
18711
20539
|
}
|
|
20540
|
+
_getDelimiterValue(delimiter) {
|
|
20541
|
+
const delimiterValue = [];
|
|
20542
|
+
if (delimiter.isArray()) {
|
|
20543
|
+
let isError = !1, errorObject = ErrorValueObject.create(ErrorType$1.VALUE);
|
|
20544
|
+
if (delimiter.iterator((delimiterObject) => {
|
|
20545
|
+
const _delimiterObject = delimiterObject;
|
|
20546
|
+
if (_delimiterObject.isError())
|
|
20547
|
+
return isError = !0, errorObject = _delimiterObject, !1;
|
|
20548
|
+
delimiterValue.push(this._getStringValue(_delimiterObject));
|
|
20549
|
+
}), isError)
|
|
20550
|
+
return errorObject;
|
|
20551
|
+
} else {
|
|
20552
|
+
if (delimiter.isError())
|
|
20553
|
+
return delimiter;
|
|
20554
|
+
delimiterValue.push(this._getStringValue(delimiter));
|
|
20555
|
+
}
|
|
20556
|
+
return delimiterValue;
|
|
20557
|
+
}
|
|
18712
20558
|
_getVariantsNumberFloorValue(...variants) {
|
|
18713
20559
|
const values = [];
|
|
18714
20560
|
for (let i = 0; i < variants.length; i++) {
|
|
@@ -18721,22 +20567,31 @@ const _Textbefore = class _Textbefore extends BaseFunction {
|
|
|
18721
20567
|
return values;
|
|
18722
20568
|
}
|
|
18723
20569
|
_getResult(textValue, delimiterValue, instanceNumValue, matchModeValue, matchEndValue, ifNotFoundObject, onlyThreeVariant) {
|
|
18724
|
-
const matchNum = textValue.match(new RegExp(delimiterValue, `g${matchModeValue ? "i" : ""}`));
|
|
18725
|
-
if (matchNum && matchNum.length < Math.abs(instanceNumValue) && onlyThreeVariant)
|
|
18726
|
-
return ErrorValueObject.create(ErrorType$1.NA);
|
|
18727
|
-
if (!matchNum || matchNum.length < Math.abs(instanceNumValue))
|
|
18728
|
-
return matchEndValue ? instanceNumValue > 0 ? StringValueObject.create(textValue) : StringValueObject.create("") : ifNotFoundObject;
|
|
18729
20570
|
let substrText = matchModeValue ? textValue.toLocaleLowerCase() : textValue;
|
|
18730
|
-
const _delimiterValue = matchModeValue ? delimiterValue.toLocaleLowerCase() : delimiterValue;
|
|
18731
|
-
let resultIndex = 0;
|
|
20571
|
+
const _delimiterValue = matchModeValue ? delimiterValue.map((item) => item.toLocaleLowerCase()) : delimiterValue;
|
|
20572
|
+
let resultIndex = 0, matchNum = 0, preDelimiterLength = 0;
|
|
18732
20573
|
for (let i = 0; i < Math.abs(instanceNumValue); i++)
|
|
18733
20574
|
if (instanceNumValue < 0) {
|
|
18734
|
-
const
|
|
18735
|
-
|
|
20575
|
+
const delimiterItem = _delimiterValue.map((item) => ({
|
|
20576
|
+
index: substrText.lastIndexOf(item),
|
|
20577
|
+
length: item.length
|
|
20578
|
+
})).filter((item) => item.index !== -1).sort((a, b) => b.index - a.index)[0];
|
|
20579
|
+
if (!delimiterItem)
|
|
20580
|
+
break;
|
|
20581
|
+
resultIndex = delimiterItem.index, substrText = substrText.substr(0, delimiterItem.index), matchNum++;
|
|
18736
20582
|
} else {
|
|
18737
|
-
const
|
|
18738
|
-
|
|
20583
|
+
const delimiterItem = _delimiterValue.map((item) => ({
|
|
20584
|
+
index: substrText.indexOf(item),
|
|
20585
|
+
length: item.length
|
|
20586
|
+
})).filter((item) => item.index !== -1).sort((a, b) => a.index - b.index)[0];
|
|
20587
|
+
if (!delimiterItem)
|
|
20588
|
+
break;
|
|
20589
|
+
resultIndex += delimiterItem.index + preDelimiterLength, substrText = substrText.substr(delimiterItem.index + delimiterItem.length), preDelimiterLength = delimiterItem.length, matchNum++;
|
|
18739
20590
|
}
|
|
20591
|
+
if (matchNum && matchNum < Math.abs(instanceNumValue) && onlyThreeVariant)
|
|
20592
|
+
return ErrorValueObject.create(ErrorType$1.NA);
|
|
20593
|
+
if (!matchNum || matchNum < Math.abs(instanceNumValue))
|
|
20594
|
+
return matchEndValue ? instanceNumValue > 0 ? StringValueObject.create(textValue) : StringValueObject.create("") : ifNotFoundObject;
|
|
18740
20595
|
const result = textValue.substr(0, resultIndex);
|
|
18741
20596
|
return StringValueObject.create(result);
|
|
18742
20597
|
}
|
|
@@ -18751,7 +20606,7 @@ const _Textsplit = class _Textsplit extends BaseFunction {
|
|
|
18751
20606
|
}
|
|
18752
20607
|
calculate(text, colDelimiter, rowDelimiter, ignoreEmpty, matchMode, padWith) {
|
|
18753
20608
|
let _rowDelimiter = rowDelimiter != null ? rowDelimiter : StringValueObject.create("\\s");
|
|
18754
|
-
const _ignoreEmpty = ignoreEmpty != null ? ignoreEmpty : NumberValueObject.create(0), _matchMode = matchMode != null ? matchMode : NumberValueObject.create(0), _padWith = padWith != null ? padWith : StringValueObject.create(ErrorType$1.NA), { _variant: _colDelimiter, values: colDelimiterValue } = this._getStringValues(colDelimiter), { _variant, values: rowDelimiterValue } = this._getStringValues(_rowDelimiter);
|
|
20609
|
+
const _ignoreEmpty = ignoreEmpty != null ? ignoreEmpty : NumberValueObject.create(0), _matchMode = matchMode != null ? matchMode : NumberValueObject.create(0), _padWith = padWith != null ? padWith : StringValueObject.create(ErrorType$1.NA), { _variant: _colDelimiter, values: colDelimiterValue } = this._getStringValues(colDelimiter), { _variant, values: rowDelimiterValue } = this._getStringValues(_rowDelimiter, !1);
|
|
18755
20610
|
_rowDelimiter = _variant;
|
|
18756
20611
|
const maxRowLength = Math.max(
|
|
18757
20612
|
text.isArray() ? text.getRowCount() : 1,
|
|
@@ -18773,14 +20628,14 @@ const _Textsplit = class _Textsplit extends BaseFunction {
|
|
|
18773
20628
|
);
|
|
18774
20629
|
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray.map((item) => item.get(0, 0));
|
|
18775
20630
|
}
|
|
18776
|
-
_getStringValues(variant) {
|
|
20631
|
+
_getStringValues(variant, isNotNull = !0) {
|
|
18777
20632
|
let _variant = variant;
|
|
18778
20633
|
const values = [];
|
|
18779
20634
|
if (_variant.isArray())
|
|
18780
20635
|
_variant.iterator((variantObject) => {
|
|
18781
20636
|
if (variantObject != null && variantObject.isError())
|
|
18782
20637
|
return _variant = variantObject, !1;
|
|
18783
|
-
if (variantObject != null && variantObject.isNull())
|
|
20638
|
+
if (variantObject != null && variantObject.isNull() && isNotNull)
|
|
18784
20639
|
return _variant = ErrorValueObject.create(ErrorType$1.VALUE), !1;
|
|
18785
20640
|
const value = this._getRegExpStringValue(variantObject);
|
|
18786
20641
|
if (value === "")
|
|
@@ -18788,6 +20643,7 @@ const _Textsplit = class _Textsplit extends BaseFunction {
|
|
|
18788
20643
|
values.push(value);
|
|
18789
20644
|
});
|
|
18790
20645
|
else {
|
|
20646
|
+
_variant.isNull() && isNotNull && (_variant = ErrorValueObject.create(ErrorType$1.VALUE));
|
|
18791
20647
|
const value = this._getRegExpStringValue(_variant);
|
|
18792
20648
|
value === "" && (_variant = ErrorValueObject.create(ErrorType$1.VALUE)), values.push(value);
|
|
18793
20649
|
}
|
|
@@ -18859,11 +20715,13 @@ const functionText = [
|
|
|
18859
20715
|
[Len, FUNCTION_NAMES_TEXT.LEN],
|
|
18860
20716
|
[Lenb, FUNCTION_NAMES_TEXT.LENB],
|
|
18861
20717
|
[Lower, FUNCTION_NAMES_TEXT.LOWER],
|
|
20718
|
+
[Mid, FUNCTION_NAMES_TEXT.MID],
|
|
18862
20719
|
[Rept, FUNCTION_NAMES_TEXT.REPT],
|
|
18863
20720
|
[Text, FUNCTION_NAMES_TEXT.TEXT],
|
|
18864
20721
|
[Textafter, FUNCTION_NAMES_TEXT.TEXTAFTER],
|
|
18865
20722
|
[Textbefore, FUNCTION_NAMES_TEXT.TEXTBEFORE],
|
|
18866
|
-
[Textsplit, FUNCTION_NAMES_TEXT.TEXTSPLIT]
|
|
20723
|
+
[Textsplit, FUNCTION_NAMES_TEXT.TEXTSPLIT],
|
|
20724
|
+
[Leftb, FUNCTION_NAMES_TEXT.LEFTB]
|
|
18867
20725
|
], functionUniver = [];
|
|
18868
20726
|
var FUNCTION_NAMES_UNIVER = /* @__PURE__ */ ((FUNCTION_NAMES_UNIVER2) => FUNCTION_NAMES_UNIVER2)(FUNCTION_NAMES_UNIVER || {});
|
|
18869
20727
|
const functionWeb = [];
|