1 /* gsl_histogram2d_copy.c
2 * Copyright (C) 2000 Simone Piccardi
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 3 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
19 /***************************************************************
21 * File gsl_histogram2d_copy.c:
22 * Routine to copy a 2D histogram.
23 * Need GSL library and header.
28 ***************************************************************/
31 #include <gsl/gsl_errno.h>
32 #include <gsl/gsl_histogram2d.h>
35 * gsl_histogram2d_copy:
36 * copy the contents of an histogram into another
39 gsl_histogram2d_memcpy (gsl_histogram2d * dest, const gsl_histogram2d * src)
44 if (dest->nx != src->nx || dest->ny != src->ny)
46 GSL_ERROR ("histograms have different sizes, cannot copy",
50 for (i = 0; i <= nx; i++)
52 dest->xrange[i] = src->xrange[i];
55 for (i = 0; i <= ny; i++)
57 dest->yrange[i] = src->yrange[i];
60 for (i = 0; i < nx * ny; i++)
62 dest->bin[i] = src->bin[i];
69 * gsl_histogram2d_duplicate:
70 * duplicate an histogram creating
71 * an identical new one
75 gsl_histogram2d_clone (const gsl_histogram2d * src)
82 h = gsl_histogram2d_calloc_range (nx, ny, src->xrange, src->yrange);
86 GSL_ERROR_VAL ("failed to allocate space for histogram struct",
90 for (i = 0; i < nx * ny; i++)
92 h->bin[i] = src->bin[i];