JP4359258B2 - Arithmetic apparatus and arithmetic method - Google Patents

Arithmetic apparatus and arithmetic method Download PDF

Info

Publication number
JP4359258B2
JP4359258B2 JP2005126326A JP2005126326A JP4359258B2 JP 4359258 B2 JP4359258 B2 JP 4359258B2 JP 2005126326 A JP2005126326 A JP 2005126326A JP 2005126326 A JP2005126326 A JP 2005126326A JP 4359258 B2 JP4359258 B2 JP 4359258B2
Authority
JP
Japan
Prior art keywords
sum
error
multiplication
follows
variables
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.)
Expired - Fee Related
Application number
JP2005126326A
Other languages
Japanese (ja)
Other versions
JP2006302180A (en
Inventor
秀和 森田
信行 浜口
朗 都倉
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.)
Hitachi Ltd
Original Assignee
Hitachi 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 Hitachi Ltd filed Critical Hitachi Ltd
Priority to JP2005126326A priority Critical patent/JP4359258B2/en
Publication of JP2006302180A publication Critical patent/JP2006302180A/en
Application granted granted Critical
Publication of JP4359258B2 publication Critical patent/JP4359258B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Description

本発明は、浮動小数点を用いた演算を行う演算装置および演算方法に関する。   The present invention relates to a calculation device and a calculation method for performing a calculation using a floating point.

一般に、コンピュータなどの演算装置において、乗算、加算などの演算を行う場合、二進数で表現された数値について、所定の桁の切り捨てあるいは切り上げを行いながら、演算を実行することになる。   In general, when performing arithmetic operations such as multiplication and addition in an arithmetic device such as a computer, arithmetic operations are performed while rounding down or rounding up predetermined digits for numerical values expressed in binary numbers.

たとえば、IEEE(Institute of Electrical and Electronic Engineers)754では、単精度、倍精度という二進浮動小数点形式を規定している。単精度とは、1つの数値を32ビット(符号部1ビット・指数部8ビット・仮数部23ビット)で表現するものであり、倍精度とは、1つの数値を64ビット(符号部1ビット・指数部11ビット・仮数部52ビット)で表現するものである。
そして、これら単精度および倍精度の拡張形式が演算に用いられる場合もある。
For example, IEEE (Institute of Electrical and Electronic Engineers) 754 defines binary floating point formats of single precision and double precision. Single precision expresses one numerical value with 32 bits (sign part 1 bit, exponent part 8 bits, mantissa part 23 bits), and double precision means one numerical value with 64 bits (sign part 1 bit) (Expression part 11 bits, mantissa part 52 bits)
In some cases, these single-precision and double-precision extended formats are used for computation.

このように、IEEE754では浮動小数点形式が規定されているが、これらの浮動小数点数を用いたコンピュータにおける内積演算では、丸め、情報落ち及び桁落ちの誤差が生じるため、正確な内積演算結果が得られない、という問題がある。
そこで、内積演算の精度を改善するものとして、いくつかの装置が提案されている。
As described above, IEEE 754 defines a floating-point format. However, an inner product operation in a computer using these floating-point numbers causes errors in rounding, information loss, and digit loss, so that an accurate inner product operation result can be obtained. There is a problem that it is not possible.
In view of this, several devices have been proposed to improve the accuracy of the inner product calculation.

たとえば、特許文献1では、入力ベクトルxに対し、全てのベクトル成分からスカラー数βを減じた後、スカラー数α倍したα(x-βI)なる変換を施してから内積演算を行う装置が開示されている。   For example, Patent Document 1 discloses an apparatus that performs an inner product operation on an input vector x after subtracting the scalar number β from all vector components and then performing a transformation α (x−βI) multiplied by the scalar number α. Has been.

また、特許文献2では、複数の入力データに対応するビットスライスに基づいて、ルックアップテーブルから該ビットスライスの数値配列に対応する部分内積を検出して出力し、該部分内積を初期値あるいは中間累積値に対して加算して加算出力値を出力し、該加算出力値の下位側切捨てビットの数値を保持し、上記加算処理を入力データの桁数分に対応するサイクルを繰り返して得られる最終累算結果の値に最終加算サイクルから所定サイクル前までの上記切捨てビットの数値を付加することにより、演算精度の劣化を改善する演算装置が開示されている。
特開平11−96140号公報(段落0014〜段落0031、図3) 特開2000−132539号公報(段落0066〜段落0073、図1)
In Patent Document 2, based on bit slices corresponding to a plurality of input data, a partial inner product corresponding to the numerical array of the bit slice is detected and output from a lookup table, and the partial inner product is set to an initial value or an intermediate value. The final value obtained by adding the accumulated value and outputting the added output value, holding the numerical value of the lower-order truncation bit of the added output value, and repeating the above addition process for the number of digits of the input data There is disclosed an arithmetic device that improves the deterioration of the arithmetic accuracy by adding the value of the above-mentioned truncation bit from the last addition cycle to a predetermined cycle before the accumulated result value.
JP-A-11-96140 (paragraphs 0014 to 0031, FIG. 3) JP 2000-132539 A (paragraphs 0066 to 0073, FIG. 1)

しかしながら、特許文献1、特許文献2ではいずれも、ハードウェアによる内積演算の精度改善方式が採用されていて、ハードウェアの設計段階で桁数に制限が設けられるため、IEEE754に準拠している任意の浮動小数点を用いた内積演算において、丸め、情報落ち及び桁落ちの誤差が少なからず生じることがあり、正確な演算結果が得られないという問題点があった。
そこで、本発明は、前記問題点に鑑みてなされたものであり、より正確な浮動小数点を用いた演算を行うことを目的とする。
However, in both Patent Document 1 and Patent Document 2, since the accuracy improvement method of the inner product calculation by hardware is adopted and the number of digits is limited at the hardware design stage, any one conforming to IEEE 754 is arbitrary. In the inner product calculation using the floating point, there is a problem that errors of rounding, information loss and digit loss may occur, and an accurate calculation result cannot be obtained.
Therefore, the present invention has been made in view of the above problems, and an object thereof is to perform a calculation using a more accurate floating point.

前記課題を解決するために、乗算対象である第1の数と第2の数との積の演算を、二進浮動小数点を用いて行う演算装置であって、第1の数、第2の数、および、演算によって発生した数を、所定の桁数より下位の桁のビットを切り捨てることによってあるいは切り上げることによって所定の桁数内の数として記憶する記憶部と、記憶部に記憶された第1の数を、所定の上位数桁である第1の上位数と、残りの下位数桁である第1の下位数と、に分離し、記憶部に記憶された第2の数を、所定の上位数桁である第2の上位数と、残りの下位数桁である第2の下位数と、に分離し、第1の上位数と第2の上位数とを乗算して第1の乗算数とし、第1の上位数と第2の下位数とを乗算して第2の乗算数とし、第1の下位数と第2の上位数とを乗算して第3の乗算数とし、第1の下位数と第2の下位数とを乗算して第4の乗算数とし、第1の乗算数、第2の乗算数、第3の乗算数および第4の乗算数を任意の順番で3回の加算を行うことでその総和を算出するとき、各回における和とは別に各回の誤差それぞれを記憶部に記憶させ、各回の誤差すべてを加算して総誤差を算出し、3回の加算後の和に対して総誤差を加算することで総和を算出するとともに、そのときの誤差である総和誤差も算出する処理部と、を有することを特徴とする。その他の手段については後記する。 In order to solve the above-described problem, an arithmetic unit that performs an operation of a product of a first number and a second number to be multiplied using a binary floating point, the first number, the second number A storage unit that stores the number and the number generated by the operation as a number within a predetermined number of digits by rounding down or rounding up the bits of the digits lower than the predetermined number of digits, and a second number stored in the storage unit The number of 1 is separated into a first upper number that is a predetermined upper number digit and a first lower number that is a remaining lower number digit, and the second number stored in the storage unit is determined as a predetermined number Is divided into a second upper number that is the upper number digits of the second number and a second lower number that is the remaining lower number digits, and the first higher number and the second upper number are multiplied by the first higher number. Multiply the first higher number and the second lower number to obtain the second multiplication number, and multiply the first lower number and the second upper number. The third multiplication number, the first lower number and the second lower number are multiplied to obtain the fourth multiplication number, the first multiplication number, the second multiplication number, the third multiplication number, and the second multiplication number. When calculating the sum by multiplying the number of multiplications of 4 three times in an arbitrary order, the error of each time is stored in the storage unit separately from the sum at each time, and the total error is added to each time. And a processing unit that calculates an error and calculates a total sum by adding the total error to the sum after three additions, and also calculates a total error that is an error at that time. . Other means will be described later.

