1 <?xml version="1.0" encoding="UTF-8"?>
4 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
5 * Copyright (C) 2008 - INRIA
7 * Copyright (C) 2012 - 2016 - Scilab Enterprises
9 * This file is hereby licensed under the terms of the GNU GPL v2.0,
10 * pursuant to article 5.3.4 of the CeCILL v.2.1.
11 * This file was originally licensed under the terms of the CeCILL v2.1,
12 * and continues to be available under such terms.
13 * For more information, see the COPYING file which you should have received
14 * along with this program.
18 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="sp2adj" xml:lang="ja">
22 <refname>sp2adj</refname>
24 <refpurpose>疎行列を隣接形式に変換する</refpurpose>
34 [xadj,iadj,v]=sp2adj(A)
54 m行n列の実数または複素数の疎行列 (nz 個の非ゼロエントリ)
74 <literal>j=1:n</literal>の場合,
78 <literal>xadj(j+1)-xadj(j)</literal> は
96 nz行1列の浮動小数点整数の行列, 非ゼロエントリの行添字.
98 <literal>j=1:n</literal>および,
100 <literal>k = xadj(j):xadj(j+1)-1</literal>に関して,
102 浮動小数点整数 <literal>i = iadj(k)</literal> は
120 nz行1列の浮動小数点整数の行列, Aの非ゼロエントリ.
122 <literal>j=1:n</literal>および,
124 <literal>k = xadj(j):xadj(j+1)-1</literal>に関して,
126 浮動小数点整数<literal>Aij = v(k)</literal>は
146 sp2adjは,疎行列を隣接形式に変換します.
152 "Compressed sparse column" または CSCと呼ばれる理由です.
164 以下の例では,1から10のエントリを有する通常の行列を作成します.
166 次に,これを疎行列に変換し,ゼロを除きます.
174 <programlisting role="example"><![CDATA[
183 [xadj,iadj,v]=sp2adj(B)
184 expected_xadj = [1 3 4 7 9 11]';
185 expected_adjncy = [3 5 3 1 2 4 3 5 1 4]';
186 expected_anz = [1 2 3 4 5 6 7 8 9 10]';
187 and(expected_xadj == xadj) // Should be %t
188 and(expected_adjncy == iadj) // Should be %t
189 and(expected_anz == v) // Should be %t
190 // j is the column index
191 for j = 1 : size(xadj,"*")-1
192 irows = iadj(xadj(j):xadj(j+1)-1);
193 vcolj = v(xadj(j):xadj(j+1)-1);
194 mprintf("Column #%d:\n",j)
195 mprintf(" Rows = %s:\n",sci2exp(irows))
196 mprintf(" Values= %s:\n",sci2exp(vcolj))
206 <programlisting role="no-scilab-exec"><![CDATA[
228 等式 xadj(2)-xadj(1)=2 は列 #1に非ゼロ要素が2個あることを示します.
230 行添字は iadjに保存され, 列 #1 の非ゼロエントリは
232 行 #3 および #5であることを示します.
234 行列 v は実際のエントリが 1および2であることを示します.
240 以下の例では,疎行列の非ゼロエントリを隣接構造でループ処理を
246 <programlisting role="example"><![CDATA[
257 [xadj,iadj,v]=sp2adj(B)
258 expected_xadj = [1 2 3 4 5 5 6 6 7 8 9]';
259 expected_adjncy = [2 5 2 3 1 2 7 6]';
260 expected_anz = [3 7 5 3 6 5 2 3]';
261 and(expected_xadj == xadj) // Should be %t
262 and(expected_adjncy == iadj) // Should be %t
263 and(expected_anz == v) // Should be %t
268 以下の例では,sp2adjおよびadj2sp関数が逆関数であることを
274 <programlisting role="example"><![CDATA[
275 // Templates for the Solution of Algebraic Eigenvalue Problems: a Practical Guide
276 // Edited by Zhaojun Bai, James Demmel, Jack Dongarra, Axel Ruhe, and Henk van der Vorst
277 // "Sparse Matrix Storage Formats", J. Dongarra
278 // http://web.eecs.utk.edu/~dongarra/etemplates/book.html
290 // To get the Compressed Sparse Column (CSC) :
291 [col_ptr,row_ind,val]=sp2adj(A)
292 // To convert back to sparse:
293 AAsp=adj2sp(col_ptr,row_ind,val)
294 // Check the conversion
297 // To get the Compressed Sparse Row (CSR) :
298 [row_ptr,col_ind,val]=sp2adj(A')
299 // To convert back to sparse:
300 AAsp=adj2sp(row_ptr,col_ind,val)'
301 // Check the conversion
307 <refsection role="see also">
311 <simplelist type="inline">
315 <link linkend="adj2sp">adj2sp</link>
321 <link linkend="sparse">sparse</link>
327 <link linkend="spcompack">spcompack</link>
333 <link linkend="spget">spget</link>
347 "Implementation of Lipsol in Scilab", Hector E. Rubio Scola, INRIA, Decembre 1997, Rapport Technique No 0215
353 "Solving Large Linear Optimization Problems with Scilab : Application to Multicommodity Problems", Hector E. Rubio Scola, Janvier 1999, Rapport Technique No 0227
359 "Toolbox Scilab : Detection signal design for failure detection and isolation for linear dynamic systems User's Guide", Hector E. Rubio Scola, 2000, Rapport Technique No 0241
365 "Computer Solution of Large Sparse Positive Definite Systems", A. George, Prentice-Hall, Inc. Englewood Cliffs, New Jersey, 1981.