JP2004164417A - Method and apparatus for logarithmic calculation - Google Patents

Method and apparatus for logarithmic calculation Download PDF

Info

Publication number
JP2004164417A
JP2004164417A JP2002331038A JP2002331038A JP2004164417A JP 2004164417 A JP2004164417 A JP 2004164417A JP 2002331038 A JP2002331038 A JP 2002331038A JP 2002331038 A JP2002331038 A JP 2002331038A JP 2004164417 A JP2004164417 A JP 2004164417A
Authority
JP
Japan
Prior art keywords
value
lmin
lstp
range
xstp
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Withdrawn
Application number
JP2002331038A
Other languages
Japanese (ja)
Inventor
Yoshifumi Yamamoto
喜史 山本
Yutaka Awata
豊 粟田
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujitsu Ltd
Original Assignee
Fujitsu Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP2002331038A priority Critical patent/JP2004164417A/en
Publication of JP2004164417A publication Critical patent/JP2004164417A/en
Withdrawn legal-status Critical Current

Links

Images

Landscapes

  • Complex Calculations (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To provide a logarithmic calculation system for efficiently performing logarithmic calculation by a circuit scale or a firmware size smaller than the size of an LSI circuit or DSP firmware adopting a conventional logarithmic calculation system. <P>SOLUTION: A calculated value of a logarithm having an optional base (a) corresponding to an input value X is a value found from a range divided by a lower limit value Lmin and an upper limit value Lmax, all real number values in the range are expressed by (Lmin+n*Lstp) on the basis of a step of step width Lstp obtained by equally dividing the range into n steps and the lower limit value Lmin. The logarithmic calculation system comprises a procedure for comparing the input value X with the data of (xmin*(xstp)<SP>n</SP>) by utilizing that the (Lmin+n*Lstp) is equal to the value of loga(xmin*(xstp)<SP>n</SP>) and calculating the value of (n) corresponding to the input value X and a procedure for finding the calculated value (Lmin+n*Lstp) of the logarithm corresponding to the input value X by using the calculated value (n). <P>COPYRIGHT: (C)2004,JPO

Description

【0001】
【発明の属する技術分野】
本発明は、データ通信システム等において実行される対数演算を演算処理装置やソフトウェアを用いて処理する対数演算処理方式に関する。データ通信における対数演算処理としては、例えば、通信回線の保守、管理、運用パラメータの1つである回線減衰量の算出時に回線送受信端の電力比を対数演算処理するものが挙げられる。本発明は、このような対数演算処理を行う対数演算処理方法および装置に関するものである。
【0002】
【従来の技術】
一般に、対数関数は、0から無限大の入力値Xに対して、その計算値は、負の無限大から正の無限大の値をとりうる。この特性により、ある入力値Xの対数演算値を算出する場合、その値を求める範囲として、下限値Lminと、上限値Lmaxとが定められる。
【0003】
なお、この定めた範囲のすべての値は、この範囲をn等分に区切ったステップ幅Lstpの刻みと、下限値Lminにより、(Lmin+n*Lstp)であらわすことができる。対数値は、下限値以下の値のときはLminに、上限値以上の値のときはLmaxに固定されるものと仮定する。
【0004】
従来からよく知られている対数演算処理方式は、対数演算値をL、入力値をXとして、次式(1)のように定義する。
【0005】
【数1】

Figure 2004164417
上式(1)の常用対数演算は、その処理としてa,bを任意定数とし、その底をa、真数をbとした一般化された対数Log(X)の定義式(2)
【0006】
【数2】
Figure 2004164417
において、a=10、b=eを代入することにより、次式(3)が得られる。
【0007】
【数3】
Figure 2004164417
上式(1)の常用対数演算は、この式(3)に従って演算処理を実行することで得られる。ここで定数Log(10)の値は定数として与えるものとすると、Log10(X)の演算処理としては、Log(X)の値を導出する演算処理と、その算出値をLog(10)の値で割る2つの処理にて構成される。
【0008】
ここで、Log(X)の値を導出する演算処理方式については、従来より級数展開による方式が一般的に知られている。この従来の級数展開による対数演算処理方式は、次式(4)にしたがって演算処理を実行するものである。
【0009】
【数4】
Figure 2004164417
なお、本発明に関連する従来の技術として、特開昭61−72335号公報には、はさみ打ち近似法を利用した対数演算処理方式が示されている。
【0010】
【特許文献1】
特開昭61−72335号公報
【0011】
【発明が解決しようとする課題】
この従来の対数演算処理方式の場合、上式(4)の級数展開による対数演算処理には浮動小数点演算による除算演算が含まれるため、この処理方式を演算処理装置に適用してLSIなどのハードウェアを製作する場合に、除算器と浮動小数点演算処理装置が必要になる。このため、LSIの回路規模が大きくなってしまうという問題があった。
【0012】
上記した問題点は、この従来の対数演算処理方式をソフトウェアで実現する場合においても同様である。図1に、上式(4)の級数展開による対数演算処理をC言語で記述したプログラムコード10を示す。
【0013】
図1のプログラムコード10をDSP(digital signal processor)用ファームウェアとしてコンパイルした場合、浮動小数点演算による除算演算の処理のため、コンパイル後のファームウェアのサイズが非常に大きくなるという問題があった。この問題は、LSI化した演算処理装置においては、LSIの面積の増大、ソフトウェア化した場合においては、DSP用ファームウェアを格納するメモリ容量の増大を招くことになり、コストを増加させるという課題があった。
【0014】
本発明は、上記の点に鑑みてなされたものであり、従来の対数演算処理方式によるLSIの回路やDSP用ファームウェアのサイズよりも小さい回路規模あるいはファームウェアサイズで、効率よく対数演算処理が実行できる対数演算処理方式を提供することを目的とする。
【0015】
【課題を解決するための手段】
上記課題を解決するため、請求項1に記載した発明は、入力値Xに対する任意の底aの対数log(X)の演算値を算出する演算処理方法において、前記演算値は、下限値Lminと上限値Lmaxで区切られた範囲から求まる値で、かつ、前記範囲内の全ての実数値は、前記範囲をn等分して区切られたステップ幅Lstpの刻みと、前記下限値Lminとにより、(Lmin+n*Lstp)により表されるものであり、この(Lmin+n*Lstp)は、底aをLmin乗した任意定数xminと、底aをLstp乗じた任意定数xstpの値をlog(xmin*(xstp))した値に等しいことを利用して、入力値Xと、前記xmin*(xstp)とをデータ比較して入力値Xに該当するnの値を算出する手順と、前記算出した値nを用いて入力値Xに対する底aの対数log(X)の演算値となる(Lmin+n*Lstp)を求める手順とからなることを特徴とする。
【0016】
請求項2に記載した発明は、請求項1記載の対数演算処理方法において、前記データ比較を行う前に、演算値の算出範囲から、あらかじめ選んだ複数の点の値と入力値Xとのデータ比較を行うことにより、演算値の算出範囲を狭め、前記データ比較の比較回数を少なくし、かつ、対数演算の累積誤差を所定の範囲内に収める手順をさらに有することを特徴とする。
【0017】
上記課題を解決するため、請求項3に記載した発明は、入力値Xに対する任意の底aの対数log(X)の演算値を算出する対数演算処理装置において、前記演算値が、ある任意定数の下限値Lminと上限値Lmaxで区切られた範囲から求まる値で、かつ、前記範囲内の全ての実数値が、n等分して区切られるステップ幅Lstpの刻みと、前記下限値Lminとにより、Lmin+n*Lstpにより表すことができるものであり、この演算値をすべてあらわせられるLmin+n*Lstpが、前記底aをLmin乗した任意定数xminと、前記底aをLstp乗じた任意定数xstpの値をlog(xmin*(xstp))した値に等しいことを利用して、入力値Xと、前記xmin*(xstp)とをデータ比較してXに該当するnの値を算出する第1の手段と、前記算出した値nを用いて入力値Xに対する任意の底aの対数log(X)の演算値となる(Lmin+n*Lstp)を求める第2の手段とを有することを特徴とする。
【0018】
請求項4に記載した発明は、請求項3記載の対数演算処理装置において、前記第1の手段が前記データ比較を行う前に、演算値の算出範囲から、あらかじめ選んだ複数の点の値と入力値Xとのデータ比較を行うことにより、演算値の算出範囲を狭め、前記データ比較の比較回数を少なくし、かつ、対数演算の累積誤差を所定の範囲内に収める第3の手段をさらに有することを特徴とする。
【0019】
また、上記課題を解決するため、請求項5に記載した発明は、対数演算処理プログラムが、入力値Xに対する任意の底aの対数log(X)の演算値が、下限値Lminと上限値Lmaxで区切られた範囲から求まる値で、かつ、前記範囲内の全ての実数値は、前記範囲をn等分して区切られるステップ幅Lstpの刻みと、前記下限値Lminとにより、(Lmin+n*Lstp)により表され、この(Lmin+n*Lstp)が、底aをLmin乗した任意定数xminと、前記底aをLstp乗じた任意定数xstpの値をlog(xmin*(xstp))した値に等しいことを利用して、入力値Xと、前記xmin*(xstp)とをデータ比較して入力値Xに該当するnの値を算出する手順と、前記算出した値nを用いて入力値Xに対する任意の底aの対数log(X)の演算値となる(Lmin+n*Lstp)を求める手順とをコンピュータに実行させることを特徴とする。
【0020】
また、上記課題を解決するため、請求項6に記載した発明は、コンピュータ読み取り可能な記録媒体が、入力値Xに対する任意の底aの対数log(X)の演算値が、ある任意定数の下限値Lminと上限値Lmaxで区切られた範囲から求まる値で、かつ、前記範囲内の全ての実数値は、n等分して区切られるステップ幅Lstpの刻みと、前記下限値Lminとにより、Lmin+n*Lstpにより表すことができるものであり、この演算値をすべてあらわせられるLmin+n*Lstpは、前記底aをLmin乗した任意定数xminと、前記底aをLstp乗じた任意定数xstpの値をlog(xmin*(xstp))した値に等しいことを利用して、入力値Xと、前記xmin*(xstp)とをデータ比較してXに該当するnの値を算出する手順と、前記算出した値nを用いて入力値Xに対する任意の底aの対数log(X)の演算値となる(Lmin+n*Lstp)を求める手順とをコンピュータに実行させるための対数演算処理プログラムを記録したことを特徴とする。
【0021】
【発明の実施の形態】
以下、本発明の実施の形態について図面を用いて説明する。
【0022】
従来方式の課題であるLSIの回路規模やファームウェアサイズの増加の問題は、浮動小数点演算による除算演算の処理を含む級数展開による方式を用いていたことが主な原因と考えられる。
【0023】
本発明の対数演算処理方式では、除算を使用しないものとし、使用する演算は、演算器としては比較的小さく構築できる加算、乗算、ビットシフト、データ比較器のみとする(条件1)。また、本発明の対数演算処理方式には、浮動小数点演算を使用しないものとし、浮動小数点演算は、固定小数点演算により代替する(条件2)。
【0024】
以上の条件1及び条件2を満足する対数演算処理方式であれば、従来方式の課題を解決することが可能であり、その結果として、従来方式の場合よりも小さなLSI面積あるいはファームウェアサイズで効率よく対数演算処理を実行することができる。
【0025】
まず、対数演算処理方式について考察を行う。前述の対数演算値Lの仮定から、Lは、その求める範囲の下限値Lminと、この範囲をn等分に区切ったステップ幅Lstpとを用いて、次式(5)のように表すことができる。
【0026】
【数5】
Figure 2004164417
ここで、nは正の整数である。
【0027】
さらに、Lmin、Lstpの対数演算結果を逆算して得られる入力値Xの値をそれぞれXmin、Xstpとすると、
【0028】
【数6】
Figure 2004164417
【0029】
【数7】
Figure 2004164417
が得られる。この式(6)及び式(7)を式(5)に代入すると、次式(8)が得られる。
【0030】
【数8】
Figure 2004164417
上式(8)に式(1)を代入して整理すると、次式(9)が得られる。
【0031】
【数9】
Figure 2004164417
各辺を比較すれば、次式(10)の関係が得られる。
【0032】
【数10】
Figure 2004164417
図2は、上式(10)の関係をまとめたものであり、本発明の対数演算処理方式の基本原理を説明するための図である。
【0033】
図2から明らかなように、一定のステップ幅Lstpでn等分された範囲のすべての値を、その下限値Lminにステップ幅をn回加算した値(Lmin+n*Lstp)で表すことができる。
【0034】
対数演算の計算値Lは、下限値の対数演算の逆算から得られる値Xminに、ステップ幅の対数演算の逆数から得られる値Xstpをn回累乗した値の掛け算(Xmin*(Xstp))の対数をとったものに等しいことがわかる。よって、入力データXの対数演算結果は、Xと(Xmin*(Xstp))とのデータ比較によって、上式(10)を満たすnの値を算出して、この算出したnについて(Lmin+n*Lstp)を算出したものであることがわかる。
【0035】
以上の対数演算処理は、加算、乗算、データ比較のみで構成することができ、除算を含んでいないため、前述の条件1を満足するものと言うことができる。
【0036】
次に、本発明の対数演算処理方式の具体的な処理手順について、図3を用いて説明する。図3は、本発明の一実施形態に係る対数演算処理方法を実行するための演算処理シーケンスを説明するためのフロー図である。
【0037】
図3に示したように、この実施形態の演算処理シーケンスが開始されると、まずステップS10において、内部変数の定義を行う。具体的には、入力データXを内部変数へ受け渡す内部テンポラリ変数xinの定義と入力データXの代入、(xmin*(xstp))の値を一時的に保存する変数xrefの定義、対数演算値を格納する変数Lの定義、及び下限値を表す定数Lmin(i)の設定を行う。
【0038】
次に、ステップS20において、最大n回必要となる、入力データXと(xmin*(xstp))とのデータ比較の回数を減らすために、予め選んだ複数の点の(xmin*(xstp))の値と入力データXとのデータ比較を荒く行い、その比較結果から入力データXの該当範囲を限定する(ステップS21)。入力データXの該当範囲が限定された後、限定範囲に応じた初期値を変数xrefおよび変数Lに代入する(ステップS22)。
【0039】
次に、ステップS30において対数演算処理を行う。上式(10)を満たす条件xref>=xinが真となるまで、対数演算処理を繰り返し実行するループ(ステップS31−S34)によって、変数xrefにxstpをループ回数n回乗算し、変数LにLstpをn回加算する。
【0040】
ステップS30が完了すると、ステップS40において、ループの繰り返しによって得られる演算データXの対数演算の計算値L=(Lmin+n*Lstp)を出力して、図3の演算処理シーケンスが終了する。
【0041】
この実施形態の対数演算処理方法では、以上のような処理手順で、対数演算値Lを算出するため演算処理が行われるが、式(1)の対数演算値Lの定義からわかるように、この実施形態では、底を10とした常用対数に10を掛けた演算処理を行うのみである。
【0042】
しかしながら、本発明の対数演算処理方式には、式(2)に示された一般化された対数Log(X)の演算処理についても、上述の式を次のように修正することで適用することが可能となる。
【0043】
すなわち、対数演算結果を次式(11)のように定義する。
【0044】
【数11】
Figure 2004164417
この式(11)を式(1)に代入すると,次式(12)が得られる。
【0045】
【数12】
Figure 2004164417
式(1)は、底を10とした常用対数の演算処理となる。さらに、Lmin、LstpとXmin、Xstpとの関係式は次のようになる。
【0046】
【数13】
Figure 2004164417
上式(13)のLmin、Lstpをそれぞれ、Ymin、Ystpに置き換えれば、上述の実施形態の対数演算処理方法の適用が可能となる。
【0047】
そして、式(2)で定義される一般化された対数Log(X)については、式(2)のb=10、底aは任意の変数とすると、次式(14)が成り立つ。
【0048】
【数14】
Figure 2004164417
したがって、上述の実施形態の対数演算処理方法を適用した常用対数演算Log10(X)の演算処理が可能であれば、一般化された対数Log(X)の演算処理もできることになる。すなわち、本発明の対数演算処理方式は、一般化された対数Log(X)の演算についても適用可能であることがわかる。
【0049】
次に、上述の条件2として挙げた固定小数点演算について説明する。
【0050】
デジタルシグナルプロセッサ(DSP)では、実数計算を実行する演算法として、浮動小数点演算と固定小数点演算の2つの方法がある。しかし、一般的に、実数計算のDSP用ファームウェアは、固定小数点演算によるものの方が、浮動小数点演算によるものよりも、実行時間が短く、ファームウェアサイズも小さくなる。
【0051】
これは、固定小数点演算は、小数点以下の実数値を、整数値として扱えるためで、その理由は、そのフォーマットとして、kビット長データのなかにqビット目と(q+1)ビット目の間に小数点位置を仮想するためである。実際に、小数点位置を仮想して、小数点以下の実数値をあらわした例を図4に示す。
【0052】
図4には、実数値1.25を16ビットQ8フォーマットに変換した例が示してある。16ビットQ8フォーマットでは、16ビット長のデータの中のビット8とビット7の間に小数点位置を想定して実数値をあらわしている。最上位のビット15は符号ビットであり、符号ビットが0のときは正の実数、符号ビットが1のときは負の実数を表すものと定義する。
【0053】
図4から明らかなように、実数値1.25は、16ビットQ8フォーマットでは整数値320とあらわされ、小数点以下の実数値を整数値として扱うことができることがわかる。
【0054】
また、図4から分かるように、固定小数点演算では、取扱うビットの長さに限りがあるため、1種類のQフォーマットで扱える値の範囲に制限がある。16ビットQ8フォーマットの例では、正の値は63.99609375(=(214−1)*2−8)〜0の範囲であり、負の値は−0.00390625(=−2−8)〜−63.99609375(=−(214−1)*2−8)の範囲に制限される。絶対値は最小で2−8=0.00390625、最大で(214−1)*2−8=63.99609375が扱える値の範囲の制限となる。
【0055】
ここで、最小の絶対値については、この値が小数点以下で扱える精度の最小値となることに注意が必要である。なお、扱える値の最大値を大きくする場合は、仮想小数点位置をLSB側へ、小数点以下の精度を高く取りたい場合には、仮想小数点位置をMSB側へ移動する処理により可能となる。
【0056】
以上に説明したように、本発明の対数演算処理方式によれば、従来の方式の場合より小さなDSP用ファームウェアのサイズで、対数演算処理が実行できる。本発明の対数演算処理方式は、従来の方式よりもDSP搭載のメモリ(RAM)の容量を小さくすることができる。本発明の対数演算処理方式は、固定小数点演算を用い、かつ除算器を使用しないため、演算処理装置などハードウェアに適用した場合、小さな回路規模でのハードウェア化が容易に実現できる。したがって、本発明の対数演算処理方式を用いてLSI化された対数演算処理装置は、除算器は必要としないため、従来のものよりも小さな実装面積で実現でき、その製造コストも削減できる。
【0057】
次に、本発明の対数演算処理方式を適用した演算処理装置の具体的な実施例を図5を用いて説明する。
【0058】
図5は、本発明の一実施形態に係る対数演算処理装置を示す。図5に示した対数演算処理装置は、図3の処理シーケンスにしたがって構成されている。
【0059】
図5の対数演算処理装置において、入力データXは、入力ポート10より入力データ格納レジスタ11(xin)に格納され、このxinは、xin(入力データX)の該当範囲を限定するため、定数格納レジスタ15よりロードされる内部変数xrefの初期値とデータ比較器12においてデータ比較され、xin<xrefが真となるまで、データ比較を繰返し実行する。この比較回数は、比較回数値格納レジスタ12−1に格納されたカウンタ値iにより示され、データ比較を実行するごとに1インクリメントされる。定数格納レジスタ15よりロードされる内部変数xrefの値は範囲限定用変数格納レジスタ16にも格納される。
【0060】
内部変数xrefは、8ビット左シフタ14により8ビット左シフトされる。xin<xrefが真となると、データ比較は完了する。この完了は、データ比較器12から出力される比較完了信号により、定数格納レジスタ15に通知される。定数格納レジスタ15は、比較完了信号を受取ると、そのときのカウンタ値iの値により選ばれる内部変数xrefの初期値xmin[i]及び変数Lの初期値Lmin[i]をそれぞれ、対数演算処理に用いられる、xmin*(xstp)変数格納レジスタ18及び対数演算値格納レジスタ17(L)に書き込む。
【0061】
また、データ比較器12から出力される比較完了信号は、データ比較器13にも通知される。データ比較器13は、比較完了信号を受取ると、入力データ格納レジスタ11(xin)の値と、定数格納レジスタ15よりロードされたxmin*(xstp)変数格納レジスタ18の値とのデータ比較を開始する。このデータ比較器13も、先のデータ比較器12と同様に、xin>=xrefが真となるまで、データ比較を繰返し実行する。
【0062】
この比較回数は、比較回数値格納レジスタ13−1に格納されたカウンタ値nにより示され、データ比較を実行するごとに1インクリメントされる。同時に、xmin*(xstp)変数格納レジスタ18の値には、乗算器19によりxstpが乗算され、対数演算値レジスタLの値には、加算器20によりLstpが加算される。
【0063】
xin>=xrefが真となると、データ比較は完了する。この完了は、データ比較器13から出力される比較完了信号を用いて、対数演算値格納レジスタ17、乗算器19および加算器20にそれぞれ通知される。そして、対数演算値格納レジスタ17は、対数演算処理値Lを出力ポート30に出力して、対数演算処理装置はすべての演算処理を終了する。
【0064】
次に、本発明の対数演算処理方式を適用したコンピュータプログラムについて図6を用いて具体的に説明する。図6に示した対数演算処理プログラム100は、図3の処理シーケンスにしたがって構成されている。
【0065】
図6の対数演算処理プログラム100において、入力データXは、関数Log10(X)の引数として、内部変数xinに格納され、この変数xinは、xinの該当範囲を限定するため、ステップS21において、内部変数xrefの初期値とデータ比較され、xin<xrefが真となるまでデータ比較を繰返す。この比較回数は内部変数iにより示され、データ比較を実行するごとに1インクリメントされ、内部変数xrefは8ビット左シフトされる。
【0066】
xin<xrefが真となると、ステップS21は終了し、ステップS22へ移行する。ステップS22においては、ステップS21で確定した内部変数iの値により、内部変数xrefの初期値xmin[i]および変数Lの初期値Lmin[i]を決定する。
【0067】
このステップS22で決定した変数xrefおよび変数Lを用いて、ステップS30の対数演算処理を行う。ステップS30においては、入力データxinと内部変数xrefとのデータ比較をxin>=xrefが真となるまで繰返し実行し、先のデータ比較と同様に、この比較回数を示す変数nは比較ごとに1インクリメントされる。同時に、変数xmin*(xstp)=xrefにxstpを乗算し、対数演算値格納レジスタL=Lmin+n*LstpにLstpが加算される。
【0068】
xin>=xrefが真となると、ステップS30は終了し、関数Log10の返却値として、対数演算処理値である変数Lの値を返して全ての対数演算処理を終了する。
【0069】
(付記1)
入力値Xに対する任意の底aの対数log(X)の演算値を算出する演算処理方法において、前記演算値は、下限値Lminと上限値Lmaxで区切られた範囲から求まる値で、かつ、前記範囲内の全ての実数値は、前記範囲をn等分して区切られたステップ幅Lstpの刻みと、前記下限値Lminとにより、(Lmin+n*Lstp)により表されるものであり、この(Lmin+n*Lstp)は、底aをLmin乗した任意定数xminと、底aをLstp乗じた任意定数xstpの値をlog(xmin*(xstp))した値に等しいことを利用して、入力値Xと、前記xmin*(xstp)とをデータ比較して入力値Xに該当するnの値を算出する手順と、前記算出した値nを用いて入力値Xに対する底aの対数log(X)の演算値となる(Lmin+n*Lstp)を求める手順とからなることを特徴とする対数演算処理方法。
【0070】
(付記2)
前記データ比較を行う前に、演算値の算出範囲から、あらかじめ選んだ複数の点の値と入力値Xとのデータ比較を行うことにより、演算値の算出範囲を狭め、前記データ比較の比較回数を少なくし、かつ、対数演算の累積誤差を所定の範囲内に収める手順をさらに有することを特徴とする付記1記載の対数演算処理方法。
【0071】
(付記3)
入力値Xに対する任意の底aの対数log(X)の演算値を算出する対数演算処理装置において、前記演算値が、ある任意定数の下限値Lminと上限値Lmaxで区切られた範囲から求まる値で、かつ、前記範囲内の全ての実数値が、n等分して区切られるステップ幅Lstpの刻みと、前記下限値Lminとにより、Lmin+n*Lstpにより表すことができるものであり、この演算値をすべてあらわせられるLmin+n*Lstpが、前記底aをLmin乗した任意定数xminと、前記底aをLstp乗じた任意定数xstpの値をlog(xmin*(xstp))した値に等しいことを利用して、入力値Xと、前記xmin*(xstp)とをデータ比較してXに該当するnの値を算出する第1の手段と、前記算出した値nを用いて入力値Xに対する任意の底aの対数log(X)の演算値となる(Lmin+n*Lstp)を求める第2の手段とを有することを特徴とする対数演算処理装置。
【0072】
(付記4)
前記第1の手段が前記データ比較を行う前に、演算値の算出範囲から、あらかじめ選んだ複数の点の値と入力値Xとのデータ比較を行うことにより、演算値の算出範囲を狭め、前記データ比較の比較回数を少なくし、かつ、対数演算の累積誤差を所定の範囲内に収める第3の手段をさらに有することを特徴とする付記3記載の対数演算処理装置。
【0073】
(付記5)
入力値Xに対する任意の底aの対数log(X)の演算値が、下限値Lminと上限値Lmaxで区切られた範囲から求まる値で、かつ、前記範囲内の全ての実数値は、前記範囲をn等分して区切られるステップ幅Lstpの刻みと、前記下限値Lminとにより、(Lmin+n*Lstp)により表され、この(Lmin+n*Lstp)が、底aをLmin乗した任意定数xminと、前記底aをLstp乗じた任意定数xstpの値をlog(xmin*(xstp))した値に等しいことを利用して、入力値Xと、前記xmin*(xstp)とをデータ比較して入力値Xに該当するnの値を算出する手順と、前記算出した値nを用いて入力値Xに対する任意の底aの対数log(X)の演算値となる(Lmin+n*Lstp)を求める手順とをコンピュータに実行させるための対数演算処理プログラム。
【0074】
(付記6)
入力値Xに対する任意の底aの対数log(X)の演算値が、ある任意定数の下限値Lminと上限値Lmaxで区切られた範囲から求まる値で、かつ、前記範囲内の全ての実数値は、n等分して区切られるステップ幅Lstpの刻みと、前記下限値Lminとにより、Lmin+n*Lstpにより表すことができるものであり、この演算値をすべてあらわせられるLmin+n*Lstpは、前記底aをLmin乗した任意定数xminと、前記底aをLstp乗じた任意定数xstpの値をlog(xmin*(xstp))した値に等しいことを利用して、入力値Xと、前記xmin*(xstp)とをデータ比較してXに該当するnの値を算出する手順と、前記算出した値nを用いて入力値Xに対する任意の底aの対数log(X)の演算値となる(Lmin+n*Lstp)を求める手順とをコンピュータに実行させるための対数演算処理プログラムを記録したコンピュータ読み取り可能な記録媒体。
【0075】
(付記7)
前記対数演算処理プログラムが、前記データ比較を行う前に、演算値の算出範囲から、あらかじめ選んだ複数の点の値と入力値Xとのデータ比較を行うことにより、演算値の算出範囲を狭め、前記データ比較の比較回数を少なくし、かつ、対数演算の累積誤差を所定の範囲内に収める手順をさらに有することを特徴とする付記5記載の対数演算処理プログラム。
【0076】
(付記8)
前記対数演算処理プログラムが、前記データ比較を行う前に、演算値の算出範囲から、あらかじめ選んだ複数の点の値と入力値Xとのデータ比較を行うことにより、演算値の算出範囲を狭め、前記データ比較の比較回数を少なくし、かつ、対数演算の累積誤差を所定の範囲内に収める手順をさらに有することを特徴とする付記6記載のコンピュータ読み取り可能な記録媒体。
【0077】
【発明の効果】
以上説明したように、本発明の対数演算処理方式によれば、従来の方式よりもLSIの面積ならびに小さなファームサイズで、対数演算処理を実行できる処理方式ならびに演算処理装置の提供が可能となる。また、本発明の対数演算処理方式では、実行時間短縮のため、処理の中で実行される内部変数と演算データとのデータ比較の回数を少なくする手段、ならびに処理の中で計算結果の切上げを行うために生じる誤差を要求精度内に収める手段の提供も可能としている。また、本発明の対数演算処理方式を用いることで、コストの低減および処理時間の短縮に寄与することができる。
【0078】
【図面の簡単な説明】
【図1】従来の級数展開による対数演算処理方式を説明するための図である。
【図2】本発明の対数演算処理方式の基本原理を説明するための図である。
【図3】本発明の一実施形態に係る対数演算処理方法を実行するための演算処理シーケンスを説明するためのフロー図である。
【図4】実数値の16ビットQ8フォーマットへの変換方法を説明するための図である。
【図5】本発明の一実施形態に係る対数演算処理装置を示すブロック図である。
【図6】本発明の対数演算処理方式を適用したコンピュータプログラムの一例を示す図である。
【符号の説明】
10 入力ポート
11 入力データ格納レジスタ
12 データ比較器1
13 データ比較器2
14 8ビット左シフタ
15 定数格納レジスタ
16 範囲限定用変数格納レジスタ
17 対数演算値格納レジスタ
18 変数格納レジスタ
19 乗算器
20 加算器
30 出力ポート[0001]
TECHNICAL FIELD OF THE INVENTION
The present invention relates to a logarithmic operation processing method for processing a logarithmic operation performed in a data communication system or the like using an arithmetic processing unit or software. As a logarithmic calculation process in data communication, for example, there is a logarithmic calculation process of a power ratio of a line transmitting / receiving end when calculating a line attenuation amount which is one of maintenance, management, and operation parameters of a communication line. The present invention relates to a logarithmic calculation processing method and apparatus for performing such logarithmic calculation processing.
[0002]
[Prior art]
In general, a logarithmic function can take a value from negative infinity to positive infinity for an input value X from 0 to infinity. When a logarithmic operation value of a certain input value X is calculated by this characteristic, a lower limit value Lmin and an upper limit value Lmax are determined as a range for obtaining the value.
[0003]
It should be noted that all the values in this defined range can be expressed as (Lmin + n * Lstp) by the step width Lstp in which the range is divided into n equal parts and the lower limit Lmin. It is assumed that the logarithmic value is fixed to Lmin when the value is equal to or less than the lower limit, and is fixed to Lmax when the value is equal to or more than the upper limit.
[0004]
A conventionally well-known logarithmic calculation processing method defines a logarithmic calculation value as L and an input value as X as in the following equation (1).
[0005]
(Equation 1)
Figure 2004164417
In the common logarithm operation of the above equation (1), a generalized logarithm Log in which a and b are arbitrary constants, the base is a, and the antilog is b is used as the processing. a Definition formula (2) for (X)
[0006]
(Equation 2)
Figure 2004164417
In the above, by substituting a = 10 and b = e, the following equation (3) is obtained.
[0007]
[Equation 3]
Figure 2004164417
The common logarithmic operation of the above equation (1) is obtained by executing the arithmetic processing according to the equation (3). Here, assuming that the value of the constant Log (10) is given as a constant, 10 The calculation process of (X) includes two processes of deriving the value of Log (X) and dividing the calculated value by the value of Log (10).
[0008]
Here, as an arithmetic processing method for deriving the value of Log (X), a method based on series expansion has been generally known from the past. In the conventional logarithmic operation processing method based on series expansion, operation processing is performed according to the following equation (4).
[0009]
(Equation 4)
Figure 2004164417
As a conventional technique related to the present invention, Japanese Patent Application Laid-Open No. 61-72335 discloses a logarithmic calculation processing method using a scissoring approximation method.
[0010]
[Patent Document 1]
JP-A-61-72335
[0011]
[Problems to be solved by the invention]
In the case of this conventional logarithmic arithmetic processing method, the logarithmic arithmetic processing by the series expansion of the above equation (4) includes a division operation by a floating-point arithmetic operation. When producing ware, a divider and a floating-point processing unit are required. For this reason, there is a problem that the circuit scale of the LSI becomes large.
[0012]
The above-described problem is the same when the conventional logarithmic calculation processing method is realized by software. FIG. 1 shows a program code 10 in which a logarithmic calculation process by series expansion of the above equation (4) is described in C language.
[0013]
When the program code 10 of FIG. 1 is compiled as firmware for a digital signal processor (DSP), there is a problem that the size of the firmware after compilation becomes very large due to the processing of the division operation by the floating-point operation. This problem leads to an increase in the area of the LSI in an arithmetic processing device in the form of an LSI, and an increase in the memory capacity for storing DSP firmware in the case of a software implementation, resulting in an increase in cost. Was.
[0014]
The present invention has been made in view of the above points, and it is possible to efficiently execute logarithmic calculation processing with a circuit size or firmware size smaller than the size of an LSI circuit or DSP firmware using a conventional logarithmic calculation processing method. An object of the present invention is to provide a logarithmic operation processing method.
[0015]
[Means for Solving the Problems]
In order to solve the above-mentioned problem, the invention described in claim 1 is based on a logarithm log of an arbitrary base a with respect to an input value X. a (X) In the calculation processing method for calculating the calculation value, the calculation value is a value obtained from a range divided by a lower limit Lmin and an upper limit Lmax, and all real values in the range are in the range. Is represented by (Lmin + n * Lstp) by the step of the step width Lstp divided into n equal parts and the lower limit Lmin, and (Lmin + n * Lstp) is obtained by raising the base a to the Lmin. Log the value of the arbitrary constant xstp obtained by multiplying the arbitrary constant xmin and the base a by Lstp. a (Xmin * (xstp) n ), The input value X and xmin * (xstp) n Calculating the value of n corresponding to the input value X by comparing the data with the data, and the logarithm logarithm of the base a with respect to the input value X using the calculated value n. a Calculating (Lmin + n * Lstp) as the operation value of (X).
[0016]
According to a second aspect of the present invention, in the logarithmic arithmetic processing method according to the first aspect, before performing the data comparison, the data of a plurality of points selected in advance from the calculation range of the operation value and the input value X are calculated. The method further includes a procedure of narrowing the calculation range of the operation value by performing the comparison, reducing the number of times of the data comparison, and keeping the accumulated error of the logarithmic operation within a predetermined range.
[0017]
In order to solve the above-mentioned problem, the invention described in claim 3 is based on a logarithm log of an arbitrary base a with respect to an input value X. a In the logarithmic calculation processing device for calculating the calculation value of (X), the calculation value is a value obtained from a range defined by a lower limit value Lmin and an upper limit value Lmax of a certain constant, and all real values within the range are obtained. The numerical value can be represented by Lmin + n * Lstp by the step of the step width Lstp divided into n equal parts and the lower limit Lmin, and the calculated value Lmin + n * Lstp is represented by the base The value of an arbitrary constant xmin obtained by multiplying a by Lmin and an arbitrary constant xstp obtained by multiplying the base a by Lstp is log. a (Xmin * (xstp) n ), The input value X and xmin * (xstp) n Means for calculating the value of n corresponding to X by comparing the data with the data, and the logarithm log of an arbitrary base a with respect to the input value X using the calculated value n. a A second means for calculating (Lmin + n * Lstp) which is an operation value of (X).
[0018]
According to a fourth aspect of the present invention, in the logarithmic arithmetic processing device according to the third aspect, before the first means performs the data comparison, a value of a plurality of points selected in advance from a calculation range of a calculation value is calculated. By performing data comparison with the input value X, a third means for narrowing the calculation range of the operation value, reducing the number of times of the data comparison, and keeping the cumulative error of the logarithmic operation within a predetermined range is further provided. It is characterized by having.
[0019]
In order to solve the above-mentioned problem, the invention according to claim 5 is a computer program, wherein the logarithmic calculation processing program executes the logarithm log of an arbitrary base a with respect to the input value X. a The calculated value of (X) is a value obtained from a range defined by a lower limit Lmin and an upper limit Lmax, and all the real values in the range are divided into n steps by the step width Lstp. Is expressed by (Lmin + n * Lstp), and the lower limit Lmin is represented by (Lmin + n * Lstp). This (Lmin + n * Lstp) is an arbitrary constant xmin obtained by multiplying the base a by Lmin and an arbitrary constant xstp obtained by multiplying the base a by Lstp. Log value a (Xmin * (xstp) n ), The input value X and xmin * (xstp) n Calculating the value of n corresponding to the input value X by comparing the data with the data, and the logarithm log of an arbitrary base a with respect to the input value X using the calculated value n. a And (C) obtaining a calculated value of (X) (Lmin + n * Lstp).
[0020]
According to another aspect of the present invention, a computer-readable recording medium stores a logarithm log of an arbitrary base a with respect to an input value X. a The calculated value of (X) is a value obtained from a range defined by a lower limit Lmin and an upper limit Lmax of a given constant, and all real values within the range are divided into n equal step widths. Lmin + n * Lstp can be expressed by the increment of Lstp and the lower limit Lmin, and Lmin + n * Lstp which can express all the calculated values is an arbitrary constant xmin obtained by raising the base a to the Lmin, and the base The value of an arbitrary constant xstp obtained by multiplying a by Lstp is log a (Xmin * (xstp) n ), The input value X and xmin * (xstp) n Calculating the value of n corresponding to X by comparing the data with the data, and the logarithm log of an arbitrary base a with respect to the input value X using the calculated value n. a A logarithmic calculation processing program for causing a computer to execute a procedure for obtaining (Lmin + n * Lstp) as a calculation value of (X) is recorded.
[0021]
BEST MODE FOR CARRYING OUT THE INVENTION
Hereinafter, embodiments of the present invention will be described with reference to the drawings.
[0022]
The problem of the increase in the circuit size and firmware size of the LSI, which is a problem of the conventional method, is considered to be mainly due to the use of a series expansion method including a division operation by a floating-point operation.
[0023]
In the logarithmic arithmetic processing method of the present invention, division is not used, and only arithmetic, which can be constructed relatively small, is addition, multiplication, bit shift, and a data comparator (condition 1). In the logarithmic operation processing method of the present invention, no floating-point operation is used, and the floating-point operation is replaced by a fixed-point operation (condition 2).
[0024]
If the logarithmic calculation processing method satisfies the above conditions 1 and 2, it is possible to solve the problem of the conventional method, and as a result, it is possible to efficiently use a smaller LSI area or a smaller firmware size than the conventional method. Logarithmic calculation processing can be performed.
[0025]
First, a logarithmic calculation processing method will be considered. Based on the above assumption of the logarithmic operation value L, L can be expressed as in the following equation (5) using the lower limit value Lmin of the range to be obtained and the step width Lstp obtained by dividing this range into n equal parts. it can.
[0026]
(Equation 5)
Figure 2004164417
Here, n is a positive integer.
[0027]
Further, assuming that the values of the input values X obtained by back-calculating the logarithm calculation results of Lmin and Lstp are Xmin and Xstp, respectively,
[0028]
(Equation 6)
Figure 2004164417
[0029]
(Equation 7)
Figure 2004164417
Is obtained. By substituting the equations (6) and (7) into the equation (5), the following equation (8) is obtained.
[0030]
(Equation 8)
Figure 2004164417
Substituting equation (1) into equation (8) above and rearranging yields the following equation (9).
[0031]
(Equation 9)
Figure 2004164417
By comparing each side, the following equation (10) is obtained.
[0032]
(Equation 10)
Figure 2004164417
FIG. 2 summarizes the relationship of the above equation (10) and is a diagram for explaining the basic principle of the logarithmic calculation processing method of the present invention.
[0033]
As is clear from FIG. 2, all the values in the range equally divided into n by the fixed step width Lstp can be represented by a value (Lmin + n * Lstp) obtained by adding the step width to the lower limit Lmin n times.
[0034]
The calculated value L of the logarithmic operation is obtained by multiplying the value Xmin obtained from the inverse operation of the logarithmic operation of the lower limit value by the value Xstp obtained from the inverse number of the logarithmic operation of the step width to the nth power (Xmin * (Xstp)). n ). Therefore, the logarithm calculation result of the input data X is X and (Xmin * (Xstp) n )), It can be seen that the value of n that satisfies the above equation (10) was calculated, and (Lmin + n * Lstp) was calculated for this calculated n.
[0035]
The above logarithmic calculation process can be configured only by addition, multiplication, and data comparison, and does not include division. Therefore, it can be said that the above condition 1 is satisfied.
[0036]
Next, a specific processing procedure of the logarithmic calculation processing method of the present invention will be described with reference to FIG. FIG. 3 is a flowchart for explaining an operation processing sequence for executing the logarithmic operation processing method according to an embodiment of the present invention.
[0037]
As shown in FIG. 3, when the operation processing sequence of this embodiment is started, first, in step S10, an internal variable is defined. More specifically, the definition of the internal temporary variable xin that transfers the input data X to the internal variable and the substitution of the input data X, (xmin * (xstp) n ), A variable Lref for storing a logarithm operation value, and a constant Lmin (i) representing a lower limit are set.
[0038]
Next, in step S20, the input data X and (xmin * (xstp) required at most n times n ) In order to reduce the number of data comparisons with (xmin * (xstp) n ) Is roughly compared with the input data X, and the range of the input data X is limited based on the comparison result (step S21). After the corresponding range of the input data X is limited, an initial value corresponding to the limited range is substituted for the variable xref and the variable L (step S22).
[0039]
Next, logarithmic calculation processing is performed in step S30. The variable xref is multiplied by xstp n times and the variable L is multiplied by Lstp by a loop (steps S31 to S34) for repeatedly executing the logarithmic calculation process until the condition xref> = xin that satisfies the expression (10) becomes true. Is added n times.
[0040]
When step S30 is completed, in step S40, the calculated value L = (Lmin + n * Lstp) of the logarithmic calculation of the calculation data X obtained by repeating the loop is output, and the calculation processing sequence in FIG. 3 ends.
[0041]
In the logarithmic calculation processing method of this embodiment, the calculation processing is performed to calculate the logarithm calculation value L in the above-described processing procedure. In the embodiment, only the arithmetic processing of multiplying the common logarithm with the base 10 by 10 is performed.
[0042]
However, the logarithmic operation processing method of the present invention includes a generalized logarithmic Log shown in Expression (2). a The calculation processing of (X) can also be applied by modifying the above expression as follows.
[0043]
That is, the logarithmic operation result is defined as in the following equation (11).
[0044]
[Equation 11]
Figure 2004164417
By substituting the equation (11) into the equation (1), the following equation (12) is obtained.
[0045]
(Equation 12)
Figure 2004164417
Equation (1) is a common logarithmic calculation process with a base of 10. Further, the relational expression between Lmin, Lstp and Xmin, Xstp is as follows.
[0046]
(Equation 13)
Figure 2004164417
If Lmin and Lstp in the above equation (13) are replaced with Ymin and Ystp, respectively, the logarithmic calculation processing method of the above-described embodiment can be applied.
[0047]
Then, the generalized logarithm Log defined by the equation (2) a Regarding (X), if b = 10 and base a in the equation (2) are arbitrary variables, the following equation (14) holds.
[0048]
[Equation 14]
Figure 2004164417
Therefore, the common logarithmic operation Log to which the logarithmic operation processing method of the above embodiment is applied. 10 If the arithmetic processing of (X) is possible, generalized logarithmic Log a The calculation processing of (X) can also be performed. That is, the logarithmic operation processing method of the present invention employs a generalized logarithmic Log. a It can be seen that the calculation of (X) is also applicable.
[0049]
Next, the fixed-point operation described as Condition 2 will be described.
[0050]
In a digital signal processor (DSP), there are two methods of executing a real number calculation, a floating point operation and a fixed point operation. However, in general, the DSP firmware for real number calculation has a shorter execution time and a smaller firmware size when using fixed-point arithmetic than when using floating-point arithmetic.
[0051]
This is because the fixed-point operation can treat a real number value below the decimal point as an integer value. The reason is that the format is such that the decimal point is between the q-th bit and the (q + 1) -th bit in the k-bit length data. This is for imagining the position. FIG. 4 shows an example in which a decimal point position is actually imagined and real numbers below the decimal point are represented.
[0052]
FIG. 4 shows an example in which the real value 1.25 is converted into a 16-bit Q8 format. In the 16-bit Q8 format, a real value is represented by assuming a decimal point position between bits 8 and 7 in 16-bit data. The most significant bit 15 is a sign bit. It is defined that a sign bit of 0 represents a positive real number and a sign bit of 1 represents a negative real number.
[0053]
As is clear from FIG. 4, the real value 1.25 is represented as an integer value 320 in the 16-bit Q8 format, and it can be seen that a real value below the decimal point can be treated as an integer value.
[0054]
In addition, as can be seen from FIG. 4, in fixed-point arithmetic, the length of bits to be handled is limited, so that the range of values that can be handled by one type of Q format is limited. In the example of the 16-bit Q8 format, a positive value is 63.9609375 (= (2 14 -1) * 2 -8 ) To 0, and a negative value is −0.00390625 (= −2). -8 ) To -63.99609375 (=-(2 14 -1) * 2 -8 ). Absolute value is at least 2 -8 = 0.00390625, at most (2 14 -1) * 2 -8 = 63.9996375 is the range of values that can be handled.
[0055]
Here, it should be noted that the minimum absolute value is the minimum value of precision that can be handled below the decimal point. When the maximum value of the values that can be handled is increased, the virtual decimal point position is shifted to the LSB side, and when the precision after the decimal point is to be increased, the virtual decimal point position is shifted to the MSB side.
[0056]
As described above, according to the logarithmic calculation processing method of the present invention, the logarithmic calculation processing can be executed with a smaller DSP firmware size than in the conventional method. The logarithmic calculation processing method of the present invention can reduce the capacity of a memory (RAM) equipped with a DSP as compared with the conventional method. The logarithmic arithmetic processing method of the present invention uses fixed-point arithmetic and does not use a divider. Therefore, when applied to hardware such as an arithmetic processing device, it is easy to realize hardware with a small circuit scale. Therefore, the logarithmic processing device formed into an LSI by using the logarithmic processing method of the present invention does not require a divider, so that it can be realized with a smaller mounting area than the conventional one, and the manufacturing cost can be reduced.
[0057]
Next, a specific embodiment of an arithmetic processing device to which the logarithmic arithmetic processing method of the present invention is applied will be described with reference to FIG.
[0058]
FIG. 5 shows a logarithmic calculation processing device according to an embodiment of the present invention. The logarithmic operation processing device shown in FIG. 5 is configured according to the processing sequence of FIG.
[0059]
In the logarithmic processing device of FIG. 5, input data X is stored from an input port 10 into an input data storage register 11 (xin). The data is compared in the data comparator 12 with the initial value of the internal variable xref loaded from the register 15, and the data comparison is repeatedly executed until xin <xref becomes true. This comparison count is indicated by the counter value i stored in the comparison count value storage register 12-1, and is incremented by one each time data comparison is performed. The value of the internal variable xref loaded from the constant storage register 15 is also stored in the range limiting variable storage register 16.
[0060]
The internal variable xref is shifted left by 8 bits by the 8-bit left shifter. When xin <xref becomes true, the data comparison is completed. This completion is notified to the constant storage register 15 by a comparison completion signal output from the data comparator 12. Upon receiving the comparison completion signal, the constant storage register 15 performs a logarithmic calculation process on the initial value xmin [i] of the internal variable xref and the initial value Lmin [i] of the variable L selected by the value of the counter value i at that time. Xmin * (xstp) used for n Write to the variable storage register 18 and the logarithm operation value storage register 17 (L).
[0061]
Further, the comparison completion signal output from the data comparator 12 is also notified to the data comparator 13. Upon receiving the comparison completion signal, the data comparator 13 compares the value of the input data storage register 11 (xin) with the value of xmin * (xstp) loaded from the constant storage register 15. n Data comparison with the value of the variable storage register 18 is started. Similarly to the data comparator 12, the data comparator 13 repeatedly executes the data comparison until xin> = xref becomes true.
[0062]
This comparison count is indicated by the counter value n stored in the comparison count value storage register 13-1, and is incremented by one each time data comparison is performed. At the same time, xmin * (xstp) n The value of the variable storage register 18 is multiplied by xstp by the multiplier 19, and the value of the logarithm operation value register L is added by Lstp by the adder 20.
[0063]
When xin> = xref becomes true, the data comparison is completed. This completion is notified to the logarithm operation value storage register 17, the multiplier 19 and the adder 20 using the comparison completion signal output from the data comparator 13. Then, the logarithmic operation value storage register 17 outputs the logarithmic operation processing value L to the output port 30, and the logarithmic operation processing device ends all the arithmetic processing.
[0064]
Next, a computer program to which the logarithmic operation processing method of the present invention is applied will be specifically described with reference to FIG. The logarithmic calculation processing program 100 shown in FIG. 6 is configured according to the processing sequence of FIG.
[0065]
In the logarithmic calculation processing program 100 of FIG. 6, the input data X is a function Log 10 (X) is stored in the internal variable xin as an argument. This variable xin is compared with the initial value of the internal variable xref in step S21 in order to limit the applicable range of xin, and xin <xref becomes true. Repeat the data comparison up to. The number of comparisons is indicated by an internal variable i, and is incremented by one each time data comparison is performed, and the internal variable xref is shifted left by 8 bits.
[0066]
When xin <xref becomes true, step S21 ends and the process moves to step S22. In step S22, the initial value xmin [i] of the internal variable xref and the initial value Lmin [i] of the variable L are determined based on the value of the internal variable i determined in step S21.
[0067]
Using the variable xref and the variable L determined in step S22, the logarithmic calculation process in step S30 is performed. In step S30, the data comparison between the input data xin and the internal variable xref is repeatedly executed until xin >> = xref becomes true. As in the previous data comparison, the variable n indicating the number of comparisons becomes 1 for each comparison. Incremented. At the same time, the variable xmin * (xstp) n = Xref is multiplied by xstp, and Lstp is added to the logarithm operation value storage register L = Lmin + n * Lstp.
[0068]
When xin> = xref becomes true, step S30 ends, and the value of the variable L, which is the logarithmic operation processing value, is returned as the return value of the function Log10, and all logarithmic operation processing ends.
[0069]
(Appendix 1)
Logarithm of arbitrary base a for input value X a (X) In the calculation processing method for calculating the calculation value, the calculation value is a value obtained from a range divided by a lower limit Lmin and an upper limit Lmax, and all real values in the range are in the range. Is represented by (Lmin + n * Lstp) by the step of the step width Lstp divided into n equal parts and the lower limit Lmin, and (Lmin + n * Lstp) is obtained by raising the base a to the Lmin. Log the value of the arbitrary constant xstp obtained by multiplying the arbitrary constant xmin and the base a by Lstp. a (Xmin * (xstp) n ), The input value X and xmin * (xstp) n Calculating the value of n corresponding to the input value X by comparing the data with the data, and the logarithm logarithm of the base a with respect to the input value X using the calculated value n. a Obtaining a calculated value (Lmin + n * Lstp) of (X).
[0070]
(Appendix 2)
Before performing the data comparison, by comparing data of a plurality of points selected in advance from the calculation value calculation range with the input value X, the calculation value calculation range is narrowed, and the number of comparisons of the data comparison is reduced. 2. The logarithmic calculation processing method according to claim 1, further comprising the step of reducing the number of errors and keeping the cumulative error of the logarithmic calculation within a predetermined range.
[0071]
(Appendix 3)
Logarithm of arbitrary base a for input value X a In the logarithmic calculation processing device for calculating the calculation value of (X), the calculation value is a value obtained from a range defined by a lower limit value Lmin and an upper limit value Lmax of a certain constant, and all real values within the range are obtained. The numerical value can be represented by Lmin + n * Lstp by the step of the step width Lstp divided into n equal parts and the lower limit Lmin, and the calculated value Lmin + n * Lstp is represented by the base The value of an arbitrary constant xmin obtained by multiplying a by Lmin and an arbitrary constant xstp obtained by multiplying the base a by Lstp is log. a (Xmin * (xstp) n ), The input value X and xmin * (xstp) n Means for calculating the value of n corresponding to X by comparing the data with the data, and the logarithm log of an arbitrary base a with respect to the input value X using the calculated value n. a A second means for calculating (Lmin + n * Lstp) which is an operation value of (X).
[0072]
(Appendix 4)
Before the first means performs the data comparison, by performing data comparison between the values of a plurality of points selected in advance and the input value X from the calculation value calculation range, the calculation value calculation range is narrowed, The logarithmic calculation processing device according to claim 3, further comprising third means for reducing the number of times of the data comparison and keeping the cumulative error of the logarithmic calculation within a predetermined range.
[0073]
(Appendix 5)
Logarithm of arbitrary base a for input value X a The calculated value of (X) is a value obtained from a range defined by a lower limit Lmin and an upper limit Lmax, and all the real values in the range are divided into n steps by the step width Lstp. Is expressed by (Lmin + n * Lstp), and the lower limit Lmin is represented by (Lmin + n * Lstp). This (Lmin + n * Lstp) is an arbitrary constant xmin obtained by multiplying the base a by Lmin and an arbitrary constant xstp obtained by multiplying the base a by Lstp. Log value a (Xmin * (xstp) n ), The input value X and xmin * (xstp) n Calculating the value of n corresponding to the input value X by comparing the data with the data, and the logarithm log of an arbitrary base a with respect to the input value X using the calculated value n. a Logarithmic calculation processing program for causing a computer to execute (X) a procedure for obtaining (Lmin + n * Lstp) as a calculation value.
[0074]
(Appendix 6)
Logarithm of arbitrary base a for input value X a The calculated value of (X) is a value obtained from a range defined by a lower limit Lmin and an upper limit Lmax of a given constant, and all real values within the range are divided into n equal step widths. Lmin + n * Lstp can be expressed by the increment of Lstp and the lower limit Lmin, and Lmin + n * Lstp which can express all the calculated values is an arbitrary constant xmin obtained by raising the base a to the Lmin, and the base The value of an arbitrary constant xstp obtained by multiplying a by Lstp is log a (Xmin * (xstp) n ), The input value X and xmin * (xstp) n Calculating the value of n corresponding to X by comparing the data with the data, and the logarithm log of an arbitrary base a with respect to the input value X using the calculated value n. a A computer-readable recording medium in which a logarithmic calculation processing program for causing a computer to execute (L) + (Lmin + n * Lstp) as a calculation value of (X) is recorded.
[0075]
(Appendix 7)
The logarithmic calculation processing program narrows down the calculation range of the calculated value by comparing data of a plurality of points selected in advance with the input value X from the calculation range of the calculated value before performing the data comparison. The logarithmic calculation processing program according to claim 5, further comprising a step of reducing the number of times of the data comparison and keeping the cumulative error of the logarithmic calculation within a predetermined range.
[0076]
(Appendix 8)
The logarithmic calculation processing program narrows down the calculation range of the calculated value by comparing data of a plurality of points selected in advance with the input value X from the calculation range of the calculated value before performing the data comparison. 7. The computer-readable recording medium according to claim 6, further comprising a step of reducing the number of times of the data comparison and keeping the cumulative error of the logarithmic operation within a predetermined range.
[0077]
【The invention's effect】
As described above, according to the logarithmic operation processing method of the present invention, it is possible to provide a processing method and an operation processing device capable of executing logarithmic operation processing with an LSI area and a smaller firmware size than the conventional method. Further, in the logarithmic calculation processing method of the present invention, in order to reduce the execution time, means for reducing the number of data comparisons between the internal variables executed in the process and the calculation data, and rounding up the calculation result in the process It is also possible to provide a means for keeping the error generated for performing within required accuracy. Further, by using the logarithmic operation processing method of the present invention, it is possible to contribute to reduction in cost and processing time.
[0078]
[Brief description of the drawings]
FIG. 1 is a diagram for explaining a conventional logarithmic operation processing method by series expansion.
FIG. 2 is a diagram for explaining a basic principle of a logarithmic operation processing method according to the present invention.
FIG. 3 is a flowchart for explaining an arithmetic processing sequence for executing a logarithmic arithmetic processing method according to an embodiment of the present invention.
FIG. 4 is a diagram for explaining a method of converting a real value into a 16-bit Q8 format.
FIG. 5 is a block diagram showing a logarithmic calculation processing device according to an embodiment of the present invention.
FIG. 6 is a diagram illustrating an example of a computer program to which the logarithmic operation processing method of the present invention is applied.
[Explanation of symbols]
10 Input port
11 Input data storage register
12 Data comparator 1
13 Data comparator 2
14 8-bit left shifter
15 Constant storage register
16 Variable storage register for range limitation
17 Logarithm operation value storage register
18 Variable storage register
19 Multiplier
20 adder
30 output port

