~ubuntu-branches/ubuntu/raring/scilab/raring-proposed

« back to all changes in this revision

Viewing changes to modules/sparse/help/en_US/sparseconvert/adj2sp.xml

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2012-08-30 14:42:38 UTC
  • mfrom: (1.4.7)
  • Revision ID: package-import@ubuntu.com-20120830144238-c1y2og7dbm7m9nig
Tags: 5.4.0-beta-3-1~exp1
* New upstream release
* Update the scirenderer dep
* Get ride of libjhdf5-java dependency

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
 *
13
13
 -->
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">
15
 
  <refnamediv>
16
 
    <refname>adj2sp</refname>
17
 
    <refpurpose>converts adjacency form into sparse matrix.</refpurpose>
18
 
  </refnamediv>
19
 
  <refsynopsisdiv>
20
 
    <title>Calling Sequence</title>
21
 
    <synopsis>
22
 
      A=adj2sp(xadj,iadj,v)
23
 
      A=adj2sp(xadj,iadj,v,mn)
24
 
    </synopsis>
25
 
  </refsynopsisdiv>
26
 
  <refsection>
27
 
    <title>Arguments</title>
28
 
    <variablelist>
29
 
      <varlistentry>
30
 
        <term>xadj</term>
31
 
        <listitem>
32
 
          <para>
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
36
 
            column j. 
37
 
          </para>
38
 
        </listitem>
39
 
      </varlistentry>
40
 
      <varlistentry>
41
 
        <term>iadj</term>
42
 
        <listitem>
43
 
          <para>
44
 
            a nz-by-1 matrix of floating point integers, the row indices for the
45
 
            nonzeros. 
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.
48
 
          </para>
49
 
        </listitem>
50
 
      </varlistentry>
51
 
      <varlistentry>
52
 
        <term>v</term>
53
 
        <listitem>
54
 
          <para>
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.
58
 
          </para>
59
 
        </listitem>
60
 
      </varlistentry>
61
 
      <varlistentry>
62
 
        <term>mn</term>
63
 
        <listitem>
64
 
          <para>
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>.
70
 
          </para>
71
 
        </listitem>
72
 
      </varlistentry>
73
 
      <varlistentry>
74
 
        <term>A</term>
75
 
        <listitem>
76
 
          <para>m-by-n real or complex sparse matrix (with nz non-zero entries)</para>
77
 
        </listitem>
78
 
      </varlistentry>
79
 
    </variablelist>
80
 
  </refsection>
81
 
  <refsection>
82
 
    <title>Description</title>
83
 
    <para>
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. 
87
 
    </para>
88
 
  </refsection>
89
 
  <refsection>
90
 
    <title>Examples</title>
91
 
    <para>
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.
94
 
    </para>
95
 
    <programlisting role="example"><![CDATA[ 
 
15
    <refnamediv>
 
16
        <refname>adj2sp</refname>
 
17
        <refpurpose>converts adjacency form into sparse matrix.</refpurpose>
 
18
    </refnamediv>
 
19
    <refsynopsisdiv>
 
20
        <title>Calling Sequence</title>
 
21
        <synopsis>
 
22
            A=adj2sp(xadj,iadj,v)
 
23
            A=adj2sp(xadj,iadj,v,mn)
 
24
        </synopsis>
 
25
    </refsynopsisdiv>
 
26
    <refsection>
 
27
        <title>Arguments</title>
 
28
        <variablelist>
 
29
            <varlistentry>
 
30
                <term>xadj</term>
 
31
                <listitem>
 
32
                    <para>
 
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
 
36
                        column j. 
 
37
                    </para>
 
38
                </listitem>
 
39
            </varlistentry>
 
40
            <varlistentry>
 
41
                <term>iadj</term>
 
42
                <listitem>
 
43
                    <para>
 
44
                        a nz-by-1 matrix of floating point integers, the row indices for the
 
45
                        nonzeros. 
 
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.
 
48
                    </para>
 
49
                </listitem>
 
50
            </varlistentry>
 
51
            <varlistentry>
 
52
                <term>v</term>
 
53
                <listitem>
 
54
                    <para>
 
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.
 
58
                    </para>
 
59
                </listitem>
 
60
            </varlistentry>
 
61
            <varlistentry>
 
62
                <term>mn</term>
 
63
                <listitem>
 
64
                    <para>
 
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>.
 
70
                    </para>
 
71
                </listitem>
 
72
            </varlistentry>
 
73
            <varlistentry>
 
74
                <term>A</term>
 
75
                <listitem>
 
76
                    <para>m-by-n real or complex sparse matrix (with nz non-zero entries)</para>
 
77
                </listitem>
 
78
            </varlistentry>
 
79
        </variablelist>
 
80
    </refsection>
 
81
    <refsection>
 
82
        <title>Description</title>
 
83
        <para>
 
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. 
 
87
        </para>
 
88
    </refsection>
 
89
    <refsection>
 
90
        <title>Examples</title>
 
91
        <para>
 
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.
 
94
        </para>
 
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]';
107
107
C=sparse(A)
108
108
and(B==C)
109
109
 ]]></programlisting>
110
 
    <para>
111
 
      In the following example, we create a sparse matrix from its adjacency format. 
