1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
|
<html lang="en">
<head>
<title>Creating row and column views - GNU Scientific Library -- Reference Manual</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="GNU Scientific Library -- Reference Manual">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Matrices.html" title="Matrices">
<link rel="prev" href="Matrix-views.html" title="Matrix views">
<link rel="next" href="Copying-matrices.html" title="Copying matrices">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 The GSL Team.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being ``GNU General Public License'' and ``Free Software
Needs Free Documentation'', the Front-Cover text being ``A GNU Manual'',
and with the Back-Cover Text being (a) (see below). A copy of the
license is included in the section entitled ``GNU Free Documentation
License''.
(a) The Back-Cover Text is: ``You have the freedom to copy and modify this
GNU Manual.''-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<a name="Creating-row-and-column-views"></a>
<p>
Next: <a rel="next" accesskey="n" href="Copying-matrices.html">Copying matrices</a>,
Previous: <a rel="previous" accesskey="p" href="Matrix-views.html">Matrix views</a>,
Up: <a rel="up" accesskey="u" href="Matrices.html">Matrices</a>
<hr>
</div>
<h4 class="subsection">8.4.6 Creating row and column views</h4>
<p>In general there are two ways to access an object, by reference or by
copying. The functions described in this section create vector views
which allow access to a row or column of a matrix by reference.
Modifying elements of the view is equivalent to modifying the matrix,
since both the vector view and the matrix point to the same memory
block.
<div class="defun">
— Function: gsl_vector_view <b>gsl_matrix_row</b> (<var>gsl_matrix * m, size_t i</var>)<var><a name="index-gsl_005fmatrix_005frow-983"></a></var><br>
— 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-984"></a></var><br>
<blockquote><p>These functions return a vector view of the <var>i</var>-th row of the matrix
<var>m</var>. The <code>data</code> pointer of the new vector is set to null if
<var>i</var> is out of range.
<p>The function <code>gsl_vector_const_row</code> is equivalent to
<code>gsl_matrix_row</code> but can be used for matrices which are declared
<code>const</code>.
</p></blockquote></div>
<div class="defun">
— Function: gsl_vector_view <b>gsl_matrix_column</b> (<var>gsl_matrix * m, size_t j</var>)<var><a name="index-gsl_005fmatrix_005fcolumn-985"></a></var><br>
— 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-986"></a></var><br>
<blockquote><p>These functions return a vector view of the <var>j</var>-th column of the
matrix <var>m</var>. The <code>data</code> pointer of the new vector is set to
null if <var>j</var> is out of range.
<p>The function <code>gsl_vector_const_column</code> is equivalent to
<code>gsl_matrix_column</code> but can be used for matrices which are declared
<code>const</code>.
</p></blockquote></div>
<div class="defun">
— Function: gsl_vector_view <b>gsl_matrix_subrow</b> (<var>gsl_matrix * m, size_t i, size_t offset, size_t n</var>)<var><a name="index-gsl_005fmatrix_005fsubrow-987"></a></var><br>
— Function: gsl_vector_const_view <b>gsl_matrix_const_subrow</b> (<var>const gsl_matrix * m, size_t i, size_t offset, size_t n</var>)<var><a name="index-gsl_005fmatrix_005fconst_005fsubrow-988"></a></var><br>
<blockquote><p>These functions return a vector view of the <var>i</var>-th row of the matrix
<var>m</var> beginning at <var>offset</var> elements past the first column and
containing <var>n</var> elements. The <code>data</code> pointer of the new vector
is set to null if <var>i</var>, <var>offset</var>, or <var>n</var> are out of range.
<p>The function <code>gsl_vector_const_subrow</code> is equivalent to
<code>gsl_matrix_subrow</code> but can be used for matrices which are declared
<code>const</code>.
</p></blockquote></div>
<div class="defun">
— Function: gsl_vector_view <b>gsl_matrix_subcolumn</b> (<var>gsl_matrix * m, size_t j, size_t offset, size_t n</var>)<var><a name="index-gsl_005fmatrix_005fsubcolumn-989"></a></var><br>
— Function: gsl_vector_const_view <b>gsl_matrix_const_subcolumn</b> (<var>const gsl_matrix * m, size_t j, size_t offset, size_t n</var>)<var><a name="index-gsl_005fmatrix_005fconst_005fsubcolumn-990"></a></var><br>
<blockquote><p>These functions return a vector view of the <var>j</var>-th column of the matrix
<var>m</var> beginning at <var>offset</var> elements past the first row and
containing <var>n</var> elements. The <code>data</code> pointer of the new vector
is set to null if <var>j</var>, <var>offset</var>, or <var>n</var> are out of range.
<p>The function <code>gsl_vector_const_subcolumn</code> is equivalent to
<code>gsl_matrix_subcolumn</code> but can be used for matrices which are declared
<code>const</code>.
</p></blockquote></div>
<p><a name="index-matrix-diagonal-991"></a><a name="index-diagonal_002c-of-a-matrix-992"></a>
<div class="defun">
— Function: gsl_vector_view <b>gsl_matrix_diagonal</b> (<var>gsl_matrix * m</var>)<var><a name="index-gsl_005fmatrix_005fdiagonal-993"></a></var><br>
— 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-994"></a></var><br>
<blockquote><p>These functions return a vector view of the diagonal of the matrix
<var>m</var>. The matrix <var>m</var> is not required to be square. For a
rectangular matrix the length of the diagonal is the same as the smaller
dimension of the matrix.
<p>The function <code>gsl_matrix_const_diagonal</code> is equivalent to
<code>gsl_matrix_diagonal</code> but can be used for matrices which are
declared <code>const</code>.
</p></blockquote></div>
<p><a name="index-matrix-subdiagonal-995"></a><a name="index-subdiagonal_002c-of-a-matrix-996"></a>
<div class="defun">
— Function: gsl_vector_view <b>gsl_matrix_subdiagonal</b> (<var>gsl_matrix * m, size_t k</var>)<var><a name="index-gsl_005fmatrix_005fsubdiagonal-997"></a></var><br>
— 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-998"></a></var><br>
<blockquote><p>These functions return a vector view of the <var>k</var>-th subdiagonal of
the matrix <var>m</var>. The matrix <var>m</var> is not required to be square.
The diagonal of the matrix corresponds to k = 0.
<p>The function <code>gsl_matrix_const_subdiagonal</code> is equivalent to
<code>gsl_matrix_subdiagonal</code> but can be used for matrices which are
declared <code>const</code>.
</p></blockquote></div>
<p><a name="index-matrix-superdiagonal-999"></a><a name="index-superdiagonal_002c-matrix-1000"></a>
<div class="defun">
— Function: gsl_vector_view <b>gsl_matrix_superdiagonal</b> (<var>gsl_matrix * m, size_t k</var>)<var><a name="index-gsl_005fmatrix_005fsuperdiagonal-1001"></a></var><br>
— 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-1002"></a></var><br>
<blockquote><p>These functions return a vector view of the <var>k</var>-th superdiagonal of
the matrix <var>m</var>. The matrix <var>m</var> is not required to be square. The
diagonal of the matrix corresponds to k = 0.
<p>The function <code>gsl_matrix_const_superdiagonal</code> is equivalent to
<code>gsl_matrix_superdiagonal</code> but can be used for matrices which are
declared <code>const</code>.
</p></blockquote></div>
<!-- @deftypefun {gsl_vector *} gsl_vector_alloc_row_from_matrix (gsl_matrix * @var{m}, size_t @var{i}) -->
<!-- This function allocates a new @code{gsl_vector} struct which points to -->
<!-- the @var{i}-th row of the matrix @var{m}. -->
<!-- @end deftypefun -->
<!-- @deftypefun {gsl_vector *} gsl_vector_alloc_col_from_matrix (gsl_matrix * @var{m}, size_t @var{j}) -->
<!-- This function allocates a new @code{gsl_vector} struct which points to -->
<!-- the @var{j}-th column of the matrix @var{m}. -->
<!-- @end deftypefun -->
<hr>The GNU Scientific Library - a free numerical library licensed under the GNU GPL<br>Back to the <a href="/software/gsl/">GNU Scientific Library Homepage</a></body></html>
|