Debian Codegraph @

external/gsl/gsl_matrix__copy_source.c

raw
1 /* matrix/copy_source.c
2 *
3 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20 int
21 FUNCTION (gsl_matrix, memcpy) (TYPE (gsl_matrix) * dest,
22 const TYPE (gsl_matrix) * src)
23 {
24 const size_t src_size1 = src->size1;
25 const size_t src_size2 = src->size2;
26 const size_t dest_size1 = dest->size1;
27 const size_t dest_size2 = dest->size2;
28
29 if (src_size1 != dest_size1 || src_size2 != dest_size2)
30 {
31 GSL_ERROR ("matrix sizes are different", GSL_EBADLEN);
32 }
33
34 {
35 const size_t src_tda = src->tda ;
36 const size_t dest_tda = dest->tda ;
37 size_t i, j;
38
39 for (i = 0; i < src_size1 ; i++)
40 {
41 for (j = 0; j < MULTIPLICITY * src_size2; j++)
42 {
43 dest->data[MULTIPLICITY * dest_tda * i + j]
44 = src->data[MULTIPLICITY * src_tda * i + j];
45 }
46 }
47 }
48
49 return GSL_SUCCESS;
50 }
51
52
53 int
54 FUNCTION (gsl_matrix, swap) (TYPE (gsl_matrix) * dest, TYPE (gsl_matrix) * src)
55 {
56 const size_t src_size1 = src->size1;
57 const size_t src_size2 = src->size2;
58 const size_t dest_size1 = dest->size1;
59 const size_t dest_size2 = dest->size2;
60
61 if (src_size1 != dest_size1 || src_size2 != dest_size2)
62 {
63 GSL_ERROR ("matrix sizes are different", GSL_EBADLEN);
64 }
65
66 {
67 const size_t src_tda = src->tda ;
68 const size_t dest_tda = dest->tda ;
69 size_t i, j;
70
71 for (i = 0; i < src_size1 ; i++)
72 {
73 for (j = 0; j < MULTIPLICITY * src_size2; j++)
74 {
75 ATOMIC tmp = src->data[MULTIPLICITY * src_tda * i + j];
76 src->data[MULTIPLICITY * src_tda * i + j]
77 = dest->data[MULTIPLICITY * dest_tda * i + j];
78 dest->data[MULTIPLICITY * dest_tda * i + j] = tmp ;
79 }
80 }
81 }
82
83 return GSL_SUCCESS;
84 }
85
86
87
88