Debian Codegraph @

external/gsl/gsl_histogram__copy.c

raw symbols SCIP
1 /* gsl_histogram_copy.c
2 * Copyright (C) 2000 Simone Piccardi
3 *
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.
8 *
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.
13 *
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.
18 */
19 /***************************************************************
20 *
21 * File gsl_histogram_copy.c:
22 * Routine to copy an histogram.
23 * Need GSL library and headers.
24 *
25 * Author: S. Piccardi
26 * Jan. 2000
27 *
28 ***************************************************************/
29 #include "gsl__config.h"cxx . . $ `<file>/external/gsl/gsl__config.h`/
30 #include <stdlib.h>
31 #include "gsl_errno.h"cxx . . $ `<file>/external/gsl/gsl_errno.h`/
32 #include "gsl_histogram.h"cxx . . $ `<file>/external/gsl/gsl_histogram.h`/
33
34 /*
35 * gsl_histogram_copy:
36 * copy the contents of an histogram into another
37 */
38
39 int
40 gsl_histogram_memcpycxx . . $ gsl_histogram_memcpy(5c42e2d87a3110f8). (gsl_histogramcxx . . $ gsl_histogram# * dest, const gsl_histogramcxx . . $ gsl_histogram# * src)
41 {
42 size_t n = src->ncxx . . $ $anonymous_type_62a17a7d119001a7_0#n.;
43 size_t i;
44
45 if (dest->ncxx . . $ $anonymous_type_62a17a7d119001a7_0#n. != src->ncxx . . $ $anonymous_type_62a17a7d119001a7_0#n.)
46 {
47 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("histograms have different sizes, cannot copy",
48 GSL_EINVAL);
49 }
50
51 for (i = 0; i <= n; i++)
52 {
53 dest->rangecxx . . $ $anonymous_type_62a17a7d119001a7_0#range.[i] = src->rangecxx . . $ $anonymous_type_62a17a7d119001a7_0#range.[i];
54 }
55
56 for (i = 0; i < n; i++)
57 {
58 dest->bincxx . . $ $anonymous_type_62a17a7d119001a7_0#bin.[i] = src->bincxx . . $ $anonymous_type_62a17a7d119001a7_0#bin.[i];
59 }
60
61 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
62 }
63
64 /*
65 * gsl_histogram_duplicate:
66 * duplicate an histogram creating
67 * an identical new one
68 */
69
70 gsl_histogramcxx . . $ gsl_histogram# *
71 gsl_histogram_clonecxx . . $ gsl_histogram_clone(5ff6aab8aa29acc2). (const gsl_histogramcxx . . $ gsl_histogram# * src)
72 {
73 size_t n = src->ncxx . . $ $anonymous_type_62a17a7d119001a7_0#n.;
74 size_t i;
75 gsl_histogramcxx . . $ gsl_histogram# *h;
76
77 h = gsl_histogram_calloc_rangecxx . . $ gsl_histogram_calloc_range(98e2faa2470dfbe3). (n, src->rangecxx . . $ $anonymous_type_62a17a7d119001a7_0#range.);
78
79 if (h == 0)
80 {
81 GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("failed to allocate space for histogram struct",
82 GSL_ENOMEM, 0);
83 }
84
85 for (i = 0; i < n; i++)
86 {
87 h->bincxx . . $ $anonymous_type_62a17a7d119001a7_0#bin.[i] = src->bincxx . . $ $anonymous_type_62a17a7d119001a7_0#bin.[i];
88 }
89
90 return h;
91 }