| 1 | /* gsl_histogram2d_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_histogram2d_copy.c: |
| 22 | * Routine to copy a 2D histogram. |
| 23 | * Need GSL library and header. |
| 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_histogram2d.h"cxx . . $ `<file>/external/gsl/gsl_histogram2d.h`/ |
| 33 | |
| 34 | /* |
| 35 | * gsl_histogram2d_copy: |
| 36 | * copy the contents of an histogram into another |
| 37 | */ |
| 38 | int |
| 39 | gsl_histogram2d_memcpycxx . . $ gsl_histogram2d_memcpy(3d51464134a36aa4). (gsl_histogram2dcxx . . $ gsl_histogram2d# * dest, const gsl_histogram2dcxx . . $ gsl_histogram2d# * src) |
| 40 | { |
| 41 | size_t nx = src->nxcxx . . $ $anonymous_type_2826d176da817e9d_0#nx.; |
| 42 | size_t ny = src->nycxx . . $ $anonymous_type_2826d176da817e9d_0#ny.; |
| 43 | size_t i; |
| 44 | if (dest->nxcxx . . $ $anonymous_type_2826d176da817e9d_0#nx. != src->nxcxx . . $ $anonymous_type_2826d176da817e9d_0#nx. || dest->nycxx . . $ $anonymous_type_2826d176da817e9d_0#ny. != src->nycxx . . $ $anonymous_type_2826d176da817e9d_0#ny.) |
| 45 | { |
| 46 | GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("histograms have different sizes, cannot copy", |
| 47 | GSL_EINVAL); |
| 48 | } |
| 49 | |
| 50 | for (i = 0; i <= nx; i++) |
| 51 | { |
| 52 | dest->xrangecxx . . $ $anonymous_type_2826d176da817e9d_0#xrange.[i] = src->xrangecxx . . $ $anonymous_type_2826d176da817e9d_0#xrange.[i]; |
| 53 | } |
| 54 | |
| 55 | for (i = 0; i <= ny; i++) |
| 56 | { |
| 57 | dest->yrangecxx . . $ $anonymous_type_2826d176da817e9d_0#yrange.[i] = src->yrangecxx . . $ $anonymous_type_2826d176da817e9d_0#yrange.[i]; |
| 58 | } |
| 59 | |
| 60 | for (i = 0; i < nx * ny; i++) |
| 61 | { |
| 62 | dest->bincxx . . $ $anonymous_type_2826d176da817e9d_0#bin.[i] = src->bincxx . . $ $anonymous_type_2826d176da817e9d_0#bin.[i]; |
| 63 | } |
| 64 | |
| 65 | return GSL_SUCCESScxx . . $ GSL_SUCCESS.; |
| 66 | } |
| 67 | |
| 68 | /* |
| 69 | * gsl_histogram2d_duplicate: |
| 70 | * duplicate an histogram creating |
| 71 | * an identical new one |
| 72 | */ |
| 73 | |
| 74 | gsl_histogram2dcxx . . $ gsl_histogram2d# * |
| 75 | gsl_histogram2d_clonecxx . . $ gsl_histogram2d_clone(b1a5ebd10980a7ec). (const gsl_histogram2dcxx . . $ gsl_histogram2d# * src) |
| 76 | { |
| 77 | size_t nx = src->nxcxx . . $ $anonymous_type_2826d176da817e9d_0#nx.; |
| 78 | size_t ny = src->nycxx . . $ $anonymous_type_2826d176da817e9d_0#ny.; |
| 79 | size_t i; |
| 80 | gsl_histogram2dcxx . . $ gsl_histogram2d# *h; |
| 81 | |
| 82 | h = gsl_histogram2d_calloc_rangecxx . . $ gsl_histogram2d_calloc_range(420c3dcb387665c2). (nx, ny, src->xrangecxx . . $ $anonymous_type_2826d176da817e9d_0#xrange., src->yrangecxx . . $ $anonymous_type_2826d176da817e9d_0#yrange.); |
| 83 | |
| 84 | if (h == 0) |
| 85 | { |
| 86 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("failed to allocate space for histogram struct", |
| 87 | GSL_ENOMEM, 0); |
| 88 | } |
| 89 | |
| 90 | for (i = 0; i < nx * ny; i++) |
| 91 | { |
| 92 | h->bincxx . . $ $anonymous_type_2826d176da817e9d_0#bin.[i] = src->bincxx . . $ $anonymous_type_2826d176da817e9d_0#bin.[i]; |
| 93 | } |
| 94 | |
| 95 | return h; |
| 96 | } |