Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
6.0.1 - 日本語

Change language to:
English - Français - Português - Русский

Please note that the recommended version of Scilab is 2024.0.0. This page might be outdated.
See the recommended documentation of this function

Scilabヘルプ >> Development tools > Assert > assert_cond2reqdigits

assert_cond2reqdigits

指定した条件数に必要な桁数を提案する.

呼び出し手順

d = assert_cond2reqdigits ( condition )
d = assert_cond2reqdigits ( condition , offset )
d = assert_cond2reqdigits ( condition , offset , b )

パラメータ

condition :

doubleの行列, 条件数. 条件数は厳密に正とする必要があります.

offset :

doubleの行列, 必要な基底bの桁数(デフォルト offset = 0). 例えば, offset=-1 は必要な桁数よりも小さい数 を出力します(必要な精度を減らす). offset=1は必要な桁数よりも大きな数を出力します (必要な精度を増やす).

b :

doubleの行列, 整数値, b (デフォルト: b = 10).

d :

doubleの行列, 必要な桁数. 正の実数で, b=10の場合は0 から 15.95 の範囲, b=2の場合は0から53の範囲.

説明

条件数に基づき,対応する必要な桁数を返します.

オプションのパラメータが空の行列[]に等しい場合, そのデフォルト値に置換されます.

この必要な桁数は単なる推奨値であることを強調しておきます. 代わりに,より小さいまたは大きな桁数を使用する 正当な理由がある場合がありえます.

  • 悪条件の問題においても, 正確な計算が可能な素晴らしいアルゴリズムがある場合を 考えてみましょう. この場合,より高い精度(正のオフセット)が必要となります.
  • 性能と精度のトレードオフがあり,性能が勝る場合について 考えてみましょう. この場合, より劣る精度(負のオフセット)が必要となります.

スカラー入力引数は全て他の入力引数と同じ大きさのdoubleの 行列に展開されます.

アルゴリズムは以下のようになります. 条件の基底10の指数を計算し,オフセットを引きます. この数は失われる桁数の予測値を表します. これを範囲 [0,dmax] に投影します. ただし, dmax -log10(2^(-53)) は doubleで最大実現可能な 桁数です. dmaxと失われる桁数の差から 必要な桁数 d を計算します. この結果,相対許容誤差は 10^-d となります.

assert_cond2reqdigits ( 0 ) // 15.95459
assert_cond2reqdigits ( 1 ) // 15.95459
assert_cond2reqdigits ( 1.e1 ) // 14.95459
assert_cond2reqdigits ( 1.e2 ) // 13.95459
assert_cond2reqdigits ( 1.e3 ) // 12.95459
assert_cond2reqdigits ( 1.e16 ) // 0
assert_cond2reqdigits ( 1.e17 ) // 0
assert_cond2reqdigits ( 1.e18 ) // 0
// 行列入力.
condition = [0,1,10,100,1000,1.D13,1.D14,1.D15,1.D16,1.D17,1.D18];
assert_cond2reqdigits ( condition )
// オフセットを使用
// 負のオフセット : 必要な桁数を減らす (より低い精度を要求)
assert_cond2reqdigits ( 1.e2 , [0 -1] ) // [13.95459    12.95459]
// 正のオフセット : 必要な桁数を増やす (より高い精度を要求)
// オフセットの影響を調べます.
assert_cond2reqdigits ( 1.e2 , [0 1 2 3] ) // [13.95459    14.95459    15.95459    15.95459]
// 負のオフセット (より低い精度を要求)
// オフセットの影響を調べます.
assert_cond2reqdigits ( 1.e14 , [0 -1 -2 -3] ) // [1.9545898    0.9545898    0.    0.]
// 基底2を使用
assert_cond2reqdigits ( 0     , [] , 2 ) // 53
assert_cond2reqdigits ( 1     , [] , 2 ) // 53
assert_cond2reqdigits ( 1.e1  , [] , 2 ) // 49.678072
assert_cond2reqdigits ( 1.e2  , [] , 2 ) // 46.356144
assert_cond2reqdigits ( 1.e3  , [] , 2 ) // 43.034216
assert_cond2reqdigits ( 1.e16 , [] , 2 ) // 0
assert_cond2reqdigits ( 1.e17 , [] , 2 ) // 0
assert_cond2reqdigits ( 1.e18 , [] , 2 ) // 0
// 条件に基づき必要な10進桁数をプロット
condition = logspace(0,18,1000);
d = assert_cond2reqdigits ( condition );
plot(condition,d)
h=gcf();
h.children.log_flags="lnn";
h.children.children.children.thickness=4;
xt = h.children.x_ticks;
xt.locations = 10^(0:2:18)';
xt.labels = ["10^0";"10^2";"10^4";"10^6";"10^8";"10^10";"10^12";"10^14";"10^16";"10^18"];
h.children.x_ticks=xt;
xtitle("Number of required digits","Condition","Required decimal digits");
// 条件に基づき必要な2進桁数をプロット
condition = logspace(0,18,1000);
d = assert_cond2reqdigits ( condition , [] , 2 );
plot(condition,d)
h=gcf();
h.children.log_flags="lnn";
h.children.children.children.thickness=4;
xt = h.children.x_ticks;
xt.locations = 10^(0:2:18)';
xt.labels = ["10^0";"10^2";"10^4";"10^6";"10^8";"10^10";"10^12";"10^14";"10^16";"10^18"];
h.children.x_ticks=xt;
xtitle("Number of required digits","Condition","Required binary digits");
d = assert_cond2reqdigits ( condition , +10 , 2 );
plot(condition,d,"r")
d = assert_cond2reqdigits ( condition , -10 , 2 );
plot(condition,d,"g")
legend(["Offset=0","Offset=+10","Offset=-10"]);

履歴

VersionDescription
5.4.0 関数が導入されました
Report an issue
<< assert_cond2reltol Assert assert_generror >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Mon Feb 12 23:12:44 CET 2018