3
<title>2D Histogram allocation - 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="Histograms.html#Histograms" title="Histograms">
9
<link rel="prev" href="The-2D-histogram-struct.html#The-2D-histogram-struct" title="The 2D histogram struct">
10
<link rel="next" href="Copying-2D-Histograms.html#Copying-2D-Histograms" title="Copying 2D Histograms">
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="g_t2D-Histogram-allocation"></a>
43
Next: <a rel="next" accesskey="n" href="Copying-2D-Histograms.html#Copying-2D-Histograms">Copying 2D Histograms</a>,
44
Previous: <a rel="previous" accesskey="p" href="The-2D-histogram-struct.html#The-2D-histogram-struct">The 2D histogram struct</a>,
45
Up: <a rel="up" accesskey="u" href="Histograms.html#Histograms">Histograms</a>
49
<h3 class="section">21.14 2D Histogram allocation</h3>
51
<p>The functions for allocating memory to a 2D histogram follow the style
52
of <code>malloc</code> and <code>free</code>. In addition they also perform their
53
own error checking. If there is insufficient memory available to
54
allocate a histogram then the functions call the error handler (with
55
an error number of <code>GSL_ENOMEM</code>) in addition to returning a null
56
pointer. Thus if you use the library error handler to abort your program
57
then it isn't necessary to check every 2D histogram <code>alloc</code>.
60
— Function: gsl_histogram2d * <b>gsl_histogram2d_alloc</b> (<var>size_t nx, size_t ny</var>)<var><a name="index-gsl_005fhistogram2d_005falloc-1809"></a></var><br>
61
<blockquote><p>This function allocates memory for a two-dimensional histogram with
62
<var>nx</var> bins in the x direction and <var>ny</var> bins in the y direction.
63
The function returns a pointer to a newly created <code>gsl_histogram2d</code>
64
struct. If insufficient memory is available a null pointer is returned
65
and the error handler is invoked with an error code of
66
<code>GSL_ENOMEM</code>. The bins and ranges must be initialized with one of
67
the functions below before the histogram is ready for use.
68
</p></blockquote></div>
70
<!-- @deftypefun {gsl_histogram2d *} gsl_histogram2d_calloc (size_t @var{nx}, size_t @var{ny}) -->
71
<!-- This function allocates memory for a two-dimensional histogram with -->
72
<!-- @var{nx} bins in the x direction and @var{ny} bins in the y -->
73
<!-- direction. The function returns a pointer to a newly initialized -->
74
<!-- @code{gsl_histogram2d} struct. The bins are uniformly spaced with a -->
75
<!-- total range of -->
76
<!-- @c{$0 \le x < nx$} -->
77
<!-- @math{0 <= x < nx} in the x-direction and -->
78
<!-- @c{$0 \le y < ny$} -->
79
<!-- @math{0 <= y < ny} in the y-direction, as shown in the table below. -->
80
<!-- The bins are initialized to zero so the histogram is ready for use. -->
81
<!-- If insufficient memory is available a null pointer is returned and the -->
82
<!-- error handler is invoked with an error code of @code{GSL_ENOMEM}. -->
83
<!-- @end deftypefun -->
84
<!-- @deftypefun {gsl_histogram2d *} gsl_histogram2d_calloc_uniform (size_t @var{nx}, size_t @var{ny}, double @var{xmin}, double @var{xmax}, double @var{ymin}, double @var{ymax}) -->
85
<!-- This function allocates a histogram of size @var{nx}-by-@var{ny} which -->
86
<!-- uniformly covers the ranges @var{xmin} to @var{xmax} and @var{ymin} to -->
87
<!-- @var{ymax} in the @math{x} and @math{y} directions respectively. -->
88
<!-- @end deftypefun -->
89
<!-- @deftypefun {gsl_histogram2d *} gsl_histogram2d_calloc_range (size_t @var{nx}, size_t @var{ny}, double * @var{xrange}, double * @var{yrange}) -->
90
<!-- This function allocates a histogram of size @var{nx}-by-@var{ny} using -->
91
<!-- the @math{nx+1} and @math{ny+1} bin ranges specified by the arrays -->
92
<!-- @var{xrange} and @var{xyrange}. -->
93
<!-- @end deftypefun -->
95
— Function: int <b>gsl_histogram2d_set_ranges</b> (<var>gsl_histogram2d * h, const double xrange</var>[]<var>, size_t xsize, const double yrange</var>[]<var>, size_t ysize</var>)<var><a name="index-gsl_005fhistogram2d_005fset_005franges-1810"></a></var><br>
96
<blockquote><p>This function sets the ranges of the existing histogram <var>h</var> using
97
the arrays <var>xrange</var> and <var>yrange</var> of size <var>xsize</var> and
98
<var>ysize</var> respectively. The values of the histogram bins are reset to
100
</p></blockquote></div>
103
— Function: int <b>gsl_histogram2d_set_ranges_uniform</b> (<var>gsl_histogram2d * h, double xmin, double xmax, double ymin, double ymax</var>)<var><a name="index-gsl_005fhistogram2d_005fset_005franges_005funiform-1811"></a></var><br>
104
<blockquote><p>This function sets the ranges of the existing histogram <var>h</var> to cover
105
the ranges <var>xmin</var> to <var>xmax</var> and <var>ymin</var> to <var>ymax</var>
106
uniformly. The values of the histogram bins are reset to zero.
107
</p></blockquote></div>
110
— Function: void <b>gsl_histogram2d_free</b> (<var>gsl_histogram2d * h</var>)<var><a name="index-gsl_005fhistogram2d_005ffree-1812"></a></var><br>
111
<blockquote><p>This function frees the 2D histogram <var>h</var> and all of the memory
113
</p></blockquote></div>