本発明によれば、より正確な浮動小数点を用いた演算を行うことができる。   According to the present invention, more accurate calculation using a floating point can be performed.

以下、本発明に係るデータ処理装置(演算装置)について、適宜図面を参照しながら説明する。   Hereinafter, a data processing apparatus (arithmetic apparatus) according to the present invention will be described with reference to the drawings as appropriate.

まず、図1を参照しながら、データ処理装置の構成について説明する。図1は、データ処理装置の構成図である。
データ処理装置1は、補助記憶部101、メモリ(記憶部)102、処理部としてのCPU(Central Processing Unit)103、入力部104、出力部105および入出力インタフェース106を備えて構成される。
First, the configuration of the data processing apparatus will be described with reference to FIG. FIG. 1 is a configuration diagram of a data processing apparatus.
The data processing apparatus 1 includes an auxiliary storage unit 101, a memory (storage unit) 102, a CPU (Central Processing Unit) 103 as a processing unit, an input unit 104, an output unit 105, and an input / output interface 106.

補助記憶部101は、各種情報を記憶するものであり、たとえば、ハードディスク、ROM(Read Only Memory)などにより実現される。補助記憶部101は、ここでは、プログラム111、コンパイラ112および実行モジュール113を記憶している。   The auxiliary storage unit 101 stores various types of information, and is realized by, for example, a hard disk, a ROM (Read Only Memory), or the like. Here, the auxiliary storage unit 101 stores a program 111, a compiler 112, and an execution module 113.

プログラム111は、図2で示すフローチャート上の処理が記述されているプログラム(以下、ソースプログラムという)である。
コンパイラ112は、プログラム111をコンパイル・リンクするものである。
実行モジュール113は、コンパイラ112によってコンパイル・リンクされたモジュールである。
The program 111 is a program (hereinafter referred to as a source program) in which processing on the flowchart shown in FIG. 2 is described.
The compiler 112 compiles and links the program 111.
The execution module 113 is a module compiled and linked by the compiler 112.

メモリ102は、各種情報を記憶する一時記憶手段であり、たとえば、RAM(Random Access Memory)により実現される。
CPU103は、各種演算処理を行うものであり、メモリ102、入出力インタフェース106を介して実行モジュール113を実行する役割を果たす。
入力部104は、各種実行コマンドなどを入力する入力装置である。
出力部105は、各種実行結果などを出力する出力装置である。
入出力インタフェース106は、図1に示すように、各構成間の入出力のインタフェースの役割を果たすものである。
The memory 102 is temporary storage means for storing various information, and is realized by, for example, a RAM (Random Access Memory).
The CPU 103 performs various arithmetic processes and plays a role of executing the execution module 113 via the memory 102 and the input / output interface 106.
The input unit 104 is an input device for inputting various execution commands.
The output unit 105 is an output device that outputs various execution results.
As shown in FIG. 1, the input / output interface 106 serves as an input / output interface between the components.

そして、前記のように構成されるデータ処理装置1は、次のように動作する。
まず、操作者により入力部104から入力されたコンパイルコマンドは、入出力インタフェース106を介して、メモリ102にストアされる。メモリ102では、補助記憶部101のプログラム111が、コンパイラ112によってコンパイル・リンクされ、機械語コードである実行モジュール113が生成される。
The data processing apparatus 1 configured as described above operates as follows.
First, a compile command input from the input unit 104 by the operator is stored in the memory 102 via the input / output interface 106. In the memory 102, the program 111 in the auxiliary storage unit 101 is compiled and linked by the compiler 112, and an execution module 113 that is a machine language code is generated.

次に、操作者により入力部104から実行コマンドが入力されると、CPU103がメモリ102に実行モジュール113をロードする。実行モジュール113がメモリ102にロードされると、CPU103によって、図2に示すフローチャート上の各処理S201〜S208がメモリ102からCPU103に逐次呼び出され、各処理が実行された後、その実行結果がメモリ102にストアされる。
メモリ102にストアされた実行結果は、CPU103によって、入出力インターフェイス106を介して、出力部105に出力される。
Next, when an execution command is input from the input unit 104 by the operator, the CPU 103 loads the execution module 113 into the memory 102. When the execution module 113 is loaded into the memory 102, each process S201 to S208 in the flowchart shown in FIG. 2 is sequentially called from the memory 102 to the CPU 103 by the CPU 103, and each process is executed. 102.
The execution result stored in the memory 102 is output to the output unit 105 by the CPU 103 via the input / output interface 106.

続いて、図2を参照しながら、データ処理装置の処理について説明する(適宜図1参照)。図2は、データ処理装置の全体的な処理を示したフローチャートである。ここでは、i=N次元での内積演算のベクトルA(i)、B(i)の精度改善を行う場合を例にして説明する。   Subsequently, the processing of the data processing apparatus will be described with reference to FIG. 2 (see FIG. 1 as appropriate). FIG. 2 is a flowchart showing the overall processing of the data processing apparatus. Here, the case where the accuracy of the vectors A (i) and B (i) of the inner product calculation in i = N dimensions is improved will be described as an example.

まず、入力処理S201が、メモリ102からCPU103に呼び出される。この入力処理S201では、図3に示すように、CPU103が、S301からS303までの処理を繰り返し、操作者により入力部104から入力されたi=N次元のデータ、すなわち、A(i)、B(i)を、メモリ102にロードさせる。   First, the input process S201 is called from the memory 102 to the CPU 103. In this input process S201, as shown in FIG. 3, the CPU 103 repeats the processes from S301 to S303, and i = N-dimensional data input from the input unit 104 by the operator, that is, A (i), B (I) is loaded into the memory 102.

図2に戻って、次に、初期化処理S202がメモリ102からCPU103に呼び出される。この初期化処理S202では、図4に示すように、S401において、CPU103が、変数であるSUMおよびDSUMの領域をメモリ102上に確保し、SUMおよびDSUMの値をそれぞれ0に初期化する。   Returning to FIG. 2, next, the initialization process S <b> 202 is called from the memory 102 to the CPU 103. In this initialization process S202, as shown in FIG. 4, in S401, the CPU 103 secures the SUM and DSUM areas as variables on the memory 102, and initializes the SUM and DSUM values to 0, respectively.

SUMは、最終的な誤差の補正がされていない和を代入する変数であり、DSUMは、誤差の補正部分を代入する変数である。
このようなSUM、DSUMを用いることにより、データ処理装置1において数値の乗算や加算などの演算を行う場合、次のような効果がある。すなわち、メモリ102やCPU103が記憶(保持)できる桁数が決まっているので、それによる数値のずれを誤差として記憶し、その後の演算においてもその誤差を使用することで、演算全体の誤差を減らしたり、なくしたりすることが可能となる。
SUM is a variable for substituting the sum that has not been corrected for the final error, and DSUM is a variable for substituting the error correction part.
By using such SUM and DSUM, when the data processing apparatus 1 performs operations such as multiplication and addition of numerical values, the following effects are obtained. In other words, since the number of digits that can be stored (held) by the memory 102 or the CPU 103 is determined, the deviation of the numerical value is stored as an error, and the error is used in subsequent calculations, thereby reducing the error of the entire calculation. Or can be eliminated.

次に、図2の処理S203〜S206において、ベクトルのN次元数分の繰返し処理、すなわち、内積の演算処理を行う。たとえば、2次元の場合はN=2とし、その場合、A(i)、B(i)は、それぞれA(A(1),A(2))、B(B(1),B(2))と表現することとする。   Next, in the processes S203 to S206 in FIG. 2, an iterative process for the N-dimensional number of vectors, that is, an inner product calculation process is performed. For example, in the two-dimensional case, N = 2, and in this case, A (i) and B (i) are A (A (1), A (2)) and B (B (1), B (2), respectively. )).

具体的には、まず、CPU103は、i=NのときのA(i)*B(i)における誤差を補正する(S204)。次に、CPU103は、i=NのときのΣA(i)*B(i)における誤差を補正する(S205)。   Specifically, first, the CPU 103 corrects an error in A (i) * B (i) when i = N (S204). Next, the CPU 103 corrects an error in ΣA (i) * B (i) when i = N (S205).

図5は、図2に示したS204の詳細図である。まず、S501において、CPU103は、変数A(i)、A1(i)、A2(i)、B(i)、B1(i)およびB2(i)の領域を、メモリ102上に確保する。
そして、CPU103は、A(i)を、1のビットの最上位桁と最下位桁が分かれるようにA1(i)とA2(i)に分離する。
FIG. 5 is a detailed view of S204 shown in FIG. First, in step S <b> 501, the CPU 103 secures areas for variables A (i), A1 (i), A2 (i), B (i), B1 (i), and B2 (i) on the memory 102.
Then, the CPU 103 separates A (i) into A1 (i) and A2 (i) so that the most significant digit and the least significant digit of one bit are separated.