112
 
      Then we check that it matches the expected sparse matrix.
113
 
    </para>
114
 
    <programlisting role="example"><![CDATA[ 
 
110
        <para>
 
111
            In the following example, we create a sparse matrix from its adjacency format. 
 
112
            Then we check that it matches the expected sparse matrix.
 
113
        </para>
 
114
        <programlisting role="example"><![CDATA[ 
115
115
xadj = [1 2 3 4 5 5 6 6 7 8 9]';
116
116
iadj = [2 5 2 3 1 2 7 6]';
117
117
v = [3 7 5 3 6 5 2 3]';
128
128
B=sparse(A)
129
129
and(B==C)
130
130
 ]]></programlisting>
131
 
    <para>
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.
135
 
    </para>
136
 
    <programlisting role="example"><![CDATA[ 
 
131
        <para>
 
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.
 
135
        </para>
 
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]';
140
140
mn=[7 10];
141
141
C=adj2sp(xadj,iadj,v,mn)
142
142
 ]]></programlisting>
143
 
    <para>
144
 
      In the following example, create a 3-by-3 sparse matrix. 
145
 
      This example is adapted from the documentation of SciPy.
146
 
    </para>
147
 
    <programlisting role="example"><![CDATA[ 
 
143
        <para>
 
144
            In the following example, create a 3-by-3 sparse matrix. 
 
145
            This example is adapted from the documentation of SciPy.
 
146
        </para>
 
147
        <programlisting role="example"><![CDATA[ 
148
148
xadj =  [1,3,4,7]
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>
153
 
    <para>
154
 
      The previous script produces the following output.
155
 
    </para>
156
 
    <programlisting role="no-scilab-exec"><![CDATA[ 
 
153
        <para>
 
154
            The previous script produces the following output.
 
155
        </para>
 
156
        <programlisting role="no-scilab-exec"><![CDATA[ 
157
157
-->full(adj2sp(xadj,iadj,v))
158
158
 ans  =
159
159
    1.    0.    4.  
160
160
    0.    0.    5.  
161
161
    2.    3.    6.  
162
162
 ]]></programlisting>
163
 
    <para>
164
 
      In the following example, we check that the sp2adj and adj2sp functions 
165
 
      are inverse.
166
 
    </para>
167
 
    <programlisting role="example"><![CDATA[ 
 
163
        <para>
 
164
            In the following example, we check that the sp2adj and adj2sp functions 
 
165
            are inverse.
 
166
        </para>
 
167
        <programlisting role="example"><![CDATA[ 
168
168
A = sprand(100,50,.05);
169
169
[xadj,adjncy,anz]= sp2adj(A);
170
170
[n,m] = size(A);
171
171
p = adj2sp(xadj,adjncy,anz,[n,m]);
172
172
A-p
173
173
 ]]></programlisting>
174
 
  </refsection>
175
 
  <refsection role="see also">
176
 
    <title>See Also</title>
177
 
    <simplelist type="inline">
178
 
      <member>
179
 
        <link linkend="sp2adj">sp2adj</link>
180
 
      </member>
181
 
      <member>
182
 
        <link linkend="spcompack">spcompack</link>
183
 
      </member>
184
 
    </simplelist>
185
 
  </refsection>
186
 
  <refsection>
187
 
    <title>References</title>
188
 
    <para>
189
 
      "Implementation of Lipsol in Scilab", Hector E. Rubio Scola, INRIA, Decembre 1997, Rapport Technique No 0215
190
 
    </para>
191
 
    <para>
192
 
      "Solving Large Linear Optimization Problems with Scilab : Application to Multicommodity Problems", Hector E. Rubio Scola, Janvier 1999, Rapport Technique No 0227
193
 
    </para>
194
 
    <para>
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
196
 
    </para>
197
 
    <para>
198
 
      "Computer Solution of Large Sparse Positive Definite Systems", A. George, Prentice-Hall, Inc. Englewood Cliffs, New Jersey, 1981.
199
 
    </para>
200
 
  </refsection>
 
174
    </refsection>
 
175
    <refsection role="see also">
 
176
        <title>See Also</title>
 
177
        <simplelist type="inline">
 
178
            <member>
 
179
                <link linkend="sp2adj">sp2adj</link>
 
180
            </member>
 
181
            <member>
 
182
                <link linkend="spcompack">spcompack</link>
 
183
            </member>
 
184
        </simplelist>
 
185
    </refsection>
 
186
    <refsection>
 
187
        <title>References</title>
 
188
        <para>
 
189
            "Implementation of Lipsol in Scilab", Hector E. Rubio Scola, INRIA, Decembre 1997, Rapport Technique No 0215
 
190
        </para>
 
191
        <para>
 
192
            "Solving Large Linear Optimization Problems with Scilab : Application to Multicommodity Problems", Hector E. Rubio Scola, Janvier 1999, Rapport Technique No 0227
 
193
        </para>
 
194
        <para>
 
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
 
196
        </para>
 
197
        <para>
 
198
            "Computer Solution of Large Sparse Positive Definite Systems", A. George, Prentice-Hall, Inc. Englewood Cliffs, New Jersey, 1981.
 
199
        </para>
 
200
    </refsection>
201
201
</refentry>