1 /* gsl_histogram_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_histogram_copy.c:
22 * Routine to copy an histogram.
23 * Need GSL library and headers.
28 ***************************************************************/
31 #include <gsl/gsl_errno.h>
32 #include <gsl/gsl_histogram.h>
36 * copy the contents of an histogram into another
40 gsl_histogram_memcpy (gsl_histogram * dest, const gsl_histogram * src)
45 if (dest->n != src->n)
47 GSL_ERROR ("histograms have different sizes, cannot copy",
51 for (i = 0; i <= n; i++)
53 dest->range[i] = src->range[i];
56 for (i = 0; i < n; i++)
58 dest->bin[i] = src->bin[i];
65 * gsl_histogram_duplicate:
66 * duplicate an histogram creating
67 * an identical new one
71 gsl_histogram_clone (const gsl_histogram * src)
77 h = gsl_histogram_calloc_range (n, src->range);
81 GSL_ERROR_VAL ("failed to allocate space for histogram struct",
85 for (i = 0; i < n; i++)
87 h->bin[i] = src->bin[i];