また、CPU103は、B(i)についても同様に、1のビットの最上位桁と最下位桁が分かれるようにB(i)とB2(i)に分離する。
なお、この分離は、A(i),B(i)のいずれかのみに行うようにしてもよい。
Similarly, for B (i), the CPU 103 separates B (i) and B2 (i) so that the most significant digit and the least significant digit of one bit are separated.
Note that this separation may be performed only in one of A (i) and B (i).

S502において、CPU103は、変数S1、S2、S3およびS4の領域を、メモリ102上に確保し、A1(i)*B1(i)をS1、A1(i)*B2(i)をS2、A2(i)*B1(i)をS3、A2(i)*B2(i)をS4にそれぞれ代入する。
これにより、A(i)*B(i)は、S1+S2+S3+S4で表現されることとなる。
In S502, the CPU 103 secures areas of variables S1, S2, S3, and S4 on the memory 102, A1 (i) * B1 (i) is S1, and A1 (i) * B2 (i) is S2, A2. (I) Substitute * B1 (i) for S3 and A2 (i) * B2 (i) for S4.
As a result, A (i) * B (i) is expressed as S1 + S2 + S3 + S4.

S503において、CPU103は、変数T1、T2の領域をメモリ102上に確保し、前記したS1とS2の和をT1に代入する。また、S1とS2の和の誤差をS2-(T1-S1)から計算し、T2に代入する。
これにより、和S1+S2で生じた丸めや情報落ちによる誤差をフォローすることができる。
In S503, the CPU 103 secures the areas of the variables T1 and T2 on the memory 102, and substitutes the sum of S1 and S2 described above for T1. Further, an error of the sum of S1 and S2 is calculated from S2- (T1-S1) and substituted for T2.
Thereby, it is possible to follow an error caused by rounding or information loss caused by the sum S1 + S2.

S504において、CPU103は、変数T3、T4の領域をメモリ102上に確保し、前記したS3とS4の和をT3に代入する。また、S3とS4の和の誤差をS4-(T3-S3)から計算し、T4に代入する。
これにより、和S3+S4で生じた丸めや情報落ちによる誤差をフォローすることができる。
In S504, the CPU 103 secures the areas of the variables T3 and T4 on the memory 102, and substitutes the sum of S3 and S4 described above for T3. Further, an error of the sum of S3 and S4 is calculated from S4- (T3-S3) and substituted for T4.
Thereby, it is possible to follow an error caused by rounding or information loss caused by the sum S3 + S4.

S505において、CPU103は、変数T5、T6の領域をメモリ102上に確保し、前記したT1とT3の和をT5に代入する。また、T1とT3の和の誤差をT3-(T5-T1)から計算し、T6に代入する。
これにより、和T1+T3で生じた丸めや情報落ちによる誤差をフォローすることができる。
In S505, the CPU 103 secures the areas of variables T5 and T6 on the memory 102, and substitutes the sum of T1 and T3 described above for T5. Also, the error of the sum of T1 and T3 is calculated from T3- (T5-T1) and substituted for T6.
Thereby, it is possible to follow an error caused by rounding or information loss caused by the sum T1 + T3.

S506において、CPU103は、変数T7の領域をメモリ102上に確保し、前記したT2とT4とT6の和をT7に代入する。
なお、このT7は、大きな誤差を生じる可能性が少ないので、その誤差についてフォローしなくても問題はない。
In step S506, the CPU 103 secures an area for the variable T7 on the memory 102, and substitutes the sum of the above-described T2, T4, and T6 for T7.
Since T7 is less likely to cause a large error, there is no problem even if the error is not followed.

S507において、CPU103は、変数D、Eの領域をメモリ102上に確保し、前記したT5とT7の和をDに代入する。また、T5とT7の和の誤差をT7-(D-T5)から計算し、Eに代入する。
このように、CPU103は、与えられたすべてのiについて、S501〜S507の処理を行う。
In S507, the CPU 103 secures the areas of the variables D and E on the memory 102 and substitutes the sum of T5 and T7 described above for D. Further, an error of the sum of T5 and T7 is calculated from T7− (D−T5) and substituted for E.
Thus, the CPU 103 performs the processing of S501 to S507 for all given i.

図6は、図2に示したS205の詳細図である。なお、図6のS601〜S605は、図5のS503〜S507と同様の処理である。   FIG. 6 is a detailed view of S205 shown in FIG. Note that S601 to S605 in FIG. 6 are the same processes as S503 to S507 in FIG.

S601において、CPU103は、変数S11、S12の領域をメモリ102上に確保し、前記したSUMとDの和をS11に代入する。また、SUMとDの和の誤差をS12に代入する。   In S601, the CPU 103 secures the areas of the variables S11 and S12 on the memory 102, and substitutes the sum of the above SUM and D into S11. Further, the error of the sum of SUM and D is substituted into S12.

S602において、CPU103は、変数S13、S14の領域をメモリ102上に確保し、前記したDSUMとEの和をS13に代入する。また、DSUMとEの和の誤差をS14に代入する。   In S602, the CPU 103 secures the areas of variables S13 and S14 on the memory 102, and substitutes the sum of DSUM and E into S13. Further, the error of the sum of DSUM and E is substituted into S14.

S603において、CPU103は、変数S15、S16の領域をメモリ102上に確保し、前記したS11とS13の和をS15に代入する。また、S11とS13の和の誤差をS16に代入する。   In S603, the CPU 103 secures the areas of the variables S15 and S16 on the memory 102, and substitutes the sum of S11 and S13 described above for S15. Further, the error of the sum of S11 and S13 is substituted into S16.

S604において、CPU103は、変数S17の領域をメモリ102上に確保し、前記したS12とS14とS16の和をS17に代入する。   In S604, the CPU 103 secures an area for the variable S17 on the memory 102, and substitutes the sum of S12, S14, and S16 described above for S17.

S605において、CPU103は、前記したS15とS17の和をSUMに代入し、S15とS17の和の誤差をDSUMに代入する。
このように、CPU103は、与えられたすべてのiについて、S601〜S605の処理を行う。
In S605, the CPU 103 substitutes the sum of S15 and S17 described above for SUM, and substitutes the error of the sum of S15 and S17 for DSUM.
As described above, the CPU 103 performs the processing of S601 to S605 for all given i.

図2に戻り、S207において、CPU103は、SUMと補正項DSUMの和を演算し、SUMに代入する。
S208において、CPU103は、出力処理として、S207で代入したSUMの値を演算結果として出力部105に出力する。
Returning to FIG. 2, in S207, the CPU 103 calculates the sum of the SUM and the correction term DSUM, and substitutes the sum into the SUM.
In S208, as an output process, the CPU 103 outputs the SUM value substituted in S207 to the output unit 105 as a calculation result.

このように、S201〜S208の各処理を行うことで、内積演算A・Bについての正確な演算結果を得ることができる。
また、このように正確な演算結果を得ることにより、高精度の内積計算を必要とする産業(例えば、ニューラルネットワーク、ベクトル量子化、敏感な数値シミュレーションを必要とする物理学分野)に本発明を応用することができる。
As described above, by performing each processing of S201 to S208, it is possible to obtain an accurate calculation result for the inner product calculation A / B.
In addition, by obtaining accurate calculation results in this way, the present invention is applied to industries that require high-precision inner product calculation (for example, physics that requires neural network, vector quantization, and sensitive numerical simulation). Can be applied.

続いて、前記した内積演算の具体例について説明する(適宜各図参照)。なお、ここでは、理解を容易にするため、2次元ベクトルに関する内積演算の場合を例にとり説明する。また、データ処理装置1(図1参照)が各演算で使用する数値について、仮数部として保持できる桁数を8ビットとする(指数部を除く)。そして、演算結果の数値が8ビットを超えた場合、上位8ビットのみを保持し、残りのビットは切り捨てるものとする。   Subsequently, specific examples of the inner product calculation described above will be described (refer to each figure as appropriate). Here, in order to facilitate understanding, a case of inner product calculation regarding a two-dimensional vector will be described as an example. Further, regarding the numerical values used by the data processing device 1 (see FIG. 1), the number of digits that can be held as the mantissa part is 8 bits (excluding the exponent part). When the numerical value of the operation result exceeds 8 bits, only the upper 8 bits are retained, and the remaining bits are discarded.

