3
<title>Creating row and column views - GNU Scientific Library -- Reference Manual</title>
4
<meta http-equiv="Content-Type" content="text/html">
5
<meta name="description" content="GNU Scientific Library -- Reference Manual">
6
<meta name="generator" content="makeinfo 4.8">
7
<link title="Top" rel="start" href="index.html#Top">
8
<link rel="up" href="Matrices.html#Matrices" title="Matrices">
9
<link rel="prev" href="Matrix-views.html#Matrix-views" title="Matrix views">
10
<link rel="next" href="Copying-matrices.html#Copying-matrices" title="Copying matrices">
11
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
13
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 The GSL Team.
15
Permission is granted to copy, distribute and/or modify this document
16
under the terms of the GNU Free Documentation License, Version 1.2 or
17
any later version published by the Free Software Foundation; with the
18
Invariant Sections being ``GNU General Public License'' and ``Free Software
19
Needs Free Documentation'', the Front-Cover text being ``A GNU Manual'',
20
and with the Back-Cover Text being (a) (see below). A copy of the
21
license is included in the section entitled ``GNU Free Documentation
24
(a) The Back-Cover Text is: ``You have freedom to copy and modify this
25
GNU Manual, like GNU software.''-->
26
<meta http-equiv="Content-Style-Type" content="text/css">
27
<style type="text/css"><!--
28
pre.display { font-family:inherit }
29
pre.format { font-family:inherit }
30
pre.smalldisplay { font-family:inherit; font-size:smaller }
31
pre.smallformat { font-family:inherit; font-size:smaller }
32
pre.smallexample { font-size:smaller }
33
pre.smalllisp { font-size:smaller }
34
span.sc { font-variant:small-caps }
35
span.roman { font-family:serif; font-weight:normal; }
36
span.sansserif { font-family:sans-serif; font-weight:normal; }
42
<a name="Creating-row-and-column-views"></a>
43
Next: <a rel="next" accesskey="n" href="Copying-matrices.html#Copying-matrices">Copying matrices</a>,
44
Previous: <a rel="previous" accesskey="p" href="Matrix-views.html#Matrix-views">Matrix views</a>,
45
Up: <a rel="up" accesskey="u" href="Matrices.html#Matrices">Matrices</a>
49
<h4 class="subsection">8.4.6 Creating row and column views</h4>
51
<p>In general there are two ways to access an object, by reference or by
52
copying. The functions described in this section create vector views
53
which allow access to a row or column of a matrix by reference.
54
Modifying elements of the view is equivalent to modifying the matrix,
55
since both the vector view and the matrix point to the same memory
59
— Function: gsl_vector_view <b>gsl_matrix_row</b> (<var>gsl_matrix * m, size_t i</var>)<var><a name="index-gsl_005fmatrix_005frow-913"></a></var><br>
60
— Function: gsl_vector_const_view <b>gsl_matrix_const_row</b> (<var>const gsl_matrix * m, size_t i</var>)<var><a name="index-gsl_005fmatrix_005fconst_005frow-914"></a></var><br>
61
<blockquote><p>These functions return a vector view of the <var>i</var>-th row of the matrix
62
<var>m</var>. The <code>data</code> pointer of the new vector is set to null if
63
<var>i</var> is out of range.
65
<p>The function <code>gsl_vector_const_row</code> is equivalent to
66
<code>gsl_matrix_row</code> but can be used for matrices which are declared
68
</p></blockquote></div>
71
— Function: gsl_vector_view <b>gsl_matrix_column</b> (<var>gsl_matrix * m, size_t j</var>)<var><a name="index-gsl_005fmatrix_005fcolumn-915"></a></var><br>
72
— Function: gsl_vector_const_view <b>gsl_matrix_const_column</b> (<var>const gsl_matrix * m, size_t j</var>)<var><a name="index-gsl_005fmatrix_005fconst_005fcolumn-916"></a></var><br>
73
<blockquote><p>These functions return a vector view of the <var>j</var>-th column of the
74
matrix <var>m</var>. The <code>data</code> pointer of the new vector is set to
75
null if <var>j</var> is out of range.
77
<p>The function <code>gsl_vector_const_column</code> is equivalent to
78
<code>gsl_matrix_column</code> but can be used for matrices which are declared
80
</p></blockquote></div>
82
<p><a name="index-matrix-diagonal-917"></a><a name="index-diagonal_002c-of-a-matrix-918"></a>
85
— Function: gsl_vector_view <b>gsl_matrix_diagonal</b> (<var>gsl_matrix * m</var>)<var><a name="index-gsl_005fmatrix_005fdiagonal-919"></a></var><br>
86
— Function: gsl_vector_const_view <b>gsl_matrix_const_diagonal</b> (<var>const gsl_matrix * m</var>)<var><a name="index-gsl_005fmatrix_005fconst_005fdiagonal-920"></a></var><br>
87
<blockquote><p>These functions returns a vector view of the diagonal of the matrix
88
<var>m</var>. The matrix <var>m</var> is not required to be square. For a
89
rectangular matrix the length of the diagonal is the same as the smaller
90
dimension of the matrix.
92
<p>The function <code>gsl_matrix_const_diagonal</code> is equivalent to
93
<code>gsl_matrix_diagonal</code> but can be used for matrices which are
94
declared <code>const</code>.
95
</p></blockquote></div>
97
<p><a name="index-matrix-subdiagonal-921"></a><a name="index-subdiagonal_002c-of-a-matrix-922"></a>
100
— Function: gsl_vector_view <b>gsl_matrix_subdiagonal</b> (<var>gsl_matrix * m, size_t k</var>)<var><a name="index-gsl_005fmatrix_005fsubdiagonal-923"></a></var><br>
101
— Function: gsl_vector_const_view <b>gsl_matrix_const_subdiagonal</b> (<var>const gsl_matrix * m, size_t k</var>)<var><a name="index-gsl_005fmatrix_005fconst_005fsubdiagonal-924"></a></var><br>
102
<blockquote><p>These functions return a vector view of the <var>k</var>-th subdiagonal of
103
the matrix <var>m</var>. The matrix <var>m</var> is not required to be square.
104
The diagonal of the matrix corresponds to k = 0.
106
<p>The function <code>gsl_matrix_const_subdiagonal</code> is equivalent to
107
<code>gsl_matrix_subdiagonal</code> but can be used for matrices which are
108
declared <code>const</code>.
109
</p></blockquote></div>
111
<p><a name="index-matrix-superdiagonal-925"></a><a name="index-superdiagonal_002c-matrix-926"></a>
114
— Function: gsl_vector_view <b>gsl_matrix_superdiagonal</b> (<var>gsl_matrix * m, size_t k</var>)<var><a name="index-gsl_005fmatrix_005fsuperdiagonal-927"></a></var><br>
115
— Function: gsl_vector_const_view <b>gsl_matrix_const_superdiagonal</b> (<var>const gsl_matrix * m, size_t k</var>)<var><a name="index-gsl_005fmatrix_005fconst_005fsuperdiagonal-928"></a></var><br>
116
<blockquote><p>These functions return a vector view of the <var>k</var>-th superdiagonal of
117
the matrix <var>m</var>. The matrix <var>m</var> is not required to be square. The
118
diagonal of the matrix corresponds to k = 0.
120
<p>The function <code>gsl_matrix_const_superdiagonal</code> is equivalent to
121
<code>gsl_matrix_superdiagonal</code> but can be used for matrices which are
122
declared <code>const</code>.
123
</p></blockquote></div>
125
<!-- @deftypefun {gsl_vector *} gsl_vector_alloc_row_from_matrix (gsl_matrix * @var{m}, size_t @var{i}) -->
126
<!-- This function allocates a new @code{gsl_vector} struct which points to -->
127
<!-- the @var{i}-th row of the matrix @var{m}. -->
128
<!-- @end deftypefun -->
129
<!-- @deftypefun {gsl_vector *} gsl_vector_alloc_col_from_matrix (gsl_matrix * @var{m}, size_t @var{j}) -->
130
<!-- This function allocates a new @code{gsl_vector} struct which points to -->
131
<!-- the @var{j}-th column of the matrix @var{m}. -->
132
<!-- @end deftypefun -->