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

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_computedigits

assert_computedigits

計算結果の上位桁数を返す.

呼び出し手順

d = assert_computedigits ( computed , expected )
d = assert_computedigits ( computed , expected , basis )

パラメータ

computed :

doubleの行列, 計算値

expected :

doubleの行列, 予測値

basis :

1行1列のdoubleの行列, 整数値, 基底 (デフォルトの基底=10)

d :

doubleの行列, 上位桁数.

説明

以下の式により非ゼロの結果の予測値に対する 計算結果の上位桁数を計算します:

\begin{eqnarray}
                d = - \frac{\log_{10} ( r )}{\log_{10}(basis)}
                \end{eqnarray}

ただし,相対誤差は以下により定義されます

\begin{eqnarray}
                r = \frac{|computed - expected|}{|expected|}
                \end{eqnarray}

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

上位桁数は dmin = 0 と dmax = -log10(2^(-53)) (約 15.95 ~ 16 ) の範囲となります. 基底2の場合,上位桁数は 53です.

expectedがcomputedに等しい場合, d は最大値,すなわちdmax,に 設定されます. そうでない場合,expectedがゼロでcomputedがゼロでない場合, d はその最小値,すなわち dmin=0に設定されます.

相対誤差は予測値に基づいているため, computedとexpectedの値は交換できません.

計算は値の実部と虚部に分割されます. 桁数の戻り値は,実部と虚部の桁数の最小値です.

TODO : assert_digits ( computed , expected , dmin ) 関数の中で computedigitsを使用

TODO : 比較 "matrix" (現在は "element")のためのcomptypeオプションを追加

d = assert_computedigits ( 1 , 1 ) // d ~ 16
d = assert_computedigits ( 1 , 1 , 2 ) // d = 53
d = assert_computedigits ( 0 , 0 ) // d ~ 16
d = assert_computedigits ( 1 , 0 ) // d = 0
d = assert_computedigits ( 0 , 1 ) // d = 0
d = assert_computedigits ( 3.1415926 , %pi ) // d ~ 8
d = assert_computedigits ( 3.1415926 , %pi , 2 ) // d ~ 26
d = assert_computedigits ( [0 0 1 1] , [0 1 0 1] ) // d ~ [16 0 0 16]
d = assert_computedigits(ones(3,2),ones(3,2)) // d ~ 16 * ones(3,2)
d = assert_computedigits(1.224646799D-16,8.462643383D-18) // d = 0
// IEEE値を確認
// d ~ [16 0 0 0]
d = assert_computedigits([%nan %nan %nan %nan],[%nan %inf -%inf 0])
// d ~ [0 16 0 0]
d = assert_computedigits([%inf %inf %inf %inf],[%nan %inf -%inf 0])
// d = [0 0 16 0]
d = assert_computedigits([-%inf -%inf -%inf -%inf],[%nan %inf -%inf 0])
// d = [0 0 0 16]
d = assert_computedigits([0 0 0 0],[%nan %inf -%inf 0])
// 複素数を確認
d = assert_computedigits ( 1.2345 + %i*6.7891 , 1.23456789 + %i*6.789123456 ) // d ~ 4

履歴

バージョン記述
5.4.0 関数が導入されました
Report an issue
<< assert_comparecomplex Assert assert_cond2reltol >>

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:
Thu Feb 14 15:02:37 CET 2019