前記条件のもとで、2次元ベクトルA及びBを次のように設定する。
A=(A(1),A(2))、B=(B(1),B(2))
A(1)、A(2)、B(1)、B(2)は、二進数であり、それぞれの値は、次の通りである。
A(1)=10110111(十進数表記で「183」:以下同様に、かっこ内は十進数表記)
A(2)=10010101(149)
B(1)=11011010(218)
B(2)=11100011(227)
Under the above conditions, the two-dimensional vectors A and B are set as follows.
A = (A (1), A (2)), B = (B (1), B (2))
A (1), A (2), B (1), and B (2) are binary numbers, and their values are as follows.
A (1) = 10110111 (“183” in decimal notation: Similarly, parenthesized notation)
A (2) = 10010101 (149)
B (1) = 111011010 (218)
B (2) = 11100011 (227)

前記条件のとき、内積演算A・Bの正確な答えであるA・B(正解)は、次のようになる。
A・B(正解)=1001101111010110(39894)+
1000010000011111(33823)
=10001111111110101(73717)
Under the above conditions, A · B (correct answer) which is the correct answer of the inner product operation A · B is as follows.
A / B (correct answer) = 1001101111010110 (39894) +
10,00010000011111 (33823)
= 100001111111110101 (73717)

そして、本実施形態のデータ処理装置1(図1参照)を用いない場合、すなわち、従来のように切り捨てによって生じた誤差を補正しない場合、内積演算A・Bの結果であるA・B(従来)は、次のようになる。
A・B(従来)=10011011*28(39680)+
10000100*28(33792)
=10001111*29(73216)
When the data processing apparatus 1 (see FIG. 1) of the present embodiment is not used, that is, when the error caused by truncation is not corrected as in the prior art, A / B (conventional) is the result of the inner product calculation A / B. ) Is as follows.
A · B (conventional) = 10011011 * 2 8 (39680) +
10,000 100 * 2 8 (33792)
= 100001111 * 2 9 (73216)

つまり、従来の演算方式では、73717−73216=501の誤差が生じてしまう。   That is, in the conventional calculation method, an error of 73717−73216 = 501 occurs.

次に、前記条件のときに、本実施形態のデータ処理装置1(図1参照)を用いて、内積演算A・Bの結果であるA・B(本願)を算出する演算について説明する(適宜各図参照)。   Next, an operation for calculating A · B (this application) as a result of the inner product operation A · B using the data processing device 1 (see FIG. 1) of the present embodiment under the above conditions will be described (as appropriate). (See each figure).

まず、S201において、S301に示すように、入力部104からデータを入力する。その結果、以下のように配列が初期化される。
A(1)=10110111(183)
A(2)=10010101(149)
B(1)=11011010(218)
B(2)=11100011(227)
First, in S201, data is input from the input unit 104 as shown in S301. As a result, the array is initialized as follows.
A (1) = 10110111 (183)
A (2) = 10010101 (149)
B (1) = 111011010 (218)
B (2) = 11100011 (227)

次に、S202において、CPU103は、変数SUM、DSUMのS401に示すように、変数SUM及びDSUMの値を0に初期化する。
また、この例では2次元での内積演算を実施するため、S203における変数Nを2に初期化する。
Next, in S202, the CPU 103 initializes the values of the variables SUM and DSUM to 0 as shown in S401 of the variables SUM and DSUM.
In this example, in order to perform a two-dimensional inner product calculation, the variable N in S203 is initialized to 2.

そして、S202が実行された後、i=1としてS204が実行される。次に、積A(1)*B(1)における誤差を補正するために、S501において、CPU103は、ベクトル成分を以下のように分離する。
A(1)=A1(1)+A2(1)
B(1)=B1(1)+B2(1)
A1(1)=10110000(176)
A2(1)=00000111(7)
B1(1)=11010000(208)
B2(1)=00001010(10)
Then, after S202 is executed, S204 is executed with i = 1. Next, in order to correct the error in the product A (1) * B (1), in S501, the CPU 103 separates the vector components as follows.
A (1) = A1 (1) + A2 (1)
B (1) = B1 (1) + B2 (1)
A1 (1) = 10110000 (176)
A2 (1) = 00000111 (7)
B1 (1) = 11010000 (208)
B2 (1) = 000001010 (10)

なお、ここでは、A(1)およびB(1)の各々について、A1(1)およびB1(1)のそれぞれ下4桁が0になるように分離したが、下3桁や下2桁などが0になるように分離してもよい。また、A(1)およびB(1)のいずれかだけを分離するようにしてもよい。
いずれにしても、このように、A(1)およびB(1)を、1のビットの最上位桁と最下位桁が分かれるように2つ以上の数に分離することで、以下の演算における誤差を少なくすることができるのである。
In this example, A (1) and B (1) are separated so that the lower 4 digits of A1 (1) and B1 (1) are 0, but the lower 3 digits, lower 2 digits, etc. May be separated so that becomes zero. Further, only one of A (1) and B (1) may be separated.
In any case, by separating A (1) and B (1) into two or more numbers so that the most significant digit and the least significant digit of one bit are separated in this way, The error can be reduced.

そして、S501が実行された後、S502において、変数S1、S2、S3、S4は以下のようになる。
S1=10001111*28(36608)
S2=11011100*23(1760)
S3=10110110*23(1456)
S4=01000110(70)
After S501 is executed, the variables S1, S2, S3, and S4 are as follows in S502.
S1 = 100001111 * 2 8 (36608)
S2 = 111011100 * 2 3 (1760)
S3 = 10110110 * 2 3 (1456)
S4 = 0100011010 (70)

S502が実行された後、S503において、変数T1、T2は以下のようになる。
T1=10010101*28(38144)
T2=11100000(224)
After S502 is executed, the variables T1 and T2 are as follows in S503.
T1 = 10010101 * 2 8 (38144)
T2 = 111100000 (224)

また、S504において、変数T3、T4は以下のようになる。
T3=10111110*23(1520)
T4=00000110(6)
In S504, the variables T3 and T4 are as follows.
T3 = 10111110 * 2 3 (1520)
T4 = 00000110 (6)

さらに、S505において、変数T5、T6は以下のようになる。
T5=10011010*28(39424)
T6=11110000(240)
Further, in S505, the variables T5 and T6 are as follows.
T5 = 10011010 * 2 8 (39424)
T6 = 11110000 (240)

また、S506において、変数T7は以下のようになる。
T7=11101011*21(470)
In S506, the variable T7 is as follows.
T7 = 11101011 * 2 1 (470)

さらに、S507において、変数D、Eは以下のようになる。
D=10011011*28(39680)
E=11010110(214)
In S507, the variables D and E are as follows.
D = 10011011 * 2 8 (39680)
E = 111010110 (214)

続いて、i=1としてS205が実行される。なお、ここでは、SUMとDSUMは初期値のままであるので、ともに0である。   Subsequently, S205 is executed with i = 1. Here, since SUM and DSUM remain at their initial values, both are 0.

まず、S601において、変数S11、S12は以下のようになる。
S11=10011011*28(39680)
S12=000000000(0)
First, in S601, variables S11 and S12 are as follows.
S11 = 10011011 * 2 8 (39680)
S12 = 000000000000 (0)

また、S602において、変数S13、S14は以下のようになる。
S13=11010110(214)
S14=00000000(0)
In S602, the variables S13 and S14 are as follows.
S13 = 11010110 (214)
S14 = 00000000 (0)

さらに、S603において、変数S15、S16は以下のようになる。
S15=10011011*28(39680)
S16=11010110(214)
Further, in S603, the variables S15 and S16 are as follows.
S15 = 10011011 * 2 8 (39680)
S16 = 11010110 (214)

また、S604において、変数S17は以下のようになる。
S17=11010110(214)
In S604, the variable S17 is as follows.
S17 = 111010110 (214)

そして、S605において、変数SUM、DSUMは以下のようになる。
SUM=10011011*28(39680)
DSUM=11010110(214)
In S605, the variables SUM and DSUM are as follows.
SUM = 10011011 * 2 8 (39680)
DSUM = 111010110 (214)

次に、i=2としてS204が実行される。まず、積A(2)*B(2)における誤差を補正するために、S501において、ベクトル成分を以下のように分離する。
A(2)=A1(2)+A2(2)
B(2)=B1(2)+B2(2)
A1(2)=10010000(144)
A2(2)=00000101(5)
B1(2)=11100000(225)
B2(2)=00000011(3)
Next, S204 is executed with i = 2. First, in order to correct an error in the product A (2) * B (2), in S501, vector components are separated as follows.
A (2) = A1 (2) + A2 (2)
B (2) = B1 (2) + B2 (2)
A1 (2) = 10010000 (144)
A2 (2) = 00000101 (5)
B1 (2) = 111100000 (225)
B2 (2) = 00000011 (3)

