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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 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." -->
<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
<head>
<title>GNU Scientific Library – Reference Manual: Vectors</title>
<meta name="description" content="GNU Scientific Library – Reference Manual: Vectors">
<meta name="keywords" content="GNU Scientific Library – Reference Manual: Vectors">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Function-Index.html#Function-Index" rel="index" title="Function Index">
<link href="Vectors-and-Matrices.html#Vectors-and-Matrices" rel="up" title="Vectors and Matrices">
<link href="Vector-allocation.html#Vector-allocation" rel="next" title="Vector allocation">
<link href="Example-programs-for-blocks.html#Example-programs-for-blocks" rel="previous" title="Example programs for blocks">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Vectors"></a>
<div class="header">
<p>
Next: <a href="Matrices.html#Matrices" accesskey="n" rel="next">Matrices</a>, Previous: <a href="Blocks.html#Blocks" accesskey="p" rel="previous">Blocks</a>, Up: <a href="Vectors-and-Matrices.html#Vectors-and-Matrices" accesskey="u" rel="up">Vectors and Matrices</a> [<a href="Function-Index.html#Function-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Vectors-1"></a>
<h3 class="section">8.3 Vectors</h3>
<a name="index-vectors-1"></a>
<a name="index-stride_002c-of-vector-index"></a>
<p>Vectors are defined by a <code>gsl_vector</code> structure which describes a
slice of a block. Different vectors can be created which point to the
same block. A vector slice is a set of equally-spaced elements of an
area of memory.
</p>
<a name="index-gsl_005fvector"></a>
<p>The <code>gsl_vector</code> structure contains five components, the
<em>size</em>, the <em>stride</em>, a pointer to the memory where the elements
are stored, <var>data</var>, a pointer to the block owned by the vector,
<var>block</var>, if any, and an ownership flag, <var>owner</var>. The structure
is very simple and looks like this,
</p>
<div class="example">
<pre class="example">typedef struct
{
size_t size;
size_t stride;
double * data;
gsl_block * block;
int owner;
} gsl_vector;
</pre></div>
<p>The <var>size</var> is simply the number of vector elements. The range of
valid indices runs from 0 to <code>size-1</code>. The <var>stride</var> is the
step-size from one element to the next in physical memory, measured in
units of the appropriate datatype. The pointer <var>data</var> gives the
location of the first element of the vector in memory. The pointer
<var>block</var> stores the location of the memory block in which the vector
elements are located (if any). If the vector owns this block then the
<var>owner</var> field is set to one and the block will be deallocated when the
vector is freed. If the vector points to a block owned by another
object then the <var>owner</var> field is zero and any underlying block will not be
deallocated with the vector.
</p>
<p>The functions for allocating and accessing vectors are defined in
<samp>gsl_vector.h</samp>
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="Vector-allocation.html#Vector-allocation" accesskey="1">Vector allocation</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="Accessing-vector-elements.html#Accessing-vector-elements" accesskey="2">Accessing vector elements</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="Initializing-vector-elements.html#Initializing-vector-elements" accesskey="3">Initializing vector elements</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="Reading-and-writing-vectors.html#Reading-and-writing-vectors" accesskey="4">Reading and writing vectors</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="Vector-views.html#Vector-views" accesskey="5">Vector views</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="Copying-vectors.html#Copying-vectors" accesskey="6">Copying vectors</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="Exchanging-elements.html#Exchanging-elements" accesskey="7">Exchanging elements</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="Vector-operations.html#Vector-operations" accesskey="8">Vector operations</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="Finding-maximum-and-minimum-elements-of-vectors.html#Finding-maximum-and-minimum-elements-of-vectors" accesskey="9">Finding maximum and minimum elements of vectors</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="Vector-properties.html#Vector-properties">Vector properties</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="Example-programs-for-vectors.html#Example-programs-for-vectors">Example programs for vectors</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<div class="header">
<p>
Next: <a href="Matrices.html#Matrices" accesskey="n" rel="next">Matrices</a>, Previous: <a href="Blocks.html#Blocks" accesskey="p" rel="previous">Blocks</a>, Up: <a href="Vectors-and-Matrices.html#Vectors-and-Matrices" accesskey="u" rel="up">Vectors and Matrices</a> [<a href="Function-Index.html#Function-Index" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>
|