Claims (6)

入力値Xに対する任意の底aの対数log(X)の演算値を算出する演算処理方法において、
前記演算値は、下限値Lminと上限値Lmaxで区切られた範囲から求まる値で、かつ、前記範囲内の全ての実数値は、前記範囲をn等分して区切られたステップ幅Lstpの刻みと、前記下限値Lminとにより、(Lmin+n*Lstp)により表されるものであり、この(Lmin+n*Lstp)は、底aをLmin乗した任意定数xminと、底aをLstp乗じた任意定数xstpの値をlog(xmin*(xstp))した値に等しいことを利用して、
入力値Xと、前記xmin*(xstp)とをデータ比較して入力値Xに該当するnの値を算出する手順と、
前記算出した値nを用いて入力値Xに対する底aの対数log(X)の演算値となる(Lmin+n*Lstp)を求める手順と
からなることを特徴とする対数演算処理方法。
In an arithmetic processing method for calculating an arithmetic value of a logarithm log a (X) of an arbitrary base a with respect to an input value X,
The calculated value is a value obtained from a range defined by a lower limit Lmin and an upper limit Lmax, and all real values in the range are steps of a step width Lstp obtained by dividing the range into n equal parts. And the lower limit Lmin, represented by (Lmin + n * Lstp), where (Lmin + n * Lstp) is an arbitrary constant xmin obtained by raising the base a to Lmin and an arbitrary constant xstp obtained by multiplying the base a by Lstp. Utilizing the fact that the value of is equal to the value of log a (xmin * (xstp) n ),
Comparing the input value X with the xmin * (xstp) n to calculate the value of n corresponding to the input value X;
Using the calculated value n to calculate (Lmin + n * Lstp) which is the calculated value of the logarithm log a (X) of the base a with respect to the input value X.
前記データ比較を行う前に、演算値の算出範囲から、あらかじめ選んだ複数の点の値と入力値Xとのデータ比較を行うことにより、演算値の算出範囲を狭め、前記データ比較の比較回数を少なくし、かつ、対数演算の累積誤差を所定の範囲内に収める手順をさらに有することを特徴とする請求項1記載の対数演算処理方法。Before performing the data comparison, by comparing data of a plurality of points selected in advance from the calculation value calculation range with the input value X, the calculation value calculation range is narrowed, and the number of comparisons of the data comparison is reduced. 2. The logarithmic calculation processing method according to claim 1, further comprising the step of reducing the number of errors and keeping the cumulative error of the logarithmic calculation within a predetermined range. 入力値Xに対する任意の底aの対数log(X)の演算値を算出する対数演算処理装置において、
前記演算値が、ある任意定数の下限値Lminと上限値Lmaxで区切られた範囲から求まる値で、かつ、前記範囲内の全ての実数値が、n等分して区切られるステップ幅Lstpの刻みと、前記下限値Lminとにより、Lmin+n*Lstpにより表すことができるものであり、この演算値をすべてあらわせられるLmin+n*Lstpが、前記底aをLmin乗した任意定数xminと、前記底aをLstp乗じた任意定数xstpの値をlog(xmin*(xstp))した値に等しいことを利用して、
入力値Xと、前記xmin*(xstp)とをデータ比較してXに該当するnの値を算出する第1の手段と、
前記算出した値nを用いて入力値Xに対する任意の底aの対数log(X)の演算値となる(Lmin+n*Lstp)を求める第2の手段と
を有することを特徴とする対数演算処理装置。
In a logarithmic calculation processing device for calculating a calculation value of a logarithm log a (X) of an arbitrary base a with respect to an input value X,
The calculated value is a value obtained from a range defined by a lower limit Lmin and an upper limit Lmax of an arbitrary constant, and a step width Lstp in which all real values in the range are equally divided into n and separated And the lower limit Lmin, Lmin + n * Lstp can be represented by Lmin + n * Lstp, which can express all the calculated values, and an arbitrary constant xmin obtained by raising the base a to the power of Lmin, and the base a by the Lstp Using the fact that the value of the multiplied arbitrary constant xstp is equal to the value obtained by log a (xmin * (xstp) n ),
First means for comparing the input value X with the xmin * (xstp) n to calculate a value of n corresponding to X;
A second means for calculating (Lmin + n * Lstp) which is an operation value of a logarithm log a (X) of an arbitrary base a with respect to the input value X using the calculated value n. apparatus.
前記第1の手段が前記データ比較を行う前に、演算値の算出範囲から、あらかじめ選んだ複数の点の値と入力値Xとのデータ比較を行うことにより、演算値の算出範囲を狭め、前記データ比較の比較回数を少なくし、かつ、対数演算の累積誤差を所定の範囲内に収める第3の手段をさらに有することを特徴とする請求項3記載の対数演算処理装置。Before the first means performs the data comparison, by performing data comparison between the values of a plurality of points selected in advance and the input value X from the calculation value calculation range, the calculation value calculation range is narrowed, 4. The logarithmic calculation processing device according to claim 3, further comprising third means for reducing the number of times of the data comparison and keeping the cumulative error of the logarithmic calculation within a predetermined range. 入力値Xに対する任意の底aの対数log(X)の演算値が、下限値Lminと上限値Lmaxで区切られた範囲から求まる値で、かつ、前記範囲内の全ての実数値は、前記範囲をn等分して区切られるステップ幅Lstpの刻みと、前記下限値Lminとにより、(Lmin+n*Lstp)により表され、この(Lmin+n*Lstp)が、底aをLmin乗した任意定数xminと、前記底aをLstp乗じた任意定数xstpの値をlog(xmin*(xstp))した値に等しいことを利用して、
入力値Xと、前記xmin*(xstp)とをデータ比較して入力値Xに該当するnの値を算出する手順と、
前記算出した値nを用いて入力値Xに対する任意の底aの対数log(X)の演算値となる(Lmin+n*Lstp)を求める手順と
をコンピュータに実行させるための対数演算処理プログラム。
The calculated value of the logarithm log a (X) of an arbitrary base a with respect to the input value X is a value obtained from a range delimited by a lower limit Lmin and an upper limit Lmax, and all the real values in the range are as described above. The range of the step width Lstp divided by dividing the range into n equal parts and the lower limit Lmin are represented by (Lmin + n * Lstp), where (Lmin + n * Lstp) is an arbitrary constant xmin obtained by raising the base a to the Lmin. By using the fact that the value of an arbitrary constant xstp obtained by multiplying the base a by Lstp is equal to the value of log a (xmin * (xstp) n ),
Comparing the input value X with the xmin * (xstp) n to calculate the value of n corresponding to the input value X;
A step of obtaining (Lmin + n * Lstp) which is an operation value of logarithm log a (X) of an arbitrary base a with respect to an input value X using the calculated value n.
入力値Xに対する任意の底aの対数log(X)の演算値が、ある任意定数の下限値Lminと上限値Lmaxで区切られた範囲から求まる値で、かつ、前記範囲内の全ての実数値は、n等分して区切られるステップ幅Lstpの刻みと、前記下限値Lminとにより、Lmin+n*Lstpにより表すことができるものであり、この演算値をすべてあらわせられるLmin+n*Lstpは、前記底aをLmin乗した任意定数xminと、前記底aをLstp乗じた任意定数xstpの値をlog(xmin*(xstp))した値に等しいことを利用して、
入力値Xと、前記xmin*(xstp)とをデータ比較してXに該当するnの値を算出する手順と、
前記算出した値nを用いて入力値Xに対する任意の底aの対数log(X)の演算値となる(Lmin+n*Lstp)を求める手順と
をコンピュータに実行させるための対数演算処理プログラムを記録したコンピュータ読み取り可能な記録媒体。
The calculated value of the logarithm log a (X) of an arbitrary base a with respect to the input value X is a value obtained from a range defined by a lower limit Lmin and an upper limit Lmax of a certain constant, and all the reals within the range are obtained. The numerical value can be represented by Lmin + n * Lstp by the step of the step width Lstp divided into n equal parts and the lower limit Lmin, and Lmin + n * Lstp which can express all the calculated values is the base value. Utilizing that an arbitrary constant xmin obtained by raising a to the power of Lmin and a value of an arbitrary constant xstp obtained by multiplying the base a by Lstp is equal to log a (xmin * (xstp) n ),
Comparing the input value X with the xmin * (xstp) n to calculate a value of n corresponding to X;
Using the calculated value n to calculate (Lmin + n * Lstp) which is the calculated value of the logarithm log a (X) of an arbitrary base a with respect to the input value X. Computer readable recording medium.
JP2002331038A 2002-11-14 2002-11-14 Method and apparatus for logarithmic calculation Withdrawn JP2004164417A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2002331038A JP2004164417A (en) 2002-11-14 2002-11-14 Method and apparatus for logarithmic calculation

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2002331038A JP2004164417A (en) 2002-11-14 2002-11-14 Method and apparatus for logarithmic calculation

