Skip to content

Commit 7355365

Browse files
committed
⚡️ コンフィグ参照回数を削減
1 parent e54b9ee commit 7355365

File tree

6 files changed

+32
-24
lines changed

6 files changed

+32
-24
lines changed

dist/JavaLibraryScript.js

Lines changed: 12 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/JavaLibraryScript.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/JavaLibraryScript.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/JavaLibraryScript.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/math/BigFloat.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -865,17 +865,16 @@ class BigFloat extends JavaLibraryScriptCore {
865865
* 自然対数[Atanh法]
866866
* @param {BigInt} value
867867
* @param {BigInt} precision
868+
* @param {BigInt} maxSteps
868869
* @returns {BigInt}
869870
* @throws {Error}
870871
* @static
871872
*/
872-
static _ln(value, precision) {
873+
static _ln(value, precision, maxSteps) {
873874
if (value <= 0n) throw new Error("ln(x) is undefined for x <= 0");
874875

875876
const scale = 10n ** precision;
876877

877-
const maxSteps = this.config.lnMaxSteps;
878-
879878
let x = value;
880879
let k = 0n;
881880
while (x > 10n * scale) {
@@ -939,26 +938,29 @@ class BigFloat extends JavaLibraryScriptCore {
939938
ln() {
940939
/** @type {typeof BigFloat} */
941940
const construct = this.constructor;
942-
const exPr = construct.config.extraPrecision;
941+
const config = construct.config;
942+
const maxSteps = config.lnMaxSteps;
943+
const exPr = config.extraPrecision;
943944

944945
const totalPr = this._precision + exPr;
945946
const val = this.value * 10n ** exPr;
946947

947-
const raw = construct._ln(val, totalPr);
948+
const raw = construct._ln(val, totalPr, maxSteps);
948949
return this._makeResult(raw, this._precision, totalPr);
949950
}
950951

951952
/**
952953
* 対数
953954
* @param {BigInt} baseValue
954955
* @param {BigInt} precision
956+
* @param {BigInt} maxSteps
955957
* @returns {BigInt}
956958
* @throws {Error}
957959
* @static
958960
*/
959-
static _log(value, baseValue, precision) {
960-
const lnX = this._ln(value, precision);
961-
const lnB = this._ln(baseValue, precision);
961+
static _log(value, baseValue, precision, maxSteps) {
962+
const lnX = this._ln(value, precision, maxSteps);
963+
const lnB = this._ln(baseValue, precision, maxSteps);
962964

963965
if (lnB === 0n) throw new Error("log base cannot be 1 or 0");
964966

@@ -979,7 +981,8 @@ class BigFloat extends JavaLibraryScriptCore {
979981

980982
/** @type {typeof BigFloat} */
981983
const construct = this.constructor;
982-
const raw = construct._log(valA, valB, exPrec);
984+
const maxSteps = construct.config.lnMaxSteps;
985+
const raw = construct._log(valA, valB, exPrec, maxSteps);
983986
return this._makeResult(raw, prec, exPrec);
984987
}
985988
}

types/JavaLibraryScript.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,11 +1173,12 @@ declare class BigFloat extends JavaLibraryScriptCore {
11731173
* 自然対数[Atanh法]
11741174
* @param {BigInt} value
11751175
* @param {BigInt} precision
1176+
* @param {BigInt} maxSteps
11761177
* @returns {BigInt}
11771178
* @throws {Error}
11781179
* @static
11791180
*/
1180-
static _ln(value: bigint, precision: bigint): bigint;
1181+
static _ln(value: bigint, precision: bigint, maxSteps: bigint): bigint;
11811182
/**
11821183
* 自然対数 ln(10) (簡易計算用)
11831184
* @param {BigInt} precision - 精度
@@ -1189,11 +1190,12 @@ declare class BigFloat extends JavaLibraryScriptCore {
11891190
* 対数
11901191
* @param {BigInt} baseValue
11911192
* @param {BigInt} precision
1193+
* @param {BigInt} maxSteps
11921194
* @returns {BigInt}
11931195
* @throws {Error}
11941196
* @static
11951197
*/
1196-
static _log(value: any, baseValue: bigint, precision: bigint): bigint;
1198+
static _log(value: any, baseValue: bigint, precision: bigint, maxSteps: bigint): bigint;
11971199
/**
11981200
* @param {string | number | BigInt | BigFloat} value - 初期値
11991201
* @param {number} [precision=20] - 精度

0 commit comments

Comments
 (0)