14
14
<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" version="5.0-subset Scilab" xml:id="adj2sp" xml:lang="en">
16
<refname>adj2sp</refname>
17
<refpurpose>converts adjacency form into sparse matrix.</refpurpose>
20
<title>Calling Sequence</title>
23
A=adj2sp(xadj,iadj,v,mn)
27
<title>Arguments</title>
33
a (n+1)-by-1 matrix of floating point integers.
34
For <literal>j=1:n</literal>, the floating point integer
35
<literal>xadj(j+1)-xadj(j)</literal> is the number of non zero entries in
44
a nz-by-1 matrix of floating point integers, the row indices for the
46
For <literal>j=1:n</literal>, for <literal>k = xadj(j):xadj(j+1)-1</literal>, the floating point integer
47
<literal>i = iadj(k)</literal> is the row index of the nonzero entry #k.
55
a nz-by-1 matrix of floating point integers, the non-zero entries of A.
56
For <literal>j=1:n</literal>, for <literal>k = xadj(j):xadj(j+1)-1</literal>, the floating point integer
57
<literal>Aij = v(k)</literal> is the value of the nonzero entry #k.
65
a 1-by-2 or 2-by-1 matrix of floating point integers, optional,
66
<literal>mn(1)</literal> is the number of rows in A,
67
<literal>mn(2)</literal> is the number of columns in A.
68
If <literal>mn</literal> is not provided, then <literal>mn=[m,n]</literal> is the default with
69
<literal>m=max(iadj)</literal> and <literal>n=size(xadj,"*")-1</literal>.
76
<para>m-by-n real or complex sparse matrix (with nz non-zero entries)</para>
82
<title>Description</title>
84
adj2sp converts a sparse matrix into its adjacency form format.
85
The values in the adjacency format are stored colum-by-column.
86
This is why this format is sometimes called "Compressed sparse column" or CSC.
90
<title>Examples</title>
92
In the following example, we create a sparse matrix from its adjacency format.
93
Then we check that it matches the expected sparse matrix.
95
<programlisting role="example"><![CDATA[
16
<refname>adj2sp</refname>
17
<refpurpose>converts adjacency form into sparse matrix.</refpurpose>
20
<title>Calling Sequence</title>
23
A=adj2sp(xadj,iadj,v,mn)
27
<title>Arguments</title>
33
a (n+1)-by-1 matrix of floating point integers.
34
For <literal>j=1:n</literal>, the floating point integer
35
<literal>xadj(j+1)-xadj(j)</literal> is the number of non zero entries in
44
a nz-by-1 matrix of floating point integers, the row indices for the
46
For <literal>j=1:n</literal>, for <literal>k = xadj(j):xadj(j+1)-1</literal>, the floating point integer
47
<literal>i = iadj(k)</literal> is the row index of the nonzero entry #k.
55
a nz-by-1 matrix of floating point integers, the non-zero entries of A.
56
For <literal>j=1:n</literal>, for <literal>k = xadj(j):xadj(j+1)-1</literal>, the floating point integer
57
<literal>Aij = v(k)</literal> is the value of the nonzero entry #k.
65
a 1-by-2 or 2-by-1 matrix of floating point integers, optional,
66
<literal>mn(1)</literal> is the number of rows in A,
67
<literal>mn(2)</literal> is the number of columns in A.
68
If <literal>mn</literal> is not provided, then <literal>mn=[m,n]</literal> is the default with
69
<literal>m=max(iadj)</literal> and <literal>n=size(xadj,"*")-1</literal>.
76
<para>m-by-n real or complex sparse matrix (with nz non-zero entries)</para>
82
<title>Description</title>
84
adj2sp converts a sparse matrix into its adjacency form format.
85
The values in the adjacency format are stored colum-by-column.
86
This is why this format is sometimes called "Compressed sparse column" or CSC.
90
<title>Examples</title>
92
In the following example, we create a sparse matrix from its adjacency format.
93
Then we check that it matches the expected sparse matrix.
95
<programlisting role="example"><![CDATA[
96
96
xadj = [1 3 4 7 9 11]';
97
97
iadj = [3 5 3 1 2 4 3 5 1 4]';
98
98
v = [1 2 3 4 5 6 7 8 9 10]';
130
130
]]></programlisting>
132
In the following example, we check the use of the mn parameter.
133
The consistency between the mn parameter and the actual content of
134
xadj and iadj is checked by adj2sp.
136
<programlisting role="example"><![CDATA[
132
In the following example, we check the use of the mn parameter.
133
The consistency between the mn parameter and the actual content of
134
xadj and iadj is checked by adj2sp.
136
<programlisting role="example"><![CDATA[
137
137
xadj = [1 2 3 4 5 5 6 6 7 8 9]';
138
138
iadj = [2 5 2 3 1 2 7 6]';
139
139
v = [3 7 5 3 6 5 2 3]';
141
141
C=adj2sp(xadj,iadj,v,mn)
142
142
]]></programlisting>
144
In the following example, create a 3-by-3 sparse matrix.
145
This example is adapted from the documentation of SciPy.
147
<programlisting role="example"><![CDATA[
144
In the following example, create a 3-by-3 sparse matrix.
145
This example is adapted from the documentation of SciPy.
147
<programlisting role="example"><![CDATA[
149
149
iadj = [1,3,3,1,2,3]
150
150
v = [1,2,3,4,5,6]
151
151
full(adj2sp(xadj,iadj,v))
152
152
]]></programlisting>
154
The previous script produces the following output.
156
<programlisting role="no-scilab-exec"><![CDATA[
154
The previous script produces the following output.
156
<programlisting role="no-scilab-exec"><![CDATA[
157
157
-->full(adj2sp(xadj,iadj,v))
162
162
]]></programlisting>
164
In the following example, we check that the sp2adj and adj2sp functions
167
<programlisting role="example"><![CDATA[
164
In the following example, we check that the sp2adj and adj2sp functions
167
<programlisting role="example"><![CDATA[
168
168
A = sprand(100,50,.05);
169
169
[xadj,adjncy,anz]= sp2adj(A);
171
171
p = adj2sp(xadj,adjncy,anz,[n,m]);
173
173
]]></programlisting>
175
<refsection role="see also">
176
<title>See Also</title>
177
<simplelist type="inline">
179
<link linkend="sp2adj">sp2adj</link>
182
<link linkend="spcompack">spcompack</link>
187
<title>References</title>
189
"Implementation of Lipsol in Scilab", Hector E. Rubio Scola, INRIA, Decembre 1997, Rapport Technique No 0215
192
"Solving Large Linear Optimization Problems with Scilab : Application to Multicommodity Problems", Hector E. Rubio Scola, Janvier 1999, Rapport Technique No 0227
195
"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
198
"Computer Solution of Large Sparse Positive Definite Systems", A. George, Prentice-Hall, Inc. Englewood Cliffs, New Jersey, 1981.
175
<refsection role="see also">
176
<title>See Also</title>
177
<simplelist type="inline">
179
<link linkend="sp2adj">sp2adj</link>
182
<link linkend="spcompack">spcompack</link>
187
<title>References</title>
189
"Implementation of Lipsol in Scilab", Hector E. Rubio Scola, INRIA, Decembre 1997, Rapport Technique No 0215
192
"Solving Large Linear Optimization Problems with Scilab : Application to Multicommodity Problems", Hector E. Rubio Scola, Janvier 1999, Rapport Technique No 0227
195
"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
198
"Computer Solution of Large Sparse Positive Definite Systems", A. George, Prentice-Hall, Inc. Englewood Cliffs, New Jersey, 1981.