そして、S501が実行された後、S502において、変数S1、S2、S3、S4は以下のようになる。
S1=11111100*27(32256)
S2=11011000*21(432)
S3=10001100*23(1120)
S4=00001111(15)
After S501 is executed, the variables S1, S2, S3, and S4 are as follows in S502.
S1 = 11111100 * 2 7 (32256)
S2 = 11011000 * 2 1 (432)
S3 = 1000101100 * 2 3 (1120)
S4 = 00001111 (15)

S502が実行された後、S503において、変数T1、T2は以下のようになる。
T1=11111111*27(32640)
T2=00110000(48)
After S502 is executed, the variables T1 and T2 are as follows in S503.
T1 = 11111111 * 2 7 (32640)
T2 = 00110000 (48)

また、S504において、変数T3、T4は以下のようになる。
T3=10001101*23(1128)
T4=00000110(7)
In S504, the variables T3 and T4 are as follows.
T3 = 10001101 * 2 3 (1128)
T4 = 00000110 (7)

さらに、S505において、変数T5、T6は以下のようになる。
T5=10000011*28(33536)
T6=11101000(232)
Further, in S505, the variables T5 and T6 are as follows.
T5 = 10000011 * 2 8 (33536)
T6 = 11101000 (232)

また、S506において、変数T7は以下のようになる。
T7=10001111*21(286)
In S506, the variable T7 is as follows.
T7 = 100001111 * 2 1 (286)

さらに、S507において、変数D、Eは以下のようになる。
D=10000100*28(33792)
E=00011110(30)
In S507, the variables D and E are as follows.
D = 10000100 * 2 8 (33792)
E = 00011110 (30)

続いて、i=2としてS205が実行される。なお、ここでは、SUMとDSUMの値は、次のようになっている。
SUM=10011011*28(39680)
DSUM=11010110(214)
Subsequently, S205 is executed with i = 2. Here, the values of SUM and DSUM are as follows.
SUM = 10011011 * 2 8 (39680)
DSUM = 111010110 (214)

まず、S601において、変数S11、S12は以下のようになる。
S11=10001111*29(73216)
S12=10000000*21(256)
First, in S601, variables S11 and S12 are as follows.
S11 = 100001111 * 2 9 (73216)
S12 = 10000000 * 2 1 (256)

また、S602において、変数S13、S14は以下のようになる。
S13=11110100(244)
S14=00000000(0)
In S602, the variables S13 and S14 are as follows.
S13 = 11110100 (244)
S14 = 00000000 (0)

さらに、S603において、変数S15、S16は以下のようになる。
S15=10001111*29(73216)
S16=11110100(244)
Further, in S603, the variables S15 and S16 are as follows.
S15 = 100001111 * 2 9 (73216)
S16 = 11110100 (244)

また、S604において、変数S17は以下のようになる。
S17=11111010*21(500)
In S604, the variable S17 is as follows.
S17 = 11111010 * 2 1 (500)

そして、S605において、変数SUM、DSUMは以下のようになる。
SUM=10001111*29(73216)
DSUM=11111010*21(500)
In S605, the variables SUM and DSUM are as follows.
SUM = 100111111 * 2 9 (73216)
DSUM = 11111010 * 2 1 (500)

最後に、S207において、CPU103は、SUM+DSUMをSUMに代入し、SUM=73716を得る。
なお、S207においては、実際には、SUMの値とDSUMの値を別々にメモリ102に記憶するので、丸め誤差などが生じることはない。
Finally, in S207, the CPU 103 substitutes SUM + DSUM for SUM to obtain SUM = 73716.
In S207, the SUM value and the DSUM value are actually stored in the memory 102 separately, so that no rounding error or the like occurs.

そして、出力処理S208において、CPU103は、演算結果、すなわち、A・B(本願)=10001111111110100(73716)を出力する。   In the output process S208, the CPU 103 outputs a calculation result, that is, A · B (this application) = 100111111110110100 (73716).

つまり、A・B(正解)、A・B(従来)およびA・B(本願)の演算結果の十進数表記を並べて記載すると、次のようになり、A・B(本願)の誤差がA・B(従来)の誤差に比べて、極めて小さくなることがわかる。
A・B(正解)=73717
A・B(従来)=73216(誤差501)
A・B(本願)=73716(誤差1)
That is, when the decimal notation of the calculation results of A · B (correct answer), A · B (conventional) and A · B (this application) is written side by side, the error is as follows. -It turns out that it becomes very small compared with the error of B (conventional).
A ・ B (Correct) = 73717
A · B (conventional) = 73216 (error 501)
A · B (this application) = 73716 (error 1)

具体的な別の例として、IEEE754で規定された倍精度形式を用いた3次元での内積演算A・Bにおける精度改善処理を以下に示す。なお、以下の例では、数値は十進数表記とする。
3次元ベクトルA及びBを以下のように設定するとき、内積演算A・B(正解)は以下のようになる。
A=(a00,a01,a02)、B=(b00,b10,b20)
a00=1738663799
a01=773694423
a02=112614455
b00=1506009561
b10=2117293945
b20=421597465
A・B(正解)=a00*b00+a01*b10+a02*b20=4304060790507107549
As another specific example, an accuracy improvement process in a three-dimensional inner product operation A / B using a double precision format defined in IEEE754 is shown below. In the following example, the numerical value is expressed in decimal.
When the three-dimensional vectors A and B are set as follows, the inner product calculation A · B (correct answer) is as follows.
A = (a00, a01, a02), B = (b00, b10, b20)
a00 = 1738663799
a01 = 773694423
a02 = 112614455
b00 = 1506009561
b10 = 2117293945
b20 = 421597465
A ・ B (Correct) = a00 * b00 + a01 * b10 + a02 * b20 = 4304060790507107549

まず、上記の条件で本発明を用いない場合、すなわち、丸め、情報落ち及び桁落ちで生じた誤差を補正しない場合、内積演算A・B(従来)は以下に示すような結果となる。
A・B(従来)=0.43040607905071073*1019
First, when the present invention is not used under the above-described conditions, that is, when errors caused by rounding, information loss, and digit loss are not corrected, the inner product calculation A / B (conventional) has the following results.
A ・ B (conventional) = 0.43040607905071073 * 10 19

一方、上記の条件で、本発明を用いた場合、以下に示すような結果となる。まず、入力処理S201により、S301のように、入力装置104からデータを入力する。その結果、以下のように配列が初期化される。
A(1)=1738663799
A(2)=773694423
A(3)=112614455
B(1)=1506009561
B(2)=2117293945
B(3)=421597465
On the other hand, when the present invention is used under the above conditions, the following results are obtained. First, in the input process S201, data is input from the input device 104 as in S301. As a result, the array is initialized as follows.
A (1) = 1738663799
A (2) = 773694423
A (3) = 112614455
B (1) = 1506009561
B (2) = 2117293945
B (3) = 421597465

次に、初期化処理S202により、変数SUM、S401のように、変数SUM及びDSUMを0に初期化する。また、今回の例では3次元での内積演算を実施するため、S203における変数Nを3に初期化する。   Next, the initialization process S202 initializes the variables SUM and DSUM to 0 like the variables SUM and S401. In this example, the variable N in S203 is initialized to 3 in order to perform the inner product calculation in three dimensions.

初期化処理が実行された後、i=1としてS204処理が実行される。まず、積A(1)*B(1)における誤差を補正するために、S501により、ベクトル成分を以下のように分離する。なお、ここで、Dは十進数であることを示し、変数Dとは無関係である。また、右辺の末尾の2桁の数は、10を底とする指数の指数部を示す。
A1(1)=0.173866377600000000000000000000D+10
A2(1)=0.230000000000000000000000000000D+02
B1(1)=0.150600953600000000000000000000D+10
B2(1)=0.250000000000000000000000000000D+02
After the initialization process is executed, S204 is executed with i = 1. First, in order to correct an error in the product A (1) * B (1), in S501, vector components are separated as follows. Here, D indicates a decimal number and is irrelevant to the variable D. Also, the last two digits on the right side indicate the exponent part of the exponent with base 10.
A1 (1) = 0.173866377600000000000000000000D + 10
A2 (1) = 0.230000000000000000000000000000D + 02
B1 (1) = 0.150600953600000000000000000000D + 10
B2 (1) = 0.250000000000000000000000000000D + 02

S501が実行された後、S502により、変数S1、S2、S3、S4は以下のようになる。
S1=0.261844422655376793600000000000D+19
S2=0.434665944000000000000000000000D+11
S3=0.346382193280000000000000000000D+11
S4=0.575000000000000000000000000000D+03
After S501 is executed, the variables S1, S2, S3, and S4 are as follows by S502.
S1 = 0.261844422655376793600000000000D + 19
S2 = 0.434665944000000000000000000000D + 11
S3 = 0.346382193280000000000000000000D + 11
S4 = 0.575000000000000000000000000000D + 03

