Debian Codegraph @

external/gsl/gsl_vector__swap_source.c

raw symbols SCIP
1 /* vector/swap_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 FUNCTIONcxx . . $ `./templates_on.h:233:9`! (gsl_vector, swap) (TYPEcxx . . $ `./templates_on.h:234:9`! (gsl_vector) * v, TYPEcxx . . $ `./templates_on.h:234:9`! (gsl_vector) * w)
22 {
23 ATOMICcxx . . $ `./templates_on.h:151:9`! * d1 = v->datacxx . . $ $anonymous_type_780a9cb6b33ca32e_0#data. ;
24 ATOMICcxx . . $ `./templates_on.h:151:9`! * d2 = w->datacxx . . $ $anonymous_type_780a9cb6b33ca32e_0#data. ;
25 const size_t size = v->sizecxx . . $ $anonymous_type_780a9cb6b33ca32e_0#size. ;
26 const size_t s1 = MULTIPLICITYcxx . . $ `./templates_on.h:152:9`! * v->stridecxx . . $ $anonymous_type_780a9cb6b33ca32e_0#stride. ;
27 const size_t s2 = MULTIPLICITYcxx . . $ `./templates_on.h:152:9`! * w->stridecxx . . $ $anonymous_type_780a9cb6b33ca32e_0#stride. ;
28 size_t i, k ;
29
30 if (v->sizecxx . . $ $anonymous_type_780a9cb6b33ca32e_0#size. != w->sizecxx . . $ $anonymous_type_780a9cb6b33ca32e_0#size.)
31 {
32 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`!("vector lengths must be equal", GSL_EINVAL);
33 }
34
35 for (i = 0; i < size; i++)
36 {
37 for (k = 0; k < MULTIPLICITYcxx . . $ `./templates_on.h:152:9`!; k++)
38 {
39 ATOMICcxx . . $ `./templates_on.h:151:9`! tmp = d1[i*s1 + k];
40 d1[i*s1+k] = d2[i*s2 + k];
41 d2[i*s2+k] = tmp;
42 }
43 }
44
45 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
46 }
47
48 int
49 FUNCTIONcxx . . $ `./templates_on.h:233:9`! (gsl_vector, swap_elements) (TYPEcxx . . $ `./templates_on.h:234:9`! (gsl_vector) * v, const size_t i, const size_t j)
50 {
51 ATOMICcxx . . $ `./templates_on.h:151:9`! * data = v->datacxx . . $ $anonymous_type_780a9cb6b33ca32e_0#data. ;
52 const size_t size = v->sizecxx . . $ $anonymous_type_780a9cb6b33ca32e_0#size. ;
53 const size_t stride = v->stridecxx . . $ $anonymous_type_780a9cb6b33ca32e_0#stride. ;
54
55 if (i >= size)
56 {
57 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`!("first index is out of range", GSL_EINVAL);
58 }
59
60 if (j >= size)
61 {
62 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`!("second index is out of range", GSL_EINVAL);
63 }
64
65 if (i != j)
66 {
67 const size_t s = MULTIPLICITYcxx . . $ `./templates_on.h:152:9`! * stride ;
68 size_t k ;
69
70 for (k = 0; k < MULTIPLICITYcxx . . $ `./templates_on.h:152:9`!; k++)
71 {
72 ATOMICcxx . . $ `./templates_on.h:151:9`! tmp = data[j*s + k];
73 data[j*s+k] = data[i*s + k];
74 data[i*s+k] = tmp;
75 }
76 }
77
78 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
79 }
80
81 int
82 FUNCTIONcxx . . $ `./templates_on.h:233:9`! (gsl_vector, reverse) (TYPEcxx . . $ `./templates_on.h:234:9`! (gsl_vector) * v)
83 {
84 ATOMICcxx . . $ `./templates_on.h:151:9`! * data = v->datacxx . . $ $anonymous_type_780a9cb6b33ca32e_0#data. ;
85 const size_t size = v->sizecxx . . $ $anonymous_type_780a9cb6b33ca32e_0#size. ;
86 const size_t stride = v->stridecxx . . $ $anonymous_type_780a9cb6b33ca32e_0#stride. ;
87
88 const size_t s = MULTIPLICITYcxx . . $ `./templates_on.h:152:9`! * stride ;
89
90 size_t i ;
91
92 for (i = 0 ; i < (size / 2) ; i++)
93 {
94 size_t j = size - i - 1 ;
95 size_t k;
96
97 for (k = 0; k < MULTIPLICITYcxx . . $ `./templates_on.h:152:9`!; k++)
98 {
99 ATOMICcxx . . $ `./templates_on.h:151:9`! tmp = data[j*s + k];
100 data[j*s+k] = data[i*s + k];
101 data[i*s+k] = tmp;
102 }
103 }
104
105 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
106 }
107