JP5634941B2 - Arithmetic apparatus, arithmetic method and arithmetic program - Google Patents
Arithmetic apparatus, arithmetic method and arithmetic program Download PDFInfo
- Publication number
- JP5634941B2 JP5634941B2 JP2011111812A JP2011111812A JP5634941B2 JP 5634941 B2 JP5634941 B2 JP 5634941B2 JP 2011111812 A JP2011111812 A JP 2011111812A JP 2011111812 A JP2011111812 A JP 2011111812A JP 5634941 B2 JP5634941 B2 JP 5634941B2
- Authority
- JP
- Japan
- Prior art keywords
- matrix
- data
- zdd
- unit
- calculation
- 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
Links
Images
Landscapes
- Complex Calculations (AREA)
Description
本発明は、演算装置、演算方法および演算プログラムに関する。 The present invention relates to a calculation device, a calculation method, and a calculation program.
計算機上で動作させることにより、例えば、0(ゼロ)と、0(ゼロ)以外の数を要素に持つM行N列の2値行列と、N次元の実数ベクトルとの行列演算を行うライブラリが提案されている(非特許文献1参照)。例えば、このライブラリでは、行列が疎な場合、すなわち、非零である要素数をKとしたときにK≪MNである場合には、非零成分のみについて行列計算を行う。 By operating on a computer, for example, a library that performs a matrix operation of an M-row N-column binary matrix having elements other than 0 (zero) and a number other than 0 (zero) and an N-dimensional real vector is provided. It has been proposed (see Non-Patent Document 1). For example, in this library, when the matrix is sparse, that is, when K << MN when the number of non-zero elements is K, matrix calculation is performed only for non-zero components.
一般に、M行N列の2値行列と、N次元の実数ベクトルとの行列演算を行う場合には、「O(MN)」の演算量に応じた計算時間および記憶容量とが必要となる。なお、「O(オー)」は行列演算のオーダーを示し、「MN」は要素数を示す。一方で、上述したライブラリでは、行列が疎な場合、すなわち、非零である要素数「K」がK≪MNである場合に、非零成分のみについて行列計算を行うので、「O(K)」の演算量に応じた計算時間および記憶容量が必要となる。このように、上述したライブラリにより行列演算を行う場合には、非零である要素数「K」に応じた計算時間および記憶容量が行列演算に必要となる。このため、上述したライブラリにより要素数が膨大な行列について演算を行う場合、演算量も膨大となる結果、演算に必要となる計算時間および記憶容量の規模が大きくなってしまうという問題がある。 In general, when performing a matrix operation of a binary matrix of M rows and N columns and an N-dimensional real vector, calculation time and storage capacity corresponding to the calculation amount of “O (MN)” are required. “O (O)” indicates the order of matrix operation, and “MN” indicates the number of elements. On the other hand, in the above-described library, when the matrix is sparse, that is, when the number of non-zero elements “K” is K << MN, matrix calculation is performed only for the non-zero component, so “O (K) The calculation time and the storage capacity according to the calculation amount of “are required. As described above, when performing matrix operation using the above-described library, calculation time and storage capacity corresponding to the non-zero number of elements “K” are required for matrix operation. For this reason, when a calculation is performed on a matrix with a large number of elements using the above-described library, there is a problem that the calculation amount and the storage capacity required for the calculation increase as a result of the large calculation amount.
本発明は、上記に鑑みてなされたものであって、2値行列と実数ベクトルとの行列演算を効率的に実行することが可能な演算装置、演算方法および演算プログラムを提供することを目的とする。 The present invention has been made in view of the above, and an object of the present invention is to provide an arithmetic device, an arithmetic method, and an arithmetic program capable of efficiently executing a matrix operation between a binary matrix and a real vector. To do.
上述した課題を解決し、目的を達成するために、本発明は、2値行列とN次元の実数ベクトルとの行列演算を行う演算装置であって、M行N列(M、Nは整数)の前記2値行列のデータを入力するデータ入力部と、N次元(Nは整数)の前記実数ベクトルを入力するベクトル入力部と、前記データ入力部により入力された前記2値行列のデータを、二分決定グラフのデータ構造に変換した変換データを構築する構築部と、前記構築部により構築された前記変換データと、前記ベクトル入力部により入力された前記実数ベクトルとの行列演算を実行する演算部と、前記演算部による演算結果を出力する出力部とを有することを特徴とする。 In order to solve the above-described problems and achieve the object, the present invention is an arithmetic device that performs a matrix operation of a binary matrix and an N-dimensional real vector, and has M rows and N columns (M and N are integers). A data input unit for inputting the binary matrix data, a vector input unit for inputting the N-dimensional (N is an integer) real vector, and the binary matrix data input by the data input unit, A construction unit that constructs transformation data converted into a data structure of a binary decision graph, and a computation unit that performs matrix computation of the transformation data constructed by the construction unit and the real vector input by the vector input unit And an output unit for outputting a calculation result by the calculation unit.
また、本発明は、2値行列とN次元の実数ベクトルとの行列演算をコンピュータにより実行される演算方法であって、M行N列(M、Nは整数)の前記2値行列のデータを入力するデータ入力工程と、N次元(Nは整数)の前記実数ベクトルを入力するベクトル入力工程と、前記データ入力工程により入力された前記2値行列のデータを、二分決定グラフのデータ構造に変換した変換データを構築する構築工程と、前記構築工程により構築された前記変換データと、前記ベクトル入力部により入力された前記実数ベクトルとの行列演算を実行する演算工程と、前記演算工程による演算結果を出力する出力工程とを実行することを特徴とする。 Further, the present invention is an operation method in which a matrix operation between a binary matrix and an N-dimensional real vector is executed by a computer, and the binary matrix data of M rows and N columns (M and N are integers) are obtained. A data input step for inputting, a vector input step for inputting the N-dimensional (N is an integer) real vector, and the binary matrix data input by the data input step are converted into a data structure of a binary decision graph. A construction step for constructing the converted data, a computation step for performing a matrix computation of the conversion data constructed by the construction step and the real vector input by the vector input unit, and a computation result by the computation step And an output step of outputting.
また、本発明は、2値行列とN次元の実数ベクトルとの行列演算を行うコンピュータに実行させるための演算プログラムであって、前記コンピュータに、M行N列(M、Nは整数)の前記2値行列のデータを入力するデータ入力手順と、N次元(Nは整数)の前記実数ベクトルを入力するベクトル入力手順と、前記データ入力手順により入力された前記2値行列のデータを、二分決定グラフのデータ構造に変換した変換データを構築する構築手順と、前記構築手順により構築された前記変換データと、前記ベクトル入力手順により入力された前記実数ベクトルとの行列演算を実行する演算手順と、前記演算手順による演算結果を出力する出力手順とを実行させることを特徴とする。 The present invention also provides an arithmetic program for causing a computer to perform a matrix operation of a binary matrix and an N-dimensional real vector, the computer having M rows and N columns (M and N are integers). Data input procedure for inputting binary matrix data, vector input procedure for inputting N-dimensional (N is an integer) real vector, and binary matrix data input by the data input procedure are determined in binary. A construction procedure for constructing transformation data converted into a data structure of a graph, a computation procedure for performing a matrix computation of the transformation data constructed by the construction procedure and the real vector input by the vector input procedure, An output procedure for outputting a calculation result according to the calculation procedure is executed.
本発明によれば、2値行列と実数ベクトルとの行列演算を効率的に実行できるという効果を奏する。 According to the present invention, there is an effect that a matrix operation between a binary matrix and a real vector can be efficiently executed.
以下に、図面を参照しつつ、本願に係る演算装置、演算方法および演算プログラムの各実施例について詳細に説明する。後述する実施例は一例にすぎず、本願に係る演算装置、演算方法および演算プログラムを限定するものではない。また、後述する各実施例は処理内容に矛盾を生じさせない範囲で適宜組み合わせることもできる。 Hereinafter, embodiments of a calculation device, a calculation method, and a calculation program according to the present application will be described in detail with reference to the drawings. The embodiment described below is merely an example, and does not limit the arithmetic device, the arithmetic method, and the arithmetic program according to the present application. In addition, the embodiments described later can be appropriately combined within a range that does not cause a contradiction in the processing contents.
[演算装置の概要と特徴(実施例1)]
実施例1に係る演算装置は、2値行列と実数ベクトルとの行列演算を行うことを概要とする。そして、実施例1に係る演算装置は、2値行列を所定のデータ構造を用いて圧縮し、圧縮した2値行列を対象として演算を実行する点に特徴がある。
[Outline and Features of Arithmetic Unit (Example 1)]
The arithmetic device according to the first embodiment is summarized as performing a matrix operation of a binary matrix and a real vector. The arithmetic device according to the first embodiment is characterized in that a binary matrix is compressed using a predetermined data structure, and an operation is performed on the compressed binary matrix.
具体的には、実施例1に係る演算装置は、M行N列(M、Nは正の整数)の2値行列を、ゼロサプレス型二分決定グラフ(Zero-Suppressed Binary Decision Diagram,以下、適宜ZDDと記載する)を用いたデータ構造に変換する。そして、実施例1に係る演算装置は、ZDDと実数ベクトルとの積の演算を、ZDD上で再帰的なアルゴリズムとして実行する。すなわち、実施例1に係る演算装置は、2値行列をZDDを用いたデータ構造に変換することにより2値行列のデータを圧縮して表現することができる。そして、実施例1に係る演算装置は、2値行列が有する非零の要素数「K」に応じた演算を実行するのではなく、2値行列をZDDを用いたデータ構造に変換したときのZDDのノード数「W」に応じた演算を実行できるようになる。このようなことから、実施例1に係る演算装置は、2値行列と実数ベクトルとの積の演算に必要となる計算時間や記憶容量を減らすことができ、行列演算を効率的に実行できる。 Specifically, the arithmetic device according to the first embodiment uses a binary matrix of M rows and N columns (M and N are positive integers) as a zero-suppressed binary decision diagram (hereinafter referred to as ZDD). To a data structure using Then, the arithmetic device according to the first embodiment executes the operation of the product of the ZDD and the real vector as a recursive algorithm on the ZDD. That is, the arithmetic device according to the first embodiment can compress and represent binary matrix data by converting the binary matrix into a data structure using ZDD. And the arithmetic unit which concerns on Example 1 does not perform the calculation according to the non-zero element number "K" which a binary matrix has, but when converting a binary matrix into the data structure using ZDD An operation corresponding to the number of nodes “W” of ZDD can be executed. For this reason, the arithmetic device according to the first embodiment can reduce the calculation time and the storage capacity necessary for calculating the product of the binary matrix and the real vector, and can efficiently execute the matrix operation.
[演算装置の構成(実施例1)]
図1は、実施例1に係る演算装置の構成を示す機能ブロック図である。実施例1に係る演算装置100は、例えば、所定のプログラムなどに記述された手順に従い、所定の演算処理を行うパーソナルコンピュータやワークステーション、オフコンなどに相当する。なお、図1では、演算装置100を説明する上で必要となる機能を図示し、中央演算装置や主記憶装置、補助記憶装置などの一般的な機能の図示は省略する。
[Configuration of Arithmetic Unit (Example 1)]
FIG. 1 is a functional block diagram illustrating the configuration of the arithmetic device according to the first embodiment. The
図1に示すように、実施例1に係る演算装置100は、データ入力部110と、ZDD構築部120と、データ記憶部130と、ベクトル入力部140と、行列演算実行部150と、計算結果出力部160とを有する。
As illustrated in FIG. 1, the
データ入力部110は、M行N列(M、Nは正の整数)の2値行列(要素が0もしくは1の値である行列)を入力する。図2は、データ入力部が入力する2値行列の一例を示す図である。図2に示すように、データ入力部110は、例えば、3行3列の2値行列を入力する。なお、データ入力部110は、例えば、キーボードやマウスなどのユーザインターフェースや、USB(Universal Serial Bus)やイーサネット(登録商標)などのハードウェアインターフェースなどを介して2値行列を入力する。
The
ZDD構築部120は、データ入力部110により入力されたM行N列の2値行列から、ZDD(Zero-Suppressed Binary Decision Diagram)を構築する。まず、ZDD構築部120によるZDDの構築手順の説明に先立ち、ZDDについて説明する。
The
ZDDは、組み合わせ集合を2分グラフの形で保持するデータ構造である。ここで、組み合わせ集合とは、あるアイテムの集合A={a1,a2,…,}に対して、e⊆Aであるようなeを要素とする集合である。一例を挙げれば、集合B={a,b,c}がある場合に、集合{{a,b},{b,c},{a,c}}は、集合Bの組み合わせ集合ということになる。図3は、ZDDの一例を示す図である。なお、図3は、組み合わせ集合{{a,b},{b},{c}}のZDDを表している。図3に示すように、ZDD「I1」は指向性を持ったグラフ構造で構成される。また、図3に示すように、ZDD「I1」は、「0または1」のラベルが貼り付けられた終端ノード(図3の四角いノード)と、「a,bまたはc」のラベルが貼り付けられた中間ノード(図3の丸いノード)との2種類のノードを有する。また、図3に示すように、中間ノードは、それぞれ、HIリンク(実線矢印)およびLOリンク(点線矢印)を有する。中間ノードが有する各リンクは、それぞれが別の子ノードを指す。また、図3に示すように、ZDDには、先頭ノードを表すポインタ「f」が設けられる。このように、ZDDは、終端ノード、中間ノード、HIリンク、LOリンクおよびポインタを有するグラフ構造によって組み合わせ集合を表現する。 ZDD is a data structure that holds a combination set in the form of a binary graph. Here, the combination set is a set whose element is e such that e⊆A with respect to a set A = {a 1 , a 2 ,... For example, when there is a set B = {a, b, c}, the set {{a, b}, {b, c}, {a, c}} is a combination set of the set B. Become. FIG. 3 is a diagram illustrating an example of ZDD. FIG. 3 represents the ZDD of the combination set {{a, b}, {b}, {c}}. As shown in FIG. 3, ZDD “I 1 ” has a graph structure having directivity. In addition, as shown in FIG. 3, the ZDD “I 1 ” has a terminal node (a square node in FIG. 3) labeled with “0 or 1” and a label “a, b, or c”. It has two types of nodes with attached intermediate nodes (round nodes in FIG. 3). Further, as shown in FIG. 3, each intermediate node has an HI link (solid arrow) and an LO link (dotted arrow). Each link that an intermediate node has points to a different child node. Also, as shown in FIG. 3, the ZDD is provided with a pointer “f” representing the head node. Thus, ZDD represents a combination set by a graph structure having terminal nodes, intermediate nodes, HI links, LO links, and pointers.
例えば、ある組み合わせeが、ZDDが表す組み合わせ集合に含まれるか否かは、以下に説明する手続きにより判明する。まず、ZDDの先頭ノードを表すポインタに沿って、先頭ノードに遷移する。そこで、先頭ノードのラベルが表すアイテムがeに含まれているならHIリンクが指すノードに遷移し、そうでないならLOリンクが指すノードに遷移する。以上の手続きを最終的に終端ノードにたどり着くまで実行し、最終的にラベル1をもつ終端ノードに遷移し、かつeに含まれるすべてのアイテムに対応するノードを遷移してきているなら、eは組み合わせ集合に含まれる。一方、以上の手続きを最終的に終端ノードにたどり着くまで実行し、最終的にラベル1をもつ終端ノードに遷移せず、かつeに含まれるすべてのアイテムに対応するノードを遷移してきていないなら、eは組み合わせ集合に含まれない。
For example, whether or not a certain combination e is included in the combination set represented by ZDD can be determined by the procedure described below. First, a transition is made to the head node along a pointer representing the head node of ZDD. Therefore, if the item represented by the label of the first node is included in e, the transition is made to the node pointed to by the HI link. If the above procedure is finally executed until the terminal node is reached, and finally the transition is made to the terminal
図4は、図3に示すZDDに対応するノード表の一例を示す図である。図4に示すように、ZDDは、コンピュータ上においては、ノードIDをインデックスとし、各要素を配列したノード表で表現される。図4に示すように、ノード表には、各要素として、ノードIDごとに、ノードのラベル、HIリンク先のノードID、LOリンク先のノードIDがそれぞれ格納されている。 FIG. 4 is a diagram illustrating an example of a node table corresponding to the ZDD illustrated in FIG. As shown in FIG. 4, on the computer, the ZDD is represented by a node table in which each element is arranged with a node ID as an index. As shown in FIG. 4, the node table stores a node label, a HI link destination node ID, and a LO link destination node ID for each node ID as each element.
ところで、ある組み合わせをZDDで表現するときには、アイテム間にあらかじめ順序が定められている。具体的には、あるノードのラベルであるアイテムとその子ノードのラベルであるアイテムとを比較したときに、必ず子ノードのアイテムの順序が後になるようにするという制約がある。例えば、上述したZDD「I1」(図3)では、ラベル「a」、「b」、「c」が貼り付けられたアイテムの間に、「a」、「b」、「c」の順で順序が定められている。また、ノードIDがiであるノードのHIリンク先となるノードのノードIDをHI(i)、LOリンク先となるノードのノードIDをLO(i)とした場合に、上述したZDDの配列(図4)では、i>2のときに、常にHI(i)<i,LO(i)<iが成り立つように構成されている。以下、ノードIDがiであるノードのラベルをv(i)、HIリンク先のノードのノードIDをHI(i)、LOリンク先のノードのノードIDをLO(i)と記述する。 By the way, when a certain combination is expressed in ZDD, an order is determined in advance between items. Specifically, there is a restriction that when an item that is a label of a certain node is compared with an item that is a label of the child node, the order of the items of the child node is always later. For example, in the above-described ZDD “I 1 ” (FIG. 3), the items “a”, “b”, “c” are placed in the order of “a”, “b”, “c”. The order is determined. Further, when the node ID of the node that becomes the HI link destination of the node whose node ID is i is HI (i) and the node ID of the node that becomes the LO link destination is LO (i), the above ZDD array ( 4), when i> 2, HI (i) <i and LO (i) <i are always satisfied. Hereinafter, the label of the node whose node ID is i is described as v (i), the node ID of the HI link destination node as HI (i), and the node ID of the LO link destination node as LO (i).
ZDDの説明に続いて、ZDD構築部120が、M行N列の2値行列からZDDを構築する手順について説明する。ZDD構築部120は、データ入力部110からM行N列の2値行列を取得し、行列の各行について、1つの要素のみからなる集合を作成する。行列の各行について、ZDD構築部120により作成される1つの要素のみからなる集合は、例えば、以下に示す式(1)で表される。
Following the description of ZDD, a procedure in which the
続いて、ZDD構築部120は、行列の各行について、1つの要素のみからなる集合を作成した後、それらの和集合を作成する。ZDD構築部120により作成される和集合は、例えば、以下に示す式(2)で表される。
Subsequently, the
なお、上述した式(1)および(2)に示すa(i,j)は、行列のi行目のN個の要素のうち、値が「1」である列番号を並べたものである。例えば、データ入力部110から取得した2値行列が、図2に示すような3行3列の2値行列で与えられたとすると、a(1,1)=1,a(1,2)=3となる。また、上述した式(1)および(2)に示すb(i)は、行列のi行目のN個の要素のうち、値が「1」である要素の個数を示すものである。例えば、データ入力部110から取得した2値行列が、図2に示すような3行3列の2値行列で与えられたとすると、b(1)=2,b(2)=1,b(3)=1となる。また、上述した式(1)および(2)に示すRiは、行列のi行目に対応するシンボルを示すものであり、上述した式(1)および(2)に示すCiは、行列のi列目に対応するシンボルを示すものである。
Note that a (i, j) shown in the above-described equations (1) and (2) is an array of column numbers having a value of “1” among the N elements in the i-th row of the matrix. . For example, if the binary matrix acquired from the
このように、ZDD構築部120は、データ入力部110により入力された2値行列を、上述した式(2)に示すようにして圧縮して表現できる。
As described above, the
続いて、ZDD構築部120は、上述の式(2)で表わされる和集合を組み合わせ集合Fとして、組み合わせ集合FのZDDを計算し、データ記憶部130に格納する。なお、組み合わせ集合と、その集合に出現するシンボルの順序とが与えられれば、既存の技術を利用して、ZDDを対象とした演算を行うことによりZDDを計算することができる。そこで、ZDD構築部120は、組み合わせ集合F(式(2))に出現するシンボルR1,R2,…,RM,C1,C2,…,CNに対して、R1<R2<・・・<RM<C1<C2<・・・<CNという順序を与え、既存の技術を利用した演算を行うことにより、組み合わせ集合FのZDDを計算する。なお、ZDDを対象とした演算を行う既存の技術としては、例えば、Shin-ichi Minato,「Zero-Suppressed BDDs for Set Manipulation in Combinatorial Problems」,DAC’93,pp.272-277などがある。
Subsequently, the
図5は、ZDD構築部120により構築されるZDDの一例を示す図である。図6は、ZDD構築部120により構築されたZDDに対応するノード表の一例を示す図である。なお、図5および図6は、上述した式(2)で表される組み合わせ集合から構築されるZDDである。ZDD構築部120は、組み合わせ集合Fと、組み合わせ集合Fに出現するシンボルの順序とが与えられると、既存技術を利用した演算を行うことにより、図5に示すようなZDD「I2」を構築できる。図5に示すように、ZDD「I2」は、ラベル「R1」,「R2」,「R3」,「C1」,「C2」,「C3」が貼り付けられた中間ノード(丸いノード)と、「0」または「1」のラベルが貼り付けられた終端ノード(四角いノード)とを有する。また、図5に示すように、ZDD「I2」は、中間ノードのうち、ポインタ「f」が指すラベル「R1」が貼り付けられたノードを先頭ノードとする。また、図6に示すように、ZDD「I2」は、コンピュータ上において、ノードIDをインデックスとし、各要素を配列したノード表で表現される。ノード表のノードID「1」〜「8」は、図5に示すラベル「0」,「1」,「C3」,「C2」,「C1」,「R3」,「R2」,「R1」のノードにそれぞれ対応する。なお、ZDD構築部120により構築されるZDDは、組み合わせ集合を可能な限り圧縮した形で表現することが可能なデータ構造である。もし、ZDD構築部120が、組み合わせ集合を全く圧縮することなく、ZDDを構築したとする。この場合、ZDD構築部120は、2値行列の行数と、行列中の非零成分の個数分の中間ノードを有するZDDとして、組み合わせ集合を表現することとなる。一方、ZDD構築部120は、組み合わせ集合で表される2値行列の各行をベクトルとして行同士を比較し、共通部分を可能な限り圧縮した構造でZDDを構築したとする。この場合、ZDD構築部120は、共通部分を圧縮せずに構築したZDDよりも、中間ノードの数を減らしたZDDとして、組み合わせ集合を表現することができる。
FIG. 5 is a diagram illustrating an example of ZDD constructed by the
ベクトル入力部140は、データ入力部110により入力された2値行列との積の計算対象であるN次元(Nは正の整数)の実数ベクトルを入力する。なお、ベクトル入力部140は、データ入力部110と同様に、ユーザインターフェースやハードウェアインターフェースなどを介してN次元の実数ベクトルを入力する。
The
行列演算実行部150は、ZDD構築部120により2値行列から構築されたZDDと、ベクトル入力部140により入力されたN次元の実数ベクトル(以下、適宜N次元ベクトルと記載する)とを用いて、行列演算を実行する。
The matrix
具体的には、行列演算実行部150は、以下に説明するように、2値行列から構築されたZDDと、実数ベクトルとの積の演算を、ZDD上で再帰的なアルゴリズムとして実行する。まず、行列演算実行部150は、ベクトル入力部140からN次元ベクトルを取得し、取得したN次元ベクトルをq、i番目の要素をqiと表す。続いて、行列演算実行部150は、データ記憶部130からZDDを取得し、N次元ベクトルとの積を演算する。なお、N次元ベクトル「q」と、ZDDとの演算結果を、M次元ベクトルpとする。行列演算実行部150は、まず、スコアを格納する要素数(W−M)の1次元配列scoreを用意し、すべての要素を0で初期化しておく。ここで、要素数(W−M)は、ZDDの中間ノードのうち、列に対応するラベルを持つものの数である。次に、行列演算実行部150は、インデックス(i)をi=3に初期化する。続いて、行列演算実行部150は、v(i)が、C1〜CNのいずれかに一致するか否かを判定する。v(i)は、ノードIDがiであるノードのラベルである。v(i)が、C1〜CNのいずれかに一致する場合には、行列演算実行部150は、1次元配列score[i]の値を、ノードIDがiであるノードの子ノードの1次元配列score[HI(i)]と、v(i)=Cjとなるjに対応するパラメータqjの和に更新する。HI(i)は、ノードIDがiであるノードのHIリンク先となるノードのノードIDである。なお、ノード表については、HI(i)<iが成り立っているので、score[i]の値の計算は更新されたscore[HI(i)]の値を利用して行うことができる。
Specifically, the matrix
一方、v(i)が、C1〜CNのいずれにも一致しない場合には、行列演算実行部150は、pkにscore[HI(i)]の値を代入する。なお、kは、v(i)=Rkとなるときの行番号のことである。つまり、v(i)が、C1〜CNのいずれにも一致しない場合、v(i)は、R1〜RMのいずれかに一致するためである。
On the other hand, v (i) is, when does not match any of the C. 1 to C N is a matrix
続いて、行列演算実行部150は、ZDDの全てのノードについて1次元配列scoreの計算を完了したか(i≦Wであるか)否かを判定する。全てのノードについて1次元配列scoreの計算を完了していない場合には、行列演算実行部150は、インデックス(i)を1インクリメントして、上述したのと同様の手順で1次元配列scoreの計算を行う。一方、全てのノードについて1次元配列scoreの計算を完了している場合には、行列演算実行部150は、行列演算の結果pを後述する計算結果出力部160に送出して処理を終了する。
Subsequently, the matrix
上述してきたように、行列演算実行部150による行列演算は、以下に示す式(3)のように計算できることを利用し、各ノードに計算途中の値を記憶することによって、最終的な計算結果pを得るものである。
As described above, the matrix calculation performed by the matrix
以下、図7および図8を用いて、行列演算実行部150による行列演算について補足説明する。図7は、図2に示す行列の1行目のデータについて構築したZDDを示す図である。図8は、図7に対応するノード表を示す図である。行列演算実行部150は、図7に示すZDD「I3」を構成するノードのうち、ノードIDが3であるノードについて、score[3]=q3とする。続いて、行列演算実行部150は、図7に示すZDD「I3」を構成するノードのうち、ノードIDが4であるノードについて、score[4]=q1+q3とし、最終的に、p1=q1+q3を計算する。
Hereinafter, the matrix calculation performed by the matrix
上述してきたように、行列演算実行部150は、ZDDと実数ベクトルとの積の演算を、ZDDのノード数(W)に比例する時間で演算の処理を終了することができる。すなわち、行列演算実行部150は、演算量「O(W)」に応じた計算時間および記憶容量で処理を行うことができ、演算量「O(MN)」や演算量「O(K)」よりも、必要となる計算時間や記憶容量を削減できる。上述してきた方法により、ZDDと実数ベクトルとの積の演算量を、「O(W)」に減らすことができる理由は次のとおりである。再帰的計算において各中間ノードに対応して計算されるscoreの値は、行ベクトルと実数ベクトルqとの乗算の途中までの演算結果を保持している。このとき、ある行ベクトルに対する乗算と、別の行ベクトルに対する乗算において、途中までの計算が同一である場合、その結果が同一のノードに保持されることになるので、計算回数を削減することができる。その結果、ZDDと実数ベクトルとの積の演算量を「O(W)」に減らすことができる。
As described above, the matrix
計算結果出力部160は、行列演算実行部150による演算の結果を外部へ出力する。例えば、計算結果出力部160は、ディスプレイやモニタ、プリンタなどの周辺機器へ演算の結果を出力する。
The calculation
なお、上述してきた演算装置100の各種処理機能は、例えば、電子回路や集積回路により実装することができる。電子回路としては、例えば、CPU(Central Processing Unit)やMPU(Micro Processing Unit)がある。また、集積回路としては、例えば、ASIC(Application Specific Integrated Circuit)やFPGA(Field Programmable Gate Array)などがある。また、データ記憶部130は、例えば、RAM(Random Access Memory)やフラッシュメモリ(flash memory)などの半導体メモリ素子を用いて実装することができる。
Note that the various processing functions of the
[演算装置による処理(実施例1)]
図9〜図11を用いて、実施例1に係る演算装置による処理の流れを説明する。図9は、実施例1に係るZDD構築処理の流れを示す図である。図10は、実施例1に係る行列と実数ベクトルとの積の計算処理の流れを示す図である。図11は、行列演算処理の流れを示す図である。実施例1に係る演算装置100による処理は、図9に示すZDD構築処理と、図10および図11に示す行列と実数ベクトルとの積の計算処理とに2分される。
[Processing by Arithmetic Unit (Example 1)]
The flow of processing performed by the arithmetic device according to the first embodiment will be described with reference to FIGS. FIG. 9 is a diagram illustrating the flow of the ZDD construction process according to the first embodiment. FIG. 10 is a diagram illustrating a flow of calculation processing of the product of the matrix and the real vector according to the first embodiment. FIG. 11 is a diagram showing the flow of matrix calculation processing. The processing performed by the
(ZDD構築処理)
図9に示すように、データ入力部110は、M行N列の2値行列を入力する(S101)。続いて、ZDD構築部120は、S101で入力した行列の各行を入力として、組み合わせ集合Fを計算する(S102)。そして、ZDD構築部120は、S102で計算した組み合わせ集合Fに対応するZDDを構築する(S103)。
(ZDD construction process)
As shown in FIG. 9, the
具体的には、ZDD構築部120は、データ入力部110からM行N列の2値行列を取得し、行列の各行について、1つの要素のみからなる集合を作成する(式(1)参照)。続いて、ZDD構築部120は、行列の各行について、1つの要素のみからなる集合を作成した後、それらの和集合を作成し、組み合わせ集合Fを作成する(式(2)参照)。そして、ZDD構築部120は、組み合わせ集合F(式(2))に出現するシンボルR1,R2,…,RM,C1,C2,…,CNに対して、R1<R2<・・・<RM<C1<C2<・・・<CNという順序を与え、既存の技術を利用した演算を行うことにより、組み合わせ集合Fに対応するZDDを構築する。
Specifically, the
(行列と実数ベクトルとの積の計算処理)
図10に示すように、ベクトル入力部140は、N次元の実数ベクトルを入力する(S201)。続いて、行列演算実行部150は、ZDD構築部120により2値行列から構築されたZDDと、ベクトル入力部140により入力されたN次元の実数ベクトルとを用いて、行列演算を実行する(S202)。
(Calculation processing of product of matrix and real vector)
As shown in FIG. 10, the
(行列演算処理)
行列演算実行部150は、図11に示す処理を実行する前に、ベクトル入力部140からN次元ベクトルqを取得し、データ記憶部130からZDDを取得して、スコアを格納する要素数(W−M)の1次元配列scoreを用意し、すべての要素を0で初期化しておく。以上の準備が完了した後、行列演算実行部150は、インデックス(i)をi=3に初期化する(S301)。
(Matrix operation processing)
The matrix
続いて、行列演算実行部150は、v(i)が、C1〜CNのいずれかに一致するか否か(v(i)=Cj(1≦j≦N)?)を判定する(S302)。判定の結果、v(i)が、C1〜CNのいずれかに一致する場合には(S302、Yes)、行列演算実行部150は、score[i]の値を、score(HI(i))+qjに更新する(S303)。
Subsequently, the matrix
続いて、行列演算実行部150は、i≦Wであるか否かを判定する(S304)。判定の結果、i≦Wである場合には(S304、Yes)、行列演算実行部150は、ZDDの全てのノードについてscoreの計算を完了しているものとして、演算結果pを計算結果出力部150に送出して(S305)、行列演算処理を終了する。一方、判定の結果、i≦Wではない場合には(S304、No)、行列演算実行部150は、ZDDの全てのノードについてscoreの計算を完了していないものとして、iの値を1インクリメント(i←i+1)して(ステップS306)、上述のS302に戻る。
Subsequently, the matrix
上述したステップS302において、判定の結果、v(i)が、C1〜CNのいずれにも一致しない場合には(S302、No)、行列演算実行部150は、pk←score(HI(i))として(S307)、上述のS305に移行する。
In step S302 described above, the result of the determination, v (i) is, in a case that does not match any of the C 1~ C N (S302, No ), the matrix
[実施例1による効果]
上述してきたように、実施例1に係る演算装置100は、M行N列(M、Nは正の整数)の2値行列を、ZDDを用いたデータ構造に変換する(図5、6等)。そして、実施例1に係る演算装置は、ZDDと実数ベクトルとの積の演算を、ZDD上で再帰的なアルゴリズムとして実行する(図11等)。すなわち、実施例1に係る演算装置は、2値行列をZDDを用いたデータ構造に変換することにより2値行列のデータを圧縮して表現することができる。そして、実施例1に係る演算装置は、2値行列が有する非零の要素数「K」に応じた演算を実行するのではなく、2値行列をZDDを用いたデータ構造に変換したときのZDDのノード数「W」に応じた演算を実行できるようになる。このようなことから、実施例1に係る演算装置は、2値行列と実数ベクトルとの積の演算に必要となる計算時間を減らすことができ、行列演算を効率的に実行できる。
[Effects of Example 1]
As described above, the
また、疎な2値行列のデータを圧縮するので、演算に必要となる記憶容量を削減することもできる。 In addition, since the data of a sparse binary matrix is compressed, the storage capacity required for computation can be reduced.
また、上述の実施例1では、図9に示すZDD構築処理と、図10および図11に示す行列と実数ベクトルとの積の計算処理とを2分して説明したが、図9に示すZDD構築処理と、図10および図11に示す行列と実数ベクトルとの積の計算処理とをシリアルに実行してもよい。 In the above-described first embodiment, the ZDD construction process illustrated in FIG. 9 and the calculation process of the product of the matrix and the real vector illustrated in FIGS. 10 and 11 are divided into two. However, the ZDD illustrated in FIG. The construction process and the calculation process of the product of the matrix and the real vector shown in FIGS. 10 and 11 may be executed serially.
なお、上述してきた実施例1に係る演算装置は、各種数値計算や物理的なシミュレーション、各種情報管理などに幅広く適用することができる。特に、ある特定の2値行列が繰り返し利用される状況においては、一旦ZDDによって2値行列を構築すれば、計算量削減の効果が見込まれる。 The arithmetic device according to the first embodiment described above can be widely applied to various numerical calculations, physical simulations, various information management, and the like. In particular, in a situation where a specific binary matrix is repeatedly used, once the binary matrix is constructed by ZDD, the effect of reducing the amount of calculation is expected.
以下、本発明にかかる演算装置、演算方法および演算プログラムの他の実施形態として実施例2を説明する。 Hereinafter, Example 2 will be described as another embodiment of the arithmetic device, the arithmetic method, and the arithmetic program according to the present invention.
(1)装置構成等
図1に示した演算装置100の各構成要素は機能概念的なものであり、必ずしも物理的に図示の如く構成されていることを要しない。すなわち、演算装置100の分散または統合の具体的形態は図1に示すものに限られず、演算装置100のZDD構築部120、データ記憶部130および行列演算実行部150を機能的に統合されていてもよい。このように、演算装置100の各構成要素の全部または一部を、各種の負荷や使用状況などに応じて、任意の単位で機能的または物理的に分散・統合して構成することができる。
(1) Device Configuration, etc. Each component of the
(2)演算プログラム
また、実施例1で説明した演算装置100の各種の処理(例えば、図9〜11等参照)は、あらかじめ用意されたプログラムをパーソナルコンピュータやワークステーションなどの電子機器で実行することによって実現することができる。そこで、以下では、図12を用いて、実施例1で説明した演算装置100と同様の機能を有する演算プログラムを実行する電子機器の一例を説明する。図12は、演算プログラムを実行する電子機器の一例を示す図である。
(2) Arithmetic Program The various types of processing of the
図12に示すように、演算装置100が有する機能と同様の機能を有する電子機器200は、CPU(Central Processing Unit)210、入力部220、出力部230、メモリ240およびハードディスク装置250を有する。そして、CPU210、入力部220、出力部230、メモリ240およびハードディスク装置250は、バス260を介して接続される。
As shown in FIG. 12, the
CPU210は、各種演算処理を実行する。なお、電子機器200は、CPU210の代わりに、例えば、MPU(Micro Processing Unit)などの電子回路、ASIC(Application Specific Integrated Circuit)やFPGA(Field Programmable Gate Array)などの集積回路を用いることもできる。
The
入力部220は2値行列などの各種情報を入力する。また、出力部230は行列演算の結果などを出力する。また、メモリ240は、2値行列を変換したZDDなどの各種情報を一時的に記憶する。なお、メモリ240は、例えば、RAM(Random Access Memory)やフラッシュメモリ(flash memory)などの半導体メモリ素子を用いて実装できる。また、ハードディスク装置250は、CPU210による各種処理の実行に必要な情報を記憶する。
The
ハードディスク装置250には、演算装置100が有する機能と同様の機能を発揮する演算プログラム251および演算用データ252が記憶されている。なお、この演算プログラム251を適宜分散させて、ネットワークを介して通信可能に接続された他のコンピュータの記憶部に記憶させておくこともできる。
The
そして、CPU210が、演算プログラム251をハードディスク装置250から読み出してメモリ240に展開することにより、図12に示すように、演算プログラム251は演算プロセス241として機能する。演算プロセス241は、ハードディスク装置250から読み出した演算用データ252等の各種データを適宜メモリ240上の自身に割当てられた領域に展開し、この展開した各種データに基づいて各種処理を実行する。
Then, the
なお、演算プロセス241は、例えば、上述した演算装置100のZDD構築部120や行列演算実行部150などにより実行される処理、例えば、上述の図9〜11などを用いて説明した処理を含む。
Note that the
なお、上述した演算プログラム251については、必ずしも最初からハードディスク装置250に記憶させておく必要はない。例えば、電子機器200が、フレキシブルディスク、CD−ROM、DVD、光磁気ディスク、ICカードなどの「可搬用の物理媒体」に予め記憶された演算プログラム251を読み出して実行するようにしてもよい。
Note that the above-described
さらには、電子機器200が、公衆回線、インターネット、LAN、WANなどを介して接続可能な「他のコンピュータ(またはサーバ)」などに格納された演算プログラム251を読み出して実行するようにしてもよい。
Furthermore, the
(3)演算方法
実施例1で説明した演算装置100により、以下のような演算方法が実現される。
(3) Calculation Method The following calculation method is realized by the
すなわち、2値行列とN次元の実数ベクトルとの行列演算を演算装置100としてのコンピュータが実行する演算方法であって、コンピュータは、M行N列(M、Nは整数)の2値行列のデータを入力するデータ入力工程と(図9、S101)、N次元(Nは整数)の実数ベクトルを入力するベクトル入力工程と(図10、S201)、データ入力工程により入力された2値行列のデータを、二分決定グラフのデータ構造に変換した変換データを構築する構築工程と(図9、S103)、構築工程により構築された変換データと、ベクトル入力部により入力された実数ベクトルとの行列演算を実行する演算工程と(図10、S202、図11)、演算工程による演算結果を出力する出力工程とを実行することを特徴とする演算方法が実現される。
That is, an arithmetic method in which a computer as the
100 演算装置
110 データ入力部
120 ZDD構築部
130 データ記憶部
140 ベクトル入力部
150 行列演算実行部
160 計算結果出力部
200 電子機器
210 CPU
220 入力部
230 出力部
240 メモリ
250 ハードディスク装置
260 バス
DESCRIPTION OF
220
Claims (3)
M行N列(M、Nは整数)の前記2値行列のデータを入力するデータ入力部と、
N次元の前記実数ベクトルを入力するベクトル入力部と、
前記データ入力部により入力された前記2値行列のデータを、二分決定グラフのデータ構造に変換した変換データを構築する構築部と、
前記構築部により構築された前記変換データと、前記ベクトル入力部により入力された前記実数ベクトルとの行列演算を実行する演算部と、
前記演算部による演算結果を出力する出力部と
を有することを特徴とする演算装置。 An arithmetic device that performs a matrix operation between a binary matrix and an N-dimensional real vector,
A data input unit for inputting data of the binary matrix of M rows and N columns (M and N are integers);
A vector input unit for inputting the N-dimensional real vector;
A construction part for constructing conversion data obtained by converting the data of the binary matrix input by the data input part into a data structure of a binary decision graph;
An arithmetic unit that performs a matrix operation on the conversion data constructed by the construction unit and the real vector input by the vector input unit;
And an output unit that outputs a calculation result of the calculation unit.
データ入力部が、M行N列(M、Nは整数)の前記2値行列のデータを入力するデータ入力工程と、
ベクトル入力部が、N次元の前記実数ベクトルを入力するベクトル入力工程と、
構築部が、前記データ入力工程により入力された前記2値行列のデータを、二分決定グラフのデータ構造に変換した変換データを構築する構築工程と、
演算部が、前記構築工程により構築された前記変換データと、前記ベクトル入力工程により入力された前記実数ベクトルとの行列演算を実行する演算工程と、
出力部が、前記演算工程による演算結果を出力する出力工程と
を含むことを特徴とする演算方法。 An arithmetic method executed by a computer that performs a matrix operation between a binary matrix and an N-dimensional real vector,
Data input unit, M rows and N columns (M, N are integers) and a data input step of inputting data of said binary matrix,
A vector input unit that inputs the N-dimensional real vector; and
Construction unit, the construction process of the data of the data inputted by the input step the binary matrix, to construct a conversion data converted into the data structure of BDD,
An operation step of performing a matrix operation between the conversion data constructed in the construction step and the real vector input in the vector input step ;
An output method includes: an output step of outputting a calculation result of the calculation step.
前記コンピュータを、
M行N列(M、Nは整数)の前記2値行列のデータを入力するデータ入力手段と、
N次元の前記実数ベクトルを入力するベクトル入力手段と、
前記データ入力手段により入力された前記2値行列のデータを、二分決定グラフのデータ構造に変換した変換データを構築する構築手段と、
前記構築手段により構築された前記変換データと、前記ベクトル入力手段により入力された前記実数ベクトルとの行列演算を実行する演算手段と、
前記演算手段による演算結果を出力する出力手段と
として機能させるための演算プログラム。 An arithmetic program for causing a computer to perform a matrix operation between a binary matrix and an N-dimensional real vector,
The computer,
Data input means for inputting data of the binary matrix of M rows and N columns (M and N are integers);
Vector input means for inputting the N-dimensional real vector;
Construction means for constructing conversion data obtained by converting the data of the binary matrix input by the data input means into a data structure of a binary decision graph;
Arithmetic means for performing a matrix operation between the conversion data constructed by the construction means and the real vector input by the vector input means ;
And output means for outputting a calculation result by the calculating means
Arithmetic program to function as
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2011111812A JP5634941B2 (en) | 2011-05-18 | 2011-05-18 | Arithmetic apparatus, arithmetic method and arithmetic program |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2011111812A JP5634941B2 (en) | 2011-05-18 | 2011-05-18 | Arithmetic apparatus, arithmetic method and arithmetic program |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2012243040A JP2012243040A (en) | 2012-12-10 |
JP5634941B2 true JP5634941B2 (en) | 2014-12-03 |
Family
ID=47464698
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2011111812A Expired - Fee Related JP5634941B2 (en) | 2011-05-18 | 2011-05-18 | Arithmetic apparatus, arithmetic method and arithmetic program |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP5634941B2 (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP7109106B2 (en) | 2018-03-08 | 2022-07-29 | 有限会社神奈川技研 | Construction of signposts, signposts and post structures |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP5736336B2 (en) * | 2012-03-27 | 2015-06-17 | 日本電信電話株式会社 | Matrix vector product computing device, matrix vector product computing method, and matrix vector product computing program |
JP5860829B2 (en) * | 2013-03-19 | 2016-02-16 | 日本電信電話株式会社 | Product operation apparatus, method, and program |
JP6709740B2 (en) * | 2017-01-06 | 2020-06-17 | 日本電信電話株式会社 | Strictly spread calculation device, method, and program |
-
2011
- 2011-05-18 JP JP2011111812A patent/JP5634941B2/en not_active Expired - Fee Related
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP7109106B2 (en) | 2018-03-08 | 2022-07-29 | 有限会社神奈川技研 | Construction of signposts, signposts and post structures |
Also Published As
Publication number | Publication date |
---|---|
JP2012243040A (en) | 2012-12-10 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Tien et al. | Algorithms for Bayesian network modeling and reliability assessment of infrastructure systems | |
Mo et al. | Efficient analysis of multi-state k-out-of-n systems | |
US11182157B2 (en) | Information processing device, arithmetic device, and information processing method | |
JP5634941B2 (en) | Arithmetic apparatus, arithmetic method and arithmetic program | |
US20090235216A1 (en) | Combinational Equivalence Checking for Threshold Logic Circuits | |
JP7007520B6 (en) | Information processing device, arithmetic device, and information processing method | |
US11748645B2 (en) | Optimization apparatus and control method thereof | |
CN112114776B (en) | Quantum multiplication method, device, electronic device and storage medium | |
Xu et al. | A novel polynomial-chaos-based Kalman filter | |
Gu et al. | Model reduction via projection onto nonlinear manifolds, with applications to analog circuits and biochemical systems | |
US20190042543A1 (en) | Matrix decomposition device and matrix decomposition method | |
Drake | PyEDA: Data Structures and Algorithms for Electronic Design Automation. | |
Braccesi et al. | Fast evaluation of stress state spectral moments | |
US11656787B2 (en) | Calculation system, information processing device, and optimum solution search process method | |
WO2020196862A1 (en) | Information processing device, information processing system, information processing method, storage medium, and program | |
González-Parra et al. | Polynomial chaos for random fractional order differential equations | |
Tetteh et al. | Evolution of complex combinational logic circuits using grammatical evolution with systemverilog | |
Kumar et al. | Generalized forms of fractional Euler and Runge–Kutta methods using non-uniform grid | |
US20230289401A1 (en) | Solution accuracy guaranteeing annealing calculation device, method, and program | |
Hindman et al. | The First Nontrivial Hales-Jewett Number is Four. | |
WO2023169345A1 (en) | Method and apparatus for processing data simulation task, electronic device, and storage medium | |
JP4233513B2 (en) | Analysis device, analysis program, and computer-readable recording medium recording analysis program | |
US10333697B2 (en) | Nondecreasing sequence determining device, method and program | |
CN114528996B (en) | Method, device and medium for determining initial parameters of target system test state | |
Wang et al. | Exact eigenfunctions of N-body system with quadratic pair potential |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20130722 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20140606 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20140617 |
|
A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20140717 |
|
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: 20141014 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20141015 |
|
R150 | Certificate of patent or registration of utility model |
Ref document number: 5634941 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 |
|
LAPS | Cancellation because of no payment of annual fees |