S502が実行された後、S503により、変数T1、T2は以下のようになる。
T1=0.261844427002036224000000000000D+19
T2=0.960000000000000000000000000000D+02
After S502 is executed, the variables T1 and T2 are as follows by S503.
T1 = 0.261844427002036224000000000000D + 19
T2 = 0.960000000000000000000000000000D + 02

S503が実行された後、S504により、変数T3、T4は以下のようになる。
T3=0.346382199030000000000000000000D+11
T4=0.000000000000000000000000000000D+00
After S503 is executed, the variables T3 and T4 are as follows by S504.
T3 = 0.346382199030000000000000000000D + 11
T4 = 0.000000000000000000000000000000D + 00

S504が実行された後、S505により、変数T5、T6は以下のようになる。
T5=0.261844430465858201600000000000D+19
T6=0.127000000000000000000000000000D+03
After S504 is executed, the variables T5 and T6 are as follows by S505.
T5 = 0.261844430465858201600000000000D + 19
T6 = 0.127000000000000000000000000000D + 03

S505が実行された後、S506により、変数T7は以下のようになる。
T7=0.223000000000000000000000000000D+03
After S505 is executed, the variable T7 becomes as follows by S506.
T7 = 0.223000000000000000000000000000D + 03

S506が実行された後、S507により、変数D、Eは以下のようになる。
D=0.261844430465858201600000000000D+19
E=0.223000000000000000000000000000D+03
After S506 is executed, the variables D and E are as follows by S507.
D = 0.261844430465858201600000000000D + 19
E = 0.223000000000000000000000000000D + 03

i=1としてS204が実行された後、次にi=1としてS205が実行される。
まず、S601により、変数S11、S12は以下のようになる。
S11=0.261844430465858201600000000000D+19
S12=0.000000000000000000000000000000D+00
After S204 is executed with i = 1, S205 is executed with i = 1.
First, the variables S11 and S12 are as follows by S601.
S11 = 0.261844430465858201600000000000D + 19
S12 = 0.000000000000000000000000000000D + 00

S601が実行された後、S602により、変数S13、S14は以下のようになる。
S13=0.223000000000000000000000000000D+03
S14=0.000000000000000000000000000000D+00
After S601 is executed, the variables S13 and S14 are as follows by S602.
S13 = 0.223000000000000000000000000000D + 03
S14 = 0.000000000000000000000000000000D + 00

S602が実行された後、S603により、変数S15、S16は以下のようになる。
S15=0.261844430465858201600000000000D+19
S16=0.223000000000000000000000000000D+03
After S602 is executed, the variables S15 and S16 are as follows by S603.
S15 = 0.261844430465858201600000000000D + 19
S16 = 0.223000000000000000000000000000D + 03

S603が実行された後、S604により、変数S17は以下のようになる。
S17=0.223000000000000000000000000000D+03
After S603 is executed, the variable S17 becomes as follows by S604.
S17 = 0.223000000000000000000000000000D + 03

S604が実行された後、S605により、変数SUM、DSUMは以下のようになる。
SUM= 0.261844430465858201600000000000D+19
DSUM=0.223000000000000000000000000000D+03
After S604 is executed, the variables SUM and DSUM are as follows by S605.
SUM = 0.261844430465858201600000000000D + 19
DSUM = 0.223000000000000000000000000000D + 03

i=1としてS205が実行された後、i=2としてS204処理が実行される。まず、積A(2)*B(2)における誤差を補正するために、S501により、ベクトル成分を以下のように分離する。
A1(2)=0.773694416000000000000000000000D+09
A2(2)=0.700000000000000000000000000000D+01
B1(2)=0.211729392000000000000000000000D+10
B2(2)=0.250000000000000000000000000000D+02
After S205 is executed with i = 1, S204 processing is executed with i = 2. First, in order to correct an error in the product A (2) * B (2), in S501, vector components are separated as follows.
A1 (2) = 0.773694416000000000000000000000D + 09
A2 (2) = 0.700000000000000000000000000000D + 01
B1 (2) = 0.211729392000000000000000000000D + 10
B2 (2) = 0.250000000000000000000000000000D + 02

S501が実行された後、S502により、変数S1、S2、S3、S4は以下のようになる。
S1=0.163813848293475072000000000000D+19
S2=0.193423604000000000000000000000D+11
S3=0.148210574400000000000000000000D+11
S4=0.175000000000000000000000000000D+03
After S501 is executed, the variables S1, S2, S3, and S4 are as follows by S502.
S1 = 0.163813848293475072000000000000D + 19
S2 = 0.193423604000000000000000000000D + 11
S3 = 0.148210574400000000000000000000D + 11
S4 = 0.175000000000000000000000000000D + 03

S502が実行された後、S503により、変数T1、T2は以下のようになる。
T1=0.163813850227711104000000000000D+19
T2=0.800000000000000000000000000000D+02
After S502 is executed, the variables T1 and T2 are as follows by S503.
T1 = 0.163813850227711104000000000000D + 19
T2 = 0.800000000000000000000000000000D + 02

S503が実行された後、S504により、変数T3、T4は以下のようになる。
T3=0.346382199030000000000000000000D+11
T4=0.000000000000000000000000000000D+00
After S503 is executed, the variables T3 and T4 are as follows by S504.
T3 = 0.346382199030000000000000000000D + 11
T4 = 0.000000000000000000000000000000D + 00

S504が実行された後、S505により、変数T5、T6は以下のようになる。
T5=0.163813851709816857600000000000D+19
T6=0.790000000000000000000000000000D+02
After S504 is executed, the variables T5 and T6 are as follows by S505.
T5 = 0.163813851709816857600000000000D + 19
T6 = 0.790000000000000000000000000000D + 02

S505が実行された後、S506により、変数T7は以下のようになる。
T7=0.159000000000000000000000000000D+03
After S505 is executed, the variable T7 becomes as follows by S506.
T7 = 0.159000000000000000000000000000D + 03

S506が実行された後、S507により、変数D、Eは以下のようになる。
D=0.163813851709816883200000000000D+19
E=-0.970000000000000000000000000000D+02
After S506 is executed, the variables D and E are as follows by S507.
D = 0.163813851709816883200000000000D + 19
E = -0.970000000000000000000000000000D + 02

i=2としてS204が実行された後、次にi=2としてS205が実行される。まず、S601により、変数S11、S12は以下のようになる。
S11=0.425658282175675084800000000000D+19
S12=0.000000000000000000000000000000D+00
After S204 is executed with i = 2, then S205 is executed with i = 2. First, the variables S11 and S12 are as follows by S601.
S11 = 0.425658282175675084800000000000D + 19
S12 = 0.000000000000000000000000000000D + 00

S601が実行された後、S602により、変数S13、S14は以下のようになる。
S13=0.126000000000000000000000000000D+03
S14=0.000000000000000000000000000000D+00
After S601 is executed, the variables S13 and S14 are as follows by S602.
S13 = 0.126000000000000000000000000000D + 03
S14 = 0.000000000000000000000000000000D + 00

S602が実行された後、S603により、変数S15、S16は以下のようになる。
S15=0.425658282175675084800000000000D+19
S16=0.126000000000000000000000000000D+03
After S602 is executed, the variables S15 and S16 are as follows by S603.
S15 = 0.425658282175675084800000000000D + 19
S16 = 0.126000000000000000000000000000D + 03

S603が実行された後、S604により、変数S17は以下のようになる。
S17=0.126000000000000000000000000000D+03
After S603 is executed, the variable S17 becomes as follows by S604.
S17 = 0.126000000000000000000000000000D + 03

S604が実行された後、S605により、変数SUM、DSUMは以下のようになる。
SUM= 0.425658282175675084800000000000D+19
DSUM=0.126000000000000000000000000000D+03
After S604 is executed, the variables SUM and DSUM are as follows by S605.
SUM = 0.425658282175675084800000000000D + 19
DSUM = 0.126000000000000000000000000000D + 03

i=2としてS205が実行された後、i=3としてS204処理が実行される。まず、積A(3)*B(3)における誤差を補正するために、S501により、ベクトル成分を以下のように分離する。
A1(3)=0.773694416000000000000000000000D+09
A2(3)=0.700000000000000000000000000000D+01
B1(3)=0.211729392000000000000000000000D+10
B2(3)=0.250000000000000000000000000000D+02
After S205 is executed with i = 2, S204 processing is executed with i = 3. First, in order to correct an error in the product A (3) * B (3), in S501, vector components are separated as follows.
A1 (3) = 0.773694416000000000000000000000D + 09
A2 (3) = 0.700000000000000000000000000000D + 01
B1 (3) = 0.211729392000000000000000000000D + 10
B2 (3) = 0.250000000000000000000000000000D + 02

