Debian Codegraph @

external/gsl/gsl_matrix__view_source.c

raw symbols SCIP
1 /* matrix/view_source.c
2 *
3 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 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 QUALIFIED_VIEWcxx . . $ `./templates_on.h:237:9`! (_gsl_matrix,view)
21 FUNCTIONcxx . . $ `./templates_on.h:233:9`! (gsl_matrix, view_array) (QUALIFIERcxx . . $ `./templates_on.h:197:9`! ATOMICcxx . . $ `./templates_on.h:128:9`! * array,
22 const size_t n1, const size_t n2)
23 {
24 QUALIFIED_VIEWcxx . . $ `./templates_on.h:237:9`! (_gsl_matrix,view) view = NULL_MATRIX_VIEWcxx . . $ `external/gsl/gsl_matrix__view.h:5:9`!;
25
26 if (n1 == 0)
27 {
28 GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("matrix dimension n1 must be positive integer",
29 GSL_EINVAL, view);
30 }
31 else if (n2 == 0)
32 {
33 GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("matrix dimension n2 must be positive integer",
34 GSL_EINVAL, view);
35 }
36
37 {
38 TYPEcxx . . $ `./templates_on.h:234:9`!(gsl_matrix) m = NULL_MATRIXcxx . . $ `external/gsl/gsl_matrix__view.h:4:9`!;
39
40 m.datacxx . . $ $anonymous_type_a528b1853546c6a1_0#data. = (ATOMICcxx . . $ `./templates_on.h:128:9`! *)array;
41 m.size1cxx . . $ $anonymous_type_a528b1853546c6a1_0#size1. = n1;
42 m.size2cxx . . $ $anonymous_type_a528b1853546c6a1_0#size2. = n2;
43 m.tdacxx . . $ $anonymous_type_a528b1853546c6a1_0#tda. = n2;
44 m.blockcxx . . $ $anonymous_type_a528b1853546c6a1_0#block. = 0;
45 m.ownercxx . . $ $anonymous_type_a528b1853546c6a1_0#owner. = 0;
46
47 view.matrixcxx . . $ $anonymous_type_a528b1853546c6a1_1#matrix. = m;
48 return view;
49 }
50 }
51
52 QUALIFIED_VIEWcxx . . $ `./templates_on.h:237:9`! (_gsl_matrix,view)
53 FUNCTIONcxx . . $ `./templates_on.h:233:9`!(gsl_matrix, view_array_with_tda) (QUALIFIERcxx . . $ `./templates_on.h:197:9`! ATOMICcxx . . $ `./templates_on.h:128:9`! * base,
54 const size_t n1,
55 const size_t n2,
56 const size_t tda)
57 {
58 QUALIFIED_VIEWcxx . . $ `./templates_on.h:237:9`! (_gsl_matrix,view) view = NULL_MATRIX_VIEWcxx . . $ `external/gsl/gsl_matrix__view.h:5:9`!;
59
60 if (n1 == 0)
61 {
62 GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("matrix dimension n1 must be positive integer",
63 GSL_EINVAL, view);
64 }
65 else if (n2 == 0)
66 {
67 GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("matrix dimension n2 must be positive integer",
68 GSL_EINVAL, view);
69 }
70 else if (n2 > tda)
71 {
72 GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("matrix dimension n2 must not exceed tda",
73 GSL_EINVAL, view);
74 }
75
76
77 {
78 TYPEcxx . . $ `./templates_on.h:234:9`!(gsl_matrix) m = NULL_MATRIXcxx . . $ `external/gsl/gsl_matrix__view.h:4:9`!;
79
80 m.datacxx . . $ $anonymous_type_a528b1853546c6a1_0#data. = (ATOMICcxx . . $ `./templates_on.h:128:9`! *)base;
81 m.size1cxx . . $ $anonymous_type_a528b1853546c6a1_0#size1. = n1;
82 m.size2cxx . . $ $anonymous_type_a528b1853546c6a1_0#size2. = n2;
83 m.tdacxx . . $ $anonymous_type_a528b1853546c6a1_0#tda. = tda;
84 m.blockcxx . . $ $anonymous_type_a528b1853546c6a1_0#block. = 0;
85 m.ownercxx . . $ $anonymous_type_a528b1853546c6a1_0#owner. = 0;
86
87 view.matrixcxx . . $ $anonymous_type_a528b1853546c6a1_1#matrix. = m;
88 return view;
89 }
90 }
91
92 QUALIFIED_VIEWcxx . . $ `./templates_on.h:237:9`! (_gsl_matrix,view)
93 FUNCTIONcxx . . $ `./templates_on.h:233:9`!(gsl_matrix, view_vector) (QUALIFIED_TYPEcxx . . $ `./templates_on.h:236:9`!(gsl_vector) * v,
94 const size_t n1,
95 const size_t n2)
96 {
97 QUALIFIED_VIEWcxx . . $ `./templates_on.h:237:9`! (_gsl_matrix,view) view = NULL_MATRIX_VIEWcxx . . $ `external/gsl/gsl_matrix__view.h:5:9`!;
98
99 if (n1 == 0)
100 {
101 GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("matrix dimension n1 must be positive integer",
102 GSL_EINVAL, view);
103 }
104 else if (n2 == 0)
105 {
106 GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("matrix dimension n2 must be positive integer",
107 GSL_EINVAL, view);
108 }
109 else if (v->stridecxx . . $ $anonymous_type_8a20c748c45d8e6_0#stride. != 1)
110 {
111 GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("vector must have unit stride",
112 GSL_EINVAL, view);
113 }
114 else if (n1 * n2 > v->sizecxx . . $ $anonymous_type_8a20c748c45d8e6_0#size.)
115 {
116 GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("matrix size exceeds size of original",
117 GSL_EINVAL, view);
118 }
119
120 {
121 TYPEcxx . . $ `./templates_on.h:234:9`!(gsl_matrix) m = NULL_MATRIXcxx . . $ `external/gsl/gsl_matrix__view.h:4:9`!;
122
123 m.datacxx . . $ $anonymous_type_a528b1853546c6a1_0#data. = v->datacxx . . $ $anonymous_type_8a20c748c45d8e6_0#data.;
124 m.size1cxx . . $ $anonymous_type_a528b1853546c6a1_0#size1. = n1;
125 m.size2cxx . . $ $anonymous_type_a528b1853546c6a1_0#size2. = n2;
126 m.tdacxx . . $ $anonymous_type_a528b1853546c6a1_0#tda. = n2;
127 m.blockcxx . . $ $anonymous_type_a528b1853546c6a1_0#block. = v->blockcxx . . $ $anonymous_type_8a20c748c45d8e6_0#block.;
128 m.ownercxx . . $ $anonymous_type_a528b1853546c6a1_0#owner. = 0;
129
130 view.matrixcxx . . $ $anonymous_type_a528b1853546c6a1_1#matrix. = m;
131 return view;
132 }
133 }
134
135
136 QUALIFIED_VIEWcxx . . $ `./templates_on.h:237:9`! (_gsl_matrix,view)
137 FUNCTIONcxx . . $ `./templates_on.h:233:9`!(gsl_matrix, view_vector_with_tda) (QUALIFIED_TYPEcxx . . $ `./templates_on.h:236:9`!(gsl_vector) * v,
138 const size_t n1,
139 const size_t n2,
140 const size_t tda)
141 {
142 QUALIFIED_VIEWcxx . . $ `./templates_on.h:237:9`! (_gsl_matrix,view) view = NULL_MATRIX_VIEWcxx . . $ `external/gsl/gsl_matrix__view.h:5:9`!;
143
144 if (n1 == 0)
145 {
146 GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("matrix dimension n1 must be positive integer",
147 GSL_EINVAL, view);
148 }
149 else if (n2 == 0)
150 {
151 GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("matrix dimension n2 must be positive integer",
152 GSL_EINVAL, view);
153 }
154 else if (v->stridecxx . . $ $anonymous_type_8a20c748c45d8e6_0#stride. != 1)
155 {
156 GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("vector must have unit stride",
157 GSL_EINVAL, view);
158 }
159 else if (n2 > tda)
160 {
161 GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("matrix dimension n2 must not exceed tda",
162 GSL_EINVAL, view);
163 }
164 else if (n1 * tda > v->sizecxx . . $ $anonymous_type_8a20c748c45d8e6_0#size.)
165 {
166 GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("matrix size exceeds size of original",
167 GSL_EINVAL, view);
168 }
169
170 {
171 TYPEcxx . . $ `./templates_on.h:234:9`!(gsl_matrix) m = NULL_MATRIXcxx . . $ `external/gsl/gsl_matrix__view.h:4:9`!;
172
173 m.datacxx . . $ $anonymous_type_a528b1853546c6a1_0#data. = v->datacxx . . $ $anonymous_type_8a20c748c45d8e6_0#data.;
174 m.size1cxx . . $ $anonymous_type_a528b1853546c6a1_0#size1. = n1;
175 m.size2cxx . . $ $anonymous_type_a528b1853546c6a1_0#size2. = n2;
176 m.tdacxx . . $ $anonymous_type_a528b1853546c6a1_0#tda. = tda;
177 m.blockcxx . . $ $anonymous_type_a528b1853546c6a1_0#block. = v->blockcxx . . $ $anonymous_type_8a20c748c45d8e6_0#block.;
178 m.ownercxx . . $ $anonymous_type_a528b1853546c6a1_0#owner. = 0;
179
180 view.matrixcxx . . $ $anonymous_type_a528b1853546c6a1_1#matrix. = m;
181 return view;
182 }
183 }
184
185 #ifdef JUNK
186 int
187 FUNCTION (gsl_matrix, view_from_matrix) (TYPE(gsl_matrix) * m,
188 TYPE(gsl_matrix) * mm,
189 const size_t k1,
190 const size_t k2,
191 const size_t n1,
192 const size_t n2)
193 {
194 if (n1 == 0)
195 {
196 GSL_ERROR_VAL ("matrix dimension n1 must be positive integer",
197 GSL_EINVAL, 0);
198 }
199 else if (n2 == 0)
200 {
201 GSL_ERROR_VAL ("matrix dimension n2 must be positive integer",
202 GSL_EINVAL, 0);
203 }
204 else if (k1 + n1 > mm->size1)
205 {
206 GSL_ERROR_VAL ("submatrix dimension 1 exceeds size of original",
207 GSL_EINVAL, 0);
208 }
209 else if (k2 + n2 > mm->size2)
210 {
211 GSL_ERROR_VAL ("submatrix dimension 2 exceeds size of original",
212 GSL_EINVAL, 0);
213 }
214
215 m->data = mm->data + k1 * mm->tda + k2 ;
216 m->size1 = n1;
217 m->size2 = n2;
218 m->tda = mm->tda;
219 m->block = mm->block;
220 m->owner = 0;
221
222 return GSL_SUCCESS;
223 }
224
225 int
226 FUNCTION (gsl_vector, view_row_from_matrix) (TYPE(gsl_vector) * v,
227 TYPE(gsl_matrix) * m,
228 const size_t i)
229 {
230 const size_t column_length = m->size1;
231
232 if (i >= column_length)
233 {
234 GSL_ERROR ("row index is out of range", GSL_EINVAL);
235 }
236
237 if (v->block != 0)
238 {
239 GSL_ERROR ("vector already has memory allocated to it", GSL_ENOMEM);
240 }
241
242 v->data = m->data + MULTIPLICITY * i * m->tda ;
243 v->size = m->size2;
244 v->stride = 1;
245
246 return GSL_SUCCESS;
247 }
248
249 int
250 FUNCTION (gsl_vector, view_col_from_matrix) (TYPE(gsl_vector) * v,
251 TYPE(gsl_matrix) * m,
252 const size_t j)
253 {
254 const size_t row_length = m->size2;
255
256 if (j >= row_length)
257 {
258 GSL_ERROR_VAL ("column index is out of range", GSL_EINVAL, 0);
259 }
260
261 if (v->block != 0)
262 {
263 GSL_ERROR ("vector already has memory allocated to it", GSL_ENOMEM);
264 }
265
266 v->data = m->data + MULTIPLICITY * j ;
267 v->size = m->size1;
268 v->stride = m->tda;
269
270 return GSL_SUCCESS;
271 }
272 #endif /* JUNK */
273