Publications (1)

Publication Number Publication Date
JP2004164417A true JP2004164417A (en) 2004-06-10

Family

ID=32808545

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2002331038A Withdrawn JP2004164417A (en) 2002-11-14 2002-11-14 Method and apparatus for logarithmic calculation

Country Status (1)

Country Link
JP (1) JP2004164417A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8510360B2 (en) 2010-06-04 2013-08-13 International Business Machines Corporation Calculating large precision common logarithms

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8510360B2 (en) 2010-06-04 2013-08-13 International Business Machines Corporation Calculating large precision common logarithms

Similar Documents

Publication Publication Date Title
US8793300B2 (en) Montgomery multiplication circuit
JP7292297B2 (en) probabilistic rounding logic
US7809784B2 (en) Apparatus and method for calculation of divisions and square roots
JP5397061B2 (en) Arithmetic processing device, control method thereof, and arithmetic processing program
JP2502836B2 (en) Preprocessing device for division circuit
JP2004164417A (en) Method and apparatus for logarithmic calculation
JP5175983B2 (en) Arithmetic unit
JP2004005395A (en) Arithmetic processing unit and semiconductor device
US20050246406A9 (en) Emod a fast modulus calculation for computer systems
KR101084581B1 (en) Method and Apparatus for Operating of Fixed-point Exponential Function, and Recording Medium thereof
WO2009017849A1 (en) Method and system for creating fixed-point software code
JP2021114117A (en) Information processing program, information processing method, and information processing device
US20230028953A1 (en) Implementing functions in hardware
JPH0831024B2 (en) Arithmetic processor
JP2021502743A5 (en)
JP3851025B2 (en) Division circuit
Graillat et al. Numerical validation in quadruple precision using stochastic arithmetic
TWI753668B (en) Information processing apparatus, computer program, recording medium and information processing method
CN116127523B (en) Data processing method and device in privacy calculation and electronic equipment
WO2023004799A1 (en) Electronic device and neural network quantization method
WO2021106253A1 (en) Information processing device, program, and information processing method
JP2508286B2 (en) Square root calculator
JPH0721012A (en) Divider
Graillat et al. Compensated horner scheme
CN116822253A (en) Hybrid precision implementation method and system suitable for MANUM sea wave mode

Legal Events

Date Code Title Description
A300 Withdrawal of application because of no request for examination

Free format text: JAPANESE INTERMEDIATE CODE: A300

Effective date: 20060207