S501が実行された後、S502により、変数S1、S2、S3、S4は以下のようになる。
S1=0.474779682161446560000000000000D+17
S2=0.112614454000000000000000000000D+09
S3=0.421597464000000000000000000000D+09
S4=0.100000000000000000000000000000D+01
After S501 is executed, the variables S1, S2, S3, and S4 are as follows by S502.
S1 = 0.474779682161446560000000000000D + 17
S2 = 0.112614454000000000000000000000D + 09
S3 = 0.421597464000000000000000000000D + 09
S4 = 0.100000000000000000000000000000D + 01

S502が実行された後、S503により、変数T1、T2は以下のようになる。
T1=0.474779683287591120000000000000D+17
T2=-0.200000000000000000000000000000D+01
After S502 is executed, the variables T1 and T2 are as follows by S503.
T1 = 0.474779683287591120000000000000D + 17
T2 = -0.200000000000000000000000000000D + 01

S503が実行された後、S504により、変数T3、T4は以下のようになる。
T3=0.421597465000000000000000000000D+09
T4=0.000000000000000000000000000000D+00
After S503 is executed, the variables T3 and T4 are as follows by S504.
T3 = 0.421597465000000000000000000000D + 09
T4 = 0.000000000000000000000000000000D + 00

S504が実行された後、S505により、変数T5、T6は以下のようになる。
T5=0.474779687503565760000000000000D+17
T6=-0.100000000000000000000000000000D+01
After S504 is executed, the variables T5 and T6 are as follows by S505.
T5 = 0.474779687503565760000000000000D + 17
T6 = -0.100000000000000000000000000000D + 01

S505が実行された後、S506により、変数T7は以下のようになる。
T7=0.159000000000000000000000000000D+03
After S505 is executed, the variable T7 becomes as follows by S506.
T7 = 0.159000000000000000000000000000D + 03

S506が実行された後、S507により、変数D、Eは以下のようになる。
D=0.474779687503565760000000000000D+17
E=-0.100000000000000000000000000000D+01
After S506 is executed, the variables D and E are as follows by S507.
D = 0.474779687503565760000000000000D + 17
E = -0.100000000000000000000000000000D + 01

i=3としてS204が実行された後、次にi=3としてS205が実行される。まず、S601により、変数S11、S12は以下のようになる。
S11=0.430406079050710732800000000000D+19
S12=0.960000000000000000000000000000D+02
After S204 is executed with i = 3, S205 is executed with i = 3. First, the variables S11 and S12 are as follows by S601.
S11 = 0.430406079050710732800000000000D + 19
S12 = 0.960000000000000000000000000000D + 02

S601が実行された後、S602により、変数S13、S14は以下のようになる。
S13=0.125000000000000000000000000000D+03
S14=0.000000000000000000000000000000D+00
After S601 is executed, the variables S13 and S14 are as follows by S602.
S13 = 0.125000000000000000000000000000D + 03
S14 = 0.000000000000000000000000000000D + 00

S602が実行された後、S603により、変数S15、S16は以下のようになる。
S15=0.430406079050710732800000000000D+19
S16=0.125000000000000000000000000000D+03
After S602 is executed, the variables S15 and S16 are as follows by S603.
S15 = 0.430406079050710732800000000000D + 19
S16 = 0.125000000000000000000000000000D + 03

S603が実行された後、S604により、変数S17は以下のようになる。
S17=0.221000000000000000000000000000D+03
After S603 is executed, the variable S17 becomes as follows by S604.
S17 = 0.221000000000000000000000000000D + 03

S604が実行された後、S605により、変数SUM、DSUMは以下のようになる。
SUM= 0.430406079050710732800000000000D+19
DSUM=0.221000000000000000000000000000D+03
After S604 is executed, the variables SUM and DSUM are as follows by S605.
SUM = 0.430406079050710732800000000000D + 19
DSUM = 0.221000000000000000000000000000D + 03

最後にS206において、変数SUMとDSUMの和をSUMに代入することにより、変数SUMは以下のようになる。
SUM=0.430406079050710754900000000000D+19
Finally, in S206, by substituting the sum of the variables SUM and DSUM into SUM, the variable SUM becomes as follows.
SUM = 0.430406079050710754900000000000D + 19

以上より、本発明を用いた場合、内積演算A・B(本願)は以下に示すような結果となる。
A・B(本願)=0.4304060790507107549*1019
From the above, when the present invention is used, the inner product calculation A · B (this application) has the following results.
A ・ B (this application) = 0.4304060790507107549 * 10 19

つまり、A・B(正解)、A・B(従来)およびA・B(本願)の演算結果を並べて記載すると、次のようになり、A・B(本願)の精度が極めて高いことがわかる。
A・B(正解)= 4304060790507107549
A・B(従来)=0.43040607905071073*1019 (誤差0.249*103
A・B(本願)=0.4304060790507107549*1019(誤差0)
In other words, when the calculation results of A · B (correct answer), A · B (conventional) and A · B (this application) are described side by side, it becomes as follows, and it can be seen that the accuracy of A · B (this application) is extremely high. .
A ・ B (Correct) = 4304060790507107549
A / B (conventional) = 0.43040607905071073 * 10 19 (error 0.249 * 10 3 )
A ・ B (this application) = 0.4304060790507107549 * 10 19 (error 0)

以上で実施形態の説明を終えるが、本発明の態様はこれらに限定されるものではない。
たとえば、IEEE754で規定された単精度形式などを用いて演算を行ってもよい。
また、内積演算について説明したが、加算や乗算などの演算のみに適用してもよい。
さらに、ベクトルの次元数は、3次元以上であってもよい。
This is the end of the description of the embodiments, but the aspects of the present invention are not limited to these.
For example, the calculation may be performed using a single precision format defined by IEEE754.
Further, although the inner product operation has been described, the present invention may be applied only to operations such as addition and multiplication.
Furthermore, the number of dimensions of the vector may be three or more.

また、数値を所定の桁数以内にする場合は、切り捨てによるものでなくても、切り上げなどによるものであってもよい。
さらに、数値を所定の桁数以内にする場合は、十進数に変換したときに四捨五入する、などの別の方法を用いたものであってもよい。
Further, when the numerical value is within a predetermined number of digits, it may not be due to rounding down but may be due to rounding up.
Furthermore, when the numerical value is within a predetermined number of digits, another method such as rounding off when converted to a decimal number may be used.

また、減算の演算を行う場合も、加算の場合と同様の演算を行うことで、より正確な演算結果を得ることができる。
その他、ハードウェア構成や処理手順などの具体的な構成について、本発明の趣旨を逸脱しない範囲で適宜変更が可能である。たとえば、2台以上の演算装置を組み合わせて使う場合に適用してもよい。
Also, when performing the subtraction operation, a more accurate calculation result can be obtained by performing the same operation as in the addition operation.
In addition, a specific configuration such as a hardware configuration and a processing procedure can be appropriately changed without departing from the gist of the present invention. For example, the present invention may be applied when two or more arithmetic devices are used in combination.

データ処理装置の構成図である。It is a block diagram of a data processor. データ処理装置の処理を示したフローチャートである。It is the flowchart which showed the process of the data processor. 入力処理S201の詳細図である。It is a detailed view of input processing S201. 初期化処理S202の詳細図である。It is a detailed view of the initialization process S202. 処理S204の詳細図である。It is a detailed view of process S204. 処理S205の詳細図である。It is a detailed figure of processing S205.

符号の説明Explanation of symbols

101 補助記憶部
102 メモリ
103 CPU
104 入力部
105 出力部
101 Auxiliary storage unit 102 Memory 103 CPU
104 Input section 105 Output section

Claims (4)

乗算対象である第1の数と第2の数との積の演算を、二進浮動小数点を用いて行う演算装置であって、
前記第1の数、前記第2の数、および、演算によって発生した数を、所定の桁数より下位の桁のビットを切り捨てることによってあるいは切り上げることによって所定の桁数内の数として記憶する記憶部と、
前記記憶部に記憶された前記第1の数を、所定の上位数桁である第1の上位数と、残りの下位数桁である第1の下位数と、に分離し、
前記記憶部に記憶された前記第2の数を、前記所定の上位数桁である第2の上位数と、残りの下位数桁である第2の下位数と、に分離し、
前記第1の上位数と前記第2の上位数とを乗算して第1の乗算数とし、
前記第1の上位数と前記第2の下位数とを乗算して第2の乗算数とし、
前記第1の下位数と前記第2の上位数とを乗算して第3の乗算数とし、
前記第1の下位数と前記第2の下位数とを乗算して第4の乗算数とし、
前記第1の乗算数、前記第2の乗算数、前記第3の乗算数および前記第4の乗算数を任意の順番で3回の加算を行うことでその総和を算出するとき、各回における和とは別に各回の誤差それぞれを前記記憶部に記憶させ、前記各回の誤差すべてを加算して総誤差を算出し、3回の加算後の和に対して前記総誤差を加算することで前記総和を算出するとともに、そのときの誤差である総和誤差も算出する処理部と、
を有することを特徴とする演算装置。
An arithmetic device that performs an operation of a product of a first number and a second number to be multiplied using a binary floating point,
A storage for storing the first number, the second number, and the number generated by the operation as a number within a predetermined number of digits by rounding down or rounding up the bits of a digit lower than the predetermined number of digits. And
Separating the first number stored in the storage unit into a first upper number which is a predetermined upper number digit and a first lower number which is a remaining lower number digit ;
Separating the second number stored in the storage unit into a second upper number that is the predetermined higher-order digits and a second lower number that is the remaining lower-order digits;
Multiplying the first upper number and the second upper number to obtain a first multiplication number;
Multiplying the first upper number and the second lower number to obtain a second multiplication number;
Multiplying the first lower number and the second upper number to obtain a third multiplication number;
Multiplying the first lower number and the second lower number to obtain a fourth multiplication number;
When the sum is calculated by adding the first multiplication number, the second multiplication number, the third multiplication number, and the fourth multiplication number three times in an arbitrary order, the sum at each time Separately, each error of each time is stored in the storage unit, and the total error is calculated by adding all the errors of each time, and the total error is added to the sum after the three times of addition. And a processing unit that calculates a total error that is an error at that time ,
An arithmetic device comprising:
1次元以上の2つのベクトルの内積演算を行う場合、When performing an inner product operation of two vectors of one dimension or more,
前記処理部は、  The processor is
各次元に関して前記総和と前記総和誤差とを算出し、それらを加算することで前記2つのベクトルの内積演算を行う  Calculate the sum and the sum error for each dimension, and add them to perform the inner product operation of the two vectors
ことを特徴とする請求項1に記載の演算装置。  The arithmetic unit according to claim 1.
乗算対象である第1の数と第2の数との積の演算を、二進浮動小数点を用いて行う演算装置における演算方法であって、An operation method in an operation device that performs an operation of a product of a first number and a second number to be multiplied using a binary floating point,
前記演算装置は、前記第1の数、前記第2の数、および、演算によって発生した数を、所定の桁数より下位の桁のビットを切り捨てることによってあるいは切り上げることによって所定の桁数内の数として記憶する記憶部と、処理部とを備えており、  The arithmetic unit may calculate the first number, the second number, and the number generated by the calculation within a predetermined number of digits by rounding down or rounding up the bits of the digits lower than the predetermined number of digits. A storage unit for storing numbers and a processing unit;
前記処理部は、  The processor is
前記記憶部に記憶された前記第1の数を、所定の上位数桁である第1の上位数と、残りの下位数桁である第1の下位数と、に分離し、  Separating the first number stored in the storage unit into a first upper number which is a predetermined upper number digit and a first lower number which is a remaining lower number digit;
前記記憶部に記憶された前記第2の数を、前記所定の上位数桁である第2の上位数と、残りの下位数桁である第2の下位数と、に分離し、  Separating the second number stored in the storage unit into a second upper number that is the predetermined higher-order digits and a second lower number that is the remaining lower-order digits;
前記第1の上位数と前記第2の上位数とを乗算して第1の乗算数とし、  Multiplying the first upper number and the second upper number to obtain a first multiplication number;
前記第1の上位数と前記第2の下位数とを乗算して第2の乗算数とし、  Multiplying the first upper number and the second lower number to obtain a second multiplication number;
前記第1の下位数と前記第2の上位数とを乗算して第3の乗算数とし、  Multiplying the first lower number and the second upper number to obtain a third multiplication number;
前記第1の下位数と前記第2の下位数とを乗算して第4の乗算数とし、  Multiplying the first lower number and the second lower number to obtain a fourth multiplication number;
前記第1の乗算数、前記第2の乗算数、前記第3の乗算数および前記第4の乗算数を任意の順番で3回の加算を行うことでその総和を算出するとき、各回における和とは別に各回の誤差それぞれを前記記憶部に記憶させ、前記各回の誤差すべてを加算して総誤差を算出し、3回の加算後の和に対して前記総誤差を加算することで前記総和を算出するとともに、そのときの誤差である総和誤差も算出する  When the sum is calculated by adding the first multiplication number, the second multiplication number, the third multiplication number, and the fourth multiplication number three times in an arbitrary order, the sum at each time Separately, each error of each time is stored in the storage unit, and the total error is calculated by adding all the errors of each time, and the total error is added to the sum after the three times of addition. And the total error, which is the error at that time, is also calculated
ことを特徴とする演算方法。  An arithmetic method characterized by the above.
1次元以上の2つのベクトルの内積演算を行う場合、When performing an inner product operation of two vectors of one dimension or more,
前記処理部は、  The processor is
各次元に関して前記総和と前記総和誤差とを算出し、それらを加算することで前記2つのベクトルの内積演算を行う  Calculate the sum and the sum error for each dimension, and add them to perform the inner product operation of the two vectors
ことを特徴とする請求項3に記載の演算方法。  The calculation method according to claim 3.
JP2005126326A 2005-04-25 2005-04-25 Arithmetic apparatus and arithmetic method Expired - Fee Related JP4359258B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2005126326A JP4359258B2 (en) 2005-04-25 2005-04-25 Arithmetic apparatus and arithmetic method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2005126326A JP4359258B2 (en) 2005-04-25 2005-04-25 Arithmetic apparatus and arithmetic method

Publications (2)

Publication Number Publication Date
JP2006302180A JP2006302180A (en) 2006-11-02
JP4359258B2 true JP4359258B2 (en) 2009-11-04

Family

ID=37470363

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2005126326A Expired - Fee Related JP4359258B2 (en) 2005-04-25 2005-04-25 Arithmetic apparatus and arithmetic method

Country Status (1)

Country Link
JP (1) JP4359258B2 (en)

Also Published As

Publication number Publication date
JP2006302180A (en) 2006-11-02

Similar Documents

Publication Publication Date Title
CN105468331B (en) Independent floating point conversion unit
US8280939B2 (en) Methods and apparatus for automatic accuracy-sustaining scaling of block-floating-point operands
US8719322B2 (en) Floating point format converter
CN110235099B (en) Apparatus and method for processing input operand values
CN111695671A (en) Method and device for training neural network and electronic equipment
US9851947B2 (en) Arithmetic processing method and arithmetic processor having improved fixed-point error
US11294627B2 (en) Floating point dot-product operator with correct rounding
US20140089361A1 (en) Arithmetic processing apparatus and an arithmetic processing method
US20080098057A1 (en) Multiplication Apparatus
JP4273071B2 (en) Divide and square root calculator
WO2021136259A1 (en) Floating-point number multiplication computation method and apparatus, and arithmetical logic unit
US11550544B2 (en) Fused Multiply-Add operator for mixed precision floating-point numbers with correct rounding
JP4359258B2 (en) Arithmetic apparatus and arithmetic method
US9933999B2 (en) Apparatus, method and program for calculating the result of a repeating iterative sum
Graillat et al. Tight interval inclusions with compensated algorithms
US20220138282A1 (en) Computing device and computing method
Hass Synthesizing optimal fixed-point arithmetic for embedded signal processing
US10353671B2 (en) Circuitry and method for performing division
JP2007257239A (en) Computing apparatus, and computing method
JP4490925B2 (en) Calculation device, calculation method, and calculation program
US20230147929A1 (en) Exact versus inexact decimal floating-point numbers and computation system
Lakshmikantham et al. O (n3) noniterative heuristic algorithm for linear programs with error-free implementation
US11947960B2 (en) Modulo-space processing in multiply-and-accumulate units
JP2023161967A (en) Arithmetic device, arithmetic method, and program
JP2007257225A (en) Computing apparatus, and computing method

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20070530

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20090331

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20090525

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20090804

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20090807

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20120814

Year of fee payment: 3

R150 Certificate of patent or registration of utility model

Ref document number: 4359258

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

Free format text: JAPANESE INTERMEDIATE CODE: R150

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20120814

Year of fee payment: 3

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20130814

Year of fee payment: 4

LAPS Cancellation because of no payment of annual fees